0001-openwrt-ath79.patch 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200
  1. diff -Nur linux-4.1.13.orig/arch/mips/ath79/clock.c linux-4.1.13/arch/mips/ath79/clock.c
  2. --- linux-4.1.13.orig/arch/mips/ath79/clock.c 2015-11-09 23:34:10.000000000 +0100
  3. +++ linux-4.1.13/arch/mips/ath79/clock.c 2015-12-04 19:57:05.422010155 +0100
  4. @@ -25,7 +25,7 @@
  5. #include "common.h"
  6. #define AR71XX_BASE_FREQ 40000000
  7. -#define AR724X_BASE_FREQ 5000000
  8. +#define AR724X_BASE_FREQ 40000000
  9. #define AR913X_BASE_FREQ 5000000
  10. struct clk {
  11. @@ -99,8 +99,8 @@
  12. div = ((pll >> AR724X_PLL_DIV_SHIFT) & AR724X_PLL_DIV_MASK);
  13. freq = div * ref_rate;
  14. - div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK);
  15. - freq *= div;
  16. + div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK) * 2;
  17. + freq /= div;
  18. cpu_rate = freq;
  19. @@ -350,6 +350,91 @@
  20. iounmap(dpll_base);
  21. }
  22. +static void __init qca953x_clocks_init(void)
  23. +{
  24. + unsigned long ref_rate;
  25. + unsigned long cpu_rate;
  26. + unsigned long ddr_rate;
  27. + unsigned long ahb_rate;
  28. + u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
  29. + u32 cpu_pll, ddr_pll;
  30. + u32 bootstrap;
  31. +
  32. + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  33. + if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
  34. + ref_rate = 40 * 1000 * 1000;
  35. + else
  36. + ref_rate = 25 * 1000 * 1000;
  37. +
  38. + pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
  39. + out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  40. + QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
  41. + ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  42. + QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
  43. + nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
  44. + QCA953X_PLL_CPU_CONFIG_NINT_MASK;
  45. + frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
  46. + QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
  47. +
  48. + cpu_pll = nint * ref_rate / ref_div;
  49. + cpu_pll += frac * (ref_rate >> 6) / ref_div;
  50. + cpu_pll /= (1 << out_div);
  51. +
  52. + pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
  53. + out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  54. + QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
  55. + ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  56. + QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
  57. + nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
  58. + QCA953X_PLL_DDR_CONFIG_NINT_MASK;
  59. + frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
  60. + QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
  61. +
  62. + ddr_pll = nint * ref_rate / ref_div;
  63. + ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
  64. + ddr_pll /= (1 << out_div);
  65. +
  66. + clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
  67. +
  68. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  69. + QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  70. +
  71. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
  72. + cpu_rate = ref_rate;
  73. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
  74. + cpu_rate = cpu_pll / (postdiv + 1);
  75. + else
  76. + cpu_rate = ddr_pll / (postdiv + 1);
  77. +
  78. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
  79. + QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
  80. +
  81. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
  82. + ddr_rate = ref_rate;
  83. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
  84. + ddr_rate = ddr_pll / (postdiv + 1);
  85. + else
  86. + ddr_rate = cpu_pll / (postdiv + 1);
  87. +
  88. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
  89. + QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
  90. +
  91. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
  92. + ahb_rate = ref_rate;
  93. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
  94. + ahb_rate = ddr_pll / (postdiv + 1);
  95. + else
  96. + ahb_rate = cpu_pll / (postdiv + 1);
  97. +
  98. + ath79_add_sys_clkdev("ref", ref_rate);
  99. + ath79_add_sys_clkdev("cpu", cpu_rate);
  100. + ath79_add_sys_clkdev("ddr", ddr_rate);
  101. + ath79_add_sys_clkdev("ahb", ahb_rate);
  102. +
  103. + clk_add_alias("wdt", NULL, "ref", NULL);
  104. + clk_add_alias("uart", NULL, "ref", NULL);
  105. +}
  106. +
  107. static void __init qca955x_clocks_init(void)
  108. {
  109. unsigned long ref_rate;
  110. @@ -435,6 +520,100 @@
  111. clk_add_alias("uart", NULL, "ref", NULL);
  112. }
  113. +static void __init qca956x_clocks_init(void)
  114. +{
  115. + unsigned long ref_rate;
  116. + unsigned long cpu_rate;
  117. + unsigned long ddr_rate;
  118. + unsigned long ahb_rate;
  119. + u32 pll, out_div, ref_div, nint, hfrac, lfrac, clk_ctrl, postdiv;
  120. + u32 cpu_pll, ddr_pll;
  121. + u32 bootstrap;
  122. +
  123. + bootstrap = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
  124. + if (bootstrap & QCA956X_BOOTSTRAP_REF_CLK_40)
  125. + ref_rate = 40 * 1000 * 1000;
  126. + else
  127. + ref_rate = 25 * 1000 * 1000;
  128. +
  129. + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG_REG);
  130. + out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  131. + QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
  132. + ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  133. + QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
  134. +
  135. + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG1_REG);
  136. + nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
  137. + QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
  138. + hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
  139. + QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK;
  140. + lfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT) &
  141. + QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK;
  142. +
  143. + cpu_pll = nint * ref_rate / ref_div;
  144. + cpu_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
  145. + cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
  146. + cpu_pll /= (1 << out_div);
  147. +
  148. + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG_REG);
  149. + out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  150. + QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
  151. + ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  152. + QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
  153. + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG1_REG);
  154. + nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
  155. + QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
  156. + hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
  157. + QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK;
  158. + lfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT) &
  159. + QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK;
  160. +
  161. + ddr_pll = nint * ref_rate / ref_div;
  162. + ddr_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
  163. + ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
  164. + ddr_pll /= (1 << out_div);
  165. +
  166. + clk_ctrl = ath79_pll_rr(QCA956X_PLL_CLK_CTRL_REG);
  167. +
  168. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  169. + QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  170. +
  171. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
  172. + cpu_rate = ref_rate;
  173. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL)
  174. + cpu_rate = ddr_pll / (postdiv + 1);
  175. + else
  176. + cpu_rate = cpu_pll / (postdiv + 1);
  177. +
  178. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
  179. + QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
  180. +
  181. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
  182. + ddr_rate = ref_rate;
  183. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL)
  184. + ddr_rate = cpu_pll / (postdiv + 1);
  185. + else
  186. + ddr_rate = ddr_pll / (postdiv + 1);
  187. +
  188. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
  189. + QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
  190. +
  191. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
  192. + ahb_rate = ref_rate;
  193. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
  194. + ahb_rate = ddr_pll / (postdiv + 1);
  195. + else
  196. + ahb_rate = cpu_pll / (postdiv + 1);
  197. +
  198. + ath79_add_sys_clkdev("ref", ref_rate);
  199. + ath79_add_sys_clkdev("cpu", cpu_rate);
  200. + ath79_add_sys_clkdev("ddr", ddr_rate);
  201. + ath79_add_sys_clkdev("ahb", ahb_rate);
  202. +
  203. + clk_add_alias("wdt", NULL, "ref", NULL);
  204. + clk_add_alias("uart", NULL, "ref", NULL);
  205. +}
  206. +
  207. void __init ath79_clocks_init(void)
  208. {
  209. if (soc_is_ar71xx())
  210. @@ -447,8 +626,12 @@
  211. ar933x_clocks_init();
  212. else if (soc_is_ar934x())
  213. ar934x_clocks_init();
  214. + else if (soc_is_qca953x())
  215. + qca953x_clocks_init();
  216. else if (soc_is_qca955x())
  217. qca955x_clocks_init();
  218. + else if (soc_is_qca956x())
  219. + qca956x_clocks_init();
  220. else
  221. BUG();
  222. }
  223. @@ -488,3 +671,15 @@
  224. return clk->rate;
  225. }
  226. EXPORT_SYMBOL(clk_get_rate);
  227. +
  228. +int clk_set_rate(struct clk *clk, unsigned long rate)
  229. +{
  230. + return 0;
  231. +}
  232. +EXPORT_SYMBOL_GPL(clk_set_rate);
  233. +
  234. +long clk_round_rate(struct clk *clk, unsigned long rate)
  235. +{
  236. + return 0;
  237. +}
  238. +EXPORT_SYMBOL_GPL(clk_round_rate);
  239. diff -Nur linux-4.1.13.orig/arch/mips/ath79/common.c linux-4.1.13/arch/mips/ath79/common.c
  240. --- linux-4.1.13.orig/arch/mips/ath79/common.c 2015-11-09 23:34:10.000000000 +0100
  241. +++ linux-4.1.13/arch/mips/ath79/common.c 2015-12-04 19:57:04.474072175 +0100
  242. @@ -22,6 +22,7 @@
  243. #include "common.h"
  244. static DEFINE_SPINLOCK(ath79_device_reset_lock);
  245. +static DEFINE_MUTEX(ath79_flash_mutex);
  246. u32 ath79_cpu_freq;
  247. EXPORT_SYMBOL_GPL(ath79_cpu_freq);
  248. @@ -72,10 +73,14 @@
  249. reg = AR933X_RESET_REG_RESET_MODULE;
  250. else if (soc_is_ar934x())
  251. reg = AR934X_RESET_REG_RESET_MODULE;
  252. + else if (soc_is_qca953x())
  253. + reg = QCA953X_RESET_REG_RESET_MODULE;
  254. else if (soc_is_qca955x())
  255. reg = QCA955X_RESET_REG_RESET_MODULE;
  256. + else if (soc_is_qca956x())
  257. + reg = QCA956X_RESET_REG_RESET_MODULE;
  258. else
  259. - BUG();
  260. + panic("Reset register not defined for this SOC");
  261. spin_lock_irqsave(&ath79_device_reset_lock, flags);
  262. t = ath79_reset_rr(reg);
  263. @@ -100,10 +105,14 @@
  264. reg = AR933X_RESET_REG_RESET_MODULE;
  265. else if (soc_is_ar934x())
  266. reg = AR934X_RESET_REG_RESET_MODULE;
  267. + else if (soc_is_qca953x())
  268. + reg = QCA953X_RESET_REG_RESET_MODULE;
  269. else if (soc_is_qca955x())
  270. reg = QCA955X_RESET_REG_RESET_MODULE;
  271. + else if (soc_is_qca956x())
  272. + reg = QCA956X_RESET_REG_RESET_MODULE;
  273. else
  274. - BUG();
  275. + panic("Reset register not defined for this SOC");
  276. spin_lock_irqsave(&ath79_device_reset_lock, flags);
  277. t = ath79_reset_rr(reg);
  278. @@ -111,3 +120,42 @@
  279. spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
  280. }
  281. EXPORT_SYMBOL_GPL(ath79_device_reset_clear);
  282. +
  283. +u32 ath79_device_reset_get(u32 mask)
  284. +{
  285. + unsigned long flags;
  286. + u32 reg;
  287. + u32 ret;
  288. +
  289. + if (soc_is_ar71xx())
  290. + reg = AR71XX_RESET_REG_RESET_MODULE;
  291. + else if (soc_is_ar724x())
  292. + reg = AR724X_RESET_REG_RESET_MODULE;
  293. + else if (soc_is_ar913x())
  294. + reg = AR913X_RESET_REG_RESET_MODULE;
  295. + else if (soc_is_ar933x())
  296. + reg = AR933X_RESET_REG_RESET_MODULE;
  297. + else if (soc_is_ar934x())
  298. + reg = AR934X_RESET_REG_RESET_MODULE;
  299. + else
  300. + BUG();
  301. +
  302. + spin_lock_irqsave(&ath79_device_reset_lock, flags);
  303. + ret = ath79_reset_rr(reg);
  304. + spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
  305. + return ret;
  306. +}
  307. +EXPORT_SYMBOL_GPL(ath79_device_reset_get);
  308. +
  309. +void ath79_flash_acquire(void)
  310. +{
  311. + mutex_lock(&ath79_flash_mutex);
  312. +}
  313. +EXPORT_SYMBOL_GPL(ath79_flash_acquire);
  314. +
  315. +void ath79_flash_release(void)
  316. +{
  317. + mutex_unlock(&ath79_flash_mutex);
  318. +}
  319. +EXPORT_SYMBOL_GPL(ath79_flash_release);
  320. +
  321. diff -Nur linux-4.1.13.orig/arch/mips/ath79/common.h linux-4.1.13/arch/mips/ath79/common.h
  322. --- linux-4.1.13.orig/arch/mips/ath79/common.h 2015-11-09 23:34:10.000000000 +0100
  323. +++ linux-4.1.13/arch/mips/ath79/common.h 2015-12-04 19:57:05.893979276 +0100
  324. @@ -27,6 +27,9 @@
  325. void ath79_gpio_function_enable(u32 mask);
  326. void ath79_gpio_function_disable(u32 mask);
  327. void ath79_gpio_function_setup(u32 set, u32 clear);
  328. +void ath79_gpio_function2_setup(u32 set, u32 clear);
  329. +void ath79_gpio_output_select(unsigned gpio, u8 val);
  330. +int ath79_gpio_direction_select(unsigned gpio, bool oe);
  331. void ath79_gpio_init(void);
  332. #endif /* __ATH79_COMMON_H */
  333. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-ap9x-pci.c linux-4.1.13/arch/mips/ath79/dev-ap9x-pci.c
  334. --- linux-4.1.13.orig/arch/mips/ath79/dev-ap9x-pci.c 1970-01-01 01:00:00.000000000 +0100
  335. +++ linux-4.1.13/arch/mips/ath79/dev-ap9x-pci.c 2015-09-13 20:04:35.064524285 +0200
  336. @@ -0,0 +1,159 @@
  337. +/*
  338. + * Atheros AP9X reference board PCI initialization
  339. + *
  340. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  341. + *
  342. + * This program is free software; you can redistribute it and/or modify it
  343. + * under the terms of the GNU General Public License version 2 as published
  344. + * by the Free Software Foundation.
  345. + */
  346. +
  347. +#include <linux/pci.h>
  348. +#include <linux/ath9k_platform.h>
  349. +#include <linux/delay.h>
  350. +
  351. +#include <asm/mach-ath79/ath79.h>
  352. +
  353. +#include "dev-ap9x-pci.h"
  354. +#include "pci-ath9k-fixup.h"
  355. +#include "pci.h"
  356. +
  357. +static struct ath9k_platform_data ap9x_wmac0_data = {
  358. + .led_pin = -1,
  359. +};
  360. +static struct ath9k_platform_data ap9x_wmac1_data = {
  361. + .led_pin = -1,
  362. +};
  363. +static char ap9x_wmac0_mac[6];
  364. +static char ap9x_wmac1_mac[6];
  365. +
  366. +__init void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin)
  367. +{
  368. + switch (wmac) {
  369. + case 0:
  370. + ap9x_wmac0_data.led_pin = pin;
  371. + break;
  372. + case 1:
  373. + ap9x_wmac1_data.led_pin = pin;
  374. + break;
  375. + }
  376. +}
  377. +
  378. +__init struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
  379. +{
  380. + switch (wmac) {
  381. + case 0:
  382. + return &ap9x_wmac0_data;
  383. +
  384. + case 1:
  385. + return &ap9x_wmac1_data;
  386. + }
  387. +
  388. + return NULL;
  389. +}
  390. +
  391. +__init void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val)
  392. +{
  393. + switch (wmac) {
  394. + case 0:
  395. + ap9x_wmac0_data.gpio_mask = mask;
  396. + ap9x_wmac0_data.gpio_val = val;
  397. + break;
  398. + case 1:
  399. + ap9x_wmac1_data.gpio_mask = mask;
  400. + ap9x_wmac1_data.gpio_val = val;
  401. + break;
  402. + }
  403. +}
  404. +
  405. +__init void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
  406. + int num_leds)
  407. +{
  408. + switch (wmac) {
  409. + case 0:
  410. + ap9x_wmac0_data.leds = leds;
  411. + ap9x_wmac0_data.num_leds = num_leds;
  412. + break;
  413. + case 1:
  414. + ap9x_wmac1_data.leds = leds;
  415. + ap9x_wmac1_data.num_leds = num_leds;
  416. + break;
  417. + }
  418. +}
  419. +
  420. +static int ap91_pci_plat_dev_init(struct pci_dev *dev)
  421. +{
  422. + switch (PCI_SLOT(dev->devfn)) {
  423. + case 0:
  424. + dev->dev.platform_data = &ap9x_wmac0_data;
  425. + break;
  426. + }
  427. +
  428. + return 0;
  429. +}
  430. +
  431. +__init void ap91_pci_init(u8 *cal_data, u8 *mac_addr)
  432. +{
  433. + if (cal_data)
  434. + memcpy(ap9x_wmac0_data.eeprom_data, cal_data,
  435. + sizeof(ap9x_wmac0_data.eeprom_data));
  436. +
  437. + if (mac_addr) {
  438. + memcpy(ap9x_wmac0_mac, mac_addr, sizeof(ap9x_wmac0_mac));
  439. + ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
  440. + }
  441. +
  442. + ath79_pci_set_plat_dev_init(ap91_pci_plat_dev_init);
  443. + ath79_register_pci();
  444. +
  445. + pci_enable_ath9k_fixup(0, ap9x_wmac0_data.eeprom_data);
  446. +}
  447. +
  448. +__init void ap91_pci_init_simple(void)
  449. +{
  450. + ap91_pci_init(NULL, NULL);
  451. + ap9x_wmac0_data.eeprom_name = "pci_wmac0.eeprom";
  452. +}
  453. +
  454. +static int ap94_pci_plat_dev_init(struct pci_dev *dev)
  455. +{
  456. + switch (PCI_SLOT(dev->devfn)) {
  457. + case 17:
  458. + dev->dev.platform_data = &ap9x_wmac0_data;
  459. + break;
  460. +
  461. + case 18:
  462. + dev->dev.platform_data = &ap9x_wmac1_data;
  463. + break;
  464. + }
  465. +
  466. + return 0;
  467. +}
  468. +
  469. +__init void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  470. + u8 *cal_data1, u8 *mac_addr1)
  471. +{
  472. + if (cal_data0)
  473. + memcpy(ap9x_wmac0_data.eeprom_data, cal_data0,
  474. + sizeof(ap9x_wmac0_data.eeprom_data));
  475. +
  476. + if (cal_data1)
  477. + memcpy(ap9x_wmac1_data.eeprom_data, cal_data1,
  478. + sizeof(ap9x_wmac1_data.eeprom_data));
  479. +
  480. + if (mac_addr0) {
  481. + memcpy(ap9x_wmac0_mac, mac_addr0, sizeof(ap9x_wmac0_mac));
  482. + ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
  483. + }
  484. +
  485. + if (mac_addr1) {
  486. + memcpy(ap9x_wmac1_mac, mac_addr1, sizeof(ap9x_wmac1_mac));
  487. + ap9x_wmac1_data.macaddr = ap9x_wmac1_mac;
  488. + }
  489. +
  490. + ath79_pci_set_plat_dev_init(ap94_pci_plat_dev_init);
  491. + ath79_register_pci();
  492. +
  493. + pci_enable_ath9k_fixup(17, ap9x_wmac0_data.eeprom_data);
  494. + pci_enable_ath9k_fixup(18, ap9x_wmac1_data.eeprom_data);
  495. +}
  496. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-ap9x-pci.h linux-4.1.13/arch/mips/ath79/dev-ap9x-pci.h
  497. --- linux-4.1.13.orig/arch/mips/ath79/dev-ap9x-pci.h 1970-01-01 01:00:00.000000000 +0100
  498. +++ linux-4.1.13/arch/mips/ath79/dev-ap9x-pci.h 2015-09-13 20:04:35.064524285 +0200
  499. @@ -0,0 +1,48 @@
  500. +/*
  501. + * Atheros AP9X reference board PCI initialization
  502. + *
  503. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  504. + *
  505. + * This program is free software; you can redistribute it and/or modify it
  506. + * under the terms of the GNU General Public License version 2 as published
  507. + * by the Free Software Foundation.
  508. + */
  509. +
  510. +#ifndef _ATH79_DEV_AP9X_PCI_H
  511. +#define _ATH79_DEV_AP9X_PCI_H
  512. +
  513. +struct gpio_led;
  514. +struct ath9k_platform_data;
  515. +
  516. +#if defined(CONFIG_ATH79_DEV_AP9X_PCI)
  517. +void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin);
  518. +void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val);
  519. +void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
  520. + int num_leds);
  521. +struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac);
  522. +
  523. +void ap91_pci_init(u8 *cal_data, u8 *mac_addr);
  524. +void ap91_pci_init_simple(void);
  525. +void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  526. + u8 *cal_data1, u8 *mac_addr1);
  527. +
  528. +#else
  529. +static inline void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin) {}
  530. +static inline void ap9x_pci_setup_wmac_gpio(unsigned wmac,
  531. + u32 mask, u32 val) {}
  532. +static inline void ap9x_pci_setup_wmac_leds(unsigned wmac,
  533. + struct gpio_led *leds,
  534. + int num_leds) {}
  535. +static inline struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
  536. +{
  537. + return NULL;
  538. +}
  539. +
  540. +static inline void ap91_pci_init(u8 *cal_data, u8 *mac_addr) {}
  541. +static inline void ap91_pci_init_simple(void) {}
  542. +static inline void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  543. + u8 *cal_data1, u8 *mac_addr1) {}
  544. +#endif
  545. +
  546. +#endif /* _ATH79_DEV_AP9X_PCI_H */
  547. +
  548. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-common.c linux-4.1.13/arch/mips/ath79/dev-common.c
  549. --- linux-4.1.13.orig/arch/mips/ath79/dev-common.c 2015-11-09 23:34:10.000000000 +0100
  550. +++ linux-4.1.13/arch/mips/ath79/dev-common.c 2015-12-04 19:57:04.474072175 +0100
  551. @@ -80,11 +80,22 @@
  552. uart_clk_rate = ath79_get_sys_clk_rate("uart");
  553. + if (soc_is_ar71xx())
  554. + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_UART_EN);
  555. + else if (soc_is_ar724x())
  556. + ath79_gpio_function_enable(AR724X_GPIO_FUNC_UART_EN);
  557. + else if (soc_is_ar913x())
  558. + ath79_gpio_function_enable(AR913X_GPIO_FUNC_UART_EN);
  559. + else if (soc_is_ar933x())
  560. + ath79_gpio_function_enable(AR933X_GPIO_FUNC_UART_EN);
  561. +
  562. if (soc_is_ar71xx() ||
  563. soc_is_ar724x() ||
  564. soc_is_ar913x() ||
  565. soc_is_ar934x() ||
  566. - soc_is_qca955x()) {
  567. + soc_is_qca953x() ||
  568. + soc_is_qca955x() ||
  569. + soc_is_qca956x()) {
  570. ath79_uart_data[0].uartclk = uart_clk_rate;
  571. platform_device_register(&ath79_uart_device);
  572. } else if (soc_is_ar933x()) {
  573. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-dsa.c linux-4.1.13/arch/mips/ath79/dev-dsa.c
  574. --- linux-4.1.13.orig/arch/mips/ath79/dev-dsa.c 1970-01-01 01:00:00.000000000 +0100
  575. +++ linux-4.1.13/arch/mips/ath79/dev-dsa.c 2015-09-13 20:04:35.064524285 +0200
  576. @@ -0,0 +1,41 @@
  577. +/*
  578. + * Atheros AR71xx DSA switch device support
  579. + *
  580. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  581. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  582. + *
  583. + * This program is free software; you can redistribute it and/or modify it
  584. + * under the terms of the GNU General Public License version 2 as published
  585. + * by the Free Software Foundation.
  586. + */
  587. +
  588. +#include <linux/init.h>
  589. +#include <linux/version.h>
  590. +#include <linux/platform_device.h>
  591. +
  592. +#include <asm/mach-ath79/ath79.h>
  593. +
  594. +#include "dev-dsa.h"
  595. +
  596. +static struct platform_device ar71xx_dsa_switch_device = {
  597. + .name = "dsa",
  598. + .id = 0,
  599. +};
  600. +
  601. +void __init ath79_register_dsa(struct device *netdev,
  602. + struct device *miidev,
  603. + struct dsa_platform_data *d)
  604. +{
  605. + int i;
  606. +
  607. + d->netdev = netdev;
  608. + for (i = 0; i < d->nr_chips; i++)
  609. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
  610. + d->chip[i].mii_bus = miidev;
  611. +#else
  612. + d->chip[i].host_dev = miidev;
  613. +#endif
  614. +
  615. + ar71xx_dsa_switch_device.dev.platform_data = d;
  616. + platform_device_register(&ar71xx_dsa_switch_device);
  617. +}
  618. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-dsa.h linux-4.1.13/arch/mips/ath79/dev-dsa.h
  619. --- linux-4.1.13.orig/arch/mips/ath79/dev-dsa.h 1970-01-01 01:00:00.000000000 +0100
  620. +++ linux-4.1.13/arch/mips/ath79/dev-dsa.h 2015-09-13 20:04:35.064524285 +0200
  621. @@ -0,0 +1,21 @@
  622. +/*
  623. + * Atheros AR71xx DSA switch device support
  624. + *
  625. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  626. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  627. + *
  628. + * This program is free software; you can redistribute it and/or modify it
  629. + * under the terms of the GNU General Public License version 2 as published
  630. + * by the Free Software Foundation.
  631. + */
  632. +
  633. +#ifndef _ATH79_DEV_DSA_H
  634. +#define _ATH79_DEV_DSA_H
  635. +
  636. +#include <net/dsa.h>
  637. +
  638. +void ath79_register_dsa(struct device *netdev,
  639. + struct device *miidev,
  640. + struct dsa_platform_data *d);
  641. +
  642. +#endif /* _ATH79_DEV_DSA_H */
  643. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-eth.c linux-4.1.13/arch/mips/ath79/dev-eth.c
  644. --- linux-4.1.13.orig/arch/mips/ath79/dev-eth.c 1970-01-01 01:00:00.000000000 +0100
  645. +++ linux-4.1.13/arch/mips/ath79/dev-eth.c 2015-11-21 17:22:11.759223549 +0100
  646. @@ -0,0 +1,1254 @@
  647. +/*
  648. + * Atheros AR71xx SoC platform devices
  649. + *
  650. + * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
  651. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  652. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  653. + *
  654. + * Parts of this file are based on Atheros 2.6.15 BSP
  655. + * Parts of this file are based on Atheros 2.6.31 BSP
  656. + *
  657. + * This program is free software; you can redistribute it and/or modify it
  658. + * under the terms of the GNU General Public License version 2 as published
  659. + * by the Free Software Foundation.
  660. + */
  661. +
  662. +#include <linux/kernel.h>
  663. +#include <linux/init.h>
  664. +#include <linux/delay.h>
  665. +#include <linux/etherdevice.h>
  666. +#include <linux/platform_device.h>
  667. +#include <linux/serial_8250.h>
  668. +#include <linux/clk.h>
  669. +#include <linux/sizes.h>
  670. +
  671. +#include <asm/mach-ath79/ath79.h>
  672. +#include <asm/mach-ath79/ar71xx_regs.h>
  673. +#include <asm/mach-ath79/irq.h>
  674. +
  675. +#include "common.h"
  676. +#include "dev-eth.h"
  677. +
  678. +unsigned char ath79_mac_base[ETH_ALEN] __initdata;
  679. +
  680. +static struct resource ath79_mdio0_resources[] = {
  681. + {
  682. + .name = "mdio_base",
  683. + .flags = IORESOURCE_MEM,
  684. + .start = AR71XX_GE0_BASE,
  685. + .end = AR71XX_GE0_BASE + 0x200 - 1,
  686. + }
  687. +};
  688. +
  689. +struct ag71xx_mdio_platform_data ath79_mdio0_data;
  690. +
  691. +struct platform_device ath79_mdio0_device = {
  692. + .name = "ag71xx-mdio",
  693. + .id = 0,
  694. + .resource = ath79_mdio0_resources,
  695. + .num_resources = ARRAY_SIZE(ath79_mdio0_resources),
  696. + .dev = {
  697. + .platform_data = &ath79_mdio0_data,
  698. + },
  699. +};
  700. +
  701. +static struct resource ath79_mdio1_resources[] = {
  702. + {
  703. + .name = "mdio_base",
  704. + .flags = IORESOURCE_MEM,
  705. + .start = AR71XX_GE1_BASE,
  706. + .end = AR71XX_GE1_BASE + 0x200 - 1,
  707. + }
  708. +};
  709. +
  710. +struct ag71xx_mdio_platform_data ath79_mdio1_data;
  711. +
  712. +struct platform_device ath79_mdio1_device = {
  713. + .name = "ag71xx-mdio",
  714. + .id = 1,
  715. + .resource = ath79_mdio1_resources,
  716. + .num_resources = ARRAY_SIZE(ath79_mdio1_resources),
  717. + .dev = {
  718. + .platform_data = &ath79_mdio1_data,
  719. + },
  720. +};
  721. +
  722. +static void ath79_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
  723. +{
  724. + void __iomem *base;
  725. + u32 t;
  726. +
  727. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  728. +
  729. + t = __raw_readl(base + cfg_reg);
  730. + t &= ~(3 << shift);
  731. + t |= (2 << shift);
  732. + __raw_writel(t, base + cfg_reg);
  733. + udelay(100);
  734. +
  735. + __raw_writel(pll_val, base + pll_reg);
  736. +
  737. + t |= (3 << shift);
  738. + __raw_writel(t, base + cfg_reg);
  739. + udelay(100);
  740. +
  741. + t &= ~(3 << shift);
  742. + __raw_writel(t, base + cfg_reg);
  743. + udelay(100);
  744. +
  745. + printk(KERN_DEBUG "ar71xx: pll_reg %#x: %#x\n",
  746. + (unsigned int)(base + pll_reg), __raw_readl(base + pll_reg));
  747. +
  748. + iounmap(base);
  749. +}
  750. +
  751. +static void __init ath79_mii_ctrl_set_if(unsigned int reg,
  752. + unsigned int mii_if)
  753. +{
  754. + void __iomem *base;
  755. + u32 t;
  756. +
  757. + base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
  758. +
  759. + t = __raw_readl(base + reg);
  760. + t &= ~(AR71XX_MII_CTRL_IF_MASK);
  761. + t |= (mii_if & AR71XX_MII_CTRL_IF_MASK);
  762. + __raw_writel(t, base + reg);
  763. +
  764. + iounmap(base);
  765. +}
  766. +
  767. +static void ath79_mii_ctrl_set_speed(unsigned int reg, unsigned int speed)
  768. +{
  769. + void __iomem *base;
  770. + unsigned int mii_speed;
  771. + u32 t;
  772. +
  773. + switch (speed) {
  774. + case SPEED_10:
  775. + mii_speed = AR71XX_MII_CTRL_SPEED_10;
  776. + break;
  777. + case SPEED_100:
  778. + mii_speed = AR71XX_MII_CTRL_SPEED_100;
  779. + break;
  780. + case SPEED_1000:
  781. + mii_speed = AR71XX_MII_CTRL_SPEED_1000;
  782. + break;
  783. + default:
  784. + BUG();
  785. + }
  786. +
  787. + base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
  788. +
  789. + t = __raw_readl(base + reg);
  790. + t &= ~(AR71XX_MII_CTRL_SPEED_MASK << AR71XX_MII_CTRL_SPEED_SHIFT);
  791. + t |= mii_speed << AR71XX_MII_CTRL_SPEED_SHIFT;
  792. + __raw_writel(t, base + reg);
  793. +
  794. + iounmap(base);
  795. +}
  796. +
  797. +static unsigned long ar934x_get_mdio_ref_clock(void)
  798. +{
  799. + void __iomem *base;
  800. + unsigned long ret;
  801. + u32 t;
  802. +
  803. + base = ioremap(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  804. +
  805. + ret = 0;
  806. + t = __raw_readl(base + AR934X_PLL_SWITCH_CLOCK_CONTROL_REG);
  807. + if (t & AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL) {
  808. + ret = 100 * 1000 * 1000;
  809. + } else {
  810. + struct clk *clk;
  811. +
  812. + clk = clk_get(NULL, "ref");
  813. + if (!IS_ERR(clk))
  814. + ret = clk_get_rate(clk);
  815. + }
  816. +
  817. + iounmap(base);
  818. +
  819. + return ret;
  820. +}
  821. +
  822. +void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
  823. +{
  824. + struct platform_device *mdio_dev;
  825. + struct ag71xx_mdio_platform_data *mdio_data;
  826. + unsigned int max_id;
  827. +
  828. + if (ath79_soc == ATH79_SOC_AR9341 ||
  829. + ath79_soc == ATH79_SOC_AR9342 ||
  830. + ath79_soc == ATH79_SOC_AR9344 ||
  831. + ath79_soc == ATH79_SOC_QCA9556 ||
  832. + ath79_soc == ATH79_SOC_QCA9558)
  833. + max_id = 1;
  834. + else
  835. + max_id = 0;
  836. +
  837. + if (id > max_id) {
  838. + printk(KERN_ERR "ar71xx: invalid MDIO id %u\n", id);
  839. + return;
  840. + }
  841. +
  842. + switch (ath79_soc) {
  843. + case ATH79_SOC_AR7241:
  844. + case ATH79_SOC_AR9330:
  845. + case ATH79_SOC_AR9331:
  846. + case ATH79_SOC_QCA9533:
  847. + case ATH79_SOC_QCA9561:
  848. + case ATH79_SOC_TP9343:
  849. + mdio_dev = &ath79_mdio1_device;
  850. + mdio_data = &ath79_mdio1_data;
  851. + break;
  852. +
  853. + case ATH79_SOC_AR9341:
  854. + case ATH79_SOC_AR9342:
  855. + case ATH79_SOC_AR9344:
  856. + case ATH79_SOC_QCA9556:
  857. + case ATH79_SOC_QCA9558:
  858. + if (id == 0) {
  859. + mdio_dev = &ath79_mdio0_device;
  860. + mdio_data = &ath79_mdio0_data;
  861. + } else {
  862. + mdio_dev = &ath79_mdio1_device;
  863. + mdio_data = &ath79_mdio1_data;
  864. + }
  865. + break;
  866. +
  867. + case ATH79_SOC_AR7242:
  868. + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG,
  869. + AR7242_PLL_REG_ETH0_INT_CLOCK, 0x62000000,
  870. + AR71XX_ETH0_PLL_SHIFT);
  871. + /* fall through */
  872. + default:
  873. + mdio_dev = &ath79_mdio0_device;
  874. + mdio_data = &ath79_mdio0_data;
  875. + break;
  876. + }
  877. +
  878. + mdio_data->phy_mask = phy_mask;
  879. +
  880. + switch (ath79_soc) {
  881. + case ATH79_SOC_AR7240:
  882. + mdio_data->is_ar7240 = 1;
  883. + /* fall through */
  884. + case ATH79_SOC_AR7241:
  885. + mdio_data->builtin_switch = 1;
  886. + break;
  887. +
  888. + case ATH79_SOC_AR9330:
  889. + mdio_data->is_ar9330 = 1;
  890. + /* fall through */
  891. + case ATH79_SOC_AR9331:
  892. + mdio_data->builtin_switch = 1;
  893. + break;
  894. +
  895. + case ATH79_SOC_AR9341:
  896. + case ATH79_SOC_AR9342:
  897. + case ATH79_SOC_AR9344:
  898. + if (id == 1) {
  899. + mdio_data->builtin_switch = 1;
  900. + mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
  901. + mdio_data->mdio_clock = 6250000;
  902. + }
  903. + mdio_data->is_ar934x = 1;
  904. + break;
  905. +
  906. + case ATH79_SOC_QCA9533:
  907. + case ATH79_SOC_QCA9561:
  908. + case ATH79_SOC_TP9343:
  909. + mdio_data->builtin_switch = 1;
  910. + break;
  911. +
  912. + case ATH79_SOC_QCA9556:
  913. + case ATH79_SOC_QCA9558:
  914. + mdio_data->is_ar934x = 1;
  915. + break;
  916. +
  917. + default:
  918. + break;
  919. + }
  920. +
  921. + platform_device_register(mdio_dev);
  922. +}
  923. +
  924. +struct ath79_eth_pll_data ath79_eth0_pll_data;
  925. +struct ath79_eth_pll_data ath79_eth1_pll_data;
  926. +
  927. +static u32 ath79_get_eth_pll(unsigned int mac, int speed)
  928. +{
  929. + struct ath79_eth_pll_data *pll_data;
  930. + u32 pll_val;
  931. +
  932. + switch (mac) {
  933. + case 0:
  934. + pll_data = &ath79_eth0_pll_data;
  935. + break;
  936. + case 1:
  937. + pll_data = &ath79_eth1_pll_data;
  938. + break;
  939. + default:
  940. + BUG();
  941. + }
  942. +
  943. + switch (speed) {
  944. + case SPEED_10:
  945. + pll_val = pll_data->pll_10;
  946. + break;
  947. + case SPEED_100:
  948. + pll_val = pll_data->pll_100;
  949. + break;
  950. + case SPEED_1000:
  951. + pll_val = pll_data->pll_1000;
  952. + break;
  953. + default:
  954. + BUG();
  955. + }
  956. +
  957. + return pll_val;
  958. +}
  959. +
  960. +static void ath79_set_speed_ge0(int speed)
  961. +{
  962. + u32 val = ath79_get_eth_pll(0, speed);
  963. +
  964. + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH0_INT_CLOCK,
  965. + val, AR71XX_ETH0_PLL_SHIFT);
  966. + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
  967. +}
  968. +
  969. +static void ath79_set_speed_ge1(int speed)
  970. +{
  971. + u32 val = ath79_get_eth_pll(1, speed);
  972. +
  973. + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH1_INT_CLOCK,
  974. + val, AR71XX_ETH1_PLL_SHIFT);
  975. + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
  976. +}
  977. +
  978. +static void ar7242_set_speed_ge0(int speed)
  979. +{
  980. + u32 val = ath79_get_eth_pll(0, speed);
  981. + void __iomem *base;
  982. +
  983. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  984. + __raw_writel(val, base + AR7242_PLL_REG_ETH0_INT_CLOCK);
  985. + iounmap(base);
  986. +}
  987. +
  988. +static void ar91xx_set_speed_ge0(int speed)
  989. +{
  990. + u32 val = ath79_get_eth_pll(0, speed);
  991. +
  992. + ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH0_INT_CLOCK,
  993. + val, AR913X_ETH0_PLL_SHIFT);
  994. + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
  995. +}
  996. +
  997. +static void ar91xx_set_speed_ge1(int speed)
  998. +{
  999. + u32 val = ath79_get_eth_pll(1, speed);
  1000. +
  1001. + ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH1_INT_CLOCK,
  1002. + val, AR913X_ETH1_PLL_SHIFT);
  1003. + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
  1004. +}
  1005. +
  1006. +static void ar934x_set_speed_ge0(int speed)
  1007. +{
  1008. + void __iomem *base;
  1009. + u32 val = ath79_get_eth_pll(0, speed);
  1010. +
  1011. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  1012. + __raw_writel(val, base + AR934X_PLL_ETH_XMII_CONTROL_REG);
  1013. + iounmap(base);
  1014. +}
  1015. +
  1016. +static void qca955x_set_speed_xmii(int speed)
  1017. +{
  1018. + void __iomem *base;
  1019. + u32 val = ath79_get_eth_pll(0, speed);
  1020. +
  1021. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  1022. + __raw_writel(val, base + QCA955X_PLL_ETH_XMII_CONTROL_REG);
  1023. + iounmap(base);
  1024. +}
  1025. +
  1026. +static void qca955x_set_speed_sgmii(int speed)
  1027. +{
  1028. + void __iomem *base;
  1029. + u32 val = ath79_get_eth_pll(1, speed);
  1030. +
  1031. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  1032. + __raw_writel(val, base + QCA955X_PLL_ETH_SGMII_CONTROL_REG);
  1033. + iounmap(base);
  1034. +}
  1035. +
  1036. +static void ath79_set_speed_dummy(int speed)
  1037. +{
  1038. +}
  1039. +
  1040. +static void ath79_ddr_no_flush(void)
  1041. +{
  1042. +}
  1043. +
  1044. +static void ath79_ddr_flush_ge0(void)
  1045. +{
  1046. + ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_GE0);
  1047. +}
  1048. +
  1049. +static void ath79_ddr_flush_ge1(void)
  1050. +{
  1051. + ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_GE1);
  1052. +}
  1053. +
  1054. +static void ar724x_ddr_flush_ge0(void)
  1055. +{
  1056. + ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_GE0);
  1057. +}
  1058. +
  1059. +static void ar724x_ddr_flush_ge1(void)
  1060. +{
  1061. + ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_GE1);
  1062. +}
  1063. +
  1064. +static void ar91xx_ddr_flush_ge0(void)
  1065. +{
  1066. + ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_GE0);
  1067. +}
  1068. +
  1069. +static void ar91xx_ddr_flush_ge1(void)
  1070. +{
  1071. + ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_GE1);
  1072. +}
  1073. +
  1074. +static void ar933x_ddr_flush_ge0(void)
  1075. +{
  1076. + ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_GE0);
  1077. +}
  1078. +
  1079. +static void ar933x_ddr_flush_ge1(void)
  1080. +{
  1081. + ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_GE1);
  1082. +}
  1083. +
  1084. +static struct resource ath79_eth0_resources[] = {
  1085. + {
  1086. + .name = "mac_base",
  1087. + .flags = IORESOURCE_MEM,
  1088. + .start = AR71XX_GE0_BASE,
  1089. + .end = AR71XX_GE0_BASE + 0x200 - 1,
  1090. + }, {
  1091. + .name = "mac_irq",
  1092. + .flags = IORESOURCE_IRQ,
  1093. + .start = ATH79_CPU_IRQ(4),
  1094. + .end = ATH79_CPU_IRQ(4),
  1095. + },
  1096. +};
  1097. +
  1098. +struct ag71xx_platform_data ath79_eth0_data = {
  1099. + .reset_bit = AR71XX_RESET_GE0_MAC,
  1100. +};
  1101. +
  1102. +struct platform_device ath79_eth0_device = {
  1103. + .name = "ag71xx",
  1104. + .id = 0,
  1105. + .resource = ath79_eth0_resources,
  1106. + .num_resources = ARRAY_SIZE(ath79_eth0_resources),
  1107. + .dev = {
  1108. + .platform_data = &ath79_eth0_data,
  1109. + },
  1110. +};
  1111. +
  1112. +static struct resource ath79_eth1_resources[] = {
  1113. + {
  1114. + .name = "mac_base",
  1115. + .flags = IORESOURCE_MEM,
  1116. + .start = AR71XX_GE1_BASE,
  1117. + .end = AR71XX_GE1_BASE + 0x200 - 1,
  1118. + }, {
  1119. + .name = "mac_irq",
  1120. + .flags = IORESOURCE_IRQ,
  1121. + .start = ATH79_CPU_IRQ(5),
  1122. + .end = ATH79_CPU_IRQ(5),
  1123. + },
  1124. +};
  1125. +
  1126. +struct ag71xx_platform_data ath79_eth1_data = {
  1127. + .reset_bit = AR71XX_RESET_GE1_MAC,
  1128. +};
  1129. +
  1130. +struct platform_device ath79_eth1_device = {
  1131. + .name = "ag71xx",
  1132. + .id = 1,
  1133. + .resource = ath79_eth1_resources,
  1134. + .num_resources = ARRAY_SIZE(ath79_eth1_resources),
  1135. + .dev = {
  1136. + .platform_data = &ath79_eth1_data,
  1137. + },
  1138. +};
  1139. +
  1140. +struct ag71xx_switch_platform_data ath79_switch_data;
  1141. +
  1142. +#define AR71XX_PLL_VAL_1000 0x00110000
  1143. +#define AR71XX_PLL_VAL_100 0x00001099
  1144. +#define AR71XX_PLL_VAL_10 0x00991099
  1145. +
  1146. +#define AR724X_PLL_VAL_1000 0x00110000
  1147. +#define AR724X_PLL_VAL_100 0x00001099
  1148. +#define AR724X_PLL_VAL_10 0x00991099
  1149. +
  1150. +#define AR7242_PLL_VAL_1000 0x16000000
  1151. +#define AR7242_PLL_VAL_100 0x00000101
  1152. +#define AR7242_PLL_VAL_10 0x00001616
  1153. +
  1154. +#define AR913X_PLL_VAL_1000 0x1a000000
  1155. +#define AR913X_PLL_VAL_100 0x13000a44
  1156. +#define AR913X_PLL_VAL_10 0x00441099
  1157. +
  1158. +#define AR933X_PLL_VAL_1000 0x00110000
  1159. +#define AR933X_PLL_VAL_100 0x00001099
  1160. +#define AR933X_PLL_VAL_10 0x00991099
  1161. +
  1162. +#define AR934X_PLL_VAL_1000 0x16000000
  1163. +#define AR934X_PLL_VAL_100 0x00000101
  1164. +#define AR934X_PLL_VAL_10 0x00001616
  1165. +
  1166. +static void __init ath79_init_eth_pll_data(unsigned int id)
  1167. +{
  1168. + struct ath79_eth_pll_data *pll_data;
  1169. + u32 pll_10, pll_100, pll_1000;
  1170. +
  1171. + switch (id) {
  1172. + case 0:
  1173. + pll_data = &ath79_eth0_pll_data;
  1174. + break;
  1175. + case 1:
  1176. + pll_data = &ath79_eth1_pll_data;
  1177. + break;
  1178. + default:
  1179. + BUG();
  1180. + }
  1181. +
  1182. + switch (ath79_soc) {
  1183. + case ATH79_SOC_AR7130:
  1184. + case ATH79_SOC_AR7141:
  1185. + case ATH79_SOC_AR7161:
  1186. + pll_10 = AR71XX_PLL_VAL_10;
  1187. + pll_100 = AR71XX_PLL_VAL_100;
  1188. + pll_1000 = AR71XX_PLL_VAL_1000;
  1189. + break;
  1190. +
  1191. + case ATH79_SOC_AR7240:
  1192. + case ATH79_SOC_AR7241:
  1193. + pll_10 = AR724X_PLL_VAL_10;
  1194. + pll_100 = AR724X_PLL_VAL_100;
  1195. + pll_1000 = AR724X_PLL_VAL_1000;
  1196. + break;
  1197. +
  1198. + case ATH79_SOC_AR7242:
  1199. + pll_10 = AR7242_PLL_VAL_10;
  1200. + pll_100 = AR7242_PLL_VAL_100;
  1201. + pll_1000 = AR7242_PLL_VAL_1000;
  1202. + break;
  1203. +
  1204. + case ATH79_SOC_AR9130:
  1205. + case ATH79_SOC_AR9132:
  1206. + pll_10 = AR913X_PLL_VAL_10;
  1207. + pll_100 = AR913X_PLL_VAL_100;
  1208. + pll_1000 = AR913X_PLL_VAL_1000;
  1209. + break;
  1210. +
  1211. + case ATH79_SOC_AR9330:
  1212. + case ATH79_SOC_AR9331:
  1213. + pll_10 = AR933X_PLL_VAL_10;
  1214. + pll_100 = AR933X_PLL_VAL_100;
  1215. + pll_1000 = AR933X_PLL_VAL_1000;
  1216. + break;
  1217. +
  1218. + case ATH79_SOC_AR9341:
  1219. + case ATH79_SOC_AR9342:
  1220. + case ATH79_SOC_AR9344:
  1221. + case ATH79_SOC_QCA9533:
  1222. + case ATH79_SOC_QCA9556:
  1223. + case ATH79_SOC_QCA9558:
  1224. + case ATH79_SOC_QCA9561:
  1225. + case ATH79_SOC_TP9343:
  1226. + pll_10 = AR934X_PLL_VAL_10;
  1227. + pll_100 = AR934X_PLL_VAL_100;
  1228. + pll_1000 = AR934X_PLL_VAL_1000;
  1229. + break;
  1230. +
  1231. + default:
  1232. + BUG();
  1233. + }
  1234. +
  1235. + if (!pll_data->pll_10)
  1236. + pll_data->pll_10 = pll_10;
  1237. +
  1238. + if (!pll_data->pll_100)
  1239. + pll_data->pll_100 = pll_100;
  1240. +
  1241. + if (!pll_data->pll_1000)
  1242. + pll_data->pll_1000 = pll_1000;
  1243. +}
  1244. +
  1245. +static int __init ath79_setup_phy_if_mode(unsigned int id,
  1246. + struct ag71xx_platform_data *pdata)
  1247. +{
  1248. + unsigned int mii_if;
  1249. +
  1250. + switch (id) {
  1251. + case 0:
  1252. + switch (ath79_soc) {
  1253. + case ATH79_SOC_AR7130:
  1254. + case ATH79_SOC_AR7141:
  1255. + case ATH79_SOC_AR7161:
  1256. + case ATH79_SOC_AR9130:
  1257. + case ATH79_SOC_AR9132:
  1258. + switch (pdata->phy_if_mode) {
  1259. + case PHY_INTERFACE_MODE_MII:
  1260. + mii_if = AR71XX_MII0_CTRL_IF_MII;
  1261. + break;
  1262. + case PHY_INTERFACE_MODE_GMII:
  1263. + mii_if = AR71XX_MII0_CTRL_IF_GMII;
  1264. + break;
  1265. + case PHY_INTERFACE_MODE_RGMII:
  1266. + mii_if = AR71XX_MII0_CTRL_IF_RGMII;
  1267. + break;
  1268. + case PHY_INTERFACE_MODE_RMII:
  1269. + mii_if = AR71XX_MII0_CTRL_IF_RMII;
  1270. + break;
  1271. + default:
  1272. + return -EINVAL;
  1273. + }
  1274. + ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII0_CTRL, mii_if);
  1275. + break;
  1276. +
  1277. + case ATH79_SOC_AR7240:
  1278. + case ATH79_SOC_AR7241:
  1279. + case ATH79_SOC_AR9330:
  1280. + case ATH79_SOC_AR9331:
  1281. + case ATH79_SOC_QCA9533:
  1282. + case ATH79_SOC_TP9343:
  1283. + pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
  1284. + break;
  1285. +
  1286. + case ATH79_SOC_AR7242:
  1287. + /* FIXME */
  1288. +
  1289. + case ATH79_SOC_AR9341:
  1290. + case ATH79_SOC_AR9342:
  1291. + case ATH79_SOC_AR9344:
  1292. + switch (pdata->phy_if_mode) {
  1293. + case PHY_INTERFACE_MODE_MII:
  1294. + case PHY_INTERFACE_MODE_GMII:
  1295. + case PHY_INTERFACE_MODE_RGMII:
  1296. + case PHY_INTERFACE_MODE_RMII:
  1297. + break;
  1298. + default:
  1299. + return -EINVAL;
  1300. + }
  1301. + break;
  1302. +
  1303. + case ATH79_SOC_QCA9556:
  1304. + case ATH79_SOC_QCA9558:
  1305. + switch (pdata->phy_if_mode) {
  1306. + case PHY_INTERFACE_MODE_MII:
  1307. + case PHY_INTERFACE_MODE_RGMII:
  1308. + case PHY_INTERFACE_MODE_SGMII:
  1309. + break;
  1310. + default:
  1311. + return -EINVAL;
  1312. + }
  1313. + break;
  1314. +
  1315. + case ATH79_SOC_QCA9561:
  1316. + if (!pdata->phy_if_mode)
  1317. + pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
  1318. + break;
  1319. +
  1320. + default:
  1321. + BUG();
  1322. + }
  1323. + break;
  1324. + case 1:
  1325. + switch (ath79_soc) {
  1326. + case ATH79_SOC_AR7130:
  1327. + case ATH79_SOC_AR7141:
  1328. + case ATH79_SOC_AR7161:
  1329. + case ATH79_SOC_AR9130:
  1330. + case ATH79_SOC_AR9132:
  1331. + switch (pdata->phy_if_mode) {
  1332. + case PHY_INTERFACE_MODE_RMII:
  1333. + mii_if = AR71XX_MII1_CTRL_IF_RMII;
  1334. + break;
  1335. + case PHY_INTERFACE_MODE_RGMII:
  1336. + mii_if = AR71XX_MII1_CTRL_IF_RGMII;
  1337. + break;
  1338. + default:
  1339. + return -EINVAL;
  1340. + }
  1341. + ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII1_CTRL, mii_if);
  1342. + break;
  1343. +
  1344. + case ATH79_SOC_AR7240:
  1345. + case ATH79_SOC_AR7241:
  1346. + case ATH79_SOC_AR9330:
  1347. + case ATH79_SOC_AR9331:
  1348. + case ATH79_SOC_QCA9561:
  1349. + case ATH79_SOC_TP9343:
  1350. + pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
  1351. + break;
  1352. +
  1353. + case ATH79_SOC_AR7242:
  1354. + /* FIXME */
  1355. +
  1356. + case ATH79_SOC_AR9341:
  1357. + case ATH79_SOC_AR9342:
  1358. + case ATH79_SOC_AR9344:
  1359. + case ATH79_SOC_QCA9533:
  1360. + switch (pdata->phy_if_mode) {
  1361. + case PHY_INTERFACE_MODE_MII:
  1362. + case PHY_INTERFACE_MODE_GMII:
  1363. + break;
  1364. + default:
  1365. + return -EINVAL;
  1366. + }
  1367. + break;
  1368. +
  1369. + case ATH79_SOC_QCA9556:
  1370. + case ATH79_SOC_QCA9558:
  1371. + switch (pdata->phy_if_mode) {
  1372. + case PHY_INTERFACE_MODE_MII:
  1373. + case PHY_INTERFACE_MODE_RGMII:
  1374. + case PHY_INTERFACE_MODE_SGMII:
  1375. + break;
  1376. + default:
  1377. + return -EINVAL;
  1378. + }
  1379. + break;
  1380. +
  1381. + default:
  1382. + BUG();
  1383. + }
  1384. + break;
  1385. + }
  1386. +
  1387. + return 0;
  1388. +}
  1389. +
  1390. +void __init ath79_setup_ar933x_phy4_switch(bool mac, bool mdio)
  1391. +{
  1392. + void __iomem *base;
  1393. + u32 t;
  1394. +
  1395. + base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
  1396. +
  1397. + t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
  1398. + t &= ~(AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
  1399. + if (mac)
  1400. + t |= AR933X_ETH_CFG_SW_PHY_SWAP;
  1401. + if (mdio)
  1402. + t |= AR933X_ETH_CFG_SW_PHY_ADDR_SWAP;
  1403. + __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
  1404. +
  1405. + iounmap(base);
  1406. +}
  1407. +
  1408. +void __init ath79_setup_ar934x_eth_cfg(u32 mask)
  1409. +{
  1410. + void __iomem *base;
  1411. + u32 t;
  1412. +
  1413. + base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
  1414. +
  1415. + t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  1416. +
  1417. + t &= ~(AR934X_ETH_CFG_RGMII_GMAC0 |
  1418. + AR934X_ETH_CFG_MII_GMAC0 |
  1419. + AR934X_ETH_CFG_GMII_GMAC0 |
  1420. + AR934X_ETH_CFG_SW_ONLY_MODE |
  1421. + AR934X_ETH_CFG_SW_PHY_SWAP);
  1422. +
  1423. + t |= mask;
  1424. +
  1425. + __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
  1426. + /* flush write */
  1427. + __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  1428. +
  1429. + iounmap(base);
  1430. +}
  1431. +
  1432. +void __init ath79_setup_ar934x_eth_rx_delay(unsigned int rxd,
  1433. + unsigned int rxdv)
  1434. +{
  1435. + void __iomem *base;
  1436. + u32 t;
  1437. +
  1438. + rxd &= AR934X_ETH_CFG_RXD_DELAY_MASK;
  1439. + rxdv &= AR934X_ETH_CFG_RDV_DELAY_MASK;
  1440. +
  1441. + base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
  1442. +
  1443. + t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  1444. +
  1445. + t &= ~(AR934X_ETH_CFG_RXD_DELAY_MASK << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
  1446. + AR934X_ETH_CFG_RDV_DELAY_MASK << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
  1447. +
  1448. + t |= (rxd << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
  1449. + rxdv << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
  1450. +
  1451. + __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
  1452. + /* flush write */
  1453. + __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  1454. +
  1455. + iounmap(base);
  1456. +}
  1457. +
  1458. +void __init ath79_setup_qca955x_eth_cfg(u32 mask)
  1459. +{
  1460. + void __iomem *base;
  1461. + u32 t;
  1462. +
  1463. + base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  1464. +
  1465. + t = __raw_readl(base + QCA955X_GMAC_REG_ETH_CFG);
  1466. +
  1467. + t &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
  1468. +
  1469. + t |= mask;
  1470. +
  1471. + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  1472. +
  1473. + iounmap(base);
  1474. +}
  1475. +
  1476. +static int ath79_eth_instance __initdata;
  1477. +void __init ath79_register_eth(unsigned int id)
  1478. +{
  1479. + struct platform_device *pdev;
  1480. + struct ag71xx_platform_data *pdata;
  1481. + int err;
  1482. +
  1483. + if (id > 1) {
  1484. + printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
  1485. + return;
  1486. + }
  1487. +
  1488. + ath79_init_eth_pll_data(id);
  1489. +
  1490. + if (id == 0)
  1491. + pdev = &ath79_eth0_device;
  1492. + else
  1493. + pdev = &ath79_eth1_device;
  1494. +
  1495. + pdata = pdev->dev.platform_data;
  1496. +
  1497. + pdata->max_frame_len = 1540;
  1498. + pdata->desc_pktlen_mask = 0xfff;
  1499. +
  1500. + err = ath79_setup_phy_if_mode(id, pdata);
  1501. + if (err) {
  1502. + printk(KERN_ERR
  1503. + "ar71xx: invalid PHY interface mode for GE%u\n", id);
  1504. + return;
  1505. + }
  1506. +
  1507. + switch (ath79_soc) {
  1508. + case ATH79_SOC_AR7130:
  1509. + if (id == 0) {
  1510. + pdata->ddr_flush = ath79_ddr_flush_ge0;
  1511. + pdata->set_speed = ath79_set_speed_ge0;
  1512. + } else {
  1513. + pdata->ddr_flush = ath79_ddr_flush_ge1;
  1514. + pdata->set_speed = ath79_set_speed_ge1;
  1515. + }
  1516. + break;
  1517. +
  1518. + case ATH79_SOC_AR7141:
  1519. + case ATH79_SOC_AR7161:
  1520. + if (id == 0) {
  1521. + pdata->ddr_flush = ath79_ddr_flush_ge0;
  1522. + pdata->set_speed = ath79_set_speed_ge0;
  1523. + } else {
  1524. + pdata->ddr_flush = ath79_ddr_flush_ge1;
  1525. + pdata->set_speed = ath79_set_speed_ge1;
  1526. + }
  1527. + pdata->has_gbit = 1;
  1528. + break;
  1529. +
  1530. + case ATH79_SOC_AR7242:
  1531. + if (id == 0) {
  1532. + pdata->reset_bit |= AR724X_RESET_GE0_MDIO |
  1533. + AR71XX_RESET_GE0_PHY;
  1534. + pdata->ddr_flush = ar724x_ddr_flush_ge0;
  1535. + pdata->set_speed = ar7242_set_speed_ge0;
  1536. + } else {
  1537. + pdata->reset_bit |= AR724X_RESET_GE1_MDIO |
  1538. + AR71XX_RESET_GE1_PHY;
  1539. + pdata->ddr_flush = ar724x_ddr_flush_ge1;
  1540. + pdata->set_speed = ath79_set_speed_dummy;
  1541. + }
  1542. + pdata->has_gbit = 1;
  1543. + pdata->is_ar724x = 1;
  1544. +
  1545. + if (!pdata->fifo_cfg1)
  1546. + pdata->fifo_cfg1 = 0x0010ffff;
  1547. + if (!pdata->fifo_cfg2)
  1548. + pdata->fifo_cfg2 = 0x015500aa;
  1549. + if (!pdata->fifo_cfg3)
  1550. + pdata->fifo_cfg3 = 0x01f00140;
  1551. + break;
  1552. +
  1553. + case ATH79_SOC_AR7241:
  1554. + if (id == 0)
  1555. + pdata->reset_bit |= AR724X_RESET_GE0_MDIO;
  1556. + else
  1557. + pdata->reset_bit |= AR724X_RESET_GE1_MDIO;
  1558. + /* fall through */
  1559. + case ATH79_SOC_AR7240:
  1560. + if (id == 0) {
  1561. + pdata->reset_bit |= AR71XX_RESET_GE0_PHY;
  1562. + pdata->ddr_flush = ar724x_ddr_flush_ge0;
  1563. + pdata->set_speed = ath79_set_speed_dummy;
  1564. +
  1565. + pdata->phy_mask = BIT(4);
  1566. + } else {
  1567. + pdata->reset_bit |= AR71XX_RESET_GE1_PHY;
  1568. + pdata->ddr_flush = ar724x_ddr_flush_ge1;
  1569. + pdata->set_speed = ath79_set_speed_dummy;
  1570. +
  1571. + pdata->speed = SPEED_1000;
  1572. + pdata->duplex = DUPLEX_FULL;
  1573. + pdata->switch_data = &ath79_switch_data;
  1574. +
  1575. + ath79_switch_data.phy_poll_mask |= BIT(4);
  1576. + }
  1577. + pdata->has_gbit = 1;
  1578. + pdata->is_ar724x = 1;
  1579. + if (ath79_soc == ATH79_SOC_AR7240)
  1580. + pdata->is_ar7240 = 1;
  1581. +
  1582. + if (!pdata->fifo_cfg1)
  1583. + pdata->fifo_cfg1 = 0x0010ffff;
  1584. + if (!pdata->fifo_cfg2)
  1585. + pdata->fifo_cfg2 = 0x015500aa;
  1586. + if (!pdata->fifo_cfg3)
  1587. + pdata->fifo_cfg3 = 0x01f00140;
  1588. + break;
  1589. +
  1590. + case ATH79_SOC_AR9130:
  1591. + if (id == 0) {
  1592. + pdata->ddr_flush = ar91xx_ddr_flush_ge0;
  1593. + pdata->set_speed = ar91xx_set_speed_ge0;
  1594. + } else {
  1595. + pdata->ddr_flush = ar91xx_ddr_flush_ge1;
  1596. + pdata->set_speed = ar91xx_set_speed_ge1;
  1597. + }
  1598. + pdata->is_ar91xx = 1;
  1599. + break;
  1600. +
  1601. + case ATH79_SOC_AR9132:
  1602. + if (id == 0) {
  1603. + pdata->ddr_flush = ar91xx_ddr_flush_ge0;
  1604. + pdata->set_speed = ar91xx_set_speed_ge0;
  1605. + } else {
  1606. + pdata->ddr_flush = ar91xx_ddr_flush_ge1;
  1607. + pdata->set_speed = ar91xx_set_speed_ge1;
  1608. + }
  1609. + pdata->is_ar91xx = 1;
  1610. + pdata->has_gbit = 1;
  1611. + break;
  1612. +
  1613. + case ATH79_SOC_AR9330:
  1614. + case ATH79_SOC_AR9331:
  1615. + if (id == 0) {
  1616. + pdata->reset_bit = AR933X_RESET_GE0_MAC |
  1617. + AR933X_RESET_GE0_MDIO;
  1618. + pdata->ddr_flush = ar933x_ddr_flush_ge0;
  1619. + pdata->set_speed = ath79_set_speed_dummy;
  1620. +
  1621. + pdata->phy_mask = BIT(4);
  1622. + } else {
  1623. + pdata->reset_bit = AR933X_RESET_GE1_MAC |
  1624. + AR933X_RESET_GE1_MDIO;
  1625. + pdata->ddr_flush = ar933x_ddr_flush_ge1;
  1626. + pdata->set_speed = ath79_set_speed_dummy;
  1627. +
  1628. + pdata->speed = SPEED_1000;
  1629. + pdata->has_gbit = 1;
  1630. + pdata->duplex = DUPLEX_FULL;
  1631. + pdata->switch_data = &ath79_switch_data;
  1632. +
  1633. + ath79_switch_data.phy_poll_mask |= BIT(4);
  1634. + }
  1635. +
  1636. + pdata->is_ar724x = 1;
  1637. +
  1638. + if (!pdata->fifo_cfg1)
  1639. + pdata->fifo_cfg1 = 0x0010ffff;
  1640. + if (!pdata->fifo_cfg2)
  1641. + pdata->fifo_cfg2 = 0x015500aa;
  1642. + if (!pdata->fifo_cfg3)
  1643. + pdata->fifo_cfg3 = 0x01f00140;
  1644. + break;
  1645. +
  1646. + case ATH79_SOC_AR9341:
  1647. + case ATH79_SOC_AR9342:
  1648. + case ATH79_SOC_AR9344:
  1649. + case ATH79_SOC_QCA9533:
  1650. + if (id == 0) {
  1651. + pdata->reset_bit = AR934X_RESET_GE0_MAC |
  1652. + AR934X_RESET_GE0_MDIO;
  1653. + pdata->set_speed = ar934x_set_speed_ge0;
  1654. + } else {
  1655. + pdata->reset_bit = AR934X_RESET_GE1_MAC |
  1656. + AR934X_RESET_GE1_MDIO;
  1657. + pdata->set_speed = ath79_set_speed_dummy;
  1658. +
  1659. + pdata->switch_data = &ath79_switch_data;
  1660. +
  1661. + /* reset the built-in switch */
  1662. + ath79_device_reset_set(AR934X_RESET_ETH_SWITCH);
  1663. + ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH);
  1664. + }
  1665. +
  1666. + pdata->ddr_flush = ath79_ddr_no_flush;
  1667. + pdata->has_gbit = 1;
  1668. + pdata->is_ar724x = 1;
  1669. +
  1670. + pdata->max_frame_len = SZ_16K - 1;
  1671. + pdata->desc_pktlen_mask = SZ_16K - 1;
  1672. +
  1673. + if (!pdata->fifo_cfg1)
  1674. + pdata->fifo_cfg1 = 0x0010ffff;
  1675. + if (!pdata->fifo_cfg2)
  1676. + pdata->fifo_cfg2 = 0x015500aa;
  1677. + if (!pdata->fifo_cfg3)
  1678. + pdata->fifo_cfg3 = 0x01f00140;
  1679. + break;
  1680. +
  1681. + case ATH79_SOC_QCA9561:
  1682. + case ATH79_SOC_TP9343:
  1683. + if (id == 0) {
  1684. + pdata->reset_bit = AR933X_RESET_GE0_MAC |
  1685. + AR933X_RESET_GE0_MDIO;
  1686. + pdata->set_speed = ath79_set_speed_dummy;
  1687. +
  1688. + if (!pdata->phy_mask)
  1689. + pdata->phy_mask = BIT(4);
  1690. + } else {
  1691. + pdata->reset_bit = AR933X_RESET_GE1_MAC |
  1692. + AR933X_RESET_GE1_MDIO;
  1693. + pdata->set_speed = ath79_set_speed_dummy;
  1694. +
  1695. + pdata->speed = SPEED_1000;
  1696. + pdata->duplex = DUPLEX_FULL;
  1697. + pdata->switch_data = &ath79_switch_data;
  1698. +
  1699. + ath79_switch_data.phy_poll_mask |= BIT(4);
  1700. + }
  1701. +
  1702. + pdata->ddr_flush = ath79_ddr_no_flush;
  1703. + pdata->has_gbit = 1;
  1704. + pdata->is_ar724x = 1;
  1705. +
  1706. + if (!pdata->fifo_cfg1)
  1707. + pdata->fifo_cfg1 = 0x0010ffff;
  1708. + if (!pdata->fifo_cfg2)
  1709. + pdata->fifo_cfg2 = 0x015500aa;
  1710. + if (!pdata->fifo_cfg3)
  1711. + pdata->fifo_cfg3 = 0x01f00140;
  1712. + break;
  1713. +
  1714. + case ATH79_SOC_QCA9556:
  1715. + case ATH79_SOC_QCA9558:
  1716. + if (id == 0) {
  1717. + pdata->reset_bit = QCA955X_RESET_GE0_MAC |
  1718. + QCA955X_RESET_GE0_MDIO;
  1719. + pdata->set_speed = qca955x_set_speed_xmii;
  1720. + } else {
  1721. + pdata->reset_bit = QCA955X_RESET_GE1_MAC |
  1722. + QCA955X_RESET_GE1_MDIO;
  1723. + pdata->set_speed = qca955x_set_speed_sgmii;
  1724. + }
  1725. +
  1726. + pdata->ddr_flush = ath79_ddr_no_flush;
  1727. + pdata->has_gbit = 1;
  1728. + pdata->is_ar724x = 1;
  1729. +
  1730. + /*
  1731. + * Limit the maximum frame length to 4095 bytes.
  1732. + * Although the documentation says that the hardware
  1733. + * limit is 16383 bytes but that does not work in
  1734. + * practice. It seems that the hardware only updates
  1735. + * the lowest 12 bits of the packet length field
  1736. + * in the RX descriptor.
  1737. + */
  1738. + pdata->max_frame_len = SZ_4K - 1;
  1739. + pdata->desc_pktlen_mask = SZ_16K - 1;
  1740. +
  1741. + if (!pdata->fifo_cfg1)
  1742. + pdata->fifo_cfg1 = 0x0010ffff;
  1743. + if (!pdata->fifo_cfg2)
  1744. + pdata->fifo_cfg2 = 0x015500aa;
  1745. + if (!pdata->fifo_cfg3)
  1746. + pdata->fifo_cfg3 = 0x01f00140;
  1747. + break;
  1748. +
  1749. + default:
  1750. + BUG();
  1751. + }
  1752. +
  1753. + switch (pdata->phy_if_mode) {
  1754. + case PHY_INTERFACE_MODE_GMII:
  1755. + case PHY_INTERFACE_MODE_RGMII:
  1756. + case PHY_INTERFACE_MODE_SGMII:
  1757. + if (!pdata->has_gbit) {
  1758. + printk(KERN_ERR "ar71xx: no gbit available on eth%d\n",
  1759. + id);
  1760. + return;
  1761. + }
  1762. + /* fallthrough */
  1763. + default:
  1764. + break;
  1765. + }
  1766. +
  1767. + if (!is_valid_ether_addr(pdata->mac_addr)) {
  1768. + random_ether_addr(pdata->mac_addr);
  1769. + printk(KERN_DEBUG
  1770. + "ar71xx: using random MAC address for eth%d\n",
  1771. + ath79_eth_instance);
  1772. + }
  1773. +
  1774. + if (pdata->mii_bus_dev == NULL) {
  1775. + switch (ath79_soc) {
  1776. + case ATH79_SOC_AR9341:
  1777. + case ATH79_SOC_AR9342:
  1778. + case ATH79_SOC_AR9344:
  1779. + if (id == 0)
  1780. + pdata->mii_bus_dev = &ath79_mdio0_device.dev;
  1781. + else
  1782. + pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  1783. + break;
  1784. +
  1785. + case ATH79_SOC_AR7241:
  1786. + case ATH79_SOC_AR9330:
  1787. + case ATH79_SOC_AR9331:
  1788. + case ATH79_SOC_QCA9533:
  1789. + case ATH79_SOC_QCA9561:
  1790. + case ATH79_SOC_TP9343:
  1791. + pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  1792. + break;
  1793. +
  1794. + case ATH79_SOC_QCA9556:
  1795. + case ATH79_SOC_QCA9558:
  1796. + /* don't assign any MDIO device by default */
  1797. + break;
  1798. +
  1799. + default:
  1800. + pdata->mii_bus_dev = &ath79_mdio0_device.dev;
  1801. + break;
  1802. + }
  1803. + }
  1804. +
  1805. + /* Reset the device */
  1806. + ath79_device_reset_set(pdata->reset_bit);
  1807. + msleep(100);
  1808. +
  1809. + ath79_device_reset_clear(pdata->reset_bit);
  1810. + msleep(100);
  1811. +
  1812. + platform_device_register(pdev);
  1813. + ath79_eth_instance++;
  1814. +}
  1815. +
  1816. +void __init ath79_set_mac_base(unsigned char *mac)
  1817. +{
  1818. + memcpy(ath79_mac_base, mac, ETH_ALEN);
  1819. +}
  1820. +
  1821. +void __init ath79_parse_ascii_mac(char *mac_str, u8 *mac)
  1822. +{
  1823. + int t;
  1824. +
  1825. + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
  1826. + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  1827. +
  1828. + if (t != ETH_ALEN)
  1829. + t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
  1830. + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  1831. +
  1832. + if (t != ETH_ALEN || !is_valid_ether_addr(mac)) {
  1833. + memset(mac, 0, ETH_ALEN);
  1834. + printk(KERN_DEBUG "ar71xx: invalid mac address \"%s\"\n",
  1835. + mac_str);
  1836. + }
  1837. +}
  1838. +
  1839. +static void __init ath79_set_mac_base_ascii(char *str)
  1840. +{
  1841. + u8 mac[ETH_ALEN];
  1842. +
  1843. + ath79_parse_ascii_mac(str, mac);
  1844. + ath79_set_mac_base(mac);
  1845. +}
  1846. +
  1847. +static int __init ath79_ethaddr_setup(char *str)
  1848. +{
  1849. + ath79_set_mac_base_ascii(str);
  1850. + return 1;
  1851. +}
  1852. +__setup("ethaddr=", ath79_ethaddr_setup);
  1853. +
  1854. +static int __init ath79_kmac_setup(char *str)
  1855. +{
  1856. + ath79_set_mac_base_ascii(str);
  1857. + return 1;
  1858. +}
  1859. +__setup("kmac=", ath79_kmac_setup);
  1860. +
  1861. +void __init ath79_init_mac(unsigned char *dst, const unsigned char *src,
  1862. + int offset)
  1863. +{
  1864. + int t;
  1865. +
  1866. + if (!dst)
  1867. + return;
  1868. +
  1869. + if (!src || !is_valid_ether_addr(src)) {
  1870. + memset(dst, '\0', ETH_ALEN);
  1871. + return;
  1872. + }
  1873. +
  1874. + t = (((u32) src[3]) << 16) + (((u32) src[4]) << 8) + ((u32) src[5]);
  1875. + t += offset;
  1876. +
  1877. + dst[0] = src[0];
  1878. + dst[1] = src[1];
  1879. + dst[2] = src[2];
  1880. + dst[3] = (t >> 16) & 0xff;
  1881. + dst[4] = (t >> 8) & 0xff;
  1882. + dst[5] = t & 0xff;
  1883. +}
  1884. +
  1885. +void __init ath79_init_local_mac(unsigned char *dst, const unsigned char *src)
  1886. +{
  1887. + int i;
  1888. +
  1889. + if (!dst)
  1890. + return;
  1891. +
  1892. + if (!src || !is_valid_ether_addr(src)) {
  1893. + memset(dst, '\0', ETH_ALEN);
  1894. + return;
  1895. + }
  1896. +
  1897. + for (i = 0; i < ETH_ALEN; i++)
  1898. + dst[i] = src[i];
  1899. + dst[0] |= 0x02;
  1900. +}
  1901. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-eth.h linux-4.1.13/arch/mips/ath79/dev-eth.h
  1902. --- linux-4.1.13.orig/arch/mips/ath79/dev-eth.h 1970-01-01 01:00:00.000000000 +0100
  1903. +++ linux-4.1.13/arch/mips/ath79/dev-eth.h 2015-09-13 20:04:35.064524285 +0200
  1904. @@ -0,0 +1,53 @@
  1905. +/*
  1906. + * Atheros AR71xx SoC device definitions
  1907. + *
  1908. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  1909. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1910. + *
  1911. + * This program is free software; you can redistribute it and/or modify it
  1912. + * under the terms of the GNU General Public License version 2 as published
  1913. + * by the Free Software Foundation.
  1914. + */
  1915. +
  1916. +#ifndef _ATH79_DEV_ETH_H
  1917. +#define _ATH79_DEV_ETH_H
  1918. +
  1919. +#include <asm/mach-ath79/ag71xx_platform.h>
  1920. +
  1921. +struct platform_device;
  1922. +
  1923. +extern unsigned char ath79_mac_base[] __initdata;
  1924. +void ath79_parse_ascii_mac(char *mac_str, u8 *mac);
  1925. +void ath79_init_mac(unsigned char *dst, const unsigned char *src,
  1926. + int offset);
  1927. +void ath79_init_local_mac(unsigned char *dst, const unsigned char *src);
  1928. +
  1929. +struct ath79_eth_pll_data {
  1930. + u32 pll_10;
  1931. + u32 pll_100;
  1932. + u32 pll_1000;
  1933. +};
  1934. +
  1935. +extern struct ath79_eth_pll_data ath79_eth0_pll_data;
  1936. +extern struct ath79_eth_pll_data ath79_eth1_pll_data;
  1937. +
  1938. +extern struct ag71xx_platform_data ath79_eth0_data;
  1939. +extern struct ag71xx_platform_data ath79_eth1_data;
  1940. +extern struct platform_device ath79_eth0_device;
  1941. +extern struct platform_device ath79_eth1_device;
  1942. +void ath79_register_eth(unsigned int id);
  1943. +
  1944. +extern struct ag71xx_switch_platform_data ath79_switch_data;
  1945. +
  1946. +extern struct ag71xx_mdio_platform_data ath79_mdio0_data;
  1947. +extern struct ag71xx_mdio_platform_data ath79_mdio1_data;
  1948. +extern struct platform_device ath79_mdio0_device;
  1949. +extern struct platform_device ath79_mdio1_device;
  1950. +void ath79_register_mdio(unsigned int id, u32 phy_mask);
  1951. +
  1952. +void ath79_setup_ar933x_phy4_switch(bool mac, bool mdio);
  1953. +void ath79_setup_ar934x_eth_cfg(u32 mask);
  1954. +void ath79_setup_ar934x_eth_rx_delay(unsigned int rxd, unsigned int rxdv);
  1955. +void ath79_setup_qca955x_eth_cfg(u32 mask);
  1956. +
  1957. +#endif /* _ATH79_DEV_ETH_H */
  1958. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-m25p80.c linux-4.1.13/arch/mips/ath79/dev-m25p80.c
  1959. --- linux-4.1.13.orig/arch/mips/ath79/dev-m25p80.c 1970-01-01 01:00:00.000000000 +0100
  1960. +++ linux-4.1.13/arch/mips/ath79/dev-m25p80.c 2015-09-13 20:04:35.064524285 +0200
  1961. @@ -0,0 +1,118 @@
  1962. +/*
  1963. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  1964. + *
  1965. + * This program is free software; you can redistribute it and/or modify it
  1966. + * under the terms of the GNU General Public License version 2 as published
  1967. + * by the Free Software Foundation.
  1968. + */
  1969. +
  1970. +#include <linux/init.h>
  1971. +#include <linux/spi/spi.h>
  1972. +#include <linux/spi/flash.h>
  1973. +#include <linux/mtd/mtd.h>
  1974. +#include <linux/mtd/partitions.h>
  1975. +#include <linux/mtd/concat.h>
  1976. +
  1977. +#include "dev-spi.h"
  1978. +#include "dev-m25p80.h"
  1979. +
  1980. +static struct ath79_spi_controller_data ath79_spi0_cdata =
  1981. +{
  1982. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  1983. + .cs_line = 0,
  1984. +};
  1985. +
  1986. +static struct ath79_spi_controller_data ath79_spi1_cdata =
  1987. +{
  1988. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  1989. + .cs_line = 1,
  1990. +};
  1991. +
  1992. +static struct spi_board_info ath79_spi_info[] = {
  1993. + {
  1994. + .bus_num = 0,
  1995. + .chip_select = 0,
  1996. + .max_speed_hz = 25000000,
  1997. + .modalias = "m25p80",
  1998. + .controller_data = &ath79_spi0_cdata,
  1999. + },
  2000. + {
  2001. + .bus_num = 0,
  2002. + .chip_select = 1,
  2003. + .max_speed_hz = 25000000,
  2004. + .modalias = "m25p80",
  2005. + .controller_data = &ath79_spi1_cdata,
  2006. + }
  2007. +};
  2008. +
  2009. +static struct ath79_spi_platform_data ath79_spi_data;
  2010. +
  2011. +void __init ath79_register_m25p80(struct flash_platform_data *pdata)
  2012. +{
  2013. + ath79_spi_data.bus_num = 0;
  2014. + ath79_spi_data.num_chipselect = 1;
  2015. + ath79_spi0_cdata.is_flash = true;
  2016. + ath79_spi_info[0].platform_data = pdata;
  2017. + ath79_register_spi(&ath79_spi_data, ath79_spi_info, 1);
  2018. +}
  2019. +
  2020. +static struct flash_platform_data *multi_pdata;
  2021. +
  2022. +static struct mtd_info *concat_devs[2] = { NULL, NULL };
  2023. +static struct work_struct mtd_concat_work;
  2024. +
  2025. +static void mtd_concat_add_work(struct work_struct *work)
  2026. +{
  2027. + struct mtd_info *mtd;
  2028. +
  2029. + mtd = mtd_concat_create(concat_devs, ARRAY_SIZE(concat_devs), "flash");
  2030. +
  2031. + mtd_device_register(mtd, multi_pdata->parts, multi_pdata->nr_parts);
  2032. +}
  2033. +
  2034. +static void mtd_concat_add(struct mtd_info *mtd)
  2035. +{
  2036. + static bool registered = false;
  2037. +
  2038. + if (registered)
  2039. + return;
  2040. +
  2041. + if (!strcmp(mtd->name, "spi0.0"))
  2042. + concat_devs[0] = mtd;
  2043. + else if (!strcmp(mtd->name, "spi0.1"))
  2044. + concat_devs[1] = mtd;
  2045. + else
  2046. + return;
  2047. +
  2048. + if (!concat_devs[0] || !concat_devs[1])
  2049. + return;
  2050. +
  2051. + registered = true;
  2052. + INIT_WORK(&mtd_concat_work, mtd_concat_add_work);
  2053. + schedule_work(&mtd_concat_work);
  2054. +}
  2055. +
  2056. +static void mtd_concat_remove(struct mtd_info *mtd)
  2057. +{
  2058. +}
  2059. +
  2060. +static void add_mtd_concat_notifier(void)
  2061. +{
  2062. + static struct mtd_notifier not = {
  2063. + .add = mtd_concat_add,
  2064. + .remove = mtd_concat_remove,
  2065. + };
  2066. +
  2067. + register_mtd_user(&not);
  2068. +}
  2069. +
  2070. +
  2071. +void __init ath79_register_m25p80_multi(struct flash_platform_data *pdata)
  2072. +{
  2073. + multi_pdata = pdata;
  2074. + add_mtd_concat_notifier();
  2075. + ath79_spi_data.bus_num = 0;
  2076. + ath79_spi_data.num_chipselect = 2;
  2077. + ath79_spi0_cdata.is_flash = true;
  2078. + ath79_register_spi(&ath79_spi_data, ath79_spi_info, 2);
  2079. +}
  2080. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-m25p80.h linux-4.1.13/arch/mips/ath79/dev-m25p80.h
  2081. --- linux-4.1.13.orig/arch/mips/ath79/dev-m25p80.h 1970-01-01 01:00:00.000000000 +0100
  2082. +++ linux-4.1.13/arch/mips/ath79/dev-m25p80.h 2015-09-13 20:04:35.064524285 +0200
  2083. @@ -0,0 +1,17 @@
  2084. +/*
  2085. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  2086. + *
  2087. + * This program is free software; you can redistribute it and/or modify it
  2088. + * under the terms of the GNU General Public License version 2 as published
  2089. + * by the Free Software Foundation.
  2090. + */
  2091. +
  2092. +#ifndef _ATH79_DEV_M25P80_H
  2093. +#define _ATH79_DEV_M25P80_H
  2094. +
  2095. +#include <linux/spi/flash.h>
  2096. +
  2097. +void ath79_register_m25p80(struct flash_platform_data *pdata) __init;
  2098. +void ath79_register_m25p80_multi(struct flash_platform_data *pdata) __init;
  2099. +
  2100. +#endif /* _ATH79_DEV_M25P80_H */
  2101. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-nfc.c linux-4.1.13/arch/mips/ath79/dev-nfc.c
  2102. --- linux-4.1.13.orig/arch/mips/ath79/dev-nfc.c 1970-01-01 01:00:00.000000000 +0100
  2103. +++ linux-4.1.13/arch/mips/ath79/dev-nfc.c 2015-09-13 20:04:35.064524285 +0200
  2104. @@ -0,0 +1,141 @@
  2105. +/*
  2106. + * Atheros AR934X SoCs built-in NAND flash controller support
  2107. + *
  2108. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  2109. + *
  2110. + * This program is free software; you can redistribute it and/or modify it
  2111. + * under the terms of the GNU General Public License version 2 as published
  2112. + * by the Free Software Foundation.
  2113. + */
  2114. +
  2115. +#include <linux/kernel.h>
  2116. +#include <linux/delay.h>
  2117. +#include <linux/init.h>
  2118. +#include <linux/irq.h>
  2119. +#include <linux/dma-mapping.h>
  2120. +#include <linux/etherdevice.h>
  2121. +#include <linux/platform_device.h>
  2122. +#include <linux/platform/ar934x_nfc.h>
  2123. +
  2124. +#include <asm/mach-ath79/ath79.h>
  2125. +#include <asm/mach-ath79/ar71xx_regs.h>
  2126. +
  2127. +#include "dev-nfc.h"
  2128. +
  2129. +static struct resource ath79_nfc_resources[2];
  2130. +static u64 ar934x_nfc_dmamask = DMA_BIT_MASK(32);
  2131. +static struct ar934x_nfc_platform_data ath79_nfc_data;
  2132. +
  2133. +static struct platform_device ath79_nfc_device = {
  2134. + .name = AR934X_NFC_DRIVER_NAME,
  2135. + .id = -1,
  2136. + .resource = ath79_nfc_resources,
  2137. + .num_resources = ARRAY_SIZE(ath79_nfc_resources),
  2138. + .dev = {
  2139. + .dma_mask = &ar934x_nfc_dmamask,
  2140. + .coherent_dma_mask = DMA_BIT_MASK(32),
  2141. + .platform_data = &ath79_nfc_data,
  2142. + },
  2143. +};
  2144. +
  2145. +static void __init ath79_nfc_init_resource(struct resource res[2],
  2146. + unsigned long base,
  2147. + unsigned long size,
  2148. + int irq)
  2149. +{
  2150. + memset(res, 0, sizeof(struct resource) * 2);
  2151. +
  2152. + res[0].flags = IORESOURCE_MEM;
  2153. + res[0].start = base;
  2154. + res[0].end = base + size - 1;
  2155. +
  2156. + res[1].flags = IORESOURCE_IRQ;
  2157. + res[1].start = irq;
  2158. + res[1].end = irq;
  2159. +}
  2160. +
  2161. +static void ar934x_nfc_hw_reset(bool active)
  2162. +{
  2163. + if (active) {
  2164. + ath79_device_reset_set(AR934X_RESET_NANDF);
  2165. + udelay(100);
  2166. +
  2167. + ath79_device_reset_set(AR934X_RESET_ETH_SWITCH_ANALOG);
  2168. + udelay(250);
  2169. + } else {
  2170. + ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH_ANALOG);
  2171. + udelay(250);
  2172. +
  2173. + ath79_device_reset_clear(AR934X_RESET_NANDF);
  2174. + udelay(100);
  2175. + }
  2176. +}
  2177. +
  2178. +static void ar934x_nfc_setup(void)
  2179. +{
  2180. + ath79_nfc_data.hw_reset = ar934x_nfc_hw_reset;
  2181. +
  2182. + ath79_nfc_init_resource(ath79_nfc_resources,
  2183. + AR934X_NFC_BASE, AR934X_NFC_SIZE,
  2184. + ATH79_MISC_IRQ(21));
  2185. +
  2186. + platform_device_register(&ath79_nfc_device);
  2187. +}
  2188. +
  2189. +static void qca955x_nfc_hw_reset(bool active)
  2190. +{
  2191. + if (active) {
  2192. + ath79_device_reset_set(QCA955X_RESET_NANDF);
  2193. + udelay(250);
  2194. + } else {
  2195. + ath79_device_reset_clear(QCA955X_RESET_NANDF);
  2196. + udelay(100);
  2197. + }
  2198. +}
  2199. +
  2200. +static void qca955x_nfc_setup(void)
  2201. +{
  2202. + ath79_nfc_data.hw_reset = qca955x_nfc_hw_reset;
  2203. +
  2204. + ath79_nfc_init_resource(ath79_nfc_resources,
  2205. + QCA955X_NFC_BASE, QCA955X_NFC_SIZE,
  2206. + ATH79_MISC_IRQ(21));
  2207. +
  2208. + platform_device_register(&ath79_nfc_device);
  2209. +}
  2210. +
  2211. +void __init ath79_nfc_set_select_chip(void (*f)(int chip_no))
  2212. +{
  2213. + ath79_nfc_data.select_chip = f;
  2214. +}
  2215. +
  2216. +void __init ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd))
  2217. +{
  2218. + ath79_nfc_data.scan_fixup = f;
  2219. +}
  2220. +
  2221. +void __init ath79_nfc_set_swap_dma(bool enable)
  2222. +{
  2223. + ath79_nfc_data.swap_dma = enable;
  2224. +}
  2225. +
  2226. +void __init ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode)
  2227. +{
  2228. + ath79_nfc_data.ecc_mode = mode;
  2229. +}
  2230. +
  2231. +void __init ath79_nfc_set_parts(struct mtd_partition *parts, int nr_parts)
  2232. +{
  2233. + ath79_nfc_data.parts = parts;
  2234. + ath79_nfc_data.nr_parts = nr_parts;
  2235. +}
  2236. +
  2237. +void __init ath79_register_nfc(void)
  2238. +{
  2239. + if (soc_is_ar934x())
  2240. + ar934x_nfc_setup();
  2241. + else if (soc_is_qca955x())
  2242. + qca955x_nfc_setup();
  2243. + else
  2244. + BUG();
  2245. +}
  2246. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-nfc.h linux-4.1.13/arch/mips/ath79/dev-nfc.h
  2247. --- linux-4.1.13.orig/arch/mips/ath79/dev-nfc.h 1970-01-01 01:00:00.000000000 +0100
  2248. +++ linux-4.1.13/arch/mips/ath79/dev-nfc.h 2015-09-13 20:04:35.064524285 +0200
  2249. @@ -0,0 +1,34 @@
  2250. +/*
  2251. + * Atheros AR934X SoCs built-in NAND Flash Controller support
  2252. + *
  2253. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  2254. + *
  2255. + * This program is free software; you can redistribute it and/or modify it
  2256. + * under the terms of the GNU General Public License version 2 as published
  2257. + * by the Free Software Foundation.
  2258. + */
  2259. +
  2260. +#ifndef _ATH79_DEV_NFC_H
  2261. +#define _ATH79_DEV_NFC_H
  2262. +
  2263. +struct mtd_partition;
  2264. +enum ar934x_nfc_ecc_mode;
  2265. +
  2266. +#ifdef CONFIG_ATH79_DEV_NFC
  2267. +void ath79_nfc_set_parts(struct mtd_partition *parts, int nr_parts);
  2268. +void ath79_nfc_set_select_chip(void (*f)(int chip_no));
  2269. +void ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd));
  2270. +void ath79_nfc_set_swap_dma(bool enable);
  2271. +void ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode);
  2272. +void ath79_register_nfc(void);
  2273. +#else
  2274. +static inline void ath79_nfc_set_parts(struct mtd_partition *parts,
  2275. + int nr_parts) {}
  2276. +static inline void ath79_nfc_set_select_chip(void (*f)(int chip_no)) {}
  2277. +static inline void ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd)) {}
  2278. +static inline void ath79_nfc_set_swap_dma(bool enable) {}
  2279. +static inline void ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode) {}
  2280. +static inline void ath79_register_nfc(void) {}
  2281. +#endif
  2282. +
  2283. +#endif /* _ATH79_DEV_NFC_H */
  2284. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-usb.c linux-4.1.13/arch/mips/ath79/dev-usb.c
  2285. --- linux-4.1.13.orig/arch/mips/ath79/dev-usb.c 2015-11-09 23:34:10.000000000 +0100
  2286. +++ linux-4.1.13/arch/mips/ath79/dev-usb.c 2015-12-04 19:57:04.478071913 +0100
  2287. @@ -37,6 +37,8 @@
  2288. static struct usb_ehci_pdata ath79_ehci_pdata_v2 = {
  2289. .caps_offset = 0x100,
  2290. .has_tt = 1,
  2291. + .qca_force_host_mode = 1,
  2292. + .qca_force_16bit_ptw = 1,
  2293. };
  2294. static void __init ath79_usb_register(const char *name, int id,
  2295. @@ -159,6 +161,9 @@
  2296. ath79_device_reset_clear(AR913X_RESET_USB_PHY);
  2297. mdelay(10);
  2298. + ath79_ehci_pdata_v2.qca_force_host_mode = 0;
  2299. + ath79_ehci_pdata_v2.qca_force_16bit_ptw = 0;
  2300. +
  2301. ath79_usb_register("ehci-platform", -1,
  2302. AR913X_EHCI_BASE, AR913X_EHCI_SIZE,
  2303. ATH79_CPU_IRQ(3),
  2304. @@ -182,14 +187,34 @@
  2305. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2306. }
  2307. -static void __init ar934x_usb_setup(void)
  2308. +static void enable_tx_tx_idp_violation_fix(unsigned base)
  2309. {
  2310. - u32 bootstrap;
  2311. + void __iomem *phy_reg;
  2312. + u32 t;
  2313. - bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
  2314. - if (bootstrap & AR934X_BOOTSTRAP_USB_MODE_DEVICE)
  2315. + phy_reg = ioremap(base, 4);
  2316. + if (!phy_reg)
  2317. return;
  2318. + t = ioread32(phy_reg);
  2319. + t &= ~0xff;
  2320. + t |= 0x58;
  2321. + iowrite32(t, phy_reg);
  2322. +
  2323. + iounmap(phy_reg);
  2324. +}
  2325. +
  2326. +static void ar934x_usb_reset_notifier(struct platform_device *pdev)
  2327. +{
  2328. + if (pdev->id != -1)
  2329. + return;
  2330. +
  2331. + enable_tx_tx_idp_violation_fix(0x18116c94);
  2332. + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
  2333. +}
  2334. +
  2335. +static void __init ar934x_usb_setup(void)
  2336. +{
  2337. ath79_device_reset_set(AR934X_RESET_USBSUS_OVERRIDE);
  2338. udelay(1000);
  2339. @@ -202,14 +227,64 @@
  2340. ath79_device_reset_clear(AR934X_RESET_USB_HOST);
  2341. udelay(1000);
  2342. + if (ath79_soc_rev >= 3)
  2343. + ath79_ehci_pdata_v2.reset_notifier = ar934x_usb_reset_notifier;
  2344. +
  2345. ath79_usb_register("ehci-platform", -1,
  2346. AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
  2347. ATH79_CPU_IRQ(3),
  2348. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2349. }
  2350. +static void __init qca953x_usb_setup(void)
  2351. +{
  2352. + u32 bootstrap;
  2353. +
  2354. + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  2355. +
  2356. + ath79_device_reset_set(QCA953X_RESET_USBSUS_OVERRIDE);
  2357. + udelay(1000);
  2358. +
  2359. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY);
  2360. + udelay(1000);
  2361. +
  2362. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY_ANALOG);
  2363. + udelay(1000);
  2364. +
  2365. + ath79_device_reset_clear(QCA953X_RESET_USB_HOST);
  2366. + udelay(1000);
  2367. +
  2368. + ath79_usb_register("ehci-platform", -1,
  2369. + QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,
  2370. + ATH79_CPU_IRQ(3),
  2371. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2372. +}
  2373. +
  2374. +static void qca955x_usb_reset_notifier(struct platform_device *pdev)
  2375. +{
  2376. + u32 base;
  2377. +
  2378. + switch (pdev->id) {
  2379. + case 0:
  2380. + base = 0x18116c94;
  2381. + break;
  2382. +
  2383. + case 1:
  2384. + base = 0x18116e54;
  2385. + break;
  2386. +
  2387. + default:
  2388. + return;
  2389. + }
  2390. +
  2391. + enable_tx_tx_idp_violation_fix(base);
  2392. + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
  2393. +}
  2394. +
  2395. static void __init qca955x_usb_setup(void)
  2396. {
  2397. + ath79_ehci_pdata_v2.reset_notifier = qca955x_usb_reset_notifier;
  2398. +
  2399. ath79_usb_register("ehci-platform", 0,
  2400. QCA955X_EHCI0_BASE, QCA955X_EHCI_SIZE,
  2401. ATH79_IP3_IRQ(0),
  2402. @@ -221,6 +296,19 @@
  2403. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2404. }
  2405. +static void __init qca956x_usb_setup(void)
  2406. +{
  2407. + ath79_usb_register("ehci-platform", 0,
  2408. + QCA956X_EHCI0_BASE, QCA956X_EHCI_SIZE,
  2409. + ATH79_IP3_IRQ(0),
  2410. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2411. +
  2412. + ath79_usb_register("ehci-platform", 1,
  2413. + QCA956X_EHCI1_BASE, QCA956X_EHCI_SIZE,
  2414. + ATH79_IP3_IRQ(1),
  2415. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  2416. +}
  2417. +
  2418. void __init ath79_register_usb(void)
  2419. {
  2420. if (soc_is_ar71xx())
  2421. @@ -235,8 +323,12 @@
  2422. ar933x_usb_setup();
  2423. else if (soc_is_ar934x())
  2424. ar934x_usb_setup();
  2425. + else if (soc_is_qca953x())
  2426. + qca953x_usb_setup();
  2427. else if (soc_is_qca955x())
  2428. qca955x_usb_setup();
  2429. + else if (soc_is_qca9561())
  2430. + qca956x_usb_setup();
  2431. else
  2432. BUG();
  2433. }
  2434. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-wmac.c linux-4.1.13/arch/mips/ath79/dev-wmac.c
  2435. --- linux-4.1.13.orig/arch/mips/ath79/dev-wmac.c 2015-11-09 23:34:10.000000000 +0100
  2436. +++ linux-4.1.13/arch/mips/ath79/dev-wmac.c 2015-12-04 19:57:04.506070082 +0100
  2437. @@ -15,14 +15,21 @@
  2438. #include <linux/init.h>
  2439. #include <linux/delay.h>
  2440. #include <linux/irq.h>
  2441. +#include <linux/etherdevice.h>
  2442. #include <linux/platform_device.h>
  2443. #include <linux/ath9k_platform.h>
  2444. +#include <linux/gpio.h>
  2445. #include <asm/mach-ath79/ath79.h>
  2446. #include <asm/mach-ath79/ar71xx_regs.h>
  2447. +#include "common.h"
  2448. #include "dev-wmac.h"
  2449. -static struct ath9k_platform_data ath79_wmac_data;
  2450. +static u8 ath79_wmac_mac[ETH_ALEN];
  2451. +
  2452. +static struct ath9k_platform_data ath79_wmac_data = {
  2453. + .led_pin = -1,
  2454. +};
  2455. static struct resource ath79_wmac_resources[] = {
  2456. {
  2457. @@ -44,7 +51,7 @@
  2458. },
  2459. };
  2460. -static void __init ar913x_wmac_setup(void)
  2461. +static int ar913x_wmac_reset(void)
  2462. {
  2463. /* reset the WMAC */
  2464. ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
  2465. @@ -53,22 +60,48 @@
  2466. ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
  2467. mdelay(10);
  2468. + return 0;
  2469. +}
  2470. +
  2471. +static void __init ar913x_wmac_setup(void)
  2472. +{
  2473. + ar913x_wmac_reset();
  2474. +
  2475. ath79_wmac_resources[0].start = AR913X_WMAC_BASE;
  2476. ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1;
  2477. ath79_wmac_resources[1].start = ATH79_CPU_IRQ(2);
  2478. ath79_wmac_resources[1].end = ATH79_CPU_IRQ(2);
  2479. +
  2480. + ath79_wmac_data.external_reset = ar913x_wmac_reset;
  2481. }
  2482. static int ar933x_wmac_reset(void)
  2483. {
  2484. + int retries = 20;
  2485. +
  2486. ath79_device_reset_set(AR933X_RESET_WMAC);
  2487. ath79_device_reset_clear(AR933X_RESET_WMAC);
  2488. - return 0;
  2489. + while (1) {
  2490. + u32 bootstrap;
  2491. +
  2492. + bootstrap = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  2493. + if ((bootstrap & AR933X_BOOTSTRAP_EEPBUSY) == 0)
  2494. + return 0;
  2495. +
  2496. + if (retries-- == 0)
  2497. + break;
  2498. +
  2499. + udelay(10000);
  2500. + retries++;
  2501. + }
  2502. +
  2503. + pr_err("ar933x: WMAC reset timed out");
  2504. + return -ETIMEDOUT;
  2505. }
  2506. -static int ar933x_r1_get_wmac_revision(void)
  2507. +static int ar93xx_get_soc_revision(void)
  2508. {
  2509. return ath79_soc_rev;
  2510. }
  2511. @@ -93,7 +126,7 @@
  2512. ath79_wmac_data.is_clk_25mhz = true;
  2513. if (ath79_soc_rev == 1)
  2514. - ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision;
  2515. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  2516. ath79_wmac_data.external_reset = ar933x_wmac_reset;
  2517. }
  2518. @@ -114,6 +147,28 @@
  2519. ath79_wmac_data.is_clk_25mhz = false;
  2520. else
  2521. ath79_wmac_data.is_clk_25mhz = true;
  2522. +
  2523. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  2524. +}
  2525. +
  2526. +static void qca953x_wmac_setup(void)
  2527. +{
  2528. + u32 t;
  2529. +
  2530. + ath79_wmac_device.name = "qca953x_wmac";
  2531. +
  2532. + ath79_wmac_resources[0].start = QCA953X_WMAC_BASE;
  2533. + ath79_wmac_resources[0].end = QCA953X_WMAC_BASE + QCA953X_WMAC_SIZE - 1;
  2534. + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
  2535. + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
  2536. +
  2537. + t = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  2538. + if (t & QCA953X_BOOTSTRAP_REF_CLK_40)
  2539. + ath79_wmac_data.is_clk_25mhz = false;
  2540. + else
  2541. + ath79_wmac_data.is_clk_25mhz = true;
  2542. +
  2543. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  2544. }
  2545. static void qca955x_wmac_setup(void)
  2546. @@ -134,7 +189,221 @@
  2547. ath79_wmac_data.is_clk_25mhz = true;
  2548. }
  2549. -void __init ath79_register_wmac(u8 *cal_data)
  2550. +static void qca956x_wmac_setup(void)
  2551. +{
  2552. + u32 t;
  2553. +
  2554. + ath79_wmac_device.name = "qca956x_wmac";
  2555. +
  2556. + ath79_wmac_resources[0].start = QCA956X_WMAC_BASE;
  2557. + ath79_wmac_resources[0].end = QCA956X_WMAC_BASE + QCA956X_WMAC_SIZE - 1;
  2558. + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
  2559. + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
  2560. +
  2561. + t = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
  2562. + if (t & QCA956X_BOOTSTRAP_REF_CLK_40)
  2563. + ath79_wmac_data.is_clk_25mhz = false;
  2564. + else
  2565. + ath79_wmac_data.is_clk_25mhz = true;
  2566. +}
  2567. +
  2568. +static bool __init
  2569. +ar93xx_wmac_otp_read_word(void __iomem *base, int addr, u32 *data)
  2570. +{
  2571. + int timeout = 1000;
  2572. + u32 val;
  2573. +
  2574. + __raw_readl(base + AR9300_OTP_BASE + (4 * addr));
  2575. + while (timeout--) {
  2576. + val = __raw_readl(base + AR9300_OTP_STATUS);
  2577. + if ((val & AR9300_OTP_STATUS_TYPE) == AR9300_OTP_STATUS_VALID)
  2578. + break;
  2579. +
  2580. + udelay(10);
  2581. + }
  2582. +
  2583. + if (!timeout)
  2584. + return false;
  2585. +
  2586. + *data = __raw_readl(base + AR9300_OTP_READ_DATA);
  2587. + return true;
  2588. +}
  2589. +
  2590. +static bool __init
  2591. +ar93xx_wmac_otp_read(void __iomem *base, int addr, u8 *dest, int len)
  2592. +{
  2593. + u32 data;
  2594. + int i;
  2595. +
  2596. + for (i = 0; i < len; i++) {
  2597. + int offset = 8 * ((addr - i) % 4);
  2598. +
  2599. + if (!ar93xx_wmac_otp_read_word(base, (addr - i) / 4, &data))
  2600. + return false;
  2601. +
  2602. + dest[i] = (data >> offset) & 0xff;
  2603. + }
  2604. +
  2605. + return true;
  2606. +}
  2607. +
  2608. +static bool __init
  2609. +ar93xx_wmac_otp_uncompress(void __iomem *base, int addr, int len, u8 *dest,
  2610. + int dest_start, int dest_len)
  2611. +{
  2612. + int dest_bytes = 0;
  2613. + int offset = 0;
  2614. + int end = addr - len;
  2615. + u8 hdr[2];
  2616. +
  2617. + while (addr > end) {
  2618. + if (!ar93xx_wmac_otp_read(base, addr, hdr, 2))
  2619. + return false;
  2620. +
  2621. + addr -= 2;
  2622. + offset += hdr[0];
  2623. +
  2624. + if (offset <= dest_start + dest_len &&
  2625. + offset + len >= dest_start) {
  2626. + int data_offset = 0;
  2627. + int dest_offset = 0;
  2628. + int copy_len;
  2629. +
  2630. + if (offset < dest_start)
  2631. + data_offset = dest_start - offset;
  2632. + else
  2633. + dest_offset = offset - dest_start;
  2634. +
  2635. + copy_len = len - data_offset;
  2636. + if (copy_len > dest_len - dest_offset)
  2637. + copy_len = dest_len - dest_offset;
  2638. +
  2639. + ar93xx_wmac_otp_read(base, addr - data_offset,
  2640. + dest + dest_offset,
  2641. + copy_len);
  2642. +
  2643. + dest_bytes += copy_len;
  2644. + }
  2645. + addr -= hdr[1];
  2646. + }
  2647. + return !!dest_bytes;
  2648. +}
  2649. +
  2650. +bool __init ar93xx_wmac_read_mac_address(u8 *dest)
  2651. +{
  2652. + void __iomem *base;
  2653. + bool ret = false;
  2654. + int addr = 0x1ff;
  2655. + unsigned int len;
  2656. + u32 hdr_u32;
  2657. + u8 *hdr = (u8 *) &hdr_u32;
  2658. + u8 mac[6] = { 0x00, 0x02, 0x03, 0x04, 0x05, 0x06 };
  2659. + int mac_start = 2, mac_end = 8;
  2660. +
  2661. + BUG_ON(!soc_is_ar933x() && !soc_is_ar934x());
  2662. + base = ioremap_nocache(AR933X_WMAC_BASE, AR933X_WMAC_SIZE);
  2663. + while (addr > sizeof(hdr)) {
  2664. + if (!ar93xx_wmac_otp_read(base, addr, hdr, sizeof(hdr)))
  2665. + break;
  2666. +
  2667. + if (hdr_u32 == 0 || hdr_u32 == ~0)
  2668. + break;
  2669. +
  2670. + len = (hdr[1] << 4) | (hdr[2] >> 4);
  2671. + addr -= 4;
  2672. +
  2673. + switch (hdr[0] >> 5) {
  2674. + case 0:
  2675. + if (len < mac_end)
  2676. + break;
  2677. +
  2678. + ar93xx_wmac_otp_read(base, addr - mac_start, mac, 6);
  2679. + ret = true;
  2680. + break;
  2681. + case 3:
  2682. + ret |= ar93xx_wmac_otp_uncompress(base, addr, len, mac,
  2683. + mac_start, 6);
  2684. + break;
  2685. + default:
  2686. + break;
  2687. + }
  2688. +
  2689. + addr -= len + 2;
  2690. + }
  2691. +
  2692. + iounmap(base);
  2693. + if (ret)
  2694. + memcpy(dest, mac, 6);
  2695. +
  2696. + return ret;
  2697. +}
  2698. +
  2699. +void __init ath79_wmac_disable_2ghz(void)
  2700. +{
  2701. + ath79_wmac_data.disable_2ghz = true;
  2702. +}
  2703. +
  2704. +void __init ath79_wmac_disable_5ghz(void)
  2705. +{
  2706. + ath79_wmac_data.disable_5ghz = true;
  2707. +}
  2708. +
  2709. +void __init ath79_wmac_set_tx_gain_buffalo(void)
  2710. +{
  2711. + ath79_wmac_data.tx_gain_buffalo = true;
  2712. +}
  2713. +
  2714. +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
  2715. +{
  2716. + char buf[32];
  2717. + char *label;
  2718. + int err;
  2719. +
  2720. + scnprintf(buf, sizeof(buf), "external LNA%u", chain);
  2721. + label = kstrdup(buf, GFP_KERNEL);
  2722. +
  2723. + err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
  2724. + if (err) {
  2725. + pr_err("unable to request GPIO%d for external LNA%u\n",
  2726. + gpio, chain);
  2727. + kfree(label);
  2728. + }
  2729. +
  2730. + return err;
  2731. +}
  2732. +
  2733. +static void ar934x_set_ext_lna_gpio(unsigned chain, int gpio)
  2734. +{
  2735. + unsigned int sel;
  2736. + int err;
  2737. +
  2738. + if (WARN_ON(chain > 1))
  2739. + return;
  2740. +
  2741. + err = ath79_request_ext_lna_gpio(chain, gpio);
  2742. + if (err)
  2743. + return;
  2744. +
  2745. + if (chain == 0)
  2746. + sel = AR934X_GPIO_OUT_EXT_LNA0;
  2747. + else
  2748. + sel = AR934X_GPIO_OUT_EXT_LNA1;
  2749. +
  2750. + ath79_gpio_output_select(gpio, sel);
  2751. +}
  2752. +
  2753. +void __init ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio)
  2754. +{
  2755. + if (soc_is_ar934x())
  2756. + ar934x_set_ext_lna_gpio(chain, gpio);
  2757. +}
  2758. +
  2759. +void __init ath79_wmac_set_led_pin(int gpio)
  2760. +{
  2761. + ath79_wmac_data.led_pin = gpio;
  2762. +}
  2763. +
  2764. +void __init ath79_register_wmac(u8 *cal_data, u8 *mac_addr)
  2765. {
  2766. if (soc_is_ar913x())
  2767. ar913x_wmac_setup();
  2768. @@ -142,8 +411,12 @@
  2769. ar933x_wmac_setup();
  2770. else if (soc_is_ar934x())
  2771. ar934x_wmac_setup();
  2772. + else if (soc_is_qca953x())
  2773. + qca953x_wmac_setup();
  2774. else if (soc_is_qca955x())
  2775. qca955x_wmac_setup();
  2776. + else if (soc_is_qca956x())
  2777. + qca956x_wmac_setup();
  2778. else
  2779. BUG();
  2780. @@ -151,5 +424,16 @@
  2781. memcpy(ath79_wmac_data.eeprom_data, cal_data,
  2782. sizeof(ath79_wmac_data.eeprom_data));
  2783. + if (mac_addr) {
  2784. + memcpy(ath79_wmac_mac, mac_addr, sizeof(ath79_wmac_mac));
  2785. + ath79_wmac_data.macaddr = ath79_wmac_mac;
  2786. + }
  2787. +
  2788. platform_device_register(&ath79_wmac_device);
  2789. }
  2790. +
  2791. +void __init ath79_register_wmac_simple(void)
  2792. +{
  2793. + ath79_register_wmac(NULL, NULL);
  2794. + ath79_wmac_data.eeprom_name = "soc_wmac.eeprom";
  2795. +}
  2796. diff -Nur linux-4.1.13.orig/arch/mips/ath79/dev-wmac.h linux-4.1.13/arch/mips/ath79/dev-wmac.h
  2797. --- linux-4.1.13.orig/arch/mips/ath79/dev-wmac.h 2015-11-09 23:34:10.000000000 +0100
  2798. +++ linux-4.1.13/arch/mips/ath79/dev-wmac.h 2015-12-04 19:57:04.510069820 +0100
  2799. @@ -12,6 +12,14 @@
  2800. #ifndef _ATH79_DEV_WMAC_H
  2801. #define _ATH79_DEV_WMAC_H
  2802. -void ath79_register_wmac(u8 *cal_data);
  2803. +void ath79_register_wmac(u8 *cal_data, u8 *mac_addr);
  2804. +void ath79_register_wmac_simple(void);
  2805. +void ath79_wmac_disable_2ghz(void);
  2806. +void ath79_wmac_disable_5ghz(void);
  2807. +void ath79_wmac_set_tx_gain_buffalo(void);
  2808. +void ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio);
  2809. +void ath79_wmac_set_led_pin(int gpio);
  2810. +
  2811. +bool ar93xx_wmac_read_mac_address(u8 *dest);
  2812. #endif /* _ATH79_DEV_WMAC_H */
  2813. diff -Nur linux-4.1.13.orig/arch/mips/ath79/early_printk.c linux-4.1.13/arch/mips/ath79/early_printk.c
  2814. --- linux-4.1.13.orig/arch/mips/ath79/early_printk.c 2015-11-09 23:34:10.000000000 +0100
  2815. +++ linux-4.1.13/arch/mips/ath79/early_printk.c 2015-12-04 19:57:04.478071913 +0100
  2816. @@ -56,6 +56,46 @@
  2817. /* nothing to do */
  2818. }
  2819. +static void prom_enable_uart(u32 id)
  2820. +{
  2821. + void __iomem *gpio_base;
  2822. + u32 uart_en;
  2823. + u32 t;
  2824. +
  2825. + switch (id) {
  2826. + case REV_ID_MAJOR_AR71XX:
  2827. + uart_en = AR71XX_GPIO_FUNC_UART_EN;
  2828. + break;
  2829. +
  2830. + case REV_ID_MAJOR_AR7240:
  2831. + case REV_ID_MAJOR_AR7241:
  2832. + case REV_ID_MAJOR_AR7242:
  2833. + uart_en = AR724X_GPIO_FUNC_UART_EN;
  2834. + break;
  2835. +
  2836. + case REV_ID_MAJOR_AR913X:
  2837. + uart_en = AR913X_GPIO_FUNC_UART_EN;
  2838. + break;
  2839. +
  2840. + case REV_ID_MAJOR_AR9330:
  2841. + case REV_ID_MAJOR_AR9331:
  2842. + uart_en = AR933X_GPIO_FUNC_UART_EN;
  2843. + break;
  2844. +
  2845. + case REV_ID_MAJOR_AR9341:
  2846. + case REV_ID_MAJOR_AR9342:
  2847. + case REV_ID_MAJOR_AR9344:
  2848. + /* TODO */
  2849. + default:
  2850. + return;
  2851. + }
  2852. +
  2853. + gpio_base = (void __iomem *)(KSEG1ADDR(AR71XX_GPIO_BASE));
  2854. + t = __raw_readl(gpio_base + AR71XX_GPIO_REG_FUNC);
  2855. + t |= uart_en;
  2856. + __raw_writel(t, gpio_base + AR71XX_GPIO_REG_FUNC);
  2857. +}
  2858. +
  2859. static void prom_putchar_init(void)
  2860. {
  2861. void __iomem *base;
  2862. @@ -74,8 +114,12 @@
  2863. case REV_ID_MAJOR_AR9341:
  2864. case REV_ID_MAJOR_AR9342:
  2865. case REV_ID_MAJOR_AR9344:
  2866. + case REV_ID_MAJOR_QCA9533:
  2867. + case REV_ID_MAJOR_QCA9533_V2:
  2868. case REV_ID_MAJOR_QCA9556:
  2869. case REV_ID_MAJOR_QCA9558:
  2870. + case REV_ID_MAJOR_TP9343:
  2871. + case REV_ID_MAJOR_QCA9561:
  2872. _prom_putchar = prom_putchar_ar71xx;
  2873. break;
  2874. @@ -86,8 +130,10 @@
  2875. default:
  2876. _prom_putchar = prom_putchar_dummy;
  2877. - break;
  2878. + return;
  2879. }
  2880. +
  2881. + prom_enable_uart(id);
  2882. }
  2883. void prom_putchar(unsigned char ch)
  2884. diff -Nur linux-4.1.13.orig/arch/mips/ath79/gpio.c linux-4.1.13/arch/mips/ath79/gpio.c
  2885. --- linux-4.1.13.orig/arch/mips/ath79/gpio.c 2015-11-09 23:34:10.000000000 +0100
  2886. +++ linux-4.1.13/arch/mips/ath79/gpio.c 2015-12-04 19:57:05.893979276 +0100
  2887. @@ -20,15 +20,29 @@
  2888. #include <linux/io.h>
  2889. #include <linux/ioport.h>
  2890. #include <linux/gpio.h>
  2891. +#include <linux/irq.h>
  2892. +#include <linux/interrupt.h>
  2893. +
  2894. +#include <linux/of.h>
  2895. #include <asm/mach-ath79/ar71xx_regs.h>
  2896. #include <asm/mach-ath79/ath79.h>
  2897. +#include <asm/mach-ath79/irq.h>
  2898. #include "common.h"
  2899. -static void __iomem *ath79_gpio_base;
  2900. +void __iomem *ath79_gpio_base;
  2901. +EXPORT_SYMBOL_GPL(ath79_gpio_base);
  2902. +
  2903. static unsigned long ath79_gpio_count;
  2904. static DEFINE_SPINLOCK(ath79_gpio_lock);
  2905. +/*
  2906. + * gpio_both_edge is a bitmask of which gpio pins need to have
  2907. + * the detect priority flipped from the interrupt handler to
  2908. + * emulate IRQ_TYPE_EDGE_BOTH.
  2909. + */
  2910. +static unsigned long gpio_both_edge = 0;
  2911. +
  2912. static void __ath79_gpio_set_value(unsigned gpio, int value)
  2913. {
  2914. void __iomem *base = ath79_gpio_base;
  2915. @@ -128,6 +142,30 @@
  2916. return 0;
  2917. }
  2918. +int ath79_gpio_direction_select(unsigned gpio, bool oe)
  2919. +{
  2920. + void __iomem *base = ath79_gpio_base;
  2921. + unsigned long flags;
  2922. + bool ieq_1 = (soc_is_ar934x() ||
  2923. + soc_is_qca953x());
  2924. +
  2925. + if (gpio >= ath79_gpio_count)
  2926. + return -1;
  2927. +
  2928. + spin_lock_irqsave(&ath79_gpio_lock, flags);
  2929. +
  2930. + if ((ieq_1 && oe) || (!ieq_1 && !oe))
  2931. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << gpio),
  2932. + base + AR71XX_GPIO_REG_OE);
  2933. + else
  2934. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) | (1 << gpio),
  2935. + base + AR71XX_GPIO_REG_OE);
  2936. +
  2937. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  2938. +
  2939. + return 0;
  2940. +}
  2941. +
  2942. static struct gpio_chip ath79_gpio_chip = {
  2943. .label = "ath79",
  2944. .get = ath79_gpio_get_value,
  2945. @@ -146,7 +184,8 @@
  2946. soc_is_ar913x() ||
  2947. soc_is_ar933x())
  2948. reg = AR71XX_GPIO_REG_FUNC;
  2949. - else if (soc_is_ar934x())
  2950. + else if (soc_is_ar934x() ||
  2951. + soc_is_qca953x() || soc_is_qca956x())
  2952. reg = AR934X_GPIO_REG_FUNC;
  2953. else
  2954. BUG();
  2955. @@ -154,6 +193,36 @@
  2956. return ath79_gpio_base + reg;
  2957. }
  2958. +static void __iomem *ath79_gpio_get_function2_reg(void)
  2959. +{
  2960. + u32 reg = 0;
  2961. +
  2962. + if (soc_is_ar71xx() ||
  2963. + soc_is_ar724x() ||
  2964. + soc_is_ar913x() ||
  2965. + soc_is_ar933x())
  2966. + reg = AR71XX_GPIO_REG_FUNC_2;
  2967. + else
  2968. + BUG();
  2969. +
  2970. + return ath79_gpio_base + reg;
  2971. +}
  2972. +
  2973. +
  2974. +void ath79_gpio_function2_setup(u32 set, u32 clear)
  2975. +{
  2976. + void __iomem *reg = ath79_gpio_get_function2_reg();
  2977. + unsigned long flags;
  2978. +
  2979. + spin_lock_irqsave(&ath79_gpio_lock, flags);
  2980. +
  2981. + __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
  2982. + /* flush write */
  2983. + __raw_readl(reg);
  2984. +
  2985. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  2986. +}
  2987. +
  2988. void ath79_gpio_function_setup(u32 set, u32 clear)
  2989. {
  2990. void __iomem *reg = ath79_gpio_get_function_reg();
  2991. @@ -178,6 +247,172 @@
  2992. ath79_gpio_function_setup(0, mask);
  2993. }
  2994. +void __init ath79_gpio_output_select(unsigned gpio, u8 val)
  2995. +{
  2996. + void __iomem *base = ath79_gpio_base;
  2997. + unsigned long flags;
  2998. + unsigned int reg, reg_base;
  2999. + unsigned long gpio_count;
  3000. + u32 t, s;
  3001. +
  3002. + if (soc_is_ar934x()) {
  3003. + gpio_count = AR934X_GPIO_COUNT;
  3004. + reg_base = AR934X_GPIO_REG_OUT_FUNC0;
  3005. + } else if (soc_is_qca953x()) {
  3006. + gpio_count = QCA953X_GPIO_COUNT;
  3007. + reg_base = QCA953X_GPIO_REG_OUT_FUNC0;
  3008. + } else if (soc_is_qca955x()) {
  3009. + gpio_count = QCA955X_GPIO_COUNT;
  3010. + reg_base = QCA955X_GPIO_REG_OUT_FUNC0;
  3011. + } else {
  3012. + BUG();
  3013. + }
  3014. +
  3015. + if (gpio >= gpio_count)
  3016. + return;
  3017. +
  3018. + reg = reg_base + 4 * (gpio / 4);
  3019. + s = 8 * (gpio % 4);
  3020. +
  3021. + spin_lock_irqsave(&ath79_gpio_lock, flags);
  3022. +
  3023. + t = __raw_readl(base + reg);
  3024. + t &= ~(0xff << s);
  3025. + t |= val << s;
  3026. + __raw_writel(t, base + reg);
  3027. +
  3028. + /* flush write */
  3029. + (void) __raw_readl(base + reg);
  3030. +
  3031. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  3032. +}
  3033. +
  3034. +static int ath79_gpio_irq_type(struct irq_data *d, unsigned type)
  3035. +{
  3036. + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
  3037. + void __iomem *base = ath79_gpio_base;
  3038. + unsigned long flags;
  3039. + unsigned long int_type;
  3040. + unsigned long int_polarity;
  3041. + unsigned long bit = (1 << offset);
  3042. +
  3043. + spin_lock_irqsave(&ath79_gpio_lock, flags);
  3044. +
  3045. + int_type = __raw_readl(base + AR71XX_GPIO_REG_INT_TYPE);
  3046. + int_polarity = __raw_readl(base + AR71XX_GPIO_REG_INT_POLARITY);
  3047. +
  3048. + gpio_both_edge &= ~bit;
  3049. +
  3050. + switch (type) {
  3051. + case IRQ_TYPE_EDGE_RISING:
  3052. + int_type &= ~bit;
  3053. + int_polarity |= bit;
  3054. + break;
  3055. +
  3056. + case IRQ_TYPE_EDGE_FALLING:
  3057. + int_type &= ~bit;
  3058. + int_polarity &= ~bit;
  3059. + break;
  3060. +
  3061. + case IRQ_TYPE_LEVEL_HIGH:
  3062. + int_type |= bit;
  3063. + int_polarity |= bit;
  3064. + break;
  3065. +
  3066. + case IRQ_TYPE_LEVEL_LOW:
  3067. + int_type |= bit;
  3068. + int_polarity &= ~bit;
  3069. + break;
  3070. +
  3071. + case IRQ_TYPE_EDGE_BOTH:
  3072. + int_type |= bit;
  3073. + /* set polarity based on current value */
  3074. + if (gpio_get_value(offset)) {
  3075. + int_polarity &= ~bit;
  3076. + } else {
  3077. + int_polarity |= bit;
  3078. + }
  3079. + /* flip this gpio in the interrupt handler */
  3080. + gpio_both_edge |= bit;
  3081. + break;
  3082. +
  3083. + default:
  3084. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  3085. + return -EINVAL;
  3086. + }
  3087. +
  3088. + __raw_writel(int_type, base + AR71XX_GPIO_REG_INT_TYPE);
  3089. + __raw_writel(int_polarity, base + AR71XX_GPIO_REG_INT_POLARITY);
  3090. +
  3091. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_MODE) | (1 << offset),
  3092. + base + AR71XX_GPIO_REG_INT_MODE);
  3093. +
  3094. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) & ~(1 << offset),
  3095. + base + AR71XX_GPIO_REG_INT_ENABLE);
  3096. +
  3097. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  3098. + return 0;
  3099. +}
  3100. +
  3101. +static void ath79_gpio_irq_enable(struct irq_data *d)
  3102. +{
  3103. + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
  3104. + void __iomem *base = ath79_gpio_base;
  3105. +
  3106. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) | (1 << offset),
  3107. + base + AR71XX_GPIO_REG_INT_ENABLE);
  3108. +}
  3109. +
  3110. +static void ath79_gpio_irq_disable(struct irq_data *d)
  3111. +{
  3112. + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
  3113. + void __iomem *base = ath79_gpio_base;
  3114. +
  3115. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) & ~(1 << offset),
  3116. + base + AR71XX_GPIO_REG_INT_ENABLE);
  3117. +}
  3118. +
  3119. +static struct irq_chip ath79_gpio_irqchip = {
  3120. + .name = "GPIO",
  3121. + .irq_enable = ath79_gpio_irq_enable,
  3122. + .irq_disable = ath79_gpio_irq_disable,
  3123. + .irq_set_type = ath79_gpio_irq_type,
  3124. +};
  3125. +
  3126. +static irqreturn_t ath79_gpio_irq(int irq, void *dev)
  3127. +{
  3128. + void __iomem *base = ath79_gpio_base;
  3129. + unsigned long stat = __raw_readl(base + AR71XX_GPIO_REG_INT_PENDING);
  3130. + int bit_num;
  3131. +
  3132. + for_each_set_bit(bit_num, &stat, sizeof(stat) * BITS_PER_BYTE) {
  3133. + unsigned long bit = BIT(bit_num);
  3134. +
  3135. + if (bit & gpio_both_edge) {
  3136. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_POLARITY) ^ bit,
  3137. + base + AR71XX_GPIO_REG_INT_POLARITY);
  3138. + }
  3139. +
  3140. + generic_handle_irq(ATH79_GPIO_IRQ(bit_num));
  3141. + }
  3142. +
  3143. + return IRQ_HANDLED;
  3144. +}
  3145. +
  3146. +static int __init ath79_gpio_irq_init(struct gpio_chip *chip)
  3147. +{
  3148. + int irq;
  3149. + int irq_base = ATH79_GPIO_IRQ_BASE;
  3150. +
  3151. + for (irq = irq_base; irq < irq_base + chip->ngpio; irq++) {
  3152. + irq_set_chip_data(irq, chip);
  3153. + irq_set_chip_and_handler(irq, &ath79_gpio_irqchip, handle_simple_irq);
  3154. + irq_set_noprobe(irq);
  3155. + }
  3156. +
  3157. + return 0;
  3158. +}
  3159. +
  3160. void __init ath79_gpio_init(void)
  3161. {
  3162. int err;
  3163. @@ -194,14 +429,19 @@
  3164. ath79_gpio_count = AR933X_GPIO_COUNT;
  3165. else if (soc_is_ar934x())
  3166. ath79_gpio_count = AR934X_GPIO_COUNT;
  3167. + else if (soc_is_qca953x())
  3168. + ath79_gpio_count = QCA953X_GPIO_COUNT;
  3169. else if (soc_is_qca955x())
  3170. ath79_gpio_count = QCA955X_GPIO_COUNT;
  3171. + else if (soc_is_qca956x())
  3172. + ath79_gpio_count = QCA956X_GPIO_COUNT;
  3173. else
  3174. BUG();
  3175. ath79_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
  3176. ath79_gpio_chip.ngpio = ath79_gpio_count;
  3177. - if (soc_is_ar934x() || soc_is_qca955x()) {
  3178. + if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x() ||
  3179. + soc_is_qca956x()) {
  3180. ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
  3181. ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
  3182. }
  3183. @@ -209,6 +449,10 @@
  3184. err = gpiochip_add(&ath79_gpio_chip);
  3185. if (err)
  3186. panic("cannot add AR71xx GPIO chip, error=%d", err);
  3187. +
  3188. + ath79_gpio_irq_init(&ath79_gpio_chip);
  3189. +
  3190. + request_irq(ATH79_MISC_IRQ(2), ath79_gpio_irq, 0, "ath79-gpio", NULL);
  3191. }
  3192. int gpio_get_value(unsigned gpio)
  3193. @@ -231,14 +475,22 @@
  3194. int gpio_to_irq(unsigned gpio)
  3195. {
  3196. - /* FIXME */
  3197. - return -EINVAL;
  3198. + if (gpio > ath79_gpio_count) {
  3199. + return -EINVAL;
  3200. + }
  3201. +
  3202. + return ATH79_GPIO_IRQ_BASE + gpio;
  3203. }
  3204. EXPORT_SYMBOL(gpio_to_irq);
  3205. int irq_to_gpio(unsigned irq)
  3206. {
  3207. - /* FIXME */
  3208. - return -EINVAL;
  3209. + unsigned gpio = irq - ATH79_GPIO_IRQ_BASE;
  3210. +
  3211. + if (gpio > ath79_gpio_count) {
  3212. + return -EINVAL;
  3213. + }
  3214. +
  3215. + return gpio;
  3216. }
  3217. EXPORT_SYMBOL(irq_to_gpio);
  3218. diff -Nur linux-4.1.13.orig/arch/mips/ath79/irq.c linux-4.1.13/arch/mips/ath79/irq.c
  3219. --- linux-4.1.13.orig/arch/mips/ath79/irq.c 2015-11-09 23:34:10.000000000 +0100
  3220. +++ linux-4.1.13/arch/mips/ath79/irq.c 2015-12-04 19:57:04.498070605 +0100
  3221. @@ -26,6 +26,8 @@
  3222. static void (*ath79_ip2_handler)(void);
  3223. static void (*ath79_ip3_handler)(void);
  3224. +static struct irq_chip ip2_chip;
  3225. +static struct irq_chip ip3_chip;
  3226. static void ath79_misc_irq_handler(unsigned int irq, struct irq_desc *desc)
  3227. {
  3228. @@ -106,7 +108,9 @@
  3229. else if (soc_is_ar724x() ||
  3230. soc_is_ar933x() ||
  3231. soc_is_ar934x() ||
  3232. - soc_is_qca955x())
  3233. + soc_is_qca953x() ||
  3234. + soc_is_qca955x() ||
  3235. + soc_is_qca956x())
  3236. ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
  3237. else
  3238. BUG();
  3239. @@ -147,12 +151,43 @@
  3240. for (i = ATH79_IP2_IRQ_BASE;
  3241. i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  3242. - irq_set_chip_and_handler(i, &dummy_irq_chip,
  3243. - handle_level_irq);
  3244. + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
  3245. irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  3246. }
  3247. +static void qca953x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  3248. +{
  3249. + u32 status;
  3250. +
  3251. + disable_irq_nosync(irq);
  3252. +
  3253. + status = ath79_reset_rr(QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS);
  3254. +
  3255. + if (status & QCA953X_PCIE_WMAC_INT_PCIE_ALL) {
  3256. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_PCIE);
  3257. + generic_handle_irq(ATH79_IP2_IRQ(0));
  3258. + } else if (status & QCA953X_PCIE_WMAC_INT_WMAC_ALL) {
  3259. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_WMAC);
  3260. + generic_handle_irq(ATH79_IP2_IRQ(1));
  3261. + } else {
  3262. + spurious_interrupt();
  3263. + }
  3264. +
  3265. + enable_irq(irq);
  3266. +}
  3267. +
  3268. +static void qca953x_irq_init(void)
  3269. +{
  3270. + int i;
  3271. +
  3272. + for (i = ATH79_IP2_IRQ_BASE;
  3273. + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  3274. + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
  3275. +
  3276. + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca953x_ip2_irq_dispatch);
  3277. +}
  3278. +
  3279. static void qca955x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  3280. {
  3281. u32 status;
  3282. @@ -222,19 +257,108 @@
  3283. for (i = ATH79_IP2_IRQ_BASE;
  3284. i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  3285. - irq_set_chip_and_handler(i, &dummy_irq_chip,
  3286. - handle_level_irq);
  3287. + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
  3288. irq_set_chained_handler(ATH79_CPU_IRQ(2), qca955x_ip2_irq_dispatch);
  3289. for (i = ATH79_IP3_IRQ_BASE;
  3290. i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
  3291. - irq_set_chip_and_handler(i, &dummy_irq_chip,
  3292. - handle_level_irq);
  3293. + irq_set_chip_and_handler(i, &ip3_chip, handle_level_irq);
  3294. irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
  3295. }
  3296. +static void qca956x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  3297. +{
  3298. + u32 status;
  3299. +
  3300. + disable_irq_nosync(irq);
  3301. +
  3302. + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
  3303. + status &= QCA956X_EXT_INT_PCIE_RC1_ALL | QCA956X_EXT_INT_WMAC_ALL;
  3304. +
  3305. + if (status == 0) {
  3306. + spurious_interrupt();
  3307. + goto enable;
  3308. + }
  3309. +
  3310. + if (status & QCA956X_EXT_INT_PCIE_RC1_ALL) {
  3311. + /* TODO: flush DDR? */
  3312. + generic_handle_irq(ATH79_IP2_IRQ(0));
  3313. + }
  3314. +
  3315. + if (status & QCA956X_EXT_INT_WMAC_ALL) {
  3316. + /* TODO: flsuh DDR? */
  3317. + generic_handle_irq(ATH79_IP2_IRQ(1));
  3318. + }
  3319. +
  3320. +enable:
  3321. + enable_irq(irq);
  3322. +}
  3323. +
  3324. +static void qca956x_ip3_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  3325. +{
  3326. + u32 status;
  3327. +
  3328. + disable_irq_nosync(irq);
  3329. +
  3330. + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
  3331. + status &= QCA956X_EXT_INT_PCIE_RC2_ALL |
  3332. + QCA956X_EXT_INT_USB1 | QCA956X_EXT_INT_USB2;
  3333. +
  3334. + if (status == 0) {
  3335. + spurious_interrupt();
  3336. + goto enable;
  3337. + }
  3338. +
  3339. + if (status & QCA956X_EXT_INT_USB1) {
  3340. + /* TODO: flush DDR? */
  3341. + generic_handle_irq(ATH79_IP3_IRQ(0));
  3342. + }
  3343. +
  3344. + if (status & QCA956X_EXT_INT_USB2) {
  3345. + /* TODO: flush DDR? */
  3346. + generic_handle_irq(ATH79_IP3_IRQ(1));
  3347. + }
  3348. +
  3349. + if (status & QCA956X_EXT_INT_PCIE_RC2_ALL) {
  3350. + /* TODO: flush DDR? */
  3351. + generic_handle_irq(ATH79_IP3_IRQ(2));
  3352. + }
  3353. +
  3354. +enable:
  3355. + enable_irq(irq);
  3356. +}
  3357. +
  3358. +static void qca956x_enable_timer_cb(void) {
  3359. + u32 misc;
  3360. +
  3361. + misc = ath79_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
  3362. + misc |= MISC_INT_MIPS_SI_TIMERINT_MASK;
  3363. + ath79_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, misc);
  3364. +}
  3365. +
  3366. +static void qca956x_irq_init(void)
  3367. +{
  3368. + int i;
  3369. +
  3370. + for (i = ATH79_IP2_IRQ_BASE;
  3371. + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  3372. + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
  3373. +
  3374. + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca956x_ip2_irq_dispatch);
  3375. +
  3376. + for (i = ATH79_IP3_IRQ_BASE;
  3377. + i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
  3378. + irq_set_chip_and_handler(i, &ip3_chip, handle_level_irq);
  3379. +
  3380. + irq_set_chained_handler(ATH79_CPU_IRQ(3), qca956x_ip3_irq_dispatch);
  3381. +
  3382. + /* QCA956x timer init workaround has to be applied right before setting
  3383. + * up the clock. Else, there will be no jiffies */
  3384. + late_time_init = &qca956x_enable_timer_cb;
  3385. +}
  3386. +
  3387. asmlinkage void plat_irq_dispatch(void)
  3388. {
  3389. unsigned long pending;
  3390. @@ -335,8 +459,41 @@
  3391. do_IRQ(ATH79_CPU_IRQ(3));
  3392. }
  3393. +static void qca953x_ip3_handler(void)
  3394. +{
  3395. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_USB);
  3396. + do_IRQ(ATH79_CPU_IRQ(3));
  3397. +}
  3398. +
  3399. +static void ath79_ip2_disable(struct irq_data *data)
  3400. +{
  3401. + disable_irq(ATH79_CPU_IRQ(2));
  3402. +}
  3403. +
  3404. +static void ath79_ip2_enable(struct irq_data *data)
  3405. +{
  3406. + enable_irq(ATH79_CPU_IRQ(2));
  3407. +}
  3408. +
  3409. +static void ath79_ip3_disable(struct irq_data *data)
  3410. +{
  3411. + disable_irq(ATH79_CPU_IRQ(3));
  3412. +}
  3413. +
  3414. +static void ath79_ip3_enable(struct irq_data *data)
  3415. +{
  3416. + enable_irq(ATH79_CPU_IRQ(3));
  3417. +}
  3418. +
  3419. void __init arch_init_irq(void)
  3420. {
  3421. + ip2_chip = dummy_irq_chip;
  3422. + ip3_chip = dummy_irq_chip;
  3423. + ip2_chip.irq_disable = ath79_ip2_disable;
  3424. + ip2_chip.irq_enable = ath79_ip2_enable;
  3425. + ip3_chip.irq_disable = ath79_ip3_disable;
  3426. + ip3_chip.irq_enable = ath79_ip3_enable;
  3427. +
  3428. if (soc_is_ar71xx()) {
  3429. ath79_ip2_handler = ar71xx_ip2_handler;
  3430. ath79_ip3_handler = ar71xx_ip3_handler;
  3431. @@ -352,9 +509,15 @@
  3432. } else if (soc_is_ar934x()) {
  3433. ath79_ip2_handler = ath79_default_ip2_handler;
  3434. ath79_ip3_handler = ar934x_ip3_handler;
  3435. + } else if (soc_is_qca953x()) {
  3436. + ath79_ip2_handler = ath79_default_ip2_handler;
  3437. + ath79_ip3_handler = qca953x_ip3_handler;
  3438. } else if (soc_is_qca955x()) {
  3439. ath79_ip2_handler = ath79_default_ip2_handler;
  3440. ath79_ip3_handler = ath79_default_ip3_handler;
  3441. + } else if (soc_is_qca956x()) {
  3442. + ath79_ip2_handler = ath79_default_ip2_handler;
  3443. + ath79_ip3_handler = ath79_default_ip3_handler;
  3444. } else {
  3445. BUG();
  3446. }
  3447. @@ -364,6 +527,10 @@
  3448. if (soc_is_ar934x())
  3449. ar934x_ip2_irq_init();
  3450. + else if (soc_is_qca953x())
  3451. + qca953x_irq_init();
  3452. else if (soc_is_qca955x())
  3453. qca955x_irq_init();
  3454. + else if (soc_is_qca956x())
  3455. + qca956x_irq_init();
  3456. }
  3457. diff -Nur linux-4.1.13.orig/arch/mips/ath79/Kconfig linux-4.1.13/arch/mips/ath79/Kconfig
  3458. --- linux-4.1.13.orig/arch/mips/ath79/Kconfig 2015-11-09 23:34:10.000000000 +0100
  3459. +++ linux-4.1.13/arch/mips/ath79/Kconfig 2015-12-04 19:57:05.957975089 +0100
  3460. @@ -2,75 +2,1466 @@
  3461. menu "Atheros AR71XX/AR724X/AR913X machine selection"
  3462. +config ATH79_MACH_ALFA_AP96
  3463. + bool "ALFA Network AP96 board support"
  3464. + select SOC_AR71XX
  3465. + select ATH79_DEV_ETH
  3466. + select ATH79_DEV_GPIO_BUTTONS
  3467. + select ATH79_DEV_M25P80
  3468. + select ATH79_DEV_USB
  3469. +
  3470. +config ATH79_MACH_HORNET_UB
  3471. + bool "ALFA Network Hornet-UB board support"
  3472. + select SOC_AR933X
  3473. + select ATH79_DEV_ETH
  3474. + select ATH79_DEV_GPIO_BUTTONS
  3475. + select ATH79_DEV_LEDS_GPIO
  3476. + select ATH79_DEV_M25P80
  3477. + select ATH79_DEV_USB
  3478. + select ATH79_DEV_WMAC
  3479. +
  3480. +config ATH79_MACH_ALFA_NX
  3481. + bool "ALFA Network N2/N5 board support"
  3482. + select SOC_AR724X
  3483. + select ATH79_DEV_AP9X_PCI if PCI
  3484. + select ATH79_DEV_ETH
  3485. + select ATH79_DEV_GPIO_BUTTONS
  3486. + select ATH79_DEV_LEDS_GPIO
  3487. + select ATH79_DEV_M25P80
  3488. +
  3489. +config ATH79_MACH_TUBE2H
  3490. + bool "ALFA Network Tube2H board support"
  3491. + select SOC_AR933X
  3492. + select ATH79_DEV_ETH
  3493. + select ATH79_DEV_GPIO_BUTTONS
  3494. + select ATH79_DEV_LEDS_GPIO
  3495. + select ATH79_DEV_M25P80
  3496. + select ATH79_DEV_WMAC
  3497. +
  3498. +config ATH79_MACH_ALL0258N
  3499. + bool "Allnet ALL0258N support"
  3500. + select SOC_AR724X
  3501. + select ATH79_DEV_AP9X_PCI if PCI
  3502. + select ATH79_DEV_ETH
  3503. + select ATH79_DEV_GPIO_BUTTONS
  3504. + select ATH79_DEV_LEDS_GPIO
  3505. + select ATH79_DEV_M25P80
  3506. +
  3507. +config ATH79_MACH_ALL0315N
  3508. + bool "Allnet ALL0315N support"
  3509. + select SOC_AR724X
  3510. + select ATH79_DEV_AP9X_PCI if PCI
  3511. + select ATH79_DEV_ETH
  3512. + select ATH79_DEV_GPIO_BUTTONS
  3513. + select ATH79_DEV_LEDS_GPIO
  3514. + select ATH79_DEV_M25P80
  3515. +
  3516. +config ATH79_MACH_ANTMINER_S1
  3517. + bool "Bitmain Antminer S1 support"
  3518. + select SOC_AR933X
  3519. + select ATH79_DEV_ETH
  3520. + select ATH79_DEV_GPIO_BUTTONS
  3521. + select ATH79_DEV_LEDS_GPIO
  3522. + select ATH79_DEV_M25P80
  3523. + select ATH79_DEV_USB
  3524. + select ATH79_DEV_WMAC
  3525. +
  3526. +config ATH79_MACH_ANTMINER_S3
  3527. + bool "Bitmain Antminer S3 support"
  3528. + select SOC_AR933X
  3529. + select ATH79_DEV_ETH
  3530. + select ATH79_DEV_GPIO_BUTTONS
  3531. + select ATH79_DEV_LEDS_GPIO
  3532. + select ATH79_DEV_M25P80
  3533. + select ATH79_DEV_USB
  3534. + select ATH79_DEV_WMAC
  3535. +
  3536. +config ATH79_MACH_ARDUINO_YUN
  3537. + bool "Arduino Yun"
  3538. + select SOC_AR933X
  3539. + select ATH79_DEV_ETH
  3540. + select ATH79_DEV_GPIO_BUTTONS
  3541. + select ATH79_DEV_LEDS_GPIO
  3542. + select ATH79_DEV_M25P80
  3543. + select ATH79_DEV_USB
  3544. + select ATH79_DEV_WMAC
  3545. + help
  3546. + Say 'Y' here if you want your kernel to support the
  3547. + Arduino Yun.
  3548. +
  3549. +config ATH79_MACH_AP113
  3550. + bool "Atheros AP113 board support"
  3551. + select SOC_AR724X
  3552. + select ATH79_DEV_M25P80
  3553. + select ATH79_DEV_PB9X_PCI if PCI
  3554. + select ATH79_DEV_GPIO_BUTTONS
  3555. + select ATH79_DEV_LEDS_GPIO
  3556. + select ATH79_DEV_USB
  3557. + select ATH79_DEV_ETH
  3558. +
  3559. config ATH79_MACH_AP121
  3560. bool "Atheros AP121 reference board"
  3561. select SOC_AR933X
  3562. + select ATH79_DEV_ETH
  3563. + select ATH79_DEV_GPIO_BUTTONS
  3564. + select ATH79_DEV_LEDS_GPIO
  3565. + select ATH79_DEV_M25P80
  3566. + select ATH79_DEV_USB
  3567. + select ATH79_DEV_WMAC
  3568. + help
  3569. + Say 'Y' here if you want your kernel to support the
  3570. + Atheros AP121 reference board.
  3571. +
  3572. +config ATH79_MACH_AP132
  3573. + bool "Atheros AP132 reference board"
  3574. + select SOC_QCA955X
  3575. + select ATH79_DEV_GPIO_BUTTONS
  3576. + select ATH79_DEV_LEDS_GPIO
  3577. + select ATH79_DEV_M25P80
  3578. + select ATH79_DEV_USB
  3579. + select ATH79_DEV_WMAC
  3580. + help
  3581. + Say 'Y' here if you want your kernel to support the
  3582. + Atheros AP132 reference boards.
  3583. +
  3584. +config ATH79_MACH_AP136
  3585. + bool "Atheros AP136/AP135 reference board"
  3586. + select SOC_QCA955X
  3587. + select ATH79_DEV_GPIO_BUTTONS
  3588. + select ATH79_DEV_LEDS_GPIO
  3589. + select ATH79_DEV_NFC
  3590. + select ATH79_DEV_M25P80
  3591. + select ATH79_DEV_USB
  3592. + select ATH79_DEV_WMAC
  3593. + help
  3594. + Say 'Y' here if you want your kernel to support the
  3595. + Atheros AP136 or AP135 reference boards.
  3596. +
  3597. +config ATH79_MACH_AP143
  3598. + bool "Atheros AP143 reference board"
  3599. + select SOC_QCA953X
  3600. + select ATH79_DEV_GPIO_BUTTONS
  3601. + select ATH79_DEV_LEDS_GPIO
  3602. + select ATH79_DEV_SPI
  3603. + select ATH79_DEV_USB
  3604. + select ATH79_DEV_WMAC
  3605. + select ATH79_DEV_ETH
  3606. + select ATH79_DEV_M25P80
  3607. + help
  3608. + Say 'Y' here if you want your kernel to support the
  3609. + Atheros AP143 reference board.
  3610. +
  3611. +config ATH79_MACH_AP147
  3612. + bool "Atheros AP147 reference board"
  3613. + select SOC_QCA953X
  3614. + select ATH79_DEV_GPIO_BUTTONS
  3615. + select ATH79_DEV_LEDS_GPIO
  3616. + select ATH79_DEV_M25P80
  3617. + select ATH79_DEV_USB
  3618. + select ATH79_DEV_WMAC
  3619. + select ATH79_DEV_AP9X_PCI if PCI
  3620. + help
  3621. + Say 'Y' here if you want your kernel to support the
  3622. + QCA AP147 reference boards.
  3623. +
  3624. +config ATH79_MACH_AP152
  3625. + bool "Atheros AP152 reference board"
  3626. + select SOC_QCA956X
  3627. + select ATH79_DEV_GPIO_BUTTONS
  3628. + select ATH79_DEV_LEDS_GPIO
  3629. + select ATH79_DEV_M25P80
  3630. + select ATH79_DEV_USB
  3631. + select ATH79_DEV_WMAC
  3632. + select ATH79_DEV_AP9X_PCI if PCI
  3633. + help
  3634. + Say 'Y' here if you want your kernel to support the
  3635. + QCA AP152 reference boards.
  3636. +
  3637. +
  3638. +config ATH79_MACH_AP81
  3639. + bool "Atheros AP81 reference board"
  3640. + select SOC_AR913X
  3641. + select ATH79_DEV_ETH
  3642. + select ATH79_DEV_GPIO_BUTTONS
  3643. + select ATH79_DEV_LEDS_GPIO
  3644. + select ATH79_DEV_M25P80
  3645. + select ATH79_DEV_USB
  3646. + select ATH79_DEV_WMAC
  3647. + help
  3648. + Say 'Y' here if you want your kernel to support the
  3649. + Atheros AP81 reference board.
  3650. +
  3651. +config ATH79_MACH_AP83
  3652. + bool "Atheros AP83 board support"
  3653. + select SOC_AR913X
  3654. + select ATH79_DEV_GPIO_BUTTONS
  3655. + select ATH79_DEV_LEDS_GPIO
  3656. + select ATH79_DEV_USB
  3657. + select ATH79_DEV_WMAC
  3658. +
  3659. +config ATH79_MACH_AP96
  3660. + bool "Atheros AP96 board support"
  3661. + select SOC_AR71XX
  3662. + select ATH79_DEV_AP9X_PCI if PCI
  3663. + select ATH79_DEV_ETH
  3664. + select ATH79_DEV_GPIO_BUTTONS
  3665. + select ATH79_DEV_LEDS_GPIO
  3666. + select ATH79_DEV_M25P80
  3667. + select ATH79_DEV_USB
  3668. +
  3669. +config ATH79_MACH_DB120
  3670. + bool "Atheros DB120 reference board"
  3671. + select SOC_AR934X
  3672. + select ATH79_DEV_AP9X_PCI if PCI
  3673. + select ATH79_DEV_ETH
  3674. + select ATH79_DEV_GPIO_BUTTONS
  3675. + select ATH79_DEV_LEDS_GPIO
  3676. + select ATH79_DEV_M25P80
  3677. + select ATH79_DEV_NFC
  3678. + select ATH79_DEV_USB
  3679. + select ATH79_DEV_WMAC
  3680. + help
  3681. + Say 'Y' here if you want your kernel to support the
  3682. + Atheros DB120 reference board.
  3683. +
  3684. +config ATH79_MACH_PB42
  3685. + bool "Atheros PB42 board support"
  3686. + select SOC_AR71XX
  3687. + select ATH79_DEV_ETH
  3688. + select ATH79_DEV_GPIO_BUTTONS
  3689. + select ATH79_DEV_M25P80
  3690. +
  3691. +config ATH79_MACH_PB44
  3692. + bool "Atheros PB44 reference board"
  3693. + select SOC_AR71XX
  3694. + select ATH79_DEV_ETH
  3695. + select ATH79_DEV_GPIO_BUTTONS
  3696. + select ATH79_DEV_LEDS_GPIO
  3697. + select ATH79_DEV_SPI
  3698. + select ATH79_DEV_USB
  3699. + help
  3700. + Say 'Y' here if you want your kernel to support the
  3701. + Atheros PB44 reference board.
  3702. +
  3703. +config ATH79_MACH_PB92
  3704. + bool "Atheros PB92 board support"
  3705. + select SOC_AR724X
  3706. + select ATH79_DEV_ETH
  3707. + select ATH79_DEV_GPIO_BUTTONS
  3708. + select ATH79_DEV_LEDS_GPIO
  3709. + select ATH79_DEV_PB9X_PCI if PCI
  3710. + select ATH79_DEV_USB
  3711. +
  3712. +config ATH79_MACH_AW_NR580
  3713. + bool "AzureWave AW-NR580 board support"
  3714. + select SOC_AR71XX
  3715. + select ATH79_DEV_ETH
  3716. + select ATH79_DEV_GPIO_BUTTONS
  3717. + select ATH79_DEV_LEDS_GPIO
  3718. + select ATH79_DEV_M25P80
  3719. +
  3720. +config ATH79_MACH_F9K1115V2
  3721. + bool "Belkin AC1750DB board support"
  3722. + select SOC_QCA955X
  3723. + select ATH79_DEV_ETH
  3724. + select ATH79_DEV_GPIO_BUTTONS
  3725. + select ATH79_DEV_LEDS_GPIO
  3726. + select ATH79_DEV_M25P80
  3727. + select ATH79_DEV_USB
  3728. + select ATH79_DEV_WMAC
  3729. +
  3730. +config ATH79_MACH_EPG5000
  3731. + bool "EnGenius EPG5000 board support"
  3732. + select SOC_QCA955X
  3733. + select ATH79_DEV_ETH
  3734. + select ATH79_DEV_GPIO_BUTTONS
  3735. + select ATH79_DEV_LEDS_GPIO
  3736. + select ATH79_DEV_M25P80
  3737. + select ATH79_DEV_USB
  3738. + select ATH79_DEV_WMAC
  3739. + select ATH79_NVRAM
  3740. +
  3741. +config ATH79_MACH_ESR1750
  3742. + bool "EnGenius ESR1750 board support"
  3743. + select SOC_QCA955X
  3744. + select ATH79_DEV_ETH
  3745. + select ATH79_DEV_GPIO_BUTTONS
  3746. + select ATH79_DEV_LEDS_GPIO
  3747. + select ATH79_DEV_M25P80
  3748. + select ATH79_DEV_USB
  3749. + select ATH79_DEV_WMAC
  3750. +
  3751. +config ATH79_MACH_WHR_HP_G300N
  3752. + bool "Buffalo WHR-HP-G300N board support"
  3753. + select SOC_AR724X
  3754. + select ATH79_DEV_AP9X_PCI if PCI
  3755. + select ATH79_DEV_ETH
  3756. + select ATH79_DEV_GPIO_BUTTONS
  3757. + select ATH79_DEV_LEDS_GPIO
  3758. + select ATH79_DEV_M25P80
  3759. +
  3760. +config ATH79_MACH_WLAE_AG300N
  3761. + bool "Buffalo WLAE-AG300N board support"
  3762. + select SOC_AR71XX
  3763. + select ATH79_DEV_ETH
  3764. + select ATH79_DEV_GPIO_BUTTONS
  3765. + select ATH79_DEV_LEDS_GPIO
  3766. + select ATH79_DEV_M25P80
  3767. +
  3768. +config ATH79_MACH_WLR8100
  3769. + bool "Sitecom WLR-8100 board support"
  3770. + select SOC_QCA955X
  3771. + select ATH79_DEV_ETH
  3772. + select ATH79_DEV_GPIO_BUTTONS
  3773. + select ATH79_DEV_LEDS_GPIO
  3774. + select ATH79_DEV_M25P80
  3775. + select ATH79_DEV_USB
  3776. + select ATH79_DEV_WMAC
  3777. +
  3778. +config ATH79_MACH_WZR_HP_AG300H
  3779. + bool "Buffalo WZR-HP-AG300H board support"
  3780. + select SOC_AR71XX
  3781. + select ATH79_DEV_AP9X_PCI if PCI
  3782. + select ATH79_DEV_ETH
  3783. + select ATH79_DEV_GPIO_BUTTONS
  3784. + select ATH79_DEV_LEDS_GPIO
  3785. + select ATH79_DEV_M25P80
  3786. + select ATH79_DEV_USB
  3787. +
  3788. +config ATH79_MACH_WZR_HP_G300NH
  3789. + bool "Buffalo WZR-HP-G300NH board support"
  3790. + select SOC_AR913X
  3791. + select ATH79_DEV_ETH
  3792. + select ATH79_DEV_GPIO_BUTTONS
  3793. + select ATH79_DEV_LEDS_GPIO
  3794. + select ATH79_DEV_USB
  3795. + select ATH79_DEV_WMAC
  3796. + select RTL8366_SMI
  3797. +
  3798. +config ATH79_MACH_WZR_HP_G300NH2
  3799. + bool "Buffalo WZR-HP-G300NH2 board support"
  3800. + select SOC_AR724X
  3801. + select ATH79_DEV_AP9X_PCI if PCI
  3802. + select ATH79_DEV_ETH
  3803. + select ATH79_DEV_GPIO_BUTTONS
  3804. + select ATH79_DEV_LEDS_GPIO
  3805. + select ATH79_DEV_M25P80
  3806. + select ATH79_DEV_USB
  3807. +
  3808. +config ATH79_MACH_WZR_HP_G450H
  3809. + bool "Buffalo WZR-HP-G450H board support"
  3810. + select SOC_AR724X
  3811. + select ATH79_DEV_ETH
  3812. + select ATH79_DEV_AP9X_PCI if PCI
  3813. + select ATH79_DEV_GPIO_BUTTONS
  3814. + select ATH79_DEV_LEDS_GPIO
  3815. + select ATH79_DEV_M25P80
  3816. + select ATH79_DEV_USB
  3817. +
  3818. +config ATH79_MACH_WZR_450HP2
  3819. + bool "Buffalo WZR-450HP2 board support"
  3820. + select SOC_QCA955X
  3821. + select ATH79_DEV_ETH
  3822. + select ATH79_DEV_GPIO_BUTTONS
  3823. + select ATH79_DEV_LEDS_GPIO
  3824. + select ATH79_DEV_M25P80
  3825. + select ATH79_DEV_USB
  3826. + select ATH79_DEV_WMAC
  3827. +
  3828. +config ATH79_MACH_WP543
  3829. + bool "Compex WP543/WPJ543 board support"
  3830. + select SOC_AR71XX
  3831. + select ATH79_DEV_ETH
  3832. + select ATH79_DEV_GPIO_BUTTONS
  3833. + select ATH79_DEV_LEDS_GPIO
  3834. + select ATH79_DEV_M25P80
  3835. + select ATH79_DEV_USB
  3836. + select MYLOADER
  3837. +
  3838. +config ATH79_MACH_WPE72
  3839. + bool "Compex WPE72/WPE72NX board support"
  3840. + select SOC_AR724X
  3841. + select ATH79_DEV_ETH
  3842. + select ATH79_DEV_GPIO_BUTTONS
  3843. + select ATH79_DEV_LEDS_GPIO
  3844. + select ATH79_DEV_M25P80
  3845. + select ATH79_DEV_USB
  3846. + select MYLOADER
  3847. +
  3848. +config ATH79_MACH_WPJ344
  3849. + bool "Compex WPJ344 board support"
  3850. + select SOC_AS934X
  3851. + select ATH79_DEV_ETH
  3852. + select ATH79_DEV_GPIO_BUTTONS
  3853. + select ATH79_DEV_LEDS_GPIO
  3854. + select ATH79_DEV_M25P80
  3855. + select ATH79_DEV_USB
  3856. + select ATH79_DEV_WMAC
  3857. +
  3858. +config ATH79_MACH_WPJ531
  3859. + bool "Compex WPJ531 board support"
  3860. + select SOC_QCA953X
  3861. + select ATH79_DEV_ETH
  3862. + select ATH79_DEV_GPIO_BUTTONS
  3863. + select ATH79_DEV_LEDS_GPIO
  3864. + select ATH79_DEV_M25P80
  3865. + select ATH79_DEV_USB
  3866. + select ATH79_DEV_WMAC
  3867. +
  3868. +config ATH79_MACH_WPJ558
  3869. + bool "Compex WPJ558 board support"
  3870. + select SOC_QCA955X
  3871. + select ATH79_DEV_ETH
  3872. + select ATH79_DEV_GPIO_BUTTONS
  3873. + select ATH79_DEV_LEDS_GPIO
  3874. + select ATH79_DEV_M25P80
  3875. + select ATH79_DEV_USB
  3876. + select ATH79_DEV_WMAC
  3877. +
  3878. +config ATH79_MACH_DGL_5500_A1
  3879. + bool "D-Link DGL-5500 A1 support"
  3880. + select SOC_QCA955X
  3881. + select ATH79_DEV_ETH
  3882. + select ATH79_DEV_GPIO_BUTTONS
  3883. + select ATH79_DEV_LEDS_GPIO
  3884. + select ATH79_DEV_M25P80
  3885. + select ATH79_DEV_WMAC
  3886. + select ATH79_DEV_USB
  3887. +
  3888. +config ATH79_MACH_DHP_1565_A1
  3889. + bool "D-Link DHP-1565 rev. A1 board support"
  3890. + select SOC_AR934X
  3891. + select ATH79_DEV_AP9X_PCI if PCI
  3892. + select ATH79_DEV_ETH
  3893. + select ATH79_DEV_GPIO_BUTTONS
  3894. + select ATH79_DEV_LEDS_GPIO
  3895. + select ATH79_DEV_M25P80
  3896. + select ATH79_DEV_USB
  3897. + select ATH79_DEV_WMAC
  3898. +
  3899. +config ATH79_MACH_DIR_505_A1
  3900. + bool "D-Link DIR-505-A1 support"
  3901. + select SOC_AR933X
  3902. + select ATH79_DEV_ETH
  3903. + select ATH79_DEV_GPIO_BUTTONS
  3904. + select ATH79_DEV_LEDS_GPIO
  3905. + select ATH79_DEV_M25P80
  3906. + select ATH79_DEV_WMAC
  3907. + select ATH79_NVRAM
  3908. +
  3909. +config ATH79_MACH_DIR_600_A1
  3910. + bool "D-Link DIR-600 A1/DIR-615 E1/DIR-615 E4 support"
  3911. + select SOC_AR724X
  3912. + select ATH79_DEV_AP9X_PCI if PCI
  3913. + select ATH79_DEV_ETH
  3914. + select ATH79_DEV_GPIO_BUTTONS
  3915. + select ATH79_DEV_LEDS_GPIO
  3916. + select ATH79_DEV_M25P80
  3917. + select ATH79_NVRAM
  3918. +
  3919. +config ATH79_MACH_DIR_615_C1
  3920. + bool "D-Link DIR-615 rev. C1 support"
  3921. + select SOC_AR913X
  3922. + select ATH79_DEV_ETH
  3923. + select ATH79_DEV_GPIO_BUTTONS
  3924. + select ATH79_DEV_LEDS_GPIO
  3925. + select ATH79_DEV_M25P80
  3926. + select ATH79_DEV_WMAC
  3927. + select ATH79_NVRAM
  3928. +
  3929. +config ATH79_MACH_DIR_615_I1
  3930. + bool "D-Link DIR-615 rev. I1 support"
  3931. + select SOC_AR934X
  3932. + select ATH79_DEV_AP9X_PCI if PCI
  3933. + select ATH79_DEV_ETH
  3934. + select ATH79_DEV_GPIO_BUTTONS
  3935. + select ATH79_DEV_LEDS_GPIO
  3936. + select ATH79_DEV_M25P80
  3937. + select ATH79_DEV_WMAC
  3938. + select ATH79_NVRAM
  3939. +
  3940. +config ATH79_MACH_DIR_825_B1
  3941. + bool "D-Link DIR-825 rev. B1 board support"
  3942. + select SOC_AR71XX
  3943. + select ATH79_DEV_AP9X_PCI if PCI
  3944. + select ATH79_DEV_ETH
  3945. + select ATH79_DEV_GPIO_BUTTONS
  3946. + select ATH79_DEV_LEDS_GPIO
  3947. + select ATH79_DEV_M25P80
  3948. + select ATH79_DEV_USB
  3949. +
  3950. +config ATH79_MACH_DIR_825_C1
  3951. + bool "D-Link DIR-825 rev. C1/DIR-835 rev. A1 board support"
  3952. + select SOC_AR934X
  3953. + select ATH79_DEV_AP9X_PCI if PCI
  3954. + select ATH79_DEV_ETH
  3955. + select ATH79_DEV_GPIO_BUTTONS
  3956. + select ATH79_DEV_LEDS_GPIO
  3957. + select ATH79_DEV_M25P80
  3958. + select ATH79_DEV_USB
  3959. + select ATH79_DEV_WMAC
  3960. +
  3961. +config ATH79_MACH_DLAN_HOTSPOT
  3962. + bool "devolo dLAN Hotspot support"
  3963. + select SOC_AR933X
  3964. + select ATH79_DEV_ETH
  3965. + select ATH79_DEV_GPIO_BUTTONS
  3966. + select ATH79_DEV_LEDS_GPIO
  3967. + select ATH79_DEV_M25P80
  3968. + select ATH79_DEV_WMAC
  3969. +
  3970. +config ATH79_MACH_DLAN_PRO_500_WP
  3971. + bool "devolo dLAN pro 500 Wireless+ support"
  3972. + select SOC_AR934X
  3973. + select ATH79_DEV_ETH
  3974. + select ATH79_DEV_GPIO_BUTTONS
  3975. + select ATH79_DEV_LEDS_GPIO
  3976. + select ATH79_DEV_SPI
  3977. + select ATH79_DEV_M25P80
  3978. + select ATH79_DEV_WMAC
  3979. + select ATH79_DEV_USB
  3980. +
  3981. +config ATH79_MACH_DLAN_PRO_1200_AC
  3982. + bool "devolo dLAN pro 1200+ WiFi ac support"
  3983. + select SOC_AR934X
  3984. + select ATH79_DEV_AP9X_PCI if PCI
  3985. + select ATH79_DEV_ETH
  3986. + select ATH79_DEV_GPIO_BUTTONS
  3987. + select ATH79_DEV_LEDS_GPIO
  3988. + select ATH79_DEV_SPI
  3989. + select ATH79_DEV_M25P80
  3990. + select ATH79_DEV_WMAC
  3991. + select ATH79_DEV_NFC
  3992. + select ATH79_DEV_USB
  3993. +
  3994. +config ATH79_MACH_DRAGINO2
  3995. + bool "DRAGINO V2 support"
  3996. + select SOC_AR933X
  3997. + select ATH79_DEV_M25P80
  3998. + select ATH79_DEV_GPIO_BUTTONS
  3999. + select ATH79_DEV_LEDS_GPIO
  4000. + select ATH79_DEV_WMAC
  4001. + select ATH79_DEV_ETH
  4002. + select ATH79_DEV_USB
  4003. +
  4004. +config ATH79_MACH_ESR900
  4005. + bool "EnGenius ESR900 board support"
  4006. + select SOC_QCA955X
  4007. + select ATH79_DEV_ETH
  4008. + select ATH79_DEV_GPIO_BUTTONS
  4009. + select ATH79_DEV_LEDS_GPIO
  4010. + select ATH79_DEV_M25P80
  4011. + select ATH79_DEV_USB
  4012. + select ATH79_DEV_WMAC
  4013. +
  4014. +config ATH79_MACH_EW_DORIN
  4015. + bool "embedded wireless Dorin Platform support"
  4016. + select SOC_AR933X
  4017. + select ATH79_DEV_M25P80
  4018. + select ATH79_DEV_GPIO_BUTTONS
  4019. + select ATH79_DEV_LEDS_GPIO
  4020. + select ATH79_DEV_WMAC
  4021. + select ATH79_DEV_ETH
  4022. + help
  4023. + Say 'Y' here if you want your kernel to support the
  4024. + Dorin Platform from www.80211.de .
  4025. +
  4026. +config ATH79_MACH_EL_M150
  4027. + bool "EasyLink EL-M150 support"
  4028. + select SOC_AR933X
  4029. + select ATH79_DEV_ETH
  4030. + select ATH79_DEV_GPIO_BUTTONS
  4031. + select ATH79_DEV_LEDS_GPIO
  4032. + select ATH79_DEV_M25P80
  4033. + select ATH79_DEV_USB
  4034. + select ATH79_DEV_WMAC
  4035. +
  4036. +config ATH79_MACH_EL_MINI
  4037. + bool "EasyLink EL-MINI support"
  4038. + select SOC_AR933X
  4039. + select ATH79_DEV_ETH
  4040. + select ATH79_DEV_GPIO_BUTTONS
  4041. + select ATH79_DEV_LEDS_GPIO
  4042. + select ATH79_DEV_M25P80
  4043. + select ATH79_DEV_USB
  4044. + select ATH79_DEV_WMAC
  4045. +
  4046. +config ATH79_MACH_GL_AR150
  4047. + bool "GL AR150 support"
  4048. + select SOC_AR933X
  4049. + select ATH79_DEV_ETH
  4050. + select ATH79_DEV_GPIO_BUTTONS
  4051. + select ATH79_DEV_LEDS_GPIO
  4052. + select ATH79_DEV_M25P80
  4053. + select ATH79_DEV_USB
  4054. + select ATH79_DEV_WMAC
  4055. +
  4056. +config ATH79_MACH_GL_AR300
  4057. + bool "GL_AR300 support"
  4058. + select SOC_AR934X
  4059. + select ATH79_DEV_ETH
  4060. + select ATH79_DEV_GPIO_BUTTONS
  4061. + select ATH79_DEV_LEDS_GPIO
  4062. + select ATH79_DEV_M25P80
  4063. + select ATH79_DEV_USB
  4064. + select ATH79_DEV_WMAC
  4065. +
  4066. +config ATH79_MACH_GL_DOMINO
  4067. + bool "DOMINO support"
  4068. + select SOC_AR933X
  4069. + select ATH79_DEV_ETH
  4070. + select ATH79_DEV_GPIO_BUTTONS
  4071. + select ATH79_DEV_LEDS_GPIO
  4072. + select ATH79_DEV_M25P80
  4073. + select ATH79_DEV_USB
  4074. + select ATH79_DEV_WMAC
  4075. +
  4076. +config ATH79_MACH_GL_INET
  4077. + bool "GL-INET support"
  4078. + select SOC_AR933X
  4079. + select ATH79_DEV_ETH
  4080. + select ATH79_DEV_GPIO_BUTTONS
  4081. + select ATH79_DEV_LEDS_GPIO
  4082. + select ATH79_DEV_M25P80
  4083. + select ATH79_DEV_USB
  4084. + select ATH79_DEV_WMAC
  4085. +
  4086. +config ATH79_MACH_EAP300V2
  4087. + bool "EnGenius EAP300 v2 support"
  4088. + select SOC_AR934X
  4089. + select ATH79_DEV_ETH
  4090. + select ATH79_DEV_GPIO_BUTTONS
  4091. + select ATH79_DEV_LEDS_GPIO
  4092. + select ATH79_DEV_M25P80
  4093. + select ATH79_DEV_WMAC
  4094. +
  4095. +config ATH79_MACH_GS_MINIBOX_V1
  4096. + bool "Gainstrong MiniBox V1.0 support"
  4097. + select SOC_AR933X
  4098. + select ARH79_DEV_ETH
  4099. + select ARH79_DEV_GPIO_BUTTONS
  4100. + select ATH79_DEV_LEDS_GPIO
  4101. + select ATH79_DEV_M25P80
  4102. + select ATH79_DEV_USB
  4103. + select ATH79_DEV_WMAC
  4104. +
  4105. +config ATH79_MACH_GS_OOLITE
  4106. + bool "GS Oolite V1 support"
  4107. + select SOC_AR933X
  4108. + select ARH79_DEV_ETH
  4109. + select ARH79_DEV_GPIO_BUTTONS
  4110. + select ATH79_DEV_LEDS_GPIO
  4111. + select ATH79_DEV_M25P80
  4112. + select ATH79_DEV_USB
  4113. + select ATH79_DEV_WMAC
  4114. +
  4115. +config ATH79_MACH_HIWIFI_HC6361
  4116. + bool "HiWiFi HC6361 board support"
  4117. + select SOC_AR933X
  4118. + select ATH79_DEV_ETH
  4119. + select ATH79_DEV_GPIO_BUTTONS
  4120. + select ATH79_DEV_LEDS_GPIO
  4121. + select ATH79_DEV_M25P80
  4122. + select ATH79_DEV_USB
  4123. + select ATH79_DEV_WMAC
  4124. +
  4125. +config ATH79_MACH_JA76PF
  4126. + bool "jjPlus JA76PF board support"
  4127. + select SOC_AR71XX
  4128. + select ATH79_DEV_ETH
  4129. + select ATH79_DEV_GPIO_BUTTONS
  4130. + select ATH79_DEV_LEDS_GPIO
  4131. + select ATH79_DEV_M25P80
  4132. + select ATH79_DEV_USB
  4133. +
  4134. +config ATH79_MACH_JWAP003
  4135. + bool "jjPlus JWAP003 board support"
  4136. + select SOC_AR71XX
  4137. + select ATH79_DEV_ETH
  4138. + select ATH79_DEV_GPIO_BUTTONS
  4139. + select ATH79_DEV_M25P80
  4140. + select ATH79_DEV_USB
  4141. +
  4142. +config ATH79_MACH_WRT160NL
  4143. + bool "Linksys WRT160NL board support"
  4144. + select SOC_AR913X
  4145. + select ATH79_DEV_ETH
  4146. + select ATH79_DEV_GPIO_BUTTONS
  4147. + select ATH79_DEV_LEDS_GPIO
  4148. + select ATH79_DEV_M25P80
  4149. + select ATH79_DEV_USB
  4150. + select ATH79_DEV_WMAC
  4151. + select ATH79_NVRAM
  4152. +
  4153. +config ATH79_MACH_WRT400N
  4154. + bool "Linksys WRT400N board support"
  4155. + select SOC_AR71XX
  4156. + select ATH79_DEV_AP9X_PCI if PCI
  4157. + select ATH79_DEV_ETH
  4158. + select ATH79_DEV_GPIO_BUTTONS
  4159. + select ATH79_DEV_LEDS_GPIO
  4160. + select ATH79_DEV_M25P80
  4161. +
  4162. +config ATH79_MACH_R6100
  4163. + bool "NETGEAR R6100 board support"
  4164. + select SOC_AR934X
  4165. + select ATH79_DEV_AP9X_PCI if PCI
  4166. + select ATH79_DEV_ETH
  4167. + select ATH79_DEV_GPIO_BUTTONS
  4168. + select ATH79_DEV_LEDS_GPIO
  4169. + select ATH79_DEV_NFC
  4170. + select ATH79_DEV_USB
  4171. + select ATH79_DEV_WMAC
  4172. +
  4173. +config ATH79_MACH_MC_MAC1200R
  4174. + bool "MERCURY MAC1200R board support"
  4175. + select SOC_AR934X
  4176. + select ATH79_DEV_AP9X_PCI if PCI
  4177. + select ATH79_DEV_ETH
  4178. + select ATH79_DEV_GPIO_BUTTONS
  4179. + select ATH79_DEV_LEDS_GPIO
  4180. + select ATH79_DEV_M25P80
  4181. + select ATH79_DEV_WMAC
  4182. +
  4183. +config ATH79_MACH_RB4XX
  4184. + bool "MikroTik RouterBOARD 4xx series support"
  4185. + select SOC_AR71XX
  4186. + select ATH79_DEV_ETH
  4187. + select ATH79_DEV_GPIO_BUTTONS
  4188. + select ATH79_DEV_LEDS_GPIO
  4189. + select ATH79_DEV_USB
  4190. +
  4191. +config ATH79_MACH_RB750
  4192. + bool "MikroTik RouterBOARD 750 support"
  4193. + select SOC_AR724X
  4194. + select ATH79_DEV_AP9X_PCI if PCI
  4195. + select ATH79_DEV_ETH
  4196. + select ATH79_DEV_USB
  4197. + select ATH79_ROUTERBOOT
  4198. +
  4199. +config ATH79_MACH_RB91X
  4200. + bool "MikroTik RouterBOARD 91X support"
  4201. + select SOC_AR934X
  4202. + select ATH79_DEV_ETH
  4203. + select ATH79_DEV_SPI
  4204. + select ATH79_DEV_WMAC
  4205. + select ATH79_DEV_USB
  4206. + select ATH79_ROUTERBOOT
  4207. +
  4208. +config ATH79_MACH_RB922
  4209. + bool "MikroTik RouterBOARD 922 support"
  4210. + select SOC_QCA955X
  4211. + select ATH79_DEV_ETH
  4212. + select ATH79_DEV_M25P80
  4213. + select ATH79_DEV_NFC
  4214. + select ATH79_DEV_USB
  4215. + select ATH79_ROUTERBOOT
  4216. + select RLE_DECOMPRESS
  4217. +
  4218. +config ATH79_MACH_RB95X
  4219. + bool "MikroTik RouterBOARD 95X support"
  4220. + select SOC_AR934X
  4221. + select ATH79_DEV_ETH
  4222. + select ATH79_DEV_NFC
  4223. + select ATH79_DEV_WMAC
  4224. + select ATH79_DEV_USB
  4225. + select ATH79_ROUTERBOOT
  4226. +
  4227. +config ATH79_MACH_RB2011
  4228. + bool "MikroTik RouterBOARD 2011 support"
  4229. + select SOC_AR934X
  4230. + select ATH79_DEV_ETH
  4231. + select ATH79_DEV_M25P80
  4232. + select ATH79_DEV_NFC
  4233. + select ATH79_DEV_USB
  4234. + select ATH79_DEV_WMAC
  4235. + select ATH79_ROUTERBOOT
  4236. +
  4237. +config ATH79_MACH_RBSXTLITE
  4238. + bool "MikroTik RouterBOARD SXT Lite"
  4239. + select SOC_AR934X
  4240. + select ATH79_DEV_ETH
  4241. + select ATH79_DEV_NFC
  4242. + select ATH79_DEV_WMAC
  4243. + select ATH79_ROUTERBOOT
  4244. +
  4245. +config ATH79_MACH_SMART_300
  4246. + bool "NC-LINK SMART-300 board support"
  4247. + select SOC_AR934X
  4248. + select ATH79_DEV_ETH
  4249. + select ATH79_DEV_GPIO_BUTTONS
  4250. + select ATH79_DEV_LEDS_GPIO
  4251. + select ATH79_DEV_M25P80
  4252. + select ATH79_DEV_WMAC
  4253. +
  4254. +config ATH79_MACH_WNDAP360
  4255. + bool "NETGEAR WNDAP360 board support"
  4256. + select SOC_AR71XX
  4257. + select ATH79_DEV_AP9X_PCI if PCI
  4258. + select ATH79_DEV_ETH
  4259. + select ATH79_DEV_GPIO_BUTTONS
  4260. + select ATH79_DEV_LEDS_GPIO
  4261. + select ATH79_DEV_M25P80
  4262. +
  4263. +config ATH79_MACH_WNDR3700
  4264. + bool "NETGEAR WNDR3700 board support"
  4265. + select SOC_AR71XX
  4266. + select ATH79_DEV_AP9X_PCI if PCI
  4267. + select ATH79_DEV_ETH
  4268. + select ATH79_DEV_GPIO_BUTTONS
  4269. + select ATH79_DEV_LEDS_GPIO
  4270. + select ATH79_DEV_M25P80
  4271. + select ATH79_DEV_USB
  4272. +
  4273. +config ATH79_MACH_WNDR4300
  4274. + bool "NETGEAR WNDR3700v4/WNDR4300 board support"
  4275. + select SOC_AR934X
  4276. + select ATH79_DEV_AP9X_PCI if PCI
  4277. + select ATH79_DEV_ETH
  4278. + select ATH79_DEV_GPIO_BUTTONS
  4279. + select ATH79_DEV_LEDS_GPIO
  4280. + select ATH79_DEV_NFC
  4281. + select ATH79_DEV_USB
  4282. + select ATH79_DEV_WMAC
  4283. +
  4284. +config ATH79_MACH_WNR2000
  4285. + bool "NETGEAR WNR2000 board support"
  4286. + select SOC_AR913X
  4287. + select ATH79_DEV_ETH
  4288. + select ATH79_DEV_GPIO_BUTTONS
  4289. + select ATH79_DEV_LEDS_GPIO
  4290. + select ATH79_DEV_M25P80
  4291. + select ATH79_DEV_WMAC
  4292. +
  4293. +config ATH79_MACH_WNR2000_V3
  4294. + bool "NETGEAR WNR2000 V3/WNR612 v2/WNR1000 v2 board support"
  4295. + select SOC_AR724X
  4296. + select ATH79_DEV_AP9X_PCI if PCI
  4297. + select ATH79_DEV_ETH
  4298. + select ATH79_DEV_GPIO_BUTTONS
  4299. + select ATH79_DEV_LEDS_GPIO
  4300. + select ATH79_DEV_M25P80
  4301. +
  4302. + config ATH79_MACH_WNR2200
  4303. + bool "NETGEAR WNR2200 board support"
  4304. + select SOC_AR724X
  4305. + select ATH79_DEV_AP9X_PCI if PCI
  4306. + select ATH79_DEV_ETH
  4307. + select ATH79_DEV_GPIO_BUTTONS
  4308. + select ATH79_DEV_LEDS_GPIO
  4309. + select ATH79_DEV_M25P80
  4310. + select ATH79_DEV_USB
  4311. +
  4312. +config ATH79_MACH_WNR2000_V4
  4313. + bool "NETGEAR WNR2000 V4"
  4314. + select SOC_AR934X
  4315. + select ATH79_DEV_ETH
  4316. + select ATH79_DEV_GPIO_BUTTONS
  4317. + select ATH79_DEV_LEDS_GPIO
  4318. + select ATH79_DEV_M25P80
  4319. + select ATH79_DEV_USB
  4320. + select ATH79_DEV_WMAC
  4321. +
  4322. +config ATH79_MACH_OM2P
  4323. + bool "OpenMesh OM2P board support"
  4324. + select SOC_AR724X
  4325. + select SOC_AR933X
  4326. + select ATH79_DEV_AP9X_PCI if PCI
  4327. + select ATH79_DEV_ETH
  4328. + select ATH79_DEV_GPIO_BUTTONS
  4329. + select ATH79_DEV_LEDS_GPIO
  4330. + select ATH79_DEV_M25P80
  4331. + select ATH79_DEV_WMAC
  4332. +
  4333. +config ATH79_MACH_OM5P
  4334. + bool "OpenMesh OM5P board support"
  4335. + select SOC_AR934X
  4336. + select ATH79_DEV_AP9X_PCI if PCI
  4337. + select ATH79_DEV_ETH
  4338. + select ATH79_DEV_GPIO_BUTTONS
  4339. + select ATH79_DEV_LEDS_GPIO
  4340. + select ATH79_DEV_M25P80
  4341. + select ATH79_DEV_WMAC
  4342. +
  4343. +config ATH79_MACH_ONION_OMEGA
  4344. + bool "ONION OMEGA support"
  4345. + select SOC_AR933X
  4346. + select ATH79_DEV_ETH
  4347. + select ATH79_DEV_GPIO_BUTTONS
  4348. + select ATH79_DEV_LEDS_GPIO
  4349. + select ATH79_DEV_M25P80
  4350. + select ATH79_DEV_USB
  4351. + select ATH79_DEV_WMAC
  4352. +
  4353. +config ATH79_MACH_MR12
  4354. + bool "Meraki MR12 board support"
  4355. + select SOC_AR724X
  4356. + select ATH79_DEV_AP9X_PCI if PCI
  4357. + select ATH79_DEV_ETH
  4358. + select ATH79_DEV_GPIO_BUTTONS
  4359. + select ATH79_DEV_LEDS_GPIO
  4360. + select ATH79_DEV_M25P80
  4361. + select ATH79_DEV_WMAC
  4362. +
  4363. +config ATH79_MACH_MR16
  4364. + bool "Meraki MR16 board support"
  4365. + select SOC_AR71XX
  4366. + select ATH79_DEV_AP9X_PCI if PCI
  4367. + select ATH79_DEV_ETH
  4368. + select ATH79_DEV_GPIO_BUTTONS
  4369. + select ATH79_DEV_LEDS_GPIO
  4370. + select ATH79_DEV_M25P80
  4371. + select ATH79_DEV_WMAC
  4372. +
  4373. +config ATH79_MACH_MR600
  4374. + bool "OpenMesh MR600 board support"
  4375. + select SOC_AR934X
  4376. + select ATH79_DEV_AP9X_PCI if PCI
  4377. + select ATH79_DEV_ETH
  4378. + select ATH79_DEV_GPIO_BUTTONS
  4379. + select ATH79_DEV_LEDS_GPIO
  4380. + select ATH79_DEV_M25P80
  4381. + select ATH79_DEV_WMAC
  4382. +
  4383. +config ATH79_MACH_MZK_W04NU
  4384. + bool "Planex MZK-W04NU board support"
  4385. + select SOC_AR913X
  4386. + select ATH79_DEV_ETH
  4387. + select ATH79_DEV_GPIO_BUTTONS
  4388. + select ATH79_DEV_LEDS_GPIO
  4389. + select ATH79_DEV_M25P80
  4390. + select ATH79_DEV_USB
  4391. + select ATH79_DEV_WMAC
  4392. +
  4393. +config ATH79_MACH_MZK_W300NH
  4394. + bool "Planex MZK-W300NH board support"
  4395. + select SOC_AR913X
  4396. + select ATH79_DEV_ETH
  4397. + select ATH79_DEV_GPIO_BUTTONS
  4398. + select ATH79_DEV_LEDS_GPIO
  4399. + select ATH79_DEV_M25P80
  4400. + select ATH79_DEV_WMAC
  4401. +
  4402. +config ATH79_MACH_RW2458N
  4403. + bool "Redwave RW2458N board support"
  4404. + select SOC_AR724X
  4405. + select ATH79_DEV_AP9X_PCI if PCI
  4406. + select ATH79_DEV_ETH
  4407. + select ATH79_DEV_GPIO_BUTTONS
  4408. + select ATH79_DEV_LEDS_GPIO
  4409. + select ATH79_DEV_M25P80
  4410. + select ATH79_DEV_USB
  4411. +
  4412. +config ATH79_MACH_CAP4200AG
  4413. + bool "Senao CAP4200AG support"
  4414. + select SOC_AR934X
  4415. + select ATH79_DEV_AP9X_PCI if PCI
  4416. + select ATH79_DEV_ETH
  4417. + select ATH79_DEV_GPIO_BUTTONS
  4418. + select ATH79_DEV_LEDS_GPIO
  4419. + select ATH79_DEV_M25P80
  4420. + select ATH79_DEV_WMAC
  4421. +
  4422. +config ATH79_MACH_MR1750
  4423. + bool "OpenMesh MR1750 board support"
  4424. + select SOC_QCA955X
  4425. + select ATH79_DEV_AP9X_PCI if PCI
  4426. + select ATH79_DEV_ETH
  4427. + select ATH79_DEV_GPIO_BUTTONS
  4428. + select ATH79_DEV_LEDS_GPIO
  4429. + select ATH79_DEV_M25P80
  4430. + select ATH79_DEV_WMAC
  4431. +
  4432. +config ATH79_MACH_MR900
  4433. + bool "OpenMesh MR900 board support"
  4434. + select SOC_QCA955X
  4435. + select ATH79_DEV_AP9X_PCI if PCI
  4436. + select ATH79_DEV_ETH
  4437. + select ATH79_DEV_GPIO_BUTTONS
  4438. + select ATH79_DEV_LEDS_GPIO
  4439. + select ATH79_DEV_M25P80
  4440. + select ATH79_DEV_WMAC
  4441. +
  4442. +config ATH79_MACH_EAP7660D
  4443. + bool "Senao EAP7660D support"
  4444. + select SOC_AR71XX
  4445. + select ATH79_DEV_ETH
  4446. + select ATH79_DEV_GPIO_BUTTONS
  4447. + select ATH79_DEV_LEDS_GPIO
  4448. + select ATH79_DEV_M25P80
  4449. +
  4450. +config ATH79_MACH_BSB
  4451. + bool "Smart Electronics Black Swift board"
  4452. + select SOC_AR933X
  4453. + select ATH79_DEV_ETH
  4454. + select ATH79_DEV_GPIO_BUTTONS
  4455. + select ATH79_DEV_LEDS_GPIO
  4456. + select ATH79_DEV_M25P80
  4457. + select ATH79_DEV_USB
  4458. + select ATH79_DEV_WMAC
  4459. +
  4460. +config ATH79_MACH_ARCHER_C7
  4461. + bool "TP-LINK Archer C5/C7/TL-WDR4900 v2 board support"
  4462. + select SOC_QCA955X
  4463. + select ATH79_DEV_AP9X_PCI if PCI
  4464. + select ATH79_DEV_ETH
  4465. + select ATH79_DEV_GPIO_BUTTONS
  4466. + select ATH79_DEV_LEDS_GPIO
  4467. + select ATH79_DEV_M25P80
  4468. + select ATH79_DEV_USB
  4469. + select ATH79_DEV_WMAC
  4470. +
  4471. +config ATH79_MACH_CPE510
  4472. + bool "TP-LINK CPE510 support"
  4473. + select SOC_AR934X
  4474. + select ATH79_DEV_ETH
  4475. + select ATH79_DEV_GPIO_BUTTONS
  4476. + select ATH79_DEV_LEDS_GPIO
  4477. + select ATH79_DEV_M25P80
  4478. + select ATH79_DEV_WMAC
  4479. +
  4480. +config ATH79_MACH_TL_MR11U
  4481. + bool "TP-LINK TL-MR11U/TL-MR3040 support"
  4482. + select SOC_AR933X
  4483. + select ATH79_DEV_ETH
  4484. select ATH79_DEV_GPIO_BUTTONS
  4485. select ATH79_DEV_LEDS_GPIO
  4486. - select ATH79_DEV_SPI
  4487. + select ATH79_DEV_M25P80
  4488. select ATH79_DEV_USB
  4489. select ATH79_DEV_WMAC
  4490. - help
  4491. - Say 'Y' here if you want your kernel to support the
  4492. - Atheros AP121 reference board.
  4493. -config ATH79_MACH_AP136
  4494. - bool "Atheros AP136 reference board"
  4495. - select SOC_QCA955X
  4496. +config ATH79_MACH_TL_MR13U
  4497. + bool "TP-LINK TL-MR13U support"
  4498. + select SOC_AR933X
  4499. + select ATH79_DEV_ETH
  4500. select ATH79_DEV_GPIO_BUTTONS
  4501. select ATH79_DEV_LEDS_GPIO
  4502. - select ATH79_DEV_SPI
  4503. + select ATH79_DEV_M25P80
  4504. select ATH79_DEV_USB
  4505. select ATH79_DEV_WMAC
  4506. - help
  4507. - Say 'Y' here if you want your kernel to support the
  4508. - Atheros AP136 reference board.
  4509. -config ATH79_MACH_AP81
  4510. - bool "Atheros AP81 reference board"
  4511. +config ATH79_MACH_TL_MR3020
  4512. + bool "TP-LINK TL-MR3020 support"
  4513. + select SOC_AR933X
  4514. + select ATH79_DEV_ETH
  4515. + select ATH79_DEV_GPIO_BUTTONS
  4516. + select ATH79_DEV_LEDS_GPIO
  4517. + select ATH79_DEV_M25P80
  4518. + select ATH79_DEV_USB
  4519. + select ATH79_DEV_WMAC
  4520. +
  4521. +config ATH79_MACH_TL_MR3X20
  4522. + bool "TP-LINK TL-MR3220/3420 support"
  4523. + select SOC_AR724X
  4524. + select ATH79_DEV_AP9X_PCI if PCI
  4525. + select ATH79_DEV_ETH
  4526. + select ATH79_DEV_GPIO_BUTTONS
  4527. + select ATH79_DEV_LEDS_GPIO
  4528. + select ATH79_DEV_M25P80
  4529. + select ATH79_DEV_USB
  4530. +
  4531. +config ATH79_MACH_TL_WAX50RE
  4532. + bool "TP-LINK TL-WA750/850RE support"
  4533. + select SOC_AR934X
  4534. + select ATH79_DEV_ETH
  4535. + select ATH79_DEV_GPIO_BUTTONS
  4536. + select ATH79_DEV_LEDS_GPIO
  4537. + select ATH79_DEV_M25P80
  4538. + select ATH79_DEV_WMAC
  4539. +
  4540. +config ATH79_MACH_TL_WA701ND_V2
  4541. + bool "TP-LINK TL-WA701ND v2 support"
  4542. + select SOC_AR933X
  4543. + select ATH79_DEV_ETH
  4544. + select ATH79_DEV_GPIO_BUTTONS
  4545. + select ATH79_DEV_LEDS_GPIO
  4546. + select ATH79_DEV_M25P80
  4547. + select ATH79_DEV_USB
  4548. + select ATH79_DEV_WMAC
  4549. +
  4550. +config ATH79_MACH_TL_WA7210N_V2
  4551. + bool "TP-LINK TL-WA7210N v2 support"
  4552. + select SOC_AR724X
  4553. + select ATH79_DEV_AP9X_PCI if PCI
  4554. + select ATH79_DEV_ETH
  4555. + select ATH79_DEV_LEDS_GPIO
  4556. + select ATH79_DEV_GPIO_BUTTONS
  4557. + select ATH79_DEV_M25P80
  4558. + select ATH79_DEV_WMAC
  4559. +
  4560. +config ATH79_MACH_TL_WA830RE_V2
  4561. + bool "TP-LINK TL-WA830RE v2 support"
  4562. + select SOC_AR934X
  4563. + select ATH79_DEV_ETH
  4564. + select ATH79_DEV_GPIO_BUTTONS
  4565. + select ATH79_DEV_LEDS_GPIO
  4566. + select ATH79_DEV_M25P80
  4567. + select ATH79_DEV_USB
  4568. + select ATH79_DEV_WMAC
  4569. +
  4570. +config ATH79_MACH_TL_WA901ND
  4571. + bool "TP-LINK TL-WA901ND/TL-WA7510N support"
  4572. + select SOC_AR724X
  4573. + select ATH79_DEV_AP9X_PCI if PCI
  4574. + select ATH79_DEV_ETH
  4575. + select ATH79_DEV_GPIO_BUTTONS
  4576. + select ATH79_DEV_LEDS_GPIO
  4577. + select ATH79_DEV_M25P80
  4578. +
  4579. +config ATH79_MACH_TL_WA901ND_V2
  4580. + bool "TP-LINK TL-WA901ND v2 support"
  4581. select SOC_AR913X
  4582. + select ATH79_DEV_ETH
  4583. select ATH79_DEV_GPIO_BUTTONS
  4584. select ATH79_DEV_LEDS_GPIO
  4585. - select ATH79_DEV_SPI
  4586. + select ATH79_DEV_M25P80
  4587. + select ATH79_DEV_WMAC
  4588. +
  4589. +config ATH79_MACH_TL_WDR3320_V2
  4590. + bool "TP-LINK TL-WDR3320 v2 board support"
  4591. + select SOC_AR934X
  4592. + select ATH79_DEV_AP9X_PCI if PCI
  4593. + select ATH79_DEV_ETH
  4594. + select ATH79_DEV_GPIO_BUTTONS
  4595. + select ATH79_DEV_LEDS_GPIO
  4596. + select ATH79_DEV_M25P80
  4597. select ATH79_DEV_USB
  4598. select ATH79_DEV_WMAC
  4599. - help
  4600. - Say 'Y' here if you want your kernel to support the
  4601. - Atheros AP81 reference board.
  4602. -config ATH79_MACH_DB120
  4603. - bool "Atheros DB120 reference board"
  4604. +config ATH79_MACH_TL_WDR3500
  4605. + bool "TP-LINK TL-WDR3500 board support"
  4606. select SOC_AR934X
  4607. + select ATH79_DEV_AP9X_PCI if PCI
  4608. + select ATH79_DEV_ETH
  4609. select ATH79_DEV_GPIO_BUTTONS
  4610. select ATH79_DEV_LEDS_GPIO
  4611. - select ATH79_DEV_SPI
  4612. + select ATH79_DEV_M25P80
  4613. select ATH79_DEV_USB
  4614. select ATH79_DEV_WMAC
  4615. - help
  4616. - Say 'Y' here if you want your kernel to support the
  4617. - Atheros DB120 reference board.
  4618. -config ATH79_MACH_PB44
  4619. - bool "Atheros PB44 reference board"
  4620. +config ATH79_MACH_TL_WDR4300
  4621. + bool "TP-LINK TL-WDR3600/4300/4310 board support"
  4622. + select SOC_AR934X
  4623. + select ATH79_DEV_AP9X_PCI if PCI
  4624. + select ATH79_DEV_ETH
  4625. + select ATH79_DEV_GPIO_BUTTONS
  4626. + select ATH79_DEV_LEDS_GPIO
  4627. + select ATH79_DEV_M25P80
  4628. + select ATH79_DEV_USB
  4629. + select ATH79_DEV_WMAC
  4630. +
  4631. +config ATH79_MACH_TL_WDR6500_V2
  4632. + bool "TP-LINK TL-WDR6500 v2 board support"
  4633. + select SOC_QCA956X
  4634. + select ATH79_DEV_AP9X_PCI if PCI
  4635. + select ATH79_DEV_ETH
  4636. + select ATH79_DEV_GPIO_BUTTONS
  4637. + select ATH79_DEV_LEDS_GPIO
  4638. + select ATH79_DEV_M25P80
  4639. + select ATH79_DEV_USB
  4640. + select ATH79_DEV_WMAC
  4641. +
  4642. +config ATH79_MACH_TL_WR703N
  4643. + bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
  4644. + select SOC_AR933X
  4645. + select ATH79_DEV_ETH
  4646. + select ATH79_DEV_GPIO_BUTTONS
  4647. + select ATH79_DEV_LEDS_GPIO
  4648. + select ATH79_DEV_M25P80
  4649. + select ATH79_DEV_USB
  4650. + select ATH79_DEV_WMAC
  4651. +
  4652. +config ATH79_MACH_TL_WR720N_V3
  4653. + bool "TP-LINK TL-WR720N v3/v4 support"
  4654. + select SOC_AR933X
  4655. + select ATH79_DEV_ETH
  4656. + select ATH79_DEV_GPIO_BUTTONS
  4657. + select ATH79_DEV_LEDS_GPIO
  4658. + select ATH79_DEV_M25P80
  4659. + select ATH79_DEV_USB
  4660. + select ATH79_DEV_WMAC
  4661. +
  4662. +config ATH79_MACH_TL_WR741ND
  4663. + bool "TP-LINK TL-WR741ND support"
  4664. + select SOC_AR724X
  4665. + select ATH79_DEV_AP9X_PCI if PCI
  4666. + select ATH79_DEV_ETH
  4667. + select ATH79_DEV_GPIO_BUTTONS
  4668. + select ATH79_DEV_LEDS_GPIO
  4669. + select ATH79_DEV_M25P80
  4670. +
  4671. +config ATH79_MACH_TL_WR741ND_V4
  4672. + bool "TP-LINK TL-WR741ND v4/TL-MR3220 v2 support"
  4673. + select SOC_AR933X
  4674. + select ATH79_DEV_ETH
  4675. + select ATH79_DEV_GPIO_BUTTONS
  4676. + select ATH79_DEV_LEDS_GPIO
  4677. + select ATH79_DEV_M25P80
  4678. + select ATH79_DEV_USB
  4679. + select ATH79_DEV_WMAC
  4680. +
  4681. +config ATH79_MACH_TL_WR841N_V1
  4682. + bool "TP-LINK TL-WR841N v1 support"
  4683. select SOC_AR71XX
  4684. + select ATH79_DEV_DSA
  4685. + select ATH79_DEV_ETH
  4686. select ATH79_DEV_GPIO_BUTTONS
  4687. select ATH79_DEV_LEDS_GPIO
  4688. - select ATH79_DEV_SPI
  4689. + select ATH79_DEV_M25P80
  4690. +
  4691. +config ATH79_MACH_TL_WR841N_V8
  4692. + bool "TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 support"
  4693. + select SOC_AR934X
  4694. + select ATH79_DEV_ETH
  4695. + select ATH79_DEV_GPIO_BUTTONS
  4696. + select ATH79_DEV_LEDS_GPIO
  4697. + select ATH79_DEV_M25P80
  4698. + select ATH79_DEV_USB
  4699. + select ATH79_DEV_WMAC
  4700. +
  4701. +config ATH79_MACH_TL_WR841N_V9
  4702. + bool "TP-LINK TL-WR841N/ND v9 support"
  4703. + select SOC_QCA953X
  4704. + select ATH79_DEV_ETH
  4705. + select ATH79_DEV_GPIO_BUTTONS
  4706. + select ATH79_DEV_LEDS_GPIO
  4707. + select ATH79_DEV_M25P80
  4708. + select ATH79_DEV_WMAC
  4709. +
  4710. +config ATH79_MACH_TL_WR941ND
  4711. + bool "TP-LINK TL-WR941ND support"
  4712. + select SOC_AR913X
  4713. + select ATH79_DEV_DSA
  4714. + select ATH79_DEV_ETH
  4715. + select ATH79_DEV_GPIO_BUTTONS
  4716. + select ATH79_DEV_LEDS_GPIO
  4717. + select ATH79_DEV_M25P80
  4718. + select ATH79_DEV_WMAC
  4719. +
  4720. +config ATH79_MACH_TL_WR941ND_V6
  4721. + bool "TP-LINK TL-WR941ND v6 support"
  4722. + select SOC_QCA956X
  4723. + select ATH79_DEV_ETH
  4724. + select ATH79_DEV_GPIO_BUTTONS
  4725. + select ATH79_DEV_LEDS_GPIO
  4726. + select ATH79_DEV_M25P80
  4727. + select ATH79_DEV_WMAC
  4728. +
  4729. +config ATH79_MACH_TL_WR1041N_V2
  4730. + bool "TP-LINK TL-WR1041N v2 support"
  4731. + select SOC_AR934X
  4732. + select ATH79_DEV_AP9X_PCI if PCI
  4733. + select ATH79_DEV_ETH
  4734. + select ATH79_DEV_GPIO_BUTTONS
  4735. + select ATH79_DEV_LEDS_GPIO
  4736. + select ATH79_DEV_M25P80
  4737. + select ATH79_DEV_USB
  4738. + select ATH79_DEV_WMAC
  4739. +
  4740. +config ATH79_MACH_TL_WR1043ND
  4741. + bool "TP-LINK TL-WR1043ND support"
  4742. + select SOC_AR913X
  4743. + select ATH79_DEV_ETH
  4744. + select ATH79_DEV_GPIO_BUTTONS
  4745. + select ATH79_DEV_LEDS_GPIO
  4746. + select ATH79_DEV_M25P80
  4747. + select ATH79_DEV_USB
  4748. + select ATH79_DEV_WMAC
  4749. +
  4750. +config ATH79_MACH_TL_WR1043ND_V2
  4751. + bool "TP-LINK TL-WR1043ND v2 support"
  4752. + select SOC_QCA955X
  4753. + select ATH79_DEV_ETH
  4754. + select ATH79_DEV_GPIO_BUTTONS
  4755. + select ATH79_DEV_LEDS_GPIO
  4756. + select ATH79_DEV_M25P80
  4757. + select ATH79_DEV_USB
  4758. + select ATH79_DEV_WMAC
  4759. +
  4760. +config ATH79_MACH_TL_WR2543N
  4761. + bool "TP-LINK TL-WR2543N/ND support"
  4762. + select SOC_AR724X
  4763. + select ATH79_DEV_AP9X_PCI if PCI
  4764. + select ATH79_DEV_ETH
  4765. + select ATH79_DEV_GPIO_BUTTONS
  4766. + select ATH79_DEV_LEDS_GPIO
  4767. + select ATH79_DEV_M25P80
  4768. + select ATH79_DEV_USB
  4769. +
  4770. +config ATH79_MACH_TEW_632BRP
  4771. + bool "TRENDnet TEW-632BRP support"
  4772. + select SOC_AR913X
  4773. + select ATH79_DEV_ETH
  4774. + select ATH79_DEV_GPIO_BUTTONS
  4775. + select ATH79_DEV_LEDS_GPIO
  4776. + select ATH79_DEV_M25P80
  4777. + select ATH79_DEV_WMAC
  4778. + select ATH79_NVRAM
  4779. +
  4780. +config ATH79_MACH_TEW_673GRU
  4781. + bool "TRENDnet TEW-673GRU support"
  4782. + select SOC_AR71XX
  4783. + select ATH79_DEV_AP9X_PCI if PCI
  4784. + select ATH79_DEV_ETH
  4785. + select ATH79_DEV_GPIO_BUTTONS
  4786. + select ATH79_DEV_LEDS_GPIO
  4787. + select ATH79_DEV_M25P80
  4788. + select ATH79_DEV_USB
  4789. + select ATH79_NVRAM
  4790. +
  4791. +config ATH79_MACH_TEW_712BR
  4792. + bool "TRENDnet TEW-712BR support"
  4793. + select SOC_AR933X
  4794. + select ATH79_DEV_ETH
  4795. + select ATH79_DEV_GPIO_BUTTONS
  4796. + select ATH79_DEV_LEDS_GPIO
  4797. + select ATH79_DEV_M25P80
  4798. + select ATH79_DEV_WMAC
  4799. + select ATH79_NVRAM
  4800. +
  4801. +config ATH79_MACH_TEW_732BR
  4802. + bool "TRENDnet TEW-732BR support"
  4803. + select SOC_AR934X
  4804. + select ATH79_DEV_ETH
  4805. + select ATH79_DEV_GPIO_BUTTONS
  4806. + select ATH79_DEV_LEDS_GPIO
  4807. + select ATH79_DEV_M25P80
  4808. + select ATH79_DEV_WMAC
  4809. +
  4810. +config ATH79_MACH_UBNT
  4811. + bool "Ubiquiti AR71xx based boards support"
  4812. + select SOC_AR71XX
  4813. + select ATH79_DEV_ETH
  4814. + select ATH79_DEV_GPIO_BUTTONS
  4815. + select ATH79_DEV_LEDS_GPIO
  4816. + select ATH79_DEV_M25P80
  4817. select ATH79_DEV_USB
  4818. - help
  4819. - Say 'Y' here if you want your kernel to support the
  4820. - Atheros PB44 reference board.
  4821. config ATH79_MACH_UBNT_XM
  4822. - bool "Ubiquiti Networks XM (rev 1.0) board"
  4823. + bool "Ubiquiti Networks XM/UniFi boards"
  4824. select SOC_AR724X
  4825. + select SOC_AR934X
  4826. + select ATH79_DEV_AP9X_PCI if PCI
  4827. + select ATH79_DEV_ETH
  4828. select ATH79_DEV_GPIO_BUTTONS
  4829. select ATH79_DEV_LEDS_GPIO
  4830. - select ATH79_DEV_SPI
  4831. + select ATH79_DEV_M25P80
  4832. + select ATH79_DEV_USB
  4833. + select ATH79_DEV_WMAC
  4834. help
  4835. Say 'Y' here if you want your kernel to support the
  4836. Ubiquiti Networks XM (rev 1.0) board.
  4837. +config ATH79_MACH_WEIO
  4838. + bool "WeIO board"
  4839. + select SOC_AR933X
  4840. + select ATH79_DEV_GPIO_BUTTONS
  4841. + select ATH79_DEV_LEDS_GPIO
  4842. + select ATH79_DEV_M25P80
  4843. + select ATH79_DEV_USB
  4844. + select ATH79_DEV_WMAC
  4845. +
  4846. +config ATH79_MACH_MYNET_N600
  4847. + bool "WD My Net N600 board support"
  4848. + select SOC_AR934X
  4849. + select ATH79_DEV_ETH
  4850. + select ATH79_DEV_GPIO_BUTTONS
  4851. + select ATH79_DEV_LEDS_GPIO
  4852. + select ATH79_DEV_M25P80
  4853. + select ATH79_DEV_WMAC
  4854. + select ATH79_NVRAM
  4855. +
  4856. +config ATH79_MACH_MYNET_N750
  4857. + bool "WD My Net N750 board support"
  4858. + select SOC_AR934X
  4859. + select ATH79_DEV_ETH
  4860. + select ATH79_DEV_GPIO_BUTTONS
  4861. + select ATH79_DEV_LEDS_GPIO
  4862. + select ATH79_DEV_M25P80
  4863. + select ATH79_DEV_WMAC
  4864. + select ATH79_NVRAM
  4865. +
  4866. +config ATH79_MACH_MYNET_REXT
  4867. + bool "WD My Net Wi-Fi Range Extender board support"
  4868. + select SOC_AR934X
  4869. + select ATH79_DEV_AP9X_PCI if PCI
  4870. + select ATH79_DEV_ETH
  4871. + select ATH79_DEV_GPIO_BUTTONS
  4872. + select ATH79_DEV_LEDS_GPIO
  4873. + select ATH79_DEV_M25P80
  4874. + select ATH79_DEV_WMAC
  4875. + select ATH79_NVRAM
  4876. +
  4877. +config ATH79_MACH_ZCN_1523H
  4878. + bool "Zcomax ZCN-1523H support"
  4879. + select SOC_AR724X
  4880. + select ATH79_DEV_AP9X_PCI if PCI
  4881. + select ATH79_DEV_ETH
  4882. + select ATH79_DEV_GPIO_BUTTONS
  4883. + select ATH79_DEV_LEDS_GPIO
  4884. + select ATH79_DEV_M25P80
  4885. +
  4886. +config ATH79_MACH_NBG460N
  4887. + bool "Zyxel NBG460N/550N/550NH board support"
  4888. + select SOC_AR913X
  4889. + select ATH79_DEV_ETH
  4890. + select ATH79_DEV_GPIO_BUTTONS
  4891. + select ATH79_DEV_LEDS_GPIO
  4892. + select ATH79_DEV_M25P80
  4893. + select ATH79_DEV_WMAC
  4894. +
  4895. +config ATH79_MACH_NBG6716
  4896. + bool "Zyxel NBG6616/NBG6716 board support"
  4897. + select SOC_QCA955X
  4898. + select ATH79_DEV_ETH
  4899. + select ATH79_DEV_GPIO_BUTTONS
  4900. + select ATH79_DEV_LEDS_GPIO
  4901. + select ATH79_DEV_M25P80
  4902. + select ATH79_DEV_NFC
  4903. + select ATH79_DEV_USB
  4904. + select ATH79_DEV_WMAC
  4905. +
  4906. +config ATH79_MACH_CARAMBOLA2
  4907. + bool "8devices Carambola2 board"
  4908. + select SOC_AR933X
  4909. + select ATH79_DEV_ETH
  4910. + select ATH79_DEV_GPIO_BUTTONS
  4911. + select ATH79_DEV_LEDS_GPIO
  4912. + select ATH79_DEV_M25P80
  4913. + select ATH79_DEV_USB
  4914. + select ATH79_DEV_WMAC
  4915. +
  4916. +config ATH79_MACH_CF_E316N_V2
  4917. + bool "COMFAST CF-E316N v2 board"
  4918. + select SOC_AR934X
  4919. + select ATH79_DEV_ETH
  4920. + select ATH79_DEV_GPIO_BUTTONS
  4921. + select ATH79_DEV_LEDS_GPIO
  4922. + select ATH79_DEV_M25P80
  4923. + select ATH79_DEV_USB
  4924. + select ATH79_DEV_WMAC
  4925. +
  4926. +config ATH79_MACH_BHU_BXU2000N2_A
  4927. + bool "BHU BXU2000n-2 rev. A support"
  4928. + select SOC_AR934X
  4929. + select ATH79_DEV_ETH
  4930. + select ATH79_DEV_GPIO_BUTTONS
  4931. + select ATH79_DEV_LEDS_GPIO
  4932. + select ATH79_DEV_M25P80
  4933. + select ATH79_DEV_USB
  4934. + select ATH79_DEV_WMAC
  4935. +
  4936. +config ATH79_MACH_QIHOO_C301
  4937. + bool "Qihoo 360 C301 board support"
  4938. + select SOC_AR934X
  4939. + select ATH79_DEV_ETH
  4940. + select ATH79_DEV_GPIO_BUTTONS
  4941. + select ATH79_DEV_LEDS_GPIO
  4942. + select ATH79_DEV_M25P80
  4943. + select ATH79_DEV_WMAC
  4944. + select ATH79_DEV_USB
  4945. + select ATH79_NVRAM
  4946. +
  4947. endmenu
  4948. config SOC_AR71XX
  4949. @@ -93,12 +1484,39 @@
  4950. select PCI_AR724X if PCI
  4951. def_bool n
  4952. +config SOC_QCA953X
  4953. + select USB_ARCH_HAS_EHCI
  4954. + def_bool n
  4955. +
  4956. config SOC_QCA955X
  4957. select HW_HAS_PCI
  4958. select PCI_AR724X if PCI
  4959. def_bool n
  4960. -config PCI_AR724X
  4961. +config SOC_QCA956X
  4962. + select USB_ARCH_HAS_EHCI
  4963. + select HW_HAS_PCI
  4964. + select PCI_AR724X if PCI
  4965. + def_bool n
  4966. +
  4967. +config ATH79_DEV_M25P80
  4968. + select ATH79_DEV_SPI
  4969. + def_bool n
  4970. +
  4971. +config ATH79_DEV_AP9X_PCI
  4972. + select ATH79_PCI_ATH9K_FIXUP
  4973. + def_bool n
  4974. +
  4975. +config ATH79_DEV_DSA
  4976. + def_bool n
  4977. +
  4978. +config ATH79_DEV_ETH
  4979. + def_bool n
  4980. +
  4981. +config ATH79_DEV_DSA
  4982. + def_bool n
  4983. +
  4984. +config ATH79_DEV_ETH
  4985. def_bool n
  4986. config ATH79_DEV_GPIO_BUTTONS
  4987. @@ -107,6 +1525,10 @@
  4988. config ATH79_DEV_LEDS_GPIO
  4989. def_bool n
  4990. +config ATH79_DEV_NFC
  4991. + depends on (SOC_AR934X || SOC_QCA955X)
  4992. + def_bool n
  4993. +
  4994. config ATH79_DEV_SPI
  4995. def_bool n
  4996. @@ -114,7 +1536,21 @@
  4997. def_bool n
  4998. config ATH79_DEV_WMAC
  4999. - depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
  5000. + depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X || SOC_QCA956X)
  5001. + def_bool n
  5002. +
  5003. +config ATH79_NVRAM
  5004. + def_bool n
  5005. +
  5006. +config ATH79_PCI_ATH9K_FIXUP
  5007. + def_bool n
  5008. +
  5009. +config ATH79_ROUTERBOOT
  5010. + select RLE_DECOMPRESS
  5011. + select LZO_DECOMPRESS
  5012. + def_bool n
  5013. +
  5014. +config PCI_AR724X
  5015. def_bool n
  5016. endif
  5017. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-alfa-ap96.c linux-4.1.13/arch/mips/ath79/mach-alfa-ap96.c
  5018. --- linux-4.1.13.orig/arch/mips/ath79/mach-alfa-ap96.c 1970-01-01 01:00:00.000000000 +0100
  5019. +++ linux-4.1.13/arch/mips/ath79/mach-alfa-ap96.c 2015-09-13 20:04:35.064524285 +0200
  5020. @@ -0,0 +1,151 @@
  5021. +/*
  5022. + * ALFA Network AP96 board support
  5023. + *
  5024. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  5025. + *
  5026. + * This program is free software; you can redistribute it and/or modify it
  5027. + * under the terms of the GNU General Public License version 2 as published
  5028. + * by the Free Software Foundation.
  5029. + */
  5030. +
  5031. +#include <linux/init.h>
  5032. +#include <linux/bitops.h>
  5033. +#include <linux/gpio.h>
  5034. +#include <linux/platform_device.h>
  5035. +#include <linux/mmc/host.h>
  5036. +#include <linux/spi/spi.h>
  5037. +#include <linux/spi/mmc_spi.h>
  5038. +
  5039. +#include <asm/mach-ath79/ath79.h>
  5040. +#include <asm/mach-ath79/ar71xx_regs.h>
  5041. +
  5042. +#include "common.h"
  5043. +#include "dev-eth.h"
  5044. +#include "dev-gpio-buttons.h"
  5045. +#include "dev-spi.h"
  5046. +#include "dev-usb.h"
  5047. +#include "machtypes.h"
  5048. +#include "pci.h"
  5049. +
  5050. +#define ALFA_AP96_GPIO_PCIE_RESET 2
  5051. +#define ALFA_AP96_GPIO_SIM_DETECT 3
  5052. +#define ALFA_AP96_GPIO_MICROSD_CD 4
  5053. +#define ALFA_AP96_GPIO_PCIE_W_DISABLE 5
  5054. +
  5055. +#define ALFA_AP96_GPIO_BUTTON_RESET 11
  5056. +
  5057. +#define ALFA_AP96_KEYS_POLL_INTERVAL 20 /* msecs */
  5058. +#define ALFA_AP96_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_AP96_KEYS_POLL_INTERVAL)
  5059. +
  5060. +static struct gpio_keys_button alfa_ap96_gpio_keys[] __initdata = {
  5061. + {
  5062. + .desc = "Reset button",
  5063. + .type = EV_KEY,
  5064. + .code = KEY_RESTART,
  5065. + .debounce_interval = ALFA_AP96_KEYS_DEBOUNCE_INTERVAL,
  5066. + .gpio = ALFA_AP96_GPIO_BUTTON_RESET,
  5067. + .active_low = 1,
  5068. + }
  5069. +};
  5070. +
  5071. +static struct mmc_spi_platform_data alfa_ap96_mmc_data = {
  5072. + .flags = MMC_SPI_USE_CD_GPIO,
  5073. + .cd_gpio = ALFA_AP96_GPIO_MICROSD_CD,
  5074. + .cd_debounce = 1,
  5075. + .caps = MMC_CAP_NEEDS_POLL,
  5076. + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  5077. +};
  5078. +
  5079. +static struct ath79_spi_controller_data ap96_spi0_cdata = {
  5080. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  5081. + .cs_line = 0,
  5082. + .is_flash = true,
  5083. +};
  5084. +
  5085. +static struct ath79_spi_controller_data ap96_spi1_cdata = {
  5086. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  5087. + .cs_line = 1,
  5088. +};
  5089. +
  5090. +static struct ath79_spi_controller_data ap96_spi2_cdata = {
  5091. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  5092. + .cs_line = 2,
  5093. +};
  5094. +
  5095. +static struct spi_board_info alfa_ap96_spi_info[] = {
  5096. + {
  5097. + .bus_num = 0,
  5098. + .chip_select = 0,
  5099. + .max_speed_hz = 25000000,
  5100. + .modalias = "m25p80",
  5101. + .controller_data = &ap96_spi0_cdata
  5102. + }, {
  5103. + .bus_num = 0,
  5104. + .chip_select = 1,
  5105. + .max_speed_hz = 25000000,
  5106. + .modalias = "mmc_spi",
  5107. + .platform_data = &alfa_ap96_mmc_data,
  5108. + .controller_data = &ap96_spi1_cdata
  5109. + }, {
  5110. + .bus_num = 0,
  5111. + .chip_select = 2,
  5112. + .max_speed_hz = 6250000,
  5113. + .modalias = "rtc-pcf2123",
  5114. + .controller_data = &ap96_spi2_cdata
  5115. + },
  5116. +};
  5117. +
  5118. +static struct ath79_spi_platform_data alfa_ap96_spi_data = {
  5119. + .bus_num = 0,
  5120. + .num_chipselect = 3,
  5121. +};
  5122. +
  5123. +static void __init alfa_ap96_gpio_setup(void)
  5124. +{
  5125. + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
  5126. + AR71XX_GPIO_FUNC_SPI_CS2_EN);
  5127. +
  5128. + gpio_request(ALFA_AP96_GPIO_MICROSD_CD, "microSD CD");
  5129. + gpio_direction_input(ALFA_AP96_GPIO_MICROSD_CD);
  5130. + gpio_request(ALFA_AP96_GPIO_PCIE_RESET, "PCIe reset");
  5131. + gpio_direction_output(ALFA_AP96_GPIO_PCIE_RESET, 1);
  5132. + gpio_request(ALFA_AP96_GPIO_PCIE_W_DISABLE, "PCIe write disable");
  5133. + gpio_direction_output(ALFA_AP96_GPIO_PCIE_W_DISABLE, 1);
  5134. +}
  5135. +
  5136. +#define ALFA_AP96_WAN_PHYMASK BIT(4)
  5137. +#define ALFA_AP96_LAN_PHYMASK BIT(5)
  5138. +#define ALFA_AP96_MDIO_PHYMASK (ALFA_AP96_LAN_PHYMASK | ALFA_AP96_WAN_PHYMASK)
  5139. +
  5140. +static void __init alfa_ap96_init(void)
  5141. +{
  5142. + alfa_ap96_gpio_setup();
  5143. +
  5144. + ath79_register_mdio(0, ~ALFA_AP96_MDIO_PHYMASK);
  5145. +
  5146. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  5147. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  5148. + ath79_eth0_data.phy_mask = ALFA_AP96_WAN_PHYMASK;
  5149. + ath79_eth1_pll_data.pll_1000 = 0x110000;
  5150. +
  5151. + ath79_register_eth(0);
  5152. +
  5153. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  5154. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  5155. + ath79_eth1_data.phy_mask = ALFA_AP96_LAN_PHYMASK;
  5156. + ath79_eth1_pll_data.pll_1000 = 0x110000;
  5157. +
  5158. + ath79_register_eth(1);
  5159. +
  5160. + ath79_register_pci();
  5161. + ath79_register_spi(&alfa_ap96_spi_data, alfa_ap96_spi_info,
  5162. + ARRAY_SIZE(alfa_ap96_spi_info));
  5163. +
  5164. + ath79_register_gpio_keys_polled(-1, ALFA_AP96_KEYS_POLL_INTERVAL,
  5165. + ARRAY_SIZE(alfa_ap96_gpio_keys),
  5166. + alfa_ap96_gpio_keys);
  5167. + ath79_register_usb();
  5168. +}
  5169. +
  5170. +MIPS_MACHINE(ATH79_MACH_ALFA_AP96, "ALFA-AP96", "ALFA Network AP96",
  5171. + alfa_ap96_init);
  5172. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-alfa-nx.c linux-4.1.13/arch/mips/ath79/mach-alfa-nx.c
  5173. --- linux-4.1.13.orig/arch/mips/ath79/mach-alfa-nx.c 1970-01-01 01:00:00.000000000 +0100
  5174. +++ linux-4.1.13/arch/mips/ath79/mach-alfa-nx.c 2015-09-13 20:04:35.064524285 +0200
  5175. @@ -0,0 +1,113 @@
  5176. +/*
  5177. + * ALFA Network N2/N5 board support
  5178. + *
  5179. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5180. + *
  5181. + * This program is free software; you can redistribute it and/or modify it
  5182. + * under the terms of the GNU General Public License version 2 as published
  5183. + * by the Free Software Foundation.
  5184. + */
  5185. +
  5186. +#include <asm/mach-ath79/ar71xx_regs.h>
  5187. +#include <asm/mach-ath79/ath79.h>
  5188. +
  5189. +#include "common.h"
  5190. +#include "dev-eth.h"
  5191. +#include "dev-ap9x-pci.h"
  5192. +#include "dev-gpio-buttons.h"
  5193. +#include "dev-leds-gpio.h"
  5194. +#include "dev-m25p80.h"
  5195. +#include "machtypes.h"
  5196. +
  5197. +#define ALFA_NX_GPIO_LED_2 17
  5198. +#define ALFA_NX_GPIO_LED_3 16
  5199. +#define ALFA_NX_GPIO_LED_5 12
  5200. +#define ALFA_NX_GPIO_LED_6 8
  5201. +#define ALFA_NX_GPIO_LED_7 6
  5202. +#define ALFA_NX_GPIO_LED_8 7
  5203. +
  5204. +#define ALFA_NX_GPIO_BTN_RESET 11
  5205. +
  5206. +#define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */
  5207. +#define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
  5208. +
  5209. +#define ALFA_NX_MAC0_OFFSET 0
  5210. +#define ALFA_NX_MAC1_OFFSET 6
  5211. +#define ALFA_NX_CALDATA_OFFSET 0x1000
  5212. +
  5213. +static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = {
  5214. + {
  5215. + .desc = "Reset button",
  5216. + .type = EV_KEY,
  5217. + .code = KEY_RESTART,
  5218. + .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL,
  5219. + .gpio = ALFA_NX_GPIO_BTN_RESET,
  5220. + .active_low = 1,
  5221. + }
  5222. +};
  5223. +
  5224. +static struct gpio_led alfa_nx_leds_gpio[] __initdata = {
  5225. + {
  5226. + .name = "alfa:green:led_2",
  5227. + .gpio = ALFA_NX_GPIO_LED_2,
  5228. + .active_low = 1,
  5229. + }, {
  5230. + .name = "alfa:green:led_3",
  5231. + .gpio = ALFA_NX_GPIO_LED_3,
  5232. + .active_low = 1,
  5233. + }, {
  5234. + .name = "alfa:red:led_5",
  5235. + .gpio = ALFA_NX_GPIO_LED_5,
  5236. + .active_low = 1,
  5237. + }, {
  5238. + .name = "alfa:amber:led_6",
  5239. + .gpio = ALFA_NX_GPIO_LED_6,
  5240. + .active_low = 1,
  5241. + }, {
  5242. + .name = "alfa:green:led_7",
  5243. + .gpio = ALFA_NX_GPIO_LED_7,
  5244. + .active_low = 1,
  5245. + }, {
  5246. + .name = "alfa:green:led_8",
  5247. + .gpio = ALFA_NX_GPIO_LED_8,
  5248. + .active_low = 1,
  5249. + }
  5250. +};
  5251. +
  5252. +static void __init alfa_nx_setup(void)
  5253. +{
  5254. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  5255. +
  5256. + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  5257. + AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  5258. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  5259. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  5260. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  5261. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  5262. +
  5263. + ath79_register_m25p80(NULL);
  5264. +
  5265. + ath79_register_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio),
  5266. + alfa_nx_leds_gpio);
  5267. +
  5268. + ath79_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL,
  5269. + ARRAY_SIZE(alfa_nx_gpio_keys),
  5270. + alfa_nx_gpio_keys);
  5271. +
  5272. + ath79_register_mdio(0, 0x0);
  5273. +
  5274. + ath79_init_mac(ath79_eth0_data.mac_addr,
  5275. + art + ALFA_NX_MAC0_OFFSET, 0);
  5276. + ath79_init_mac(ath79_eth1_data.mac_addr,
  5277. + art + ALFA_NX_MAC1_OFFSET, 0);
  5278. +
  5279. + /* WAN port */
  5280. + ath79_register_eth(0);
  5281. + /* LAN port */
  5282. + ath79_register_eth(1);
  5283. +
  5284. + ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL);
  5285. +}
  5286. +
  5287. +MIPS_MACHINE(ATH79_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5",
  5288. + alfa_nx_setup);
  5289. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-all0258n.c linux-4.1.13/arch/mips/ath79/mach-all0258n.c
  5290. --- linux-4.1.13.orig/arch/mips/ath79/mach-all0258n.c 1970-01-01 01:00:00.000000000 +0100
  5291. +++ linux-4.1.13/arch/mips/ath79/mach-all0258n.c 2015-09-13 20:04:35.064524285 +0200
  5292. @@ -0,0 +1,88 @@
  5293. +/*
  5294. + * Allnet ALL0258N support
  5295. + *
  5296. + * Copyright (C) 2011 Daniel Golle <dgolle@allnet.de>
  5297. + *
  5298. + * This program is free software; you can redistribute it and/or modify it
  5299. + * under the terms of the GNU General Public License version 2 as published
  5300. + * by the Free Software Foundation.
  5301. + */
  5302. +
  5303. +#include <asm/mach-ath79/ath79.h>
  5304. +
  5305. +#include "dev-eth.h"
  5306. +#include "dev-ap9x-pci.h"
  5307. +#include "dev-gpio-buttons.h"
  5308. +#include "dev-leds-gpio.h"
  5309. +#include "dev-m25p80.h"
  5310. +#include "machtypes.h"
  5311. +
  5312. +/* found via /sys/gpio/... try and error */
  5313. +#define ALL0258N_GPIO_BTN_RESET 1
  5314. +#define ALL0258N_GPIO_LED_RSSIHIGH 13
  5315. +#define ALL0258N_GPIO_LED_RSSIMEDIUM 15
  5316. +#define ALL0258N_GPIO_LED_RSSILOW 14
  5317. +
  5318. +/* defaults taken from others machs */
  5319. +#define ALL0258N_KEYS_POLL_INTERVAL 20 /* msecs */
  5320. +#define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL)
  5321. +
  5322. +/* showed up in the original firmware's bootlog */
  5323. +#define ALL0258N_SEC_PHYMASK BIT(3)
  5324. +
  5325. +static struct gpio_led all0258n_leds_gpio[] __initdata = {
  5326. + {
  5327. + .name = "all0258n:green:rssihigh",
  5328. + .gpio = ALL0258N_GPIO_LED_RSSIHIGH,
  5329. + .active_low = 1,
  5330. + }, {
  5331. + .name = "all0258n:yellow:rssimedium",
  5332. + .gpio = ALL0258N_GPIO_LED_RSSIMEDIUM,
  5333. + .active_low = 1,
  5334. + }, {
  5335. + .name = "all0258n:red:rssilow",
  5336. + .gpio = ALL0258N_GPIO_LED_RSSILOW,
  5337. + .active_low = 1,
  5338. + }
  5339. +};
  5340. +
  5341. +static struct gpio_keys_button all0258n_gpio_keys[] __initdata = {
  5342. + {
  5343. + .desc = "reset",
  5344. + .type = EV_KEY,
  5345. + .code = KEY_RESTART,
  5346. + .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL,
  5347. + .gpio = ALL0258N_GPIO_BTN_RESET,
  5348. + .active_low = 1,
  5349. + }
  5350. +};
  5351. +
  5352. +static void __init all0258n_setup(void)
  5353. +{
  5354. + u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000);
  5355. + u8 *ee = (u8 *) KSEG1ADDR(0x1f7f1000);
  5356. +
  5357. + ath79_register_m25p80(NULL);
  5358. +
  5359. + ath79_register_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio),
  5360. + all0258n_leds_gpio);
  5361. +
  5362. + ath79_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL,
  5363. + ARRAY_SIZE(all0258n_gpio_keys),
  5364. + all0258n_gpio_keys);
  5365. +
  5366. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  5367. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  5368. +
  5369. + ath79_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK;
  5370. +
  5371. + ath79_register_mdio(0, 0x0);
  5372. +
  5373. + ath79_register_eth(0);
  5374. + ath79_register_eth(1);
  5375. +
  5376. + ap91_pci_init(ee, mac);
  5377. +}
  5378. +
  5379. +MIPS_MACHINE(ATH79_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N",
  5380. + all0258n_setup);
  5381. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-all0315n.c linux-4.1.13/arch/mips/ath79/mach-all0315n.c
  5382. --- linux-4.1.13.orig/arch/mips/ath79/mach-all0315n.c 1970-01-01 01:00:00.000000000 +0100
  5383. +++ linux-4.1.13/arch/mips/ath79/mach-all0315n.c 2015-09-13 20:04:35.064524285 +0200
  5384. @@ -0,0 +1,85 @@
  5385. +/*
  5386. + * Allnet ALL0315N support
  5387. + *
  5388. + * Copyright (C) 2012 Daniel Golle <dgolle@allnet.de>
  5389. + *
  5390. + *
  5391. + * This program is free software; you can redistribute it and/or modify it
  5392. + * under the terms of the GNU General Public License version 2 as published
  5393. + * by the Free Software Foundation.
  5394. + */
  5395. +
  5396. +#include <asm/mach-ath79/ath79.h>
  5397. +#include <asm/mach-ath79/ar71xx_regs.h>
  5398. +
  5399. +#include "common.h"
  5400. +#include "dev-eth.h"
  5401. +#include "dev-ap9x-pci.h"
  5402. +#include "dev-gpio-buttons.h"
  5403. +#include "dev-m25p80.h"
  5404. +#include "dev-leds-gpio.h"
  5405. +#include "machtypes.h"
  5406. +#include "pci.h"
  5407. +
  5408. +#define ALL0315N_GPIO_BTN_RESET 0
  5409. +#define ALL0315N_GPIO_LED_RSSIHIGH 14
  5410. +#define ALL0315N_GPIO_LED_RSSIMEDIUM 15
  5411. +#define ALL0315N_GPIO_LED_RSSILOW 16
  5412. +
  5413. +#define ALL0315N_KEYS_POLL_INTERVAL 20 /* msecs */
  5414. +#define ALL0315N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0315N_KEYS_POLL_INTERVAL)
  5415. +
  5416. +static struct gpio_led all0315n_leds_gpio[] __initdata = {
  5417. + {
  5418. + .name = "all0315n:green:rssihigh",
  5419. + .gpio = ALL0315N_GPIO_LED_RSSIHIGH,
  5420. + .active_low = 1,
  5421. + }, {
  5422. + .name = "all0315n:yellow:rssimedium",
  5423. + .gpio = ALL0315N_GPIO_LED_RSSIMEDIUM,
  5424. + .active_low = 1,
  5425. + }, {
  5426. + .name = "all0315n:red:rssilow",
  5427. + .gpio = ALL0315N_GPIO_LED_RSSILOW,
  5428. + .active_low = 1,
  5429. + }
  5430. +};
  5431. +
  5432. +static struct gpio_keys_button all0315n_gpio_keys[] __initdata = {
  5433. + {
  5434. + .desc = "reset",
  5435. + .type = EV_KEY,
  5436. + .code = KEY_RESTART,
  5437. + .debounce_interval = ALL0315N_KEYS_DEBOUNCE_INTERVAL,
  5438. + .gpio = ALL0315N_GPIO_BTN_RESET,
  5439. + .active_low = 1,
  5440. + }
  5441. +};
  5442. +
  5443. +static void __init all0315n_setup(void)
  5444. +{
  5445. + u8 *mac = (u8 *) KSEG1ADDR(0x1ffc0000);
  5446. + u8 *ee = (u8 *) KSEG1ADDR(0x1ffc1000);
  5447. +
  5448. + ath79_register_m25p80(NULL);
  5449. +
  5450. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  5451. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  5452. + ath79_eth0_data.phy_mask = BIT(0);
  5453. +
  5454. + ath79_register_mdio(0, 0x0);
  5455. + ath79_register_eth(0);
  5456. +
  5457. + ath79_register_leds_gpio(-1, ARRAY_SIZE(all0315n_leds_gpio),
  5458. + all0315n_leds_gpio);
  5459. +
  5460. + ath79_register_gpio_keys_polled(-1, ALL0315N_KEYS_POLL_INTERVAL,
  5461. + ARRAY_SIZE(all0315n_gpio_keys),
  5462. + all0315n_gpio_keys);
  5463. +
  5464. + ap9x_pci_setup_wmac_led_pin(0, 1);
  5465. + ap91_pci_init(ee, NULL);
  5466. +}
  5467. +
  5468. +MIPS_MACHINE(ATH79_MACH_ALL0315N, "ALL0315N", "Allnet ALL0315N",
  5469. + all0315n_setup);
  5470. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-antminer-s1.c linux-4.1.13/arch/mips/ath79/mach-antminer-s1.c
  5471. --- linux-4.1.13.orig/arch/mips/ath79/mach-antminer-s1.c 1970-01-01 01:00:00.000000000 +0100
  5472. +++ linux-4.1.13/arch/mips/ath79/mach-antminer-s1.c 2015-11-21 17:22:11.759223549 +0100
  5473. @@ -0,0 +1,98 @@
  5474. +/*
  5475. + * Bitmain Antminer S1 board support
  5476. + *
  5477. + * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com>
  5478. + *
  5479. + * This program is free software; you can redistribute it and/or modify it
  5480. + * under the terms of the GNU General Public License version 2 as published
  5481. + * by the Free Software Foundation.
  5482. + */
  5483. +
  5484. +#include <linux/gpio.h>
  5485. +
  5486. +#include <asm/mach-ath79/ath79.h>
  5487. +#include <asm/mach-ath79/ar71xx_regs.h>
  5488. +
  5489. +#include "common.h"
  5490. +#include "dev-eth.h"
  5491. +#include "dev-gpio-buttons.h"
  5492. +#include "dev-leds-gpio.h"
  5493. +#include "dev-m25p80.h"
  5494. +#include "dev-wmac.h"
  5495. +#include "machtypes.h"
  5496. +#include "dev-usb.h"
  5497. +
  5498. +#define ANTMINER_S1_GPIO_BTN_RESET 11
  5499. +
  5500. +#define ANTMINER_S1_GPIO_LED_SYSTEM 23
  5501. +#define ANTMINER_S1_GPIO_LED_WLAN 0
  5502. +#define ANTMINER_S1_GPIO_USB_POWER 26
  5503. +
  5504. +#define ANTMINER_S1_KEYSPOLL_INTERVAL 20 /* msecs */
  5505. +#define ANTMINER_S1_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S1_KEYSPOLL_INTERVAL)
  5506. +
  5507. +static const char *ANTMINER_S1_part_probes[] = {
  5508. + "tp-link",
  5509. + NULL,
  5510. +};
  5511. +
  5512. +static struct flash_platform_data ANTMINER_S1_flash_data = {
  5513. + .part_probes = ANTMINER_S1_part_probes,
  5514. +};
  5515. +
  5516. +static struct gpio_led ANTMINER_S1_leds_gpio[] __initdata = {
  5517. + {
  5518. + .name = "antminer-s1:green:system",
  5519. + .gpio = ANTMINER_S1_GPIO_LED_SYSTEM,
  5520. + .active_low = 0,
  5521. + },{
  5522. + .name = "antminer-s1:green:wlan",
  5523. + .gpio = ANTMINER_S1_GPIO_LED_WLAN,
  5524. + .active_low = 0,
  5525. + },
  5526. +};
  5527. +
  5528. +static struct gpio_keys_button ANTMINER_S1_GPIO_keys[] __initdata = {
  5529. + {
  5530. + .desc = "reset",
  5531. + .type = EV_KEY,
  5532. + .code = KEY_RESTART,
  5533. + .debounce_interval = ANTMINER_S1_KEYSDEBOUNCE_INTERVAL,
  5534. + .gpio = ANTMINER_S1_GPIO_BTN_RESET,
  5535. + .active_low = 0,
  5536. + },
  5537. +};
  5538. +
  5539. +static void __init antminer_s1_setup(void)
  5540. +{
  5541. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5542. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  5543. +
  5544. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  5545. + ath79_setup_ar933x_phy4_switch(false, false);
  5546. +
  5547. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S1_leds_gpio),
  5548. + ANTMINER_S1_leds_gpio);
  5549. +
  5550. + ath79_register_gpio_keys_polled(-1, ANTMINER_S1_KEYSPOLL_INTERVAL,
  5551. + ARRAY_SIZE(ANTMINER_S1_GPIO_keys),
  5552. + ANTMINER_S1_GPIO_keys);
  5553. +
  5554. + gpio_request_one(ANTMINER_S1_GPIO_USB_POWER,
  5555. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  5556. + "USB power");
  5557. + ath79_register_usb();
  5558. +
  5559. + ath79_register_m25p80(&ANTMINER_S1_flash_data);
  5560. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  5561. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  5562. +
  5563. + ath79_register_mdio(0, 0x0);
  5564. + ath79_register_eth(0);
  5565. + ath79_register_eth(1);
  5566. +
  5567. + ath79_register_wmac(ee, mac);
  5568. +}
  5569. +
  5570. +MIPS_MACHINE(ATH79_MACH_ANTMINER_S1, "ANTMINER-S1",
  5571. + "Antminer-S1", antminer_s1_setup);
  5572. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-antminer-s3.c linux-4.1.13/arch/mips/ath79/mach-antminer-s3.c
  5573. --- linux-4.1.13.orig/arch/mips/ath79/mach-antminer-s3.c 1970-01-01 01:00:00.000000000 +0100
  5574. +++ linux-4.1.13/arch/mips/ath79/mach-antminer-s3.c 2015-11-21 17:22:11.759223549 +0100
  5575. @@ -0,0 +1,103 @@
  5576. +/*
  5577. + * Bitmain Antminer S3 board support
  5578. + *
  5579. + * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com>
  5580. + *
  5581. + * This program is free software; you can redistribute it and/or modify it
  5582. + * under the terms of the GNU General Public License version 2 as published
  5583. + * by the Free Software Foundation.
  5584. + */
  5585. +
  5586. +#include <linux/gpio.h>
  5587. +
  5588. +#include <asm/mach-ath79/ath79.h>
  5589. +#include <asm/mach-ath79/ar71xx_regs.h>
  5590. +
  5591. +#include "common.h"
  5592. +#include "dev-eth.h"
  5593. +#include "dev-gpio-buttons.h"
  5594. +#include "dev-leds-gpio.h"
  5595. +#include "dev-m25p80.h"
  5596. +#include "dev-wmac.h"
  5597. +#include "machtypes.h"
  5598. +#include "dev-usb.h"
  5599. +
  5600. +#define ANTMINER_S3_GPIO_LED_WLAN 0
  5601. +#define ANTMINER_S3_GPIO_LED_SYSTEM 17
  5602. +#define ANTMINER_S3_GPIO_LED_LAN 22
  5603. +#define ANTMINER_S3_GPIO_USB_POWER 26
  5604. +
  5605. +#define ANTMINER_S3_GPIO_BTN_RESET 11
  5606. +
  5607. +#define ANTMINER_S3_KEYSPOLL_INTERVAL 88 /* msecs */
  5608. +#define ANTMINER_S3_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S3_KEYSPOLL_INTERVAL)
  5609. +
  5610. +static const char *ANTMINER_S3_part_probes[] = {
  5611. + "tp-link",
  5612. + NULL,
  5613. +};
  5614. +
  5615. +static struct flash_platform_data ANTMINER_S3_flash_data = {
  5616. + .part_probes = ANTMINER_S3_part_probes,
  5617. +};
  5618. +
  5619. +static struct gpio_led ANTMINER_S3_leds_gpio[] __initdata = {
  5620. + {
  5621. + .name = "antminer-s3:green:wlan",
  5622. + .gpio = ANTMINER_S3_GPIO_LED_WLAN,
  5623. + .active_low = 0,
  5624. + },{
  5625. + .name = "antminer-s3:green:system",
  5626. + .gpio = ANTMINER_S3_GPIO_LED_SYSTEM,
  5627. + .active_low = 0,
  5628. + },{
  5629. + .name = "antminer-s3:yellow:lan",
  5630. + .gpio = ANTMINER_S3_GPIO_LED_LAN,
  5631. + .active_low = 0,
  5632. + },
  5633. +};
  5634. +
  5635. +static struct gpio_keys_button ANTMINER_S3_GPIO_keys[] __initdata = {
  5636. + {
  5637. + .desc = "reset",
  5638. + .type = EV_KEY,
  5639. + .code = KEY_RESTART,
  5640. + .debounce_interval = ANTMINER_S3_KEYSDEBOUNCE_INTERVAL,
  5641. + .gpio = ANTMINER_S3_GPIO_BTN_RESET,
  5642. + .active_low = 0,
  5643. + },
  5644. +};
  5645. +
  5646. +static void __init antminer_s3_setup(void)
  5647. +{
  5648. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5649. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  5650. +
  5651. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  5652. + ath79_setup_ar933x_phy4_switch(false, false);
  5653. +
  5654. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S3_leds_gpio),
  5655. + ANTMINER_S3_leds_gpio);
  5656. +
  5657. + ath79_register_gpio_keys_polled(-1, ANTMINER_S3_KEYSPOLL_INTERVAL,
  5658. + ARRAY_SIZE(ANTMINER_S3_GPIO_keys),
  5659. + ANTMINER_S3_GPIO_keys);
  5660. +
  5661. + gpio_request_one(ANTMINER_S3_GPIO_USB_POWER,
  5662. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  5663. + "USB power");
  5664. + ath79_register_usb();
  5665. +
  5666. + ath79_register_m25p80(&ANTMINER_S3_flash_data);
  5667. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  5668. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  5669. +
  5670. + ath79_register_mdio(0, 0x0);
  5671. + ath79_register_eth(0);
  5672. + ath79_register_eth(1);
  5673. +
  5674. + ath79_register_wmac(ee, mac);
  5675. +}
  5676. +
  5677. +MIPS_MACHINE(ATH79_MACH_ANTMINER_S3, "ANTMINER-S3",
  5678. + "Antminer-S3", antminer_s3_setup);
  5679. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap113.c linux-4.1.13/arch/mips/ath79/mach-ap113.c
  5680. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap113.c 1970-01-01 01:00:00.000000000 +0100
  5681. +++ linux-4.1.13/arch/mips/ath79/mach-ap113.c 2015-09-13 20:04:35.068524086 +0200
  5682. @@ -0,0 +1,84 @@
  5683. +/*
  5684. + * Atheros AP113 board support
  5685. + *
  5686. + * Copyright (C) 2011 Florian Fainelli <florian@openwrt.org>
  5687. + *
  5688. + * This program is free software; you can redistribute it and/or modify it
  5689. + * under the terms of the GNU General Public License version 2 as published
  5690. + * by the Free Software Foundation.
  5691. + */
  5692. +
  5693. +#include "dev-eth.h"
  5694. +#include "dev-gpio-buttons.h"
  5695. +#include "dev-leds-gpio.h"
  5696. +#include "dev-m25p80.h"
  5697. +#include "pci.h"
  5698. +#include "dev-usb.h"
  5699. +#include "machtypes.h"
  5700. +
  5701. +#define AP113_GPIO_LED_USB 0
  5702. +#define AP113_GPIO_LED_STATUS 1
  5703. +#define AP113_GPIO_LED_ST 11
  5704. +
  5705. +#define AP113_GPIO_BTN_JUMPSTART 12
  5706. +
  5707. +#define AP113_KEYS_POLL_INTERVAL 20 /* msecs */
  5708. +#define AP113_KEYS_DEBOUNCE_INTERVAL (3 * AP113_KEYS_POLL_INTERVAL)
  5709. +
  5710. +static struct gpio_led ap113_leds_gpio[] __initdata = {
  5711. + {
  5712. + .name = "ap113:green:usb",
  5713. + .gpio = AP113_GPIO_LED_USB,
  5714. + .active_low = 1,
  5715. + },
  5716. + {
  5717. + .name = "ap113:green:status",
  5718. + .gpio = AP113_GPIO_LED_STATUS,
  5719. + .active_low = 1,
  5720. + },
  5721. + {
  5722. + .name = "ap113:green:st",
  5723. + .gpio = AP113_GPIO_LED_ST,
  5724. + .active_low = 1,
  5725. + }
  5726. +};
  5727. +
  5728. +static struct gpio_keys_button ap113_gpio_keys[] __initdata = {
  5729. + {
  5730. + .desc = "jumpstart button",
  5731. + .type = EV_KEY,
  5732. + .code = KEY_WPS_BUTTON,
  5733. + .debounce_interval = AP113_KEYS_DEBOUNCE_INTERVAL,
  5734. + .gpio = AP113_GPIO_BTN_JUMPSTART,
  5735. + .active_low = 1,
  5736. + },
  5737. +};
  5738. +
  5739. +static void __init ap113_setup(void)
  5740. +{
  5741. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  5742. +
  5743. + ath79_register_m25p80(NULL);
  5744. +
  5745. + ath79_register_mdio(0, ~BIT(0));
  5746. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  5747. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  5748. + ath79_eth0_data.speed = SPEED_1000;
  5749. + ath79_eth0_data.duplex = DUPLEX_FULL;
  5750. + ath79_eth0_data.phy_mask = BIT(0);
  5751. +
  5752. + ath79_register_eth(0);
  5753. +
  5754. + ath79_register_gpio_keys_polled(-1, AP113_KEYS_POLL_INTERVAL,
  5755. + ARRAY_SIZE(ap113_gpio_keys),
  5756. + ap113_gpio_keys);
  5757. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap113_leds_gpio),
  5758. + ap113_leds_gpio);
  5759. +
  5760. + ath79_register_pci();
  5761. +
  5762. + ath79_register_usb();
  5763. +}
  5764. +
  5765. +MIPS_MACHINE(ATH79_MACH_AP113, "AP113", "Atheros AP113",
  5766. + ap113_setup);
  5767. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap121.c linux-4.1.13/arch/mips/ath79/mach-ap121.c
  5768. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap121.c 2015-11-09 23:34:10.000000000 +0100
  5769. +++ linux-4.1.13/arch/mips/ath79/mach-ap121.c 2015-12-04 19:57:04.298083689 +0100
  5770. @@ -1,19 +1,21 @@
  5771. /*
  5772. * Atheros AP121 board support
  5773. *
  5774. - * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
  5775. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5776. *
  5777. * This program is free software; you can redistribute it and/or modify it
  5778. * under the terms of the GNU General Public License version 2 as published
  5779. * by the Free Software Foundation.
  5780. */
  5781. -#include "machtypes.h"
  5782. +#include "dev-eth.h"
  5783. #include "dev-gpio-buttons.h"
  5784. #include "dev-leds-gpio.h"
  5785. +#include "dev-m25p80.h"
  5786. #include "dev-spi.h"
  5787. #include "dev-usb.h"
  5788. #include "dev-wmac.h"
  5789. +#include "machtypes.h"
  5790. #define AP121_GPIO_LED_WLAN 0
  5791. #define AP121_GPIO_LED_USB 1
  5792. @@ -24,7 +26,14 @@
  5793. #define AP121_KEYS_POLL_INTERVAL 20 /* msecs */
  5794. #define AP121_KEYS_DEBOUNCE_INTERVAL (3 * AP121_KEYS_POLL_INTERVAL)
  5795. -#define AP121_CAL_DATA_ADDR 0x1fff1000
  5796. +#define AP121_MAC0_OFFSET 0x0000
  5797. +#define AP121_MAC1_OFFSET 0x0006
  5798. +#define AP121_CALDATA_OFFSET 0x1000
  5799. +#define AP121_WMAC_MAC_OFFSET 0x1002
  5800. +
  5801. +#define AP121_MINI_GPIO_LED_WLAN 0
  5802. +#define AP121_MINI_GPIO_BTN_JUMPSTART 12
  5803. +#define AP121_MINI_GPIO_BTN_RESET 11
  5804. static struct gpio_led ap121_leds_gpio[] __initdata = {
  5805. {
  5806. @@ -58,35 +67,78 @@
  5807. }
  5808. };
  5809. -static struct spi_board_info ap121_spi_info[] = {
  5810. +static struct gpio_led ap121_mini_leds_gpio[] __initdata = {
  5811. {
  5812. - .bus_num = 0,
  5813. - .chip_select = 0,
  5814. - .max_speed_hz = 25000000,
  5815. - .modalias = "mx25l1606e",
  5816. - }
  5817. + .name = "ap121:green:wlan",
  5818. + .gpio = AP121_MINI_GPIO_LED_WLAN,
  5819. + .active_low = 0,
  5820. + },
  5821. };
  5822. -static struct ath79_spi_platform_data ap121_spi_data = {
  5823. - .bus_num = 0,
  5824. - .num_chipselect = 1,
  5825. +static struct gpio_keys_button ap121_mini_gpio_keys[] __initdata = {
  5826. + {
  5827. + .desc = "jumpstart button",
  5828. + .type = EV_KEY,
  5829. + .code = KEY_WPS_BUTTON,
  5830. + .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
  5831. + .gpio = AP121_MINI_GPIO_BTN_JUMPSTART,
  5832. + .active_low = 1,
  5833. + },
  5834. + {
  5835. + .desc = "reset button",
  5836. + .type = EV_KEY,
  5837. + .code = KEY_RESTART,
  5838. + .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
  5839. + .gpio = AP121_MINI_GPIO_BTN_RESET,
  5840. + .active_low = 1,
  5841. + }
  5842. };
  5843. +static void __init ap121_common_setup(void)
  5844. +{
  5845. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  5846. +
  5847. + ath79_register_m25p80(NULL);
  5848. + ath79_register_wmac(art + AP121_CALDATA_OFFSET,
  5849. + art + AP121_WMAC_MAC_OFFSET);
  5850. +
  5851. + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP121_MAC0_OFFSET, 0);
  5852. + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP121_MAC1_OFFSET, 0);
  5853. +
  5854. + ath79_register_mdio(0, 0x0);
  5855. +
  5856. + /* LAN ports */
  5857. + ath79_register_eth(1);
  5858. +
  5859. + /* WAN port */
  5860. + ath79_register_eth(0);
  5861. +}
  5862. +
  5863. static void __init ap121_setup(void)
  5864. {
  5865. - u8 *cal_data = (u8 *) KSEG1ADDR(AP121_CAL_DATA_ADDR);
  5866. + ap121_common_setup();
  5867. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121_leds_gpio),
  5868. ap121_leds_gpio);
  5869. ath79_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
  5870. ARRAY_SIZE(ap121_gpio_keys),
  5871. ap121_gpio_keys);
  5872. -
  5873. - ath79_register_spi(&ap121_spi_data, ap121_spi_info,
  5874. - ARRAY_SIZE(ap121_spi_info));
  5875. ath79_register_usb();
  5876. - ath79_register_wmac(cal_data);
  5877. }
  5878. MIPS_MACHINE(ATH79_MACH_AP121, "AP121", "Atheros AP121 reference board",
  5879. ap121_setup);
  5880. +
  5881. +static void __init ap121_mini_setup(void)
  5882. +{
  5883. + ap121_common_setup();
  5884. +
  5885. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121_mini_leds_gpio),
  5886. + ap121_mini_leds_gpio);
  5887. + ath79_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
  5888. + ARRAY_SIZE(ap121_mini_gpio_keys),
  5889. + ap121_mini_gpio_keys);
  5890. +}
  5891. +
  5892. +MIPS_MACHINE(ATH79_MACH_AP121_MINI, "AP121-MINI", "Atheros AP121-MINI",
  5893. + ap121_mini_setup);
  5894. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap132.c linux-4.1.13/arch/mips/ath79/mach-ap132.c
  5895. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap132.c 1970-01-01 01:00:00.000000000 +0100
  5896. +++ linux-4.1.13/arch/mips/ath79/mach-ap132.c 2015-09-13 20:04:35.068524086 +0200
  5897. @@ -0,0 +1,189 @@
  5898. +/*
  5899. + * Atheros AP132 reference board support
  5900. + *
  5901. + * Copyright (c) 2012 Qualcomm Atheros
  5902. + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  5903. + * Copyright (c) 2013 Embedded Wireless GmbH <info@embeddedwireless.de>
  5904. + *
  5905. + * Permission to use, copy, modify, and/or distribute this software for any
  5906. + * purpose with or without fee is hereby granted, provided that the above
  5907. + * copyright notice and this permission notice appear in all copies.
  5908. + *
  5909. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  5910. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  5911. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  5912. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  5913. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  5914. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  5915. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  5916. + *
  5917. + */
  5918. +
  5919. +#include <linux/platform_device.h>
  5920. +#include <linux/ar8216_platform.h>
  5921. +
  5922. +#include <asm/mach-ath79/ar71xx_regs.h>
  5923. +
  5924. +#include "common.h"
  5925. +#include "dev-ap9x-pci.h"
  5926. +#include "dev-gpio-buttons.h"
  5927. +#include "dev-eth.h"
  5928. +#include "dev-leds-gpio.h"
  5929. +#include "dev-m25p80.h"
  5930. +#include "dev-usb.h"
  5931. +#include "dev-wmac.h"
  5932. +#include "machtypes.h"
  5933. +
  5934. +#define AP132_GPIO_LED_USB 4
  5935. +#define AP132_GPIO_LED_WLAN_5G 12
  5936. +#define AP132_GPIO_LED_WLAN_2G 13
  5937. +#define AP132_GPIO_LED_STATUS_RED 14
  5938. +#define AP132_GPIO_LED_WPS_RED 15
  5939. +
  5940. +#define AP132_GPIO_BTN_WPS 16
  5941. +
  5942. +#define AP132_KEYS_POLL_INTERVAL 20 /* msecs */
  5943. +#define AP132_KEYS_DEBOUNCE_INTERVAL (3 * AP132_KEYS_POLL_INTERVAL)
  5944. +
  5945. +#define AP132_MAC0_OFFSET 0
  5946. +#define AP132_WMAC_CALDATA_OFFSET 0x1000
  5947. +
  5948. +static struct gpio_led ap132_leds_gpio[] __initdata = {
  5949. + {
  5950. + .name = "ap132:red:status",
  5951. + .gpio = AP132_GPIO_LED_STATUS_RED,
  5952. + .active_low = 1,
  5953. + },
  5954. + {
  5955. + .name = "ap132:red:wps",
  5956. + .gpio = AP132_GPIO_LED_WPS_RED,
  5957. + .active_low = 1,
  5958. + },
  5959. + {
  5960. + .name = "ap132:red:wlan-2g",
  5961. + .gpio = AP132_GPIO_LED_WLAN_2G,
  5962. + .active_low = 1,
  5963. + },
  5964. + {
  5965. + .name = "ap132:red:usb",
  5966. + .gpio = AP132_GPIO_LED_USB,
  5967. + .active_low = 1,
  5968. + }
  5969. +};
  5970. +
  5971. +static struct gpio_keys_button ap132_gpio_keys[] __initdata = {
  5972. + {
  5973. + .desc = "WPS button",
  5974. + .type = EV_KEY,
  5975. + .code = KEY_WPS_BUTTON,
  5976. + .debounce_interval = AP132_KEYS_DEBOUNCE_INTERVAL,
  5977. + .gpio = AP132_GPIO_BTN_WPS,
  5978. + .active_low = 1,
  5979. + },
  5980. +};
  5981. +
  5982. +static struct ar8327_pad_cfg ap132_ar8327_pad0_cfg;
  5983. +
  5984. +static struct ar8327_platform_data ap132_ar8327_data = {
  5985. + .pad0_cfg = &ap132_ar8327_pad0_cfg,
  5986. + .port0_cfg = {
  5987. + .force_link = 1,
  5988. + .speed = AR8327_PORT_SPEED_1000,
  5989. + .duplex = 1,
  5990. + .txpause = 1,
  5991. + .rxpause = 1,
  5992. + },
  5993. +};
  5994. +
  5995. +static struct mdio_board_info ap132_mdio1_info[] = {
  5996. + {
  5997. + .bus_id = "ag71xx-mdio.1",
  5998. + .phy_addr = 0,
  5999. + .platform_data = &ap132_ar8327_data,
  6000. + },
  6001. +};
  6002. +
  6003. +static void __init ap132_mdio_setup(void)
  6004. +{
  6005. + void __iomem *base;
  6006. + u32 t;
  6007. +
  6008. +#define GPIO_IN_ENABLE3_ADDRESS 0x0050
  6009. +#define GPIO_IN_ENABLE3_MII_GE1_MDI_MASK 0x00ff0000
  6010. +#define GPIO_IN_ENABLE3_MII_GE1_MDI_LSB 16
  6011. +#define GPIO_IN_ENABLE3_MII_GE1_MDI_SET(x) (((x) << GPIO_IN_ENABLE3_MII_GE1_MDI_LSB) & GPIO_IN_ENABLE3_MII_GE1_MDI_MASK)
  6012. +#define GPIO_OUT_FUNCTION4_ADDRESS 0x003c
  6013. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK 0xff000000
  6014. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_LSB 24
  6015. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_SET(x) (((x) << GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_LSB) & GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK)
  6016. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK 0x0000ff00
  6017. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_LSB 8
  6018. +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_SET(x) (((x) << GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_LSB) & GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK)
  6019. +
  6020. + base = ioremap(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
  6021. +
  6022. + t = __raw_readl(base + GPIO_IN_ENABLE3_ADDRESS);
  6023. + t &= ~GPIO_IN_ENABLE3_MII_GE1_MDI_MASK;
  6024. + t |= GPIO_IN_ENABLE3_MII_GE1_MDI_SET(19);
  6025. + __raw_writel(t, base + GPIO_IN_ENABLE3_ADDRESS);
  6026. +
  6027. +
  6028. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << 19), base + AR71XX_GPIO_REG_OE);
  6029. +
  6030. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << 17), base + AR71XX_GPIO_REG_OE);
  6031. +
  6032. +
  6033. + t = __raw_readl(base + GPIO_OUT_FUNCTION4_ADDRESS);
  6034. + t &= ~(GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK | GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK);
  6035. + t |= GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_SET(0x20) | GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_SET(0x21);
  6036. + __raw_writel(t, base + GPIO_OUT_FUNCTION4_ADDRESS);
  6037. +
  6038. + iounmap(base);
  6039. +
  6040. +}
  6041. +
  6042. +static void __init ap132_setup(void)
  6043. +{
  6044. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6045. +
  6046. + ath79_register_m25p80(NULL);
  6047. +
  6048. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap132_leds_gpio),
  6049. + ap132_leds_gpio);
  6050. + ath79_register_gpio_keys_polled(-1, AP132_KEYS_POLL_INTERVAL,
  6051. + ARRAY_SIZE(ap132_gpio_keys),
  6052. + ap132_gpio_keys);
  6053. +
  6054. + ath79_register_usb();
  6055. +
  6056. + ath79_register_wmac(art + AP132_WMAC_CALDATA_OFFSET, NULL);
  6057. +
  6058. + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */
  6059. + ap132_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII;
  6060. + ap132_ar8327_pad0_cfg.sgmii_delay_en = true;
  6061. +
  6062. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  6063. +
  6064. + ap132_mdio_setup();
  6065. +
  6066. + ath79_register_mdio(1, 0x0);
  6067. +
  6068. + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP132_MAC0_OFFSET, 0);
  6069. +
  6070. + mdiobus_register_board_info(ap132_mdio1_info,
  6071. + ARRAY_SIZE(ap132_mdio1_info));
  6072. +
  6073. + /* GMAC1 is connected to the SGMII interface */
  6074. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  6075. + ath79_eth1_data.speed = SPEED_1000;
  6076. + ath79_eth1_data.duplex = DUPLEX_FULL;
  6077. + ath79_eth1_data.phy_mask = BIT(0);
  6078. + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  6079. +
  6080. + ath79_register_eth(1);
  6081. +}
  6082. +
  6083. +MIPS_MACHINE(ATH79_MACH_AP132, "AP132",
  6084. + "Atheros AP132 reference board",
  6085. + ap132_setup);
  6086. +
  6087. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap136.c linux-4.1.13/arch/mips/ath79/mach-ap136.c
  6088. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap136.c 2015-11-09 23:34:10.000000000 +0100
  6089. +++ linux-4.1.13/arch/mips/ath79/mach-ap136.c 2015-12-04 19:57:04.370078979 +0100
  6090. @@ -18,23 +18,29 @@
  6091. *
  6092. */
  6093. -#include <linux/pci.h>
  6094. -#include <linux/ath9k_platform.h>
  6095. +#include <linux/platform_device.h>
  6096. +#include <linux/ar8216_platform.h>
  6097. -#include "machtypes.h"
  6098. +#include <asm/mach-ath79/ar71xx_regs.h>
  6099. +
  6100. +#include "common.h"
  6101. +#include "pci.h"
  6102. +#include "dev-ap9x-pci.h"
  6103. #include "dev-gpio-buttons.h"
  6104. +#include "dev-eth.h"
  6105. #include "dev-leds-gpio.h"
  6106. -#include "dev-spi.h"
  6107. +#include "dev-m25p80.h"
  6108. +#include "dev-nfc.h"
  6109. #include "dev-usb.h"
  6110. #include "dev-wmac.h"
  6111. -#include "pci.h"
  6112. +#include "machtypes.h"
  6113. -#define AP136_GPIO_LED_STATUS_RED 14
  6114. -#define AP136_GPIO_LED_STATUS_GREEN 19
  6115. #define AP136_GPIO_LED_USB 4
  6116. -#define AP136_GPIO_LED_WLAN_2G 13
  6117. #define AP136_GPIO_LED_WLAN_5G 12
  6118. +#define AP136_GPIO_LED_WLAN_2G 13
  6119. +#define AP136_GPIO_LED_STATUS_RED 14
  6120. #define AP136_GPIO_LED_WPS_RED 15
  6121. +#define AP136_GPIO_LED_STATUS_GREEN 19
  6122. #define AP136_GPIO_LED_WPS_GREEN 20
  6123. #define AP136_GPIO_BTN_WPS 16
  6124. @@ -43,37 +49,39 @@
  6125. #define AP136_KEYS_POLL_INTERVAL 20 /* msecs */
  6126. #define AP136_KEYS_DEBOUNCE_INTERVAL (3 * AP136_KEYS_POLL_INTERVAL)
  6127. -#define AP136_WMAC_CALDATA_OFFSET 0x1000
  6128. -#define AP136_PCIE_CALDATA_OFFSET 0x5000
  6129. +#define AP136_MAC0_OFFSET 0
  6130. +#define AP136_MAC1_OFFSET 6
  6131. +#define AP136_WMAC_CALDATA_OFFSET 0x1000
  6132. +#define AP136_PCIE_CALDATA_OFFSET 0x5000
  6133. static struct gpio_led ap136_leds_gpio[] __initdata = {
  6134. {
  6135. - .name = "qca:green:status",
  6136. + .name = "ap136:green:status",
  6137. .gpio = AP136_GPIO_LED_STATUS_GREEN,
  6138. .active_low = 1,
  6139. },
  6140. {
  6141. - .name = "qca:red:status",
  6142. + .name = "ap136:red:status",
  6143. .gpio = AP136_GPIO_LED_STATUS_RED,
  6144. .active_low = 1,
  6145. },
  6146. {
  6147. - .name = "qca:green:wps",
  6148. + .name = "ap136:green:wps",
  6149. .gpio = AP136_GPIO_LED_WPS_GREEN,
  6150. .active_low = 1,
  6151. },
  6152. {
  6153. - .name = "qca:red:wps",
  6154. + .name = "ap136:red:wps",
  6155. .gpio = AP136_GPIO_LED_WPS_RED,
  6156. .active_low = 1,
  6157. },
  6158. {
  6159. - .name = "qca:red:wlan-2g",
  6160. + .name = "ap136:red:wlan-2g",
  6161. .gpio = AP136_GPIO_LED_WLAN_2G,
  6162. .active_low = 1,
  6163. },
  6164. {
  6165. - .name = "qca:red:usb",
  6166. + .name = "ap136:red:usb",
  6167. .gpio = AP136_GPIO_LED_USB,
  6168. .active_low = 1,
  6169. }
  6170. @@ -98,59 +106,151 @@
  6171. },
  6172. };
  6173. -static struct spi_board_info ap136_spi_info[] = {
  6174. - {
  6175. - .bus_num = 0,
  6176. - .chip_select = 0,
  6177. - .max_speed_hz = 25000000,
  6178. - .modalias = "mx25l6405d",
  6179. - }
  6180. +static struct ar8327_pad_cfg ap136_ar8327_pad0_cfg;
  6181. +static struct ar8327_pad_cfg ap136_ar8327_pad6_cfg;
  6182. +
  6183. +static struct ar8327_platform_data ap136_ar8327_data = {
  6184. + .pad0_cfg = &ap136_ar8327_pad0_cfg,
  6185. + .pad6_cfg = &ap136_ar8327_pad6_cfg,
  6186. + .port0_cfg = {
  6187. + .force_link = 1,
  6188. + .speed = AR8327_PORT_SPEED_1000,
  6189. + .duplex = 1,
  6190. + .txpause = 1,
  6191. + .rxpause = 1,
  6192. + },
  6193. + .port6_cfg = {
  6194. + .force_link = 1,
  6195. + .speed = AR8327_PORT_SPEED_1000,
  6196. + .duplex = 1,
  6197. + .txpause = 1,
  6198. + .rxpause = 1,
  6199. + },
  6200. };
  6201. -static struct ath79_spi_platform_data ap136_spi_data = {
  6202. - .bus_num = 0,
  6203. - .num_chipselect = 1,
  6204. +static struct mdio_board_info ap136_mdio0_info[] = {
  6205. + {
  6206. + .bus_id = "ag71xx-mdio.0",
  6207. + .phy_addr = 0,
  6208. + .platform_data = &ap136_ar8327_data,
  6209. + },
  6210. };
  6211. -#ifdef CONFIG_PCI
  6212. -static struct ath9k_platform_data ap136_ath9k_data;
  6213. +static void __init ap136_common_setup(void)
  6214. +{
  6215. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6216. +
  6217. + ath79_register_m25p80(NULL);
  6218. +
  6219. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
  6220. + ap136_leds_gpio);
  6221. + ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
  6222. + ARRAY_SIZE(ap136_gpio_keys),
  6223. + ap136_gpio_keys);
  6224. +
  6225. + ath79_register_usb();
  6226. + ath79_register_nfc();
  6227. +
  6228. + ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET, NULL);
  6229. +
  6230. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  6231. -static int ap136_pci_plat_dev_init(struct pci_dev *dev)
  6232. + ath79_register_mdio(0, 0x0);
  6233. + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP136_MAC0_OFFSET, 0);
  6234. +
  6235. + mdiobus_register_board_info(ap136_mdio0_info,
  6236. + ARRAY_SIZE(ap136_mdio0_info));
  6237. +
  6238. + /* GMAC0 is connected to the RMGII interface */
  6239. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  6240. + ath79_eth0_data.phy_mask = BIT(0);
  6241. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  6242. +
  6243. + ath79_register_eth(0);
  6244. +
  6245. + /* GMAC1 is connected tot eh SGMII interface */
  6246. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  6247. + ath79_eth1_data.speed = SPEED_1000;
  6248. + ath79_eth1_data.duplex = DUPLEX_FULL;
  6249. +
  6250. + ath79_register_eth(1);
  6251. +}
  6252. +
  6253. +static void __init ap136_010_setup(void)
  6254. {
  6255. - if (dev->bus->number == 1 && (PCI_SLOT(dev->devfn)) == 0)
  6256. - dev->dev.platform_data = &ap136_ath9k_data;
  6257. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6258. - return 0;
  6259. + /* GMAC0 of the AR8327 switch is connected to GMAC0 via RGMII */
  6260. + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  6261. + ap136_ar8327_pad0_cfg.txclk_delay_en = true;
  6262. + ap136_ar8327_pad0_cfg.rxclk_delay_en = true;
  6263. + ap136_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  6264. + ap136_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  6265. +
  6266. + /* GMAC6 of the AR8327 switch is connected to GMAC1 via SGMII */
  6267. + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  6268. + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
  6269. + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  6270. +
  6271. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  6272. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  6273. +
  6274. + ap136_common_setup();
  6275. + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
  6276. }
  6277. -static void __init ap136_pci_init(u8 *eeprom)
  6278. +MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
  6279. + "Atheros AP136-010 reference board",
  6280. + ap136_010_setup);
  6281. +
  6282. +static void __init ap136_020_common_setup(void)
  6283. {
  6284. - memcpy(ap136_ath9k_data.eeprom_data, eeprom,
  6285. - sizeof(ap136_ath9k_data.eeprom_data));
  6286. + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */
  6287. + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII;
  6288. + ap136_ar8327_pad0_cfg.sgmii_delay_en = true;
  6289. +
  6290. + /* GMAC6 of the AR8327 switch is connected to GMAC0 via RGMII */
  6291. + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_RGMII;
  6292. + ap136_ar8327_pad6_cfg.txclk_delay_en = true;
  6293. + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
  6294. + ap136_ar8327_pad6_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  6295. + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  6296. - ath79_pci_set_plat_dev_init(ap136_pci_plat_dev_init);
  6297. - ath79_register_pci();
  6298. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  6299. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  6300. +
  6301. + ap136_common_setup();
  6302. }
  6303. -#else
  6304. -static inline void ap136_pci_init(u8 *eeprom) {}
  6305. -#endif /* CONFIG_PCI */
  6306. -static void __init ap136_setup(void)
  6307. +static void __init ap136_020_setup(void)
  6308. {
  6309. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6310. - ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
  6311. - ap136_leds_gpio);
  6312. - ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
  6313. - ARRAY_SIZE(ap136_gpio_keys),
  6314. - ap136_gpio_keys);
  6315. - ath79_register_spi(&ap136_spi_data, ap136_spi_info,
  6316. - ARRAY_SIZE(ap136_spi_info));
  6317. - ath79_register_usb();
  6318. - ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET);
  6319. - ap136_pci_init(art + AP136_PCIE_CALDATA_OFFSET);
  6320. + ap136_020_common_setup();
  6321. + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
  6322. }
  6323. -MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
  6324. - "Atheros AP136-010 reference board",
  6325. - ap136_setup);
  6326. +MIPS_MACHINE(ATH79_MACH_AP136_020, "AP136-020",
  6327. + "Atheros AP136-020 reference board",
  6328. + ap136_020_setup);
  6329. +
  6330. +/*
  6331. + * AP135-020 is similar to AP136-020, any future AP135 specific init
  6332. + * code can be added here.
  6333. + */
  6334. +static void __init ap135_020_setup(void)
  6335. +{
  6336. + ap136_leds_gpio[0].name = "ap135:green:status";
  6337. + ap136_leds_gpio[1].name = "ap135:red:status";
  6338. + ap136_leds_gpio[2].name = "ap135:green:wps";
  6339. + ap136_leds_gpio[3].name = "ap135:red:wps";
  6340. + ap136_leds_gpio[4].name = "ap135:red:wlan-2g";
  6341. + ap136_leds_gpio[5].name = "ap135:red:usb";
  6342. +
  6343. + ap136_020_common_setup();
  6344. + ath79_register_pci();
  6345. +}
  6346. +
  6347. +MIPS_MACHINE(ATH79_MACH_AP135_020, "AP135-020",
  6348. + "Atheros AP135-020 reference board",
  6349. + ap135_020_setup);
  6350. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap143.c linux-4.1.13/arch/mips/ath79/mach-ap143.c
  6351. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap143.c 1970-01-01 01:00:00.000000000 +0100
  6352. +++ linux-4.1.13/arch/mips/ath79/mach-ap143.c 2015-09-13 20:04:35.068524086 +0200
  6353. @@ -0,0 +1,142 @@
  6354. +/*
  6355. + * Atheros AP143 reference board support
  6356. + *
  6357. + * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
  6358. + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  6359. + *
  6360. + * Permission to use, copy, modify, and/or distribute this software for any
  6361. + * purpose with or without fee is hereby granted, provided that the above
  6362. + * copyright notice and this permission notice appear in all copies.
  6363. + *
  6364. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  6365. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  6366. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  6367. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  6368. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  6369. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  6370. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  6371. + *
  6372. + */
  6373. +
  6374. +#include <linux/platform_device.h>
  6375. +#include <linux/ath9k_platform.h>
  6376. +#include <linux/ar8216_platform.h>
  6377. +
  6378. +#include <asm/mach-ath79/ar71xx_regs.h>
  6379. +
  6380. +#include "common.h"
  6381. +#include "dev-eth.h"
  6382. +#include "dev-gpio-buttons.h"
  6383. +#include "dev-leds-gpio.h"
  6384. +#include "dev-m25p80.h"
  6385. +#include "dev-spi.h"
  6386. +#include "dev-usb.h"
  6387. +#include "dev-wmac.h"
  6388. +#include "machtypes.h"
  6389. +
  6390. +#define AP143_GPIO_LED_WLAN 12
  6391. +#define AP143_GPIO_LED_WPS 13
  6392. +#define AP143_GPIO_LED_STATUS 13
  6393. +
  6394. +#define AP143_GPIO_LED_WAN 4
  6395. +#define AP143_GPIO_LED_LAN1 16
  6396. +#define AP143_GPIO_LED_LAN2 15
  6397. +#define AP143_GPIO_LED_LAN3 14
  6398. +#define AP143_GPIO_LED_LAN4 11
  6399. +
  6400. +#define AP143_GPIO_BTN_WPS 17
  6401. +
  6402. +#define AP143_KEYS_POLL_INTERVAL 20 /* msecs */
  6403. +#define AP143_KEYS_DEBOUNCE_INTERVAL (3 * AP143_KEYS_POLL_INTERVAL)
  6404. +
  6405. +#define AP143_MAC0_OFFSET 0
  6406. +#define AP143_MAC1_OFFSET 6
  6407. +#define AP143_WMAC_CALDATA_OFFSET 0x1000
  6408. +
  6409. +static struct gpio_led ap143_leds_gpio[] __initdata = {
  6410. + {
  6411. + .name = "ap143:green:status",
  6412. + .gpio = AP143_GPIO_LED_STATUS,
  6413. + .active_low = 1,
  6414. + },
  6415. + {
  6416. + .name = "ap143:green:wlan",
  6417. + .gpio = AP143_GPIO_LED_WLAN,
  6418. + .active_low = 1,
  6419. + }
  6420. +};
  6421. +
  6422. +static struct gpio_keys_button ap143_gpio_keys[] __initdata = {
  6423. + {
  6424. + .desc = "WPS button",
  6425. + .type = EV_KEY,
  6426. + .code = KEY_WPS_BUTTON,
  6427. + .debounce_interval = AP143_KEYS_DEBOUNCE_INTERVAL,
  6428. + .gpio = AP143_GPIO_BTN_WPS,
  6429. + .active_low = 1,
  6430. + },
  6431. +};
  6432. +
  6433. +static void __init ap143_gpio_led_setup(void)
  6434. +{
  6435. + ath79_gpio_direction_select(AP143_GPIO_LED_WAN, true);
  6436. + ath79_gpio_direction_select(AP143_GPIO_LED_LAN1, true);
  6437. + ath79_gpio_direction_select(AP143_GPIO_LED_LAN2, true);
  6438. + ath79_gpio_direction_select(AP143_GPIO_LED_LAN3, true);
  6439. + ath79_gpio_direction_select(AP143_GPIO_LED_LAN4, true);
  6440. +
  6441. + ath79_gpio_output_select(AP143_GPIO_LED_WAN,
  6442. + QCA953X_GPIO_OUT_MUX_LED_LINK5);
  6443. + ath79_gpio_output_select(AP143_GPIO_LED_LAN1,
  6444. + QCA953X_GPIO_OUT_MUX_LED_LINK1);
  6445. + ath79_gpio_output_select(AP143_GPIO_LED_LAN2,
  6446. + QCA953X_GPIO_OUT_MUX_LED_LINK2);
  6447. + ath79_gpio_output_select(AP143_GPIO_LED_LAN3,
  6448. + QCA953X_GPIO_OUT_MUX_LED_LINK3);
  6449. + ath79_gpio_output_select(AP143_GPIO_LED_LAN4,
  6450. + QCA953X_GPIO_OUT_MUX_LED_LINK4);
  6451. +
  6452. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap143_leds_gpio),
  6453. + ap143_leds_gpio);
  6454. + ath79_register_gpio_keys_polled(-1, AP143_KEYS_POLL_INTERVAL,
  6455. + ARRAY_SIZE(ap143_gpio_keys),
  6456. + ap143_gpio_keys);
  6457. +}
  6458. +
  6459. +static void __init ap143_setup(void)
  6460. +{
  6461. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6462. +
  6463. + ath79_register_m25p80(NULL);
  6464. +
  6465. + ap143_gpio_led_setup();
  6466. +
  6467. + ath79_register_usb();
  6468. +
  6469. + ath79_wmac_set_led_pin(AP143_GPIO_LED_WLAN);
  6470. + ath79_register_wmac(art + AP143_WMAC_CALDATA_OFFSET, NULL);
  6471. +
  6472. + ath79_register_mdio(0, 0x0);
  6473. + ath79_register_mdio(1, 0x0);
  6474. +
  6475. + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP143_MAC0_OFFSET, 0);
  6476. + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP143_MAC1_OFFSET, 0);
  6477. +
  6478. + /* WAN port */
  6479. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6480. + ath79_eth0_data.speed = SPEED_100;
  6481. + ath79_eth0_data.duplex = DUPLEX_FULL;
  6482. + ath79_eth0_data.phy_mask = BIT(4);
  6483. + ath79_register_eth(0);
  6484. +
  6485. + /* LAN ports */
  6486. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  6487. + ath79_eth1_data.speed = SPEED_1000;
  6488. + ath79_eth1_data.duplex = DUPLEX_FULL;
  6489. + ath79_switch_data.phy_poll_mask |= BIT(4);
  6490. + ath79_switch_data.phy4_mii_en = 1;
  6491. + ath79_register_eth(1);
  6492. +}
  6493. +
  6494. +MIPS_MACHINE(ATH79_MACH_AP143, "AP143", "Qualcomm Atheros AP143 reference board",
  6495. + ap143_setup);
  6496. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap147.c linux-4.1.13/arch/mips/ath79/mach-ap147.c
  6497. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap147.c 1970-01-01 01:00:00.000000000 +0100
  6498. +++ linux-4.1.13/arch/mips/ath79/mach-ap147.c 2015-09-13 20:04:35.068524086 +0200
  6499. @@ -0,0 +1,125 @@
  6500. +/*
  6501. + * Atheros AP147 reference board support
  6502. + *
  6503. + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
  6504. + * Copyright (C) 2015 Sven Eckelmann <sven@open-mesh.com>
  6505. + *
  6506. + * This program is free software; you can redistribute it and/or modify it
  6507. + * under the terms of the GNU General Public License version 2 as published
  6508. + * by the Free Software Foundation.
  6509. + */
  6510. +
  6511. +#include <linux/platform_device.h>
  6512. +#include <linux/ar8216_platform.h>
  6513. +
  6514. +#include <asm/mach-ath79/ar71xx_regs.h>
  6515. +#include <asm/mach-ath79/ath79.h>
  6516. +
  6517. +#include "common.h"
  6518. +#include "dev-ap9x-pci.h"
  6519. +#include "dev-eth.h"
  6520. +#include "dev-gpio-buttons.h"
  6521. +#include "dev-leds-gpio.h"
  6522. +#include "dev-m25p80.h"
  6523. +#include "dev-usb.h"
  6524. +#include "dev-wmac.h"
  6525. +#include "machtypes.h"
  6526. +#include "pci.h"
  6527. +
  6528. +#define AP147_GPIO_LED_WAN 4
  6529. +#define AP147_GPIO_LED_LAN1 16
  6530. +#define AP147_GPIO_LED_LAN2 15
  6531. +#define AP147_GPIO_LED_LAN3 14
  6532. +#define AP147_GPIO_LED_LAN4 11
  6533. +#define AP147_GPIO_LED_STATUS 13
  6534. +#define AP147_GPIO_LED_WLAN_2G 12
  6535. +
  6536. +#define AP147_GPIO_BTN_WPS 17
  6537. +
  6538. +#define AP147_KEYS_POLL_INTERVAL 20 /* msecs */
  6539. +#define AP147_KEYS_DEBOUNCE_INTERVAL (3 * AP147_KEYS_POLL_INTERVAL)
  6540. +
  6541. +#define AP147_MAC0_OFFSET 0x1000
  6542. +
  6543. +static struct gpio_led ap147_leds_gpio[] __initdata = {
  6544. + {
  6545. + .name = "ap147:green:status",
  6546. + .gpio = AP147_GPIO_LED_STATUS,
  6547. + .active_low = 1,
  6548. + }, {
  6549. + .name = "ap147:green:wlan-2g",
  6550. + .gpio = AP147_GPIO_LED_WLAN_2G,
  6551. + .active_low = 1,
  6552. + }, {
  6553. + .name = "ap147:green:lan1",
  6554. + .gpio = AP147_GPIO_LED_LAN1,
  6555. + .active_low = 1,
  6556. + }, {
  6557. + .name = "ap147:green:lan2",
  6558. + .gpio = AP147_GPIO_LED_LAN2,
  6559. + .active_low = 1,
  6560. + }, {
  6561. + .name = "ap147:green:lan3",
  6562. + .gpio = AP147_GPIO_LED_LAN3,
  6563. + .active_low = 1,
  6564. + }, {
  6565. + .name = "ap147:green:lan4",
  6566. + .gpio = AP147_GPIO_LED_LAN4,
  6567. + .active_low = 1,
  6568. + }, {
  6569. + .name = "ap147:green:wan",
  6570. + .gpio = AP147_GPIO_LED_WAN,
  6571. + .active_low = 1,
  6572. + },
  6573. +};
  6574. +
  6575. +static struct gpio_keys_button ap147_gpio_keys[] __initdata = {
  6576. + {
  6577. + .desc = "wps button",
  6578. + .type = EV_KEY,
  6579. + .code = KEY_WPS_BUTTON,
  6580. + .debounce_interval = AP147_KEYS_DEBOUNCE_INTERVAL,
  6581. + .gpio = AP147_GPIO_BTN_WPS,
  6582. + .active_low = 1,
  6583. + }
  6584. +};
  6585. +
  6586. +static void __init ap147_setup(void)
  6587. +{
  6588. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  6589. +
  6590. + ath79_register_m25p80(NULL);
  6591. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap147_leds_gpio),
  6592. + ap147_leds_gpio);
  6593. + ath79_register_gpio_keys_polled(-1, AP147_KEYS_POLL_INTERVAL,
  6594. + ARRAY_SIZE(ap147_gpio_keys),
  6595. + ap147_gpio_keys);
  6596. +
  6597. + ath79_register_usb();
  6598. +
  6599. + ath79_register_pci();
  6600. +
  6601. + ath79_register_wmac(art + AP147_MAC0_OFFSET, NULL);
  6602. +
  6603. + ath79_setup_ar933x_phy4_switch(false, false);
  6604. +
  6605. + ath79_register_mdio(0, 0x0);
  6606. +
  6607. + /* LAN */
  6608. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  6609. + ath79_eth1_data.duplex = DUPLEX_FULL;
  6610. + ath79_switch_data.phy_poll_mask |= BIT(4);
  6611. + ath79_init_mac(ath79_eth1_data.mac_addr, art, 0);
  6612. + ath79_register_eth(1);
  6613. +
  6614. + /* WAN */
  6615. + ath79_switch_data.phy4_mii_en = 1;
  6616. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6617. + ath79_eth0_data.duplex = DUPLEX_FULL;
  6618. + ath79_eth0_data.speed = SPEED_100;
  6619. + ath79_eth0_data.phy_mask = BIT(4);
  6620. + ath79_init_mac(ath79_eth0_data.mac_addr, art, 1);
  6621. + ath79_register_eth(0);
  6622. +}
  6623. +
  6624. +MIPS_MACHINE(ATH79_MACH_AP147_010, "AP147-010", "Atheros AP147-010 reference board", ap147_setup);
  6625. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap152.c linux-4.1.13/arch/mips/ath79/mach-ap152.c
  6626. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap152.c 1970-01-01 01:00:00.000000000 +0100
  6627. +++ linux-4.1.13/arch/mips/ath79/mach-ap152.c 2015-11-21 17:22:11.759223549 +0100
  6628. @@ -0,0 +1,141 @@
  6629. +
  6630. +/*
  6631. + * Qualcomm Atheros AP152 reference board support
  6632. + *
  6633. + * Copyright (c) 2015 Qualcomm Atheros
  6634. + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  6635. + *
  6636. + * Permission to use, copy, modify, and/or distribute this software for any
  6637. + * purpose with or without fee is hereby granted, provided that the above
  6638. + * copyright notice and this permission notice appear in all copies.
  6639. + *
  6640. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  6641. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  6642. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  6643. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  6644. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  6645. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  6646. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  6647. + *
  6648. + */
  6649. +
  6650. +#include <linux/platform_device.h>
  6651. +#include <linux/ath9k_platform.h>
  6652. +#include <linux/ar8216_platform.h>
  6653. +#include <asm/mach-ath79/ar71xx_regs.h>
  6654. +
  6655. +#include "common.h"
  6656. +#include "dev-m25p80.h"
  6657. +#include "machtypes.h"
  6658. +#include "pci.h"
  6659. +#include "dev-eth.h"
  6660. +#include "dev-gpio-buttons.h"
  6661. +#include "dev-leds-gpio.h"
  6662. +#include "dev-spi.h"
  6663. +#include "dev-usb.h"
  6664. +#include "dev-wmac.h"
  6665. +
  6666. +#define AP152_GPIO_LED_USB0 7
  6667. +#define AP152_GPIO_LED_USB1 8
  6668. +
  6669. +#define AP152_GPIO_BTN_RESET 2
  6670. +#define AP152_GPIO_BTN_WPS 1
  6671. +#define AP152_KEYS_POLL_INTERVAL 20 /* msecs */
  6672. +#define AP152_KEYS_DEBOUNCE_INTERVAL (3 * AP152_KEYS_POLL_INTERVAL)
  6673. +
  6674. +#define AP152_MAC0_OFFSET 0
  6675. +#define AP152_WMAC_CALDATA_OFFSET 0x1000
  6676. +
  6677. +static struct gpio_led ap152_leds_gpio[] __initdata = {
  6678. + {
  6679. + .name = "ap152:green:usb0",
  6680. + .gpio = AP152_GPIO_LED_USB0,
  6681. + .active_low = 1,
  6682. + },
  6683. + {
  6684. + .name = "ap152:green:usb1",
  6685. + .gpio = AP152_GPIO_LED_USB1,
  6686. + .active_low = 1,
  6687. + },
  6688. +};
  6689. +
  6690. +static struct gpio_keys_button ap152_gpio_keys[] __initdata = {
  6691. + {
  6692. + .desc = "WPS button",
  6693. + .type = EV_KEY,
  6694. + .code = KEY_WPS_BUTTON,
  6695. + .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
  6696. + .gpio = AP152_GPIO_BTN_WPS,
  6697. + .active_low = 1,
  6698. + },
  6699. + {
  6700. + .desc = "Reset button",
  6701. + .type = EV_KEY,
  6702. + .code = KEY_RESTART,
  6703. + .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
  6704. + .gpio = AP152_GPIO_BTN_RESET,
  6705. + .active_low = 1,
  6706. + },
  6707. +};
  6708. +
  6709. +static struct ar8327_pad_cfg ap152_ar8337_pad0_cfg = {
  6710. + .mode = AR8327_PAD_MAC_SGMII,
  6711. + .sgmii_delay_en = true,
  6712. +};
  6713. +
  6714. +static struct ar8327_platform_data ap152_ar8337_data = {
  6715. + .pad0_cfg = &ap152_ar8337_pad0_cfg,
  6716. + .port0_cfg = {
  6717. + .force_link = 1,
  6718. + .speed = AR8327_PORT_SPEED_1000,
  6719. + .duplex = 1,
  6720. + .txpause = 1,
  6721. + .rxpause = 1,
  6722. + },
  6723. +};
  6724. +
  6725. +static struct mdio_board_info ap152_mdio0_info[] = {
  6726. + {
  6727. + .bus_id = "ag71xx-mdio.0",
  6728. + .phy_addr = 0,
  6729. + .platform_data = &ap152_ar8337_data,
  6730. + },
  6731. +};
  6732. +
  6733. +static void __init ap152_setup(void)
  6734. +{
  6735. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6736. +
  6737. + ath79_register_m25p80(NULL);
  6738. +
  6739. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap152_leds_gpio),
  6740. + ap152_leds_gpio);
  6741. + ath79_register_gpio_keys_polled(-1, AP152_KEYS_POLL_INTERVAL,
  6742. + ARRAY_SIZE(ap152_gpio_keys),
  6743. + ap152_gpio_keys);
  6744. +
  6745. + ath79_register_usb();
  6746. +
  6747. + platform_device_register(&ath79_mdio0_device);
  6748. +
  6749. + mdiobus_register_board_info(ap152_mdio0_info,
  6750. + ARRAY_SIZE(ap152_mdio0_info));
  6751. +
  6752. + ath79_register_wmac(art + AP152_WMAC_CALDATA_OFFSET, NULL);
  6753. + ath79_register_pci();
  6754. +
  6755. + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP152_MAC0_OFFSET, 0);
  6756. +
  6757. + /* GMAC0 is connected to an AR8337 switch */
  6758. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  6759. + ath79_eth0_data.speed = SPEED_1000;
  6760. + ath79_eth0_data.duplex = DUPLEX_FULL;
  6761. + ath79_eth0_data.phy_mask = BIT(0);
  6762. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  6763. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  6764. +
  6765. + ath79_register_eth(0);
  6766. +}
  6767. +
  6768. +MIPS_MACHINE(ATH79_MACH_AP152, "AP152", "Qualcomm Atheros AP152 reference board",
  6769. + ap152_setup);
  6770. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap81.c linux-4.1.13/arch/mips/ath79/mach-ap81.c
  6771. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap81.c 2015-11-09 23:34:10.000000000 +0100
  6772. +++ linux-4.1.13/arch/mips/ath79/mach-ap81.c 2015-12-04 19:57:04.310082904 +0100
  6773. @@ -9,12 +9,16 @@
  6774. * by the Free Software Foundation.
  6775. */
  6776. -#include "machtypes.h"
  6777. -#include "dev-wmac.h"
  6778. +#include <linux/mtd/mtd.h>
  6779. +#include <linux/mtd/partitions.h>
  6780. +
  6781. +#include "dev-eth.h"
  6782. #include "dev-gpio-buttons.h"
  6783. #include "dev-leds-gpio.h"
  6784. -#include "dev-spi.h"
  6785. +#include "dev-m25p80.h"
  6786. #include "dev-usb.h"
  6787. +#include "dev-wmac.h"
  6788. +#include "machtypes.h"
  6789. #define AP81_GPIO_LED_STATUS 1
  6790. #define AP81_GPIO_LED_AOSS 3
  6791. @@ -67,20 +71,6 @@
  6792. }
  6793. };
  6794. -static struct spi_board_info ap81_spi_info[] = {
  6795. - {
  6796. - .bus_num = 0,
  6797. - .chip_select = 0,
  6798. - .max_speed_hz = 25000000,
  6799. - .modalias = "m25p64",
  6800. - }
  6801. -};
  6802. -
  6803. -static struct ath79_spi_platform_data ap81_spi_data = {
  6804. - .bus_num = 0,
  6805. - .num_chipselect = 1,
  6806. -};
  6807. -
  6808. static void __init ap81_setup(void)
  6809. {
  6810. u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
  6811. @@ -90,10 +80,24 @@
  6812. ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL,
  6813. ARRAY_SIZE(ap81_gpio_keys),
  6814. ap81_gpio_keys);
  6815. - ath79_register_spi(&ap81_spi_data, ap81_spi_info,
  6816. - ARRAY_SIZE(ap81_spi_info));
  6817. - ath79_register_wmac(cal_data);
  6818. + ath79_register_m25p80(NULL);
  6819. + ath79_register_wmac(cal_data, NULL);
  6820. ath79_register_usb();
  6821. +
  6822. + ath79_register_mdio(0, 0x0);
  6823. +
  6824. + ath79_init_mac(ath79_eth0_data.mac_addr, cal_data, 0);
  6825. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6826. + ath79_eth0_data.speed = SPEED_100;
  6827. + ath79_eth0_data.duplex = DUPLEX_FULL;
  6828. + ath79_eth0_data.has_ar8216 = 1;
  6829. +
  6830. + ath79_init_mac(ath79_eth1_data.mac_addr, cal_data, 1);
  6831. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6832. + ath79_eth1_data.phy_mask = 0x10;
  6833. +
  6834. + ath79_register_eth(0);
  6835. + ath79_register_eth(1);
  6836. }
  6837. MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
  6838. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap83.c linux-4.1.13/arch/mips/ath79/mach-ap83.c
  6839. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap83.c 1970-01-01 01:00:00.000000000 +0100
  6840. +++ linux-4.1.13/arch/mips/ath79/mach-ap83.c 2015-12-04 19:57:04.438074530 +0100
  6841. @@ -0,0 +1,242 @@
  6842. +/*
  6843. + * Atheros AP83 board support
  6844. + *
  6845. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  6846. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6847. + *
  6848. + * This program is free software; you can redistribute it and/or modify it
  6849. + * under the terms of the GNU General Public License version 2 as published
  6850. + * by the Free Software Foundation.
  6851. + */
  6852. +
  6853. +#include <linux/delay.h>
  6854. +#include <linux/platform_device.h>
  6855. +#include <linux/mtd/mtd.h>
  6856. +#include <linux/mtd/partitions.h>
  6857. +#include <linux/mtd/physmap.h>
  6858. +#include <linux/spi/spi.h>
  6859. +#include <linux/spi/spi_gpio.h>
  6860. +#include <linux/spi/vsc7385.h>
  6861. +
  6862. +#include <asm/mach-ath79/ar71xx_regs.h>
  6863. +#include <asm/mach-ath79/ath79.h>
  6864. +
  6865. +#include "dev-eth.h"
  6866. +#include "dev-gpio-buttons.h"
  6867. +#include "dev-leds-gpio.h"
  6868. +#include "dev-usb.h"
  6869. +#include "dev-wmac.h"
  6870. +#include "machtypes.h"
  6871. +
  6872. +#define AP83_GPIO_LED_WLAN 6
  6873. +#define AP83_GPIO_LED_POWER 14
  6874. +#define AP83_GPIO_LED_JUMPSTART 15
  6875. +#define AP83_GPIO_BTN_JUMPSTART 12
  6876. +#define AP83_GPIO_BTN_RESET 21
  6877. +
  6878. +#define AP83_050_GPIO_VSC7385_CS 1
  6879. +#define AP83_050_GPIO_VSC7385_MISO 3
  6880. +#define AP83_050_GPIO_VSC7385_MOSI 16
  6881. +#define AP83_050_GPIO_VSC7385_SCK 17
  6882. +
  6883. +#define AP83_KEYS_POLL_INTERVAL 20 /* msecs */
  6884. +#define AP83_KEYS_DEBOUNCE_INTERVAL (3 * AP83_KEYS_POLL_INTERVAL)
  6885. +
  6886. +static struct physmap_flash_data ap83_flash_data = {
  6887. + .width = 2,
  6888. +};
  6889. +
  6890. +static struct resource ap83_flash_resources[] = {
  6891. + [0] = {
  6892. + .start = AR71XX_SPI_BASE,
  6893. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  6894. + .flags = IORESOURCE_MEM,
  6895. + },
  6896. +};
  6897. +
  6898. +static struct platform_device ap83_flash_device = {
  6899. + .name = "ar91xx-flash",
  6900. + .id = -1,
  6901. + .resource = ap83_flash_resources,
  6902. + .num_resources = ARRAY_SIZE(ap83_flash_resources),
  6903. + .dev = {
  6904. + .platform_data = &ap83_flash_data,
  6905. + }
  6906. +};
  6907. +
  6908. +static struct gpio_led ap83_leds_gpio[] __initdata = {
  6909. + {
  6910. + .name = "ap83:green:jumpstart",
  6911. + .gpio = AP83_GPIO_LED_JUMPSTART,
  6912. + .active_low = 0,
  6913. + }, {
  6914. + .name = "ap83:green:power",
  6915. + .gpio = AP83_GPIO_LED_POWER,
  6916. + .active_low = 0,
  6917. + }, {
  6918. + .name = "ap83:green:wlan",
  6919. + .gpio = AP83_GPIO_LED_WLAN,
  6920. + .active_low = 0,
  6921. + },
  6922. +};
  6923. +
  6924. +static struct gpio_keys_button ap83_gpio_keys[] __initdata = {
  6925. + {
  6926. + .desc = "soft_reset",
  6927. + .type = EV_KEY,
  6928. + .code = KEY_RESTART,
  6929. + .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
  6930. + .gpio = AP83_GPIO_BTN_RESET,
  6931. + .active_low = 1,
  6932. + }, {
  6933. + .desc = "jumpstart",
  6934. + .type = EV_KEY,
  6935. + .code = KEY_WPS_BUTTON,
  6936. + .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
  6937. + .gpio = AP83_GPIO_BTN_JUMPSTART,
  6938. + .active_low = 1,
  6939. + }
  6940. +};
  6941. +
  6942. +static struct resource ap83_040_spi_resources[] = {
  6943. + [0] = {
  6944. + .start = AR71XX_SPI_BASE,
  6945. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  6946. + .flags = IORESOURCE_MEM,
  6947. + },
  6948. +};
  6949. +
  6950. +static struct platform_device ap83_040_spi_device = {
  6951. + .name = "ap83-spi",
  6952. + .id = 0,
  6953. + .resource = ap83_040_spi_resources,
  6954. + .num_resources = ARRAY_SIZE(ap83_040_spi_resources),
  6955. +};
  6956. +
  6957. +static struct spi_gpio_platform_data ap83_050_spi_data = {
  6958. + .miso = AP83_050_GPIO_VSC7385_MISO,
  6959. + .mosi = AP83_050_GPIO_VSC7385_MOSI,
  6960. + .sck = AP83_050_GPIO_VSC7385_SCK,
  6961. + .num_chipselect = 1,
  6962. +};
  6963. +
  6964. +static struct platform_device ap83_050_spi_device = {
  6965. + .name = "spi_gpio",
  6966. + .id = 0,
  6967. + .dev = {
  6968. + .platform_data = &ap83_050_spi_data,
  6969. + }
  6970. +};
  6971. +
  6972. +static void ap83_vsc7385_reset(void)
  6973. +{
  6974. + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
  6975. + udelay(10);
  6976. + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
  6977. + mdelay(50);
  6978. +}
  6979. +
  6980. +static struct vsc7385_platform_data ap83_vsc7385_data = {
  6981. + .reset = ap83_vsc7385_reset,
  6982. + .ucode_name = "vsc7385_ucode_ap83.bin",
  6983. + .mac_cfg = {
  6984. + .tx_ipg = 6,
  6985. + .bit2 = 0,
  6986. + .clk_sel = 3,
  6987. + },
  6988. +};
  6989. +
  6990. +static struct spi_board_info ap83_spi_info[] = {
  6991. + {
  6992. + .bus_num = 0,
  6993. + .chip_select = 0,
  6994. + .max_speed_hz = 25000000,
  6995. + .modalias = "spi-vsc7385",
  6996. + .platform_data = &ap83_vsc7385_data,
  6997. + .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
  6998. + }
  6999. +};
  7000. +
  7001. +static void __init ap83_generic_setup(void)
  7002. +{
  7003. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  7004. +
  7005. + ath79_register_mdio(0, 0xfffffffe);
  7006. +
  7007. + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  7008. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7009. + ath79_eth0_data.phy_mask = 0x1;
  7010. +
  7011. + ath79_register_eth(0);
  7012. +
  7013. + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  7014. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7015. + ath79_eth1_data.speed = SPEED_1000;
  7016. + ath79_eth1_data.duplex = DUPLEX_FULL;
  7017. +
  7018. + ath79_eth1_pll_data.pll_1000 = 0x1f000000;
  7019. +
  7020. + ath79_register_eth(1);
  7021. +
  7022. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
  7023. + ap83_leds_gpio);
  7024. +
  7025. + ath79_register_gpio_keys_polled(-1, AP83_KEYS_POLL_INTERVAL,
  7026. + ARRAY_SIZE(ap83_gpio_keys),
  7027. + ap83_gpio_keys);
  7028. +
  7029. + ath79_register_usb();
  7030. +
  7031. + ath79_register_wmac(eeprom, NULL);
  7032. +
  7033. + platform_device_register(&ap83_flash_device);
  7034. +
  7035. + spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
  7036. +}
  7037. +
  7038. +static void ap83_040_flash_lock(struct platform_device *pdev)
  7039. +{
  7040. + ath79_flash_acquire();
  7041. +}
  7042. +
  7043. +static void ap83_040_flash_unlock(struct platform_device *pdev)
  7044. +{
  7045. + ath79_flash_release();
  7046. +}
  7047. +
  7048. +static void __init ap83_040_setup(void)
  7049. +{
  7050. + ap83_flash_data.lock = ap83_040_flash_lock;
  7051. + ap83_flash_data.unlock = ap83_040_flash_unlock;
  7052. + ap83_generic_setup();
  7053. + platform_device_register(&ap83_040_spi_device);
  7054. +}
  7055. +
  7056. +static void __init ap83_050_setup(void)
  7057. +{
  7058. + ap83_generic_setup();
  7059. + platform_device_register(&ap83_050_spi_device);
  7060. +}
  7061. +
  7062. +static void __init ap83_setup(void)
  7063. +{
  7064. + u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
  7065. + unsigned int board_version;
  7066. +
  7067. + board_version = (unsigned int)(board_id[0] - '0');
  7068. + board_version += ((unsigned int)(board_id[1] - '0')) * 10;
  7069. +
  7070. + switch (board_version) {
  7071. + case 40:
  7072. + ap83_040_setup();
  7073. + break;
  7074. + case 50:
  7075. + ap83_050_setup();
  7076. + break;
  7077. + default:
  7078. + printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
  7079. + board_version);
  7080. + }
  7081. +}
  7082. +
  7083. +MIPS_MACHINE(ATH79_MACH_AP83, "AP83", "Atheros AP83", ap83_setup);
  7084. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ap96.c linux-4.1.13/arch/mips/ath79/mach-ap96.c
  7085. --- linux-4.1.13.orig/arch/mips/ath79/mach-ap96.c 1970-01-01 01:00:00.000000000 +0100
  7086. +++ linux-4.1.13/arch/mips/ath79/mach-ap96.c 2015-09-13 20:04:35.068524086 +0200
  7087. @@ -0,0 +1,142 @@
  7088. +/*
  7089. + * Atheros AP96 board support
  7090. + *
  7091. + * Copyright (C) 2009 Marco Porsch
  7092. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  7093. + * Copyright (C) 2010 Atheros Communications
  7094. + *
  7095. + * This program is free software; you can redistribute it and/or modify it
  7096. + * under the terms of the GNU General Public License version 2 as published
  7097. + * by the Free Software Foundation.
  7098. + */
  7099. +
  7100. +#include <linux/platform_device.h>
  7101. +#include <linux/delay.h>
  7102. +
  7103. +#include <asm/mach-ath79/ath79.h>
  7104. +
  7105. +#include "dev-ap9x-pci.h"
  7106. +#include "dev-eth.h"
  7107. +#include "dev-gpio-buttons.h"
  7108. +#include "dev-leds-gpio.h"
  7109. +#include "dev-m25p80.h"
  7110. +#include "dev-usb.h"
  7111. +#include "machtypes.h"
  7112. +
  7113. +#define AP96_GPIO_LED_12_GREEN 0
  7114. +#define AP96_GPIO_LED_3_GREEN 1
  7115. +#define AP96_GPIO_LED_2_GREEN 2
  7116. +#define AP96_GPIO_LED_WPS_GREEN 4
  7117. +#define AP96_GPIO_LED_5_GREEN 5
  7118. +#define AP96_GPIO_LED_4_ORANGE 6
  7119. +
  7120. +/* Reset button - next to the power connector */
  7121. +#define AP96_GPIO_BTN_RESET 3
  7122. +/* WPS button - next to a led on right */
  7123. +#define AP96_GPIO_BTN_WPS 8
  7124. +
  7125. +#define AP96_KEYS_POLL_INTERVAL 20 /* msecs */
  7126. +#define AP96_KEYS_DEBOUNCE_INTERVAL (3 * AP96_KEYS_POLL_INTERVAL)
  7127. +
  7128. +#define AP96_WMAC0_MAC_OFFSET 0x120c
  7129. +#define AP96_WMAC1_MAC_OFFSET 0x520c
  7130. +#define AP96_CALDATA0_OFFSET 0x1000
  7131. +#define AP96_CALDATA1_OFFSET 0x5000
  7132. +
  7133. +/*
  7134. + * AP96 has 12 unlabeled leds in the front; these are numbered from 1 to 12
  7135. + * below (from left to right on the board). Led 1 seems to be on whenever the
  7136. + * board is powered. Led 11 shows LAN link activity actity. Led 3 is orange;
  7137. + * others are green.
  7138. + *
  7139. + * In addition, there is one led next to a button on the right side for WPS.
  7140. + */
  7141. +static struct gpio_led ap96_leds_gpio[] __initdata = {
  7142. + {
  7143. + .name = "ap96:green:led2",
  7144. + .gpio = AP96_GPIO_LED_2_GREEN,
  7145. + .active_low = 1,
  7146. + }, {
  7147. + .name = "ap96:green:led3",
  7148. + .gpio = AP96_GPIO_LED_3_GREEN,
  7149. + .active_low = 1,
  7150. + }, {
  7151. + .name = "ap96:orange:led4",
  7152. + .gpio = AP96_GPIO_LED_4_ORANGE,
  7153. + .active_low = 1,
  7154. + }, {
  7155. + .name = "ap96:green:led5",
  7156. + .gpio = AP96_GPIO_LED_5_GREEN,
  7157. + .active_low = 1,
  7158. + }, {
  7159. + .name = "ap96:green:led12",
  7160. + .gpio = AP96_GPIO_LED_12_GREEN,
  7161. + .active_low = 1,
  7162. + }, { /* next to a button on right */
  7163. + .name = "ap96:green:wps",
  7164. + .gpio = AP96_GPIO_LED_WPS_GREEN,
  7165. + .active_low = 1,
  7166. + }
  7167. +};
  7168. +
  7169. +static struct gpio_keys_button ap96_gpio_keys[] __initdata = {
  7170. + {
  7171. + .desc = "reset",
  7172. + .type = EV_KEY,
  7173. + .code = KEY_RESTART,
  7174. + .debounce_interval = AP96_KEYS_DEBOUNCE_INTERVAL,
  7175. + .gpio = AP96_GPIO_BTN_RESET,
  7176. + .active_low = 1,
  7177. + }, {
  7178. + .desc = "wps",
  7179. + .type = EV_KEY,
  7180. + .code = KEY_WPS_BUTTON,
  7181. + .debounce_interval = AP96_KEYS_DEBOUNCE_INTERVAL,
  7182. + .gpio = AP96_GPIO_BTN_WPS,
  7183. + .active_low = 1,
  7184. + }
  7185. +};
  7186. +
  7187. +#define AP96_WAN_PHYMASK 0x10
  7188. +#define AP96_LAN_PHYMASK 0x0f
  7189. +
  7190. +static void __init ap96_setup(void)
  7191. +{
  7192. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  7193. +
  7194. + ath79_register_mdio(0, ~(AP96_WAN_PHYMASK | AP96_LAN_PHYMASK));
  7195. +
  7196. + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
  7197. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7198. + ath79_eth0_data.phy_mask = AP96_LAN_PHYMASK;
  7199. + ath79_eth0_data.speed = SPEED_1000;
  7200. + ath79_eth0_data.duplex = DUPLEX_FULL;
  7201. +
  7202. + ath79_register_eth(0);
  7203. +
  7204. + ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
  7205. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7206. + ath79_eth1_data.phy_mask = AP96_WAN_PHYMASK;
  7207. +
  7208. + ath79_eth1_pll_data.pll_1000 = 0x1f000000;
  7209. +
  7210. + ath79_register_eth(1);
  7211. +
  7212. + ath79_register_usb();
  7213. +
  7214. + ath79_register_m25p80(NULL);
  7215. +
  7216. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap96_leds_gpio),
  7217. + ap96_leds_gpio);
  7218. +
  7219. + ath79_register_gpio_keys_polled(-1, AP96_KEYS_POLL_INTERVAL,
  7220. + ARRAY_SIZE(ap96_gpio_keys),
  7221. + ap96_gpio_keys);
  7222. +
  7223. + ap94_pci_init(art + AP96_CALDATA0_OFFSET,
  7224. + art + AP96_WMAC0_MAC_OFFSET,
  7225. + art + AP96_CALDATA1_OFFSET,
  7226. + art + AP96_WMAC1_MAC_OFFSET);
  7227. +}
  7228. +
  7229. +MIPS_MACHINE(ATH79_MACH_AP96, "AP96", "Atheros AP96", ap96_setup);
  7230. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-archer-c7.c linux-4.1.13/arch/mips/ath79/mach-archer-c7.c
  7231. --- linux-4.1.13.orig/arch/mips/ath79/mach-archer-c7.c 1970-01-01 01:00:00.000000000 +0100
  7232. +++ linux-4.1.13/arch/mips/ath79/mach-archer-c7.c 2015-09-13 20:04:35.068524086 +0200
  7233. @@ -0,0 +1,266 @@
  7234. +/*
  7235. + * TP-LINK Archer C5/C7/TL-WDR4900 v2 board support
  7236. + *
  7237. + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  7238. + * Copyright (c) 2014 施康成 <tenninjas@tenninjas.ca>
  7239. + * Copyright (c) 2014 Imre Kaloz <kaloz@openwrt.org>
  7240. + *
  7241. + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  7242. + * Copyright (c) 2012 Qualcomm Atheros
  7243. + *
  7244. + * Permission to use, copy, modify, and/or distribute this software for any
  7245. + * purpose with or without fee is hereby granted, provided that the above
  7246. + * copyright notice and this permission notice appear in all copies.
  7247. + *
  7248. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7249. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  7250. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  7251. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  7252. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  7253. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  7254. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  7255. + *
  7256. + */
  7257. +
  7258. +#include <linux/pci.h>
  7259. +#include <linux/phy.h>
  7260. +#include <linux/gpio.h>
  7261. +#include <linux/platform_device.h>
  7262. +#include <linux/ath9k_platform.h>
  7263. +#include <linux/ar8216_platform.h>
  7264. +
  7265. +#include <asm/mach-ath79/ar71xx_regs.h>
  7266. +
  7267. +#include "common.h"
  7268. +#include "dev-ap9x-pci.h"
  7269. +#include "dev-eth.h"
  7270. +#include "dev-gpio-buttons.h"
  7271. +#include "dev-leds-gpio.h"
  7272. +#include "dev-m25p80.h"
  7273. +#include "dev-spi.h"
  7274. +#include "dev-usb.h"
  7275. +#include "dev-wmac.h"
  7276. +#include "machtypes.h"
  7277. +#include "pci.h"
  7278. +
  7279. +#define ARCHER_C7_GPIO_LED_WLAN2G 12
  7280. +#define ARCHER_C7_GPIO_LED_SYSTEM 14
  7281. +#define ARCHER_C7_GPIO_LED_QSS 15
  7282. +#define ARCHER_C7_GPIO_LED_WLAN5G 17
  7283. +#define ARCHER_C7_GPIO_LED_USB1 18
  7284. +#define ARCHER_C7_GPIO_LED_USB2 19
  7285. +
  7286. +#define ARCHER_C7_GPIO_BTN_RFKILL 13
  7287. +#define ARCHER_C7_GPIO_BTN_RESET 16
  7288. +
  7289. +#define ARCHER_C7_GPIO_USB1_POWER 22
  7290. +#define ARCHER_C7_GPIO_USB2_POWER 21
  7291. +
  7292. +#define ARCHER_C7_KEYS_POLL_INTERVAL 20 /* msecs */
  7293. +#define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL)
  7294. +
  7295. +#define ARCHER_C7_WMAC_CALDATA_OFFSET 0x1000
  7296. +#define ARCHER_C7_PCIE_CALDATA_OFFSET 0x5000
  7297. +
  7298. +static const char *archer_c7_part_probes[] = {
  7299. + "tp-link",
  7300. + NULL,
  7301. +};
  7302. +
  7303. +static struct flash_platform_data archer_c7_flash_data = {
  7304. + .part_probes = archer_c7_part_probes,
  7305. +};
  7306. +
  7307. +static struct gpio_led archer_c7_leds_gpio[] __initdata = {
  7308. + {
  7309. + .name = "tp-link:blue:qss",
  7310. + .gpio = ARCHER_C7_GPIO_LED_QSS,
  7311. + .active_low = 1,
  7312. + },
  7313. + {
  7314. + .name = "tp-link:blue:system",
  7315. + .gpio = ARCHER_C7_GPIO_LED_SYSTEM,
  7316. + .active_low = 1,
  7317. + },
  7318. + {
  7319. + .name = "tp-link:blue:wlan2g",
  7320. + .gpio = ARCHER_C7_GPIO_LED_WLAN2G,
  7321. + .active_low = 1,
  7322. + },
  7323. + {
  7324. + .name = "tp-link:blue:wlan5g",
  7325. + .gpio = ARCHER_C7_GPIO_LED_WLAN5G,
  7326. + .active_low = 1,
  7327. + },
  7328. + {
  7329. + .name = "tp-link:green:usb1",
  7330. + .gpio = ARCHER_C7_GPIO_LED_USB1,
  7331. + .active_low = 1,
  7332. + },
  7333. + {
  7334. + .name = "tp-link:green:usb2",
  7335. + .gpio = ARCHER_C7_GPIO_LED_USB2,
  7336. + .active_low = 1,
  7337. + },
  7338. +};
  7339. +
  7340. +static struct gpio_keys_button archer_c7_gpio_keys[] __initdata = {
  7341. + {
  7342. + .desc = "Reset button",
  7343. + .type = EV_KEY,
  7344. + .code = KEY_WPS_BUTTON,
  7345. + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
  7346. + .gpio = ARCHER_C7_GPIO_BTN_RESET,
  7347. + .active_low = 1,
  7348. + },
  7349. + {
  7350. + .desc = "RFKILL switch",
  7351. + .type = EV_SW,
  7352. + .code = KEY_RFKILL,
  7353. + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
  7354. + .gpio = ARCHER_C7_GPIO_BTN_RFKILL,
  7355. + },
  7356. +};
  7357. +
  7358. +static const struct ar8327_led_info archer_c7_leds_ar8327[] __initconst = {
  7359. + AR8327_LED_INFO(PHY0_0, HW, "tp-link:blue:wan"),
  7360. + AR8327_LED_INFO(PHY1_0, HW, "tp-link:blue:lan1"),
  7361. + AR8327_LED_INFO(PHY2_0, HW, "tp-link:blue:lan2"),
  7362. + AR8327_LED_INFO(PHY3_0, HW, "tp-link:blue:lan3"),
  7363. + AR8327_LED_INFO(PHY4_0, HW, "tp-link:blue:lan4"),
  7364. +};
  7365. +
  7366. +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
  7367. +static struct ar8327_pad_cfg archer_c7_ar8327_pad0_cfg = {
  7368. + .mode = AR8327_PAD_MAC_SGMII,
  7369. + .sgmii_delay_en = true,
  7370. +};
  7371. +
  7372. +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
  7373. +static struct ar8327_pad_cfg archer_c7_ar8327_pad6_cfg = {
  7374. + .mode = AR8327_PAD_MAC_RGMII,
  7375. + .txclk_delay_en = true,
  7376. + .rxclk_delay_en = true,
  7377. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  7378. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  7379. +};
  7380. +
  7381. +static struct ar8327_led_cfg archer_c7_ar8327_led_cfg = {
  7382. + .led_ctrl0 = 0xc737c737,
  7383. + .led_ctrl1 = 0x00000000,
  7384. + .led_ctrl2 = 0x00000000,
  7385. + .led_ctrl3 = 0x0030c300,
  7386. + .open_drain = false,
  7387. +};
  7388. +
  7389. +static struct ar8327_platform_data archer_c7_ar8327_data = {
  7390. + .pad0_cfg = &archer_c7_ar8327_pad0_cfg,
  7391. + .pad6_cfg = &archer_c7_ar8327_pad6_cfg,
  7392. + .port0_cfg = {
  7393. + .force_link = 1,
  7394. + .speed = AR8327_PORT_SPEED_1000,
  7395. + .duplex = 1,
  7396. + .txpause = 1,
  7397. + .rxpause = 1,
  7398. + },
  7399. + .port6_cfg = {
  7400. + .force_link = 1,
  7401. + .speed = AR8327_PORT_SPEED_1000,
  7402. + .duplex = 1,
  7403. + .txpause = 1,
  7404. + .rxpause = 1,
  7405. + },
  7406. + .led_cfg = &archer_c7_ar8327_led_cfg,
  7407. + .num_leds = ARRAY_SIZE(archer_c7_leds_ar8327),
  7408. + .leds = archer_c7_leds_ar8327,
  7409. +};
  7410. +
  7411. +static struct mdio_board_info archer_c7_mdio0_info[] = {
  7412. + {
  7413. + .bus_id = "ag71xx-mdio.0",
  7414. + .phy_addr = 0,
  7415. + .platform_data = &archer_c7_ar8327_data,
  7416. + },
  7417. +};
  7418. +
  7419. +static void __init common_setup(bool pcie_slot)
  7420. +{
  7421. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  7422. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  7423. + u8 tmpmac[ETH_ALEN];
  7424. +
  7425. + ath79_register_m25p80(&archer_c7_flash_data);
  7426. + ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_leds_gpio),
  7427. + archer_c7_leds_gpio);
  7428. + ath79_register_gpio_keys_polled(-1, ARCHER_C7_KEYS_POLL_INTERVAL,
  7429. + ARRAY_SIZE(archer_c7_gpio_keys),
  7430. + archer_c7_gpio_keys);
  7431. +
  7432. + ath79_init_mac(tmpmac, mac, -1);
  7433. + ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, tmpmac);
  7434. +
  7435. + if (pcie_slot) {
  7436. + ath79_register_pci();
  7437. + } else {
  7438. + ath79_init_mac(tmpmac, mac, -1);
  7439. + ap9x_pci_setup_wmac_led_pin(0, 0);
  7440. + ap91_pci_init(art + ARCHER_C7_PCIE_CALDATA_OFFSET, tmpmac);
  7441. + }
  7442. +
  7443. + mdiobus_register_board_info(archer_c7_mdio0_info,
  7444. + ARRAY_SIZE(archer_c7_mdio0_info));
  7445. + ath79_register_mdio(0, 0x0);
  7446. +
  7447. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  7448. +
  7449. + /* GMAC0 is connected to the RMGII interface */
  7450. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7451. + ath79_eth0_data.phy_mask = BIT(0);
  7452. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  7453. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  7454. +
  7455. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  7456. + ath79_register_eth(0);
  7457. +
  7458. + /* GMAC1 is connected to the SGMII interface */
  7459. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  7460. + ath79_eth1_data.speed = SPEED_1000;
  7461. + ath79_eth1_data.duplex = DUPLEX_FULL;
  7462. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  7463. +
  7464. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  7465. + ath79_register_eth(1);
  7466. +
  7467. + gpio_request_one(ARCHER_C7_GPIO_USB1_POWER,
  7468. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  7469. + "USB1 power");
  7470. + gpio_request_one(ARCHER_C7_GPIO_USB2_POWER,
  7471. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  7472. + "USB2 power");
  7473. + ath79_register_usb();
  7474. +}
  7475. +
  7476. +static void __init archer_c5_setup(void)
  7477. +{
  7478. + common_setup(true);
  7479. +}
  7480. +
  7481. +MIPS_MACHINE(ATH79_MACH_ARCHER_C5, "ARCHER-C5", "TP-LINK Archer C5",
  7482. + archer_c5_setup);
  7483. +
  7484. +static void __init archer_c7_setup(void)
  7485. +{
  7486. + common_setup(true);
  7487. +}
  7488. +
  7489. +MIPS_MACHINE(ATH79_MACH_ARCHER_C7, "ARCHER-C7", "TP-LINK Archer C7",
  7490. + archer_c7_setup);
  7491. +
  7492. +static void __init tl_wdr4900_v2_setup(void)
  7493. +{
  7494. + common_setup(false);
  7495. +}
  7496. +
  7497. +MIPS_MACHINE(ATH79_MACH_TL_WDR4900_V2, "TL-WDR4900-v2", "TP-LINK TL-WDR4900 v2",
  7498. + tl_wdr4900_v2_setup)
  7499. +
  7500. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-arduino-yun.c linux-4.1.13/arch/mips/ath79/mach-arduino-yun.c
  7501. --- linux-4.1.13.orig/arch/mips/ath79/mach-arduino-yun.c 1970-01-01 01:00:00.000000000 +0100
  7502. +++ linux-4.1.13/arch/mips/ath79/mach-arduino-yun.c 2015-11-21 17:22:11.759223549 +0100
  7503. @@ -0,0 +1,137 @@
  7504. +/*
  7505. + * Arduino Yun support
  7506. + *
  7507. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  7508. + * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
  7509. + *
  7510. + * This program is free software; you can redistribute it and/or modify it
  7511. + * under the terms of the GNU General Public License version 2 as published
  7512. + * by the Free Software Foundation.
  7513. + */
  7514. +
  7515. +#include "dev-eth.h"
  7516. +#include "dev-gpio-buttons.h"
  7517. +#include "dev-leds-gpio.h"
  7518. +#include "dev-m25p80.h"
  7519. +#include "dev-spi.h"
  7520. +#include "dev-usb.h"
  7521. +#include "dev-wmac.h"
  7522. +#include "machtypes.h"
  7523. +#include <asm/mach-ath79/ar71xx_regs.h>
  7524. +#include <asm/mach-ath79/ath79.h>
  7525. +#include "common.h"
  7526. +#include "gpio.h"
  7527. +#include "linux/gpio.h"
  7528. +
  7529. +// Uncomment to have reset on gpio18 instead of gipo7
  7530. +#define DS2_B
  7531. +
  7532. +#define DS_GPIO_LED_WLAN 0
  7533. +#define DS_GPIO_LED_USB 1
  7534. +
  7535. +#define DS_GPIO_OE 21
  7536. +#define DS_GPIO_AVR_RESET 18
  7537. +
  7538. +// Maintained to have the console in the previous version of DS2 working
  7539. +#define DS_GPIO_AVR_RESET_DS2 7
  7540. +
  7541. +#define DS_GPIO_OE2 22
  7542. +#define DS_GPIO_UART_ENA 23
  7543. +#define DS_GPIO_CONF_BTN 20
  7544. +
  7545. +#define DS_KEYS_POLL_INTERVAL 20 /* msecs */
  7546. +#define DS_KEYS_DEBOUNCE_INTERVAL (3 * DS_KEYS_POLL_INTERVAL)
  7547. +
  7548. +#define DS_MAC0_OFFSET 0x0000
  7549. +#define DS_MAC1_OFFSET 0x0006
  7550. +#define DS_CALDATA_OFFSET 0x1000
  7551. +#define DS_WMAC_MAC_OFFSET 0x1002
  7552. +
  7553. +
  7554. +static struct gpio_led ds_leds_gpio[] __initdata = {
  7555. + {
  7556. + .name = "arduino:white:usb",
  7557. + .gpio = DS_GPIO_LED_USB,
  7558. + .active_low = 0,
  7559. + },
  7560. + {
  7561. + .name = "arduino:blue:wlan",
  7562. + .gpio = DS_GPIO_LED_WLAN,
  7563. + .active_low = 0,
  7564. + },
  7565. +};
  7566. +
  7567. +static void __init ds_common_setup(void)
  7568. +{
  7569. + static u8 mac[6];
  7570. +
  7571. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  7572. + ath79_register_m25p80(NULL);
  7573. +
  7574. + if (ar93xx_wmac_read_mac_address(mac)) {
  7575. + ath79_register_wmac(NULL, NULL);
  7576. + } else {
  7577. + ath79_register_wmac(art + DS_CALDATA_OFFSET,
  7578. + art + DS_WMAC_MAC_OFFSET);
  7579. + memcpy(mac, art + DS_WMAC_MAC_OFFSET, sizeof(mac));
  7580. + }
  7581. +
  7582. + mac[3] |= 0x08;
  7583. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  7584. +
  7585. + mac[3] &= 0xF7;
  7586. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  7587. + ath79_register_mdio(0, 0x0);
  7588. +
  7589. + /* LAN ports */
  7590. + ath79_register_eth(1);
  7591. +
  7592. + /* WAN port */
  7593. + ath79_register_eth(0);
  7594. +}
  7595. +
  7596. +static void __init ds_setup(void)
  7597. +{
  7598. + u32 t;
  7599. +
  7600. + ds_common_setup();
  7601. +
  7602. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio),
  7603. + ds_leds_gpio);
  7604. + ath79_register_usb();
  7605. +
  7606. + //Disable the Function for some pins to have GPIO functionality active
  7607. + // GPIO6-7-8 and GPIO11
  7608. + ath79_gpio_function_setup(AR933X_GPIO_FUNC_JTAG_DISABLE | AR933X_GPIO_FUNC_I2S_MCK_EN, 0);
  7609. +
  7610. + ath79_gpio_function2_setup(AR933X_GPIO_FUNC2_JUMPSTART_DISABLE, 0);
  7611. +
  7612. + printk("Setting DogStick2 GPIO\n");
  7613. +
  7614. + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  7615. + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  7616. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  7617. +
  7618. + // Put the avr reset to high
  7619. + if (gpio_request_one(DS_GPIO_AVR_RESET_DS2,
  7620. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
  7621. + printk("Error setting GPIO OE\n");
  7622. + gpio_unexport(DS_GPIO_AVR_RESET_DS2);
  7623. + gpio_free(DS_GPIO_AVR_RESET_DS2);
  7624. +
  7625. + // enable OE of level shifter
  7626. + if (gpio_request_one(DS_GPIO_OE,
  7627. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
  7628. + printk("Error setting GPIO OE\n");
  7629. +
  7630. + if (gpio_request_one(DS_GPIO_UART_ENA,
  7631. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "UART-ENA") != 0)
  7632. + printk("Error setting GPIO Uart Enable\n");
  7633. +
  7634. + // enable OE of level shifter
  7635. + if (gpio_request_one(DS_GPIO_OE2,
  7636. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-2") != 0)
  7637. + printk("Error setting GPIO OE2\n");
  7638. +}
  7639. +
  7640. +MIPS_MACHINE(ATH79_MACH_ARDUINO_YUN, "Yun", "Arduino Yun", ds_setup);
  7641. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-aw-nr580.c linux-4.1.13/arch/mips/ath79/mach-aw-nr580.c
  7642. --- linux-4.1.13.orig/arch/mips/ath79/mach-aw-nr580.c 1970-01-01 01:00:00.000000000 +0100
  7643. +++ linux-4.1.13/arch/mips/ath79/mach-aw-nr580.c 2015-09-13 20:04:35.068524086 +0200
  7644. @@ -0,0 +1,107 @@
  7645. +/*
  7646. + * AzureWave AW-NR580 board support
  7647. + *
  7648. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  7649. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7650. + *
  7651. + * This program is free software; you can redistribute it and/or modify it
  7652. + * under the terms of the GNU General Public License version 2 as published
  7653. + * by the Free Software Foundation.
  7654. + */
  7655. +
  7656. +#include <asm/mach-ath79/ath79.h>
  7657. +
  7658. +#include "dev-eth.h"
  7659. +#include "dev-m25p80.h"
  7660. +#include "dev-gpio-buttons.h"
  7661. +#include "dev-leds-gpio.h"
  7662. +#include "machtypes.h"
  7663. +#include "pci.h"
  7664. +
  7665. +#define AW_NR580_GPIO_LED_READY_RED 0
  7666. +#define AW_NR580_GPIO_LED_WLAN 1
  7667. +#define AW_NR580_GPIO_LED_READY_GREEN 2
  7668. +#define AW_NR580_GPIO_LED_WPS_GREEN 4
  7669. +#define AW_NR580_GPIO_LED_WPS_AMBER 5
  7670. +
  7671. +#define AW_NR580_GPIO_BTN_WPS 3
  7672. +#define AW_NR580_GPIO_BTN_RESET 11
  7673. +
  7674. +#define AW_NR580_KEYS_POLL_INTERVAL 20 /* msecs */
  7675. +#define AW_NR580_KEYS_DEBOUNCE_INTERVAL (3 * AW_NR580_KEYS_POLL_INTERVAL)
  7676. +
  7677. +static struct gpio_led aw_nr580_leds_gpio[] __initdata = {
  7678. + {
  7679. + .name = "aw-nr580:red:ready",
  7680. + .gpio = AW_NR580_GPIO_LED_READY_RED,
  7681. + .active_low = 0,
  7682. + }, {
  7683. + .name = "aw-nr580:green:ready",
  7684. + .gpio = AW_NR580_GPIO_LED_READY_GREEN,
  7685. + .active_low = 0,
  7686. + }, {
  7687. + .name = "aw-nr580:green:wps",
  7688. + .gpio = AW_NR580_GPIO_LED_WPS_GREEN,
  7689. + .active_low = 0,
  7690. + }, {
  7691. + .name = "aw-nr580:amber:wps",
  7692. + .gpio = AW_NR580_GPIO_LED_WPS_AMBER,
  7693. + .active_low = 0,
  7694. + }, {
  7695. + .name = "aw-nr580:green:wlan",
  7696. + .gpio = AW_NR580_GPIO_LED_WLAN,
  7697. + .active_low = 0,
  7698. + }
  7699. +};
  7700. +
  7701. +static struct gpio_keys_button aw_nr580_gpio_keys[] __initdata = {
  7702. + {
  7703. + .desc = "reset",
  7704. + .type = EV_KEY,
  7705. + .code = KEY_RESTART,
  7706. + .debounce_interval = AW_NR580_KEYS_DEBOUNCE_INTERVAL,
  7707. + .gpio = AW_NR580_GPIO_BTN_RESET,
  7708. + .active_low = 1,
  7709. + }, {
  7710. + .desc = "wps",
  7711. + .type = EV_KEY,
  7712. + .code = KEY_WPS_BUTTON,
  7713. + .debounce_interval = AW_NR580_KEYS_DEBOUNCE_INTERVAL,
  7714. + .gpio = AW_NR580_GPIO_BTN_WPS,
  7715. + .active_low = 1,
  7716. + }
  7717. +};
  7718. +
  7719. +static const char *aw_nr580_part_probes[] = {
  7720. + "RedBoot",
  7721. + NULL,
  7722. +};
  7723. +
  7724. +static struct flash_platform_data aw_nr580_flash_data = {
  7725. + .part_probes = aw_nr580_part_probes,
  7726. +};
  7727. +
  7728. +static void __init aw_nr580_setup(void)
  7729. +{
  7730. + ath79_register_mdio(0, 0x0);
  7731. +
  7732. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  7733. + ath79_eth0_data.speed = SPEED_100;
  7734. + ath79_eth0_data.duplex = DUPLEX_FULL;
  7735. +
  7736. + ath79_register_eth(0);
  7737. +
  7738. + ath79_register_pci();
  7739. +
  7740. + ath79_register_m25p80(&aw_nr580_flash_data);
  7741. +
  7742. + ath79_register_leds_gpio(-1, ARRAY_SIZE(aw_nr580_leds_gpio),
  7743. + aw_nr580_leds_gpio);
  7744. +
  7745. + ath79_register_gpio_keys_polled(-1, AW_NR580_KEYS_POLL_INTERVAL,
  7746. + ARRAY_SIZE(aw_nr580_gpio_keys),
  7747. + aw_nr580_gpio_keys);
  7748. +}
  7749. +
  7750. +MIPS_MACHINE(ATH79_MACH_AW_NR580, "AW-NR580", "AzureWave AW-NR580",
  7751. + aw_nr580_setup);
  7752. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-bhu-bxu2000n2-a.c linux-4.1.13/arch/mips/ath79/mach-bhu-bxu2000n2-a.c
  7753. --- linux-4.1.13.orig/arch/mips/ath79/mach-bhu-bxu2000n2-a.c 1970-01-01 01:00:00.000000000 +0100
  7754. +++ linux-4.1.13/arch/mips/ath79/mach-bhu-bxu2000n2-a.c 2015-09-13 20:04:35.068524086 +0200
  7755. @@ -0,0 +1,120 @@
  7756. +/*
  7757. + * BHU BXU2000n-2 A1 board support
  7758. + *
  7759. + * Copyright (C) 2013 Terry Yang <yangbo@bhunetworks.com>
  7760. + *
  7761. + * This program is free software; you can redistribute it and/or modify it
  7762. + * under the terms of the GNU General Public License version 2 as published
  7763. + * by the Free Software Foundation.
  7764. + */
  7765. +
  7766. +#include <linux/gpio.h>
  7767. +#include <linux/platform_device.h>
  7768. +
  7769. +#include <asm/mach-ath79/ath79.h>
  7770. +#include <asm/mach-ath79/ar71xx_regs.h>
  7771. +
  7772. +#include "common.h"
  7773. +#include "dev-eth.h"
  7774. +#include "dev-gpio-buttons.h"
  7775. +#include "dev-leds-gpio.h"
  7776. +#include "dev-m25p80.h"
  7777. +#include "dev-usb.h"
  7778. +#include "dev-wmac.h"
  7779. +#include "machtypes.h"
  7780. +
  7781. +#define BHU_BXU2000N2_A1_GPIO_LED_WLAN 13
  7782. +#define BHU_BXU2000N2_A1_GPIO_LED_WAN 19
  7783. +#define BHU_BXU2000N2_A1_GPIO_LED_LAN 21
  7784. +#define BHU_BXU2000N2_A1_GPIO_LED_SYSTEM 14
  7785. +
  7786. +#define BHU_BXU2000N2_A1_GPIO_BTN_RESET 17
  7787. +
  7788. +#define BHU_BXU2000N2_KEYS_POLL_INTERVAL 20 /* msecs */
  7789. +#define BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL \
  7790. + (3 * BHU_BXU2000N2_KEYS_POLL_INTERVAL)
  7791. +
  7792. +static const char *bhu_bxu2000n2_part_probes[] = {
  7793. + "cmdlinepart",
  7794. + NULL,
  7795. +};
  7796. +
  7797. +static struct flash_platform_data bhu_bxu2000n2_flash_data = {
  7798. + .part_probes = bhu_bxu2000n2_part_probes,
  7799. +};
  7800. +
  7801. +static struct gpio_led bhu_bxu2000n2_a1_leds_gpio[] __initdata = {
  7802. + {
  7803. + .name = "bhu:green:status",
  7804. + .gpio = BHU_BXU2000N2_A1_GPIO_LED_SYSTEM,
  7805. + .active_low = 1,
  7806. + }, {
  7807. + .name = "bhu:green:lan",
  7808. + .gpio = BHU_BXU2000N2_A1_GPIO_LED_LAN,
  7809. + .active_low = 1,
  7810. + }, {
  7811. + .name = "bhu:green:wan",
  7812. + .gpio = BHU_BXU2000N2_A1_GPIO_LED_WAN,
  7813. + .active_low = 1,
  7814. + }, {
  7815. + .name = "bhu:green:wlan",
  7816. + .gpio = BHU_BXU2000N2_A1_GPIO_LED_WLAN,
  7817. + .active_low = 1,
  7818. + },
  7819. +};
  7820. +
  7821. +static struct gpio_keys_button bhu_bxu2000n2_a1_gpio_keys[] __initdata = {
  7822. + {
  7823. + .desc = "Reset button",
  7824. + .type = EV_KEY,
  7825. + .code = KEY_RESTART,
  7826. + .debounce_interval = BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL,
  7827. + .gpio = BHU_BXU2000N2_A1_GPIO_BTN_RESET,
  7828. + .active_low = 1,
  7829. + }
  7830. +};
  7831. +
  7832. +static void __init bhu_ap123_setup(void)
  7833. +{
  7834. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  7835. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  7836. +
  7837. + ath79_register_m25p80(&bhu_bxu2000n2_flash_data);
  7838. +
  7839. + ath79_register_mdio(1, 0x0);
  7840. +
  7841. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  7842. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  7843. +
  7844. + /* GMAC0 is connected to the PHY4 of the internal switch */
  7845. + ath79_switch_data.phy4_mii_en = 1;
  7846. + ath79_switch_data.phy_poll_mask = BIT(4);
  7847. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  7848. + ath79_eth0_data.phy_mask = BIT(4);
  7849. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  7850. + ath79_register_eth(0);
  7851. +
  7852. + /* GMAC1 is connected to the internal switch. Only use PHY3 */
  7853. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  7854. + ath79_eth1_data.phy_mask = BIT(3);
  7855. + ath79_register_eth(1);
  7856. +
  7857. + ath79_register_wmac(ee, ee+2);
  7858. +}
  7859. +
  7860. +static void __init bhu_bxu2000n2_a1_setup(void)
  7861. +{
  7862. + bhu_ap123_setup();
  7863. +
  7864. + ath79_register_leds_gpio(-1, ARRAY_SIZE(bhu_bxu2000n2_a1_leds_gpio),
  7865. + bhu_bxu2000n2_a1_leds_gpio);
  7866. +
  7867. + ath79_register_gpio_keys_polled(1, BHU_BXU2000N2_KEYS_POLL_INTERVAL,
  7868. + ARRAY_SIZE(bhu_bxu2000n2_a1_gpio_keys),
  7869. + bhu_bxu2000n2_a1_gpio_keys);
  7870. +}
  7871. +
  7872. +MIPS_MACHINE(ATH79_MACH_BHU_BXU2000N2_A1, "BXU2000n-2-A1",
  7873. + "BHU BXU2000n-2 rev. A1",
  7874. + bhu_bxu2000n2_a1_setup);
  7875. +
  7876. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-bsb.c linux-4.1.13/arch/mips/ath79/mach-bsb.c
  7877. --- linux-4.1.13.orig/arch/mips/ath79/mach-bsb.c 1970-01-01 01:00:00.000000000 +0100
  7878. +++ linux-4.1.13/arch/mips/ath79/mach-bsb.c 2015-09-13 20:04:35.068524086 +0200
  7879. @@ -0,0 +1,83 @@
  7880. +/*
  7881. + * Smart Electronics Black Swift board support
  7882. + *
  7883. + * Copyright (C) 2014 Dmitriy Zherebkov dzh@black-swift.com
  7884. + *
  7885. + * This program is free software; you can redistribute it and/or modify it
  7886. + * under the terms of the GNU General Public License version 2 as published
  7887. + * by the Free Software Foundation.
  7888. + */
  7889. +
  7890. +#include <asm/mach-ath79/ath79.h>
  7891. +#include <asm/mach-ath79/ar71xx_regs.h>
  7892. +#include "common.h"
  7893. +#include "dev-eth.h"
  7894. +#include "dev-gpio-buttons.h"
  7895. +#include "dev-leds-gpio.h"
  7896. +#include "dev-m25p80.h"
  7897. +#include "dev-spi.h"
  7898. +#include "dev-usb.h"
  7899. +#include "dev-wmac.h"
  7900. +#include "machtypes.h"
  7901. +
  7902. +#define BSB_GPIO_LED_SYS 27
  7903. +
  7904. +#define BSB_GPIO_BTN_RESET 11
  7905. +
  7906. +#define BSB_KEYS_POLL_INTERVAL 20 /* msecs */
  7907. +#define BSB_KEYS_DEBOUNCE_INTERVAL (3 * BSB_KEYS_POLL_INTERVAL)
  7908. +
  7909. +#define BSB_MAC_OFFSET 0x0000
  7910. +#define BSB_CALDATA_OFFSET 0x1000
  7911. +
  7912. +static struct gpio_led bsb_leds_gpio[] __initdata = {
  7913. + {
  7914. + .name = "bsb:red:sys",
  7915. + .gpio = BSB_GPIO_LED_SYS,
  7916. + .active_low = 1,
  7917. + }
  7918. +};
  7919. +
  7920. +static struct gpio_keys_button bsb_gpio_keys[] __initdata = {
  7921. + {
  7922. + .desc = "reset button",
  7923. + .type = EV_KEY,
  7924. + .code = KEY_RESTART,
  7925. + .debounce_interval = BSB_KEYS_DEBOUNCE_INTERVAL,
  7926. + .gpio = BSB_GPIO_BTN_RESET,
  7927. + .active_low = 1,
  7928. + },
  7929. +};
  7930. +
  7931. +static void __init bsb_setup(void)
  7932. +{
  7933. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  7934. +
  7935. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  7936. + ath79_setup_ar933x_phy4_switch(false,false);
  7937. +
  7938. + ath79_register_leds_gpio(-1, ARRAY_SIZE(bsb_leds_gpio),
  7939. + bsb_leds_gpio);
  7940. + ath79_register_gpio_keys_polled(-1, BSB_KEYS_POLL_INTERVAL,
  7941. + ARRAY_SIZE(bsb_gpio_keys),
  7942. + bsb_gpio_keys);
  7943. +
  7944. + ath79_register_usb();
  7945. +
  7946. + ath79_register_m25p80(NULL);
  7947. +
  7948. + ath79_init_mac(ath79_eth0_data.mac_addr, art + BSB_MAC_OFFSET, 1);
  7949. + ath79_init_mac(ath79_eth1_data.mac_addr, art + BSB_MAC_OFFSET, 2);
  7950. +
  7951. + ath79_register_mdio(0, 0x0);
  7952. +
  7953. + ath79_register_eth(0);
  7954. + ath79_register_eth(1);
  7955. +
  7956. + ath79_register_wmac(art + BSB_CALDATA_OFFSET,
  7957. + art + BSB_MAC_OFFSET);
  7958. +}
  7959. +
  7960. +MIPS_MACHINE(ATH79_MACH_BSB, "BSB", "Smart Electronics Black Swift board",
  7961. + bsb_setup);
  7962. +
  7963. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-cap4200ag.c linux-4.1.13/arch/mips/ath79/mach-cap4200ag.c
  7964. --- linux-4.1.13.orig/arch/mips/ath79/mach-cap4200ag.c 1970-01-01 01:00:00.000000000 +0100
  7965. +++ linux-4.1.13/arch/mips/ath79/mach-cap4200ag.c 2015-09-13 20:04:35.068524086 +0200
  7966. @@ -0,0 +1,131 @@
  7967. +/*
  7968. + * Senao CAP4200AG board support
  7969. + *
  7970. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  7971. + *
  7972. + * This program is free software; you can redistribute it and/or modify it
  7973. + * under the terms of the GNU General Public License version 2 as published
  7974. + * by the Free Software Foundation.
  7975. + */
  7976. +
  7977. +#include <linux/pci.h>
  7978. +#include <linux/phy.h>
  7979. +#include <linux/platform_device.h>
  7980. +#include <linux/ath9k_platform.h>
  7981. +
  7982. +#include <asm/mach-ath79/ar71xx_regs.h>
  7983. +
  7984. +#include "common.h"
  7985. +#include "dev-ap9x-pci.h"
  7986. +#include "dev-eth.h"
  7987. +#include "dev-gpio-buttons.h"
  7988. +#include "dev-leds-gpio.h"
  7989. +#include "dev-m25p80.h"
  7990. +#include "dev-spi.h"
  7991. +#include "dev-usb.h"
  7992. +#include "dev-wmac.h"
  7993. +#include "machtypes.h"
  7994. +
  7995. +#define CAP4200AG_GPIO_LED_PWR_GREEN 12
  7996. +#define CAP4200AG_GPIO_LED_PWR_AMBER 13
  7997. +#define CAP4200AG_GPIO_LED_LAN_GREEN 14
  7998. +#define CAP4200AG_GPIO_LED_LAN_AMBER 15
  7999. +#define CAP4200AG_GPIO_LED_WLAN_GREEN 18
  8000. +#define CAP4200AG_GPIO_LED_WLAN_AMBER 19
  8001. +
  8002. +#define CAP4200AG_GPIO_BTN_RESET 17
  8003. +
  8004. +#define CAP4200AG_KEYS_POLL_INTERVAL 20 /* msecs */
  8005. +#define CAP4200AG_KEYS_DEBOUNCE_INTERVAL (3 * CAP4200AG_KEYS_POLL_INTERVAL)
  8006. +
  8007. +#define CAP4200AG_MAC_OFFSET 0
  8008. +#define CAP4200AG_WMAC_CALDATA_OFFSET 0x1000
  8009. +#define CAP4200AG_PCIE_CALDATA_OFFSET 0x5000
  8010. +
  8011. +static struct gpio_led cap4200ag_leds_gpio[] __initdata = {
  8012. + {
  8013. + .name = "senao:green:pwr",
  8014. + .gpio = CAP4200AG_GPIO_LED_PWR_GREEN,
  8015. + .active_low = 1,
  8016. + },
  8017. + {
  8018. + .name = "senao:amber:pwr",
  8019. + .gpio = CAP4200AG_GPIO_LED_PWR_AMBER,
  8020. + .active_low = 1,
  8021. + },
  8022. + {
  8023. + .name = "senao:green:lan",
  8024. + .gpio = CAP4200AG_GPIO_LED_LAN_GREEN,
  8025. + .active_low = 1,
  8026. + },
  8027. + {
  8028. + .name = "senao:amber:lan",
  8029. + .gpio = CAP4200AG_GPIO_LED_LAN_AMBER,
  8030. + .active_low = 1,
  8031. + },
  8032. + {
  8033. + .name = "senao:green:wlan",
  8034. + .gpio = CAP4200AG_GPIO_LED_WLAN_GREEN,
  8035. + .active_low = 1,
  8036. + },
  8037. + {
  8038. + .name = "senao:amber:wlan",
  8039. + .gpio = CAP4200AG_GPIO_LED_WLAN_AMBER,
  8040. + .active_low = 1,
  8041. + },
  8042. +};
  8043. +
  8044. +static struct gpio_keys_button cap4200ag_gpio_keys[] __initdata = {
  8045. + {
  8046. + .desc = "Reset button",
  8047. + .type = EV_KEY,
  8048. + .code = KEY_RESTART,
  8049. + .debounce_interval = CAP4200AG_KEYS_DEBOUNCE_INTERVAL,
  8050. + .gpio = CAP4200AG_GPIO_BTN_RESET,
  8051. + .active_low = 1,
  8052. + },
  8053. +};
  8054. +
  8055. +static void __init cap4200ag_setup(void)
  8056. +{
  8057. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  8058. + u8 mac[6];
  8059. +
  8060. + ath79_gpio_output_select(CAP4200AG_GPIO_LED_LAN_GREEN,
  8061. + AR934X_GPIO_OUT_GPIO);
  8062. + ath79_gpio_output_select(CAP4200AG_GPIO_LED_LAN_AMBER,
  8063. + AR934X_GPIO_OUT_GPIO);
  8064. +
  8065. + ath79_register_m25p80(NULL);
  8066. +
  8067. + ath79_register_leds_gpio(-1, ARRAY_SIZE(cap4200ag_leds_gpio),
  8068. + cap4200ag_leds_gpio);
  8069. + ath79_register_gpio_keys_polled(-1, CAP4200AG_KEYS_POLL_INTERVAL,
  8070. + ARRAY_SIZE(cap4200ag_gpio_keys),
  8071. + cap4200ag_gpio_keys);
  8072. +
  8073. + ath79_init_mac(mac, art + CAP4200AG_MAC_OFFSET, -1);
  8074. + ath79_wmac_disable_2ghz();
  8075. + ath79_register_wmac(art + CAP4200AG_WMAC_CALDATA_OFFSET, mac);
  8076. +
  8077. + ath79_init_mac(mac, art + CAP4200AG_MAC_OFFSET, -2);
  8078. + ap91_pci_init(art + CAP4200AG_PCIE_CALDATA_OFFSET, mac);
  8079. +
  8080. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  8081. + AR934X_ETH_CFG_SW_ONLY_MODE);
  8082. +
  8083. + ath79_register_mdio(0, 0x0);
  8084. +
  8085. + ath79_init_mac(ath79_eth0_data.mac_addr,
  8086. + art + CAP4200AG_MAC_OFFSET, -2);
  8087. +
  8088. + /* GMAC0 is connected to an external PHY */
  8089. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  8090. + ath79_eth0_data.phy_mask = BIT(0);
  8091. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  8092. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  8093. + ath79_register_eth(0);
  8094. +}
  8095. +
  8096. +MIPS_MACHINE(ATH79_MACH_CAP4200AG, "CAP4200AG", "Senao CAP4200AG",
  8097. + cap4200ag_setup);
  8098. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-carambola2.c linux-4.1.13/arch/mips/ath79/mach-carambola2.c
  8099. --- linux-4.1.13.orig/arch/mips/ath79/mach-carambola2.c 1970-01-01 01:00:00.000000000 +0100
  8100. +++ linux-4.1.13/arch/mips/ath79/mach-carambola2.c 2015-09-13 20:04:35.068524086 +0200
  8101. @@ -0,0 +1,105 @@
  8102. +/*
  8103. + * 8devices Carambola2 board support
  8104. + *
  8105. + * Copyright (C) 2013 Darius Augulis <darius@8devices.com>
  8106. + *
  8107. + * This program is free software; you can redistribute it and/or modify it
  8108. + * under the terms of the GNU General Public License version 2 as published
  8109. + * by the Free Software Foundation.
  8110. + */
  8111. +
  8112. +#include <asm/mach-ath79/ath79.h>
  8113. +#include <asm/mach-ath79/ar71xx_regs.h>
  8114. +#include "common.h"
  8115. +#include "dev-eth.h"
  8116. +#include "dev-gpio-buttons.h"
  8117. +#include "dev-leds-gpio.h"
  8118. +#include "dev-m25p80.h"
  8119. +#include "dev-spi.h"
  8120. +#include "dev-usb.h"
  8121. +#include "dev-wmac.h"
  8122. +#include "machtypes.h"
  8123. +
  8124. +#define CARAMBOLA2_GPIO_LED_WLAN 0
  8125. +#define CARAMBOLA2_GPIO_LED_ETH0 14
  8126. +#define CARAMBOLA2_GPIO_LED_ETH1 13
  8127. +
  8128. +#define CARAMBOLA2_GPIO_BTN_JUMPSTART 11
  8129. +
  8130. +#define CARAMBOLA2_KEYS_POLL_INTERVAL 20 /* msecs */
  8131. +#define CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL (3 * CARAMBOLA2_KEYS_POLL_INTERVAL)
  8132. +
  8133. +#define CARAMBOLA2_MAC0_OFFSET 0x0000
  8134. +#define CARAMBOLA2_MAC1_OFFSET 0x0006
  8135. +#define CARAMBOLA2_CALDATA_OFFSET 0x1000
  8136. +#define CARAMBOLA2_WMAC_MAC_OFFSET 0x1002
  8137. +
  8138. +static struct gpio_led carambola2_leds_gpio[] __initdata = {
  8139. + {
  8140. + .name = "carambola2:green:wlan",
  8141. + .gpio = CARAMBOLA2_GPIO_LED_WLAN,
  8142. + .active_low = 1,
  8143. + }, {
  8144. + .name = "carambola2:orange:eth0",
  8145. + .gpio = CARAMBOLA2_GPIO_LED_ETH0,
  8146. + .active_low = 0,
  8147. + }, {
  8148. + .name = "carambola2:orange:eth1",
  8149. + .gpio = CARAMBOLA2_GPIO_LED_ETH1,
  8150. + .active_low = 0,
  8151. + }
  8152. +};
  8153. +
  8154. +static struct gpio_keys_button carambola2_gpio_keys[] __initdata = {
  8155. + {
  8156. + .desc = "jumpstart button",
  8157. + .type = EV_KEY,
  8158. + .code = KEY_WPS_BUTTON,
  8159. + .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
  8160. + .gpio = CARAMBOLA2_GPIO_BTN_JUMPSTART,
  8161. + .active_low = 1,
  8162. + },
  8163. +};
  8164. +
  8165. +static void __init carambola2_common_setup(void)
  8166. +{
  8167. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  8168. +
  8169. + ath79_register_m25p80(NULL);
  8170. + ath79_register_wmac(art + CARAMBOLA2_CALDATA_OFFSET,
  8171. + art + CARAMBOLA2_WMAC_MAC_OFFSET);
  8172. +
  8173. + ath79_setup_ar933x_phy4_switch(true, true);
  8174. +
  8175. + ath79_init_mac(ath79_eth0_data.mac_addr, art + CARAMBOLA2_MAC0_OFFSET, 0);
  8176. + ath79_init_mac(ath79_eth1_data.mac_addr, art + CARAMBOLA2_MAC1_OFFSET, 0);
  8177. +
  8178. + ath79_register_mdio(0, 0x0);
  8179. +
  8180. + /* LAN ports */
  8181. + ath79_register_eth(1);
  8182. +
  8183. + /* WAN port */
  8184. + ath79_register_eth(0);
  8185. +}
  8186. +
  8187. +static void __init carambola2_setup(void)
  8188. +{
  8189. + carambola2_common_setup();
  8190. +
  8191. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  8192. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  8193. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  8194. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  8195. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  8196. +
  8197. + ath79_register_leds_gpio(-1, ARRAY_SIZE(carambola2_leds_gpio),
  8198. + carambola2_leds_gpio);
  8199. + ath79_register_gpio_keys_polled(-1, CARAMBOLA2_KEYS_POLL_INTERVAL,
  8200. + ARRAY_SIZE(carambola2_gpio_keys),
  8201. + carambola2_gpio_keys);
  8202. + ath79_register_usb();
  8203. +}
  8204. +
  8205. +MIPS_MACHINE(ATH79_MACH_CARAMBOLA2, "CARAMBOLA2", "8devices Carambola2 board",
  8206. + carambola2_setup);
  8207. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-cf-e316n-v2.c linux-4.1.13/arch/mips/ath79/mach-cf-e316n-v2.c
  8208. --- linux-4.1.13.orig/arch/mips/ath79/mach-cf-e316n-v2.c 1970-01-01 01:00:00.000000000 +0100
  8209. +++ linux-4.1.13/arch/mips/ath79/mach-cf-e316n-v2.c 2015-09-13 20:04:35.068524086 +0200
  8210. @@ -0,0 +1,132 @@
  8211. +/*
  8212. + * COMFAST CF-E316N v2
  8213. + * by Shenzhen Four Seas Global Link Network Technology Co., Ltd
  8214. + *
  8215. + * aka CF-E316V2, CF-E316N-V2 and CF-E316Nv2.0 (no FCC ID)
  8216. + *
  8217. + * Copyright (C) 2015 Paul Fertser <fercerpav@gmail.com>
  8218. + *
  8219. + * This program is free software; you can redistribute it and/or modify it
  8220. + * under the terms of the GNU General Public License version 2 as published
  8221. + * by the Free Software Foundation.
  8222. + */
  8223. +
  8224. +#include <linux/gpio.h>
  8225. +#include <linux/platform_device.h>
  8226. +#include <linux/timer.h>
  8227. +
  8228. +#include <asm/mach-ath79/ath79.h>
  8229. +#include <asm/mach-ath79/ar71xx_regs.h>
  8230. +
  8231. +#include "common.h"
  8232. +#include "dev-eth.h"
  8233. +#include "dev-gpio-buttons.h"
  8234. +#include "dev-leds-gpio.h"
  8235. +#include "dev-m25p80.h"
  8236. +#include "dev-wmac.h"
  8237. +#include "dev-usb.h"
  8238. +#include "machtypes.h"
  8239. +
  8240. +static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = {
  8241. + {
  8242. + .name = "cf-e316n-v2:blue:diag",
  8243. + .gpio = 0,
  8244. + .active_low = 0,
  8245. + }, {
  8246. + .name = "cf-e316n-v2:red:diag",
  8247. + .gpio = 2,
  8248. + .active_low = 0,
  8249. + }, {
  8250. + .name = "cf-e316n-v2:green:diag",
  8251. + .gpio = 3,
  8252. + .active_low = 0,
  8253. + }, {
  8254. + .name = "cf-e316n-v2:blue:wlan",
  8255. + .gpio = 12,
  8256. + .active_low = 1,
  8257. + }, {
  8258. + .name = "cf-e316n-v2:blue:wan",
  8259. + .gpio = 17,
  8260. + .active_low = 1,
  8261. + }, {
  8262. + .name = "cf-e316n-v2:blue:lan",
  8263. + .gpio = 19,
  8264. + .active_low = 1,
  8265. + },
  8266. +};
  8267. +
  8268. +static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = {
  8269. + {
  8270. + .desc = "Reset button",
  8271. + .type = EV_KEY,
  8272. + .code = KEY_RESTART,
  8273. + .debounce_interval = 60,
  8274. + .gpio = 20,
  8275. + .active_low = 1,
  8276. + },
  8277. +};
  8278. +
  8279. +/* There's a Pericon Technology PT7A7514 connected to GPIO 16 */
  8280. +#define EXT_WATCHDOG_GPIO 16
  8281. +static struct timer_list gpio_wdt_timer;
  8282. +
  8283. +static void gpio_wdt_toggle(unsigned long period)
  8284. +{
  8285. + static int state;
  8286. + state = !state;
  8287. + gpio_set_value(EXT_WATCHDOG_GPIO, state);
  8288. + mod_timer(&gpio_wdt_timer, jiffies + period);
  8289. +}
  8290. +
  8291. +static void __init cf_e316n_v2_setup(void)
  8292. +{
  8293. + u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000);
  8294. + u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002);
  8295. + u8 *ee = (u8 *) KSEG1ADDR(0x1f011000);
  8296. + u8 tmpmac[ETH_ALEN];
  8297. +
  8298. + gpio_request(EXT_WATCHDOG_GPIO, "PT7A7514 watchdog");
  8299. + gpio_direction_output(EXT_WATCHDOG_GPIO, 0);
  8300. + setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, msecs_to_jiffies(500));
  8301. + gpio_wdt_toggle(msecs_to_jiffies(1));
  8302. +
  8303. + ath79_register_m25p80(NULL);
  8304. +
  8305. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  8306. + ath79_register_mdio(1, 0x0);
  8307. +
  8308. + /* GMAC0 is connected to the PHY0 of the internal switch */
  8309. + ath79_switch_data.phy4_mii_en = 1;
  8310. + ath79_switch_data.phy_poll_mask = BIT(0);
  8311. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  8312. + ath79_eth0_data.phy_mask = BIT(0);
  8313. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  8314. + ath79_init_mac(ath79_eth0_data.mac_addr, maclan, 0);
  8315. + ath79_register_eth(0);
  8316. +
  8317. + /* GMAC1 is connected to the internal switch */
  8318. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  8319. + ath79_init_mac(ath79_eth1_data.mac_addr, maclan, 2);
  8320. + ath79_register_eth(1);
  8321. +
  8322. + /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
  8323. + gpio_request(13, "RF Amp 1");
  8324. + gpio_direction_output(13, 1);
  8325. + gpio_request(14, "RF Amp 2");
  8326. + gpio_direction_output(14, 1);
  8327. + ath79_init_mac(tmpmac, macwlan, 0);
  8328. + ath79_register_wmac(ee, tmpmac);
  8329. +
  8330. + ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
  8331. + cf_e316n_v2_leds_gpio);
  8332. +
  8333. + ath79_register_gpio_keys_polled(1, 20,
  8334. + ARRAY_SIZE(cf_e316n_v2_gpio_keys),
  8335. + cf_e316n_v2_gpio_keys);
  8336. +
  8337. + /* J1 is a High-Speed USB port, pin 1 is Vcc */
  8338. + ath79_register_usb();
  8339. +}
  8340. +
  8341. +MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
  8342. + cf_e316n_v2_setup);
  8343. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-cpe510.c linux-4.1.13/arch/mips/ath79/mach-cpe510.c
  8344. --- linux-4.1.13.orig/arch/mips/ath79/mach-cpe510.c 1970-01-01 01:00:00.000000000 +0100
  8345. +++ linux-4.1.13/arch/mips/ath79/mach-cpe510.c 2015-09-13 20:04:35.068524086 +0200
  8346. @@ -0,0 +1,107 @@
  8347. +/*
  8348. + * TP-LINK CPE210/220/510/520 board support
  8349. + *
  8350. + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
  8351. + *
  8352. + * This program is free software; you can redistribute it and/or modify it
  8353. + * under the terms of the GNU General Public License version 2 as published
  8354. + * by the Free Software Foundation.
  8355. + */
  8356. +
  8357. +#include <linux/gpio.h>
  8358. +#include <linux/platform_device.h>
  8359. +
  8360. +#include <asm/mach-ath79/ath79.h>
  8361. +#include <asm/mach-ath79/ar71xx_regs.h>
  8362. +
  8363. +#include "common.h"
  8364. +#include "dev-eth.h"
  8365. +#include "dev-gpio-buttons.h"
  8366. +#include "dev-leds-gpio.h"
  8367. +#include "dev-m25p80.h"
  8368. +#include "dev-wmac.h"
  8369. +#include "machtypes.h"
  8370. +
  8371. +
  8372. +#define CPE510_GPIO_LED_LAN0 11
  8373. +#define CPE510_GPIO_LED_LAN1 12
  8374. +#define CPE510_GPIO_LED_L1 13
  8375. +#define CPE510_GPIO_LED_L2 14
  8376. +#define CPE510_GPIO_LED_L3 15
  8377. +#define CPE510_GPIO_LED_L4 16
  8378. +
  8379. +#define CPE510_GPIO_BTN_RESET 4
  8380. +
  8381. +#define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
  8382. +#define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
  8383. +
  8384. +
  8385. +static struct gpio_led cpe510_leds_gpio[] __initdata = {
  8386. + {
  8387. + .name = "tp-link:green:lan0",
  8388. + .gpio = CPE510_GPIO_LED_LAN0,
  8389. + .active_low = 1,
  8390. + }, {
  8391. + .name = "tp-link:green:lan1",
  8392. + .gpio = CPE510_GPIO_LED_LAN1,
  8393. + .active_low = 1,
  8394. + }, {
  8395. + .name = "tp-link:green:link1",
  8396. + .gpio = CPE510_GPIO_LED_L1,
  8397. + .active_low = 1,
  8398. + }, {
  8399. + .name = "tp-link:green:link2",
  8400. + .gpio = CPE510_GPIO_LED_L2,
  8401. + .active_low = 1,
  8402. + }, {
  8403. + .name = "tp-link:green:link3",
  8404. + .gpio = CPE510_GPIO_LED_L3,
  8405. + .active_low = 1,
  8406. + }, {
  8407. + .name = "tp-link:green:link4",
  8408. + .gpio = CPE510_GPIO_LED_L4,
  8409. + .active_low = 1,
  8410. + },
  8411. +};
  8412. +
  8413. +static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
  8414. + {
  8415. + .desc = "Reset button",
  8416. + .type = EV_KEY,
  8417. + .code = KEY_RESTART,
  8418. + .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
  8419. + .gpio = CPE510_GPIO_BTN_RESET,
  8420. + .active_low = 1,
  8421. + }
  8422. +};
  8423. +
  8424. +
  8425. +static void __init cpe510_setup(void)
  8426. +{
  8427. + u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
  8428. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  8429. +
  8430. + /* Disable JTAG, enabling GPIOs 0-3 */
  8431. + /* Configure OBS4 line, for GPIO 4*/
  8432. + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  8433. + AR934X_GPIO_FUNC_CLK_OBS4_EN);
  8434. +
  8435. + ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio),
  8436. + cpe510_leds_gpio);
  8437. +
  8438. + ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL,
  8439. + ARRAY_SIZE(cpe510_gpio_keys),
  8440. + cpe510_gpio_keys);
  8441. +
  8442. + ath79_register_m25p80(NULL);
  8443. +
  8444. + ath79_register_mdio(1, 0);
  8445. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  8446. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  8447. + ath79_register_eth(1);
  8448. +
  8449. + ath79_register_wmac(ee, mac);
  8450. +}
  8451. +
  8452. +MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",
  8453. + cpe510_setup);
  8454. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-db120.c linux-4.1.13/arch/mips/ath79/mach-db120.c
  8455. --- linux-4.1.13.orig/arch/mips/ath79/mach-db120.c 2015-11-09 23:34:10.000000000 +0100
  8456. +++ linux-4.1.13/arch/mips/ath79/mach-db120.c 2015-12-04 19:57:04.322082119 +0100
  8457. @@ -2,7 +2,7 @@
  8458. * Atheros DB120 reference board support
  8459. *
  8460. * Copyright (c) 2011 Qualcomm Atheros
  8461. - * Copyright (c) 2011 Gabor Juhos <juhosg@openwrt.org>
  8462. + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  8463. *
  8464. * Permission to use, copy, modify, and/or distribute this software for any
  8465. * purpose with or without fee is hereby granted, provided that the above
  8466. @@ -19,16 +19,26 @@
  8467. */
  8468. #include <linux/pci.h>
  8469. +#include <linux/phy.h>
  8470. +#include <linux/platform_device.h>
  8471. #include <linux/ath9k_platform.h>
  8472. +#include <linux/ar8216_platform.h>
  8473. -#include "machtypes.h"
  8474. +#include <asm/mach-ath79/ar71xx_regs.h>
  8475. +
  8476. +#include "common.h"
  8477. +#include "dev-ap9x-pci.h"
  8478. +#include "dev-eth.h"
  8479. #include "dev-gpio-buttons.h"
  8480. #include "dev-leds-gpio.h"
  8481. +#include "dev-m25p80.h"
  8482. +#include "dev-nfc.h"
  8483. #include "dev-spi.h"
  8484. #include "dev-usb.h"
  8485. #include "dev-wmac.h"
  8486. -#include "pci.h"
  8487. +#include "machtypes.h"
  8488. +#define DB120_GPIO_LED_USB 11
  8489. #define DB120_GPIO_LED_WLAN_5G 12
  8490. #define DB120_GPIO_LED_WLAN_2G 13
  8491. #define DB120_GPIO_LED_STATUS 14
  8492. @@ -39,8 +49,10 @@
  8493. #define DB120_KEYS_POLL_INTERVAL 20 /* msecs */
  8494. #define DB120_KEYS_DEBOUNCE_INTERVAL (3 * DB120_KEYS_POLL_INTERVAL)
  8495. -#define DB120_WMAC_CALDATA_OFFSET 0x1000
  8496. -#define DB120_PCIE_CALDATA_OFFSET 0x5000
  8497. +#define DB120_MAC0_OFFSET 0
  8498. +#define DB120_MAC1_OFFSET 6
  8499. +#define DB120_WMAC_CALDATA_OFFSET 0x1000
  8500. +#define DB120_PCIE_CALDATA_OFFSET 0x5000
  8501. static struct gpio_led db120_leds_gpio[] __initdata = {
  8502. {
  8503. @@ -63,6 +75,11 @@
  8504. .gpio = DB120_GPIO_LED_WLAN_2G,
  8505. .active_low = 1,
  8506. },
  8507. + {
  8508. + .name = "db120:green:usb",
  8509. + .gpio = DB120_GPIO_LED_USB,
  8510. + .active_low = 1,
  8511. + }
  8512. };
  8513. static struct gpio_keys_button db120_gpio_keys[] __initdata = {
  8514. @@ -76,60 +93,85 @@
  8515. },
  8516. };
  8517. -static struct spi_board_info db120_spi_info[] = {
  8518. - {
  8519. - .bus_num = 0,
  8520. - .chip_select = 0,
  8521. - .max_speed_hz = 25000000,
  8522. - .modalias = "s25sl064a",
  8523. - }
  8524. +static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = {
  8525. + .mode = AR8327_PAD_MAC_RGMII,
  8526. + .txclk_delay_en = true,
  8527. + .rxclk_delay_en = true,
  8528. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  8529. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  8530. };
  8531. -static struct ath79_spi_platform_data db120_spi_data = {
  8532. - .bus_num = 0,
  8533. - .num_chipselect = 1,
  8534. +static struct ar8327_led_cfg db120_ar8327_led_cfg = {
  8535. + .led_ctrl0 = 0x00000000,
  8536. + .led_ctrl1 = 0xc737c737,
  8537. + .led_ctrl2 = 0x00000000,
  8538. + .led_ctrl3 = 0x00c30c00,
  8539. + .open_drain = true,
  8540. };
  8541. -#ifdef CONFIG_PCI
  8542. -static struct ath9k_platform_data db120_ath9k_data;
  8543. -
  8544. -static int db120_pci_plat_dev_init(struct pci_dev *dev)
  8545. -{
  8546. - switch (PCI_SLOT(dev->devfn)) {
  8547. - case 0:
  8548. - dev->dev.platform_data = &db120_ath9k_data;
  8549. - break;
  8550. - }
  8551. -
  8552. - return 0;
  8553. -}
  8554. -
  8555. -static void __init db120_pci_init(u8 *eeprom)
  8556. -{
  8557. - memcpy(db120_ath9k_data.eeprom_data, eeprom,
  8558. - sizeof(db120_ath9k_data.eeprom_data));
  8559. +static struct ar8327_platform_data db120_ar8327_data = {
  8560. + .pad0_cfg = &db120_ar8327_pad0_cfg,
  8561. + .port0_cfg = {
  8562. + .force_link = 1,
  8563. + .speed = AR8327_PORT_SPEED_1000,
  8564. + .duplex = 1,
  8565. + .txpause = 1,
  8566. + .rxpause = 1,
  8567. + },
  8568. + .led_cfg = &db120_ar8327_led_cfg,
  8569. +};
  8570. - ath79_pci_set_plat_dev_init(db120_pci_plat_dev_init);
  8571. - ath79_register_pci();
  8572. -}
  8573. -#else
  8574. -static inline void db120_pci_init(u8 *eeprom) {}
  8575. -#endif /* CONFIG_PCI */
  8576. +static struct mdio_board_info db120_mdio0_info[] = {
  8577. + {
  8578. + .bus_id = "ag71xx-mdio.0",
  8579. + .phy_addr = 0,
  8580. + .platform_data = &db120_ar8327_data,
  8581. + },
  8582. +};
  8583. static void __init db120_setup(void)
  8584. {
  8585. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  8586. + ath79_gpio_output_select(DB120_GPIO_LED_USB, AR934X_GPIO_OUT_GPIO);
  8587. + ath79_register_m25p80(NULL);
  8588. +
  8589. ath79_register_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
  8590. db120_leds_gpio);
  8591. ath79_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
  8592. ARRAY_SIZE(db120_gpio_keys),
  8593. db120_gpio_keys);
  8594. - ath79_register_spi(&db120_spi_data, db120_spi_info,
  8595. - ARRAY_SIZE(db120_spi_info));
  8596. ath79_register_usb();
  8597. - ath79_register_wmac(art + DB120_WMAC_CALDATA_OFFSET);
  8598. - db120_pci_init(art + DB120_PCIE_CALDATA_OFFSET);
  8599. + ath79_register_wmac(art + DB120_WMAC_CALDATA_OFFSET, NULL);
  8600. + ap91_pci_init(art + DB120_PCIE_CALDATA_OFFSET, NULL);
  8601. +
  8602. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  8603. + AR934X_ETH_CFG_SW_ONLY_MODE);
  8604. +
  8605. + ath79_register_mdio(1, 0x0);
  8606. + ath79_register_mdio(0, 0x0);
  8607. +
  8608. + ath79_init_mac(ath79_eth0_data.mac_addr, art + DB120_MAC0_OFFSET, 0);
  8609. +
  8610. + mdiobus_register_board_info(db120_mdio0_info,
  8611. + ARRAY_SIZE(db120_mdio0_info));
  8612. +
  8613. + /* GMAC0 is connected to an AR8327 switch */
  8614. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  8615. + ath79_eth0_data.phy_mask = BIT(0);
  8616. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  8617. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  8618. + ath79_register_eth(0);
  8619. +
  8620. + /* GMAC1 is connected to the internal switch */
  8621. + ath79_init_mac(ath79_eth1_data.mac_addr, art + DB120_MAC1_OFFSET, 0);
  8622. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  8623. + ath79_eth1_data.speed = SPEED_1000;
  8624. + ath79_eth1_data.duplex = DUPLEX_FULL;
  8625. +
  8626. + ath79_register_eth(1);
  8627. +
  8628. + ath79_register_nfc();
  8629. }
  8630. MIPS_MACHINE(ATH79_MACH_DB120, "DB120", "Atheros DB120 reference board",
  8631. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dgl-5500-a1.c linux-4.1.13/arch/mips/ath79/mach-dgl-5500-a1.c
  8632. --- linux-4.1.13.orig/arch/mips/ath79/mach-dgl-5500-a1.c 1970-01-01 01:00:00.000000000 +0100
  8633. +++ linux-4.1.13/arch/mips/ath79/mach-dgl-5500-a1.c 2015-09-13 20:04:35.068524086 +0200
  8634. @@ -0,0 +1,150 @@
  8635. +/*
  8636. + * D-Link DGL-5500 board support
  8637. + *
  8638. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  8639. + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  8640. + *
  8641. + * This program is free software; you can redistribute it and/or modify it
  8642. + * under the terms of the GNU General Public License version 2 as published
  8643. + * by the Free Software Foundation.
  8644. + */
  8645. +
  8646. +#include <linux/gpio.h>
  8647. +#include <linux/platform_device.h>
  8648. +#include <linux/ar8216_platform.h>
  8649. +
  8650. +#include <asm/mach-ath79/ar71xx_regs.h>
  8651. +
  8652. +#include "common.h"
  8653. +#include "pci.h"
  8654. +#include "dev-gpio-buttons.h"
  8655. +#include "dev-eth.h"
  8656. +#include "dev-leds-gpio.h"
  8657. +#include "dev-m25p80.h"
  8658. +#include "dev-usb.h"
  8659. +#include "dev-wmac.h"
  8660. +#include "machtypes.h"
  8661. +
  8662. +#define DGL_5500_A1_GPIO_LED_POWER_ORANGE 14
  8663. +#define DGL_5500_A1_GPIO_LED_POWER_GREEN 19
  8664. +#define DGL_5500_A1_GPIO_LED_PLANET_GREEN 22
  8665. +#define DGL_5500_A1_GPIO_LED_PLANET_ORANGE 23
  8666. +
  8667. +#define DGL_5500_A1_GPIO_BTN_WPS 16
  8668. +#define DGL_5500_A1_GPIO_BTN_RESET 17
  8669. +
  8670. +#define DGL_5500_A1_KEYS_POLL_INTERVAL 20 /* msecs */
  8671. +#define DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL \
  8672. + (3 * DGL_5500_A1_KEYS_POLL_INTERVAL)
  8673. +
  8674. +#define DGL_5500_A1_WMAC_CALDATA_OFFSET 0x1000
  8675. +
  8676. +#define DGL_5500_A1_LAN_MAC_OFFSET 0x04
  8677. +#define DGL_5500_A1_WAN_MAC_OFFSET 0x16
  8678. +
  8679. +static struct gpio_led dgl_5500_a1_leds_gpio[] __initdata = {
  8680. + {
  8681. + .name = "d-link:green:power",
  8682. + .gpio = DGL_5500_A1_GPIO_LED_POWER_GREEN,
  8683. + .active_low = 1,
  8684. + },
  8685. + {
  8686. + .name = "d-link:orange:power",
  8687. + .gpio = DGL_5500_A1_GPIO_LED_POWER_ORANGE,
  8688. + .active_low = 1,
  8689. + },
  8690. + {
  8691. + .name = "d-link:green:planet",
  8692. + .gpio = DGL_5500_A1_GPIO_LED_PLANET_GREEN,
  8693. + .active_low = 1,
  8694. + },
  8695. + {
  8696. + .name = "d-link:orange:planet",
  8697. + .gpio = DGL_5500_A1_GPIO_LED_PLANET_ORANGE,
  8698. + .active_low = 1,
  8699. + },
  8700. +};
  8701. +
  8702. +static struct gpio_keys_button dgl_5500_a1_gpio_keys[] __initdata = {
  8703. + {
  8704. + .desc = "Reset button",
  8705. + .type = EV_KEY,
  8706. + .code = KEY_RESTART,
  8707. + .debounce_interval = DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL,
  8708. + .gpio = DGL_5500_A1_GPIO_BTN_RESET,
  8709. + .active_low = 1,
  8710. + },
  8711. + {
  8712. + .desc = "WPS button",
  8713. + .type = EV_KEY,
  8714. + .code = KEY_WPS_BUTTON,
  8715. + .debounce_interval = DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL,
  8716. + .gpio = DGL_5500_A1_GPIO_BTN_WPS,
  8717. + .active_low = 1,
  8718. + },
  8719. +};
  8720. +
  8721. +static struct ar8327_pad_cfg dgl_5500_a1_ar8327_pad0_cfg = {
  8722. + /* Use the SGMII interface for the GMAC0 of the AR8327 switch */
  8723. + .mode = AR8327_PAD_MAC_SGMII,
  8724. + .sgmii_delay_en = true,
  8725. +};
  8726. +
  8727. +static struct ar8327_platform_data dgl_5500_a1_ar8327_data = {
  8728. + .pad0_cfg = &dgl_5500_a1_ar8327_pad0_cfg,
  8729. + .port0_cfg = {
  8730. + .force_link = 1,
  8731. + .speed = AR8327_PORT_SPEED_1000,
  8732. + .duplex = 1,
  8733. + .txpause = 1,
  8734. + .rxpause = 1,
  8735. + },
  8736. +};
  8737. +
  8738. +static struct mdio_board_info dgl_5500_a1_mdio0_info[] = {
  8739. + {
  8740. + .bus_id = "ag71xx-mdio.0",
  8741. + .phy_addr = 0,
  8742. + .platform_data = &dgl_5500_a1_ar8327_data,
  8743. + },
  8744. +};
  8745. +
  8746. +static void __init dgl_5500_a1_setup(void)
  8747. +{
  8748. + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
  8749. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  8750. + u8 lan_mac[ETH_ALEN];
  8751. +
  8752. + ath79_parse_ascii_mac(mac + DGL_5500_A1_LAN_MAC_OFFSET, lan_mac);
  8753. +
  8754. + ath79_register_m25p80(NULL);
  8755. +
  8756. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dgl_5500_a1_leds_gpio),
  8757. + dgl_5500_a1_leds_gpio);
  8758. + ath79_register_gpio_keys_polled(-1, DGL_5500_A1_KEYS_POLL_INTERVAL,
  8759. + ARRAY_SIZE(dgl_5500_a1_gpio_keys),
  8760. + dgl_5500_a1_gpio_keys);
  8761. +
  8762. + ath79_register_wmac(art + DGL_5500_A1_WMAC_CALDATA_OFFSET, lan_mac);
  8763. +
  8764. + ath79_register_mdio(0, 0x0);
  8765. + mdiobus_register_board_info(dgl_5500_a1_mdio0_info,
  8766. + ARRAY_SIZE(dgl_5500_a1_mdio0_info));
  8767. +
  8768. + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  8769. +
  8770. + /* GMAC1 is connected to an AR8327N switch via the SMGII interface */
  8771. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  8772. + ath79_eth1_data.phy_mask = BIT(0);
  8773. + ath79_eth1_data.mii_bus_dev = &ath79_mdio0_device.dev;
  8774. +
  8775. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  8776. +
  8777. + ath79_register_eth(1);
  8778. +
  8779. + ath79_register_usb();
  8780. + ath79_register_pci();
  8781. +}
  8782. +
  8783. +MIPS_MACHINE(ATH79_MACH_DGL_5500_A1, "DGL-5500-A1", "D-Link DGL-5500 rev. A1",
  8784. + dgl_5500_a1_setup);
  8785. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dhp-1565-a1.c linux-4.1.13/arch/mips/ath79/mach-dhp-1565-a1.c
  8786. --- linux-4.1.13.orig/arch/mips/ath79/mach-dhp-1565-a1.c 1970-01-01 01:00:00.000000000 +0100
  8787. +++ linux-4.1.13/arch/mips/ath79/mach-dhp-1565-a1.c 2015-09-13 20:04:35.068524086 +0200
  8788. @@ -0,0 +1,170 @@
  8789. +/*
  8790. + * D-Link DHP-1565 rev. A1 board support
  8791. + *
  8792. + * Copyright (C) 2014 Jacek Kikiewicz
  8793. + *
  8794. + * This program is free software; you can redistribute it and/or modify it
  8795. + * under the terms of the GNU General Public License version 2 as published
  8796. + * by the Free Software Foundation.
  8797. + */
  8798. +
  8799. +#include <linux/pci.h>
  8800. +#include <linux/phy.h>
  8801. +#include <linux/gpio.h>
  8802. +#include <linux/platform_device.h>
  8803. +#include <linux/ath9k_platform.h>
  8804. +#include <linux/ar8216_platform.h>
  8805. +
  8806. +#include <asm/mach-ath79/ar71xx_regs.h>
  8807. +
  8808. +#include "common.h"
  8809. +#include "dev-ap9x-pci.h"
  8810. +#include "dev-eth.h"
  8811. +#include "dev-gpio-buttons.h"
  8812. +#include "dev-leds-gpio.h"
  8813. +#include "dev-m25p80.h"
  8814. +#include "dev-spi.h"
  8815. +#include "dev-usb.h"
  8816. +#include "dev-wmac.h"
  8817. +#include "machtypes.h"
  8818. +
  8819. +#define DHP1565A1_GPIO_LED_BLUE_USB 11
  8820. +#define DHP1565A1_GPIO_LED_AMBER_POWER 14
  8821. +#define DHP1565A1_GPIO_LED_BLUE_POWER 22
  8822. +#define DHP1565A1_GPIO_LED_BLUE_WPS 15
  8823. +#define DHP1565A1_GPIO_LED_AMBER_PLANET 19
  8824. +#define DHP1565A1_GPIO_LED_BLUE_PLANET 18
  8825. +#define DHP1565A1_GPIO_LED_WLAN_2G 13
  8826. +
  8827. +#define DHP1565A1_GPIO_WAN_LED_ENABLE 20
  8828. +
  8829. +#define DHP1565A1_GPIO_BTN_RESET 17
  8830. +#define DHP1565A1_GPIO_BTN_WPS 16
  8831. +
  8832. +#define DHP1565A1_KEYS_POLL_INTERVAL 20 /* msecs */
  8833. +#define DHP1565A1_KEYS_DEBOUNCE_INTERVAL (3 * DHP1565A1_KEYS_POLL_INTERVAL)
  8834. +
  8835. +#define DHP1565A1_MAC0_OFFSET 0xFFA0
  8836. +#define DHP1565A1_MAC1_OFFSET 0xFFB4
  8837. +#define DHP1565A1_WMAC0_OFFSET 0x5
  8838. +#define DHP1565A1_WMAC_CALDATA_OFFSET 0x1000
  8839. +#define DHP1565A1_PCIE_CALDATA_OFFSET 0x5000
  8840. +
  8841. +static struct gpio_led dhp1565a1_leds_gpio[] __initdata = {
  8842. + {
  8843. + .name = "d-link:amber:power",
  8844. + .gpio = DHP1565A1_GPIO_LED_AMBER_POWER,
  8845. + .active_low = 1,
  8846. + },
  8847. + {
  8848. + .name = "d-link:green:power",
  8849. + .gpio = DHP1565A1_GPIO_LED_BLUE_POWER,
  8850. + .active_low = 1,
  8851. + },
  8852. + {
  8853. + .name = "d-link:amber:planet",
  8854. + .gpio = DHP1565A1_GPIO_LED_AMBER_PLANET,
  8855. + .active_low = 1,
  8856. + },
  8857. + {
  8858. + .name = "d-link:green:planet",
  8859. + .gpio = DHP1565A1_GPIO_LED_BLUE_PLANET,
  8860. + .active_low = 1,
  8861. + },
  8862. +};
  8863. +
  8864. +static struct gpio_keys_button dhp1565a1_gpio_keys[] __initdata = {
  8865. + {
  8866. + .desc = "Soft reset",
  8867. + .type = EV_KEY,
  8868. + .code = KEY_RESTART,
  8869. + .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
  8870. + .gpio = DHP1565A1_GPIO_BTN_RESET,
  8871. + .active_low = 1,
  8872. + },
  8873. + {
  8874. + .desc = "WPS button",
  8875. + .type = EV_KEY,
  8876. + .code = KEY_WPS_BUTTON,
  8877. + .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
  8878. + .gpio = DHP1565A1_GPIO_BTN_WPS,
  8879. + .active_low = 1,
  8880. + },
  8881. +};
  8882. +
  8883. +static struct ar8327_pad_cfg dhp1565a1_ar8327_pad0_cfg = {
  8884. + .mode = AR8327_PAD_MAC_RGMII,
  8885. + .txclk_delay_en = true,
  8886. + .rxclk_delay_en = true,
  8887. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  8888. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  8889. +};
  8890. +
  8891. +static struct ar8327_platform_data dhp1565a1_ar8327_data = {
  8892. + .pad0_cfg = &dhp1565a1_ar8327_pad0_cfg,
  8893. + .port0_cfg = {
  8894. + .force_link = 1,
  8895. + .speed = AR8327_PORT_SPEED_1000,
  8896. + .duplex = 1,
  8897. + .txpause = 1,
  8898. + .rxpause = 1,
  8899. + },
  8900. +};
  8901. +
  8902. +static struct mdio_board_info dhp1565a1_mdio0_info[] = {
  8903. + {
  8904. + .bus_id = "ag71xx-mdio.0",
  8905. + .phy_addr = 0,
  8906. + .platform_data = &dhp1565a1_ar8327_data,
  8907. + },
  8908. +};
  8909. +
  8910. +static void __init dhp1565a1_generic_setup(void)
  8911. +{
  8912. + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
  8913. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  8914. + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
  8915. + u8 wmac0[ETH_ALEN];
  8916. +
  8917. + ath79_parse_ascii_mac(mac + DHP1565A1_MAC0_OFFSET, mac0);
  8918. + ath79_parse_ascii_mac(mac + DHP1565A1_MAC1_OFFSET, mac1);
  8919. +
  8920. + ath79_register_m25p80(NULL);
  8921. +
  8922. + ath79_register_gpio_keys_polled(-1, DHP1565A1_KEYS_POLL_INTERVAL,
  8923. + ARRAY_SIZE(dhp1565a1_gpio_keys),
  8924. + dhp1565a1_gpio_keys);
  8925. +
  8926. + ath79_init_mac(wmac0, mac0, 0);
  8927. + ath79_register_wmac(art + DHP1565A1_WMAC_CALDATA_OFFSET, wmac0);
  8928. +
  8929. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  8930. +
  8931. + mdiobus_register_board_info(dhp1565a1_mdio0_info,
  8932. + ARRAY_SIZE(dhp1565a1_mdio0_info));
  8933. +
  8934. + ath79_register_mdio(0, 0x0);
  8935. +
  8936. + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 1);
  8937. +
  8938. + /* GMAC0 is connected to an AR8327N switch */
  8939. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  8940. + ath79_eth0_data.phy_mask = BIT(0);
  8941. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  8942. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  8943. + ath79_register_eth(0);
  8944. +
  8945. + ath79_register_usb();
  8946. +}
  8947. +
  8948. +static void __init dhp1565a1_setup(void)
  8949. +{
  8950. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dhp1565a1_leds_gpio),
  8951. + dhp1565a1_leds_gpio);
  8952. +
  8953. + dhp1565a1_generic_setup();
  8954. +}
  8955. +
  8956. +MIPS_MACHINE(ATH79_MACH_DHP_1565_A1, "DHP-1565-A1",
  8957. + "D-Link DHP-1565 rev. A1",
  8958. + dhp1565a1_setup);
  8959. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-505-a1.c linux-4.1.13/arch/mips/ath79/mach-dir-505-a1.c
  8960. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-505-a1.c 1970-01-01 01:00:00.000000000 +0100
  8961. +++ linux-4.1.13/arch/mips/ath79/mach-dir-505-a1.c 2015-09-13 20:04:35.068524086 +0200
  8962. @@ -0,0 +1,116 @@
  8963. +/*
  8964. + * DLink DIR-505 A1 board support
  8965. + *
  8966. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  8967. + *
  8968. + * This program is free software; you can redistribute it and/or modify it
  8969. + * under the terms of the GNU General Public License version 2 as published
  8970. + * by the Free Software Foundation.
  8971. + */
  8972. +
  8973. +#include <linux/gpio.h>
  8974. +
  8975. +#include <asm/mach-ath79/ath79.h>
  8976. +#include <asm/mach-ath79/ar71xx_regs.h>
  8977. +
  8978. +#include "common.h"
  8979. +#include "dev-eth.h"
  8980. +#include "dev-gpio-buttons.h"
  8981. +#include "dev-leds-gpio.h"
  8982. +#include "dev-m25p80.h"
  8983. +#include "dev-wmac.h"
  8984. +#include "dev-usb.h"
  8985. +#include "machtypes.h"
  8986. +
  8987. +#define DIR_505A1_GPIO_BTN_WPS 11 /* verify */
  8988. +#define DIR_505A1_GPIO_BTN_RESET 12 /* verify */
  8989. +
  8990. +#define DIR_505A1_GPIO_LED_RED 26 /* unused, fyi */
  8991. +#define DIR_505A1_GPIO_LED_GREEN 27
  8992. +
  8993. +#define DIR_505A1_GPIO_WAN_LED_ENABLE 1
  8994. +
  8995. +#define DIR_505A1_KEYS_POLL_INTERVAL 20 /* msecs */
  8996. +#define DIR_505A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_505A1_KEYS_POLL_INTERVAL)
  8997. +
  8998. +#define DIR_505A1_ART_ADDRESS 0x1f010000
  8999. +#define DIR_505A1_CALDATA_OFFSET 0x1000
  9000. +
  9001. +#define DIR_505A1_MAC_PART_ADDRESS 0x1f020000
  9002. +#define DIR_505A1_LAN_MAC_OFFSET 0x04
  9003. +#define DIR_505A1_WAN_MAC_OFFSET 0x16
  9004. +
  9005. +static struct gpio_led dir_505_a1_leds_gpio[] __initdata = {
  9006. + {
  9007. + .name = "d-link:green:power",
  9008. + .gpio = DIR_505A1_GPIO_LED_GREEN,
  9009. + .active_low = 1,
  9010. + }, {
  9011. + .name = "d-link:red:status",
  9012. + .gpio = DIR_505A1_GPIO_LED_RED,
  9013. + .active_low = 1,
  9014. + },
  9015. +};
  9016. +
  9017. +static struct gpio_keys_button dir_505_a1_gpio_keys[] __initdata = {
  9018. + {
  9019. + .desc = "Reset button",
  9020. + .type = EV_KEY,
  9021. + .code = KEY_RESTART,
  9022. + .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
  9023. + .gpio = DIR_505A1_GPIO_BTN_RESET,
  9024. + .active_low = 0,
  9025. + }, {
  9026. + .desc = "WPS button",
  9027. + .type = EV_KEY,
  9028. + .code = KEY_WPS_BUTTON,
  9029. + .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
  9030. + .gpio = DIR_505A1_GPIO_BTN_WPS,
  9031. + .active_low = 1,
  9032. + }
  9033. +};
  9034. +
  9035. +static void __init dir_505_a1_setup(void)
  9036. +{
  9037. + u8 *art = (u8 *) KSEG1ADDR(DIR_505A1_ART_ADDRESS);
  9038. + u8 *mac = (u8 *) KSEG1ADDR(DIR_505A1_MAC_PART_ADDRESS);
  9039. + u8 lan_mac[ETH_ALEN];
  9040. + u8 wan_mac[ETH_ALEN];
  9041. +
  9042. + ath79_setup_ar933x_phy4_switch(false, false);
  9043. +
  9044. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  9045. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  9046. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  9047. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  9048. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  9049. +
  9050. + gpio_request_one(DIR_505A1_GPIO_WAN_LED_ENABLE,
  9051. + GPIOF_OUT_INIT_LOW, "WAN LED enable");
  9052. +
  9053. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_505_a1_leds_gpio),
  9054. + dir_505_a1_leds_gpio);
  9055. +
  9056. + ath79_register_gpio_keys_polled(1, DIR_505A1_KEYS_POLL_INTERVAL,
  9057. + ARRAY_SIZE(dir_505_a1_gpio_keys),
  9058. + dir_505_a1_gpio_keys);
  9059. +
  9060. + ath79_register_m25p80(NULL);
  9061. +
  9062. + ath79_register_usb();
  9063. +
  9064. + ath79_parse_ascii_mac(mac + DIR_505A1_LAN_MAC_OFFSET, lan_mac);
  9065. + ath79_parse_ascii_mac(mac + DIR_505A1_WAN_MAC_OFFSET, wan_mac);
  9066. +
  9067. + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
  9068. + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  9069. +
  9070. + ath79_register_mdio(0, 0x0);
  9071. + ath79_register_eth(1);
  9072. + ath79_register_eth(0);
  9073. +
  9074. + ath79_register_wmac(art + DIR_505A1_CALDATA_OFFSET, lan_mac);
  9075. +}
  9076. +
  9077. +MIPS_MACHINE(ATH79_MACH_DIR_505_A1, "DIR-505-A1",
  9078. + "D-Link DIR-505 rev. A1", dir_505_a1_setup);
  9079. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-600-a1.c linux-4.1.13/arch/mips/ath79/mach-dir-600-a1.c
  9080. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-600-a1.c 1970-01-01 01:00:00.000000000 +0100
  9081. +++ linux-4.1.13/arch/mips/ath79/mach-dir-600-a1.c 2015-09-13 20:04:35.068524086 +0200
  9082. @@ -0,0 +1,159 @@
  9083. +/*
  9084. + * D-Link DIR-600 rev. A1 board support
  9085. + *
  9086. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  9087. + * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
  9088. + *
  9089. + * This program is free software; you can redistribute it and/or modify it
  9090. + * under the terms of the GNU General Public License version 2 as published
  9091. + * by the Free Software Foundation.
  9092. + */
  9093. +
  9094. +#include <asm/mach-ath79/ath79.h>
  9095. +#include <asm/mach-ath79/ar71xx_regs.h>
  9096. +
  9097. +#include "common.h"
  9098. +#include "dev-ap9x-pci.h"
  9099. +#include "dev-eth.h"
  9100. +#include "dev-gpio-buttons.h"
  9101. +#include "dev-leds-gpio.h"
  9102. +#include "dev-m25p80.h"
  9103. +#include "machtypes.h"
  9104. +#include "nvram.h"
  9105. +
  9106. +#define DIR_600_A1_GPIO_LED_WPS 0
  9107. +#define DIR_600_A1_GPIO_LED_POWER_AMBER 1
  9108. +#define DIR_600_A1_GPIO_LED_POWER_GREEN 6
  9109. +#define DIR_600_A1_GPIO_LED_LAN1 13
  9110. +#define DIR_600_A1_GPIO_LED_LAN2 14
  9111. +#define DIR_600_A1_GPIO_LED_LAN3 15
  9112. +#define DIR_600_A1_GPIO_LED_LAN4 16
  9113. +#define DIR_600_A1_GPIO_LED_WAN_AMBER 7
  9114. +#define DIR_600_A1_GPIO_LED_WAN_GREEN 17
  9115. +
  9116. +#define DIR_600_A1_GPIO_BTN_RESET 8
  9117. +#define DIR_600_A1_GPIO_BTN_WPS 12
  9118. +
  9119. +#define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
  9120. +#define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
  9121. +
  9122. +#define DIR_600_A1_NVRAM_ADDR 0x1f030000
  9123. +#define DIR_600_A1_NVRAM_SIZE 0x10000
  9124. +
  9125. +static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
  9126. + {
  9127. + .name = "d-link:green:power",
  9128. + .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
  9129. + }, {
  9130. + .name = "d-link:amber:power",
  9131. + .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
  9132. + }, {
  9133. + .name = "d-link:amber:wan",
  9134. + .gpio = DIR_600_A1_GPIO_LED_WAN_AMBER,
  9135. + }, {
  9136. + .name = "d-link:green:wan",
  9137. + .gpio = DIR_600_A1_GPIO_LED_WAN_GREEN,
  9138. + .active_low = 1,
  9139. + }, {
  9140. + .name = "d-link:green:lan1",
  9141. + .gpio = DIR_600_A1_GPIO_LED_LAN1,
  9142. + .active_low = 1,
  9143. + }, {
  9144. + .name = "d-link:green:lan2",
  9145. + .gpio = DIR_600_A1_GPIO_LED_LAN2,
  9146. + .active_low = 1,
  9147. + }, {
  9148. + .name = "d-link:green:lan3",
  9149. + .gpio = DIR_600_A1_GPIO_LED_LAN3,
  9150. + .active_low = 1,
  9151. + }, {
  9152. + .name = "d-link:green:lan4",
  9153. + .gpio = DIR_600_A1_GPIO_LED_LAN4,
  9154. + .active_low = 1,
  9155. + }, {
  9156. + .name = "d-link:blue:wps",
  9157. + .gpio = DIR_600_A1_GPIO_LED_WPS,
  9158. + .active_low = 1,
  9159. + }
  9160. +};
  9161. +
  9162. +static struct gpio_keys_button dir_600_a1_gpio_keys[] __initdata = {
  9163. + {
  9164. + .desc = "reset",
  9165. + .type = EV_KEY,
  9166. + .code = KEY_RESTART,
  9167. + .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
  9168. + .gpio = DIR_600_A1_GPIO_BTN_RESET,
  9169. + .active_low = 1,
  9170. + }, {
  9171. + .desc = "wps",
  9172. + .type = EV_KEY,
  9173. + .code = KEY_WPS_BUTTON,
  9174. + .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
  9175. + .gpio = DIR_600_A1_GPIO_BTN_WPS,
  9176. + .active_low = 1,
  9177. + }
  9178. +};
  9179. +
  9180. +static void __init dir_600_a1_setup(void)
  9181. +{
  9182. + const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
  9183. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  9184. + u8 mac_buff[6];
  9185. + u8 *mac = NULL;
  9186. +
  9187. + if (ath79_nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
  9188. + "lan_mac=", mac_buff) == 0) {
  9189. + ath79_init_mac(ath79_eth0_data.mac_addr, mac_buff, 0);
  9190. + ath79_init_mac(ath79_eth1_data.mac_addr, mac_buff, 1);
  9191. + mac = mac_buff;
  9192. + }
  9193. +
  9194. + ath79_register_m25p80(NULL);
  9195. +
  9196. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  9197. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  9198. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  9199. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  9200. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  9201. +
  9202. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
  9203. + dir_600_a1_leds_gpio);
  9204. +
  9205. + ath79_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL,
  9206. + ARRAY_SIZE(dir_600_a1_gpio_keys),
  9207. + dir_600_a1_gpio_keys);
  9208. +
  9209. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  9210. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  9211. +
  9212. + ath79_register_mdio(0, 0x0);
  9213. +
  9214. + /* LAN ports */
  9215. + ath79_register_eth(1);
  9216. +
  9217. + /* WAN port */
  9218. + ath79_register_eth(0);
  9219. +
  9220. + ap91_pci_init(ee, mac);
  9221. +}
  9222. +
  9223. +MIPS_MACHINE(ATH79_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
  9224. + dir_600_a1_setup);
  9225. +
  9226. +static void __init dir_615_e1_setup(void)
  9227. +{
  9228. + dir_600_a1_setup();
  9229. +}
  9230. +
  9231. +MIPS_MACHINE(ATH79_MACH_DIR_615_E1, "DIR-615-E1", "D-Link DIR-615 rev. E1",
  9232. + dir_615_e1_setup);
  9233. +
  9234. +static void __init dir_615_e4_setup(void)
  9235. +{
  9236. + dir_600_a1_setup();
  9237. + ap9x_pci_setup_wmac_led_pin(0, 1);
  9238. +}
  9239. +
  9240. +MIPS_MACHINE(ATH79_MACH_DIR_615_E4, "DIR-615-E4", "D-Link DIR-615 rev. E4",
  9241. + dir_615_e4_setup);
  9242. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-615-c1.c linux-4.1.13/arch/mips/ath79/mach-dir-615-c1.c
  9243. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-615-c1.c 1970-01-01 01:00:00.000000000 +0100
  9244. +++ linux-4.1.13/arch/mips/ath79/mach-dir-615-c1.c 2015-09-13 20:04:35.068524086 +0200
  9245. @@ -0,0 +1,135 @@
  9246. +/*
  9247. + * D-Link DIR-615 rev C1 board support
  9248. + *
  9249. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  9250. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  9251. + *
  9252. + * This program is free software; you can redistribute it and/or modify it
  9253. + * under the terms of the GNU General Public License version 2 as published
  9254. + * by the Free Software Foundation.
  9255. + */
  9256. +
  9257. +#include <asm/mach-ath79/ath79.h>
  9258. +
  9259. +#include "dev-eth.h"
  9260. +#include "dev-gpio-buttons.h"
  9261. +#include "dev-leds-gpio.h"
  9262. +#include "dev-m25p80.h"
  9263. +#include "dev-wmac.h"
  9264. +#include "machtypes.h"
  9265. +#include "nvram.h"
  9266. +
  9267. +#define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
  9268. +#define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
  9269. +#define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
  9270. +#define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
  9271. +#define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
  9272. +#define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
  9273. +#define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
  9274. +
  9275. +/* buttons may need refinement */
  9276. +
  9277. +#define DIR_615C1_GPIO_BTN_WPS 12
  9278. +#define DIR_615C1_GPIO_BTN_RESET 21
  9279. +
  9280. +#define DIR_615C1_KEYS_POLL_INTERVAL 20 /* msecs */
  9281. +#define DIR_615C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615C1_KEYS_POLL_INTERVAL)
  9282. +
  9283. +#define DIR_615C1_CONFIG_ADDR 0x1f020000
  9284. +#define DIR_615C1_CONFIG_SIZE 0x10000
  9285. +
  9286. +#define DIR_615C1_WLAN_MAC_ADDR 0x1f3fffb4
  9287. +
  9288. +static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
  9289. + {
  9290. + .name = "d-link:orange:status",
  9291. + .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
  9292. + .active_low = 1,
  9293. + }, {
  9294. + .name = "d-link:blue:wps",
  9295. + .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
  9296. + .active_low = 1,
  9297. + }, {
  9298. + .name = "d-link:green:wan",
  9299. + .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
  9300. + .active_low = 1,
  9301. + }, {
  9302. + .name = "d-link:green:wancpu",
  9303. + .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
  9304. + .active_low = 1,
  9305. + }, {
  9306. + .name = "d-link:green:wlan",
  9307. + .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
  9308. + .active_low = 1,
  9309. + }, {
  9310. + .name = "d-link:green:status",
  9311. + .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
  9312. + .active_low = 1,
  9313. + }, {
  9314. + .name = "d-link:orange:wan",
  9315. + .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
  9316. + .active_low = 1,
  9317. + }
  9318. +
  9319. +};
  9320. +
  9321. +static struct gpio_keys_button dir_615c1_gpio_keys[] __initdata = {
  9322. + {
  9323. + .desc = "reset",
  9324. + .type = EV_KEY,
  9325. + .code = KEY_RESTART,
  9326. + .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
  9327. + .gpio = DIR_615C1_GPIO_BTN_RESET,
  9328. + }, {
  9329. + .desc = "wps",
  9330. + .type = EV_KEY,
  9331. + .code = KEY_WPS_BUTTON,
  9332. + .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
  9333. + .gpio = DIR_615C1_GPIO_BTN_WPS,
  9334. + }
  9335. +};
  9336. +
  9337. +#define DIR_615C1_LAN_PHYMASK BIT(0)
  9338. +#define DIR_615C1_WAN_PHYMASK BIT(4)
  9339. +#define DIR_615C1_MDIO_MASK (~(DIR_615C1_LAN_PHYMASK | \
  9340. + DIR_615C1_WAN_PHYMASK))
  9341. +
  9342. +static void __init dir_615c1_setup(void)
  9343. +{
  9344. + const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
  9345. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  9346. + u8 mac[ETH_ALEN], wlan_mac[ETH_ALEN];
  9347. +
  9348. + if (ath79_nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
  9349. + "lan_mac=", mac) == 0) {
  9350. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  9351. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  9352. + }
  9353. +
  9354. + ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615C1_WLAN_MAC_ADDR), wlan_mac);
  9355. +
  9356. + ath79_register_mdio(0, DIR_615C1_MDIO_MASK);
  9357. +
  9358. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  9359. + ath79_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
  9360. +
  9361. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  9362. + ath79_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
  9363. +
  9364. + ath79_register_eth(0);
  9365. + ath79_register_eth(1);
  9366. +
  9367. + ath79_register_m25p80(NULL);
  9368. +
  9369. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
  9370. + dir_615c1_leds_gpio);
  9371. +
  9372. + ath79_register_gpio_keys_polled(-1, DIR_615C1_KEYS_POLL_INTERVAL,
  9373. + ARRAY_SIZE(dir_615c1_gpio_keys),
  9374. + dir_615c1_gpio_keys);
  9375. +
  9376. + ath79_register_wmac(eeprom, wlan_mac);
  9377. +}
  9378. +
  9379. +MIPS_MACHINE(ATH79_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
  9380. + dir_615c1_setup);
  9381. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-615-i1.c linux-4.1.13/arch/mips/ath79/mach-dir-615-i1.c
  9382. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-615-i1.c 1970-01-01 01:00:00.000000000 +0100
  9383. +++ linux-4.1.13/arch/mips/ath79/mach-dir-615-i1.c 2015-09-13 20:04:35.068524086 +0200
  9384. @@ -0,0 +1,133 @@
  9385. +/*
  9386. + * D-Link DIR-615 rev. I1 board support
  9387. + * Copyright (C) 2013-2015 Jaehoon You <teslamint@gmail.com>
  9388. + *
  9389. + * based on the DIR-600 rev. A1 board support code
  9390. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  9391. + * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
  9392. + *
  9393. + * based on the TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support code
  9394. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  9395. + *
  9396. + * This program is free software; you can redistribute it and/or modify it
  9397. + * under the terms of the GNU General Public License version 2 as published
  9398. + * by the Free Software Foundation.
  9399. + */
  9400. +
  9401. +#include <linux/platform_device.h>
  9402. +
  9403. +#include <asm/mach-ath79/ath79.h>
  9404. +#include <asm/mach-ath79/ar71xx_regs.h>
  9405. +
  9406. +#include "common.h"
  9407. +#include "dev-eth.h"
  9408. +#include "dev-gpio-buttons.h"
  9409. +#include "dev-leds-gpio.h"
  9410. +#include "dev-m25p80.h"
  9411. +#include "dev-wmac.h"
  9412. +#include "machtypes.h"
  9413. +
  9414. +#define DIR_615_I1_GPIO_LED_WPS 15
  9415. +#define DIR_615_I1_GPIO_LED_POWER_AMBER 14
  9416. +#define DIR_615_I1_GPIO_LED_POWER_GREEN 4
  9417. +#define DIR_615_I1_GPIO_LED_WAN_AMBER 22
  9418. +#define DIR_615_I1_GPIO_LED_WAN_GREEN 12
  9419. +#define DIR_615_I1_GPIO_LED_WLAN_GREEN 13
  9420. +
  9421. +#define DIR_615_I1_GPIO_BTN_WPS 16
  9422. +#define DIR_615_I1_GPIO_BTN_RESET 17
  9423. +
  9424. +#define DIR_615_I1_KEYS_POLL_INTERVAL 20 /* msecs */
  9425. +#define DIR_615_I1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_I1_KEYS_POLL_INTERVAL)
  9426. +
  9427. +#define DIR_615_I1_LAN_PHYMASK BIT(0)
  9428. +#define DIR_615_I1_WAN_PHYMASK BIT(4)
  9429. +#define DIR_615_I1_WLAN_MAC_ADDR 0x1fffffb4
  9430. +
  9431. +static struct gpio_led dir_615_i1_leds_gpio[] __initdata = {
  9432. + {
  9433. + .name = "d-link:green:power",
  9434. + .gpio = DIR_615_I1_GPIO_LED_POWER_GREEN,
  9435. + }, {
  9436. + .name = "d-link:amber:power",
  9437. + .gpio = DIR_615_I1_GPIO_LED_POWER_AMBER,
  9438. + }, {
  9439. + .name = "d-link:amber:wan",
  9440. + .gpio = DIR_615_I1_GPIO_LED_WAN_AMBER,
  9441. + }, {
  9442. + .name = "d-link:green:wan",
  9443. + .gpio = DIR_615_I1_GPIO_LED_WAN_GREEN,
  9444. + .active_low = 1,
  9445. + }, {
  9446. + .name = "d-link:green:wlan",
  9447. + .gpio = DIR_615_I1_GPIO_LED_WLAN_GREEN,
  9448. + .active_low = 1,
  9449. + }, {
  9450. + .name = "d-link:blue:wps",
  9451. + .gpio = DIR_615_I1_GPIO_LED_WPS,
  9452. + .active_low = 1,
  9453. + }
  9454. +};
  9455. +
  9456. +static struct gpio_keys_button dir_615_i1_gpio_keys[] __initdata = {
  9457. + {
  9458. + .desc = "reset",
  9459. + .type = EV_KEY,
  9460. + .code = KEY_RESTART,
  9461. + .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
  9462. + .gpio = DIR_615_I1_GPIO_BTN_RESET,
  9463. + .active_low = 1,
  9464. + }, {
  9465. + .desc = "wps",
  9466. + .type = EV_KEY,
  9467. + .code = KEY_WPS_BUTTON,
  9468. + .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
  9469. + .gpio = DIR_615_I1_GPIO_BTN_WPS,
  9470. + .active_low = 1,
  9471. + }
  9472. +};
  9473. +
  9474. +static void __init dir_615_i1_setup(void)
  9475. +{
  9476. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  9477. + u8 mac[ETH_ALEN];
  9478. +
  9479. + ath79_register_mdio(0, 0x0);
  9480. + ath79_register_mdio(1, ~(DIR_615_I1_WAN_PHYMASK));
  9481. +
  9482. + ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615_I1_WLAN_MAC_ADDR), mac);
  9483. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  9484. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  9485. +
  9486. + /* GMAC0 is connected to the PHY0 of the internal switch */
  9487. + ath79_switch_data.phy4_mii_en = 1;
  9488. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  9489. + ath79_eth0_data.phy_mask = DIR_615_I1_WAN_PHYMASK;
  9490. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  9491. +
  9492. + /* GMAC1 is connected to the internal switch */
  9493. + ath79_eth1_data.phy_mask = DIR_615_I1_LAN_PHYMASK;
  9494. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  9495. +
  9496. + ath79_register_eth(0);
  9497. + ath79_register_eth(1);
  9498. +
  9499. + ath79_register_m25p80(NULL);
  9500. +
  9501. + /* Disable JTAG, enabling GPIOs 0-3 */
  9502. + /* Configure OBS4 line, for GPIO 4*/
  9503. + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  9504. + AR934X_GPIO_FUNC_CLK_OBS4_EN);
  9505. +
  9506. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615_i1_leds_gpio),
  9507. + dir_615_i1_leds_gpio);
  9508. +
  9509. + ath79_register_gpio_keys_polled(-1, DIR_615_I1_KEYS_POLL_INTERVAL,
  9510. + ARRAY_SIZE(dir_615_i1_gpio_keys),
  9511. + dir_615_i1_gpio_keys);
  9512. +
  9513. + ath79_register_wmac(eeprom, mac);
  9514. +}
  9515. +
  9516. +MIPS_MACHINE(ATH79_MACH_DIR_615_I1, "DIR-615-I1", "D-Link DIR-615 rev. I1",
  9517. + dir_615_i1_setup);
  9518. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-825-b1.c linux-4.1.13/arch/mips/ath79/mach-dir-825-b1.c
  9519. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-825-b1.c 1970-01-01 01:00:00.000000000 +0100
  9520. +++ linux-4.1.13/arch/mips/ath79/mach-dir-825-b1.c 2015-09-13 20:04:35.068524086 +0200
  9521. @@ -0,0 +1,191 @@
  9522. +/*
  9523. + * D-Link DIR-825 rev. B1 board support
  9524. + *
  9525. + * Copyright (C) 2009-2011 Lukas Kuna, Evkanet, s.r.o.
  9526. + *
  9527. + * based on mach-wndr3700.c
  9528. + *
  9529. + * This program is free software; you can redistribute it and/or modify it
  9530. + * under the terms of the GNU General Public License version 2 as published
  9531. + * by the Free Software Foundation.
  9532. + */
  9533. +
  9534. +#include <linux/platform_device.h>
  9535. +#include <linux/delay.h>
  9536. +#include <linux/rtl8366.h>
  9537. +
  9538. +#include <asm/mach-ath79/ath79.h>
  9539. +
  9540. +#include "dev-eth.h"
  9541. +#include "dev-ap9x-pci.h"
  9542. +#include "dev-gpio-buttons.h"
  9543. +#include "dev-leds-gpio.h"
  9544. +#include "dev-m25p80.h"
  9545. +#include "dev-usb.h"
  9546. +#include "machtypes.h"
  9547. +
  9548. +#define DIR825B1_GPIO_LED_BLUE_USB 0
  9549. +#define DIR825B1_GPIO_LED_ORANGE_POWER 1
  9550. +#define DIR825B1_GPIO_LED_BLUE_POWER 2
  9551. +#define DIR825B1_GPIO_LED_BLUE_WPS 4
  9552. +#define DIR825B1_GPIO_LED_ORANGE_PLANET 6
  9553. +#define DIR825B1_GPIO_LED_BLUE_PLANET 11
  9554. +
  9555. +#define DIR825B1_GPIO_BTN_RESET 3
  9556. +#define DIR825B1_GPIO_BTN_WPS 8
  9557. +
  9558. +#define DIR825B1_GPIO_RTL8366_SDA 5
  9559. +#define DIR825B1_GPIO_RTL8366_SCK 7
  9560. +
  9561. +#define DIR825B1_KEYS_POLL_INTERVAL 20 /* msecs */
  9562. +#define DIR825B1_KEYS_DEBOUNCE_INTERVAL (3 * DIR825B1_KEYS_POLL_INTERVAL)
  9563. +
  9564. +#define DIR825B1_CAL0_OFFSET 0x1000
  9565. +#define DIR825B1_CAL1_OFFSET 0x5000
  9566. +#define DIR825B1_MAC0_OFFSET 0xffa0
  9567. +#define DIR825B1_MAC1_OFFSET 0xffb4
  9568. +
  9569. +#define DIR825B1_CAL_LOCATION_0 0x1f660000
  9570. +#define DIR825B1_CAL_LOCATION_1 0x1f7f0000
  9571. +
  9572. +static struct gpio_led dir825b1_leds_gpio[] __initdata = {
  9573. + {
  9574. + .name = "d-link:blue:usb",
  9575. + .gpio = DIR825B1_GPIO_LED_BLUE_USB,
  9576. + .active_low = 1,
  9577. + }, {
  9578. + .name = "d-link:orange:power",
  9579. + .gpio = DIR825B1_GPIO_LED_ORANGE_POWER,
  9580. + .active_low = 1,
  9581. + }, {
  9582. + .name = "d-link:blue:power",
  9583. + .gpio = DIR825B1_GPIO_LED_BLUE_POWER,
  9584. + .active_low = 1,
  9585. + }, {
  9586. + .name = "d-link:blue:wps",
  9587. + .gpio = DIR825B1_GPIO_LED_BLUE_WPS,
  9588. + .active_low = 1,
  9589. + }, {
  9590. + .name = "d-link:orange:planet",
  9591. + .gpio = DIR825B1_GPIO_LED_ORANGE_PLANET,
  9592. + .active_low = 1,
  9593. + }, {
  9594. + .name = "d-link:blue:planet",
  9595. + .gpio = DIR825B1_GPIO_LED_BLUE_PLANET,
  9596. + .active_low = 1,
  9597. + }
  9598. +};
  9599. +
  9600. +static struct gpio_keys_button dir825b1_gpio_keys[] __initdata = {
  9601. + {
  9602. + .desc = "reset",
  9603. + .type = EV_KEY,
  9604. + .code = KEY_RESTART,
  9605. + .debounce_interval = DIR825B1_KEYS_DEBOUNCE_INTERVAL,
  9606. + .gpio = DIR825B1_GPIO_BTN_RESET,
  9607. + .active_low = 1,
  9608. + }, {
  9609. + .desc = "wps",
  9610. + .type = EV_KEY,
  9611. + .code = KEY_WPS_BUTTON,
  9612. + .debounce_interval = DIR825B1_KEYS_DEBOUNCE_INTERVAL,
  9613. + .gpio = DIR825B1_GPIO_BTN_WPS,
  9614. + .active_low = 1,
  9615. + }
  9616. +};
  9617. +
  9618. +static struct rtl8366_initval dir825b1_rtl8366s_initvals[] = {
  9619. + { .reg = 0x06, .val = 0x0108 },
  9620. +};
  9621. +
  9622. +static struct rtl8366_platform_data dir825b1_rtl8366s_data = {
  9623. + .gpio_sda = DIR825B1_GPIO_RTL8366_SDA,
  9624. + .gpio_sck = DIR825B1_GPIO_RTL8366_SCK,
  9625. + .num_initvals = ARRAY_SIZE(dir825b1_rtl8366s_initvals),
  9626. + .initvals = dir825b1_rtl8366s_initvals,
  9627. +};
  9628. +
  9629. +static struct platform_device dir825b1_rtl8366s_device = {
  9630. + .name = RTL8366S_DRIVER_NAME,
  9631. + .id = -1,
  9632. + .dev = {
  9633. + .platform_data = &dir825b1_rtl8366s_data,
  9634. + }
  9635. +};
  9636. +
  9637. +static bool __init dir825b1_is_caldata_valid(u8 *p)
  9638. +{
  9639. + u16 *magic0, *magic1;
  9640. +
  9641. + magic0 = (u16 *)(p + DIR825B1_CAL0_OFFSET);
  9642. + magic1 = (u16 *)(p + DIR825B1_CAL1_OFFSET);
  9643. +
  9644. + return (*magic0 == 0xa55a && *magic1 == 0xa55a);
  9645. +}
  9646. +
  9647. +static void __init dir825b1_wlan_init(void)
  9648. +{
  9649. + u8 *caldata;
  9650. + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
  9651. + u8 wmac0[ETH_ALEN], wmac1[ETH_ALEN];
  9652. +
  9653. + caldata = (u8 *) KSEG1ADDR(DIR825B1_CAL_LOCATION_0);
  9654. + if (!dir825b1_is_caldata_valid(caldata)) {
  9655. + caldata = (u8 *)KSEG1ADDR(DIR825B1_CAL_LOCATION_1);
  9656. + if (!dir825b1_is_caldata_valid(caldata)) {
  9657. + pr_err("no calibration data found\n");
  9658. + return;
  9659. + }
  9660. + }
  9661. +
  9662. + ath79_parse_ascii_mac(caldata + DIR825B1_MAC0_OFFSET, mac0);
  9663. + ath79_parse_ascii_mac(caldata + DIR825B1_MAC1_OFFSET, mac1);
  9664. +
  9665. + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  9666. + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 0);
  9667. + ath79_init_mac(wmac0, mac0, 0);
  9668. + ath79_init_mac(wmac1, mac1, 1);
  9669. +
  9670. + ap9x_pci_setup_wmac_led_pin(0, 5);
  9671. + ap9x_pci_setup_wmac_led_pin(1, 5);
  9672. +
  9673. + ap94_pci_init(caldata + DIR825B1_CAL0_OFFSET, wmac0,
  9674. + caldata + DIR825B1_CAL1_OFFSET, wmac1);
  9675. +}
  9676. +
  9677. +static void __init dir825b1_setup(void)
  9678. +{
  9679. + dir825b1_wlan_init();
  9680. +
  9681. + ath79_register_mdio(0, 0x0);
  9682. +
  9683. + ath79_eth0_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
  9684. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  9685. + ath79_eth0_data.speed = SPEED_1000;
  9686. + ath79_eth0_data.duplex = DUPLEX_FULL;
  9687. + ath79_eth0_pll_data.pll_1000 = 0x11110000;
  9688. +
  9689. + ath79_eth1_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
  9690. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  9691. + ath79_eth1_data.phy_mask = 0x10;
  9692. + ath79_eth1_pll_data.pll_1000 = 0x11110000;
  9693. +
  9694. + ath79_register_eth(0);
  9695. + ath79_register_eth(1);
  9696. +
  9697. + ath79_register_m25p80(NULL);
  9698. +
  9699. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir825b1_leds_gpio),
  9700. + dir825b1_leds_gpio);
  9701. +
  9702. + ath79_register_gpio_keys_polled(-1, DIR825B1_KEYS_POLL_INTERVAL,
  9703. + ARRAY_SIZE(dir825b1_gpio_keys),
  9704. + dir825b1_gpio_keys);
  9705. +
  9706. + ath79_register_usb();
  9707. +
  9708. + platform_device_register(&dir825b1_rtl8366s_device);
  9709. +}
  9710. +
  9711. +MIPS_MACHINE(ATH79_MACH_DIR_825_B1, "DIR-825-B1", "D-Link DIR-825 rev. B1",
  9712. + dir825b1_setup);
  9713. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dir-825-c1.c linux-4.1.13/arch/mips/ath79/mach-dir-825-c1.c
  9714. --- linux-4.1.13.orig/arch/mips/ath79/mach-dir-825-c1.c 1970-01-01 01:00:00.000000000 +0100
  9715. +++ linux-4.1.13/arch/mips/ath79/mach-dir-825-c1.c 2015-09-13 20:04:35.068524086 +0200
  9716. @@ -0,0 +1,241 @@
  9717. +/*
  9718. + * D-Link DIR-825 rev. C1 board support
  9719. + *
  9720. + * Copyright (C) 2013 Alexander Stadler
  9721. + *
  9722. + * This program is free software; you can redistribute it and/or modify it
  9723. + * under the terms of the GNU General Public License version 2 as published
  9724. + * by the Free Software Foundation.
  9725. + */
  9726. +
  9727. +#include <linux/pci.h>
  9728. +#include <linux/phy.h>
  9729. +#include <linux/gpio.h>
  9730. +#include <linux/platform_device.h>
  9731. +#include <linux/ath9k_platform.h>
  9732. +#include <linux/ar8216_platform.h>
  9733. +
  9734. +#include <asm/mach-ath79/ar71xx_regs.h>
  9735. +
  9736. +#include "common.h"
  9737. +#include "dev-ap9x-pci.h"
  9738. +#include "dev-eth.h"
  9739. +#include "dev-gpio-buttons.h"
  9740. +#include "dev-leds-gpio.h"
  9741. +#include "dev-m25p80.h"
  9742. +#include "dev-spi.h"
  9743. +#include "dev-usb.h"
  9744. +#include "dev-wmac.h"
  9745. +#include "machtypes.h"
  9746. +
  9747. +#define DIR825C1_GPIO_LED_BLUE_USB 11
  9748. +#define DIR825C1_GPIO_LED_AMBER_POWER 14
  9749. +#define DIR825C1_GPIO_LED_BLUE_POWER 22
  9750. +#define DIR825C1_GPIO_LED_BLUE_WPS 15
  9751. +#define DIR825C1_GPIO_LED_AMBER_PLANET 19
  9752. +#define DIR825C1_GPIO_LED_BLUE_PLANET 18
  9753. +#define DIR825C1_GPIO_LED_WLAN_2G 13
  9754. +
  9755. +#define DIR825C1_GPIO_WAN_LED_ENABLE 20
  9756. +
  9757. +#define DIR825C1_GPIO_BTN_RESET 17
  9758. +#define DIR825C1_GPIO_BTN_WPS 16
  9759. +
  9760. +#define DIR825C1_KEYS_POLL_INTERVAL 20 /* msecs */
  9761. +#define DIR825C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR825C1_KEYS_POLL_INTERVAL)
  9762. +
  9763. +#define DIR825C1_MAC0_OFFSET 0x4
  9764. +#define DIR825C1_MAC1_OFFSET 0x18
  9765. +#define DIR825C1_WMAC_CALDATA_OFFSET 0x1000
  9766. +#define DIR825C1_PCIE_CALDATA_OFFSET 0x5000
  9767. +
  9768. +static struct gpio_led dir825c1_leds_gpio[] __initdata = {
  9769. + {
  9770. + .name = "d-link:blue:usb",
  9771. + .gpio = DIR825C1_GPIO_LED_BLUE_USB,
  9772. + .active_low = 1,
  9773. + },
  9774. + {
  9775. + .name = "d-link:amber:power",
  9776. + .gpio = DIR825C1_GPIO_LED_AMBER_POWER,
  9777. + .active_low = 1,
  9778. + },
  9779. + {
  9780. + .name = "d-link:blue:power",
  9781. + .gpio = DIR825C1_GPIO_LED_BLUE_POWER,
  9782. + .active_low = 1,
  9783. + },
  9784. + {
  9785. + .name = "d-link:blue:wps",
  9786. + .gpio = DIR825C1_GPIO_LED_BLUE_WPS,
  9787. + .active_low = 1,
  9788. + },
  9789. + {
  9790. + .name = "d-link:amber:planet",
  9791. + .gpio = DIR825C1_GPIO_LED_AMBER_PLANET,
  9792. + .active_low = 1,
  9793. + },
  9794. + {
  9795. + .name = "d-link:blue:wlan2g",
  9796. + .gpio = DIR825C1_GPIO_LED_WLAN_2G,
  9797. + .active_low = 1,
  9798. + },
  9799. +};
  9800. +
  9801. +static struct gpio_led dir835a1_leds_gpio[] __initdata = {
  9802. + {
  9803. + .name = "d-link:amber:power",
  9804. + .gpio = DIR825C1_GPIO_LED_AMBER_POWER,
  9805. + .active_low = 1,
  9806. + },
  9807. + {
  9808. + .name = "d-link:green:power",
  9809. + .gpio = DIR825C1_GPIO_LED_BLUE_POWER,
  9810. + .active_low = 1,
  9811. + },
  9812. + {
  9813. + .name = "d-link:blue:wps",
  9814. + .gpio = DIR825C1_GPIO_LED_BLUE_WPS,
  9815. + .active_low = 1,
  9816. + },
  9817. + {
  9818. + .name = "d-link:amber:planet",
  9819. + .gpio = DIR825C1_GPIO_LED_AMBER_PLANET,
  9820. + .active_low = 1,
  9821. + },
  9822. + {
  9823. + .name = "d-link:green:planet",
  9824. + .gpio = DIR825C1_GPIO_LED_BLUE_PLANET,
  9825. + .active_low = 1,
  9826. + },
  9827. +};
  9828. +
  9829. +static struct gpio_keys_button dir825c1_gpio_keys[] __initdata = {
  9830. + {
  9831. + .desc = "Soft reset",
  9832. + .type = EV_KEY,
  9833. + .code = KEY_RESTART,
  9834. + .debounce_interval = DIR825C1_KEYS_DEBOUNCE_INTERVAL,
  9835. + .gpio = DIR825C1_GPIO_BTN_RESET,
  9836. + .active_low = 1,
  9837. + },
  9838. + {
  9839. + .desc = "WPS button",
  9840. + .type = EV_KEY,
  9841. + .code = KEY_WPS_BUTTON,
  9842. + .debounce_interval = DIR825C1_KEYS_DEBOUNCE_INTERVAL,
  9843. + .gpio = DIR825C1_GPIO_BTN_WPS,
  9844. + .active_low = 1,
  9845. + },
  9846. +};
  9847. +
  9848. +static struct ar8327_pad_cfg dir825c1_ar8327_pad0_cfg = {
  9849. + .mode = AR8327_PAD_MAC_RGMII,
  9850. + .txclk_delay_en = true,
  9851. + .rxclk_delay_en = true,
  9852. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  9853. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  9854. +};
  9855. +
  9856. +static struct ar8327_led_cfg dir825c1_ar8327_led_cfg = {
  9857. + .led_ctrl0 = 0x00000000,
  9858. + .led_ctrl1 = 0xc737c737,
  9859. + .led_ctrl2 = 0x00000000,
  9860. + .led_ctrl3 = 0x00c30c00,
  9861. + .open_drain = true,
  9862. +};
  9863. +
  9864. +static struct ar8327_platform_data dir825c1_ar8327_data = {
  9865. + .pad0_cfg = &dir825c1_ar8327_pad0_cfg,
  9866. + .port0_cfg = {
  9867. + .force_link = 1,
  9868. + .speed = AR8327_PORT_SPEED_1000,
  9869. + .duplex = 1,
  9870. + .txpause = 1,
  9871. + .rxpause = 1,
  9872. + },
  9873. + .led_cfg = &dir825c1_ar8327_led_cfg,
  9874. +};
  9875. +
  9876. +static struct mdio_board_info dir825c1_mdio0_info[] = {
  9877. + {
  9878. + .bus_id = "ag71xx-mdio.0",
  9879. + .phy_addr = 0,
  9880. + .platform_data = &dir825c1_ar8327_data,
  9881. + },
  9882. +};
  9883. +
  9884. +static void __init dir825c1_generic_setup(void)
  9885. +{
  9886. + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
  9887. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  9888. + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
  9889. + u8 wmac0[ETH_ALEN], wmac1[ETH_ALEN];
  9890. +
  9891. + ath79_parse_ascii_mac(mac + DIR825C1_MAC0_OFFSET, mac0);
  9892. + ath79_parse_ascii_mac(mac + DIR825C1_MAC1_OFFSET, mac1);
  9893. +
  9894. + ath79_register_m25p80(NULL);
  9895. +
  9896. + ath79_register_gpio_keys_polled(-1, DIR825C1_KEYS_POLL_INTERVAL,
  9897. + ARRAY_SIZE(dir825c1_gpio_keys),
  9898. + dir825c1_gpio_keys);
  9899. +
  9900. + ath79_init_mac(wmac0, mac0, 0);
  9901. + ath79_register_wmac(art + DIR825C1_WMAC_CALDATA_OFFSET, wmac0);
  9902. +
  9903. + ath79_init_mac(wmac1, mac1, 1);
  9904. + ap91_pci_init(art + DIR825C1_PCIE_CALDATA_OFFSET, wmac1);
  9905. +
  9906. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  9907. +
  9908. + mdiobus_register_board_info(dir825c1_mdio0_info,
  9909. + ARRAY_SIZE(dir825c1_mdio0_info));
  9910. +
  9911. + ath79_register_mdio(0, 0x0);
  9912. +
  9913. + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  9914. +
  9915. + /* GMAC0 is connected to an AR8327N switch */
  9916. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  9917. + ath79_eth0_data.phy_mask = BIT(0);
  9918. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  9919. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  9920. + ath79_register_eth(0);
  9921. +
  9922. + ath79_register_usb();
  9923. +}
  9924. +
  9925. +static void __init dir825c1_setup(void)
  9926. +{
  9927. + ath79_gpio_output_select(DIR825C1_GPIO_LED_BLUE_USB,
  9928. + AR934X_GPIO_OUT_GPIO);
  9929. +
  9930. + gpio_request_one(DIR825C1_GPIO_WAN_LED_ENABLE,
  9931. + GPIOF_OUT_INIT_LOW, "WAN LED enable");
  9932. +
  9933. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir825c1_leds_gpio),
  9934. + dir825c1_leds_gpio);
  9935. +
  9936. + ap9x_pci_setup_wmac_led_pin(0, 0);
  9937. +
  9938. + dir825c1_generic_setup();
  9939. +}
  9940. +
  9941. +static void __init dir835a1_setup(void)
  9942. +{
  9943. + dir825c1_ar8327_data.led_cfg = NULL;
  9944. +
  9945. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir835a1_leds_gpio),
  9946. + dir835a1_leds_gpio);
  9947. +
  9948. + dir825c1_generic_setup();
  9949. +}
  9950. +
  9951. +MIPS_MACHINE(ATH79_MACH_DIR_825_C1, "DIR-825-C1",
  9952. + "D-Link DIR-825 rev. C1",
  9953. + dir825c1_setup);
  9954. +
  9955. +MIPS_MACHINE(ATH79_MACH_DIR_835_A1, "DIR-835-A1",
  9956. + "D-Link DIR-835 rev. A1",
  9957. + dir835a1_setup);
  9958. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dlan-hotspot.c linux-4.1.13/arch/mips/ath79/mach-dlan-hotspot.c
  9959. --- linux-4.1.13.orig/arch/mips/ath79/mach-dlan-hotspot.c 1970-01-01 01:00:00.000000000 +0100
  9960. +++ linux-4.1.13/arch/mips/ath79/mach-dlan-hotspot.c 2015-12-04 18:27:35.457807850 +0100
  9961. @@ -0,0 +1,117 @@
  9962. +/*
  9963. + * devolo dLAN Hotspot board support
  9964. + *
  9965. + * Copyright (C) 2015 Torsten Schnuis <torsten.schnuis@gik.de>
  9966. + * Copyright (C) 2015 devolo AG
  9967. + *
  9968. + * This program is free software; you can redistribute it and/or modify it
  9969. + * under the terms of the GNU General Public License version 2 as published
  9970. + * by the Free Software Foundation.
  9971. + */
  9972. +
  9973. +#include <linux/gpio.h>
  9974. +
  9975. +#include <asm/mach-ath79/ath79.h>
  9976. +
  9977. +#include "dev-eth.h"
  9978. +#include "dev-gpio-buttons.h"
  9979. +#include "dev-leds-gpio.h"
  9980. +#include "dev-m25p80.h"
  9981. +#include "dev-usb.h"
  9982. +#include "dev-wmac.h"
  9983. +#include "machtypes.h"
  9984. +
  9985. +#define DLAN_HOTSPOT_GPIO_LED_WIFI 0
  9986. +
  9987. +#define DLAN_HOTSPOT_GPIO_BTN_RESET 11
  9988. +#define DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING 12
  9989. +#define DLAN_HOTSPOT_GPIO_BTN_WIFI 21
  9990. +
  9991. +#define DLAN_HOTSPOT_GPIO_PLC_POWER 22
  9992. +#define DLAN_HOTSPOT_GPIO_PLC_RESET 20
  9993. +#define DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS 18
  9994. +
  9995. +#define DLAN_HOTSPOT_KEYS_POLL_INTERVAL 20 /* msecs */
  9996. +#define DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_HOTSPOT_KEYS_POLL_INTERVAL)
  9997. +
  9998. +#define DLAN_HOTSPOT_ART_ADDRESS 0x1fff0000
  9999. +#define DLAN_HOTSPOT_CALDATA_OFFSET 0x00001000
  10000. +#define DLAN_HOTSPOT_MAC_ADDRESS_OFFSET 0x00001002
  10001. +
  10002. +static struct gpio_led dlan_hotspot_leds_gpio[] __initdata = {
  10003. + {
  10004. + .name = "devolo:green:wifi",
  10005. + .gpio = DLAN_HOTSPOT_GPIO_LED_WIFI,
  10006. + .active_low = 0,
  10007. + }
  10008. +};
  10009. +
  10010. +static struct gpio_keys_button dlan_hotspot_gpio_keys[] __initdata = {
  10011. + {
  10012. + .desc = "Reset button",
  10013. + .type = EV_KEY,
  10014. + .code = KEY_RESTART,
  10015. + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  10016. + .gpio = DLAN_HOTSPOT_GPIO_BTN_RESET,
  10017. + .active_low = 0,
  10018. + },
  10019. + {
  10020. + .desc = "Pairing button",
  10021. + .type = EV_KEY,
  10022. + .code = BTN_0,
  10023. + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  10024. + .gpio = DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING,
  10025. + .active_low = 0,
  10026. + },
  10027. + {
  10028. + .desc = "WLAN button",
  10029. + .type = EV_KEY,
  10030. + .code = KEY_WPS_BUTTON,
  10031. + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  10032. + .gpio = DLAN_HOTSPOT_GPIO_BTN_WIFI,
  10033. + .active_low = 0,
  10034. + }
  10035. +};
  10036. +
  10037. +static void __init dlan_hotspot_setup(void)
  10038. +{
  10039. + u8 *art = (u8 *) KSEG1ADDR(DLAN_HOTSPOT_ART_ADDRESS);
  10040. + u8 *cal = art + DLAN_HOTSPOT_CALDATA_OFFSET;
  10041. + u8 *wifi_mac = art + DLAN_HOTSPOT_MAC_ADDRESS_OFFSET;
  10042. +
  10043. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  10044. + ath79_setup_ar933x_phy4_switch(false, false);
  10045. +
  10046. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_hotspot_leds_gpio),
  10047. + dlan_hotspot_leds_gpio);
  10048. +
  10049. + ath79_register_gpio_keys_polled(-1, DLAN_HOTSPOT_KEYS_POLL_INTERVAL,
  10050. + ARRAY_SIZE(dlan_hotspot_gpio_keys),
  10051. + dlan_hotspot_gpio_keys);
  10052. +
  10053. + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_POWER,
  10054. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  10055. + "PLC power");
  10056. + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_RESET,
  10057. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  10058. + "PLC reset");
  10059. + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS,
  10060. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  10061. + "PLC LEDs");
  10062. +
  10063. + ath79_register_usb();
  10064. +
  10065. + ath79_register_m25p80(NULL);
  10066. +
  10067. + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 1);
  10068. + ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 2);
  10069. +
  10070. + ath79_register_mdio(0, 0x0);
  10071. + ath79_register_eth(0);
  10072. + ath79_register_eth(1);
  10073. +
  10074. + ath79_register_wmac(cal, wifi_mac);
  10075. +}
  10076. +
  10077. +MIPS_MACHINE(ATH79_MACH_DLAN_HOTSPOT, "dLAN-Hotspot",
  10078. + "dLAN Hotspot", dlan_hotspot_setup);
  10079. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dlan-pro-1200-ac.c linux-4.1.13/arch/mips/ath79/mach-dlan-pro-1200-ac.c
  10080. --- linux-4.1.13.orig/arch/mips/ath79/mach-dlan-pro-1200-ac.c 1970-01-01 01:00:00.000000000 +0100
  10081. +++ linux-4.1.13/arch/mips/ath79/mach-dlan-pro-1200-ac.c 2015-09-13 20:04:35.068524086 +0200
  10082. @@ -0,0 +1,189 @@
  10083. +/*
  10084. + * devolo dLAN pro 500 Wireless+ support
  10085. + *
  10086. + * Copyright (c) 2013-2015 devolo AG
  10087. + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  10088. + *
  10089. + * Permission to use, copy, modify, and/or distribute this software for any
  10090. + * purpose with or without fee is hereby granted, provided that the above
  10091. + * copyright notice and this permission notice appear in all copies.
  10092. + *
  10093. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10094. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10095. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10096. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10097. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  10098. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  10099. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  10100. + *
  10101. + */
  10102. +
  10103. +#include <linux/pci.h>
  10104. +#include <linux/phy.h>
  10105. +#include <linux/platform_device.h>
  10106. +#include <linux/ath9k_platform.h>
  10107. +#include <linux/ar8216_platform.h>
  10108. +#include <linux/gpio.h>
  10109. +
  10110. +#include <asm/mach-ath79/ar71xx_regs.h>
  10111. +
  10112. +#include "common.h"
  10113. +#include "dev-ap9x-pci.h"
  10114. +#include "dev-eth.h"
  10115. +#include "dev-gpio-buttons.h"
  10116. +#include "dev-leds-gpio.h"
  10117. +#include "dev-m25p80.h"
  10118. +#include "dev-nfc.h"
  10119. +#include "dev-spi.h"
  10120. +#include "dev-wmac.h"
  10121. +#include "machtypes.h"
  10122. +
  10123. +#define DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE 13
  10124. +#define DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE 21
  10125. +#define DLAN_PRO_1200_AC_GPIO_LED_WLAN 12
  10126. +#define DLAN_PRO_1200_AC_GPIO_LED_DLAN 14
  10127. +#define DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR 15
  10128. +
  10129. +#define DLAN_PRO_1200_AC_GPIO_BTN_WLAN 20
  10130. +#define DLAN_PRO_1200_AC_GPIO_BTN_DLAN 22
  10131. +#define DLAN_PRO_1200_AC_GPIO_BTN_RESET 4
  10132. +#define DLAN_PRO_1200_AC_GPIO_DLAN_IND 17
  10133. +#define DLAN_PRO_1200_AC_GPIO_DLAN_ERR_IND 16
  10134. +
  10135. +#define DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL 20 /* msecs */
  10136. +#define DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL)
  10137. +
  10138. +#define DLAN_PRO_1200_AC_ART_ADDRESS 0x1fff0000
  10139. +#define DLAN_PRO_1200_AC_CALDATA_OFFSET 0x1000
  10140. +#define DLAN_PRO_1200_AC_WIFIMAC_OFFSET 0x1002
  10141. +#define DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET 0x5000
  10142. +
  10143. +static struct gpio_led dlan_pro_1200_ac_leds_gpio[] __initdata = {
  10144. + {
  10145. + .name = "devolo:status:wlan",
  10146. + .gpio = DLAN_PRO_1200_AC_GPIO_LED_WLAN,
  10147. + .active_low = 1,
  10148. + },
  10149. + {
  10150. + .name = "devolo:status:dlan",
  10151. + .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN,
  10152. + .active_low = 1,
  10153. + },
  10154. + {
  10155. + .name = "devolo:error:dlan",
  10156. + .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR,
  10157. + .active_low = 0,
  10158. + }
  10159. +};
  10160. +
  10161. +static struct gpio_keys_button dlan_pro_1200_ac_gpio_keys[] __initdata = {
  10162. + {
  10163. + .desc = "dLAN button",
  10164. + .type = EV_KEY,
  10165. + .code = BTN_0,
  10166. + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  10167. + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_DLAN,
  10168. + .active_low = 1,
  10169. + },
  10170. + {
  10171. + .desc = "WLAN button",
  10172. + .type = EV_KEY,
  10173. + .code = KEY_WPS_BUTTON,
  10174. + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  10175. + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_WLAN,
  10176. + .active_low = 0,
  10177. + },
  10178. + {
  10179. + .desc = "Reset button",
  10180. + .type = EV_KEY,
  10181. + .code = KEY_RESTART,
  10182. + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  10183. + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_RESET,
  10184. + .active_low = 1,
  10185. + }
  10186. +};
  10187. +
  10188. +static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad0_cfg = {
  10189. + .mode = AR8327_PAD_MAC_RGMII,
  10190. + .txclk_delay_en = true,
  10191. + .rxclk_delay_en = false,
  10192. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  10193. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  10194. +};
  10195. +
  10196. +static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad5_cfg = {
  10197. + .mode = 0,
  10198. + .txclk_delay_en = 0,
  10199. + .rxclk_delay_en = 0,
  10200. + .txclk_delay_sel = 0,
  10201. + .rxclk_delay_sel = 0,
  10202. +};
  10203. +
  10204. +static struct ar8327_platform_data dlan_pro_1200_ac_ar8327_data = {
  10205. + .pad0_cfg = &dlan_pro_1200_ac_ar8327_pad0_cfg,
  10206. + .pad5_cfg = &dlan_pro_1200_ac_ar8327_pad5_cfg,
  10207. + .port0_cfg = {
  10208. + .force_link = 1,
  10209. + .speed = AR8327_PORT_SPEED_1000,
  10210. + .duplex = 1,
  10211. + .txpause = 1,
  10212. + .rxpause = 1,
  10213. + },
  10214. +};
  10215. +
  10216. +static struct mdio_board_info dlan_pro_1200_ac_mdio0_info[] = {
  10217. + {
  10218. + .bus_id = "ag71xx-mdio.0",
  10219. + .phy_addr = 0,
  10220. + .platform_data = &dlan_pro_1200_ac_ar8327_data,
  10221. + },
  10222. +};
  10223. +
  10224. +static void __init dlan_pro_1200_ac_setup(void)
  10225. +{
  10226. + u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_1200_AC_ART_ADDRESS);
  10227. + u8 *cal = art + DLAN_PRO_1200_AC_CALDATA_OFFSET;
  10228. + u8 *wifi_mac = art + DLAN_PRO_1200_AC_WIFIMAC_OFFSET;
  10229. +
  10230. + ath79_register_m25p80(NULL);
  10231. +
  10232. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_1200_ac_leds_gpio),
  10233. + dlan_pro_1200_ac_leds_gpio);
  10234. +
  10235. + ath79_register_gpio_keys_polled(-1, DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL,
  10236. + ARRAY_SIZE(dlan_pro_1200_ac_gpio_keys),
  10237. + dlan_pro_1200_ac_gpio_keys);
  10238. +
  10239. + /* dLAN power must be enabled from user-space as soon as the boot-from-host daemon is running */
  10240. + gpio_request_one(DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE,
  10241. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  10242. + "dLAN power");
  10243. +
  10244. + /* WLAN power is turned on initially to allow the PCI bus scan to succeed */
  10245. + gpio_request_one(DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE,
  10246. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  10247. + "WLAN power");
  10248. +
  10249. + ath79_register_wmac(cal, wifi_mac);
  10250. + ap91_pci_init(art + DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET, NULL);
  10251. +
  10252. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE);
  10253. +
  10254. + ath79_register_mdio(1, 0x0);
  10255. + ath79_register_mdio(0, 0x0);
  10256. +
  10257. + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
  10258. +
  10259. + mdiobus_register_board_info(dlan_pro_1200_ac_mdio0_info,
  10260. + ARRAY_SIZE(dlan_pro_1200_ac_mdio0_info));
  10261. +
  10262. + /* GMAC0 is connected to an AR8337 */
  10263. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  10264. + ath79_eth0_data.phy_mask = BIT(0);
  10265. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  10266. + ath79_eth0_pll_data.pll_1000 = 0x02000000;
  10267. + ath79_register_eth(0);
  10268. +}
  10269. +
  10270. +MIPS_MACHINE(ATH79_MACH_DLAN_PRO_1200_AC, "dLAN-pro-1200-ac", "devolo dLAN pro 1200+ WiFi ac",
  10271. + dlan_pro_1200_ac_setup);
  10272. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dlan-pro-500-wp.c linux-4.1.13/arch/mips/ath79/mach-dlan-pro-500-wp.c
  10273. --- linux-4.1.13.orig/arch/mips/ath79/mach-dlan-pro-500-wp.c 1970-01-01 01:00:00.000000000 +0100
  10274. +++ linux-4.1.13/arch/mips/ath79/mach-dlan-pro-500-wp.c 2015-09-13 20:04:35.068524086 +0200
  10275. @@ -0,0 +1,203 @@
  10276. +/*
  10277. + * devolo dLAN pro 500 Wireless+ support
  10278. + *
  10279. + * Copyright (c) 2013-2015 devolo AG
  10280. + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  10281. + *
  10282. + * Permission to use, copy, modify, and/or distribute this software for any
  10283. + * purpose with or without fee is hereby granted, provided that the above
  10284. + * copyright notice and this permission notice appear in all copies.
  10285. + *
  10286. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10287. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10288. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10289. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10290. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  10291. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  10292. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  10293. + *
  10294. + */
  10295. +
  10296. +#include <linux/pci.h>
  10297. +#include <linux/phy.h>
  10298. +#include <linux/platform_device.h>
  10299. +#include <linux/ath9k_platform.h>
  10300. +#include <linux/ar8216_platform.h>
  10301. +#include <linux/gpio.h>
  10302. +
  10303. +#include <asm/mach-ath79/ar71xx_regs.h>
  10304. +
  10305. +#include "common.h"
  10306. +#include "dev-ap9x-pci.h"
  10307. +#include "dev-eth.h"
  10308. +#include "dev-gpio-buttons.h"
  10309. +#include "dev-leds-gpio.h"
  10310. +#include "dev-m25p80.h"
  10311. +#include "dev-spi.h"
  10312. +#include "dev-wmac.h"
  10313. +#include "machtypes.h"
  10314. +
  10315. +#define DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE 13
  10316. +#define DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE 17
  10317. +#define DLAN_PRO_500_WP_GPIO_LED_WLAN_5G 11
  10318. +#define DLAN_PRO_500_WP_GPIO_LED_WLAN_2G 12
  10319. +#define DLAN_PRO_500_WP_GPIO_LED_STATUS 16
  10320. +#define DLAN_PRO_500_WP_GPIO_LED_ETH 14
  10321. +
  10322. +#define DLAN_PRO_500_WP_GPIO_BTN_WPS 20
  10323. +#define DLAN_PRO_500_WP_GPIO_BTN_WLAN 22
  10324. +#define DLAN_PRO_500_WP_GPIO_BTN_DLAN 21
  10325. +#define DLAN_PRO_500_WP_GPIO_BTN_RESET 4
  10326. +
  10327. +#define DLAN_PRO_500_WP_KEYS_POLL_INTERVAL 20 /* msecs */
  10328. +#define DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_500_WP_KEYS_POLL_INTERVAL)
  10329. +
  10330. +#define DLAN_PRO_500_WP_ART_ADDRESS 0x1fff0000
  10331. +#define DLAN_PRO_500_WP_CALDATA_OFFSET 0x1000
  10332. +#define DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET 0x1002
  10333. +#define DLAN_PRO_500_WP_PCIE_CALDATA_OFFSET 0x5000
  10334. +
  10335. +static struct gpio_led dlan_pro_500_wp_leds_gpio[] __initdata = {
  10336. + {
  10337. + .name = "devolo:green:status",
  10338. + .gpio = DLAN_PRO_500_WP_GPIO_LED_STATUS,
  10339. + .active_low = 1,
  10340. + },
  10341. + {
  10342. + .name = "devolo:green:eth",
  10343. + .gpio = DLAN_PRO_500_WP_GPIO_LED_ETH,
  10344. + .active_low = 1,
  10345. + },
  10346. + {
  10347. + .name = "devolo:blue:wlan-5g",
  10348. + .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_5G,
  10349. + .active_low = 1,
  10350. + },
  10351. + {
  10352. + .name = "devolo:green:wlan-2g",
  10353. + .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_2G,
  10354. + .active_low = 1,
  10355. + }
  10356. +};
  10357. +
  10358. +static struct gpio_keys_button dlan_pro_500_wp_gpio_keys[] __initdata = {
  10359. + {
  10360. + .desc = "dLAN button",
  10361. + .type = EV_KEY,
  10362. + .code = BTN_0,
  10363. + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  10364. + .gpio = DLAN_PRO_500_WP_GPIO_BTN_DLAN,
  10365. + .active_low = 0,
  10366. + },
  10367. + {
  10368. + .desc = "WPS button",
  10369. + .type = EV_KEY,
  10370. + .code = KEY_WPS_BUTTON,
  10371. + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  10372. + .gpio = DLAN_PRO_500_WP_GPIO_BTN_WPS,
  10373. + .active_low = 0,
  10374. + },
  10375. + {
  10376. + .desc = "WLAN button",
  10377. + .type = EV_KEY,
  10378. + .code = BTN_2,
  10379. + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  10380. + .gpio = DLAN_PRO_500_WP_GPIO_BTN_WLAN,
  10381. + .active_low = 1,
  10382. + },
  10383. + {
  10384. + .desc = "Reset button",
  10385. + .type = EV_KEY,
  10386. + .code = KEY_RESTART,
  10387. + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  10388. + .gpio = DLAN_PRO_500_WP_GPIO_BTN_RESET,
  10389. + .active_low = 1,
  10390. + }
  10391. +};
  10392. +
  10393. +static struct ar8327_pad_cfg dlan_pro_500_wp_ar8327_pad0_cfg = {
  10394. + .mode = AR8327_PAD_PHY_RGMII,
  10395. + .txclk_delay_en = false,
  10396. + .rxclk_delay_en = false,
  10397. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  10398. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  10399. +};
  10400. +
  10401. +static struct ar8327_led_cfg dlan_pro_500_wp_ar8327_led_cfg = {
  10402. + .led_ctrl0 = 0x00000000,
  10403. + .led_ctrl1 = 0xc737c737,
  10404. + .led_ctrl2 = 0x00000000,
  10405. + .led_ctrl3 = 0x00c30c00,
  10406. + .open_drain = true,
  10407. +};
  10408. +
  10409. +static struct ar8327_platform_data dlan_pro_500_wp_ar8327_data = {
  10410. + .pad0_cfg = &dlan_pro_500_wp_ar8327_pad0_cfg,
  10411. + .port0_cfg = {
  10412. + .force_link = 1,
  10413. + .speed = AR8327_PORT_SPEED_1000,
  10414. + .duplex = 1,
  10415. + .txpause = 0,
  10416. + .rxpause = 0,
  10417. + },
  10418. + .led_cfg = &dlan_pro_500_wp_ar8327_led_cfg,
  10419. +};
  10420. +
  10421. +static struct mdio_board_info dlan_pro_500_wp_mdio0_info[] = {
  10422. + {
  10423. + .bus_id = "ag71xx-mdio.0",
  10424. + .phy_addr = 0,
  10425. + .platform_data = &dlan_pro_500_wp_ar8327_data,
  10426. + },
  10427. +};
  10428. +
  10429. +static void __init dlan_pro_500_wp_setup(void)
  10430. +{
  10431. + u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_500_WP_ART_ADDRESS);
  10432. + u8 *cal = art + DLAN_PRO_500_WP_CALDATA_OFFSET;
  10433. + u8 *wifi_mac = art + DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET;
  10434. +
  10435. + ath79_register_m25p80(NULL);
  10436. +
  10437. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_500_wp_leds_gpio),
  10438. + dlan_pro_500_wp_leds_gpio);
  10439. +
  10440. + ath79_register_gpio_keys_polled(-1, DLAN_PRO_500_WP_KEYS_POLL_INTERVAL,
  10441. + ARRAY_SIZE(dlan_pro_500_wp_gpio_keys),
  10442. + dlan_pro_500_wp_gpio_keys);
  10443. +
  10444. + gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE,
  10445. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  10446. + "PLC power");
  10447. + gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE,
  10448. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  10449. + "PLC LEDs");
  10450. +
  10451. + ath79_register_wmac(cal, wifi_mac);
  10452. +
  10453. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  10454. +
  10455. + ath79_register_mdio(1, 0x0);
  10456. + ath79_register_mdio(0, 0x0);
  10457. +
  10458. + mdiobus_register_board_info(dlan_pro_500_wp_mdio0_info,
  10459. + ARRAY_SIZE(dlan_pro_500_wp_mdio0_info));
  10460. +
  10461. + /* GMAC0 is connected to a AR7400 PLC in PHY mode */
  10462. + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
  10463. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  10464. + ath79_eth0_pll_data.pll_1000 = 0x0e000000;
  10465. + ath79_eth0_data.speed = SPEED_1000;
  10466. + ath79_eth0_data.duplex = DUPLEX_FULL;
  10467. + ath79_register_eth(0);
  10468. +
  10469. + /* GMAC1 is connected to the internal switch */
  10470. + ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 1);
  10471. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  10472. + ath79_eth1_data.speed = SPEED_1000;
  10473. + ath79_eth1_data.duplex = DUPLEX_FULL;
  10474. + ath79_register_eth(1);
  10475. +}
  10476. +
  10477. +MIPS_MACHINE(ATH79_MACH_DLAN_PRO_500_WP, "dLAN-pro-500-wp", "devolo dLAN pro 500 Wireless+",
  10478. + dlan_pro_500_wp_setup);
  10479. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-dragino2.c linux-4.1.13/arch/mips/ath79/mach-dragino2.c
  10480. --- linux-4.1.13.orig/arch/mips/ath79/mach-dragino2.c 1970-01-01 01:00:00.000000000 +0100
  10481. +++ linux-4.1.13/arch/mips/ath79/mach-dragino2.c 2015-09-13 20:04:35.068524086 +0200
  10482. @@ -0,0 +1,136 @@
  10483. +/*
  10484. + * DRAGINO V2 board support, based on Atheros AP121 board support
  10485. + *
  10486. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  10487. + * Copyright (C) 2012 Elektra Wagenrad <elektra@villagetelco.org>
  10488. + * Copyright (C) 2014 Vittorio Gambaletta <openwrt@vittgam.net>
  10489. + *
  10490. + * This program is free software; you can redistribute it and/or modify it
  10491. + * under the terms of the GNU General Public License version 2 as published
  10492. + * by the Free Software Foundation.
  10493. + */
  10494. +
  10495. +#include <linux/gpio.h>
  10496. +#include <asm/mach-ath79/ath79.h>
  10497. +#include <asm/mach-ath79/ar71xx_regs.h>
  10498. +#include "common.h"
  10499. +#include "dev-eth.h"
  10500. +#include "dev-gpio-buttons.h"
  10501. +#include "dev-leds-gpio.h"
  10502. +#include "dev-m25p80.h"
  10503. +#include "dev-spi.h"
  10504. +#include "dev-usb.h"
  10505. +#include "dev-wmac.h"
  10506. +#include "machtypes.h"
  10507. +
  10508. +#define DRAGINO2_GPIO_LED_WLAN 0
  10509. +#define DRAGINO2_GPIO_LED_LAN 13
  10510. +#define DRAGINO2_GPIO_LED_WAN 17
  10511. +
  10512. +/*
  10513. + * The following GPIO is named "SYS" on newer revisions of the the board.
  10514. + * It was previously used to indicate USB activity, even though it was
  10515. + * named "Router".
  10516. + */
  10517. +
  10518. +#define DRAGINO2_GPIO_LED_SYS 28
  10519. +#define DRAGINO2_GPIO_BTN_JUMPSTART 11
  10520. +#define DRAGINO2_GPIO_BTN_RESET 12
  10521. +
  10522. +#define DRAGINO2_KEYS_POLL_INTERVAL 20 /* msecs */
  10523. +#define DRAGINO2_KEYS_DEBOUNCE_INTERVAL (3 * DRAGINO2_KEYS_POLL_INTERVAL)
  10524. +
  10525. +#define DRAGINO2_MAC0_OFFSET 0x0000
  10526. +#define DRAGINO2_MAC1_OFFSET 0x0006
  10527. +#define DRAGINO2_CALDATA_OFFSET 0x1000
  10528. +#define DRAGINO2_WMAC_MAC_OFFSET 0x1002
  10529. +
  10530. +static struct gpio_led dragino2_leds_gpio[] __initdata = {
  10531. + {
  10532. + .name = "dragino2:red:wlan",
  10533. + .gpio = DRAGINO2_GPIO_LED_WLAN,
  10534. + .active_low = 0,
  10535. + },
  10536. + {
  10537. + .name = "dragino2:red:wan",
  10538. + .gpio = DRAGINO2_GPIO_LED_WAN,
  10539. + .active_low = 1,
  10540. + },
  10541. + {
  10542. + .name = "dragino2:red:lan",
  10543. + .gpio = DRAGINO2_GPIO_LED_LAN,
  10544. + .active_low = 1,
  10545. + },
  10546. + {
  10547. + .name = "dragino2:red:system",
  10548. + .gpio = DRAGINO2_GPIO_LED_SYS,
  10549. + .active_low = 0,
  10550. + },
  10551. +};
  10552. +
  10553. +static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
  10554. + {
  10555. + .desc = "jumpstart button",
  10556. + .type = EV_KEY,
  10557. + .code = KEY_WPS_BUTTON,
  10558. + .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
  10559. + .gpio = DRAGINO2_GPIO_BTN_JUMPSTART,
  10560. + .active_low = 1,
  10561. + },
  10562. + {
  10563. + .desc = "reset button",
  10564. + .type = EV_KEY,
  10565. + .code = KEY_RESTART,
  10566. + .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
  10567. + .gpio = DRAGINO2_GPIO_BTN_RESET,
  10568. + .active_low = 1,
  10569. + }
  10570. +};
  10571. +
  10572. +static void __init dragino2_common_setup(void)
  10573. +{
  10574. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  10575. +
  10576. + ath79_register_m25p80(NULL);
  10577. + ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
  10578. + art + DRAGINO2_WMAC_MAC_OFFSET);
  10579. +
  10580. + ath79_init_mac(ath79_eth0_data.mac_addr, art + DRAGINO2_MAC0_OFFSET, 0);
  10581. + ath79_init_mac(ath79_eth1_data.mac_addr, art + DRAGINO2_MAC1_OFFSET, 0);
  10582. +
  10583. + ath79_register_mdio(0, 0x0);
  10584. +
  10585. + /* Enable GPIO13, GPIO14, GPIO15, GPIO16 and GPIO17 */
  10586. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  10587. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  10588. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  10589. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  10590. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  10591. +
  10592. + /* LAN port */
  10593. + ath79_register_eth(1);
  10594. +
  10595. + /* WAN port */
  10596. + ath79_register_eth(0);
  10597. +
  10598. + /* Enable GPIO26 and GPIO27 */
  10599. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP,
  10600. + ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP) |
  10601. + AR933X_BOOTSTRAP_MDIO_GPIO_EN);
  10602. +}
  10603. +
  10604. +static void __init dragino2_setup(void)
  10605. +{
  10606. + dragino2_common_setup();
  10607. +
  10608. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dragino2_leds_gpio),
  10609. + dragino2_leds_gpio);
  10610. + ath79_register_gpio_keys_polled(-1, DRAGINO2_KEYS_POLL_INTERVAL,
  10611. + ARRAY_SIZE(dragino2_gpio_keys),
  10612. + dragino2_gpio_keys);
  10613. + ath79_register_usb();
  10614. +}
  10615. +
  10616. +MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",
  10617. + dragino2_setup);
  10618. +
  10619. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-eap300v2.c linux-4.1.13/arch/mips/ath79/mach-eap300v2.c
  10620. --- linux-4.1.13.orig/arch/mips/ath79/mach-eap300v2.c 1970-01-01 01:00:00.000000000 +0100
  10621. +++ linux-4.1.13/arch/mips/ath79/mach-eap300v2.c 2015-09-13 20:04:35.068524086 +0200
  10622. @@ -0,0 +1,101 @@
  10623. +/*
  10624. + * EnGenius EAP300 v2 board support
  10625. + *
  10626. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  10627. + *
  10628. + * This program is free software; you can redistribute it and/or modify it
  10629. + * under the terms of the GNU General Public License version 2 as published
  10630. + * by the Free Software Foundation.
  10631. + */
  10632. +
  10633. +#include <linux/gpio.h>
  10634. +#include <linux/mtd/mtd.h>
  10635. +#include <linux/mtd/partitions.h>
  10636. +#include <linux/platform_device.h>
  10637. +
  10638. +#include <asm/mach-ath79/ar71xx_regs.h>
  10639. +#include <asm/mach-ath79/ath79.h>
  10640. +
  10641. +#include "common.h"
  10642. +#include "dev-eth.h"
  10643. +#include "dev-gpio-buttons.h"
  10644. +#include "dev-leds-gpio.h"
  10645. +#include "dev-m25p80.h"
  10646. +#include "dev-wmac.h"
  10647. +#include "machtypes.h"
  10648. +
  10649. +#define EAP300V2_GPIO_LED_POWER 0
  10650. +#define EAP300V2_GPIO_LED_LAN 16
  10651. +#define EAP300V2_GPIO_LED_WLAN 17
  10652. +
  10653. +#define EAP300V2_GPIO_BTN_RESET 1
  10654. +
  10655. +#define EAP300V2_KEYS_POLL_INTERVAL 20 /* msecs */
  10656. +#define EAP300V2_KEYS_DEBOUNCE_INTERVAL (3 * EAP300V2_KEYS_POLL_INTERVAL)
  10657. +
  10658. +static struct gpio_led eap300v2_leds_gpio[] __initdata = {
  10659. + {
  10660. + .name = "engenius:blue:power",
  10661. + .gpio = EAP300V2_GPIO_LED_POWER,
  10662. + .active_low = 1,
  10663. + }, {
  10664. + .name = "engenius:blue:lan",
  10665. + .gpio = EAP300V2_GPIO_LED_LAN,
  10666. + .active_low = 1,
  10667. + }, {
  10668. + .name = "engenius:blue:wlan",
  10669. + .gpio = EAP300V2_GPIO_LED_WLAN,
  10670. + .active_low = 1,
  10671. + }
  10672. +};
  10673. +
  10674. +static struct gpio_keys_button eap300v2_gpio_keys[] __initdata = {
  10675. + {
  10676. + .desc = "reset",
  10677. + .type = EV_KEY,
  10678. + .code = KEY_RESTART,
  10679. + .debounce_interval = EAP300V2_KEYS_DEBOUNCE_INTERVAL,
  10680. + .gpio = EAP300V2_GPIO_BTN_RESET,
  10681. + .active_low = 1,
  10682. + }
  10683. +};
  10684. +
  10685. +#define EAP300V2_ART_MAC_OFFSET 2
  10686. +
  10687. +#define EAP300V2_LAN_PHYMASK BIT(0)
  10688. +
  10689. +static void __init eap300v2_setup(void)
  10690. +{
  10691. + u8 *art = (u8 *)KSEG1ADDR(0x1fff1000);
  10692. +
  10693. + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  10694. +
  10695. + ath79_gpio_output_select(EAP300V2_GPIO_LED_POWER, AR934X_GPIO_OUT_GPIO);
  10696. + ath79_gpio_output_select(EAP300V2_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  10697. + ath79_gpio_output_select(EAP300V2_GPIO_LED_WLAN, AR934X_GPIO_OUT_GPIO);
  10698. +
  10699. + ath79_register_leds_gpio(-1, ARRAY_SIZE(eap300v2_leds_gpio),
  10700. + eap300v2_leds_gpio);
  10701. + ath79_register_gpio_keys_polled(-1, EAP300V2_KEYS_POLL_INTERVAL,
  10702. + ARRAY_SIZE(eap300v2_gpio_keys),
  10703. + eap300v2_gpio_keys);
  10704. +
  10705. + ath79_register_m25p80(NULL);
  10706. + ath79_register_wmac(art, NULL);
  10707. + ath79_register_mdio(1, 0x0);
  10708. +
  10709. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  10710. +
  10711. + ath79_init_mac(ath79_eth0_data.mac_addr,
  10712. + art + EAP300V2_ART_MAC_OFFSET, 0);
  10713. +
  10714. + ath79_switch_data.phy4_mii_en = 1;
  10715. + ath79_switch_data.phy_poll_mask = EAP300V2_LAN_PHYMASK;
  10716. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  10717. + ath79_eth0_data.phy_mask = EAP300V2_LAN_PHYMASK;
  10718. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  10719. + ath79_register_eth(0);
  10720. +}
  10721. +
  10722. +MIPS_MACHINE(ATH79_MACH_EAP300V2, "EAP300V2", "EnGenius EAP300 v2",
  10723. + eap300v2_setup);
  10724. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-eap7660d.c linux-4.1.13/arch/mips/ath79/mach-eap7660d.c
  10725. --- linux-4.1.13.orig/arch/mips/ath79/mach-eap7660d.c 1970-01-01 01:00:00.000000000 +0100
  10726. +++ linux-4.1.13/arch/mips/ath79/mach-eap7660d.c 2015-09-13 20:04:35.068524086 +0200
  10727. @@ -0,0 +1,181 @@
  10728. +/*
  10729. + * Senao EAP7660D board support
  10730. + *
  10731. + * Copyright (C) 2010 Daniel Golle <daniel.golle@gmail.com>
  10732. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  10733. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  10734. + *
  10735. + * This program is free software; you can redistribute it and/or modify it
  10736. + * under the terms of the GNU General Public License version 2 as published
  10737. + * by the Free Software Foundation.
  10738. + */
  10739. +
  10740. +#include <linux/pci.h>
  10741. +#include <linux/ath5k_platform.h>
  10742. +#include <linux/delay.h>
  10743. +
  10744. +#include <asm/mach-ath79/ath79.h>
  10745. +
  10746. +#include "dev-eth.h"
  10747. +#include "dev-gpio-buttons.h"
  10748. +#include "dev-leds-gpio.h"
  10749. +#include "dev-m25p80.h"
  10750. +#include "machtypes.h"
  10751. +#include "pci.h"
  10752. +
  10753. +#define EAP7660D_KEYS_POLL_INTERVAL 20 /* msecs */
  10754. +#define EAP7660D_KEYS_DEBOUNCE_INTERVAL (3 * EAP7660D_KEYS_POLL_INTERVAL)
  10755. +
  10756. +#define EAP7660D_GPIO_DS4 7
  10757. +#define EAP7660D_GPIO_DS5 2
  10758. +#define EAP7660D_GPIO_DS7 0
  10759. +#define EAP7660D_GPIO_DS8 4
  10760. +#define EAP7660D_GPIO_SW1 3
  10761. +#define EAP7660D_GPIO_SW3 8
  10762. +#define EAP7660D_PHYMASK BIT(20)
  10763. +#define EAP7660D_BOARDCONFIG 0x1F7F0000
  10764. +#define EAP7660D_GBIC_MAC_OFFSET 0x1000
  10765. +#define EAP7660D_WMAC0_MAC_OFFSET 0x1010
  10766. +#define EAP7660D_WMAC1_MAC_OFFSET 0x1016
  10767. +#define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
  10768. +#define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
  10769. +
  10770. +#ifdef CONFIG_PCI
  10771. +static struct ath5k_platform_data eap7660d_wmac0_data;
  10772. +static struct ath5k_platform_data eap7660d_wmac1_data;
  10773. +static char eap7660d_wmac0_mac[6];
  10774. +static char eap7660d_wmac1_mac[6];
  10775. +static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
  10776. +static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
  10777. +
  10778. +static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
  10779. +{
  10780. + switch (PCI_SLOT(dev->devfn)) {
  10781. + case 17:
  10782. + dev->dev.platform_data = &eap7660d_wmac0_data;
  10783. + break;
  10784. +
  10785. + case 18:
  10786. + dev->dev.platform_data = &eap7660d_wmac1_data;
  10787. + break;
  10788. + }
  10789. +
  10790. + return 0;
  10791. +}
  10792. +
  10793. +void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
  10794. + u8 *cal_data1, u8 *mac_addr1)
  10795. +{
  10796. + if (cal_data0 && *cal_data0 == 0xa55a) {
  10797. + memcpy(eap7660d_wmac0_eeprom, cal_data0,
  10798. + ATH5K_PLAT_EEP_MAX_WORDS);
  10799. + eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
  10800. + }
  10801. +
  10802. + if (cal_data1 && *cal_data1 == 0xa55a) {
  10803. + memcpy(eap7660d_wmac1_eeprom, cal_data1,
  10804. + ATH5K_PLAT_EEP_MAX_WORDS);
  10805. + eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
  10806. + }
  10807. +
  10808. + if (mac_addr0) {
  10809. + memcpy(eap7660d_wmac0_mac, mac_addr0,
  10810. + sizeof(eap7660d_wmac0_mac));
  10811. + eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
  10812. + }
  10813. +
  10814. + if (mac_addr1) {
  10815. + memcpy(eap7660d_wmac1_mac, mac_addr1,
  10816. + sizeof(eap7660d_wmac1_mac));
  10817. + eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
  10818. + }
  10819. +
  10820. + ath79_pci_set_plat_dev_init(eap7660d_pci_plat_dev_init);
  10821. + ath79_register_pci();
  10822. +}
  10823. +#else
  10824. +static inline void eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
  10825. + u8 *cal_data1, u8 *mac_addr1)
  10826. +{
  10827. +}
  10828. +#endif /* CONFIG_PCI */
  10829. +
  10830. +static struct gpio_led eap7660d_leds_gpio[] __initdata = {
  10831. + {
  10832. + .name = "eap7660d:green:ds8",
  10833. + .gpio = EAP7660D_GPIO_DS8,
  10834. + .active_low = 0,
  10835. + },
  10836. + {
  10837. + .name = "eap7660d:green:ds5",
  10838. + .gpio = EAP7660D_GPIO_DS5,
  10839. + .active_low = 0,
  10840. + },
  10841. + {
  10842. + .name = "eap7660d:green:ds7",
  10843. + .gpio = EAP7660D_GPIO_DS7,
  10844. + .active_low = 0,
  10845. + },
  10846. + {
  10847. + .name = "eap7660d:green:ds4",
  10848. + .gpio = EAP7660D_GPIO_DS4,
  10849. + .active_low = 0,
  10850. + }
  10851. +};
  10852. +
  10853. +static struct gpio_keys_button eap7660d_gpio_keys[] __initdata = {
  10854. + {
  10855. + .desc = "reset",
  10856. + .type = EV_KEY,
  10857. + .code = KEY_RESTART,
  10858. + .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
  10859. + .gpio = EAP7660D_GPIO_SW1,
  10860. + .active_low = 1,
  10861. + },
  10862. + {
  10863. + .desc = "wps",
  10864. + .type = EV_KEY,
  10865. + .code = KEY_WPS_BUTTON,
  10866. + .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
  10867. + .gpio = EAP7660D_GPIO_SW3,
  10868. + .active_low = 1,
  10869. + }
  10870. +};
  10871. +
  10872. +static const char *eap7660d_part_probes[] = {
  10873. + "RedBoot",
  10874. + NULL,
  10875. +};
  10876. +
  10877. +static struct flash_platform_data eap7660d_flash_data = {
  10878. + .part_probes = eap7660d_part_probes,
  10879. +};
  10880. +
  10881. +static void __init eap7660d_setup(void)
  10882. +{
  10883. + u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
  10884. +
  10885. + ath79_register_mdio(0, ~EAP7660D_PHYMASK);
  10886. +
  10887. + ath79_init_mac(ath79_eth0_data.mac_addr,
  10888. + boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
  10889. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  10890. + ath79_eth0_data.phy_mask = EAP7660D_PHYMASK;
  10891. + ath79_register_eth(0);
  10892. + ath79_register_m25p80(&eap7660d_flash_data);
  10893. + ath79_register_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
  10894. + eap7660d_leds_gpio);
  10895. + ath79_register_gpio_keys_polled(-1, EAP7660D_KEYS_POLL_INTERVAL,
  10896. + ARRAY_SIZE(eap7660d_gpio_keys),
  10897. + eap7660d_gpio_keys);
  10898. + eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
  10899. + boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
  10900. + boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
  10901. + boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
  10902. +};
  10903. +
  10904. +MIPS_MACHINE(ATH79_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",
  10905. + eap7660d_setup);
  10906. +
  10907. +MIPS_MACHINE(ATH79_MACH_ALL0305, "ALL0305", "Allnet ALL0305",
  10908. + eap7660d_setup);
  10909. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-el-m150.c linux-4.1.13/arch/mips/ath79/mach-el-m150.c
  10910. --- linux-4.1.13.orig/arch/mips/ath79/mach-el-m150.c 1970-01-01 01:00:00.000000000 +0100
  10911. +++ linux-4.1.13/arch/mips/ath79/mach-el-m150.c 2015-09-13 20:04:35.068524086 +0200
  10912. @@ -0,0 +1,112 @@
  10913. +/*
  10914. + * Easy-Link EL-M150 board support
  10915. + *
  10916. + * Copyright (C) 2012 huangfc <huangfangcheng@163.com>
  10917. + * Copyright (C) 2012 HYS <550663898@qq.com>
  10918. + *
  10919. + * This program is free software; you can redistribute it and/or modify it
  10920. + * under the terms of the GNU General Public License version 2 as published
  10921. + * by the Free Software Foundation.
  10922. + */
  10923. +
  10924. +#include <linux/gpio.h>
  10925. +
  10926. +#include <asm/mach-ath79/ath79.h>
  10927. +#include <asm/mach-ath79/ar71xx_regs.h>
  10928. +
  10929. +#include "common.h"
  10930. +#include "dev-eth.h"
  10931. +#include "dev-gpio-buttons.h"
  10932. +#include "dev-leds-gpio.h"
  10933. +#include "dev-m25p80.h"
  10934. +#include "dev-wmac.h"
  10935. +#include "machtypes.h"
  10936. +#include "dev-usb.h"
  10937. +
  10938. +#define EL_M150_GPIO_BTN6 6
  10939. +#define EL_M150_GPIO_BTN7 7
  10940. +#define EL_M150_GPIO_BTN_RESET 11
  10941. +
  10942. +#define EL_M150_GPIO_LED_SYSTEM 27
  10943. +#define EL_M150_GPIO_USB_POWER 8
  10944. +
  10945. +#define EL_M150_KEYS_POLL_INTERVAL 20 /* msecs */
  10946. +#define EL_M150_KEYS_DEBOUNCE_INTERVAL (3 * EL_M150_KEYS_POLL_INTERVAL)
  10947. +
  10948. +static const char *EL_M150_part_probes[] = {
  10949. + "tp-link",
  10950. + NULL,
  10951. +};
  10952. +
  10953. +static struct flash_platform_data EL_M150_flash_data = {
  10954. + .part_probes = EL_M150_part_probes,
  10955. +};
  10956. +
  10957. +static struct gpio_led EL_M150_leds_gpio[] __initdata = {
  10958. + {
  10959. + .name = "easylink:green:system",
  10960. + .gpio = EL_M150_GPIO_LED_SYSTEM,
  10961. + .active_low = 1,
  10962. + },
  10963. +};
  10964. +
  10965. +static struct gpio_keys_button EL_M150_gpio_keys[] __initdata = {
  10966. + {
  10967. + .desc = "reset",
  10968. + .type = EV_KEY,
  10969. + .code = KEY_RESTART,
  10970. + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
  10971. + .gpio = EL_M150_GPIO_BTN_RESET,
  10972. + .active_low = 0,
  10973. + },
  10974. + {
  10975. + .desc = "BTN_6",
  10976. + .type = EV_KEY,
  10977. + .code = BTN_6,
  10978. + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
  10979. + .gpio = EL_M150_GPIO_BTN6,
  10980. + .active_low = 1,
  10981. + },
  10982. + {
  10983. + .desc = "BTN_7",
  10984. + .type = EV_KEY,
  10985. + .code = BTN_7,
  10986. + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
  10987. + .gpio = EL_M150_GPIO_BTN7,
  10988. + .active_low = 1,
  10989. + },
  10990. +};
  10991. +
  10992. +static void __init el_m150_setup(void)
  10993. +{
  10994. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  10995. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  10996. +
  10997. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  10998. + ath79_setup_ar933x_phy4_switch(false, false);
  10999. +
  11000. + ath79_register_leds_gpio(-1, ARRAY_SIZE(EL_M150_leds_gpio),
  11001. + EL_M150_leds_gpio);
  11002. +
  11003. + ath79_register_gpio_keys_polled(-1, EL_M150_KEYS_POLL_INTERVAL,
  11004. + ARRAY_SIZE(EL_M150_gpio_keys),
  11005. + EL_M150_gpio_keys);
  11006. +
  11007. + gpio_request_one(EL_M150_GPIO_USB_POWER,
  11008. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  11009. + "USB power");
  11010. + ath79_register_usb();
  11011. +
  11012. + ath79_register_m25p80(&EL_M150_flash_data);
  11013. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  11014. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  11015. +
  11016. + ath79_register_mdio(0, 0x0);
  11017. + ath79_register_eth(0);
  11018. + ath79_register_eth(1);
  11019. +
  11020. + ath79_register_wmac(ee, mac);
  11021. +}
  11022. +
  11023. +MIPS_MACHINE(ATH79_MACH_EL_M150, "EL-M150",
  11024. + "EasyLink EL-M150", el_m150_setup);
  11025. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-el-mini.c linux-4.1.13/arch/mips/ath79/mach-el-mini.c
  11026. --- linux-4.1.13.orig/arch/mips/ath79/mach-el-mini.c 1970-01-01 01:00:00.000000000 +0100
  11027. +++ linux-4.1.13/arch/mips/ath79/mach-el-mini.c 2015-09-13 20:04:35.068524086 +0200
  11028. @@ -0,0 +1,86 @@
  11029. +/*
  11030. + * Easy-Link EL-MINI board support
  11031. + *
  11032. + * Copyright (C) 2012 huangfc <huangfangcheng@163.com>
  11033. + * Copyright (C) 2011 hys <550663898@qq.com>
  11034. + *
  11035. + * This program is free software; you can redistribute it and/or modify it
  11036. + * under the terms of the GNU General Public License version 2 as published
  11037. + * by the Free Software Foundation.
  11038. + */
  11039. +
  11040. +#include <linux/gpio.h>
  11041. +
  11042. +#include <asm/mach-ath79/ath79.h>
  11043. +
  11044. +#include "dev-eth.h"
  11045. +#include "dev-gpio-buttons.h"
  11046. +#include "dev-leds-gpio.h"
  11047. +#include "dev-m25p80.h"
  11048. +#include "dev-usb.h"
  11049. +#include "dev-wmac.h"
  11050. +#include "machtypes.h"
  11051. +
  11052. +#define MINI_GPIO_LED_SYSTEM 27
  11053. +#define MINI_GPIO_BTN_RESET 11
  11054. +
  11055. +#define MINI_GPIO_USB_POWER 8
  11056. +
  11057. +#define MINI_KEYS_POLL_INTERVAL 20 /* msecs */
  11058. +#define MINI_KEYS_DEBOUNCE_INTERVAL (3 * MINI_KEYS_POLL_INTERVAL)
  11059. +
  11060. +static const char *mini_part_probes[] = {
  11061. + "tp-link",
  11062. + NULL,
  11063. +};
  11064. +
  11065. +static struct flash_platform_data mini_flash_data = {
  11066. + .part_probes = mini_part_probes,
  11067. +};
  11068. +
  11069. +static struct gpio_led mini_leds_gpio[] __initdata = {
  11070. + {
  11071. + .name = "easylink:green:system",
  11072. + .gpio = MINI_GPIO_LED_SYSTEM,
  11073. + .active_low = 1,
  11074. + },
  11075. +};
  11076. +
  11077. +static struct gpio_keys_button mini_gpio_keys[] __initdata = {
  11078. + {
  11079. + .desc = "reset",
  11080. + .type = EV_KEY,
  11081. + .code = KEY_RESTART,
  11082. + .debounce_interval = MINI_KEYS_DEBOUNCE_INTERVAL,
  11083. + .gpio = MINI_GPIO_BTN_RESET,
  11084. + .active_low = 0,
  11085. + }
  11086. +};
  11087. +
  11088. +static void __init el_mini_setup(void)
  11089. +{
  11090. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  11091. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  11092. +
  11093. + ath79_register_m25p80(&mini_flash_data);
  11094. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mini_leds_gpio),
  11095. + mini_leds_gpio);
  11096. + ath79_register_gpio_keys_polled(-1, MINI_KEYS_POLL_INTERVAL,
  11097. + ARRAY_SIZE(mini_gpio_keys),
  11098. + mini_gpio_keys);
  11099. +
  11100. + gpio_request_one(MINI_GPIO_USB_POWER,
  11101. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  11102. + "USB power");
  11103. + ath79_register_usb();
  11104. +
  11105. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  11106. +
  11107. + ath79_register_mdio(0, 0x0);
  11108. + ath79_register_eth(0);
  11109. +
  11110. + ath79_register_wmac(ee, mac);
  11111. +}
  11112. +
  11113. +MIPS_MACHINE(ATH79_MACH_EL_MINI, "EL-MINI", "EasyLink EL-MINI",
  11114. + el_mini_setup);
  11115. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-epg5000.c linux-4.1.13/arch/mips/ath79/mach-epg5000.c
  11116. --- linux-4.1.13.orig/arch/mips/ath79/mach-epg5000.c 1970-01-01 01:00:00.000000000 +0100
  11117. +++ linux-4.1.13/arch/mips/ath79/mach-epg5000.c 2015-09-13 20:04:35.068524086 +0200
  11118. @@ -0,0 +1,178 @@
  11119. +/*
  11120. + * EnGenius EPG5000 board support
  11121. + *
  11122. + * Copyright (c) 2014 Jon Suphammer <jon@suphammer.net>
  11123. + * Copyright (c) 2015 Christian Beier <cb@shoutrlabs.com>
  11124. + *
  11125. + * This program is free software; you can redistribute it and/or modify it
  11126. + * under the terms of the GNU General Public License version 2 as published
  11127. + * by the Free Software Foundation.
  11128. + */
  11129. +
  11130. +#include <linux/platform_device.h>
  11131. +#include <linux/ar8216_platform.h>
  11132. +
  11133. +#include <asm/mach-ath79/ar71xx_regs.h>
  11134. +
  11135. +#include "common.h"
  11136. +#include "pci.h"
  11137. +#include "dev-ap9x-pci.h"
  11138. +#include "dev-gpio-buttons.h"
  11139. +#include "dev-eth.h"
  11140. +#include "dev-leds-gpio.h"
  11141. +#include "dev-m25p80.h"
  11142. +#include "dev-usb.h"
  11143. +#include "dev-wmac.h"
  11144. +#include "machtypes.h"
  11145. +#include "nvram.h"
  11146. +
  11147. +#define EPG5000_GPIO_LED_WLAN_5G 23
  11148. +#define EPG5000_GPIO_LED_WLAN_2G 13
  11149. +#define EPG5000_GPIO_LED_POWER_AMBER 2
  11150. +#define EPG5000_GPIO_LED_WPS_AMBER 22
  11151. +#define EPG5000_GPIO_LED_WPS_BLUE 19
  11152. +
  11153. +#define EPG5000_GPIO_BTN_WPS 16
  11154. +#define EPG5000_GPIO_BTN_RESET 17
  11155. +
  11156. +#define EPG5000_KEYS_POLL_INTERVAL 20 /* msecs */
  11157. +#define EPG5000_KEYS_DEBOUNCE_INTERVAL (3 * EPG5000_KEYS_POLL_INTERVAL)
  11158. +
  11159. +#define EPG5000_CALDATA_ADDR 0x1fff0000
  11160. +#define EPG5000_WMAC_CALDATA_OFFSET 0x1000
  11161. +#define EPG5000_PCIE_CALDATA_OFFSET 0x5000
  11162. +
  11163. +#define EPG5000_NVRAM_ADDR 0x1f030000
  11164. +#define EPG5000_NVRAM_SIZE 0x10000
  11165. +
  11166. +static struct gpio_led epg5000_leds_gpio[] __initdata = {
  11167. + {
  11168. + .name = "epg5000:amber:power",
  11169. + .gpio = EPG5000_GPIO_LED_POWER_AMBER,
  11170. + .active_low = 1,
  11171. + },
  11172. + {
  11173. + .name = "epg5000:blue:wps",
  11174. + .gpio = EPG5000_GPIO_LED_WPS_BLUE,
  11175. + .active_low = 1,
  11176. + },
  11177. + {
  11178. + .name = "epg5000:amber:wps",
  11179. + .gpio = EPG5000_GPIO_LED_WPS_AMBER,
  11180. + .active_low = 1,
  11181. + },
  11182. + {
  11183. + .name = "epg5000:blue:wlan-2g",
  11184. + .gpio = EPG5000_GPIO_LED_WLAN_2G,
  11185. + .active_low = 1,
  11186. + },
  11187. + {
  11188. + .name = "epg5000:blue:wlan-5g",
  11189. + .gpio = EPG5000_GPIO_LED_WLAN_5G,
  11190. + .active_low = 1,
  11191. + }
  11192. +};
  11193. +
  11194. +static struct gpio_keys_button epg5000_gpio_keys[] __initdata = {
  11195. + {
  11196. + .desc = "WPS button",
  11197. + .type = EV_KEY,
  11198. + .code = KEY_WPS_BUTTON,
  11199. + .debounce_interval = EPG5000_KEYS_DEBOUNCE_INTERVAL,
  11200. + .gpio = EPG5000_GPIO_BTN_WPS,
  11201. + .active_low = 1,
  11202. + },
  11203. + {
  11204. + .desc = "Reset button",
  11205. + .type = EV_KEY,
  11206. + .code = KEY_RESTART,
  11207. + .debounce_interval = EPG5000_KEYS_DEBOUNCE_INTERVAL,
  11208. + .gpio = EPG5000_GPIO_BTN_RESET,
  11209. + .active_low = 1,
  11210. + },
  11211. +};
  11212. +
  11213. +static struct ar8327_pad_cfg epg5000_ar8327_pad0_cfg = {
  11214. + .mode = AR8327_PAD_MAC_RGMII,
  11215. + .txclk_delay_en = true,
  11216. + .rxclk_delay_en = true,
  11217. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11218. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11219. + .mac06_exchange_en = true,
  11220. +};
  11221. +
  11222. +static struct ar8327_platform_data epg5000_ar8327_data = {
  11223. + .pad0_cfg = &epg5000_ar8327_pad0_cfg,
  11224. + .port0_cfg = {
  11225. + .force_link = 1,
  11226. + .speed = AR8327_PORT_SPEED_1000,
  11227. + .duplex = 1,
  11228. + .txpause = 1,
  11229. + .rxpause = 1,
  11230. + },
  11231. +};
  11232. +
  11233. +static struct mdio_board_info epg5000_mdio0_info[] = {
  11234. + {
  11235. + .bus_id = "ag71xx-mdio.0",
  11236. + .phy_addr = 0,
  11237. + .platform_data = &epg5000_ar8327_data,
  11238. + },
  11239. +};
  11240. +
  11241. +static int epg5000_get_mac(const char *name, char *mac)
  11242. +{
  11243. + u8 *nvram = (u8 *) KSEG1ADDR(EPG5000_NVRAM_ADDR);
  11244. + int err;
  11245. +
  11246. + err = ath79_nvram_parse_mac_addr(nvram, EPG5000_NVRAM_SIZE,
  11247. + name, mac);
  11248. + if (err) {
  11249. + pr_err("no MAC address found for %s\n", name);
  11250. + return false;
  11251. + }
  11252. +
  11253. + return true;
  11254. +}
  11255. +
  11256. +static void __init epg5000_setup(void)
  11257. +{
  11258. + u8 *caldata = (u8 *) KSEG1ADDR(EPG5000_CALDATA_ADDR);
  11259. + u8 mac1[ETH_ALEN];
  11260. +
  11261. + ath79_register_m25p80(NULL);
  11262. +
  11263. + ath79_register_leds_gpio(-1, ARRAY_SIZE(epg5000_leds_gpio),
  11264. + epg5000_leds_gpio);
  11265. + ath79_register_gpio_keys_polled(-1, EPG5000_KEYS_POLL_INTERVAL,
  11266. + ARRAY_SIZE(epg5000_gpio_keys),
  11267. + epg5000_gpio_keys);
  11268. +
  11269. + ath79_register_usb();
  11270. +
  11271. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  11272. +
  11273. + ath79_register_mdio(0, 0x0);
  11274. +
  11275. + mdiobus_register_board_info(epg5000_mdio0_info,
  11276. + ARRAY_SIZE(epg5000_mdio0_info));
  11277. +
  11278. + /* GMAC0 is connected to an QCA8327N switch */
  11279. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  11280. + ath79_eth0_data.phy_mask = BIT(0);
  11281. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  11282. +
  11283. + if (epg5000_get_mac("ethaddr=", mac1))
  11284. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  11285. +
  11286. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  11287. + ath79_register_eth(0);
  11288. +
  11289. + ath79_register_wmac(caldata + EPG5000_WMAC_CALDATA_OFFSET, mac1);
  11290. +
  11291. + ath79_register_pci();
  11292. +}
  11293. +
  11294. +MIPS_MACHINE(ATH79_MACH_EPG5000, "EPG5000",
  11295. + "EnGenius EPG5000",
  11296. + epg5000_setup);
  11297. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-esr1750.c linux-4.1.13/arch/mips/ath79/mach-esr1750.c
  11298. --- linux-4.1.13.orig/arch/mips/ath79/mach-esr1750.c 1970-01-01 01:00:00.000000000 +0100
  11299. +++ linux-4.1.13/arch/mips/ath79/mach-esr1750.c 2015-09-13 20:04:35.068524086 +0200
  11300. @@ -0,0 +1,177 @@
  11301. +/*
  11302. + * EnGenius ESR1750 board support
  11303. + *
  11304. + * Copyright (c) 2014 Jon Suphammer <jon@suphammer.net>
  11305. + *
  11306. + * This program is free software; you can redistribute it and/or modify it
  11307. + * under the terms of the GNU General Public License version 2 as published
  11308. + * by the Free Software Foundation.
  11309. + */
  11310. +
  11311. +#include <linux/platform_device.h>
  11312. +#include <linux/ar8216_platform.h>
  11313. +
  11314. +#include <asm/mach-ath79/ar71xx_regs.h>
  11315. +
  11316. +#include "common.h"
  11317. +#include "pci.h"
  11318. +#include "dev-ap9x-pci.h"
  11319. +#include "dev-gpio-buttons.h"
  11320. +#include "dev-eth.h"
  11321. +#include "dev-leds-gpio.h"
  11322. +#include "dev-m25p80.h"
  11323. +#include "dev-usb.h"
  11324. +#include "dev-wmac.h"
  11325. +#include "machtypes.h"
  11326. +#include "nvram.h"
  11327. +
  11328. +#define ESR1750_GPIO_LED_WLAN_5G 23
  11329. +#define ESR1750_GPIO_LED_WLAN_2G 13
  11330. +#define ESR1750_GPIO_LED_POWER_AMBER 2
  11331. +#define ESR1750_GPIO_LED_WPS_AMBER 22
  11332. +#define ESR1750_GPIO_LED_WPS_BLUE 19
  11333. +
  11334. +#define ESR1750_GPIO_BTN_WPS 16
  11335. +#define ESR1750_GPIO_BTN_RESET 17
  11336. +
  11337. +#define ESR1750_KEYS_POLL_INTERVAL 20 /* msecs */
  11338. +#define ESR1750_KEYS_DEBOUNCE_INTERVAL (3 * ESR1750_KEYS_POLL_INTERVAL)
  11339. +
  11340. +#define ESR1750_CALDATA_ADDR 0x1fff0000
  11341. +#define ESR1750_WMAC_CALDATA_OFFSET 0x1000
  11342. +#define ESR1750_PCIE_CALDATA_OFFSET 0x5000
  11343. +
  11344. +#define ESR1750_NVRAM_ADDR 0x1f030000
  11345. +#define ESR1750_NVRAM_SIZE 0x10000
  11346. +
  11347. +static struct gpio_led esr1750_leds_gpio[] __initdata = {
  11348. + {
  11349. + .name = "esr1750:amber:power",
  11350. + .gpio = ESR1750_GPIO_LED_POWER_AMBER,
  11351. + .active_low = 1,
  11352. + },
  11353. + {
  11354. + .name = "esr1750:blue:wps",
  11355. + .gpio = ESR1750_GPIO_LED_WPS_BLUE,
  11356. + .active_low = 1,
  11357. + },
  11358. + {
  11359. + .name = "esr1750:amber:wps",
  11360. + .gpio = ESR1750_GPIO_LED_WPS_AMBER,
  11361. + .active_low = 1,
  11362. + },
  11363. + {
  11364. + .name = "esr1750:blue:wlan-2g",
  11365. + .gpio = ESR1750_GPIO_LED_WLAN_2G,
  11366. + .active_low = 1,
  11367. + },
  11368. + {
  11369. + .name = "esr1750:blue:wlan-5g",
  11370. + .gpio = ESR1750_GPIO_LED_WLAN_5G,
  11371. + .active_low = 1,
  11372. + }
  11373. +};
  11374. +
  11375. +static struct gpio_keys_button esr1750_gpio_keys[] __initdata = {
  11376. + {
  11377. + .desc = "WPS button",
  11378. + .type = EV_KEY,
  11379. + .code = KEY_WPS_BUTTON,
  11380. + .debounce_interval = ESR1750_KEYS_DEBOUNCE_INTERVAL,
  11381. + .gpio = ESR1750_GPIO_BTN_WPS,
  11382. + .active_low = 1,
  11383. + },
  11384. + {
  11385. + .desc = "Reset button",
  11386. + .type = EV_KEY,
  11387. + .code = KEY_RESTART,
  11388. + .debounce_interval = ESR1750_KEYS_DEBOUNCE_INTERVAL,
  11389. + .gpio = ESR1750_GPIO_BTN_RESET,
  11390. + .active_low = 1,
  11391. + },
  11392. +};
  11393. +
  11394. +static struct ar8327_pad_cfg esr1750_ar8327_pad0_cfg = {
  11395. + .mode = AR8327_PAD_MAC_RGMII,
  11396. + .txclk_delay_en = true,
  11397. + .rxclk_delay_en = true,
  11398. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11399. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11400. + .mac06_exchange_en = true,
  11401. +};
  11402. +
  11403. +static struct ar8327_platform_data esr1750_ar8327_data = {
  11404. + .pad0_cfg = &esr1750_ar8327_pad0_cfg,
  11405. + .port0_cfg = {
  11406. + .force_link = 1,
  11407. + .speed = AR8327_PORT_SPEED_1000,
  11408. + .duplex = 1,
  11409. + .txpause = 1,
  11410. + .rxpause = 1,
  11411. + },
  11412. +};
  11413. +
  11414. +static struct mdio_board_info esr1750_mdio0_info[] = {
  11415. + {
  11416. + .bus_id = "ag71xx-mdio.0",
  11417. + .phy_addr = 0,
  11418. + .platform_data = &esr1750_ar8327_data,
  11419. + },
  11420. +};
  11421. +
  11422. +static int esr1750_get_mac(const char *name, char *mac)
  11423. +{
  11424. + u8 *nvram = (u8 *) KSEG1ADDR(ESR1750_NVRAM_ADDR);
  11425. + int err;
  11426. +
  11427. + err = ath79_nvram_parse_mac_addr(nvram, ESR1750_NVRAM_SIZE,
  11428. + name, mac);
  11429. + if (err) {
  11430. + pr_err("no MAC address found for %s\n", name);
  11431. + return false;
  11432. + }
  11433. +
  11434. + return true;
  11435. +}
  11436. +
  11437. +static void __init esr1750_setup(void)
  11438. +{
  11439. + u8 *caldata = (u8 *) KSEG1ADDR(ESR1750_CALDATA_ADDR);
  11440. + u8 mac1[ETH_ALEN];
  11441. +
  11442. + ath79_register_m25p80(NULL);
  11443. +
  11444. + ath79_register_leds_gpio(-1, ARRAY_SIZE(esr1750_leds_gpio),
  11445. + esr1750_leds_gpio);
  11446. + ath79_register_gpio_keys_polled(-1, ESR1750_KEYS_POLL_INTERVAL,
  11447. + ARRAY_SIZE(esr1750_gpio_keys),
  11448. + esr1750_gpio_keys);
  11449. +
  11450. + ath79_register_usb();
  11451. +
  11452. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  11453. +
  11454. + ath79_register_mdio(0, 0x0);
  11455. +
  11456. + mdiobus_register_board_info(esr1750_mdio0_info,
  11457. + ARRAY_SIZE(esr1750_mdio0_info));
  11458. +
  11459. + /* GMAC0 is connected to an QCA8327N switch */
  11460. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  11461. + ath79_eth0_data.phy_mask = BIT(0);
  11462. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  11463. +
  11464. + if (esr1750_get_mac("ethaddr=", mac1))
  11465. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  11466. +
  11467. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  11468. + ath79_register_eth(0);
  11469. +
  11470. + ath79_register_wmac(caldata + ESR1750_WMAC_CALDATA_OFFSET, mac1);
  11471. +
  11472. + ath79_register_pci();
  11473. +}
  11474. +
  11475. +MIPS_MACHINE(ATH79_MACH_ESR1750, "ESR1750",
  11476. + "EnGenius ESR1750",
  11477. + esr1750_setup);
  11478. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-esr900.c linux-4.1.13/arch/mips/ath79/mach-esr900.c
  11479. --- linux-4.1.13.orig/arch/mips/ath79/mach-esr900.c 1970-01-01 01:00:00.000000000 +0100
  11480. +++ linux-4.1.13/arch/mips/ath79/mach-esr900.c 2015-09-13 20:04:35.068524086 +0200
  11481. @@ -0,0 +1,200 @@
  11482. +/*
  11483. + * EnGenius ESR900 board support
  11484. + *
  11485. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  11486. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  11487. + *
  11488. + * This program is free software; you can redistribute it and/or modify it
  11489. + * under the terms of the GNU General Public License version 2 as published
  11490. + * by the Free Software Foundation.
  11491. + */
  11492. +
  11493. +#define pr_fmt(fmt) "esr900: " fmt
  11494. +
  11495. +#include <linux/platform_device.h>
  11496. +#include <linux/ar8216_platform.h>
  11497. +
  11498. +#include <asm/mach-ath79/ar71xx_regs.h>
  11499. +
  11500. +#include "common.h"
  11501. +#include "pci.h"
  11502. +#include "dev-ap9x-pci.h"
  11503. +#include "dev-gpio-buttons.h"
  11504. +#include "dev-eth.h"
  11505. +#include "dev-leds-gpio.h"
  11506. +#include "dev-m25p80.h"
  11507. +#include "dev-usb.h"
  11508. +#include "dev-wmac.h"
  11509. +#include "machtypes.h"
  11510. +#include "nvram.h"
  11511. +
  11512. +#define ESR900_GPIO_LED_POWER 2
  11513. +#define ESR900_GPIO_LED_WLAN_2G 13
  11514. +#define ESR900_GPIO_LED_WPS_BLUE 19
  11515. +#define ESR900_GPIO_LED_WPS_AMBER 22
  11516. +#define ESR900_GPIO_LED_WLAN_5G 23
  11517. +
  11518. +#define ESR900_GPIO_BTN_WPS 16
  11519. +#define ESR900_GPIO_BTN_RESET 17
  11520. +
  11521. +#define ESR900_KEYS_POLL_INTERVAL 20 /* msecs */
  11522. +#define ESR900_KEYS_DEBOUNCE_INTERVAL (3 * ESR900_KEYS_POLL_INTERVAL)
  11523. +
  11524. +#define ESR900_CALDATA_ADDR 0x1fff0000
  11525. +#define ESR900_WMAC_CALDATA_OFFSET 0x1000
  11526. +#define ESR900_PCIE_CALDATA_OFFSET 0x5000
  11527. +
  11528. +#define ESR900_CONFIG_ADDR 0x1f030000
  11529. +#define ESR900_CONFIG_SIZE 0x10000
  11530. +
  11531. +#define ESR900_LAN_PHYMASK BIT(0)
  11532. +#define ESR900_WAN_PHYMASK BIT(5)
  11533. +#define ESR900_MDIO_MASK (~(ESR900_LAN_PHYMASK | ESR900_WAN_PHYMASK))
  11534. +
  11535. +static struct gpio_led esr900_leds_gpio[] __initdata = {
  11536. + {
  11537. + .name = "engenius:amber:power",
  11538. + .gpio = ESR900_GPIO_LED_POWER,
  11539. + .active_low = 1,
  11540. + },
  11541. + {
  11542. + .name = "engenius:blue:wlan-2g",
  11543. + .gpio = ESR900_GPIO_LED_WLAN_2G,
  11544. + .active_low = 1,
  11545. + },
  11546. + {
  11547. + .name = "engenius:blue:wps",
  11548. + .gpio = ESR900_GPIO_LED_WPS_BLUE,
  11549. + .active_low = 1,
  11550. + },
  11551. + {
  11552. + .name = "engenius:amber:wps",
  11553. + .gpio = ESR900_GPIO_LED_WPS_AMBER,
  11554. + .active_low = 1,
  11555. + },
  11556. + {
  11557. + .name = "engenius:blue:wlan-5g",
  11558. + .gpio = ESR900_GPIO_LED_WLAN_5G,
  11559. + .active_low = 1,
  11560. + }
  11561. +};
  11562. +
  11563. +static struct gpio_keys_button esr900_gpio_keys[] __initdata = {
  11564. + {
  11565. + .desc = "WPS button",
  11566. + .type = EV_KEY,
  11567. + .code = KEY_WPS_BUTTON,
  11568. + .debounce_interval = ESR900_KEYS_DEBOUNCE_INTERVAL,
  11569. + .gpio = ESR900_GPIO_BTN_WPS,
  11570. + .active_low = 1,
  11571. + },
  11572. + {
  11573. + .desc = "Reset button",
  11574. + .type = EV_KEY,
  11575. + .code = KEY_RESTART,
  11576. + .debounce_interval = ESR900_KEYS_DEBOUNCE_INTERVAL,
  11577. + .gpio = ESR900_GPIO_BTN_RESET,
  11578. + .active_low = 1,
  11579. + },
  11580. +};
  11581. +
  11582. +static struct ar8327_pad_cfg esr900_ar8327_pad0_cfg = {
  11583. + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
  11584. + .mode = AR8327_PAD_MAC_RGMII,
  11585. + .txclk_delay_en = true,
  11586. + .rxclk_delay_en = true,
  11587. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  11588. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11589. +};
  11590. +
  11591. +static struct ar8327_pad_cfg esr900_ar8327_pad6_cfg = {
  11592. + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
  11593. + .mode = AR8327_PAD_MAC_SGMII,
  11594. + .rxclk_delay_en = true,
  11595. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  11596. +};
  11597. +
  11598. +static struct ar8327_platform_data esr900_ar8327_data = {
  11599. + .pad0_cfg = &esr900_ar8327_pad0_cfg,
  11600. + .pad6_cfg = &esr900_ar8327_pad6_cfg,
  11601. + .port0_cfg = {
  11602. + .force_link = 1,
  11603. + .speed = AR8327_PORT_SPEED_1000,
  11604. + .duplex = 1,
  11605. + .txpause = 1,
  11606. + .rxpause = 1,
  11607. + },
  11608. + .port6_cfg = {
  11609. + .force_link = 1,
  11610. + .speed = AR8327_PORT_SPEED_1000,
  11611. + .duplex = 1,
  11612. + .txpause = 1,
  11613. + .rxpause = 1,
  11614. + },
  11615. +};
  11616. +
  11617. +static struct mdio_board_info esr900_mdio0_info[] = {
  11618. + {
  11619. + .bus_id = "ag71xx-mdio.0",
  11620. + .phy_addr = 0,
  11621. + .platform_data = &esr900_ar8327_data,
  11622. + },
  11623. +};
  11624. +
  11625. +static void __init esr900_setup(void)
  11626. +{
  11627. + const char *config = (char *) KSEG1ADDR(ESR900_CONFIG_ADDR);
  11628. + u8 *art = (u8 *) KSEG1ADDR(ESR900_CALDATA_ADDR);
  11629. + u8 lan_mac[ETH_ALEN];
  11630. + u8 wlan0_mac[ETH_ALEN];
  11631. + u8 wlan1_mac[ETH_ALEN];
  11632. +
  11633. + if (ath79_nvram_parse_mac_addr(config, ESR900_CONFIG_SIZE,
  11634. + "ethaddr=", lan_mac) == 0) {
  11635. + ath79_init_local_mac(ath79_eth0_data.mac_addr, lan_mac);
  11636. + ath79_init_mac(wlan0_mac, lan_mac, 0);
  11637. + ath79_init_mac(wlan1_mac, lan_mac, 1);
  11638. + } else {
  11639. + pr_err("could not find ethaddr in u-boot environment\n");
  11640. + }
  11641. +
  11642. + ath79_register_m25p80(NULL);
  11643. +
  11644. + ath79_register_leds_gpio(-1, ARRAY_SIZE(esr900_leds_gpio),
  11645. + esr900_leds_gpio);
  11646. + ath79_register_gpio_keys_polled(-1, ESR900_KEYS_POLL_INTERVAL,
  11647. + ARRAY_SIZE(esr900_gpio_keys),
  11648. + esr900_gpio_keys);
  11649. +
  11650. + ath79_register_usb();
  11651. +
  11652. + ath79_register_wmac(art + ESR900_WMAC_CALDATA_OFFSET, wlan0_mac);
  11653. +
  11654. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  11655. +
  11656. + ath79_register_mdio(0, 0x0);
  11657. +
  11658. + mdiobus_register_board_info(esr900_mdio0_info,
  11659. + ARRAY_SIZE(esr900_mdio0_info));
  11660. +
  11661. + /* GMAC0 is connected to the RMGII interface */
  11662. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  11663. + ath79_eth0_data.phy_mask = ESR900_LAN_PHYMASK;
  11664. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  11665. +
  11666. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  11667. + ath79_register_eth(0);
  11668. +
  11669. + /* GMAC1 is connected to the SGMII interface */
  11670. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  11671. + ath79_eth1_data.speed = SPEED_1000;
  11672. + ath79_eth1_data.duplex = DUPLEX_FULL;
  11673. +
  11674. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  11675. + ath79_register_eth(1);
  11676. +
  11677. + ap91_pci_init(art + ESR900_PCIE_CALDATA_OFFSET, wlan1_mac);
  11678. +}
  11679. +
  11680. +MIPS_MACHINE(ATH79_MACH_ESR900, "ESR900", "EnGenius ESR900", esr900_setup);
  11681. +
  11682. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ew-dorin.c linux-4.1.13/arch/mips/ath79/mach-ew-dorin.c
  11683. --- linux-4.1.13.orig/arch/mips/ath79/mach-ew-dorin.c 1970-01-01 01:00:00.000000000 +0100
  11684. +++ linux-4.1.13/arch/mips/ath79/mach-ew-dorin.c 2015-09-13 20:04:35.068524086 +0200
  11685. @@ -0,0 +1,150 @@
  11686. +/*
  11687. + * EW Dorin board support
  11688. + * (based on Atheros Ref. Design AP121)
  11689. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  11690. + * Copyright (C) 2012-2015 Embedded Wireless GmbH www.80211.de
  11691. + *
  11692. + * This program is free software; you can redistribute it and/or modify it
  11693. + * under the terms of the GNU General Public License version 2 as published
  11694. + * by the Free Software Foundation.
  11695. + */
  11696. +
  11697. +#include <asm/mach-ath79/ath79.h>
  11698. +#include <asm/mach-ath79/ar71xx_regs.h>
  11699. +
  11700. +#include "dev-eth.h"
  11701. +#include "dev-gpio-buttons.h"
  11702. +#include "dev-leds-gpio.h"
  11703. +#include "dev-m25p80.h"
  11704. +#include "dev-spi.h"
  11705. +#include "dev-usb.h"
  11706. +#include "dev-wmac.h"
  11707. +#include "machtypes.h"
  11708. +
  11709. +#define DORIN_KEYS_POLL_INTERVAL 20 /* msecs */
  11710. +#define DORIN_KEYS_DEBOUNCE_INTERVAL (3 * DORIN_KEYS_POLL_INTERVAL)
  11711. +
  11712. +#define DORIN_CALDATA_OFFSET 0x1000
  11713. +#define DORIN_WMAC_MAC_OFFSET 0x1002
  11714. +
  11715. +#define DORIN_GPIO_LED_21 21
  11716. +#define DORIN_GPIO_LED_22 22
  11717. +#define DORIN_GPIO_LED_STATUS 23
  11718. +
  11719. +#define DORIN_GPIO_BTN_JUMPSTART 11
  11720. +#define DORIN_GPIO_BTN_RESET 6
  11721. +
  11722. +static struct gpio_led dorin_leds_gpio[] __initdata = {
  11723. + {
  11724. + .name = "dorin:green:led21",
  11725. + .gpio = DORIN_GPIO_LED_21,
  11726. + .active_low = 1,
  11727. + },
  11728. + {
  11729. + .name = "dorin:green:led22",
  11730. + .gpio = DORIN_GPIO_LED_22,
  11731. + .active_low = 1,
  11732. + },
  11733. + {
  11734. + .name = "dorin:green:status",
  11735. + .gpio = DORIN_GPIO_LED_STATUS,
  11736. + .active_low = 1,
  11737. + },
  11738. +};
  11739. +
  11740. +static struct gpio_keys_button dorin_gpio_keys[] __initdata = {
  11741. + {
  11742. + .desc = "jumpstart button",
  11743. + .type = EV_KEY,
  11744. + .code = KEY_WPS_BUTTON,
  11745. + .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  11746. + .gpio = DORIN_GPIO_BTN_JUMPSTART,
  11747. + .active_low = 1,
  11748. + },
  11749. + {
  11750. + .desc = "reset button",
  11751. + .type = EV_KEY,
  11752. + .code = KEY_RESTART,
  11753. + .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  11754. + .gpio = DORIN_GPIO_BTN_RESET,
  11755. + .active_low = 0,
  11756. + }
  11757. +};
  11758. +
  11759. +static void __init ew_dorin_setup(void)
  11760. +{
  11761. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  11762. + static u8 mac[6];
  11763. +
  11764. + ath79_register_m25p80(NULL);
  11765. +
  11766. + ath79_register_usb();
  11767. +
  11768. + if (ar93xx_wmac_read_mac_address(mac)) {
  11769. + ath79_register_wmac(NULL, NULL);
  11770. + } else {
  11771. + ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  11772. + art + DORIN_WMAC_MAC_OFFSET);
  11773. + memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  11774. + }
  11775. +
  11776. + mac[3] |= 0x40;
  11777. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  11778. +
  11779. + ath79_register_mdio(0, 0x0);
  11780. +
  11781. + /* LAN ports */
  11782. + ath79_register_eth(1);
  11783. +
  11784. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  11785. + dorin_leds_gpio);
  11786. + ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  11787. + ARRAY_SIZE(dorin_gpio_keys),
  11788. + dorin_gpio_keys);
  11789. +}
  11790. +
  11791. +MIPS_MACHINE(ATH79_MACH_EW_DORIN, "EW-DORIN", "EmbWir-Dorin",
  11792. + ew_dorin_setup);
  11793. +
  11794. +
  11795. +static void __init ew_dorin_router_setup(void)
  11796. +{
  11797. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  11798. + static u8 mac[6];
  11799. +
  11800. + ath79_register_m25p80(NULL);
  11801. +
  11802. + ath79_register_usb();
  11803. +
  11804. + if (ar93xx_wmac_read_mac_address(mac)) {
  11805. + ath79_register_wmac(NULL, NULL);
  11806. + } else {
  11807. + ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  11808. + art + DORIN_WMAC_MAC_OFFSET);
  11809. + memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  11810. + }
  11811. +
  11812. + mac[3] |= 0x40;
  11813. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  11814. +
  11815. + mac[3] &= 0x3F;
  11816. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  11817. + ath79_setup_ar933x_phy4_switch(true, true);
  11818. +
  11819. + ath79_register_mdio(0, 0x0);
  11820. +
  11821. + /* LAN ports */
  11822. + ath79_register_eth(1);
  11823. +
  11824. + /* WAN port */
  11825. + ath79_register_eth(0);
  11826. +
  11827. + ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  11828. + dorin_leds_gpio);
  11829. + ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  11830. + ARRAY_SIZE(dorin_gpio_keys),
  11831. + dorin_gpio_keys);
  11832. +}
  11833. +
  11834. +MIPS_MACHINE(ATH79_MACH_EW_DORIN_ROUTER, "EW-DORIN-ROUTER",
  11835. + "EmbWir-Dorin-Router", ew_dorin_router_setup);
  11836. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-f9k1115v2.c linux-4.1.13/arch/mips/ath79/mach-f9k1115v2.c
  11837. --- linux-4.1.13.orig/arch/mips/ath79/mach-f9k1115v2.c 1970-01-01 01:00:00.000000000 +0100
  11838. +++ linux-4.1.13/arch/mips/ath79/mach-f9k1115v2.c 2015-09-13 20:04:35.068524086 +0200
  11839. @@ -0,0 +1,190 @@
  11840. +/*
  11841. + * Belkin AC1750DB (F9K1115V2) board support
  11842. + *
  11843. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  11844. + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  11845. + *
  11846. + * This program is free software; you can redistribute it and/or modify it
  11847. + * under the terms of the GNU General Public License version 2 as published
  11848. + * by the Free Software Foundation.
  11849. + */
  11850. +
  11851. +#include <linux/gpio.h>
  11852. +#include <linux/platform_device.h>
  11853. +#include <linux/ar8216_platform.h>
  11854. +
  11855. +#include <asm/mach-ath79/ar71xx_regs.h>
  11856. +
  11857. +#include "common.h"
  11858. +#include "pci.h"
  11859. +#include "dev-gpio-buttons.h"
  11860. +#include "dev-eth.h"
  11861. +#include "dev-leds-gpio.h"
  11862. +#include "dev-m25p80.h"
  11863. +#include "dev-usb.h"
  11864. +#include "dev-wmac.h"
  11865. +#include "machtypes.h"
  11866. +
  11867. +#define F9K1115V2_GPIO_LED_USB2 4
  11868. +#define F9K1115V2_GPIO_LED_WPS_AMBER 14
  11869. +#define F9K1115V2_GPIO_LED_STATUS_AMBER 15
  11870. +#define F9K1115V2_GPIO_LED_WPS_BLUE 19
  11871. +#define F9K1115V2_GPIO_LED_STATUS_BLUE 20
  11872. +
  11873. +#define F9K1115V2_GPIO_BTN_WPS 16
  11874. +#define F9K1115V2_GPIO_BTN_RESET 17
  11875. +
  11876. +#define F9K1115V2_GPIO_USB2_POWER 21
  11877. +
  11878. +#define F9K1115V2_KEYS_POLL_INTERVAL 20 /* msecs */
  11879. +#define F9K1115V2_KEYS_DEBOUNCE_INTERVAL (3 * F9K1115V2_KEYS_POLL_INTERVAL)
  11880. +
  11881. +#define F9K1115V2_WAN_MAC_OFFSET 0
  11882. +#define F9K1115V2_LAN_MAC_OFFSET 6
  11883. +#define F9K1115V2_WMAC_CALDATA_OFFSET 0x1000
  11884. +#define F9K1115V2_PCIE_CALDATA_OFFSET 0x5000
  11885. +
  11886. +static struct gpio_led f9k1115v2_leds_gpio[] __initdata = {
  11887. + {
  11888. + .name = "belkin:amber:status",
  11889. + .gpio = F9K1115V2_GPIO_LED_STATUS_AMBER,
  11890. + .active_low = 1,
  11891. + },
  11892. + {
  11893. + .name = "belkin:blue:status",
  11894. + .gpio = F9K1115V2_GPIO_LED_STATUS_BLUE,
  11895. + .active_low = 1,
  11896. + },
  11897. + {
  11898. + .name = "belkin:blue:wps",
  11899. + .gpio = F9K1115V2_GPIO_LED_WPS_BLUE,
  11900. + .active_low = 1,
  11901. + },
  11902. + {
  11903. + .name = "belkin:amber:wps",
  11904. + .gpio = F9K1115V2_GPIO_LED_WPS_AMBER,
  11905. + .active_low = 1,
  11906. + },
  11907. + {
  11908. + .name = "belkin:green:usb2",
  11909. + .gpio = F9K1115V2_GPIO_LED_USB2,
  11910. + .active_low = 1,
  11911. + },
  11912. +};
  11913. +
  11914. +static struct gpio_keys_button f9k1115v2_gpio_keys[] __initdata = {
  11915. + {
  11916. + .desc = "Reset button",
  11917. + .type = EV_KEY,
  11918. + .code = KEY_RESTART,
  11919. + .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
  11920. + .gpio = F9K1115V2_GPIO_BTN_RESET,
  11921. + .active_low = 1,
  11922. + },
  11923. + {
  11924. + .desc = "WPS button",
  11925. + .type = EV_KEY,
  11926. + .code = KEY_WPS_BUTTON,
  11927. + .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
  11928. + .gpio = F9K1115V2_GPIO_BTN_WPS,
  11929. + .active_low = 1,
  11930. + },
  11931. +};
  11932. +
  11933. +static struct ar8327_pad_cfg f9k1115v2_ar8327_pad0_cfg = {
  11934. + /* Use the RGMII interface for the GMAC0 of the AR8337 switch */
  11935. + .mode = AR8327_PAD_MAC_RGMII,
  11936. + .txclk_delay_en = true,
  11937. + .rxclk_delay_en = true,
  11938. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  11939. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  11940. + .mac06_exchange_en = true,
  11941. +};
  11942. +
  11943. +static struct ar8327_pad_cfg f9k1115v2_ar8327_pad6_cfg = {
  11944. + /* Use the SGMII interface for the GMAC6 of the AR8337 switch */
  11945. + .mode = AR8327_PAD_MAC_SGMII,
  11946. + .rxclk_delay_en = true,
  11947. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  11948. +};
  11949. +
  11950. +static struct ar8327_platform_data f9k1115v2_ar8327_data = {
  11951. + .pad0_cfg = &f9k1115v2_ar8327_pad0_cfg,
  11952. + .pad6_cfg = &f9k1115v2_ar8327_pad6_cfg,
  11953. + .port0_cfg = {
  11954. + .force_link = 1,
  11955. + .speed = AR8327_PORT_SPEED_1000,
  11956. + .duplex = 1,
  11957. + .txpause = 1,
  11958. + .rxpause = 1,
  11959. + },
  11960. + .port6_cfg = {
  11961. + .force_link = 1,
  11962. + .speed = AR8327_PORT_SPEED_1000,
  11963. + .duplex = 1,
  11964. + .txpause = 1,
  11965. + .rxpause = 1,
  11966. + },
  11967. +};
  11968. +
  11969. +static struct mdio_board_info f9k1115v2_mdio0_info[] = {
  11970. + {
  11971. + .bus_id = "ag71xx-mdio.0",
  11972. + .phy_addr = 0,
  11973. + .platform_data = &f9k1115v2_ar8327_data,
  11974. + },
  11975. +};
  11976. +
  11977. +static void __init f9k1115v2_setup(void)
  11978. +{
  11979. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  11980. +
  11981. + ath79_register_m25p80(NULL);
  11982. +
  11983. + ath79_register_leds_gpio(-1, ARRAY_SIZE(f9k1115v2_leds_gpio),
  11984. + f9k1115v2_leds_gpio);
  11985. + ath79_register_gpio_keys_polled(-1, F9K1115V2_KEYS_POLL_INTERVAL,
  11986. + ARRAY_SIZE(f9k1115v2_gpio_keys),
  11987. + f9k1115v2_gpio_keys);
  11988. +
  11989. + ath79_register_wmac(art + F9K1115V2_WMAC_CALDATA_OFFSET, NULL);
  11990. +
  11991. + ath79_register_mdio(0, 0x0);
  11992. + mdiobus_register_board_info(f9k1115v2_mdio0_info,
  11993. + ARRAY_SIZE(f9k1115v2_mdio0_info));
  11994. +
  11995. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  11996. +
  11997. + ath79_init_mac(ath79_eth0_data.mac_addr,
  11998. + art + F9K1115V2_WAN_MAC_OFFSET, 0);
  11999. +
  12000. + ath79_init_mac(ath79_eth1_data.mac_addr,
  12001. + art + F9K1115V2_LAN_MAC_OFFSET, 0);
  12002. +
  12003. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  12004. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  12005. +
  12006. + /* GMAC0 is connected to the RMGII interface */
  12007. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  12008. + ath79_eth0_data.phy_mask = BIT(0);
  12009. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  12010. +
  12011. + ath79_register_eth(0);
  12012. +
  12013. + /* GMAC1 is connected to the SGMII interface */
  12014. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  12015. + ath79_eth1_data.speed = SPEED_1000;
  12016. + ath79_eth1_data.duplex = DUPLEX_FULL;
  12017. +
  12018. + ath79_register_eth(1);
  12019. +
  12020. + ath79_register_pci();
  12021. +
  12022. + ath79_register_usb();
  12023. + gpio_request_one(F9K1115V2_GPIO_USB2_POWER,
  12024. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12025. + "USB2 power");
  12026. +}
  12027. +
  12028. +MIPS_MACHINE(ATH79_MACH_F9K1115V2, "F9K1115V2", "Belkin AC1750DB",
  12029. + f9k1115v2_setup);
  12030. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gl-ar150.c linux-4.1.13/arch/mips/ath79/mach-gl-ar150.c
  12031. --- linux-4.1.13.orig/arch/mips/ath79/mach-gl-ar150.c 1970-01-01 01:00:00.000000000 +0100
  12032. +++ linux-4.1.13/arch/mips/ath79/mach-gl-ar150.c 2015-12-04 18:27:35.461807609 +0100
  12033. @@ -0,0 +1,125 @@
  12034. +/*
  12035. + * GL_ar150 board support
  12036. + *
  12037. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  12038. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  12039. + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  12040. + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  12041. + *
  12042. + * This program is free software; you can redistribute it and/or modify it
  12043. + * under the terms of the GNU General Public License version 2 as published
  12044. + * by the Free Software Foundation.
  12045. +*/
  12046. +
  12047. +#include <linux/gpio.h>
  12048. +
  12049. +#include <asm/mach-ath79/ath79.h>
  12050. +
  12051. +#include "dev-eth.h"
  12052. +#include "dev-gpio-buttons.h"
  12053. +#include "dev-leds-gpio.h"
  12054. +#include "dev-m25p80.h"
  12055. +#include "dev-usb.h"
  12056. +#include "dev-wmac.h"
  12057. +#include "machtypes.h"
  12058. +
  12059. +#define GL_AR150_GPIO_LED_WLAN 0
  12060. +#define GL_AR150_GPIO_LED_LAN 13
  12061. +#define GL_AR150_GPIO_LED_WAN 15
  12062. +
  12063. +#define GL_AR150_GPIO_BIN_USB 6
  12064. +#define GL_AR150_GPIO_BTN_MANUAL 7
  12065. +#define GL_AR150_GPIO_BTN_AUTO 8
  12066. +#define GL_AR150_GPIO_BTN_RESET 11
  12067. +
  12068. +#define GL_AR150_KEYS_POLL_INTERVAL 20 /* msecs */
  12069. +#define GL_AR150_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR150_KEYS_POLL_INTERVAL)
  12070. +
  12071. +#define GL_AR150_MAC0_OFFSET 0x0000
  12072. +#define GL_AR150_MAC1_OFFSET 0x0000
  12073. +#define GL_AR150_CALDATA_OFFSET 0x1000
  12074. +#define GL_AR150_WMAC_MAC_OFFSET 0x0000
  12075. +
  12076. +static struct gpio_led gl_ar150_leds_gpio[] __initdata = {
  12077. + {
  12078. + .name = "gl_ar150:wlan",
  12079. + .gpio = GL_AR150_GPIO_LED_WLAN,
  12080. + .active_low = 0,
  12081. + },
  12082. + {
  12083. + .name = "gl_ar150:lan",
  12084. + .gpio = GL_AR150_GPIO_LED_LAN,
  12085. + .active_low = 0,
  12086. + },
  12087. + {
  12088. + .name = "gl_ar150:wan",
  12089. + .gpio = GL_AR150_GPIO_LED_WAN,
  12090. + .active_low = 0,
  12091. + .default_state = 1,
  12092. + },
  12093. +};
  12094. +
  12095. +static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = {
  12096. + {
  12097. + .desc = "BTN_7",
  12098. + .type = EV_KEY,
  12099. + .code = BTN_7,
  12100. + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  12101. + .gpio = GL_AR150_GPIO_BTN_MANUAL,
  12102. + .active_low = 0,
  12103. + },
  12104. + {
  12105. + .desc = "BTN_8",
  12106. + .type = EV_KEY,
  12107. + .code = BTN_8,
  12108. + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  12109. + .gpio = GL_AR150_GPIO_BTN_AUTO,
  12110. + .active_low = 0,
  12111. + },
  12112. + {
  12113. + .desc = "reset",
  12114. + .type = EV_KEY,
  12115. + .code = KEY_RESTART,
  12116. + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  12117. + .gpio = GL_AR150_GPIO_BTN_RESET,
  12118. + .active_low = 0,
  12119. + },
  12120. +};
  12121. +
  12122. +static void __init gl_ar150_setup(void)
  12123. +{
  12124. +
  12125. + /* ART base address */
  12126. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  12127. +
  12128. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  12129. + ath79_setup_ar933x_phy4_switch(false, false);
  12130. +
  12131. + /* register flash. */
  12132. + ath79_register_m25p80(NULL);
  12133. +
  12134. + /* register gpio LEDs and keys */
  12135. + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio),
  12136. + gl_ar150_leds_gpio);
  12137. + ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL,
  12138. + ARRAY_SIZE(gl_ar150_gpio_keys),
  12139. + gl_ar150_gpio_keys);
  12140. +
  12141. + /* enable usb */
  12142. + gpio_request_one(GL_AR150_GPIO_BIN_USB,
  12143. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12144. + "USB power");
  12145. + ath79_register_usb();
  12146. +
  12147. + /* register eth0 as WAN, eth1 as LAN */
  12148. + ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0);
  12149. + ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0);
  12150. + ath79_register_mdio(0, 0x0);
  12151. + ath79_register_eth(0);
  12152. + ath79_register_eth(1);
  12153. +
  12154. + /* register wireless mac with cal data */
  12155. + ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET);
  12156. +}
  12157. +
  12158. +MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup);
  12159. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gl-ar300.c linux-4.1.13/arch/mips/ath79/mach-gl-ar300.c
  12160. --- linux-4.1.13.orig/arch/mips/ath79/mach-gl-ar300.c 1970-01-01 01:00:00.000000000 +0100
  12161. +++ linux-4.1.13/arch/mips/ath79/mach-gl-ar300.c 2015-12-04 18:27:35.461807609 +0100
  12162. @@ -0,0 +1,103 @@
  12163. +/*
  12164. + * Domino board support
  12165. + *
  12166. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  12167. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  12168. + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  12169. + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  12170. + *
  12171. + * This program is free software; you can redistribute it and/or modify it
  12172. + * under the terms of the GNU General Public License version 2 as published
  12173. + * by the Free Software Foundation.
  12174. +*/
  12175. +
  12176. +#include <linux/gpio.h>
  12177. +#include <linux/platform_device.h>
  12178. +#include <linux/ath9k_platform.h>
  12179. +#include <asm/mach-ath79/ar71xx_regs.h>
  12180. +#include <asm/mach-ath79/ath79.h>
  12181. +
  12182. +#include "common.h"
  12183. +#include "dev-eth.h"
  12184. +#include "dev-gpio-buttons.h"
  12185. +#include "dev-leds-gpio.h"
  12186. +#include "dev-m25p80.h"
  12187. +#include "dev-usb.h"
  12188. +#include "dev-wmac.h"
  12189. +#include "machtypes.h"
  12190. +
  12191. +#define GL_AR300_GPIO_LED_WLAN 13
  12192. +#define GL_AR300_GPIO_LED_WAN 14
  12193. +#define GL_AR300_GPIO_BTN_RESET 16
  12194. +
  12195. +
  12196. +#define GL_AR300_KEYS_POLL_INTERVAL 20 /* msecs */
  12197. +#define GL_AR300_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300_KEYS_POLL_INTERVAL)
  12198. +
  12199. +#define GL_AR300_MAC0_OFFSET 0x0000
  12200. +#define GL_AR300_MAC1_OFFSET 0x0000
  12201. +#define GL_AR300_CALDATA_OFFSET 0x1000
  12202. +#define GL_AR300_WMAC_MAC_OFFSET 0x0000
  12203. +
  12204. +static struct gpio_led gl_ar300_leds_gpio[] __initdata = {
  12205. + {
  12206. + .name = "gl_ar300:wlan",
  12207. + .gpio = GL_AR300_GPIO_LED_WLAN,
  12208. + .active_low = 1,
  12209. + },
  12210. + {
  12211. + .name = "gl_ar300:wan",
  12212. + .gpio = GL_AR300_GPIO_LED_WAN,
  12213. + .active_low = 1,
  12214. + },
  12215. +};
  12216. +
  12217. +static struct gpio_keys_button gl_ar300_gpio_keys[] __initdata = {
  12218. + {
  12219. + .desc = "reset",
  12220. + .type = EV_KEY,
  12221. + .code = KEY_RESTART,
  12222. + .debounce_interval = GL_AR300_KEYS_DEBOUNCE_INTERVAL,
  12223. + .gpio = GL_AR300_GPIO_BTN_RESET,
  12224. + .active_low = 1,
  12225. + },
  12226. +};
  12227. +
  12228. +static void __init gl_ar300_setup(void)
  12229. +{
  12230. +
  12231. + /* ART base address */
  12232. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  12233. +
  12234. + /* register flash. */
  12235. + ath79_register_m25p80(NULL);
  12236. +
  12237. + /* register gpio LEDs and keys */
  12238. + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300_leds_gpio),
  12239. + gl_ar300_leds_gpio);
  12240. + ath79_register_gpio_keys_polled(-1, GL_AR300_KEYS_POLL_INTERVAL,
  12241. + ARRAY_SIZE(gl_ar300_gpio_keys),
  12242. + gl_ar300_gpio_keys);
  12243. +
  12244. + /* enable usb */
  12245. + ath79_register_usb();
  12246. + ath79_register_mdio(1, 0x0);
  12247. +
  12248. + /* register eth0 as WAN, eth1 as LAN */
  12249. + ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR300_MAC0_OFFSET, 0);
  12250. + ath79_switch_data.phy4_mii_en = 1;
  12251. + ath79_switch_data.phy_poll_mask = BIT(4);
  12252. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  12253. + ath79_eth0_data.phy_mask = BIT(4);
  12254. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  12255. + ath79_register_eth(0);
  12256. +
  12257. + ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR300_MAC1_OFFSET, 0);
  12258. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  12259. + ath79_register_eth(1);
  12260. +
  12261. + /* register wireless mac with cal data */
  12262. + ath79_register_wmac(art + GL_AR300_CALDATA_OFFSET, art + GL_AR300_WMAC_MAC_OFFSET);
  12263. +}
  12264. +
  12265. +MIPS_MACHINE(ATH79_MACH_GL_AR300, "GL-AR300", "GL AR300",gl_ar300_setup);
  12266. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gl-domino.c linux-4.1.13/arch/mips/ath79/mach-gl-domino.c
  12267. --- linux-4.1.13.orig/arch/mips/ath79/mach-gl-domino.c 1970-01-01 01:00:00.000000000 +0100
  12268. +++ linux-4.1.13/arch/mips/ath79/mach-gl-domino.c 2015-12-04 18:27:35.461807609 +0100
  12269. @@ -0,0 +1,136 @@
  12270. +/*
  12271. + * Domino board support
  12272. + *
  12273. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  12274. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  12275. + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  12276. + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  12277. + *
  12278. + * This program is free software; you can redistribute it and/or modify it
  12279. + * under the terms of the GNU General Public License version 2 as published
  12280. + * by the Free Software Foundation.
  12281. +*/
  12282. +
  12283. +#include <linux/gpio.h>
  12284. +
  12285. +#include <asm/mach-ath79/ath79.h>
  12286. +
  12287. +#include "dev-eth.h"
  12288. +#include "dev-gpio-buttons.h"
  12289. +#include "dev-leds-gpio.h"
  12290. +#include "dev-m25p80.h"
  12291. +#include "dev-usb.h"
  12292. +#include "dev-wmac.h"
  12293. +#include "machtypes.h"
  12294. +
  12295. +#define DOMINO_GPIO_LED_WLAN 0
  12296. +#define DOMINO_GPIO_LED_WAN 17
  12297. +#define DOMINO_GPIO_LED_USB 1
  12298. +#define DOMINO_GPIO_LED_LAN1 13
  12299. +#define DOMINO_GPIO_LED_LAN2 14
  12300. +#define DOMINO_GPIO_LED_LAN3 15
  12301. +#define DOMINO_GPIO_LED_LAN4 16
  12302. +#define DOMINO_GPIO_LED_SYS 27
  12303. +#define DOMINO_GPIO_LED_WPS 26
  12304. +#define DOMINO_GPIO_USB_POWER 6
  12305. +
  12306. +#define DOMINO_GPIO_BTN_RESET 11
  12307. +#define DOMINO_GPIO_BTN_WPS 20
  12308. +
  12309. +#define DOMINO_KEYS_POLL_INTERVAL 20 /* msecs */
  12310. +#define DOMINO_KEYS_DEBOUNCE_INTERVAL (3 * DOMINO_KEYS_POLL_INTERVAL)
  12311. +
  12312. +#define DOMINO_MAC0_OFFSET 0x0000
  12313. +#define DOMINO_MAC1_OFFSET 0x0000
  12314. +#define DOMINO_CALDATA_OFFSET 0x1000
  12315. +#define DOMINO_WMAC_MAC_OFFSET 0x0000
  12316. +
  12317. +static struct gpio_led domino_leds_gpio[] __initdata = {
  12318. + {
  12319. + .name = "domino:blue:wlan",
  12320. + .gpio = DOMINO_GPIO_LED_WLAN,
  12321. + .active_low = 0,
  12322. + },
  12323. + {
  12324. + .name = "domino:red:wan",
  12325. + .gpio = DOMINO_GPIO_LED_WAN,
  12326. + .active_low = 1,
  12327. + },
  12328. + {
  12329. + .name = "domino:white:usb",
  12330. + .gpio = DOMINO_GPIO_LED_USB,
  12331. + .active_low = 0,
  12332. + },
  12333. + {
  12334. + .name = "domino:green:lan1",
  12335. + .gpio = DOMINO_GPIO_LED_LAN1,
  12336. + .active_low = 0,
  12337. + },
  12338. + {
  12339. + .name = "domino:yellow:wps",
  12340. + .gpio = DOMINO_GPIO_LED_WPS,
  12341. + .active_low = 1,
  12342. + },
  12343. + {
  12344. + .name = "domino:orange:sys",
  12345. + .gpio = DOMINO_GPIO_LED_SYS,
  12346. + .active_low = 1,
  12347. + },
  12348. +};
  12349. +
  12350. +static struct gpio_keys_button domino_gpio_keys[] __initdata = {
  12351. + {
  12352. + .desc = "reset",
  12353. + .type = EV_KEY,
  12354. + .code = KEY_RESTART,
  12355. + .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
  12356. + .gpio = DOMINO_GPIO_BTN_RESET,
  12357. + .active_low = 0,
  12358. + },
  12359. + {
  12360. + .desc = "wps",
  12361. + .type = EV_KEY,
  12362. + .code = KEY_WPS_BUTTON,
  12363. + .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
  12364. + .gpio = DOMINO_GPIO_BTN_WPS,
  12365. + .active_low = 0,
  12366. + }
  12367. +};
  12368. +
  12369. +static void __init domino_setup(void)
  12370. +{
  12371. +
  12372. + /* ART base address */
  12373. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  12374. +
  12375. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  12376. + ath79_setup_ar933x_phy4_switch(false, false);
  12377. +
  12378. + /* register flash. */
  12379. + ath79_register_m25p80(NULL);
  12380. +
  12381. + /* register gpio LEDs and keys */
  12382. + ath79_register_leds_gpio(-1, ARRAY_SIZE(domino_leds_gpio),
  12383. + domino_leds_gpio);
  12384. + ath79_register_gpio_keys_polled(-1, DOMINO_KEYS_POLL_INTERVAL,
  12385. + ARRAY_SIZE(domino_gpio_keys),
  12386. + domino_gpio_keys);
  12387. +
  12388. + gpio_request_one(DOMINO_GPIO_USB_POWER,
  12389. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12390. + "USB power");
  12391. + /* enable usb */
  12392. + ath79_register_usb();
  12393. +
  12394. + /* register eth0 as WAN, eth1 as LAN */
  12395. + ath79_init_mac(ath79_eth0_data.mac_addr, art+DOMINO_MAC0_OFFSET, 0);
  12396. + ath79_init_mac(ath79_eth1_data.mac_addr, art+DOMINO_MAC1_OFFSET, 0);
  12397. + ath79_register_mdio(0, 0x0);
  12398. + ath79_register_eth(0);
  12399. + ath79_register_eth(1);
  12400. +
  12401. + /* register wireless mac with cal data */
  12402. + ath79_register_wmac(art + DOMINO_CALDATA_OFFSET, art + DOMINO_WMAC_MAC_OFFSET);
  12403. +}
  12404. +
  12405. +MIPS_MACHINE(ATH79_MACH_GL_DOMINO, "DOMINO", "Domino Pi", domino_setup);
  12406. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gl-inet.c linux-4.1.13/arch/mips/ath79/mach-gl-inet.c
  12407. --- linux-4.1.13.orig/arch/mips/ath79/mach-gl-inet.c 1970-01-01 01:00:00.000000000 +0100
  12408. +++ linux-4.1.13/arch/mips/ath79/mach-gl-inet.c 2015-09-13 20:04:35.068524086 +0200
  12409. @@ -0,0 +1,104 @@
  12410. +/*
  12411. + * GL-CONNECT iNet board support
  12412. + *
  12413. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  12414. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  12415. + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  12416. + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  12417. + *
  12418. + * This program is free software; you can redistribute it and/or modify it
  12419. + * under the terms of the GNU General Public License version 2 as published
  12420. + * by the Free Software Foundation.
  12421. + */
  12422. +
  12423. +#include <linux/gpio.h>
  12424. +
  12425. +#include <asm/mach-ath79/ath79.h>
  12426. +
  12427. +#include "dev-eth.h"
  12428. +#include "dev-gpio-buttons.h"
  12429. +#include "dev-leds-gpio.h"
  12430. +#include "dev-m25p80.h"
  12431. +#include "dev-usb.h"
  12432. +#include "dev-wmac.h"
  12433. +#include "machtypes.h"
  12434. +
  12435. +#define GL_INET_GPIO_LED_WLAN 0
  12436. +#define GL_INET_GPIO_LED_LAN 13
  12437. +#define GL_INET_GPIO_BTN_RESET 11
  12438. +
  12439. +#define GL_INET_KEYS_POLL_INTERVAL 20 /* msecs */
  12440. +#define GL_INET_KEYS_DEBOUNCE_INTERVAL (3 * GL_INET_KEYS_POLL_INTERVAL)
  12441. +
  12442. +static const char * gl_inet_part_probes[] = {
  12443. + "tp-link", /* dont change, this will use tplink parser */
  12444. + NULL ,
  12445. +};
  12446. +
  12447. +static struct flash_platform_data gl_inet_flash_data = {
  12448. + .part_probes = gl_inet_part_probes,
  12449. +};
  12450. +
  12451. +static struct gpio_led gl_inet_leds_gpio[] __initdata = {
  12452. + {
  12453. + .name = "gl-connect:red:wlan",
  12454. + .gpio = GL_INET_GPIO_LED_WLAN,
  12455. + .active_low = 0,
  12456. + },
  12457. + {
  12458. + .name = "gl-connect:green:lan",
  12459. + .gpio = GL_INET_GPIO_LED_LAN,
  12460. + .active_low = 0,
  12461. + .default_state = 1,
  12462. + },
  12463. +};
  12464. +
  12465. +static struct gpio_keys_button gl_inet_gpio_keys[] __initdata = {
  12466. + {
  12467. + .desc = "reset",
  12468. + .type = EV_KEY,
  12469. + .code = KEY_RESTART,
  12470. + .debounce_interval = GL_INET_KEYS_DEBOUNCE_INTERVAL,
  12471. + .gpio = GL_INET_GPIO_BTN_RESET,
  12472. + .active_low = 0,
  12473. + }
  12474. +};
  12475. +
  12476. +static void __init gl_inet_setup(void)
  12477. +{
  12478. + /* get the mac address which is stored in the 1st 64k uboot MTD */
  12479. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  12480. +
  12481. + /* get the art address, which is the last 64K. By using
  12482. + 0x1fff1000, it doesn't matter it is 4M, 8M or 16M flash */
  12483. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  12484. +
  12485. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  12486. + ath79_setup_ar933x_phy4_switch(false, false);
  12487. +
  12488. + /* register flash. MTD will use tp-link parser to parser MTD */
  12489. + ath79_register_m25p80(&gl_inet_flash_data);
  12490. +
  12491. + /* register gpio LEDs and keys */
  12492. + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_inet_leds_gpio),
  12493. + gl_inet_leds_gpio);
  12494. + ath79_register_gpio_keys_polled(-1, GL_INET_KEYS_POLL_INTERVAL,
  12495. + ARRAY_SIZE(gl_inet_gpio_keys),
  12496. + gl_inet_gpio_keys);
  12497. +
  12498. + /* enable usb */
  12499. + ath79_register_usb();
  12500. +
  12501. + /* register eth0 as WAN, eth1 as LAN */
  12502. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  12503. + ath79_register_mdio(0, 0x0);
  12504. + ath79_register_eth(0);
  12505. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  12506. + ath79_register_eth(1);
  12507. +
  12508. + /* register wireless mac with cal data */
  12509. + ath79_register_wmac(ee, mac);
  12510. +}
  12511. +
  12512. +MIPS_MACHINE(ATH79_MACH_GL_INET, "GL-INET", "GL-CONNECT INET v1",
  12513. + gl_inet_setup);
  12514. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gs-minibox-v1.c linux-4.1.13/arch/mips/ath79/mach-gs-minibox-v1.c
  12515. --- linux-4.1.13.orig/arch/mips/ath79/mach-gs-minibox-v1.c 1970-01-01 01:00:00.000000000 +0100
  12516. +++ linux-4.1.13/arch/mips/ath79/mach-gs-minibox-v1.c 2015-11-21 17:22:11.759223549 +0100
  12517. @@ -0,0 +1,85 @@
  12518. +/*
  12519. + * Gainstrong MiniBox V1.0 board support
  12520. + *
  12521. + *
  12522. + * This program is free software; you can redistribute it and/or modify it
  12523. + * under the terms of the GNU General Public License version 2 as published
  12524. + * by the Free Software Foundation.
  12525. + */
  12526. +
  12527. +#include <linux/gpio.h>
  12528. +
  12529. +#include <asm/mach-ath79/ath79.h>
  12530. +#include <asm/mach-ath79/ar71xx_regs.h>
  12531. +
  12532. +#include "common.h"
  12533. +#include "dev-eth.h"
  12534. +#include "dev-gpio-buttons.h"
  12535. +#include "dev-leds-gpio.h"
  12536. +#include "dev-m25p80.h"
  12537. +#include "dev-usb.h"
  12538. +#include "dev-wmac.h"
  12539. +#include "machtypes.h"
  12540. +
  12541. +#define GS_MINIBOX_V1_GPIO_BTN_RESET 11
  12542. +
  12543. +#define GS_MINIBOX_V1_GPIO_LED_SYSTEM 1
  12544. +
  12545. +#define GS_MINIBOX_V1_KEYS_POLL_INTERVAL 20 /* msecs */
  12546. +#define GS_MINIBOX_V1_KEYS_DEBOUNCE_INTERVAL (3 * GS_MINIBOX_V1_KEYS_POLL_INTERVAL)
  12547. +
  12548. +static const char *gs_minibox_v1_part_probes[] = {
  12549. + "tp-link",
  12550. + NULL,
  12551. +};
  12552. +
  12553. +static struct flash_platform_data gs_minibox_v1_flash_data = {
  12554. + .part_probes = gs_minibox_v1_part_probes,
  12555. +};
  12556. +
  12557. +static struct gpio_led gs_minibox_v1_leds_gpio[] __initdata = {
  12558. + {
  12559. + .name = "minibox-v1:green:system",
  12560. + .gpio = GS_MINIBOX_V1_GPIO_LED_SYSTEM,
  12561. + .active_low = 1,
  12562. + },
  12563. +};
  12564. +
  12565. +static struct gpio_keys_button gs_minibox_v1_gpio_keys[] __initdata = {
  12566. + {
  12567. + .desc = "reset",
  12568. + .type = EV_KEY,
  12569. + .code = KEY_RESTART,
  12570. + .debounce_interval = GS_MINIBOX_V1_KEYS_DEBOUNCE_INTERVAL,
  12571. + .gpio = GS_MINIBOX_V1_GPIO_BTN_RESET,
  12572. + .active_low = 0,
  12573. + },
  12574. +};
  12575. +
  12576. +static void __init gs_minibox_v1_setup(void)
  12577. +{
  12578. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  12579. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  12580. +
  12581. + ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_minibox_v1_leds_gpio),
  12582. + gs_minibox_v1_leds_gpio);
  12583. +
  12584. + ath79_register_gpio_keys_polled(-1, GS_MINIBOX_V1_KEYS_POLL_INTERVAL,
  12585. + ARRAY_SIZE(gs_minibox_v1_gpio_keys),
  12586. + gs_minibox_v1_gpio_keys);
  12587. +
  12588. + ath79_register_usb();
  12589. +
  12590. + ath79_register_m25p80(&gs_minibox_v1_flash_data);
  12591. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  12592. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  12593. +
  12594. + ath79_register_mdio(0, 0x0);
  12595. + ath79_register_eth(1);
  12596. + ath79_register_eth(0);
  12597. +
  12598. + ath79_register_wmac(ee, mac);
  12599. +}
  12600. +
  12601. +MIPS_MACHINE(ATH79_MACH_GS_MINIBOX_V1, "MINIBOX-V1",
  12602. + "MiniBox V1.0", gs_minibox_v1_setup);
  12603. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-gs-oolite.c linux-4.1.13/arch/mips/ath79/mach-gs-oolite.c
  12604. --- linux-4.1.13.orig/arch/mips/ath79/mach-gs-oolite.c 1970-01-01 01:00:00.000000000 +0100
  12605. +++ linux-4.1.13/arch/mips/ath79/mach-gs-oolite.c 2015-09-13 20:04:35.068524086 +0200
  12606. @@ -0,0 +1,103 @@
  12607. +/*
  12608. + * Oolite board support
  12609. + *
  12610. + *
  12611. + * This program is free software; you can redistribute it and/or modify it
  12612. + * under the terms of the GNU General Public License version 2 as published
  12613. + * by the Free Software Foundation.
  12614. + */
  12615. +
  12616. +#include <linux/gpio.h>
  12617. +
  12618. +#include <asm/mach-ath79/ath79.h>
  12619. +#include <asm/mach-ath79/ar71xx_regs.h>
  12620. +
  12621. +#include "common.h"
  12622. +#include "dev-eth.h"
  12623. +#include "dev-gpio-buttons.h"
  12624. +#include "dev-leds-gpio.h"
  12625. +#include "dev-m25p80.h"
  12626. +#include "dev-wmac.h"
  12627. +#include "machtypes.h"
  12628. +#include "dev-usb.h"
  12629. +
  12630. +#define GS_OOLITE_GPIO_BTN6 6
  12631. +#define GS_OOLITE_GPIO_BTN7 7
  12632. +#define GS_OOLITE_GPIO_BTN_RESET 11
  12633. +
  12634. +#define GS_OOLITE_GPIO_LED_SYSTEM 27
  12635. +
  12636. +#define GS_OOLITE_KEYS_POLL_INTERVAL 20 /* msecs */
  12637. +#define GS_OOLITE_KEYS_DEBOUNCE_INTERVAL (3 * GS_OOLITE_KEYS_POLL_INTERVAL)
  12638. +
  12639. +static const char *gs_oolite_part_probes[] = {
  12640. + "tp-link",
  12641. + NULL,
  12642. +};
  12643. +
  12644. +static struct flash_platform_data gs_oolite_flash_data = {
  12645. + .part_probes = gs_oolite_part_probes,
  12646. +};
  12647. +
  12648. +static struct gpio_led gs_oolite_leds_gpio[] __initdata = {
  12649. + {
  12650. + .name = "oolite:red:system",
  12651. + .gpio = GS_OOLITE_GPIO_LED_SYSTEM,
  12652. + .active_low = 1,
  12653. + },
  12654. +};
  12655. +
  12656. +static struct gpio_keys_button gs_oolite_gpio_keys[] __initdata = {
  12657. + {
  12658. + .desc = "reset",
  12659. + .type = EV_KEY,
  12660. + .code = KEY_RESTART,
  12661. + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
  12662. + .gpio = GS_OOLITE_GPIO_BTN_RESET,
  12663. + .active_low = 0,
  12664. + },
  12665. + {
  12666. + .desc = "BTN_6",
  12667. + .type = EV_KEY,
  12668. + .code = BTN_6,
  12669. + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
  12670. + .gpio = GS_OOLITE_GPIO_BTN6,
  12671. + .active_low = 0,
  12672. + },
  12673. + {
  12674. + .desc = "BTN_7",
  12675. + .type = EV_KEY,
  12676. + .code = BTN_7,
  12677. + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
  12678. + .gpio = GS_OOLITE_GPIO_BTN7,
  12679. + .active_low = 0,
  12680. + },
  12681. +};
  12682. +
  12683. +static void __init gs_oolite_setup(void)
  12684. +{
  12685. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  12686. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  12687. +
  12688. + ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_oolite_leds_gpio),
  12689. + gs_oolite_leds_gpio);
  12690. +
  12691. + ath79_register_gpio_keys_polled(-1, GS_OOLITE_KEYS_POLL_INTERVAL,
  12692. + ARRAY_SIZE(gs_oolite_gpio_keys),
  12693. + gs_oolite_gpio_keys);
  12694. +
  12695. + ath79_register_usb();
  12696. +
  12697. + ath79_register_m25p80(&gs_oolite_flash_data);
  12698. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  12699. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  12700. +
  12701. + ath79_register_mdio(0, 0x0);
  12702. + ath79_register_eth(1);
  12703. + ath79_register_eth(0);
  12704. +
  12705. + ath79_register_wmac(ee, mac);
  12706. +}
  12707. +
  12708. +MIPS_MACHINE(ATH79_MACH_GS_OOLITE, "GS-OOLITE",
  12709. + "Oolite V1.0", gs_oolite_setup);
  12710. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-hiwifi-hc6361.c linux-4.1.13/arch/mips/ath79/mach-hiwifi-hc6361.c
  12711. --- linux-4.1.13.orig/arch/mips/ath79/mach-hiwifi-hc6361.c 1970-01-01 01:00:00.000000000 +0100
  12712. +++ linux-4.1.13/arch/mips/ath79/mach-hiwifi-hc6361.c 2015-09-13 20:04:35.068524086 +0200
  12713. @@ -0,0 +1,115 @@
  12714. +/*
  12715. + * HiWiFi HC6361 board support
  12716. + *
  12717. + * Copyright (C) 2012-2013 eric
  12718. + * Copyright (C) 2014 Yousong Zhou <yszhou4tech@gmail.com>
  12719. + *
  12720. + * This program is free software; you can redistribute it and/or modify it
  12721. + * under the terms of the GNU General Public License version 2 as published
  12722. + * by the Free Software Foundation.
  12723. + */
  12724. +
  12725. +#include <linux/gpio.h>
  12726. +#include <linux/proc_fs.h>
  12727. +
  12728. +#include <asm/mach-ath79/ath79.h>
  12729. +#include <asm/mach-ath79/ar71xx_regs.h>
  12730. +
  12731. +#include "common.h"
  12732. +#include "dev-eth.h"
  12733. +#include "dev-gpio-buttons.h"
  12734. +#include "dev-leds-gpio.h"
  12735. +#include "dev-m25p80.h"
  12736. +#include "dev-usb.h"
  12737. +#include "dev-wmac.h"
  12738. +#include "machtypes.h"
  12739. +
  12740. +#define HIWIFI_HC6361_GPIO_LED_WLAN_2P4 0 /* 2.4G WLAN LED */
  12741. +#define HIWIFI_HC6361_GPIO_LED_SYSTEM 1 /* System LED */
  12742. +#define HIWIFI_HC6361_GPIO_LED_INTERNET 27 /* Internet LED */
  12743. +
  12744. +#define HIWIFI_HC6361_GPIO_USBPOWER 20 /* USB power control */
  12745. +#define HIWIFI_HC6361_GPIO_BTN_RST 11 /* Reset button */
  12746. +
  12747. +#define HIWIFI_HC6361_KEYS_POLL_INTERVAL 20 /* msecs */
  12748. +#define HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL \
  12749. + (3 * HIWIFI_HC6361_KEYS_POLL_INTERVAL)
  12750. +
  12751. +static struct gpio_led hiwifi_leds_gpio[] __initdata = {
  12752. + {
  12753. + .name = "hiwifi:blue:wlan-2p4",
  12754. + .gpio = HIWIFI_HC6361_GPIO_LED_WLAN_2P4,
  12755. + .active_low = 1,
  12756. + }, {
  12757. + .name = "hiwifi:blue:system",
  12758. + .gpio = HIWIFI_HC6361_GPIO_LED_SYSTEM,
  12759. + .active_low = 1,
  12760. + }, {
  12761. + .name = "hiwifi:blue:internet",
  12762. + .gpio = HIWIFI_HC6361_GPIO_LED_INTERNET,
  12763. + .active_low = 1,
  12764. + }
  12765. +};
  12766. +
  12767. +static struct gpio_keys_button hiwifi_gpio_keys[] __initdata = {
  12768. + {
  12769. + .desc = "reset",
  12770. + .type = EV_KEY,
  12771. + .code = KEY_RESTART,
  12772. + .debounce_interval = HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL,
  12773. + .gpio = HIWIFI_HC6361_GPIO_BTN_RST,
  12774. + .active_low = 1,
  12775. + }
  12776. +};
  12777. +
  12778. +static void __init get_mac_from_bdinfo(u8 *mac, void *bdinfo)
  12779. +{
  12780. + if (sscanf(bdinfo, "fac_mac = %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
  12781. + &mac[0], &mac[1], &mac[2], &mac[3],
  12782. + &mac[4], &mac[5]) == 6) {
  12783. + return;
  12784. + }
  12785. +
  12786. + printk(KERN_WARNING "Parsing MAC address failed.\n");
  12787. + memcpy(mac, "\x00\xba\xbe\x00\x00\x00", 6);
  12788. +}
  12789. +
  12790. +static void __init hiwifi_hc6361_setup(void)
  12791. +{
  12792. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  12793. + u8 mac[6];
  12794. +
  12795. + ath79_setup_ar933x_phy4_switch(false, false);
  12796. +
  12797. + ath79_register_m25p80(NULL);
  12798. + ath79_gpio_function_enable(
  12799. + AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  12800. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  12801. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  12802. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  12803. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  12804. +
  12805. + ath79_register_leds_gpio(-1, ARRAY_SIZE(hiwifi_leds_gpio),
  12806. + hiwifi_leds_gpio);
  12807. + ath79_register_gpio_keys_polled(-1, HIWIFI_HC6361_KEYS_POLL_INTERVAL,
  12808. + ARRAY_SIZE(hiwifi_gpio_keys),
  12809. + hiwifi_gpio_keys);
  12810. + gpio_request_one(HIWIFI_HC6361_GPIO_USBPOWER,
  12811. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12812. + "USB power");
  12813. + ath79_register_usb();
  12814. +
  12815. + get_mac_from_bdinfo(mac, (void *) KSEG1ADDR(0x1f010180));
  12816. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  12817. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  12818. +
  12819. + ath79_register_mdio(0, 0x0);
  12820. +
  12821. + ath79_register_eth(1);
  12822. + ath79_register_eth(0);
  12823. +
  12824. + ath79_register_wmac(ee, mac);
  12825. +}
  12826. +
  12827. +MIPS_MACHINE(ATH79_MACH_HIWIFI_HC6361, "HiWiFi-HC6361",
  12828. + "HiWiFi HC6361", hiwifi_hc6361_setup);
  12829. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-hornet-ub.c linux-4.1.13/arch/mips/ath79/mach-hornet-ub.c
  12830. --- linux-4.1.13.orig/arch/mips/ath79/mach-hornet-ub.c 1970-01-01 01:00:00.000000000 +0100
  12831. +++ linux-4.1.13/arch/mips/ath79/mach-hornet-ub.c 2015-09-13 20:04:35.068524086 +0200
  12832. @@ -0,0 +1,142 @@
  12833. +/*
  12834. + * ALFA NETWORK Hornet-UB board support
  12835. + *
  12836. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  12837. + *
  12838. + * This program is free software; you can redistribute it and/or modify it
  12839. + * under the terms of the GNU General Public License version 2 as published
  12840. + * by the Free Software Foundation.
  12841. + */
  12842. +
  12843. +#include <linux/gpio.h>
  12844. +
  12845. +#include <asm/mach-ath79/ath79.h>
  12846. +#include <asm/mach-ath79/ar71xx_regs.h>
  12847. +
  12848. +#include "common.h"
  12849. +#include "dev-eth.h"
  12850. +#include "dev-gpio-buttons.h"
  12851. +#include "dev-leds-gpio.h"
  12852. +#include "dev-m25p80.h"
  12853. +#include "dev-usb.h"
  12854. +#include "dev-wmac.h"
  12855. +#include "machtypes.h"
  12856. +
  12857. +#define HORNET_UB_GPIO_LED_WLAN 0
  12858. +#define HORNET_UB_GPIO_LED_USB 1
  12859. +#define HORNET_UB_GPIO_LED_LAN 13
  12860. +#define HORNET_UB_GPIO_LED_WAN 17
  12861. +#define HORNET_UB_GPIO_LED_WPS 27
  12862. +#define HORNET_UB_GPIO_EXT_LNA 28
  12863. +
  12864. +#define HORNET_UB_GPIO_BTN_RESET 12
  12865. +#define HORNET_UB_GPIO_BTN_WPS 11
  12866. +
  12867. +#define HORNET_UB_GPIO_USB_POWER 26
  12868. +
  12869. +#define HORNET_UB_KEYS_POLL_INTERVAL 20 /* msecs */
  12870. +#define HORNET_UB_KEYS_DEBOUNCE_INTERVAL (3 * HORNET_UB_KEYS_POLL_INTERVAL)
  12871. +
  12872. +#define HORNET_UB_MAC0_OFFSET 0x0000
  12873. +#define HORNET_UB_MAC1_OFFSET 0x0006
  12874. +#define HORNET_UB_CALDATA_OFFSET 0x1000
  12875. +
  12876. +static struct gpio_led hornet_ub_leds_gpio[] __initdata = {
  12877. + {
  12878. + .name = "alfa:blue:lan",
  12879. + .gpio = HORNET_UB_GPIO_LED_LAN,
  12880. + .active_low = 0,
  12881. + },
  12882. + {
  12883. + .name = "alfa:blue:usb",
  12884. + .gpio = HORNET_UB_GPIO_LED_USB,
  12885. + .active_low = 0,
  12886. + },
  12887. + {
  12888. + .name = "alfa:blue:wan",
  12889. + .gpio = HORNET_UB_GPIO_LED_WAN,
  12890. + .active_low = 1,
  12891. + },
  12892. + {
  12893. + .name = "alfa:blue:wlan",
  12894. + .gpio = HORNET_UB_GPIO_LED_WLAN,
  12895. + .active_low = 0,
  12896. + },
  12897. + {
  12898. + .name = "alfa:blue:wps",
  12899. + .gpio = HORNET_UB_GPIO_LED_WPS,
  12900. + .active_low = 1,
  12901. + },
  12902. +};
  12903. +
  12904. +static struct gpio_keys_button hornet_ub_gpio_keys[] __initdata = {
  12905. + {
  12906. + .desc = "WPS button",
  12907. + .type = EV_KEY,
  12908. + .code = KEY_WPS_BUTTON,
  12909. + .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
  12910. + .gpio = HORNET_UB_GPIO_BTN_WPS,
  12911. + .active_low = 0,
  12912. + },
  12913. + {
  12914. + .desc = "Reset button",
  12915. + .type = EV_KEY,
  12916. + .code = KEY_RESTART,
  12917. + .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
  12918. + .gpio = HORNET_UB_GPIO_BTN_RESET,
  12919. + .active_low = 1,
  12920. + }
  12921. +};
  12922. +
  12923. +static void __init hornet_ub_gpio_setup(void)
  12924. +{
  12925. + u32 t;
  12926. +
  12927. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  12928. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  12929. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  12930. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  12931. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  12932. +
  12933. + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  12934. + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  12935. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  12936. +
  12937. + gpio_request_one(HORNET_UB_GPIO_USB_POWER,
  12938. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12939. + "USB power");
  12940. + gpio_request_one(HORNET_UB_GPIO_EXT_LNA,
  12941. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  12942. + "external LNA0");
  12943. +
  12944. +}
  12945. +
  12946. +static void __init hornet_ub_setup(void)
  12947. +{
  12948. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  12949. +
  12950. + hornet_ub_gpio_setup();
  12951. +
  12952. + ath79_register_m25p80(NULL);
  12953. + ath79_register_leds_gpio(-1, ARRAY_SIZE(hornet_ub_leds_gpio),
  12954. + hornet_ub_leds_gpio);
  12955. + ath79_register_gpio_keys_polled(-1, HORNET_UB_KEYS_POLL_INTERVAL,
  12956. + ARRAY_SIZE(hornet_ub_gpio_keys),
  12957. + hornet_ub_gpio_keys);
  12958. +
  12959. + ath79_init_mac(ath79_eth1_data.mac_addr,
  12960. + art + HORNET_UB_MAC0_OFFSET, 0);
  12961. + ath79_init_mac(ath79_eth0_data.mac_addr,
  12962. + art + HORNET_UB_MAC1_OFFSET, 0);
  12963. +
  12964. + ath79_register_mdio(0, 0x0);
  12965. +
  12966. + ath79_register_eth(1);
  12967. + ath79_register_eth(0);
  12968. +
  12969. + ath79_register_wmac(art + HORNET_UB_CALDATA_OFFSET, NULL);
  12970. + ath79_register_usb();
  12971. +}
  12972. +
  12973. +MIPS_MACHINE(ATH79_MACH_HORNET_UB, "HORNET-UB", "ALFA NETWORK Hornet-UB",
  12974. + hornet_ub_setup);
  12975. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ja76pf.c linux-4.1.13/arch/mips/ath79/mach-ja76pf.c
  12976. --- linux-4.1.13.orig/arch/mips/ath79/mach-ja76pf.c 1970-01-01 01:00:00.000000000 +0100
  12977. +++ linux-4.1.13/arch/mips/ath79/mach-ja76pf.c 2015-09-13 20:04:35.068524086 +0200
  12978. @@ -0,0 +1,190 @@
  12979. +/*
  12980. + * jjPlus JA76PF board support
  12981. + */
  12982. +
  12983. +#include <linux/i2c.h>
  12984. +#include <linux/i2c-gpio.h>
  12985. +#include <linux/platform_device.h>
  12986. +
  12987. +#include <asm/mach-ath79/ath79.h>
  12988. +
  12989. +#include "dev-eth.h"
  12990. +#include "dev-gpio-buttons.h"
  12991. +#include "dev-leds-gpio.h"
  12992. +#include "dev-m25p80.h"
  12993. +#include "dev-usb.h"
  12994. +#include "machtypes.h"
  12995. +#include "pci.h"
  12996. +
  12997. +#define JA76PF_KEYS_POLL_INTERVAL 20 /* msecs */
  12998. +#define JA76PF_KEYS_DEBOUNCE_INTERVAL (3 * JA76PF_KEYS_POLL_INTERVAL)
  12999. +
  13000. +#define JA76PF_GPIO_I2C_SCL 0
  13001. +#define JA76PF_GPIO_I2C_SDA 1
  13002. +#define JA76PF_GPIO_LED_1 5
  13003. +#define JA76PF_GPIO_LED_2 4
  13004. +#define JA76PF_GPIO_LED_3 3
  13005. +#define JA76PF_GPIO_BTN_RESET 11
  13006. +
  13007. +static struct gpio_led ja76pf_leds_gpio[] __initdata = {
  13008. + {
  13009. + .name = "jjplus:green:led1",
  13010. + .gpio = JA76PF_GPIO_LED_1,
  13011. + .active_low = 1,
  13012. + }, {
  13013. + .name = "jjplus:green:led2",
  13014. + .gpio = JA76PF_GPIO_LED_2,
  13015. + .active_low = 1,
  13016. + }, {
  13017. + .name = "jjplus:green:led3",
  13018. + .gpio = JA76PF_GPIO_LED_3,
  13019. + .active_low = 1,
  13020. + }
  13021. +};
  13022. +
  13023. +static struct gpio_keys_button ja76pf_gpio_keys[] __initdata = {
  13024. + {
  13025. + .desc = "reset",
  13026. + .type = EV_KEY,
  13027. + .code = KEY_RESTART,
  13028. + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  13029. + .gpio = JA76PF_GPIO_BTN_RESET,
  13030. + .active_low = 1,
  13031. + }
  13032. +};
  13033. +
  13034. +static struct i2c_gpio_platform_data ja76pf_i2c_gpio_data = {
  13035. + .sda_pin = JA76PF_GPIO_I2C_SDA,
  13036. + .scl_pin = JA76PF_GPIO_I2C_SCL,
  13037. +};
  13038. +
  13039. +static struct platform_device ja76pf_i2c_gpio_device = {
  13040. + .name = "i2c-gpio",
  13041. + .id = 0,
  13042. + .dev = {
  13043. + .platform_data = &ja76pf_i2c_gpio_data,
  13044. + }
  13045. +};
  13046. +
  13047. +static const char *ja76pf_part_probes[] = {
  13048. + "RedBoot",
  13049. + NULL,
  13050. +};
  13051. +
  13052. +static struct flash_platform_data ja76pf_flash_data = {
  13053. + .part_probes = ja76pf_part_probes,
  13054. +};
  13055. +
  13056. +#define JA76PF_WAN_PHYMASK (1 << 4)
  13057. +#define JA76PF_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 < 3))
  13058. +#define JA76PF_MDIO_PHYMASK (JA76PF_LAN_PHYMASK | JA76PF_WAN_PHYMASK)
  13059. +
  13060. +static void __init ja76pf_init(void)
  13061. +{
  13062. + ath79_register_m25p80(&ja76pf_flash_data);
  13063. +
  13064. + ath79_register_mdio(0, ~JA76PF_MDIO_PHYMASK);
  13065. +
  13066. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  13067. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13068. + ath79_eth0_data.phy_mask = JA76PF_LAN_PHYMASK;
  13069. +
  13070. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  13071. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13072. + ath79_eth1_data.phy_mask = JA76PF_WAN_PHYMASK;
  13073. + ath79_eth1_data.speed = SPEED_1000;
  13074. + ath79_eth1_data.duplex = DUPLEX_FULL;
  13075. +
  13076. + ath79_register_eth(0);
  13077. + ath79_register_eth(1);
  13078. +
  13079. + platform_device_register(&ja76pf_i2c_gpio_device);
  13080. +
  13081. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
  13082. + ja76pf_leds_gpio);
  13083. +
  13084. + ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
  13085. + ARRAY_SIZE(ja76pf_gpio_keys),
  13086. + ja76pf_gpio_keys);
  13087. +
  13088. + ath79_register_usb();
  13089. + ath79_register_pci();
  13090. +}
  13091. +
  13092. +MIPS_MACHINE(ATH79_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);
  13093. +
  13094. +#define JA76PF2_GPIO_LED_D2 5
  13095. +#define JA76PF2_GPIO_LED_D3 4
  13096. +#define JA76PF2_GPIO_LED_D4 3
  13097. +#define JA76PF2_GPIO_BTN_RESET 7
  13098. +#define JA76PF2_GPIO_BTN_WPS 8
  13099. +
  13100. +static struct gpio_led ja76pf2_leds_gpio[] __initdata = {
  13101. + {
  13102. + .name = "jjplus:green:led1",
  13103. + .gpio = JA76PF2_GPIO_LED_D2,
  13104. + .active_low = 1,
  13105. + }, {
  13106. + .name = "jjplus:green:led2",
  13107. + .gpio = JA76PF2_GPIO_LED_D3,
  13108. + .active_low = 0,
  13109. + }, {
  13110. + .name = "jjplus:green:led3",
  13111. + .gpio = JA76PF2_GPIO_LED_D4,
  13112. + .active_low = 0,
  13113. + }
  13114. +};
  13115. +
  13116. +static struct gpio_keys_button ja76pf2_gpio_keys[] __initdata = {
  13117. + {
  13118. + .desc = "reset",
  13119. + .type = EV_KEY,
  13120. + .code = KEY_RESTART,
  13121. + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  13122. + .gpio = JA76PF2_GPIO_BTN_RESET,
  13123. + .active_low = 1,
  13124. + },
  13125. + {
  13126. + .desc = "wps",
  13127. + .type = EV_KEY,
  13128. + .code = KEY_WPS_BUTTON,
  13129. + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  13130. + .gpio = JA76PF2_GPIO_BTN_WPS,
  13131. + .active_low = 1,
  13132. + },
  13133. +};
  13134. +
  13135. +#define JA76PF2_LAN_PHYMASK BIT(0)
  13136. +#define JA76PF2_WAN_PHYMASK BIT(4)
  13137. +#define JA76PF2_MDIO_PHYMASK (JA76PF2_LAN_PHYMASK | JA76PF2_WAN_PHYMASK)
  13138. +
  13139. +static void __init ja76pf2_init(void)
  13140. +{
  13141. + ath79_register_m25p80(&ja76pf_flash_data);
  13142. +
  13143. + ath79_register_mdio(0, ~JA76PF2_MDIO_PHYMASK);
  13144. +
  13145. + /* MAC0 is connected to the CPU port of the AR8316 switch */
  13146. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  13147. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13148. + ath79_eth0_data.phy_mask = BIT(0);
  13149. +
  13150. + /* MAC1 is connected to the PHY4 of the AR8316 switch */
  13151. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  13152. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13153. + ath79_eth1_data.phy_mask = BIT(4);
  13154. +
  13155. + ath79_register_eth(0);
  13156. + ath79_register_eth(1);
  13157. +
  13158. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf2_leds_gpio),
  13159. + ja76pf2_leds_gpio);
  13160. +
  13161. + ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
  13162. + ARRAY_SIZE(ja76pf2_gpio_keys),
  13163. + ja76pf2_gpio_keys);
  13164. +
  13165. + ath79_register_pci();
  13166. +}
  13167. +
  13168. +MIPS_MACHINE(ATH79_MACH_JA76PF2, "JA76PF2", "jjPlus JA76PF2", ja76pf2_init);
  13169. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-jwap003.c linux-4.1.13/arch/mips/ath79/mach-jwap003.c
  13170. --- linux-4.1.13.orig/arch/mips/ath79/mach-jwap003.c 1970-01-01 01:00:00.000000000 +0100
  13171. +++ linux-4.1.13/arch/mips/ath79/mach-jwap003.c 2015-09-13 20:04:35.068524086 +0200
  13172. @@ -0,0 +1,95 @@
  13173. +/*
  13174. + * jjPlus JWAP003 board support
  13175. + *
  13176. + */
  13177. +
  13178. +#include <linux/i2c.h>
  13179. +#include <linux/i2c-gpio.h>
  13180. +#include <linux/platform_device.h>
  13181. +
  13182. +#include <asm/mach-ath79/ath79.h>
  13183. +
  13184. +#include "dev-eth.h"
  13185. +#include "dev-m25p80.h"
  13186. +#include "dev-gpio-buttons.h"
  13187. +#include "dev-usb.h"
  13188. +#include "machtypes.h"
  13189. +#include "pci.h"
  13190. +
  13191. +#define JWAP003_KEYS_POLL_INTERVAL 20 /* msecs */
  13192. +#define JWAP003_KEYS_DEBOUNCE_INTERVAL (3 * JWAP003_KEYS_POLL_INTERVAL)
  13193. +
  13194. +#define JWAP003_GPIO_WPS 11
  13195. +#define JWAP003_GPIO_I2C_SCL 0
  13196. +#define JWAP003_GPIO_I2C_SDA 1
  13197. +
  13198. +static struct gpio_keys_button jwap003_gpio_keys[] __initdata = {
  13199. + {
  13200. + .desc = "wps",
  13201. + .type = EV_KEY,
  13202. + .code = KEY_WPS_BUTTON,
  13203. + .debounce_interval = JWAP003_KEYS_DEBOUNCE_INTERVAL,
  13204. + .gpio = JWAP003_GPIO_WPS,
  13205. + .active_low = 1,
  13206. + }
  13207. +};
  13208. +
  13209. +static struct i2c_gpio_platform_data jwap003_i2c_gpio_data = {
  13210. + .sda_pin = JWAP003_GPIO_I2C_SDA,
  13211. + .scl_pin = JWAP003_GPIO_I2C_SCL,
  13212. +};
  13213. +
  13214. +static struct platform_device jwap003_i2c_gpio_device = {
  13215. + .name = "i2c-gpio",
  13216. + .id = 0,
  13217. + .dev = {
  13218. + .platform_data = &jwap003_i2c_gpio_data,
  13219. + }
  13220. +};
  13221. +
  13222. +static const char *jwap003_part_probes[] = {
  13223. + "RedBoot",
  13224. + NULL,
  13225. +};
  13226. +
  13227. +static struct flash_platform_data jwap003_flash_data = {
  13228. + .part_probes = jwap003_part_probes,
  13229. +};
  13230. +
  13231. +#define JWAP003_WAN_PHYMASK BIT(0)
  13232. +#define JWAP003_LAN_PHYMASK BIT(4)
  13233. +
  13234. +static void __init jwap003_init(void)
  13235. +{
  13236. + ath79_register_m25p80(&jwap003_flash_data);
  13237. +
  13238. + ath79_register_mdio(0, 0x0);
  13239. +
  13240. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  13241. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  13242. + ath79_eth0_data.phy_mask = JWAP003_WAN_PHYMASK;
  13243. + ath79_eth0_data.speed = SPEED_100;
  13244. + ath79_eth0_data.duplex = DUPLEX_FULL;
  13245. + ath79_eth0_data.has_ar8216 = 1;
  13246. +
  13247. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  13248. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  13249. + ath79_eth1_data.phy_mask = JWAP003_LAN_PHYMASK;
  13250. + ath79_eth1_data.speed = SPEED_100;
  13251. + ath79_eth1_data.duplex = DUPLEX_FULL;
  13252. +
  13253. + ath79_register_eth(0);
  13254. + ath79_register_eth(1);
  13255. +
  13256. + platform_device_register(&jwap003_i2c_gpio_device);
  13257. +
  13258. + ath79_register_usb();
  13259. +
  13260. + ath79_register_gpio_keys_polled(-1, JWAP003_KEYS_POLL_INTERVAL,
  13261. + ARRAY_SIZE(jwap003_gpio_keys),
  13262. + jwap003_gpio_keys);
  13263. +
  13264. + ath79_register_pci();
  13265. +}
  13266. +
  13267. +MIPS_MACHINE(ATH79_MACH_JWAP003, "JWAP003", "jjPlus JWAP003", jwap003_init);
  13268. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mc-mac1200r.c linux-4.1.13/arch/mips/ath79/mach-mc-mac1200r.c
  13269. --- linux-4.1.13.orig/arch/mips/ath79/mach-mc-mac1200r.c 1970-01-01 01:00:00.000000000 +0100
  13270. +++ linux-4.1.13/arch/mips/ath79/mach-mc-mac1200r.c 2015-09-13 20:04:35.068524086 +0200
  13271. @@ -0,0 +1,155 @@
  13272. +/*
  13273. + * MERCURY MAC1200R board support
  13274. + *
  13275. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  13276. + * Copyright (C) 2013 Gui Iribarren <gui@altermundi.net>
  13277. + *
  13278. + * This program is free software; you can redistribute it and/or modify it
  13279. + * under the terms of the GNU General Public License version 2 as published
  13280. + * by the Free Software Foundation.
  13281. + */
  13282. +
  13283. +#include <linux/pci.h>
  13284. +#include <linux/phy.h>
  13285. +#include <linux/gpio.h>
  13286. +#include <linux/platform_device.h>
  13287. +#include <linux/ath9k_platform.h>
  13288. +#include <linux/ar8216_platform.h>
  13289. +
  13290. +#include <asm/mach-ath79/ar71xx_regs.h>
  13291. +
  13292. +#include "common.h"
  13293. +#include "dev-ap9x-pci.h"
  13294. +#include "dev-eth.h"
  13295. +#include "dev-gpio-buttons.h"
  13296. +#include "dev-leds-gpio.h"
  13297. +#include "dev-m25p80.h"
  13298. +#include "dev-spi.h"
  13299. +#include "dev-wmac.h"
  13300. +#include "machtypes.h"
  13301. +
  13302. +#define MAC1200R_GPIO_LED_WLAN2G 13
  13303. +#define MAC1200R_GPIO_LED_WLAN5G 17
  13304. +#define MAC1200R_GPIO_LED_SYSTEM 14
  13305. +#define MAC1200R_GPIO_LED_WPS 11
  13306. +#define MAC1200R_GPIO_LED_WAN 12
  13307. +#define MAC1200R_GPIO_LED_LAN1 15
  13308. +#define MAC1200R_GPIO_LED_LAN2 21
  13309. +#define MAC1200R_GPIO_LED_LAN3 22
  13310. +#define MAC1200R_GPIO_LED_LAN4 20
  13311. +
  13312. +#define MAC1200R_GPIO_BTN_WPS 16
  13313. +
  13314. +#define MAC1200R_KEYS_POLL_INTERVAL 20 /* msecs */
  13315. +#define MAC1200R_KEYS_DEBOUNCE_INTERVAL (3 * MAC1200R_KEYS_POLL_INTERVAL)
  13316. +
  13317. +#define MAC1200R_MAC0_OFFSET 0
  13318. +#define MAC1200R_MAC1_OFFSET 6
  13319. +#define MAC1200R_WMAC_CALDATA_OFFSET 0x1000
  13320. +#define MAC1200R_PCIE_CALDATA_OFFSET 0x5000
  13321. +
  13322. +static const char *mac1200r_part_probes[] = {
  13323. + "tp-link",
  13324. + NULL,
  13325. +};
  13326. +
  13327. +static struct flash_platform_data mac1200r_flash_data = {
  13328. + .part_probes = mac1200r_part_probes,
  13329. +};
  13330. +
  13331. +static struct gpio_led mac1200r_leds_gpio[] __initdata = {
  13332. + {
  13333. + .name = "mercury:green:wps",
  13334. + .gpio = MAC1200R_GPIO_LED_WPS,
  13335. + .active_low = 1,
  13336. + },
  13337. + {
  13338. + .name = "mercury:green:system",
  13339. + .gpio = MAC1200R_GPIO_LED_SYSTEM,
  13340. + .active_low = 1,
  13341. + },
  13342. + {
  13343. + .name = "mercury:green:wlan2g",
  13344. + .gpio = MAC1200R_GPIO_LED_WLAN2G,
  13345. + .active_low = 1,
  13346. + },
  13347. + {
  13348. + .name = "mercury:green:wlan5g",
  13349. + .gpio = MAC1200R_GPIO_LED_WLAN5G,
  13350. + .active_low = 1,
  13351. + },
  13352. +};
  13353. +
  13354. +static struct gpio_keys_button mac1200r_gpio_keys[] __initdata = {
  13355. + {
  13356. + .desc = "Reset button",
  13357. + .type = EV_KEY,
  13358. + .code = KEY_RESTART,
  13359. + .debounce_interval = MAC1200R_KEYS_DEBOUNCE_INTERVAL,
  13360. + .gpio = MAC1200R_GPIO_BTN_WPS,
  13361. + .active_low = 1,
  13362. + },
  13363. +};
  13364. +
  13365. +
  13366. +static void __init mac1200r_setup(void)
  13367. +{
  13368. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  13369. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  13370. + u8 tmpmac[ETH_ALEN];
  13371. +
  13372. + ath79_register_m25p80(&mac1200r_flash_data);
  13373. +
  13374. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mac1200r_leds_gpio),
  13375. + mac1200r_leds_gpio);
  13376. +
  13377. + ath79_register_gpio_keys_polled(-1, MAC1200R_KEYS_POLL_INTERVAL,
  13378. + ARRAY_SIZE(mac1200r_gpio_keys),
  13379. + mac1200r_gpio_keys);
  13380. +
  13381. + ath79_init_mac(tmpmac, mac, 0);
  13382. + ath79_wmac_disable_5ghz();
  13383. + ath79_register_wmac(art + MAC1200R_WMAC_CALDATA_OFFSET, tmpmac);
  13384. +
  13385. + ath79_init_mac(tmpmac, mac, 1);
  13386. + ap91_pci_init(art + MAC1200R_PCIE_CALDATA_OFFSET, tmpmac);
  13387. +
  13388. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  13389. +
  13390. + ath79_register_mdio(1, 0x0);
  13391. +
  13392. + /* LAN */
  13393. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  13394. +
  13395. + /* GMAC1 is connected to the internal switch */
  13396. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  13397. +
  13398. + ath79_register_eth(1);
  13399. +
  13400. + /* WAN */
  13401. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 2);
  13402. +
  13403. + /* GMAC0 is connected to the PHY4 of the internal switch */
  13404. + ath79_switch_data.phy4_mii_en = 1;
  13405. + ath79_switch_data.phy_poll_mask = BIT(4);
  13406. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  13407. + ath79_eth0_data.phy_mask = BIT(4);
  13408. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  13409. +
  13410. + ath79_register_eth(0);
  13411. +
  13412. + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN1,
  13413. + AR934X_GPIO_OUT_LED_LINK3);
  13414. + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN2,
  13415. + AR934X_GPIO_OUT_LED_LINK2);
  13416. + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN3,
  13417. + AR934X_GPIO_OUT_LED_LINK1);
  13418. + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN4,
  13419. + AR934X_GPIO_OUT_LED_LINK0);
  13420. + ath79_gpio_output_select(MAC1200R_GPIO_LED_WAN,
  13421. + AR934X_GPIO_OUT_LED_LINK4);
  13422. +}
  13423. +
  13424. +MIPS_MACHINE(ATH79_MACH_MC_MAC1200R, "MC-MAC1200R",
  13425. + "MERCURY MAC1200R",
  13426. + mac1200r_setup);
  13427. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mr12.c linux-4.1.13/arch/mips/ath79/mach-mr12.c
  13428. --- linux-4.1.13.orig/arch/mips/ath79/mach-mr12.c 1970-01-01 01:00:00.000000000 +0100
  13429. +++ linux-4.1.13/arch/mips/ath79/mach-mr12.c 2015-09-13 20:04:35.068524086 +0200
  13430. @@ -0,0 +1,115 @@
  13431. +/*
  13432. + * Cisco Meraki MR12 board support
  13433. + *
  13434. + * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
  13435. + *
  13436. + * Based on Atheros AP96 board support configuration
  13437. + *
  13438. + * Copyright (C) 2009 Marco Porsch
  13439. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  13440. + * Copyright (C) 2010 Atheros Communications
  13441. + *
  13442. + * This program is free software; you can redistribute it and/or modify it
  13443. + * under the terms of the GNU General Public License version 2 as published
  13444. + * by the Free Software Foundation.
  13445. + */
  13446. +
  13447. +#include <linux/platform_device.h>
  13448. +#include <linux/delay.h>
  13449. +
  13450. +#include <asm/mach-ath79/ath79.h>
  13451. +
  13452. +#include "dev-ap9x-pci.h"
  13453. +#include "dev-eth.h"
  13454. +#include "dev-gpio-buttons.h"
  13455. +#include "dev-leds-gpio.h"
  13456. +#include "dev-m25p80.h"
  13457. +#include "machtypes.h"
  13458. +
  13459. +#define MR12_GPIO_LED_W4_GREEN 14
  13460. +#define MR12_GPIO_LED_W3_GREEN 13
  13461. +#define MR12_GPIO_LED_W2_GREEN 12
  13462. +#define MR12_GPIO_LED_W1_GREEN 11
  13463. +
  13464. +#define MR12_GPIO_LED_WAN 15
  13465. +
  13466. +#define MR12_GPIO_LED_POWER_ORANGE 16
  13467. +#define MR12_GPIO_LED_POWER_GREEN 17
  13468. +
  13469. +#define MR12_GPIO_BTN_RESET 8
  13470. +#define MR12_KEYS_POLL_INTERVAL 20 /* msecs */
  13471. +#define MR12_KEYS_DEBOUNCE_INTERVAL (3 * MR12_KEYS_POLL_INTERVAL)
  13472. +
  13473. +#define MR12_WAN_PHYMASK BIT(4)
  13474. +
  13475. +#define MR12_WMAC0_MAC_OFFSET 0x120c
  13476. +#define MR12_CALDATA0_OFFSET 0x1000
  13477. +
  13478. +static struct gpio_led MR12_leds_gpio[] __initdata = {
  13479. + {
  13480. + .name = "mr12:green:wan",
  13481. + .gpio = MR12_GPIO_LED_WAN,
  13482. + .active_low = 1,
  13483. + }, {
  13484. + .name = "mr12:orange:power",
  13485. + .gpio = MR12_GPIO_LED_POWER_ORANGE,
  13486. + .active_low = 1,
  13487. + }, {
  13488. + .name = "mr12:green:power",
  13489. + .gpio = MR12_GPIO_LED_POWER_GREEN,
  13490. + .active_low = 1,
  13491. + }, {
  13492. + .name = "mr12:green:wifi4",
  13493. + .gpio = MR12_GPIO_LED_W4_GREEN,
  13494. + .active_low = 1,
  13495. + }, {
  13496. + .name = "mr12:green:wifi3",
  13497. + .gpio = MR12_GPIO_LED_W3_GREEN,
  13498. + .active_low = 1,
  13499. + }, {
  13500. + .name = "mr12:green:wifi2",
  13501. + .gpio = MR12_GPIO_LED_W2_GREEN,
  13502. + .active_low = 1,
  13503. + }, {
  13504. + .name = "mr12:green:wifi1",
  13505. + .gpio = MR12_GPIO_LED_W1_GREEN,
  13506. + .active_low = 1,
  13507. + }
  13508. +};
  13509. +
  13510. +static struct gpio_keys_button MR12_gpio_keys[] __initdata = {
  13511. + {
  13512. + .desc = "reset",
  13513. + .type = EV_KEY,
  13514. + .code = KEY_RESTART,
  13515. + .debounce_interval = MR12_KEYS_DEBOUNCE_INTERVAL,
  13516. + .gpio = MR12_GPIO_BTN_RESET,
  13517. + .active_low = 1,
  13518. + }
  13519. +};
  13520. +
  13521. +static void __init MR12_setup(void)
  13522. +{
  13523. + u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
  13524. +
  13525. + ath79_register_mdio(0,0x0);
  13526. +
  13527. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  13528. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13529. + ath79_eth0_data.phy_mask = MR12_WAN_PHYMASK;
  13530. + ath79_register_eth(0);
  13531. +
  13532. + ath79_register_m25p80(NULL);
  13533. +
  13534. + ath79_register_leds_gpio(-1, ARRAY_SIZE(MR12_leds_gpio),
  13535. + MR12_leds_gpio);
  13536. + ath79_register_gpio_keys_polled(-1, MR12_KEYS_POLL_INTERVAL,
  13537. + ARRAY_SIZE(MR12_gpio_keys),
  13538. + MR12_gpio_keys);
  13539. +
  13540. + ap91_pci_init(mac + MR12_CALDATA0_OFFSET,
  13541. + mac + MR12_WMAC0_MAC_OFFSET);
  13542. +
  13543. +}
  13544. +
  13545. +MIPS_MACHINE(ATH79_MACH_MR12, "MR12", "Meraki MR12", MR12_setup);
  13546. \ No newline at end of file
  13547. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mr16.c linux-4.1.13/arch/mips/ath79/mach-mr16.c
  13548. --- linux-4.1.13.orig/arch/mips/ath79/mach-mr16.c 1970-01-01 01:00:00.000000000 +0100
  13549. +++ linux-4.1.13/arch/mips/ath79/mach-mr16.c 2015-09-13 20:04:35.068524086 +0200
  13550. @@ -0,0 +1,118 @@
  13551. +/*
  13552. + * Cisco Meraki MR16 board support
  13553. + *
  13554. + * Copyright (C) 2015 Chris Blake <chrisrblake93@gmail.com>
  13555. + *
  13556. + * Based on Atheros AP96 board support configuration
  13557. + *
  13558. + * Copyright (C) 2009 Marco Porsch
  13559. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  13560. + * Copyright (C) 2010 Atheros Communications
  13561. + *
  13562. + * This program is free software; you can redistribute it and/or modify it
  13563. + * under the terms of the GNU General Public License version 2 as published
  13564. + * by the Free Software Foundation.
  13565. + */
  13566. +
  13567. +#include <linux/platform_device.h>
  13568. +#include <linux/delay.h>
  13569. +
  13570. +#include <asm/mach-ath79/ath79.h>
  13571. +
  13572. +#include "dev-ap9x-pci.h"
  13573. +#include "dev-eth.h"
  13574. +#include "dev-gpio-buttons.h"
  13575. +#include "dev-leds-gpio.h"
  13576. +#include "dev-m25p80.h"
  13577. +#include "machtypes.h"
  13578. +
  13579. +#define MR16_GPIO_LED_W4_GREEN 3
  13580. +#define MR16_GPIO_LED_W3_GREEN 2
  13581. +#define MR16_GPIO_LED_W2_GREEN 1
  13582. +#define MR16_GPIO_LED_W1_GREEN 0
  13583. +
  13584. +#define MR16_GPIO_LED_WAN 4
  13585. +
  13586. +#define MR16_GPIO_LED_POWER_ORANGE 5
  13587. +#define MR16_GPIO_LED_POWER_GREEN 6
  13588. +
  13589. +#define MR16_GPIO_BTN_RESET 7
  13590. +#define MR16_KEYS_POLL_INTERVAL 20 /* msecs */
  13591. +#define MR16_KEYS_DEBOUNCE_INTERVAL (3 * MR16_KEYS_POLL_INTERVAL)
  13592. +
  13593. +#define MR16_WAN_PHYMASK BIT(0)
  13594. +
  13595. +#define MR16_WMAC0_MAC_OFFSET 0x120c
  13596. +#define MR16_WMAC1_MAC_OFFSET 0x520c
  13597. +#define MR16_CALDATA0_OFFSET 0x1000
  13598. +#define MR16_CALDATA1_OFFSET 0x5000
  13599. +
  13600. +static struct gpio_led MR16_leds_gpio[] __initdata = {
  13601. + {
  13602. + .name = "mr16:green:wan",
  13603. + .gpio = MR16_GPIO_LED_WAN,
  13604. + .active_low = 1,
  13605. + }, {
  13606. + .name = "mr16:orange:power",
  13607. + .gpio = MR16_GPIO_LED_POWER_ORANGE,
  13608. + .active_low = 1,
  13609. + }, {
  13610. + .name = "mr16:green:power",
  13611. + .gpio = MR16_GPIO_LED_POWER_GREEN,
  13612. + .active_low = 1,
  13613. + }, {
  13614. + .name = "mr16:green:wifi4",
  13615. + .gpio = MR16_GPIO_LED_W4_GREEN,
  13616. + .active_low = 1,
  13617. + }, {
  13618. + .name = "mr16:green:wifi3",
  13619. + .gpio = MR16_GPIO_LED_W3_GREEN,
  13620. + .active_low = 1,
  13621. + }, {
  13622. + .name = "mr16:green:wifi2",
  13623. + .gpio = MR16_GPIO_LED_W2_GREEN,
  13624. + .active_low = 1,
  13625. + }, {
  13626. + .name = "mr16:green:wifi1",
  13627. + .gpio = MR16_GPIO_LED_W1_GREEN,
  13628. + .active_low = 1,
  13629. + }
  13630. +};
  13631. +
  13632. +static struct gpio_keys_button MR16_gpio_keys[] __initdata = {
  13633. + {
  13634. + .desc = "reset",
  13635. + .type = EV_KEY,
  13636. + .code = KEY_RESTART,
  13637. + .debounce_interval = MR16_KEYS_DEBOUNCE_INTERVAL,
  13638. + .gpio = MR16_GPIO_BTN_RESET,
  13639. + .active_low = 1,
  13640. + }
  13641. +};
  13642. +
  13643. +static void __init MR16_setup(void)
  13644. +{
  13645. + u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
  13646. +
  13647. + ath79_register_mdio(0,0x0);
  13648. +
  13649. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  13650. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13651. + ath79_eth0_data.phy_mask = MR16_WAN_PHYMASK;
  13652. + ath79_register_eth(0);
  13653. +
  13654. + ath79_register_m25p80(NULL);
  13655. +
  13656. + ath79_register_leds_gpio(-1, ARRAY_SIZE(MR16_leds_gpio),
  13657. + MR16_leds_gpio);
  13658. + ath79_register_gpio_keys_polled(-1, MR16_KEYS_POLL_INTERVAL,
  13659. + ARRAY_SIZE(MR16_gpio_keys),
  13660. + MR16_gpio_keys);
  13661. +
  13662. + ap94_pci_init(mac + MR16_CALDATA0_OFFSET,
  13663. + mac + MR16_WMAC0_MAC_OFFSET,
  13664. + mac + MR16_CALDATA1_OFFSET,
  13665. + mac + MR16_WMAC1_MAC_OFFSET);
  13666. +}
  13667. +
  13668. +MIPS_MACHINE(ATH79_MACH_MR16, "MR16", "Meraki MR16", MR16_setup);
  13669. \ No newline at end of file
  13670. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mr1750.c linux-4.1.13/arch/mips/ath79/mach-mr1750.c
  13671. --- linux-4.1.13.orig/arch/mips/ath79/mach-mr1750.c 1970-01-01 01:00:00.000000000 +0100
  13672. +++ linux-4.1.13/arch/mips/ath79/mach-mr1750.c 2015-11-21 17:22:11.759223549 +0100
  13673. @@ -0,0 +1,129 @@
  13674. +/*
  13675. + * MR1750 board support
  13676. + *
  13677. + * Copyright (c) 2012 Qualcomm Atheros
  13678. + * Copyright (c) 2012-2013 Marek Lindner <marek@open-mesh.com>
  13679. + *
  13680. + * Permission to use, copy, modify, and/or distribute this software for any
  13681. + * purpose with or without fee is hereby granted, provided that the above
  13682. + * copyright notice and this permission notice appear in all copies.
  13683. + *
  13684. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13685. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13686. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13687. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13688. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13689. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13690. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13691. + *
  13692. + */
  13693. +
  13694. +#include <linux/platform_device.h>
  13695. +#include <linux/ar8216_platform.h>
  13696. +
  13697. +#include <asm/mach-ath79/ar71xx_regs.h>
  13698. +
  13699. +#include "common.h"
  13700. +#include "dev-ap9x-pci.h"
  13701. +#include "dev-gpio-buttons.h"
  13702. +#include "dev-eth.h"
  13703. +#include "dev-leds-gpio.h"
  13704. +#include "dev-m25p80.h"
  13705. +#include "dev-wmac.h"
  13706. +#include "machtypes.h"
  13707. +#include "pci.h"
  13708. +
  13709. +#define MR1750_GPIO_LED_LAN 12
  13710. +#define MR1750_GPIO_LED_WLAN_2G 13
  13711. +#define MR1750_GPIO_LED_STATUS_GREEN 19
  13712. +#define MR1750_GPIO_LED_STATUS_RED 21
  13713. +#define MR1750_GPIO_LED_POWER 22
  13714. +#define MR1750_GPIO_LED_WLAN_5G 23
  13715. +
  13716. +#define MR1750_GPIO_BTN_RESET 17
  13717. +
  13718. +#define MR1750_KEYS_POLL_INTERVAL 20 /* msecs */
  13719. +#define MR1750_KEYS_DEBOUNCE_INTERVAL (3 * MR1750_KEYS_POLL_INTERVAL)
  13720. +
  13721. +#define MR1750_MAC0_OFFSET 0
  13722. +#define MR1750_WMAC_CALDATA_OFFSET 0x1000
  13723. +
  13724. +static struct gpio_led mr1750_leds_gpio[] __initdata = {
  13725. + {
  13726. + .name = "mr1750:blue:power",
  13727. + .gpio = MR1750_GPIO_LED_POWER,
  13728. + .active_low = 1,
  13729. + },
  13730. + {
  13731. + .name = "mr1750:blue:wan",
  13732. + .gpio = MR1750_GPIO_LED_LAN,
  13733. + .active_low = 1,
  13734. + },
  13735. + {
  13736. + .name = "mr1750:blue:wlan24",
  13737. + .gpio = MR1750_GPIO_LED_WLAN_2G,
  13738. + .active_low = 1,
  13739. + },
  13740. + {
  13741. + .name = "mr1750:blue:wlan58",
  13742. + .gpio = MR1750_GPIO_LED_WLAN_5G,
  13743. + .active_low = 1,
  13744. + },
  13745. + {
  13746. + .name = "mr1750:green:status",
  13747. + .gpio = MR1750_GPIO_LED_STATUS_GREEN,
  13748. + .active_low = 1,
  13749. + },
  13750. + {
  13751. + .name = "mr1750:red:status",
  13752. + .gpio = MR1750_GPIO_LED_STATUS_RED,
  13753. + .active_low = 1,
  13754. + },
  13755. +};
  13756. +
  13757. +static struct gpio_keys_button mr1750_gpio_keys[] __initdata = {
  13758. + {
  13759. + .desc = "Reset button",
  13760. + .type = EV_KEY,
  13761. + .code = KEY_RESTART,
  13762. + .debounce_interval = MR1750_KEYS_DEBOUNCE_INTERVAL,
  13763. + .gpio = MR1750_GPIO_BTN_RESET,
  13764. + .active_low = 1,
  13765. + },
  13766. +};
  13767. +
  13768. +static void __init mr1750_setup(void)
  13769. +{
  13770. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  13771. + u8 mac[6];
  13772. +
  13773. + ath79_eth0_pll_data.pll_1000 = 0xbe000101;
  13774. + ath79_eth0_pll_data.pll_100 = 0x80000101;
  13775. + ath79_eth0_pll_data.pll_10 = 0x80001313;
  13776. +
  13777. + ath79_register_m25p80(NULL);
  13778. +
  13779. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mr1750_leds_gpio),
  13780. + mr1750_leds_gpio);
  13781. + ath79_register_gpio_keys_polled(-1, MR1750_KEYS_POLL_INTERVAL,
  13782. + ARRAY_SIZE(mr1750_gpio_keys),
  13783. + mr1750_gpio_keys);
  13784. +
  13785. + ath79_init_mac(mac, art + MR1750_MAC0_OFFSET, 1);
  13786. + ath79_register_wmac(art + MR1750_WMAC_CALDATA_OFFSET, mac);
  13787. + ath79_register_pci();
  13788. +
  13789. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  13790. + ath79_register_mdio(0, 0x0);
  13791. +
  13792. + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR1750_MAC0_OFFSET, 0);
  13793. +
  13794. + /* GMAC0 is connected to the RMGII interface */
  13795. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13796. + ath79_eth0_data.phy_mask = BIT(5);
  13797. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  13798. +
  13799. + ath79_register_eth(0);
  13800. +}
  13801. +
  13802. +MIPS_MACHINE(ATH79_MACH_MR1750, "MR1750", "OpenMesh MR1750", mr1750_setup);
  13803. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mr600.c linux-4.1.13/arch/mips/ath79/mach-mr600.c
  13804. --- linux-4.1.13.orig/arch/mips/ath79/mach-mr600.c 1970-01-01 01:00:00.000000000 +0100
  13805. +++ linux-4.1.13/arch/mips/ath79/mach-mr600.c 2015-09-13 20:04:35.068524086 +0200
  13806. @@ -0,0 +1,177 @@
  13807. +/*
  13808. + * OpenMesh OM2P board support
  13809. + *
  13810. + * Copyright (C) 2012 Marek Lindner <marek@open-mesh.com>
  13811. + *
  13812. + * Permission to use, copy, modify, and/or distribute this software for any
  13813. + * purpose with or without fee is hereby granted, provided that the above
  13814. + * copyright notice and this permission notice appear in all copies.
  13815. + *
  13816. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13817. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13818. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13819. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13820. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13821. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13822. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13823. + *
  13824. + */
  13825. +
  13826. +#include <linux/pci.h>
  13827. +#include <linux/phy.h>
  13828. +#include <linux/platform_device.h>
  13829. +#include <linux/ath9k_platform.h>
  13830. +
  13831. +#include <asm/mach-ath79/ar71xx_regs.h>
  13832. +
  13833. +#include "common.h"
  13834. +#include "dev-ap9x-pci.h"
  13835. +#include "dev-eth.h"
  13836. +#include "dev-gpio-buttons.h"
  13837. +#include "dev-leds-gpio.h"
  13838. +#include "dev-m25p80.h"
  13839. +#include "dev-spi.h"
  13840. +#include "dev-wmac.h"
  13841. +#include "machtypes.h"
  13842. +
  13843. +#define MR600_GPIO_LED_WLAN58 12
  13844. +#define MR600_GPIO_LED_WPS 13
  13845. +#define MR600_GPIO_LED_POWER 14
  13846. +
  13847. +#define MR600V2_GPIO_LED_WLAN58_RED 12
  13848. +#define MR600V2_GPIO_LED_WPS 13
  13849. +#define MR600V2_GPIO_LED_POWER 14
  13850. +#define MR600V2_GPIO_LED_WLAN24_GREEN 18
  13851. +#define MR600V2_GPIO_LED_WLAN24_YELLOW 19
  13852. +#define MR600V2_GPIO_LED_WLAN24_RED 20
  13853. +#define MR600V2_GPIO_LED_WLAN58_GREEN 21
  13854. +#define MR600V2_GPIO_LED_WLAN58_YELLOW 22
  13855. +
  13856. +#define MR600_GPIO_BTN_RESET 17
  13857. +
  13858. +#define MR600_KEYS_POLL_INTERVAL 20 /* msecs */
  13859. +#define MR600_KEYS_DEBOUNCE_INTERVAL (3 * MR600_KEYS_POLL_INTERVAL)
  13860. +
  13861. +#define MR600_MAC_OFFSET 0
  13862. +#define MR600_WMAC_CALDATA_OFFSET 0x1000
  13863. +#define MR600_PCIE_CALDATA_OFFSET 0x5000
  13864. +
  13865. +static struct gpio_led mr600_leds_gpio[] __initdata = {
  13866. + {
  13867. + .name = "mr600:orange:power",
  13868. + .gpio = MR600_GPIO_LED_POWER,
  13869. + .active_low = 1,
  13870. + },
  13871. + {
  13872. + .name = "mr600:blue:wps",
  13873. + .gpio = MR600_GPIO_LED_WPS,
  13874. + .active_low = 1,
  13875. + },
  13876. + {
  13877. + .name = "mr600:green:wlan58",
  13878. + .gpio = MR600_GPIO_LED_WLAN58,
  13879. + .active_low = 1,
  13880. + },
  13881. +};
  13882. +
  13883. +static struct gpio_led mr600v2_leds_gpio[] __initdata = {
  13884. + {
  13885. + .name = "mr600:blue:power",
  13886. + .gpio = MR600V2_GPIO_LED_POWER,
  13887. + .active_low = 1,
  13888. + },
  13889. + {
  13890. + .name = "mr600:blue:wps",
  13891. + .gpio = MR600V2_GPIO_LED_WPS,
  13892. + .active_low = 1,
  13893. + },
  13894. + {
  13895. + .name = "mr600:red:wlan24",
  13896. + .gpio = MR600V2_GPIO_LED_WLAN24_RED,
  13897. + .active_low = 1,
  13898. + },
  13899. + {
  13900. + .name = "mr600:yellow:wlan24",
  13901. + .gpio = MR600V2_GPIO_LED_WLAN24_YELLOW,
  13902. + .active_low = 1,
  13903. + },
  13904. + {
  13905. + .name = "mr600:green:wlan24",
  13906. + .gpio = MR600V2_GPIO_LED_WLAN24_GREEN,
  13907. + .active_low = 1,
  13908. + },
  13909. + {
  13910. + .name = "mr600:red:wlan58",
  13911. + .gpio = MR600V2_GPIO_LED_WLAN58_RED,
  13912. + .active_low = 1,
  13913. + },
  13914. + {
  13915. + .name = "mr600:yellow:wlan58",
  13916. + .gpio = MR600V2_GPIO_LED_WLAN58_YELLOW,
  13917. + .active_low = 1,
  13918. + },
  13919. + {
  13920. + .name = "mr600:green:wlan58",
  13921. + .gpio = MR600V2_GPIO_LED_WLAN58_GREEN,
  13922. + .active_low = 1,
  13923. + },
  13924. +};
  13925. +
  13926. +static struct gpio_keys_button mr600_gpio_keys[] __initdata = {
  13927. + {
  13928. + .desc = "Reset button",
  13929. + .type = EV_KEY,
  13930. + .code = KEY_RESTART,
  13931. + .debounce_interval = MR600_KEYS_DEBOUNCE_INTERVAL,
  13932. + .gpio = MR600_GPIO_BTN_RESET,
  13933. + .active_low = 1,
  13934. + },
  13935. +};
  13936. +
  13937. +static void __init mr600_base_setup(unsigned num_leds, struct gpio_led *leds)
  13938. +{
  13939. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  13940. + u8 mac[6];
  13941. +
  13942. + ath79_register_m25p80(NULL);
  13943. +
  13944. + ath79_register_leds_gpio(-1, num_leds, leds);
  13945. + ath79_register_gpio_keys_polled(-1, MR600_KEYS_POLL_INTERVAL,
  13946. + ARRAY_SIZE(mr600_gpio_keys),
  13947. + mr600_gpio_keys);
  13948. +
  13949. + ath79_init_mac(mac, art + MR600_MAC_OFFSET, 1);
  13950. + ath79_register_wmac(art + MR600_WMAC_CALDATA_OFFSET, mac);
  13951. +
  13952. + ath79_init_mac(mac, art + MR600_MAC_OFFSET, 8);
  13953. + ap91_pci_init(art + MR600_PCIE_CALDATA_OFFSET, mac);
  13954. +
  13955. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  13956. + AR934X_ETH_CFG_SW_ONLY_MODE);
  13957. +
  13958. + ath79_register_mdio(0, 0x0);
  13959. +
  13960. + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR600_MAC_OFFSET, 0);
  13961. +
  13962. + /* GMAC0 is connected to an external PHY */
  13963. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  13964. + ath79_eth0_data.phy_mask = BIT(0);
  13965. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  13966. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  13967. + ath79_register_eth(0);
  13968. +}
  13969. +
  13970. +static void __init mr600_setup(void)
  13971. +{
  13972. + mr600_base_setup(ARRAY_SIZE(mr600_leds_gpio), mr600_leds_gpio);
  13973. + ap9x_pci_setup_wmac_led_pin(0, 0);
  13974. +}
  13975. +
  13976. +MIPS_MACHINE(ATH79_MACH_MR600, "MR600", "OpenMesh MR600", mr600_setup);
  13977. +
  13978. +static void __init mr600v2_setup(void)
  13979. +{
  13980. + mr600_base_setup(ARRAY_SIZE(mr600v2_leds_gpio), mr600v2_leds_gpio);
  13981. +}
  13982. +
  13983. +MIPS_MACHINE(ATH79_MACH_MR600V2, "MR600v2", "OpenMesh MR600v2", mr600v2_setup);
  13984. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mr900.c linux-4.1.13/arch/mips/ath79/mach-mr900.c
  13985. --- linux-4.1.13.orig/arch/mips/ath79/mach-mr900.c 1970-01-01 01:00:00.000000000 +0100
  13986. +++ linux-4.1.13/arch/mips/ath79/mach-mr900.c 2015-09-13 20:04:35.068524086 +0200
  13987. @@ -0,0 +1,140 @@
  13988. +/*
  13989. + * MR900 board support
  13990. + *
  13991. + * Copyright (c) 2012 Qualcomm Atheros
  13992. + * Copyright (c) 2012-2013 Marek Lindner <marek@open-mesh.com>
  13993. + *
  13994. + * Permission to use, copy, modify, and/or distribute this software for any
  13995. + * purpose with or without fee is hereby granted, provided that the above
  13996. + * copyright notice and this permission notice appear in all copies.
  13997. + *
  13998. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13999. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14000. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14001. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14002. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14003. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14004. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14005. + *
  14006. + */
  14007. +
  14008. +#include <linux/platform_device.h>
  14009. +#include <linux/ar8216_platform.h>
  14010. +#include <linux/ath9k_platform.h>
  14011. +
  14012. +#include <asm/mach-ath79/ar71xx_regs.h>
  14013. +
  14014. +#include "common.h"
  14015. +#include "dev-ap9x-pci.h"
  14016. +#include "dev-gpio-buttons.h"
  14017. +#include "dev-eth.h"
  14018. +#include "dev-leds-gpio.h"
  14019. +#include "dev-m25p80.h"
  14020. +#include "dev-wmac.h"
  14021. +#include "machtypes.h"
  14022. +#include "pci.h"
  14023. +
  14024. +#define MR900_GPIO_LED_LAN 12
  14025. +#define MR900_GPIO_LED_WLAN_2G 13
  14026. +#define MR900_GPIO_LED_STATUS_GREEN 19
  14027. +#define MR900_GPIO_LED_STATUS_RED 21
  14028. +#define MR900_GPIO_LED_POWER 22
  14029. +#define MR900_GPIO_LED_WLAN_5G 23
  14030. +
  14031. +#define MR900_GPIO_BTN_RESET 17
  14032. +
  14033. +#define MR900_KEYS_POLL_INTERVAL 20 /* msecs */
  14034. +#define MR900_KEYS_DEBOUNCE_INTERVAL (3 * MR900_KEYS_POLL_INTERVAL)
  14035. +
  14036. +#define MR900_MAC0_OFFSET 0
  14037. +#define MR900_WMAC_CALDATA_OFFSET 0x1000
  14038. +#define MR900_PCIE_CALDATA_OFFSET 0x5000
  14039. +
  14040. +static struct gpio_led mr900_leds_gpio[] __initdata = {
  14041. + {
  14042. + .name = "mr900:blue:power",
  14043. + .gpio = MR900_GPIO_LED_POWER,
  14044. + .active_low = 1,
  14045. + },
  14046. + {
  14047. + .name = "mr900:blue:wan",
  14048. + .gpio = MR900_GPIO_LED_LAN,
  14049. + .active_low = 1,
  14050. + },
  14051. + {
  14052. + .name = "mr900:blue:wlan24",
  14053. + .gpio = MR900_GPIO_LED_WLAN_2G,
  14054. + .active_low = 1,
  14055. + },
  14056. + {
  14057. + .name = "mr900:blue:wlan58",
  14058. + .gpio = MR900_GPIO_LED_WLAN_5G,
  14059. + .active_low = 1,
  14060. + },
  14061. + {
  14062. + .name = "mr900:green:status",
  14063. + .gpio = MR900_GPIO_LED_STATUS_GREEN,
  14064. + .active_low = 1,
  14065. + },
  14066. + {
  14067. + .name = "mr900:red:status",
  14068. + .gpio = MR900_GPIO_LED_STATUS_RED,
  14069. + .active_low = 1,
  14070. + },
  14071. +};
  14072. +
  14073. +static struct gpio_keys_button mr900_gpio_keys[] __initdata = {
  14074. + {
  14075. + .desc = "Reset button",
  14076. + .type = EV_KEY,
  14077. + .code = KEY_RESTART,
  14078. + .debounce_interval = MR900_KEYS_DEBOUNCE_INTERVAL,
  14079. + .gpio = MR900_GPIO_BTN_RESET,
  14080. + .active_low = 1,
  14081. + },
  14082. +};
  14083. +
  14084. +static void __init mr900_setup(void)
  14085. +{
  14086. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  14087. + u8 mac[6], pcie_mac[6];
  14088. + struct ath9k_platform_data *pdata;
  14089. +
  14090. + ath79_eth0_pll_data.pll_1000 = 0xbe000101;
  14091. + ath79_eth0_pll_data.pll_100 = 0x80000101;
  14092. + ath79_eth0_pll_data.pll_10 = 0x80001313;
  14093. +
  14094. + ath79_register_m25p80(NULL);
  14095. +
  14096. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mr900_leds_gpio),
  14097. + mr900_leds_gpio);
  14098. + ath79_register_gpio_keys_polled(-1, MR900_KEYS_POLL_INTERVAL,
  14099. + ARRAY_SIZE(mr900_gpio_keys),
  14100. + mr900_gpio_keys);
  14101. +
  14102. + ath79_init_mac(mac, art + MR900_MAC0_OFFSET, 1);
  14103. + ath79_register_wmac(art + MR900_WMAC_CALDATA_OFFSET, mac);
  14104. + ath79_init_mac(pcie_mac, art + MR900_MAC0_OFFSET, 16);
  14105. + ap91_pci_init(art + MR900_PCIE_CALDATA_OFFSET, pcie_mac);
  14106. + pdata = ap9x_pci_get_wmac_data(0);
  14107. + if (!pdata) {
  14108. + pr_err("mr900: unable to get address of wlan data\n");
  14109. + return;
  14110. + }
  14111. + pdata->use_eeprom = true;
  14112. +
  14113. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  14114. + ath79_register_mdio(0, 0x0);
  14115. +
  14116. + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR900_MAC0_OFFSET, 0);
  14117. +
  14118. + /* GMAC0 is connected to the RMGII interface */
  14119. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  14120. + ath79_eth0_data.phy_mask = BIT(5);
  14121. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  14122. +
  14123. + ath79_register_eth(0);
  14124. +}
  14125. +
  14126. +MIPS_MACHINE(ATH79_MACH_MR900, "MR900", "OpenMesh MR900", mr900_setup);
  14127. +MIPS_MACHINE(ATH79_MACH_MR900v2, "MR900v2", "OpenMesh MR900v2", mr900_setup);
  14128. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mynet-n600.c linux-4.1.13/arch/mips/ath79/mach-mynet-n600.c
  14129. --- linux-4.1.13.orig/arch/mips/ath79/mach-mynet-n600.c 1970-01-01 01:00:00.000000000 +0100
  14130. +++ linux-4.1.13/arch/mips/ath79/mach-mynet-n600.c 2015-09-13 20:04:35.068524086 +0200
  14131. @@ -0,0 +1,202 @@
  14132. +/*
  14133. + * WD My Net N600 board support
  14134. + *
  14135. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  14136. + *
  14137. + * This program is free software; you can redistribute it and/or modify it
  14138. + * under the terms of the GNU General Public License version 2 as published
  14139. + * by the Free Software Foundation.
  14140. + */
  14141. +
  14142. +#include <linux/pci.h>
  14143. +#include <linux/phy.h>
  14144. +#include <linux/gpio.h>
  14145. +#include <linux/platform_device.h>
  14146. +#include <linux/ath9k_platform.h>
  14147. +#include <linux/ar8216_platform.h>
  14148. +
  14149. +#include <asm/mach-ath79/ar71xx_regs.h>
  14150. +
  14151. +#include "common.h"
  14152. +#include "dev-ap9x-pci.h"
  14153. +#include "dev-eth.h"
  14154. +#include "dev-gpio-buttons.h"
  14155. +#include "dev-leds-gpio.h"
  14156. +#include "dev-m25p80.h"
  14157. +#include "dev-spi.h"
  14158. +#include "dev-usb.h"
  14159. +#include "dev-wmac.h"
  14160. +#include "machtypes.h"
  14161. +#include "nvram.h"
  14162. +
  14163. +#define MYNET_N600_GPIO_LED_WIFI 0
  14164. +#define MYNET_N600_GPIO_LED_POWER 11
  14165. +#define MYNET_N600_GPIO_LED_INTERNET 12
  14166. +#define MYNET_N600_GPIO_LED_WPS 13
  14167. +
  14168. +#define MYNET_N600_GPIO_LED_LAN1 4
  14169. +#define MYNET_N600_GPIO_LED_LAN2 3
  14170. +#define MYNET_N600_GPIO_LED_LAN3 2
  14171. +#define MYNET_N600_GPIO_LED_LAN4 1
  14172. +
  14173. +#define MYNET_N600_GPIO_BTN_RESET 16
  14174. +#define MYNET_N600_GPIO_BTN_WPS 17
  14175. +
  14176. +#define MYNET_N600_GPIO_EXTERNAL_LNA0 14
  14177. +#define MYNET_N600_GPIO_EXTERNAL_LNA1 15
  14178. +
  14179. +#define MYNET_N600_KEYS_POLL_INTERVAL 20 /* msecs */
  14180. +#define MYNET_N600_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_N600_KEYS_POLL_INTERVAL)
  14181. +
  14182. +#define MYNET_N600_MAC0_OFFSET 0
  14183. +#define MYNET_N600_MAC1_OFFSET 6
  14184. +#define MYNET_N600_WMAC_CALDATA_OFFSET 0x1000
  14185. +#define MYNET_N600_PCIE_CALDATA_OFFSET 0x5000
  14186. +
  14187. +#define MYNET_N600_NVRAM_ADDR 0x1f058010
  14188. +#define MYNET_N600_NVRAM_SIZE 0x7ff0
  14189. +
  14190. +static struct gpio_led mynet_n600_leds_gpio[] __initdata = {
  14191. + {
  14192. + .name = "wd:blue:power",
  14193. + .gpio = MYNET_N600_GPIO_LED_POWER,
  14194. + .active_low = 0,
  14195. + },
  14196. + {
  14197. + .name = "wd:blue:wps",
  14198. + .gpio = MYNET_N600_GPIO_LED_WPS,
  14199. + .active_low = 0,
  14200. + },
  14201. + {
  14202. + .name = "wd:blue:wireless",
  14203. + .gpio = MYNET_N600_GPIO_LED_WIFI,
  14204. + .active_low = 0,
  14205. + },
  14206. + {
  14207. + .name = "wd:blue:internet",
  14208. + .gpio = MYNET_N600_GPIO_LED_INTERNET,
  14209. + .active_low = 0,
  14210. + },
  14211. + {
  14212. + .name = "wd:green:lan1",
  14213. + .gpio = MYNET_N600_GPIO_LED_LAN1,
  14214. + .active_low = 1,
  14215. + },
  14216. + {
  14217. + .name = "wd:green:lan2",
  14218. + .gpio = MYNET_N600_GPIO_LED_LAN2,
  14219. + .active_low = 1,
  14220. + },
  14221. + {
  14222. + .name = "wd:green:lan3",
  14223. + .gpio = MYNET_N600_GPIO_LED_LAN3,
  14224. + .active_low = 1,
  14225. + },
  14226. + {
  14227. + .name = "wd:green:lan4",
  14228. + .gpio = MYNET_N600_GPIO_LED_LAN4,
  14229. + .active_low = 1,
  14230. + },
  14231. +};
  14232. +
  14233. +static struct gpio_keys_button mynet_n600_gpio_keys[] __initdata = {
  14234. + {
  14235. + .desc = "Reset button",
  14236. + .type = EV_KEY,
  14237. + .code = KEY_RESTART,
  14238. + .debounce_interval = MYNET_N600_KEYS_DEBOUNCE_INTERVAL,
  14239. + .gpio = MYNET_N600_GPIO_BTN_RESET,
  14240. + .active_low = 1,
  14241. + },
  14242. + {
  14243. + .desc = "WPS button",
  14244. + .type = EV_KEY,
  14245. + .code = KEY_WPS_BUTTON,
  14246. + .debounce_interval = MYNET_N600_KEYS_DEBOUNCE_INTERVAL,
  14247. + .gpio = MYNET_N600_GPIO_BTN_WPS,
  14248. + .active_low = 1,
  14249. + },
  14250. +};
  14251. +
  14252. +static void mynet_n600_get_mac(const char *name, char *mac)
  14253. +{
  14254. + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_N600_NVRAM_ADDR);
  14255. + int err;
  14256. +
  14257. + err = ath79_nvram_parse_mac_addr(nvram, MYNET_N600_NVRAM_SIZE,
  14258. + name, mac);
  14259. + if (err)
  14260. + pr_err("no MAC address found for %s\n", name);
  14261. +}
  14262. +
  14263. +#define MYNET_N600_WAN_PHY_MASK BIT(0)
  14264. +
  14265. +static void __init mynet_n600_setup(void)
  14266. +{
  14267. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  14268. + u8 tmpmac[ETH_ALEN];
  14269. +
  14270. + ath79_register_m25p80(NULL);
  14271. +
  14272. + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN1,
  14273. + AR934X_GPIO_OUT_GPIO);
  14274. + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN2,
  14275. + AR934X_GPIO_OUT_GPIO);
  14276. + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN3,
  14277. + AR934X_GPIO_OUT_GPIO);
  14278. + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN4,
  14279. + AR934X_GPIO_OUT_GPIO);
  14280. + ath79_gpio_output_select(MYNET_N600_GPIO_LED_INTERNET,
  14281. + AR934X_GPIO_OUT_GPIO);
  14282. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_n600_leds_gpio),
  14283. + mynet_n600_leds_gpio);
  14284. +
  14285. + ath79_register_gpio_keys_polled(-1, MYNET_N600_KEYS_POLL_INTERVAL,
  14286. + ARRAY_SIZE(mynet_n600_gpio_keys),
  14287. + mynet_n600_gpio_keys);
  14288. +
  14289. + /*
  14290. + * Control signal for external LNAs 0 and 1
  14291. + * Taken from GPL bootloader source:
  14292. + * board/ar7240/db12x/alpha_gpio.c
  14293. + */
  14294. + ath79_wmac_set_ext_lna_gpio(0, MYNET_N600_GPIO_EXTERNAL_LNA0);
  14295. + ath79_wmac_set_ext_lna_gpio(1, MYNET_N600_GPIO_EXTERNAL_LNA1);
  14296. +
  14297. + mynet_n600_get_mac("wlan24mac=", tmpmac);
  14298. + ath79_register_wmac(art + MYNET_N600_WMAC_CALDATA_OFFSET, tmpmac);
  14299. +
  14300. + mynet_n600_get_mac("wlan5mac=", tmpmac);
  14301. + ap91_pci_init(art + MYNET_N600_PCIE_CALDATA_OFFSET, tmpmac);
  14302. +
  14303. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE |
  14304. + AR934X_ETH_CFG_SW_PHY_SWAP);
  14305. +
  14306. + ath79_register_mdio(1, 0x0);
  14307. +
  14308. + /* LAN */
  14309. + mynet_n600_get_mac("lanmac=", ath79_eth1_data.mac_addr);
  14310. +
  14311. + /* GMAC1 is connected to the internal switch */
  14312. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  14313. +
  14314. + ath79_register_eth(1);
  14315. +
  14316. + /* WAN */
  14317. + mynet_n600_get_mac("wanmac=", ath79_eth0_data.mac_addr);
  14318. +
  14319. + /* GMAC0 is connected to the PHY4 of the internal switch */
  14320. + ath79_switch_data.phy4_mii_en = 1;
  14321. + ath79_switch_data.phy_poll_mask = MYNET_N600_WAN_PHY_MASK;
  14322. +
  14323. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  14324. + ath79_eth0_data.phy_mask = MYNET_N600_WAN_PHY_MASK;
  14325. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  14326. +
  14327. + ath79_register_eth(0);
  14328. +
  14329. + ath79_register_usb();
  14330. +}
  14331. +
  14332. +MIPS_MACHINE(ATH79_MACH_MYNET_N600, "MYNET-N600", "WD My Net N600",
  14333. + mynet_n600_setup);
  14334. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mynet-n750.c linux-4.1.13/arch/mips/ath79/mach-mynet-n750.c
  14335. --- linux-4.1.13.orig/arch/mips/ath79/mach-mynet-n750.c 1970-01-01 01:00:00.000000000 +0100
  14336. +++ linux-4.1.13/arch/mips/ath79/mach-mynet-n750.c 2015-09-13 20:04:35.068524086 +0200
  14337. @@ -0,0 +1,226 @@
  14338. +/*
  14339. + * WD My Net N750 board support
  14340. + *
  14341. + * Copyright (C) 2013 Felix Kaechele <felix@fetzig.org>
  14342. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  14343. + *
  14344. + * This program is free software; you can redistribute it and/or modify it
  14345. + * under the terms of the GNU General Public License version 2 as published
  14346. + * by the Free Software Foundation.
  14347. + */
  14348. +
  14349. +#include <linux/pci.h>
  14350. +#include <linux/phy.h>
  14351. +#include <linux/gpio.h>
  14352. +#include <linux/delay.h>
  14353. +#include <linux/platform_device.h>
  14354. +#include <linux/ath9k_platform.h>
  14355. +#include <linux/ar8216_platform.h>
  14356. +
  14357. +#include <asm/mach-ath79/ar71xx_regs.h>
  14358. +
  14359. +#include "common.h"
  14360. +#include "dev-ap9x-pci.h"
  14361. +#include "dev-eth.h"
  14362. +#include "dev-gpio-buttons.h"
  14363. +#include "dev-leds-gpio.h"
  14364. +#include "dev-m25p80.h"
  14365. +#include "dev-spi.h"
  14366. +#include "dev-usb.h"
  14367. +#include "dev-wmac.h"
  14368. +#include "machtypes.h"
  14369. +#include "nvram.h"
  14370. +
  14371. +
  14372. +/*
  14373. + * Taken from GPL bootloader source:
  14374. + * board/ar7240/db12x/alpha_gpio.c
  14375. + */
  14376. +#define MYNET_N750_GPIO_LED_WIFI 11
  14377. +#define MYNET_N750_GPIO_LED_INTERNET 12
  14378. +#define MYNET_N750_GPIO_LED_WPS 13
  14379. +#define MYNET_N750_GPIO_LED_POWER 14
  14380. +
  14381. +#define MYNET_N750_GPIO_BTN_RESET 17
  14382. +#define MYNET_N750_GPIO_BTN_WPS 19
  14383. +
  14384. +#define MYNET_N750_GPIO_EXTERNAL_LNA0 15
  14385. +#define MYNET_N750_GPIO_EXTERNAL_LNA1 18
  14386. +
  14387. +#define MYNET_N750_KEYS_POLL_INTERVAL 20 /* msecs */
  14388. +#define MYNET_N750_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_N750_KEYS_POLL_INTERVAL)
  14389. +
  14390. +#define MYNET_N750_WMAC_CALDATA_OFFSET 0x1000
  14391. +#define MYNET_N750_PCIE_CALDATA_OFFSET 0x5000
  14392. +
  14393. +#define MYNET_N750_NVRAM_ADDR 0x1f058010
  14394. +#define MYNET_N750_NVRAM_SIZE 0x7ff0
  14395. +
  14396. +static struct gpio_led mynet_n750_leds_gpio[] __initdata = {
  14397. + {
  14398. + .name = "wd:blue:power",
  14399. + .gpio = MYNET_N750_GPIO_LED_POWER,
  14400. + .active_low = 0,
  14401. + },
  14402. + {
  14403. + .name = "wd:blue:wps",
  14404. + .gpio = MYNET_N750_GPIO_LED_WPS,
  14405. + .active_low = 0,
  14406. + },
  14407. + {
  14408. + .name = "wd:blue:wireless",
  14409. + .gpio = MYNET_N750_GPIO_LED_WIFI,
  14410. + .active_low = 0,
  14411. + },
  14412. + {
  14413. + .name = "wd:blue:internet",
  14414. + .gpio = MYNET_N750_GPIO_LED_INTERNET,
  14415. + .active_low = 0,
  14416. + },
  14417. +};
  14418. +
  14419. +static struct gpio_keys_button mynet_n750_gpio_keys[] __initdata = {
  14420. + {
  14421. + .desc = "Reset button",
  14422. + .type = EV_KEY,
  14423. + .code = KEY_RESTART,
  14424. + .debounce_interval = MYNET_N750_KEYS_DEBOUNCE_INTERVAL,
  14425. + .gpio = MYNET_N750_GPIO_BTN_RESET,
  14426. + .active_low = 1,
  14427. + },
  14428. + {
  14429. + .desc = "WPS button",
  14430. + .type = EV_KEY,
  14431. + .code = KEY_WPS_BUTTON,
  14432. + .debounce_interval = MYNET_N750_KEYS_DEBOUNCE_INTERVAL,
  14433. + .gpio = MYNET_N750_GPIO_BTN_WPS,
  14434. + .active_low = 1,
  14435. + },
  14436. +};
  14437. +
  14438. +static const struct ar8327_led_info mynet_n750_leds_ar8327[] __initconst = {
  14439. + AR8327_LED_INFO(PHY0_0, HW, "wd:green:lan1"),
  14440. + AR8327_LED_INFO(PHY1_0, HW, "wd:green:lan2"),
  14441. + AR8327_LED_INFO(PHY2_0, HW, "wd:green:lan3"),
  14442. + AR8327_LED_INFO(PHY3_0, HW, "wd:green:lan4"),
  14443. + AR8327_LED_INFO(PHY4_0, HW, "wd:green:wan"),
  14444. + AR8327_LED_INFO(PHY0_1, HW, "wd:yellow:lan1"),
  14445. + AR8327_LED_INFO(PHY1_1, HW, "wd:yellow:lan2"),
  14446. + AR8327_LED_INFO(PHY2_1, HW, "wd:yellow:lan3"),
  14447. + AR8327_LED_INFO(PHY3_1, HW, "wd:yellow:lan4"),
  14448. + AR8327_LED_INFO(PHY4_1, HW, "wd:yellow:wan"),
  14449. +};
  14450. +
  14451. +static struct ar8327_pad_cfg mynet_n750_ar8327_pad0_cfg = {
  14452. + .mode = AR8327_PAD_MAC_RGMII,
  14453. + .txclk_delay_en = true,
  14454. + .rxclk_delay_en = true,
  14455. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  14456. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  14457. +};
  14458. +
  14459. +static struct ar8327_led_cfg mynet_n750_ar8327_led_cfg = {
  14460. + .led_ctrl0 = 0xcc35cc35,
  14461. + .led_ctrl1 = 0xca35ca35,
  14462. + .led_ctrl2 = 0xc935c935,
  14463. + .led_ctrl3 = 0x03ffff00,
  14464. + .open_drain = false,
  14465. +};
  14466. +
  14467. +static struct ar8327_platform_data mynet_n750_ar8327_data = {
  14468. + .pad0_cfg = &mynet_n750_ar8327_pad0_cfg,
  14469. + .port0_cfg = {
  14470. + .force_link = 1,
  14471. + .speed = AR8327_PORT_SPEED_1000,
  14472. + .duplex = 1,
  14473. + .txpause = 1,
  14474. + .rxpause = 1,
  14475. + },
  14476. + .led_cfg = &mynet_n750_ar8327_led_cfg,
  14477. + .num_leds = ARRAY_SIZE(mynet_n750_leds_ar8327),
  14478. + .leds = mynet_n750_leds_ar8327,
  14479. +};
  14480. +
  14481. +static struct mdio_board_info mynet_n750_mdio0_info[] = {
  14482. + {
  14483. + .bus_id = "ag71xx-mdio.0",
  14484. + .phy_addr = 0,
  14485. + .platform_data = &mynet_n750_ar8327_data,
  14486. + },
  14487. +};
  14488. +
  14489. +static void mynet_n750_get_mac(const char *name, char *mac)
  14490. +{
  14491. + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_N750_NVRAM_ADDR);
  14492. + int err;
  14493. +
  14494. + err = ath79_nvram_parse_mac_addr(nvram, MYNET_N750_NVRAM_SIZE,
  14495. + name, mac);
  14496. + if (err)
  14497. + pr_err("no MAC address found for %s\n", name);
  14498. +}
  14499. +
  14500. +/*
  14501. + * The bootloader on this board powers down all PHYs on the switch
  14502. + * before booting the kernel. We bring all PHYs back up so that they are
  14503. + * discoverable by the mdio bus scan and the switch is detected
  14504. + * correctly.
  14505. + */
  14506. +static void mynet_n750_mdio_fixup(struct mii_bus *bus)
  14507. +{
  14508. + int i;
  14509. +
  14510. + for (i = 0; i < 5; i++)
  14511. + bus->write(bus, i, MII_BMCR,
  14512. + (BMCR_RESET | BMCR_ANENABLE | BMCR_SPEED1000));
  14513. +
  14514. + mdelay(1000);
  14515. +}
  14516. +
  14517. +static void __init mynet_n750_setup(void)
  14518. +{
  14519. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  14520. + u8 tmpmac[ETH_ALEN];
  14521. +
  14522. + ath79_register_m25p80(NULL);
  14523. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_n750_leds_gpio),
  14524. + mynet_n750_leds_gpio);
  14525. + ath79_register_gpio_keys_polled(-1, MYNET_N750_KEYS_POLL_INTERVAL,
  14526. + ARRAY_SIZE(mynet_n750_gpio_keys),
  14527. + mynet_n750_gpio_keys);
  14528. + /*
  14529. + * Control signal for external LNAs 0 and 1
  14530. + * Taken from GPL bootloader source:
  14531. + * board/ar7240/db12x/alpha_gpio.c
  14532. + */
  14533. + ath79_wmac_set_ext_lna_gpio(0, MYNET_N750_GPIO_EXTERNAL_LNA0);
  14534. + ath79_wmac_set_ext_lna_gpio(1, MYNET_N750_GPIO_EXTERNAL_LNA1);
  14535. +
  14536. + mynet_n750_get_mac("wlan24mac=", tmpmac);
  14537. + ath79_register_wmac(art + MYNET_N750_WMAC_CALDATA_OFFSET, tmpmac);
  14538. +
  14539. + mynet_n750_get_mac("wlan5mac=", tmpmac);
  14540. + ap91_pci_init(art + MYNET_N750_PCIE_CALDATA_OFFSET, tmpmac);
  14541. +
  14542. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  14543. +
  14544. + mdiobus_register_board_info(mynet_n750_mdio0_info,
  14545. + ARRAY_SIZE(mynet_n750_mdio0_info));
  14546. +
  14547. + ath79_mdio0_data.reset = mynet_n750_mdio_fixup;
  14548. + ath79_register_mdio(0, 0x0);
  14549. +
  14550. + mynet_n750_get_mac("lanmac=", ath79_eth0_data.mac_addr);
  14551. +
  14552. + /* GMAC0 is connected to an AR8327N switch */
  14553. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  14554. + ath79_eth0_data.phy_mask = BIT(0);
  14555. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  14556. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  14557. + ath79_register_eth(0);
  14558. +
  14559. + ath79_register_usb();
  14560. +}
  14561. +
  14562. +MIPS_MACHINE(ATH79_MACH_MYNET_N750, "MYNET-N750", "WD My Net N750",
  14563. + mynet_n750_setup);
  14564. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mynet-rext.c linux-4.1.13/arch/mips/ath79/mach-mynet-rext.c
  14565. --- linux-4.1.13.orig/arch/mips/ath79/mach-mynet-rext.c 1970-01-01 01:00:00.000000000 +0100
  14566. +++ linux-4.1.13/arch/mips/ath79/mach-mynet-rext.c 2015-09-13 20:04:35.068524086 +0200
  14567. @@ -0,0 +1,208 @@
  14568. +/*
  14569. + * WD My Net WI-FI Range Extender (Codename:Starfish db12x) board support
  14570. + *
  14571. + * Copyright (C) 2013 Christian Lamparter <chunkeey@googlemail.com>
  14572. + *
  14573. + * This program is free software; you can redistribute it and/or modify it
  14574. + * under the terms of the GNU General Public License version 2 as published
  14575. + * by the Free Software Foundation.
  14576. + */
  14577. +
  14578. +#include <linux/pci.h>
  14579. +#include <linux/phy.h>
  14580. +#include <linux/gpio.h>
  14581. +#include <linux/platform_device.h>
  14582. +#include <linux/ath9k_platform.h>
  14583. +#include <linux/ar8216_platform.h>
  14584. +#include <linux/platform_data/phy-at803x.h>
  14585. +
  14586. +#include <asm/mach-ath79/ar71xx_regs.h>
  14587. +
  14588. +#include "common.h"
  14589. +#include "dev-ap9x-pci.h"
  14590. +#include "dev-eth.h"
  14591. +#include "dev-gpio-buttons.h"
  14592. +#include "dev-leds-gpio.h"
  14593. +#include "dev-m25p80.h"
  14594. +#include "dev-spi.h"
  14595. +#include "dev-usb.h"
  14596. +#include "dev-wmac.h"
  14597. +#include "machtypes.h"
  14598. +#include "nvram.h"
  14599. +
  14600. +#define MYNET_REXT_GPIO_LED_POWER 11
  14601. +#define MYNET_REXT_GPIO_LED_ETHERNET 12
  14602. +#define MYNET_REXT_GPIO_LED_WIFI 19
  14603. +
  14604. +#define MYNET_REXT_GPIO_LED_RF_QTY1 20
  14605. +#define MYNET_REXT_GPIO_LED_RF_QTY2 21
  14606. +#define MYNET_REXT_GPIO_LED_RF_QTY3 22
  14607. +
  14608. +#define MYNET_REXT_GPIO_BTN_RESET 13
  14609. +#define MYNET_REXT_GPIO_BTN_WPS 15
  14610. +#define MYNET_REXT_GPIO_SW_RF 14
  14611. +
  14612. +#define MYNET_REXT_GPIO_PHY_SWRST 16 /* disables Ethernet PHY */
  14613. +#define MYNET_REXT_GPIO_PHY_INT 17
  14614. +#define MYNET_REXT_GPIO_18 18
  14615. +
  14616. +#define MYNET_REXT_KEYS_POLL_INTERVAL 20 /* msecs */
  14617. +#define MYNET_REXT_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_REXT_KEYS_POLL_INTERVAL)
  14618. +
  14619. +#define MYNET_REXT_WMAC_CALDATA_OFFSET 0x1000
  14620. +
  14621. +#define MYNET_REXT_NVRAM_ADDR 0x1f7e0010
  14622. +#define MYNET_REXT_NVRAM_SIZE 0xfff0
  14623. +
  14624. +#define MYNET_REXT_ART_ADDR 0x1f7f0000
  14625. +
  14626. +static const char *mynet_rext_part_probes[] = {
  14627. + "cybertan",
  14628. + NULL,
  14629. +};
  14630. +
  14631. +static struct flash_platform_data mynet_rext_flash_data = {
  14632. + .type = "s25fl064k",
  14633. + .part_probes = mynet_rext_part_probes,
  14634. +};
  14635. +
  14636. +static struct gpio_led mynet_rext_leds_gpio[] __initdata = {
  14637. + {
  14638. + .name = "wd:blue:power",
  14639. + .gpio = MYNET_REXT_GPIO_LED_POWER,
  14640. + .active_low = 0,
  14641. + },
  14642. + {
  14643. + .name = "wd:blue:wireless",
  14644. + .gpio = MYNET_REXT_GPIO_LED_WIFI,
  14645. + .active_low = 1,
  14646. + },
  14647. + {
  14648. + .name = "wd:blue:ethernet",
  14649. + .gpio = MYNET_REXT_GPIO_LED_ETHERNET,
  14650. + .active_low = 1,
  14651. + },
  14652. + {
  14653. + .name = "wd:blue:quality1",
  14654. + .gpio = MYNET_REXT_GPIO_LED_RF_QTY1,
  14655. + .active_low = 1,
  14656. + },
  14657. + {
  14658. + .name = "wd:blue:quality2",
  14659. + .gpio = MYNET_REXT_GPIO_LED_RF_QTY2,
  14660. + .active_low = 1,
  14661. + },
  14662. + {
  14663. + .name = "wd:blue:quality3",
  14664. + .gpio = MYNET_REXT_GPIO_LED_RF_QTY3,
  14665. + .active_low = 1,
  14666. + },
  14667. +};
  14668. +
  14669. +static struct gpio_keys_button mynet_rext_gpio_keys[] __initdata = {
  14670. + {
  14671. + .desc = "Reset button",
  14672. + .type = EV_KEY,
  14673. + .code = KEY_RESTART,
  14674. + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
  14675. + .gpio = MYNET_REXT_GPIO_BTN_RESET,
  14676. + .active_low = 1,
  14677. + },
  14678. + {
  14679. + .desc = "WPS button",
  14680. + .type = EV_KEY,
  14681. + .code = KEY_WPS_BUTTON,
  14682. + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
  14683. + .gpio = MYNET_REXT_GPIO_BTN_WPS,
  14684. + .active_low = 1,
  14685. + },
  14686. + {
  14687. + .desc = "RF Band switch",
  14688. + .type = EV_SW,
  14689. + .code = BTN_1,
  14690. + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
  14691. + .gpio = MYNET_REXT_GPIO_SW_RF,
  14692. + },
  14693. +};
  14694. +
  14695. +static struct at803x_platform_data mynet_rext_at803x_data = {
  14696. + .disable_smarteee = 0,
  14697. + .enable_rgmii_rx_delay = 1,
  14698. + .enable_rgmii_tx_delay = 0,
  14699. + .fixup_rgmii_tx_delay = 1,
  14700. +};
  14701. +
  14702. +static struct mdio_board_info mynet_rext_mdio0_info[] = {
  14703. + {
  14704. + .bus_id = "ag71xx-mdio.0",
  14705. + .phy_addr = 4,
  14706. + .platform_data = &mynet_rext_at803x_data,
  14707. + },
  14708. +};
  14709. +
  14710. +static void mynet_rext_get_mac(const char *name, char *mac)
  14711. +{
  14712. + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_REXT_NVRAM_ADDR);
  14713. + int err;
  14714. +
  14715. + err = ath79_nvram_parse_mac_addr(nvram, MYNET_REXT_NVRAM_SIZE,
  14716. + name, mac);
  14717. + if (err)
  14718. + pr_err("no MAC address found for %s\n", name);
  14719. +}
  14720. +
  14721. +static void __init mynet_rext_setup(void)
  14722. +{
  14723. + u8 *art = (u8 *) KSEG1ADDR(MYNET_REXT_ART_ADDR);
  14724. + u8 tmpmac[ETH_ALEN];
  14725. +
  14726. + ath79_register_m25p80(&mynet_rext_flash_data);
  14727. +
  14728. + /* GPIO configuration from drivers/char/GPIO8.c */
  14729. +
  14730. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_POWER,
  14731. + AR934X_GPIO_OUT_GPIO);
  14732. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_WIFI,
  14733. + AR934X_GPIO_OUT_GPIO);
  14734. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY1,
  14735. + AR934X_GPIO_OUT_GPIO);
  14736. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY2,
  14737. + AR934X_GPIO_OUT_GPIO);
  14738. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY3,
  14739. + AR934X_GPIO_OUT_GPIO);
  14740. + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_ETHERNET,
  14741. + AR934X_GPIO_OUT_GPIO);
  14742. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_rext_leds_gpio),
  14743. + mynet_rext_leds_gpio);
  14744. +
  14745. + ath79_register_gpio_keys_polled(-1, MYNET_REXT_KEYS_POLL_INTERVAL,
  14746. + ARRAY_SIZE(mynet_rext_gpio_keys),
  14747. + mynet_rext_gpio_keys);
  14748. +
  14749. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  14750. + AR934X_ETH_CFG_RXD_DELAY |
  14751. + AR934X_ETH_CFG_RDV_DELAY);
  14752. +
  14753. + ath79_register_mdio(0, 0x0);
  14754. +
  14755. + mdiobus_register_board_info(mynet_rext_mdio0_info,
  14756. + ARRAY_SIZE(mynet_rext_mdio0_info));
  14757. +
  14758. + /* LAN */
  14759. + mynet_rext_get_mac("et0macaddr=", ath79_eth0_data.mac_addr);
  14760. +
  14761. + /* GMAC0 is connected to an external PHY on Port 4 */
  14762. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  14763. + ath79_eth0_data.phy_mask = BIT(4);
  14764. + ath79_eth0_pll_data.pll_10 = 0x00001313; /* athrs_mac.c */
  14765. + ath79_eth0_pll_data.pll_1000 = 0x0e000000; /* athrs_mac.c */
  14766. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  14767. + ath79_register_eth(0);
  14768. +
  14769. + /* WLAN */
  14770. + mynet_rext_get_mac("wl0_hwaddr=", tmpmac);
  14771. + ap91_pci_init(art + MYNET_REXT_WMAC_CALDATA_OFFSET, tmpmac);
  14772. +}
  14773. +
  14774. +MIPS_MACHINE(ATH79_MACH_MYNET_REXT, "MYNET-REXT",
  14775. + "WD My Net Wi-Fi Range Extender", mynet_rext_setup);
  14776. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mzk-w04nu.c linux-4.1.13/arch/mips/ath79/mach-mzk-w04nu.c
  14777. --- linux-4.1.13.orig/arch/mips/ath79/mach-mzk-w04nu.c 1970-01-01 01:00:00.000000000 +0100
  14778. +++ linux-4.1.13/arch/mips/ath79/mach-mzk-w04nu.c 2015-09-13 20:04:35.068524086 +0200
  14779. @@ -0,0 +1,124 @@
  14780. +/*
  14781. + * Planex MZK-W04NU board support
  14782. + *
  14783. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  14784. + *
  14785. + * This program is free software; you can redistribute it and/or modify it
  14786. + * under the terms of the GNU General Public License version 2 as published
  14787. + * by the Free Software Foundation.
  14788. + */
  14789. +
  14790. +#include <asm/mach-ath79/ath79.h>
  14791. +
  14792. +#include "dev-eth.h"
  14793. +#include "dev-gpio-buttons.h"
  14794. +#include "dev-leds-gpio.h"
  14795. +#include "dev-m25p80.h"
  14796. +#include "dev-usb.h"
  14797. +#include "dev-wmac.h"
  14798. +#include "machtypes.h"
  14799. +
  14800. +#define MZK_W04NU_GPIO_LED_USB 0
  14801. +#define MZK_W04NU_GPIO_LED_STATUS 1
  14802. +#define MZK_W04NU_GPIO_LED_WPS 3
  14803. +#define MZK_W04NU_GPIO_LED_WLAN 6
  14804. +#define MZK_W04NU_GPIO_LED_AP 15
  14805. +#define MZK_W04NU_GPIO_LED_ROUTER 16
  14806. +
  14807. +#define MZK_W04NU_GPIO_BTN_APROUTER 5
  14808. +#define MZK_W04NU_GPIO_BTN_WPS 12
  14809. +#define MZK_W04NU_GPIO_BTN_RESET 21
  14810. +
  14811. +#define MZK_W04NU_KEYS_POLL_INTERVAL 20 /* msecs */
  14812. +#define MZK_W04NU_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W04NU_KEYS_POLL_INTERVAL)
  14813. +
  14814. +static struct gpio_led mzk_w04nu_leds_gpio[] __initdata = {
  14815. + {
  14816. + .name = "planex:green:status",
  14817. + .gpio = MZK_W04NU_GPIO_LED_STATUS,
  14818. + .active_low = 1,
  14819. + }, {
  14820. + .name = "planex:blue:wps",
  14821. + .gpio = MZK_W04NU_GPIO_LED_WPS,
  14822. + .active_low = 1,
  14823. + }, {
  14824. + .name = "planex:green:wlan",
  14825. + .gpio = MZK_W04NU_GPIO_LED_WLAN,
  14826. + .active_low = 1,
  14827. + }, {
  14828. + .name = "planex:green:usb",
  14829. + .gpio = MZK_W04NU_GPIO_LED_USB,
  14830. + .active_low = 1,
  14831. + }, {
  14832. + .name = "planex:green:ap",
  14833. + .gpio = MZK_W04NU_GPIO_LED_AP,
  14834. + .active_low = 1,
  14835. + }, {
  14836. + .name = "planex:green:router",
  14837. + .gpio = MZK_W04NU_GPIO_LED_ROUTER,
  14838. + .active_low = 1,
  14839. + }
  14840. +};
  14841. +
  14842. +static struct gpio_keys_button mzk_w04nu_gpio_keys[] __initdata = {
  14843. + {
  14844. + .desc = "reset",
  14845. + .type = EV_KEY,
  14846. + .code = KEY_RESTART,
  14847. + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  14848. + .gpio = MZK_W04NU_GPIO_BTN_RESET,
  14849. + .active_low = 1,
  14850. + }, {
  14851. + .desc = "wps",
  14852. + .type = EV_KEY,
  14853. + .code = KEY_WPS_BUTTON,
  14854. + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  14855. + .gpio = MZK_W04NU_GPIO_BTN_WPS,
  14856. + .active_low = 1,
  14857. + }, {
  14858. + .desc = "aprouter",
  14859. + .type = EV_KEY,
  14860. + .code = BTN_2,
  14861. + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  14862. + .gpio = MZK_W04NU_GPIO_BTN_APROUTER,
  14863. + .active_low = 0,
  14864. + }
  14865. +};
  14866. +
  14867. +#define MZK_W04NU_WAN_PHYMASK BIT(4)
  14868. +#define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
  14869. +
  14870. +static void __init mzk_w04nu_setup(void)
  14871. +{
  14872. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  14873. +
  14874. + ath79_register_mdio(0, MZK_W04NU_MDIO_MASK);
  14875. +
  14876. + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  14877. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  14878. + ath79_eth0_data.speed = SPEED_100;
  14879. + ath79_eth0_data.duplex = DUPLEX_FULL;
  14880. + ath79_eth0_data.has_ar8216 = 1;
  14881. +
  14882. + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  14883. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  14884. + ath79_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK;
  14885. +
  14886. + ath79_register_eth(0);
  14887. + ath79_register_eth(1);
  14888. +
  14889. + ath79_register_m25p80(NULL);
  14890. +
  14891. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio),
  14892. + mzk_w04nu_leds_gpio);
  14893. +
  14894. + ath79_register_gpio_keys_polled(-1, MZK_W04NU_KEYS_POLL_INTERVAL,
  14895. + ARRAY_SIZE(mzk_w04nu_gpio_keys),
  14896. + mzk_w04nu_gpio_keys);
  14897. + ath79_register_usb();
  14898. +
  14899. + ath79_register_wmac(eeprom, NULL);
  14900. +}
  14901. +
  14902. +MIPS_MACHINE(ATH79_MACH_MZK_W04NU, "MZK-W04NU", "Planex MZK-W04NU",
  14903. + mzk_w04nu_setup);
  14904. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-mzk-w300nh.c linux-4.1.13/arch/mips/ath79/mach-mzk-w300nh.c
  14905. --- linux-4.1.13.orig/arch/mips/ath79/mach-mzk-w300nh.c 1970-01-01 01:00:00.000000000 +0100
  14906. +++ linux-4.1.13/arch/mips/ath79/mach-mzk-w300nh.c 2015-09-13 20:04:35.068524086 +0200
  14907. @@ -0,0 +1,115 @@
  14908. +/*
  14909. + * Planex MZK-W300NH board support
  14910. + *
  14911. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  14912. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  14913. + *
  14914. + * This program is free software; you can redistribute it and/or modify it
  14915. + * under the terms of the GNU General Public License version 2 as published
  14916. + * by the Free Software Foundation.
  14917. + */
  14918. +
  14919. +#include <asm/mach-ath79/ath79.h>
  14920. +
  14921. +#include "dev-eth.h"
  14922. +#include "dev-gpio-buttons.h"
  14923. +#include "dev-leds-gpio.h"
  14924. +#include "dev-m25p80.h"
  14925. +#include "dev-wmac.h"
  14926. +#include "machtypes.h"
  14927. +
  14928. +#define MZK_W300NH_GPIO_LED_STATUS 1
  14929. +#define MZK_W300NH_GPIO_LED_WPS 3
  14930. +#define MZK_W300NH_GPIO_LED_WLAN 6
  14931. +#define MZK_W300NH_GPIO_LED_AP_GREEN 15
  14932. +#define MZK_W300NH_GPIO_LED_AP_AMBER 16
  14933. +
  14934. +#define MZK_W300NH_GPIO_BTN_APROUTER 5
  14935. +#define MZK_W300NH_GPIO_BTN_WPS 12
  14936. +#define MZK_W300NH_GPIO_BTN_RESET 21
  14937. +
  14938. +#define MZK_W300NH_KEYS_POLL_INTERVAL 20 /* msecs */
  14939. +#define MZK_W300NH_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W300NH_KEYS_POLL_INTERVAL)
  14940. +
  14941. +static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
  14942. + {
  14943. + .name = "planex:green:status",
  14944. + .gpio = MZK_W300NH_GPIO_LED_STATUS,
  14945. + .active_low = 1,
  14946. + }, {
  14947. + .name = "planex:blue:wps",
  14948. + .gpio = MZK_W300NH_GPIO_LED_WPS,
  14949. + .active_low = 1,
  14950. + }, {
  14951. + .name = "planex:green:wlan",
  14952. + .gpio = MZK_W300NH_GPIO_LED_WLAN,
  14953. + .active_low = 1,
  14954. + }, {
  14955. + .name = "planex:green:aprouter",
  14956. + .gpio = MZK_W300NH_GPIO_LED_AP_GREEN,
  14957. + }, {
  14958. + .name = "planex:amber:aprouter",
  14959. + .gpio = MZK_W300NH_GPIO_LED_AP_AMBER,
  14960. + }
  14961. +};
  14962. +
  14963. +static struct gpio_keys_button mzk_w300nh_gpio_keys[] __initdata = {
  14964. + {
  14965. + .desc = "reset",
  14966. + .type = EV_KEY,
  14967. + .code = KEY_RESTART,
  14968. + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  14969. + .gpio = MZK_W300NH_GPIO_BTN_RESET,
  14970. + .active_low = 1,
  14971. + }, {
  14972. + .desc = "wps",
  14973. + .type = EV_KEY,
  14974. + .code = KEY_WPS_BUTTON,
  14975. + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  14976. + .gpio = MZK_W300NH_GPIO_BTN_WPS,
  14977. + .active_low = 1,
  14978. + }, {
  14979. + .desc = "aprouter",
  14980. + .type = EV_KEY,
  14981. + .code = BTN_2,
  14982. + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  14983. + .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
  14984. + .active_low = 0,
  14985. + }
  14986. +};
  14987. +
  14988. +#define MZK_W300NH_WAN_PHYMASK BIT(4)
  14989. +#define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
  14990. +
  14991. +static void __init mzk_w300nh_setup(void)
  14992. +{
  14993. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  14994. +
  14995. + ath79_register_mdio(0, MZK_W300NH_MDIO_MASK);
  14996. +
  14997. + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  14998. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  14999. + ath79_eth0_data.speed = SPEED_100;
  15000. + ath79_eth0_data.duplex = DUPLEX_FULL;
  15001. + ath79_eth0_data.has_ar8216 = 1;
  15002. +
  15003. + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  15004. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  15005. + ath79_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
  15006. +
  15007. + ath79_register_eth(0);
  15008. + ath79_register_eth(1);
  15009. +
  15010. + ath79_register_m25p80(NULL);
  15011. +
  15012. + ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
  15013. + mzk_w300nh_leds_gpio);
  15014. +
  15015. + ath79_register_gpio_keys_polled(-1, MZK_W300NH_KEYS_POLL_INTERVAL,
  15016. + ARRAY_SIZE(mzk_w300nh_gpio_keys),
  15017. + mzk_w300nh_gpio_keys);
  15018. + ath79_register_wmac(eeprom, NULL);
  15019. +}
  15020. +
  15021. +MIPS_MACHINE(ATH79_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
  15022. + mzk_w300nh_setup);
  15023. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-nbg460n.c linux-4.1.13/arch/mips/ath79/mach-nbg460n.c
  15024. --- linux-4.1.13.orig/arch/mips/ath79/mach-nbg460n.c 1970-01-01 01:00:00.000000000 +0100
  15025. +++ linux-4.1.13/arch/mips/ath79/mach-nbg460n.c 2015-09-13 20:04:35.068524086 +0200
  15026. @@ -0,0 +1,220 @@
  15027. +/*
  15028. + * Zyxel NBG 460N/550N/550NH board support
  15029. + *
  15030. + * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
  15031. + *
  15032. + * based on mach-tl-wr1043nd.c
  15033. + *
  15034. + * This program is free software; you can redistribute it and/or modify it
  15035. + * under the terms of the GNU General Public License version 2 as published
  15036. + * by the Free Software Foundation.
  15037. + */
  15038. +
  15039. +#include <linux/delay.h>
  15040. +#include <linux/i2c.h>
  15041. +#include <linux/i2c-algo-bit.h>
  15042. +#include <linux/i2c-gpio.h>
  15043. +#include <linux/mtd/mtd.h>
  15044. +#include <linux/mtd/partitions.h>
  15045. +#include <linux/platform_device.h>
  15046. +#include <linux/rtl8366.h>
  15047. +
  15048. +#include <asm/mach-ath79/ath79.h>
  15049. +
  15050. +#include "dev-eth.h"
  15051. +#include "dev-gpio-buttons.h"
  15052. +#include "dev-leds-gpio.h"
  15053. +#include "dev-m25p80.h"
  15054. +#include "dev-wmac.h"
  15055. +#include "machtypes.h"
  15056. +
  15057. +/* LEDs */
  15058. +#define NBG460N_GPIO_LED_WPS 3
  15059. +#define NBG460N_GPIO_LED_WAN 6
  15060. +#define NBG460N_GPIO_LED_POWER 14
  15061. +#define NBG460N_GPIO_LED_WLAN 15
  15062. +
  15063. +/* Buttons */
  15064. +#define NBG460N_GPIO_BTN_WPS 12
  15065. +#define NBG460N_GPIO_BTN_RESET 21
  15066. +
  15067. +#define NBG460N_KEYS_POLL_INTERVAL 20 /* msecs */
  15068. +#define NBG460N_KEYS_DEBOUNCE_INTERVAL (3 * NBG460N_KEYS_POLL_INTERVAL)
  15069. +
  15070. +/* RTC chip PCF8563 I2C interface */
  15071. +#define NBG460N_GPIO_PCF8563_SDA 8
  15072. +#define NBG460N_GPIO_PCF8563_SCK 7
  15073. +
  15074. +/* Switch configuration I2C interface */
  15075. +#define NBG460N_GPIO_RTL8366_SDA 16
  15076. +#define NBG460N_GPIO_RTL8366_SCK 18
  15077. +
  15078. +static struct mtd_partition nbg460n_partitions[] = {
  15079. + {
  15080. + .name = "Bootbase",
  15081. + .offset = 0,
  15082. + .size = 0x010000,
  15083. + .mask_flags = MTD_WRITEABLE,
  15084. + }, {
  15085. + .name = "U-Boot Config",
  15086. + .offset = 0x010000,
  15087. + .size = 0x030000,
  15088. + }, {
  15089. + .name = "U-Boot",
  15090. + .offset = 0x040000,
  15091. + .size = 0x030000,
  15092. + }, {
  15093. + .name = "linux",
  15094. + .offset = 0x070000,
  15095. + .size = 0x0e0000,
  15096. + }, {
  15097. + .name = "rootfs",
  15098. + .offset = 0x150000,
  15099. + .size = 0x2a0000,
  15100. + }, {
  15101. + .name = "CalibData",
  15102. + .offset = 0x3f0000,
  15103. + .size = 0x010000,
  15104. + .mask_flags = MTD_WRITEABLE,
  15105. + }, {
  15106. + .name = "firmware",
  15107. + .offset = 0x070000,
  15108. + .size = 0x380000,
  15109. + }
  15110. +};
  15111. +
  15112. +static struct flash_platform_data nbg460n_flash_data = {
  15113. + .parts = nbg460n_partitions,
  15114. + .nr_parts = ARRAY_SIZE(nbg460n_partitions),
  15115. +};
  15116. +
  15117. +static struct gpio_led nbg460n_leds_gpio[] __initdata = {
  15118. + {
  15119. + .name = "nbg460n:green:power",
  15120. + .gpio = NBG460N_GPIO_LED_POWER,
  15121. + .active_low = 0,
  15122. + .default_trigger = "default-on",
  15123. + }, {
  15124. + .name = "nbg460n:green:wps",
  15125. + .gpio = NBG460N_GPIO_LED_WPS,
  15126. + .active_low = 0,
  15127. + }, {
  15128. + .name = "nbg460n:green:wlan",
  15129. + .gpio = NBG460N_GPIO_LED_WLAN,
  15130. + .active_low = 0,
  15131. + }, {
  15132. + /* Not really for controlling the LED,
  15133. + when set low the LED blinks uncontrollable */
  15134. + .name = "nbg460n:green:wan",
  15135. + .gpio = NBG460N_GPIO_LED_WAN,
  15136. + .active_low = 0,
  15137. + }
  15138. +};
  15139. +
  15140. +static struct gpio_keys_button nbg460n_gpio_keys[] __initdata = {
  15141. + {
  15142. + .desc = "reset",
  15143. + .type = EV_KEY,
  15144. + .code = KEY_RESTART,
  15145. + .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
  15146. + .gpio = NBG460N_GPIO_BTN_RESET,
  15147. + .active_low = 1,
  15148. + }, {
  15149. + .desc = "wps",
  15150. + .type = EV_KEY,
  15151. + .code = KEY_WPS_BUTTON,
  15152. + .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
  15153. + .gpio = NBG460N_GPIO_BTN_WPS,
  15154. + .active_low = 1,
  15155. + }
  15156. +};
  15157. +
  15158. +static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata = {
  15159. + .sda_pin = NBG460N_GPIO_PCF8563_SDA,
  15160. + .scl_pin = NBG460N_GPIO_PCF8563_SCK,
  15161. + .udelay = 10,
  15162. +};
  15163. +
  15164. +static struct platform_device nbg460n_i2c_device = {
  15165. + .name = "i2c-gpio",
  15166. + .id = -1,
  15167. + .num_resources = 0,
  15168. + .resource = NULL,
  15169. + .dev = {
  15170. + .platform_data = &nbg460n_i2c_device_platdata,
  15171. + },
  15172. +};
  15173. +
  15174. +static struct i2c_board_info nbg460n_i2c_devs[] __initdata = {
  15175. + {
  15176. + I2C_BOARD_INFO("pcf8563", 0x51),
  15177. + },
  15178. +};
  15179. +
  15180. +static void nbg460n_i2c_init(void)
  15181. +{
  15182. + /* The gpio interface */
  15183. + platform_device_register(&nbg460n_i2c_device);
  15184. + /* I2C devices */
  15185. + i2c_register_board_info(0, nbg460n_i2c_devs,
  15186. + ARRAY_SIZE(nbg460n_i2c_devs));
  15187. +}
  15188. +
  15189. +
  15190. +static struct rtl8366_platform_data nbg460n_rtl8366s_data = {
  15191. + .gpio_sda = NBG460N_GPIO_RTL8366_SDA,
  15192. + .gpio_sck = NBG460N_GPIO_RTL8366_SCK,
  15193. +};
  15194. +
  15195. +static struct platform_device nbg460n_rtl8366s_device = {
  15196. + .name = RTL8366S_DRIVER_NAME,
  15197. + .id = -1,
  15198. + .dev = {
  15199. + .platform_data = &nbg460n_rtl8366s_data,
  15200. + }
  15201. +};
  15202. +
  15203. +static void __init nbg460n_setup(void)
  15204. +{
  15205. + /* end of bootloader sector contains mac address */
  15206. + u8 *mac = (u8 *) KSEG1ADDR(0x1fc0fff8);
  15207. + /* last sector contains wlan calib data */
  15208. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  15209. +
  15210. + /* LAN Port */
  15211. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  15212. + ath79_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
  15213. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  15214. + ath79_eth0_data.speed = SPEED_1000;
  15215. + ath79_eth0_data.duplex = DUPLEX_FULL;
  15216. +
  15217. + /* WAN Port */
  15218. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  15219. + ath79_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
  15220. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  15221. + ath79_eth1_data.phy_mask = 0x10;
  15222. +
  15223. + ath79_register_eth(0);
  15224. + ath79_register_eth(1);
  15225. +
  15226. + /* register the switch phy */
  15227. + platform_device_register(&nbg460n_rtl8366s_device);
  15228. +
  15229. + /* register flash */
  15230. + ath79_register_m25p80(&nbg460n_flash_data);
  15231. +
  15232. + ath79_register_wmac(eeprom, mac);
  15233. +
  15234. + /* register RTC chip */
  15235. + nbg460n_i2c_init();
  15236. +
  15237. + ath79_register_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio),
  15238. + nbg460n_leds_gpio);
  15239. +
  15240. + ath79_register_gpio_keys_polled(-1, NBG460N_KEYS_POLL_INTERVAL,
  15241. + ARRAY_SIZE(nbg460n_gpio_keys),
  15242. + nbg460n_gpio_keys);
  15243. +}
  15244. +
  15245. +MIPS_MACHINE(ATH79_MACH_NBG460N, "NBG460N", "Zyxel NBG460N/550N/550NH",
  15246. + nbg460n_setup);
  15247. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-nbg6716.c linux-4.1.13/arch/mips/ath79/mach-nbg6716.c
  15248. --- linux-4.1.13.orig/arch/mips/ath79/mach-nbg6716.c 1970-01-01 01:00:00.000000000 +0100
  15249. +++ linux-4.1.13/arch/mips/ath79/mach-nbg6716.c 2015-11-21 17:22:11.759223549 +0100
  15250. @@ -0,0 +1,381 @@
  15251. +/*
  15252. + * ZyXEL NBG6716/NBG6616 board support
  15253. + *
  15254. + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  15255. + * Copyright (c) 2012 Qualcomm Atheros
  15256. + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
  15257. + * Copyright (c) 2013 Andre Valentin <avalentin@marcant.net>
  15258. + *
  15259. + * Permission to use, copy, modify, and/or distribute this software for any
  15260. + * purpose with or without fee is hereby granted, provided that the above
  15261. + * copyright notice and this permission notice appear in all copies.
  15262. + *
  15263. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  15264. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15265. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15266. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15267. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15268. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15269. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15270. + *
  15271. + */
  15272. +
  15273. +#include <linux/platform_device.h>
  15274. +#include <linux/ar8216_platform.h>
  15275. +#include <linux/gpio.h>
  15276. +#include <linux/mtd/mtd.h>
  15277. +#include <linux/mtd/nand.h>
  15278. +#include <linux/platform/ar934x_nfc.h>
  15279. +
  15280. +#include <asm/mach-ath79/ar71xx_regs.h>
  15281. +
  15282. +#include "common.h"
  15283. +#include "pci.h"
  15284. +#include "dev-ap9x-pci.h"
  15285. +#include "dev-gpio-buttons.h"
  15286. +#include "dev-eth.h"
  15287. +#include "dev-leds-gpio.h"
  15288. +#include "dev-nfc.h"
  15289. +#include "dev-m25p80.h"
  15290. +#include "dev-usb.h"
  15291. +#include "dev-wmac.h"
  15292. +#include "machtypes.h"
  15293. +#include "nvram.h"
  15294. +
  15295. +#define NBG6716_GPIO_LED_INTERNET 18
  15296. +#define NBG6716_GPIO_LED_POWER 15
  15297. +#define NBG6716_GPIO_LED_USB1 4
  15298. +#define NBG6716_GPIO_LED_USB2 13
  15299. +#define NBG6716_GPIO_LED_WIFI2G 19
  15300. +#define NBG6716_GPIO_LED_WIFI5G 17
  15301. +#define NBG6716_GPIO_LED_WPS 21
  15302. +
  15303. +#define NBG6716_GPIO_BTN_RESET 23
  15304. +#define NBG6716_GPIO_BTN_RFKILL 1
  15305. +#define NBG6716_GPIO_BTN_USB1 0
  15306. +#define NBG6716_GPIO_BTN_USB2 14
  15307. +#define NBG6716_GPIO_BTN_WPS 22
  15308. +
  15309. +#define NBG6716_GPIO_USB_POWER 16
  15310. +
  15311. +#define NBG6716_KEYS_POLL_INTERVAL 20 /* msecs */
  15312. +#define NBG6716_KEYS_DEBOUNCE_INTERVAL (3 * NBG6716_KEYS_POLL_INTERVAL)
  15313. +
  15314. +#define NBG6716_MAC0_OFFSET 0
  15315. +#define NBG6716_MAC1_OFFSET 6
  15316. +#define NBG6716_WMAC_CALDATA_OFFSET 0x1000
  15317. +#define NBG6716_PCIE_CALDATA_OFFSET 0x5000
  15318. +
  15319. +/* NBG6616 has a different GPIO usage as it does not have USB Buttons */
  15320. +#define NBG6616_GPIO_LED_USB0 14
  15321. +#define NBG6616_GPIO_LED_USB1 21
  15322. +#define NBG6616_GPIO_LED_WPS 0
  15323. +
  15324. +static struct gpio_led nbg6716_leds_gpio[] __initdata = {
  15325. + {
  15326. + .name = "nbg6716:white:internet",
  15327. + .gpio = NBG6716_GPIO_LED_INTERNET,
  15328. + .active_low = 1,
  15329. + },
  15330. + {
  15331. + .name = "nbg6716:white:power",
  15332. + .gpio = NBG6716_GPIO_LED_POWER,
  15333. + .active_low = 1,
  15334. + },
  15335. + {
  15336. + .name = "nbg6716:white:usb1",
  15337. + .gpio = NBG6716_GPIO_LED_USB1,
  15338. + .active_low = 1,
  15339. + },
  15340. + {
  15341. + .name = "nbg6716:white:usb2",
  15342. + .gpio = NBG6716_GPIO_LED_USB2,
  15343. + .active_low = 1,
  15344. + },
  15345. + {
  15346. + .name = "nbg6716:white:wifi2g",
  15347. + .gpio = NBG6716_GPIO_LED_WIFI2G,
  15348. + .active_low = 1,
  15349. + },
  15350. + {
  15351. + .name = "nbg6716:white:wifi5g",
  15352. + .gpio = NBG6716_GPIO_LED_WIFI5G,
  15353. + .active_low = 1,
  15354. + },
  15355. + {
  15356. + .name = "nbg6716:white:wps",
  15357. + .gpio = NBG6716_GPIO_LED_WPS,
  15358. + .active_low = 1,
  15359. + }
  15360. +};
  15361. +
  15362. +static struct gpio_keys_button nbg6716_gpio_keys[] __initdata = {
  15363. + {
  15364. + .desc = "RESET button",
  15365. + .type = EV_KEY,
  15366. + .code = KEY_RESTART,
  15367. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15368. + .gpio = NBG6716_GPIO_BTN_RESET,
  15369. + .active_low = 1,
  15370. + },
  15371. + {
  15372. + .desc = "RFKILL button",
  15373. + .type = EV_SW,
  15374. + .code = KEY_RFKILL,
  15375. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15376. + .gpio = NBG6716_GPIO_BTN_RFKILL,
  15377. + .active_low = 0,
  15378. + },
  15379. + {
  15380. + .desc = "USB1 eject button",
  15381. + .type = EV_KEY,
  15382. + .code = BTN_1,
  15383. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15384. + .gpio = NBG6716_GPIO_BTN_USB1,
  15385. + .active_low = 1,
  15386. + },
  15387. + {
  15388. + .desc = "USB2 eject button",
  15389. + .type = EV_KEY,
  15390. + .code = BTN_2,
  15391. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15392. + .gpio = NBG6716_GPIO_BTN_USB2,
  15393. + .active_low = 1,
  15394. + },
  15395. + {
  15396. + .desc = "WPS button",
  15397. + .type = EV_KEY,
  15398. + .code = KEY_WPS_BUTTON,
  15399. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15400. + .gpio = NBG6716_GPIO_BTN_WPS,
  15401. + .active_low = 1,
  15402. + },
  15403. +};
  15404. +
  15405. +
  15406. +
  15407. +static struct gpio_led nbg6616_leds_gpio[] __initdata = {
  15408. + {
  15409. + .name = "nbg6616:green:power",
  15410. + .gpio = NBG6716_GPIO_LED_POWER,
  15411. + .active_low = 1,
  15412. + },
  15413. + {
  15414. + .name = "nbg6616:green:usb2",
  15415. + .gpio = NBG6616_GPIO_LED_USB0,
  15416. + .active_low = 1,
  15417. + },
  15418. + {
  15419. + .name = "nbg6616:green:usb1",
  15420. + .gpio = NBG6616_GPIO_LED_USB1,
  15421. + .active_low = 1,
  15422. + },
  15423. + {
  15424. + .name = "nbg6616:green:wifi2g",
  15425. + .gpio = NBG6716_GPIO_LED_WIFI2G,
  15426. + .active_low = 1,
  15427. + },
  15428. + {
  15429. + .name = "nbg6616:green:wifi5g",
  15430. + .gpio = NBG6716_GPIO_LED_WIFI5G,
  15431. + .active_low = 1,
  15432. + },
  15433. + {
  15434. + .name = "nbg6616:green:wps",
  15435. + .gpio = NBG6616_GPIO_LED_WPS,
  15436. + .active_low = 1,
  15437. + }
  15438. +};
  15439. +
  15440. +static struct gpio_keys_button nbg6616_gpio_keys[] __initdata = {
  15441. + {
  15442. + .desc = "RESET button",
  15443. + .type = EV_KEY,
  15444. + .code = KEY_RESTART,
  15445. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15446. + .gpio = NBG6716_GPIO_BTN_RESET,
  15447. + .active_low = 1,
  15448. + },
  15449. + {
  15450. + .desc = "RFKILL button",
  15451. + .type = EV_KEY,
  15452. + .code = KEY_RFKILL,
  15453. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15454. + .gpio = NBG6716_GPIO_BTN_RFKILL,
  15455. + .active_low = 1,
  15456. + },
  15457. + {
  15458. + .desc = "WPS button",
  15459. + .type = EV_KEY,
  15460. + .code = KEY_WPS_BUTTON,
  15461. + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
  15462. + .gpio = NBG6716_GPIO_BTN_WPS,
  15463. + .active_low = 1,
  15464. + },
  15465. +};
  15466. +
  15467. +
  15468. +static struct ar8327_pad_cfg nbg6716_ar8327_pad0_cfg;
  15469. +static struct ar8327_pad_cfg nbg6716_ar8327_pad6_cfg;
  15470. +static struct ar8327_led_cfg nbg6716_ar8327_led_cfg;
  15471. +
  15472. +static struct ar8327_platform_data nbg6716_ar8327_data = {
  15473. + .pad0_cfg = &nbg6716_ar8327_pad0_cfg,
  15474. + .pad6_cfg = &nbg6716_ar8327_pad6_cfg,
  15475. + .port0_cfg = {
  15476. + .force_link = 1,
  15477. + .speed = AR8327_PORT_SPEED_1000,
  15478. + .duplex = 1,
  15479. + .txpause = 1,
  15480. + .rxpause = 1,
  15481. + },
  15482. + .port6_cfg = {
  15483. + .force_link = 1,
  15484. + .speed = AR8327_PORT_SPEED_1000,
  15485. + .duplex = 1,
  15486. + .txpause = 1,
  15487. + .rxpause = 1,
  15488. + },
  15489. + .led_cfg = &nbg6716_ar8327_led_cfg
  15490. +};
  15491. +
  15492. +static struct mdio_board_info nbg6716_mdio0_info[] = {
  15493. + {
  15494. + .bus_id = "ag71xx-mdio.0",
  15495. + .phy_addr = 0,
  15496. + .platform_data = &nbg6716_ar8327_data,
  15497. + },
  15498. +};
  15499. +
  15500. +static void nbg6716_get_mac(void* nvram_addr, const char *name, char *mac)
  15501. +{
  15502. + u8 *nvram = (u8 *) KSEG1ADDR(nvram_addr);
  15503. + int err;
  15504. +
  15505. + err = ath79_nvram_parse_mac_addr(nvram, 0x10000,
  15506. + name, mac);
  15507. + if (err)
  15508. + pr_err("no MAC address found for %s\n", name);
  15509. +}
  15510. +
  15511. +static void __init nbg6716_common_setup(u32 leds_num, struct gpio_led* leds,
  15512. + u32 keys_num,
  15513. + struct gpio_keys_button* keys,
  15514. + void* art_addr, void* nvram)
  15515. +{
  15516. + u8 *art = (u8 *) KSEG1ADDR(art_addr);
  15517. + u8 tmpmac[ETH_ALEN];
  15518. +
  15519. + ath79_register_m25p80(NULL);
  15520. +
  15521. + ath79_register_leds_gpio(-1, leds_num, leds);
  15522. + ath79_register_gpio_keys_polled(-1, NBG6716_KEYS_POLL_INTERVAL,
  15523. + keys_num, keys);
  15524. +
  15525. + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
  15526. + ath79_register_nfc();
  15527. +
  15528. + gpio_request_one(NBG6716_GPIO_USB_POWER,
  15529. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  15530. + "USB power");
  15531. +
  15532. + ath79_register_usb();
  15533. +
  15534. + nbg6716_get_mac(nvram, "ethaddr=", tmpmac);
  15535. +
  15536. + ath79_register_pci();
  15537. +
  15538. + ath79_register_wmac(art + NBG6716_WMAC_CALDATA_OFFSET, tmpmac);
  15539. +
  15540. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  15541. +
  15542. + ath79_register_mdio(0, 0x0);
  15543. +
  15544. + ath79_init_mac(ath79_eth0_data.mac_addr, tmpmac, 2);
  15545. + ath79_init_mac(ath79_eth1_data.mac_addr, tmpmac, 3);
  15546. +
  15547. + mdiobus_register_board_info(nbg6716_mdio0_info,
  15548. + ARRAY_SIZE(nbg6716_mdio0_info));
  15549. +
  15550. + /* GMAC0 is connected to the RMGII interface */
  15551. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  15552. + ath79_eth0_data.phy_mask = BIT(0);
  15553. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  15554. +
  15555. + ath79_register_eth(0);
  15556. +
  15557. + /* GMAC1 is connected to the SGMII interface */
  15558. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  15559. + ath79_eth1_data.speed = SPEED_1000;
  15560. + ath79_eth1_data.duplex = DUPLEX_FULL;
  15561. +
  15562. + ath79_register_eth(1);
  15563. +}
  15564. +
  15565. +static void __init nbg6716_010_setup(void)
  15566. +{
  15567. + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
  15568. + nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  15569. + nbg6716_ar8327_pad0_cfg.txclk_delay_en = true;
  15570. + nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true;
  15571. + nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  15572. + nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  15573. + nbg6716_ar8327_pad0_cfg.mac06_exchange_en = true;
  15574. +
  15575. + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
  15576. + nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  15577. + nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true;
  15578. + nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  15579. +
  15580. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  15581. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  15582. +
  15583. + nbg6716_ar8327_led_cfg.open_drain = 0;
  15584. + nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7;
  15585. + nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7;
  15586. + nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7;
  15587. + nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00;
  15588. +
  15589. + nbg6716_common_setup(ARRAY_SIZE(nbg6716_leds_gpio), nbg6716_leds_gpio,
  15590. + ARRAY_SIZE(nbg6716_gpio_keys), nbg6716_gpio_keys,
  15591. + (void*) 0x1f050000, (void*) 0x1f040000);
  15592. +}
  15593. +
  15594. +static void __init nbg6616_010_setup(void)
  15595. +{
  15596. + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
  15597. + nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  15598. + nbg6716_ar8327_pad0_cfg.txclk_delay_en = true;
  15599. + nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true;
  15600. + nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  15601. + nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  15602. +
  15603. + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
  15604. + nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  15605. + nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true;
  15606. + nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  15607. +
  15608. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  15609. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  15610. +
  15611. + nbg6716_ar8327_led_cfg.open_drain = 0;
  15612. + nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7;
  15613. + nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7;
  15614. + nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7;
  15615. + nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00;
  15616. +
  15617. +
  15618. + nbg6716_common_setup(ARRAY_SIZE(nbg6616_leds_gpio), nbg6616_leds_gpio,
  15619. + ARRAY_SIZE(nbg6616_gpio_keys), nbg6616_gpio_keys,
  15620. + (void*) 0x1f040000, (void*) 0x1f030000);
  15621. +}
  15622. +
  15623. +
  15624. +MIPS_MACHINE(ATH79_MACH_NBG6716, "NBG6716",
  15625. + "Zyxel NBG6716",
  15626. + nbg6716_010_setup);
  15627. +
  15628. +MIPS_MACHINE(ATH79_MACH_NBG6616, "NBG6616",
  15629. + "Zyxel NBG6616",
  15630. + nbg6616_010_setup);
  15631. +
  15632. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-om2p.c linux-4.1.13/arch/mips/ath79/mach-om2p.c
  15633. --- linux-4.1.13.orig/arch/mips/ath79/mach-om2p.c 1970-01-01 01:00:00.000000000 +0100
  15634. +++ linux-4.1.13/arch/mips/ath79/mach-om2p.c 2015-09-13 20:04:35.068524086 +0200
  15635. @@ -0,0 +1,225 @@
  15636. +/*
  15637. + * OpenMesh OM2P support
  15638. + *
  15639. + * Copyright (C) 2011 Marek Lindner <marek@open-mesh.com>
  15640. + *
  15641. + * This program is free software; you can redistribute it and/or modify it
  15642. + * under the terms of the GNU General Public License version 2 as published
  15643. + * by the Free Software Foundation.
  15644. + */
  15645. +
  15646. +#include <linux/gpio.h>
  15647. +#include <linux/mtd/mtd.h>
  15648. +#include <linux/mtd/partitions.h>
  15649. +#include <linux/platform_device.h>
  15650. +
  15651. +#include <asm/mach-ath79/ar71xx_regs.h>
  15652. +#include <asm/mach-ath79/ath79.h>
  15653. +
  15654. +#include "common.h"
  15655. +#include "dev-ap9x-pci.h"
  15656. +#include "dev-eth.h"
  15657. +#include "dev-gpio-buttons.h"
  15658. +#include "dev-leds-gpio.h"
  15659. +#include "dev-m25p80.h"
  15660. +#include "dev-wmac.h"
  15661. +#include "machtypes.h"
  15662. +
  15663. +#define OM2P_GPIO_LED_POWER 0
  15664. +#define OM2P_GPIO_LED_GREEN 13
  15665. +#define OM2P_GPIO_LED_RED 14
  15666. +#define OM2P_GPIO_LED_YELLOW 15
  15667. +#define OM2P_GPIO_LED_LAN 16
  15668. +#define OM2P_GPIO_LED_WAN 17
  15669. +#define OM2P_GPIO_BTN_RESET 1
  15670. +
  15671. +#define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
  15672. +#define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
  15673. +
  15674. +#define OM2P_WAN_PHYMASK BIT(4)
  15675. +
  15676. +#define OM2P_LC_GPIO_LED_POWER 1
  15677. +#define OM2P_LC_GPIO_LED_GREEN 15
  15678. +#define OM2P_LC_GPIO_LED_RED 16
  15679. +#define OM2P_LC_GPIO_LED_YELLOW 0
  15680. +#define OM2P_LC_GPIO_LED_LAN 13
  15681. +#define OM2P_LC_GPIO_LED_WAN 17
  15682. +#define OM2P_LC_GPIO_BTN_RESET 12
  15683. +
  15684. +static struct flash_platform_data om2p_flash_data = {
  15685. + .type = "s25sl12800",
  15686. + .name = "ar7240-nor0",
  15687. +};
  15688. +
  15689. +static struct gpio_led om2p_leds_gpio[] __initdata = {
  15690. + {
  15691. + .name = "om2p:blue:power",
  15692. + .gpio = OM2P_GPIO_LED_POWER,
  15693. + .active_low = 1,
  15694. + }, {
  15695. + .name = "om2p:red:wifi",
  15696. + .gpio = OM2P_GPIO_LED_RED,
  15697. + .active_low = 1,
  15698. + }, {
  15699. + .name = "om2p:yellow:wifi",
  15700. + .gpio = OM2P_GPIO_LED_YELLOW,
  15701. + .active_low = 1,
  15702. + }, {
  15703. + .name = "om2p:green:wifi",
  15704. + .gpio = OM2P_GPIO_LED_GREEN,
  15705. + .active_low = 1,
  15706. + }, {
  15707. + .name = "om2p:blue:lan",
  15708. + .gpio = OM2P_GPIO_LED_LAN,
  15709. + .active_low = 1,
  15710. + }, {
  15711. + .name = "om2p:blue:wan",
  15712. + .gpio = OM2P_GPIO_LED_WAN,
  15713. + .active_low = 1,
  15714. + }
  15715. +};
  15716. +
  15717. +static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
  15718. + {
  15719. + .desc = "reset",
  15720. + .type = EV_KEY,
  15721. + .code = KEY_RESTART,
  15722. + .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
  15723. + .gpio = OM2P_GPIO_BTN_RESET,
  15724. + .active_low = 1,
  15725. + }
  15726. +};
  15727. +
  15728. +static void __init om2p_setup(void)
  15729. +{
  15730. + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
  15731. + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
  15732. + u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
  15733. +
  15734. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  15735. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  15736. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  15737. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  15738. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  15739. +
  15740. + ath79_register_m25p80(&om2p_flash_data);
  15741. +
  15742. + ath79_register_mdio(0, ~OM2P_WAN_PHYMASK);
  15743. +
  15744. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  15745. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  15746. +
  15747. + ath79_register_eth(0);
  15748. + ath79_register_eth(1);
  15749. +
  15750. + ap91_pci_init(ee, NULL);
  15751. +
  15752. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
  15753. + om2p_leds_gpio);
  15754. +
  15755. + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
  15756. + ARRAY_SIZE(om2p_gpio_keys),
  15757. + om2p_gpio_keys);
  15758. +}
  15759. +
  15760. +MIPS_MACHINE(ATH79_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);
  15761. +
  15762. +
  15763. +static struct flash_platform_data om2p_lc_flash_data = {
  15764. + .type = "s25sl12800",
  15765. +};
  15766. +
  15767. +static void __init om2p_lc_setup(void)
  15768. +{
  15769. + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
  15770. + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
  15771. + u8 *art = (u8 *)KSEG1ADDR(0x1ffc1000);
  15772. + u32 t;
  15773. +
  15774. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  15775. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  15776. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  15777. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  15778. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  15779. +
  15780. + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  15781. + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  15782. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  15783. +
  15784. + ath79_register_m25p80(&om2p_lc_flash_data);
  15785. +
  15786. + om2p_leds_gpio[0].gpio = OM2P_LC_GPIO_LED_POWER;
  15787. + om2p_leds_gpio[1].gpio = OM2P_LC_GPIO_LED_RED;
  15788. + om2p_leds_gpio[2].gpio = OM2P_LC_GPIO_LED_YELLOW;
  15789. + om2p_leds_gpio[3].gpio = OM2P_LC_GPIO_LED_GREEN;
  15790. + om2p_leds_gpio[4].gpio = OM2P_LC_GPIO_LED_LAN;
  15791. + om2p_leds_gpio[5].gpio = OM2P_LC_GPIO_LED_WAN;
  15792. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
  15793. + om2p_leds_gpio);
  15794. +
  15795. + om2p_gpio_keys[0].gpio = OM2P_LC_GPIO_BTN_RESET;
  15796. + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
  15797. + ARRAY_SIZE(om2p_gpio_keys),
  15798. + om2p_gpio_keys);
  15799. +
  15800. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  15801. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  15802. +
  15803. + ath79_register_mdio(0, 0x0);
  15804. +
  15805. + ath79_register_eth(0);
  15806. + ath79_register_eth(1);
  15807. +
  15808. + ath79_register_wmac(art, NULL);
  15809. +}
  15810. +
  15811. +MIPS_MACHINE(ATH79_MACH_OM2P_LC, "OM2P-LC", "OpenMesh OM2P LC", om2p_lc_setup);
  15812. +MIPS_MACHINE(ATH79_MACH_OM2Pv2, "OM2Pv2", "OpenMesh OM2Pv2", om2p_lc_setup);
  15813. +
  15814. +static void __init om2p_hs_setup(void)
  15815. +{
  15816. + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
  15817. + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
  15818. + u8 *art = (u8 *)KSEG1ADDR(0x1ffc1000);
  15819. +
  15820. + /* make lan / wan leds software controllable */
  15821. + ath79_gpio_output_select(OM2P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  15822. + ath79_gpio_output_select(OM2P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
  15823. +
  15824. + /* enable reset button */
  15825. + ath79_gpio_output_select(OM2P_GPIO_BTN_RESET, AR934X_GPIO_OUT_GPIO);
  15826. + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  15827. +
  15828. + om2p_leds_gpio[4].gpio = OM2P_GPIO_LED_WAN;
  15829. + om2p_leds_gpio[5].gpio = OM2P_GPIO_LED_LAN;
  15830. +
  15831. + ath79_register_m25p80(&om2p_lc_flash_data);
  15832. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
  15833. + om2p_leds_gpio);
  15834. + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
  15835. + ARRAY_SIZE(om2p_gpio_keys),
  15836. + om2p_gpio_keys);
  15837. +
  15838. + ath79_register_wmac(art, NULL);
  15839. +
  15840. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  15841. + ath79_register_mdio(1, 0x0);
  15842. +
  15843. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  15844. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  15845. +
  15846. + /* GMAC0 is connected to the PHY0 of the internal switch */
  15847. + ath79_switch_data.phy4_mii_en = 1;
  15848. + ath79_switch_data.phy_poll_mask = BIT(0);
  15849. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  15850. + ath79_eth0_data.phy_mask = BIT(0);
  15851. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  15852. + ath79_register_eth(0);
  15853. +
  15854. + /* GMAC1 is connected to the internal switch */
  15855. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  15856. + ath79_register_eth(1);
  15857. +}
  15858. +
  15859. +MIPS_MACHINE(ATH79_MACH_OM2P_HS, "OM2P-HS", "OpenMesh OM2P HS", om2p_hs_setup);
  15860. +MIPS_MACHINE(ATH79_MACH_OM2P_HSv2, "OM2P-HSv2", "OpenMesh OM2P HSv2", om2p_hs_setup);
  15861. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-om5p.c linux-4.1.13/arch/mips/ath79/mach-om5p.c
  15862. --- linux-4.1.13.orig/arch/mips/ath79/mach-om5p.c 1970-01-01 01:00:00.000000000 +0100
  15863. +++ linux-4.1.13/arch/mips/ath79/mach-om5p.c 2015-09-13 20:04:35.068524086 +0200
  15864. @@ -0,0 +1,218 @@
  15865. +/*
  15866. + * OpenMesh OM5P support
  15867. + *
  15868. + * Copyright (C) 2013 Marek Lindner <marek@open-mesh.com>
  15869. + * Copyright (C) 2014 Sven Eckelmann <sven@open-mesh.com>
  15870. + *
  15871. + * This program is free software; you can redistribute it and/or modify it
  15872. + * under the terms of the GNU General Public License version 2 as published
  15873. + * by the Free Software Foundation.
  15874. + */
  15875. +
  15876. +#include <linux/gpio.h>
  15877. +#include <linux/mtd/mtd.h>
  15878. +#include <linux/mtd/partitions.h>
  15879. +#include <linux/platform_device.h>
  15880. +#include <linux/i2c.h>
  15881. +#include <linux/i2c-algo-bit.h>
  15882. +#include <linux/i2c-gpio.h>
  15883. +#include <linux/platform_data/phy-at803x.h>
  15884. +
  15885. +#include <asm/mach-ath79/ar71xx_regs.h>
  15886. +#include <asm/mach-ath79/ath79.h>
  15887. +
  15888. +#include "common.h"
  15889. +#include "dev-ap9x-pci.h"
  15890. +#include "dev-eth.h"
  15891. +#include "dev-gpio-buttons.h"
  15892. +#include "dev-leds-gpio.h"
  15893. +#include "dev-m25p80.h"
  15894. +#include "dev-wmac.h"
  15895. +#include "machtypes.h"
  15896. +
  15897. +#define OM5P_GPIO_LED_POWER 13
  15898. +#define OM5P_GPIO_LED_GREEN 16
  15899. +#define OM5P_GPIO_LED_RED 19
  15900. +#define OM5P_GPIO_LED_YELLOW 17
  15901. +#define OM5P_GPIO_LED_LAN 14
  15902. +#define OM5P_GPIO_LED_WAN 15
  15903. +#define OM5P_GPIO_BTN_RESET 4
  15904. +#define OM5P_GPIO_I2C_SCL 20
  15905. +#define OM5P_GPIO_I2C_SDA 21
  15906. +
  15907. +#define OM5P_KEYS_POLL_INTERVAL 20 /* msecs */
  15908. +#define OM5P_KEYS_DEBOUNCE_INTERVAL (3 * OM5P_KEYS_POLL_INTERVAL)
  15909. +
  15910. +#define OM5P_WMAC_CALDATA_OFFSET 0x1000
  15911. +#define OM5P_PCI_CALDATA_OFFSET 0x5000
  15912. +
  15913. +static struct gpio_led om5p_leds_gpio[] __initdata = {
  15914. + {
  15915. + .name = "om5p:blue:power",
  15916. + .gpio = OM5P_GPIO_LED_POWER,
  15917. + .active_low = 1,
  15918. + }, {
  15919. + .name = "om5p:red:wifi",
  15920. + .gpio = OM5P_GPIO_LED_RED,
  15921. + .active_low = 1,
  15922. + }, {
  15923. + .name = "om5p:yellow:wifi",
  15924. + .gpio = OM5P_GPIO_LED_YELLOW,
  15925. + .active_low = 1,
  15926. + }, {
  15927. + .name = "om5p:green:wifi",
  15928. + .gpio = OM5P_GPIO_LED_GREEN,
  15929. + .active_low = 1,
  15930. + }, {
  15931. + .name = "om5p:blue:lan",
  15932. + .gpio = OM5P_GPIO_LED_LAN,
  15933. + .active_low = 1,
  15934. + }, {
  15935. + .name = "om5p:blue:wan",
  15936. + .gpio = OM5P_GPIO_LED_WAN,
  15937. + .active_low = 1,
  15938. + }
  15939. +};
  15940. +
  15941. +static struct gpio_keys_button om5p_gpio_keys[] __initdata = {
  15942. + {
  15943. + .desc = "reset",
  15944. + .type = EV_KEY,
  15945. + .code = KEY_RESTART,
  15946. + .debounce_interval = OM5P_KEYS_DEBOUNCE_INTERVAL,
  15947. + .gpio = OM5P_GPIO_BTN_RESET,
  15948. + .active_low = 1,
  15949. + }
  15950. +};
  15951. +
  15952. +static struct flash_platform_data om5p_flash_data = {
  15953. + .type = "mx25l12805d",
  15954. +};
  15955. +
  15956. +static void __init om5p_setup(void)
  15957. +{
  15958. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  15959. + u8 mac[6];
  15960. +
  15961. + /* make lan / wan leds software controllable */
  15962. + ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  15963. + ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
  15964. +
  15965. + ath79_register_m25p80(&om5p_flash_data);
  15966. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
  15967. + om5p_leds_gpio);
  15968. + ath79_register_gpio_keys_polled(-1, OM5P_KEYS_POLL_INTERVAL,
  15969. + ARRAY_SIZE(om5p_gpio_keys),
  15970. + om5p_gpio_keys);
  15971. +
  15972. + ath79_init_mac(mac, art, 2);
  15973. + ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
  15974. +
  15975. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  15976. + ath79_register_mdio(1, 0x0);
  15977. +
  15978. + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
  15979. + ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
  15980. +
  15981. + /* GMAC0 is connected to the PHY0 of the internal switch */
  15982. + ath79_switch_data.phy4_mii_en = 1;
  15983. + ath79_switch_data.phy_poll_mask = BIT(0);
  15984. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  15985. + ath79_eth0_data.phy_mask = BIT(0);
  15986. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  15987. + ath79_register_eth(0);
  15988. +
  15989. + /* GMAC1 is connected to the internal switch */
  15990. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  15991. + ath79_register_eth(1);
  15992. +}
  15993. +
  15994. +MIPS_MACHINE(ATH79_MACH_OM5P, "OM5P", "OpenMesh OM5P", om5p_setup);
  15995. +
  15996. +static struct i2c_gpio_platform_data om5pan_i2c_device_platdata = {
  15997. + .sda_pin = OM5P_GPIO_I2C_SDA,
  15998. + .scl_pin = OM5P_GPIO_I2C_SCL,
  15999. + .udelay = 10,
  16000. + .sda_is_open_drain = 1,
  16001. + .scl_is_open_drain = 1,
  16002. +};
  16003. +
  16004. +static struct platform_device om5pan_i2c_device = {
  16005. + .name = "i2c-gpio",
  16006. + .id = 0,
  16007. + .dev = {
  16008. + .platform_data = &om5pan_i2c_device_platdata,
  16009. + },
  16010. +};
  16011. +
  16012. +static struct i2c_board_info om5pan_i2c_devs[] __initdata = {
  16013. + {
  16014. + I2C_BOARD_INFO("tmp423", 0x4c),
  16015. + },
  16016. +};
  16017. +
  16018. +static struct at803x_platform_data om5p_an_at803x_data = {
  16019. + .disable_smarteee = 1,
  16020. + .enable_rgmii_rx_delay = 1,
  16021. + .enable_rgmii_tx_delay = 1,
  16022. +};
  16023. +
  16024. +static struct mdio_board_info om5p_an_mdio0_info[] = {
  16025. + {
  16026. + .bus_id = "ag71xx-mdio.0",
  16027. + .phy_addr = 7,
  16028. + .platform_data = &om5p_an_at803x_data,
  16029. + },
  16030. +};
  16031. +
  16032. +static void __init om5p_an_setup(void)
  16033. +{
  16034. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  16035. + u8 mac[6];
  16036. +
  16037. + /* temperature sensor */
  16038. + platform_device_register(&om5pan_i2c_device);
  16039. + i2c_register_board_info(0, om5pan_i2c_devs,
  16040. + ARRAY_SIZE(om5pan_i2c_devs));
  16041. +
  16042. + /* make lan / wan leds software controllable */
  16043. + ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  16044. + ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
  16045. +
  16046. + ath79_register_m25p80(&om5p_flash_data);
  16047. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
  16048. + om5p_leds_gpio);
  16049. +
  16050. + ath79_init_mac(mac, art, 0x02);
  16051. + ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
  16052. +
  16053. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  16054. + ath79_setup_ar934x_eth_rx_delay(2, 2);
  16055. + ath79_register_mdio(0, 0x0);
  16056. + ath79_register_mdio(1, 0x0);
  16057. +
  16058. + mdiobus_register_board_info(om5p_an_mdio0_info,
  16059. + ARRAY_SIZE(om5p_an_mdio0_info));
  16060. +
  16061. + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
  16062. + ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
  16063. +
  16064. + /* GMAC0 is connected to the PHY7 */
  16065. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  16066. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  16067. + ath79_eth0_data.phy_mask = BIT(7);
  16068. + ath79_eth0_pll_data.pll_1000 = 0x02000000;
  16069. + ath79_eth0_pll_data.pll_100 = 0x00000101;
  16070. + ath79_eth0_pll_data.pll_10 = 0x00001313;
  16071. + ath79_register_eth(0);
  16072. +
  16073. + /* GMAC1 is connected to the internal switch */
  16074. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  16075. + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  16076. + ath79_register_eth(1);
  16077. +
  16078. + ath79_init_mac(mac, art, 0x10);
  16079. + ap91_pci_init(art + OM5P_PCI_CALDATA_OFFSET, mac);
  16080. +}
  16081. +
  16082. +MIPS_MACHINE(ATH79_MACH_OM5P_AN, "OM5P-AN", "OpenMesh OM5P AN", om5p_an_setup);
  16083. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-onion-omega.c linux-4.1.13/arch/mips/ath79/mach-onion-omega.c
  16084. --- linux-4.1.13.orig/arch/mips/ath79/mach-onion-omega.c 1970-01-01 01:00:00.000000000 +0100
  16085. +++ linux-4.1.13/arch/mips/ath79/mach-onion-omega.c 2015-09-13 20:04:35.068524086 +0200
  16086. @@ -0,0 +1,84 @@
  16087. +/*
  16088. + * Onion Omega board support
  16089. + *
  16090. + * Copyright (C) 2015 Boken Lin <bl@onion.io>
  16091. + *
  16092. + * This program is free software; you can redistribute it and/or modify it
  16093. + * under the terms of the GNU General Public License version 2 as published
  16094. + * by the Free Software Foundation.
  16095. + */
  16096. +
  16097. +#include <linux/gpio.h>
  16098. +
  16099. +#include <asm/mach-ath79/ath79.h>
  16100. +
  16101. +#include "dev-eth.h"
  16102. +#include "dev-gpio-buttons.h"
  16103. +#include "dev-leds-gpio.h"
  16104. +#include "dev-m25p80.h"
  16105. +#include "dev-usb.h"
  16106. +#include "dev-wmac.h"
  16107. +#include "machtypes.h"
  16108. +
  16109. +#define OMEGA_GPIO_LED_SYSTEM 27
  16110. +#define OMEGA_GPIO_BTN_RESET 11
  16111. +
  16112. +#define OMEGA_GPIO_USB_POWER 8
  16113. +
  16114. +#define OMEGA_KEYS_POLL_INTERVAL 20 /* msecs */
  16115. +#define OMEGA_KEYS_DEBOUNCE_INTERVAL (3 * OMEGA_KEYS_POLL_INTERVAL)
  16116. +
  16117. +static const char *omega_part_probes[] = {
  16118. + "tp-link",
  16119. + NULL,
  16120. +};
  16121. +
  16122. +static struct flash_platform_data omega_flash_data = {
  16123. + .part_probes = omega_part_probes,
  16124. +};
  16125. +
  16126. +static struct gpio_led omega_leds_gpio[] __initdata = {
  16127. + {
  16128. + .name = "onion:amber:system",
  16129. + .gpio = OMEGA_GPIO_LED_SYSTEM,
  16130. + .active_low = 1,
  16131. + },
  16132. +};
  16133. +
  16134. +static struct gpio_keys_button omega_gpio_keys[] __initdata = {
  16135. + {
  16136. + .desc = "reset",
  16137. + .type = EV_KEY,
  16138. + .code = KEY_RESTART,
  16139. + .debounce_interval = OMEGA_KEYS_DEBOUNCE_INTERVAL,
  16140. + .gpio = OMEGA_GPIO_BTN_RESET,
  16141. + .active_low = 0,
  16142. + }
  16143. +};
  16144. +
  16145. +static void __init onion_omega_setup(void)
  16146. +{
  16147. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  16148. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  16149. +
  16150. + ath79_register_m25p80(&omega_flash_data);
  16151. + ath79_register_leds_gpio(-1, ARRAY_SIZE(omega_leds_gpio),
  16152. + omega_leds_gpio);
  16153. + ath79_register_gpio_keys_polled(-1, OMEGA_KEYS_POLL_INTERVAL,
  16154. + ARRAY_SIZE(omega_gpio_keys),
  16155. + omega_gpio_keys);
  16156. +
  16157. + gpio_request_one(OMEGA_GPIO_USB_POWER,
  16158. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  16159. + "USB power");
  16160. + ath79_register_usb();
  16161. +
  16162. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  16163. +
  16164. + ath79_register_mdio(0, 0x0);
  16165. + ath79_register_eth(0);
  16166. +
  16167. + ath79_register_wmac(ee, mac);
  16168. +}
  16169. +
  16170. +MIPS_MACHINE(ATH79_MACH_ONION_OMEGA, "ONION-OMEGA", "Onion Omega", onion_omega_setup);
  16171. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-pb42.c linux-4.1.13/arch/mips/ath79/mach-pb42.c
  16172. --- linux-4.1.13.orig/arch/mips/ath79/mach-pb42.c 1970-01-01 01:00:00.000000000 +0100
  16173. +++ linux-4.1.13/arch/mips/ath79/mach-pb42.c 2015-09-13 20:04:35.068524086 +0200
  16174. @@ -0,0 +1,83 @@
  16175. +/*
  16176. + * Atheros PB42 board support
  16177. + *
  16178. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  16179. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  16180. + *
  16181. + * This program is free software; you can redistribute it and/or modify it
  16182. + * under the terms of the GNU General Public License version 2 as published
  16183. + * by the Free Software Foundation.
  16184. + */
  16185. +
  16186. +#include <asm/mach-ath79/ath79.h>
  16187. +
  16188. +#include "dev-eth.h"
  16189. +#include "dev-gpio-buttons.h"
  16190. +#include "dev-m25p80.h"
  16191. +#include "dev-usb.h"
  16192. +#include "machtypes.h"
  16193. +#include "pci.h"
  16194. +
  16195. +#define PB42_KEYS_POLL_INTERVAL 20 /* msecs */
  16196. +#define PB42_KEYS_DEBOUNCE_INTERVAL (3 * PB42_KEYS_POLL_INTERVAL)
  16197. +
  16198. +#define PB42_GPIO_BTN_SW4 8
  16199. +#define PB42_GPIO_BTN_SW5 3
  16200. +
  16201. +static struct gpio_keys_button pb42_gpio_keys[] __initdata = {
  16202. + {
  16203. + .desc = "sw4",
  16204. + .type = EV_KEY,
  16205. + .code = BTN_0,
  16206. + .debounce_interval = PB42_KEYS_DEBOUNCE_INTERVAL,
  16207. + .gpio = PB42_GPIO_BTN_SW4,
  16208. + .active_low = 1,
  16209. + }, {
  16210. + .desc = "sw5",
  16211. + .type = EV_KEY,
  16212. + .code = BTN_1,
  16213. + .debounce_interval = PB42_KEYS_DEBOUNCE_INTERVAL,
  16214. + .gpio = PB42_GPIO_BTN_SW5,
  16215. + .active_low = 1,
  16216. + }
  16217. +};
  16218. +
  16219. +static const char *pb42_part_probes[] = {
  16220. + "RedBoot",
  16221. + NULL,
  16222. +};
  16223. +
  16224. +static struct flash_platform_data pb42_flash_data = {
  16225. + .part_probes = pb42_part_probes,
  16226. +};
  16227. +
  16228. +#define PB42_WAN_PHYMASK BIT(20)
  16229. +#define PB42_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
  16230. +#define PB42_MDIO_PHYMASK (PB42_LAN_PHYMASK | PB42_WAN_PHYMASK)
  16231. +
  16232. +static void __init pb42_init(void)
  16233. +{
  16234. + ath79_register_m25p80(&pb42_flash_data);
  16235. +
  16236. + ath79_register_mdio(0, ~PB42_MDIO_PHYMASK);
  16237. +
  16238. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  16239. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  16240. + ath79_eth0_data.phy_mask = PB42_WAN_PHYMASK;
  16241. +
  16242. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  16243. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  16244. + ath79_eth1_data.speed = SPEED_100;
  16245. + ath79_eth1_data.duplex = DUPLEX_FULL;
  16246. +
  16247. + ath79_register_eth(0);
  16248. + ath79_register_eth(1);
  16249. +
  16250. + ath79_register_gpio_keys_polled(-1, PB42_KEYS_POLL_INTERVAL,
  16251. + ARRAY_SIZE(pb42_gpio_keys),
  16252. + pb42_gpio_keys);
  16253. +
  16254. + ath79_register_pci();
  16255. +}
  16256. +
  16257. +MIPS_MACHINE(ATH79_MACH_PB42, "PB42", "Atheros PB42", pb42_init);
  16258. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-pb44.c linux-4.1.13/arch/mips/ath79/mach-pb44.c
  16259. --- linux-4.1.13.orig/arch/mips/ath79/mach-pb44.c 2015-11-09 23:34:10.000000000 +0100
  16260. +++ linux-4.1.13/arch/mips/ath79/mach-pb44.c 2015-12-04 19:57:04.334081334 +0100
  16261. @@ -8,23 +8,48 @@
  16262. * by the Free Software Foundation.
  16263. */
  16264. +#include <linux/delay.h>
  16265. #include <linux/init.h>
  16266. #include <linux/platform_device.h>
  16267. #include <linux/i2c.h>
  16268. #include <linux/i2c-gpio.h>
  16269. #include <linux/i2c/pcf857x.h>
  16270. +#include <linux/i2c/pcf857x.h>
  16271. +#include <linux/spi/flash.h>
  16272. +#include <linux/spi/vsc7385.h>
  16273. -#include "machtypes.h"
  16274. +#include <asm/mach-ath79/ar71xx_regs.h>
  16275. +#include <asm/mach-ath79/ath79.h>
  16276. +
  16277. +#include "dev-eth.h"
  16278. #include "dev-gpio-buttons.h"
  16279. #include "dev-leds-gpio.h"
  16280. #include "dev-spi.h"
  16281. #include "dev-usb.h"
  16282. +#include "machtypes.h"
  16283. #include "pci.h"
  16284. #define PB44_GPIO_I2C_SCL 0
  16285. #define PB44_GPIO_I2C_SDA 1
  16286. +#define PB44_PCF8757_VSC7395_CS 0
  16287. +#define PB44_PCF8757_STEREO_CS 1
  16288. +#define PB44_PCF8757_SLIC_CS0 2
  16289. +#define PB44_PCF8757_SLIC_TEST 3
  16290. +#define PB44_PCF8757_SLIC_INT0 4
  16291. +#define PB44_PCF8757_SLIC_INT1 5
  16292. +#define PB44_PCF8757_SW_RESET 6
  16293. +#define PB44_PCF8757_SW_JUMP 8
  16294. +#define PB44_PCF8757_LED_JUMP1 9
  16295. +#define PB44_PCF8757_LED_JUMP2 10
  16296. +#define PB44_PCF8757_TP24 11
  16297. +#define PB44_PCF8757_TP25 12
  16298. +#define PB44_PCF8757_TP26 13
  16299. +#define PB44_PCF8757_TP27 14
  16300. +#define PB44_PCF8757_TP28 15
  16301. +
  16302. #define PB44_GPIO_EXP_BASE 16
  16303. +#define PB44_GPIO_VSC7395_CS (PB44_GPIO_EXP_BASE + PB44_PCF8757_VSC7395_CS)
  16304. #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
  16305. #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
  16306. #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
  16307. @@ -87,20 +112,71 @@
  16308. }
  16309. };
  16310. +static struct ath79_spi_controller_data pb44_spi0_data = {
  16311. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  16312. + .cs_line = 0,
  16313. +};
  16314. +
  16315. +static struct ath79_spi_controller_data pb44_spi1_data = {
  16316. + .cs_type = ATH79_SPI_CS_TYPE_GPIO,
  16317. + .cs_line = PB44_GPIO_VSC7395_CS,
  16318. +};
  16319. +
  16320. +static void pb44_vsc7395_reset(void)
  16321. +{
  16322. + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
  16323. + udelay(10);
  16324. + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
  16325. + mdelay(50);
  16326. +}
  16327. +
  16328. +static struct vsc7385_platform_data pb44_vsc7395_data = {
  16329. + .reset = pb44_vsc7395_reset,
  16330. + .ucode_name = "vsc7395_ucode_pb44.bin",
  16331. + .mac_cfg = {
  16332. + .tx_ipg = 6,
  16333. + .bit2 = 1,
  16334. + .clk_sel = 0,
  16335. + },
  16336. +};
  16337. +
  16338. +static const char *pb44_part_probes[] = {
  16339. + "RedBoot",
  16340. + NULL,
  16341. +};
  16342. +
  16343. +static struct flash_platform_data pb44_flash_data = {
  16344. + .part_probes = pb44_part_probes,
  16345. +};
  16346. +
  16347. static struct spi_board_info pb44_spi_info[] = {
  16348. {
  16349. .bus_num = 0,
  16350. .chip_select = 0,
  16351. .max_speed_hz = 25000000,
  16352. .modalias = "m25p64",
  16353. + .platform_data = &pb44_flash_data,
  16354. + .controller_data = &pb44_spi0_data,
  16355. },
  16356. + {
  16357. + .bus_num = 0,
  16358. + .chip_select = 1,
  16359. + .max_speed_hz = 25000000,
  16360. + .modalias = "spi-vsc7385",
  16361. + .platform_data = &pb44_vsc7395_data,
  16362. + .controller_data = &pb44_spi1_data,
  16363. + }
  16364. };
  16365. static struct ath79_spi_platform_data pb44_spi_data = {
  16366. .bus_num = 0,
  16367. - .num_chipselect = 1,
  16368. + .num_chipselect = 2,
  16369. };
  16370. +#define PB44_WAN_PHYMASK BIT(0)
  16371. +#define PB44_LAN_PHYMASK 0
  16372. +#define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
  16373. +
  16374. static void __init pb44_init(void)
  16375. {
  16376. i2c_register_board_info(0, pb44_i2c_board_info,
  16377. @@ -116,6 +192,22 @@
  16378. ARRAY_SIZE(pb44_spi_info));
  16379. ath79_register_usb();
  16380. ath79_register_pci();
  16381. +
  16382. + ath79_register_mdio(0, ~PB44_MDIO_PHYMASK);
  16383. +
  16384. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  16385. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  16386. + ath79_eth0_data.phy_mask = PB44_WAN_PHYMASK;
  16387. +
  16388. + ath79_register_eth(0);
  16389. +
  16390. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  16391. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  16392. + ath79_eth1_data.speed = SPEED_1000;
  16393. + ath79_eth1_data.duplex = DUPLEX_FULL;
  16394. + ath79_eth1_pll_data.pll_1000 = 0x110000;
  16395. +
  16396. + ath79_register_eth(1);
  16397. }
  16398. MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
  16399. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-pb92.c linux-4.1.13/arch/mips/ath79/mach-pb92.c
  16400. --- linux-4.1.13.orig/arch/mips/ath79/mach-pb92.c 1970-01-01 01:00:00.000000000 +0100
  16401. +++ linux-4.1.13/arch/mips/ath79/mach-pb92.c 2015-09-13 20:04:35.068524086 +0200
  16402. @@ -0,0 +1,70 @@
  16403. +/*
  16404. + * Atheros PB92 board support
  16405. + *
  16406. + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
  16407. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  16408. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  16409. + *
  16410. + * This program is free software; you can redistribute it and/or modify it
  16411. + * under the terms of the GNU General Public License version 2 as published
  16412. + * by the Free Software Foundation.
  16413. + */
  16414. +
  16415. +#include <asm/mach-ath79/ath79.h>
  16416. +
  16417. +#include "dev-eth.h"
  16418. +#include "dev-gpio-buttons.h"
  16419. +#include "dev-m25p80.h"
  16420. +#include "dev-usb.h"
  16421. +#include "machtypes.h"
  16422. +#include "pci.h"
  16423. +
  16424. +#define PB92_KEYS_POLL_INTERVAL 20 /* msecs */
  16425. +#define PB92_KEYS_DEBOUNCE_INTERVAL (3 * PB92_KEYS_POLL_INTERVAL)
  16426. +
  16427. +#define PB92_GPIO_BTN_SW4 8
  16428. +#define PB92_GPIO_BTN_SW5 3
  16429. +
  16430. +static struct gpio_keys_button pb92_gpio_keys[] __initdata = {
  16431. + {
  16432. + .desc = "sw4",
  16433. + .type = EV_KEY,
  16434. + .code = BTN_0,
  16435. + .debounce_interval = PB92_KEYS_DEBOUNCE_INTERVAL,
  16436. + .gpio = PB92_GPIO_BTN_SW4,
  16437. + .active_low = 1,
  16438. + }, {
  16439. + .desc = "sw5",
  16440. + .type = EV_KEY,
  16441. + .code = BTN_1,
  16442. + .debounce_interval = PB92_KEYS_DEBOUNCE_INTERVAL,
  16443. + .gpio = PB92_GPIO_BTN_SW5,
  16444. + .active_low = 1,
  16445. + }
  16446. +};
  16447. +
  16448. +static void __init pb92_init(void)
  16449. +{
  16450. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  16451. +
  16452. + ath79_register_m25p80(NULL);
  16453. +
  16454. + ath79_register_mdio(0, ~BIT(0));
  16455. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  16456. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  16457. + ath79_eth0_data.speed = SPEED_1000;
  16458. + ath79_eth0_data.duplex = DUPLEX_FULL;
  16459. + ath79_eth0_data.phy_mask = BIT(0);
  16460. +
  16461. + ath79_register_eth(0);
  16462. +
  16463. + ath79_register_gpio_keys_polled(-1, PB92_KEYS_POLL_INTERVAL,
  16464. + ARRAY_SIZE(pb92_gpio_keys),
  16465. + pb92_gpio_keys);
  16466. +
  16467. + ath79_register_usb();
  16468. +
  16469. + ath79_register_pci();
  16470. +}
  16471. +
  16472. +MIPS_MACHINE(ATH79_MACH_PB92, "PB92", "Atheros PB92", pb92_init);
  16473. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-qihoo-c301.c linux-4.1.13/arch/mips/ath79/mach-qihoo-c301.c
  16474. --- linux-4.1.13.orig/arch/mips/ath79/mach-qihoo-c301.c 1970-01-01 01:00:00.000000000 +0100
  16475. +++ linux-4.1.13/arch/mips/ath79/mach-qihoo-c301.c 2015-09-13 20:04:35.068524086 +0200
  16476. @@ -0,0 +1,166 @@
  16477. +/*
  16478. + * Qihoo 360 C301 board support
  16479. + *
  16480. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  16481. + * Copyright (C) 2014 Weijie Gao <hackpascal@gmail.com>
  16482. + *
  16483. + * This program is free software; you can redistribute it and/or modify it
  16484. + * under the terms of the GNU General Public License version 2 as published
  16485. + * by the Free Software Foundation.
  16486. + */
  16487. +
  16488. +#include <linux/pci.h>
  16489. +#include <linux/phy.h>
  16490. +#include <linux/gpio.h>
  16491. +#include <linux/platform_device.h>
  16492. +#include <linux/ath9k_platform.h>
  16493. +
  16494. +#include <asm/mach-ath79/ar71xx_regs.h>
  16495. +
  16496. +#include "common.h"
  16497. +#include "pci.h"
  16498. +#include "dev-eth.h"
  16499. +#include "dev-gpio-buttons.h"
  16500. +#include "dev-leds-gpio.h"
  16501. +#include "dev-m25p80.h"
  16502. +#include "dev-spi.h"
  16503. +#include "dev-usb.h"
  16504. +#include "dev-wmac.h"
  16505. +#include "machtypes.h"
  16506. +#include "nvram.h"
  16507. +
  16508. +#define QIHOO_C301_GPIO_LED_STATUS_GREEN 0
  16509. +#define QIHOO_C301_GPIO_LED_STATUS_RED 11
  16510. +
  16511. +#define QIHOO_C301_GPIO_LED_WAN 1
  16512. +#define QIHOO_C301_GPIO_LED_LAN1 2
  16513. +#define QIHOO_C301_GPIO_LED_LAN2 3
  16514. +#define QIHOO_C301_GPIO_ETH_LEN_EN 18
  16515. +
  16516. +#define QIHOO_C301_GPIO_BTN_RESET 16
  16517. +
  16518. +#define QIHOO_C301_GPIO_USB_POWER 19
  16519. +
  16520. +#define QIHOO_C301_GPIO_SPI_CS1 12
  16521. +
  16522. +#define QIHOO_C301_GPIO_EXTERNAL_LNA0 14
  16523. +#define QIHOO_C301_GPIO_EXTERNAL_LNA1 15
  16524. +
  16525. +#define QIHOO_C301_KEYS_POLL_INTERVAL 20 /* msecs */
  16526. +#define QIHOO_C301_KEYS_DEBOUNCE_INTERVAL \
  16527. + (3 * QIHOO_C301_KEYS_POLL_INTERVAL)
  16528. +
  16529. +#define QIHOO_C301_WMAC_CALDATA_OFFSET 0x1000
  16530. +
  16531. +#define QIHOO_C301_NVRAM_ADDR 0x1f058010
  16532. +#define QIHOO_C301_NVRAM_SIZE 0x7ff0
  16533. +
  16534. +static struct gpio_led qihoo_c301_leds_gpio[] __initdata = {
  16535. + {
  16536. + .name = "qihoo:green:status",
  16537. + .gpio = QIHOO_C301_GPIO_LED_STATUS_GREEN,
  16538. + .active_low = 1,
  16539. + },
  16540. + {
  16541. + .name = "qihoo:red:status",
  16542. + .gpio = QIHOO_C301_GPIO_LED_STATUS_RED,
  16543. + .active_low = 1,
  16544. + },
  16545. +};
  16546. +
  16547. +static struct gpio_keys_button qihoo_c301_gpio_keys[] __initdata = {
  16548. + {
  16549. + .desc = "reset",
  16550. + .type = EV_KEY,
  16551. + .code = KEY_RESTART,
  16552. + .debounce_interval = QIHOO_C301_KEYS_DEBOUNCE_INTERVAL,
  16553. + .gpio = QIHOO_C301_GPIO_BTN_RESET,
  16554. + .active_low = 1,
  16555. + },
  16556. +};
  16557. +
  16558. +static struct flash_platform_data flash __initdata = {NULL, NULL, 0};
  16559. +
  16560. +static void qihoo_c301_get_mac(const char *name, char *mac)
  16561. +{
  16562. + u8 *nvram = (u8 *) KSEG1ADDR(QIHOO_C301_NVRAM_ADDR);
  16563. + int err;
  16564. +
  16565. + err = ath79_nvram_parse_mac_addr(nvram, QIHOO_C301_NVRAM_SIZE,
  16566. + name, mac);
  16567. + if (err)
  16568. + pr_err("no MAC address found for %s\n", name);
  16569. +}
  16570. +
  16571. +static void __init qihoo_c301_setup(void)
  16572. +{
  16573. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  16574. + u8 tmpmac[ETH_ALEN];
  16575. +
  16576. + ath79_register_m25p80_multi(&flash);
  16577. +
  16578. + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  16579. +
  16580. + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_WAN,
  16581. + AR934X_GPIO_OUT_LED_LINK4);
  16582. + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_LAN1,
  16583. + AR934X_GPIO_OUT_LED_LINK1);
  16584. + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_LAN2,
  16585. + AR934X_GPIO_OUT_LED_LINK2);
  16586. +
  16587. + ath79_gpio_output_select(QIHOO_C301_GPIO_SPI_CS1,
  16588. + AR934X_GPIO_OUT_SPI_CS1);
  16589. +
  16590. + gpio_request_one(QIHOO_C301_GPIO_ETH_LEN_EN,
  16591. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  16592. + "Ethernet LED enable");
  16593. +
  16594. + ath79_register_leds_gpio(-1, ARRAY_SIZE(qihoo_c301_leds_gpio),
  16595. + qihoo_c301_leds_gpio);
  16596. +
  16597. + ath79_register_gpio_keys_polled(-1, QIHOO_C301_KEYS_POLL_INTERVAL,
  16598. + ARRAY_SIZE(qihoo_c301_gpio_keys),
  16599. + qihoo_c301_gpio_keys);
  16600. +
  16601. + ath79_wmac_set_ext_lna_gpio(0, QIHOO_C301_GPIO_EXTERNAL_LNA0);
  16602. + ath79_wmac_set_ext_lna_gpio(1, QIHOO_C301_GPIO_EXTERNAL_LNA1);
  16603. +
  16604. + qihoo_c301_get_mac("wlan24mac=", tmpmac);
  16605. + ath79_register_wmac(art + QIHOO_C301_WMAC_CALDATA_OFFSET, tmpmac);
  16606. +
  16607. + ath79_register_pci();
  16608. +
  16609. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE |
  16610. + AR934X_ETH_CFG_SW_PHY_SWAP);
  16611. +
  16612. + ath79_register_mdio(1, 0x0);
  16613. +
  16614. + /* LAN */
  16615. + qihoo_c301_get_mac("lanmac=", ath79_eth1_data.mac_addr);
  16616. +
  16617. + /* GMAC1 is connected to the internal switch */
  16618. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  16619. +
  16620. + ath79_register_eth(1);
  16621. +
  16622. + /* WAN */
  16623. + qihoo_c301_get_mac("wanmac=", ath79_eth0_data.mac_addr);
  16624. +
  16625. + /* GMAC0 is connected to the PHY4 of the internal switch */
  16626. + ath79_switch_data.phy4_mii_en = 1;
  16627. + ath79_switch_data.phy_poll_mask = BIT(0);
  16628. +
  16629. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  16630. + ath79_eth0_data.phy_mask = BIT(0);
  16631. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  16632. +
  16633. + ath79_register_eth(0);
  16634. +
  16635. + gpio_request_one(QIHOO_C301_GPIO_USB_POWER,
  16636. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  16637. + "USB power");
  16638. + ath79_register_usb();
  16639. +}
  16640. +
  16641. +MIPS_MACHINE(ATH79_MACH_QIHOO_C301, "QIHOO-C301", "Qihoo 360 C301",
  16642. + qihoo_c301_setup);
  16643. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-r6100.c linux-4.1.13/arch/mips/ath79/mach-r6100.c
  16644. --- linux-4.1.13.orig/arch/mips/ath79/mach-r6100.c 1970-01-01 01:00:00.000000000 +0100
  16645. +++ linux-4.1.13/arch/mips/ath79/mach-r6100.c 2015-09-13 20:04:35.068524086 +0200
  16646. @@ -0,0 +1,146 @@
  16647. +/*
  16648. + * NETGEAR R6100 board support
  16649. + *
  16650. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  16651. + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  16652. + *
  16653. + * This program is free software; you can redistribute it and/or modify it
  16654. + * under the terms of the GNU General Public License version 2 as published
  16655. + * by the Free Software Foundation.
  16656. + */
  16657. +
  16658. +#include <linux/pci.h>
  16659. +#include <linux/phy.h>
  16660. +#include <linux/gpio.h>
  16661. +#include <linux/platform_device.h>
  16662. +#include <linux/ath9k_platform.h>
  16663. +#include <linux/platform/ar934x_nfc.h>
  16664. +
  16665. +#include <asm/mach-ath79/ar71xx_regs.h>
  16666. +
  16667. +#include "common.h"
  16668. +#include "dev-ap9x-pci.h"
  16669. +#include "dev-eth.h"
  16670. +#include "dev-gpio-buttons.h"
  16671. +#include "dev-leds-gpio.h"
  16672. +#include "dev-nfc.h"
  16673. +#include "dev-usb.h"
  16674. +#include "dev-wmac.h"
  16675. +#include "machtypes.h"
  16676. +
  16677. +#define R6100_GPIO_LED_WLAN 0
  16678. +#define R6100_GPIO_LED_USB 11
  16679. +#define R6100_GPIO_LED_WAN_GREEN 13
  16680. +#define R6100_GPIO_LED_POWER_AMBER 14
  16681. +#define R6100_GPIO_LED_WAN_AMBER 15
  16682. +#define R6100_GPIO_LED_POWER_GREEN 17
  16683. +
  16684. +#define R6100_GPIO_BTN_WIRELESS 1
  16685. +#define R6100_GPIO_BTN_WPS 3
  16686. +#define R6100_GPIO_BTN_RESET 12
  16687. +
  16688. +#define R6100_GPIO_USB_POWER 16
  16689. +
  16690. +#define R6100_KEYS_POLL_INTERVAL 20 /* msecs */
  16691. +#define R6100_KEYS_DEBOUNCE_INTERVAL (3 * R6100_KEYS_POLL_INTERVAL)
  16692. +
  16693. +static struct gpio_led r6100_leds_gpio[] __initdata = {
  16694. + {
  16695. + .name = "netgear:green:power",
  16696. + .gpio = R6100_GPIO_LED_POWER_GREEN,
  16697. + .active_low = 1,
  16698. + },
  16699. + {
  16700. + .name = "netgear:amber:power",
  16701. + .gpio = R6100_GPIO_LED_POWER_AMBER,
  16702. + .active_low = 1,
  16703. + },
  16704. + {
  16705. + .name = "netgear:green:wan",
  16706. + .gpio = R6100_GPIO_LED_WAN_GREEN,
  16707. + .active_low = 1,
  16708. + },
  16709. + {
  16710. + .name = "netgear:amber:wan",
  16711. + .gpio = R6100_GPIO_LED_WAN_AMBER,
  16712. + .active_low = 1,
  16713. + },
  16714. + {
  16715. + .name = "netgear:blue:usb",
  16716. + .gpio = R6100_GPIO_LED_USB,
  16717. + .active_low = 1,
  16718. + },
  16719. + {
  16720. + .name = "netgear:blue:wlan",
  16721. + .gpio = R6100_GPIO_LED_WLAN,
  16722. + .active_low = 1,
  16723. + },
  16724. +};
  16725. +
  16726. +static struct gpio_keys_button r6100_gpio_keys[] __initdata = {
  16727. + {
  16728. + .desc = "Reset button",
  16729. + .type = EV_KEY,
  16730. + .code = KEY_RESTART,
  16731. + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  16732. + .gpio = R6100_GPIO_BTN_RESET,
  16733. + .active_low = 0,
  16734. + },
  16735. + {
  16736. + .desc = "WPS button",
  16737. + .type = EV_KEY,
  16738. + .code = KEY_WPS_BUTTON,
  16739. + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  16740. + .gpio = R6100_GPIO_BTN_WPS,
  16741. + .active_low = 0,
  16742. + },
  16743. + {
  16744. + .desc = "RFKILL switch",
  16745. + .type = EV_SW,
  16746. + .code = KEY_RFKILL,
  16747. + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  16748. + .gpio = R6100_GPIO_BTN_WIRELESS,
  16749. + .active_low = 0,
  16750. + },
  16751. +};
  16752. +
  16753. +static void __init r6100_setup(void)
  16754. +{
  16755. + ath79_register_leds_gpio(-1, ARRAY_SIZE(r6100_leds_gpio),
  16756. + r6100_leds_gpio);
  16757. + ath79_register_gpio_keys_polled(-1, R6100_KEYS_POLL_INTERVAL,
  16758. + ARRAY_SIZE(r6100_gpio_keys),
  16759. + r6100_gpio_keys);
  16760. +
  16761. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  16762. +
  16763. + ath79_register_mdio(1, 0x0);
  16764. +
  16765. + /* GMAC0 is connected to the PHY0 of the internal switch */
  16766. + ath79_switch_data.phy4_mii_en = 1;
  16767. + ath79_switch_data.phy_poll_mask = BIT(0);
  16768. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  16769. + ath79_eth0_data.phy_mask = BIT(0);
  16770. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  16771. + ath79_register_eth(0);
  16772. +
  16773. + /* GMAC1 is connected to the internal switch */
  16774. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  16775. + ath79_register_eth(1);
  16776. +
  16777. + gpio_request_one(R6100_GPIO_USB_POWER,
  16778. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  16779. + "USB power");
  16780. +
  16781. + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
  16782. + ath79_register_nfc();
  16783. +
  16784. + ath79_register_usb();
  16785. +
  16786. + ath79_register_wmac_simple();
  16787. +
  16788. + ap91_pci_init_simple();
  16789. +}
  16790. +
  16791. +MIPS_MACHINE(ATH79_MACH_R6100, "R6100", "NETGEAR R6100",
  16792. + r6100_setup);
  16793. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb2011.c linux-4.1.13/arch/mips/ath79/mach-rb2011.c
  16794. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb2011.c 1970-01-01 01:00:00.000000000 +0100
  16795. +++ linux-4.1.13/arch/mips/ath79/mach-rb2011.c 2015-09-13 20:04:35.068524086 +0200
  16796. @@ -0,0 +1,338 @@
  16797. +/*
  16798. + * MikroTik RouterBOARD 2011 support
  16799. + *
  16800. + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
  16801. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  16802. + *
  16803. + * This program is free software; you can redistribute it and/or modify it
  16804. + * under the terms of the GNU General Public License version 2 as published
  16805. + * by the Free Software Foundation.
  16806. + */
  16807. +
  16808. +#define pr_fmt(fmt) "rb2011: " fmt
  16809. +
  16810. +#include <linux/phy.h>
  16811. +#include <linux/delay.h>
  16812. +#include <linux/platform_device.h>
  16813. +#include <linux/ath9k_platform.h>
  16814. +#include <linux/ar8216_platform.h>
  16815. +#include <linux/mtd/mtd.h>
  16816. +#include <linux/mtd/nand.h>
  16817. +#include <linux/mtd/partitions.h>
  16818. +#include <linux/spi/spi.h>
  16819. +#include <linux/spi/flash.h>
  16820. +#include <linux/routerboot.h>
  16821. +#include <linux/gpio.h>
  16822. +
  16823. +#include <asm/prom.h>
  16824. +#include <asm/mach-ath79/ath79.h>
  16825. +#include <asm/mach-ath79/ar71xx_regs.h>
  16826. +
  16827. +#include "common.h"
  16828. +#include "dev-eth.h"
  16829. +#include "dev-m25p80.h"
  16830. +#include "dev-nfc.h"
  16831. +#include "dev-usb.h"
  16832. +#include "dev-wmac.h"
  16833. +#include "machtypes.h"
  16834. +#include "routerboot.h"
  16835. +
  16836. +#define RB2011_GPIO_NAND_NCE 14
  16837. +#define RB2011_GPIO_SFP_LOS 21
  16838. +
  16839. +#define RB_ROUTERBOOT_OFFSET 0x0000
  16840. +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
  16841. +#define RB_HARD_CFG_SIZE 0x1000
  16842. +#define RB_BIOS_OFFSET 0xd000
  16843. +#define RB_BIOS_SIZE 0x1000
  16844. +#define RB_SOFT_CFG_OFFSET 0xf000
  16845. +#define RB_SOFT_CFG_SIZE 0x1000
  16846. +
  16847. +#define RB_ART_SIZE 0x10000
  16848. +
  16849. +#define RB2011_FLAG_SFP BIT(0)
  16850. +#define RB2011_FLAG_USB BIT(1)
  16851. +#define RB2011_FLAG_WLAN BIT(2)
  16852. +
  16853. +static struct mtd_partition rb2011_spi_partitions[] = {
  16854. + {
  16855. + .name = "routerboot",
  16856. + .offset = RB_ROUTERBOOT_OFFSET,
  16857. + .mask_flags = MTD_WRITEABLE,
  16858. + }, {
  16859. + .name = "hard_config",
  16860. + .size = RB_HARD_CFG_SIZE,
  16861. + .mask_flags = MTD_WRITEABLE,
  16862. + }, {
  16863. + .name = "bios",
  16864. + .offset = RB_BIOS_OFFSET,
  16865. + .size = RB_BIOS_SIZE,
  16866. + .mask_flags = MTD_WRITEABLE,
  16867. + }, {
  16868. + .name = "soft_config",
  16869. + .size = RB_SOFT_CFG_SIZE,
  16870. + }
  16871. +};
  16872. +
  16873. +static void __init rb2011_init_partitions(const struct rb_info *info)
  16874. +{
  16875. + rb2011_spi_partitions[0].size = info->hard_cfg_offs;
  16876. + rb2011_spi_partitions[1].offset = info->hard_cfg_offs;
  16877. + rb2011_spi_partitions[3].offset = info->soft_cfg_offs;
  16878. +}
  16879. +
  16880. +static struct mtd_partition rb2011_nand_partitions[] = {
  16881. + {
  16882. + .name = "booter",
  16883. + .offset = 0,
  16884. + .size = (256 * 1024),
  16885. + .mask_flags = MTD_WRITEABLE,
  16886. + },
  16887. + {
  16888. + .name = "kernel",
  16889. + .offset = (256 * 1024),
  16890. + .size = (4 * 1024 * 1024) - (256 * 1024),
  16891. + },
  16892. + {
  16893. + .name = "rootfs",
  16894. + .offset = MTDPART_OFS_NXTBLK,
  16895. + .size = MTDPART_SIZ_FULL,
  16896. + },
  16897. +};
  16898. +
  16899. +static struct flash_platform_data rb2011_spi_flash_data = {
  16900. + .parts = rb2011_spi_partitions,
  16901. + .nr_parts = ARRAY_SIZE(rb2011_spi_partitions),
  16902. +};
  16903. +
  16904. +static struct ar8327_pad_cfg rb2011_ar8327_pad0_cfg = {
  16905. + .mode = AR8327_PAD_MAC_RGMII,
  16906. + .txclk_delay_en = true,
  16907. + .rxclk_delay_en = true,
  16908. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL3,
  16909. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  16910. +};
  16911. +
  16912. +static struct ar8327_pad_cfg rb2011_ar8327_pad6_cfg;
  16913. +static struct ar8327_sgmii_cfg rb2011_ar8327_sgmii_cfg;
  16914. +
  16915. +static struct ar8327_led_cfg rb2011_ar8327_led_cfg = {
  16916. + .led_ctrl0 = 0xc731c731,
  16917. + .led_ctrl1 = 0x00000000,
  16918. + .led_ctrl2 = 0x00000000,
  16919. + .led_ctrl3 = 0x0030c300,
  16920. + .open_drain = false,
  16921. +};
  16922. +
  16923. +static const struct ar8327_led_info rb2011_ar8327_leds[] __initconst = {
  16924. + AR8327_LED_INFO(PHY0_0, HW, "rb:green:eth1"),
  16925. + AR8327_LED_INFO(PHY1_0, HW, "rb:green:eth2"),
  16926. + AR8327_LED_INFO(PHY2_0, HW, "rb:green:eth3"),
  16927. + AR8327_LED_INFO(PHY3_0, HW, "rb:green:eth4"),
  16928. + AR8327_LED_INFO(PHY4_0, HW, "rb:green:eth5"),
  16929. + AR8327_LED_INFO(PHY0_1, SW, "rb:green:eth6"),
  16930. + AR8327_LED_INFO(PHY1_1, SW, "rb:green:eth7"),
  16931. + AR8327_LED_INFO(PHY2_1, SW, "rb:green:eth8"),
  16932. + AR8327_LED_INFO(PHY3_1, SW, "rb:green:eth9"),
  16933. + AR8327_LED_INFO(PHY4_1, SW, "rb:green:eth10"),
  16934. + AR8327_LED_INFO(PHY4_2, SW, "rb:green:usr"),
  16935. +};
  16936. +
  16937. +static struct ar8327_platform_data rb2011_ar8327_data = {
  16938. + .pad0_cfg = &rb2011_ar8327_pad0_cfg,
  16939. + .port0_cfg = {
  16940. + .force_link = 1,
  16941. + .speed = AR8327_PORT_SPEED_1000,
  16942. + .duplex = 1,
  16943. + .txpause = 1,
  16944. + .rxpause = 1,
  16945. + },
  16946. + .led_cfg = &rb2011_ar8327_led_cfg,
  16947. + .num_leds = ARRAY_SIZE(rb2011_ar8327_leds),
  16948. + .leds = rb2011_ar8327_leds,
  16949. +};
  16950. +
  16951. +static struct mdio_board_info rb2011_mdio0_info[] = {
  16952. + {
  16953. + .bus_id = "ag71xx-mdio.0",
  16954. + .phy_addr = 0,
  16955. + .platform_data = &rb2011_ar8327_data,
  16956. + },
  16957. +};
  16958. +
  16959. +static void __init rb2011_wlan_init(void)
  16960. +{
  16961. + char *art_buf;
  16962. + u8 wlan_mac[ETH_ALEN];
  16963. +
  16964. + art_buf = rb_get_wlan_data();
  16965. + if (art_buf == NULL)
  16966. + return;
  16967. +
  16968. + ath79_init_mac(wlan_mac, ath79_mac_base, 11);
  16969. + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
  16970. +
  16971. + kfree(art_buf);
  16972. +}
  16973. +
  16974. +static void rb2011_nand_select_chip(int chip_no)
  16975. +{
  16976. + switch (chip_no) {
  16977. + case 0:
  16978. + gpio_set_value(RB2011_GPIO_NAND_NCE, 0);
  16979. + break;
  16980. + default:
  16981. + gpio_set_value(RB2011_GPIO_NAND_NCE, 1);
  16982. + break;
  16983. + }
  16984. + ndelay(500);
  16985. +}
  16986. +
  16987. +static struct nand_ecclayout rb2011_nand_ecclayout = {
  16988. + .eccbytes = 6,
  16989. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  16990. + .oobavail = 9,
  16991. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  16992. +};
  16993. +
  16994. +static int rb2011_nand_scan_fixup(struct mtd_info *mtd)
  16995. +{
  16996. + struct nand_chip *chip = mtd->priv;
  16997. +
  16998. + if (mtd->writesize == 512) {
  16999. + /*
  17000. + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
  17001. + * will not be able to find the kernel that we load.
  17002. + */
  17003. + chip->ecc.layout = &rb2011_nand_ecclayout;
  17004. + }
  17005. +
  17006. + return 0;
  17007. +}
  17008. +
  17009. +static void __init rb2011_nand_init(void)
  17010. +{
  17011. + gpio_request_one(RB2011_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
  17012. +
  17013. + ath79_nfc_set_scan_fixup(rb2011_nand_scan_fixup);
  17014. + ath79_nfc_set_parts(rb2011_nand_partitions,
  17015. + ARRAY_SIZE(rb2011_nand_partitions));
  17016. + ath79_nfc_set_select_chip(rb2011_nand_select_chip);
  17017. + ath79_nfc_set_swap_dma(true);
  17018. + ath79_register_nfc();
  17019. +}
  17020. +
  17021. +static int rb2011_get_port_link(unsigned port)
  17022. +{
  17023. + if (port != 6)
  17024. + return -EINVAL;
  17025. +
  17026. + /* The Loss of signal line is active low */
  17027. + return !gpio_get_value(RB2011_GPIO_SFP_LOS);
  17028. +}
  17029. +
  17030. +static void __init rb2011_sfp_init(void)
  17031. +{
  17032. + gpio_request_one(RB2011_GPIO_SFP_LOS, GPIOF_IN, "SFP LOS");
  17033. +
  17034. + rb2011_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  17035. +
  17036. + rb2011_ar8327_data.pad6_cfg = &rb2011_ar8327_pad6_cfg;
  17037. +
  17038. + rb2011_ar8327_sgmii_cfg.sgmii_ctrl = 0xc70167d0;
  17039. + rb2011_ar8327_sgmii_cfg.serdes_aen = true;
  17040. +
  17041. + rb2011_ar8327_data.sgmii_cfg = &rb2011_ar8327_sgmii_cfg;
  17042. +
  17043. + rb2011_ar8327_data.port6_cfg.force_link = 1;
  17044. + rb2011_ar8327_data.port6_cfg.speed = AR8327_PORT_SPEED_1000;
  17045. + rb2011_ar8327_data.port6_cfg.duplex = 1;
  17046. +
  17047. + rb2011_ar8327_data.get_port_link = rb2011_get_port_link;
  17048. +}
  17049. +
  17050. +static int __init rb2011_setup(u32 flags)
  17051. +{
  17052. + const struct rb_info *info;
  17053. + char buf[64];
  17054. +
  17055. + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
  17056. + if (!info)
  17057. + return -ENODEV;
  17058. +
  17059. + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
  17060. + (info->board_name) ? info->board_name : "");
  17061. + mips_set_machine_name(buf);
  17062. +
  17063. + rb2011_init_partitions(info);
  17064. +
  17065. + ath79_register_m25p80(&rb2011_spi_flash_data);
  17066. + rb2011_nand_init();
  17067. +
  17068. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  17069. + AR934X_ETH_CFG_SW_ONLY_MODE);
  17070. +
  17071. + ath79_register_mdio(1, 0x0);
  17072. + ath79_register_mdio(0, 0x0);
  17073. +
  17074. + mdiobus_register_board_info(rb2011_mdio0_info,
  17075. + ARRAY_SIZE(rb2011_mdio0_info));
  17076. +
  17077. + /* GMAC0 is connected to an ar8327 switch */
  17078. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17079. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17080. + ath79_eth0_data.phy_mask = BIT(0);
  17081. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  17082. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  17083. +
  17084. + ath79_register_eth(0);
  17085. +
  17086. + /* GMAC1 is connected to the internal switch */
  17087. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 5);
  17088. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  17089. + ath79_eth1_data.speed = SPEED_1000;
  17090. + ath79_eth1_data.duplex = DUPLEX_FULL;
  17091. +
  17092. + ath79_register_eth(1);
  17093. +
  17094. + if (flags & RB2011_FLAG_SFP)
  17095. + rb2011_sfp_init();
  17096. +
  17097. + if (flags & RB2011_FLAG_WLAN)
  17098. + rb2011_wlan_init();
  17099. +
  17100. + if (flags & RB2011_FLAG_USB)
  17101. + ath79_register_usb();
  17102. +
  17103. + return 0;
  17104. +}
  17105. +
  17106. +static void __init rb2011l_setup(void)
  17107. +{
  17108. + rb2011_setup(0);
  17109. +}
  17110. +
  17111. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011L, "2011L", rb2011l_setup);
  17112. +
  17113. +static void __init rb2011us_setup(void)
  17114. +{
  17115. + rb2011_setup(RB2011_FLAG_SFP | RB2011_FLAG_USB);
  17116. +}
  17117. +
  17118. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011US, "2011US", rb2011us_setup);
  17119. +
  17120. +static void __init rb2011r5_setup(void)
  17121. +{
  17122. + rb2011_setup(RB2011_FLAG_SFP | RB2011_FLAG_USB | RB2011_FLAG_WLAN);
  17123. +}
  17124. +
  17125. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011R5, "2011r5", rb2011r5_setup);
  17126. +
  17127. +static void __init rb2011g_setup(void)
  17128. +{
  17129. + rb2011_setup(RB2011_FLAG_SFP |
  17130. + RB2011_FLAG_USB |
  17131. + RB2011_FLAG_WLAN);
  17132. +}
  17133. +
  17134. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011G, "2011G", rb2011g_setup);
  17135. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb4xx.c linux-4.1.13/arch/mips/ath79/mach-rb4xx.c
  17136. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb4xx.c 1970-01-01 01:00:00.000000000 +0100
  17137. +++ linux-4.1.13/arch/mips/ath79/mach-rb4xx.c 2015-09-13 20:04:35.068524086 +0200
  17138. @@ -0,0 +1,465 @@
  17139. +/*
  17140. + * MikroTik RouterBOARD 4xx series support
  17141. + *
  17142. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  17143. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  17144. + *
  17145. + * This program is free software; you can redistribute it and/or modify it
  17146. + * under the terms of the GNU General Public License version 2 as published
  17147. + * by the Free Software Foundation.
  17148. + */
  17149. +
  17150. +#include <linux/platform_device.h>
  17151. +#include <linux/irq.h>
  17152. +#include <linux/mdio-gpio.h>
  17153. +#include <linux/mmc/host.h>
  17154. +#include <linux/spi/spi.h>
  17155. +#include <linux/spi/flash.h>
  17156. +#include <linux/spi/mmc_spi.h>
  17157. +#include <linux/mtd/mtd.h>
  17158. +#include <linux/mtd/partitions.h>
  17159. +
  17160. +#include <asm/mach-ath79/ar71xx_regs.h>
  17161. +#include <asm/mach-ath79/ath79.h>
  17162. +#include <asm/mach-ath79/rb4xx_cpld.h>
  17163. +
  17164. +#include "common.h"
  17165. +#include "dev-eth.h"
  17166. +#include "dev-gpio-buttons.h"
  17167. +#include "dev-leds-gpio.h"
  17168. +#include "dev-usb.h"
  17169. +#include "machtypes.h"
  17170. +#include "pci.h"
  17171. +
  17172. +#define RB4XX_GPIO_USER_LED 4
  17173. +#define RB4XX_GPIO_RESET_SWITCH 7
  17174. +
  17175. +#define RB4XX_GPIO_CPLD_BASE 32
  17176. +#define RB4XX_GPIO_CPLD_LED1 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED1)
  17177. +#define RB4XX_GPIO_CPLD_LED2 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED2)
  17178. +#define RB4XX_GPIO_CPLD_LED3 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED3)
  17179. +#define RB4XX_GPIO_CPLD_LED4 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED4)
  17180. +#define RB4XX_GPIO_CPLD_LED5 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED5)
  17181. +
  17182. +#define RB4XX_KEYS_POLL_INTERVAL 20 /* msecs */
  17183. +#define RB4XX_KEYS_DEBOUNCE_INTERVAL (3 * RB4XX_KEYS_POLL_INTERVAL)
  17184. +
  17185. +static struct gpio_led rb4xx_leds_gpio[] __initdata = {
  17186. + {
  17187. + .name = "rb4xx:yellow:user",
  17188. + .gpio = RB4XX_GPIO_USER_LED,
  17189. + .active_low = 0,
  17190. + }, {
  17191. + .name = "rb4xx:green:led1",
  17192. + .gpio = RB4XX_GPIO_CPLD_LED1,
  17193. + .active_low = 1,
  17194. + }, {
  17195. + .name = "rb4xx:green:led2",
  17196. + .gpio = RB4XX_GPIO_CPLD_LED2,
  17197. + .active_low = 1,
  17198. + }, {
  17199. + .name = "rb4xx:green:led3",
  17200. + .gpio = RB4XX_GPIO_CPLD_LED3,
  17201. + .active_low = 1,
  17202. + }, {
  17203. + .name = "rb4xx:green:led4",
  17204. + .gpio = RB4XX_GPIO_CPLD_LED4,
  17205. + .active_low = 1,
  17206. + }, {
  17207. + .name = "rb4xx:green:led5",
  17208. + .gpio = RB4XX_GPIO_CPLD_LED5,
  17209. + .active_low = 0,
  17210. + },
  17211. +};
  17212. +
  17213. +static struct gpio_keys_button rb4xx_gpio_keys[] __initdata = {
  17214. + {
  17215. + .desc = "reset_switch",
  17216. + .type = EV_KEY,
  17217. + .code = KEY_RESTART,
  17218. + .debounce_interval = RB4XX_KEYS_DEBOUNCE_INTERVAL,
  17219. + .gpio = RB4XX_GPIO_RESET_SWITCH,
  17220. + .active_low = 1,
  17221. + }
  17222. +};
  17223. +
  17224. +static struct platform_device rb4xx_nand_device = {
  17225. + .name = "rb4xx-nand",
  17226. + .id = -1,
  17227. +};
  17228. +
  17229. +static struct ath79_pci_irq rb4xx_pci_irqs[] __initdata = {
  17230. + {
  17231. + .slot = 17,
  17232. + .pin = 1,
  17233. + .irq = ATH79_PCI_IRQ(2),
  17234. + }, {
  17235. + .slot = 18,
  17236. + .pin = 1,
  17237. + .irq = ATH79_PCI_IRQ(0),
  17238. + }, {
  17239. + .slot = 18,
  17240. + .pin = 2,
  17241. + .irq = ATH79_PCI_IRQ(1),
  17242. + }, {
  17243. + .slot = 19,
  17244. + .pin = 1,
  17245. + .irq = ATH79_PCI_IRQ(1),
  17246. + }, {
  17247. + .slot = 19,
  17248. + .pin = 2,
  17249. + .irq = ATH79_PCI_IRQ(2),
  17250. + }, {
  17251. + .slot = 20,
  17252. + .pin = 1,
  17253. + .irq = ATH79_PCI_IRQ(2),
  17254. + }, {
  17255. + .slot = 20,
  17256. + .pin = 2,
  17257. + .irq = ATH79_PCI_IRQ(0),
  17258. + }, {
  17259. + .slot = 21,
  17260. + .pin = 1,
  17261. + .irq = ATH79_PCI_IRQ(0),
  17262. + }, {
  17263. + .slot = 22,
  17264. + .pin = 1,
  17265. + .irq = ATH79_PCI_IRQ(1),
  17266. + }, {
  17267. + .slot = 22,
  17268. + .pin = 2,
  17269. + .irq = ATH79_PCI_IRQ(2),
  17270. + }, {
  17271. + .slot = 23,
  17272. + .pin = 1,
  17273. + .irq = ATH79_PCI_IRQ(2),
  17274. + }, {
  17275. + .slot = 23,
  17276. + .pin = 2,
  17277. + .irq = ATH79_PCI_IRQ(0),
  17278. + }
  17279. +};
  17280. +
  17281. +static struct mtd_partition rb4xx_partitions[] = {
  17282. + {
  17283. + .name = "routerboot",
  17284. + .offset = 0,
  17285. + .size = 0x0b000,
  17286. + .mask_flags = MTD_WRITEABLE,
  17287. + }, {
  17288. + .name = "hard_config",
  17289. + .offset = 0x0b000,
  17290. + .size = 0x01000,
  17291. + .mask_flags = MTD_WRITEABLE,
  17292. + }, {
  17293. + .name = "bios",
  17294. + .offset = 0x0d000,
  17295. + .size = 0x02000,
  17296. + .mask_flags = MTD_WRITEABLE,
  17297. + }, {
  17298. + .name = "soft_config",
  17299. + .offset = 0x0f000,
  17300. + .size = 0x01000,
  17301. + }
  17302. +};
  17303. +
  17304. +static struct flash_platform_data rb4xx_flash_data = {
  17305. + .type = "pm25lv512",
  17306. + .parts = rb4xx_partitions,
  17307. + .nr_parts = ARRAY_SIZE(rb4xx_partitions),
  17308. +};
  17309. +
  17310. +static struct rb4xx_cpld_platform_data rb4xx_cpld_data = {
  17311. + .gpio_base = RB4XX_GPIO_CPLD_BASE,
  17312. +};
  17313. +
  17314. +static struct mmc_spi_platform_data rb4xx_mmc_data = {
  17315. + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  17316. +};
  17317. +
  17318. +static struct spi_board_info rb4xx_spi_info[] = {
  17319. + {
  17320. + .bus_num = 0,
  17321. + .chip_select = 0,
  17322. + .max_speed_hz = 25000000,
  17323. + .modalias = "m25p80",
  17324. + .platform_data = &rb4xx_flash_data,
  17325. + }, {
  17326. + .bus_num = 0,
  17327. + .chip_select = 1,
  17328. + .max_speed_hz = 25000000,
  17329. + .modalias = "spi-rb4xx-cpld",
  17330. + .platform_data = &rb4xx_cpld_data,
  17331. + }
  17332. +};
  17333. +
  17334. +static struct spi_board_info rb4xx_microsd_info[] = {
  17335. + {
  17336. + .bus_num = 0,
  17337. + .chip_select = 2,
  17338. + .max_speed_hz = 25000000,
  17339. + .modalias = "mmc_spi",
  17340. + .platform_data = &rb4xx_mmc_data,
  17341. + }
  17342. +};
  17343. +
  17344. +
  17345. +static struct resource rb4xx_spi_resources[] = {
  17346. + {
  17347. + .start = AR71XX_SPI_BASE,
  17348. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  17349. + .flags = IORESOURCE_MEM,
  17350. + },
  17351. +};
  17352. +
  17353. +static struct platform_device rb4xx_spi_device = {
  17354. + .name = "rb4xx-spi",
  17355. + .id = -1,
  17356. + .resource = rb4xx_spi_resources,
  17357. + .num_resources = ARRAY_SIZE(rb4xx_spi_resources),
  17358. +};
  17359. +
  17360. +static void __init rb4xx_generic_setup(void)
  17361. +{
  17362. + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
  17363. + AR71XX_GPIO_FUNC_SPI_CS2_EN);
  17364. +
  17365. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
  17366. + rb4xx_leds_gpio);
  17367. +
  17368. + ath79_register_gpio_keys_polled(-1, RB4XX_KEYS_POLL_INTERVAL,
  17369. + ARRAY_SIZE(rb4xx_gpio_keys),
  17370. + rb4xx_gpio_keys);
  17371. +
  17372. + spi_register_board_info(rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
  17373. + platform_device_register(&rb4xx_spi_device);
  17374. + platform_device_register(&rb4xx_nand_device);
  17375. +}
  17376. +
  17377. +static void __init rb411_setup(void)
  17378. +{
  17379. + rb4xx_generic_setup();
  17380. + spi_register_board_info(rb4xx_microsd_info,
  17381. + ARRAY_SIZE(rb4xx_microsd_info));
  17382. +
  17383. + ath79_register_mdio(0, 0xfffffffc);
  17384. +
  17385. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17386. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  17387. + ath79_eth0_data.phy_mask = 0x00000003;
  17388. +
  17389. + ath79_register_eth(0);
  17390. +
  17391. + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  17392. + ath79_register_pci();
  17393. +}
  17394. +
  17395. +MIPS_MACHINE(ATH79_MACH_RB_411, "411", "MikroTik RouterBOARD 411/A/AH",
  17396. + rb411_setup);
  17397. +
  17398. +static void __init rb411u_setup(void)
  17399. +{
  17400. + rb411_setup();
  17401. + ath79_register_usb();
  17402. +}
  17403. +
  17404. +MIPS_MACHINE(ATH79_MACH_RB_411U, "411U", "MikroTik RouterBOARD 411U",
  17405. + rb411u_setup);
  17406. +
  17407. +#define RB433_LAN_PHYMASK BIT(0)
  17408. +#define RB433_WAN_PHYMASK BIT(4)
  17409. +#define RB433_MDIO_PHYMASK (RB433_LAN_PHYMASK | RB433_WAN_PHYMASK)
  17410. +
  17411. +static void __init rb433_setup(void)
  17412. +{
  17413. + rb4xx_generic_setup();
  17414. + spi_register_board_info(rb4xx_microsd_info,
  17415. + ARRAY_SIZE(rb4xx_microsd_info));
  17416. +
  17417. + ath79_register_mdio(0, ~RB433_MDIO_PHYMASK);
  17418. +
  17419. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
  17420. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  17421. + ath79_eth0_data.phy_mask = RB433_LAN_PHYMASK;
  17422. +
  17423. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
  17424. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  17425. + ath79_eth1_data.phy_mask = RB433_WAN_PHYMASK;
  17426. +
  17427. + ath79_register_eth(1);
  17428. + ath79_register_eth(0);
  17429. +
  17430. + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  17431. + ath79_register_pci();
  17432. +}
  17433. +
  17434. +MIPS_MACHINE(ATH79_MACH_RB_433, "433", "MikroTik RouterBOARD 433/AH",
  17435. + rb433_setup);
  17436. +
  17437. +static void __init rb433u_setup(void)
  17438. +{
  17439. + rb433_setup();
  17440. + ath79_register_usb();
  17441. +}
  17442. +
  17443. +MIPS_MACHINE(ATH79_MACH_RB_433U, "433U", "MikroTik RouterBOARD 433UAH",
  17444. + rb433u_setup);
  17445. +
  17446. +static void __init rb435g_setup(void)
  17447. +{
  17448. + rb4xx_generic_setup();
  17449. +
  17450. + spi_register_board_info(rb4xx_microsd_info,
  17451. + ARRAY_SIZE(rb4xx_microsd_info));
  17452. +
  17453. + ath79_register_mdio(0, ~RB433_MDIO_PHYMASK);
  17454. +
  17455. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
  17456. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17457. + ath79_eth0_data.phy_mask = RB433_LAN_PHYMASK;
  17458. +
  17459. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
  17460. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17461. + ath79_eth1_data.phy_mask = RB433_WAN_PHYMASK;
  17462. +
  17463. + ath79_register_eth(1);
  17464. + ath79_register_eth(0);
  17465. +
  17466. + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  17467. + ath79_register_pci();
  17468. +
  17469. + ath79_register_usb();
  17470. +}
  17471. +
  17472. +MIPS_MACHINE(ATH79_MACH_RB_435G, "435G", "MikroTik RouterBOARD 435G",
  17473. + rb435g_setup);
  17474. +
  17475. +#define RB450_LAN_PHYMASK BIT(0)
  17476. +#define RB450_WAN_PHYMASK BIT(4)
  17477. +#define RB450_MDIO_PHYMASK (RB450_LAN_PHYMASK | RB450_WAN_PHYMASK)
  17478. +
  17479. +static void __init rb450_generic_setup(int gige)
  17480. +{
  17481. + rb4xx_generic_setup();
  17482. + ath79_register_mdio(0, ~RB450_MDIO_PHYMASK);
  17483. +
  17484. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
  17485. + ath79_eth0_data.phy_if_mode = (gige) ?
  17486. + PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII;
  17487. + ath79_eth0_data.phy_mask = RB450_LAN_PHYMASK;
  17488. +
  17489. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
  17490. + ath79_eth1_data.phy_if_mode = (gige) ?
  17491. + PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_RMII;
  17492. + ath79_eth1_data.phy_mask = RB450_WAN_PHYMASK;
  17493. +
  17494. + ath79_register_eth(1);
  17495. + ath79_register_eth(0);
  17496. +}
  17497. +
  17498. +static void __init rb450_setup(void)
  17499. +{
  17500. + rb450_generic_setup(0);
  17501. +}
  17502. +
  17503. +MIPS_MACHINE(ATH79_MACH_RB_450, "450", "MikroTik RouterBOARD 450",
  17504. + rb450_setup);
  17505. +
  17506. +static void __init rb450g_setup(void)
  17507. +{
  17508. + rb450_generic_setup(1);
  17509. + spi_register_board_info(rb4xx_microsd_info,
  17510. + ARRAY_SIZE(rb4xx_microsd_info));
  17511. +}
  17512. +
  17513. +MIPS_MACHINE(ATH79_MACH_RB_450G, "450G", "MikroTik RouterBOARD 450G",
  17514. + rb450g_setup);
  17515. +
  17516. +static void __init rb493_setup(void)
  17517. +{
  17518. + rb4xx_generic_setup();
  17519. +
  17520. + ath79_register_mdio(0, 0x3fffff00);
  17521. +
  17522. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17523. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  17524. + ath79_eth0_data.speed = SPEED_100;
  17525. + ath79_eth0_data.duplex = DUPLEX_FULL;
  17526. +
  17527. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  17528. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  17529. + ath79_eth1_data.phy_mask = 0x00000001;
  17530. +
  17531. + ath79_register_eth(0);
  17532. + ath79_register_eth(1);
  17533. +
  17534. + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  17535. + ath79_register_pci();
  17536. +}
  17537. +
  17538. +MIPS_MACHINE(ATH79_MACH_RB_493, "493", "MikroTik RouterBOARD 493/AH",
  17539. + rb493_setup);
  17540. +
  17541. +#define RB493G_GPIO_MDIO_MDC 7
  17542. +#define RB493G_GPIO_MDIO_DATA 8
  17543. +
  17544. +#define RB493G_MDIO_PHYMASK BIT(0)
  17545. +
  17546. +static struct mdio_gpio_platform_data rb493g_mdio_data = {
  17547. + .mdc = RB493G_GPIO_MDIO_MDC,
  17548. + .mdio = RB493G_GPIO_MDIO_DATA,
  17549. +
  17550. + .phy_mask = ~RB493G_MDIO_PHYMASK,
  17551. +};
  17552. +
  17553. +static struct platform_device rb493g_mdio_device = {
  17554. + .name = "mdio-gpio",
  17555. + .id = -1,
  17556. + .dev = {
  17557. + .platform_data = &rb493g_mdio_data,
  17558. + },
  17559. +};
  17560. +
  17561. +static void __init rb493g_setup(void)
  17562. +{
  17563. + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
  17564. + AR71XX_GPIO_FUNC_SPI_CS2_EN);
  17565. +
  17566. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
  17567. + rb4xx_leds_gpio);
  17568. +
  17569. + spi_register_board_info(rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
  17570. + spi_register_board_info(rb4xx_microsd_info,
  17571. + ARRAY_SIZE(rb4xx_microsd_info));
  17572. +
  17573. + platform_device_register(&rb4xx_spi_device);
  17574. + platform_device_register(&rb4xx_nand_device);
  17575. +
  17576. + ath79_register_mdio(0, ~RB493G_MDIO_PHYMASK);
  17577. +
  17578. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17579. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17580. + ath79_eth0_data.phy_mask = RB493G_MDIO_PHYMASK;
  17581. + ath79_eth0_data.speed = SPEED_1000;
  17582. + ath79_eth0_data.duplex = DUPLEX_FULL;
  17583. +
  17584. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  17585. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17586. + ath79_eth1_data.mii_bus_dev = &rb493g_mdio_device.dev;
  17587. + ath79_eth1_data.phy_mask = RB493G_MDIO_PHYMASK;
  17588. + ath79_eth1_data.speed = SPEED_1000;
  17589. + ath79_eth1_data.duplex = DUPLEX_FULL;
  17590. +
  17591. + platform_device_register(&rb493g_mdio_device);
  17592. +
  17593. + ath79_register_eth(1);
  17594. + ath79_register_eth(0);
  17595. +
  17596. + ath79_register_usb();
  17597. +
  17598. + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  17599. + ath79_register_pci();
  17600. +}
  17601. +
  17602. +MIPS_MACHINE(ATH79_MACH_RB_493G, "493G", "MikroTik RouterBOARD 493G",
  17603. + rb493g_setup);
  17604. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb750.c linux-4.1.13/arch/mips/ath79/mach-rb750.c
  17605. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb750.c 1970-01-01 01:00:00.000000000 +0100
  17606. +++ linux-4.1.13/arch/mips/ath79/mach-rb750.c 2015-09-13 20:04:35.068524086 +0200
  17607. @@ -0,0 +1,346 @@
  17608. +/*
  17609. + * MikroTik RouterBOARD 750/750GL support
  17610. + *
  17611. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  17612. + *
  17613. + * This program is free software; you can redistribute it and/or modify it
  17614. + * under the terms of the GNU General Public License version 2 as published
  17615. + * by the Free Software Foundation.
  17616. + */
  17617. +
  17618. +#include <linux/export.h>
  17619. +#include <linux/pci.h>
  17620. +#include <linux/ath9k_platform.h>
  17621. +#include <linux/platform_device.h>
  17622. +#include <linux/phy.h>
  17623. +#include <linux/ar8216_platform.h>
  17624. +#include <linux/rle.h>
  17625. +#include <linux/routerboot.h>
  17626. +
  17627. +#include <asm/mach-ath79/ar71xx_regs.h>
  17628. +#include <asm/mach-ath79/ath79.h>
  17629. +#include <asm/mach-ath79/irq.h>
  17630. +#include <asm/mach-ath79/mach-rb750.h>
  17631. +
  17632. +#include "common.h"
  17633. +#include "dev-ap9x-pci.h"
  17634. +#include "dev-usb.h"
  17635. +#include "dev-eth.h"
  17636. +#include "machtypes.h"
  17637. +#include "routerboot.h"
  17638. +
  17639. +static struct rb750_led_data rb750_leds[] = {
  17640. + {
  17641. + .name = "rb750:green:act",
  17642. + .mask = RB750_LED_ACT,
  17643. + .active_low = 1,
  17644. + }, {
  17645. + .name = "rb750:green:port1",
  17646. + .mask = RB750_LED_PORT5,
  17647. + .active_low = 1,
  17648. + }, {
  17649. + .name = "rb750:green:port2",
  17650. + .mask = RB750_LED_PORT4,
  17651. + .active_low = 1,
  17652. + }, {
  17653. + .name = "rb750:green:port3",
  17654. + .mask = RB750_LED_PORT3,
  17655. + .active_low = 1,
  17656. + }, {
  17657. + .name = "rb750:green:port4",
  17658. + .mask = RB750_LED_PORT2,
  17659. + .active_low = 1,
  17660. + }, {
  17661. + .name = "rb750:green:port5",
  17662. + .mask = RB750_LED_PORT1,
  17663. + .active_low = 1,
  17664. + }
  17665. +};
  17666. +
  17667. +static struct rb750_led_data rb750gr3_leds[] = {
  17668. + {
  17669. + .name = "rb750:green:act",
  17670. + .mask = RB7XX_LED_ACT,
  17671. + .active_low = 1,
  17672. + },
  17673. +};
  17674. +
  17675. +static struct rb750_led_platform_data rb750_leds_data;
  17676. +static struct platform_device rb750_leds_device = {
  17677. + .name = "leds-rb750",
  17678. + .dev = {
  17679. + .platform_data = &rb750_leds_data,
  17680. + }
  17681. +};
  17682. +
  17683. +static struct rb7xx_nand_platform_data rb750_nand_data;
  17684. +static struct platform_device rb750_nand_device = {
  17685. + .name = "rb750-nand",
  17686. + .id = -1,
  17687. + .dev = {
  17688. + .platform_data = &rb750_nand_data,
  17689. + }
  17690. +};
  17691. +
  17692. +static void rb750_latch_change(u32 mask_clr, u32 mask_set)
  17693. +{
  17694. + static DEFINE_SPINLOCK(lock);
  17695. + static u32 latch_set = RB750_LED_BITS | RB750_LVC573_LE;
  17696. + static u32 latch_oe;
  17697. + static u32 latch_clr;
  17698. + unsigned long flags;
  17699. + u32 t;
  17700. +
  17701. + spin_lock_irqsave(&lock, flags);
  17702. +
  17703. + if ((mask_clr & BIT(31)) != 0 &&
  17704. + (latch_set & RB750_LVC573_LE) == 0) {
  17705. + goto unlock;
  17706. + }
  17707. +
  17708. + latch_set = (latch_set | mask_set) & ~mask_clr;
  17709. + latch_clr = (latch_clr | mask_clr) & ~mask_set;
  17710. +
  17711. + if (latch_oe == 0)
  17712. + latch_oe = __raw_readl(ath79_gpio_base + AR71XX_GPIO_REG_OE);
  17713. +
  17714. + if (likely(latch_set & RB750_LVC573_LE)) {
  17715. + void __iomem *base = ath79_gpio_base;
  17716. +
  17717. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  17718. + t |= mask_clr | latch_oe | mask_set;
  17719. +
  17720. + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
  17721. + __raw_writel(latch_clr, base + AR71XX_GPIO_REG_CLEAR);
  17722. + __raw_writel(latch_set, base + AR71XX_GPIO_REG_SET);
  17723. + } else if (mask_clr & RB750_LVC573_LE) {
  17724. + void __iomem *base = ath79_gpio_base;
  17725. +
  17726. + latch_oe = __raw_readl(base + AR71XX_GPIO_REG_OE);
  17727. + __raw_writel(RB750_LVC573_LE, base + AR71XX_GPIO_REG_CLEAR);
  17728. + /* flush write */
  17729. + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
  17730. + }
  17731. +
  17732. +unlock:
  17733. + spin_unlock_irqrestore(&lock, flags);
  17734. +}
  17735. +
  17736. +static void rb750_nand_enable_pins(void)
  17737. +{
  17738. + rb750_latch_change(RB750_LVC573_LE, 0);
  17739. + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  17740. + AR724X_GPIO_FUNC_SPI_EN);
  17741. +}
  17742. +
  17743. +static void rb750_nand_disable_pins(void)
  17744. +{
  17745. + ath79_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN,
  17746. + AR724X_GPIO_FUNC_JTAG_DISABLE);
  17747. + rb750_latch_change(0, RB750_LVC573_LE);
  17748. +}
  17749. +
  17750. +static void __init rb750_setup(void)
  17751. +{
  17752. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  17753. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  17754. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  17755. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  17756. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  17757. +
  17758. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17759. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  17760. +
  17761. + ath79_register_mdio(0, 0x0);
  17762. +
  17763. + /* LAN ports */
  17764. + ath79_register_eth(1);
  17765. +
  17766. + /* WAN port */
  17767. + ath79_register_eth(0);
  17768. +
  17769. + rb750_leds_data.num_leds = ARRAY_SIZE(rb750_leds);
  17770. + rb750_leds_data.leds = rb750_leds;
  17771. + rb750_leds_data.latch_change = rb750_latch_change;
  17772. + platform_device_register(&rb750_leds_device);
  17773. +
  17774. + rb750_nand_data.nce_line = RB750_NAND_NCE;
  17775. + rb750_nand_data.enable_pins = rb750_nand_enable_pins;
  17776. + rb750_nand_data.disable_pins = rb750_nand_disable_pins;
  17777. + rb750_nand_data.latch_change = rb750_latch_change;
  17778. + platform_device_register(&rb750_nand_device);
  17779. +}
  17780. +
  17781. +MIPS_MACHINE(ATH79_MACH_RB_750, "750i", "MikroTik RouterBOARD 750",
  17782. + rb750_setup);
  17783. +
  17784. +static struct ar8327_pad_cfg rb750gr3_ar8327_pad0_cfg = {
  17785. + .mode = AR8327_PAD_MAC_RGMII,
  17786. + .txclk_delay_en = true,
  17787. + .rxclk_delay_en = true,
  17788. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  17789. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  17790. +};
  17791. +
  17792. +static struct ar8327_platform_data rb750gr3_ar8327_data = {
  17793. + .pad0_cfg = &rb750gr3_ar8327_pad0_cfg,
  17794. + .port0_cfg = {
  17795. + .force_link = 1,
  17796. + .speed = AR8327_PORT_SPEED_1000,
  17797. + .duplex = 1,
  17798. + .txpause = 1,
  17799. + .rxpause = 1,
  17800. + }
  17801. +};
  17802. +
  17803. +static struct mdio_board_info rb750g3_mdio_info[] = {
  17804. + {
  17805. + .bus_id = "ag71xx-mdio.0",
  17806. + .phy_addr = 0,
  17807. + .platform_data = &rb750gr3_ar8327_data,
  17808. + },
  17809. +};
  17810. +
  17811. +static void rb750gr3_nand_enable_pins(void)
  17812. +{
  17813. + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  17814. + AR724X_GPIO_FUNC_SPI_EN |
  17815. + AR724X_GPIO_FUNC_SPI_CS_EN2);
  17816. +}
  17817. +
  17818. +static void rb750gr3_nand_disable_pins(void)
  17819. +{
  17820. + ath79_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN |
  17821. + AR724X_GPIO_FUNC_SPI_CS_EN2,
  17822. + AR724X_GPIO_FUNC_JTAG_DISABLE);
  17823. +}
  17824. +
  17825. +static void rb750gr3_latch_change(u32 mask_clr, u32 mask_set)
  17826. +{
  17827. + static DEFINE_SPINLOCK(lock);
  17828. + static u32 latch_set = RB7XX_LED_ACT;
  17829. + static u32 latch_clr;
  17830. + void __iomem *base = ath79_gpio_base;
  17831. + unsigned long flags;
  17832. + u32 t;
  17833. +
  17834. + spin_lock_irqsave(&lock, flags);
  17835. +
  17836. + latch_set = (latch_set | mask_set) & ~mask_clr;
  17837. + latch_clr = (latch_clr | mask_clr) & ~mask_set;
  17838. +
  17839. + mask_set = latch_set & (RB7XX_USB_POWERON | RB7XX_MONITOR);
  17840. + mask_clr = latch_clr & (RB7XX_USB_POWERON | RB7XX_MONITOR);
  17841. +
  17842. + if ((latch_set ^ RB7XX_LED_ACT) & RB7XX_LED_ACT) {
  17843. + /* enable output mode */
  17844. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  17845. + t |= RB7XX_LED_ACT;
  17846. + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
  17847. +
  17848. + mask_clr |= RB7XX_LED_ACT;
  17849. + } else {
  17850. + /* disable output mode */
  17851. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  17852. + t &= ~RB7XX_LED_ACT;
  17853. + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
  17854. + }
  17855. +
  17856. + __raw_writel(mask_set, base + AR71XX_GPIO_REG_SET);
  17857. + __raw_writel(mask_clr, base + AR71XX_GPIO_REG_CLEAR);
  17858. +
  17859. + spin_unlock_irqrestore(&lock, flags);
  17860. +}
  17861. +
  17862. +static void __init rb750gr3_setup(void)
  17863. +{
  17864. + ath79_register_mdio(0, 0x0);
  17865. + mdiobus_register_board_info(rb750g3_mdio_info,
  17866. + ARRAY_SIZE(rb750g3_mdio_info));
  17867. +
  17868. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  17869. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  17870. + ath79_eth0_data.phy_mask = BIT(0);
  17871. + ath79_eth0_pll_data.pll_1000 = 0x62000000;
  17872. +
  17873. + ath79_register_eth(0);
  17874. +
  17875. + rb750_leds_data.num_leds = ARRAY_SIZE(rb750gr3_leds);
  17876. + rb750_leds_data.leds = rb750gr3_leds;
  17877. + rb750_leds_data.latch_change = rb750gr3_latch_change;
  17878. + platform_device_register(&rb750_leds_device);
  17879. +
  17880. + rb750_nand_data.nce_line = RB7XX_NAND_NCE;
  17881. + rb750_nand_data.enable_pins = rb750gr3_nand_enable_pins;
  17882. + rb750_nand_data.disable_pins = rb750gr3_nand_disable_pins;
  17883. + rb750_nand_data.latch_change = rb750gr3_latch_change;
  17884. + platform_device_register(&rb750_nand_device);
  17885. +}
  17886. +
  17887. +MIPS_MACHINE(ATH79_MACH_RB_750G_R3, "750Gr3", "MikroTik RouterBOARD 750GL",
  17888. + rb750gr3_setup);
  17889. +
  17890. +#define RB751_HARDCONFIG 0x1f00b000
  17891. +#define RB751_HARDCONFIG_SIZE 0x1000
  17892. +
  17893. +static void __init rb751_wlan_setup(void)
  17894. +{
  17895. + u8 *hardconfig = (u8 *) KSEG1ADDR(RB751_HARDCONFIG);
  17896. + struct ath9k_platform_data *wmac_data;
  17897. + u16 tag_len;
  17898. + u8 *tag;
  17899. + u16 mac_len;
  17900. + u8 *mac;
  17901. + int err;
  17902. +
  17903. + wmac_data = ap9x_pci_get_wmac_data(0);
  17904. + if (!wmac_data) {
  17905. + pr_err("rb75x: unable to get address of wlan data\n");
  17906. + return;
  17907. + }
  17908. +
  17909. + ap9x_pci_setup_wmac_led_pin(0, 9);
  17910. +
  17911. + err = routerboot_find_tag(hardconfig, RB751_HARDCONFIG_SIZE,
  17912. + RB_ID_WLAN_DATA, &tag, &tag_len);
  17913. + if (err) {
  17914. + pr_err("rb75x: no calibration data found\n");
  17915. + return;
  17916. + }
  17917. +
  17918. + err = rle_decode(tag, tag_len, (unsigned char *) wmac_data->eeprom_data,
  17919. + sizeof(wmac_data->eeprom_data), NULL, NULL);
  17920. + if (err) {
  17921. + pr_err("rb75x: unable to decode wlan eeprom data\n");
  17922. + return;
  17923. + }
  17924. +
  17925. + err = routerboot_find_tag(hardconfig, RB751_HARDCONFIG_SIZE,
  17926. + RB_ID_MAC_ADDRESS_PACK, &mac, &mac_len);
  17927. + if (err) {
  17928. + pr_err("rb75x: no mac address found\n");
  17929. + return;
  17930. + }
  17931. +
  17932. + ap91_pci_init(NULL, mac);
  17933. +}
  17934. +
  17935. +static void __init rb751_setup(void)
  17936. +{
  17937. + rb750_setup();
  17938. + ath79_register_usb();
  17939. + rb751_wlan_setup();
  17940. +}
  17941. +
  17942. +MIPS_MACHINE(ATH79_MACH_RB_751, "751", "MikroTik RouterBOARD 751",
  17943. + rb751_setup);
  17944. +
  17945. +static void __init rb751g_setup(void)
  17946. +{
  17947. + rb750gr3_setup();
  17948. + ath79_register_usb();
  17949. + rb751_wlan_setup();
  17950. +}
  17951. +
  17952. +MIPS_MACHINE(ATH79_MACH_RB_751G, "751g", "MikroTik RouterBOARD 751G",
  17953. + rb751g_setup);
  17954. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb91x.c linux-4.1.13/arch/mips/ath79/mach-rb91x.c
  17955. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb91x.c 1970-01-01 01:00:00.000000000 +0100
  17956. +++ linux-4.1.13/arch/mips/ath79/mach-rb91x.c 2015-09-13 20:04:35.068524086 +0200
  17957. @@ -0,0 +1,349 @@
  17958. +/*
  17959. + * MikroTik RouterBOARD 91X support
  17960. + *
  17961. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  17962. + *
  17963. + * This program is free software; you can redistribute it and/or modify it
  17964. + * under the terms of the GNU General Public License version 2 as published
  17965. + * by the Free Software Foundation.
  17966. + */
  17967. +
  17968. +#define pr_fmt(fmt) "rb91x: " fmt
  17969. +
  17970. +#include <linux/phy.h>
  17971. +#include <linux/delay.h>
  17972. +#include <linux/platform_device.h>
  17973. +#include <linux/ath9k_platform.h>
  17974. +#include <linux/mtd/mtd.h>
  17975. +#include <linux/mtd/nand.h>
  17976. +#include <linux/mtd/partitions.h>
  17977. +#include <linux/spi/spi.h>
  17978. +#include <linux/spi/74x164.h>
  17979. +#include <linux/spi/flash.h>
  17980. +#include <linux/routerboot.h>
  17981. +#include <linux/gpio.h>
  17982. +#include <linux/platform_data/gpio-latch.h>
  17983. +#include <linux/platform_data/rb91x_nand.h>
  17984. +#include <linux/platform_data/phy-at803x.h>
  17985. +
  17986. +#include <asm/prom.h>
  17987. +#include <asm/mach-ath79/ath79.h>
  17988. +#include <asm/mach-ath79/ath79_spi_platform.h>
  17989. +#include <asm/mach-ath79/ar71xx_regs.h>
  17990. +
  17991. +#include "common.h"
  17992. +#include "dev-eth.h"
  17993. +#include "dev-leds-gpio.h"
  17994. +#include "dev-nfc.h"
  17995. +#include "dev-usb.h"
  17996. +#include "dev-spi.h"
  17997. +#include "dev-wmac.h"
  17998. +#include "machtypes.h"
  17999. +#include "pci.h"
  18000. +#include "routerboot.h"
  18001. +
  18002. +#define RB_ROUTERBOOT_OFFSET 0x0000
  18003. +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
  18004. +#define RB_HARD_CFG_SIZE 0x1000
  18005. +#define RB_BIOS_OFFSET 0xd000
  18006. +#define RB_BIOS_SIZE 0x1000
  18007. +#define RB_SOFT_CFG_OFFSET 0xf000
  18008. +#define RB_SOFT_CFG_SIZE 0x1000
  18009. +
  18010. +#define RB91X_FLAG_USB BIT(0)
  18011. +#define RB91X_FLAG_PCIE BIT(1)
  18012. +
  18013. +#define RB91X_LATCH_GPIO_BASE AR934X_GPIO_COUNT
  18014. +#define RB91X_LATCH_GPIO(_x) (RB91X_LATCH_GPIO_BASE + (_x))
  18015. +
  18016. +#define RB91X_SSR_GPIO_BASE (RB91X_LATCH_GPIO_BASE + AR934X_GPIO_COUNT)
  18017. +#define RB91X_SSR_GPIO(_x) (RB91X_SSR_GPIO_BASE + (_x))
  18018. +
  18019. +#define RB91X_SSR_BIT_LED1 0
  18020. +#define RB91X_SSR_BIT_LED2 1
  18021. +#define RB91X_SSR_BIT_LED3 2
  18022. +#define RB91X_SSR_BIT_LED4 3
  18023. +#define RB91X_SSR_BIT_LED5 4
  18024. +#define RB91X_SSR_BIT_5 5
  18025. +#define RB91X_SSR_BIT_USB_POWER 6
  18026. +#define RB91X_SSR_BIT_PCIE_POWER 7
  18027. +
  18028. +#define RB91X_GPIO_SSR_STROBE RB91X_LATCH_GPIO(0)
  18029. +#define RB91X_GPIO_LED_POWER RB91X_LATCH_GPIO(1)
  18030. +#define RB91X_GPIO_LED_USER RB91X_LATCH_GPIO(2)
  18031. +#define RB91X_GPIO_NAND_READ RB91X_LATCH_GPIO(3)
  18032. +#define RB91X_GPIO_NAND_RDY RB91X_LATCH_GPIO(4)
  18033. +#define RB91X_GPIO_NLE RB91X_LATCH_GPIO(11)
  18034. +#define RB91X_GPIO_NAND_NRW RB91X_LATCH_GPIO(12)
  18035. +#define RB91X_GPIO_NAND_NCE RB91X_LATCH_GPIO(13)
  18036. +#define RB91X_GPIO_NAND_CLE RB91X_LATCH_GPIO(14)
  18037. +#define RB91X_GPIO_NAND_ALE RB91X_LATCH_GPIO(15)
  18038. +
  18039. +#define RB91X_GPIO_LED_1 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED1)
  18040. +#define RB91X_GPIO_LED_2 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED2)
  18041. +#define RB91X_GPIO_LED_3 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED3)
  18042. +#define RB91X_GPIO_LED_4 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED4)
  18043. +#define RB91X_GPIO_LED_5 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED5)
  18044. +#define RB91X_GPIO_USB_POWER RB91X_SSR_GPIO(RB91X_SSR_BIT_USB_POWER)
  18045. +#define RB91X_GPIO_PCIE_POWER RB91X_SSR_GPIO(RB91X_SSR_BIT_PCIE_POWER)
  18046. +
  18047. +struct rb_board_info {
  18048. + const char *name;
  18049. + u32 flags;
  18050. +};
  18051. +
  18052. +static struct mtd_partition rb711gr100_spi_partitions[] = {
  18053. + {
  18054. + .name = "routerboot",
  18055. + .offset = RB_ROUTERBOOT_OFFSET,
  18056. + .mask_flags = MTD_WRITEABLE,
  18057. + }, {
  18058. + .name = "hard_config",
  18059. + .size = RB_HARD_CFG_SIZE,
  18060. + .mask_flags = MTD_WRITEABLE,
  18061. + }, {
  18062. + .name = "bios",
  18063. + .offset = RB_BIOS_OFFSET,
  18064. + .size = RB_BIOS_SIZE,
  18065. + .mask_flags = MTD_WRITEABLE,
  18066. + }, {
  18067. + .name = "soft_config",
  18068. + .size = RB_SOFT_CFG_SIZE,
  18069. + }
  18070. +};
  18071. +
  18072. +static struct flash_platform_data rb711gr100_spi_flash_data = {
  18073. + .parts = rb711gr100_spi_partitions,
  18074. + .nr_parts = ARRAY_SIZE(rb711gr100_spi_partitions),
  18075. +};
  18076. +
  18077. +static int rb711gr100_gpio_latch_gpios[AR934X_GPIO_COUNT] __initdata = {
  18078. + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  18079. + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
  18080. +};
  18081. +
  18082. +static struct gpio_latch_platform_data rb711gr100_gpio_latch_data __initdata = {
  18083. + .base = RB91X_LATCH_GPIO_BASE,
  18084. + .num_gpios = ARRAY_SIZE(rb711gr100_gpio_latch_gpios),
  18085. + .gpios = rb711gr100_gpio_latch_gpios,
  18086. + .le_gpio_index = 11,
  18087. + .le_active_low = true,
  18088. +};
  18089. +
  18090. +static struct rb91x_nand_platform_data rb711gr100_nand_data __initdata = {
  18091. + .gpio_nce = RB91X_GPIO_NAND_NCE,
  18092. + .gpio_ale = RB91X_GPIO_NAND_ALE,
  18093. + .gpio_cle = RB91X_GPIO_NAND_CLE,
  18094. + .gpio_rdy = RB91X_GPIO_NAND_RDY,
  18095. + .gpio_read = RB91X_GPIO_NAND_READ,
  18096. + .gpio_nrw = RB91X_GPIO_NAND_NRW,
  18097. + .gpio_nle = RB91X_GPIO_NLE,
  18098. +};
  18099. +
  18100. +static u8 rb711gr100_ssr_initdata[] __initdata = {
  18101. + BIT(RB91X_SSR_BIT_PCIE_POWER) |
  18102. + BIT(RB91X_SSR_BIT_USB_POWER) |
  18103. + BIT(RB91X_SSR_BIT_5)
  18104. +};
  18105. +
  18106. +static struct gen_74x164_chip_platform_data rb711gr100_ssr_data = {
  18107. + .base = RB91X_SSR_GPIO_BASE,
  18108. + .num_registers = ARRAY_SIZE(rb711gr100_ssr_initdata),
  18109. + .init_data = rb711gr100_ssr_initdata,
  18110. +};
  18111. +
  18112. +static struct ath79_spi_controller_data rb711gr100_spi0_cdata = {
  18113. + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
  18114. + .cs_line = 0,
  18115. + .is_flash = true,
  18116. +};
  18117. +
  18118. +static struct ath79_spi_controller_data rb711gr100_spi1_cdata = {
  18119. + .cs_type = ATH79_SPI_CS_TYPE_GPIO,
  18120. + .cs_line = RB91X_GPIO_SSR_STROBE,
  18121. +};
  18122. +
  18123. +static struct spi_board_info rb711gr100_spi_info[] = {
  18124. + {
  18125. + .bus_num = 0,
  18126. + .chip_select = 0,
  18127. + .max_speed_hz = 25000000,
  18128. + .modalias = "m25p80",
  18129. + .platform_data = &rb711gr100_spi_flash_data,
  18130. + .controller_data = &rb711gr100_spi0_cdata
  18131. + }, {
  18132. + .bus_num = 0,
  18133. + .chip_select = 1,
  18134. + .max_speed_hz = 10000000,
  18135. + .modalias = "74x164",
  18136. + .platform_data = &rb711gr100_ssr_data,
  18137. + .controller_data = &rb711gr100_spi1_cdata
  18138. + }
  18139. +};
  18140. +
  18141. +static struct ath79_spi_platform_data rb711gr100_spi_data __initdata = {
  18142. + .bus_num = 0,
  18143. + .num_chipselect = 2,
  18144. +};
  18145. +
  18146. +static struct gpio_led rb711gr100_leds[] __initdata = {
  18147. + {
  18148. + .name = "rb:green:led1",
  18149. + .gpio = RB91X_GPIO_LED_1,
  18150. + .active_low = 0,
  18151. + },
  18152. + {
  18153. + .name = "rb:green:led2",
  18154. + .gpio = RB91X_GPIO_LED_2,
  18155. + .active_low = 0,
  18156. + },
  18157. + {
  18158. + .name = "rb:green:led3",
  18159. + .gpio = RB91X_GPIO_LED_3,
  18160. + .active_low = 0,
  18161. + },
  18162. + {
  18163. + .name = "rb:green:led4",
  18164. + .gpio = RB91X_GPIO_LED_4,
  18165. + .active_low = 0,
  18166. + },
  18167. + {
  18168. + .name = "rb:green:led5",
  18169. + .gpio = RB91X_GPIO_LED_5,
  18170. + .active_low = 0,
  18171. + },
  18172. + {
  18173. + .name = "rb:green:user",
  18174. + .gpio = RB91X_GPIO_LED_USER,
  18175. + .active_low = 0,
  18176. + },
  18177. + {
  18178. + .name = "rb:green:power",
  18179. + .gpio = RB91X_GPIO_LED_POWER,
  18180. + .active_low = 0,
  18181. + },
  18182. +};
  18183. +
  18184. +static struct at803x_platform_data rb91x_at803x_data = {
  18185. + .disable_smarteee = 1,
  18186. + .enable_rgmii_rx_delay = 1,
  18187. + .enable_rgmii_tx_delay = 1,
  18188. +};
  18189. +
  18190. +static struct mdio_board_info rb91x_mdio0_info[] = {
  18191. + {
  18192. + .bus_id = "ag71xx-mdio.0",
  18193. + .phy_addr = 0,
  18194. + .platform_data = &rb91x_at803x_data,
  18195. + },
  18196. +};
  18197. +
  18198. +static void __init rb711gr100_init_partitions(const struct rb_info *info)
  18199. +{
  18200. + rb711gr100_spi_partitions[0].size = info->hard_cfg_offs;
  18201. + rb711gr100_spi_partitions[1].offset = info->hard_cfg_offs;
  18202. +
  18203. + rb711gr100_spi_partitions[3].offset = info->soft_cfg_offs;
  18204. +}
  18205. +
  18206. +void __init rb711gr100_wlan_init(void)
  18207. +{
  18208. + char *caldata;
  18209. + u8 wlan_mac[ETH_ALEN];
  18210. +
  18211. + caldata = rb_get_wlan_data();
  18212. + if (caldata == NULL)
  18213. + return;
  18214. +
  18215. + ath79_init_mac(wlan_mac, ath79_mac_base, 1);
  18216. + ath79_register_wmac(caldata + 0x1000, wlan_mac);
  18217. +
  18218. + kfree(caldata);
  18219. +}
  18220. +
  18221. +#define RB_BOARD_INFO(_name, _flags) \
  18222. + { \
  18223. + .name = (_name), \
  18224. + .flags = (_flags), \
  18225. + }
  18226. +
  18227. +static const struct rb_board_info rb711gr100_boards[] __initconst = {
  18228. + RB_BOARD_INFO("911G-2HPnD", 0),
  18229. + RB_BOARD_INFO("911G-5HPnD", 0),
  18230. + RB_BOARD_INFO("912UAG-2HPnD", RB91X_FLAG_USB | RB91X_FLAG_PCIE),
  18231. + RB_BOARD_INFO("912UAG-5HPnD", RB91X_FLAG_USB | RB91X_FLAG_PCIE),
  18232. +};
  18233. +
  18234. +static u32 rb711gr100_get_flags(const struct rb_info *info)
  18235. +{
  18236. + int i;
  18237. +
  18238. + for (i = 0; i < ARRAY_SIZE(rb711gr100_boards); i++) {
  18239. + const struct rb_board_info *bi;
  18240. +
  18241. + bi = &rb711gr100_boards[i];
  18242. + if (strcmp(info->board_name, bi->name) == 0)
  18243. + return bi->flags;
  18244. + }
  18245. +
  18246. + return 0;
  18247. +}
  18248. +
  18249. +static void __init rb711gr100_setup(void)
  18250. +{
  18251. + const struct rb_info *info;
  18252. + char buf[64];
  18253. + u32 flags;
  18254. +
  18255. + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
  18256. + if (!info)
  18257. + return;
  18258. +
  18259. + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
  18260. + (info->board_name) ? info->board_name : "");
  18261. + mips_set_machine_name(buf);
  18262. +
  18263. + rb711gr100_init_partitions(info);
  18264. + ath79_register_spi(&rb711gr100_spi_data, rb711gr100_spi_info,
  18265. + ARRAY_SIZE(rb711gr100_spi_info));
  18266. +
  18267. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  18268. + AR934X_ETH_CFG_RXD_DELAY |
  18269. + AR934X_ETH_CFG_SW_ONLY_MODE);
  18270. +
  18271. + ath79_register_mdio(0, 0x0);
  18272. +
  18273. + mdiobus_register_board_info(rb91x_mdio0_info,
  18274. + ARRAY_SIZE(rb91x_mdio0_info));
  18275. +
  18276. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  18277. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  18278. + ath79_eth0_data.phy_mask = BIT(0);
  18279. + ath79_eth0_pll_data.pll_1000 = 0x02000000;
  18280. +
  18281. + ath79_register_eth(0);
  18282. +
  18283. + rb711gr100_wlan_init();
  18284. +
  18285. + platform_device_register_data(NULL, "rb91x-nand", -1,
  18286. + &rb711gr100_nand_data,
  18287. + sizeof(rb711gr100_nand_data));
  18288. +
  18289. + platform_device_register_data(NULL, "gpio-latch", -1,
  18290. + &rb711gr100_gpio_latch_data,
  18291. + sizeof(rb711gr100_gpio_latch_data));
  18292. +
  18293. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb711gr100_leds),
  18294. + rb711gr100_leds);
  18295. +
  18296. + flags = rb711gr100_get_flags(info);
  18297. +
  18298. + if (flags & RB91X_FLAG_USB)
  18299. + ath79_register_usb();
  18300. +
  18301. + if (flags & RB91X_FLAG_PCIE)
  18302. + ath79_register_pci();
  18303. +
  18304. +}
  18305. +
  18306. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_711GR100, "711Gr100", rb711gr100_setup);
  18307. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb922.c linux-4.1.13/arch/mips/ath79/mach-rb922.c
  18308. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb922.c 1970-01-01 01:00:00.000000000 +0100
  18309. +++ linux-4.1.13/arch/mips/ath79/mach-rb922.c 2015-09-13 20:04:35.068524086 +0200
  18310. @@ -0,0 +1,236 @@
  18311. +/*
  18312. + * MikroTik RouterBOARD 91X support
  18313. + *
  18314. + * Copyright (C) 2015 Gabor Juhos <juhosg@openwrt.org>
  18315. + *
  18316. + * This program is free software; you can redistribute it and/or modify it
  18317. + * under the terms of the GNU General Public License version 2 as published
  18318. + * by the Free Software Foundation.
  18319. + */
  18320. +
  18321. +#include <linux/phy.h>
  18322. +#include <linux/delay.h>
  18323. +#include <linux/platform_device.h>
  18324. +#include <linux/ath9k_platform.h>
  18325. +#include <linux/mtd/mtd.h>
  18326. +#include <linux/mtd/nand.h>
  18327. +#include <linux/mtd/partitions.h>
  18328. +#include <linux/spi/spi.h>
  18329. +#include <linux/spi/flash.h>
  18330. +#include <linux/routerboot.h>
  18331. +#include <linux/gpio.h>
  18332. +#include <linux/platform_data/phy-at803x.h>
  18333. +
  18334. +#include <asm/prom.h>
  18335. +#include <asm/mach-ath79/ath79.h>
  18336. +#include <asm/mach-ath79/ar71xx_regs.h>
  18337. +
  18338. +#include "common.h"
  18339. +#include "dev-gpio-buttons.h"
  18340. +#include "dev-eth.h"
  18341. +#include "dev-leds-gpio.h"
  18342. +#include "dev-m25p80.h"
  18343. +#include "dev-nfc.h"
  18344. +#include "dev-usb.h"
  18345. +#include "dev-spi.h"
  18346. +#include "machtypes.h"
  18347. +#include "pci.h"
  18348. +#include "routerboot.h"
  18349. +
  18350. +#define RB922_GPIO_LED_USR 12
  18351. +#define RB922_GPIO_USB_POWER 13
  18352. +#define RB922_GPIO_FAN_CTRL 14
  18353. +#define RB922_GPIO_BTN_RESET 20
  18354. +#define RB922_GPIO_NAND_NCE 23
  18355. +
  18356. +#define RB922_PHY_ADDR 4
  18357. +
  18358. +#define RB922_KEYS_POLL_INTERVAL 20 /* msecs */
  18359. +#define RB922_KEYS_DEBOUNCE_INTERVAL (3 * RB922_KEYS_POLL_INTERVAL)
  18360. +
  18361. +#define RB_ROUTERBOOT_OFFSET 0x0000
  18362. +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
  18363. +#define RB_HARD_CFG_SIZE 0x1000
  18364. +#define RB_BIOS_OFFSET 0xd000
  18365. +#define RB_BIOS_SIZE 0x1000
  18366. +#define RB_SOFT_CFG_OFFSET 0xf000
  18367. +#define RB_SOFT_CFG_SIZE 0x1000
  18368. +
  18369. +static struct mtd_partition rb922gs_spi_partitions[] = {
  18370. + {
  18371. + .name = "routerboot",
  18372. + .offset = RB_ROUTERBOOT_OFFSET,
  18373. + .mask_flags = MTD_WRITEABLE,
  18374. + }, {
  18375. + .name = "hard_config",
  18376. + .size = RB_HARD_CFG_SIZE,
  18377. + .mask_flags = MTD_WRITEABLE,
  18378. + }, {
  18379. + .name = "bios",
  18380. + .offset = RB_BIOS_OFFSET,
  18381. + .size = RB_BIOS_SIZE,
  18382. + .mask_flags = MTD_WRITEABLE,
  18383. + }, {
  18384. + .name = "soft_config",
  18385. + .size = RB_SOFT_CFG_SIZE,
  18386. + }
  18387. +};
  18388. +
  18389. +static struct flash_platform_data rb922gs_spi_flash_data = {
  18390. + .parts = rb922gs_spi_partitions,
  18391. + .nr_parts = ARRAY_SIZE(rb922gs_spi_partitions),
  18392. +};
  18393. +
  18394. +static struct gpio_led rb922gs_leds[] __initdata = {
  18395. + {
  18396. + .name = "rb:green:user",
  18397. + .gpio = RB922_GPIO_LED_USR,
  18398. + .active_low = 1,
  18399. + },
  18400. +};
  18401. +
  18402. +static struct gpio_keys_button rb922gs_gpio_keys[] __initdata = {
  18403. + {
  18404. + .desc = "Reset button",
  18405. + .type = EV_KEY,
  18406. + .code = KEY_RESTART,
  18407. + .debounce_interval = RB922_KEYS_DEBOUNCE_INTERVAL,
  18408. + .gpio = RB922_GPIO_BTN_RESET,
  18409. + .active_low = 1,
  18410. + },
  18411. +};
  18412. +
  18413. +static struct at803x_platform_data rb922gs_at803x_data = {
  18414. + .disable_smarteee = 1,
  18415. +};
  18416. +
  18417. +static struct mdio_board_info rb922gs_mdio0_info[] = {
  18418. + {
  18419. + .bus_id = "ag71xx-mdio.0",
  18420. + .phy_addr = RB922_PHY_ADDR,
  18421. + .platform_data = &rb922gs_at803x_data,
  18422. + },
  18423. +};
  18424. +
  18425. +static void __init rb922gs_init_partitions(const struct rb_info *info)
  18426. +{
  18427. + rb922gs_spi_partitions[0].size = info->hard_cfg_offs;
  18428. + rb922gs_spi_partitions[1].offset = info->hard_cfg_offs;
  18429. + rb922gs_spi_partitions[3].offset = info->soft_cfg_offs;
  18430. +}
  18431. +
  18432. +static void rb922gs_nand_select_chip(int chip_no)
  18433. +{
  18434. + switch (chip_no) {
  18435. + case 0:
  18436. + gpio_set_value(RB922_GPIO_NAND_NCE, 0);
  18437. + break;
  18438. + default:
  18439. + gpio_set_value(RB922_GPIO_NAND_NCE, 1);
  18440. + break;
  18441. + }
  18442. + ndelay(500);
  18443. +}
  18444. +
  18445. +static struct nand_ecclayout rb922gs_nand_ecclayout = {
  18446. + .eccbytes = 6,
  18447. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  18448. + .oobavail = 9,
  18449. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  18450. +};
  18451. +
  18452. +static int rb922gs_nand_scan_fixup(struct mtd_info *mtd)
  18453. +{
  18454. + struct nand_chip *chip = mtd->priv;
  18455. +
  18456. + if (mtd->writesize == 512) {
  18457. + /*
  18458. + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
  18459. + * will not be able to find the kernel that we load.
  18460. + */
  18461. + chip->ecc.layout = &rb922gs_nand_ecclayout;
  18462. + }
  18463. +
  18464. + return 0;
  18465. +}
  18466. +
  18467. +static struct mtd_partition rb922gs_nand_partitions[] = {
  18468. + {
  18469. + .name = "booter",
  18470. + .offset = 0,
  18471. + .size = (256 * 1024),
  18472. + .mask_flags = MTD_WRITEABLE,
  18473. + },
  18474. + {
  18475. + .name = "kernel",
  18476. + .offset = (256 * 1024),
  18477. + .size = (4 * 1024 * 1024) - (256 * 1024),
  18478. + },
  18479. + {
  18480. + .name = "rootfs",
  18481. + .offset = MTDPART_OFS_NXTBLK,
  18482. + .size = MTDPART_SIZ_FULL,
  18483. + },
  18484. +};
  18485. +
  18486. +static void __init rb922gs_nand_init(void)
  18487. +{
  18488. + gpio_request_one(RB922_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
  18489. +
  18490. + ath79_nfc_set_scan_fixup(rb922gs_nand_scan_fixup);
  18491. + ath79_nfc_set_parts(rb922gs_nand_partitions,
  18492. + ARRAY_SIZE(rb922gs_nand_partitions));
  18493. + ath79_nfc_set_select_chip(rb922gs_nand_select_chip);
  18494. + ath79_nfc_set_swap_dma(true);
  18495. + ath79_register_nfc();
  18496. +}
  18497. +
  18498. +static void __init rb922gs_setup(void)
  18499. +{
  18500. + const struct rb_info *info;
  18501. + char buf[64];
  18502. +
  18503. + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
  18504. + if (!info)
  18505. + return;
  18506. +
  18507. + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
  18508. + (info->board_name) ? info->board_name : "");
  18509. + mips_set_machine_name(buf);
  18510. +
  18511. + rb922gs_init_partitions(info);
  18512. + ath79_register_m25p80(&rb922gs_spi_flash_data);
  18513. +
  18514. + rb922gs_nand_init();
  18515. +
  18516. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  18517. +
  18518. + ath79_register_mdio(0, 0x0);
  18519. +
  18520. + mdiobus_register_board_info(rb922gs_mdio0_info,
  18521. + ARRAY_SIZE(rb922gs_mdio0_info));
  18522. +
  18523. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  18524. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  18525. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  18526. + ath79_eth0_data.phy_mask = BIT(RB922_PHY_ADDR);
  18527. + ath79_eth0_pll_data.pll_10 = 0x81001313;
  18528. + ath79_eth0_pll_data.pll_100 = 0x81000101;
  18529. + ath79_eth0_pll_data.pll_1000 = 0x8f000000;
  18530. +
  18531. + ath79_register_eth(0);
  18532. +
  18533. + ath79_register_pci();
  18534. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb922gs_leds), rb922gs_leds);
  18535. + ath79_register_gpio_keys_polled(-1, RB922_KEYS_POLL_INTERVAL,
  18536. + ARRAY_SIZE(rb922gs_gpio_keys),
  18537. + rb922gs_gpio_keys);
  18538. +
  18539. + /* NOTE:
  18540. + * This only supports the RB911G-5HPacD board for now. For other boards
  18541. + * more devices must be registered based on the hardware options which
  18542. + * can be found in the hardware configuration of RouterBOOT.
  18543. + */
  18544. +}
  18545. +
  18546. +MIPS_MACHINE_NONAME(ATH79_MACH_RB_922GS, "922gs", rb922gs_setup);
  18547. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rb95x.c linux-4.1.13/arch/mips/ath79/mach-rb95x.c
  18548. --- linux-4.1.13.orig/arch/mips/ath79/mach-rb95x.c 1970-01-01 01:00:00.000000000 +0100
  18549. +++ linux-4.1.13/arch/mips/ath79/mach-rb95x.c 2015-09-13 20:04:35.068524086 +0200
  18550. @@ -0,0 +1,258 @@
  18551. +/*
  18552. + * MikroTik RouterBOARD 95X support
  18553. + *
  18554. + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
  18555. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  18556. + * Copyright (C) 2013 Kamil Trzcinski <ayufan@ayufan.eu>
  18557. + *
  18558. + * This program is free software; you can redistribute it and/or modify it
  18559. + * under the terms of the GNU General Public License version 2 as published
  18560. + * by the Free Software Foundation.
  18561. + */
  18562. +
  18563. +#define pr_fmt(fmt) "rb95x: " fmt
  18564. +
  18565. +#include <linux/phy.h>
  18566. +#include <linux/delay.h>
  18567. +#include <linux/platform_device.h>
  18568. +#include <linux/ath9k_platform.h>
  18569. +#include <linux/ar8216_platform.h>
  18570. +#include <linux/mtd/mtd.h>
  18571. +#include <linux/mtd/nand.h>
  18572. +#include <linux/mtd/partitions.h>
  18573. +#include <linux/spi/spi.h>
  18574. +#include <linux/spi/flash.h>
  18575. +#include <linux/routerboot.h>
  18576. +#include <linux/gpio.h>
  18577. +
  18578. +#include <asm/mach-ath79/ath79.h>
  18579. +#include <asm/mach-ath79/ar71xx_regs.h>
  18580. +
  18581. +#include "common.h"
  18582. +#include "dev-eth.h"
  18583. +#include "dev-m25p80.h"
  18584. +#include "dev-nfc.h"
  18585. +#include "dev-usb.h"
  18586. +#include "dev-wmac.h"
  18587. +#include "machtypes.h"
  18588. +#include "routerboot.h"
  18589. +#include "dev-leds-gpio.h"
  18590. +
  18591. +#define RB95X_GPIO_NAND_NCE 14
  18592. +
  18593. +static struct mtd_partition rb95x_nand_partitions[] = {
  18594. + {
  18595. + .name = "booter",
  18596. + .offset = 0,
  18597. + .size = (256 * 1024),
  18598. + .mask_flags = MTD_WRITEABLE,
  18599. + },
  18600. + {
  18601. + .name = "kernel",
  18602. + .offset = (256 * 1024),
  18603. + .size = (4 * 1024 * 1024) - (256 * 1024),
  18604. + },
  18605. + {
  18606. + .name = "rootfs",
  18607. + .offset = MTDPART_OFS_NXTBLK,
  18608. + .size = MTDPART_SIZ_FULL,
  18609. + },
  18610. +};
  18611. +
  18612. +static struct gpio_led rb951ui_leds_gpio[] __initdata = {
  18613. + {
  18614. + .name = "rb:green:wlan",
  18615. + .gpio = 11,
  18616. + .active_low = 1,
  18617. + }, {
  18618. + .name = "rb:green:act",
  18619. + .gpio = 3,
  18620. + .active_low = 1,
  18621. + }, {
  18622. + .name = "rb:green:port1",
  18623. + .gpio = 13,
  18624. + .active_low = 1,
  18625. + }, {
  18626. + .name = "rb:green:port2",
  18627. + .gpio = 12,
  18628. + .active_low = 1,
  18629. + }, {
  18630. + .name = "rb:green:port3",
  18631. + .gpio = 4,
  18632. + .active_low = 1,
  18633. + }, {
  18634. + .name = "rb:green:port4",
  18635. + .gpio = 21,
  18636. + .active_low = 1,
  18637. + }, {
  18638. + .name = "rb:green:port5",
  18639. + .gpio = 16,
  18640. + .active_low = 1,
  18641. + }
  18642. +};
  18643. +
  18644. +static struct ar8327_pad_cfg rb95x_ar8327_pad0_cfg = {
  18645. + .mode = AR8327_PAD_MAC_RGMII,
  18646. + .txclk_delay_en = true,
  18647. + .rxclk_delay_en = true,
  18648. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  18649. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  18650. +};
  18651. +
  18652. +static struct ar8327_platform_data rb95x_ar8327_data = {
  18653. + .pad0_cfg = &rb95x_ar8327_pad0_cfg,
  18654. + .port0_cfg = {
  18655. + .force_link = 1,
  18656. + .speed = AR8327_PORT_SPEED_1000,
  18657. + .duplex = 1,
  18658. + .txpause = 1,
  18659. + .rxpause = 1,
  18660. + }
  18661. +};
  18662. +
  18663. +static struct mdio_board_info rb95x_mdio0_info[] = {
  18664. + {
  18665. + .bus_id = "ag71xx-mdio.0",
  18666. + .phy_addr = 0,
  18667. + .platform_data = &rb95x_ar8327_data,
  18668. + },
  18669. +};
  18670. +
  18671. +void __init rb95x_wlan_init(void)
  18672. +{
  18673. + char *art_buf;
  18674. + u8 wlan_mac[ETH_ALEN];
  18675. +
  18676. + art_buf = rb_get_wlan_data();
  18677. + if (art_buf == NULL)
  18678. + return;
  18679. +
  18680. + ath79_init_mac(wlan_mac, ath79_mac_base, 11);
  18681. + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
  18682. +
  18683. + kfree(art_buf);
  18684. +}
  18685. +
  18686. +static void rb95x_nand_select_chip(int chip_no)
  18687. +{
  18688. + switch (chip_no) {
  18689. + case 0:
  18690. + gpio_set_value(RB95X_GPIO_NAND_NCE, 0);
  18691. + break;
  18692. + default:
  18693. + gpio_set_value(RB95X_GPIO_NAND_NCE, 1);
  18694. + break;
  18695. + }
  18696. + ndelay(500);
  18697. +}
  18698. +
  18699. +static struct nand_ecclayout rb95x_nand_ecclayout = {
  18700. + .eccbytes = 6,
  18701. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  18702. + .oobavail = 9,
  18703. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  18704. +};
  18705. +
  18706. +static int rb95x_nand_scan_fixup(struct mtd_info *mtd)
  18707. +{
  18708. + struct nand_chip *chip = mtd->priv;
  18709. +
  18710. + if (mtd->writesize == 512) {
  18711. + /*
  18712. + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
  18713. + * will not be able to find the kernel that we load.
  18714. + */
  18715. + chip->ecc.layout = &rb95x_nand_ecclayout;
  18716. + }
  18717. +
  18718. + return 0;
  18719. +}
  18720. +
  18721. +void __init rb95x_nand_init(void)
  18722. +{
  18723. + gpio_request_one(RB95X_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
  18724. +
  18725. + ath79_nfc_set_scan_fixup(rb95x_nand_scan_fixup);
  18726. + ath79_nfc_set_parts(rb95x_nand_partitions,
  18727. + ARRAY_SIZE(rb95x_nand_partitions));
  18728. + ath79_nfc_set_select_chip(rb95x_nand_select_chip);
  18729. + ath79_nfc_set_swap_dma(true);
  18730. + ath79_register_nfc();
  18731. +}
  18732. +
  18733. +static int __init rb95x_setup(void)
  18734. +{
  18735. + const struct rb_info *info;
  18736. +
  18737. + info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x10000);
  18738. + if (!info)
  18739. + return -EINVAL;
  18740. +
  18741. + rb95x_nand_init();
  18742. +
  18743. + return 0;
  18744. +}
  18745. +
  18746. +static void __init rb951g_setup(void)
  18747. +{
  18748. + if (rb95x_setup())
  18749. + return;
  18750. +
  18751. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  18752. + AR934X_ETH_CFG_SW_ONLY_MODE);
  18753. +
  18754. + ath79_register_mdio(0, 0x0);
  18755. +
  18756. + mdiobus_register_board_info(rb95x_mdio0_info,
  18757. + ARRAY_SIZE(rb95x_mdio0_info));
  18758. +
  18759. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  18760. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  18761. + ath79_eth0_data.phy_mask = BIT(0);
  18762. +
  18763. + ath79_register_eth(0);
  18764. +
  18765. + rb95x_wlan_init();
  18766. + ath79_register_usb();
  18767. +}
  18768. +
  18769. +MIPS_MACHINE(ATH79_MACH_RB_951G, "951G", "MikroTik RouterBOARD 951G-2HnD",
  18770. + rb951g_setup);
  18771. +
  18772. +static void __init rb951ui_setup(void)
  18773. +{
  18774. + if (rb95x_setup())
  18775. + return;
  18776. +
  18777. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  18778. +
  18779. + ath79_register_mdio(1, 0x0);
  18780. +
  18781. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  18782. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  18783. +
  18784. + ath79_switch_data.phy4_mii_en = 1;
  18785. + ath79_switch_data.phy_poll_mask = BIT(4);
  18786. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  18787. + ath79_eth0_data.phy_mask = BIT(4);
  18788. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  18789. + ath79_register_eth(0);
  18790. +
  18791. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  18792. + ath79_register_eth(1);
  18793. +
  18794. + gpio_request_one(20, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  18795. + "USB power");
  18796. +
  18797. + gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  18798. + "POE power");
  18799. +
  18800. + rb95x_wlan_init();
  18801. + ath79_register_usb();
  18802. +
  18803. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb951ui_leds_gpio),
  18804. + rb951ui_leds_gpio);
  18805. +}
  18806. +
  18807. +MIPS_MACHINE(ATH79_MACH_RB_951U, "951HnD", "MikroTik RouterBOARD 951Ui-2HnD",
  18808. + rb951ui_setup);
  18809. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rbsxtlite.c linux-4.1.13/arch/mips/ath79/mach-rbsxtlite.c
  18810. --- linux-4.1.13.orig/arch/mips/ath79/mach-rbsxtlite.c 1970-01-01 01:00:00.000000000 +0100
  18811. +++ linux-4.1.13/arch/mips/ath79/mach-rbsxtlite.c 2015-09-13 20:04:35.068524086 +0200
  18812. @@ -0,0 +1,238 @@
  18813. +/*
  18814. + * MikroTik RouterBOARD SXT Lite support
  18815. + *
  18816. + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
  18817. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  18818. + * Copyright (C) 2013 Vyacheslav Adamanov <adamanov@gmail.com>
  18819. + *
  18820. + * This program is free software; you can redistribute it and/or modify it
  18821. + * under the terms of the GNU General Public License version 2 as published
  18822. + * by the Free Software Foundation.
  18823. + */
  18824. +
  18825. +#define pr_fmt(fmt) "sxtlite: " fmt
  18826. +
  18827. +#include <linux/phy.h>
  18828. +#include <linux/delay.h>
  18829. +#include <linux/platform_device.h>
  18830. +#include <linux/ath9k_platform.h>
  18831. +#include <linux/mtd/mtd.h>
  18832. +#include <linux/mtd/nand.h>
  18833. +#include <linux/mtd/partitions.h>
  18834. +#include <linux/spi/spi.h>
  18835. +#include <linux/spi/flash.h>
  18836. +#include <linux/rle.h>
  18837. +#include <linux/routerboot.h>
  18838. +#include <linux/gpio.h>
  18839. +
  18840. +#include <asm/mach-ath79/ath79.h>
  18841. +#include <asm/mach-ath79/ar71xx_regs.h>
  18842. +#include "common.h"
  18843. +#include "dev-ap9x-pci.h"
  18844. +#include "dev-gpio-buttons.h"
  18845. +#include "dev-leds-gpio.h"
  18846. +#include "dev-eth.h"
  18847. +#include "dev-m25p80.h"
  18848. +#include "dev-nfc.h"
  18849. +#include "dev-wmac.h"
  18850. +#include "dev-usb.h"
  18851. +#include "machtypes.h"
  18852. +#include "routerboot.h"
  18853. +#include <linux/ar8216_platform.h>
  18854. +
  18855. +#define SXTLITE_GPIO_NAND_NCE 14
  18856. +#define SXTLITE_GPIO_LED_USER 3
  18857. +#define SXTLITE_GPIO_LED_1 13
  18858. +#define SXTLITE_GPIO_LED_2 12
  18859. +#define SXTLITE_GPIO_LED_3 4
  18860. +#define SXTLITE_GPIO_LED_4 21
  18861. +#define SXTLITE_GPIO_LED_5 18
  18862. +#define SXTLITE_GPIO_LED_POWER 11
  18863. +
  18864. +#define SXTLITE_GPIO_BUZZER 19
  18865. +
  18866. +#define SXTLITE_GPIO_BTN_RESET 15
  18867. +
  18868. +#define SXTLITE_KEYS_POLL_INTERVAL 20
  18869. +#define SXTLITE_KEYS_DEBOUNCE_INTERVAL (3 * SXTLITE_KEYS_POLL_INTERVAL)
  18870. +
  18871. +static struct mtd_partition rbsxtlite_nand_partitions[] = {
  18872. + {
  18873. + .name = "booter",
  18874. + .offset = 0,
  18875. + .size = (256 * 1024),
  18876. + .mask_flags = MTD_WRITEABLE,
  18877. + },
  18878. + {
  18879. + .name = "kernel",
  18880. + .offset = (256 * 1024),
  18881. + .size = (4 * 1024 * 1024) - (256 * 1024),
  18882. + },
  18883. + {
  18884. + .name = "rootfs",
  18885. + .offset = MTDPART_OFS_NXTBLK,
  18886. + .size = MTDPART_SIZ_FULL,
  18887. + },
  18888. +};
  18889. +
  18890. +static struct gpio_led rbsxtlite_leds_gpio[] __initdata = {
  18891. + {
  18892. + .name = "rb:green:user",
  18893. + .gpio = SXTLITE_GPIO_LED_USER,
  18894. + .active_low = 1,
  18895. + },
  18896. + {
  18897. + .name = "rb:green:led1",
  18898. + .gpio = SXTLITE_GPIO_LED_1,
  18899. + .active_low = 1,
  18900. + },
  18901. + {
  18902. + .name = "rb:green:led2",
  18903. + .gpio = SXTLITE_GPIO_LED_2,
  18904. + .active_low = 1,
  18905. + },
  18906. + {
  18907. + .name = "rb:green:led3",
  18908. + .gpio = SXTLITE_GPIO_LED_3,
  18909. + .active_low = 1,
  18910. + },
  18911. + {
  18912. + .name = "rb:green:led4",
  18913. + .gpio = SXTLITE_GPIO_LED_4,
  18914. + .active_low = 1,
  18915. + },
  18916. + {
  18917. + .name = "rb:green:led5",
  18918. + .gpio = SXTLITE_GPIO_LED_5,
  18919. + .active_low = 1,
  18920. + },
  18921. + {
  18922. + .name = "rb:green:power",
  18923. + .gpio = SXTLITE_GPIO_LED_POWER,
  18924. + },
  18925. +};
  18926. +
  18927. +static struct gpio_keys_button rbsxtlite_gpio_keys[] __initdata = {
  18928. + {
  18929. + .desc = "Reset button",
  18930. + .type = EV_KEY,
  18931. + .code = KEY_RESTART,
  18932. + .debounce_interval = SXTLITE_KEYS_DEBOUNCE_INTERVAL,
  18933. + .gpio = SXTLITE_GPIO_BTN_RESET,
  18934. + .active_low = 0,
  18935. + },
  18936. +};
  18937. +
  18938. +static int __init rbsxtlite_rbinfo_init(void)
  18939. +{
  18940. + const struct rb_info *info;
  18941. +
  18942. + info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x10000);
  18943. + if (!info)
  18944. + return -EINVAL;
  18945. + return 0;
  18946. +
  18947. +}
  18948. +
  18949. +void __init rbsxtlite_wlan_init(void)
  18950. +{
  18951. + char *art_buf;
  18952. + u8 wlan_mac[ETH_ALEN];
  18953. +
  18954. + art_buf = rb_get_wlan_data();
  18955. + if (art_buf == NULL)
  18956. + return;
  18957. +
  18958. + ath79_init_mac(wlan_mac, ath79_mac_base, 1);
  18959. + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
  18960. +
  18961. + kfree(art_buf);
  18962. +}
  18963. +
  18964. +static void rbsxtlite_nand_select_chip(int chip_no)
  18965. +{
  18966. + switch (chip_no) {
  18967. + case 0:
  18968. + gpio_set_value(SXTLITE_GPIO_NAND_NCE, 0);
  18969. + break;
  18970. + default:
  18971. + gpio_set_value(SXTLITE_GPIO_NAND_NCE, 1);
  18972. + break;
  18973. + }
  18974. + ndelay(500);
  18975. +}
  18976. +
  18977. +static struct nand_ecclayout rbsxtlite_nand_ecclayout = {
  18978. + .eccbytes = 6,
  18979. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  18980. + .oobavail = 9,
  18981. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  18982. +};
  18983. +
  18984. +static int rbsxtlite_nand_scan_fixup(struct mtd_info *mtd)
  18985. +{
  18986. + struct nand_chip *chip = mtd->priv;
  18987. +
  18988. + if (mtd->writesize == 512) {
  18989. + /*
  18990. + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
  18991. + * will not be able to find the kernel that we load.
  18992. + */
  18993. + chip->ecc.layout = &rbsxtlite_nand_ecclayout;
  18994. + }
  18995. +
  18996. + return 0;
  18997. +}
  18998. +
  18999. +void __init rbsxtlite_gpio_init(void)
  19000. +{
  19001. + gpio_request_one(SXTLITE_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
  19002. +}
  19003. +
  19004. +void __init rbsxtlite_nand_init(void)
  19005. +{
  19006. + ath79_nfc_set_scan_fixup(rbsxtlite_nand_scan_fixup);
  19007. + ath79_nfc_set_parts(rbsxtlite_nand_partitions,
  19008. + ARRAY_SIZE(rbsxtlite_nand_partitions));
  19009. + ath79_nfc_set_select_chip(rbsxtlite_nand_select_chip);
  19010. + ath79_nfc_set_swap_dma(true);
  19011. + ath79_register_nfc();
  19012. +}
  19013. +
  19014. +
  19015. +static void __init rbsxtlite_setup(void)
  19016. +{
  19017. + if(rbsxtlite_rbinfo_init())
  19018. + return;
  19019. + rbsxtlite_nand_init();
  19020. + rbsxtlite_wlan_init();
  19021. +
  19022. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rbsxtlite_leds_gpio),
  19023. + rbsxtlite_leds_gpio);
  19024. + ath79_register_gpio_keys_polled(-1, SXTLITE_KEYS_POLL_INTERVAL,
  19025. + ARRAY_SIZE(rbsxtlite_gpio_keys),
  19026. + rbsxtlite_gpio_keys);
  19027. +
  19028. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  19029. +
  19030. + ath79_register_mdio(1, 0x0);
  19031. +
  19032. + /* GMAC0 is left unused */
  19033. +
  19034. + /* GMAC1 is connected to MAC0 on the internal switch */
  19035. + /* The ethernet port connects to PHY P0, which connects to MAC1
  19036. + on the internal switch */
  19037. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
  19038. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  19039. + ath79_register_eth(1);
  19040. +
  19041. +
  19042. +}
  19043. +
  19044. +
  19045. +MIPS_MACHINE(ATH79_MACH_RB_SXTLITE2ND, "sxt2n", "Mikrotik RouterBOARD SXT Lite2",
  19046. + rbsxtlite_setup);
  19047. +
  19048. +MIPS_MACHINE(ATH79_MACH_RB_SXTLITE5ND, "sxt5n", "Mikrotik RouterBOARD SXT Lite5",
  19049. + rbsxtlite_setup);
  19050. +
  19051. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-rw2458n.c linux-4.1.13/arch/mips/ath79/mach-rw2458n.c
  19052. --- linux-4.1.13.orig/arch/mips/ath79/mach-rw2458n.c 1970-01-01 01:00:00.000000000 +0100
  19053. +++ linux-4.1.13/arch/mips/ath79/mach-rw2458n.c 2015-09-13 20:04:35.068524086 +0200
  19054. @@ -0,0 +1,91 @@
  19055. +/*
  19056. + * Redwave RW2458N support
  19057. + *
  19058. + * Copyright (C) 2011-2013 Cezary Jackiewicz <cezary@eko.one.pl>
  19059. + *
  19060. + * This program is free software; you can redistribute it and/or modify it
  19061. + * under the terms of the GNU General Public License version 2 as published
  19062. + * by the Free Software Foundation.
  19063. + */
  19064. +
  19065. +#include <asm/mach-ath79/ath79.h>
  19066. +
  19067. +#include "dev-eth.h"
  19068. +#include "dev-ap9x-pci.h"
  19069. +#include "dev-gpio-buttons.h"
  19070. +#include "dev-leds-gpio.h"
  19071. +#include "dev-m25p80.h"
  19072. +#include "dev-usb.h"
  19073. +#include "machtypes.h"
  19074. +#include "pci.h"
  19075. +
  19076. +#define RW2458N_GPIO_LED_D3 1
  19077. +#define RW2458N_GPIO_LED_D4 0
  19078. +#define RW2458N_GPIO_LED_D5 11
  19079. +#define RW2458N_GPIO_LED_D6 7
  19080. +#define RW2458N_GPIO_BTN_RESET 12
  19081. +
  19082. +#define RW2458N_KEYS_POLL_INTERVAL 20 /* msecs */
  19083. +#define RW2458N_KEYS_DEBOUNCE_INTERVAL (3 * RW2458N_KEYS_POLL_INTERVAL)
  19084. +
  19085. +static struct gpio_keys_button rw2458n_gpio_keys[] __initdata = {
  19086. + {
  19087. + .desc = "reset",
  19088. + .type = EV_KEY,
  19089. + .code = KEY_RESTART,
  19090. + .debounce_interval = RW2458N_KEYS_DEBOUNCE_INTERVAL,
  19091. + .gpio = RW2458N_GPIO_BTN_RESET,
  19092. + .active_low = 1,
  19093. + }
  19094. +};
  19095. +
  19096. +#define RW2458N_WAN_PHYMASK BIT(4)
  19097. +
  19098. +static struct gpio_led rw2458n_leds_gpio[] __initdata = {
  19099. + {
  19100. + .name = "rw2458n:green:d3",
  19101. + .gpio = RW2458N_GPIO_LED_D3,
  19102. + .active_low = 1,
  19103. + }, {
  19104. + .name = "rw2458n:green:d4",
  19105. + .gpio = RW2458N_GPIO_LED_D4,
  19106. + .active_low = 1,
  19107. + }, {
  19108. + .name = "rw2458n:green:d5",
  19109. + .gpio = RW2458N_GPIO_LED_D5,
  19110. + .active_low = 1,
  19111. + }, {
  19112. + .name = "rw2458n:green:d6",
  19113. + .gpio = RW2458N_GPIO_LED_D6,
  19114. + .active_low = 1,
  19115. + }
  19116. +};
  19117. +
  19118. +static void __init rw2458n_setup(void)
  19119. +{
  19120. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  19121. + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  19122. +
  19123. + ath79_register_m25p80(NULL);
  19124. +
  19125. + ath79_register_mdio(0, ~RW2458N_WAN_PHYMASK);
  19126. +
  19127. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  19128. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  19129. +
  19130. + ath79_register_eth(0);
  19131. + ath79_register_eth(1);
  19132. +
  19133. + ath79_register_leds_gpio(-1, ARRAY_SIZE(rw2458n_leds_gpio),
  19134. + rw2458n_leds_gpio);
  19135. +
  19136. + ath79_register_gpio_keys_polled(-1, RW2458N_KEYS_POLL_INTERVAL,
  19137. + ARRAY_SIZE(rw2458n_gpio_keys),
  19138. + rw2458n_gpio_keys);
  19139. + ath79_register_usb();
  19140. +
  19141. + ath79_register_pci();
  19142. +}
  19143. +
  19144. +MIPS_MACHINE(ATH79_MACH_RW2458N, "RW2458N", "Redwave RW2458N",
  19145. + rw2458n_setup);
  19146. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-smart-300.c linux-4.1.13/arch/mips/ath79/mach-smart-300.c
  19147. --- linux-4.1.13.orig/arch/mips/ath79/mach-smart-300.c 1970-01-01 01:00:00.000000000 +0100
  19148. +++ linux-4.1.13/arch/mips/ath79/mach-smart-300.c 2015-09-13 20:04:35.068524086 +0200
  19149. @@ -0,0 +1,135 @@
  19150. +/*
  19151. + * NC-LINK SMART-300 board support
  19152. + *
  19153. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  19154. + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  19155. + *
  19156. + * This program is free software; you can redistribute it and/or modify it
  19157. + * under the terms of the GNU General Public License version 2 as published
  19158. + * by the Free Software Foundation.
  19159. + */
  19160. +
  19161. +#include <linux/platform_device.h>
  19162. +#include <linux/gpio.h>
  19163. +#include <asm/mach-ath79/ath79.h>
  19164. +#include <asm/mach-ath79/ar71xx_regs.h>
  19165. +#include <asm/mach-ath79/ag71xx_platform.h>
  19166. +
  19167. +#include "common.h"
  19168. +#include "dev-eth.h"
  19169. +#include "dev-gpio-buttons.h"
  19170. +#include "dev-leds-gpio.h"
  19171. +#include "dev-m25p80.h"
  19172. +#include "dev-wmac.h"
  19173. +#include "machtypes.h"
  19174. +
  19175. +#define SMART_300_GPIO_LED_WLAN 13
  19176. +#define SMART_300_GPIO_LED_WAN 18
  19177. +#define SMART_300_GPIO_LED_LAN4 19
  19178. +#define SMART_300_GPIO_LED_LAN3 12
  19179. +#define SMART_300_GPIO_LED_LAN2 21
  19180. +#define SMART_300_GPIO_LED_LAN1 20
  19181. +#define SMART_300_GPIO_LED_SYSTEM 15
  19182. +#define SMART_300_GPIO_LED_POWER 14
  19183. +
  19184. +#define SMART_300_GPIO_BTN_RESET 17
  19185. +#define SMART_300_GPIO_SW_RFKILL 16
  19186. +
  19187. +#define SMART_300_KEYS_POLL_INTERVAL 20 /* msecs */
  19188. +#define SMART_300_KEYS_DEBOUNCE_INTERVAL (3 * SMART_300_KEYS_POLL_INTERVAL)
  19189. +
  19190. +#define SMART_300_GPIO_MASK 0x007fffff
  19191. +
  19192. +static const char *smart_300_part_probes[] = {
  19193. + "tp-link",
  19194. + NULL,
  19195. +};
  19196. +
  19197. +static struct flash_platform_data smart_300_flash_data = {
  19198. + .part_probes = smart_300_part_probes,
  19199. +};
  19200. +
  19201. +static struct gpio_led smart_300_leds_gpio[] __initdata = {
  19202. + {
  19203. + .name = "nc-link:green:lan1",
  19204. + .gpio = SMART_300_GPIO_LED_LAN1,
  19205. + .active_low = 1,
  19206. + }, {
  19207. + .name = "nc-link:green:lan2",
  19208. + .gpio = SMART_300_GPIO_LED_LAN2,
  19209. + .active_low = 1,
  19210. + }, {
  19211. + .name = "nc-link:green:lan3",
  19212. + .gpio = SMART_300_GPIO_LED_LAN3,
  19213. + .active_low = 1,
  19214. + }, {
  19215. + .name = "nc-link:green:lan4",
  19216. + .gpio = SMART_300_GPIO_LED_LAN4,
  19217. + .active_low = 1,
  19218. + }, {
  19219. + .name = "nc-link:green:system",
  19220. + .gpio = SMART_300_GPIO_LED_SYSTEM,
  19221. + .active_low = 1,
  19222. + }, {
  19223. + .name = "nc-link:green:wan",
  19224. + .gpio = SMART_300_GPIO_LED_WAN,
  19225. + .active_low = 1,
  19226. + }, {
  19227. + .name = "nc-link:green:wlan",
  19228. + .gpio = SMART_300_GPIO_LED_WLAN,
  19229. + .active_low = 1,
  19230. + },
  19231. +};
  19232. +
  19233. +static struct gpio_keys_button smart_300_gpio_keys[] __initdata = {
  19234. + {
  19235. + .desc = "reset",
  19236. + .type = EV_KEY,
  19237. + .code = KEY_RESTART,
  19238. + .debounce_interval = SMART_300_KEYS_DEBOUNCE_INTERVAL,
  19239. + .gpio = SMART_300_GPIO_BTN_RESET,
  19240. + .active_low = 1,
  19241. + }
  19242. +};
  19243. +
  19244. +static void __init smart_300_setup(void)
  19245. +{
  19246. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  19247. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  19248. +
  19249. + ath79_register_leds_gpio(-1, ARRAY_SIZE(smart_300_leds_gpio),
  19250. + smart_300_leds_gpio);
  19251. +
  19252. + ath79_register_gpio_keys_polled(1, SMART_300_KEYS_POLL_INTERVAL,
  19253. + ARRAY_SIZE(smart_300_gpio_keys),
  19254. + smart_300_gpio_keys);
  19255. +
  19256. + ath79_register_m25p80(&smart_300_flash_data);
  19257. +
  19258. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  19259. +
  19260. + ath79_register_mdio(1, 0x0);
  19261. +
  19262. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  19263. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  19264. +
  19265. + /* GMAC0 is connected to the PHY0 of the internal switch */
  19266. + ath79_switch_data.phy4_mii_en = 1;
  19267. + ath79_switch_data.phy_poll_mask = BIT(4);
  19268. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  19269. + ath79_eth0_data.phy_mask = BIT(4);
  19270. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  19271. + ath79_register_eth(0);
  19272. +
  19273. + /* GMAC1 is connected to the internal switch */
  19274. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  19275. + ath79_register_eth(1);
  19276. +
  19277. + ath79_register_wmac(ee, mac);
  19278. +
  19279. + gpio_request(SMART_300_GPIO_LED_POWER, "power");
  19280. + gpio_direction_output(SMART_300_GPIO_LED_POWER, GPIOF_OUT_INIT_LOW);
  19281. +}
  19282. +
  19283. +MIPS_MACHINE(ATH79_MACH_SMART_300, "SMART-300", "NC-LINK SMART-300",
  19284. + smart_300_setup);
  19285. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tew-632brp.c linux-4.1.13/arch/mips/ath79/mach-tew-632brp.c
  19286. --- linux-4.1.13.orig/arch/mips/ath79/mach-tew-632brp.c 1970-01-01 01:00:00.000000000 +0100
  19287. +++ linux-4.1.13/arch/mips/ath79/mach-tew-632brp.c 2015-09-13 20:04:35.068524086 +0200
  19288. @@ -0,0 +1,111 @@
  19289. +/*
  19290. + * TrendNET TEW-632BRP board support
  19291. + *
  19292. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  19293. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  19294. + *
  19295. + * This program is free software; you can redistribute it and/or modify it
  19296. + * under the terms of the GNU General Public License version 2 as published
  19297. + * by the Free Software Foundation.
  19298. + */
  19299. +
  19300. +#include <asm/mach-ath79/ath79.h>
  19301. +
  19302. +#include "dev-eth.h"
  19303. +#include "dev-gpio-buttons.h"
  19304. +#include "dev-leds-gpio.h"
  19305. +#include "dev-m25p80.h"
  19306. +#include "dev-wmac.h"
  19307. +#include "machtypes.h"
  19308. +#include "nvram.h"
  19309. +
  19310. +#define TEW_632BRP_GPIO_LED_STATUS 1
  19311. +#define TEW_632BRP_GPIO_LED_WPS 3
  19312. +#define TEW_632BRP_GPIO_LED_WLAN 6
  19313. +#define TEW_632BRP_GPIO_BTN_WPS 12
  19314. +#define TEW_632BRP_GPIO_BTN_RESET 21
  19315. +
  19316. +#define TEW_632BRP_KEYS_POLL_INTERVAL 20 /* msecs */
  19317. +#define TEW_632BRP_KEYS_DEBOUNCE_INTERVAL (3 * TEW_632BRP_KEYS_POLL_INTERVAL)
  19318. +
  19319. +#define TEW_632BRP_CONFIG_ADDR 0x1f020000
  19320. +#define TEW_632BRP_CONFIG_SIZE 0x10000
  19321. +
  19322. +static struct gpio_led tew_632brp_leds_gpio[] __initdata = {
  19323. + {
  19324. + .name = "tew-632brp:green:status",
  19325. + .gpio = TEW_632BRP_GPIO_LED_STATUS,
  19326. + .active_low = 1,
  19327. + }, {
  19328. + .name = "tew-632brp:blue:wps",
  19329. + .gpio = TEW_632BRP_GPIO_LED_WPS,
  19330. + .active_low = 1,
  19331. + }, {
  19332. + .name = "tew-632brp:green:wlan",
  19333. + .gpio = TEW_632BRP_GPIO_LED_WLAN,
  19334. + .active_low = 1,
  19335. + }
  19336. +};
  19337. +
  19338. +static struct gpio_keys_button tew_632brp_gpio_keys[] __initdata = {
  19339. + {
  19340. + .desc = "reset",
  19341. + .type = EV_KEY,
  19342. + .code = KEY_RESTART,
  19343. + .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
  19344. + .gpio = TEW_632BRP_GPIO_BTN_RESET,
  19345. + .active_low = 1,
  19346. + }, {
  19347. + .desc = "wps",
  19348. + .type = EV_KEY,
  19349. + .code = KEY_WPS_BUTTON,
  19350. + .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
  19351. + .gpio = TEW_632BRP_GPIO_BTN_WPS,
  19352. + .active_low = 1,
  19353. + }
  19354. +};
  19355. +
  19356. +#define TEW_632BRP_LAN_PHYMASK BIT(0)
  19357. +#define TEW_632BRP_WAN_PHYMASK BIT(4)
  19358. +#define TEW_632BRP_MDIO_MASK (~(TEW_632BRP_LAN_PHYMASK | \
  19359. + TEW_632BRP_WAN_PHYMASK))
  19360. +
  19361. +static void __init tew_632brp_setup(void)
  19362. +{
  19363. + const char *config = (char *) KSEG1ADDR(TEW_632BRP_CONFIG_ADDR);
  19364. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  19365. + u8 mac[6];
  19366. + u8 *wlan_mac = NULL;
  19367. +
  19368. + if (ath79_nvram_parse_mac_addr(config, TEW_632BRP_CONFIG_SIZE,
  19369. + "lan_mac=", mac) == 0) {
  19370. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  19371. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  19372. + wlan_mac = mac;
  19373. + }
  19374. +
  19375. + ath79_register_mdio(0, TEW_632BRP_MDIO_MASK);
  19376. +
  19377. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  19378. + ath79_eth0_data.phy_mask = TEW_632BRP_LAN_PHYMASK;
  19379. +
  19380. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  19381. + ath79_eth1_data.phy_mask = TEW_632BRP_WAN_PHYMASK;
  19382. +
  19383. + ath79_register_eth(0);
  19384. + ath79_register_eth(1);
  19385. +
  19386. + ath79_register_m25p80(NULL);
  19387. +
  19388. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_632brp_leds_gpio),
  19389. + tew_632brp_leds_gpio);
  19390. +
  19391. + ath79_register_gpio_keys_polled(-1, TEW_632BRP_KEYS_POLL_INTERVAL,
  19392. + ARRAY_SIZE(tew_632brp_gpio_keys),
  19393. + tew_632brp_gpio_keys);
  19394. +
  19395. + ath79_register_wmac(eeprom, wlan_mac);
  19396. +}
  19397. +
  19398. +MIPS_MACHINE(ATH79_MACH_TEW_632BRP, "TEW-632BRP", "TRENDnet TEW-632BRP",
  19399. + tew_632brp_setup);
  19400. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tew-673gru.c linux-4.1.13/arch/mips/ath79/mach-tew-673gru.c
  19401. --- linux-4.1.13.orig/arch/mips/ath79/mach-tew-673gru.c 1970-01-01 01:00:00.000000000 +0100
  19402. +++ linux-4.1.13/arch/mips/ath79/mach-tew-673gru.c 2015-09-13 20:04:35.072523889 +0200
  19403. @@ -0,0 +1,198 @@
  19404. +/*
  19405. + * TRENDnet TEW-673GRU board support
  19406. + *
  19407. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  19408. + *
  19409. + * This program is free software; you can redistribute it and/or modify it
  19410. + * under the terms of the GNU General Public License version 2 as published
  19411. + * by the Free Software Foundation.
  19412. + */
  19413. +
  19414. +#include <linux/platform_device.h>
  19415. +#include <linux/delay.h>
  19416. +#include <linux/rtl8366.h>
  19417. +#include <linux/spi/spi.h>
  19418. +#include <linux/spi/spi_gpio.h>
  19419. +
  19420. +#include <asm/mach-ath79/ath79.h>
  19421. +
  19422. +#include "dev-ap9x-pci.h"
  19423. +#include "dev-eth.h"
  19424. +#include "dev-gpio-buttons.h"
  19425. +#include "dev-leds-gpio.h"
  19426. +#include "dev-m25p80.h"
  19427. +#include "dev-usb.h"
  19428. +#include "machtypes.h"
  19429. +
  19430. +#define TEW673GRU_GPIO_LCD_SCK 0
  19431. +#define TEW673GRU_GPIO_LCD_MOSI 1
  19432. +#define TEW673GRU_GPIO_LCD_MISO 2
  19433. +#define TEW673GRU_GPIO_LCD_CS 6
  19434. +
  19435. +#define TEW673GRU_GPIO_LED_WPS 9
  19436. +
  19437. +#define TEW673GRU_GPIO_BTN_RESET 3
  19438. +#define TEW673GRU_GPIO_BTN_WPS 8
  19439. +
  19440. +#define TEW673GRU_GPIO_RTL8366_SDA 5
  19441. +#define TEW673GRU_GPIO_RTL8366_SCK 7
  19442. +
  19443. +#define TEW673GRU_KEYS_POLL_INTERVAL 20 /* msecs */
  19444. +#define TEW673GRU_KEYS_DEBOUNCE_INTERVAL (3 * TEW673GRU_KEYS_POLL_INTERVAL)
  19445. +
  19446. +#define TEW673GRU_CAL0_OFFSET 0x1000
  19447. +#define TEW673GRU_CAL1_OFFSET 0x5000
  19448. +#define TEW673GRU_MAC0_OFFSET 0xffa0
  19449. +#define TEW673GRU_MAC1_OFFSET 0xffb4
  19450. +
  19451. +#define TEW673GRU_CAL_LOCATION_0 0x1f660000
  19452. +#define TEW673GRU_CAL_LOCATION_1 0x1f7f0000
  19453. +
  19454. +static struct gpio_led tew673gru_leds_gpio[] __initdata = {
  19455. + {
  19456. + .name = "trendnet:blue:wps",
  19457. + .gpio = TEW673GRU_GPIO_LED_WPS,
  19458. + .active_low = 1,
  19459. + }
  19460. +};
  19461. +
  19462. +static struct gpio_keys_button tew673gru_gpio_keys[] __initdata = {
  19463. + {
  19464. + .desc = "reset",
  19465. + .type = EV_KEY,
  19466. + .code = KEY_RESTART,
  19467. + .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
  19468. + .gpio = TEW673GRU_GPIO_BTN_RESET,
  19469. + .active_low = 1,
  19470. + }, {
  19471. + .desc = "wps",
  19472. + .type = EV_KEY,
  19473. + .code = KEY_WPS_BUTTON,
  19474. + .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
  19475. + .gpio = TEW673GRU_GPIO_BTN_WPS,
  19476. + .active_low = 1,
  19477. + }
  19478. +};
  19479. +
  19480. +static struct rtl8366_initval tew673gru_rtl8366s_initvals[] = {
  19481. + { .reg = 0x06, .val = 0x0108 },
  19482. +};
  19483. +
  19484. +static struct rtl8366_platform_data tew673gru_rtl8366s_data = {
  19485. + .gpio_sda = TEW673GRU_GPIO_RTL8366_SDA,
  19486. + .gpio_sck = TEW673GRU_GPIO_RTL8366_SCK,
  19487. + .num_initvals = ARRAY_SIZE(tew673gru_rtl8366s_initvals),
  19488. + .initvals = tew673gru_rtl8366s_initvals,
  19489. +};
  19490. +
  19491. +static struct platform_device tew673gru_rtl8366s_device = {
  19492. + .name = RTL8366S_DRIVER_NAME,
  19493. + .id = -1,
  19494. + .dev = {
  19495. + .platform_data = &tew673gru_rtl8366s_data,
  19496. + }
  19497. +};
  19498. +
  19499. +static struct spi_board_info tew673gru_spi_info[] = {
  19500. + {
  19501. + .bus_num = 1,
  19502. + .chip_select = 0,
  19503. + .max_speed_hz = 400000,
  19504. + .modalias = "spidev",
  19505. + .mode = SPI_MODE_2,
  19506. + .controller_data = (void *) TEW673GRU_GPIO_LCD_CS,
  19507. + },
  19508. +};
  19509. +
  19510. +static struct spi_gpio_platform_data tew673gru_spi_data = {
  19511. + .sck = TEW673GRU_GPIO_LCD_SCK,
  19512. + .miso = TEW673GRU_GPIO_LCD_MISO,
  19513. + .mosi = TEW673GRU_GPIO_LCD_MOSI,
  19514. + .num_chipselect = 1,
  19515. +};
  19516. +
  19517. +static struct platform_device tew673gru_spi_device = {
  19518. + .name = "spi_gpio",
  19519. + .id = 1,
  19520. + .dev = {
  19521. + .platform_data = &tew673gru_spi_data,
  19522. + },
  19523. +};
  19524. +
  19525. +static bool __init tew673gru_is_caldata_valid(u8 *p)
  19526. +{
  19527. + u16 *magic0, *magic1;
  19528. +
  19529. + magic0 = (u16 *)(p + TEW673GRU_CAL0_OFFSET);
  19530. + magic1 = (u16 *)(p + TEW673GRU_CAL1_OFFSET);
  19531. +
  19532. + return (*magic0 == 0xa55a && *magic1 == 0xa55a);
  19533. +}
  19534. +
  19535. +static void __init tew673gru_wlan_init(void)
  19536. +{
  19537. + u8 mac1[ETH_ALEN], mac2[ETH_ALEN];
  19538. + u8 *caldata;
  19539. +
  19540. + caldata = (u8 *) KSEG1ADDR(TEW673GRU_CAL_LOCATION_0);
  19541. + if (!tew673gru_is_caldata_valid(caldata)) {
  19542. + caldata = (u8 *)KSEG1ADDR(TEW673GRU_CAL_LOCATION_1);
  19543. + if (!tew673gru_is_caldata_valid(caldata)) {
  19544. + pr_err("no calibration data found\n");
  19545. + return;
  19546. + }
  19547. + }
  19548. +
  19549. + ath79_parse_ascii_mac(caldata + TEW673GRU_MAC0_OFFSET, mac1);
  19550. + ath79_parse_ascii_mac(caldata + TEW673GRU_MAC1_OFFSET, mac2);
  19551. +
  19552. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 2);
  19553. + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 3);
  19554. +
  19555. + ap9x_pci_setup_wmac_led_pin(0, 5);
  19556. + ap9x_pci_setup_wmac_led_pin(1, 5);
  19557. +
  19558. + ap94_pci_init(caldata + TEW673GRU_CAL0_OFFSET, mac1,
  19559. + caldata + TEW673GRU_CAL1_OFFSET, mac2);
  19560. +}
  19561. +
  19562. +static void __init tew673gru_setup(void)
  19563. +{
  19564. + tew673gru_wlan_init();
  19565. +
  19566. + ath79_register_mdio(0, 0x0);
  19567. +
  19568. + ath79_eth0_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
  19569. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  19570. + ath79_eth0_data.speed = SPEED_1000;
  19571. + ath79_eth0_data.duplex = DUPLEX_FULL;
  19572. + ath79_eth0_pll_data.pll_1000 = 0x11110000;
  19573. +
  19574. + ath79_eth1_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
  19575. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  19576. + ath79_eth1_data.phy_mask = 0x10;
  19577. + ath79_eth1_pll_data.pll_1000 = 0x11110000;
  19578. +
  19579. + ath79_register_eth(0);
  19580. + ath79_register_eth(1);
  19581. +
  19582. + ath79_register_m25p80(NULL);
  19583. +
  19584. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew673gru_leds_gpio),
  19585. + tew673gru_leds_gpio);
  19586. +
  19587. + ath79_register_gpio_keys_polled(-1, TEW673GRU_KEYS_POLL_INTERVAL,
  19588. + ARRAY_SIZE(tew673gru_gpio_keys),
  19589. + tew673gru_gpio_keys);
  19590. +
  19591. + ath79_register_usb();
  19592. +
  19593. + platform_device_register(&tew673gru_rtl8366s_device);
  19594. +
  19595. + spi_register_board_info(tew673gru_spi_info,
  19596. + ARRAY_SIZE(tew673gru_spi_info));
  19597. + platform_device_register(&tew673gru_spi_device);
  19598. +}
  19599. +
  19600. +MIPS_MACHINE(ATH79_MACH_TEW_673GRU, "TEW-673GRU", "TRENDnet TEW-673GRU",
  19601. + tew673gru_setup);
  19602. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tew-712br.c linux-4.1.13/arch/mips/ath79/mach-tew-712br.c
  19603. --- linux-4.1.13.orig/arch/mips/ath79/mach-tew-712br.c 1970-01-01 01:00:00.000000000 +0100
  19604. +++ linux-4.1.13/arch/mips/ath79/mach-tew-712br.c 2015-09-13 20:04:35.072523889 +0200
  19605. @@ -0,0 +1,153 @@
  19606. +/*
  19607. + * TRENDnet TEW-712BR board support
  19608. + *
  19609. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  19610. + *
  19611. + * This program is free software; you can redistribute it and/or modify it
  19612. + * under the terms of the GNU General Public License version 2 as published
  19613. + * by the Free Software Foundation.
  19614. + */
  19615. +
  19616. +#include <linux/gpio.h>
  19617. +
  19618. +#include <asm/mach-ath79/ath79.h>
  19619. +#include <asm/mach-ath79/ar71xx_regs.h>
  19620. +
  19621. +#include "common.h"
  19622. +#include "dev-eth.h"
  19623. +#include "dev-gpio-buttons.h"
  19624. +#include "dev-leds-gpio.h"
  19625. +#include "dev-m25p80.h"
  19626. +#include "dev-wmac.h"
  19627. +#include "machtypes.h"
  19628. +
  19629. +#define TEW_712BR_GPIO_BTN_WPS 11
  19630. +#define TEW_712BR_GPIO_BTN_RESET 12
  19631. +
  19632. +#define TEW_712BR_GPIO_LED_LAN1 13
  19633. +#define TEW_712BR_GPIO_LED_LAN2 14
  19634. +#define TEW_712BR_GPIO_LED_LAN3 15
  19635. +#define TEW_712BR_GPIO_LED_LAN4 16
  19636. +#define TEW_712BR_GPIO_LED_POWER_GREEN 20
  19637. +#define TEW_712BR_GPIO_LED_POWER_ORANGE 27
  19638. +#define TEW_712BR_GPIO_LED_WAN_GREEN 17
  19639. +#define TEW_712BR_GPIO_LED_WAN_ORANGE 23
  19640. +#define TEW_712BR_GPIO_LED_WLAN 0
  19641. +#define TEW_712BR_GPIO_LED_WPS 26
  19642. +
  19643. +#define TEW_712BR_GPIO_WAN_LED_ENABLE 1
  19644. +
  19645. +#define TEW_712BR_KEYS_POLL_INTERVAL 20 /* msecs */
  19646. +#define TEW_712BR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_712BR_KEYS_POLL_INTERVAL)
  19647. +
  19648. +#define TEW_712BR_ART_ADDRESS 0x1f010000
  19649. +#define TEW_712BR_CALDATA_OFFSET 0x1000
  19650. +
  19651. +#define TEW_712BR_MAC_PART_ADDRESS 0x1f020000
  19652. +#define TEW_712BR_LAN_MAC_OFFSET 0x04
  19653. +#define TEW_712BR_WAN_MAC_OFFSET 0x16
  19654. +
  19655. +static struct gpio_led tew_712br_leds_gpio[] __initdata = {
  19656. + {
  19657. + .name = "trendnet:green:lan1",
  19658. + .gpio = TEW_712BR_GPIO_LED_LAN1,
  19659. + .active_low = 0,
  19660. + }, {
  19661. + .name = "trendnet:green:lan2",
  19662. + .gpio = TEW_712BR_GPIO_LED_LAN2,
  19663. + .active_low = 0,
  19664. + }, {
  19665. + .name = "trendnet:green:lan3",
  19666. + .gpio = TEW_712BR_GPIO_LED_LAN3,
  19667. + .active_low = 0,
  19668. + }, {
  19669. + .name = "trendnet:green:lan4",
  19670. + .gpio = TEW_712BR_GPIO_LED_LAN4,
  19671. + .active_low = 0,
  19672. + }, {
  19673. + .name = "trendnet:blue:wps",
  19674. + .gpio = TEW_712BR_GPIO_LED_WPS,
  19675. + .active_low = 1,
  19676. + }, {
  19677. + .name = "trendnet:green:power",
  19678. + .gpio = TEW_712BR_GPIO_LED_POWER_GREEN,
  19679. + .active_low = 0,
  19680. + }, {
  19681. + .name = "trendnet:orange:power",
  19682. + .gpio = TEW_712BR_GPIO_LED_POWER_ORANGE,
  19683. + .active_low = 0,
  19684. + }, {
  19685. + .name = "trendnet:green:wan",
  19686. + .gpio = TEW_712BR_GPIO_LED_WAN_GREEN,
  19687. + .active_low = 1,
  19688. + }, {
  19689. + .name = "trendnet:orange:wan",
  19690. + .gpio = TEW_712BR_GPIO_LED_WAN_ORANGE,
  19691. + .active_low = 0,
  19692. + }, {
  19693. + .name = "trendnet:green:wlan",
  19694. + .gpio = TEW_712BR_GPIO_LED_WLAN,
  19695. + .active_low = 0,
  19696. + },
  19697. +};
  19698. +
  19699. +static struct gpio_keys_button tew_712br_gpio_keys[] __initdata = {
  19700. + {
  19701. + .desc = "Reset button",
  19702. + .type = EV_KEY,
  19703. + .code = KEY_RESTART,
  19704. + .debounce_interval = TEW_712BR_KEYS_DEBOUNCE_INTERVAL,
  19705. + .gpio = TEW_712BR_GPIO_BTN_RESET,
  19706. + .active_low = 1,
  19707. + }, {
  19708. + .desc = "WPS button",
  19709. + .type = EV_KEY,
  19710. + .code = KEY_WPS_BUTTON,
  19711. + .debounce_interval = TEW_712BR_KEYS_DEBOUNCE_INTERVAL,
  19712. + .gpio = TEW_712BR_GPIO_BTN_WPS,
  19713. + .active_low = 1,
  19714. + }
  19715. +};
  19716. +
  19717. +static void __init tew_712br_setup(void)
  19718. +{
  19719. + u8 *art = (u8 *) KSEG1ADDR(TEW_712BR_ART_ADDRESS);
  19720. + u8 *mac = (u8 *) KSEG1ADDR(TEW_712BR_MAC_PART_ADDRESS);
  19721. + u8 lan_mac[ETH_ALEN];
  19722. + u8 wan_mac[ETH_ALEN];
  19723. +
  19724. + ath79_setup_ar933x_phy4_switch(false, false);
  19725. +
  19726. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  19727. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  19728. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  19729. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  19730. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  19731. +
  19732. + gpio_request_one(TEW_712BR_GPIO_WAN_LED_ENABLE,
  19733. + GPIOF_OUT_INIT_LOW, "WAN LED enable");
  19734. +
  19735. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_712br_leds_gpio),
  19736. + tew_712br_leds_gpio);
  19737. +
  19738. + ath79_register_gpio_keys_polled(1, TEW_712BR_KEYS_POLL_INTERVAL,
  19739. + ARRAY_SIZE(tew_712br_gpio_keys),
  19740. + tew_712br_gpio_keys);
  19741. +
  19742. + ath79_register_m25p80(NULL);
  19743. +
  19744. + ath79_parse_ascii_mac(mac + TEW_712BR_LAN_MAC_OFFSET, lan_mac);
  19745. + ath79_parse_ascii_mac(mac + TEW_712BR_WAN_MAC_OFFSET, wan_mac);
  19746. +
  19747. + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
  19748. + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  19749. +
  19750. + ath79_register_mdio(0, 0x0);
  19751. + ath79_register_eth(1);
  19752. + ath79_register_eth(0);
  19753. +
  19754. + ath79_register_wmac(art + TEW_712BR_CALDATA_OFFSET, wan_mac);
  19755. +}
  19756. +
  19757. +MIPS_MACHINE(ATH79_MACH_TEW_712BR, "TEW-712BR",
  19758. + "TRENDnet TEW-712BR", tew_712br_setup);
  19759. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tew-732br.c linux-4.1.13/arch/mips/ath79/mach-tew-732br.c
  19760. --- linux-4.1.13.orig/arch/mips/ath79/mach-tew-732br.c 1970-01-01 01:00:00.000000000 +0100
  19761. +++ linux-4.1.13/arch/mips/ath79/mach-tew-732br.c 2015-09-13 20:04:35.072523889 +0200
  19762. @@ -0,0 +1,127 @@
  19763. +/*
  19764. + * TRENDnet TEW-732BR board support
  19765. + *
  19766. + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
  19767. + *
  19768. + * This program is free software; you can redistribute it and/or modify it
  19769. + * under the terms of the GNU General Public License version 2 as published
  19770. + * by the Free Software Foundation.
  19771. + */
  19772. +
  19773. +#include <linux/gpio.h>
  19774. +#include <linux/platform_device.h>
  19775. +
  19776. +#include <asm/mach-ath79/ath79.h>
  19777. +#include <asm/mach-ath79/ar71xx_regs.h>
  19778. +
  19779. +#include "common.h"
  19780. +#include "dev-eth.h"
  19781. +#include "dev-gpio-buttons.h"
  19782. +#include "dev-leds-gpio.h"
  19783. +#include "dev-m25p80.h"
  19784. +#include "dev-wmac.h"
  19785. +#include "machtypes.h"
  19786. +
  19787. +#define TEW_732BR_GPIO_BTN_WPS 16
  19788. +#define TEW_732BR_GPIO_BTN_RESET 17
  19789. +
  19790. +#define TEW_732BR_GPIO_LED_POWER_GREEN 4
  19791. +#define TEW_732BR_GPIO_LED_POWER_AMBER 14
  19792. +#define TEW_732BR_GPIO_LED_PLANET_GREEN 12
  19793. +#define TEW_732BR_GPIO_LED_PLANET_AMBER 22
  19794. +
  19795. +#define TEW_732BR_KEYS_POLL_INTERVAL 20 /* msecs */
  19796. +#define TEW_732BR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_732BR_KEYS_POLL_INTERVAL)
  19797. +
  19798. +#define TEW_732BR_ART_ADDRESS 0x1fff0000
  19799. +#define TEW_732BR_CALDATA_OFFSET 0x1000
  19800. +#define TEW_732BR_LAN_MAC_OFFSET 0xffa0
  19801. +#define TEW_732BR_WAN_MAC_OFFSET 0xffb4
  19802. +
  19803. +static struct gpio_led tew_732br_leds_gpio[] __initdata = {
  19804. + {
  19805. + .name = "trendnet:green:power",
  19806. + .gpio = TEW_732BR_GPIO_LED_POWER_GREEN,
  19807. + .active_low = 0,
  19808. + },
  19809. + {
  19810. + .name = "trendnet:amber:power",
  19811. + .gpio = TEW_732BR_GPIO_LED_POWER_AMBER,
  19812. + .active_low = 0,
  19813. + },
  19814. + {
  19815. + .name = "trendnet:green:wan",
  19816. + .gpio = TEW_732BR_GPIO_LED_PLANET_GREEN,
  19817. + .active_low = 1,
  19818. + },
  19819. + {
  19820. + .name = "trendnet:amber:wan",
  19821. + .gpio = TEW_732BR_GPIO_LED_PLANET_AMBER,
  19822. + .active_low = 0,
  19823. + },
  19824. +};
  19825. +
  19826. +static struct gpio_keys_button tew_732br_gpio_keys[] __initdata = {
  19827. + {
  19828. + .desc = "Reset button",
  19829. + .type = EV_KEY,
  19830. + .code = KEY_RESTART,
  19831. + .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
  19832. + .gpio = TEW_732BR_GPIO_BTN_RESET,
  19833. + .active_low = 1,
  19834. + },
  19835. + {
  19836. + .desc = "WPS button",
  19837. + .type = EV_KEY,
  19838. + .code = KEY_WPS_BUTTON,
  19839. + .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
  19840. + .gpio = TEW_732BR_GPIO_BTN_WPS,
  19841. + .active_low = 1,
  19842. + },
  19843. +};
  19844. +
  19845. +static void __init tew_732br_setup(void)
  19846. +{
  19847. + u8 *art = (u8 *) KSEG1ADDR(TEW_732BR_ART_ADDRESS);
  19848. + u8 lan_mac[ETH_ALEN];
  19849. + u8 wan_mac[ETH_ALEN];
  19850. +
  19851. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_732br_leds_gpio),
  19852. + tew_732br_leds_gpio);
  19853. +
  19854. + ath79_register_gpio_keys_polled(1, TEW_732BR_KEYS_POLL_INTERVAL,
  19855. + ARRAY_SIZE(tew_732br_gpio_keys),
  19856. + tew_732br_gpio_keys);
  19857. +
  19858. + ath79_register_m25p80(NULL);
  19859. +
  19860. + ath79_parse_ascii_mac(art + TEW_732BR_LAN_MAC_OFFSET, lan_mac);
  19861. + ath79_parse_ascii_mac(art + TEW_732BR_WAN_MAC_OFFSET, wan_mac);
  19862. +
  19863. + ath79_register_wmac(art + TEW_732BR_CALDATA_OFFSET, lan_mac);
  19864. +
  19865. + ath79_register_mdio(1, 0x0);
  19866. +
  19867. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  19868. +
  19869. + /* LAN: GMAC1 is connected to the internal switch */
  19870. + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  19871. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  19872. +
  19873. + ath79_register_eth(1);
  19874. +
  19875. + /* WAN: GMAC0 is connected to the PHY4 of the internal switch */
  19876. + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
  19877. +
  19878. + ath79_switch_data.phy4_mii_en = 1;
  19879. + ath79_switch_data.phy_poll_mask = BIT(4);
  19880. +
  19881. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  19882. + ath79_eth0_data.phy_mask = BIT(4);
  19883. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  19884. +
  19885. + ath79_register_eth(0);
  19886. +}
  19887. +
  19888. +MIPS_MACHINE(ATH79_MACH_TEW_732BR, "TEW-732BR", "TRENDnet TEW-732BR",
  19889. + tew_732br_setup);
  19890. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr11u.c linux-4.1.13/arch/mips/ath79/mach-tl-mr11u.c
  19891. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr11u.c 1970-01-01 01:00:00.000000000 +0100
  19892. +++ linux-4.1.13/arch/mips/ath79/mach-tl-mr11u.c 2015-09-13 20:04:35.072523889 +0200
  19893. @@ -0,0 +1,183 @@
  19894. +/*
  19895. + * TP-LINK TL-MR11U/TL-MR3040 board support
  19896. + *
  19897. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  19898. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  19899. + *
  19900. + * This program is free software; you can redistribute it and/or modify it
  19901. + * under the terms of the GNU General Public License version 2 as published
  19902. + * by the Free Software Foundation.
  19903. + */
  19904. +
  19905. +#include <linux/gpio.h>
  19906. +
  19907. +#include <asm/mach-ath79/ath79.h>
  19908. +#include <asm/mach-ath79/ar71xx_regs.h>
  19909. +
  19910. +#include "common.h"
  19911. +#include "dev-eth.h"
  19912. +#include "dev-gpio-buttons.h"
  19913. +#include "dev-leds-gpio.h"
  19914. +#include "dev-m25p80.h"
  19915. +#include "dev-usb.h"
  19916. +#include "dev-wmac.h"
  19917. +#include "machtypes.h"
  19918. +
  19919. +#define TL_MR11U_GPIO_LED_3G 27
  19920. +#define TL_MR11U_GPIO_LED_WLAN 26
  19921. +#define TL_MR11U_GPIO_LED_LAN 17
  19922. +
  19923. +#define TL_MR11U_GPIO_BTN_WPS 20
  19924. +#define TL_MR11U_GPIO_BTN_RESET 11
  19925. +
  19926. +#define TL_MR11U_GPIO_USB_POWER 8
  19927. +#define TL_MR3040_GPIO_USB_POWER 18
  19928. +
  19929. +#define TL_MR3040_V2_GPIO_BTN_SW1 19
  19930. +#define TL_MR3040_V2_GPIO_BTN_SW2 20
  19931. +
  19932. +#define TL_MR11U_KEYS_POLL_INTERVAL 20 /* msecs */
  19933. +#define TL_MR11U_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR11U_KEYS_POLL_INTERVAL)
  19934. +
  19935. +static const char *tl_mr11u_part_probes[] = {
  19936. + "tp-link",
  19937. + NULL,
  19938. +};
  19939. +
  19940. +static struct flash_platform_data tl_mr11u_flash_data = {
  19941. + .part_probes = tl_mr11u_part_probes,
  19942. +};
  19943. +
  19944. +static struct gpio_led tl_mr11u_leds_gpio[] __initdata = {
  19945. + {
  19946. + .name = "tp-link:green:3g",
  19947. + .gpio = TL_MR11U_GPIO_LED_3G,
  19948. + .active_low = 1,
  19949. + },
  19950. + {
  19951. + .name = "tp-link:green:wlan",
  19952. + .gpio = TL_MR11U_GPIO_LED_WLAN,
  19953. + .active_low = 1,
  19954. + },
  19955. + {
  19956. + .name = "tp-link:green:lan",
  19957. + .gpio = TL_MR11U_GPIO_LED_LAN,
  19958. + .active_low = 1,
  19959. + }
  19960. +};
  19961. +
  19962. +static struct gpio_keys_button tl_mr11u_gpio_keys[] __initdata = {
  19963. + {
  19964. + .desc = "reset",
  19965. + .type = EV_KEY,
  19966. + .code = KEY_RESTART,
  19967. + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  19968. + .gpio = TL_MR11U_GPIO_BTN_RESET,
  19969. + .active_low = 0,
  19970. + },
  19971. + {
  19972. + .desc = "wps",
  19973. + .type = EV_KEY,
  19974. + .code = KEY_WPS_BUTTON,
  19975. + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  19976. + .gpio = TL_MR11U_GPIO_BTN_WPS,
  19977. + .active_low = 0,
  19978. + },
  19979. +};
  19980. +
  19981. +static struct gpio_keys_button tl_mr3040_v2_gpio_keys[] __initdata = {
  19982. + {
  19983. + .desc = "reset",
  19984. + .type = EV_KEY,
  19985. + .code = KEY_RESTART,
  19986. + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  19987. + .gpio = TL_MR11U_GPIO_BTN_RESET,
  19988. + .active_low = 0,
  19989. + },
  19990. + {
  19991. + .desc = "sw1",
  19992. + .type = EV_SW,
  19993. + .code = BTN_0,
  19994. + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  19995. + .gpio = TL_MR3040_V2_GPIO_BTN_SW1,
  19996. + .active_low = 0,
  19997. + },
  19998. + {
  19999. + .desc = "sw2",
  20000. + .type = EV_SW,
  20001. + .code = BTN_1,
  20002. + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  20003. + .gpio = TL_MR3040_V2_GPIO_BTN_SW2,
  20004. + .active_low = 0,
  20005. + }
  20006. +};
  20007. +
  20008. +static void __init common_setup(void)
  20009. +{
  20010. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20011. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20012. +
  20013. + /* Disable hardware control LAN1 and LAN2 LEDs, enabling GPIO14 and GPIO15 */
  20014. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  20015. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN);
  20016. +
  20017. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  20018. + ath79_setup_ar933x_phy4_switch(false, false);
  20019. +
  20020. + ath79_register_m25p80(&tl_mr11u_flash_data);
  20021. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr11u_leds_gpio),
  20022. + tl_mr11u_leds_gpio);
  20023. +
  20024. + ath79_register_usb();
  20025. +
  20026. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  20027. +
  20028. + ath79_register_mdio(0, 0x0);
  20029. + ath79_register_eth(0);
  20030. +
  20031. + ath79_register_wmac(ee, mac);
  20032. +}
  20033. +
  20034. +static void __init tl_mr11u_setup(void)
  20035. +{
  20036. + common_setup();
  20037. +
  20038. + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  20039. + ARRAY_SIZE(tl_mr11u_gpio_keys),
  20040. + tl_mr11u_gpio_keys);
  20041. + gpio_request_one(TL_MR11U_GPIO_USB_POWER,
  20042. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20043. + "USB power");
  20044. +}
  20045. +
  20046. +MIPS_MACHINE(ATH79_MACH_TL_MR11U, "TL-MR11U", "TP-LINK TL-MR11U",
  20047. + tl_mr11u_setup);
  20048. +
  20049. +static void __init tl_mr3040_setup(void)
  20050. +{
  20051. + common_setup();
  20052. +
  20053. + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  20054. + 1, tl_mr11u_gpio_keys);
  20055. + gpio_request_one(TL_MR3040_GPIO_USB_POWER,
  20056. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20057. + "USB power");
  20058. +}
  20059. +
  20060. +MIPS_MACHINE(ATH79_MACH_TL_MR3040, "TL-MR3040", "TP-LINK TL-MR3040",
  20061. + tl_mr3040_setup);
  20062. +
  20063. +static void __init tl_mr3040_v2_setup(void)
  20064. +{
  20065. + common_setup();
  20066. +
  20067. + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  20068. + ARRAY_SIZE(tl_mr3040_v2_gpio_keys),
  20069. + tl_mr3040_v2_gpio_keys);
  20070. + gpio_request_one(TL_MR3040_GPIO_USB_POWER,
  20071. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20072. + "USB power");
  20073. +}
  20074. +
  20075. +MIPS_MACHINE(ATH79_MACH_TL_MR3040_V2, "TL-MR3040-v2", "TP-LINK TL-MR3040 v2",
  20076. + tl_mr3040_v2_setup);
  20077. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr13u.c linux-4.1.13/arch/mips/ath79/mach-tl-mr13u.c
  20078. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr13u.c 1970-01-01 01:00:00.000000000 +0100
  20079. +++ linux-4.1.13/arch/mips/ath79/mach-tl-mr13u.c 2015-09-13 20:04:35.072523889 +0200
  20080. @@ -0,0 +1,107 @@
  20081. +/*
  20082. + * TP-LINK TL-MR13U board support
  20083. + *
  20084. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  20085. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  20086. + *
  20087. + * This program is free software; you can redistribute it and/or modify it
  20088. + * under the terms of the GNU General Public License version 2 as published
  20089. + * by the Free Software Foundation.
  20090. + */
  20091. +
  20092. +#include <linux/gpio.h>
  20093. +
  20094. +#include <asm/mach-ath79/ath79.h>
  20095. +
  20096. +#include "dev-eth.h"
  20097. +#include "dev-gpio-buttons.h"
  20098. +#include "dev-leds-gpio.h"
  20099. +#include "dev-m25p80.h"
  20100. +#include "dev-usb.h"
  20101. +#include "dev-wmac.h"
  20102. +#include "machtypes.h"
  20103. +
  20104. +#define TL_MR13U_GPIO_LED_SYSTEM 27
  20105. +
  20106. +#define TL_MR13U_GPIO_BTN_RESET 11
  20107. +#define TL_MR13U_GPIO_BTN_SW1 6
  20108. +#define TL_MR13U_GPIO_BTN_SW2 7
  20109. +
  20110. +#define TL_MR13U_GPIO_USB_POWER 18
  20111. +
  20112. +#define TL_MR13U_KEYS_POLL_INTERVAL 20 /* msecs */
  20113. +#define TL_MR13U_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR13U_KEYS_POLL_INTERVAL)
  20114. +
  20115. +static const char *tl_mr13u_part_probes[] = {
  20116. + "tp-link",
  20117. + NULL,
  20118. +};
  20119. +
  20120. +static struct flash_platform_data tl_mr13u_flash_data = {
  20121. + .part_probes = tl_mr13u_part_probes,
  20122. +};
  20123. +
  20124. +static struct gpio_led tl_mr13u_leds_gpio[] __initdata = {
  20125. + {
  20126. + .name = "tp-link:blue:system",
  20127. + .gpio = TL_MR13U_GPIO_LED_SYSTEM,
  20128. + .active_low = 0,
  20129. + },
  20130. +};
  20131. +
  20132. +static struct gpio_keys_button tl_mr13u_gpio_keys[] __initdata = {
  20133. + {
  20134. + .desc = "reset",
  20135. + .type = EV_KEY,
  20136. + .code = KEY_RESTART,
  20137. + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
  20138. + .gpio = TL_MR13U_GPIO_BTN_RESET,
  20139. + .active_low = 0,
  20140. + },
  20141. + {
  20142. + .desc = "sw1",
  20143. + .type = EV_KEY,
  20144. + .code = BTN_0,
  20145. + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
  20146. + .gpio = TL_MR13U_GPIO_BTN_SW1,
  20147. + .active_low = 0,
  20148. + },
  20149. + {
  20150. + .desc = "sw2",
  20151. + .type = EV_KEY,
  20152. + .code = BTN_1,
  20153. + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
  20154. + .gpio = TL_MR13U_GPIO_BTN_SW2,
  20155. + .active_low = 0,
  20156. + },
  20157. +};
  20158. +
  20159. +static void __init tl_mr13u_setup(void)
  20160. +{
  20161. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20162. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20163. +
  20164. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  20165. + ath79_setup_ar933x_phy4_switch(false, false);
  20166. +
  20167. + ath79_register_m25p80(&tl_mr13u_flash_data);
  20168. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr13u_leds_gpio),
  20169. + tl_mr13u_leds_gpio);
  20170. + ath79_register_gpio_keys_polled(-1, TL_MR13U_KEYS_POLL_INTERVAL,
  20171. + ARRAY_SIZE(tl_mr13u_gpio_keys),
  20172. + tl_mr13u_gpio_keys);
  20173. +
  20174. + gpio_request_one(TL_MR13U_GPIO_USB_POWER,
  20175. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20176. + "USB power");
  20177. + ath79_register_usb();
  20178. +
  20179. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  20180. +
  20181. + ath79_register_mdio(0, 0x0);
  20182. + ath79_register_eth(0);
  20183. + ath79_register_wmac(ee, mac);
  20184. +}
  20185. +
  20186. +MIPS_MACHINE(ATH79_MACH_TL_MR13U, "TL-MR13U", "TP-LINK TL-MR13U v1",
  20187. + tl_mr13u_setup);
  20188. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr3020.c linux-4.1.13/arch/mips/ath79/mach-tl-mr3020.c
  20189. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr3020.c 1970-01-01 01:00:00.000000000 +0100
  20190. +++ linux-4.1.13/arch/mips/ath79/mach-tl-mr3020.c 2015-09-13 20:04:35.072523889 +0200
  20191. @@ -0,0 +1,126 @@
  20192. +/*
  20193. + * TP-LINK TL-MR3020 board support
  20194. + *
  20195. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  20196. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  20197. + *
  20198. + * This program is free software; you can redistribute it and/or modify it
  20199. + * under the terms of the GNU General Public License version 2 as published
  20200. + * by the Free Software Foundation.
  20201. + */
  20202. +
  20203. +#include <linux/gpio.h>
  20204. +
  20205. +#include <asm/mach-ath79/ath79.h>
  20206. +#include <asm/mach-ath79/ar71xx_regs.h>
  20207. +
  20208. +#include "dev-eth.h"
  20209. +#include "dev-gpio-buttons.h"
  20210. +#include "dev-leds-gpio.h"
  20211. +#include "dev-m25p80.h"
  20212. +#include "dev-usb.h"
  20213. +#include "dev-wmac.h"
  20214. +#include "machtypes.h"
  20215. +
  20216. +#define TL_MR3020_GPIO_LED_3G 27
  20217. +#define TL_MR3020_GPIO_LED_WLAN 0
  20218. +#define TL_MR3020_GPIO_LED_LAN 17
  20219. +#define TL_MR3020_GPIO_LED_WPS 26
  20220. +
  20221. +#define TL_MR3020_GPIO_BTN_WPS 11
  20222. +#define TL_MR3020_GPIO_BTN_SW1 18
  20223. +#define TL_MR3020_GPIO_BTN_SW2 20
  20224. +
  20225. +#define TL_MR3020_GPIO_USB_POWER 8
  20226. +
  20227. +#define TL_MR3020_KEYS_POLL_INTERVAL 20 /* msecs */
  20228. +#define TL_MR3020_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3020_KEYS_POLL_INTERVAL)
  20229. +
  20230. +static const char *tl_mr3020_part_probes[] = {
  20231. + "tp-link",
  20232. + NULL,
  20233. +};
  20234. +
  20235. +static struct flash_platform_data tl_mr3020_flash_data = {
  20236. + .part_probes = tl_mr3020_part_probes,
  20237. +};
  20238. +
  20239. +static struct gpio_led tl_mr3020_leds_gpio[] __initdata = {
  20240. + {
  20241. + .name = "tp-link:green:3g",
  20242. + .gpio = TL_MR3020_GPIO_LED_3G,
  20243. + .active_low = 1,
  20244. + },
  20245. + {
  20246. + .name = "tp-link:green:wlan",
  20247. + .gpio = TL_MR3020_GPIO_LED_WLAN,
  20248. + .active_low = 0,
  20249. + },
  20250. + {
  20251. + .name = "tp-link:green:lan",
  20252. + .gpio = TL_MR3020_GPIO_LED_LAN,
  20253. + .active_low = 1,
  20254. + },
  20255. + {
  20256. + .name = "tp-link:green:wps",
  20257. + .gpio = TL_MR3020_GPIO_LED_WPS,
  20258. + .active_low = 1,
  20259. + },
  20260. +};
  20261. +
  20262. +static struct gpio_keys_button tl_mr3020_gpio_keys[] __initdata = {
  20263. + {
  20264. + .desc = "wps",
  20265. + .type = EV_KEY,
  20266. + .code = KEY_WPS_BUTTON,
  20267. + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  20268. + .gpio = TL_MR3020_GPIO_BTN_WPS,
  20269. + .active_low = 0,
  20270. + },
  20271. + {
  20272. + .desc = "sw1",
  20273. + .type = EV_KEY,
  20274. + .code = BTN_0,
  20275. + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  20276. + .gpio = TL_MR3020_GPIO_BTN_SW1,
  20277. + .active_low = 0,
  20278. + },
  20279. + {
  20280. + .desc = "sw2",
  20281. + .type = EV_KEY,
  20282. + .code = BTN_1,
  20283. + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  20284. + .gpio = TL_MR3020_GPIO_BTN_SW2,
  20285. + .active_low = 0,
  20286. + }
  20287. +};
  20288. +
  20289. +static void __init tl_mr3020_setup(void)
  20290. +{
  20291. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20292. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20293. +
  20294. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  20295. + ath79_setup_ar933x_phy4_switch(false, false);
  20296. +
  20297. + ath79_register_m25p80(&tl_mr3020_flash_data);
  20298. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3020_leds_gpio),
  20299. + tl_mr3020_leds_gpio);
  20300. + ath79_register_gpio_keys_polled(-1, TL_MR3020_KEYS_POLL_INTERVAL,
  20301. + ARRAY_SIZE(tl_mr3020_gpio_keys),
  20302. + tl_mr3020_gpio_keys);
  20303. +
  20304. + gpio_request_one(TL_MR3020_GPIO_USB_POWER,
  20305. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20306. + "USB power");
  20307. + ath79_register_usb();
  20308. +
  20309. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  20310. +
  20311. + ath79_register_mdio(0, 0x0);
  20312. + ath79_register_eth(0);
  20313. + ath79_register_wmac(ee, mac);
  20314. +}
  20315. +
  20316. +MIPS_MACHINE(ATH79_MACH_TL_MR3020, "TL-MR3020", "TP-LINK TL-MR3020",
  20317. + tl_mr3020_setup);
  20318. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr3x20.c linux-4.1.13/arch/mips/ath79/mach-tl-mr3x20.c
  20319. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-mr3x20.c 1970-01-01 01:00:00.000000000 +0100
  20320. +++ linux-4.1.13/arch/mips/ath79/mach-tl-mr3x20.c 2015-09-13 20:04:35.072523889 +0200
  20321. @@ -0,0 +1,147 @@
  20322. +/*
  20323. + * TP-LINK TL-MR3220/3420 board support
  20324. + *
  20325. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  20326. + *
  20327. + * This program is free software; you can redistribute it and/or modify it
  20328. + * under the terms of the GNU General Public License version 2 as published
  20329. + * by the Free Software Foundation.
  20330. + */
  20331. +
  20332. +#include <linux/gpio.h>
  20333. +
  20334. +#include <asm/mach-ath79/ath79.h>
  20335. +
  20336. +#include "dev-eth.h"
  20337. +#include "dev-ap9x-pci.h"
  20338. +#include "dev-gpio-buttons.h"
  20339. +#include "dev-leds-gpio.h"
  20340. +#include "dev-m25p80.h"
  20341. +#include "dev-usb.h"
  20342. +#include "machtypes.h"
  20343. +
  20344. +#define TL_MR3X20_GPIO_LED_QSS 0
  20345. +#define TL_MR3X20_GPIO_LED_SYSTEM 1
  20346. +#define TL_MR3X20_GPIO_LED_3G 8
  20347. +
  20348. +#define TL_MR3X20_GPIO_BTN_RESET 11
  20349. +#define TL_MR3X20_GPIO_BTN_QSS 12
  20350. +
  20351. +#define TL_MR3X20_GPIO_USB_POWER 6
  20352. +
  20353. +#define TL_MR3X20_KEYS_POLL_INTERVAL 20 /* msecs */
  20354. +#define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
  20355. +
  20356. +static const char *tl_mr3x20_part_probes[] = {
  20357. + "tp-link",
  20358. + NULL,
  20359. +};
  20360. +
  20361. +static struct flash_platform_data tl_mr3x20_flash_data = {
  20362. + .part_probes = tl_mr3x20_part_probes,
  20363. +};
  20364. +
  20365. +static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
  20366. + {
  20367. + .name = "tp-link:green:system",
  20368. + .gpio = TL_MR3X20_GPIO_LED_SYSTEM,
  20369. + .active_low = 1,
  20370. + }, {
  20371. + .name = "tp-link:green:qss",
  20372. + .gpio = TL_MR3X20_GPIO_LED_QSS,
  20373. + .active_low = 1,
  20374. + }, {
  20375. + .name = "tp-link:green:3g",
  20376. + .gpio = TL_MR3X20_GPIO_LED_3G,
  20377. + .active_low = 1,
  20378. + }
  20379. +};
  20380. +
  20381. +static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
  20382. + {
  20383. + .desc = "reset",
  20384. + .type = EV_KEY,
  20385. + .code = KEY_RESTART,
  20386. + .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
  20387. + .gpio = TL_MR3X20_GPIO_BTN_RESET,
  20388. + .active_low = 1,
  20389. + }, {
  20390. + .desc = "qss",
  20391. + .type = EV_KEY,
  20392. + .code = KEY_WPS_BUTTON,
  20393. + .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
  20394. + .gpio = TL_MR3X20_GPIO_BTN_QSS,
  20395. + .active_low = 1,
  20396. + }
  20397. +};
  20398. +
  20399. +static void __init tl_ap99_setup(void)
  20400. +{
  20401. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20402. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20403. +
  20404. + ath79_register_m25p80(&tl_mr3x20_flash_data);
  20405. +
  20406. + ath79_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
  20407. + ARRAY_SIZE(tl_mr3x20_gpio_keys),
  20408. + tl_mr3x20_gpio_keys);
  20409. +
  20410. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  20411. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  20412. +
  20413. + ath79_register_mdio(0, 0x0);
  20414. +
  20415. + /* LAN ports */
  20416. + ath79_register_eth(1);
  20417. + /* WAN port */
  20418. + ath79_register_eth(0);
  20419. +
  20420. + ap91_pci_init(ee, mac);
  20421. +}
  20422. +
  20423. +static void __init tl_mr3x20_usb_setup(void)
  20424. +{
  20425. + /* enable power for the USB port */
  20426. + gpio_request_one(TL_MR3X20_GPIO_USB_POWER,
  20427. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20428. + "USB power");
  20429. + ath79_register_usb();
  20430. +}
  20431. +
  20432. +static void __init tl_mr3220_setup(void)
  20433. +{
  20434. + tl_ap99_setup();
  20435. +
  20436. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
  20437. + tl_mr3x20_leds_gpio);
  20438. + ap9x_pci_setup_wmac_led_pin(0, 1);
  20439. + tl_mr3x20_usb_setup();
  20440. +}
  20441. +
  20442. +MIPS_MACHINE(ATH79_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
  20443. + tl_mr3220_setup);
  20444. +
  20445. +static void __init tl_mr3420_setup(void)
  20446. +{
  20447. + tl_ap99_setup();
  20448. +
  20449. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
  20450. + tl_mr3x20_leds_gpio);
  20451. + ap9x_pci_setup_wmac_led_pin(0, 0);
  20452. + tl_mr3x20_usb_setup();
  20453. +}
  20454. +
  20455. +MIPS_MACHINE(ATH79_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",
  20456. + tl_mr3420_setup);
  20457. +
  20458. +static void __init tl_wr841n_v7_setup(void)
  20459. +{
  20460. + tl_ap99_setup();
  20461. +
  20462. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio) - 1,
  20463. + tl_mr3x20_leds_gpio);
  20464. + ap9x_pci_setup_wmac_led_pin(0, 0);
  20465. +}
  20466. +
  20467. +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V7, "TL-WR841N-v7",
  20468. + "TP-LINK TL-WR841N/ND v7", tl_wr841n_v7_setup);
  20469. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa701nd-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wa701nd-v2.c
  20470. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa701nd-v2.c 1970-01-01 01:00:00.000000000 +0100
  20471. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wa701nd-v2.c 2015-09-13 20:04:35.072523889 +0200
  20472. @@ -0,0 +1,116 @@
  20473. +/*
  20474. + * TP-LINK TL-WA701ND v2 board support
  20475. + *
  20476. + * Copyright (C) 2015 Luigi Tarenga <luigi.tarenga@gmail.com>
  20477. + *
  20478. + * This program is free software; you can redistribute it and/or modify it
  20479. + * under the terms of the GNU General Public License version 2 as published
  20480. + * by the Free Software Foundation.
  20481. + */
  20482. +
  20483. +#include <linux/gpio.h>
  20484. +
  20485. +#include <asm/mach-ath79/ath79.h>
  20486. +
  20487. +#include "dev-eth.h"
  20488. +#include "dev-gpio-buttons.h"
  20489. +#include "dev-leds-gpio.h"
  20490. +#include "dev-m25p80.h"
  20491. +#include "dev-usb.h"
  20492. +#include "dev-wmac.h"
  20493. +#include "machtypes.h"
  20494. +
  20495. +#define TL_WA701NDV2_GPIO_LED_WLAN 0
  20496. +#define TL_WA701NDV2_GPIO_LED_QSS 1
  20497. +#define TL_WA701NDV2_GPIO_LED_LAN 17
  20498. +#define TL_WA701NDV2_GPIO_LED_SYSTEM 27
  20499. +
  20500. +#define TL_WA701NDV2_GPIO_BTN_RESET 11
  20501. +#define TL_WA701NDV2_GPIO_BTN_QSS 26
  20502. +
  20503. +#define TL_WA701NDV2_GPIO_USB_POWER 8
  20504. +
  20505. +#define TL_WA701NDV2_KEYS_POLL_INTERVAL 20 /* msecs */
  20506. +#define TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA701NDV2_KEYS_POLL_INTERVAL)
  20507. +
  20508. +static const char *tl_wa701ndv2_part_probes[] = {
  20509. + "tp-link",
  20510. + NULL,
  20511. +};
  20512. +
  20513. +static struct flash_platform_data tl_wa701ndv2_flash_data = {
  20514. + .part_probes = tl_wa701ndv2_part_probes,
  20515. +};
  20516. +
  20517. +static struct gpio_led tl_wa701ndv2_leds_gpio[] __initdata = {
  20518. + {
  20519. + .name = "tp-link:green:wlan",
  20520. + .gpio = TL_WA701NDV2_GPIO_LED_WLAN,
  20521. + .active_low = 0,
  20522. + }, {
  20523. + .name = "tp-link:green:qss",
  20524. + .gpio = TL_WA701NDV2_GPIO_LED_QSS,
  20525. + .active_low = 0,
  20526. + }, {
  20527. + .name = "tp-link:green:lan",
  20528. + .gpio = TL_WA701NDV2_GPIO_LED_LAN,
  20529. + .active_low = 1,
  20530. + }, {
  20531. + .name = "tp-link:green:system",
  20532. + .gpio = TL_WA701NDV2_GPIO_LED_SYSTEM,
  20533. + .active_low = 1,
  20534. + }
  20535. +};
  20536. +
  20537. +static struct gpio_keys_button tl_wa701ndv2_gpio_keys[] __initdata = {
  20538. + {
  20539. + .desc = "reset",
  20540. + .type = EV_KEY,
  20541. + .code = KEY_RESTART,
  20542. + .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
  20543. + .gpio = TL_WA701NDV2_GPIO_BTN_RESET,
  20544. + .active_low = 0,
  20545. + } , {
  20546. + .desc = "qss",
  20547. + .type = EV_KEY,
  20548. + .code = KEY_WPS_BUTTON,
  20549. + .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
  20550. + .gpio = TL_WA701NDV2_GPIO_BTN_QSS,
  20551. + .active_low = 0,
  20552. + }
  20553. +
  20554. +};
  20555. +
  20556. +static void __init tl_wa701ndv2_setup(void)
  20557. +{
  20558. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20559. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20560. +
  20561. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  20562. + ath79_setup_ar933x_phy4_switch(false, false);
  20563. +
  20564. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa701ndv2_leds_gpio),
  20565. + tl_wa701ndv2_leds_gpio);
  20566. +
  20567. + ath79_register_gpio_keys_polled(-1, TL_WA701NDV2_KEYS_POLL_INTERVAL,
  20568. + ARRAY_SIZE(tl_wa701ndv2_gpio_keys),
  20569. + tl_wa701ndv2_gpio_keys);
  20570. +
  20571. + gpio_request_one(TL_WA701NDV2_GPIO_USB_POWER,
  20572. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  20573. + "USB power");
  20574. + ath79_register_usb();
  20575. +
  20576. + ath79_register_m25p80(&tl_wa701ndv2_flash_data);
  20577. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  20578. + /* ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); */
  20579. +
  20580. + ath79_register_mdio(0, 0x0);
  20581. + ath79_register_eth(0);
  20582. + ath79_register_eth(1);
  20583. +
  20584. + ath79_register_wmac(ee, mac);
  20585. +}
  20586. +
  20587. +MIPS_MACHINE(ATH79_MACH_TL_WA701ND_V2, "TL-WA701ND-v2",
  20588. + "TP-LINK TL-WA701ND v2", tl_wa701ndv2_setup);
  20589. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa7210n-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wa7210n-v2.c
  20590. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa7210n-v2.c 1970-01-01 01:00:00.000000000 +0100
  20591. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wa7210n-v2.c 2015-09-13 20:04:35.072523889 +0200
  20592. @@ -0,0 +1,125 @@
  20593. +/*
  20594. + * TP-LINK TL-WA7210N v2.1 board support
  20595. + *
  20596. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  20597. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  20598. + * Copyright (C) 2014 Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
  20599. + * Copyright (C) 2014 Alexander List <alex@graz.funkfeuer.at>
  20600. + * Copyright (C) 2015 Hendrik Frenzel <hfrenzel@scunc.net>
  20601. + *
  20602. + * rebased on TL-WA7510Nv1 support,
  20603. + * Copyright (C) 2012 Stefan Helmert <helst_listen@aol.de>
  20604. + *
  20605. + * This program is free software; you can redistribute it and/or modify it
  20606. + * under the terms of the GNU General Public License version 2 as published
  20607. + * by the Free Software Foundation.
  20608. + */
  20609. +
  20610. +#include <linux/mtd/mtd.h>
  20611. +#include <linux/mtd/partitions.h>
  20612. +#include <linux/platform_device.h>
  20613. +#include <linux/gpio.h>
  20614. +
  20615. +#include <asm/mach-ath79/ar71xx_regs.h>
  20616. +#include <asm/mach-ath79/ath79.h>
  20617. +
  20618. +#include "dev-dsa.h"
  20619. +#include "dev-eth.h"
  20620. +#include "dev-gpio-buttons.h"
  20621. +#include "dev-leds-gpio.h"
  20622. +#include "dev-m25p80.h"
  20623. +#include "dev-wmac.h"
  20624. +#include "machtypes.h"
  20625. +#include "pci.h"
  20626. +
  20627. +#include "common.h"
  20628. +
  20629. +#define TL_WA7210N_V2_GPIO_BTN_RESET 11
  20630. +#define TL_WA7210N_V2_KEYS_POLL_INT 20
  20631. +#define TL_WA7210N_V2_KEYS_DEBOUNCE_INT (3 * TL_WA7210N_V2_KEYS_POLL_INT)
  20632. +
  20633. +#define TL_WA7210N_V2_GPIO_LED_LAN 17
  20634. +#define TL_WA7210N_V2_GPIO_LED_SIG1 0
  20635. +#define TL_WA7210N_V2_GPIO_LED_SIG2 1
  20636. +#define TL_WA7210N_V2_GPIO_LED_SIG3 27
  20637. +#define TL_WA7210N_V2_GPIO_LED_SIG4 26
  20638. +
  20639. +#define TL_WA7210N_V2_GPIO_LNA_EN 28
  20640. +
  20641. +static const char *tl_wa7210n_v2_part_probes[] = {
  20642. + "tp-link",
  20643. + NULL,
  20644. +};
  20645. +
  20646. +static struct gpio_keys_button tl_wa7210n_v2_gpio_keys[] __initdata = {
  20647. + {
  20648. + .desc = "reset",
  20649. + .type = EV_KEY,
  20650. + .code = KEY_RESTART,
  20651. + .debounce_interval = TL_WA7210N_V2_KEYS_DEBOUNCE_INT,
  20652. + .gpio = TL_WA7210N_V2_GPIO_BTN_RESET,
  20653. + .active_low = 0,
  20654. + },
  20655. +};
  20656. +
  20657. +static struct gpio_led tl_wa7210n_v2_leds_gpio[] __initdata = {
  20658. + {
  20659. + .name = "tp-link:green:lan",
  20660. + .gpio = TL_WA7210N_V2_GPIO_LED_LAN,
  20661. + .active_low = 1,
  20662. + }, {
  20663. + .name = "tp-link:green:signal1",
  20664. + .gpio = TL_WA7210N_V2_GPIO_LED_SIG1,
  20665. + .active_low = 0,
  20666. + }, {
  20667. + .name = "tp-link:green:signal2",
  20668. + .gpio = TL_WA7210N_V2_GPIO_LED_SIG2,
  20669. + .active_low = 0,
  20670. + }, {
  20671. + .name = "tp-link:green:signal3",
  20672. + .gpio = TL_WA7210N_V2_GPIO_LED_SIG3,
  20673. + .active_low = 1,
  20674. + }, {
  20675. + .name = "tp-link:green:signal4",
  20676. + .gpio = TL_WA7210N_V2_GPIO_LED_SIG4,
  20677. + .active_low = 1,
  20678. + },
  20679. +};
  20680. +
  20681. +static struct flash_platform_data tl_wa7210n_v2_flash_data = {
  20682. + .part_probes = tl_wa7210n_v2_part_probes,
  20683. +};
  20684. +
  20685. +static void __init tl_wa7210n_v2_setup(void)
  20686. +{
  20687. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20688. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20689. +
  20690. + ath79_register_gpio_keys_polled(-1, TL_WA7210N_V2_KEYS_POLL_INT,
  20691. + ARRAY_SIZE(tl_wa7210n_v2_gpio_keys),
  20692. + tl_wa7210n_v2_gpio_keys);
  20693. +
  20694. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa7210n_v2_leds_gpio),
  20695. + tl_wa7210n_v2_leds_gpio);
  20696. +
  20697. + ath79_gpio_function_enable(TL_WA7210N_V2_GPIO_LNA_EN);
  20698. +
  20699. + ath79_setup_ar933x_phy4_switch(false, false);
  20700. +
  20701. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  20702. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  20703. +
  20704. + ath79_register_eth(0);
  20705. + ath79_register_eth(1);
  20706. +
  20707. + ath79_register_mdio(0, 0x0);
  20708. +
  20709. + ath79_register_wmac(ee, mac);
  20710. +
  20711. + ath79_register_m25p80(&tl_wa7210n_v2_flash_data);
  20712. +
  20713. + ath79_register_pci();
  20714. +}
  20715. +
  20716. +MIPS_MACHINE(ATH79_MACH_TL_WA7210N_V2, "TL-WA7210N-v2", "TP-LINK TL-WA7210N v2",
  20717. + tl_wa7210n_v2_setup);
  20718. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa830re-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wa830re-v2.c
  20719. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa830re-v2.c 1970-01-01 01:00:00.000000000 +0100
  20720. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wa830re-v2.c 2015-09-13 20:04:35.072523889 +0200
  20721. @@ -0,0 +1,132 @@
  20722. +/*
  20723. + * TP-LINK TL-WA830RE v2 board support
  20724. + *
  20725. + * Copyright (C) 2014 Fredrik Jonson <fredrik@famjonson.se>
  20726. + *
  20727. + * This program is free software; you can redistribute it and/or modify it
  20728. + * under the terms of the GNU General Public License version 2 as published
  20729. + * by the Free Software Foundation.
  20730. + */
  20731. +
  20732. +#include <linux/gpio.h>
  20733. +#include <linux/platform_device.h>
  20734. +
  20735. +#include <asm/mach-ath79/ath79.h>
  20736. +#include <asm/mach-ath79/ar71xx_regs.h>
  20737. +
  20738. +#include "common.h"
  20739. +#include "dev-eth.h"
  20740. +#include "dev-gpio-buttons.h"
  20741. +#include "dev-leds-gpio.h"
  20742. +#include "dev-m25p80.h"
  20743. +#include "dev-usb.h"
  20744. +#include "dev-wmac.h"
  20745. +#include "machtypes.h"
  20746. +
  20747. +#define TL_WA830REV2_GPIO_LED_WLAN 13
  20748. +#define TL_WA830REV2_GPIO_LED_QSS 15
  20749. +#define TL_WA830REV2_GPIO_LED_LAN 18
  20750. +#define TL_WA830REV2_GPIO_LED_SYSTEM 14
  20751. +
  20752. +#define TL_WA830REV2_GPIO_BTN_RESET 17
  20753. +#define TL_WA830REV2_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
  20754. +
  20755. +#define TL_WA830REV2_GPIO_USB_POWER 4
  20756. +
  20757. +#define TL_WA830REV2_KEYS_POLL_INTERVAL 20 /* msecs */
  20758. +#define TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA830REV2_KEYS_POLL_INTERVAL)
  20759. +
  20760. +static const char *tl_wa830re_v2_part_probes[] = {
  20761. + "tp-link",
  20762. + NULL,
  20763. +};
  20764. +
  20765. +static struct flash_platform_data tl_wa830re_v2_flash_data = {
  20766. + .part_probes = tl_wa830re_v2_part_probes,
  20767. +};
  20768. +
  20769. +static struct gpio_led tl_wa830re_v2_leds_gpio[] __initdata = {
  20770. + {
  20771. + .name = "tp-link:green:qss",
  20772. + .gpio = TL_WA830REV2_GPIO_LED_QSS,
  20773. + .active_low = 1,
  20774. + }, {
  20775. + .name = "tp-link:green:system",
  20776. + .gpio = TL_WA830REV2_GPIO_LED_SYSTEM,
  20777. + .active_low = 1,
  20778. + }, {
  20779. + .name = "tp-link:green:lan",
  20780. + .gpio = TL_WA830REV2_GPIO_LED_LAN,
  20781. + .active_low = 1,
  20782. + }, {
  20783. + .name = "tp-link:green:wlan",
  20784. + .gpio = TL_WA830REV2_GPIO_LED_WLAN,
  20785. + .active_low = 1,
  20786. + },
  20787. +};
  20788. +
  20789. +static struct gpio_keys_button tl_wa830re_v2_gpio_keys[] __initdata = {
  20790. + {
  20791. + .desc = "Reset button",
  20792. + .type = EV_KEY,
  20793. + .code = KEY_RESTART,
  20794. + .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
  20795. + .gpio = TL_WA830REV2_GPIO_BTN_RESET,
  20796. + .active_low = 1,
  20797. + }, {
  20798. + .desc = "RFKILL switch",
  20799. + .type = EV_SW,
  20800. + .code = KEY_RFKILL,
  20801. + .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
  20802. + .gpio = TL_WA830REV2_GPIO_SW_RFKILL,
  20803. + .active_low = 0,
  20804. + }
  20805. +};
  20806. +
  20807. +static void __init tl_ap123_setup(void)
  20808. +{
  20809. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20810. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20811. +
  20812. + /* Disable JTAG, enabling GPIOs 0-3 */
  20813. + /* Configure OBS4 line, for GPIO 4*/
  20814. + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  20815. + AR934X_GPIO_FUNC_CLK_OBS4_EN);
  20816. +
  20817. + /* config gpio4 as normal gpio function */
  20818. + ath79_gpio_output_select(TL_WA830REV2_GPIO_USB_POWER,
  20819. + AR934X_GPIO_OUT_GPIO);
  20820. +
  20821. + ath79_register_m25p80(&tl_wa830re_v2_flash_data);
  20822. +
  20823. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  20824. +
  20825. + ath79_register_mdio(1, 0x0);
  20826. +
  20827. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  20828. +
  20829. + /* GMAC0 is connected to the PHY0 of the internal switch */
  20830. + ath79_switch_data.phy4_mii_en = 1;
  20831. + ath79_switch_data.phy_poll_mask = BIT(0);
  20832. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  20833. + ath79_eth0_data.phy_mask = BIT(0);
  20834. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  20835. + ath79_register_eth(0);
  20836. +
  20837. + ath79_register_wmac(ee, mac);
  20838. +}
  20839. +
  20840. +static void __init tl_wa830re_v2_setup(void)
  20841. +{
  20842. + tl_ap123_setup();
  20843. +
  20844. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa830re_v2_leds_gpio) - 1,
  20845. + tl_wa830re_v2_leds_gpio);
  20846. +
  20847. + ath79_register_gpio_keys_polled(1, TL_WA830REV2_KEYS_POLL_INTERVAL,
  20848. + ARRAY_SIZE(tl_wa830re_v2_gpio_keys),
  20849. + tl_wa830re_v2_gpio_keys);
  20850. +}
  20851. +
  20852. +MIPS_MACHINE(ATH79_MACH_TL_WA830RE_V2, "TL-WA830RE-v2", "TP-LINK TL-WA830RE v2",
  20853. + tl_wa830re_v2_setup);
  20854. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa901nd.c linux-4.1.13/arch/mips/ath79/mach-tl-wa901nd.c
  20855. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa901nd.c 1970-01-01 01:00:00.000000000 +0100
  20856. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wa901nd.c 2015-09-13 20:04:35.072523889 +0200
  20857. @@ -0,0 +1,127 @@
  20858. +/*
  20859. + * TP-LINK TL-WA901N/ND v1, TL-WA7510N v1 board support
  20860. + *
  20861. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  20862. + * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
  20863. + * Copyright (C) 2012 Stefan Helmert <helst_listen@aol.de>
  20864. + *
  20865. + * This program is free software; you can redistribute it and/or modify it
  20866. + * under the terms of the GNU General Public License version 2 as published
  20867. + * by the Free Software Foundation.
  20868. + */
  20869. +
  20870. +#include <asm/mach-ath79/ar71xx_regs.h>
  20871. +#include <asm/mach-ath79/ath79.h>
  20872. +
  20873. +#include "common.h"
  20874. +#include "dev-ap9x-pci.h"
  20875. +#include "dev-eth.h"
  20876. +#include "dev-gpio-buttons.h"
  20877. +#include "dev-leds-gpio.h"
  20878. +#include "dev-m25p80.h"
  20879. +#include "machtypes.h"
  20880. +#include "pci.h"
  20881. +
  20882. +#define TL_WA901ND_GPIO_LED_QSS 0
  20883. +#define TL_WA901ND_GPIO_LED_SYSTEM 1
  20884. +#define TL_WA901ND_GPIO_LED_LAN 13
  20885. +
  20886. +#define TL_WA901ND_GPIO_BTN_RESET 11
  20887. +#define TL_WA901ND_GPIO_BTN_QSS 12
  20888. +
  20889. +#define TL_WA901ND_KEYS_POLL_INTERVAL 20 /* msecs */
  20890. +#define TL_WA901ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA901ND_KEYS_POLL_INTERVAL)
  20891. +
  20892. +static const char *tl_wa901nd_part_probes[] = {
  20893. + "tp-link",
  20894. + NULL,
  20895. +};
  20896. +
  20897. +static struct flash_platform_data tl_wa901nd_flash_data = {
  20898. + .part_probes = tl_wa901nd_part_probes,
  20899. +};
  20900. +
  20901. +static struct gpio_led tl_wa901nd_leds_gpio[] __initdata = {
  20902. + {
  20903. + .name = "tp-link:green:lan",
  20904. + .gpio = TL_WA901ND_GPIO_LED_LAN,
  20905. + .active_low = 1,
  20906. + }, {
  20907. + .name = "tp-link:green:system",
  20908. + .gpio = TL_WA901ND_GPIO_LED_SYSTEM,
  20909. + .active_low = 1,
  20910. + }, {
  20911. + .name = "tp-link:green:qss",
  20912. + .gpio = TL_WA901ND_GPIO_LED_QSS,
  20913. + .active_low = 1,
  20914. + }
  20915. +};
  20916. +
  20917. +static struct gpio_keys_button tl_wa901nd_gpio_keys[] __initdata = {
  20918. + {
  20919. + .desc = "reset",
  20920. + .type = EV_KEY,
  20921. + .code = KEY_RESTART,
  20922. + .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
  20923. + .gpio = TL_WA901ND_GPIO_BTN_RESET,
  20924. + .active_low = 1,
  20925. + }, {
  20926. + .desc = "qss",
  20927. + .type = EV_KEY,
  20928. + .code = KEY_WPS_BUTTON,
  20929. + .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
  20930. + .gpio = TL_WA901ND_GPIO_BTN_QSS,
  20931. + .active_low = 1,
  20932. + }
  20933. +};
  20934. +
  20935. +static void __init common_setup(void)
  20936. +{
  20937. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20938. +
  20939. + /*
  20940. + * ath79_eth0 would be the WAN port, but is not connected.
  20941. + * ath79_eth1 connects to the internal switch chip, however
  20942. + * we have a single LAN port only.
  20943. + */
  20944. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  20945. + ath79_register_mdio(0, 0x0);
  20946. + ath79_register_eth(1);
  20947. +
  20948. + ath79_register_m25p80(&tl_wa901nd_flash_data);
  20949. +}
  20950. +
  20951. +static void __init tl_wa901nd_setup(void)
  20952. +{
  20953. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  20954. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  20955. +
  20956. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  20957. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  20958. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  20959. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  20960. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  20961. +
  20962. + common_setup();
  20963. +
  20964. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_leds_gpio),
  20965. + tl_wa901nd_leds_gpio);
  20966. +
  20967. + ath79_register_gpio_keys_polled(-1, TL_WA901ND_KEYS_POLL_INTERVAL,
  20968. + ARRAY_SIZE(tl_wa901nd_gpio_keys),
  20969. + tl_wa901nd_gpio_keys);
  20970. +
  20971. + ap91_pci_init(ee, mac);
  20972. +}
  20973. +
  20974. +MIPS_MACHINE(ATH79_MACH_TL_WA901ND, "TL-WA901ND", "TP-LINK TL-WA901ND",
  20975. + tl_wa901nd_setup);
  20976. +
  20977. +static void __init tl_wa7510n_v1_setup(void)
  20978. +{
  20979. + common_setup();
  20980. + ath79_register_pci();
  20981. +}
  20982. +
  20983. +MIPS_MACHINE(ATH79_MACH_TL_WA7510N_V1, "TL-WA7510N", "TP-LINK TL-WA7510N v1",
  20984. + tl_wa7510n_v1_setup);
  20985. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa901nd-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wa901nd-v2.c
  20986. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wa901nd-v2.c 1970-01-01 01:00:00.000000000 +0100
  20987. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wa901nd-v2.c 2015-09-13 20:04:35.072523889 +0200
  20988. @@ -0,0 +1,104 @@
  20989. +/*
  20990. + * TP-LINK TL-WA901N/ND v2 board support
  20991. + *
  20992. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  20993. + * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
  20994. + * Copyright (C) 2011 Jonathan Bennett <jbscience87@gmail.com>
  20995. + *
  20996. + * This program is free software; you can redistribute it and/or modify it
  20997. + * under the terms of the GNU General Public License version 2 as published
  20998. + * by the Free Software Foundation.
  20999. + */
  21000. +
  21001. +#include <asm/mach-ath79/ath79.h>
  21002. +#include <asm/mach-ath79/ar71xx_regs.h>
  21003. +
  21004. +#include "dev-eth.h"
  21005. +#include "dev-m25p80.h"
  21006. +#include "dev-gpio-buttons.h"
  21007. +#include "dev-leds-gpio.h"
  21008. +#include "dev-wmac.h"
  21009. +#include "machtypes.h"
  21010. +
  21011. +#define TL_WA901ND_V2_GPIO_LED_QSS 4
  21012. +#define TL_WA901ND_V2_GPIO_LED_SYSTEM 2
  21013. +#define TL_WA901ND_V2_GPIO_LED_WLAN 9
  21014. +
  21015. +#define TL_WA901ND_V2_GPIO_BTN_RESET 3
  21016. +#define TL_WA901ND_V2_GPIO_BTN_QSS 7
  21017. +
  21018. +#define TL_WA901ND_V2_KEYS_POLL_INTERVAL 20 /* msecs */
  21019. +#define TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL \
  21020. + (3 * TL_WA901ND_V2_KEYS_POLL_INTERVAL)
  21021. +
  21022. +static const char *tl_wa901nd_v2_part_probes[] = {
  21023. + "tp-link",
  21024. + NULL,
  21025. +};
  21026. +
  21027. +static struct flash_platform_data tl_wa901nd_v2_flash_data = {
  21028. + .part_probes = tl_wa901nd_v2_part_probes,
  21029. +};
  21030. +
  21031. +static struct gpio_led tl_wa901nd_v2_leds_gpio[] __initdata = {
  21032. + {
  21033. + .name = "tp-link:green:system",
  21034. + .gpio = TL_WA901ND_V2_GPIO_LED_SYSTEM,
  21035. + .active_low = 1,
  21036. + }, {
  21037. + .name = "tp-link:green:qss",
  21038. + .gpio = TL_WA901ND_V2_GPIO_LED_QSS,
  21039. + }, {
  21040. + .name = "tp-link:green:wlan",
  21041. + .gpio = TL_WA901ND_V2_GPIO_LED_WLAN,
  21042. + .active_low = 1,
  21043. + }
  21044. +};
  21045. +
  21046. +static struct gpio_keys_button tl_wa901nd_v2_gpio_keys[] __initdata = {
  21047. + {
  21048. + .desc = "reset",
  21049. + .type = EV_KEY,
  21050. + .code = KEY_RESTART,
  21051. + .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
  21052. + .gpio = TL_WA901ND_V2_GPIO_BTN_RESET,
  21053. + .active_low = 1,
  21054. + }, {
  21055. + .desc = "qss",
  21056. + .type = EV_KEY,
  21057. + .code = KEY_WPS_BUTTON,
  21058. + .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
  21059. + .gpio = TL_WA901ND_V2_GPIO_BTN_QSS,
  21060. + .active_low = 1,
  21061. + }
  21062. +};
  21063. +
  21064. +static void __init tl_wa901nd_v2_setup(void)
  21065. +{
  21066. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  21067. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  21068. +
  21069. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  21070. +
  21071. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  21072. + ath79_eth0_data.phy_mask = 0x00001000;
  21073. + ath79_register_mdio(0, 0x0);
  21074. +
  21075. + ath79_eth0_data.reset_bit = AR71XX_RESET_GE0_MAC |
  21076. + AR71XX_RESET_GE0_PHY;
  21077. + ath79_register_eth(0);
  21078. +
  21079. + ath79_register_m25p80(&tl_wa901nd_v2_flash_data);
  21080. +
  21081. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_v2_leds_gpio),
  21082. + tl_wa901nd_v2_leds_gpio);
  21083. +
  21084. + ath79_register_gpio_keys_polled(-1, TL_WA901ND_V2_KEYS_POLL_INTERVAL,
  21085. + ARRAY_SIZE(tl_wa901nd_v2_gpio_keys),
  21086. + tl_wa901nd_v2_gpio_keys);
  21087. +
  21088. + ath79_register_wmac(eeprom, mac);
  21089. +}
  21090. +
  21091. +MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V2, "TL-WA901ND-v2",
  21092. + "TP-LINK TL-WA901ND v2", tl_wa901nd_v2_setup);
  21093. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wax50re.c linux-4.1.13/arch/mips/ath79/mach-tl-wax50re.c
  21094. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wax50re.c 1970-01-01 01:00:00.000000000 +0100
  21095. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wax50re.c 2015-09-13 20:04:35.072523889 +0200
  21096. @@ -0,0 +1,313 @@
  21097. +/*
  21098. + * TP-LINK TL-WA750RE v1/TL-WA801ND v2/TL-WA850RE v1/TL-WA901ND v3
  21099. + * board support
  21100. + *
  21101. + * Copyright (C) 2013 Martijn Zilverschoon <thefriedzombie@gmail.com>
  21102. + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
  21103. + *
  21104. + * This program is free software; you can redistribute it and/or modify it
  21105. + * under the terms of the GNU General Public License version 2 as published
  21106. + * by the Free Software Foundation.
  21107. + */
  21108. +
  21109. +#include <linux/gpio.h>
  21110. +#include <linux/platform_device.h>
  21111. +
  21112. +#include <asm/mach-ath79/ath79.h>
  21113. +#include <asm/mach-ath79/ar71xx_regs.h>
  21114. +
  21115. +#include "common.h"
  21116. +#include "dev-eth.h"
  21117. +#include "dev-gpio-buttons.h"
  21118. +#include "dev-leds-gpio.h"
  21119. +#include "dev-m25p80.h"
  21120. +#include "dev-wmac.h"
  21121. +#include "machtypes.h"
  21122. +
  21123. +#define TL_WAX50RE_GPIO_LED_LAN 20
  21124. +#define TL_WAX50RE_GPIO_LED_WLAN 13
  21125. +#define TL_WAX50RE_GPIO_LED_RE 15
  21126. +#define TL_WAX50RE_GPIO_LED_SIGNAL1 0
  21127. +#define TL_WAX50RE_GPIO_LED_SIGNAL2 1
  21128. +#define TL_WAX50RE_GPIO_LED_SIGNAL3 2
  21129. +#define TL_WAX50RE_GPIO_LED_SIGNAL4 3
  21130. +#define TL_WAX50RE_GPIO_LED_SIGNAL5 4
  21131. +
  21132. +#define TL_WA860RE_GPIO_LED_WLAN_ORANGE 0
  21133. +#define TL_WA860RE_GPIO_LED_WLAN_GREEN 2
  21134. +#define TL_WA860RE_GPIO_LED_POWER_ORANGE 12
  21135. +#define TL_WA860RE_GPIO_LED_POWER_GREEN 14
  21136. +#define TL_WA860RE_GPIO_LED_LAN 20
  21137. +
  21138. +#define TL_WA801ND_V2_GPIO_LED_LAN 18
  21139. +#define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
  21140. +
  21141. +#define TL_WAX50RE_GPIO_BTN_RESET 17
  21142. +#define TL_WAX50RE_GPIO_BTN_WPS 16
  21143. +
  21144. +#define TL_WA860RE_GPIO_BTN_RESET 17
  21145. +#define TL_WA860RE_GPIO_BTN_WPS 16
  21146. +#define TL_WA860RE_GPIO_BTN_ONOFF 11
  21147. +
  21148. +#define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
  21149. +#define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
  21150. +
  21151. +static const char *tl_wax50re_part_probes[] = {
  21152. + "tp-link",
  21153. + NULL,
  21154. +};
  21155. +
  21156. +static struct flash_platform_data tl_wax50re_flash_data = {
  21157. + .part_probes = tl_wax50re_part_probes,
  21158. +};
  21159. +
  21160. +static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
  21161. + {
  21162. + .name = "tp-link:orange:lan",
  21163. + .gpio = TL_WAX50RE_GPIO_LED_LAN,
  21164. + .active_low = 1,
  21165. + }, {
  21166. + .name = "tp-link:orange:wlan",
  21167. + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  21168. + .active_low = 1,
  21169. + }, {
  21170. + .name = "tp-link:orange:re",
  21171. + .gpio = TL_WAX50RE_GPIO_LED_RE,
  21172. + .active_low = 1,
  21173. + }, {
  21174. + .name = "tp-link:orange:signal1",
  21175. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
  21176. + .active_low = 1,
  21177. + }, {
  21178. + .name = "tp-link:orange:signal2",
  21179. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
  21180. + .active_low = 1,
  21181. + }, {
  21182. + .name = "tp-link:orange:signal3",
  21183. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
  21184. + .active_low = 1,
  21185. + }, {
  21186. + .name = "tp-link:orange:signal4",
  21187. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
  21188. + .active_low = 1,
  21189. + }, {
  21190. + .name = "tp-link:orange:signal5",
  21191. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
  21192. + .active_low = 1,
  21193. + },
  21194. +};
  21195. +
  21196. +static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
  21197. + {
  21198. + .name = "tp-link:blue:lan",
  21199. + .gpio = TL_WAX50RE_GPIO_LED_LAN,
  21200. + .active_low = 1,
  21201. + }, {
  21202. + .name = "tp-link:blue:wlan",
  21203. + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  21204. + .active_low = 1,
  21205. + }, {
  21206. + .name = "tp-link:blue:re",
  21207. + .gpio = TL_WAX50RE_GPIO_LED_RE,
  21208. + .active_low = 1,
  21209. + }, {
  21210. + .name = "tp-link:blue:signal1",
  21211. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
  21212. + .active_low = 1,
  21213. + }, {
  21214. + .name = "tp-link:blue:signal2",
  21215. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
  21216. + .active_low = 1,
  21217. + }, {
  21218. + .name = "tp-link:blue:signal3",
  21219. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
  21220. + .active_low = 1,
  21221. + }, {
  21222. + .name = "tp-link:blue:signal4",
  21223. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
  21224. + .active_low = 1,
  21225. + }, {
  21226. + .name = "tp-link:blue:signal5",
  21227. + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
  21228. + .active_low = 1,
  21229. + },
  21230. +};
  21231. +
  21232. +static struct gpio_led tl_wa860re_leds_gpio[] __initdata = {
  21233. + {
  21234. + .name = "tp-link:green:lan",
  21235. + .gpio = TL_WA860RE_GPIO_LED_LAN,
  21236. + .active_low = 1,
  21237. + }, {
  21238. + .name = "tp-link:green:power",
  21239. + .gpio = TL_WA860RE_GPIO_LED_POWER_GREEN,
  21240. + .active_low = 1,
  21241. + }, {
  21242. + .name = "tp-link:orange:power",
  21243. + .gpio = TL_WA860RE_GPIO_LED_POWER_ORANGE,
  21244. + .active_low = 1,
  21245. + }, {
  21246. + .name = "tp-link:green:wlan",
  21247. + .gpio = TL_WA860RE_GPIO_LED_WLAN_GREEN,
  21248. + .active_low = 1,
  21249. + }, {
  21250. + .name = "tp-link:orange:wlan",
  21251. + .gpio = TL_WA860RE_GPIO_LED_WLAN_ORANGE,
  21252. + .active_low = 1,
  21253. + },
  21254. +};
  21255. +
  21256. +
  21257. +static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
  21258. + {
  21259. + .desc = "Reset button",
  21260. + .type = EV_KEY,
  21261. + .code = KEY_RESTART,
  21262. + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  21263. + .gpio = TL_WAX50RE_GPIO_BTN_RESET,
  21264. + .active_low = 1,
  21265. + }, {
  21266. + .desc = "WPS",
  21267. + .type = EV_KEY,
  21268. + .code = KEY_WPS_BUTTON,
  21269. + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  21270. + .gpio = TL_WAX50RE_GPIO_BTN_WPS,
  21271. + .active_low = 1,
  21272. + },
  21273. +};
  21274. +
  21275. +static struct gpio_keys_button tl_wa860re_gpio_keys[] __initdata = {
  21276. + {
  21277. + .desc = "Reset button",
  21278. + .type = EV_KEY,
  21279. + .code = KEY_RESTART,
  21280. + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  21281. + .gpio = TL_WA860RE_GPIO_BTN_RESET,
  21282. + .active_low = 1,
  21283. + }, {
  21284. + .desc = "WPS",
  21285. + .type = EV_KEY,
  21286. + .code = KEY_WPS_BUTTON,
  21287. + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  21288. + .gpio = TL_WA860RE_GPIO_BTN_WPS,
  21289. + .active_low = 1,
  21290. + }, {
  21291. + .desc = "ONOFF",
  21292. + .type = EV_KEY,
  21293. + .code = BTN_1,
  21294. + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  21295. + .gpio = TL_WA860RE_GPIO_BTN_ONOFF,
  21296. + .active_low = 1,
  21297. + },
  21298. +};
  21299. +
  21300. +static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
  21301. + {
  21302. + .name = "tp-link:green:lan",
  21303. + .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
  21304. + .active_low = 1,
  21305. + }, {
  21306. + .name = "tp-link:green:wlan",
  21307. + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  21308. + .active_low = 1,
  21309. + }, {
  21310. + .name = "tp-link:green:qss",
  21311. + .gpio = TL_WAX50RE_GPIO_LED_RE,
  21312. + .active_low = 1,
  21313. + }, {
  21314. + .name = "tp-link:green:system",
  21315. + .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
  21316. + .active_low = 1,
  21317. + },
  21318. +};
  21319. +
  21320. +static void __init tl_ap123_setup(void)
  21321. +{
  21322. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  21323. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  21324. +
  21325. + ath79_register_m25p80(&tl_wax50re_flash_data);
  21326. +
  21327. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  21328. +
  21329. + ath79_register_mdio(1, 0x0);
  21330. +
  21331. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  21332. +
  21333. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  21334. + ath79_eth0_data.phy_mask = BIT(0);
  21335. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  21336. + ath79_register_eth(0);
  21337. +
  21338. + ath79_register_wmac(ee, mac);
  21339. +}
  21340. +
  21341. +static void __init tl_wa750re_setup(void)
  21342. +{
  21343. + tl_ap123_setup();
  21344. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
  21345. + tl_wa750re_leds_gpio);
  21346. +
  21347. + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  21348. + ARRAY_SIZE(tl_wax50re_gpio_keys),
  21349. + tl_wax50re_gpio_keys);
  21350. +}
  21351. +
  21352. +MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
  21353. + tl_wa750re_setup);
  21354. +
  21355. +static void __init tl_wa801nd_v2_setup(void)
  21356. +{
  21357. + tl_ap123_setup();
  21358. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
  21359. + tl_wa801nd_v2_leds_gpio);
  21360. +
  21361. + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  21362. + ARRAY_SIZE(tl_wax50re_gpio_keys),
  21363. + tl_wax50re_gpio_keys);
  21364. +}
  21365. +
  21366. +MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
  21367. + tl_wa801nd_v2_setup);
  21368. +
  21369. +static void __init tl_wa850re_setup(void)
  21370. +{
  21371. + tl_ap123_setup();
  21372. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
  21373. + tl_wa850re_leds_gpio);
  21374. +
  21375. + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  21376. + ARRAY_SIZE(tl_wax50re_gpio_keys),
  21377. + tl_wax50re_gpio_keys);
  21378. +}
  21379. +
  21380. +MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",
  21381. + tl_wa850re_setup);
  21382. +
  21383. +static void __init tl_wa860re_setup(void)
  21384. +{
  21385. + tl_ap123_setup();
  21386. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa860re_leds_gpio),
  21387. + tl_wa860re_leds_gpio);
  21388. +
  21389. + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  21390. + ARRAY_SIZE(tl_wa860re_gpio_keys),
  21391. + tl_wa860re_gpio_keys);
  21392. +}
  21393. +
  21394. +MIPS_MACHINE(ATH79_MACH_TL_WA860RE, "TL-WA860RE", "TP-LINK TL-WA860RE",
  21395. + tl_wa860re_setup);
  21396. +
  21397. +static void __init tl_wa901nd_v3_setup(void)
  21398. +{
  21399. + tl_ap123_setup();
  21400. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
  21401. + tl_wa801nd_v2_leds_gpio);
  21402. +
  21403. + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  21404. + ARRAY_SIZE(tl_wax50re_gpio_keys) - 1,
  21405. + tl_wax50re_gpio_keys);
  21406. +}
  21407. +
  21408. +MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V3, "TL-WA901ND-v3", "TP-LINK TL-WA901ND v3",
  21409. + tl_wa901nd_v3_setup);
  21410. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr3320-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wdr3320-v2.c
  21411. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr3320-v2.c 1970-01-01 01:00:00.000000000 +0100
  21412. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wdr3320-v2.c 2015-11-21 17:22:11.759223549 +0100
  21413. @@ -0,0 +1,146 @@
  21414. +/*
  21415. + * TP-LINK TL-WDR3320 v2 board support
  21416. + *
  21417. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  21418. + * Copyright (C) 2015 Weijie Gao <hackpascal@gmail.com>
  21419. + *
  21420. + * This program is free software; you can redistribute it and/or modify it
  21421. + * under the terms of the GNU General Public License version 2 as published
  21422. + * by the Free Software Foundation.
  21423. + */
  21424. +
  21425. +#include <linux/pci.h>
  21426. +#include <linux/phy.h>
  21427. +#include <linux/gpio.h>
  21428. +#include <linux/platform_device.h>
  21429. +#include <linux/ath9k_platform.h>
  21430. +
  21431. +#include <asm/mach-ath79/ar71xx_regs.h>
  21432. +
  21433. +#include "common.h"
  21434. +#include "dev-ap9x-pci.h"
  21435. +#include "dev-eth.h"
  21436. +#include "dev-gpio-buttons.h"
  21437. +#include "dev-leds-gpio.h"
  21438. +#include "dev-m25p80.h"
  21439. +#include "dev-spi.h"
  21440. +#include "dev-usb.h"
  21441. +#include "dev-wmac.h"
  21442. +#include "machtypes.h"
  21443. +
  21444. +#define WDR3320_GPIO_LED_WLAN5G 12
  21445. +#define WDR3320_GPIO_LED_SYSTEM 14
  21446. +#define WDR3320_GPIO_LED_QSS 15
  21447. +#define WDR3320_GPIO_LED_WAN 4
  21448. +#define WDR3320_GPIO_LED_LAN1 18
  21449. +#define WDR3320_GPIO_LED_LAN2 20
  21450. +#define WDR3320_GPIO_LED_LAN3 21
  21451. +#define WDR3320_GPIO_LED_LAN4 22
  21452. +
  21453. +#define WDR3320_GPIO_BTN_RESET 16
  21454. +
  21455. +#define WDR3320_KEYS_POLL_INTERVAL 20 /* msecs */
  21456. +#define WDR3320_KEYS_DEBOUNCE_INTERVAL (3 * WDR3320_KEYS_POLL_INTERVAL)
  21457. +
  21458. +#define WDR3320_WMAC_CALDATA_OFFSET 0x1000
  21459. +#define WDR3320_PCIE_CALDATA_OFFSET 0x5000
  21460. +
  21461. +static const char *wdr3320_part_probes[] = {
  21462. + "tp-link",
  21463. + NULL,
  21464. +};
  21465. +
  21466. +static struct flash_platform_data wdr3320_flash_data = {
  21467. + .part_probes = wdr3320_part_probes,
  21468. +};
  21469. +
  21470. +static struct gpio_led wdr3320_leds_gpio[] __initdata = {
  21471. + {
  21472. + .name = "tp-link:green:qss",
  21473. + .gpio = WDR3320_GPIO_LED_QSS,
  21474. + .active_low = 1,
  21475. + },
  21476. + {
  21477. + .name = "tp-link:green:system",
  21478. + .gpio = WDR3320_GPIO_LED_SYSTEM,
  21479. + .active_low = 1,
  21480. + },
  21481. + {
  21482. + .name = "tp-link:green:wlan5g",
  21483. + .gpio = WDR3320_GPIO_LED_WLAN5G,
  21484. + .active_low = 1,
  21485. + },
  21486. +};
  21487. +
  21488. +static struct gpio_keys_button wdr3320_gpio_keys[] __initdata = {
  21489. + {
  21490. + .desc = "reset",
  21491. + .type = EV_KEY,
  21492. + .code = KEY_RESTART,
  21493. + .debounce_interval = WDR3320_KEYS_DEBOUNCE_INTERVAL,
  21494. + .gpio = WDR3320_GPIO_BTN_RESET,
  21495. + .active_low = 1,
  21496. + },
  21497. +};
  21498. +
  21499. +static void __init wdr3320_setup(void)
  21500. +{
  21501. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  21502. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  21503. + u8 tmpmac[ETH_ALEN];
  21504. +
  21505. + ath79_register_m25p80(&wdr3320_flash_data);
  21506. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr3320_leds_gpio),
  21507. + wdr3320_leds_gpio);
  21508. + ath79_register_gpio_keys_polled(-1, WDR3320_KEYS_POLL_INTERVAL,
  21509. + ARRAY_SIZE(wdr3320_gpio_keys),
  21510. + wdr3320_gpio_keys);
  21511. +
  21512. + ath79_init_mac(tmpmac, mac, 0);
  21513. + ath79_register_wmac(art + WDR3320_WMAC_CALDATA_OFFSET, tmpmac);
  21514. +
  21515. + ath79_init_mac(tmpmac, mac, -1);
  21516. + ap9x_pci_setup_wmac_led_pin(0, 0);
  21517. + ap91_pci_init(art + WDR3320_PCIE_CALDATA_OFFSET, tmpmac);
  21518. +
  21519. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  21520. +
  21521. + ath79_register_mdio(1, 0x0);
  21522. +
  21523. + /* LAN */
  21524. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  21525. +
  21526. + /* GMAC1 is connected to the internal switch */
  21527. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  21528. +
  21529. + ath79_register_eth(1);
  21530. +
  21531. + /* WAN */
  21532. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  21533. +
  21534. + /* GMAC0 is connected to the PHY4 of the internal switch */
  21535. + ath79_switch_data.phy4_mii_en = 1;
  21536. + ath79_switch_data.phy_poll_mask = BIT(4);
  21537. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  21538. + ath79_eth0_data.phy_mask = BIT(4);
  21539. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  21540. +
  21541. + ath79_register_eth(0);
  21542. +
  21543. + ath79_register_usb();
  21544. +
  21545. + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN1,
  21546. + AR934X_GPIO_OUT_LED_LINK0);
  21547. + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN2,
  21548. + AR934X_GPIO_OUT_LED_LINK1);
  21549. + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN3,
  21550. + AR934X_GPIO_OUT_LED_LINK2);
  21551. + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN4,
  21552. + AR934X_GPIO_OUT_LED_LINK3);
  21553. + ath79_gpio_output_select(WDR3320_GPIO_LED_WAN,
  21554. + AR934X_GPIO_OUT_LED_LINK4);
  21555. +}
  21556. +
  21557. +MIPS_MACHINE(ATH79_MACH_TL_WDR3320_V2, "TL-WDR3320-v2",
  21558. + "TP-LINK TL-WDR3320 v2",
  21559. + wdr3320_setup);
  21560. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr3500.c linux-4.1.13/arch/mips/ath79/mach-tl-wdr3500.c
  21561. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr3500.c 1970-01-01 01:00:00.000000000 +0100
  21562. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wdr3500.c 2015-09-13 20:04:35.072523889 +0200
  21563. @@ -0,0 +1,169 @@
  21564. +/*
  21565. + * TP-LINK TL-WDR3500 board support
  21566. + *
  21567. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  21568. + * Copyright (C) 2013 Gui Iribarren <gui@altermundi.net>
  21569. + *
  21570. + * This program is free software; you can redistribute it and/or modify it
  21571. + * under the terms of the GNU General Public License version 2 as published
  21572. + * by the Free Software Foundation.
  21573. + */
  21574. +
  21575. +#include <linux/pci.h>
  21576. +#include <linux/phy.h>
  21577. +#include <linux/gpio.h>
  21578. +#include <linux/platform_device.h>
  21579. +#include <linux/ath9k_platform.h>
  21580. +#include <linux/ar8216_platform.h>
  21581. +
  21582. +#include <asm/mach-ath79/ar71xx_regs.h>
  21583. +
  21584. +#include "common.h"
  21585. +#include "dev-ap9x-pci.h"
  21586. +#include "dev-eth.h"
  21587. +#include "dev-gpio-buttons.h"
  21588. +#include "dev-leds-gpio.h"
  21589. +#include "dev-m25p80.h"
  21590. +#include "dev-spi.h"
  21591. +#include "dev-usb.h"
  21592. +#include "dev-wmac.h"
  21593. +#include "machtypes.h"
  21594. +
  21595. +#define WDR3500_GPIO_LED_USB 11
  21596. +#define WDR3500_GPIO_LED_WLAN2G 13
  21597. +#define WDR3500_GPIO_LED_SYSTEM 14
  21598. +#define WDR3500_GPIO_LED_QSS 15
  21599. +#define WDR3500_GPIO_LED_WAN 18
  21600. +#define WDR3500_GPIO_LED_LAN1 19
  21601. +#define WDR3500_GPIO_LED_LAN2 20
  21602. +#define WDR3500_GPIO_LED_LAN3 21
  21603. +#define WDR3500_GPIO_LED_LAN4 22
  21604. +
  21605. +#define WDR3500_GPIO_BTN_WPS 16
  21606. +#define WDR3500_GPIO_BTN_RFKILL 17
  21607. +
  21608. +#define WDR3500_GPIO_USB_POWER 12
  21609. +
  21610. +#define WDR3500_KEYS_POLL_INTERVAL 20 /* msecs */
  21611. +#define WDR3500_KEYS_DEBOUNCE_INTERVAL (3 * WDR3500_KEYS_POLL_INTERVAL)
  21612. +
  21613. +#define WDR3500_MAC0_OFFSET 0
  21614. +#define WDR3500_MAC1_OFFSET 6
  21615. +#define WDR3500_WMAC_CALDATA_OFFSET 0x1000
  21616. +#define WDR3500_PCIE_CALDATA_OFFSET 0x5000
  21617. +
  21618. +static const char *wdr3500_part_probes[] = {
  21619. + "tp-link",
  21620. + NULL,
  21621. +};
  21622. +
  21623. +static struct flash_platform_data wdr3500_flash_data = {
  21624. + .part_probes = wdr3500_part_probes,
  21625. +};
  21626. +
  21627. +static struct gpio_led wdr3500_leds_gpio[] __initdata = {
  21628. + {
  21629. + .name = "tp-link:green:qss",
  21630. + .gpio = WDR3500_GPIO_LED_QSS,
  21631. + .active_low = 1,
  21632. + },
  21633. + {
  21634. + .name = "tp-link:green:system",
  21635. + .gpio = WDR3500_GPIO_LED_SYSTEM,
  21636. + .active_low = 1,
  21637. + },
  21638. + {
  21639. + .name = "tp-link:green:usb",
  21640. + .gpio = WDR3500_GPIO_LED_USB,
  21641. + .active_low = 1,
  21642. + },
  21643. + {
  21644. + .name = "tp-link:green:wlan2g",
  21645. + .gpio = WDR3500_GPIO_LED_WLAN2G,
  21646. + .active_low = 1,
  21647. + },
  21648. +};
  21649. +
  21650. +static struct gpio_keys_button wdr3500_gpio_keys[] __initdata = {
  21651. + {
  21652. + .desc = "QSS button",
  21653. + .type = EV_KEY,
  21654. + .code = KEY_WPS_BUTTON,
  21655. + .debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
  21656. + .gpio = WDR3500_GPIO_BTN_WPS,
  21657. + .active_low = 1,
  21658. + },
  21659. + {
  21660. + .desc = "RFKILL switch",
  21661. + .type = EV_SW,
  21662. + .code = KEY_RFKILL,
  21663. + .debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
  21664. + .gpio = WDR3500_GPIO_BTN_RFKILL,
  21665. + },
  21666. +};
  21667. +
  21668. +
  21669. +static void __init wdr3500_setup(void)
  21670. +{
  21671. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  21672. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  21673. + u8 tmpmac[ETH_ALEN];
  21674. +
  21675. + ath79_register_m25p80(&wdr3500_flash_data);
  21676. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr3500_leds_gpio),
  21677. + wdr3500_leds_gpio);
  21678. + ath79_register_gpio_keys_polled(-1, WDR3500_KEYS_POLL_INTERVAL,
  21679. + ARRAY_SIZE(wdr3500_gpio_keys),
  21680. + wdr3500_gpio_keys);
  21681. +
  21682. + ath79_init_mac(tmpmac, mac, 0);
  21683. + ath79_register_wmac(art + WDR3500_WMAC_CALDATA_OFFSET, tmpmac);
  21684. +
  21685. + ath79_init_mac(tmpmac, mac, 1);
  21686. + ap9x_pci_setup_wmac_led_pin(0, 0);
  21687. + ap91_pci_init(art + WDR3500_PCIE_CALDATA_OFFSET, tmpmac);
  21688. +
  21689. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  21690. +
  21691. + ath79_register_mdio(1, 0x0);
  21692. +
  21693. + /* LAN */
  21694. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  21695. +
  21696. + /* GMAC1 is connected to the internal switch */
  21697. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  21698. +
  21699. + ath79_register_eth(1);
  21700. +
  21701. + /* WAN */
  21702. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 2);
  21703. +
  21704. + /* GMAC0 is connected to the PHY4 of the internal switch */
  21705. + ath79_switch_data.phy4_mii_en = 1;
  21706. + ath79_switch_data.phy_poll_mask = BIT(4);
  21707. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  21708. + ath79_eth0_data.phy_mask = BIT(4);
  21709. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  21710. +
  21711. + ath79_register_eth(0);
  21712. +
  21713. + gpio_request_one(WDR3500_GPIO_USB_POWER,
  21714. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  21715. + "USB power");
  21716. + ath79_register_usb();
  21717. +
  21718. + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN1,
  21719. + AR934X_GPIO_OUT_LED_LINK3);
  21720. + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN2,
  21721. + AR934X_GPIO_OUT_LED_LINK2);
  21722. + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN3,
  21723. + AR934X_GPIO_OUT_LED_LINK1);
  21724. + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN4,
  21725. + AR934X_GPIO_OUT_LED_LINK0);
  21726. + ath79_gpio_output_select(WDR3500_GPIO_LED_WAN,
  21727. + AR934X_GPIO_OUT_LED_LINK4);
  21728. +}
  21729. +
  21730. +MIPS_MACHINE(ATH79_MACH_TL_WDR3500, "TL-WDR3500",
  21731. + "TP-LINK TL-WDR3500",
  21732. + wdr3500_setup);
  21733. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr4300.c linux-4.1.13/arch/mips/ath79/mach-tl-wdr4300.c
  21734. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr4300.c 1970-01-01 01:00:00.000000000 +0100
  21735. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wdr4300.c 2015-09-13 20:04:35.072523889 +0200
  21736. @@ -0,0 +1,206 @@
  21737. +/*
  21738. + * TP-LINK TL-WDR4300 board support
  21739. + *
  21740. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  21741. + *
  21742. + * This program is free software; you can redistribute it and/or modify it
  21743. + * under the terms of the GNU General Public License version 2 as published
  21744. + * by the Free Software Foundation.
  21745. + */
  21746. +
  21747. +#include <linux/pci.h>
  21748. +#include <linux/phy.h>
  21749. +#include <linux/gpio.h>
  21750. +#include <linux/platform_device.h>
  21751. +#include <linux/ath9k_platform.h>
  21752. +#include <linux/ar8216_platform.h>
  21753. +
  21754. +#include <asm/mach-ath79/ar71xx_regs.h>
  21755. +
  21756. +#include "common.h"
  21757. +#include "dev-ap9x-pci.h"
  21758. +#include "dev-eth.h"
  21759. +#include "dev-gpio-buttons.h"
  21760. +#include "dev-leds-gpio.h"
  21761. +#include "dev-m25p80.h"
  21762. +#include "dev-spi.h"
  21763. +#include "dev-usb.h"
  21764. +#include "dev-wmac.h"
  21765. +#include "machtypes.h"
  21766. +
  21767. +#define WDR4300_GPIO_LED_USB1 11
  21768. +#define WDR4300_GPIO_LED_USB2 12
  21769. +#define WDR4300_GPIO_LED_WLAN2G 13
  21770. +#define WDR4300_GPIO_LED_SYSTEM 14
  21771. +#define WDR4300_GPIO_LED_QSS 15
  21772. +
  21773. +#define WDR4300_GPIO_BTN_WPS 16
  21774. +#define WDR4300_GPIO_BTN_RFKILL 17
  21775. +
  21776. +#define WDR4300_GPIO_EXTERNAL_LNA0 18
  21777. +#define WDR4300_GPIO_EXTERNAL_LNA1 19
  21778. +
  21779. +#define WDR4300_GPIO_USB1_POWER 22
  21780. +#define WDR4300_GPIO_USB2_POWER 21
  21781. +
  21782. +#define WDR4300_KEYS_POLL_INTERVAL 20 /* msecs */
  21783. +#define WDR4300_KEYS_DEBOUNCE_INTERVAL (3 * WDR4300_KEYS_POLL_INTERVAL)
  21784. +
  21785. +#define WDR4300_MAC0_OFFSET 0
  21786. +#define WDR4300_MAC1_OFFSET 6
  21787. +#define WDR4300_WMAC_CALDATA_OFFSET 0x1000
  21788. +#define WDR4300_PCIE_CALDATA_OFFSET 0x5000
  21789. +
  21790. +static const char *wdr4300_part_probes[] = {
  21791. + "tp-link",
  21792. + NULL,
  21793. +};
  21794. +
  21795. +static struct flash_platform_data wdr4300_flash_data = {
  21796. + .part_probes = wdr4300_part_probes,
  21797. +};
  21798. +
  21799. +static struct gpio_led wdr4300_leds_gpio[] __initdata = {
  21800. + {
  21801. + .name = "tp-link:blue:qss",
  21802. + .gpio = WDR4300_GPIO_LED_QSS,
  21803. + .active_low = 1,
  21804. + },
  21805. + {
  21806. + .name = "tp-link:blue:system",
  21807. + .gpio = WDR4300_GPIO_LED_SYSTEM,
  21808. + .active_low = 1,
  21809. + },
  21810. + {
  21811. + .name = "tp-link:green:usb1",
  21812. + .gpio = WDR4300_GPIO_LED_USB1,
  21813. + .active_low = 1,
  21814. + },
  21815. + {
  21816. + .name = "tp-link:green:usb2",
  21817. + .gpio = WDR4300_GPIO_LED_USB2,
  21818. + .active_low = 1,
  21819. + },
  21820. + {
  21821. + .name = "tp-link:blue:wlan2g",
  21822. + .gpio = WDR4300_GPIO_LED_WLAN2G,
  21823. + .active_low = 1,
  21824. + },
  21825. +};
  21826. +
  21827. +static struct gpio_keys_button wdr4300_gpio_keys[] __initdata = {
  21828. + {
  21829. + .desc = "QSS button",
  21830. + .type = EV_KEY,
  21831. + .code = KEY_WPS_BUTTON,
  21832. + .debounce_interval = WDR4300_KEYS_DEBOUNCE_INTERVAL,
  21833. + .gpio = WDR4300_GPIO_BTN_WPS,
  21834. + .active_low = 1,
  21835. + },
  21836. + {
  21837. + .desc = "RFKILL switch",
  21838. + .type = EV_SW,
  21839. + .code = KEY_RFKILL,
  21840. + .debounce_interval = WDR4300_KEYS_DEBOUNCE_INTERVAL,
  21841. + .gpio = WDR4300_GPIO_BTN_RFKILL,
  21842. + .active_low = 1,
  21843. + },
  21844. +};
  21845. +
  21846. +static const struct ar8327_led_info wdr4300_leds_ar8327[] __initconst = {
  21847. + AR8327_LED_INFO(PHY0_0, HW, "tp-link:blue:wan"),
  21848. + AR8327_LED_INFO(PHY1_0, HW, "tp-link:blue:lan1"),
  21849. + AR8327_LED_INFO(PHY2_0, HW, "tp-link:blue:lan2"),
  21850. + AR8327_LED_INFO(PHY3_0, HW, "tp-link:blue:lan3"),
  21851. + AR8327_LED_INFO(PHY4_0, HW, "tp-link:blue:lan4"),
  21852. +};
  21853. +
  21854. +static struct ar8327_pad_cfg wdr4300_ar8327_pad0_cfg = {
  21855. + .mode = AR8327_PAD_MAC_RGMII,
  21856. + .txclk_delay_en = true,
  21857. + .rxclk_delay_en = true,
  21858. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  21859. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  21860. +};
  21861. +
  21862. +static struct ar8327_led_cfg wdr4300_ar8327_led_cfg = {
  21863. + .led_ctrl0 = 0xc737c737,
  21864. + .led_ctrl1 = 0x00000000,
  21865. + .led_ctrl2 = 0x00000000,
  21866. + .led_ctrl3 = 0x0030c300,
  21867. + .open_drain = false,
  21868. +};
  21869. +
  21870. +static struct ar8327_platform_data wdr4300_ar8327_data = {
  21871. + .pad0_cfg = &wdr4300_ar8327_pad0_cfg,
  21872. + .port0_cfg = {
  21873. + .force_link = 1,
  21874. + .speed = AR8327_PORT_SPEED_1000,
  21875. + .duplex = 1,
  21876. + .txpause = 1,
  21877. + .rxpause = 1,
  21878. + },
  21879. + .led_cfg = &wdr4300_ar8327_led_cfg,
  21880. + .num_leds = ARRAY_SIZE(wdr4300_leds_ar8327),
  21881. + .leds = wdr4300_leds_ar8327,
  21882. +};
  21883. +
  21884. +static struct mdio_board_info wdr4300_mdio0_info[] = {
  21885. + {
  21886. + .bus_id = "ag71xx-mdio.0",
  21887. + .phy_addr = 0,
  21888. + .platform_data = &wdr4300_ar8327_data,
  21889. + },
  21890. +};
  21891. +
  21892. +static void __init wdr4300_setup(void)
  21893. +{
  21894. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  21895. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  21896. + u8 tmpmac[ETH_ALEN];
  21897. +
  21898. + ath79_register_m25p80(&wdr4300_flash_data);
  21899. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr4300_leds_gpio),
  21900. + wdr4300_leds_gpio);
  21901. + ath79_register_gpio_keys_polled(-1, WDR4300_KEYS_POLL_INTERVAL,
  21902. + ARRAY_SIZE(wdr4300_gpio_keys),
  21903. + wdr4300_gpio_keys);
  21904. +
  21905. + ath79_wmac_set_ext_lna_gpio(0, WDR4300_GPIO_EXTERNAL_LNA0);
  21906. + ath79_wmac_set_ext_lna_gpio(1, WDR4300_GPIO_EXTERNAL_LNA1);
  21907. +
  21908. + ath79_init_mac(tmpmac, mac, -1);
  21909. + ath79_register_wmac(art + WDR4300_WMAC_CALDATA_OFFSET, tmpmac);
  21910. +
  21911. + ath79_init_mac(tmpmac, mac, 0);
  21912. + ap9x_pci_setup_wmac_led_pin(0, 0);
  21913. + ap91_pci_init(art + WDR4300_PCIE_CALDATA_OFFSET, tmpmac);
  21914. +
  21915. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  21916. +
  21917. + mdiobus_register_board_info(wdr4300_mdio0_info,
  21918. + ARRAY_SIZE(wdr4300_mdio0_info));
  21919. +
  21920. + ath79_register_mdio(0, 0x0);
  21921. +
  21922. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -2);
  21923. +
  21924. + /* GMAC0 is connected to an AR8327N switch */
  21925. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  21926. + ath79_eth0_data.phy_mask = BIT(0);
  21927. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  21928. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  21929. + ath79_register_eth(0);
  21930. +
  21931. + gpio_request_one(WDR4300_GPIO_USB1_POWER,
  21932. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  21933. + "USB1 power");
  21934. + gpio_request_one(WDR4300_GPIO_USB2_POWER,
  21935. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  21936. + "USB2 power");
  21937. + ath79_register_usb();
  21938. +}
  21939. +
  21940. +MIPS_MACHINE(ATH79_MACH_TL_WDR4300, "TL-WDR4300",
  21941. + "TP-LINK TL-WDR3600/4300/4310",
  21942. + wdr4300_setup);
  21943. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr6500-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wdr6500-v2.c
  21944. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wdr6500-v2.c 1970-01-01 01:00:00.000000000 +0100
  21945. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wdr6500-v2.c 2015-09-13 20:04:35.072523889 +0200
  21946. @@ -0,0 +1,141 @@
  21947. +/*
  21948. + * TP-LINK TL-WDR6500 v2
  21949. + *
  21950. + * Copyright (C) 2015 Weijie Gao <hackpascal@gmail.com>
  21951. + *
  21952. + * This program is free software; you can redistribute it and/or modify it
  21953. + * under the terms of the GNU General Public License version 2 as published
  21954. + * by the Free Software Foundation.
  21955. + */
  21956. +
  21957. +#include <linux/pci.h>
  21958. +#include <linux/gpio.h>
  21959. +#include <linux/platform_device.h>
  21960. +
  21961. +#include <asm/mach-ath79/ath79.h>
  21962. +#include <asm/mach-ath79/ar71xx_regs.h>
  21963. +
  21964. +#include "common.h"
  21965. +#include "dev-eth.h"
  21966. +#include "dev-ap9x-pci.h"
  21967. +#include "dev-gpio-buttons.h"
  21968. +#include "dev-leds-gpio.h"
  21969. +#include "dev-m25p80.h"
  21970. +#include "dev-usb.h"
  21971. +#include "dev-wmac.h"
  21972. +#include "machtypes.h"
  21973. +#include "pci.h"
  21974. +
  21975. +#define TL_WDR6500_V2_GPIO_LED_SYS 21
  21976. +#define TL_WDR6500_V2_GPIO_LED_WAN 18
  21977. +#define TL_WDR6500_V2_GPIO_LED_LAN1 17
  21978. +#define TL_WDR6500_V2_GPIO_LED_LAN2 16
  21979. +#define TL_WDR6500_V2_GPIO_LED_LAN3 15
  21980. +#define TL_WDR6500_V2_GPIO_LED_LAN4 14
  21981. +
  21982. +#define TL_WDR6500_V2_GPIO_BTN_RESET 1
  21983. +
  21984. +#define TL_WDR6500_V2_KEYS_POLL_INTERVAL 20 /* msecs */
  21985. +#define TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WDR6500_V2_KEYS_POLL_INTERVAL)
  21986. +
  21987. +#define TL_WDR6500_V2_WMAC_CALDATA_OFFSET 0x1000
  21988. +#define TL_WDR6500_V2_PCIE_CALDATA_OFFSET 0x5000
  21989. +
  21990. +static const char *tl_wdr6500_v2_part_probes[] = {
  21991. + "tp-link-64k",
  21992. + NULL,
  21993. +};
  21994. +
  21995. +static struct flash_platform_data tl_wdr6500_v2_flash_data = {
  21996. + .part_probes = tl_wdr6500_v2_part_probes,
  21997. +};
  21998. +
  21999. +static struct gpio_led tl_wdr6500_v2_leds_gpio[] __initdata = {
  22000. + {
  22001. + .name = "tp-link:green:lan1",
  22002. + .gpio = TL_WDR6500_V2_GPIO_LED_LAN1,
  22003. + .active_low = 1,
  22004. + }, {
  22005. + .name = "tp-link:green:lan2",
  22006. + .gpio = TL_WDR6500_V2_GPIO_LED_LAN2,
  22007. + .active_low = 1,
  22008. + }, {
  22009. + .name = "tp-link:green:lan3",
  22010. + .gpio = TL_WDR6500_V2_GPIO_LED_LAN3,
  22011. + .active_low = 1,
  22012. + }, {
  22013. + .name = "tp-link:green:lan4",
  22014. + .gpio = TL_WDR6500_V2_GPIO_LED_LAN4,
  22015. + .active_low = 1,
  22016. + }, {
  22017. + .name = "tp-link:green:wan",
  22018. + .gpio = TL_WDR6500_V2_GPIO_LED_WAN,
  22019. + .active_low = 1,
  22020. + }, {
  22021. + .name = "tp-link:white:system",
  22022. + .gpio = TL_WDR6500_V2_GPIO_LED_SYS,
  22023. + .active_low = 0,
  22024. + },
  22025. +};
  22026. +
  22027. +static struct gpio_keys_button tl_wdr6500_v2_gpio_keys[] __initdata = {
  22028. + {
  22029. + .desc = "Reset button",
  22030. + .type = EV_KEY,
  22031. + .code = KEY_RESTART,
  22032. + .debounce_interval = TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL,
  22033. + .gpio = TL_WDR6500_V2_GPIO_BTN_RESET,
  22034. + .active_low = 1,
  22035. + }
  22036. +};
  22037. +
  22038. +
  22039. +static void __init tl_ap151_setup(void)
  22040. +{
  22041. + u8 *mac = (u8 *) KSEG1ADDR(0x1f00fc00);
  22042. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff0000);
  22043. + u8 tmpmac[ETH_ALEN];
  22044. +
  22045. + ath79_register_m25p80(&tl_wdr6500_v2_flash_data);
  22046. +
  22047. + ath79_setup_ar933x_phy4_switch(false, false);
  22048. +
  22049. + ath79_register_mdio(0, 0x0);
  22050. +
  22051. + /* WAN */
  22052. + ath79_switch_data.phy4_mii_en = 1;
  22053. + ath79_switch_data.phy_poll_mask = BIT(4);
  22054. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  22055. + ath79_eth0_data.phy_mask = BIT(4);
  22056. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  22057. + ath79_register_eth(0);
  22058. +
  22059. + /* LAN */
  22060. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  22061. + ath79_eth1_data.duplex = DUPLEX_FULL;
  22062. + ath79_eth1_data.speed = SPEED_1000;
  22063. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  22064. + ath79_register_eth(1);
  22065. +
  22066. + ath79_init_mac(tmpmac, mac, -1);
  22067. + ath79_register_wmac(ee + TL_WDR6500_V2_WMAC_CALDATA_OFFSET, tmpmac);
  22068. +
  22069. + ath79_register_pci();
  22070. +
  22071. + ath79_register_usb();
  22072. +}
  22073. +
  22074. +static void __init tl_wdr6500_v2_setup(void)
  22075. +{
  22076. + tl_ap151_setup();
  22077. +
  22078. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wdr6500_v2_leds_gpio),
  22079. + tl_wdr6500_v2_leds_gpio);
  22080. +
  22081. + ath79_register_gpio_keys_polled(1, TL_WDR6500_V2_KEYS_POLL_INTERVAL,
  22082. + ARRAY_SIZE(tl_wdr6500_v2_gpio_keys),
  22083. + tl_wdr6500_v2_gpio_keys);
  22084. +}
  22085. +
  22086. +MIPS_MACHINE(ATH79_MACH_TL_WDR6500_V2, "TL-WDR6500-v2", "TP-LINK TL-WDR6500 v2",
  22087. + tl_wdr6500_v2_setup);
  22088. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1041n-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wr1041n-v2.c
  22089. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1041n-v2.c 1970-01-01 01:00:00.000000000 +0100
  22090. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr1041n-v2.c 2015-09-13 20:04:35.072523889 +0200
  22091. @@ -0,0 +1,138 @@
  22092. +/*
  22093. + * TP-LINK TL-WR1041 v2 board support
  22094. + *
  22095. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  22096. + * Copyright (C) 2011-2012 Anan Huang <axishero@foxmail.com>
  22097. + *
  22098. + * This program is free software; you can redistribute it and/or modify it
  22099. + * under the terms of the GNU General Public License version 2 as published
  22100. + * by the Free Software Foundation.
  22101. + */
  22102. +
  22103. +#include <linux/pci.h>
  22104. +#include <linux/phy.h>
  22105. +#include <linux/platform_device.h>
  22106. +#include <linux/ath9k_platform.h>
  22107. +#include <linux/ar8216_platform.h>
  22108. +
  22109. +#include <asm/mach-ath79/ar71xx_regs.h>
  22110. +
  22111. +#include "common.h"
  22112. +#include "dev-ap9x-pci.h"
  22113. +#include "dev-eth.h"
  22114. +#include "dev-gpio-buttons.h"
  22115. +#include "dev-leds-gpio.h"
  22116. +#include "dev-m25p80.h"
  22117. +#include "dev-spi.h"
  22118. +#include "dev-wmac.h"
  22119. +#include "machtypes.h"
  22120. +
  22121. +#define TL_WR1041NV2_GPIO_BTN_RESET 14
  22122. +#define TL_WR1041NV2_GPIO_LED_WPS 13
  22123. +#define TL_WR1041NV2_GPIO_LED_WLAN 11
  22124. +
  22125. +#define TL_WR1041NV2_GPIO_LED_SYSTEM 12
  22126. +
  22127. +#define TL_WR1041NV2_KEYS_POLL_INTERVAL 20 /* msecs */
  22128. +#define TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1041NV2_KEYS_POLL_INTERVAL)
  22129. +
  22130. +#define TL_WR1041NV2_PCIE_CALDATA_OFFSET 0x5000
  22131. +
  22132. +static const char *tl_wr1041nv2_part_probes[] = {
  22133. + "tp-link",
  22134. + NULL,
  22135. +};
  22136. +
  22137. +static struct flash_platform_data tl_wr1041nv2_flash_data = {
  22138. + .part_probes = tl_wr1041nv2_part_probes,
  22139. +};
  22140. +
  22141. +static struct gpio_led tl_wr1041nv2_leds_gpio[] __initdata = {
  22142. + {
  22143. + .name = "tp-link:green:system",
  22144. + .gpio = TL_WR1041NV2_GPIO_LED_SYSTEM,
  22145. + .active_low = 1,
  22146. + }, {
  22147. + .name = "tp-link:green:wps",
  22148. + .gpio = TL_WR1041NV2_GPIO_LED_WPS,
  22149. + .active_low = 1,
  22150. + }, {
  22151. + .name = "tp-link:green:wlan",
  22152. + .gpio = TL_WR1041NV2_GPIO_LED_WLAN,
  22153. + .active_low = 1,
  22154. + }
  22155. +};
  22156. +
  22157. +static struct gpio_keys_button tl_wr1041nv2_gpio_keys[] __initdata = {
  22158. + {
  22159. + .desc = "reset",
  22160. + .type = EV_KEY,
  22161. + .code = KEY_RESTART,
  22162. + .debounce_interval = TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL,
  22163. + .gpio = TL_WR1041NV2_GPIO_BTN_RESET,
  22164. + .active_low = 1,
  22165. + }
  22166. +};
  22167. +
  22168. +static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = {
  22169. + .mode = AR8327_PAD_MAC_RGMII,
  22170. + .txclk_delay_en = true,
  22171. + .rxclk_delay_en = true,
  22172. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  22173. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  22174. +};
  22175. +
  22176. +static struct ar8327_platform_data db120_ar8327_data = {
  22177. + .pad0_cfg = &db120_ar8327_pad0_cfg,
  22178. + .port0_cfg = {
  22179. + .force_link = 1,
  22180. + .speed = AR8327_PORT_SPEED_1000,
  22181. + .duplex = 1,
  22182. + .txpause = 1,
  22183. + .rxpause = 1,
  22184. + }
  22185. +};
  22186. +
  22187. +static struct mdio_board_info db120_mdio0_info[] = {
  22188. + {
  22189. + .bus_id = "ag71xx-mdio.0",
  22190. + .phy_addr = 0,
  22191. + .platform_data = &db120_ar8327_data,
  22192. + },
  22193. +};
  22194. +
  22195. +static void __init tl_wr1041nv2_setup(void)
  22196. +{
  22197. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22198. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  22199. +
  22200. + ath79_register_m25p80(&tl_wr1041nv2_flash_data);
  22201. +
  22202. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1041nv2_leds_gpio),
  22203. + tl_wr1041nv2_leds_gpio);
  22204. + ath79_register_gpio_keys_polled(-1, TL_WR1041NV2_KEYS_POLL_INTERVAL,
  22205. + ARRAY_SIZE(tl_wr1041nv2_gpio_keys),
  22206. + tl_wr1041nv2_gpio_keys);
  22207. + ath79_register_wmac(ee, mac);
  22208. +
  22209. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  22210. + AR934X_ETH_CFG_SW_ONLY_MODE);
  22211. +
  22212. + ath79_register_mdio(1, 0x0);
  22213. + ath79_register_mdio(0, 0x0);
  22214. +
  22215. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  22216. +
  22217. + mdiobus_register_board_info(db120_mdio0_info,
  22218. + ARRAY_SIZE(db120_mdio0_info));
  22219. +
  22220. + /* GMAC0 is connected to an AR8327 switch */
  22221. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  22222. + ath79_eth0_data.phy_mask = BIT(0);
  22223. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  22224. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  22225. + ath79_register_eth(0);
  22226. +}
  22227. +
  22228. +MIPS_MACHINE(ATH79_MACH_TL_WR1041N_V2, "TL-WR1041N-v2",
  22229. + "TP-LINK TL-WR1041N v2", tl_wr1041nv2_setup);
  22230. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1043nd.c linux-4.1.13/arch/mips/ath79/mach-tl-wr1043nd.c
  22231. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1043nd.c 1970-01-01 01:00:00.000000000 +0100
  22232. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr1043nd.c 2015-09-13 20:04:35.072523889 +0200
  22233. @@ -0,0 +1,141 @@
  22234. +/*
  22235. + * TP-LINK TL-WR1043N/ND board support
  22236. + *
  22237. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  22238. + *
  22239. + * This program is free software; you can redistribute it and/or modify it
  22240. + * under the terms of the GNU General Public License version 2 as published
  22241. + * by the Free Software Foundation.
  22242. + */
  22243. +
  22244. +#include <linux/platform_device.h>
  22245. +#include <linux/rtl8366.h>
  22246. +
  22247. +#include <asm/mach-ath79/ath79.h>
  22248. +#include <asm/mach-ath79/ar71xx_regs.h>
  22249. +
  22250. +#include "dev-eth.h"
  22251. +#include "dev-m25p80.h"
  22252. +#include "dev-gpio-buttons.h"
  22253. +#include "dev-leds-gpio.h"
  22254. +#include "dev-usb.h"
  22255. +#include "dev-wmac.h"
  22256. +#include "machtypes.h"
  22257. +
  22258. +#define TL_WR1043ND_GPIO_LED_USB 1
  22259. +#define TL_WR1043ND_GPIO_LED_SYSTEM 2
  22260. +#define TL_WR1043ND_GPIO_LED_QSS 5
  22261. +#define TL_WR1043ND_GPIO_LED_WLAN 9
  22262. +
  22263. +#define TL_WR1043ND_GPIO_BTN_RESET 3
  22264. +#define TL_WR1043ND_GPIO_BTN_QSS 7
  22265. +
  22266. +#define TL_WR1043ND_GPIO_RTL8366_SDA 18
  22267. +#define TL_WR1043ND_GPIO_RTL8366_SCK 19
  22268. +
  22269. +#define TL_WR1043ND_KEYS_POLL_INTERVAL 20 /* msecs */
  22270. +#define TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043ND_KEYS_POLL_INTERVAL)
  22271. +
  22272. +static const char *tl_wr1043nd_part_probes[] = {
  22273. + "tp-link",
  22274. + NULL,
  22275. +};
  22276. +
  22277. +static struct flash_platform_data tl_wr1043nd_flash_data = {
  22278. + .part_probes = tl_wr1043nd_part_probes,
  22279. +};
  22280. +
  22281. +static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
  22282. + {
  22283. + .name = "tp-link:green:usb",
  22284. + .gpio = TL_WR1043ND_GPIO_LED_USB,
  22285. + .active_low = 1,
  22286. + }, {
  22287. + .name = "tp-link:green:system",
  22288. + .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
  22289. + .active_low = 1,
  22290. + }, {
  22291. + .name = "tp-link:green:qss",
  22292. + .gpio = TL_WR1043ND_GPIO_LED_QSS,
  22293. + .active_low = 0,
  22294. + }, {
  22295. + .name = "tp-link:green:wlan",
  22296. + .gpio = TL_WR1043ND_GPIO_LED_WLAN,
  22297. + .active_low = 1,
  22298. + }
  22299. +};
  22300. +
  22301. +static struct gpio_keys_button tl_wr1043nd_gpio_keys[] __initdata = {
  22302. + {
  22303. + .desc = "reset",
  22304. + .type = EV_KEY,
  22305. + .code = KEY_RESTART,
  22306. + .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
  22307. + .gpio = TL_WR1043ND_GPIO_BTN_RESET,
  22308. + .active_low = 1,
  22309. + }, {
  22310. + .desc = "qss",
  22311. + .type = EV_KEY,
  22312. + .code = KEY_WPS_BUTTON,
  22313. + .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
  22314. + .gpio = TL_WR1043ND_GPIO_BTN_QSS,
  22315. + .active_low = 1,
  22316. + }
  22317. +};
  22318. +
  22319. +static void tl_wr1043nd_rtl8366rb_hw_reset(bool active)
  22320. +{
  22321. + if (active)
  22322. + ath79_device_reset_set(AR71XX_RESET_GE0_PHY);
  22323. + else
  22324. + ath79_device_reset_clear(AR71XX_RESET_GE0_PHY);
  22325. +}
  22326. +
  22327. +static struct rtl8366_platform_data tl_wr1043nd_rtl8366rb_data = {
  22328. + .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
  22329. + .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
  22330. + .hw_reset = tl_wr1043nd_rtl8366rb_hw_reset,
  22331. +};
  22332. +
  22333. +static struct platform_device tl_wr1043nd_rtl8366rb_device = {
  22334. + .name = RTL8366RB_DRIVER_NAME,
  22335. + .id = -1,
  22336. + .dev = {
  22337. + .platform_data = &tl_wr1043nd_rtl8366rb_data,
  22338. + }
  22339. +};
  22340. +
  22341. +static void __init tl_wr1043nd_setup(void)
  22342. +{
  22343. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22344. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  22345. +
  22346. + tl_wr1043nd_rtl8366rb_hw_reset(true);
  22347. +
  22348. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  22349. + ath79_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
  22350. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  22351. + ath79_eth0_data.speed = SPEED_1000;
  22352. + ath79_eth0_data.duplex = DUPLEX_FULL;
  22353. + ath79_eth0_pll_data.pll_1000 = 0x1a000000;
  22354. +
  22355. + ath79_register_eth(0);
  22356. +
  22357. + ath79_register_usb();
  22358. +
  22359. + ath79_register_m25p80(&tl_wr1043nd_flash_data);
  22360. +
  22361. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
  22362. + tl_wr1043nd_leds_gpio);
  22363. +
  22364. + platform_device_register(&tl_wr1043nd_rtl8366rb_device);
  22365. +
  22366. + ath79_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL,
  22367. + ARRAY_SIZE(tl_wr1043nd_gpio_keys),
  22368. + tl_wr1043nd_gpio_keys);
  22369. +
  22370. + ath79_register_wmac(eeprom, mac);
  22371. +}
  22372. +
  22373. +MIPS_MACHINE(ATH79_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
  22374. + tl_wr1043nd_setup);
  22375. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1043nd-v2.c linux-4.1.13/arch/mips/ath79/mach-tl-wr1043nd-v2.c
  22376. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr1043nd-v2.c 1970-01-01 01:00:00.000000000 +0100
  22377. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr1043nd-v2.c 2015-09-13 20:04:35.072523889 +0200
  22378. @@ -0,0 +1,215 @@
  22379. +/*
  22380. + * TP-LINK TL-WR1043ND v2 board support
  22381. + *
  22382. + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  22383. + *
  22384. + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  22385. + * Copyright (c) 2012 Qualcomm Atheros
  22386. + *
  22387. + * Permission to use, copy, modify, and/or distribute this software for any
  22388. + * purpose with or without fee is hereby granted, provided that the above
  22389. + * copyright notice and this permission notice appear in all copies.
  22390. + *
  22391. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  22392. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  22393. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  22394. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  22395. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  22396. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  22397. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22398. + *
  22399. + */
  22400. +
  22401. +#include <linux/phy.h>
  22402. +#include <linux/gpio.h>
  22403. +#include <linux/platform_device.h>
  22404. +#include <linux/ar8216_platform.h>
  22405. +
  22406. +#include <asm/mach-ath79/ar71xx_regs.h>
  22407. +
  22408. +#include "common.h"
  22409. +#include "dev-eth.h"
  22410. +#include "dev-gpio-buttons.h"
  22411. +#include "dev-leds-gpio.h"
  22412. +#include "dev-m25p80.h"
  22413. +#include "dev-spi.h"
  22414. +#include "dev-usb.h"
  22415. +#include "dev-wmac.h"
  22416. +#include "machtypes.h"
  22417. +
  22418. +#define TL_WR1043_V2_GPIO_LED_WLAN 12
  22419. +#define TL_WR1043_V2_GPIO_LED_USB 15
  22420. +#define TL_WR1043_V2_GPIO_LED_WPS 18
  22421. +#define TL_WR1043_V2_GPIO_LED_SYSTEM 19
  22422. +
  22423. +#define TL_WR1043_V2_GPIO_BTN_RESET 16
  22424. +#define TL_WR1043_V2_GPIO_BTN_RFKILL 17
  22425. +
  22426. +#define TL_WR1043_V2_GPIO_USB_POWER 21
  22427. +
  22428. +#define TL_WR1043_V2_KEYS_POLL_INTERVAL 20 /* msecs */
  22429. +#define TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043_V2_KEYS_POLL_INTERVAL)
  22430. +
  22431. +#define TL_WR1043_V2_WMAC_CALDATA_OFFSET 0x1000
  22432. +
  22433. +static const char *wr1043nd_v2_part_probes[] = {
  22434. + "tp-link",
  22435. + NULL,
  22436. +};
  22437. +
  22438. +static struct flash_platform_data wr1043nd_v2_flash_data = {
  22439. + .part_probes = wr1043nd_v2_part_probes,
  22440. +};
  22441. +
  22442. +static struct gpio_led tl_wr1043_v2_leds_gpio[] __initdata = {
  22443. + {
  22444. + .name = "tp-link:green:wps",
  22445. + .gpio = TL_WR1043_V2_GPIO_LED_WPS,
  22446. + .active_low = 1,
  22447. + },
  22448. + {
  22449. + .name = "tp-link:green:system",
  22450. + .gpio = TL_WR1043_V2_GPIO_LED_SYSTEM,
  22451. + .active_low = 1,
  22452. + },
  22453. + {
  22454. + .name = "tp-link:green:wlan",
  22455. + .gpio = TL_WR1043_V2_GPIO_LED_WLAN,
  22456. + .active_low = 1,
  22457. + },
  22458. + {
  22459. + .name = "tp-link:green:usb",
  22460. + .gpio = TL_WR1043_V2_GPIO_LED_USB,
  22461. + .active_low = 1,
  22462. + },
  22463. +};
  22464. +
  22465. +static struct gpio_keys_button tl_wr1043_v2_gpio_keys[] __initdata = {
  22466. + {
  22467. + .desc = "Reset button",
  22468. + .type = EV_KEY,
  22469. + .code = KEY_RESTART,
  22470. + .debounce_interval = TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL,
  22471. + .gpio = TL_WR1043_V2_GPIO_BTN_RESET,
  22472. + .active_low = 1,
  22473. + },
  22474. + {
  22475. + .desc = "RFKILL button",
  22476. + .type = EV_KEY,
  22477. + .code = KEY_RFKILL,
  22478. + .debounce_interval = TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL,
  22479. + .gpio = TL_WR1043_V2_GPIO_BTN_RFKILL,
  22480. + .active_low = 1,
  22481. + },
  22482. +};
  22483. +
  22484. +static const struct ar8327_led_info tl_wr1043_leds_ar8327[] = {
  22485. + AR8327_LED_INFO(PHY0_0, HW, "tp-link:green:lan4"),
  22486. + AR8327_LED_INFO(PHY1_0, HW, "tp-link:green:lan3"),
  22487. + AR8327_LED_INFO(PHY2_0, HW, "tp-link:green:lan2"),
  22488. + AR8327_LED_INFO(PHY3_0, HW, "tp-link:green:lan1"),
  22489. + AR8327_LED_INFO(PHY4_0, HW, "tp-link:green:wan"),
  22490. +};
  22491. +
  22492. +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
  22493. +static struct ar8327_pad_cfg wr1043nd_v2_ar8327_pad0_cfg = {
  22494. + .mode = AR8327_PAD_MAC_SGMII,
  22495. + .sgmii_delay_en = true,
  22496. +};
  22497. +
  22498. +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
  22499. +static struct ar8327_pad_cfg wr1043nd_v2_ar8327_pad6_cfg = {
  22500. + .mode = AR8327_PAD_MAC_RGMII,
  22501. + .txclk_delay_en = true,
  22502. + .rxclk_delay_en = true,
  22503. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  22504. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  22505. +};
  22506. +
  22507. +static struct ar8327_led_cfg wr1043nd_v2_ar8327_led_cfg = {
  22508. + .led_ctrl0 = 0xcc35cc35,
  22509. + .led_ctrl1 = 0xca35ca35,
  22510. + .led_ctrl2 = 0xc935c935,
  22511. + .led_ctrl3 = 0x03ffff00,
  22512. + .open_drain = true,
  22513. +};
  22514. +
  22515. +static struct ar8327_platform_data wr1043nd_v2_ar8327_data = {
  22516. + .pad0_cfg = &wr1043nd_v2_ar8327_pad0_cfg,
  22517. + .pad6_cfg = &wr1043nd_v2_ar8327_pad6_cfg,
  22518. + .port0_cfg = {
  22519. + .force_link = 1,
  22520. + .speed = AR8327_PORT_SPEED_1000,
  22521. + .duplex = 1,
  22522. + .txpause = 1,
  22523. + .rxpause = 1,
  22524. + },
  22525. + .port6_cfg = {
  22526. + .force_link = 1,
  22527. + .speed = AR8327_PORT_SPEED_1000,
  22528. + .duplex = 1,
  22529. + .txpause = 1,
  22530. + .rxpause = 1,
  22531. + },
  22532. + .led_cfg = &wr1043nd_v2_ar8327_led_cfg,
  22533. + .num_leds = ARRAY_SIZE(tl_wr1043_leds_ar8327),
  22534. + .leds = tl_wr1043_leds_ar8327,
  22535. +};
  22536. +
  22537. +static struct mdio_board_info wr1043nd_v2_mdio0_info[] = {
  22538. + {
  22539. + .bus_id = "ag71xx-mdio.0",
  22540. + .phy_addr = 0,
  22541. + .platform_data = &wr1043nd_v2_ar8327_data,
  22542. + },
  22543. +};
  22544. +
  22545. +static void __init tl_wr1043nd_v2_setup(void)
  22546. +{
  22547. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22548. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  22549. +
  22550. + ath79_register_m25p80(&wr1043nd_v2_flash_data);
  22551. +
  22552. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043_v2_leds_gpio),
  22553. + tl_wr1043_v2_leds_gpio);
  22554. + ath79_register_gpio_keys_polled(-1, TL_WR1043_V2_KEYS_POLL_INTERVAL,
  22555. + ARRAY_SIZE(tl_wr1043_v2_gpio_keys),
  22556. + tl_wr1043_v2_gpio_keys);
  22557. +
  22558. + ath79_register_wmac(art + TL_WR1043_V2_WMAC_CALDATA_OFFSET, mac);
  22559. +
  22560. + mdiobus_register_board_info(wr1043nd_v2_mdio0_info,
  22561. + ARRAY_SIZE(wr1043nd_v2_mdio0_info));
  22562. + ath79_register_mdio(0, 0x0);
  22563. +
  22564. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  22565. +
  22566. + /* GMAC0 is connected to the RMGII interface */
  22567. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  22568. + ath79_eth0_data.phy_mask = BIT(0);
  22569. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  22570. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  22571. +
  22572. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  22573. + ath79_register_eth(0);
  22574. +
  22575. + /* GMAC1 is connected to the SGMII interface */
  22576. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  22577. + ath79_eth1_data.speed = SPEED_1000;
  22578. + ath79_eth1_data.duplex = DUPLEX_FULL;
  22579. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  22580. +
  22581. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  22582. + ath79_register_eth(1);
  22583. +
  22584. + ath79_register_usb();
  22585. +
  22586. + gpio_request_one(TL_WR1043_V2_GPIO_USB_POWER,
  22587. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  22588. + "USB power");
  22589. +}
  22590. +
  22591. +MIPS_MACHINE(ATH79_MACH_TL_WR1043ND_V2, "TL-WR1043ND-v2",
  22592. + "TP-LINK TL-WR1043ND v2", tl_wr1043nd_v2_setup);
  22593. +
  22594. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr2543n.c linux-4.1.13/arch/mips/ath79/mach-tl-wr2543n.c
  22595. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr2543n.c 1970-01-01 01:00:00.000000000 +0100
  22596. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr2543n.c 2015-09-13 20:04:35.072523889 +0200
  22597. @@ -0,0 +1,156 @@
  22598. +/*
  22599. + * TP-LINK TL-WR2543N/ND board support
  22600. + *
  22601. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  22602. + *
  22603. + * This program is free software; you can redistribute it and/or modify it
  22604. + * under the terms of the GNU General Public License version 2 as published
  22605. + * by the Free Software Foundation.
  22606. + */
  22607. +
  22608. +#include <linux/platform_device.h>
  22609. +#include <linux/rtl8367.h>
  22610. +
  22611. +#include <asm/mach-ath79/ath79.h>
  22612. +
  22613. +#include "dev-eth.h"
  22614. +#include "dev-ap9x-pci.h"
  22615. +#include "dev-gpio-buttons.h"
  22616. +#include "dev-leds-gpio.h"
  22617. +#include "dev-m25p80.h"
  22618. +#include "dev-usb.h"
  22619. +#include "machtypes.h"
  22620. +
  22621. +#define TL_WR2543N_GPIO_LED_WPS 0
  22622. +#define TL_WR2543N_GPIO_LED_USB 8
  22623. +
  22624. +/* The WLAN LEDs use GPIOs on the discrete AR9380 wmac */
  22625. +#define TL_WR2543N_GPIO_WMAC_LED_WLAN2G 0
  22626. +#define TL_WR2543N_GPIO_WMAC_LED_WLAN5G 1
  22627. +
  22628. +#define TL_WR2543N_GPIO_BTN_RESET 11
  22629. +#define TL_WR2543N_GPIO_BTN_WPS 12
  22630. +
  22631. +#define TL_WR2543N_GPIO_RTL8367_SDA 1
  22632. +#define TL_WR2543N_GPIO_RTL8367_SCK 6
  22633. +
  22634. +#define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */
  22635. +#define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL)
  22636. +
  22637. +static const char *tl_wr2543n_part_probes[] = {
  22638. + "tp-link",
  22639. + NULL,
  22640. +};
  22641. +
  22642. +static struct flash_platform_data tl_wr2543n_flash_data = {
  22643. + .part_probes = tl_wr2543n_part_probes,
  22644. +};
  22645. +
  22646. +static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = {
  22647. + {
  22648. + .name = "tp-link:green:usb",
  22649. + .gpio = TL_WR2543N_GPIO_LED_USB,
  22650. + .active_low = 1,
  22651. + }, {
  22652. + .name = "tp-link:green:wps",
  22653. + .gpio = TL_WR2543N_GPIO_LED_WPS,
  22654. + .active_low = 1,
  22655. + }
  22656. +};
  22657. +
  22658. +static struct gpio_led tl_wr2543n_wmac_leds_gpio[] = {
  22659. + {
  22660. + .name = "tp-link:green:wlan5g",
  22661. + .gpio = TL_WR2543N_GPIO_WMAC_LED_WLAN5G,
  22662. + .active_low = 1,
  22663. + },
  22664. +};
  22665. +
  22666. +static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = {
  22667. + {
  22668. + .desc = "reset",
  22669. + .type = EV_KEY,
  22670. + .code = KEY_RESTART,
  22671. + .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  22672. + .gpio = TL_WR2543N_GPIO_BTN_RESET,
  22673. + .active_low = 1,
  22674. + }, {
  22675. + .desc = "wps",
  22676. + .type = EV_KEY,
  22677. + .code = KEY_WPS_BUTTON,
  22678. + .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  22679. + .gpio = TL_WR2543N_GPIO_BTN_WPS,
  22680. + .active_low = 1,
  22681. + }
  22682. +};
  22683. +
  22684. +static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = {
  22685. + .mode = RTL8367_EXTIF_MODE_RGMII,
  22686. + .txdelay = 1,
  22687. + .rxdelay = 0,
  22688. + .ability = {
  22689. + .force_mode = 1,
  22690. + .txpause = 1,
  22691. + .rxpause = 1,
  22692. + .link = 1,
  22693. + .duplex = 1,
  22694. + .speed = RTL8367_PORT_SPEED_1000,
  22695. + },
  22696. +};
  22697. +
  22698. +static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = {
  22699. + .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA,
  22700. + .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK,
  22701. + .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg,
  22702. +};
  22703. +
  22704. +static struct platform_device tl_wr2543n_rtl8367_device = {
  22705. + .name = RTL8367_DRIVER_NAME,
  22706. + .id = -1,
  22707. + .dev = {
  22708. + .platform_data = &tl_wr2543n_rtl8367_data,
  22709. + }
  22710. +};
  22711. +
  22712. +static void __init tl_wr2543n_setup(void)
  22713. +{
  22714. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22715. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  22716. +
  22717. + ath79_register_m25p80(&tl_wr2543n_flash_data);
  22718. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio),
  22719. + tl_wr2543n_leds_gpio);
  22720. + ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL,
  22721. + ARRAY_SIZE(tl_wr2543n_gpio_keys),
  22722. + tl_wr2543n_gpio_keys);
  22723. + ath79_register_usb();
  22724. +
  22725. + /*
  22726. + * The ath9k driver uses this pin for its default led device, which is
  22727. + * named ath9k-phy0, and reflects activity on either the 2 GHz or 5 GHz
  22728. + * bands. This pin is connected to the WR2543's 2GHz WLAN LED.
  22729. + */
  22730. + ap9x_pci_setup_wmac_led_pin(0, TL_WR2543N_GPIO_WMAC_LED_WLAN2G);
  22731. +
  22732. + /*
  22733. + * We also have the driver set up an led device for the WR2543's
  22734. + * separate 5 GHz WLAN LED in case the user wants it.
  22735. + */
  22736. + ap9x_pci_setup_wmac_leds(0, tl_wr2543n_wmac_leds_gpio,
  22737. + ARRAY_SIZE(tl_wr2543n_wmac_leds_gpio));
  22738. + ap91_pci_init(eeprom, mac);
  22739. +
  22740. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  22741. + ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev;
  22742. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  22743. + ath79_eth0_data.speed = SPEED_1000;
  22744. + ath79_eth0_data.duplex = DUPLEX_FULL;
  22745. + ath79_eth0_pll_data.pll_1000 = 0x1a000000;
  22746. +
  22747. + ath79_register_eth(0);
  22748. +
  22749. + platform_device_register(&tl_wr2543n_rtl8367_device);
  22750. +}
  22751. +
  22752. +MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND",
  22753. + tl_wr2543n_setup);
  22754. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr703n.c linux-4.1.13/arch/mips/ath79/mach-tl-wr703n.c
  22755. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr703n.c 1970-01-01 01:00:00.000000000 +0100
  22756. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr703n.c 2015-09-13 20:04:35.072523889 +0200
  22757. @@ -0,0 +1,118 @@
  22758. +/*
  22759. + * TP-LINK TL-WR703N/TL-MR10U board support
  22760. + *
  22761. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  22762. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  22763. + *
  22764. + * This program is free software; you can redistribute it and/or modify it
  22765. + * under the terms of the GNU General Public License version 2 as published
  22766. + * by the Free Software Foundation.
  22767. + */
  22768. +
  22769. +#include <linux/gpio.h>
  22770. +
  22771. +#include <asm/mach-ath79/ath79.h>
  22772. +
  22773. +#include "dev-eth.h"
  22774. +#include "dev-gpio-buttons.h"
  22775. +#include "dev-leds-gpio.h"
  22776. +#include "dev-m25p80.h"
  22777. +#include "dev-usb.h"
  22778. +#include "dev-wmac.h"
  22779. +#include "machtypes.h"
  22780. +
  22781. +#define TL_WR703N_GPIO_LED_SYSTEM 27
  22782. +#define TL_WR703N_GPIO_BTN_RESET 11
  22783. +
  22784. +#define TL_WR703N_GPIO_USB_POWER 8
  22785. +
  22786. +#define TL_MR10U_GPIO_USB_POWER 18
  22787. +
  22788. +#define TL_WR703N_KEYS_POLL_INTERVAL 20 /* msecs */
  22789. +#define TL_WR703N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR703N_KEYS_POLL_INTERVAL)
  22790. +
  22791. +static const char *tl_wr703n_part_probes[] = {
  22792. + "tp-link",
  22793. + NULL,
  22794. +};
  22795. +
  22796. +static struct flash_platform_data tl_wr703n_flash_data = {
  22797. + .part_probes = tl_wr703n_part_probes,
  22798. +};
  22799. +
  22800. +static struct gpio_led tl_wr703n_leds_gpio[] __initdata = {
  22801. + {
  22802. + .name = "tp-link:blue:system",
  22803. + .gpio = TL_WR703N_GPIO_LED_SYSTEM,
  22804. + .active_low = 1,
  22805. + },
  22806. +};
  22807. +
  22808. +static struct gpio_keys_button tl_wr703n_gpio_keys[] __initdata = {
  22809. + {
  22810. + .desc = "reset",
  22811. + .type = EV_KEY,
  22812. + .code = KEY_RESTART,
  22813. + .debounce_interval = TL_WR703N_KEYS_DEBOUNCE_INTERVAL,
  22814. + .gpio = TL_WR703N_GPIO_BTN_RESET,
  22815. + .active_low = 0,
  22816. + }
  22817. +};
  22818. +
  22819. +static void __init common_setup(unsigned usb_power_gpio, bool sec_ethernet)
  22820. +{
  22821. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22822. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  22823. +
  22824. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  22825. + ath79_setup_ar933x_phy4_switch(false, false);
  22826. +
  22827. + ath79_register_m25p80(&tl_wr703n_flash_data);
  22828. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr703n_leds_gpio),
  22829. + tl_wr703n_leds_gpio);
  22830. + ath79_register_gpio_keys_polled(-1, TL_WR703N_KEYS_POLL_INTERVAL,
  22831. + ARRAY_SIZE(tl_wr703n_gpio_keys),
  22832. + tl_wr703n_gpio_keys);
  22833. +
  22834. + gpio_request_one(usb_power_gpio,
  22835. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  22836. + "USB power");
  22837. + ath79_register_usb();
  22838. +
  22839. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  22840. +
  22841. + ath79_register_mdio(0, 0x0);
  22842. + ath79_register_eth(0);
  22843. +
  22844. + if (sec_ethernet)
  22845. + {
  22846. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  22847. + ath79_register_eth(1);
  22848. + }
  22849. +
  22850. + ath79_register_wmac(ee, mac);
  22851. +}
  22852. +
  22853. +static void __init tl_mr10u_setup(void)
  22854. +{
  22855. + common_setup(TL_MR10U_GPIO_USB_POWER, false);
  22856. +}
  22857. +
  22858. +MIPS_MACHINE(ATH79_MACH_TL_MR10U, "TL-MR10U", "TP-LINK TL-MR10U",
  22859. + tl_mr10u_setup);
  22860. +
  22861. +static void __init tl_wr703n_setup(void)
  22862. +{
  22863. + common_setup(TL_WR703N_GPIO_USB_POWER, false);
  22864. +}
  22865. +
  22866. +MIPS_MACHINE(ATH79_MACH_TL_WR703N, "TL-WR703N", "TP-LINK TL-WR703N v1",
  22867. + tl_wr703n_setup);
  22868. +
  22869. +static void __init tl_wr710n_setup(void)
  22870. +{
  22871. + common_setup(TL_WR703N_GPIO_USB_POWER, true);
  22872. +}
  22873. +
  22874. +MIPS_MACHINE(ATH79_MACH_TL_WR710N, "TL-WR710N", "TP-LINK TL-WR710N v1",
  22875. + tl_wr710n_setup);
  22876. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr720n-v3.c linux-4.1.13/arch/mips/ath79/mach-tl-wr720n-v3.c
  22877. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr720n-v3.c 1970-01-01 01:00:00.000000000 +0100
  22878. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr720n-v3.c 2015-09-13 20:04:35.072523889 +0200
  22879. @@ -0,0 +1,108 @@
  22880. +/*
  22881. + * TP-LINK TL-WR720N board support
  22882. + *
  22883. + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  22884. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  22885. + * Copyright (C) 2013 yousong <yszhou4tech@gmail.com>
  22886. + *
  22887. + * This program is free software; you can redistribute it and/or modify it
  22888. + * under the terms of the GNU General Public License version 2 as published
  22889. + * by the Free Software Foundation.
  22890. + */
  22891. +
  22892. +#include <linux/gpio.h>
  22893. +
  22894. +#include <asm/mach-ath79/ath79.h>
  22895. +
  22896. +#include "dev-eth.h"
  22897. +#include "dev-gpio-buttons.h"
  22898. +#include "dev-leds-gpio.h"
  22899. +#include "dev-m25p80.h"
  22900. +#include "dev-usb.h"
  22901. +#include "dev-wmac.h"
  22902. +#include "machtypes.h"
  22903. +
  22904. +#define TL_WR720N_GPIO_LED_SYSTEM 27
  22905. +#define TL_WR720N_GPIO_BTN_RESET 11
  22906. +#define TL_WR720N_GPIO_BTN_SW1 18
  22907. +#define TL_WR720N_GPIO_BTN_SW2 20
  22908. +
  22909. +#define TL_WR720N_GPIO_USB_POWER 8
  22910. +
  22911. +#define TL_WR720N_KEYS_POLL_INTERVAL 20 /* msecs */
  22912. +#define TL_WR720N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR720N_KEYS_POLL_INTERVAL)
  22913. +
  22914. +static const char *tl_wr720n_part_probes[] = {
  22915. + "tp-link",
  22916. + NULL,
  22917. +};
  22918. +
  22919. +static struct flash_platform_data tl_wr720n_flash_data = {
  22920. + .part_probes = tl_wr720n_part_probes,
  22921. +};
  22922. +
  22923. +static struct gpio_led tl_wr720n_leds_gpio[] __initdata = {
  22924. + {
  22925. + .name = "tp-link:blue:system",
  22926. + .gpio = TL_WR720N_GPIO_LED_SYSTEM,
  22927. + .active_low = 1,
  22928. + },
  22929. +};
  22930. +
  22931. +static struct gpio_keys_button tl_wr720n_gpio_keys[] __initdata = {
  22932. + {
  22933. + .desc = "reset",
  22934. + .type = EV_KEY,
  22935. + .code = KEY_RESTART,
  22936. + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
  22937. + .gpio = TL_WR720N_GPIO_BTN_RESET,
  22938. + .active_low = 0,
  22939. + }, {
  22940. + .desc = "sw1",
  22941. + .type = EV_KEY,
  22942. + .code = BTN_0,
  22943. + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
  22944. + .gpio = TL_WR720N_GPIO_BTN_SW1,
  22945. + .active_low = 0,
  22946. + }, {
  22947. + .desc = "sw2",
  22948. + .type = EV_KEY,
  22949. + .code = BTN_1,
  22950. + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
  22951. + .gpio = TL_WR720N_GPIO_BTN_SW2,
  22952. + .active_low = 0,
  22953. + }
  22954. +};
  22955. +
  22956. +static void __init tl_wr720n_v3_setup(void)
  22957. +{
  22958. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  22959. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  22960. +
  22961. + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  22962. + ath79_setup_ar933x_phy4_switch(false, false);
  22963. +
  22964. + ath79_register_m25p80(&tl_wr720n_flash_data);
  22965. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr720n_leds_gpio),
  22966. + tl_wr720n_leds_gpio);
  22967. + ath79_register_gpio_keys_polled(-1, TL_WR720N_KEYS_POLL_INTERVAL,
  22968. + ARRAY_SIZE(tl_wr720n_gpio_keys),
  22969. + tl_wr720n_gpio_keys);
  22970. +
  22971. + gpio_request_one(TL_WR720N_GPIO_USB_POWER,
  22972. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  22973. + "USB power");
  22974. + ath79_register_usb();
  22975. +
  22976. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  22977. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
  22978. +
  22979. + ath79_register_mdio(0, 0x0);
  22980. + ath79_register_eth(0);
  22981. + ath79_register_eth(1);
  22982. +
  22983. + ath79_register_wmac(ee, mac);
  22984. +}
  22985. +
  22986. +MIPS_MACHINE(ATH79_MACH_TL_WR720N_V3, "TL-WR720N-v3", "TP-LINK TL-WR720N v3/v4",
  22987. + tl_wr720n_v3_setup);
  22988. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr741nd.c linux-4.1.13/arch/mips/ath79/mach-tl-wr741nd.c
  22989. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr741nd.c 1970-01-01 01:00:00.000000000 +0100
  22990. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr741nd.c 2015-09-13 20:04:35.072523889 +0200
  22991. @@ -0,0 +1,130 @@
  22992. +/*
  22993. + * TP-LINK TL-WR741ND board support
  22994. + *
  22995. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  22996. + *
  22997. + * This program is free software; you can redistribute it and/or modify it
  22998. + * under the terms of the GNU General Public License version 2 as published
  22999. + * by the Free Software Foundation.
  23000. + */
  23001. +
  23002. +#include <asm/mach-ath79/ath79.h>
  23003. +#include <asm/mach-ath79/ar71xx_regs.h>
  23004. +
  23005. +#include "common.h"
  23006. +#include "dev-ap9x-pci.h"
  23007. +#include "dev-eth.h"
  23008. +#include "dev-gpio-buttons.h"
  23009. +#include "dev-leds-gpio.h"
  23010. +#include "dev-m25p80.h"
  23011. +#include "machtypes.h"
  23012. +
  23013. +#define TL_WR741ND_GPIO_LED_QSS 0
  23014. +#define TL_WR741ND_GPIO_LED_SYSTEM 1
  23015. +#define TL_WR741ND_GPIO_LED_LAN1 13
  23016. +#define TL_WR741ND_GPIO_LED_LAN2 14
  23017. +#define TL_WR741ND_GPIO_LED_LAN3 15
  23018. +#define TL_WR741ND_GPIO_LED_LAN4 16
  23019. +#define TL_WR741ND_GPIO_LED_WAN 17
  23020. +
  23021. +#define TL_WR741ND_GPIO_BTN_RESET 11
  23022. +#define TL_WR741ND_GPIO_BTN_QSS 12
  23023. +
  23024. +#define TL_WR741ND_KEYS_POLL_INTERVAL 20 /* msecs */
  23025. +#define TL_WR741ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741ND_KEYS_POLL_INTERVAL)
  23026. +
  23027. +static const char *tl_wr741nd_part_probes[] = {
  23028. + "tp-link",
  23029. + NULL,
  23030. +};
  23031. +
  23032. +static struct flash_platform_data tl_wr741nd_flash_data = {
  23033. + .part_probes = tl_wr741nd_part_probes,
  23034. +};
  23035. +
  23036. +static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
  23037. + {
  23038. + .name = "tp-link:green:lan1",
  23039. + .gpio = TL_WR741ND_GPIO_LED_LAN1,
  23040. + .active_low = 1,
  23041. + }, {
  23042. + .name = "tp-link:green:lan2",
  23043. + .gpio = TL_WR741ND_GPIO_LED_LAN2,
  23044. + .active_low = 1,
  23045. + }, {
  23046. + .name = "tp-link:green:lan3",
  23047. + .gpio = TL_WR741ND_GPIO_LED_LAN3,
  23048. + .active_low = 1,
  23049. + }, {
  23050. + .name = "tp-link:green:lan4",
  23051. + .gpio = TL_WR741ND_GPIO_LED_LAN4,
  23052. + .active_low = 1,
  23053. + }, {
  23054. + .name = "tp-link:green:qss",
  23055. + .gpio = TL_WR741ND_GPIO_LED_QSS,
  23056. + .active_low = 1,
  23057. + }, {
  23058. + .name = "tp-link:green:system",
  23059. + .gpio = TL_WR741ND_GPIO_LED_SYSTEM,
  23060. + .active_low = 1,
  23061. + }, {
  23062. + .name = "tp-link:green:wan",
  23063. + .gpio = TL_WR741ND_GPIO_LED_WAN,
  23064. + .active_low = 1,
  23065. + },
  23066. +};
  23067. +
  23068. +static struct gpio_keys_button tl_wr741nd_gpio_keys[] __initdata = {
  23069. + {
  23070. + .desc = "reset",
  23071. + .type = EV_KEY,
  23072. + .code = KEY_RESTART,
  23073. + .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
  23074. + .gpio = TL_WR741ND_GPIO_BTN_RESET,
  23075. + .active_low = 1,
  23076. + }, {
  23077. + .desc = "qss",
  23078. + .type = EV_KEY,
  23079. + .code = KEY_WPS_BUTTON,
  23080. + .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
  23081. + .gpio = TL_WR741ND_GPIO_BTN_QSS,
  23082. + .active_low = 1,
  23083. + }
  23084. +};
  23085. +
  23086. +static void __init tl_wr741nd_setup(void)
  23087. +{
  23088. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23089. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  23090. +
  23091. + ath79_register_m25p80(&tl_wr741nd_flash_data);
  23092. +
  23093. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  23094. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  23095. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  23096. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  23097. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  23098. +
  23099. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
  23100. + tl_wr741nd_leds_gpio);
  23101. +
  23102. + ath79_register_gpio_keys_polled(-1, TL_WR741ND_KEYS_POLL_INTERVAL,
  23103. + ARRAY_SIZE(tl_wr741nd_gpio_keys),
  23104. + tl_wr741nd_gpio_keys);
  23105. +
  23106. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  23107. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  23108. +
  23109. + ath79_register_mdio(0, 0x0);
  23110. +
  23111. + /* LAN ports */
  23112. + ath79_register_eth(1);
  23113. +
  23114. + /* WAN port */
  23115. + ath79_register_eth(0);
  23116. +
  23117. + ap9x_pci_setup_wmac_led_pin(0, 1);
  23118. + ap91_pci_init(ee, mac);
  23119. +}
  23120. +MIPS_MACHINE(ATH79_MACH_TL_WR741ND, "TL-WR741ND", "TP-LINK TL-WR741ND",
  23121. + tl_wr741nd_setup);
  23122. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr741nd-v4.c linux-4.1.13/arch/mips/ath79/mach-tl-wr741nd-v4.c
  23123. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr741nd-v4.c 1970-01-01 01:00:00.000000000 +0100
  23124. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr741nd-v4.c 2015-09-13 20:04:35.072523889 +0200
  23125. @@ -0,0 +1,187 @@
  23126. +/*
  23127. + * TP-LINK TL-WR741ND v4/TL-MR3220 v2 board support
  23128. + *
  23129. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  23130. + *
  23131. + * This program is free software; you can redistribute it and/or modify it
  23132. + * under the terms of the GNU General Public License version 2 as published
  23133. + * by the Free Software Foundation.
  23134. + */
  23135. +
  23136. +#include <linux/gpio.h>
  23137. +
  23138. +#include <asm/mach-ath79/ath79.h>
  23139. +#include <asm/mach-ath79/ar71xx_regs.h>
  23140. +
  23141. +#include "common.h"
  23142. +#include "dev-eth.h"
  23143. +#include "dev-gpio-buttons.h"
  23144. +#include "dev-leds-gpio.h"
  23145. +#include "dev-m25p80.h"
  23146. +#include "dev-usb.h"
  23147. +#include "dev-wmac.h"
  23148. +#include "machtypes.h"
  23149. +
  23150. +#define TL_WR741NDV4_GPIO_BTN_RESET 11
  23151. +#define TL_WR741NDV4_GPIO_BTN_WPS 26
  23152. +
  23153. +#define TL_WR741NDV4_GPIO_LED_WLAN 0
  23154. +#define TL_WR741NDV4_GPIO_LED_QSS 1
  23155. +#define TL_WR741NDV4_GPIO_LED_WAN 13
  23156. +#define TL_WR741NDV4_GPIO_LED_LAN1 14
  23157. +#define TL_WR741NDV4_GPIO_LED_LAN2 15
  23158. +#define TL_WR741NDV4_GPIO_LED_LAN3 16
  23159. +#define TL_WR741NDV4_GPIO_LED_LAN4 17
  23160. +#define TL_WR741NDV4_GPIO_LED_SYSTEM 27
  23161. +
  23162. +#define TL_MR3220V2_GPIO_BTN_WPS 11
  23163. +#define TL_MR3220V2_GPIO_BTN_WIFI 24
  23164. +
  23165. +#define TL_MR3220V2_GPIO_LED_3G 26
  23166. +#define TL_MR3220V2_GPIO_USB_POWER 8
  23167. +
  23168. +#define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
  23169. +#define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
  23170. +
  23171. +static const char *tl_wr741ndv4_part_probes[] = {
  23172. + "tp-link",
  23173. + NULL,
  23174. +};
  23175. +
  23176. +static struct flash_platform_data tl_wr741ndv4_flash_data = {
  23177. + .part_probes = tl_wr741ndv4_part_probes,
  23178. +};
  23179. +
  23180. +static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
  23181. + {
  23182. + .name = "tp-link:green:lan1",
  23183. + .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
  23184. + .active_low = 0,
  23185. + }, {
  23186. + .name = "tp-link:green:lan2",
  23187. + .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
  23188. + .active_low = 0,
  23189. + }, {
  23190. + .name = "tp-link:green:lan3",
  23191. + .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
  23192. + .active_low = 0,
  23193. + }, {
  23194. + .name = "tp-link:green:lan4",
  23195. + .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
  23196. + .active_low = 1,
  23197. + }, {
  23198. + .name = "tp-link:green:qss",
  23199. + .gpio = TL_WR741NDV4_GPIO_LED_QSS,
  23200. + .active_low = 0,
  23201. + }, {
  23202. + .name = "tp-link:green:system",
  23203. + .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
  23204. + .active_low = 1,
  23205. + }, {
  23206. + .name = "tp-link:green:wan",
  23207. + .gpio = TL_WR741NDV4_GPIO_LED_WAN,
  23208. + .active_low = 0,
  23209. + }, {
  23210. + .name = "tp-link:green:wlan",
  23211. + .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
  23212. + .active_low = 0,
  23213. + }, {
  23214. + /* the 3G LED is only present on the MR3220 v2 */
  23215. + .name = "tp-link:green:3g",
  23216. + .gpio = TL_MR3220V2_GPIO_LED_3G,
  23217. + .active_low = 0,
  23218. + },
  23219. +};
  23220. +
  23221. +static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
  23222. + {
  23223. + .desc = "reset",
  23224. + .type = EV_KEY,
  23225. + .code = KEY_RESTART,
  23226. + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  23227. + .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
  23228. + .active_low = 0,
  23229. + }, {
  23230. + .desc = "WPS",
  23231. + .type = EV_KEY,
  23232. + .code = KEY_WPS_BUTTON,
  23233. + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  23234. + .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
  23235. + .active_low = 0,
  23236. + }
  23237. +};
  23238. +
  23239. +static struct gpio_keys_button tl_mr3220v2_gpio_keys[] __initdata = {
  23240. + {
  23241. + .desc = "WPS",
  23242. + .type = EV_KEY,
  23243. + .code = KEY_WPS_BUTTON,
  23244. + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  23245. + .gpio = TL_MR3220V2_GPIO_BTN_WPS,
  23246. + .active_low = 0,
  23247. + }, {
  23248. + .desc = "WIFI button",
  23249. + .type = EV_KEY,
  23250. + .code = KEY_RFKILL,
  23251. + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  23252. + .gpio = TL_MR3220V2_GPIO_BTN_WIFI,
  23253. + .active_low = 0,
  23254. + }
  23255. +};
  23256. +
  23257. +static void __init tl_ap121_setup(void)
  23258. +{
  23259. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23260. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  23261. +
  23262. + ath79_setup_ar933x_phy4_switch(true, true);
  23263. +
  23264. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  23265. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  23266. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  23267. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  23268. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  23269. +
  23270. + ath79_register_m25p80(&tl_wr741ndv4_flash_data);
  23271. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  23272. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  23273. +
  23274. + ath79_register_mdio(0, 0x0);
  23275. + ath79_register_eth(1);
  23276. + ath79_register_eth(0);
  23277. +
  23278. + ath79_register_wmac(ee, mac);
  23279. +}
  23280. +
  23281. +static void __init tl_wr741ndv4_setup(void)
  23282. +{
  23283. + tl_ap121_setup();
  23284. +
  23285. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
  23286. + tl_wr741ndv4_leds_gpio);
  23287. + ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
  23288. + ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
  23289. + tl_wr741ndv4_gpio_keys);
  23290. +}
  23291. +
  23292. +MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
  23293. + "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);
  23294. +
  23295. +static void __init tl_mr3220v2_setup(void)
  23296. +{
  23297. + tl_ap121_setup();
  23298. +
  23299. + gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
  23300. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  23301. + "USB power");
  23302. + ath79_register_usb();
  23303. +
  23304. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
  23305. + tl_wr741ndv4_leds_gpio);
  23306. + ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
  23307. + ARRAY_SIZE(tl_mr3220v2_gpio_keys),
  23308. + tl_mr3220v2_gpio_keys);
  23309. +}
  23310. +
  23311. +MIPS_MACHINE(ATH79_MACH_TL_MR3220_V2, "TL-MR3220-v2",
  23312. + "TP-LINK TL-MR3220 v2", tl_mr3220v2_setup);
  23313. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n.c linux-4.1.13/arch/mips/ath79/mach-tl-wr841n.c
  23314. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n.c 1970-01-01 01:00:00.000000000 +0100
  23315. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr841n.c 2015-09-13 20:04:35.072523889 +0200
  23316. @@ -0,0 +1,140 @@
  23317. +/*
  23318. + * TP-LINK TL-WR841N/ND v1 board support
  23319. + *
  23320. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  23321. + *
  23322. + * This program is free software; you can redistribute it and/or modify it
  23323. + * under the terms of the GNU General Public License version 2 as published
  23324. + * by the Free Software Foundation.
  23325. + */
  23326. +
  23327. +#include <linux/mtd/mtd.h>
  23328. +#include <linux/mtd/partitions.h>
  23329. +#include <linux/platform_device.h>
  23330. +
  23331. +#include <asm/mach-ath79/ath79.h>
  23332. +
  23333. +#include "dev-dsa.h"
  23334. +#include "dev-eth.h"
  23335. +#include "dev-gpio-buttons.h"
  23336. +#include "dev-leds-gpio.h"
  23337. +#include "dev-m25p80.h"
  23338. +#include "machtypes.h"
  23339. +#include "pci.h"
  23340. +
  23341. +#define TL_WR841ND_V1_GPIO_LED_SYSTEM 2
  23342. +#define TL_WR841ND_V1_GPIO_LED_QSS_GREEN 4
  23343. +#define TL_WR841ND_V1_GPIO_LED_QSS_RED 5
  23344. +
  23345. +#define TL_WR841ND_V1_GPIO_BTN_RESET 3
  23346. +#define TL_WR841ND_V1_GPIO_BTN_QSS 7
  23347. +
  23348. +#define TL_WR841ND_V1_KEYS_POLL_INTERVAL 20 /* msecs */
  23349. +#define TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL \
  23350. + (3 * TL_WR841ND_V1_KEYS_POLL_INTERVAL)
  23351. +
  23352. +static struct mtd_partition tl_wr841n_v1_partitions[] = {
  23353. + {
  23354. + .name = "redboot",
  23355. + .offset = 0,
  23356. + .size = 0x020000,
  23357. + .mask_flags = MTD_WRITEABLE,
  23358. + }, {
  23359. + .name = "kernel",
  23360. + .offset = 0x020000,
  23361. + .size = 0x140000,
  23362. + }, {
  23363. + .name = "rootfs",
  23364. + .offset = 0x160000,
  23365. + .size = 0x280000,
  23366. + }, {
  23367. + .name = "config",
  23368. + .offset = 0x3e0000,
  23369. + .size = 0x020000,
  23370. + .mask_flags = MTD_WRITEABLE,
  23371. + }, {
  23372. + .name = "firmware",
  23373. + .offset = 0x020000,
  23374. + .size = 0x3c0000,
  23375. + }
  23376. +};
  23377. +
  23378. +static struct flash_platform_data tl_wr841n_v1_flash_data = {
  23379. + .parts = tl_wr841n_v1_partitions,
  23380. + .nr_parts = ARRAY_SIZE(tl_wr841n_v1_partitions),
  23381. +};
  23382. +
  23383. +static struct gpio_led tl_wr841n_v1_leds_gpio[] __initdata = {
  23384. + {
  23385. + .name = "tp-link:green:system",
  23386. + .gpio = TL_WR841ND_V1_GPIO_LED_SYSTEM,
  23387. + .active_low = 1,
  23388. + }, {
  23389. + .name = "tp-link:red:qss",
  23390. + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_RED,
  23391. + }, {
  23392. + .name = "tp-link:green:qss",
  23393. + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_GREEN,
  23394. + }
  23395. +};
  23396. +
  23397. +static struct gpio_keys_button tl_wr841n_v1_gpio_keys[] __initdata = {
  23398. + {
  23399. + .desc = "reset",
  23400. + .type = EV_KEY,
  23401. + .code = KEY_RESTART,
  23402. + .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
  23403. + .gpio = TL_WR841ND_V1_GPIO_BTN_RESET,
  23404. + .active_low = 1,
  23405. + }, {
  23406. + .desc = "qss",
  23407. + .type = EV_KEY,
  23408. + .code = KEY_WPS_BUTTON,
  23409. + .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
  23410. + .gpio = TL_WR841ND_V1_GPIO_BTN_QSS,
  23411. + .active_low = 1,
  23412. + }
  23413. +};
  23414. +
  23415. +static struct dsa_chip_data tl_wr841n_v1_dsa_chip = {
  23416. + .port_names[0] = "wan",
  23417. + .port_names[1] = "lan1",
  23418. + .port_names[2] = "lan2",
  23419. + .port_names[3] = "lan3",
  23420. + .port_names[4] = "lan4",
  23421. + .port_names[5] = "cpu",
  23422. +};
  23423. +
  23424. +static struct dsa_platform_data tl_wr841n_v1_dsa_data = {
  23425. + .nr_chips = 1,
  23426. + .chip = &tl_wr841n_v1_dsa_chip,
  23427. +};
  23428. +
  23429. +static void __init tl_wr841n_v1_setup(void)
  23430. +{
  23431. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23432. +
  23433. + ath79_register_mdio(0, 0x0);
  23434. +
  23435. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  23436. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  23437. + ath79_eth0_data.speed = SPEED_100;
  23438. + ath79_eth0_data.duplex = DUPLEX_FULL;
  23439. +
  23440. + ath79_register_eth(0);
  23441. + ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
  23442. + &tl_wr841n_v1_dsa_data);
  23443. +
  23444. + ath79_register_m25p80(&tl_wr841n_v1_flash_data);
  23445. +
  23446. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v1_leds_gpio),
  23447. + tl_wr841n_v1_leds_gpio);
  23448. +
  23449. + ath79_register_gpio_keys_polled(-1, TL_WR841ND_V1_KEYS_POLL_INTERVAL,
  23450. + ARRAY_SIZE(tl_wr841n_v1_gpio_keys),
  23451. + tl_wr841n_v1_gpio_keys);
  23452. + ath79_register_pci();
  23453. +}
  23454. +
  23455. +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V1, "TL-WR841N-v1.5", "TP-LINK TL-WR841N v1",
  23456. + tl_wr841n_v1_setup);
  23457. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n-v8.c linux-4.1.13/arch/mips/ath79/mach-tl-wr841n-v8.c
  23458. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n-v8.c 1970-01-01 01:00:00.000000000 +0100
  23459. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr841n-v8.c 2015-09-13 20:04:35.072523889 +0200
  23460. @@ -0,0 +1,286 @@
  23461. +/*
  23462. + * TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support
  23463. + *
  23464. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  23465. + *
  23466. + * This program is free software; you can redistribute it and/or modify it
  23467. + * under the terms of the GNU General Public License version 2 as published
  23468. + * by the Free Software Foundation.
  23469. + */
  23470. +
  23471. +#include <linux/gpio.h>
  23472. +#include <linux/platform_device.h>
  23473. +
  23474. +#include <asm/mach-ath79/ath79.h>
  23475. +#include <asm/mach-ath79/ar71xx_regs.h>
  23476. +
  23477. +#include "common.h"
  23478. +#include "dev-eth.h"
  23479. +#include "dev-gpio-buttons.h"
  23480. +#include "dev-leds-gpio.h"
  23481. +#include "dev-m25p80.h"
  23482. +#include "dev-usb.h"
  23483. +#include "dev-wmac.h"
  23484. +#include "machtypes.h"
  23485. +
  23486. +#define TL_WR841NV8_GPIO_LED_WLAN 13
  23487. +#define TL_WR841NV8_GPIO_LED_QSS 15
  23488. +#define TL_WR841NV8_GPIO_LED_WAN 18
  23489. +#define TL_WR841NV8_GPIO_LED_LAN1 19
  23490. +#define TL_WR841NV8_GPIO_LED_LAN2 20
  23491. +#define TL_WR841NV8_GPIO_LED_LAN3 21
  23492. +#define TL_WR841NV8_GPIO_LED_LAN4 12
  23493. +#define TL_WR841NV8_GPIO_LED_SYSTEM 14
  23494. +
  23495. +#define TL_WR841NV8_GPIO_BTN_RESET 17
  23496. +#define TL_WR841NV8_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
  23497. +
  23498. +#define TL_MR3420V2_GPIO_LED_3G 11
  23499. +#define TL_MR3420V2_GPIO_USB_POWER 4
  23500. +
  23501. +#define TL_WR941NDV5_GPIO_LED_WLAN 13
  23502. +#define TL_WR941NDV5_GPIO_LED_QSS 15
  23503. +#define TL_WR941NDV5_GPIO_LED_WAN 18
  23504. +#define TL_WR941NDV5_GPIO_LED_LAN1 19
  23505. +#define TL_WR941NDV5_GPIO_LED_LAN2 20
  23506. +#define TL_WR941NDV5_GPIO_LED_LAN3 2
  23507. +#define TL_WR941NDV5_GPIO_LED_LAN4 3
  23508. +#define TL_WR941NDV5_GPIO_LED_SYSTEM 14
  23509. +
  23510. +#define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */
  23511. +#define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL)
  23512. +
  23513. +static const char *tl_wr841n_v8_part_probes[] = {
  23514. + "tp-link",
  23515. + NULL,
  23516. +};
  23517. +
  23518. +static struct flash_platform_data tl_wr841n_v8_flash_data = {
  23519. + .part_probes = tl_wr841n_v8_part_probes,
  23520. +};
  23521. +
  23522. +static struct gpio_led tl_wr841n_v8_leds_gpio[] __initdata = {
  23523. + {
  23524. + .name = "tp-link:green:lan1",
  23525. + .gpio = TL_WR841NV8_GPIO_LED_LAN1,
  23526. + .active_low = 1,
  23527. + }, {
  23528. + .name = "tp-link:green:lan2",
  23529. + .gpio = TL_WR841NV8_GPIO_LED_LAN2,
  23530. + .active_low = 1,
  23531. + }, {
  23532. + .name = "tp-link:green:lan3",
  23533. + .gpio = TL_WR841NV8_GPIO_LED_LAN3,
  23534. + .active_low = 1,
  23535. + }, {
  23536. + .name = "tp-link:green:lan4",
  23537. + .gpio = TL_WR841NV8_GPIO_LED_LAN4,
  23538. + .active_low = 1,
  23539. + }, {
  23540. + .name = "tp-link:green:qss",
  23541. + .gpio = TL_WR841NV8_GPIO_LED_QSS,
  23542. + .active_low = 1,
  23543. + }, {
  23544. + .name = "tp-link:green:system",
  23545. + .gpio = TL_WR841NV8_GPIO_LED_SYSTEM,
  23546. + .active_low = 1,
  23547. + }, {
  23548. + .name = "tp-link:green:wan",
  23549. + .gpio = TL_WR841NV8_GPIO_LED_WAN,
  23550. + .active_low = 1,
  23551. + }, {
  23552. + .name = "tp-link:green:wlan",
  23553. + .gpio = TL_WR841NV8_GPIO_LED_WLAN,
  23554. + .active_low = 1,
  23555. + }, {
  23556. + /* the 3G LED is only present on the MR3420 v2 */
  23557. + .name = "tp-link:green:3g",
  23558. + .gpio = TL_MR3420V2_GPIO_LED_3G,
  23559. + .active_low = 1,
  23560. + },
  23561. +};
  23562. +
  23563. +static struct gpio_keys_button tl_wr841n_v8_gpio_keys[] __initdata = {
  23564. + {
  23565. + .desc = "Reset button",
  23566. + .type = EV_KEY,
  23567. + .code = KEY_RESTART,
  23568. + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
  23569. + .gpio = TL_WR841NV8_GPIO_BTN_RESET,
  23570. + .active_low = 1,
  23571. + }, {
  23572. + .desc = "RFKILL switch",
  23573. + .type = EV_SW,
  23574. + .code = KEY_RFKILL,
  23575. + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
  23576. + .gpio = TL_WR841NV8_GPIO_SW_RFKILL,
  23577. + .active_low = 0,
  23578. + }
  23579. +};
  23580. +
  23581. +static struct gpio_keys_button tl_mr3420v2_gpio_keys[] __initdata = {
  23582. + {
  23583. + .desc = "Reset button",
  23584. + .type = EV_KEY,
  23585. + .code = KEY_RESTART,
  23586. + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
  23587. + .gpio = TL_WR841NV8_GPIO_BTN_RESET,
  23588. + .active_low = 1,
  23589. + }, {
  23590. + .desc = "WPS",
  23591. + .type = EV_KEY,
  23592. + .code = KEY_WPS_BUTTON,
  23593. + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
  23594. + .gpio = TL_WR841NV8_GPIO_SW_RFKILL,
  23595. + .active_low = 0,
  23596. + }
  23597. +};
  23598. +
  23599. +static struct gpio_led tl_wr941nd_v5_leds_gpio[] __initdata = {
  23600. + {
  23601. + .name = "tp-link:green:lan1",
  23602. + .gpio = TL_WR941NDV5_GPIO_LED_LAN1,
  23603. + .active_low = 1,
  23604. + }, {
  23605. + .name = "tp-link:green:lan2",
  23606. + .gpio = TL_WR941NDV5_GPIO_LED_LAN2,
  23607. + .active_low = 1,
  23608. + }, {
  23609. + .name = "tp-link:green:lan3",
  23610. + .gpio = TL_WR941NDV5_GPIO_LED_LAN3,
  23611. + .active_low = 1,
  23612. + }, {
  23613. + .name = "tp-link:green:lan4",
  23614. + .gpio = TL_WR941NDV5_GPIO_LED_LAN4,
  23615. + .active_low = 1,
  23616. + }, {
  23617. + .name = "tp-link:green:qss",
  23618. + .gpio = TL_WR941NDV5_GPIO_LED_QSS,
  23619. + .active_low = 1,
  23620. + }, {
  23621. + .name = "tp-link:green:system",
  23622. + .gpio = TL_WR941NDV5_GPIO_LED_SYSTEM,
  23623. + .active_low = 1,
  23624. + }, {
  23625. + .name = "tp-link:green:wan",
  23626. + .gpio = TL_WR941NDV5_GPIO_LED_WAN,
  23627. + .active_low = 1,
  23628. + }, {
  23629. + .name = "tp-link:green:wlan",
  23630. + .gpio = TL_WR941NDV5_GPIO_LED_WLAN,
  23631. + .active_low = 1,
  23632. + },
  23633. +};
  23634. +
  23635. +static void __init tl_ap123_setup(void)
  23636. +{
  23637. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23638. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  23639. +
  23640. + /* Disable JTAG, enabling GPIOs 0-3 */
  23641. + /* Configure OBS4 line, for GPIO 4*/
  23642. + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  23643. + AR934X_GPIO_FUNC_CLK_OBS4_EN);
  23644. +
  23645. + /* config gpio4 as normal gpio function */
  23646. + ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER,
  23647. + AR934X_GPIO_OUT_GPIO);
  23648. +
  23649. + ath79_register_m25p80(&tl_wr841n_v8_flash_data);
  23650. +
  23651. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  23652. +
  23653. + ath79_register_mdio(1, 0x0);
  23654. +
  23655. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  23656. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  23657. +
  23658. + /* GMAC0 is connected to the PHY0 of the internal switch */
  23659. + ath79_switch_data.phy4_mii_en = 1;
  23660. + ath79_switch_data.phy_poll_mask = BIT(0);
  23661. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  23662. + ath79_eth0_data.phy_mask = BIT(0);
  23663. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  23664. + ath79_register_eth(0);
  23665. +
  23666. + /* GMAC1 is connected to the internal switch */
  23667. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  23668. + ath79_register_eth(1);
  23669. +
  23670. + ath79_register_wmac(ee, mac);
  23671. +}
  23672. +
  23673. +static void __init tl_wr841n_v8_setup(void)
  23674. +{
  23675. + tl_ap123_setup();
  23676. +
  23677. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio) - 1,
  23678. + tl_wr841n_v8_leds_gpio);
  23679. +
  23680. + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
  23681. + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
  23682. + tl_wr841n_v8_gpio_keys);
  23683. +}
  23684. +
  23685. +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8",
  23686. + tl_wr841n_v8_setup);
  23687. +
  23688. +
  23689. +static void __init tl_wr842n_v2_setup(void)
  23690. +{
  23691. + tl_ap123_setup();
  23692. +
  23693. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
  23694. + tl_wr841n_v8_leds_gpio);
  23695. +
  23696. + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
  23697. + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
  23698. + tl_wr841n_v8_gpio_keys);
  23699. +
  23700. + gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,
  23701. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  23702. + "USB power");
  23703. +
  23704. + ath79_register_usb();
  23705. +}
  23706. +
  23707. +MIPS_MACHINE(ATH79_MACH_TL_WR842N_V2, "TL-WR842N-v2", "TP-LINK TL-WR842N/ND v2",
  23708. + tl_wr842n_v2_setup);
  23709. +
  23710. +static void __init tl_mr3420v2_setup(void)
  23711. +{
  23712. + tl_ap123_setup();
  23713. +
  23714. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
  23715. + tl_wr841n_v8_leds_gpio);
  23716. +
  23717. + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
  23718. + ARRAY_SIZE(tl_mr3420v2_gpio_keys),
  23719. + tl_mr3420v2_gpio_keys);
  23720. +
  23721. + /* enable power for the USB port */
  23722. + gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,
  23723. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  23724. + "USB power");
  23725. +
  23726. + ath79_register_usb();
  23727. +}
  23728. +
  23729. +MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2",
  23730. + tl_mr3420v2_setup);
  23731. +
  23732. +
  23733. +static void __init tl_wr941nd_v5_setup(void)
  23734. +{
  23735. + tl_ap123_setup();
  23736. +
  23737. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v5_leds_gpio),
  23738. + tl_wr941nd_v5_leds_gpio);
  23739. +
  23740. + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
  23741. + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
  23742. + tl_wr841n_v8_gpio_keys);
  23743. +}
  23744. +
  23745. +MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V5, "TL-WR941ND-v5", "TP-LINK TL-WR941N/ND v5",
  23746. + tl_wr941nd_v5_setup);
  23747. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n-v9.c linux-4.1.13/arch/mips/ath79/mach-tl-wr841n-v9.c
  23748. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr841n-v9.c 1970-01-01 01:00:00.000000000 +0100
  23749. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr841n-v9.c 2015-09-13 20:04:35.072523889 +0200
  23750. @@ -0,0 +1,144 @@
  23751. +/*
  23752. + * TP-LINK TL-WR841N/ND v9
  23753. + *
  23754. + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
  23755. + *
  23756. + * This program is free software; you can redistribute it and/or modify it
  23757. + * under the terms of the GNU General Public License version 2 as published
  23758. + * by the Free Software Foundation.
  23759. + */
  23760. +
  23761. +#include <linux/gpio.h>
  23762. +#include <linux/platform_device.h>
  23763. +
  23764. +#include <asm/mach-ath79/ath79.h>
  23765. +#include <asm/mach-ath79/ar71xx_regs.h>
  23766. +
  23767. +#include "common.h"
  23768. +#include "dev-eth.h"
  23769. +#include "dev-gpio-buttons.h"
  23770. +#include "dev-leds-gpio.h"
  23771. +#include "dev-m25p80.h"
  23772. +#include "dev-wmac.h"
  23773. +#include "machtypes.h"
  23774. +
  23775. +#define TL_WR841NV9_GPIO_LED_WLAN 13
  23776. +#define TL_WR841NV9_GPIO_LED_QSS 3
  23777. +#define TL_WR841NV9_GPIO_LED_WAN 4
  23778. +#define TL_WR841NV9_GPIO_LED_LAN1 16
  23779. +#define TL_WR841NV9_GPIO_LED_LAN2 15
  23780. +#define TL_WR841NV9_GPIO_LED_LAN3 14
  23781. +#define TL_WR841NV9_GPIO_LED_LAN4 11
  23782. +
  23783. +#define TL_WR841NV9_GPIO_BTN_RESET 12
  23784. +#define TL_WR841NV9_GPIO_BTN_WIFI 17
  23785. +
  23786. +#define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
  23787. +#define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
  23788. +
  23789. +static const char *tl_wr841n_v9_part_probes[] = {
  23790. + "tp-link",
  23791. + NULL,
  23792. +};
  23793. +
  23794. +static struct flash_platform_data tl_wr841n_v9_flash_data = {
  23795. + .part_probes = tl_wr841n_v9_part_probes,
  23796. +};
  23797. +
  23798. +static struct gpio_led tl_wr841n_v9_leds_gpio[] __initdata = {
  23799. + {
  23800. + .name = "tp-link:green:lan1",
  23801. + .gpio = TL_WR841NV9_GPIO_LED_LAN1,
  23802. + .active_low = 1,
  23803. + }, {
  23804. + .name = "tp-link:green:lan2",
  23805. + .gpio = TL_WR841NV9_GPIO_LED_LAN2,
  23806. + .active_low = 1,
  23807. + }, {
  23808. + .name = "tp-link:green:lan3",
  23809. + .gpio = TL_WR841NV9_GPIO_LED_LAN3,
  23810. + .active_low = 1,
  23811. + }, {
  23812. + .name = "tp-link:green:lan4",
  23813. + .gpio = TL_WR841NV9_GPIO_LED_LAN4,
  23814. + .active_low = 1,
  23815. + }, {
  23816. + .name = "tp-link:green:qss",
  23817. + .gpio = TL_WR841NV9_GPIO_LED_QSS,
  23818. + .active_low = 1,
  23819. + }, {
  23820. + .name = "tp-link:green:wan",
  23821. + .gpio = TL_WR841NV9_GPIO_LED_WAN,
  23822. + .active_low = 1,
  23823. + }, {
  23824. + .name = "tp-link:green:wlan",
  23825. + .gpio = TL_WR841NV9_GPIO_LED_WLAN,
  23826. + .active_low = 1,
  23827. + },
  23828. +};
  23829. +
  23830. +static struct gpio_keys_button tl_wr841n_v9_gpio_keys[] __initdata = {
  23831. + {
  23832. + .desc = "Reset button",
  23833. + .type = EV_KEY,
  23834. + .code = KEY_RESTART,
  23835. + .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
  23836. + .gpio = TL_WR841NV9_GPIO_BTN_RESET,
  23837. + .active_low = 1,
  23838. + }, {
  23839. + .desc = "WIFI button",
  23840. + .type = EV_KEY,
  23841. + .code = KEY_RFKILL,
  23842. + .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
  23843. + .gpio = TL_WR841NV9_GPIO_BTN_WIFI,
  23844. + .active_low = 1,
  23845. + }
  23846. +};
  23847. +
  23848. +
  23849. +static void __init tl_ap143_setup(void)
  23850. +{
  23851. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23852. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  23853. + u8 tmpmac[ETH_ALEN];
  23854. +
  23855. + ath79_register_m25p80(&tl_wr841n_v9_flash_data);
  23856. +
  23857. + ath79_setup_ar933x_phy4_switch(false, false);
  23858. +
  23859. + ath79_register_mdio(0, 0x0);
  23860. +
  23861. + /* LAN */
  23862. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  23863. + ath79_eth1_data.duplex = DUPLEX_FULL;
  23864. + ath79_switch_data.phy_poll_mask |= BIT(4);
  23865. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  23866. + ath79_register_eth(1);
  23867. +
  23868. + /* WAN */
  23869. + ath79_switch_data.phy4_mii_en = 1;
  23870. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  23871. + ath79_eth0_data.duplex = DUPLEX_FULL;
  23872. + ath79_eth0_data.speed = SPEED_100;
  23873. + ath79_eth0_data.phy_mask = BIT(4);
  23874. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  23875. + ath79_register_eth(0);
  23876. +
  23877. + ath79_init_mac(tmpmac, mac, 0);
  23878. + ath79_register_wmac(ee, tmpmac);
  23879. +}
  23880. +
  23881. +static void __init tl_wr841n_v9_setup(void)
  23882. +{
  23883. + tl_ap143_setup();
  23884. +
  23885. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v9_leds_gpio),
  23886. + tl_wr841n_v9_leds_gpio);
  23887. +
  23888. + ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
  23889. + ARRAY_SIZE(tl_wr841n_v9_gpio_keys),
  23890. + tl_wr841n_v9_gpio_keys);
  23891. +}
  23892. +
  23893. +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V9, "TL-WR841N-v9", "TP-LINK TL-WR841N/ND v9",
  23894. + tl_wr841n_v9_setup);
  23895. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr941nd.c linux-4.1.13/arch/mips/ath79/mach-tl-wr941nd.c
  23896. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr941nd.c 1970-01-01 01:00:00.000000000 +0100
  23897. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr941nd.c 2015-09-13 20:04:35.072523889 +0200
  23898. @@ -0,0 +1,121 @@
  23899. +/*
  23900. + * TP-LINK TL-WR941ND board support
  23901. + *
  23902. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  23903. + *
  23904. + * This program is free software; you can redistribute it and/or modify it
  23905. + * under the terms of the GNU General Public License version 2 as published
  23906. + * by the Free Software Foundation.
  23907. + */
  23908. +
  23909. +#include <linux/platform_device.h>
  23910. +
  23911. +#include <asm/mach-ath79/ath79.h>
  23912. +
  23913. +#include "dev-dsa.h"
  23914. +#include "dev-eth.h"
  23915. +#include "dev-gpio-buttons.h"
  23916. +#include "dev-leds-gpio.h"
  23917. +#include "dev-m25p80.h"
  23918. +#include "dev-wmac.h"
  23919. +#include "machtypes.h"
  23920. +
  23921. +#define TL_WR941ND_GPIO_LED_SYSTEM 2
  23922. +#define TL_WR941ND_GPIO_LED_QSS_RED 4
  23923. +#define TL_WR941ND_GPIO_LED_QSS_GREEN 5
  23924. +#define TL_WR941ND_GPIO_LED_WLAN 9
  23925. +
  23926. +#define TL_WR941ND_GPIO_BTN_RESET 3
  23927. +#define TL_WR941ND_GPIO_BTN_QSS 7
  23928. +
  23929. +#define TL_WR941ND_KEYS_POLL_INTERVAL 20 /* msecs */
  23930. +#define TL_WR941ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_KEYS_POLL_INTERVAL)
  23931. +
  23932. +static const char *tl_wr941nd_part_probes[] = {
  23933. + "tp-link",
  23934. + NULL,
  23935. +};
  23936. +
  23937. +static struct flash_platform_data tl_wr941nd_flash_data = {
  23938. + .part_probes = tl_wr941nd_part_probes,
  23939. +};
  23940. +
  23941. +static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
  23942. + {
  23943. + .name = "tp-link:green:system",
  23944. + .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
  23945. + .active_low = 1,
  23946. + }, {
  23947. + .name = "tp-link:red:qss",
  23948. + .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
  23949. + }, {
  23950. + .name = "tp-link:green:qss",
  23951. + .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
  23952. + }, {
  23953. + .name = "tp-link:green:wlan",
  23954. + .gpio = TL_WR941ND_GPIO_LED_WLAN,
  23955. + .active_low = 1,
  23956. + }
  23957. +};
  23958. +
  23959. +static struct gpio_keys_button tl_wr941nd_gpio_keys[] __initdata = {
  23960. + {
  23961. + .desc = "reset",
  23962. + .type = EV_KEY,
  23963. + .code = KEY_RESTART,
  23964. + .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
  23965. + .gpio = TL_WR941ND_GPIO_BTN_RESET,
  23966. + .active_low = 1,
  23967. + }, {
  23968. + .desc = "qss",
  23969. + .type = EV_KEY,
  23970. + .code = KEY_WPS_BUTTON,
  23971. + .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
  23972. + .gpio = TL_WR941ND_GPIO_BTN_QSS,
  23973. + .active_low = 1,
  23974. + }
  23975. +};
  23976. +
  23977. +static struct dsa_chip_data tl_wr941nd_dsa_chip = {
  23978. + .port_names[0] = "wan",
  23979. + .port_names[1] = "lan1",
  23980. + .port_names[2] = "lan2",
  23981. + .port_names[3] = "lan3",
  23982. + .port_names[4] = "lan4",
  23983. + .port_names[5] = "cpu",
  23984. +};
  23985. +
  23986. +static struct dsa_platform_data tl_wr941nd_dsa_data = {
  23987. + .nr_chips = 1,
  23988. + .chip = &tl_wr941nd_dsa_chip,
  23989. +};
  23990. +
  23991. +static void __init tl_wr941nd_setup(void)
  23992. +{
  23993. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  23994. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  23995. +
  23996. + ath79_register_mdio(0, 0x0);
  23997. +
  23998. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  23999. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  24000. + ath79_eth0_data.speed = SPEED_100;
  24001. + ath79_eth0_data.duplex = DUPLEX_FULL;
  24002. +
  24003. + ath79_register_eth(0);
  24004. + ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
  24005. + &tl_wr941nd_dsa_data);
  24006. +
  24007. + ath79_register_m25p80(&tl_wr941nd_flash_data);
  24008. +
  24009. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
  24010. + tl_wr941nd_leds_gpio);
  24011. +
  24012. + ath79_register_gpio_keys_polled(-1, TL_WR941ND_KEYS_POLL_INTERVAL,
  24013. + ARRAY_SIZE(tl_wr941nd_gpio_keys),
  24014. + tl_wr941nd_gpio_keys);
  24015. + ath79_register_wmac(eeprom, mac);
  24016. +}
  24017. +
  24018. +MIPS_MACHINE(ATH79_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
  24019. + tl_wr941nd_setup);
  24020. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr941nd-v6.c linux-4.1.13/arch/mips/ath79/mach-tl-wr941nd-v6.c
  24021. --- linux-4.1.13.orig/arch/mips/ath79/mach-tl-wr941nd-v6.c 1970-01-01 01:00:00.000000000 +0100
  24022. +++ linux-4.1.13/arch/mips/ath79/mach-tl-wr941nd-v6.c 2015-11-21 17:22:11.759223549 +0100
  24023. @@ -0,0 +1,149 @@
  24024. +/*
  24025. + * TP-LINK TL-WR941N/ND v6 board support
  24026. + *
  24027. + * Copyright (C) 2015 Matthias Schiffer <mschiffer@universe-factory.net>
  24028. + *
  24029. + * This program is free software; you can redistribute it and/or modify it
  24030. + * under the terms of the GNU General Public License version 2 as published
  24031. + * by the Free Software Foundation.
  24032. + */
  24033. +
  24034. +#include <linux/gpio.h>
  24035. +#include <linux/platform_device.h>
  24036. +
  24037. +#include <asm/mach-ath79/ath79.h>
  24038. +#include <asm/mach-ath79/ar71xx_regs.h>
  24039. +
  24040. +#include "common.h"
  24041. +#include "dev-eth.h"
  24042. +#include "dev-gpio-buttons.h"
  24043. +#include "dev-leds-gpio.h"
  24044. +#include "dev-m25p80.h"
  24045. +#include "dev-wmac.h"
  24046. +#include "machtypes.h"
  24047. +
  24048. +
  24049. +#define TL_WR941ND_V6_GPIO_LED_QSS 3
  24050. +#define TL_WR941ND_V6_GPIO_LED_WAN 14
  24051. +#define TL_WR941ND_V6_GPIO_LED_WAN_RED 15
  24052. +#define TL_WR941ND_V6_GPIO_LED_LAN1 7
  24053. +#define TL_WR941ND_V6_GPIO_LED_LAN2 6
  24054. +#define TL_WR941ND_V6_GPIO_LED_LAN3 5
  24055. +#define TL_WR941ND_V6_GPIO_LED_LAN4 4
  24056. +#define TL_WR941ND_V6_GPIO_LED_WLAN 8
  24057. +#define TL_WR941ND_V6_GPIO_LED_SYSTEM 18
  24058. +
  24059. +#define TL_WR941ND_V6_GPIO_BTN_RESET 1
  24060. +#define TL_WR941ND_V6_GPIO_BTN_RFKILL 2
  24061. +
  24062. +#define TL_WR941ND_V6_KEYS_POLL_INTERVAL 20
  24063. +#define TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_V6_KEYS_POLL_INTERVAL)
  24064. +
  24065. +
  24066. +static struct gpio_led tl_wr941nd_v6_leds_gpio[] __initdata = {
  24067. + {
  24068. + .name = "tp-link:blue:qss",
  24069. + .gpio = TL_WR941ND_V6_GPIO_LED_QSS,
  24070. + .active_low = 1,
  24071. + },
  24072. + {
  24073. + .name = "tp-link:blue:wan",
  24074. + .gpio = TL_WR941ND_V6_GPIO_LED_WAN,
  24075. + .active_low = 1,
  24076. + },
  24077. + {
  24078. + .name = "tp-link:red:wan",
  24079. + .gpio = TL_WR941ND_V6_GPIO_LED_WAN_RED,
  24080. + .active_low = 0,
  24081. + },
  24082. + {
  24083. + .name = "tp-link:blue:lan1",
  24084. + .gpio = TL_WR941ND_V6_GPIO_LED_LAN1,
  24085. + .active_low = 1,
  24086. + },
  24087. + {
  24088. + .name = "tp-link:blue:lan2",
  24089. + .gpio = TL_WR941ND_V6_GPIO_LED_LAN2,
  24090. + .active_low = 1,
  24091. + },
  24092. + {
  24093. + .name = "tp-link:blue:lan3",
  24094. + .gpio = TL_WR941ND_V6_GPIO_LED_LAN3,
  24095. + .active_low = 1,
  24096. + },
  24097. + {
  24098. + .name = "tp-link:blue:lan4",
  24099. + .gpio = TL_WR941ND_V6_GPIO_LED_LAN4,
  24100. + .active_low = 1,
  24101. + },
  24102. + {
  24103. + .name = "tp-link:blue:wlan",
  24104. + .gpio = TL_WR941ND_V6_GPIO_LED_WLAN,
  24105. + .active_low = 1,
  24106. + },
  24107. + {
  24108. + .name = "tp-link:blue:system",
  24109. + .gpio = TL_WR941ND_V6_GPIO_LED_SYSTEM,
  24110. + .active_low = 1,
  24111. + },
  24112. +};
  24113. +
  24114. +static struct gpio_keys_button tl_wr941nd_v6_gpio_keys[] __initdata = {
  24115. + {
  24116. + .desc = "Reset button",
  24117. + .type = EV_KEY,
  24118. + .code = KEY_RESTART,
  24119. + .debounce_interval = TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL,
  24120. + .gpio = TL_WR941ND_V6_GPIO_BTN_RESET,
  24121. + .active_low = 1,
  24122. + }, {
  24123. + .desc = "RFKILL button",
  24124. + .type = EV_KEY,
  24125. + .code = KEY_RFKILL,
  24126. + .debounce_interval = TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL,
  24127. + .gpio = TL_WR941ND_V6_GPIO_BTN_RFKILL,
  24128. + .active_low = 1,
  24129. + }
  24130. +};
  24131. +
  24132. +
  24133. +static const char *tl_wr941n_v6_part_probes[] = {
  24134. + "tp-link",
  24135. + NULL,
  24136. +};
  24137. +
  24138. +static struct flash_platform_data tl_wr941n_v6_flash_data = {
  24139. + .part_probes = tl_wr941n_v6_part_probes,
  24140. +};
  24141. +
  24142. +
  24143. +static void __init tl_wr941nd_v6_setup(void)
  24144. +{
  24145. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  24146. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  24147. +
  24148. + ath79_register_m25p80(&tl_wr941n_v6_flash_data);
  24149. +
  24150. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v6_leds_gpio),
  24151. + tl_wr941nd_v6_leds_gpio);
  24152. +
  24153. + ath79_register_gpio_keys_polled(-1, TL_WR941ND_V6_KEYS_POLL_INTERVAL,
  24154. + ARRAY_SIZE(tl_wr941nd_v6_gpio_keys),
  24155. + tl_wr941nd_v6_gpio_keys);
  24156. +
  24157. + ath79_register_mdio(0, 0x0);
  24158. +
  24159. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  24160. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  24161. +
  24162. + ath79_switch_data.phy4_mii_en = 1;
  24163. +
  24164. + ath79_register_eth(0);
  24165. + ath79_register_eth(1);
  24166. +
  24167. + ath79_register_wmac(ee, mac);
  24168. +
  24169. +}
  24170. +
  24171. +MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V6, "TL-WR941ND-v6", "TP-LINK TL-WR941N/ND v6",
  24172. + tl_wr941nd_v6_setup);
  24173. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-tube2h.c linux-4.1.13/arch/mips/ath79/mach-tube2h.c
  24174. --- linux-4.1.13.orig/arch/mips/ath79/mach-tube2h.c 1970-01-01 01:00:00.000000000 +0100
  24175. +++ linux-4.1.13/arch/mips/ath79/mach-tube2h.c 2015-09-13 20:04:35.072523889 +0200
  24176. @@ -0,0 +1,118 @@
  24177. +/*
  24178. + * ALFA NETWORK Tube2H board support
  24179. + *
  24180. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  24181. + *
  24182. + * This program is free software; you can redistribute it and/or modify it
  24183. + * under the terms of the GNU General Public License version 2 as published
  24184. + * by the Free Software Foundation.
  24185. + */
  24186. +
  24187. +#include <linux/gpio.h>
  24188. +
  24189. +#include <asm/mach-ath79/ath79.h>
  24190. +#include <asm/mach-ath79/ar71xx_regs.h>
  24191. +
  24192. +#include "common.h"
  24193. +#include "dev-eth.h"
  24194. +#include "dev-gpio-buttons.h"
  24195. +#include "dev-leds-gpio.h"
  24196. +#include "dev-m25p80.h"
  24197. +#include "dev-wmac.h"
  24198. +#include "machtypes.h"
  24199. +
  24200. +#define TUBE2H_GPIO_LED_SIGNAL4 0
  24201. +#define TUBE2H_GPIO_LED_SIGNAL3 1
  24202. +#define TUBE2H_GPIO_LED_SIGNAL2 13
  24203. +#define TUBE2H_GPIO_LED_LAN 17
  24204. +#define TUBE2H_GPIO_LED_SIGNAL1 27
  24205. +#define TUBE2H_GPIO_EXT_LNA 28
  24206. +
  24207. +#define TUBE2H_GPIO_BTN_RESET 12
  24208. +
  24209. +#define TUBE2H_KEYS_POLL_INTERVAL 20 /* msecs */
  24210. +#define TUBE2H_KEYS_DEBOUNCE_INTERVAL (3 * TUBE2H_KEYS_POLL_INTERVAL)
  24211. +
  24212. +#define TUBE2H_ART_ADDRESS 0x1f7f0000
  24213. +#define TUBE2H_LAN_MAC_OFFSET 0x06
  24214. +#define TUBE2H_CALDATA_OFFSET 0x1000
  24215. +
  24216. +static struct gpio_led tube2h_leds_gpio[] __initdata = {
  24217. + {
  24218. + .name = "alfa:blue:lan",
  24219. + .gpio = TUBE2H_GPIO_LED_LAN,
  24220. + .active_low = 1,
  24221. + },
  24222. + {
  24223. + .name = "alfa:red:signal1",
  24224. + .gpio = TUBE2H_GPIO_LED_SIGNAL1,
  24225. + .active_low = 1,
  24226. + },
  24227. + {
  24228. + .name = "alfa:orange:signal2",
  24229. + .gpio = TUBE2H_GPIO_LED_SIGNAL2,
  24230. + .active_low = 0,
  24231. + },
  24232. + {
  24233. + .name = "alfa:green:signal3",
  24234. + .gpio = TUBE2H_GPIO_LED_SIGNAL3,
  24235. + .active_low = 0,
  24236. + },
  24237. + {
  24238. + .name = "alfa:green:signal4",
  24239. + .gpio = TUBE2H_GPIO_LED_SIGNAL4,
  24240. + .active_low = 0,
  24241. + },
  24242. +};
  24243. +
  24244. +static struct gpio_keys_button tube2h_gpio_keys[] __initdata = {
  24245. + {
  24246. + .desc = "Reset button",
  24247. + .type = EV_KEY,
  24248. + .code = KEY_RESTART,
  24249. + .debounce_interval = TUBE2H_KEYS_DEBOUNCE_INTERVAL,
  24250. + .gpio = TUBE2H_GPIO_BTN_RESET,
  24251. + .active_low = 1,
  24252. + },
  24253. +};
  24254. +
  24255. +static void __init tube2h_setup(void)
  24256. +{
  24257. + u8 *art = (u8 *) KSEG1ADDR(TUBE2H_ART_ADDRESS);
  24258. + u32 t;
  24259. +
  24260. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_JTAG_DISABLE |
  24261. + AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  24262. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  24263. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  24264. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  24265. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  24266. +
  24267. + /* Ensure that GPIO26 and GPIO27 are controllable by software */
  24268. + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  24269. + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  24270. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  24271. +
  24272. + gpio_request_one(TUBE2H_GPIO_EXT_LNA,
  24273. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  24274. + "external LNA0");
  24275. +
  24276. + ath79_register_wmac(art + TUBE2H_CALDATA_OFFSET, NULL);
  24277. +
  24278. + ath79_register_m25p80(NULL);
  24279. +
  24280. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tube2h_leds_gpio),
  24281. + tube2h_leds_gpio);
  24282. + ath79_register_gpio_keys_polled(-1, TUBE2H_KEYS_POLL_INTERVAL,
  24283. + ARRAY_SIZE(tube2h_gpio_keys),
  24284. + tube2h_gpio_keys);
  24285. +
  24286. + ath79_init_mac(ath79_eth0_data.mac_addr,
  24287. + art + TUBE2H_LAN_MAC_OFFSET, 0);
  24288. + ath79_register_mdio(0, 0x0);
  24289. + ath79_register_eth(0);
  24290. +}
  24291. +
  24292. +MIPS_MACHINE(ATH79_MACH_TUBE2H, "TUBE2H", "ALFA NETWORK Tube2H",
  24293. + tube2h_setup);
  24294. +
  24295. diff -Nur linux-4.1.13.orig/arch/mips/ath79/machtypes.h linux-4.1.13/arch/mips/ath79/machtypes.h
  24296. --- linux-4.1.13.orig/arch/mips/ath79/machtypes.h 2015-11-09 23:34:10.000000000 +0100
  24297. +++ linux-4.1.13/arch/mips/ath79/machtypes.h 2015-12-04 19:57:05.957975089 +0100
  24298. @@ -16,12 +16,224 @@
  24299. enum ath79_mach_type {
  24300. ATH79_MACH_GENERIC = 0,
  24301. + ATH79_MACH_ALFA_AP96, /* ALFA Network AP96 board */
  24302. + ATH79_MACH_ALFA_NX, /* ALFA Network N2/N5 board */
  24303. + ATH79_MACH_ALL0258N, /* Allnet ALL0258N */
  24304. + ATH79_MACH_ALL0305, /* Allnet ALL0305 */
  24305. + ATH79_MACH_ALL0315N, /* Allnet ALL0315N */
  24306. + ATH79_MACH_ANTMINER_S1, /* Antminer S1 */
  24307. + ATH79_MACH_ANTMINER_S3, /* Antminer S3 */
  24308. + ATH79_MACH_ARDUINO_YUN, /* Yun */
  24309. + ATH79_MACH_AP113, /* Atheros AP113 reference board */
  24310. ATH79_MACH_AP121, /* Atheros AP121 reference board */
  24311. + ATH79_MACH_AP121_MINI, /* Atheros AP121-MINI reference board */
  24312. + ATH79_MACH_AP132, /* Atheros AP132 reference board */
  24313. + ATH79_MACH_AP135_020, /* Atheros AP135-020 reference board */
  24314. ATH79_MACH_AP136_010, /* Atheros AP136-010 reference board */
  24315. + ATH79_MACH_AP136_020, /* Atheros AP136-020 reference board */
  24316. + ATH79_MACH_AP143, /* Atheros AP143 reference board */
  24317. + ATH79_MACH_AP147_010, /* Atheros AP147-010 reference board */
  24318. + ATH79_MACH_AP152, /* Atheros AP152 reference board */
  24319. ATH79_MACH_AP81, /* Atheros AP81 reference board */
  24320. + ATH79_MACH_AP83, /* Atheros AP83 */
  24321. + ATH79_MACH_AP96, /* Atheros AP96 */
  24322. + ATH79_MACH_ARCHER_C5, /* TP-LINK Archer C5 board */
  24323. + ATH79_MACH_ARCHER_C7, /* TP-LINK Archer C7 board */
  24324. + ATH79_MACH_AW_NR580, /* AzureWave AW-NR580 */
  24325. + ATH79_MACH_BHU_BXU2000N2_A1, /* BHU BXU2000n-2 A1 */
  24326. + ATH79_MACH_BSB, /* Smart Electronics Black Swift board */
  24327. + ATH79_MACH_CAP4200AG, /* Senao CAP4200AG */
  24328. + ATH79_MACH_CARAMBOLA2, /* 8devices Carambola2 */
  24329. + ATH79_MACH_CF_E316N_V2, /* COMFAST CF-E316N v2 */
  24330. + ATH79_MACH_CPE510, /* TP-LINK CPE510 */
  24331. ATH79_MACH_DB120, /* Atheros DB120 reference board */
  24332. ATH79_MACH_PB44, /* Atheros PB44 reference board */
  24333. + ATH79_MACH_DGL_5500_A1, /* D-link DGL-5500 rev. A1 */
  24334. + ATH79_MACH_DHP_1565_A1, /* D-Link DHP-1565 rev. A1 */
  24335. + ATH79_MACH_DIR_505_A1, /* D-Link DIR-505 rev. A1 */
  24336. + ATH79_MACH_DIR_600_A1, /* D-Link DIR-600 rev. A1 */
  24337. + ATH79_MACH_DIR_615_C1, /* D-Link DIR-615 rev. C1 */
  24338. + ATH79_MACH_DIR_615_E1, /* D-Link DIR-615 rev. E1 */
  24339. + ATH79_MACH_DIR_615_E4, /* D-Link DIR-615 rev. E4 */
  24340. + ATH79_MACH_DIR_615_I1, /* D-Link DIR-615 rev. I1 */
  24341. + ATH79_MACH_DIR_825_B1, /* D-Link DIR-825 rev. B1 */
  24342. + ATH79_MACH_DIR_825_C1, /* D-Link DIR-825 rev. C1 */
  24343. + ATH79_MACH_DIR_835_A1, /* D-Link DIR-835 rev. A1 */
  24344. + ATH79_MACH_DLAN_HOTSPOT, /* devolo dLAN Hotspot */
  24345. + ATH79_MACH_DLAN_PRO_500_WP, /* devolo dLAN pro 500 Wireless+ */
  24346. + ATH79_MACH_DLAN_PRO_1200_AC, /* devolo dLAN pro 1200+ WiFi ac*/
  24347. + ATH79_MACH_DRAGINO2, /* Dragino Version 2 */
  24348. + ATH79_MACH_ESR900, /* EnGenius ESR900 */
  24349. + ATH79_MACH_EW_DORIN, /* embedded wireless Dorin Platform */
  24350. + ATH79_MACH_EW_DORIN_ROUTER, /* embedded wireless Dorin Router Platform */
  24351. + ATH79_MACH_EAP300V2, /* EnGenius EAP300 v2 */
  24352. + ATH79_MACH_EAP7660D, /* Senao EAP7660D */
  24353. + ATH79_MACH_EL_M150, /* EasyLink EL-M150 */
  24354. + ATH79_MACH_EL_MINI, /* EasyLink EL-MINI */
  24355. + ATH79_MACH_ESR1750, /* EnGenius ESR1750 */
  24356. + ATH79_MACH_EPG5000, /* EnGenius EPG5000 */
  24357. + ATH79_MACH_F9K1115V2, /* Belkin AC1750DB */
  24358. + ATH79_MACH_GL_AR150, /* GL-AR150 support */
  24359. + ATH79_MACH_GL_AR300, /* GL-AR300 */
  24360. + ATH79_MACH_GL_DOMINO, /* Domino */
  24361. + ATH79_MACH_GL_INET, /* GL-CONNECT GL-INET */
  24362. + ATH79_MACH_GS_MINIBOX_V1, /* Gainstrong MiniBox V1.0 */
  24363. + ATH79_MACH_GS_OOLITE, /* GS OOLITE V1.0 */
  24364. + ATH79_MACH_HIWIFI_HC6361, /* HiWiFi HC6361 */
  24365. + ATH79_MACH_JA76PF, /* jjPlus JA76PF */
  24366. + ATH79_MACH_JA76PF2, /* jjPlus JA76PF2 */
  24367. + ATH79_MACH_JWAP003, /* jjPlus JWAP003 */
  24368. + ATH79_MACH_HORNET_UB, /* ALFA Networks Hornet-UB */
  24369. + ATH79_MACH_MR12, /* Cisco Meraki MR12 */
  24370. + ATH79_MACH_MR16, /* Cisco Meraki MR16 */
  24371. + ATH79_MACH_MR1750, /* OpenMesh MR1750 */
  24372. + ATH79_MACH_MR600V2, /* OpenMesh MR600v2 */
  24373. + ATH79_MACH_MR600, /* OpenMesh MR600 */
  24374. + ATH79_MACH_MR900, /* OpenMesh MR900 */
  24375. + ATH79_MACH_MR900v2, /* OpenMesh MR900v2 */
  24376. + ATH79_MACH_MYNET_N600, /* WD My Net N600 */
  24377. + ATH79_MACH_MYNET_N750, /* WD My Net N750 */
  24378. + ATH79_MACH_MYNET_REXT, /* WD My Net Wi-Fi Range Extender */
  24379. + ATH79_MACH_MZK_W04NU, /* Planex MZK-W04NU */
  24380. + ATH79_MACH_MZK_W300NH, /* Planex MZK-W300NH */
  24381. + ATH79_MACH_NBG460N, /* Zyxel NBG460N/550N/550NH */
  24382. + ATH79_MACH_NBG6616, /* Zyxel NBG6616 */
  24383. + ATH79_MACH_NBG6716, /* Zyxel NBG6716 */
  24384. + ATH79_MACH_OM2P_HSv2, /* OpenMesh OM2P-HSv2 */
  24385. + ATH79_MACH_OM2P_HS, /* OpenMesh OM2P-HS */
  24386. + ATH79_MACH_OM2P_LC, /* OpenMesh OM2P-LC */
  24387. + ATH79_MACH_OM2Pv2, /* OpenMesh OM2Pv2 */
  24388. + ATH79_MACH_OM2P, /* OpenMesh OM2P */
  24389. + ATH79_MACH_OM5P_AN, /* OpenMesh OM5P-AN */
  24390. + ATH79_MACH_OM5P, /* OpenMesh OM5P */
  24391. + ATH79_MACH_ONION_OMEGA, /* ONION OMEGA */
  24392. + ATH79_MACH_PB42, /* Atheros PB42 */
  24393. + ATH79_MACH_PB92, /* Atheros PB92 */
  24394. + ATH79_MACH_QIHOO_C301, /* Qihoo 360 C301 */
  24395. + ATH79_MACH_R6100, /* NETGEAR R6100 */
  24396. + ATH79_MACH_RB_411, /* MikroTik RouterBOARD 411/411A/411AH */
  24397. + ATH79_MACH_RB_411U, /* MikroTik RouterBOARD 411U */
  24398. + ATH79_MACH_RB_433, /* MikroTik RouterBOARD 433/433AH */
  24399. + ATH79_MACH_RB_433U, /* MikroTik RouterBOARD 433UAH */
  24400. + ATH79_MACH_RB_435G, /* MikroTik RouterBOARD 435G */
  24401. + ATH79_MACH_RB_450G, /* MikroTik RouterBOARD 450G */
  24402. + ATH79_MACH_RB_450, /* MikroTik RouterBOARD 450 */
  24403. + ATH79_MACH_RB_493, /* Mikrotik RouterBOARD 493/493AH */
  24404. + ATH79_MACH_RB_493G, /* Mikrotik RouterBOARD 493G */
  24405. + ATH79_MACH_RB_711GR100, /* Mikrotik RouterBOARD 911/912 boards */
  24406. + ATH79_MACH_RB_750, /* MikroTik RouterBOARD 750 */
  24407. + ATH79_MACH_RB_750G_R3, /* MikroTik RouterBOARD 750GL */
  24408. + ATH79_MACH_RB_751, /* MikroTik RouterBOARD 751 */
  24409. + ATH79_MACH_RB_751G, /* Mikrotik RouterBOARD 751G */
  24410. + ATH79_MACH_RB_922GS, /* Mikrotik RouterBOARD 911/922GS boards */
  24411. + ATH79_MACH_RB_951G, /* Mikrotik RouterBOARD 951G */
  24412. + ATH79_MACH_RB_951U, /* Mikrotik RouterBOARD 951Ui-2HnD */
  24413. + ATH79_MACH_RB_2011G, /* Mikrotik RouterBOARD 2011UAS-2HnD */
  24414. + ATH79_MACH_RB_2011L, /* Mikrotik RouterBOARD 2011L */
  24415. + ATH79_MACH_RB_2011US, /* Mikrotik RouterBOARD 2011UAS */
  24416. + ATH79_MACH_RB_2011R5, /* Mikrotik RouterBOARD 2011UiAS(-2Hnd) */
  24417. + ATH79_MACH_RB_SXTLITE2ND, /* Mikrotik RouterBOARD SXT Lite 2nD */
  24418. + ATH79_MACH_RB_SXTLITE5ND, /* Mikrotik RouterBOARD SXT Lite 5nD */
  24419. + ATH79_MACH_RW2458N, /* Redwave RW2458N */
  24420. + ATH79_MACH_SMART_300, /* NC-LINK SMART-300 */
  24421. + ATH79_MACH_TEW_632BRP, /* TRENDnet TEW-632BRP */
  24422. + ATH79_MACH_TEW_673GRU, /* TRENDnet TEW-673GRU */
  24423. + ATH79_MACH_TEW_712BR, /* TRENDnet TEW-712BR */
  24424. + ATH79_MACH_TEW_732BR, /* TRENDnet TEW-732BR */
  24425. + ATH79_MACH_MC_MAC1200R, /* MERCURY MAC1200R*/
  24426. + ATH79_MACH_TL_MR10U, /* TP-LINK TL-MR10U */
  24427. + ATH79_MACH_TL_MR11U, /* TP-LINK TL-MR11U */
  24428. + ATH79_MACH_TL_MR13U, /* TP-LINK TL-MR13U */
  24429. + ATH79_MACH_TL_MR3020, /* TP-LINK TL-MR3020 */
  24430. + ATH79_MACH_TL_MR3040, /* TP-LINK TL-MR3040 */
  24431. + ATH79_MACH_TL_MR3040_V2, /* TP-LINK TL-MR3040 v2 */
  24432. + ATH79_MACH_TL_MR3220, /* TP-LINK TL-MR3220 */
  24433. + ATH79_MACH_TL_MR3220_V2, /* TP-LINK TL-MR3220 v2 */
  24434. + ATH79_MACH_TL_MR3420, /* TP-LINK TL-MR3420 */
  24435. + ATH79_MACH_TL_MR3420_V2, /* TP-LINK TL-MR3420 v2 */
  24436. + ATH79_MACH_TL_WA701ND_V2, /* TP-LINK TL-WA701ND v2 */
  24437. + ATH79_MACH_TL_WA750RE, /* TP-LINK TL-WA750RE */
  24438. + ATH79_MACH_TL_WA7210N_V2, /* TP-LINK TL-WA7210N v2 */
  24439. + ATH79_MACH_TL_WA7510N_V1, /* TP-LINK TL-WA7510N v1*/
  24440. + ATH79_MACH_TL_WA850RE, /* TP-LINK TL-WA850RE */
  24441. + ATH79_MACH_TL_WA860RE, /* TP-LINK TL-WA860RE */
  24442. + ATH79_MACH_TL_WA801ND_V2, /* TP-LINK TL-WA801ND v2 */
  24443. + ATH79_MACH_TL_WA830RE_V2, /* TP-LINK TL-WA830RE v2 */
  24444. + ATH79_MACH_TL_WA901ND, /* TP-LINK TL-WA901ND */
  24445. + ATH79_MACH_TL_WA901ND_V2, /* TP-LINK TL-WA901ND v2 */
  24446. + ATH79_MACH_TL_WA901ND_V3, /* TP-LINK TL-WA901ND v3 */
  24447. + ATH79_MACH_TL_WDR3320_V2, /* TP-LINK TL-WDR3320 v2 */
  24448. + ATH79_MACH_TL_WDR3500, /* TP-LINK TL-WDR3500 */
  24449. + ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
  24450. + ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
  24451. + ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
  24452. + ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
  24453. + ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
  24454. + ATH79_MACH_TL_WR1043ND_V2, /* TP-LINK TL-WR1043ND v2 */
  24455. + ATH79_MACH_TL_WR2543N, /* TP-LINK TL-WR2543N/ND */
  24456. + ATH79_MACH_TL_WR703N, /* TP-LINK TL-WR703N */
  24457. + ATH79_MACH_TL_WR710N, /* TP-LINK TL-WR710N */
  24458. + ATH79_MACH_TL_WR720N_V3, /* TP-LINK TL-WR720N v3/v4 */
  24459. + ATH79_MACH_TL_WR741ND, /* TP-LINK TL-WR741ND */
  24460. + ATH79_MACH_TL_WR741ND_V4, /* TP-LINK TL-WR741ND v4*/
  24461. + ATH79_MACH_TL_WR841N_V1, /* TP-LINK TL-WR841N v1 */
  24462. + ATH79_MACH_TL_WR841N_V7, /* TP-LINK TL-WR841N/ND v7 */
  24463. + ATH79_MACH_TL_WR841N_V8, /* TP-LINK TL-WR841N/ND v8 */
  24464. + ATH79_MACH_TL_WR841N_V9, /* TP-LINK TL-WR841N/ND v9 */
  24465. + ATH79_MACH_TL_WR842N_V2, /* TP-LINK TL-WR842N/ND v2 */
  24466. + ATH79_MACH_TL_WR941ND, /* TP-LINK TL-WR941ND */
  24467. + ATH79_MACH_TL_WR941ND_V5, /* TP-LINK TL-WR941ND v5 */
  24468. + ATH79_MACH_TL_WR941ND_V6, /* TP-LINK TL-WR941ND v6 */
  24469. + ATH79_MACH_TUBE2H, /* Alfa Network Tube2H */
  24470. + ATH79_MACH_UBNT_AIRGW, /* Ubiquiti AirGateway */
  24471. + ATH79_MACH_UBNT_AIRGWP, /* Ubiquiti AirGateway Pro */
  24472. + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
  24473. + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
  24474. + ATH79_MACH_UBNT_LOCO_M_XW, /* Ubiquiti Loco M XW */
  24475. + ATH79_MACH_UBNT_LSSR71, /* Ubiquiti LS-SR71 */
  24476. + ATH79_MACH_UBNT_LSX, /* Ubiquiti LSX */
  24477. + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
  24478. + ATH79_MACH_UBNT_NANO_M_XW, /* Ubiquiti NanoStation M XW */
  24479. + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
  24480. + ATH79_MACH_UBNT_ROCKET_M_XW, /* Ubiquiti Rocket M XW*/
  24481. + ATH79_MACH_UBNT_ROCKET_M_TI, /* Ubiquiti Rocket M TI*/
  24482. + ATH79_MACH_UBNT_RSPRO, /* Ubiquiti RouterStation Pro */
  24483. + ATH79_MACH_UBNT_RS, /* Ubiquiti RouterStation */
  24484. + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */
  24485. + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */
  24486. + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */
  24487. + ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, /* Ubiquiti UnifiAP Outdoor+ */
  24488. ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */
  24489. + ATH79_MACH_WEIO, /* WeIO board */
  24490. + ATH79_MACH_WHR_G301N, /* Buffalo WHR-G301N */
  24491. + ATH79_MACH_WHR_HP_G300N, /* Buffalo WHR-HP-G300N */
  24492. + ATH79_MACH_WHR_HP_GN, /* Buffalo WHR-HP-GN */
  24493. + ATH79_MACH_WLAE_AG300N, /* Buffalo WLAE-AG300N */
  24494. + ATH79_MACH_WLR8100, /* SITECOM WLR-8100 */
  24495. + ATH79_MACH_WNDAP360, /* NETGEAR WNDAP360 */
  24496. + ATH79_MACH_WNDR3700, /* NETGEAR WNDR3700/WNDR3800/WNDRMAC */
  24497. + ATH79_MACH_WNDR3700_V4, /* NETGEAR WNDR3700v4 */
  24498. + ATH79_MACH_WNDR4300, /* NETGEAR WNDR4300 */
  24499. + ATH79_MACH_WNR2000, /* NETGEAR WNR2000 */
  24500. + ATH79_MACH_WNR2000_V3, /* NETGEAR WNR2000 v3 */
  24501. + ATH79_MACH_WNR2000_V4, /* NETGEAR WNR2000 v4 */
  24502. + ATH79_MACH_WNR2200, /* NETGEAR WNR2200 */
  24503. + ATH79_MACH_WNR612_V2, /* NETGEAR WNR612 v2 */
  24504. + ATH79_MACH_WNR1000_V2, /* NETGEAR WNR1000 v2 */
  24505. + ATH79_MACH_WP543, /* Compex WP543 */
  24506. + ATH79_MACH_WPE72, /* Compex WPE72 */
  24507. + ATH79_MACH_WPJ344, /* Compex WPJ344 */
  24508. + ATH79_MACH_WPJ531, /* Compex WPJ531 */
  24509. + ATH79_MACH_WPJ558, /* Compex WPJ558 */
  24510. + ATH79_MACH_WRT160NL, /* Linksys WRT160NL */
  24511. + ATH79_MACH_WRT400N, /* Linksys WRT400N */
  24512. + ATH79_MACH_WZR_HP_AG300H, /* Buffalo WZR-HP-AG300H */
  24513. + ATH79_MACH_WZR_HP_G300NH, /* Buffalo WZR-HP-G300NH */
  24514. + ATH79_MACH_WZR_HP_G300NH2, /* Buffalo WZR-HP-G300NH2 */
  24515. + ATH79_MACH_WZR_HP_G450H, /* Buffalo WZR-HP-G450H */
  24516. + ATH79_MACH_WZR_450HP2, /* Buffalo WZR-450HP2 */
  24517. + ATH79_MACH_ZCN_1523H_2, /* Zcomax ZCN-1523H-2-xx */
  24518. + ATH79_MACH_ZCN_1523H_5, /* Zcomax ZCN-1523H-5-xx */
  24519. };
  24520. #endif /* _ATH79_MACHTYPE_H */
  24521. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ubnt.c linux-4.1.13/arch/mips/ath79/mach-ubnt.c
  24522. --- linux-4.1.13.orig/arch/mips/ath79/mach-ubnt.c 1970-01-01 01:00:00.000000000 +0100
  24523. +++ linux-4.1.13/arch/mips/ath79/mach-ubnt.c 2015-09-13 20:04:35.072523889 +0200
  24524. @@ -0,0 +1,205 @@
  24525. +/*
  24526. + * Ubiquiti RouterStation support
  24527. + *
  24528. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  24529. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  24530. + * Copyright (C) 2008 Ubiquiti <support@ubnt.com>
  24531. + *
  24532. + * This program is free software; you can redistribute it and/or modify it
  24533. + * under the terms of the GNU General Public License version 2 as published
  24534. + * by the Free Software Foundation.
  24535. + */
  24536. +
  24537. +#include <asm/mach-ath79/ath79.h>
  24538. +
  24539. +#include "dev-eth.h"
  24540. +#include "dev-gpio-buttons.h"
  24541. +#include "dev-leds-gpio.h"
  24542. +#include "dev-m25p80.h"
  24543. +#include "dev-usb.h"
  24544. +#include "machtypes.h"
  24545. +#include "pci.h"
  24546. +
  24547. +#define UBNT_RS_GPIO_LED_RF 2
  24548. +#define UBNT_RS_GPIO_SW4 8
  24549. +
  24550. +#define UBNT_LS_SR71_GPIO_LED_D25 0
  24551. +#define UBNT_LS_SR71_GPIO_LED_D26 1
  24552. +#define UBNT_LS_SR71_GPIO_LED_D24 2
  24553. +#define UBNT_LS_SR71_GPIO_LED_D23 4
  24554. +#define UBNT_LS_SR71_GPIO_LED_D22 5
  24555. +#define UBNT_LS_SR71_GPIO_LED_D27 6
  24556. +#define UBNT_LS_SR71_GPIO_LED_D28 7
  24557. +
  24558. +#define UBNT_KEYS_POLL_INTERVAL 20 /* msecs */
  24559. +#define UBNT_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_KEYS_POLL_INTERVAL)
  24560. +
  24561. +static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
  24562. + {
  24563. + .name = "ubnt:green:rf",
  24564. + .gpio = UBNT_RS_GPIO_LED_RF,
  24565. + .active_low = 0,
  24566. + }
  24567. +};
  24568. +
  24569. +static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
  24570. + {
  24571. + .name = "ubnt:green:d22",
  24572. + .gpio = UBNT_LS_SR71_GPIO_LED_D22,
  24573. + .active_low = 0,
  24574. + }, {
  24575. + .name = "ubnt:green:d23",
  24576. + .gpio = UBNT_LS_SR71_GPIO_LED_D23,
  24577. + .active_low = 0,
  24578. + }, {
  24579. + .name = "ubnt:green:d24",
  24580. + .gpio = UBNT_LS_SR71_GPIO_LED_D24,
  24581. + .active_low = 0,
  24582. + }, {
  24583. + .name = "ubnt:red:d25",
  24584. + .gpio = UBNT_LS_SR71_GPIO_LED_D25,
  24585. + .active_low = 0,
  24586. + }, {
  24587. + .name = "ubnt:red:d26",
  24588. + .gpio = UBNT_LS_SR71_GPIO_LED_D26,
  24589. + .active_low = 0,
  24590. + }, {
  24591. + .name = "ubnt:green:d27",
  24592. + .gpio = UBNT_LS_SR71_GPIO_LED_D27,
  24593. + .active_low = 0,
  24594. + }, {
  24595. + .name = "ubnt:green:d28",
  24596. + .gpio = UBNT_LS_SR71_GPIO_LED_D28,
  24597. + .active_low = 0,
  24598. + }
  24599. +};
  24600. +
  24601. +static struct gpio_keys_button ubnt_gpio_keys[] __initdata = {
  24602. + {
  24603. + .desc = "sw4",
  24604. + .type = EV_KEY,
  24605. + .code = KEY_RESTART,
  24606. + .debounce_interval = UBNT_KEYS_DEBOUNCE_INTERVAL,
  24607. + .gpio = UBNT_RS_GPIO_SW4,
  24608. + .active_low = 1,
  24609. + }
  24610. +};
  24611. +
  24612. +static const char *ubnt_part_probes[] = {
  24613. + "RedBoot",
  24614. + NULL,
  24615. +};
  24616. +
  24617. +static struct flash_platform_data ubnt_flash_data = {
  24618. + .part_probes = ubnt_part_probes,
  24619. +};
  24620. +
  24621. +static void __init ubnt_generic_setup(void)
  24622. +{
  24623. + ath79_register_m25p80(&ubnt_flash_data);
  24624. +
  24625. + ath79_register_gpio_keys_polled(-1, UBNT_KEYS_POLL_INTERVAL,
  24626. + ARRAY_SIZE(ubnt_gpio_keys),
  24627. + ubnt_gpio_keys);
  24628. + ath79_register_pci();
  24629. +}
  24630. +
  24631. +#define UBNT_RS_WAN_PHYMASK BIT(20)
  24632. +#define UBNT_RS_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
  24633. +
  24634. +static void __init ubnt_rs_setup(void)
  24635. +{
  24636. + ubnt_generic_setup();
  24637. +
  24638. + ath79_register_mdio(0, ~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
  24639. +
  24640. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  24641. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  24642. + ath79_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
  24643. +
  24644. + /*
  24645. + * There is Secondary MAC address duplicate problem with some
  24646. + * UBNT HW batches. Do not increase Secondary MAC address by 1
  24647. + * but do workaround with 'Locally Administrated' bit.
  24648. + */
  24649. + ath79_init_local_mac(ath79_eth1_data.mac_addr, ath79_mac_base);
  24650. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  24651. + ath79_eth1_data.speed = SPEED_100;
  24652. + ath79_eth1_data.duplex = DUPLEX_FULL;
  24653. +
  24654. + ath79_register_eth(0);
  24655. + ath79_register_eth(1);
  24656. +
  24657. + ath79_register_usb();
  24658. +
  24659. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
  24660. + ubnt_rs_leds_gpio);
  24661. +}
  24662. +
  24663. +MIPS_MACHINE(ATH79_MACH_UBNT_RS, "UBNT-RS", "Ubiquiti RouterStation",
  24664. + ubnt_rs_setup);
  24665. +
  24666. +#define UBNT_RSPRO_WAN_PHYMASK BIT(4)
  24667. +#define UBNT_RSPRO_LAN_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  24668. +
  24669. +static void __init ubnt_rspro_setup(void)
  24670. +{
  24671. + ubnt_generic_setup();
  24672. +
  24673. + ath79_register_mdio(0, ~(UBNT_RSPRO_WAN_PHYMASK |
  24674. + UBNT_RSPRO_LAN_PHYMASK));
  24675. +
  24676. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  24677. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  24678. + ath79_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
  24679. +
  24680. + /*
  24681. + * There is Secondary MAC address duplicate problem with some
  24682. + * UBNT HW batches. Do not increase Secondary MAC address by 1
  24683. + * but do workaround with 'Locally Administrated' bit.
  24684. + */
  24685. + ath79_init_local_mac(ath79_eth1_data.mac_addr, ath79_mac_base);
  24686. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  24687. + ath79_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
  24688. + ath79_eth1_data.speed = SPEED_1000;
  24689. + ath79_eth1_data.duplex = DUPLEX_FULL;
  24690. +
  24691. + ath79_register_eth(0);
  24692. + ath79_register_eth(1);
  24693. +
  24694. + ath79_register_usb();
  24695. +
  24696. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
  24697. + ubnt_rs_leds_gpio);
  24698. +}
  24699. +
  24700. +MIPS_MACHINE(ATH79_MACH_UBNT_RSPRO, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
  24701. + ubnt_rspro_setup);
  24702. +
  24703. +static void __init ubnt_lsx_setup(void)
  24704. +{
  24705. + ubnt_generic_setup();
  24706. +}
  24707. +
  24708. +MIPS_MACHINE(ATH79_MACH_UBNT_LSX, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup);
  24709. +
  24710. +#define UBNT_LSSR71_PHY_MASK BIT(1)
  24711. +
  24712. +static void __init ubnt_lssr71_setup(void)
  24713. +{
  24714. + ubnt_generic_setup();
  24715. +
  24716. + ath79_register_mdio(0, ~UBNT_LSSR71_PHY_MASK);
  24717. +
  24718. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  24719. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  24720. + ath79_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
  24721. +
  24722. + ath79_register_eth(0);
  24723. +
  24724. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
  24725. + ubnt_ls_sr71_leds_gpio);
  24726. +}
  24727. +
  24728. +MIPS_MACHINE(ATH79_MACH_UBNT_LSSR71, "UBNT-LS-SR71", "Ubiquiti LS-SR71",
  24729. + ubnt_lssr71_setup);
  24730. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-ubnt-xm.c linux-4.1.13/arch/mips/ath79/mach-ubnt-xm.c
  24731. --- linux-4.1.13.orig/arch/mips/ath79/mach-ubnt-xm.c 2015-11-09 23:34:10.000000000 +0100
  24732. +++ linux-4.1.13/arch/mips/ath79/mach-ubnt-xm.c 2015-12-04 19:57:04.386077932 +0100
  24733. @@ -12,15 +12,26 @@
  24734. #include <linux/init.h>
  24735. #include <linux/pci.h>
  24736. +#include <linux/platform_device.h>
  24737. #include <linux/ath9k_platform.h>
  24738. +#include <linux/etherdevice.h>
  24739. +#include <linux/ar8216_platform.h>
  24740. +#include <asm/mach-ath79/ath79.h>
  24741. #include <asm/mach-ath79/irq.h>
  24742. +#include <asm/mach-ath79/ar71xx_regs.h>
  24743. -#include "machtypes.h"
  24744. +#include <linux/platform_data/phy-at803x.h>
  24745. +
  24746. +#include "common.h"
  24747. +#include "dev-ap9x-pci.h"
  24748. +#include "dev-eth.h"
  24749. #include "dev-gpio-buttons.h"
  24750. #include "dev-leds-gpio.h"
  24751. -#include "dev-spi.h"
  24752. -#include "pci.h"
  24753. +#include "dev-m25p80.h"
  24754. +#include "dev-usb.h"
  24755. +#include "dev-wmac.h"
  24756. +#include "machtypes.h"
  24757. #define UBNT_XM_GPIO_LED_L1 0
  24758. #define UBNT_XM_GPIO_LED_L2 1
  24759. @@ -32,23 +43,23 @@
  24760. #define UBNT_XM_KEYS_POLL_INTERVAL 20
  24761. #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
  24762. -#define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
  24763. +#define UBNT_XM_EEPROM_ADDR 0x1fff1000
  24764. static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
  24765. {
  24766. - .name = "ubnt-xm:red:link1",
  24767. + .name = "ubnt:red:link1",
  24768. .gpio = UBNT_XM_GPIO_LED_L1,
  24769. .active_low = 0,
  24770. }, {
  24771. - .name = "ubnt-xm:orange:link2",
  24772. + .name = "ubnt:orange:link2",
  24773. .gpio = UBNT_XM_GPIO_LED_L2,
  24774. .active_low = 0,
  24775. }, {
  24776. - .name = "ubnt-xm:green:link3",
  24777. + .name = "ubnt:green:link3",
  24778. .gpio = UBNT_XM_GPIO_LED_L3,
  24779. .active_low = 0,
  24780. }, {
  24781. - .name = "ubnt-xm:green:link4",
  24782. + .name = "ubnt:green:link4",
  24783. .gpio = UBNT_XM_GPIO_LED_L4,
  24784. .active_low = 0,
  24785. },
  24786. @@ -65,62 +76,625 @@
  24787. }
  24788. };
  24789. -static struct spi_board_info ubnt_xm_spi_info[] = {
  24790. +#define UBNT_M_WAN_PHYMASK BIT(4)
  24791. +
  24792. +static void __init ubnt_xm_init(void)
  24793. +{
  24794. + u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
  24795. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  24796. + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  24797. +
  24798. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
  24799. + ubnt_xm_leds_gpio);
  24800. +
  24801. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  24802. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  24803. + ubnt_xm_gpio_keys);
  24804. +
  24805. + ath79_register_m25p80(NULL);
  24806. + ap91_pci_init(eeprom, NULL);
  24807. +
  24808. + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  24809. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  24810. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  24811. + ath79_register_eth(0);
  24812. +}
  24813. +
  24814. +MIPS_MACHINE(ATH79_MACH_UBNT_XM,
  24815. + "UBNT-XM",
  24816. + "Ubiquiti Networks XM (rev 1.0) board",
  24817. + ubnt_xm_init);
  24818. +
  24819. +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
  24820. + ubnt_xm_init);
  24821. +
  24822. +static void __init ubnt_rocket_m_setup(void)
  24823. +{
  24824. + ubnt_xm_init();
  24825. + ath79_register_usb();
  24826. +}
  24827. +
  24828. +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
  24829. + ubnt_rocket_m_setup);
  24830. +
  24831. +static void __init ubnt_nano_m_setup(void)
  24832. +{
  24833. + ubnt_xm_init();
  24834. + ath79_register_eth(1);
  24835. +}
  24836. +
  24837. +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
  24838. + ubnt_nano_m_setup);
  24839. +
  24840. +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
  24841. {
  24842. - .bus_num = 0,
  24843. - .chip_select = 0,
  24844. - .max_speed_hz = 25000000,
  24845. - .modalias = "mx25l6405d",
  24846. + .name = "ubnt:green:globe",
  24847. + .gpio = 0,
  24848. + .active_low = 1,
  24849. + }, {
  24850. + .name = "ubnt:green:power",
  24851. + .gpio = 11,
  24852. + .active_low = 1,
  24853. + .default_state = LEDS_GPIO_DEFSTATE_ON,
  24854. }
  24855. };
  24856. -static struct ath79_spi_platform_data ubnt_xm_spi_data = {
  24857. - .bus_num = 0,
  24858. - .num_chipselect = 1,
  24859. +static void __init ubnt_airrouter_setup(void)
  24860. +{
  24861. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  24862. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  24863. +
  24864. + ath79_register_m25p80(NULL);
  24865. + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  24866. +
  24867. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  24868. + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
  24869. +
  24870. + ath79_register_eth(1);
  24871. + ath79_register_eth(0);
  24872. + ath79_register_usb();
  24873. +
  24874. + ap91_pci_init(ee, NULL);
  24875. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
  24876. + ubnt_airrouter_leds_gpio);
  24877. +
  24878. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  24879. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  24880. + ubnt_xm_gpio_keys);
  24881. +}
  24882. +
  24883. +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
  24884. + ubnt_airrouter_setup);
  24885. +
  24886. +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
  24887. + {
  24888. + .name = "ubnt:orange:dome",
  24889. + .gpio = 1,
  24890. + .active_low = 0,
  24891. + }, {
  24892. + .name = "ubnt:green:dome",
  24893. + .gpio = 0,
  24894. + .active_low = 0,
  24895. + }
  24896. };
  24897. -#ifdef CONFIG_PCI
  24898. -static struct ath9k_platform_data ubnt_xm_eeprom_data;
  24899. +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
  24900. + {
  24901. + .name = "ubnt:orange:front",
  24902. + .gpio = 1,
  24903. + .active_low = 0,
  24904. + }, {
  24905. + .name = "ubnt:green:front",
  24906. + .gpio = 0,
  24907. + .active_low = 0,
  24908. + }
  24909. +};
  24910. -static int ubnt_xm_pci_plat_dev_init(struct pci_dev *dev)
  24911. +static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
  24912. + {
  24913. + .name = "ubnt:white:front",
  24914. + .gpio = 1,
  24915. + .active_low = 0,
  24916. + }, {
  24917. + .name = "ubnt:blue:front",
  24918. + .gpio = 0,
  24919. + .active_low = 0,
  24920. + }
  24921. +};
  24922. +
  24923. +
  24924. +static void __init ubnt_unifi_setup(void)
  24925. {
  24926. - switch (PCI_SLOT(dev->devfn)) {
  24927. - case 0:
  24928. - dev->dev.platform_data = &ubnt_xm_eeprom_data;
  24929. - break;
  24930. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  24931. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  24932. +
  24933. + ath79_register_m25p80(NULL);
  24934. +
  24935. + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  24936. +
  24937. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  24938. + ath79_register_eth(0);
  24939. +
  24940. + ap91_pci_init(ee, NULL);
  24941. +
  24942. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
  24943. + ubnt_unifi_leds_gpio);
  24944. +
  24945. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  24946. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  24947. + ubnt_xm_gpio_keys);
  24948. +}
  24949. +
  24950. +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
  24951. + ubnt_unifi_setup);
  24952. +
  24953. +
  24954. +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
  24955. +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  24956. +
  24957. +static void __init ubnt_unifi_outdoor_setup(void)
  24958. +{
  24959. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  24960. + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  24961. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  24962. +
  24963. + ath79_register_m25p80(NULL);
  24964. +
  24965. + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
  24966. + UBNT_UNIFIOD_2ND_PHYMASK));
  24967. +
  24968. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  24969. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  24970. + ath79_register_eth(0);
  24971. + ath79_register_eth(1);
  24972. +
  24973. + ap91_pci_init(ee, NULL);
  24974. +
  24975. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
  24976. + ubnt_unifi_outdoor_leds_gpio);
  24977. +
  24978. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  24979. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  24980. + ubnt_xm_gpio_keys);
  24981. +}
  24982. +
  24983. +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
  24984. + "Ubiquiti UniFiAP Outdoor",
  24985. + ubnt_unifi_outdoor_setup);
  24986. +
  24987. +
  24988. +static void __init ubnt_unifi_outdoor_plus_setup(void)
  24989. +{
  24990. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  24991. + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  24992. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  24993. +
  24994. + ath79_register_m25p80(NULL);
  24995. +
  24996. + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
  24997. + UBNT_UNIFIOD_2ND_PHYMASK));
  24998. +
  24999. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  25000. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  25001. + ath79_register_eth(0);
  25002. + ath79_register_eth(1);
  25003. +
  25004. + ap91_pci_init(ee, NULL);
  25005. +
  25006. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
  25007. + ubnt_unifi_outdoor_plus_leds_gpio);
  25008. +
  25009. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25010. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  25011. + ubnt_xm_gpio_keys);
  25012. +}
  25013. +
  25014. +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
  25015. + "Ubiquiti UniFiAP Outdoor+",
  25016. + ubnt_unifi_outdoor_plus_setup);
  25017. +
  25018. +
  25019. +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
  25020. + {
  25021. + .name = "ubnt:white:dome",
  25022. + .gpio = 12,
  25023. + }, {
  25024. + .name = "ubnt:blue:dome",
  25025. + .gpio = 13,
  25026. + }
  25027. +};
  25028. +
  25029. +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
  25030. + {
  25031. + .desc = "reset",
  25032. + .type = EV_KEY,
  25033. + .code = KEY_RESTART,
  25034. + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  25035. + .gpio = 17,
  25036. + .active_low = 1,
  25037. }
  25038. +};
  25039. +
  25040. +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
  25041. + .mode = AR8327_PAD_MAC_RGMII,
  25042. + .txclk_delay_en = true,
  25043. + .rxclk_delay_en = true,
  25044. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  25045. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  25046. +};
  25047. +
  25048. +static struct ar8327_platform_data uap_pro_ar8327_data = {
  25049. + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
  25050. + .port0_cfg = {
  25051. + .force_link = 1,
  25052. + .speed = AR8327_PORT_SPEED_1000,
  25053. + .duplex = 1,
  25054. + .txpause = 1,
  25055. + .rxpause = 1,
  25056. + },
  25057. +};
  25058. +
  25059. +static struct mdio_board_info uap_pro_mdio0_info[] = {
  25060. + {
  25061. + .bus_id = "ag71xx-mdio.0",
  25062. + .phy_addr = 0,
  25063. + .platform_data = &uap_pro_ar8327_data,
  25064. + },
  25065. +};
  25066. +
  25067. +#define UAP_PRO_MAC0_OFFSET 0x0000
  25068. +#define UAP_PRO_MAC1_OFFSET 0x0006
  25069. +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
  25070. +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
  25071. +
  25072. +static void __init ubnt_uap_pro_setup(void)
  25073. +{
  25074. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  25075. +
  25076. + ath79_register_m25p80(NULL);
  25077. +
  25078. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
  25079. + ubnt_uap_pro_gpio_leds);
  25080. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25081. + ARRAY_SIZE(uap_pro_gpio_keys),
  25082. + uap_pro_gpio_keys);
  25083. +
  25084. + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  25085. + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  25086. +
  25087. + ath79_register_mdio(0, 0x0);
  25088. + mdiobus_register_board_info(uap_pro_mdio0_info,
  25089. + ARRAY_SIZE(uap_pro_mdio0_info));
  25090. +
  25091. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  25092. + ath79_init_mac(ath79_eth0_data.mac_addr,
  25093. + eeprom + UAP_PRO_MAC0_OFFSET, 0);
  25094. +
  25095. + /* GMAC0 is connected to an AR8327 switch */
  25096. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  25097. + ath79_eth0_data.phy_mask = BIT(0);
  25098. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  25099. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  25100. + ath79_register_eth(0);
  25101. +}
  25102. +
  25103. +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
  25104. + ubnt_uap_pro_setup);
  25105. +
  25106. +#define UBNT_XW_GPIO_LED_L1 11
  25107. +#define UBNT_XW_GPIO_LED_L2 16
  25108. +#define UBNT_XW_GPIO_LED_L3 13
  25109. +#define UBNT_XW_GPIO_LED_L4 14
  25110. +
  25111. +static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
  25112. + {
  25113. + .name = "ubnt:red:link1",
  25114. + .gpio = UBNT_XW_GPIO_LED_L1,
  25115. + .active_low = 1,
  25116. + }, {
  25117. + .name = "ubnt:orange:link2",
  25118. + .gpio = UBNT_XW_GPIO_LED_L2,
  25119. + .active_low = 1,
  25120. + }, {
  25121. + .name = "ubnt:green:link3",
  25122. + .gpio = UBNT_XW_GPIO_LED_L3,
  25123. + .active_low = 1,
  25124. + }, {
  25125. + .name = "ubnt:green:link4",
  25126. + .gpio = UBNT_XW_GPIO_LED_L4,
  25127. + .active_low = 1,
  25128. + },
  25129. +};
  25130. +
  25131. +#define UBNT_ROCKET_TI_GPIO_LED_L1 16
  25132. +#define UBNT_ROCKET_TI_GPIO_LED_L2 17
  25133. +#define UBNT_ROCKET_TI_GPIO_LED_L3 18
  25134. +#define UBNT_ROCKET_TI_GPIO_LED_L4 19
  25135. +#define UBNT_ROCKET_TI_GPIO_LED_L5 20
  25136. +#define UBNT_ROCKET_TI_GPIO_LED_L6 21
  25137. +static struct gpio_led ubnt_rocket_ti_leds_gpio[] __initdata = {
  25138. + {
  25139. + .name = "ubnt:green:link1",
  25140. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L1,
  25141. + .active_low = 1,
  25142. + }, {
  25143. + .name = "ubnt:green:link2",
  25144. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L2,
  25145. + .active_low = 1,
  25146. + }, {
  25147. + .name = "ubnt:green:link3",
  25148. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L3,
  25149. + .active_low = 1,
  25150. + }, {
  25151. + .name = "ubnt:green:link4",
  25152. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L4,
  25153. + .active_low = 0,
  25154. + }, {
  25155. + .name = "ubnt:green:link5",
  25156. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L5,
  25157. + .active_low = 0,
  25158. + }, {
  25159. + .name = "ubnt:green:link6",
  25160. + .gpio = UBNT_ROCKET_TI_GPIO_LED_L6,
  25161. + .active_low = 0,
  25162. + },
  25163. +};
  25164. - return 0;
  25165. +static void __init ubnt_xw_init(void)
  25166. +{
  25167. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  25168. +
  25169. + ath79_register_m25p80(NULL);
  25170. +
  25171. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
  25172. + ubnt_xw_leds_gpio);
  25173. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25174. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  25175. + ubnt_xm_gpio_keys);
  25176. +
  25177. + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  25178. + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  25179. +
  25180. +
  25181. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
  25182. + ath79_init_mac(ath79_eth0_data.mac_addr,
  25183. + eeprom + UAP_PRO_MAC0_OFFSET, 0);
  25184. +
  25185. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  25186. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  25187. }
  25188. -static void __init ubnt_xm_pci_init(void)
  25189. +static void __init ubnt_nano_m_xw_setup(void)
  25190. {
  25191. - memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
  25192. - sizeof(ubnt_xm_eeprom_data.eeprom_data));
  25193. + ubnt_xw_init();
  25194. - ath79_pci_set_plat_dev_init(ubnt_xm_pci_plat_dev_init);
  25195. - ath79_register_pci();
  25196. + /* GMAC0 is connected to an AR8326 switch */
  25197. + ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
  25198. + ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
  25199. + ath79_eth0_data.speed = SPEED_100;
  25200. + ath79_eth0_data.duplex = DUPLEX_FULL;
  25201. + ath79_register_eth(0);
  25202. }
  25203. -#else
  25204. -static inline void ubnt_xm_pci_init(void) {}
  25205. -#endif /* CONFIG_PCI */
  25206. -static void __init ubnt_xm_init(void)
  25207. +static void __init ubnt_loco_m_xw_setup(void)
  25208. {
  25209. - ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
  25210. - ubnt_xm_leds_gpio);
  25211. + ubnt_xw_init();
  25212. + ath79_register_mdio(0, ~BIT(1));
  25213. + ath79_eth0_data.phy_mask = BIT(1);
  25214. + ath79_register_eth(0);
  25215. +}
  25216. +
  25217. +static void __init ubnt_rocket_m_xw_setup(void)
  25218. +{
  25219. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  25220. +
  25221. + ath79_register_m25p80(NULL);
  25222. +
  25223. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
  25224. + ubnt_xw_leds_gpio);
  25225. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25226. - ARRAY_SIZE(ubnt_xm_gpio_keys),
  25227. - ubnt_xm_gpio_keys);
  25228. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  25229. + ubnt_xm_gpio_keys);
  25230. - ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
  25231. - ARRAY_SIZE(ubnt_xm_spi_info));
  25232. + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  25233. + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  25234. - ubnt_xm_pci_init();
  25235. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  25236. + ath79_init_mac(ath79_eth0_data.mac_addr,
  25237. + eeprom + UAP_PRO_MAC0_OFFSET, 0);
  25238. +
  25239. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  25240. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  25241. +
  25242. + ath79_register_mdio(0, ~BIT(4));
  25243. + ath79_eth0_data.phy_mask = BIT(4);
  25244. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  25245. + ath79_register_eth(0);
  25246. }
  25247. -MIPS_MACHINE(ATH79_MACH_UBNT_XM,
  25248. - "UBNT-XM",
  25249. - "Ubiquiti Networks XM (rev 1.0) board",
  25250. - ubnt_xm_init);
  25251. +static struct at803x_platform_data ubnt_rocket_m_ti_at803_data = {
  25252. + .disable_smarteee = 1,
  25253. + .enable_rgmii_rx_delay = 1,
  25254. + .enable_rgmii_tx_delay = 1,
  25255. +};
  25256. +static struct mdio_board_info ubnt_rocket_m_ti_mdio_info[] = {
  25257. + {
  25258. + .bus_id = "ag71xx-mdio.0",
  25259. + .phy_addr = 4,
  25260. + .platform_data = &ubnt_rocket_m_ti_at803_data,
  25261. + },
  25262. +};
  25263. +
  25264. +static void __init ubnt_rocket_m_ti_setup(void)
  25265. +{
  25266. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  25267. +
  25268. + ath79_register_m25p80(NULL);
  25269. +
  25270. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rocket_ti_leds_gpio),
  25271. + ubnt_rocket_ti_leds_gpio);
  25272. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25273. + ARRAY_SIZE(ubnt_xm_gpio_keys),
  25274. + ubnt_xm_gpio_keys);
  25275. +
  25276. + ap91_pci_init(eeprom + 0x1000, NULL);
  25277. +
  25278. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  25279. + ath79_setup_ar934x_eth_rx_delay(3, 3);
  25280. + ath79_init_mac(ath79_eth0_data.mac_addr,
  25281. + eeprom + UAP_PRO_MAC0_OFFSET, 0);
  25282. + ath79_init_mac(ath79_eth1_data.mac_addr,
  25283. + eeprom + UAP_PRO_MAC1_OFFSET, 0);
  25284. +
  25285. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  25286. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  25287. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  25288. + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  25289. +
  25290. + mdiobus_register_board_info(ubnt_rocket_m_ti_mdio_info,
  25291. + ARRAY_SIZE(ubnt_rocket_m_ti_mdio_info));
  25292. + ath79_register_mdio(0, 0x0);
  25293. +
  25294. +
  25295. + ath79_eth0_data.phy_mask = BIT(4);
  25296. + /* read out from vendor */
  25297. + ath79_eth0_pll_data.pll_1000 = 0x2000000;
  25298. + ath79_eth0_pll_data.pll_10 = 0x1313;
  25299. + ath79_register_eth(0);
  25300. +
  25301. + ath79_register_mdio(1, 0x0);
  25302. + ath79_eth1_data.phy_mask = BIT(3);
  25303. + ath79_register_eth(1);
  25304. +}
  25305. +
  25306. +
  25307. +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
  25308. + ubnt_nano_m_xw_setup);
  25309. +
  25310. +MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
  25311. + ubnt_loco_m_xw_setup);
  25312. +
  25313. +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_XW, "UBNT-RM-XW", "Ubiquiti Rocket M XW",
  25314. + ubnt_rocket_m_xw_setup);
  25315. +
  25316. +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_TI, "UBNT-RM-TI", "Ubiquiti Rocket M TI",
  25317. + ubnt_rocket_m_ti_setup);
  25318. +
  25319. +static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
  25320. + {
  25321. + .name = "ubnt:blue:wlan",
  25322. + .gpio = 0,
  25323. + }, {
  25324. + .name = "ubnt:white:status",
  25325. + .gpio = 1,
  25326. + },
  25327. +};
  25328. +
  25329. +static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
  25330. + {
  25331. + .desc = "reset",
  25332. + .type = EV_KEY,
  25333. + .code = KEY_RESTART,
  25334. + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  25335. + .gpio = 12,
  25336. + .active_low = 1,
  25337. + }
  25338. +};
  25339. +
  25340. +static void __init ubnt_airgateway_setup(void)
  25341. +{
  25342. + u32 t;
  25343. + u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
  25344. + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  25345. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  25346. +
  25347. +
  25348. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  25349. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  25350. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  25351. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  25352. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  25353. +
  25354. + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  25355. + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  25356. + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  25357. +
  25358. + ath79_register_m25p80(NULL);
  25359. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
  25360. + ubnt_airgateway_gpio_leds);
  25361. +
  25362. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25363. + ARRAY_SIZE(airgateway_gpio_keys),
  25364. + airgateway_gpio_keys);
  25365. +
  25366. + ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
  25367. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  25368. +
  25369. + ath79_register_mdio(0, 0x0);
  25370. +
  25371. + ath79_register_eth(1);
  25372. + ath79_register_eth(0);
  25373. +
  25374. + ath79_register_wmac(ee, NULL);
  25375. +}
  25376. +
  25377. +MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
  25378. + ubnt_airgateway_setup);
  25379. +
  25380. +static struct gpio_led ubnt_airgateway_pro_gpio_leds[] __initdata = {
  25381. + {
  25382. + .name = "ubnt:blue:wlan",
  25383. + .gpio = 13,
  25384. + }, {
  25385. + .name = "ubnt:white:status",
  25386. + .gpio = 17,
  25387. + },
  25388. +};
  25389. +
  25390. +
  25391. +static struct gpio_keys_button airgateway_pro_gpio_keys[] __initdata = {
  25392. + {
  25393. + .desc = "reset",
  25394. + .type = EV_KEY,
  25395. + .code = KEY_RESTART,
  25396. + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  25397. + .gpio = 12,
  25398. + .active_low = 1,
  25399. + }
  25400. +};
  25401. +
  25402. +static void __init ubnt_airgateway_pro_setup(void)
  25403. +{
  25404. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  25405. + u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
  25406. +
  25407. + ath79_register_m25p80(NULL);
  25408. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_pro_gpio_leds),
  25409. + ubnt_airgateway_pro_gpio_leds);
  25410. +
  25411. + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  25412. + ARRAY_SIZE(airgateway_pro_gpio_keys),
  25413. + airgateway_pro_gpio_keys);
  25414. +
  25415. + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  25416. + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  25417. +
  25418. +
  25419. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  25420. +
  25421. + ath79_register_mdio(1, 0x0);
  25422. +
  25423. + /* GMAC0 is left unused in this configuration */
  25424. +
  25425. + /* GMAC1 is connected to MAC0 on the internal switch */
  25426. + /* The PoE/WAN port connects to port 5 on the internal switch */
  25427. + /* The LAN port connects to port 4 on the internal switch */
  25428. + ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
  25429. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  25430. + ath79_register_eth(1);
  25431. +
  25432. +}
  25433. +
  25434. +MIPS_MACHINE(ATH79_MACH_UBNT_AIRGWP, "UBNT-AGWP", "Ubiquiti AirGateway Pro",
  25435. + ubnt_airgateway_pro_setup);
  25436. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-weio.c linux-4.1.13/arch/mips/ath79/mach-weio.c
  25437. --- linux-4.1.13.orig/arch/mips/ath79/mach-weio.c 1970-01-01 01:00:00.000000000 +0100
  25438. +++ linux-4.1.13/arch/mips/ath79/mach-weio.c 2015-11-21 17:22:11.759223549 +0100
  25439. @@ -0,0 +1,140 @@
  25440. +/**
  25441. + * WEIO Web Of Things Platform
  25442. + *
  25443. + * Copyright (C) 2013 Drasko DRASKOVIC and Uros PETREVSKI
  25444. + *
  25445. + * ## ## ######## #### #######
  25446. + * ## ## ## ## ## ## ##
  25447. + * ## ## ## ## ## ## ##
  25448. + * ## ## ## ###### ## ## ##
  25449. + * ## ## ## ## ## ## ##
  25450. + * ## ## ## ## ## ## ##
  25451. + * ### ### ######## #### #######
  25452. + *
  25453. + * Web Of Things Platform
  25454. + *
  25455. + * This program is free software; you can redistribute it and/or
  25456. + * modify it under the terms of the GNU General Public License
  25457. + * as published by the Free Software Foundation; either version 2
  25458. + * of the License, or (at your option) any later version.
  25459. + *
  25460. + * This program is distributed in the hope that it will be useful,
  25461. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25462. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25463. + * GNU General Public License for more details.
  25464. + *
  25465. + * You should have received a copy of the GNU General Public License
  25466. + * along with this program; if not, write to the Free Software
  25467. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25468. + *
  25469. + * Authors :
  25470. + * Drasko DRASKOVIC <drasko.draskovic@gmail.com>
  25471. + * Uros PETREVSKI <uros@nodesign.net>
  25472. + */
  25473. +
  25474. +#include <asm/mach-ath79/ath79.h>
  25475. +#include <asm/mach-ath79/ar71xx_regs.h>
  25476. +#include <linux/i2c-gpio.h>
  25477. +#include <linux/platform_device.h>
  25478. +#include "common.h"
  25479. +#include "dev-eth.h"
  25480. +#include "dev-gpio-buttons.h"
  25481. +#include "dev-leds-gpio.h"
  25482. +#include "dev-m25p80.h"
  25483. +#include "dev-spi.h"
  25484. +#include "dev-usb.h"
  25485. +#include "dev-wmac.h"
  25486. +#include "machtypes.h"
  25487. +
  25488. +#define WEIO_GPIO_LED_STA 1
  25489. +#define WEIO_GPIO_LED_AP 16
  25490. +
  25491. +#define WEIO_GPIO_BTN_AP 20
  25492. +#define WEIO_GPIO_BTN_RESET 23
  25493. +
  25494. +#define WEIO_KEYS_POLL_INTERVAL 20 /* msecs */
  25495. +#define WEIO_KEYS_DEBOUNCE_INTERVAL (3 * WEIO_KEYS_POLL_INTERVAL)
  25496. +
  25497. +#define WEIO_MAC0_OFFSET 0x0000
  25498. +#define WEIO_MAC1_OFFSET 0x0006
  25499. +#define WEIO_CALDATA_OFFSET 0x1000
  25500. +#define WEIO_WMAC_MAC_OFFSET 0x1002
  25501. +
  25502. +static struct gpio_led weio_leds_gpio[] __initdata = {
  25503. + {
  25504. + .name = "weio:green:sta",
  25505. + .gpio = WEIO_GPIO_LED_STA,
  25506. + .active_low = 1,
  25507. + .default_state = LEDS_GPIO_DEFSTATE_ON,
  25508. + },
  25509. + {
  25510. + .name = "weio:green:ap",
  25511. + .gpio = WEIO_GPIO_LED_AP,
  25512. + .active_low = 1,
  25513. + .default_state = LEDS_GPIO_DEFSTATE_ON,
  25514. + }
  25515. +};
  25516. +
  25517. +static struct gpio_keys_button weio_gpio_keys[] __initdata = {
  25518. + {
  25519. + .desc = "ap button",
  25520. + .type = EV_KEY,
  25521. + .code = BTN_0,
  25522. + .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
  25523. + .gpio = WEIO_GPIO_BTN_AP,
  25524. + .active_low = 1,
  25525. + },
  25526. + {
  25527. + .desc = "soft-reset button",
  25528. + .type = EV_KEY,
  25529. + .code = BTN_1,
  25530. + .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
  25531. + .gpio = WEIO_GPIO_BTN_RESET,
  25532. + .active_low = 1,
  25533. + }
  25534. +};
  25535. +
  25536. +static struct i2c_gpio_platform_data weio_i2c_gpio_data = {
  25537. + .sda_pin = 18,
  25538. + .scl_pin = 19,
  25539. +};
  25540. +
  25541. +static struct platform_device weio_i2c_gpio = {
  25542. + .name = "i2c-gpio",
  25543. + .id = 0,
  25544. + .dev = {
  25545. + .platform_data = &weio_i2c_gpio_data,
  25546. + },
  25547. +};
  25548. +
  25549. +static void __init weio_common_setup(void)
  25550. +{
  25551. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  25552. +
  25553. + ath79_register_m25p80(NULL);
  25554. + ath79_register_wmac(art + WEIO_CALDATA_OFFSET, art + WEIO_WMAC_MAC_OFFSET);
  25555. +}
  25556. +
  25557. +static void __init weio_setup(void)
  25558. +{
  25559. + weio_common_setup();
  25560. +
  25561. + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  25562. + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  25563. + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  25564. + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  25565. + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  25566. +
  25567. + platform_device_register(&weio_i2c_gpio);
  25568. +
  25569. + ath79_register_leds_gpio(-1, ARRAY_SIZE(weio_leds_gpio),
  25570. + weio_leds_gpio);
  25571. +
  25572. + ath79_register_gpio_keys_polled(-1, WEIO_KEYS_POLL_INTERVAL,
  25573. + ARRAY_SIZE(weio_gpio_keys),
  25574. + weio_gpio_keys);
  25575. +
  25576. + ath79_register_usb();
  25577. +}
  25578. +
  25579. +MIPS_MACHINE(ATH79_MACH_WEIO, "WEIO", "WeIO board", weio_setup);
  25580. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-whr-hp-g300n.c linux-4.1.13/arch/mips/ath79/mach-whr-hp-g300n.c
  25581. --- linux-4.1.13.orig/arch/mips/ath79/mach-whr-hp-g300n.c 1970-01-01 01:00:00.000000000 +0100
  25582. +++ linux-4.1.13/arch/mips/ath79/mach-whr-hp-g300n.c 2015-09-13 20:04:35.072523889 +0200
  25583. @@ -0,0 +1,155 @@
  25584. +/*
  25585. + * Buffalo WHR-HP-G300N board support
  25586. + *
  25587. + * based on ...
  25588. + *
  25589. + * TP-LINK TL-WR741ND board support
  25590. + *
  25591. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  25592. + *
  25593. + * This program is free software; you can redistribute it and/or modify it
  25594. + * under the terms of the GNU General Public License version 2 as published
  25595. + * by the Free Software Foundation.
  25596. + */
  25597. +
  25598. +#include <asm/mach-ath79/ath79.h>
  25599. +#include <asm/mach-ath79/ar71xx_regs.h>
  25600. +
  25601. +#include "common.h"
  25602. +#include "dev-ap9x-pci.h"
  25603. +#include "dev-eth.h"
  25604. +#include "dev-gpio-buttons.h"
  25605. +#include "dev-leds-gpio.h"
  25606. +#include "dev-m25p80.h"
  25607. +#include "machtypes.h"
  25608. +
  25609. +#define WHRHPG300N_GPIO_LED_SECURITY 0
  25610. +#define WHRHPG300N_GPIO_LED_DIAG 1
  25611. +#define WHRHPG300N_GPIO_LED_ROUTER 6
  25612. +
  25613. +#define WHRHPG300N_GPIO_BTN_ROUTER_ON 7
  25614. +#define WHRHPG300N_GPIO_BTN_ROUTER_AUTO 8
  25615. +#define WHRHPG300N_GPIO_BTN_RESET 11
  25616. +#define WHRHPG300N_GPIO_BTN_AOSS 12
  25617. +#define WHRHPG300N_GPIO_LED_LAN1 13
  25618. +#define WHRHPG300N_GPIO_LED_LAN2 14
  25619. +#define WHRHPG300N_GPIO_LED_LAN3 15
  25620. +#define WHRHPG300N_GPIO_LED_LAN4 16
  25621. +#define WHRHPG300N_GPIO_LED_WAN 17
  25622. +
  25623. +#define WHRHPG300N_KEYS_POLL_INTERVAL 20 /* msecs */
  25624. +#define WHRHPG300N_KEYS_DEBOUNCE_INTERVAL (3 * WHRHPG300N_KEYS_POLL_INTERVAL)
  25625. +
  25626. +#define WHRHPG300N_MAC_OFFSET 0x20c
  25627. +
  25628. +static struct gpio_led whrhpg300n_leds_gpio[] __initdata = {
  25629. + {
  25630. + .name = "buffalo:orange:security",
  25631. + .gpio = WHRHPG300N_GPIO_LED_SECURITY,
  25632. + .active_low = 1,
  25633. + }, {
  25634. + .name = "buffalo:red:diag",
  25635. + .gpio = WHRHPG300N_GPIO_LED_DIAG,
  25636. + .active_low = 1,
  25637. + }, {
  25638. + .name = "buffalo:green:router",
  25639. + .gpio = WHRHPG300N_GPIO_LED_ROUTER,
  25640. + .active_low = 1,
  25641. + }, {
  25642. + .name = "buffalo:green:wan",
  25643. + .gpio = WHRHPG300N_GPIO_LED_WAN,
  25644. + .active_low = 1,
  25645. + }, {
  25646. + .name = "buffalo:green:lan1",
  25647. + .gpio = WHRHPG300N_GPIO_LED_LAN1,
  25648. + .active_low = 1,
  25649. + }, {
  25650. + .name = "buffalo:green:lan2",
  25651. + .gpio = WHRHPG300N_GPIO_LED_LAN2,
  25652. + .active_low = 1,
  25653. + }, {
  25654. + .name = "buffalo:green:lan3",
  25655. + .gpio = WHRHPG300N_GPIO_LED_LAN3,
  25656. + .active_low = 1,
  25657. + }, {
  25658. + .name = "buffalo:green:lan4",
  25659. + .gpio = WHRHPG300N_GPIO_LED_LAN4,
  25660. + .active_low = 1,
  25661. + }
  25662. +};
  25663. +
  25664. +static struct gpio_keys_button whrhpg300n_gpio_keys[] __initdata = {
  25665. + {
  25666. + .desc = "reset",
  25667. + .type = EV_KEY,
  25668. + .code = KEY_RESTART,
  25669. + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  25670. + .gpio = WHRHPG300N_GPIO_BTN_RESET,
  25671. + .active_low = 1,
  25672. + }, {
  25673. + .desc = "aoss/wps",
  25674. + .type = EV_KEY,
  25675. + .code = KEY_WPS_BUTTON,
  25676. + .gpio = WHRHPG300N_GPIO_BTN_AOSS,
  25677. + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  25678. + .active_low = 1,
  25679. + }, {
  25680. + .desc = "router_on",
  25681. + .type = EV_KEY,
  25682. + .code = BTN_2,
  25683. + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_ON,
  25684. + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  25685. + .active_low = 1,
  25686. + }, {
  25687. + .desc = "router_auto",
  25688. + .type = EV_KEY,
  25689. + .code = BTN_3,
  25690. + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_AUTO,
  25691. + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  25692. + .active_low = 1,
  25693. + }
  25694. +};
  25695. +
  25696. +static void __init whrhpg300n_setup(void)
  25697. +{
  25698. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  25699. + u8 *mac = (u8 *) KSEG1ADDR(ee + WHRHPG300N_MAC_OFFSET);
  25700. +
  25701. + ath79_register_m25p80(NULL);
  25702. +
  25703. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  25704. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  25705. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  25706. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  25707. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  25708. +
  25709. + ath79_register_leds_gpio(-1, ARRAY_SIZE(whrhpg300n_leds_gpio),
  25710. + whrhpg300n_leds_gpio);
  25711. +
  25712. + ath79_register_gpio_keys_polled(-1, WHRHPG300N_KEYS_POLL_INTERVAL,
  25713. + ARRAY_SIZE(whrhpg300n_gpio_keys),
  25714. + whrhpg300n_gpio_keys);
  25715. +
  25716. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  25717. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  25718. +
  25719. + ath79_register_mdio(0, 0x0);
  25720. +
  25721. + /* LAN ports */
  25722. + ath79_register_eth(1);
  25723. + /* WAN port */
  25724. + ath79_register_eth(0);
  25725. +
  25726. + ap9x_pci_setup_wmac_led_pin(0, 1);
  25727. +
  25728. + ap91_pci_init(ee, mac);
  25729. +}
  25730. +
  25731. +MIPS_MACHINE(ATH79_MACH_WHR_HP_G300N, "WHR-HP-G300N", "Buffalo WHR-HP-G300N",
  25732. + whrhpg300n_setup);
  25733. +
  25734. +MIPS_MACHINE(ATH79_MACH_WHR_G301N, "WHR-G301N", "Buffalo WHR-G301N",
  25735. + whrhpg300n_setup);
  25736. +
  25737. +MIPS_MACHINE(ATH79_MACH_WHR_HP_GN, "WHR-HP-GN", "Buffalo WHR-HP-GN",
  25738. + whrhpg300n_setup);
  25739. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wlae-ag300n.c linux-4.1.13/arch/mips/ath79/mach-wlae-ag300n.c
  25740. --- linux-4.1.13.orig/arch/mips/ath79/mach-wlae-ag300n.c 1970-01-01 01:00:00.000000000 +0100
  25741. +++ linux-4.1.13/arch/mips/ath79/mach-wlae-ag300n.c 2015-09-13 20:04:35.072523889 +0200
  25742. @@ -0,0 +1,114 @@
  25743. +/*
  25744. + * Buffalo WLAE-AG300N board support
  25745. + */
  25746. +
  25747. +#include <linux/gpio.h>
  25748. +#include <linux/mtd/mtd.h>
  25749. +#include <linux/mtd/partitions.h>
  25750. +
  25751. +#include <asm/mach-ath79/ath79.h>
  25752. +
  25753. +#include "dev-eth.h"
  25754. +#include "dev-ap9x-pci.h"
  25755. +#include "dev-gpio-buttons.h"
  25756. +#include "dev-leds-gpio.h"
  25757. +#include "dev-m25p80.h"
  25758. +#include "dev-usb.h"
  25759. +#include "machtypes.h"
  25760. +
  25761. +#define WLAEAG300N_MAC_OFFSET 0x20c
  25762. +#define WLAEAG300N_KEYS_POLL_INTERVAL 20 /* msecs */
  25763. +#define WLAEAG300N_KEYS_DEBOUNCE_INTERVAL (3 * WLAEAG300N_KEYS_POLL_INTERVAL)
  25764. +
  25765. +
  25766. +static struct gpio_led wlaeag300n_leds_gpio[] __initdata = {
  25767. + /*
  25768. + * Note: Writing 1 into GPIO 13 will power down the device.
  25769. + */
  25770. + {
  25771. + .name = "buffalo:green:wireless",
  25772. + .gpio = 14,
  25773. + .active_low = 1,
  25774. + }, {
  25775. + .name = "buffalo:red:wireless",
  25776. + .gpio = 15,
  25777. + .active_low = 1,
  25778. + }, {
  25779. + .name = "buffalo:green:status",
  25780. + .gpio = 16,
  25781. + .active_low = 1,
  25782. + }, {
  25783. + .name = "buffalo:red:status",
  25784. + .gpio = 17,
  25785. + .active_low = 1,
  25786. + }
  25787. +};
  25788. +
  25789. +
  25790. +static struct gpio_keys_button wlaeag300n_gpio_keys[] __initdata = {
  25791. + {
  25792. + .desc = "function",
  25793. + .type = EV_KEY,
  25794. + .code = KEY_MODE,
  25795. + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
  25796. + .gpio = 0,
  25797. + .active_low = 1,
  25798. + }, {
  25799. + .desc = "reset",
  25800. + .type = EV_KEY,
  25801. + .code = KEY_RESTART,
  25802. + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
  25803. + .gpio = 1,
  25804. + .active_low = 1,
  25805. + }, {
  25806. + .desc = "power",
  25807. + .type = EV_KEY,
  25808. + .code = KEY_POWER,
  25809. + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
  25810. + .gpio = 11,
  25811. + .active_low = 1,
  25812. + }, {
  25813. + .desc = "aoss",
  25814. + .type = EV_KEY,
  25815. + .code = KEY_WPS_BUTTON,
  25816. + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
  25817. + .gpio = 12,
  25818. + .active_low = 1,
  25819. + }
  25820. +};
  25821. +
  25822. +static void __init wlaeag300n_setup(void)
  25823. +{
  25824. + u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1fff1000);
  25825. + u8 *mac1 = eeprom1 + WLAEAG300N_MAC_OFFSET;
  25826. +
  25827. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  25828. + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 1);
  25829. +
  25830. + ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
  25831. +
  25832. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  25833. + ath79_eth0_data.speed = SPEED_1000;
  25834. + ath79_eth0_data.duplex = DUPLEX_FULL;
  25835. + ath79_eth0_data.phy_mask = BIT(0);
  25836. +
  25837. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  25838. + ath79_eth1_data.phy_mask = BIT(4);
  25839. +
  25840. + ath79_register_eth(0);
  25841. + ath79_register_eth(1);
  25842. +
  25843. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wlaeag300n_leds_gpio),
  25844. + wlaeag300n_leds_gpio);
  25845. +
  25846. + ath79_register_gpio_keys_polled(-1, WLAEAG300N_KEYS_POLL_INTERVAL,
  25847. + ARRAY_SIZE(wlaeag300n_gpio_keys),
  25848. + wlaeag300n_gpio_keys);
  25849. +
  25850. + ath79_register_m25p80(NULL);
  25851. +
  25852. + ap91_pci_init(eeprom1, mac1);
  25853. +}
  25854. +
  25855. +MIPS_MACHINE(ATH79_MACH_WLAE_AG300N, "WLAE-AG300N",
  25856. + "Buffalo WLAE-AG300N", wlaeag300n_setup);
  25857. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wlr8100.c linux-4.1.13/arch/mips/ath79/mach-wlr8100.c
  25858. --- linux-4.1.13.orig/arch/mips/ath79/mach-wlr8100.c 1970-01-01 01:00:00.000000000 +0100
  25859. +++ linux-4.1.13/arch/mips/ath79/mach-wlr8100.c 2015-09-13 20:04:35.072523889 +0200
  25860. @@ -0,0 +1,206 @@
  25861. +/*
  25862. + * Sitecom X8 AC1750 WLR-8100 board support
  25863. + *
  25864. + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  25865. + * Copyright (c) 2012 Qualcomm Atheros
  25866. + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
  25867. + *
  25868. + * Permission to use, copy, modify, and/or distribute this software for any
  25869. + * purpose with or without fee is hereby granted, provided that the above
  25870. + * copyright notice and this permission notice appear in all copies.
  25871. + *
  25872. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  25873. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  25874. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  25875. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  25876. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  25877. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  25878. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  25879. + *
  25880. + */
  25881. +
  25882. +#include <linux/platform_device.h>
  25883. +#include <linux/ar8216_platform.h>
  25884. +
  25885. +#include <asm/mach-ath79/ar71xx_regs.h>
  25886. +
  25887. +#include "common.h"
  25888. +#include "pci.h"
  25889. +#include "dev-ap9x-pci.h"
  25890. +#include "dev-gpio-buttons.h"
  25891. +#include "dev-eth.h"
  25892. +#include "dev-leds-gpio.h"
  25893. +#include "dev-m25p80.h"
  25894. +#include "dev-usb.h"
  25895. +#include "dev-wmac.h"
  25896. +#include "machtypes.h"
  25897. +
  25898. +#define WLR8100_GPIO_LED_USB 4
  25899. +#define WLR8100_GPIO_LED_WLAN_5G 12
  25900. +#define WLR8100_GPIO_LED_WLAN_2G 13
  25901. +#define WLR8100_GPIO_LED_STATUS_RED 14
  25902. +#define WLR8100_GPIO_LED_WPS_RED 15
  25903. +#define WLR8100_GPIO_LED_STATUS_AMBER 19
  25904. +#define WLR8100_GPIO_LED_WPS_GREEN 20
  25905. +
  25906. +#define WLR8100_GPIO_BTN_WPS 16
  25907. +#define WLR8100_GPIO_BTN_RFKILL 21
  25908. +
  25909. +#define WLR8100_KEYS_POLL_INTERVAL 20 /* msecs */
  25910. +#define WLR8100_KEYS_DEBOUNCE_INTERVAL (3 * WLR8100_KEYS_POLL_INTERVAL)
  25911. +
  25912. +#define WLR8100_MAC0_OFFSET 0
  25913. +#define WLR8100_MAC1_OFFSET 6
  25914. +#define WLR8100_WMAC_CALDATA_OFFSET 0x1000
  25915. +#define WLR8100_PCIE_CALDATA_OFFSET 0x5000
  25916. +
  25917. +static struct gpio_led wlr8100_leds_gpio[] __initdata = {
  25918. + {
  25919. + .name = "wlr8100:amber:status",
  25920. + .gpio = WLR8100_GPIO_LED_STATUS_AMBER,
  25921. + .active_low = 1,
  25922. + },
  25923. + {
  25924. + .name = "wlr8100:red:status",
  25925. + .gpio = WLR8100_GPIO_LED_STATUS_RED,
  25926. + .active_low = 1,
  25927. + },
  25928. + {
  25929. + .name = "wlr8100:green:wps",
  25930. + .gpio = WLR8100_GPIO_LED_WPS_GREEN,
  25931. + .active_low = 1,
  25932. + },
  25933. + {
  25934. + .name = "wlr8100:red:wps",
  25935. + .gpio = WLR8100_GPIO_LED_WPS_RED,
  25936. + .active_low = 1,
  25937. + },
  25938. + {
  25939. + .name = "wlr8100:red:wlan-2g",
  25940. + .gpio = WLR8100_GPIO_LED_WLAN_2G,
  25941. + .active_low = 1,
  25942. + },
  25943. + {
  25944. + .name = "wlr8100:red:usb",
  25945. + .gpio = WLR8100_GPIO_LED_USB,
  25946. + .active_low = 1,
  25947. + }
  25948. +};
  25949. +
  25950. +static struct gpio_keys_button wlr8100_gpio_keys[] __initdata = {
  25951. + {
  25952. + .desc = "WPS button",
  25953. + .type = EV_KEY,
  25954. + .code = KEY_WPS_BUTTON,
  25955. + .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
  25956. + .gpio = WLR8100_GPIO_BTN_WPS,
  25957. + .active_low = 1,
  25958. + },
  25959. + {
  25960. + .desc = "RFKILL button",
  25961. + .type = EV_KEY,
  25962. + .code = KEY_RFKILL,
  25963. + .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
  25964. + .gpio = WLR8100_GPIO_BTN_RFKILL,
  25965. + .active_low = 1,
  25966. + },
  25967. +};
  25968. +
  25969. +static struct ar8327_pad_cfg wlr8100_ar8327_pad0_cfg;
  25970. +static struct ar8327_pad_cfg wlr8100_ar8327_pad6_cfg;
  25971. +
  25972. +static struct ar8327_platform_data wlr8100_ar8327_data = {
  25973. + .pad0_cfg = &wlr8100_ar8327_pad0_cfg,
  25974. + .pad6_cfg = &wlr8100_ar8327_pad6_cfg,
  25975. + .port0_cfg = {
  25976. + .force_link = 1,
  25977. + .speed = AR8327_PORT_SPEED_1000,
  25978. + .duplex = 1,
  25979. + .txpause = 1,
  25980. + .rxpause = 1,
  25981. + },
  25982. + .port6_cfg = {
  25983. + .force_link = 1,
  25984. + .speed = AR8327_PORT_SPEED_1000,
  25985. + .duplex = 1,
  25986. + .txpause = 1,
  25987. + .rxpause = 1,
  25988. + },
  25989. +};
  25990. +
  25991. +static struct mdio_board_info wlr8100_mdio0_info[] = {
  25992. + {
  25993. + .bus_id = "ag71xx-mdio.0",
  25994. + .phy_addr = 0,
  25995. + .platform_data = &wlr8100_ar8327_data,
  25996. + },
  25997. +};
  25998. +
  25999. +static void __init wlr8100_common_setup(void)
  26000. +{
  26001. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  26002. +
  26003. + ath79_register_m25p80(NULL);
  26004. +
  26005. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wlr8100_leds_gpio),
  26006. + wlr8100_leds_gpio);
  26007. + ath79_register_gpio_keys_polled(-1, WLR8100_KEYS_POLL_INTERVAL,
  26008. + ARRAY_SIZE(wlr8100_gpio_keys),
  26009. + wlr8100_gpio_keys);
  26010. +
  26011. + ath79_register_usb();
  26012. +
  26013. + ath79_register_wmac(art + WLR8100_WMAC_CALDATA_OFFSET, NULL);
  26014. +
  26015. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  26016. +
  26017. + ath79_register_mdio(0, 0x0);
  26018. +
  26019. + ath79_init_mac(ath79_eth0_data.mac_addr, art + WLR8100_MAC0_OFFSET, 0);
  26020. +
  26021. + mdiobus_register_board_info(wlr8100_mdio0_info,
  26022. + ARRAY_SIZE(wlr8100_mdio0_info));
  26023. +
  26024. + /* GMAC0 is connected to the RMGII interface */
  26025. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  26026. + ath79_eth0_data.phy_mask = BIT(0);
  26027. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  26028. +
  26029. + ath79_register_eth(0);
  26030. +
  26031. + /* GMAC1 is connected tot eh SGMII interface */
  26032. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  26033. + ath79_eth1_data.speed = SPEED_1000;
  26034. + ath79_eth1_data.duplex = DUPLEX_FULL;
  26035. +
  26036. + ath79_register_eth(1);
  26037. +}
  26038. +
  26039. +static void __init wlr8100_010_setup(void)
  26040. +{
  26041. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  26042. +
  26043. + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
  26044. + wlr8100_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  26045. + wlr8100_ar8327_pad0_cfg.txclk_delay_en = true;
  26046. + wlr8100_ar8327_pad0_cfg.rxclk_delay_en = true;
  26047. + wlr8100_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  26048. + wlr8100_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  26049. + wlr8100_ar8327_pad0_cfg.mac06_exchange_en = true;
  26050. +
  26051. + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
  26052. + wlr8100_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  26053. + wlr8100_ar8327_pad6_cfg.rxclk_delay_en = true;
  26054. + wlr8100_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  26055. +
  26056. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  26057. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  26058. +
  26059. + wlr8100_common_setup();
  26060. + ap91_pci_init(art + WLR8100_PCIE_CALDATA_OFFSET, NULL);
  26061. +}
  26062. +
  26063. +MIPS_MACHINE(ATH79_MACH_WLR8100, "WLR8100",
  26064. + "Sitecom WLR-8100",
  26065. + wlr8100_010_setup);
  26066. +
  26067. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wndap360.c linux-4.1.13/arch/mips/ath79/mach-wndap360.c
  26068. --- linux-4.1.13.orig/arch/mips/ath79/mach-wndap360.c 1970-01-01 01:00:00.000000000 +0100
  26069. +++ linux-4.1.13/arch/mips/ath79/mach-wndap360.c 2015-09-13 20:04:35.072523889 +0200
  26070. @@ -0,0 +1,105 @@
  26071. +/*
  26072. + * Netgear WNDAP360 board support (proper leds / button support missing)
  26073. + *
  26074. + * Based on AP96
  26075. + * Copyright (C) 2013 Jacek Kikiewicz
  26076. + * Copyright (C) 2009 Marco Porsch
  26077. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  26078. + * Copyright (C) 2010 Atheros Communications
  26079. + *
  26080. + * This program is free software; you can redistribute it and/or modify it
  26081. + * under the terms of the GNU General Public License version 2 as published
  26082. + * by the Free Software Foundation.
  26083. + */
  26084. +
  26085. +#include <linux/platform_device.h>
  26086. +#include <linux/delay.h>
  26087. +
  26088. +#include <asm/mach-ath79/ath79.h>
  26089. +
  26090. +#include "dev-ap9x-pci.h"
  26091. +#include "dev-eth.h"
  26092. +#include "dev-gpio-buttons.h"
  26093. +#include "dev-leds-gpio.h"
  26094. +#include "dev-m25p80.h"
  26095. +#include "machtypes.h"
  26096. +
  26097. +#define WNDAP360_GPIO_LED_POWER_ORANGE 0
  26098. +#define WNDAP360_GPIO_LED_POWER_GREEN 2
  26099. +
  26100. +/* Reset button - next to the power connector */
  26101. +#define WNDAP360_GPIO_BTN_RESET 8
  26102. +
  26103. +#define WNDAP360_KEYS_POLL_INTERVAL 20 /* msecs */
  26104. +#define WNDAP360_KEYS_DEBOUNCE_INTERVAL (3 * WNDAP360_KEYS_POLL_INTERVAL)
  26105. +
  26106. +#define WNDAP360_WMAC0_MAC_OFFSET 0x120c
  26107. +#define WNDAP360_WMAC1_MAC_OFFSET 0x520c
  26108. +#define WNDAP360_CALDATA0_OFFSET 0x1000
  26109. +#define WNDAP360_CALDATA1_OFFSET 0x5000
  26110. +
  26111. +/*
  26112. + * WNDAP360 this still uses leds definitions from AP96
  26113. + *
  26114. + */
  26115. +static struct gpio_led wndap360_leds_gpio[] __initdata = {
  26116. + {
  26117. + .name = "netgear:green:power",
  26118. + .gpio = WNDAP360_GPIO_LED_POWER_GREEN,
  26119. + .active_low = 1,
  26120. + }, {
  26121. + .name = "netgear:orange:power",
  26122. + .gpio = WNDAP360_GPIO_LED_POWER_ORANGE,
  26123. + .active_low = 1,
  26124. + }
  26125. +};
  26126. +
  26127. +static struct gpio_keys_button wndap360_gpio_keys[] __initdata = {
  26128. + {
  26129. + .desc = "reset",
  26130. + .type = EV_KEY,
  26131. + .code = KEY_RESTART,
  26132. + .debounce_interval = WNDAP360_KEYS_DEBOUNCE_INTERVAL,
  26133. + .gpio = WNDAP360_GPIO_BTN_RESET,
  26134. + .active_low = 1,
  26135. + }
  26136. +};
  26137. +
  26138. +#define WNDAP360_LAN_PHYMASK 0x0f
  26139. +
  26140. +static void __init wndap360_setup(void)
  26141. +{
  26142. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  26143. +
  26144. + ath79_register_mdio(0, ~(WNDAP360_LAN_PHYMASK));
  26145. +
  26146. + /* Reusing wifi MAC with offset of 1 as eth0 MAC */
  26147. + ath79_init_mac(ath79_eth0_data.mac_addr,
  26148. + art + WNDAP360_WMAC0_MAC_OFFSET, 1);
  26149. + ath79_eth0_pll_data.pll_1000 = 0x11110000;
  26150. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  26151. + ath79_eth0_data.phy_mask = WNDAP360_LAN_PHYMASK;
  26152. + ath79_eth0_data.speed = SPEED_1000;
  26153. + ath79_eth0_data.duplex = DUPLEX_FULL;
  26154. +
  26155. + ath79_register_eth(0);
  26156. +
  26157. + ath79_register_m25p80(NULL);
  26158. +
  26159. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndap360_leds_gpio),
  26160. + wndap360_leds_gpio);
  26161. +
  26162. + ath79_register_gpio_keys_polled(-1, WNDAP360_KEYS_POLL_INTERVAL,
  26163. + ARRAY_SIZE(wndap360_gpio_keys),
  26164. + wndap360_gpio_keys);
  26165. +
  26166. + ap9x_pci_setup_wmac_led_pin(0, 5);
  26167. + ap9x_pci_setup_wmac_led_pin(1, 5);
  26168. +
  26169. + ap94_pci_init(art + WNDAP360_CALDATA0_OFFSET,
  26170. + art + WNDAP360_WMAC0_MAC_OFFSET,
  26171. + art + WNDAP360_CALDATA1_OFFSET,
  26172. + art + WNDAP360_WMAC1_MAC_OFFSET);
  26173. +}
  26174. +
  26175. +MIPS_MACHINE(ATH79_MACH_WNDAP360, "WNDAP360", "Netgear WNDAP360", wndap360_setup);
  26176. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wndr3700.c linux-4.1.13/arch/mips/ath79/mach-wndr3700.c
  26177. --- linux-4.1.13.orig/arch/mips/ath79/mach-wndr3700.c 1970-01-01 01:00:00.000000000 +0100
  26178. +++ linux-4.1.13/arch/mips/ath79/mach-wndr3700.c 2015-09-13 20:04:35.072523889 +0200
  26179. @@ -0,0 +1,172 @@
  26180. +/*
  26181. + * Netgear WNDR3700 board support
  26182. + *
  26183. + * Copyright (C) 2009 Marco Porsch
  26184. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  26185. + *
  26186. + * This program is free software; you can redistribute it and/or modify it
  26187. + * under the terms of the GNU General Public License version 2 as published
  26188. + * by the Free Software Foundation.
  26189. + */
  26190. +
  26191. +#include <linux/platform_device.h>
  26192. +#include <linux/mtd/mtd.h>
  26193. +#include <linux/mtd/partitions.h>
  26194. +#include <linux/delay.h>
  26195. +#include <linux/rtl8366.h>
  26196. +
  26197. +#include <asm/mach-ath79/ath79.h>
  26198. +
  26199. +#include "dev-ap9x-pci.h"
  26200. +#include "dev-eth.h"
  26201. +#include "dev-gpio-buttons.h"
  26202. +#include "dev-leds-gpio.h"
  26203. +#include "dev-m25p80.h"
  26204. +#include "dev-usb.h"
  26205. +#include "machtypes.h"
  26206. +
  26207. +#define WNDR3700_GPIO_LED_WPS_ORANGE 0
  26208. +#define WNDR3700_GPIO_LED_POWER_ORANGE 1
  26209. +#define WNDR3700_GPIO_LED_POWER_GREEN 2
  26210. +#define WNDR3700_GPIO_LED_WPS_GREEN 4
  26211. +#define WNDR3700_GPIO_LED_WAN_GREEN 6
  26212. +
  26213. +#define WNDR3700_GPIO_BTN_WPS 3
  26214. +#define WNDR3700_GPIO_BTN_RESET 8
  26215. +#define WNDR3700_GPIO_BTN_WIFI 11
  26216. +
  26217. +#define WNDR3700_GPIO_RTL8366_SDA 5
  26218. +#define WNDR3700_GPIO_RTL8366_SCK 7
  26219. +
  26220. +#define WNDR3700_KEYS_POLL_INTERVAL 20 /* msecs */
  26221. +#define WNDR3700_KEYS_DEBOUNCE_INTERVAL (3 * WNDR3700_KEYS_POLL_INTERVAL)
  26222. +
  26223. +#define WNDR3700_ETH0_MAC_OFFSET 0
  26224. +#define WNDR3700_ETH1_MAC_OFFSET 0x6
  26225. +
  26226. +#define WNDR3700_WMAC0_MAC_OFFSET 0
  26227. +#define WNDR3700_WMAC1_MAC_OFFSET 0xc
  26228. +#define WNDR3700_CALDATA0_OFFSET 0x1000
  26229. +#define WNDR3700_CALDATA1_OFFSET 0x5000
  26230. +
  26231. +static struct gpio_led wndr3700_leds_gpio[] __initdata = {
  26232. + {
  26233. + .name = "netgear:green:power",
  26234. + .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
  26235. + .active_low = 1,
  26236. + }, {
  26237. + .name = "netgear:orange:power",
  26238. + .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
  26239. + .active_low = 1,
  26240. + }, {
  26241. + .name = "netgear:green:wps",
  26242. + .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
  26243. + .active_low = 1,
  26244. + }, {
  26245. + .name = "netgear:orange:wps",
  26246. + .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
  26247. + .active_low = 1,
  26248. + }, {
  26249. + .name = "netgear:green:wan",
  26250. + .gpio = WNDR3700_GPIO_LED_WAN_GREEN,
  26251. + .active_low = 1,
  26252. + }
  26253. +};
  26254. +
  26255. +static struct gpio_keys_button wndr3700_gpio_keys[] __initdata = {
  26256. + {
  26257. + .desc = "reset",
  26258. + .type = EV_KEY,
  26259. + .code = KEY_RESTART,
  26260. + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  26261. + .gpio = WNDR3700_GPIO_BTN_RESET,
  26262. + .active_low = 1,
  26263. + }, {
  26264. + .desc = "wps",
  26265. + .type = EV_KEY,
  26266. + .code = KEY_WPS_BUTTON,
  26267. + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  26268. + .gpio = WNDR3700_GPIO_BTN_WPS,
  26269. + .active_low = 1,
  26270. + }, {
  26271. + .desc = "wifi",
  26272. + .type = EV_KEY,
  26273. + .code = BTN_2,
  26274. + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  26275. + .gpio = WNDR3700_GPIO_BTN_WIFI,
  26276. + .active_low = 1,
  26277. + }
  26278. +};
  26279. +
  26280. +static struct rtl8366_platform_data wndr3700_rtl8366s_data = {
  26281. + .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
  26282. + .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
  26283. +};
  26284. +
  26285. +static struct platform_device wndr3700_rtl8366s_device = {
  26286. + .name = RTL8366S_DRIVER_NAME,
  26287. + .id = -1,
  26288. + .dev = {
  26289. + .platform_data = &wndr3700_rtl8366s_data,
  26290. + }
  26291. +};
  26292. +
  26293. +static void __init wndr3700_setup(void)
  26294. +{
  26295. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  26296. +
  26297. + /*
  26298. + * The eth0 and wmac0 interfaces share the same MAC address which
  26299. + * can lead to problems if operated unbridged. Set the locally
  26300. + * administered bit on the eth0 MAC to make it unique.
  26301. + */
  26302. + ath79_init_local_mac(ath79_eth0_data.mac_addr,
  26303. + art + WNDR3700_ETH0_MAC_OFFSET);
  26304. + ath79_eth0_pll_data.pll_1000 = 0x11110000;
  26305. + ath79_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  26306. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  26307. + ath79_eth0_data.speed = SPEED_1000;
  26308. + ath79_eth0_data.duplex = DUPLEX_FULL;
  26309. +
  26310. + ath79_init_mac(ath79_eth1_data.mac_addr,
  26311. + art + WNDR3700_ETH1_MAC_OFFSET, 0);
  26312. + ath79_eth1_pll_data.pll_1000 = 0x11110000;
  26313. + ath79_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  26314. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  26315. + ath79_eth1_data.phy_mask = 0x10;
  26316. +
  26317. + ath79_register_eth(0);
  26318. + ath79_register_eth(1);
  26319. +
  26320. + ath79_register_usb();
  26321. +
  26322. + ath79_register_m25p80(NULL);
  26323. +
  26324. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
  26325. + wndr3700_leds_gpio);
  26326. +
  26327. + ath79_register_gpio_keys_polled(-1, WNDR3700_KEYS_POLL_INTERVAL,
  26328. + ARRAY_SIZE(wndr3700_gpio_keys),
  26329. + wndr3700_gpio_keys);
  26330. +
  26331. + platform_device_register(&wndr3700_rtl8366s_device);
  26332. + platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
  26333. +
  26334. + ap9x_pci_setup_wmac_led_pin(0, 5);
  26335. + ap9x_pci_setup_wmac_led_pin(1, 5);
  26336. +
  26337. + /* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
  26338. + ap9x_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));
  26339. +
  26340. + /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
  26341. + ap9x_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
  26342. +
  26343. + ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
  26344. + art + WNDR3700_WMAC0_MAC_OFFSET,
  26345. + art + WNDR3700_CALDATA1_OFFSET,
  26346. + art + WNDR3700_WMAC1_MAC_OFFSET);
  26347. +}
  26348. +
  26349. +MIPS_MACHINE(ATH79_MACH_WNDR3700, "WNDR3700",
  26350. + "NETGEAR WNDR3700/WNDR3800/WNDRMAC",
  26351. + wndr3700_setup);
  26352. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wndr4300.c linux-4.1.13/arch/mips/ath79/mach-wndr4300.c
  26353. --- linux-4.1.13.orig/arch/mips/ath79/mach-wndr4300.c 1970-01-01 01:00:00.000000000 +0100
  26354. +++ linux-4.1.13/arch/mips/ath79/mach-wndr4300.c 2015-09-13 20:04:35.072523889 +0200
  26355. @@ -0,0 +1,210 @@
  26356. +/*
  26357. + * NETGEAR WNDR3700v4/WNDR4300 board support
  26358. + *
  26359. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  26360. + * Copyright (C) 2014 Ralph Perlich <rpsoft@arcor.de>
  26361. + *
  26362. + * This program is free software; you can redistribute it and/or modify it
  26363. + * under the terms of the GNU General Public License version 2 as published
  26364. + * by the Free Software Foundation.
  26365. + */
  26366. +
  26367. +#include <linux/pci.h>
  26368. +#include <linux/phy.h>
  26369. +#include <linux/gpio.h>
  26370. +#include <linux/platform_device.h>
  26371. +#include <linux/ath9k_platform.h>
  26372. +#include <linux/ar8216_platform.h>
  26373. +#include <linux/mtd/mtd.h>
  26374. +#include <linux/mtd/nand.h>
  26375. +#include <linux/platform/ar934x_nfc.h>
  26376. +
  26377. +#include <asm/mach-ath79/ar71xx_regs.h>
  26378. +
  26379. +#include "common.h"
  26380. +#include "dev-ap9x-pci.h"
  26381. +#include "dev-eth.h"
  26382. +#include "dev-gpio-buttons.h"
  26383. +#include "dev-leds-gpio.h"
  26384. +#include "dev-nfc.h"
  26385. +#include "dev-usb.h"
  26386. +#include "dev-wmac.h"
  26387. +#include "machtypes.h"
  26388. +
  26389. +/* AR9344 GPIOs */
  26390. +#define WNDR4300_GPIO_LED_POWER_GREEN 0
  26391. +#define WNDR4300_GPIO_LED_POWER_AMBER 2
  26392. +#define WNDR4300_GPIO_LED_USB 13
  26393. +#define WNDR4300_GPIO_LED_WAN_GREEN 1
  26394. +#define WNDR4300_GPIO_LED_WAN_AMBER 3
  26395. +#define WNDR4300_GPIO_LED_WLAN2G 11
  26396. +#define WNDR4300_GPIO_LED_WLAN5G 14
  26397. +#define WNDR4300_GPIO_LED_WPS_GREEN 16
  26398. +#define WNDR4300_GPIO_LED_WPS_AMBER 17
  26399. +
  26400. +#define WNDR4300_GPIO_BTN_RESET 21
  26401. +#define WNDR4300_GPIO_BTN_WIRELESS 15
  26402. +#define WNDR4300_GPIO_BTN_WPS 12
  26403. +
  26404. +/* AR9580 GPIOs */
  26405. +#define WNDR4300_GPIO_USB_5V 0
  26406. +
  26407. +#define WNDR4300_KEYS_POLL_INTERVAL 20 /* msecs */
  26408. +#define WNDR4300_KEYS_DEBOUNCE_INTERVAL (3 * WNDR4300_KEYS_POLL_INTERVAL)
  26409. +
  26410. +static struct gpio_led wndr4300_leds_gpio[] __initdata = {
  26411. + {
  26412. + .name = "netgear:green:power",
  26413. + .gpio = WNDR4300_GPIO_LED_POWER_GREEN,
  26414. + .active_low = 1,
  26415. + },
  26416. + {
  26417. + .name = "netgear:amber:power",
  26418. + .gpio = WNDR4300_GPIO_LED_POWER_AMBER,
  26419. + .active_low = 1,
  26420. + },
  26421. + {
  26422. + .name = "netgear:green:wan",
  26423. + .gpio = WNDR4300_GPIO_LED_WAN_GREEN,
  26424. + .active_low = 1,
  26425. + },
  26426. + {
  26427. + .name = "netgear:amber:wan",
  26428. + .gpio = WNDR4300_GPIO_LED_WAN_AMBER,
  26429. + .active_low = 1,
  26430. + },
  26431. + {
  26432. + .name = "netgear:green:usb",
  26433. + .gpio = WNDR4300_GPIO_LED_USB,
  26434. + .active_low = 1,
  26435. + },
  26436. + {
  26437. + .name = "netgear:green:wps",
  26438. + .gpio = WNDR4300_GPIO_LED_WPS_GREEN,
  26439. + .active_low = 1,
  26440. + },
  26441. + {
  26442. + .name = "netgear:amber:wps",
  26443. + .gpio = WNDR4300_GPIO_LED_WPS_AMBER,
  26444. + .active_low = 1,
  26445. + },
  26446. + {
  26447. + .name = "netgear:green:wlan2g",
  26448. + .gpio = WNDR4300_GPIO_LED_WLAN2G,
  26449. + .active_low = 1,
  26450. + },
  26451. + {
  26452. + .name = "netgear:blue:wlan5g",
  26453. + .gpio = WNDR4300_GPIO_LED_WLAN5G,
  26454. + .active_low = 1,
  26455. + },
  26456. +};
  26457. +
  26458. +static struct gpio_keys_button wndr4300_gpio_keys[] __initdata = {
  26459. + {
  26460. + .desc = "Reset button",
  26461. + .type = EV_KEY,
  26462. + .code = KEY_RESTART,
  26463. + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
  26464. + .gpio = WNDR4300_GPIO_BTN_RESET,
  26465. + .active_low = 1,
  26466. + },
  26467. + {
  26468. + .desc = "WPS button",
  26469. + .type = EV_KEY,
  26470. + .code = KEY_WPS_BUTTON,
  26471. + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
  26472. + .gpio = WNDR4300_GPIO_BTN_WPS,
  26473. + .active_low = 1,
  26474. + },
  26475. + {
  26476. + .desc = "Wireless button",
  26477. + .type = EV_KEY,
  26478. + .code = KEY_RFKILL,
  26479. + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
  26480. + .gpio = WNDR4300_GPIO_BTN_WIRELESS,
  26481. + .active_low = 1,
  26482. + },
  26483. +};
  26484. +
  26485. +static struct ar8327_pad_cfg wndr4300_ar8327_pad0_cfg = {
  26486. + .mode = AR8327_PAD_MAC_RGMII,
  26487. + .txclk_delay_en = true,
  26488. + .rxclk_delay_en = true,
  26489. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  26490. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  26491. +};
  26492. +
  26493. +static struct ar8327_led_cfg wndr4300_ar8327_led_cfg = {
  26494. + .led_ctrl0 = 0xc737c737,
  26495. + .led_ctrl1 = 0x00000000,
  26496. + .led_ctrl2 = 0x00000000,
  26497. + .led_ctrl3 = 0x0030c300,
  26498. + .open_drain = false,
  26499. +};
  26500. +
  26501. +static struct ar8327_platform_data wndr4300_ar8327_data = {
  26502. + .pad0_cfg = &wndr4300_ar8327_pad0_cfg,
  26503. + .port0_cfg = {
  26504. + .force_link = 1,
  26505. + .speed = AR8327_PORT_SPEED_1000,
  26506. + .duplex = 1,
  26507. + .txpause = 1,
  26508. + .rxpause = 1,
  26509. + },
  26510. + .led_cfg = &wndr4300_ar8327_led_cfg,
  26511. +};
  26512. +
  26513. +static struct mdio_board_info wndr4300_mdio0_info[] = {
  26514. + {
  26515. + .bus_id = "ag71xx-mdio.0",
  26516. + .phy_addr = 0,
  26517. + .platform_data = &wndr4300_ar8327_data,
  26518. + },
  26519. +};
  26520. +
  26521. +static void __init wndr4300_setup(void)
  26522. +{
  26523. + int i;
  26524. +
  26525. + for (i = 0; i < ARRAY_SIZE(wndr4300_leds_gpio); i++)
  26526. + ath79_gpio_output_select(wndr4300_leds_gpio[i].gpio,
  26527. + AR934X_GPIO_OUT_GPIO);
  26528. +
  26529. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr4300_leds_gpio),
  26530. + wndr4300_leds_gpio);
  26531. + ath79_register_gpio_keys_polled(-1, WNDR4300_KEYS_POLL_INTERVAL,
  26532. + ARRAY_SIZE(wndr4300_gpio_keys),
  26533. + wndr4300_gpio_keys);
  26534. +
  26535. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  26536. +
  26537. + mdiobus_register_board_info(wndr4300_mdio0_info,
  26538. + ARRAY_SIZE(wndr4300_mdio0_info));
  26539. +
  26540. + ath79_register_mdio(0, 0x0);
  26541. +
  26542. + /* GMAC0 is connected to an AR8327N switch */
  26543. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  26544. + ath79_eth0_data.phy_mask = BIT(0);
  26545. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  26546. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  26547. + ath79_register_eth(0);
  26548. +
  26549. + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
  26550. + ath79_register_nfc();
  26551. + ath79_register_usb();
  26552. +
  26553. + ath79_register_wmac_simple();
  26554. +
  26555. + /* enable power for the USB port */
  26556. + ap9x_pci_setup_wmac_gpio(0, BIT(WNDR4300_GPIO_USB_5V),
  26557. + BIT(WNDR4300_GPIO_USB_5V));
  26558. +
  26559. + ap91_pci_init_simple();
  26560. +}
  26561. +
  26562. +MIPS_MACHINE(ATH79_MACH_WNDR3700_V4, "WNDR3700_V4", "NETGEAR WNDR3700v4",
  26563. + wndr4300_setup);
  26564. +MIPS_MACHINE(ATH79_MACH_WNDR4300, "WNDR4300", "NETGEAR WNDR4300",
  26565. + wndr4300_setup);
  26566. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000.c linux-4.1.13/arch/mips/ath79/mach-wnr2000.c
  26567. --- linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000.c 1970-01-01 01:00:00.000000000 +0100
  26568. +++ linux-4.1.13/arch/mips/ath79/mach-wnr2000.c 2015-09-13 20:04:35.072523889 +0200
  26569. @@ -0,0 +1,145 @@
  26570. +/*
  26571. + * NETGEAR WNR2000 board support
  26572. + *
  26573. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  26574. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  26575. + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  26576. + *
  26577. + * This program is free software; you can redistribute it and/or modify it
  26578. + * under the terms of the GNU General Public License version 2 as published
  26579. + * by the Free Software Foundation.
  26580. + */
  26581. +
  26582. +#include <linux/mtd/mtd.h>
  26583. +#include <linux/mtd/partitions.h>
  26584. +
  26585. +#include <asm/mach-ath79/ath79.h>
  26586. +
  26587. +#include "dev-eth.h"
  26588. +#include "dev-gpio-buttons.h"
  26589. +#include "dev-leds-gpio.h"
  26590. +#include "dev-m25p80.h"
  26591. +#include "dev-wmac.h"
  26592. +#include "machtypes.h"
  26593. +
  26594. +#define WNR2000_GPIO_LED_PWR_GREEN 14
  26595. +#define WNR2000_GPIO_LED_PWR_AMBER 7
  26596. +#define WNR2000_GPIO_LED_WPS 4
  26597. +#define WNR2000_GPIO_LED_WLAN 6
  26598. +#define WNR2000_GPIO_BTN_RESET 21
  26599. +#define WNR2000_GPIO_BTN_WPS 8
  26600. +
  26601. +#define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */
  26602. +#define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL)
  26603. +
  26604. +static struct mtd_partition wnr2000_partitions[] = {
  26605. + {
  26606. + .name = "u-boot",
  26607. + .offset = 0,
  26608. + .size = 0x040000,
  26609. + .mask_flags = MTD_WRITEABLE,
  26610. + }, {
  26611. + .name = "u-boot-env",
  26612. + .offset = 0x040000,
  26613. + .size = 0x010000,
  26614. + }, {
  26615. + .name = "rootfs",
  26616. + .offset = 0x050000,
  26617. + .size = 0x240000,
  26618. + }, {
  26619. + .name = "user-config",
  26620. + .offset = 0x290000,
  26621. + .size = 0x010000,
  26622. + }, {
  26623. + .name = "uImage",
  26624. + .offset = 0x2a0000,
  26625. + .size = 0x120000,
  26626. + }, {
  26627. + .name = "language_table",
  26628. + .offset = 0x3c0000,
  26629. + .size = 0x020000,
  26630. + }, {
  26631. + .name = "rootfs_checksum",
  26632. + .offset = 0x3e0000,
  26633. + .size = 0x010000,
  26634. + }, {
  26635. + .name = "art",
  26636. + .offset = 0x3f0000,
  26637. + .size = 0x010000,
  26638. + .mask_flags = MTD_WRITEABLE,
  26639. + }
  26640. +};
  26641. +
  26642. +static struct flash_platform_data wnr2000_flash_data = {
  26643. + .parts = wnr2000_partitions,
  26644. + .nr_parts = ARRAY_SIZE(wnr2000_partitions),
  26645. +};
  26646. +
  26647. +static struct gpio_led wnr2000_leds_gpio[] __initdata = {
  26648. + {
  26649. + .name = "netgear:green:power",
  26650. + .gpio = WNR2000_GPIO_LED_PWR_GREEN,
  26651. + .active_low = 1,
  26652. + }, {
  26653. + .name = "netgear:amber:power",
  26654. + .gpio = WNR2000_GPIO_LED_PWR_AMBER,
  26655. + .active_low = 1,
  26656. + }, {
  26657. + .name = "netgear:green:wps",
  26658. + .gpio = WNR2000_GPIO_LED_WPS,
  26659. + .active_low = 1,
  26660. + }, {
  26661. + .name = "netgear:blue:wlan",
  26662. + .gpio = WNR2000_GPIO_LED_WLAN,
  26663. + .active_low = 1,
  26664. + }
  26665. +};
  26666. +
  26667. +static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = {
  26668. + {
  26669. + .desc = "reset",
  26670. + .type = EV_KEY,
  26671. + .code = KEY_RESTART,
  26672. + .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
  26673. + .gpio = WNR2000_GPIO_BTN_RESET,
  26674. + }, {
  26675. + .desc = "wps",
  26676. + .type = EV_KEY,
  26677. + .code = KEY_WPS_BUTTON,
  26678. + .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
  26679. + .gpio = WNR2000_GPIO_BTN_WPS,
  26680. + }
  26681. +};
  26682. +
  26683. +static void __init wnr2000_setup(void)
  26684. +{
  26685. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  26686. +
  26687. + ath79_register_mdio(0, 0x0);
  26688. +
  26689. + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  26690. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  26691. + ath79_eth0_data.speed = SPEED_100;
  26692. + ath79_eth0_data.duplex = DUPLEX_FULL;
  26693. + ath79_eth0_data.has_ar8216 = 1;
  26694. +
  26695. + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  26696. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  26697. + ath79_eth1_data.phy_mask = 0x10;
  26698. +
  26699. + ath79_register_eth(0);
  26700. + ath79_register_eth(1);
  26701. +
  26702. + ath79_register_m25p80(&wnr2000_flash_data);
  26703. +
  26704. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
  26705. + wnr2000_leds_gpio);
  26706. +
  26707. + ath79_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL,
  26708. + ARRAY_SIZE(wnr2000_gpio_keys),
  26709. + wnr2000_gpio_keys);
  26710. +
  26711. + ath79_register_wmac(eeprom, NULL);
  26712. +}
  26713. +
  26714. +MIPS_MACHINE(ATH79_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);
  26715. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000-v3.c linux-4.1.13/arch/mips/ath79/mach-wnr2000-v3.c
  26716. --- linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000-v3.c 1970-01-01 01:00:00.000000000 +0100
  26717. +++ linux-4.1.13/arch/mips/ath79/mach-wnr2000-v3.c 2015-09-13 20:04:35.072523889 +0200
  26718. @@ -0,0 +1,140 @@
  26719. +/*
  26720. + * NETGEAR WNR2000v3/WNR612v2/WNR1000v2 board support
  26721. + *
  26722. + * Copytight (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
  26723. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  26724. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  26725. + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  26726. + *
  26727. + * This program is free software; you can redistribute it and/or modify it
  26728. + * under the terms of the GNU General Public License version 2 as published
  26729. + * by the Free Software Foundation.
  26730. + */
  26731. +
  26732. +#include <linux/mtd/mtd.h>
  26733. +#include <linux/mtd/partitions.h>
  26734. +
  26735. +#include <asm/mach-ath79/ath79.h>
  26736. +
  26737. +#include "dev-ap9x-pci.h"
  26738. +#include "dev-eth.h"
  26739. +#include "dev-gpio-buttons.h"
  26740. +#include "dev-leds-gpio.h"
  26741. +#include "dev-m25p80.h"
  26742. +#include "machtypes.h"
  26743. +
  26744. +#define WNR2000V3_GPIO_LED_WAN_GREEN 0
  26745. +#define WNR2000V3_GPIO_LED_LAN1_AMBER 1
  26746. +#define WNR2000V3_GPIO_LED_LAN4_AMBER 12
  26747. +#define WNR2000V3_GPIO_LED_PWR_GREEN 14
  26748. +#define WNR2000V3_GPIO_BTN_WPS 11
  26749. +
  26750. +#define WNR612V2_GPIO_LED_PWR_GREEN 11
  26751. +
  26752. +#define WNR1000V2_GPIO_LED_PWR_AMBER 1
  26753. +#define WNR1000V2_GPIO_LED_PWR_GREEN 11
  26754. +
  26755. +#define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
  26756. +#define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
  26757. +
  26758. +#define WNR2000V3_MAC0_OFFSET 0
  26759. +#define WNR2000V3_MAC1_OFFSET 6
  26760. +#define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
  26761. +
  26762. +static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
  26763. + {
  26764. + .name = "wnr2000v3:green:power",
  26765. + .gpio = WNR2000V3_GPIO_LED_PWR_GREEN,
  26766. + .active_low = 1,
  26767. + }, {
  26768. + .name = "wnr2000v3:green:wan",
  26769. + .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
  26770. + .active_low = 1,
  26771. + }
  26772. +};
  26773. +
  26774. +static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
  26775. + {
  26776. + .name = "netgear:green:power",
  26777. + .gpio = WNR612V2_GPIO_LED_PWR_GREEN,
  26778. + .active_low = 1,
  26779. + }
  26780. +};
  26781. +
  26782. +static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
  26783. + {
  26784. + .name = "netgear:green:power",
  26785. + .gpio = WNR1000V2_GPIO_LED_PWR_GREEN,
  26786. + .active_low = 1,
  26787. + }, {
  26788. + .name = "netgear:amber:power",
  26789. + .gpio = WNR1000V2_GPIO_LED_PWR_AMBER,
  26790. + .active_low = 1,
  26791. + }
  26792. +};
  26793. +
  26794. +static struct gpio_keys_button wnr2000v3_gpio_keys[] __initdata = {
  26795. + {
  26796. + .desc = "wps",
  26797. + .type = EV_KEY,
  26798. + .code = KEY_WPS_BUTTON,
  26799. + .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  26800. + .gpio = WNR2000V3_GPIO_BTN_WPS,
  26801. + }
  26802. +};
  26803. +
  26804. +static void __init wnr_common_setup(void)
  26805. +{
  26806. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  26807. +
  26808. + ath79_register_mdio(0, 0x0);
  26809. +
  26810. + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
  26811. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  26812. + ath79_eth0_data.speed = SPEED_100;
  26813. + ath79_eth0_data.duplex = DUPLEX_FULL;
  26814. +
  26815. + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
  26816. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  26817. + ath79_eth1_data.phy_mask = 0x10;
  26818. +
  26819. + ath79_register_eth(0);
  26820. + ath79_register_eth(1);
  26821. +
  26822. + ath79_register_m25p80(NULL);
  26823. + ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL);
  26824. +}
  26825. +
  26826. +static void __init wnr2000v3_setup(void)
  26827. +{
  26828. + wnr_common_setup();
  26829. +
  26830. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
  26831. + wnr2000v3_leds_gpio);
  26832. +
  26833. + ath79_register_gpio_keys_polled(-1, WNR2000V3_KEYS_POLL_INTERVAL,
  26834. + ARRAY_SIZE(wnr2000v3_gpio_keys),
  26835. + wnr2000v3_gpio_keys);
  26836. +}
  26837. +
  26838. +MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
  26839. +
  26840. +static void __init wnr612v2_setup(void)
  26841. +{
  26842. + wnr_common_setup();
  26843. +
  26844. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
  26845. + wnr612v2_leds_gpio);
  26846. +}
  26847. +
  26848. +MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
  26849. +
  26850. +static void __init wnr1000v2_setup(void)
  26851. +{
  26852. + wnr_common_setup();
  26853. +
  26854. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
  26855. + wnr1000v2_leds_gpio);
  26856. +}
  26857. +
  26858. +MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
  26859. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000-v4.c linux-4.1.13/arch/mips/ath79/mach-wnr2000-v4.c
  26860. --- linux-4.1.13.orig/arch/mips/ath79/mach-wnr2000-v4.c 1970-01-01 01:00:00.000000000 +0100
  26861. +++ linux-4.1.13/arch/mips/ath79/mach-wnr2000-v4.c 2015-09-13 20:04:35.072523889 +0200
  26862. @@ -0,0 +1,214 @@
  26863. +/*
  26864. + * NETGEAR WNR2000v4 board support
  26865. + *
  26866. + * Copyright (C) 2015 Michael Bazzinotti <mbazzinotti@gmail.com>
  26867. + * Copyright (C) 2014 Michaël Burtin <mburtin@gmail.com>
  26868. + * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
  26869. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  26870. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  26871. + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  26872. + *
  26873. + * This program is free software; you can redistribute it and/or modify it
  26874. + * under the terms of the GNU General Public License version 2 as published
  26875. + * by the Free Software Foundation.
  26876. + */
  26877. +
  26878. +#include <linux/mtd/mtd.h>
  26879. +#include <linux/mtd/partitions.h>
  26880. +#include <linux/platform_device.h>
  26881. +
  26882. +#include <asm/mach-ath79/ath79.h>
  26883. +#include <asm/mach-ath79/ar71xx_regs.h>
  26884. +
  26885. +#include "common.h"
  26886. +#include "dev-eth.h"
  26887. +#include "dev-gpio-buttons.h"
  26888. +#include "dev-leds-gpio.h"
  26889. +#include "dev-m25p80.h"
  26890. +#include "dev-usb.h"
  26891. +#include "dev-wmac.h"
  26892. +#include "machtypes.h"
  26893. +
  26894. +/* AR9341 GPIOs */
  26895. +#define WNR2000V4_GPIO_LED_PWR_GREEN 0
  26896. +#define WNR2000V4_GPIO_LED_PWR_AMBER 1
  26897. +#define WNR2000V4_GPIO_LED_WPS 2
  26898. +#define WNR2000V4_GPIO_LED_WLAN 12
  26899. +#define WNR2000V4_GPIO_LED_LAN1_GREEN 13
  26900. +#define WNR2000V4_GPIO_LED_LAN2_GREEN 14
  26901. +#define WNR2000V4_GPIO_LED_LAN3_GREEN 15
  26902. +#define WNR2000V4_GPIO_LED_LAN4_GREEN 16
  26903. +#define WNR2000V4_GPIO_LED_LAN1_AMBER 18
  26904. +#define WNR2000V4_GPIO_LED_LAN2_AMBER 19
  26905. +#define WNR2000V4_GPIO_LED_LAN3_AMBER 20
  26906. +#define WNR2000V4_GPIO_LED_LAN4_AMBER 21
  26907. +#define WNR2000V4_GPIO_LED_WAN_GREEN 17
  26908. +#define WNR2000V4_GPIO_LED_WAN_AMBER 22
  26909. +/* Buttons */
  26910. +#define WNR2000V4_GPIO_BTN_WPS 3
  26911. +#define WNR2000V4_GPIO_BTN_RESET 4
  26912. +#define WNR2000V4_GPIO_BTN_WLAN 11
  26913. +#define WNR2000V4_KEYS_POLL_INTERVAL 20 /* msecs */
  26914. +#define WNR2000V4_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V4_KEYS_POLL_INTERVAL)
  26915. +
  26916. +
  26917. +/* ART offsets */
  26918. +#define WNR2000V4_MAC0_OFFSET 0 /* WAN/WLAN0 MAC */
  26919. +#define WNR2000V4_MAC1_OFFSET 6 /* Eth-switch0 MAC */
  26920. +
  26921. +static struct gpio_led wnr2000v4_leds_gpio[] __initdata = {
  26922. + {
  26923. + .name = "netgear:green:power",
  26924. + .gpio = WNR2000V4_GPIO_LED_PWR_GREEN,
  26925. + .active_low = 1,
  26926. + .default_trigger = "default-on",
  26927. + },
  26928. + {
  26929. + .name = "netgear:amber:status",
  26930. + .gpio = WNR2000V4_GPIO_LED_PWR_AMBER,
  26931. + .active_low = 1,
  26932. + },
  26933. + {
  26934. + .name = "netgear:green:wan",
  26935. + .gpio = WNR2000V4_GPIO_LED_WAN_GREEN,
  26936. + .active_low = 1,
  26937. + },
  26938. + {
  26939. + .name = "netgear:amber:wan",
  26940. + .gpio = WNR2000V4_GPIO_LED_WAN_AMBER,
  26941. + .active_low = 1,
  26942. + },
  26943. + {
  26944. + .name = "netgear:blue:wlan",
  26945. + .gpio = WNR2000V4_GPIO_LED_WLAN,
  26946. + .active_low = 1,
  26947. + },
  26948. + /* LAN LEDS */
  26949. + {
  26950. + .name = "netgear:green:lan1",
  26951. + .gpio = WNR2000V4_GPIO_LED_LAN1_GREEN,
  26952. + .active_low = 1,
  26953. + },
  26954. + {
  26955. + .name = "netgear:green:lan2",
  26956. + .gpio = WNR2000V4_GPIO_LED_LAN2_GREEN,
  26957. + .active_low = 1,
  26958. + },
  26959. + {
  26960. + .name = "netgear:green:lan3",
  26961. + .gpio = WNR2000V4_GPIO_LED_LAN3_GREEN,
  26962. + .active_low = 1,
  26963. + },
  26964. + {
  26965. + .name = "netgear:green:lan4",
  26966. + .gpio = WNR2000V4_GPIO_LED_LAN4_GREEN,
  26967. + .active_low = 1,
  26968. + },
  26969. + {
  26970. + .name = "netgear:amber:lan1",
  26971. + .gpio = WNR2000V4_GPIO_LED_LAN1_AMBER,
  26972. + .active_low = 1,
  26973. + },
  26974. + {
  26975. + .name = "netgear:amber:lan2",
  26976. + .gpio = WNR2000V4_GPIO_LED_LAN2_AMBER,
  26977. + .active_low = 1,
  26978. + },
  26979. + {
  26980. + .name = "netgear:amber:lan3",
  26981. + .gpio = WNR2000V4_GPIO_LED_LAN3_AMBER,
  26982. + .active_low = 1,
  26983. + },
  26984. + {
  26985. + .name = "netgear:amber:lan4",
  26986. + .gpio = WNR2000V4_GPIO_LED_LAN4_AMBER,
  26987. + .active_low = 1,
  26988. + },
  26989. + {
  26990. + .name = "netgear:green:wps",
  26991. + .gpio = WNR2000V4_GPIO_LED_WPS,
  26992. + .active_low = 1,
  26993. + },
  26994. +};
  26995. +
  26996. +static struct gpio_keys_button wnr2000v4_gpio_keys[] __initdata = {
  26997. + {
  26998. + .desc = "WPS button",
  26999. + .type = EV_KEY,
  27000. + .code = KEY_WPS_BUTTON,
  27001. + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
  27002. + .gpio = WNR2000V4_GPIO_BTN_WPS,
  27003. + .active_low = 1,
  27004. + },
  27005. + {
  27006. + .desc = "Reset button",
  27007. + .type = EV_KEY,
  27008. + .code = KEY_RESTART,
  27009. + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
  27010. + .gpio = WNR2000V4_GPIO_BTN_RESET,
  27011. + .active_low = 1,
  27012. + },
  27013. + {
  27014. + .desc = "WLAN button",
  27015. + .type = EV_KEY,
  27016. + .code = KEY_RFKILL,
  27017. + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
  27018. + .gpio = WNR2000V4_GPIO_BTN_WLAN,
  27019. + .active_low = 1,
  27020. + },
  27021. +};
  27022. +
  27023. +static void __init wnr_common_setup(void)
  27024. +{
  27025. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  27026. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  27027. +
  27028. + ath79_register_mdio(1, 0x0);
  27029. +
  27030. + ath79_register_usb();
  27031. +
  27032. + ath79_register_m25p80(NULL);
  27033. +
  27034. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  27035. +
  27036. + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V4_MAC0_OFFSET, 0);
  27037. + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V4_MAC1_OFFSET, 0);
  27038. +
  27039. + /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
  27040. + ath79_switch_data.phy4_mii_en = 1;
  27041. + ath79_switch_data.phy_poll_mask = BIT(4);
  27042. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  27043. + ath79_eth0_data.phy_mask = BIT(4);
  27044. + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  27045. + ath79_register_eth(0);
  27046. +
  27047. + /* GMAC1 is connected to the internal switch, GE1 */
  27048. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  27049. + ath79_register_eth(1);
  27050. +
  27051. + ath79_register_wmac(ee, art);
  27052. +}
  27053. +
  27054. +static void __init wnr2000v4_setup(void)
  27055. +{
  27056. + int i;
  27057. +
  27058. + wnr_common_setup();
  27059. +
  27060. + /* Ensure no LED has an internal MUX signal, otherwise
  27061. + control of LED could be lost... This is especially important
  27062. + for most green LEDS (Eth,WAN).. who arrive in this function with
  27063. + MUX signals set. */
  27064. + for (i = 0; i < ARRAY_SIZE(wnr2000v4_leds_gpio); i++)
  27065. + ath79_gpio_output_select(wnr2000v4_leds_gpio[i].gpio,
  27066. + AR934X_GPIO_OUT_GPIO);
  27067. +
  27068. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio),
  27069. + wnr2000v4_leds_gpio);
  27070. +
  27071. + ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL,
  27072. + ARRAY_SIZE(wnr2000v4_gpio_keys),
  27073. + wnr2000v4_gpio_keys);
  27074. +}
  27075. +
  27076. +MIPS_MACHINE(ATH79_MACH_WNR2000_V4, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup);
  27077. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wnr2200.c linux-4.1.13/arch/mips/ath79/mach-wnr2200.c
  27078. --- linux-4.1.13.orig/arch/mips/ath79/mach-wnr2200.c 1970-01-01 01:00:00.000000000 +0100
  27079. +++ linux-4.1.13/arch/mips/ath79/mach-wnr2200.c 2015-11-21 17:22:11.759223549 +0100
  27080. @@ -0,0 +1,137 @@
  27081. +/*
  27082. + * NETGEAR WNR2200 board support
  27083. + *
  27084. + * Copyright (C) 2013 Aidan Kissane <aidankissane at googlemail.com>
  27085. + *
  27086. + * This program is free software; you can redistribute it and/or modify it
  27087. + * under the terms of the GNU General Public License version 2 as published
  27088. + * by the Free Software Foundation.
  27089. + */
  27090. +
  27091. +#include <linux/gpio.h>
  27092. +
  27093. +#include <linux/mtd/mtd.h>
  27094. +#include <linux/mtd/partitions.h>
  27095. +
  27096. +#include <asm/mach-ath79/ath79.h>
  27097. +
  27098. +#include "dev-ap9x-pci.h"
  27099. +#include "dev-eth.h"
  27100. +#include "dev-gpio-buttons.h"
  27101. +#include "dev-leds-gpio.h"
  27102. +#include "dev-m25p80.h"
  27103. +#include "dev-usb.h"
  27104. +#include "machtypes.h"
  27105. +
  27106. +#define WNR2200_GPIO_LED_LAN2_AMBER 0
  27107. +#define WNR2200_GPIO_LED_LAN4_AMBER 1
  27108. +#define WNR2200_GPIO_LED_WPS 5
  27109. +#define WNR2200_GPIO_LED_WAN_GREEN 7
  27110. +#define WNR2200_GPIO_LED_USB 8
  27111. +#define WNR2200_GPIO_LED_LAN3_AMBER 11
  27112. +#define WNR2200_GPIO_LED_WAN_AMBER 12
  27113. +#define WNR2200_GPIO_LED_LAN1_GREEN 13
  27114. +#define WNR2200_GPIO_LED_LAN2_GREEN 14
  27115. +#define WNR2200_GPIO_LED_LAN3_GREEN 15
  27116. +#define WNR2200_GPIO_LED_LAN4_GREEN 16
  27117. +#define WNR2200_GPIO_LED_PWR_AMBER 21
  27118. +#define WNR2200_GPIO_LED_PWR_GREEN 22
  27119. +#define WNR2200_GPIO_USB_5V 4
  27120. +#define WNR2200_GPIO_USB_POWER 24
  27121. +
  27122. +#define WNR2200_KEYS_POLL_INTERVAL 20 /* msecs */
  27123. +#define WNR2200_KEYS_DEBOUNCE_INTERVAL (3 * WNR2200_KEYS_POLL_INTERVAL)
  27124. +
  27125. +#define WNR2200_MAC0_OFFSET 0
  27126. +#define WNR2200_MAC1_OFFSET 6
  27127. +#define WNR2200_PCIE_CALDATA_OFFSET 0x1000
  27128. +
  27129. +static struct gpio_led wnr2200_leds_gpio[] __initdata = {
  27130. + {
  27131. + .name = "netgear:amber:lan2",
  27132. + .gpio = WNR2200_GPIO_LED_LAN2_AMBER,
  27133. + .active_low = 1,
  27134. + }, {
  27135. + .name = "netgear:amber:lan4",
  27136. + .gpio = WNR2200_GPIO_LED_LAN4_AMBER,
  27137. + .active_low = 1,
  27138. + }, {
  27139. + .name = "netgear:green:wps",
  27140. + .gpio = WNR2200_GPIO_LED_WPS,
  27141. + .active_low = 1,
  27142. + }, {
  27143. + .name = "netgear:green:wan",
  27144. + .gpio = WNR2200_GPIO_LED_WAN_GREEN,
  27145. + .active_low = 1,
  27146. + }, {
  27147. + .name = "netgear:green:usb",
  27148. + .gpio = WNR2200_GPIO_LED_USB,
  27149. + .active_low = 1,
  27150. + }, {
  27151. + .name = "netgear:amber:lan3",
  27152. + .gpio = WNR2200_GPIO_LED_LAN3_AMBER,
  27153. + .active_low = 1,
  27154. + }, {
  27155. + .name = "netgear:amber:wan",
  27156. + .gpio = WNR2200_GPIO_LED_WAN_AMBER,
  27157. + .active_low = 1,
  27158. + }, {
  27159. + .name = "netgear:green:lan1",
  27160. + .gpio = WNR2200_GPIO_LED_LAN1_GREEN,
  27161. + .active_low = 1,
  27162. + }, {
  27163. + .name = "netgear:green:lan2",
  27164. + .gpio = WNR2200_GPIO_LED_LAN2_GREEN,
  27165. + .active_low = 1,
  27166. + }, {
  27167. + .name = "netgear:green:lan3",
  27168. + .gpio = WNR2200_GPIO_LED_LAN3_GREEN,
  27169. + .active_low = 1,
  27170. + }, {
  27171. + .name = "netgear:green:lan4",
  27172. + .gpio = WNR2200_GPIO_LED_LAN4_GREEN,
  27173. + .active_low = 1,
  27174. + }, {
  27175. + .name = "netgear:amber:power",
  27176. + .gpio = WNR2200_GPIO_LED_PWR_AMBER,
  27177. + .active_low = 1,
  27178. + }, {
  27179. + .name = "netgear:green:power",
  27180. + .gpio = WNR2200_GPIO_LED_PWR_GREEN,
  27181. + .active_low = 1,
  27182. + }
  27183. +};
  27184. +
  27185. +static void __init wnr2200_setup(void)
  27186. +{
  27187. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  27188. +
  27189. + ath79_register_mdio(0, 0x0);
  27190. +
  27191. + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2200_MAC0_OFFSET, 0);
  27192. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  27193. + ath79_eth0_data.speed = SPEED_100;
  27194. + ath79_eth0_data.duplex = DUPLEX_FULL;
  27195. +
  27196. + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2200_MAC1_OFFSET, 0);
  27197. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  27198. + ath79_eth1_data.phy_mask = 0x10;
  27199. +
  27200. + ath79_register_eth(0);
  27201. + ath79_register_eth(1);
  27202. +
  27203. + ath79_register_m25p80(NULL);
  27204. + ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET, NULL);
  27205. +
  27206. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
  27207. + wnr2200_leds_gpio);
  27208. +
  27209. + /* enable power for the USB port */
  27210. + ap9x_pci_setup_wmac_gpio(0,
  27211. + BIT(WNR2200_GPIO_USB_5V),
  27212. + BIT(WNR2200_GPIO_USB_5V));
  27213. +
  27214. + ath79_register_usb();
  27215. +}
  27216. +
  27217. +MIPS_MACHINE(ATH79_MACH_WNR2200, "WNR2200", "NETGEAR WNR2200", wnr2200_setup);
  27218. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wp543.c linux-4.1.13/arch/mips/ath79/mach-wp543.c
  27219. --- linux-4.1.13.orig/arch/mips/ath79/mach-wp543.c 1970-01-01 01:00:00.000000000 +0100
  27220. +++ linux-4.1.13/arch/mips/ath79/mach-wp543.c 2015-09-13 20:04:35.072523889 +0200
  27221. @@ -0,0 +1,109 @@
  27222. +/*
  27223. + * Compex WP543/WPJ543 board support
  27224. + *
  27225. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  27226. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  27227. + *
  27228. + * This program is free software; you can redistribute it and/or modify it
  27229. + * under the terms of the GNU General Public License version 2 as published
  27230. + * by the Free Software Foundation.
  27231. + */
  27232. +
  27233. +#include <asm/mach-ath79/ar71xx_regs.h>
  27234. +#include <asm/mach-ath79/ath79.h>
  27235. +
  27236. +#include "dev-eth.h"
  27237. +#include "dev-gpio-buttons.h"
  27238. +#include "dev-leds-gpio.h"
  27239. +#include "dev-m25p80.h"
  27240. +#include "dev-usb.h"
  27241. +#include "machtypes.h"
  27242. +#include "pci.h"
  27243. +
  27244. +#define WP543_GPIO_SW6 2
  27245. +#define WP543_GPIO_LED_1 3
  27246. +#define WP543_GPIO_LED_2 4
  27247. +#define WP543_GPIO_LED_WLAN 5
  27248. +#define WP543_GPIO_LED_CONN 6
  27249. +#define WP543_GPIO_LED_DIAG 7
  27250. +#define WP543_GPIO_SW4 8
  27251. +
  27252. +#define WP543_KEYS_POLL_INTERVAL 20 /* msecs */
  27253. +#define WP543_KEYS_DEBOUNCE_INTERVAL (3 * WP543_KEYS_POLL_INTERVAL)
  27254. +
  27255. +static struct gpio_led wp543_leds_gpio[] __initdata = {
  27256. + {
  27257. + .name = "wp543:green:led1",
  27258. + .gpio = WP543_GPIO_LED_1,
  27259. + .active_low = 1,
  27260. + }, {
  27261. + .name = "wp543:green:led2",
  27262. + .gpio = WP543_GPIO_LED_2,
  27263. + .active_low = 1,
  27264. + }, {
  27265. + .name = "wp543:green:wlan",
  27266. + .gpio = WP543_GPIO_LED_WLAN,
  27267. + .active_low = 1,
  27268. + }, {
  27269. + .name = "wp543:green:conn",
  27270. + .gpio = WP543_GPIO_LED_CONN,
  27271. + .active_low = 1,
  27272. + }, {
  27273. + .name = "wp543:green:diag",
  27274. + .gpio = WP543_GPIO_LED_DIAG,
  27275. + .active_low = 1,
  27276. + }
  27277. +};
  27278. +
  27279. +static struct gpio_keys_button wp543_gpio_keys[] __initdata = {
  27280. + {
  27281. + .desc = "sw6",
  27282. + .type = EV_KEY,
  27283. + .code = BTN_0,
  27284. + .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
  27285. + .gpio = WP543_GPIO_SW6,
  27286. + .active_low = 1,
  27287. + }, {
  27288. + .desc = "sw4",
  27289. + .type = EV_KEY,
  27290. + .code = KEY_RESTART,
  27291. + .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
  27292. + .gpio = WP543_GPIO_SW4,
  27293. + .active_low = 1,
  27294. + }
  27295. +};
  27296. +
  27297. +static const char *wp543_part_probes[] = {
  27298. + "MyLoader",
  27299. + NULL,
  27300. +};
  27301. +
  27302. +static struct flash_platform_data wp543_flash_data = {
  27303. + .part_probes = wp543_part_probes,
  27304. +};
  27305. +
  27306. +static void __init wp543_setup(void)
  27307. +{
  27308. + ath79_register_m25p80(&wp543_flash_data);
  27309. +
  27310. + ath79_register_mdio(0, 0xfffffff0);
  27311. +
  27312. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  27313. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  27314. + ath79_eth0_data.phy_mask = 0x0f;
  27315. + ath79_eth0_data.reset_bit = AR71XX_RESET_GE0_MAC |
  27316. + AR71XX_RESET_GE0_PHY;
  27317. + ath79_register_eth(0);
  27318. +
  27319. + ath79_register_usb();
  27320. + ath79_register_pci();
  27321. +
  27322. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
  27323. + wp543_leds_gpio);
  27324. +
  27325. + ath79_register_gpio_keys_polled(-1, WP543_KEYS_POLL_INTERVAL,
  27326. + ARRAY_SIZE(wp543_gpio_keys),
  27327. + wp543_gpio_keys);
  27328. +}
  27329. +
  27330. +MIPS_MACHINE(ATH79_MACH_WP543, "WP543", "Compex WP543", wp543_setup);
  27331. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wpe72.c linux-4.1.13/arch/mips/ath79/mach-wpe72.c
  27332. --- linux-4.1.13.orig/arch/mips/ath79/mach-wpe72.c 1970-01-01 01:00:00.000000000 +0100
  27333. +++ linux-4.1.13/arch/mips/ath79/mach-wpe72.c 2015-09-13 20:04:35.072523889 +0200
  27334. @@ -0,0 +1,97 @@
  27335. +/*
  27336. + * Compex WPE72 board support
  27337. + *
  27338. + * Copyright (C) 2012 Johnathan Boyce<jon.boyce@globalreach.eu.com>
  27339. + *
  27340. + * This program is free software; you can redistribute it and/or modify it
  27341. + * under the terms of the GNU General Public License version 2 as published
  27342. + * by the Free Software Foundation.
  27343. + */
  27344. +
  27345. +#include <asm/mach-ath79/ath79.h>
  27346. +
  27347. +#include "dev-eth.h"
  27348. +#include "dev-gpio-buttons.h"
  27349. +#include "dev-leds-gpio.h"
  27350. +#include "dev-m25p80.h"
  27351. +#include "dev-usb.h"
  27352. +#include "machtypes.h"
  27353. +#include "pci.h"
  27354. +
  27355. +#define WPE72_GPIO_RESET 12
  27356. +#define WPE72_GPIO_LED_DIAG 13
  27357. +#define WPE72_GPIO_LED_1 14
  27358. +#define WPE72_GPIO_LED_2 15
  27359. +#define WPE72_GPIO_LED_3 16
  27360. +#define WPE72_GPIO_LED_4 17
  27361. +
  27362. +#define WPE72_KEYS_POLL_INTERVAL 20 /* msecs */
  27363. +#define WPE72_KEYS_DEBOUNCE_INTERVAL (3 * WPE72_KEYS_POLL_INTERVAL)
  27364. +
  27365. +static struct gpio_led wpe72_leds_gpio[] __initdata = {
  27366. + {
  27367. + .name = "wpe72:green:led1",
  27368. + .gpio = WPE72_GPIO_LED_1,
  27369. + .active_low = 1,
  27370. + }, {
  27371. + .name = "wpe72:green:led2",
  27372. + .gpio = WPE72_GPIO_LED_2,
  27373. + .active_low = 1,
  27374. + }, {
  27375. + .name = "wpe72:green:led3",
  27376. + .gpio = WPE72_GPIO_LED_3,
  27377. + .active_low = 1,
  27378. + }, {
  27379. + .name = "wpe72:green:led4",
  27380. + .gpio = WPE72_GPIO_LED_4,
  27381. + .active_low = 1,
  27382. + }, {
  27383. + .name = "wpe72:green:diag",
  27384. + .gpio = WPE72_GPIO_LED_DIAG,
  27385. + .active_low = 1,
  27386. + }
  27387. +};
  27388. +
  27389. +static struct gpio_keys_button wpe72_gpio_keys[] __initdata = {
  27390. + {
  27391. + .desc = "reset",
  27392. + .type = EV_KEY,
  27393. + .code = KEY_RESTART,
  27394. + .debounce_interval = WPE72_KEYS_DEBOUNCE_INTERVAL,
  27395. + .gpio = WPE72_GPIO_RESET,
  27396. + .active_low = 1,
  27397. + }
  27398. +};
  27399. +
  27400. +static const char *wpe72_part_probes[] = {
  27401. + "MyLoader",
  27402. + NULL,
  27403. +};
  27404. +
  27405. +static struct flash_platform_data wpe72_flash_data = {
  27406. + .part_probes = wpe72_part_probes,
  27407. +};
  27408. +
  27409. +static void __init wpe72_setup(void)
  27410. +{
  27411. + ath79_register_m25p80(&wpe72_flash_data);
  27412. + ath79_register_mdio(0, 0x0);
  27413. +
  27414. + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  27415. + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  27416. +
  27417. + ath79_register_eth(0);
  27418. + ath79_register_eth(1);
  27419. +
  27420. + ath79_register_usb();
  27421. + ath79_register_pci();
  27422. +
  27423. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpe72_leds_gpio),
  27424. + wpe72_leds_gpio);
  27425. +
  27426. + ath79_register_gpio_keys_polled(-1, WPE72_KEYS_POLL_INTERVAL,
  27427. + ARRAY_SIZE(wpe72_gpio_keys),
  27428. + wpe72_gpio_keys);
  27429. +}
  27430. +
  27431. +MIPS_MACHINE(ATH79_MACH_WPE72, "WPE72", "Compex WPE72", wpe72_setup);
  27432. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wpj344.c linux-4.1.13/arch/mips/ath79/mach-wpj344.c
  27433. --- linux-4.1.13.orig/arch/mips/ath79/mach-wpj344.c 1970-01-01 01:00:00.000000000 +0100
  27434. +++ linux-4.1.13/arch/mips/ath79/mach-wpj344.c 2015-09-13 20:04:35.072523889 +0200
  27435. @@ -0,0 +1,175 @@
  27436. +/*
  27437. + * Compex WPJ344 board support
  27438. + *
  27439. + * Copyright (c) 2011 Qualcomm Atheros
  27440. + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  27441. + *
  27442. + * Permission to use, copy, modify, and/or distribute this software for any
  27443. + * purpose with or without fee is hereby granted, provided that the above
  27444. + * copyright notice and this permission notice appear in all copies.
  27445. + *
  27446. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  27447. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  27448. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  27449. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27450. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  27451. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  27452. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27453. + *
  27454. + */
  27455. +
  27456. +#include <linux/phy.h>
  27457. +#include <linux/platform_device.h>
  27458. +#include <linux/ath9k_platform.h>
  27459. +#include <linux/ar8216_platform.h>
  27460. +
  27461. +#include <asm/mach-ath79/ar71xx_regs.h>
  27462. +
  27463. +#include "common.h"
  27464. +#include "pci.h"
  27465. +#include "dev-ap9x-pci.h"
  27466. +#include "dev-gpio-buttons.h"
  27467. +#include "dev-eth.h"
  27468. +#include "dev-usb.h"
  27469. +#include "dev-leds-gpio.h"
  27470. +#include "dev-m25p80.h"
  27471. +#include "dev-spi.h"
  27472. +#include "dev-wmac.h"
  27473. +#include "machtypes.h"
  27474. +
  27475. +#define WPJ344_GPIO_LED_SIG1 15
  27476. +#define WPJ344_GPIO_LED_SIG2 20
  27477. +#define WPJ344_GPIO_LED_SIG3 21
  27478. +#define WPJ344_GPIO_LED_SIG4 22
  27479. +#define WPJ344_GPIO_LED_STATUS 14
  27480. +
  27481. +#define WPJ344_GPIO_BTN_RESET 12
  27482. +
  27483. +#define WPJ344_KEYS_POLL_INTERVAL 20 /* msecs */
  27484. +#define WPJ344_KEYS_DEBOUNCE_INTERVAL (3 * WPJ344_KEYS_POLL_INTERVAL)
  27485. +
  27486. +#define WPJ344_MAC0_OFFSET 0
  27487. +#define WPJ344_MAC1_OFFSET 6
  27488. +#define WPJ344_WMAC_CALDATA_OFFSET 0x1000
  27489. +#define WPJ344_PCIE_CALDATA_OFFSET 0x5000
  27490. +
  27491. +static struct gpio_led wpj344_leds_gpio[] __initdata = {
  27492. + {
  27493. + .name = "wpj344:green:status",
  27494. + .gpio = WPJ344_GPIO_LED_STATUS,
  27495. + .active_low = 1,
  27496. + },
  27497. + {
  27498. + .name = "wpj344:red:sig1",
  27499. + .gpio = WPJ344_GPIO_LED_SIG1,
  27500. + .active_low = 1,
  27501. + },
  27502. + {
  27503. + .name = "wpj344:yellow:sig2",
  27504. + .gpio = WPJ344_GPIO_LED_SIG2,
  27505. + .active_low = 1,
  27506. + },
  27507. + {
  27508. + .name = "wpj344:green:sig3",
  27509. + .gpio = WPJ344_GPIO_LED_SIG3,
  27510. + .active_low = 1,
  27511. + },
  27512. + {
  27513. + .name = "wpj344:green:sig4",
  27514. + .gpio = WPJ344_GPIO_LED_SIG4,
  27515. + .active_low = 1,
  27516. + }
  27517. +};
  27518. +
  27519. +static struct gpio_keys_button wpj344_gpio_keys[] __initdata = {
  27520. + {
  27521. + .desc = "reset",
  27522. + .type = EV_KEY,
  27523. + .code = KEY_RESTART,
  27524. + .debounce_interval = WPJ344_KEYS_DEBOUNCE_INTERVAL,
  27525. + .gpio = WPJ344_GPIO_BTN_RESET,
  27526. + .active_low = 1,
  27527. + },
  27528. +};
  27529. +
  27530. +static struct ar8327_pad_cfg wpj344_ar8327_pad0_cfg = {
  27531. + .mode = AR8327_PAD_MAC_RGMII,
  27532. + .txclk_delay_en = true,
  27533. + .rxclk_delay_en = true,
  27534. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  27535. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  27536. +};
  27537. +
  27538. +static struct ar8327_led_cfg wpj344_ar8327_led_cfg = {
  27539. + .led_ctrl0 = 0x00000000,
  27540. + .led_ctrl1 = 0xc737c737,
  27541. + .led_ctrl2 = 0x00000000,
  27542. + .led_ctrl3 = 0x00c30c00,
  27543. + .open_drain = true,
  27544. +};
  27545. +
  27546. +static struct ar8327_platform_data wpj344_ar8327_data = {
  27547. + .pad0_cfg = &wpj344_ar8327_pad0_cfg,
  27548. + .port0_cfg = {
  27549. + .force_link = 1,
  27550. + .speed = AR8327_PORT_SPEED_1000,
  27551. + .duplex = 1,
  27552. + .txpause = 1,
  27553. + .rxpause = 1,
  27554. + },
  27555. + .led_cfg = &wpj344_ar8327_led_cfg,
  27556. +};
  27557. +
  27558. +static struct mdio_board_info wpj344_mdio0_info[] = {
  27559. + {
  27560. + .bus_id = "ag71xx-mdio.0",
  27561. + .phy_addr = 0,
  27562. + .platform_data = &wpj344_ar8327_data,
  27563. + },
  27564. +};
  27565. +
  27566. +static void __init wpj344_setup(void)
  27567. +{
  27568. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  27569. +
  27570. + ath79_register_m25p80(NULL);
  27571. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpj344_leds_gpio),
  27572. + wpj344_leds_gpio);
  27573. + ath79_register_gpio_keys_polled(-1, WPJ344_KEYS_POLL_INTERVAL,
  27574. + ARRAY_SIZE(wpj344_gpio_keys),
  27575. + wpj344_gpio_keys);
  27576. +
  27577. + ath79_register_usb();
  27578. +
  27579. + ath79_register_wmac(art + WPJ344_WMAC_CALDATA_OFFSET, NULL);
  27580. +
  27581. + ath79_register_pci();
  27582. +
  27583. + mdiobus_register_board_info(wpj344_mdio0_info,
  27584. + ARRAY_SIZE(wpj344_mdio0_info));
  27585. +
  27586. + ath79_register_mdio(1, 0x0);
  27587. + ath79_register_mdio(0, 0x0);
  27588. +
  27589. + ath79_init_mac(ath79_eth0_data.mac_addr, art + WPJ344_MAC0_OFFSET, 0);
  27590. + ath79_init_mac(ath79_eth1_data.mac_addr, art + WPJ344_MAC1_OFFSET, 0);
  27591. +
  27592. + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  27593. + AR934X_ETH_CFG_SW_ONLY_MODE);
  27594. +
  27595. + /* GMAC0 is connected to an AR8327 switch */
  27596. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  27597. + ath79_eth0_data.phy_mask = BIT(0);
  27598. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  27599. + ath79_eth0_pll_data.pll_1000 = 0x06000000;
  27600. +
  27601. + /* GMAC1 is connected to the internal switch */
  27602. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  27603. + ath79_eth1_data.speed = SPEED_1000;
  27604. + ath79_eth1_data.duplex = DUPLEX_FULL;
  27605. +
  27606. + ath79_register_eth(0);
  27607. + ath79_register_eth(1);
  27608. +}
  27609. +
  27610. +MIPS_MACHINE(ATH79_MACH_WPJ344, "WPJ344", "Compex WPJ344", wpj344_setup);
  27611. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wpj531.c linux-4.1.13/arch/mips/ath79/mach-wpj531.c
  27612. --- linux-4.1.13.orig/arch/mips/ath79/mach-wpj531.c 1970-01-01 01:00:00.000000000 +0100
  27613. +++ linux-4.1.13/arch/mips/ath79/mach-wpj531.c 2015-09-13 20:04:35.072523889 +0200
  27614. @@ -0,0 +1,143 @@
  27615. +/*
  27616. + * Compex WPJ531 board support
  27617. + *
  27618. + * Copyright (c) 2012 Qualcomm Atheros
  27619. + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  27620. + *
  27621. + * Permission to use, copy, modify, and/or distribute this software for any
  27622. + * purpose with or without fee is hereby granted, provided that the above
  27623. + * copyright notice and this permission notice appear in all copies.
  27624. + *
  27625. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  27626. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  27627. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  27628. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27629. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  27630. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  27631. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27632. + *
  27633. + */
  27634. +
  27635. +#include <linux/irq.h>
  27636. +#include <linux/platform_device.h>
  27637. +#include <linux/ar8216_platform.h>
  27638. +
  27639. +#include <asm/mach-ath79/ar71xx_regs.h>
  27640. +
  27641. +#include "pci.h"
  27642. +#include "common.h"
  27643. +#include "dev-ap9x-pci.h"
  27644. +#include "dev-gpio-buttons.h"
  27645. +#include "dev-eth.h"
  27646. +#include "dev-leds-gpio.h"
  27647. +#include "dev-m25p80.h"
  27648. +#include "dev-usb.h"
  27649. +#include "dev-wmac.h"
  27650. +#include "machtypes.h"
  27651. +
  27652. +#define WPJ531_GPIO_LED_SIG1 14
  27653. +#define WPJ531_GPIO_LED_SIG2 15
  27654. +#define WPJ531_GPIO_LED_SIG3 22
  27655. +#define WPJ531_GPIO_LED_SIG4 23
  27656. +#define WPJ531_GPIO_BUZZER 4
  27657. +
  27658. +#define WPJ531_GPIO_BTN_RESET 17
  27659. +
  27660. +#define WPJ531_KEYS_POLL_INTERVAL 20 /* msecs */
  27661. +#define WPJ531_KEYS_DEBOUNCE_INTERVAL (3 * WPJ531_KEYS_POLL_INTERVAL)
  27662. +
  27663. +#define WPJ531_MAC0_OFFSET 0x10
  27664. +#define WPJ531_MAC1_OFFSET 0x18
  27665. +#define WPJ531_WMAC_CALDATA_OFFSET 0x1000
  27666. +#define WPJ531_PCIE_CALDATA_OFFSET 0x5000
  27667. +
  27668. +#define WPJ531_ART_SIZE 0x8000
  27669. +
  27670. +static struct gpio_led wpj531_leds_gpio[] __initdata = {
  27671. + {
  27672. + .name = "wpj531:red:sig1",
  27673. + .gpio = WPJ531_GPIO_LED_SIG1,
  27674. + .active_low = 1,
  27675. + },
  27676. + {
  27677. + .name = "wpj531:yellow:sig2",
  27678. + .gpio = WPJ531_GPIO_LED_SIG2,
  27679. + .active_low = 1,
  27680. + },
  27681. + {
  27682. + .name = "wpj531:green:sig3",
  27683. + .gpio = WPJ531_GPIO_LED_SIG3,
  27684. + .active_low = 1,
  27685. + },
  27686. + {
  27687. + .name = "wpj531:green:sig4",
  27688. + .gpio = WPJ531_GPIO_LED_SIG4,
  27689. + .active_low = 1,
  27690. + },
  27691. + {
  27692. + .name = "wpj531:buzzer",
  27693. + .gpio = WPJ531_GPIO_BUZZER,
  27694. + .active_low = 0,
  27695. + }
  27696. +};
  27697. +
  27698. +static struct gpio_keys_button wpj531_gpio_keys[] __initdata = {
  27699. + {
  27700. + .desc = "reset",
  27701. + .type = EV_KEY,
  27702. + .code = KEY_RESTART,
  27703. + .debounce_interval = WPJ531_KEYS_DEBOUNCE_INTERVAL,
  27704. + .gpio = WPJ531_GPIO_BTN_RESET,
  27705. + .active_low = 1,
  27706. + },
  27707. +};
  27708. +
  27709. +static void __init common_setup(void)
  27710. +{
  27711. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  27712. + u8 *mac = (u8 *) KSEG1ADDR(0x1f02e000);
  27713. +
  27714. + ath79_register_m25p80(NULL);
  27715. +
  27716. + ath79_setup_ar933x_phy4_switch(false, false);
  27717. +
  27718. + ath79_register_mdio(0, 0x0);
  27719. +
  27720. + /* LAN */
  27721. + ath79_eth0_data.duplex = DUPLEX_FULL;
  27722. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  27723. + ath79_eth0_data.speed = SPEED_100;
  27724. + ath79_eth0_data.phy_mask = BIT(4);
  27725. + ath79_init_mac(ath79_eth0_data.mac_addr, mac + WPJ531_MAC0_OFFSET, 0);
  27726. + ath79_register_eth(0);
  27727. +
  27728. + /* WAN */
  27729. + ath79_switch_data.phy4_mii_en = 1;
  27730. + ath79_eth1_data.duplex = DUPLEX_FULL;
  27731. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  27732. + ath79_eth1_data.speed = SPEED_1000;
  27733. + ath79_switch_data.phy_poll_mask |= BIT(4);
  27734. + ath79_init_mac(ath79_eth1_data.mac_addr, mac + WPJ531_MAC1_OFFSET, 0);
  27735. + ath79_register_eth(1);
  27736. +
  27737. + ath79_register_wmac(art + WPJ531_WMAC_CALDATA_OFFSET, NULL);
  27738. +
  27739. + ath79_register_pci();
  27740. + ath79_register_usb();
  27741. +}
  27742. +
  27743. +static void __init wpj531_setup(void)
  27744. +{
  27745. + common_setup();
  27746. +
  27747. + ath79_register_leds_gpio(-1,
  27748. + ARRAY_SIZE(wpj531_leds_gpio),
  27749. + wpj531_leds_gpio);
  27750. +
  27751. + ath79_register_gpio_keys_polled(-1,
  27752. + WPJ531_KEYS_POLL_INTERVAL,
  27753. + ARRAY_SIZE(wpj531_gpio_keys),
  27754. + wpj531_gpio_keys);
  27755. +}
  27756. +
  27757. +MIPS_MACHINE(ATH79_MACH_WPJ531, "WPJ531", "Compex WPJ531", wpj531_setup);
  27758. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wpj558.c linux-4.1.13/arch/mips/ath79/mach-wpj558.c
  27759. --- linux-4.1.13.orig/arch/mips/ath79/mach-wpj558.c 1970-01-01 01:00:00.000000000 +0100
  27760. +++ linux-4.1.13/arch/mips/ath79/mach-wpj558.c 2015-09-13 20:04:35.072523889 +0200
  27761. @@ -0,0 +1,177 @@
  27762. +/*
  27763. + * Compex WPJ558 board support
  27764. + *
  27765. + * Copyright (c) 2012 Qualcomm Atheros
  27766. + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
  27767. + *
  27768. + * Permission to use, copy, modify, and/or distribute this software for any
  27769. + * purpose with or without fee is hereby granted, provided that the above
  27770. + * copyright notice and this permission notice appear in all copies.
  27771. + *
  27772. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  27773. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  27774. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  27775. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27776. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  27777. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  27778. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27779. + *
  27780. + */
  27781. +
  27782. +#include <linux/pci.h>
  27783. +#include <linux/phy.h>
  27784. +#include <linux/gpio.h>
  27785. +#include <linux/platform_device.h>
  27786. +#include <linux/ath9k_platform.h>
  27787. +#include <linux/ar8216_platform.h>
  27788. +
  27789. +#include <asm/mach-ath79/ar71xx_regs.h>
  27790. +
  27791. +#include "common.h"
  27792. +#include "pci.h"
  27793. +#include "dev-ap9x-pci.h"
  27794. +#include "dev-gpio-buttons.h"
  27795. +#include "dev-eth.h"
  27796. +#include "dev-usb.h"
  27797. +#include "dev-leds-gpio.h"
  27798. +#include "dev-m25p80.h"
  27799. +#include "dev-spi.h"
  27800. +#include "dev-wmac.h"
  27801. +#include "machtypes.h"
  27802. +
  27803. +#define WPJ558_GPIO_LED_SIG1 14
  27804. +#define WPJ558_GPIO_LED_SIG2 15
  27805. +#define WPJ558_GPIO_LED_SIG3 22
  27806. +#define WPJ558_GPIO_LED_SIG4 23
  27807. +#define WPJ558_GPIO_BUZZER 4
  27808. +
  27809. +#define WPJ558_GPIO_BTN_RESET 17
  27810. +
  27811. +#define WPJ558_KEYS_POLL_INTERVAL 20 /* msecs */
  27812. +#define WPJ558_KEYS_DEBOUNCE_INTERVAL (3 * WPJ558_KEYS_POLL_INTERVAL)
  27813. +
  27814. +#define WPJ558_MAC_OFFSET 0x1002
  27815. +#define WPJ558_WMAC_CALDATA_OFFSET 0x1000
  27816. +
  27817. +static struct gpio_led wpj558_leds_gpio[] __initdata = {
  27818. + {
  27819. + .name = "wpj558:red:sig1",
  27820. + .gpio = WPJ558_GPIO_LED_SIG1,
  27821. + .active_low = 1,
  27822. + },
  27823. + {
  27824. + .name = "wpj558:yellow:sig2",
  27825. + .gpio = WPJ558_GPIO_LED_SIG2,
  27826. + .active_low = 1,
  27827. + },
  27828. + {
  27829. + .name = "wpj558:green:sig3",
  27830. + .gpio = WPJ558_GPIO_LED_SIG3,
  27831. + .active_low = 1,
  27832. + },
  27833. + {
  27834. + .name = "wpj558:green:sig4",
  27835. + .gpio = WPJ558_GPIO_LED_SIG4,
  27836. + .active_low = 1,
  27837. + },
  27838. + {
  27839. + .name = "wpj558:buzzer",
  27840. + .gpio = WPJ558_GPIO_BUZZER,
  27841. + .active_low = 0,
  27842. + }
  27843. +};
  27844. +
  27845. +static struct gpio_keys_button wpj558_gpio_keys[] __initdata = {
  27846. + {
  27847. + .desc = "reset",
  27848. + .type = EV_KEY,
  27849. + .code = KEY_RESTART,
  27850. + .debounce_interval = WPJ558_KEYS_DEBOUNCE_INTERVAL,
  27851. + .gpio = WPJ558_GPIO_BTN_RESET,
  27852. + .active_low = 1,
  27853. + },
  27854. +};
  27855. +
  27856. +static struct ar8327_pad_cfg wpj558_ar8327_pad0_cfg = {
  27857. + .mode = AR8327_PAD_MAC_SGMII,
  27858. + .sgmii_delay_en = true,
  27859. +};
  27860. +
  27861. +static struct ar8327_pad_cfg wpj558_ar8327_pad6_cfg = {
  27862. + .mode = AR8327_PAD_MAC_RGMII,
  27863. + .txclk_delay_en = true,
  27864. + .rxclk_delay_en = true,
  27865. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  27866. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  27867. +};
  27868. +
  27869. +static struct ar8327_platform_data wpj558_ar8327_data = {
  27870. + .pad0_cfg = &wpj558_ar8327_pad0_cfg,
  27871. + .pad6_cfg = &wpj558_ar8327_pad6_cfg,
  27872. + .port0_cfg = {
  27873. + .force_link = 1,
  27874. + .speed = AR8327_PORT_SPEED_1000,
  27875. + .duplex = 1,
  27876. + .txpause = 1,
  27877. + .rxpause = 1,
  27878. + },
  27879. + .port6_cfg = {
  27880. + .force_link = 1,
  27881. + .speed = AR8327_PORT_SPEED_1000,
  27882. + .duplex = 1,
  27883. + .txpause = 1,
  27884. + .rxpause = 1,
  27885. + },
  27886. +};
  27887. +
  27888. +static struct mdio_board_info wpj558_mdio0_info[] = {
  27889. + {
  27890. + .bus_id = "ag71xx-mdio.0",
  27891. + .phy_addr = 0,
  27892. + .platform_data = &wpj558_ar8327_data,
  27893. + },
  27894. +};
  27895. +
  27896. +static void __init wpj558_setup(void)
  27897. +{
  27898. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  27899. +
  27900. + ath79_register_m25p80(NULL);
  27901. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpj558_leds_gpio),
  27902. + wpj558_leds_gpio);
  27903. + ath79_register_gpio_keys_polled(-1, WPJ558_KEYS_POLL_INTERVAL,
  27904. + ARRAY_SIZE(wpj558_gpio_keys),
  27905. + wpj558_gpio_keys);
  27906. +
  27907. + ath79_register_usb();
  27908. +
  27909. + ath79_register_wmac(art + WPJ558_WMAC_CALDATA_OFFSET, NULL);
  27910. +
  27911. + ath79_register_pci();
  27912. +
  27913. + mdiobus_register_board_info(wpj558_mdio0_info,
  27914. + ARRAY_SIZE(wpj558_mdio0_info));
  27915. + ath79_register_mdio(0, 0x0);
  27916. +
  27917. + ath79_init_mac(ath79_eth0_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
  27918. + ath79_init_mac(ath79_eth1_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
  27919. +
  27920. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  27921. +
  27922. + /* GMAC0 is connected to an AR8327 switch */
  27923. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  27924. + ath79_eth0_data.phy_mask = BIT(0);
  27925. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  27926. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  27927. +
  27928. + /* GMAC1 is connected to the SGMII interface */
  27929. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  27930. + ath79_eth1_data.speed = SPEED_1000;
  27931. + ath79_eth1_data.duplex = DUPLEX_FULL;
  27932. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  27933. +
  27934. + ath79_register_eth(0);
  27935. + ath79_register_eth(1);
  27936. +}
  27937. +
  27938. +MIPS_MACHINE(ATH79_MACH_WPJ558, "WPJ558", "Compex WPJ558", wpj558_setup);
  27939. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wrt160nl.c linux-4.1.13/arch/mips/ath79/mach-wrt160nl.c
  27940. --- linux-4.1.13.orig/arch/mips/ath79/mach-wrt160nl.c 1970-01-01 01:00:00.000000000 +0100
  27941. +++ linux-4.1.13/arch/mips/ath79/mach-wrt160nl.c 2015-09-13 20:04:35.072523889 +0200
  27942. @@ -0,0 +1,126 @@
  27943. +/*
  27944. + * Linksys WRT160NL board support
  27945. + *
  27946. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  27947. + *
  27948. + * This program is free software; you can redistribute it and/or modify it
  27949. + * under the terms of the GNU General Public License version 2 as published
  27950. + * by the Free Software Foundation.
  27951. + */
  27952. +
  27953. +#include <asm/mach-ath79/ath79.h>
  27954. +
  27955. +#include "dev-eth.h"
  27956. +#include "dev-gpio-buttons.h"
  27957. +#include "dev-leds-gpio.h"
  27958. +#include "dev-m25p80.h"
  27959. +#include "dev-usb.h"
  27960. +#include "dev-wmac.h"
  27961. +#include "nvram.h"
  27962. +#include "machtypes.h"
  27963. +
  27964. +#define WRT160NL_GPIO_LED_POWER 14
  27965. +#define WRT160NL_GPIO_LED_WPS_AMBER 9
  27966. +#define WRT160NL_GPIO_LED_WPS_BLUE 8
  27967. +#define WRT160NL_GPIO_LED_WLAN 6
  27968. +
  27969. +#define WRT160NL_GPIO_BTN_WPS 7
  27970. +#define WRT160NL_GPIO_BTN_RESET 21
  27971. +
  27972. +#define WRT160NL_KEYS_POLL_INTERVAL 20 /* msecs */
  27973. +#define WRT160NL_KEYS_DEBOUNCE_INTERVAL (3 * WRT160NL_KEYS_POLL_INTERVAL)
  27974. +
  27975. +#define WRT160NL_NVRAM_ADDR 0x1f7e0000
  27976. +#define WRT160NL_NVRAM_SIZE 0x10000
  27977. +
  27978. +static const char *wrt160nl_part_probes[] = {
  27979. + "cybertan",
  27980. + NULL,
  27981. +};
  27982. +
  27983. +static struct flash_platform_data wrt160nl_flash_data = {
  27984. + .part_probes = wrt160nl_part_probes,
  27985. +};
  27986. +
  27987. +static struct gpio_led wrt160nl_leds_gpio[] __initdata = {
  27988. + {
  27989. + .name = "wrt160nl:blue:power",
  27990. + .gpio = WRT160NL_GPIO_LED_POWER,
  27991. + .active_low = 1,
  27992. + .default_trigger = "default-on",
  27993. + }, {
  27994. + .name = "wrt160nl:amber:wps",
  27995. + .gpio = WRT160NL_GPIO_LED_WPS_AMBER,
  27996. + .active_low = 1,
  27997. + }, {
  27998. + .name = "wrt160nl:blue:wps",
  27999. + .gpio = WRT160NL_GPIO_LED_WPS_BLUE,
  28000. + .active_low = 1,
  28001. + }, {
  28002. + .name = "wrt160nl:blue:wlan",
  28003. + .gpio = WRT160NL_GPIO_LED_WLAN,
  28004. + .active_low = 1,
  28005. + }
  28006. +};
  28007. +
  28008. +static struct gpio_keys_button wrt160nl_gpio_keys[] __initdata = {
  28009. + {
  28010. + .desc = "reset",
  28011. + .type = EV_KEY,
  28012. + .code = KEY_RESTART,
  28013. + .debounce_interval = WRT160NL_KEYS_DEBOUNCE_INTERVAL,
  28014. + .gpio = WRT160NL_GPIO_BTN_RESET,
  28015. + .active_low = 1,
  28016. + }, {
  28017. + .desc = "wps",
  28018. + .type = EV_KEY,
  28019. + .code = KEY_WPS_BUTTON,
  28020. + .debounce_interval = WRT160NL_KEYS_DEBOUNCE_INTERVAL,
  28021. + .gpio = WRT160NL_GPIO_BTN_WPS,
  28022. + .active_low = 1,
  28023. + }
  28024. +};
  28025. +
  28026. +static void __init wrt160nl_setup(void)
  28027. +{
  28028. + const char *nvram = (char *) KSEG1ADDR(WRT160NL_NVRAM_ADDR);
  28029. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  28030. + u8 mac[6];
  28031. +
  28032. + if (ath79_nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
  28033. + "lan_hwaddr=", mac) == 0) {
  28034. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  28035. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  28036. + }
  28037. +
  28038. + ath79_register_mdio(0, 0x0);
  28039. +
  28040. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  28041. + ath79_eth0_data.phy_mask = 0x01;
  28042. +
  28043. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  28044. + ath79_eth1_data.phy_mask = 0x10;
  28045. +
  28046. + ath79_register_eth(0);
  28047. + ath79_register_eth(1);
  28048. +
  28049. + ath79_register_m25p80(&wrt160nl_flash_data);
  28050. +
  28051. + ath79_register_usb();
  28052. +
  28053. + if (ath79_nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
  28054. + "wl0_hwaddr=", mac) == 0)
  28055. + ath79_register_wmac(eeprom, mac);
  28056. + else
  28057. + ath79_register_wmac(eeprom, NULL);
  28058. +
  28059. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wrt160nl_leds_gpio),
  28060. + wrt160nl_leds_gpio);
  28061. +
  28062. + ath79_register_gpio_keys_polled(-1, WRT160NL_KEYS_POLL_INTERVAL,
  28063. + ARRAY_SIZE(wrt160nl_gpio_keys),
  28064. + wrt160nl_gpio_keys);
  28065. +}
  28066. +
  28067. +MIPS_MACHINE(ATH79_MACH_WRT160NL, "WRT160NL", "Linksys WRT160NL",
  28068. + wrt160nl_setup);
  28069. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wrt400n.c linux-4.1.13/arch/mips/ath79/mach-wrt400n.c
  28070. --- linux-4.1.13.orig/arch/mips/ath79/mach-wrt400n.c 1970-01-01 01:00:00.000000000 +0100
  28071. +++ linux-4.1.13/arch/mips/ath79/mach-wrt400n.c 2015-09-13 20:04:35.072523889 +0200
  28072. @@ -0,0 +1,161 @@
  28073. +/*
  28074. + * Linksys WRT400N board support
  28075. + *
  28076. + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  28077. + * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
  28078. + *
  28079. + * This program is free software; you can redistribute it and/or modify it
  28080. + * under the terms of the GNU General Public License version 2 as published
  28081. + * by the Free Software Foundation.
  28082. + */
  28083. +
  28084. +#include <linux/mtd/mtd.h>
  28085. +#include <linux/mtd/partitions.h>
  28086. +
  28087. +#include <asm/mach-ath79/ath79.h>
  28088. +
  28089. +#include "dev-ap9x-pci.h"
  28090. +#include "dev-eth.h"
  28091. +#include "dev-gpio-buttons.h"
  28092. +#include "dev-leds-gpio.h"
  28093. +#include "dev-m25p80.h"
  28094. +#include "machtypes.h"
  28095. +
  28096. +#define WRT400N_GPIO_LED_POWER 1
  28097. +#define WRT400N_GPIO_LED_WPS_BLUE 4
  28098. +#define WRT400N_GPIO_LED_WPS_AMBER 5
  28099. +#define WRT400N_GPIO_LED_WLAN 6
  28100. +
  28101. +#define WRT400N_GPIO_BTN_RESET 8
  28102. +#define WRT400N_GPIO_BTN_WLSEC 3
  28103. +
  28104. +#define WRT400N_KEYS_POLL_INTERVAL 20 /* msecs */
  28105. +#define WRT400N_KEYS_DEBOUNE_INTERVAL (3 * WRT400N_KEYS_POLL_INTERVAL)
  28106. +
  28107. +#define WRT400N_MAC_ADDR_OFFSET 0x120c
  28108. +#define WRT400N_CALDATA0_OFFSET 0x1000
  28109. +#define WRT400N_CALDATA1_OFFSET 0x5000
  28110. +
  28111. +static struct mtd_partition wrt400n_partitions[] = {
  28112. + {
  28113. + .name = "uboot",
  28114. + .offset = 0,
  28115. + .size = 0x030000,
  28116. + .mask_flags = MTD_WRITEABLE,
  28117. + }, {
  28118. + .name = "env",
  28119. + .offset = 0x030000,
  28120. + .size = 0x010000,
  28121. + .mask_flags = MTD_WRITEABLE,
  28122. + }, {
  28123. + .name = "linux",
  28124. + .offset = 0x040000,
  28125. + .size = 0x140000,
  28126. + }, {
  28127. + .name = "rootfs",
  28128. + .offset = 0x180000,
  28129. + .size = 0x630000,
  28130. + }, {
  28131. + .name = "nvram",
  28132. + .offset = 0x7b0000,
  28133. + .size = 0x010000,
  28134. + .mask_flags = MTD_WRITEABLE,
  28135. + }, {
  28136. + .name = "factory",
  28137. + .offset = 0x7c0000,
  28138. + .size = 0x010000,
  28139. + .mask_flags = MTD_WRITEABLE,
  28140. + }, {
  28141. + .name = "language",
  28142. + .offset = 0x7d0000,
  28143. + .size = 0x020000,
  28144. + .mask_flags = MTD_WRITEABLE,
  28145. + }, {
  28146. + .name = "caldata",
  28147. + .offset = 0x7f0000,
  28148. + .size = 0x010000,
  28149. + .mask_flags = MTD_WRITEABLE,
  28150. + }, {
  28151. + .name = "firmware",
  28152. + .offset = 0x040000,
  28153. + .size = 0x770000,
  28154. + }
  28155. +};
  28156. +
  28157. +static struct flash_platform_data wrt400n_flash_data = {
  28158. + .parts = wrt400n_partitions,
  28159. + .nr_parts = ARRAY_SIZE(wrt400n_partitions),
  28160. +};
  28161. +
  28162. +static struct gpio_led wrt400n_leds_gpio[] __initdata = {
  28163. + {
  28164. + .name = "wrt400n:blue:wps",
  28165. + .gpio = WRT400N_GPIO_LED_WPS_BLUE,
  28166. + .active_low = 1,
  28167. + }, {
  28168. + .name = "wrt400n:amber:wps",
  28169. + .gpio = WRT400N_GPIO_LED_WPS_AMBER,
  28170. + .active_low = 1,
  28171. + }, {
  28172. + .name = "wrt400n:blue:wlan",
  28173. + .gpio = WRT400N_GPIO_LED_WLAN,
  28174. + .active_low = 1,
  28175. + }, {
  28176. + .name = "wrt400n:blue:power",
  28177. + .gpio = WRT400N_GPIO_LED_POWER,
  28178. + .active_low = 0,
  28179. + .default_trigger = "default-on",
  28180. + }
  28181. +};
  28182. +
  28183. +static struct gpio_keys_button wrt400n_gpio_keys[] __initdata = {
  28184. + {
  28185. + .desc = "reset",
  28186. + .type = EV_KEY,
  28187. + .code = KEY_RESTART,
  28188. + .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
  28189. + .gpio = WRT400N_GPIO_BTN_RESET,
  28190. + .active_low = 1,
  28191. + }, {
  28192. + .desc = "wlsec",
  28193. + .type = EV_KEY,
  28194. + .code = KEY_WPS_BUTTON,
  28195. + .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
  28196. + .gpio = WRT400N_GPIO_BTN_WLSEC,
  28197. + .active_low = 1,
  28198. + }
  28199. +};
  28200. +
  28201. +static void __init wrt400n_setup(void)
  28202. +{
  28203. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  28204. + u8 *mac = art + WRT400N_MAC_ADDR_OFFSET;
  28205. +
  28206. + ath79_register_mdio(0, 0x0);
  28207. +
  28208. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  28209. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  28210. + ath79_eth0_data.speed = SPEED_100;
  28211. + ath79_eth0_data.duplex = DUPLEX_FULL;
  28212. +
  28213. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
  28214. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  28215. + ath79_eth1_data.phy_mask = 0x10;
  28216. +
  28217. + ath79_register_eth(0);
  28218. + ath79_register_eth(1);
  28219. +
  28220. + ath79_register_m25p80(&wrt400n_flash_data);
  28221. +
  28222. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wrt400n_leds_gpio),
  28223. + wrt400n_leds_gpio);
  28224. +
  28225. + ath79_register_gpio_keys_polled(-1, WRT400N_KEYS_POLL_INTERVAL,
  28226. + ARRAY_SIZE(wrt400n_gpio_keys),
  28227. + wrt400n_gpio_keys);
  28228. +
  28229. + ap94_pci_init(art + WRT400N_CALDATA0_OFFSET, NULL,
  28230. + art + WRT400N_CALDATA1_OFFSET, NULL);
  28231. +}
  28232. +
  28233. +MIPS_MACHINE(ATH79_MACH_WRT400N, "WRT400N", "Linksys WRT400N", wrt400n_setup);
  28234. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wzr-450hp2.c linux-4.1.13/arch/mips/ath79/mach-wzr-450hp2.c
  28235. --- linux-4.1.13.orig/arch/mips/ath79/mach-wzr-450hp2.c 1970-01-01 01:00:00.000000000 +0100
  28236. +++ linux-4.1.13/arch/mips/ath79/mach-wzr-450hp2.c 2015-09-13 20:04:35.072523889 +0200
  28237. @@ -0,0 +1,221 @@
  28238. +/*
  28239. + * Buffalo WZR-450HP2 board support
  28240. + *
  28241. + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  28242. + *
  28243. + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  28244. + * Copyright (c) 2012 Qualcomm Atheros
  28245. + *
  28246. + * Permission to use, copy, modify, and/or distribute this software for any
  28247. + * purpose with or without fee is hereby granted, provided that the above
  28248. + * copyright notice and this permission notice appear in all copies.
  28249. + *
  28250. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  28251. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  28252. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  28253. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  28254. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  28255. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  28256. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  28257. + *
  28258. + */
  28259. +
  28260. +#include <linux/phy.h>
  28261. +#include <linux/gpio.h>
  28262. +#include <linux/mtd/mtd.h>
  28263. +#include <linux/mtd/partitions.h>
  28264. +#include <linux/platform_device.h>
  28265. +#include <linux/ar8216_platform.h>
  28266. +
  28267. +#include <asm/mach-ath79/ar71xx_regs.h>
  28268. +
  28269. +#include "common.h"
  28270. +#include "dev-eth.h"
  28271. +#include "dev-gpio-buttons.h"
  28272. +#include "dev-leds-gpio.h"
  28273. +#include "dev-m25p80.h"
  28274. +#include "dev-spi.h"
  28275. +#include "dev-usb.h"
  28276. +#include "dev-wmac.h"
  28277. +#include "machtypes.h"
  28278. +
  28279. +#define WZR_450HP2_KEYS_POLL_INTERVAL 20 /* msecs */
  28280. +#define WZR_450HP2_KEYS_DEBOUNCE_INTERVAL (3 * WZR_450HP2_KEYS_POLL_INTERVAL)
  28281. +
  28282. +#define WZR_450HP2_WMAC_CALDATA_OFFSET 0x1000
  28283. +
  28284. +static struct mtd_partition wzrhpg450h_partitions[] = {
  28285. + {
  28286. + .name = "u-boot",
  28287. + .offset = 0,
  28288. + .size = 0x0040000,
  28289. + .mask_flags = MTD_WRITEABLE,
  28290. + }, {
  28291. + .name = "u-boot-env",
  28292. + .offset = 0x0040000,
  28293. + .size = 0x0010000,
  28294. + }, {
  28295. + .name = "ART",
  28296. + .offset = 0x0ff0000,
  28297. + .size = 0x0010000,
  28298. + .mask_flags = MTD_WRITEABLE,
  28299. + }, {
  28300. + .name = "firmware",
  28301. + .offset = 0x0050000,
  28302. + .size = 0x0f90000,
  28303. + }, {
  28304. + .name = "user_property",
  28305. + .offset = 0x0fe0000,
  28306. + .size = 0x0010000,
  28307. + }
  28308. +};
  28309. +
  28310. +static struct flash_platform_data wzr_450hp2_flash_data = {
  28311. + .parts = wzrhpg450h_partitions,
  28312. + .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
  28313. +};
  28314. +
  28315. +static struct gpio_led wzr_450hp2_leds_gpio[] __initdata = {
  28316. + {
  28317. + .name = "buffalo:green:wps",
  28318. + .gpio = 3,
  28319. + .active_low = 1,
  28320. + },
  28321. + {
  28322. + .name = "buffalo:green:system",
  28323. + .gpio = 20,
  28324. + .active_low = 1,
  28325. + },
  28326. + {
  28327. + .name = "buffalo:green:wlan",
  28328. + .gpio = 18,
  28329. + .active_low = 1,
  28330. + },
  28331. +};
  28332. +
  28333. +static struct gpio_keys_button wzr_450hp2_gpio_keys[] __initdata = {
  28334. + {
  28335. + .desc = "Reset button",
  28336. + .type = EV_KEY,
  28337. + .code = KEY_RESTART,
  28338. + .debounce_interval = WZR_450HP2_KEYS_DEBOUNCE_INTERVAL,
  28339. + .gpio = 17,
  28340. + .active_low = 1,
  28341. + },
  28342. + {
  28343. + .desc = "RFKILL button",
  28344. + .type = EV_KEY,
  28345. + .code = KEY_RFKILL,
  28346. + .debounce_interval = WZR_450HP2_KEYS_DEBOUNCE_INTERVAL,
  28347. + .gpio = 21,
  28348. + .active_low = 1,
  28349. + },
  28350. +};
  28351. +
  28352. +static const struct ar8327_led_info wzr_450hp2_leds_ar8327[] = {
  28353. + AR8327_LED_INFO(PHY0_0, HW, "buffalo:green:lan1"),
  28354. + AR8327_LED_INFO(PHY1_0, HW, "buffalo:green:lan2"),
  28355. + AR8327_LED_INFO(PHY2_0, HW, "buffalo:green:lan3"),
  28356. + AR8327_LED_INFO(PHY3_0, HW, "buffalo:green:lan4"),
  28357. + AR8327_LED_INFO(PHY4_0, HW, "buffalo:green:wan"),
  28358. +};
  28359. +
  28360. +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
  28361. +static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad0_cfg = {
  28362. + .mode = AR8327_PAD_MAC_SGMII,
  28363. + .sgmii_delay_en = true,
  28364. +};
  28365. +
  28366. +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
  28367. +static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad6_cfg = {
  28368. + .mode = AR8327_PAD_MAC_RGMII,
  28369. + .txclk_delay_en = true,
  28370. + .rxclk_delay_en = true,
  28371. + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  28372. + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  28373. +};
  28374. +
  28375. +static struct ar8327_led_cfg wzr_450hp2_ar8327_led_cfg = {
  28376. + .led_ctrl0 = 0xcc35cc35,
  28377. + .led_ctrl1 = 0xca35ca35,
  28378. + .led_ctrl2 = 0xc935c935,
  28379. + .led_ctrl3 = 0x03ffff00,
  28380. + .open_drain = true,
  28381. +};
  28382. +
  28383. +static struct ar8327_platform_data wzr_450hp2_ar8327_data = {
  28384. + .pad0_cfg = &wzr_450hp2_ar8327_pad0_cfg,
  28385. + .pad6_cfg = &wzr_450hp2_ar8327_pad6_cfg,
  28386. + .port0_cfg = {
  28387. + .force_link = 1,
  28388. + .speed = AR8327_PORT_SPEED_1000,
  28389. + .duplex = 1,
  28390. + .txpause = 1,
  28391. + .rxpause = 1,
  28392. + },
  28393. + .port6_cfg = {
  28394. + .force_link = 1,
  28395. + .speed = AR8327_PORT_SPEED_1000,
  28396. + .duplex = 1,
  28397. + .txpause = 1,
  28398. + .rxpause = 1,
  28399. + },
  28400. + .led_cfg = &wzr_450hp2_ar8327_led_cfg,
  28401. + .num_leds = ARRAY_SIZE(wzr_450hp2_leds_ar8327),
  28402. + .leds = wzr_450hp2_leds_ar8327,
  28403. +};
  28404. +
  28405. +static struct mdio_board_info wzr_450hp2_mdio0_info[] = {
  28406. + {
  28407. + .bus_id = "ag71xx-mdio.0",
  28408. + .phy_addr = 0,
  28409. + .platform_data = &wzr_450hp2_ar8327_data,
  28410. + },
  28411. +};
  28412. +
  28413. +static void __init wzr_450hp2_setup(void)
  28414. +{
  28415. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  28416. + u8 *mac_wan = art;
  28417. + u8 *mac_lan = mac_wan + ETH_ALEN;
  28418. +
  28419. + ath79_register_m25p80(&wzr_450hp2_flash_data);
  28420. +
  28421. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzr_450hp2_leds_gpio),
  28422. + wzr_450hp2_leds_gpio);
  28423. + ath79_register_gpio_keys_polled(-1, WZR_450HP2_KEYS_POLL_INTERVAL,
  28424. + ARRAY_SIZE(wzr_450hp2_gpio_keys),
  28425. + wzr_450hp2_gpio_keys);
  28426. +
  28427. + ath79_register_wmac(art + WZR_450HP2_WMAC_CALDATA_OFFSET, mac_lan);
  28428. +
  28429. + mdiobus_register_board_info(wzr_450hp2_mdio0_info,
  28430. + ARRAY_SIZE(wzr_450hp2_mdio0_info));
  28431. + ath79_register_mdio(0, 0x0);
  28432. +
  28433. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  28434. +
  28435. + /* GMAC0 is connected to the RMGII interface */
  28436. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  28437. + ath79_eth0_data.phy_mask = BIT(0);
  28438. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  28439. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  28440. +
  28441. + ath79_init_mac(ath79_eth0_data.mac_addr, mac_wan, 0);
  28442. + ath79_register_eth(0);
  28443. +
  28444. + /* GMAC1 is connected to the SGMII interface */
  28445. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  28446. + ath79_eth1_data.speed = SPEED_1000;
  28447. + ath79_eth1_data.duplex = DUPLEX_FULL;
  28448. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  28449. +
  28450. + ath79_init_mac(ath79_eth1_data.mac_addr, mac_lan, 0);
  28451. + ath79_register_eth(1);
  28452. +
  28453. + ath79_register_usb();
  28454. +}
  28455. +
  28456. +MIPS_MACHINE(ATH79_MACH_WZR_450HP2, "WZR-450HP2",
  28457. + "Buffalo WZR-450HP2", wzr_450hp2_setup);
  28458. +
  28459. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-ag300h.c linux-4.1.13/arch/mips/ath79/mach-wzr-hp-ag300h.c
  28460. --- linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-ag300h.c 1970-01-01 01:00:00.000000000 +0100
  28461. +++ linux-4.1.13/arch/mips/ath79/mach-wzr-hp-ag300h.c 2015-09-13 20:04:35.072523889 +0200
  28462. @@ -0,0 +1,205 @@
  28463. +/*
  28464. + * Buffalo WZR-HP-AG300H board support
  28465. + *
  28466. + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
  28467. + *
  28468. + * This program is free software; you can redistribute it and/or modify it
  28469. + * under the terms of the GNU General Public License version 2 as published
  28470. + * by the Free Software Foundation.
  28471. + */
  28472. +
  28473. +#include <linux/gpio.h>
  28474. +#include <linux/mtd/mtd.h>
  28475. +#include <linux/mtd/partitions.h>
  28476. +
  28477. +#include <asm/mach-ath79/ath79.h>
  28478. +
  28479. +#include "dev-eth.h"
  28480. +#include "dev-ap9x-pci.h"
  28481. +#include "dev-gpio-buttons.h"
  28482. +#include "dev-leds-gpio.h"
  28483. +#include "dev-m25p80.h"
  28484. +#include "dev-usb.h"
  28485. +#include "machtypes.h"
  28486. +
  28487. +#define WZRHPAG300H_MAC_OFFSET 0x20c
  28488. +#define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */
  28489. +#define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL)
  28490. +
  28491. +static struct mtd_partition wzrhpag300h_flash_partitions[] = {
  28492. + {
  28493. + .name = "u-boot",
  28494. + .offset = 0,
  28495. + .size = 0x0040000,
  28496. + .mask_flags = MTD_WRITEABLE,
  28497. + }, {
  28498. + .name = "u-boot-env",
  28499. + .offset = 0x0040000,
  28500. + .size = 0x0010000,
  28501. + .mask_flags = MTD_WRITEABLE,
  28502. + }, {
  28503. + .name = "art",
  28504. + .offset = 0x0050000,
  28505. + .size = 0x0010000,
  28506. + .mask_flags = MTD_WRITEABLE,
  28507. + }, {
  28508. + .name = "firmware",
  28509. + .offset = 0x0060000,
  28510. + .size = 0x1f90000,
  28511. + }, {
  28512. + .name = "user_property",
  28513. + .offset = 0x1ff0000,
  28514. + .size = 0x0010000,
  28515. + .mask_flags = MTD_WRITEABLE,
  28516. + }
  28517. +};
  28518. +
  28519. +static struct flash_platform_data wzrhpag300h_flash_data = {
  28520. + .parts = wzrhpag300h_flash_partitions,
  28521. + .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions),
  28522. +};
  28523. +
  28524. +static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
  28525. + {
  28526. + .name = "buffalo:red:diag",
  28527. + .gpio = 1,
  28528. + .active_low = 1,
  28529. + },
  28530. +};
  28531. +
  28532. +static struct gpio_led wzrhpag300h_wmac0_leds_gpio[] = {
  28533. + {
  28534. + .name = "buffalo:amber:band2g",
  28535. + .gpio = 1,
  28536. + .active_low = 1,
  28537. + },
  28538. + {
  28539. + .name = "buffalo:green:usb",
  28540. + .gpio = 3,
  28541. + .active_low = 1,
  28542. + },
  28543. + {
  28544. + .name = "buffalo:green:band2g",
  28545. + .gpio = 5,
  28546. + .active_low = 1,
  28547. + },
  28548. +};
  28549. +
  28550. +static struct gpio_led wzrhpag300h_wmac1_leds_gpio[] = {
  28551. + {
  28552. + .name = "buffalo:green:band5g",
  28553. + .gpio = 1,
  28554. + .active_low = 1,
  28555. + },
  28556. + {
  28557. + .name = "buffalo:green:router",
  28558. + .gpio = 3,
  28559. + .active_low = 1,
  28560. + },
  28561. + {
  28562. + .name = "buffalo:blue:movie_engine",
  28563. + .gpio = 4,
  28564. + .active_low = 1,
  28565. + },
  28566. + {
  28567. + .name = "buffalo:amber:band5g",
  28568. + .gpio = 5,
  28569. + .active_low = 1,
  28570. + },
  28571. +};
  28572. +
  28573. +static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = {
  28574. + {
  28575. + .desc = "reset",
  28576. + .type = EV_KEY,
  28577. + .code = KEY_RESTART,
  28578. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28579. + .gpio = 11,
  28580. + .active_low = 1,
  28581. + }, {
  28582. + .desc = "usb",
  28583. + .type = EV_KEY,
  28584. + .code = BTN_2,
  28585. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28586. + .gpio = 3,
  28587. + .active_low = 1,
  28588. + }, {
  28589. + .desc = "aoss",
  28590. + .type = EV_KEY,
  28591. + .code = KEY_WPS_BUTTON,
  28592. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28593. + .gpio = 5,
  28594. + .active_low = 1,
  28595. + }, {
  28596. + .desc = "router_auto",
  28597. + .type = EV_SW,
  28598. + .code = BTN_6,
  28599. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28600. + .gpio = 6,
  28601. + .active_low = 1,
  28602. + }, {
  28603. + .desc = "router_off",
  28604. + .type = EV_SW,
  28605. + .code = BTN_5,
  28606. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28607. + .gpio = 7,
  28608. + .active_low = 1,
  28609. + }, {
  28610. + .desc = "movie_engine",
  28611. + .type = EV_SW,
  28612. + .code = BTN_7,
  28613. + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
  28614. + .gpio = 8,
  28615. + .active_low = 1,
  28616. + }
  28617. +};
  28618. +
  28619. +static void __init wzrhpag300h_setup(void)
  28620. +{
  28621. + u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000);
  28622. + u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000);
  28623. + u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET;
  28624. + u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET;
  28625. +
  28626. + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  28627. + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1);
  28628. +
  28629. + ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
  28630. +
  28631. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  28632. + ath79_eth0_data.speed = SPEED_1000;
  28633. + ath79_eth0_data.duplex = DUPLEX_FULL;
  28634. + ath79_eth0_data.phy_mask = BIT(0);
  28635. +
  28636. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  28637. + ath79_eth1_data.phy_mask = BIT(4);
  28638. +
  28639. + ath79_register_eth(0);
  28640. + ath79_register_eth(1);
  28641. +
  28642. + gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  28643. + "USB power");
  28644. + ath79_register_usb();
  28645. +
  28646. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
  28647. + wzrhpag300h_leds_gpio);
  28648. +
  28649. + ath79_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL,
  28650. + ARRAY_SIZE(wzrhpag300h_gpio_keys),
  28651. + wzrhpag300h_gpio_keys);
  28652. +
  28653. + ath79_register_m25p80_multi(&wzrhpag300h_flash_data);
  28654. +
  28655. + ap94_pci_init(eeprom1, mac1, eeprom2, mac2);
  28656. +
  28657. + ap9x_pci_setup_wmac_led_pin(0, 1);
  28658. + ap9x_pci_setup_wmac_led_pin(1, 5);
  28659. +
  28660. + ap9x_pci_setup_wmac_leds(0, wzrhpag300h_wmac0_leds_gpio,
  28661. + ARRAY_SIZE(wzrhpag300h_wmac0_leds_gpio));
  28662. + ap9x_pci_setup_wmac_leds(1, wzrhpag300h_wmac1_leds_gpio,
  28663. + ARRAY_SIZE(wzrhpag300h_wmac1_leds_gpio));
  28664. +}
  28665. +
  28666. +MIPS_MACHINE(ATH79_MACH_WZR_HP_AG300H, "WZR-HP-AG300H",
  28667. + "Buffalo WZR-HP-AG300H/WZR-600DHP", wzrhpag300h_setup);
  28668. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g300nh2.c linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g300nh2.c
  28669. --- linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g300nh2.c 1970-01-01 01:00:00.000000000 +0100
  28670. +++ linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g300nh2.c 2015-09-13 20:04:35.072523889 +0200
  28671. @@ -0,0 +1,170 @@
  28672. +/*
  28673. + * Buffalo WZR-HP-G300NH2 board support
  28674. + *
  28675. + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
  28676. + * Copyright (C) 2011 Mark Deneen <mdeneen@gmail.com>
  28677. + *
  28678. + * This program is free software; you can redistribute it and/or modify it
  28679. + * under the terms of the GNU General Public License version 2 as published
  28680. + * by the Free Software Foundation.
  28681. + */
  28682. +
  28683. +#include <linux/gpio.h>
  28684. +#include <linux/mtd/mtd.h>
  28685. +#include <linux/mtd/partitions.h>
  28686. +
  28687. +#include <asm/mach-ath79/ath79.h>
  28688. +
  28689. +#include "dev-ap9x-pci.h"
  28690. +#include "dev-eth.h"
  28691. +#include "dev-gpio-buttons.h"
  28692. +#include "dev-leds-gpio.h"
  28693. +#include "dev-m25p80.h"
  28694. +#include "dev-usb.h"
  28695. +#include "machtypes.h"
  28696. +
  28697. +#define WZRHPG300NH2_MAC_OFFSET 0x20c
  28698. +#define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
  28699. +#define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
  28700. +
  28701. +static struct mtd_partition wzrhpg300nh2_flash_partitions[] = {
  28702. + {
  28703. + .name = "u-boot",
  28704. + .offset = 0,
  28705. + .size = 0x0040000,
  28706. + .mask_flags = MTD_WRITEABLE,
  28707. + }, {
  28708. + .name = "u-boot-env",
  28709. + .offset = 0x0040000,
  28710. + .size = 0x0010000,
  28711. + .mask_flags = MTD_WRITEABLE,
  28712. + }, {
  28713. + .name = "art",
  28714. + .offset = 0x0050000,
  28715. + .size = 0x0010000,
  28716. + .mask_flags = MTD_WRITEABLE,
  28717. + }, {
  28718. + .name = "firmware",
  28719. + .offset = 0x0060000,
  28720. + .size = 0x1f90000,
  28721. + }, {
  28722. + .name = "user_property",
  28723. + .offset = 0x1ff0000,
  28724. + .size = 0x0010000,
  28725. + .mask_flags = MTD_WRITEABLE,
  28726. + }
  28727. +};
  28728. +
  28729. +static struct flash_platform_data wzrhpg300nh2_flash_data = {
  28730. + .parts = wzrhpg300nh2_flash_partitions,
  28731. + .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions),
  28732. +};
  28733. +
  28734. +static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = {
  28735. + {
  28736. + .name = "buffalo:red:diag",
  28737. + .gpio = 16,
  28738. + .active_low = 1,
  28739. + },
  28740. +};
  28741. +
  28742. +static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = {
  28743. + {
  28744. + .name = "buffalo:blue:usb",
  28745. + .gpio = 4,
  28746. + .active_low = 1,
  28747. + },
  28748. + {
  28749. + .name = "buffalo:orange:security",
  28750. + .gpio = 6,
  28751. + .active_low = 1,
  28752. + },
  28753. + {
  28754. + .name = "buffalo:green:router",
  28755. + .gpio = 7,
  28756. + .active_low = 1,
  28757. + },
  28758. + {
  28759. + .name = "buffalo:blue:movie_engine_on",
  28760. + .gpio = 8,
  28761. + .active_low = 1,
  28762. + },
  28763. + {
  28764. + .name = "buffalo:blue:movie_engine_off",
  28765. + .gpio = 9,
  28766. + .active_low = 1,
  28767. + },
  28768. +};
  28769. +
  28770. +/* The AOSS button is wmac gpio 12 */
  28771. +static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = {
  28772. + {
  28773. + .desc = "reset",
  28774. + .type = EV_KEY,
  28775. + .code = KEY_RESTART,
  28776. + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  28777. + .gpio = 1,
  28778. + .active_low = 1,
  28779. + }, {
  28780. + .desc = "usb",
  28781. + .type = EV_KEY,
  28782. + .code = BTN_2,
  28783. + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  28784. + .gpio = 7,
  28785. + .active_low = 1,
  28786. + }, {
  28787. + .desc = "qos",
  28788. + .type = EV_KEY,
  28789. + .code = BTN_3,
  28790. + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  28791. + .gpio = 11,
  28792. + .active_low = 0,
  28793. + }, {
  28794. + .desc = "router_on",
  28795. + .type = EV_KEY,
  28796. + .code = BTN_5,
  28797. + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  28798. + .gpio = 8,
  28799. + .active_low = 0,
  28800. + },
  28801. +};
  28802. +
  28803. +static void __init wzrhpg300nh2_setup(void)
  28804. +{
  28805. +
  28806. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000);
  28807. + u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET;
  28808. + /* There is an eth1 but it is not connected to the switch */
  28809. +
  28810. + ath79_register_m25p80_multi(&wzrhpg300nh2_flash_data);
  28811. +
  28812. + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  28813. + ath79_register_mdio(0, ~(BIT(0)));
  28814. +
  28815. + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  28816. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  28817. + ath79_eth0_data.speed = SPEED_1000;
  28818. + ath79_eth0_data.duplex = DUPLEX_FULL;
  28819. + ath79_eth0_data.phy_mask = BIT(0);
  28820. +
  28821. + ath79_register_eth(0);
  28822. +
  28823. + /* gpio13 is usb power. Turn it on. */
  28824. + gpio_request_one(13, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  28825. + "USB power");
  28826. + ath79_register_usb();
  28827. +
  28828. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
  28829. + wzrhpg300nh2_leds_gpio);
  28830. + ath79_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL,
  28831. + ARRAY_SIZE(wzrhpg300nh2_gpio_keys),
  28832. + wzrhpg300nh2_gpio_keys);
  28833. + ap9x_pci_setup_wmac_led_pin(0, 5);
  28834. + ap9x_pci_setup_wmac_leds(0, wzrhpg300nh2_wmac_leds_gpio,
  28835. + ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio));
  28836. +
  28837. + ap91_pci_init(eeprom, mac0);
  28838. +}
  28839. +
  28840. +MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH2, "WZR-HP-G300NH2",
  28841. + "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup);
  28842. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g300nh.c linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g300nh.c
  28843. --- linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g300nh.c 1970-01-01 01:00:00.000000000 +0100
  28844. +++ linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g300nh.c 2015-09-13 20:04:35.072523889 +0200
  28845. @@ -0,0 +1,279 @@
  28846. +/*
  28847. + * Buffalo WZR-HP-G300NH board support
  28848. + *
  28849. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  28850. + *
  28851. + * This program is free software; you can redistribute it and/or modify it
  28852. + * under the terms of the GNU General Public License version 2 as published
  28853. + * by the Free Software Foundation.
  28854. + */
  28855. +
  28856. +#include <linux/platform_device.h>
  28857. +#include <linux/mtd/mtd.h>
  28858. +#include <linux/mtd/partitions.h>
  28859. +#include <linux/mtd/physmap.h>
  28860. +#include <linux/nxp_74hc153.h>
  28861. +#include <linux/rtl8366.h>
  28862. +
  28863. +#include <asm/mach-ath79/ath79.h>
  28864. +
  28865. +#include "dev-eth.h"
  28866. +#include "dev-gpio-buttons.h"
  28867. +#include "dev-leds-gpio.h"
  28868. +#include "dev-usb.h"
  28869. +#include "dev-wmac.h"
  28870. +#include "machtypes.h"
  28871. +
  28872. +#define WZRHPG300NH_GPIO_LED_USB 0
  28873. +#define WZRHPG300NH_GPIO_LED_DIAG 1
  28874. +#define WZRHPG300NH_GPIO_LED_WIRELESS 6
  28875. +#define WZRHPG300NH_GPIO_LED_SECURITY 17
  28876. +#define WZRHPG300NH_GPIO_LED_ROUTER 18
  28877. +
  28878. +#define WZRHPG300NH_GPIO_RTL8366_SDA 19
  28879. +#define WZRHPG300NH_GPIO_RTL8366_SCK 20
  28880. +
  28881. +#define WZRHPG300NH_GPIO_74HC153_S0 9
  28882. +#define WZRHPG300NH_GPIO_74HC153_S1 11
  28883. +#define WZRHPG300NH_GPIO_74HC153_1Y 12
  28884. +#define WZRHPG300NH_GPIO_74HC153_2Y 14
  28885. +
  28886. +#define WZRHPG300NH_GPIO_EXP_BASE 32
  28887. +#define WZRHPG300NH_GPIO_BTN_AOSS (WZRHPG300NH_GPIO_EXP_BASE + 0)
  28888. +#define WZRHPG300NH_GPIO_BTN_RESET (WZRHPG300NH_GPIO_EXP_BASE + 1)
  28889. +#define WZRHPG300NH_GPIO_BTN_ROUTER_ON (WZRHPG300NH_GPIO_EXP_BASE + 2)
  28890. +#define WZRHPG300NH_GPIO_BTN_QOS_ON (WZRHPG300NH_GPIO_EXP_BASE + 3)
  28891. +#define WZRHPG300NH_GPIO_BTN_USB (WZRHPG300NH_GPIO_EXP_BASE + 5)
  28892. +#define WZRHPG300NH_GPIO_BTN_ROUTER_AUTO (WZRHPG300NH_GPIO_EXP_BASE + 6)
  28893. +#define WZRHPG300NH_GPIO_BTN_QOS_OFF (WZRHPG300NH_GPIO_EXP_BASE + 7)
  28894. +
  28895. +#define WZRHPG300NH_KEYS_POLL_INTERVAL 20 /* msecs */
  28896. +#define WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH_KEYS_POLL_INTERVAL)
  28897. +
  28898. +#define WZRHPG300NH_MAC_OFFSET 0x20c
  28899. +
  28900. +static struct mtd_partition wzrhpg300nh_flash_partitions[] = {
  28901. + {
  28902. + .name = "u-boot",
  28903. + .offset = 0,
  28904. + .size = 0x0040000,
  28905. + .mask_flags = MTD_WRITEABLE,
  28906. + }, {
  28907. + .name = "u-boot-env",
  28908. + .offset = 0x0040000,
  28909. + .size = 0x0020000,
  28910. + .mask_flags = MTD_WRITEABLE,
  28911. + }, {
  28912. + .name = "firmware",
  28913. + .offset = 0x0060000,
  28914. + .size = 0x1f60000,
  28915. + }, {
  28916. + .name = "user_property",
  28917. + .offset = 0x1fc0000,
  28918. + .size = 0x0020000,
  28919. + .mask_flags = MTD_WRITEABLE,
  28920. + }, {
  28921. + .name = "art",
  28922. + .offset = 0x1fe0000,
  28923. + .size = 0x0020000,
  28924. + .mask_flags = MTD_WRITEABLE,
  28925. + }
  28926. +};
  28927. +
  28928. +static struct physmap_flash_data wzrhpg300nh_flash_data = {
  28929. + .width = 2,
  28930. + .parts = wzrhpg300nh_flash_partitions,
  28931. + .nr_parts = ARRAY_SIZE(wzrhpg300nh_flash_partitions),
  28932. +};
  28933. +
  28934. +#define WZRHPG300NH_FLASH_BASE 0x1e000000
  28935. +#define WZRHPG300NH_FLASH_SIZE (32 * 1024 * 1024)
  28936. +
  28937. +static struct resource wzrhpg300nh_flash_resources[] = {
  28938. + [0] = {
  28939. + .start = WZRHPG300NH_FLASH_BASE,
  28940. + .end = WZRHPG300NH_FLASH_BASE + WZRHPG300NH_FLASH_SIZE - 1,
  28941. + .flags = IORESOURCE_MEM,
  28942. + },
  28943. +};
  28944. +
  28945. +static struct platform_device wzrhpg300nh_flash_device = {
  28946. + .name = "physmap-flash",
  28947. + .id = -1,
  28948. + .resource = wzrhpg300nh_flash_resources,
  28949. + .num_resources = ARRAY_SIZE(wzrhpg300nh_flash_resources),
  28950. + .dev = {
  28951. + .platform_data = &wzrhpg300nh_flash_data,
  28952. + }
  28953. +};
  28954. +
  28955. +static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = {
  28956. + {
  28957. + .name = "buffalo:orange:security",
  28958. + .gpio = WZRHPG300NH_GPIO_LED_SECURITY,
  28959. + .active_low = 1,
  28960. + }, {
  28961. + .name = "buffalo:green:wireless",
  28962. + .gpio = WZRHPG300NH_GPIO_LED_WIRELESS,
  28963. + .active_low = 1,
  28964. + }, {
  28965. + .name = "buffalo:green:router",
  28966. + .gpio = WZRHPG300NH_GPIO_LED_ROUTER,
  28967. + .active_low = 1,
  28968. + }, {
  28969. + .name = "buffalo:red:diag",
  28970. + .gpio = WZRHPG300NH_GPIO_LED_DIAG,
  28971. + .active_low = 1,
  28972. + }, {
  28973. + .name = "buffalo:blue:usb",
  28974. + .gpio = WZRHPG300NH_GPIO_LED_USB,
  28975. + .active_low = 1,
  28976. + }
  28977. +};
  28978. +
  28979. +static struct gpio_keys_button wzrhpg300nh_gpio_keys[] __initdata = {
  28980. + {
  28981. + .desc = "reset",
  28982. + .type = EV_KEY,
  28983. + .code = KEY_RESTART,
  28984. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  28985. + .gpio = WZRHPG300NH_GPIO_BTN_RESET,
  28986. + .active_low = 1,
  28987. + }, {
  28988. + .desc = "aoss",
  28989. + .type = EV_KEY,
  28990. + .code = KEY_WPS_BUTTON,
  28991. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  28992. + .gpio = WZRHPG300NH_GPIO_BTN_AOSS,
  28993. + .active_low = 1,
  28994. + }, {
  28995. + .desc = "usb",
  28996. + .type = EV_KEY,
  28997. + .code = BTN_2,
  28998. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  28999. + .gpio = WZRHPG300NH_GPIO_BTN_USB,
  29000. + .active_low = 1,
  29001. + }, {
  29002. + .desc = "qos_on",
  29003. + .type = EV_KEY,
  29004. + .code = BTN_3,
  29005. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  29006. + .gpio = WZRHPG300NH_GPIO_BTN_QOS_ON,
  29007. + .active_low = 0,
  29008. + }, {
  29009. + .desc = "qos_off",
  29010. + .type = EV_KEY,
  29011. + .code = BTN_4,
  29012. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  29013. + .gpio = WZRHPG300NH_GPIO_BTN_QOS_OFF,
  29014. + .active_low = 0,
  29015. + }, {
  29016. + .desc = "router_on",
  29017. + .type = EV_KEY,
  29018. + .code = BTN_5,
  29019. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  29020. + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_ON,
  29021. + .active_low = 0,
  29022. + }, {
  29023. + .desc = "router_auto",
  29024. + .type = EV_KEY,
  29025. + .code = BTN_6,
  29026. + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
  29027. + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_AUTO,
  29028. + .active_low = 0,
  29029. + }
  29030. +};
  29031. +
  29032. +static struct nxp_74hc153_platform_data wzrhpg300nh_74hc153_data = {
  29033. + .gpio_base = WZRHPG300NH_GPIO_EXP_BASE,
  29034. + .gpio_pin_s0 = WZRHPG300NH_GPIO_74HC153_S0,
  29035. + .gpio_pin_s1 = WZRHPG300NH_GPIO_74HC153_S1,
  29036. + .gpio_pin_1y = WZRHPG300NH_GPIO_74HC153_1Y,
  29037. + .gpio_pin_2y = WZRHPG300NH_GPIO_74HC153_2Y,
  29038. +};
  29039. +
  29040. +static struct platform_device wzrhpg300nh_74hc153_device = {
  29041. + .name = NXP_74HC153_DRIVER_NAME,
  29042. + .id = -1,
  29043. + .dev = {
  29044. + .platform_data = &wzrhpg300nh_74hc153_data,
  29045. + }
  29046. +};
  29047. +
  29048. +static struct rtl8366_platform_data wzrhpg300nh_rtl8366_data = {
  29049. + .gpio_sda = WZRHPG300NH_GPIO_RTL8366_SDA,
  29050. + .gpio_sck = WZRHPG300NH_GPIO_RTL8366_SCK,
  29051. +};
  29052. +
  29053. +static struct platform_device wzrhpg300nh_rtl8366s_device = {
  29054. + .name = RTL8366S_DRIVER_NAME,
  29055. + .id = -1,
  29056. + .dev = {
  29057. + .platform_data = &wzrhpg300nh_rtl8366_data,
  29058. + }
  29059. +};
  29060. +
  29061. +static struct platform_device wzrhpg300nh_rtl8366rb_device = {
  29062. + .name = RTL8366RB_DRIVER_NAME,
  29063. + .id = -1,
  29064. + .dev = {
  29065. + .platform_data = &wzrhpg300nh_rtl8366_data,
  29066. + }
  29067. +};
  29068. +
  29069. +static void __init wzrhpg300nh_setup(void)
  29070. +{
  29071. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  29072. + u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET;
  29073. + bool hasrtl8366rb = false;
  29074. +
  29075. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  29076. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  29077. +
  29078. + if (rtl8366_smi_detect(&wzrhpg300nh_rtl8366_data) == RTL8366_TYPE_RB)
  29079. + hasrtl8366rb = true;
  29080. +
  29081. + if (hasrtl8366rb) {
  29082. + ath79_eth0_pll_data.pll_1000 = 0x1f000000;
  29083. + ath79_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
  29084. + ath79_eth1_pll_data.pll_1000 = 0x100;
  29085. + ath79_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
  29086. + } else {
  29087. + ath79_eth0_pll_data.pll_1000 = 0x1e000100;
  29088. + ath79_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
  29089. + ath79_eth1_pll_data.pll_1000 = 0x1e000100;
  29090. + ath79_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
  29091. + }
  29092. +
  29093. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  29094. + ath79_eth0_data.speed = SPEED_1000;
  29095. + ath79_eth0_data.duplex = DUPLEX_FULL;
  29096. +
  29097. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  29098. + ath79_eth1_data.phy_mask = 0x10;
  29099. +
  29100. + ath79_register_eth(0);
  29101. + ath79_register_eth(1);
  29102. +
  29103. + ath79_register_usb();
  29104. + ath79_register_wmac(eeprom, NULL);
  29105. +
  29106. + platform_device_register(&wzrhpg300nh_74hc153_device);
  29107. + platform_device_register(&wzrhpg300nh_flash_device);
  29108. +
  29109. + if (hasrtl8366rb)
  29110. + platform_device_register(&wzrhpg300nh_rtl8366rb_device);
  29111. + else
  29112. + platform_device_register(&wzrhpg300nh_rtl8366s_device);
  29113. +
  29114. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh_leds_gpio),
  29115. + wzrhpg300nh_leds_gpio);
  29116. +
  29117. + ath79_register_gpio_keys_polled(-1, WZRHPG300NH_KEYS_POLL_INTERVAL,
  29118. + ARRAY_SIZE(wzrhpg300nh_gpio_keys),
  29119. + wzrhpg300nh_gpio_keys);
  29120. +
  29121. +}
  29122. +
  29123. +MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH, "WZR-HP-G300NH",
  29124. + "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup);
  29125. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g450h.c linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g450h.c
  29126. --- linux-4.1.13.orig/arch/mips/ath79/mach-wzr-hp-g450h.c 1970-01-01 01:00:00.000000000 +0100
  29127. +++ linux-4.1.13/arch/mips/ath79/mach-wzr-hp-g450h.c 2015-09-13 20:04:35.072523889 +0200
  29128. @@ -0,0 +1,165 @@
  29129. +/*
  29130. + * Buffalo WZR-HP-G450G board support
  29131. + *
  29132. + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
  29133. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  29134. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  29135. + *
  29136. + * This program is free software; you can redistribute it and/or modify it
  29137. + * under the terms of the GNU General Public License version 2 as published
  29138. + * by the Free Software Foundation.
  29139. + */
  29140. +
  29141. +#include <linux/gpio.h>
  29142. +#include <linux/mtd/mtd.h>
  29143. +#include <linux/mtd/partitions.h>
  29144. +#include <linux/ath9k_platform.h>
  29145. +
  29146. +#include <asm/mach-ath79/ath79.h>
  29147. +
  29148. +#include "dev-eth.h"
  29149. +#include "dev-m25p80.h"
  29150. +#include "dev-ap9x-pci.h"
  29151. +#include "dev-gpio-buttons.h"
  29152. +#include "dev-leds-gpio.h"
  29153. +#include "dev-usb.h"
  29154. +#include "machtypes.h"
  29155. +
  29156. +#define WZRHPG450H_KEYS_POLL_INTERVAL 20 /* msecs */
  29157. +#define WZRHPG450H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG450H_KEYS_POLL_INTERVAL)
  29158. +
  29159. +static struct mtd_partition wzrhpg450h_partitions[] = {
  29160. + {
  29161. + .name = "u-boot",
  29162. + .offset = 0,
  29163. + .size = 0x0040000,
  29164. + .mask_flags = MTD_WRITEABLE,
  29165. + }, {
  29166. + .name = "u-boot-env",
  29167. + .offset = 0x0040000,
  29168. + .size = 0x0010000,
  29169. + }, {
  29170. + .name = "ART",
  29171. + .offset = 0x0050000,
  29172. + .size = 0x0010000,
  29173. + .mask_flags = MTD_WRITEABLE,
  29174. + }, {
  29175. + .name = "firmware",
  29176. + .offset = 0x0060000,
  29177. + .size = 0x1f80000,
  29178. + }, {
  29179. + .name = "user_property",
  29180. + .offset = 0x1fe0000,
  29181. + .size = 0x0020000,
  29182. + }
  29183. +};
  29184. +
  29185. +static struct flash_platform_data wzrhpg450h_flash_data = {
  29186. + .parts = wzrhpg450h_partitions,
  29187. + .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
  29188. +};
  29189. +
  29190. +static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
  29191. + {
  29192. + .name = "buffalo:red:diag",
  29193. + .gpio = 14,
  29194. + .active_low = 1,
  29195. + },
  29196. + {
  29197. + .name = "buffalo:orange:security",
  29198. + .gpio = 13,
  29199. + .active_low = 1,
  29200. + },
  29201. +};
  29202. +
  29203. +
  29204. +static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
  29205. + {
  29206. + .name = "buffalo:blue:movie_engine",
  29207. + .gpio = 13,
  29208. + .active_low = 1,
  29209. + },
  29210. + {
  29211. + .name = "buffalo:green:router",
  29212. + .gpio = 14,
  29213. + .active_low = 1,
  29214. + },
  29215. +};
  29216. +
  29217. +static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
  29218. + {
  29219. + .desc = "reset",
  29220. + .type = EV_KEY,
  29221. + .code = KEY_RESTART,
  29222. + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  29223. + .gpio = 6,
  29224. + .active_low = 1,
  29225. + }, {
  29226. + .desc = "usb",
  29227. + .type = EV_KEY,
  29228. + .code = BTN_2,
  29229. + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  29230. + .gpio = 1,
  29231. + .active_low = 1,
  29232. + }, {
  29233. + .desc = "aoss",
  29234. + .type = EV_KEY,
  29235. + .code = KEY_WPS_BUTTON,
  29236. + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  29237. + .gpio = 8,
  29238. + .active_low = 1,
  29239. + }, {
  29240. + .desc = "movie_engine",
  29241. + .type = EV_KEY,
  29242. + .code = BTN_6,
  29243. + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  29244. + .gpio = 7,
  29245. + .active_low = 0,
  29246. + }, {
  29247. + .desc = "router_off",
  29248. + .type = EV_KEY,
  29249. + .code = BTN_5,
  29250. + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  29251. + .gpio = 12,
  29252. + .active_low = 0,
  29253. + }
  29254. +};
  29255. +
  29256. +
  29257. +static void __init wzrhpg450h_init(void)
  29258. +{
  29259. + u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
  29260. + u8 *mac = (u8 *) ee + 2;
  29261. +
  29262. + ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
  29263. +
  29264. + ath79_register_mdio(0, ~BIT(0));
  29265. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  29266. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  29267. + ath79_eth0_data.speed = SPEED_1000;
  29268. + ath79_eth0_data.duplex = DUPLEX_FULL;
  29269. + ath79_eth0_data.phy_mask = BIT(0);
  29270. +
  29271. + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
  29272. + wzrhpg450h_leds_gpio);
  29273. +
  29274. + ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
  29275. + ARRAY_SIZE(wzrhpg450h_gpio_keys),
  29276. + wzrhpg450h_gpio_keys);
  29277. +
  29278. + ath79_register_eth(0);
  29279. +
  29280. + gpio_request_one(16, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  29281. + "USB power");
  29282. + ath79_register_usb();
  29283. +
  29284. + ap91_pci_init(ee, NULL);
  29285. + ap9x_pci_get_wmac_data(0)->tx_gain_buffalo = true;
  29286. + ap9x_pci_get_wmac_data(1)->tx_gain_buffalo = true;
  29287. + ap9x_pci_setup_wmac_led_pin(0, 15);
  29288. + ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
  29289. + ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
  29290. +}
  29291. +
  29292. +MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
  29293. + wzrhpg450h_init);
  29294. diff -Nur linux-4.1.13.orig/arch/mips/ath79/mach-zcn-1523h.c linux-4.1.13/arch/mips/ath79/mach-zcn-1523h.c
  29295. --- linux-4.1.13.orig/arch/mips/ath79/mach-zcn-1523h.c 1970-01-01 01:00:00.000000000 +0100
  29296. +++ linux-4.1.13/arch/mips/ath79/mach-zcn-1523h.c 2015-09-13 20:04:35.072523889 +0200
  29297. @@ -0,0 +1,154 @@
  29298. +/*
  29299. + * Zcomax ZCN-1523H-2-8/5-16 board support
  29300. + *
  29301. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  29302. + *
  29303. + * This program is free software; you can redistribute it and/or modify it
  29304. + * under the terms of the GNU General Public License version 2 as published
  29305. + * by the Free Software Foundation.
  29306. + */
  29307. +
  29308. +#include <asm/mach-ath79/ath79.h>
  29309. +#include <asm/mach-ath79/ar71xx_regs.h>
  29310. +
  29311. +#include "common.h"
  29312. +#include "dev-eth.h"
  29313. +#include "dev-m25p80.h"
  29314. +#include "dev-ap9x-pci.h"
  29315. +#include "dev-gpio-buttons.h"
  29316. +#include "dev-leds-gpio.h"
  29317. +#include "machtypes.h"
  29318. +
  29319. +#define ZCN_1523H_GPIO_BTN_RESET 0
  29320. +#define ZCN_1523H_GPIO_LED_INIT 11
  29321. +#define ZCN_1523H_GPIO_LED_LAN1 17
  29322. +
  29323. +#define ZCN_1523H_2_GPIO_LED_WEAK 13
  29324. +#define ZCN_1523H_2_GPIO_LED_MEDIUM 14
  29325. +#define ZCN_1523H_2_GPIO_LED_STRONG 15
  29326. +
  29327. +#define ZCN_1523H_5_GPIO_LAN2_POWER 1
  29328. +#define ZCN_1523H_5_GPIO_LED_LAN2 13
  29329. +#define ZCN_1523H_5_GPIO_LED_WEAK 14
  29330. +#define ZCN_1523H_5_GPIO_LED_MEDIUM 15
  29331. +#define ZCN_1523H_5_GPIO_LED_STRONG 16
  29332. +
  29333. +#define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */
  29334. +#define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL)
  29335. +
  29336. +static struct gpio_keys_button zcn_1523h_gpio_keys[] __initdata = {
  29337. + {
  29338. + .desc = "reset",
  29339. + .type = EV_KEY,
  29340. + .code = KEY_RESTART,
  29341. + .debounce_interval = ZCN_1523H_KEYS_DEBOUNCE_INTERVAL,
  29342. + .gpio = ZCN_1523H_GPIO_BTN_RESET,
  29343. + .active_low = 1,
  29344. + }
  29345. +};
  29346. +
  29347. +static struct gpio_led zcn_1523h_leds_gpio[] __initdata = {
  29348. + {
  29349. + .name = "zcn-1523h:amber:init",
  29350. + .gpio = ZCN_1523H_GPIO_LED_INIT,
  29351. + .active_low = 1,
  29352. + }, {
  29353. + .name = "zcn-1523h:green:lan1",
  29354. + .gpio = ZCN_1523H_GPIO_LED_LAN1,
  29355. + .active_low = 1,
  29356. + }
  29357. +};
  29358. +
  29359. +static struct gpio_led zcn_1523h_2_leds_gpio[] __initdata = {
  29360. + {
  29361. + .name = "zcn-1523h:red:weak",
  29362. + .gpio = ZCN_1523H_2_GPIO_LED_WEAK,
  29363. + .active_low = 1,
  29364. + }, {
  29365. + .name = "zcn-1523h:amber:medium",
  29366. + .gpio = ZCN_1523H_2_GPIO_LED_MEDIUM,
  29367. + .active_low = 1,
  29368. + }, {
  29369. + .name = "zcn-1523h:green:strong",
  29370. + .gpio = ZCN_1523H_2_GPIO_LED_STRONG,
  29371. + .active_low = 1,
  29372. + }
  29373. +};
  29374. +
  29375. +static struct gpio_led zcn_1523h_5_leds_gpio[] __initdata = {
  29376. + {
  29377. + .name = "zcn-1523h:red:weak",
  29378. + .gpio = ZCN_1523H_5_GPIO_LED_WEAK,
  29379. + .active_low = 1,
  29380. + }, {
  29381. + .name = "zcn-1523h:amber:medium",
  29382. + .gpio = ZCN_1523H_5_GPIO_LED_MEDIUM,
  29383. + .active_low = 1,
  29384. + }, {
  29385. + .name = "zcn-1523h:green:strong",
  29386. + .gpio = ZCN_1523H_5_GPIO_LED_STRONG,
  29387. + .active_low = 1,
  29388. + }, {
  29389. + .name = "zcn-1523h:green:lan2",
  29390. + .gpio = ZCN_1523H_5_GPIO_LED_LAN2,
  29391. + .active_low = 1,
  29392. + }
  29393. +};
  29394. +
  29395. +static void __init zcn_1523h_generic_setup(void)
  29396. +{
  29397. + u8 *mac = (u8 *) KSEG1ADDR(0x1f7e0004);
  29398. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  29399. +
  29400. + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  29401. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  29402. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  29403. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  29404. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  29405. +
  29406. + ath79_register_m25p80(NULL);
  29407. +
  29408. + ath79_register_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio),
  29409. + zcn_1523h_leds_gpio);
  29410. +
  29411. + ath79_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL,
  29412. + ARRAY_SIZE(zcn_1523h_gpio_keys),
  29413. + zcn_1523h_gpio_keys);
  29414. +
  29415. + ap91_pci_init(ee, mac);
  29416. +
  29417. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  29418. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  29419. +
  29420. + ath79_register_mdio(0, 0x0);
  29421. +
  29422. + /* LAN1 port */
  29423. + ath79_register_eth(0);
  29424. +}
  29425. +
  29426. +static void __init zcn_1523h_2_setup(void)
  29427. +{
  29428. + zcn_1523h_generic_setup();
  29429. + ap9x_pci_setup_wmac_gpio(0, BIT(9), 0);
  29430. +
  29431. + ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio),
  29432. + zcn_1523h_2_leds_gpio);
  29433. +}
  29434. +
  29435. +MIPS_MACHINE(ATH79_MACH_ZCN_1523H_2, "ZCN-1523H-2", "Zcomax ZCN-1523H-2",
  29436. + zcn_1523h_2_setup);
  29437. +
  29438. +static void __init zcn_1523h_5_setup(void)
  29439. +{
  29440. + zcn_1523h_generic_setup();
  29441. + ap9x_pci_setup_wmac_gpio(0, BIT(8), 0);
  29442. +
  29443. + ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio),
  29444. + zcn_1523h_5_leds_gpio);
  29445. +
  29446. + /* LAN2 port */
  29447. + ath79_register_eth(1);
  29448. +}
  29449. +
  29450. +MIPS_MACHINE(ATH79_MACH_ZCN_1523H_5, "ZCN-1523H-5", "Zcomax ZCN-1523H-5",
  29451. + zcn_1523h_5_setup);
  29452. diff -Nur linux-4.1.13.orig/arch/mips/ath79/Makefile linux-4.1.13/arch/mips/ath79/Makefile
  29453. --- linux-4.1.13.orig/arch/mips/ath79/Makefile 2015-11-09 23:34:10.000000000 +0100
  29454. +++ linux-4.1.13/arch/mips/ath79/Makefile 2015-12-04 19:57:05.957975089 +0100
  29455. @@ -17,18 +17,169 @@
  29456. # Devices
  29457. #
  29458. obj-y += dev-common.o
  29459. +obj-$(CONFIG_ATH79_DEV_AP9X_PCI) += dev-ap9x-pci.o
  29460. +obj-$(CONFIG_ATH79_DEV_DSA) += dev-dsa.o
  29461. +obj-$(CONFIG_ATH79_DEV_ETH) += dev-eth.o
  29462. obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
  29463. obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o
  29464. +obj-$(CONFIG_ATH79_DEV_M25P80) += dev-m25p80.o
  29465. +obj-$(CONFIG_ATH79_DEV_NFC) += dev-nfc.o
  29466. obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
  29467. obj-$(CONFIG_ATH79_DEV_USB) += dev-usb.o
  29468. obj-$(CONFIG_ATH79_DEV_WMAC) += dev-wmac.o
  29469. #
  29470. +# Miscellaneous objects
  29471. +#
  29472. +obj-$(CONFIG_ATH79_NVRAM) += nvram.o
  29473. +obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP) += pci-ath9k-fixup.o
  29474. +obj-$(CONFIG_ATH79_ROUTERBOOT) += routerboot.o
  29475. +
  29476. +#
  29477. # Machines
  29478. #
  29479. +obj-$(CONFIG_ATH79_MACH_ALFA_AP96) += mach-alfa-ap96.o
  29480. +obj-$(CONFIG_ATH79_MACH_ALFA_NX) += mach-alfa-nx.o
  29481. +obj-$(CONFIG_ATH79_MACH_ALL0258N) += mach-all0258n.o
  29482. +obj-$(CONFIG_ATH79_MACH_ALL0315N) += mach-all0315n.o
  29483. +obj-$(CONFIG_ATH79_MACH_ANTMINER_S1)+= mach-antminer-s1.o
  29484. +obj-$(CONFIG_ATH79_MACH_ANTMINER_S3)+= mach-antminer-s3.o
  29485. +obj-$(CONFIG_ATH79_MACH_ARDUINO_YUN) += mach-arduino-yun.o
  29486. +obj-$(CONFIG_ATH79_MACH_AP113) += mach-ap113.o
  29487. obj-$(CONFIG_ATH79_MACH_AP121) += mach-ap121.o
  29488. +obj-$(CONFIG_ATH79_MACH_AP132) += mach-ap132.o
  29489. obj-$(CONFIG_ATH79_MACH_AP136) += mach-ap136.o
  29490. +obj-$(CONFIG_ATH79_MACH_AP143) += mach-ap143.o
  29491. +obj-$(CONFIG_ATH79_MACH_AP147) += mach-ap147.o
  29492. +obj-$(CONFIG_ATH79_MACH_AP152) += mach-ap152.o
  29493. obj-$(CONFIG_ATH79_MACH_AP81) += mach-ap81.o
  29494. +obj-$(CONFIG_ATH79_MACH_AP83) += mach-ap83.o
  29495. +obj-$(CONFIG_ATH79_MACH_AP96) += mach-ap96.o
  29496. +obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7.o
  29497. +obj-$(CONFIG_ATH79_MACH_AW_NR580) += mach-aw-nr580.o
  29498. +obj-$(CONFIG_ATH79_MACH_BHU_BXU2000N2_A)+= mach-bhu-bxu2000n2-a.o
  29499. +obj-$(CONFIG_ATH79_MACH_BSB) += mach-bsb.o
  29500. +obj-$(CONFIG_ATH79_MACH_CAP4200AG) += mach-cap4200ag.o
  29501. +obj-$(CONFIG_ATH79_MACH_CF_E316N_V2) += mach-cf-e316n-v2.o
  29502. +obj-$(CONFIG_ATH79_MACH_CPE510) += mach-cpe510.o
  29503. obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o
  29504. +obj-$(CONFIG_ATH79_MACH_DLAN_HOTSPOT) += mach-dlan-hotspot.o
  29505. +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_500_WP) += mach-dlan-pro-500-wp.o
  29506. +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_1200_AC) += mach-dlan-pro-1200-ac.o
  29507. +obj-$(CONFIG_ATH79_MACH_DGL_5500_A1) += mach-dgl-5500-a1.o
  29508. +obj-$(CONFIG_ATH79_MACH_DHP_1565_A1) += mach-dhp-1565-a1.o
  29509. +obj-$(CONFIG_ATH79_MACH_DIR_505_A1) += mach-dir-505-a1.o
  29510. +obj-$(CONFIG_ATH79_MACH_DIR_600_A1) += mach-dir-600-a1.o
  29511. +obj-$(CONFIG_ATH79_MACH_DIR_615_C1) += mach-dir-615-c1.o
  29512. +obj-$(CONFIG_ATH79_MACH_DIR_615_I1) += mach-dir-615-i1.o
  29513. +obj-$(CONFIG_ATH79_MACH_DIR_825_B1) += mach-dir-825-b1.o
  29514. +obj-$(CONFIG_ATH79_MACH_DIR_825_C1) += mach-dir-825-c1.o
  29515. +obj-$(CONFIG_ATH79_MACH_DRAGINO2) += mach-dragino2.o
  29516. +obj-$(CONFIG_ATH79_MACH_ESR900) += mach-esr900.o
  29517. +obj-$(CONFIG_ATH79_MACH_EW_DORIN) += mach-ew-dorin.o
  29518. +obj-$(CONFIG_ATH79_MACH_EAP300V2) += mach-eap300v2.o
  29519. +obj-$(CONFIG_ATH79_MACH_EAP7660D) += mach-eap7660d.o
  29520. +obj-$(CONFIG_ATH79_MACH_EL_M150) += mach-el-m150.o
  29521. +obj-$(CONFIG_ATH79_MACH_EL_MINI) += mach-el-mini.o
  29522. +obj-$(CONFIG_ATH79_MACH_EPG5000) += mach-epg5000.o
  29523. +obj-$(CONFIG_ATH79_MACH_ESR1750) += mach-esr1750.o
  29524. +obj-$(CONFIG_ATH79_MACH_F9K1115V2) += mach-f9k1115v2.o
  29525. +obj-$(CONFIG_ATH79_MACH_GL_AR150) += mach-gl-ar150.o
  29526. +obj-$(CONFIG_ATH79_MACH_GL_AR300) += mach-gl-ar300.o
  29527. +obj-$(CONFIG_ATH79_MACH_GL_DOMINO) += mach-gl-domino.o
  29528. +obj-$(CONFIG_ATH79_MACH_GL_INET) += mach-gl-inet.o
  29529. +obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1) += mach-gs-minibox-v1.o
  29530. +obj-$(CONFIG_ATH79_MACH_GS_OOLITE) += mach-gs-oolite.o
  29531. +obj-$(CONFIG_ATH79_MACH_HIWIFI_HC6361) += mach-hiwifi-hc6361.o
  29532. +obj-$(CONFIG_ATH79_MACH_JA76PF) += mach-ja76pf.o
  29533. +obj-$(CONFIG_ATH79_MACH_JWAP003) += mach-jwap003.o
  29534. +obj-$(CONFIG_ATH79_MACH_HORNET_UB) += mach-hornet-ub.o
  29535. +obj-$(CONFIG_ATH79_MACH_MC_MAC1200R) += mach-mc-mac1200r.o
  29536. +obj-$(CONFIG_ATH79_MACH_MR12) += mach-mr12.o
  29537. +obj-$(CONFIG_ATH79_MACH_MR16) += mach-mr16.o
  29538. +obj-$(CONFIG_ATH79_MACH_MR1750) += mach-mr1750.o
  29539. +obj-$(CONFIG_ATH79_MACH_MR600) += mach-mr600.o
  29540. +obj-$(CONFIG_ATH79_MACH_MR900) += mach-mr900.o
  29541. +obj-$(CONFIG_ATH79_MACH_MYNET_N600) += mach-mynet-n600.o
  29542. +obj-$(CONFIG_ATH79_MACH_MYNET_N750) += mach-mynet-n750.o
  29543. +obj-$(CONFIG_ATH79_MACH_MYNET_REXT) += mach-mynet-rext.o
  29544. +obj-$(CONFIG_ATH79_MACH_MZK_W04NU) += mach-mzk-w04nu.o
  29545. +obj-$(CONFIG_ATH79_MACH_MZK_W300NH) += mach-mzk-w300nh.o
  29546. +obj-$(CONFIG_ATH79_MACH_NBG460N) += mach-nbg460n.o
  29547. +obj-$(CONFIG_ATH79_MACH_OM2P) += mach-om2p.o
  29548. +obj-$(CONFIG_ATH79_MACH_OM5P) += mach-om5p.o
  29549. +obj-$(CONFIG_ATH79_MACH_ONION_OMEGA) += mach-onion-omega.o
  29550. +obj-$(CONFIG_ATH79_MACH_PB42) += mach-pb42.o
  29551. obj-$(CONFIG_ATH79_MACH_PB44) += mach-pb44.o
  29552. +obj-$(CONFIG_ATH79_MACH_PB92) += mach-pb92.o
  29553. +obj-$(CONFIG_ATH79_MACH_QIHOO_C301) += mach-qihoo-c301.o
  29554. +obj-$(CONFIG_ATH79_MACH_R6100) += mach-r6100.o
  29555. +obj-$(CONFIG_ATH79_MACH_RB4XX) += mach-rb4xx.o
  29556. +obj-$(CONFIG_ATH79_MACH_RB750) += mach-rb750.o
  29557. +obj-$(CONFIG_ATH79_MACH_RB91X) += mach-rb91x.o
  29558. +obj-$(CONFIG_ATH79_MACH_RB922) += mach-rb922.o
  29559. +obj-$(CONFIG_ATH79_MACH_RB95X) += mach-rb95x.o
  29560. +obj-$(CONFIG_ATH79_MACH_RB2011) += mach-rb2011.o
  29561. +obj-$(CONFIG_ATH79_MACH_RBSXTLITE) += mach-rbsxtlite.o
  29562. +obj-$(CONFIG_ATH79_MACH_RW2458N) += mach-rw2458n.o
  29563. +obj-$(CONFIG_ATH79_MACH_SMART_300) += mach-smart-300.o
  29564. +obj-$(CONFIG_ATH79_MACH_TEW_632BRP) += mach-tew-632brp.o
  29565. +obj-$(CONFIG_ATH79_MACH_TEW_673GRU) += mach-tew-673gru.o
  29566. +obj-$(CONFIG_ATH79_MACH_TEW_712BR) += mach-tew-712br.o
  29567. +obj-$(CONFIG_ATH79_MACH_TEW_732BR) += mach-tew-732br.o
  29568. +obj-$(CONFIG_ATH79_MACH_TL_MR11U) += mach-tl-mr11u.o
  29569. +obj-$(CONFIG_ATH79_MACH_TL_MR13U) += mach-tl-mr13u.o
  29570. +obj-$(CONFIG_ATH79_MACH_TL_MR3020) += mach-tl-mr3020.o
  29571. +obj-$(CONFIG_ATH79_MACH_TL_MR3X20) += mach-tl-mr3x20.o
  29572. +obj-$(CONFIG_ATH79_MACH_TL_WAX50RE) += mach-tl-wax50re.o
  29573. +obj-$(CONFIG_ATH79_MACH_TL_WA701ND_V2) += mach-tl-wa701nd-v2.o
  29574. +obj-$(CONFIG_ATH79_MACH_TL_WA7210N_V2) += mach-tl-wa7210n-v2.o
  29575. +obj-$(CONFIG_ATH79_MACH_TL_WA830RE_V2) += mach-tl-wa830re-v2.o
  29576. +obj-$(CONFIG_ATH79_MACH_TL_WA901ND) += mach-tl-wa901nd.o
  29577. +obj-$(CONFIG_ATH79_MACH_TL_WA901ND_V2) += mach-tl-wa901nd-v2.o
  29578. +obj-$(CONFIG_ATH79_MACH_TL_WDR3320_V2) += mach-tl-wdr3320-v2.o
  29579. +obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
  29580. +obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
  29581. +obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
  29582. +obj-$(CONFIG_ATH79_MACH_TL_WR741ND) += mach-tl-wr741nd.o
  29583. +obj-$(CONFIG_ATH79_MACH_TL_WR741ND_V4) += mach-tl-wr741nd-v4.o
  29584. +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V1) += mach-tl-wr841n.o
  29585. +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V8) += mach-tl-wr841n-v8.o
  29586. +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V9) += mach-tl-wr841n-v9.o
  29587. +obj-$(CONFIG_ATH79_MACH_TL_WR941ND) += mach-tl-wr941nd.o
  29588. +obj-$(CONFIG_ATH79_MACH_TL_WR941ND_V6) += mach-tl-wr941nd-v6.o
  29589. +obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
  29590. +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
  29591. +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND_V2) += mach-tl-wr1043nd-v2.o
  29592. +obj-$(CONFIG_ATH79_MACH_TL_WR2543N) += mach-tl-wr2543n.o
  29593. +obj-$(CONFIG_ATH79_MACH_TL_WR703N) += mach-tl-wr703n.o
  29594. +obj-$(CONFIG_ATH79_MACH_TL_WR720N_V3) += mach-tl-wr720n-v3.o
  29595. +obj-$(CONFIG_ATH79_MACH_TUBE2H) += mach-tube2h.o
  29596. +obj-$(CONFIG_ATH79_MACH_UBNT) += mach-ubnt.o
  29597. obj-$(CONFIG_ATH79_MACH_UBNT_XM) += mach-ubnt-xm.o
  29598. +obj-$(CONFIG_ATH79_MACH_WEIO) += mach-weio.o
  29599. +obj-$(CONFIG_ATH79_MACH_WHR_HP_G300N) += mach-whr-hp-g300n.o
  29600. +obj-$(CONFIG_ATH79_MACH_WLAE_AG300N) += mach-wlae-ag300n.o
  29601. +obj-$(CONFIG_ATH79_MACH_WLR8100) += mach-wlr8100.o
  29602. +obj-$(CONFIG_ATH79_MACH_WNDAP360) += mach-wndap360.o
  29603. +obj-$(CONFIG_ATH79_MACH_WNDR3700) += mach-wndr3700.o
  29604. +obj-$(CONFIG_ATH79_MACH_WNDR4300) += mach-wndr4300.o
  29605. +obj-$(CONFIG_ATH79_MACH_WNR2000) += mach-wnr2000.o
  29606. +obj-$(CONFIG_ATH79_MACH_WNR2000_V3) += mach-wnr2000-v3.o
  29607. +obj-$(CONFIG_ATH79_MACH_WNR2000_V4) += mach-wnr2000-v4.o
  29608. +obj-$(CONFIG_ATH79_MACH_WNR2200) += mach-wnr2200.o
  29609. +obj-$(CONFIG_ATH79_MACH_WP543) += mach-wp543.o
  29610. +obj-$(CONFIG_ATH79_MACH_WPE72) += mach-wpe72.o
  29611. +obj-$(CONFIG_ATH79_MACH_WPJ344) += mach-wpj344.o
  29612. +obj-$(CONFIG_ATH79_MACH_WPJ531) += mach-wpj531.o
  29613. +obj-$(CONFIG_ATH79_MACH_WPJ558) += mach-wpj558.o
  29614. +obj-$(CONFIG_ATH79_MACH_WRT160NL) += mach-wrt160nl.o
  29615. +obj-$(CONFIG_ATH79_MACH_WRT400N) += mach-wrt400n.o
  29616. +obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH) += mach-wzr-hp-g300nh.o
  29617. +obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH2) += mach-wzr-hp-g300nh2.o
  29618. +obj-$(CONFIG_ATH79_MACH_WZR_HP_AG300H) += mach-wzr-hp-ag300h.o
  29619. +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H) += mach-wzr-hp-g450h.o
  29620. +obj-$(CONFIG_ATH79_MACH_WZR_450HP2) += mach-wzr-450hp2.o
  29621. +obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o
  29622. +obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o
  29623. +obj-$(CONFIG_ATH79_MACH_NBG6716) += mach-nbg6716.o
  29624. diff -Nur linux-4.1.13.orig/arch/mips/ath79/nvram.c linux-4.1.13/arch/mips/ath79/nvram.c
  29625. --- linux-4.1.13.orig/arch/mips/ath79/nvram.c 1970-01-01 01:00:00.000000000 +0100
  29626. +++ linux-4.1.13/arch/mips/ath79/nvram.c 2015-09-13 20:04:35.072523889 +0200
  29627. @@ -0,0 +1,80 @@
  29628. +/*
  29629. + * Atheros AR71xx minimal nvram support
  29630. + *
  29631. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  29632. + *
  29633. + * This program is free software; you can redistribute it and/or modify it
  29634. + * under the terms of the GNU General Public License version 2 as published
  29635. + * by the Free Software Foundation.
  29636. + */
  29637. +
  29638. +#include <linux/kernel.h>
  29639. +#include <linux/vmalloc.h>
  29640. +#include <linux/errno.h>
  29641. +#include <linux/init.h>
  29642. +#include <linux/string.h>
  29643. +
  29644. +#include "nvram.h"
  29645. +
  29646. +char *ath79_nvram_find_var(const char *name, const char *buf, unsigned buf_len)
  29647. +{
  29648. + unsigned len = strlen(name);
  29649. + char *cur, *last;
  29650. +
  29651. + if (buf_len == 0 || len == 0)
  29652. + return NULL;
  29653. +
  29654. + if (buf_len < len)
  29655. + return NULL;
  29656. +
  29657. + if (len == 1)
  29658. + return memchr(buf, (int) *name, buf_len);
  29659. +
  29660. + last = (char *) buf + buf_len - len;
  29661. + for (cur = (char *) buf; cur <= last; cur++)
  29662. + if (cur[0] == name[0] && memcmp(cur, name, len) == 0)
  29663. + return cur + len;
  29664. +
  29665. + return NULL;
  29666. +}
  29667. +
  29668. +int ath79_nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
  29669. + const char *name, char *mac)
  29670. +{
  29671. + char *buf;
  29672. + char *mac_str;
  29673. + int ret;
  29674. + int t;
  29675. +
  29676. + buf = vmalloc(nvram_len);
  29677. + if (!buf)
  29678. + return -ENOMEM;
  29679. +
  29680. + memcpy(buf, nvram, nvram_len);
  29681. + buf[nvram_len - 1] = '\0';
  29682. +
  29683. + mac_str = ath79_nvram_find_var(name, buf, nvram_len);
  29684. + if (!mac_str) {
  29685. + ret = -EINVAL;
  29686. + goto free;
  29687. + }
  29688. +
  29689. + if (strlen(mac_str) == 19 && mac_str[0] == '"' && mac_str[18] == '"') {
  29690. + mac_str[18] = 0;
  29691. + mac_str++;
  29692. + }
  29693. +
  29694. + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
  29695. + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  29696. +
  29697. + if (t != 6) {
  29698. + ret = -EINVAL;
  29699. + goto free;
  29700. + }
  29701. +
  29702. + ret = 0;
  29703. +
  29704. +free:
  29705. + vfree(buf);
  29706. + return ret;
  29707. +}
  29708. diff -Nur linux-4.1.13.orig/arch/mips/ath79/nvram.h linux-4.1.13/arch/mips/ath79/nvram.h
  29709. --- linux-4.1.13.orig/arch/mips/ath79/nvram.h 1970-01-01 01:00:00.000000000 +0100
  29710. +++ linux-4.1.13/arch/mips/ath79/nvram.h 2015-09-13 20:04:35.072523889 +0200
  29711. @@ -0,0 +1,19 @@
  29712. +/*
  29713. + * Atheros AR71xx minimal nvram support
  29714. + *
  29715. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  29716. + *
  29717. + * This program is free software; you can redistribute it and/or modify it
  29718. + * under the terms of the GNU General Public License version 2 as published
  29719. + * by the Free Software Foundation.
  29720. + */
  29721. +
  29722. +#ifndef _ATH79_NVRAM_H
  29723. +#define _ATH79_NVRAM_H
  29724. +
  29725. +char *ath79_nvram_find_var(const char *name, const char *buf,
  29726. + unsigned buf_len);
  29727. +int ath79_nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
  29728. + const char *name, char *mac);
  29729. +
  29730. +#endif /* _ATH79_NVRAM_H */
  29731. diff -Nur linux-4.1.13.orig/arch/mips/ath79/pci-ath9k-fixup.c linux-4.1.13/arch/mips/ath79/pci-ath9k-fixup.c
  29732. --- linux-4.1.13.orig/arch/mips/ath79/pci-ath9k-fixup.c 1970-01-01 01:00:00.000000000 +0100
  29733. +++ linux-4.1.13/arch/mips/ath79/pci-ath9k-fixup.c 2015-09-13 20:04:35.072523889 +0200
  29734. @@ -0,0 +1,126 @@
  29735. +/*
  29736. + * Atheros AP94 reference board PCI initialization
  29737. + *
  29738. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  29739. + *
  29740. + * This program is free software; you can redistribute it and/or modify it
  29741. + * under the terms of the GNU General Public License version 2 as published
  29742. + * by the Free Software Foundation.
  29743. + */
  29744. +
  29745. +#include <linux/pci.h>
  29746. +#include <linux/delay.h>
  29747. +
  29748. +#include <asm/mach-ath79/ar71xx_regs.h>
  29749. +#include <asm/mach-ath79/ath79.h>
  29750. +
  29751. +struct ath9k_fixup {
  29752. + u16 *cal_data;
  29753. + unsigned slot;
  29754. +};
  29755. +
  29756. +static int ath9k_num_fixups;
  29757. +static struct ath9k_fixup ath9k_fixups[2];
  29758. +
  29759. +static void ath9k_pci_fixup(struct pci_dev *dev)
  29760. +{
  29761. + void __iomem *mem;
  29762. + u16 *cal_data = NULL;
  29763. + u16 cmd;
  29764. + u32 bar0;
  29765. + u32 val;
  29766. + unsigned i;
  29767. +
  29768. + for (i = 0; i < ath9k_num_fixups; i++) {
  29769. + if (ath9k_fixups[i].cal_data == NULL)
  29770. + continue;
  29771. +
  29772. + if (ath9k_fixups[i].slot != PCI_SLOT(dev->devfn))
  29773. + continue;
  29774. +
  29775. + cal_data = ath9k_fixups[i].cal_data;
  29776. + break;
  29777. + }
  29778. +
  29779. + if (cal_data == NULL)
  29780. + return;
  29781. +
  29782. + if (*cal_data != 0xa55a) {
  29783. + pr_err("pci %s: invalid calibration data\n", pci_name(dev));
  29784. + return;
  29785. + }
  29786. +
  29787. + pr_info("pci %s: fixup device configuration\n", pci_name(dev));
  29788. +
  29789. + mem = ioremap(AR71XX_PCI_MEM_BASE, 0x10000);
  29790. + if (!mem) {
  29791. + pr_err("pci %s: ioremap error\n", pci_name(dev));
  29792. + return;
  29793. + }
  29794. +
  29795. + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0);
  29796. +
  29797. + switch (ath79_soc) {
  29798. + case ATH79_SOC_AR7161:
  29799. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0,
  29800. + AR71XX_PCI_MEM_BASE);
  29801. + break;
  29802. + case ATH79_SOC_AR7240:
  29803. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0xffff);
  29804. + break;
  29805. +
  29806. + case ATH79_SOC_AR7241:
  29807. + case ATH79_SOC_AR7242:
  29808. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000ffff);
  29809. + break;
  29810. + case ATH79_SOC_AR9344:
  29811. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000ffff);
  29812. + break;
  29813. +
  29814. + default:
  29815. + BUG();
  29816. + }
  29817. +
  29818. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  29819. + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  29820. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  29821. +
  29822. + /* set pointer to first reg address */
  29823. + cal_data += 3;
  29824. + while (*cal_data != 0xffff) {
  29825. + u32 reg;
  29826. + reg = *cal_data++;
  29827. + val = *cal_data++;
  29828. + val |= (*cal_data++) << 16;
  29829. +
  29830. + __raw_writel(val, mem + reg);
  29831. + udelay(100);
  29832. + }
  29833. +
  29834. + pci_read_config_dword(dev, PCI_VENDOR_ID, &val);
  29835. + dev->vendor = val & 0xffff;
  29836. + dev->device = (val >> 16) & 0xffff;
  29837. +
  29838. + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val);
  29839. + dev->revision = val & 0xff;
  29840. + dev->class = val >> 8; /* upper 3 bytes */
  29841. +
  29842. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  29843. + cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  29844. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  29845. +
  29846. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0);
  29847. +
  29848. + iounmap(mem);
  29849. +}
  29850. +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath9k_pci_fixup);
  29851. +
  29852. +void __init pci_enable_ath9k_fixup(unsigned slot, u16 *cal_data)
  29853. +{
  29854. + if (ath9k_num_fixups >= ARRAY_SIZE(ath9k_fixups))
  29855. + return;
  29856. +
  29857. + ath9k_fixups[ath9k_num_fixups].slot = slot;
  29858. + ath9k_fixups[ath9k_num_fixups].cal_data = cal_data;
  29859. + ath9k_num_fixups++;
  29860. +}
  29861. diff -Nur linux-4.1.13.orig/arch/mips/ath79/pci-ath9k-fixup.h linux-4.1.13/arch/mips/ath79/pci-ath9k-fixup.h
  29862. --- linux-4.1.13.orig/arch/mips/ath79/pci-ath9k-fixup.h 1970-01-01 01:00:00.000000000 +0100
  29863. +++ linux-4.1.13/arch/mips/ath79/pci-ath9k-fixup.h 2015-09-13 20:04:35.072523889 +0200
  29864. @@ -0,0 +1,6 @@
  29865. +#ifndef _PCI_ATH9K_FIXUP
  29866. +#define _PCI_ATH9K_FIXUP
  29867. +
  29868. +void pci_enable_ath9k_fixup(unsigned slot, u16 *cal_data) __init;
  29869. +
  29870. +#endif /* _PCI_ATH9K_FIXUP */
  29871. diff -Nur linux-4.1.13.orig/arch/mips/ath79/pci.c linux-4.1.13/arch/mips/ath79/pci.c
  29872. --- linux-4.1.13.orig/arch/mips/ath79/pci.c 2015-11-09 23:34:10.000000000 +0100
  29873. +++ linux-4.1.13/arch/mips/ath79/pci.c 2015-12-04 19:57:05.593998902 +0100
  29874. @@ -13,6 +13,7 @@
  29875. */
  29876. #include <linux/init.h>
  29877. +#include <linux/export.h>
  29878. #include <linux/pci.h>
  29879. #include <linux/resource.h>
  29880. #include <linux/platform_device.h>
  29881. @@ -25,6 +26,9 @@
  29882. static const struct ath79_pci_irq *ath79_pci_irq_map __initdata;
  29883. static unsigned ath79_pci_nr_irqs __initdata;
  29884. +static unsigned long (*__ath79_pci_swizzle_b)(unsigned long port);
  29885. +static unsigned long (*__ath79_pci_swizzle_w)(unsigned long port);
  29886. +
  29887. static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
  29888. {
  29889. .slot = 17,
  29890. @@ -49,6 +53,15 @@
  29891. }
  29892. };
  29893. +static const struct ath79_pci_irq qca953x_pci_irq_map[] __initconst = {
  29894. + {
  29895. + .bus = 0,
  29896. + .slot = 0,
  29897. + .pin = 1,
  29898. + .irq = ATH79_PCI_IRQ(0),
  29899. + },
  29900. +};
  29901. +
  29902. static const struct ath79_pci_irq qca955x_pci_irq_map[] __initconst = {
  29903. {
  29904. .bus = 0,
  29905. @@ -64,6 +77,21 @@
  29906. },
  29907. };
  29908. +static const struct ath79_pci_irq qca956x_pci_irq_map[] __initconst = {
  29909. + {
  29910. + .bus = 0,
  29911. + .slot = 0,
  29912. + .pin = 1,
  29913. + .irq = ATH79_PCI_IRQ(0),
  29914. + },
  29915. + {
  29916. + .bus = 1,
  29917. + .slot = 0,
  29918. + .pin = 1,
  29919. + .irq = ATH79_PCI_IRQ(1),
  29920. + },
  29921. +};
  29922. +
  29923. int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
  29924. {
  29925. int irq = -1;
  29926. @@ -79,9 +107,15 @@
  29927. soc_is_ar9344()) {
  29928. ath79_pci_irq_map = ar724x_pci_irq_map;
  29929. ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
  29930. + } else if (soc_is_qca953x()) {
  29931. + ath79_pci_irq_map = qca953x_pci_irq_map;
  29932. + ath79_pci_nr_irqs = ARRAY_SIZE(qca953x_pci_irq_map);
  29933. } else if (soc_is_qca955x()) {
  29934. ath79_pci_irq_map = qca955x_pci_irq_map;
  29935. ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
  29936. + } else if (soc_is_qca9561()) {
  29937. + ath79_pci_irq_map = qca956x_pci_irq_map;
  29938. + ath79_pci_nr_irqs = ARRAY_SIZE(qca956x_pci_irq_map);
  29939. } else {
  29940. pr_crit("pci %s: invalid irq map\n",
  29941. pci_name((struct pci_dev *) dev));
  29942. @@ -212,12 +246,50 @@
  29943. return pdev;
  29944. }
  29945. +static inline bool ar71xx_is_pci_addr(unsigned long port)
  29946. +{
  29947. + unsigned long phys = CPHYSADDR(port);
  29948. +
  29949. + return (phys >= AR71XX_PCI_MEM_BASE &&
  29950. + phys < AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE);
  29951. +}
  29952. +
  29953. +static unsigned long ar71xx_pci_swizzle_b(unsigned long port)
  29954. +{
  29955. + return ar71xx_is_pci_addr(port) ? port ^ 3 : port;
  29956. +}
  29957. +
  29958. +static unsigned long ar71xx_pci_swizzle_w(unsigned long port)
  29959. +{
  29960. + return ar71xx_is_pci_addr(port) ? port ^ 2 : port;
  29961. +}
  29962. +
  29963. +unsigned long ath79_pci_swizzle_b(unsigned long port)
  29964. +{
  29965. + if (__ath79_pci_swizzle_b)
  29966. + return __ath79_pci_swizzle_b(port);
  29967. +
  29968. + return port;
  29969. +}
  29970. +EXPORT_SYMBOL(ath79_pci_swizzle_b);
  29971. +
  29972. +unsigned long ath79_pci_swizzle_w(unsigned long port)
  29973. +{
  29974. + if (__ath79_pci_swizzle_w)
  29975. + return __ath79_pci_swizzle_w(port);
  29976. +
  29977. + return port;
  29978. +}
  29979. +EXPORT_SYMBOL(ath79_pci_swizzle_w);
  29980. +
  29981. int __init ath79_register_pci(void)
  29982. {
  29983. struct platform_device *pdev = NULL;
  29984. if (soc_is_ar71xx()) {
  29985. pdev = ath79_register_pci_ar71xx();
  29986. + __ath79_pci_swizzle_b = ar71xx_pci_swizzle_b;
  29987. + __ath79_pci_swizzle_w = ar71xx_pci_swizzle_w;
  29988. } else if (soc_is_ar724x()) {
  29989. pdev = ath79_register_pci_ar724x(-1,
  29990. AR724X_PCI_CFG_BASE,
  29991. @@ -243,6 +315,15 @@
  29992. AR724X_PCI_MEM_SIZE,
  29993. 0,
  29994. ATH79_IP2_IRQ(0));
  29995. + } else if (soc_is_qca9533()) {
  29996. + pdev = ath79_register_pci_ar724x(0,
  29997. + QCA953X_PCI_CFG_BASE0,
  29998. + QCA953X_PCI_CTRL_BASE0,
  29999. + QCA953X_PCI_CRP_BASE0,
  30000. + QCA953X_PCI_MEM_BASE0,
  30001. + QCA953X_PCI_MEM_SIZE,
  30002. + 0,
  30003. + ATH79_IP2_IRQ(0));
  30004. } else if (soc_is_qca9558()) {
  30005. pdev = ath79_register_pci_ar724x(0,
  30006. QCA955X_PCI_CFG_BASE0,
  30007. @@ -261,6 +342,15 @@
  30008. QCA955X_PCI_MEM_SIZE,
  30009. 1,
  30010. ATH79_IP3_IRQ(2));
  30011. + } else if (soc_is_qca9561()) {
  30012. + pdev = ath79_register_pci_ar724x(0,
  30013. + QCA956X_PCI_CFG_BASE1,
  30014. + QCA956X_PCI_CTRL_BASE1,
  30015. + QCA956X_PCI_CRP_BASE1,
  30016. + QCA956X_PCI_MEM_BASE1,
  30017. + QCA956X_PCI_MEM_SIZE,
  30018. + 1,
  30019. + ATH79_IP3_IRQ(2));
  30020. } else {
  30021. /* No PCI support */
  30022. return -ENODEV;
  30023. diff -Nur linux-4.1.13.orig/arch/mips/ath79/prom.c linux-4.1.13/arch/mips/ath79/prom.c
  30024. --- linux-4.1.13.orig/arch/mips/ath79/prom.c 2015-11-09 23:34:10.000000000 +0100
  30025. +++ linux-4.1.13/arch/mips/ath79/prom.c 2015-12-04 19:57:05.482006229 +0100
  30026. @@ -19,12 +19,114 @@
  30027. #include <asm/bootinfo.h>
  30028. #include <asm/addrspace.h>
  30029. #include <asm/fw/fw.h>
  30030. +#include <asm/fw/myloader/myloader.h>
  30031. #include "common.h"
  30032. +static char ath79_cmdline_buf[COMMAND_LINE_SIZE] __initdata;
  30033. +
  30034. +static void __init ath79_prom_append_cmdline(const char *name,
  30035. + const char *value)
  30036. +{
  30037. + snprintf(ath79_cmdline_buf, sizeof(ath79_cmdline_buf),
  30038. + " %s=%s", name, value);
  30039. + strlcat(arcs_cmdline, ath79_cmdline_buf, sizeof(arcs_cmdline));
  30040. +}
  30041. +
  30042. +#ifdef CONFIG_IMAGE_CMDLINE_HACK
  30043. +extern char __image_cmdline[];
  30044. +
  30045. +static int __init ath79_use_image_cmdline(void)
  30046. +{
  30047. + char *p = __image_cmdline;
  30048. + int replace = 0;
  30049. +
  30050. + if (*p == '-') {
  30051. + replace = 1;
  30052. + p++;
  30053. + }
  30054. +
  30055. + if (*p == '\0')
  30056. + return 0;
  30057. +
  30058. + if (replace) {
  30059. + strlcpy(arcs_cmdline, p, sizeof(arcs_cmdline));
  30060. + } else {
  30061. + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  30062. + strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
  30063. + }
  30064. +
  30065. + /* Validate and setup environment pointer */
  30066. + if (fw_arg2 < CKSEG0)
  30067. + _fw_envp = NULL;
  30068. + else
  30069. + _fw_envp = (int *)fw_arg2;
  30070. +
  30071. + return 1;
  30072. +}
  30073. +#else
  30074. +static inline int ath79_use_image_cmdline(void) { return 0; }
  30075. +#endif
  30076. +
  30077. +static int __init ath79_prom_init_myloader(void)
  30078. +{
  30079. + struct myloader_info *mylo;
  30080. + char mac_buf[32];
  30081. + unsigned char *mac;
  30082. +
  30083. + mylo = myloader_get_info();
  30084. + if (!mylo)
  30085. + return 0;
  30086. +
  30087. + switch (mylo->did) {
  30088. + case DEVID_COMPEX_WP543:
  30089. + ath79_prom_append_cmdline("board", "WP543");
  30090. + break;
  30091. + case DEVID_COMPEX_WPE72:
  30092. + ath79_prom_append_cmdline("board", "WPE72");
  30093. + break;
  30094. + default:
  30095. + pr_warn("prom: unknown device id: %x\n", mylo->did);
  30096. + return 0;
  30097. + }
  30098. +
  30099. + mac = mylo->macs[0];
  30100. + snprintf(mac_buf, sizeof(mac_buf), "%02x:%02x:%02x:%02x:%02x:%02x",
  30101. + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  30102. +
  30103. + ath79_prom_append_cmdline("ethaddr", mac_buf);
  30104. +
  30105. + ath79_use_image_cmdline();
  30106. +
  30107. + return 1;
  30108. +}
  30109. +
  30110. void __init prom_init(void)
  30111. {
  30112. - fw_init_cmdline();
  30113. + const char *env;
  30114. +
  30115. + if (ath79_prom_init_myloader())
  30116. + return;
  30117. +
  30118. + if (!ath79_use_image_cmdline())
  30119. + fw_init_cmdline();
  30120. +
  30121. + env = fw_getenv("ethaddr");
  30122. + if (env)
  30123. + ath79_prom_append_cmdline("ethaddr", env);
  30124. +
  30125. + env = fw_getenv("board");
  30126. + if (env) {
  30127. + /* Workaround for buggy bootloaders */
  30128. + if (strcmp(env, "RouterStation") == 0 ||
  30129. + strcmp(env, "Ubiquiti AR71xx-based board") == 0)
  30130. + env = "UBNT-RS";
  30131. +
  30132. + if (strcmp(env, "RouterStation PRO") == 0)
  30133. + env = "UBNT-RSPRO";
  30134. +
  30135. + ath79_prom_append_cmdline("board", env);
  30136. + }
  30137. #ifdef CONFIG_BLK_DEV_INITRD
  30138. /* Read the initrd address from the firmware environment */
  30139. @@ -34,6 +136,13 @@
  30140. initrd_end = initrd_start + fw_getenvl("initrd_size");
  30141. }
  30142. #endif
  30143. +
  30144. + if (strstr(arcs_cmdline, "board=750Gr3") ||
  30145. + strstr(arcs_cmdline, "board=951G") ||
  30146. + strstr(arcs_cmdline, "board=2011L") ||
  30147. + strstr(arcs_cmdline, "board=711Gr100") ||
  30148. + strstr(arcs_cmdline, "board=922gs"))
  30149. + ath79_prom_append_cmdline("console", "ttyS0,115200");
  30150. }
  30151. void __init prom_free_prom_memory(void)
  30152. diff -Nur linux-4.1.13.orig/arch/mips/ath79/routerboot.c linux-4.1.13/arch/mips/ath79/routerboot.c
  30153. --- linux-4.1.13.orig/arch/mips/ath79/routerboot.c 1970-01-01 01:00:00.000000000 +0100
  30154. +++ linux-4.1.13/arch/mips/ath79/routerboot.c 2015-09-13 20:04:35.072523889 +0200
  30155. @@ -0,0 +1,358 @@
  30156. +/*
  30157. + * RouterBoot helper routines
  30158. + *
  30159. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  30160. + *
  30161. + * This program is free software; you can redistribute it and/or modify it
  30162. + * under the terms of the GNU General Public License version 2 as published
  30163. + * by the Free Software Foundation.
  30164. + */
  30165. +
  30166. +#define pr_fmt(fmt) "rb: " fmt
  30167. +
  30168. +#include <linux/kernel.h>
  30169. +#include <linux/kobject.h>
  30170. +#include <linux/slab.h>
  30171. +#include <linux/errno.h>
  30172. +#include <linux/routerboot.h>
  30173. +#include <linux/rle.h>
  30174. +#include <linux/lzo.h>
  30175. +
  30176. +#include "routerboot.h"
  30177. +
  30178. +#define RB_BLOCK_SIZE 0x1000
  30179. +#define RB_ART_SIZE 0x10000
  30180. +#define RB_MAGIC_ERD 0x00455244 /* extended radio data */
  30181. +
  30182. +static struct rb_info rb_info;
  30183. +
  30184. +static u32 get_u32(void *buf)
  30185. +{
  30186. + u8 *p = buf;
  30187. +
  30188. + return ((u32) p[3] + ((u32) p[2] << 8) + ((u32) p[1] << 16) +
  30189. + ((u32) p[0] << 24));
  30190. +}
  30191. +
  30192. +static u16 get_u16(void *buf)
  30193. +{
  30194. + u8 *p = buf;
  30195. +
  30196. + return (u16) p[1] + ((u16) p[0] << 8);
  30197. +}
  30198. +
  30199. +__init int
  30200. +routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard)
  30201. +{
  30202. + u32 magic_ref = hard ? RB_MAGIC_HARD : RB_MAGIC_SOFT;
  30203. + u32 magic;
  30204. + u32 cur = *offset;
  30205. +
  30206. + while (cur < buflen) {
  30207. + magic = get_u32(buf + cur);
  30208. + if (magic == magic_ref) {
  30209. + *offset = cur;
  30210. + return 0;
  30211. + }
  30212. +
  30213. + cur += 0x1000;
  30214. + }
  30215. +
  30216. + return -ENOENT;
  30217. +}
  30218. +
  30219. +__init int
  30220. +routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
  30221. + u8 **tag_data, u16 *tag_len)
  30222. +{
  30223. + uint32_t magic;
  30224. + bool align = false;
  30225. + int ret;
  30226. +
  30227. + if (buflen < 4)
  30228. + return -EINVAL;
  30229. +
  30230. + magic = get_u32(buf);
  30231. + switch (magic) {
  30232. + case RB_MAGIC_ERD:
  30233. + align = true;
  30234. + /* fall trough */
  30235. + case RB_MAGIC_HARD:
  30236. + /* skip magic value */
  30237. + buf += 4;
  30238. + buflen -= 4;
  30239. + break;
  30240. +
  30241. + case RB_MAGIC_SOFT:
  30242. + if (buflen < 8)
  30243. + return -EINVAL;
  30244. +
  30245. + /* skip magic and CRC value */
  30246. + buf += 8;
  30247. + buflen -= 8;
  30248. +
  30249. + break;
  30250. +
  30251. + default:
  30252. + return -EINVAL;
  30253. + }
  30254. +
  30255. + ret = -ENOENT;
  30256. + while (buflen > 2) {
  30257. + u16 id;
  30258. + u16 len;
  30259. +
  30260. + len = get_u16(buf);
  30261. + buf += 2;
  30262. + buflen -= 2;
  30263. +
  30264. + if (buflen < 2)
  30265. + break;
  30266. +
  30267. + id = get_u16(buf);
  30268. + buf += 2;
  30269. + buflen -= 2;
  30270. +
  30271. + if (id == RB_ID_TERMINATOR)
  30272. + break;
  30273. +
  30274. + if (buflen < len)
  30275. + break;
  30276. +
  30277. + if (id == tag_id) {
  30278. + if (tag_len)
  30279. + *tag_len = len;
  30280. + if (tag_data)
  30281. + *tag_data = buf;
  30282. + ret = 0;
  30283. + break;
  30284. + }
  30285. +
  30286. + if (align)
  30287. + len = (len + 3) / 4;
  30288. +
  30289. + buf += len;
  30290. + buflen -= len;
  30291. + }
  30292. +
  30293. + return ret;
  30294. +}
  30295. +
  30296. +static inline int
  30297. +rb_find_hard_cfg_tag(u16 tag_id, u8 **tag_data, u16 *tag_len)
  30298. +{
  30299. + if (!rb_info.hard_cfg_data ||
  30300. + !rb_info.hard_cfg_size)
  30301. + return -ENOENT;
  30302. +
  30303. + return routerboot_find_tag(rb_info.hard_cfg_data,
  30304. + rb_info.hard_cfg_size,
  30305. + tag_id, tag_data, tag_len);
  30306. +}
  30307. +
  30308. +__init const char *
  30309. +rb_get_board_name(void)
  30310. +{
  30311. + u16 tag_len;
  30312. + u8 *tag;
  30313. + int err;
  30314. +
  30315. + err = rb_find_hard_cfg_tag(RB_ID_BOARD_NAME, &tag, &tag_len);
  30316. + if (err)
  30317. + return NULL;
  30318. +
  30319. + return tag;
  30320. +}
  30321. +
  30322. +__init u32
  30323. +rb_get_hw_options(void)
  30324. +{
  30325. + u16 tag_len;
  30326. + u8 *tag;
  30327. + int err;
  30328. +
  30329. + err = rb_find_hard_cfg_tag(RB_ID_HW_OPTIONS, &tag, &tag_len);
  30330. + if (err)
  30331. + return 0;
  30332. +
  30333. + return get_u32(tag);
  30334. +}
  30335. +
  30336. +static void * __init
  30337. +__rb_get_wlan_data(u16 id)
  30338. +{
  30339. + u16 tag_len;
  30340. + u8 *tag;
  30341. + void *buf;
  30342. + int err;
  30343. + u32 magic;
  30344. + size_t src_done;
  30345. + size_t dst_done;
  30346. +
  30347. + err = rb_find_hard_cfg_tag(RB_ID_WLAN_DATA, &tag, &tag_len);
  30348. + if (err) {
  30349. + pr_err("no calibration data found\n");
  30350. + goto err;
  30351. + }
  30352. +
  30353. + buf = kmalloc(RB_ART_SIZE, GFP_KERNEL);
  30354. + if (buf == NULL) {
  30355. + pr_err("no memory for calibration data\n");
  30356. + goto err;
  30357. + }
  30358. +
  30359. + magic = get_u32(tag);
  30360. + if (magic == RB_MAGIC_ERD) {
  30361. + u8 *erd_data;
  30362. + u16 erd_len;
  30363. +
  30364. + if (id == 0)
  30365. + goto err_free;
  30366. +
  30367. + err = routerboot_find_tag(tag, tag_len, id,
  30368. + &erd_data, &erd_len);
  30369. + if (err) {
  30370. + pr_err("no ERD data found for id %u\n", id);
  30371. + goto err_free;
  30372. + }
  30373. +
  30374. + dst_done = RB_ART_SIZE;
  30375. + err = lzo1x_decompress_safe(erd_data, erd_len, buf, &dst_done);
  30376. + if (err) {
  30377. + pr_err("unable to decompress calibration data %d\n",
  30378. + err);
  30379. + goto err_free;
  30380. + }
  30381. + } else {
  30382. + if (id != 0)
  30383. + goto err_free;
  30384. +
  30385. + err = rle_decode((char *) tag, tag_len, buf, RB_ART_SIZE,
  30386. + &src_done, &dst_done);
  30387. + if (err) {
  30388. + pr_err("unable to decode calibration data\n");
  30389. + goto err_free;
  30390. + }
  30391. + }
  30392. +
  30393. + return buf;
  30394. +
  30395. +err_free:
  30396. + kfree(buf);
  30397. +err:
  30398. + return NULL;
  30399. +}
  30400. +
  30401. +__init void *
  30402. +rb_get_wlan_data(void)
  30403. +{
  30404. + return __rb_get_wlan_data(0);
  30405. +}
  30406. +
  30407. +__init void *
  30408. +rb_get_ext_wlan_data(u16 id)
  30409. +{
  30410. + return __rb_get_wlan_data(id);
  30411. +}
  30412. +
  30413. +__init const struct rb_info *
  30414. +rb_init_info(void *data, unsigned int size)
  30415. +{
  30416. + unsigned int offset;
  30417. +
  30418. + if (size == 0 || (size % RB_BLOCK_SIZE) != 0)
  30419. + return NULL;
  30420. +
  30421. + for (offset = 0; offset < size; offset += RB_BLOCK_SIZE) {
  30422. + u32 magic;
  30423. +
  30424. + magic = get_u32(data + offset);
  30425. + switch (magic) {
  30426. + case RB_MAGIC_HARD:
  30427. + rb_info.hard_cfg_offs = offset;
  30428. + break;
  30429. +
  30430. + case RB_MAGIC_SOFT:
  30431. + rb_info.soft_cfg_offs = offset;
  30432. + break;
  30433. + }
  30434. + }
  30435. +
  30436. + if (!rb_info.hard_cfg_offs) {
  30437. + pr_err("could not find a valid RouterBOOT hard config\n");
  30438. + return NULL;
  30439. + }
  30440. +
  30441. + if (!rb_info.soft_cfg_offs) {
  30442. + pr_err("could not find a valid RouterBOOT soft config\n");
  30443. + return NULL;
  30444. + }
  30445. +
  30446. + rb_info.hard_cfg_size = RB_BLOCK_SIZE;
  30447. + rb_info.hard_cfg_data = kmemdup(data + rb_info.hard_cfg_offs,
  30448. + RB_BLOCK_SIZE, GFP_KERNEL);
  30449. + if (!rb_info.hard_cfg_data)
  30450. + return NULL;
  30451. +
  30452. + rb_info.board_name = rb_get_board_name();
  30453. + rb_info.hw_options = rb_get_hw_options();
  30454. +
  30455. + return &rb_info;
  30456. +}
  30457. +
  30458. +static char *rb_ext_wlan_data;
  30459. +
  30460. +static ssize_t
  30461. +rb_ext_wlan_data_read(struct file *filp, struct kobject *kobj,
  30462. + struct bin_attribute *attr, char *buf,
  30463. + loff_t off, size_t count)
  30464. +{
  30465. + if (off + count > attr->size)
  30466. + return -EFBIG;
  30467. +
  30468. + memcpy(buf, &rb_ext_wlan_data[off], count);
  30469. +
  30470. + return count;
  30471. +}
  30472. +
  30473. +static const struct bin_attribute rb_ext_wlan_data_attr = {
  30474. + .attr = {
  30475. + .name = "ext_wlan_data",
  30476. + .mode = S_IRUSR | S_IWUSR,
  30477. + },
  30478. + .read = rb_ext_wlan_data_read,
  30479. + .size = RB_ART_SIZE,
  30480. +};
  30481. +
  30482. +static int __init rb_sysfs_init(void)
  30483. +{
  30484. + struct kobject *rb_kobj;
  30485. + int ret;
  30486. +
  30487. + rb_ext_wlan_data = rb_get_ext_wlan_data(1);
  30488. + if (rb_ext_wlan_data == NULL)
  30489. + return -ENOENT;
  30490. +
  30491. + rb_kobj = kobject_create_and_add("routerboot", firmware_kobj);
  30492. + if (rb_kobj == NULL) {
  30493. + ret = -ENOMEM;
  30494. + pr_err("unable to create sysfs entry\n");
  30495. + goto err_free_wlan_data;
  30496. + }
  30497. +
  30498. + ret = sysfs_create_bin_file(rb_kobj, &rb_ext_wlan_data_attr);
  30499. + if (ret) {
  30500. + pr_err("unable to create sysfs file, %d\n", ret);
  30501. + goto err_put_kobj;
  30502. + }
  30503. +
  30504. + return 0;
  30505. +
  30506. +err_put_kobj:
  30507. + kobject_put(rb_kobj);
  30508. +err_free_wlan_data:
  30509. + kfree(rb_ext_wlan_data);
  30510. + return ret;
  30511. +}
  30512. +
  30513. +late_initcall(rb_sysfs_init);
  30514. diff -Nur linux-4.1.13.orig/arch/mips/ath79/routerboot.h linux-4.1.13/arch/mips/ath79/routerboot.h
  30515. --- linux-4.1.13.orig/arch/mips/ath79/routerboot.h 1970-01-01 01:00:00.000000000 +0100
  30516. +++ linux-4.1.13/arch/mips/ath79/routerboot.h 2015-09-13 20:04:35.072523889 +0200
  30517. @@ -0,0 +1,63 @@
  30518. +/*
  30519. + * RouterBoot definitions
  30520. + *
  30521. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  30522. + *
  30523. + * This program is free software; you can redistribute it and/or modify it
  30524. + * under the terms of the GNU General Public License version 2 as published
  30525. + * by the Free Software Foundation.
  30526. + */
  30527. +
  30528. +#ifndef _ATH79_ROUTERBOOT_H_
  30529. +#define _ATH79_ROUTERBOOT_H_
  30530. +
  30531. +struct rb_info {
  30532. + unsigned int hard_cfg_offs;
  30533. + unsigned int hard_cfg_size;
  30534. + void *hard_cfg_data;
  30535. + unsigned int soft_cfg_offs;
  30536. +
  30537. + const char *board_name;
  30538. + u32 hw_options;
  30539. +};
  30540. +
  30541. +#ifdef CONFIG_ATH79_ROUTERBOOT
  30542. +const struct rb_info *rb_init_info(void *data, unsigned int size);
  30543. +void *rb_get_wlan_data(void);
  30544. +void *rb_get_ext_wlan_data(u16 id);
  30545. +
  30546. +int routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
  30547. + u8 **tag_data, u16 *tag_len);
  30548. +int routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard);
  30549. +#else
  30550. +static inline const struct rb_info *
  30551. +rb_init_info(void *data, unsigned int size)
  30552. +{
  30553. + return NULL;
  30554. +}
  30555. +
  30556. +static inline void *rb_get_wlan_data(void)
  30557. +{
  30558. + return NULL;
  30559. +}
  30560. +
  30561. +static inline void *rb_get_wlan_data(u16 id)
  30562. +{
  30563. + return NULL;
  30564. +}
  30565. +
  30566. +static inline int
  30567. +routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
  30568. + u8 **tag_data, u16 *tag_len)
  30569. +{
  30570. + return -ENOENT;
  30571. +}
  30572. +
  30573. +static inline int
  30574. +routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard)
  30575. +{
  30576. + return -ENOENT;
  30577. +}
  30578. +#endif
  30579. +
  30580. +#endif /* _ATH79_ROUTERBOOT_H_ */
  30581. diff -Nur linux-4.1.13.orig/arch/mips/ath79/setup.c linux-4.1.13/arch/mips/ath79/setup.c
  30582. --- linux-4.1.13.orig/arch/mips/ath79/setup.c 2015-11-09 23:34:10.000000000 +0100
  30583. +++ linux-4.1.13/arch/mips/ath79/setup.c 2015-12-04 19:57:04.482071652 +0100
  30584. @@ -40,6 +40,7 @@
  30585. static void ath79_restart(char *command)
  30586. {
  30587. + local_irq_disable();
  30588. ath79_device_reset_set(AR71XX_RESET_FULL_CHIP);
  30589. for (;;)
  30590. if (cpu_wait)
  30591. @@ -59,6 +60,7 @@
  30592. u32 major;
  30593. u32 minor;
  30594. u32 rev = 0;
  30595. + u32 ver = 1;
  30596. id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID);
  30597. major = id & REV_ID_MAJOR_MASK;
  30598. @@ -151,6 +153,17 @@
  30599. rev = id & AR934X_REV_ID_REVISION_MASK;
  30600. break;
  30601. + case REV_ID_MAJOR_QCA9533_V2:
  30602. + ver = 2;
  30603. + ath79_soc_rev = 2;
  30604. + /* drop through */
  30605. +
  30606. + case REV_ID_MAJOR_QCA9533:
  30607. + ath79_soc = ATH79_SOC_QCA9533;
  30608. + chip = "9533";
  30609. + rev = id & QCA953X_REV_ID_REVISION_MASK;
  30610. + break;
  30611. +
  30612. case REV_ID_MAJOR_QCA9556:
  30613. ath79_soc = ATH79_SOC_QCA9556;
  30614. chip = "9556";
  30615. @@ -163,14 +176,30 @@
  30616. rev = id & QCA955X_REV_ID_REVISION_MASK;
  30617. break;
  30618. + case REV_ID_MAJOR_TP9343:
  30619. + ath79_soc = ATH79_SOC_TP9343;
  30620. + chip = "9343";
  30621. + rev = id & QCA956X_REV_ID_REVISION_MASK;
  30622. + break;
  30623. +
  30624. + case REV_ID_MAJOR_QCA9561:
  30625. + ath79_soc = ATH79_SOC_QCA9561;
  30626. + chip = "9561";
  30627. + rev = id & QCA956X_REV_ID_REVISION_MASK;
  30628. + break;
  30629. +
  30630. default:
  30631. panic("ath79: unknown SoC, id:0x%08x", id);
  30632. }
  30633. - ath79_soc_rev = rev;
  30634. + if (ver == 1)
  30635. + ath79_soc_rev = rev;
  30636. - if (soc_is_qca955x())
  30637. - sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s rev %u",
  30638. + if (soc_is_qca953x() || soc_is_qca955x() || soc_is_qca9561())
  30639. + sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
  30640. + chip, ver, rev);
  30641. + else if (soc_is_tp9343())
  30642. + sprintf(ath79_sys_type, "Qualcomm Atheros TP%s rev %u",
  30643. chip, rev);
  30644. else
  30645. sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev);
  30646. @@ -235,6 +264,8 @@
  30647. mips_hpt_frequency = cpu_clk_rate / 2;
  30648. }
  30649. +__setup("board=", mips_machtype_setup);
  30650. +
  30651. static int __init ath79_setup(void)
  30652. {
  30653. ath79_gpio_init();
  30654. diff -Nur linux-4.1.13.orig/arch/mips/fw/lib/cmdline.c linux-4.1.13/arch/mips/fw/lib/cmdline.c
  30655. --- linux-4.1.13.orig/arch/mips/fw/lib/cmdline.c 2015-11-09 23:34:10.000000000 +0100
  30656. +++ linux-4.1.13/arch/mips/fw/lib/cmdline.c 2015-12-04 19:57:04.014102269 +0100
  30657. @@ -35,6 +35,7 @@
  30658. else
  30659. _fw_envp = (int *)fw_arg2;
  30660. + arcs_cmdline[0] = '\0';
  30661. for (i = 1; i < fw_argc; i++) {
  30662. strlcat(arcs_cmdline, fw_argv(i), COMMAND_LINE_SIZE);
  30663. if (i < (fw_argc - 1))
  30664. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/checksum.h linux-4.1.13/arch/mips/include/asm/checksum.h
  30665. --- linux-4.1.13.orig/arch/mips/include/asm/checksum.h 2015-11-09 23:34:10.000000000 +0100
  30666. +++ linux-4.1.13/arch/mips/include/asm/checksum.h 2015-12-04 19:57:05.913977967 +0100
  30667. @@ -134,26 +134,30 @@
  30668. const unsigned int *stop = word + ihl;
  30669. unsigned int csum;
  30670. int carry;
  30671. + unsigned int w;
  30672. - csum = word[0];
  30673. - csum += word[1];
  30674. - carry = (csum < word[1]);
  30675. + csum = net_hdr_word(word++);
  30676. +
  30677. + w = net_hdr_word(word++);
  30678. + csum += w;
  30679. + carry = (csum < w);
  30680. csum += carry;
  30681. - csum += word[2];
  30682. - carry = (csum < word[2]);
  30683. + w = net_hdr_word(word++);
  30684. + csum += w;
  30685. + carry = (csum < w);
  30686. csum += carry;
  30687. - csum += word[3];
  30688. - carry = (csum < word[3]);
  30689. + w = net_hdr_word(word++);
  30690. + csum += w;
  30691. + carry = (csum < w);
  30692. csum += carry;
  30693. - word += 4;
  30694. do {
  30695. - csum += *word;
  30696. - carry = (csum < *word);
  30697. + w = net_hdr_word(word++);
  30698. + csum += w;
  30699. + carry = (csum < w);
  30700. csum += carry;
  30701. - word++;
  30702. } while (word != stop);
  30703. return csum_fold(csum);
  30704. @@ -212,73 +216,6 @@
  30705. return csum_fold(csum_partial(buff, len, 0));
  30706. }
  30707. -#define _HAVE_ARCH_IPV6_CSUM
  30708. -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
  30709. - const struct in6_addr *daddr,
  30710. - __u32 len, unsigned short proto,
  30711. - __wsum sum)
  30712. -{
  30713. - __wsum tmp;
  30714. -
  30715. - __asm__(
  30716. - " .set push # csum_ipv6_magic\n"
  30717. - " .set noreorder \n"
  30718. - " .set noat \n"
  30719. - " addu %0, %5 # proto (long in network byte order)\n"
  30720. - " sltu $1, %0, %5 \n"
  30721. - " addu %0, $1 \n"
  30722. -
  30723. - " addu %0, %6 # csum\n"
  30724. - " sltu $1, %0, %6 \n"
  30725. - " lw %1, 0(%2) # four words source address\n"
  30726. - " addu %0, $1 \n"
  30727. - " addu %0, %1 \n"
  30728. - " sltu $1, %0, %1 \n"
  30729. -
  30730. - " lw %1, 4(%2) \n"
  30731. - " addu %0, $1 \n"
  30732. - " addu %0, %1 \n"
  30733. - " sltu $1, %0, %1 \n"
  30734. -
  30735. - " lw %1, 8(%2) \n"
  30736. - " addu %0, $1 \n"
  30737. - " addu %0, %1 \n"
  30738. - " sltu $1, %0, %1 \n"
  30739. -
  30740. - " lw %1, 12(%2) \n"
  30741. - " addu %0, $1 \n"
  30742. - " addu %0, %1 \n"
  30743. - " sltu $1, %0, %1 \n"
  30744. -
  30745. - " lw %1, 0(%3) \n"
  30746. - " addu %0, $1 \n"
  30747. - " addu %0, %1 \n"
  30748. - " sltu $1, %0, %1 \n"
  30749. -
  30750. - " lw %1, 4(%3) \n"
  30751. - " addu %0, $1 \n"
  30752. - " addu %0, %1 \n"
  30753. - " sltu $1, %0, %1 \n"
  30754. -
  30755. - " lw %1, 8(%3) \n"
  30756. - " addu %0, $1 \n"
  30757. - " addu %0, %1 \n"
  30758. - " sltu $1, %0, %1 \n"
  30759. -
  30760. - " lw %1, 12(%3) \n"
  30761. - " addu %0, $1 \n"
  30762. - " addu %0, %1 \n"
  30763. - " sltu $1, %0, %1 \n"
  30764. -
  30765. - " addu %0, $1 # Add final carry\n"
  30766. - " .set pop"
  30767. - : "=&r" (sum), "=&r" (tmp)
  30768. - : "r" (saddr), "r" (daddr),
  30769. - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
  30770. -
  30771. - return csum_fold(sum);
  30772. -}
  30773. -
  30774. #include <asm-generic/checksum.h>
  30775. #endif /* CONFIG_GENERIC_CSUM */
  30776. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/fw/myloader/myloader.h linux-4.1.13/arch/mips/include/asm/fw/myloader/myloader.h
  30777. --- linux-4.1.13.orig/arch/mips/include/asm/fw/myloader/myloader.h 1970-01-01 01:00:00.000000000 +0100
  30778. +++ linux-4.1.13/arch/mips/include/asm/fw/myloader/myloader.h 2015-09-13 20:04:35.072523889 +0200
  30779. @@ -0,0 +1,34 @@
  30780. +/*
  30781. + * Compex's MyLoader specific definitions
  30782. + *
  30783. + * Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
  30784. + *
  30785. + * This program is free software; you can redistribute it and/or modify it
  30786. + * under the terms of the GNU General Public License version 2 as published
  30787. + * by the Free Software Foundation.
  30788. + *
  30789. + */
  30790. +
  30791. +#ifndef _ASM_MIPS_FW_MYLOADER_H
  30792. +#define _ASM_MIPS_FW_MYLOADER_H
  30793. +
  30794. +#include <linux/myloader.h>
  30795. +
  30796. +struct myloader_info {
  30797. + uint32_t vid;
  30798. + uint32_t did;
  30799. + uint32_t svid;
  30800. + uint32_t sdid;
  30801. + uint8_t macs[MYLO_ETHADDR_COUNT][6];
  30802. +};
  30803. +
  30804. +#ifdef CONFIG_MYLOADER
  30805. +extern struct myloader_info *myloader_get_info(void) __init;
  30806. +#else
  30807. +static inline struct myloader_info *myloader_get_info(void)
  30808. +{
  30809. + return NULL;
  30810. +}
  30811. +#endif /* CONFIG_MYLOADER */
  30812. +
  30813. +#endif /* _ASM_MIPS_FW_MYLOADER_H */
  30814. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ag71xx_platform.h linux-4.1.13/arch/mips/include/asm/mach-ath79/ag71xx_platform.h
  30815. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ag71xx_platform.h 1970-01-01 01:00:00.000000000 +0100
  30816. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/ag71xx_platform.h 2015-09-13 20:04:35.072523889 +0200
  30817. @@ -0,0 +1,65 @@
  30818. +/*
  30819. + * Atheros AR71xx SoC specific platform data definitions
  30820. + *
  30821. + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  30822. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  30823. + *
  30824. + * This program is free software; you can redistribute it and/or modify it
  30825. + * under the terms of the GNU General Public License version 2 as published
  30826. + * by the Free Software Foundation.
  30827. + */
  30828. +
  30829. +#ifndef __ASM_MACH_ATH79_PLATFORM_H
  30830. +#define __ASM_MACH_ATH79_PLATFORM_H
  30831. +
  30832. +#include <linux/if_ether.h>
  30833. +#include <linux/skbuff.h>
  30834. +#include <linux/phy.h>
  30835. +#include <linux/spi/spi.h>
  30836. +
  30837. +struct ag71xx_switch_platform_data {
  30838. + u8 phy4_mii_en:1;
  30839. + u8 phy_poll_mask;
  30840. +};
  30841. +
  30842. +struct ag71xx_platform_data {
  30843. + phy_interface_t phy_if_mode;
  30844. + u32 phy_mask;
  30845. + int speed;
  30846. + int duplex;
  30847. + u32 reset_bit;
  30848. + u8 mac_addr[ETH_ALEN];
  30849. + struct device *mii_bus_dev;
  30850. +
  30851. + u8 has_gbit:1;
  30852. + u8 is_ar91xx:1;
  30853. + u8 is_ar7240:1;
  30854. + u8 is_ar724x:1;
  30855. + u8 has_ar8216:1;
  30856. +
  30857. + struct ag71xx_switch_platform_data *switch_data;
  30858. +
  30859. + void (*ddr_flush)(void);
  30860. + void (*set_speed)(int speed);
  30861. +
  30862. + u32 fifo_cfg1;
  30863. + u32 fifo_cfg2;
  30864. + u32 fifo_cfg3;
  30865. +
  30866. + unsigned int max_frame_len;
  30867. + unsigned int desc_pktlen_mask;
  30868. +};
  30869. +
  30870. +struct ag71xx_mdio_platform_data {
  30871. + u32 phy_mask;
  30872. + u8 builtin_switch:1;
  30873. + u8 is_ar7240:1;
  30874. + u8 is_ar9330:1;
  30875. + u8 is_ar934x:1;
  30876. + unsigned long mdio_clock;
  30877. + unsigned long ref_clock;
  30878. +
  30879. + void (*reset)(struct mii_bus *bus);
  30880. +};
  30881. +
  30882. +#endif /* __ASM_MACH_ATH79_PLATFORM_H */
  30883. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ar71xx_regs.h linux-4.1.13/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  30884. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ar71xx_regs.h 2015-11-09 23:34:10.000000000 +0100
  30885. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/ar71xx_regs.h 2015-12-04 19:57:05.893979276 +0100
  30886. @@ -20,6 +20,10 @@
  30887. #include <linux/bitops.h>
  30888. #define AR71XX_APB_BASE 0x18000000
  30889. +#define AR71XX_GE0_BASE 0x19000000
  30890. +#define AR71XX_GE0_SIZE 0x10000
  30891. +#define AR71XX_GE1_BASE 0x1a000000
  30892. +#define AR71XX_GE1_SIZE 0x10000
  30893. #define AR71XX_EHCI_BASE 0x1b000000
  30894. #define AR71XX_EHCI_SIZE 0x1000
  30895. #define AR71XX_OHCI_BASE 0x1c000000
  30896. @@ -39,6 +43,8 @@
  30897. #define AR71XX_PLL_SIZE 0x100
  30898. #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
  30899. #define AR71XX_RESET_SIZE 0x100
  30900. +#define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
  30901. +#define AR71XX_MII_SIZE 0x100
  30902. #define AR71XX_PCI_MEM_BASE 0x10000000
  30903. #define AR71XX_PCI_MEM_SIZE 0x07000000
  30904. @@ -81,18 +87,39 @@
  30905. #define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
  30906. #define AR933X_UART_SIZE 0x14
  30907. +#define AR933X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  30908. +#define AR933X_GMAC_SIZE 0x04
  30909. #define AR933X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  30910. #define AR933X_WMAC_SIZE 0x20000
  30911. #define AR933X_EHCI_BASE 0x1b000000
  30912. #define AR933X_EHCI_SIZE 0x1000
  30913. +#define AR934X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  30914. +#define AR934X_GMAC_SIZE 0x14
  30915. #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  30916. #define AR934X_WMAC_SIZE 0x20000
  30917. #define AR934X_EHCI_BASE 0x1b000000
  30918. #define AR934X_EHCI_SIZE 0x200
  30919. +#define AR934X_NFC_BASE 0x1b000200
  30920. +#define AR934X_NFC_SIZE 0xb8
  30921. #define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  30922. #define AR934X_SRIF_SIZE 0x1000
  30923. +#define QCA953X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  30924. +#define QCA953X_GMAC_SIZE 0x14
  30925. +#define QCA953X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  30926. +#define QCA953X_WMAC_SIZE 0x20000
  30927. +#define QCA953X_EHCI_BASE 0x1b000000
  30928. +#define QCA953X_EHCI_SIZE 0x200
  30929. +#define QCA953X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  30930. +#define QCA953X_SRIF_SIZE 0x1000
  30931. +
  30932. +#define QCA953X_PCI_CFG_BASE0 0x14000000
  30933. +#define QCA953X_PCI_CTRL_BASE0 (AR71XX_APB_BASE + 0x000f0000)
  30934. +#define QCA953X_PCI_CRP_BASE0 (AR71XX_APB_BASE + 0x000c0000)
  30935. +#define QCA953X_PCI_MEM_BASE0 0x10000000
  30936. +#define QCA953X_PCI_MEM_SIZE 0x02000000
  30937. +
  30938. #define QCA955X_PCI_MEM_BASE0 0x10000000
  30939. #define QCA955X_PCI_MEM_BASE1 0x12000000
  30940. #define QCA955X_PCI_MEM_SIZE 0x02000000
  30941. @@ -106,11 +133,40 @@
  30942. #define QCA955X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
  30943. #define QCA955X_PCI_CTRL_SIZE 0x100
  30944. +#define QCA955X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  30945. +#define QCA955X_GMAC_SIZE 0x40
  30946. #define QCA955X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  30947. #define QCA955X_WMAC_SIZE 0x20000
  30948. #define QCA955X_EHCI0_BASE 0x1b000000
  30949. #define QCA955X_EHCI1_BASE 0x1b400000
  30950. #define QCA955X_EHCI_SIZE 0x1000
  30951. +#define QCA955X_NFC_BASE 0x1b800200
  30952. +#define QCA955X_NFC_SIZE 0xb8
  30953. +
  30954. +#define QCA956X_PCI_MEM_BASE1 0x12000000
  30955. +#define QCA956X_PCI_MEM_SIZE 0x02000000
  30956. +#define QCA956X_PCI_CFG_BASE1 0x16000000
  30957. +#define QCA956X_PCI_CFG_SIZE 0x1000
  30958. +#define QCA956X_PCI_CRP_BASE1 (AR71XX_APB_BASE + 0x00250000)
  30959. +#define QCA956X_PCI_CRP_SIZE 0x1000
  30960. +#define QCA956X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
  30961. +#define QCA956X_PCI_CTRL_SIZE 0x100
  30962. +
  30963. +#define QCA956X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  30964. +#define QCA956X_WMAC_SIZE 0x20000
  30965. +#define QCA956X_EHCI0_BASE 0x1b000000
  30966. +#define QCA956X_EHCI1_BASE 0x1b400000
  30967. +#define QCA956X_EHCI_SIZE 0x200
  30968. +#define QCA956X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  30969. +#define QCA956X_GMAC_SIZE 0x64
  30970. +
  30971. +#define AR9300_OTP_BASE 0x14000
  30972. +#define AR9300_OTP_STATUS 0x15f18
  30973. +#define AR9300_OTP_STATUS_TYPE 0x7
  30974. +#define AR9300_OTP_STATUS_VALID 0x4
  30975. +#define AR9300_OTP_STATUS_ACCESS_BUSY 0x2
  30976. +#define AR9300_OTP_STATUS_SM_BUSY 0x1
  30977. +#define AR9300_OTP_READ_DATA 0x15f1c
  30978. /*
  30979. * DDR_CTRL block
  30980. @@ -149,6 +205,12 @@
  30981. #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
  30982. #define AR934X_DDR_REG_FLUSH_WMAC 0xac
  30983. +#define QCA953X_DDR_REG_FLUSH_GE0 0x9c
  30984. +#define QCA953X_DDR_REG_FLUSH_GE1 0xa0
  30985. +#define QCA953X_DDR_REG_FLUSH_USB 0xa4
  30986. +#define QCA953X_DDR_REG_FLUSH_PCIE 0xa8
  30987. +#define QCA953X_DDR_REG_FLUSH_WMAC 0xac
  30988. +
  30989. /*
  30990. * PLL block
  30991. */
  30992. @@ -166,6 +228,9 @@
  30993. #define AR71XX_AHB_DIV_SHIFT 20
  30994. #define AR71XX_AHB_DIV_MASK 0x7
  30995. +#define AR71XX_ETH0_PLL_SHIFT 17
  30996. +#define AR71XX_ETH1_PLL_SHIFT 19
  30997. +
  30998. #define AR724X_PLL_REG_CPU_CONFIG 0x00
  30999. #define AR724X_PLL_REG_PCIE_CONFIG 0x18
  31000. @@ -178,6 +243,8 @@
  31001. #define AR724X_DDR_DIV_SHIFT 22
  31002. #define AR724X_DDR_DIV_MASK 0x3
  31003. +#define AR7242_PLL_REG_ETH0_INT_CLOCK 0x2c
  31004. +
  31005. #define AR913X_PLL_REG_CPU_CONFIG 0x00
  31006. #define AR913X_PLL_REG_ETH_CONFIG 0x04
  31007. #define AR913X_PLL_REG_ETH0_INT_CLOCK 0x14
  31008. @@ -190,6 +257,9 @@
  31009. #define AR913X_AHB_DIV_SHIFT 19
  31010. #define AR913X_AHB_DIV_MASK 0x1
  31011. +#define AR913X_ETH0_PLL_SHIFT 20
  31012. +#define AR913X_ETH1_PLL_SHIFT 22
  31013. +
  31014. #define AR933X_PLL_CPU_CONFIG_REG 0x00
  31015. #define AR933X_PLL_CLOCK_CTRL_REG 0x08
  31016. @@ -211,6 +281,8 @@
  31017. #define AR934X_PLL_CPU_CONFIG_REG 0x00
  31018. #define AR934X_PLL_DDR_CONFIG_REG 0x04
  31019. #define AR934X_PLL_CPU_DDR_CLK_CTRL_REG 0x08
  31020. +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
  31021. +#define AR934X_PLL_ETH_XMII_CONTROL_REG 0x2c
  31022. #define AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  31023. #define AR934X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  31024. @@ -243,9 +315,51 @@
  31025. #define AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  31026. #define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  31027. +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
  31028. +
  31029. +#define QCA953X_PLL_CPU_CONFIG_REG 0x00
  31030. +#define QCA953X_PLL_DDR_CONFIG_REG 0x04
  31031. +#define QCA953X_PLL_CLK_CTRL_REG 0x08
  31032. +#define QCA953X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
  31033. +#define QCA953X_PLL_ETH_XMII_CONTROL_REG 0x2c
  31034. +#define QCA953X_PLL_ETH_SGMII_CONTROL_REG 0x48
  31035. +
  31036. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  31037. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  31038. +#define QCA953X_PLL_CPU_CONFIG_NINT_SHIFT 6
  31039. +#define QCA953X_PLL_CPU_CONFIG_NINT_MASK 0x3f
  31040. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  31041. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  31042. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  31043. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
  31044. +
  31045. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
  31046. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
  31047. +#define QCA953X_PLL_DDR_CONFIG_NINT_SHIFT 10
  31048. +#define QCA953X_PLL_DDR_CONFIG_NINT_MASK 0x3f
  31049. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  31050. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  31051. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  31052. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  31053. +
  31054. +#define QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  31055. +#define QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  31056. +#define QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  31057. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  31058. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  31059. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  31060. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  31061. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  31062. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  31063. +#define QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
  31064. +#define QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  31065. +#define QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  31066. +
  31067. #define QCA955X_PLL_CPU_CONFIG_REG 0x00
  31068. #define QCA955X_PLL_DDR_CONFIG_REG 0x04
  31069. #define QCA955X_PLL_CLK_CTRL_REG 0x08
  31070. +#define QCA955X_PLL_ETH_XMII_CONTROL_REG 0x28
  31071. +#define QCA955X_PLL_ETH_SGMII_CONTROL_REG 0x48
  31072. #define QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  31073. #define QCA955X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  31074. @@ -278,6 +392,49 @@
  31075. #define QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  31076. #define QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  31077. +#define QCA956X_PLL_CPU_CONFIG_REG 0x00
  31078. +#define QCA956X_PLL_CPU_CONFIG1_REG 0x04
  31079. +#define QCA956X_PLL_DDR_CONFIG_REG 0x08
  31080. +#define QCA956X_PLL_DDR_CONFIG1_REG 0x0c
  31081. +#define QCA956X_PLL_CLK_CTRL_REG 0x10
  31082. +
  31083. +#define QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  31084. +#define QCA956X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  31085. +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  31086. +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
  31087. +
  31088. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT 0
  31089. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK 0x1f
  31090. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT 5
  31091. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK 0x1fff
  31092. +#define QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT 18
  31093. +#define QCA956X_PLL_CPU_CONFIG1_NINT_MASK 0x1ff
  31094. +
  31095. +#define QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  31096. +#define QCA956X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  31097. +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  31098. +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  31099. +
  31100. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT 0
  31101. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK 0x1f
  31102. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT 5
  31103. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK 0x1fff
  31104. +#define QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT 18
  31105. +#define QCA956X_PLL_DDR_CONFIG1_NINT_MASK 0x1ff
  31106. +
  31107. +#define QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  31108. +#define QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  31109. +#define QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  31110. +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  31111. +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  31112. +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  31113. +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  31114. +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  31115. +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  31116. +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL BIT(20)
  31117. +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL BIT(21)
  31118. +#define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  31119. +
  31120. /*
  31121. * USB_CONFIG block
  31122. */
  31123. @@ -317,10 +474,19 @@
  31124. #define AR934X_RESET_REG_BOOTSTRAP 0xb0
  31125. #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  31126. +#define QCA953X_RESET_REG_RESET_MODULE 0x1c
  31127. +#define QCA953X_RESET_REG_BOOTSTRAP 0xb0
  31128. +#define QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  31129. +
  31130. #define QCA955X_RESET_REG_RESET_MODULE 0x1c
  31131. #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
  31132. #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
  31133. +#define QCA956X_RESET_REG_RESET_MODULE 0x1c
  31134. +#define QCA956X_RESET_REG_BOOTSTRAP 0xb0
  31135. +#define QCA956X_RESET_REG_EXT_INT_STATUS 0xac
  31136. +
  31137. +#define MISC_INT_MIPS_SI_TIMERINT_MASK BIT(28)
  31138. #define MISC_INT_ETHSW BIT(12)
  31139. #define MISC_INT_TIMER4 BIT(10)
  31140. #define MISC_INT_TIMER3 BIT(9)
  31141. @@ -370,16 +536,104 @@
  31142. #define AR913X_RESET_USB_HOST BIT(5)
  31143. #define AR913X_RESET_USB_PHY BIT(4)
  31144. +#define AR933X_RESET_GE1_MDIO BIT(23)
  31145. +#define AR933X_RESET_GE0_MDIO BIT(22)
  31146. +#define AR933X_RESET_GE1_MAC BIT(13)
  31147. #define AR933X_RESET_WMAC BIT(11)
  31148. +#define AR933X_RESET_GE0_MAC BIT(9)
  31149. #define AR933X_RESET_USB_HOST BIT(5)
  31150. #define AR933X_RESET_USB_PHY BIT(4)
  31151. #define AR933X_RESET_USBSUS_OVERRIDE BIT(3)
  31152. +#define AR934X_RESET_HOST BIT(31)
  31153. +#define AR934X_RESET_SLIC BIT(30)
  31154. +#define AR934X_RESET_HDMA BIT(29)
  31155. +#define AR934X_RESET_EXTERNAL BIT(28)
  31156. +#define AR934X_RESET_RTC BIT(27)
  31157. +#define AR934X_RESET_PCIE_EP_INT BIT(26)
  31158. +#define AR934X_RESET_CHKSUM_ACC BIT(25)
  31159. +#define AR934X_RESET_FULL_CHIP BIT(24)
  31160. +#define AR934X_RESET_GE1_MDIO BIT(23)
  31161. +#define AR934X_RESET_GE0_MDIO BIT(22)
  31162. +#define AR934X_RESET_CPU_NMI BIT(21)
  31163. +#define AR934X_RESET_CPU_COLD BIT(20)
  31164. +#define AR934X_RESET_HOST_RESET_INT BIT(19)
  31165. +#define AR934X_RESET_PCIE_EP BIT(18)
  31166. +#define AR934X_RESET_UART1 BIT(17)
  31167. +#define AR934X_RESET_DDR BIT(16)
  31168. +#define AR934X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  31169. +#define AR934X_RESET_NANDF BIT(14)
  31170. +#define AR934X_RESET_GE1_MAC BIT(13)
  31171. +#define AR934X_RESET_ETH_SWITCH_ANALOG BIT(12)
  31172. #define AR934X_RESET_USB_PHY_ANALOG BIT(11)
  31173. +#define AR934X_RESET_HOST_DMA_INT BIT(10)
  31174. +#define AR934X_RESET_GE0_MAC BIT(9)
  31175. +#define AR934X_RESET_ETH_SWITCH BIT(8)
  31176. +#define AR934X_RESET_PCIE_PHY BIT(7)
  31177. +#define AR934X_RESET_PCIE BIT(6)
  31178. #define AR934X_RESET_USB_HOST BIT(5)
  31179. #define AR934X_RESET_USB_PHY BIT(4)
  31180. #define AR934X_RESET_USBSUS_OVERRIDE BIT(3)
  31181. +#define AR934X_RESET_LUT BIT(2)
  31182. +#define AR934X_RESET_MBOX BIT(1)
  31183. +#define AR934X_RESET_I2S BIT(0)
  31184. +
  31185. +#define QCA953X_RESET_USB_EXT_PWR BIT(29)
  31186. +#define QCA953X_RESET_EXTERNAL BIT(28)
  31187. +#define QCA953X_RESET_RTC BIT(27)
  31188. +#define QCA953X_RESET_FULL_CHIP BIT(24)
  31189. +#define QCA953X_RESET_GE1_MDIO BIT(23)
  31190. +#define QCA953X_RESET_GE0_MDIO BIT(22)
  31191. +#define QCA953X_RESET_CPU_NMI BIT(21)
  31192. +#define QCA953X_RESET_CPU_COLD BIT(20)
  31193. +#define QCA953X_RESET_DDR BIT(16)
  31194. +#define QCA953X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  31195. +#define QCA953X_RESET_GE1_MAC BIT(13)
  31196. +#define QCA953X_RESET_ETH_SWITCH_ANALOG BIT(12)
  31197. +#define QCA953X_RESET_USB_PHY_ANALOG BIT(11)
  31198. +#define QCA953X_RESET_GE0_MAC BIT(9)
  31199. +#define QCA953X_RESET_ETH_SWITCH BIT(8)
  31200. +#define QCA953X_RESET_PCIE_PHY BIT(7)
  31201. +#define QCA953X_RESET_PCIE BIT(6)
  31202. +#define QCA953X_RESET_USB_HOST BIT(5)
  31203. +#define QCA953X_RESET_USB_PHY BIT(4)
  31204. +#define QCA953X_RESET_USBSUS_OVERRIDE BIT(3)
  31205. +
  31206. +#define QCA955X_RESET_HOST BIT(31)
  31207. +#define QCA955X_RESET_SLIC BIT(30)
  31208. +#define QCA955X_RESET_HDMA BIT(29)
  31209. +#define QCA955X_RESET_EXTERNAL BIT(28)
  31210. +#define QCA955X_RESET_RTC BIT(27)
  31211. +#define QCA955X_RESET_PCIE_EP_INT BIT(26)
  31212. +#define QCA955X_RESET_CHKSUM_ACC BIT(25)
  31213. +#define QCA955X_RESET_FULL_CHIP BIT(24)
  31214. +#define QCA955X_RESET_GE1_MDIO BIT(23)
  31215. +#define QCA955X_RESET_GE0_MDIO BIT(22)
  31216. +#define QCA955X_RESET_CPU_NMI BIT(21)
  31217. +#define QCA955X_RESET_CPU_COLD BIT(20)
  31218. +#define QCA955X_RESET_HOST_RESET_INT BIT(19)
  31219. +#define QCA955X_RESET_PCIE_EP BIT(18)
  31220. +#define QCA955X_RESET_UART1 BIT(17)
  31221. +#define QCA955X_RESET_DDR BIT(16)
  31222. +#define QCA955X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  31223. +#define QCA955X_RESET_NANDF BIT(14)
  31224. +#define QCA955X_RESET_GE1_MAC BIT(13)
  31225. +#define QCA955X_RESET_SGMII_ANALOG BIT(12)
  31226. +#define QCA955X_RESET_USB_PHY_ANALOG BIT(11)
  31227. +#define QCA955X_RESET_HOST_DMA_INT BIT(10)
  31228. +#define QCA955X_RESET_GE0_MAC BIT(9)
  31229. +#define QCA955X_RESET_SGMII BIT(8)
  31230. +#define QCA955X_RESET_PCIE_PHY BIT(7)
  31231. +#define QCA955X_RESET_PCIE BIT(6)
  31232. +#define QCA955X_RESET_USB_HOST BIT(5)
  31233. +#define QCA955X_RESET_USB_PHY BIT(4)
  31234. +#define QCA955X_RESET_USBSUS_OVERRIDE BIT(3)
  31235. +#define QCA955X_RESET_LUT BIT(2)
  31236. +#define QCA955X_RESET_MBOX BIT(1)
  31237. +#define QCA955X_RESET_I2S BIT(0)
  31238. +#define AR933X_BOOTSTRAP_MDIO_GPIO_EN BIT(18)
  31239. +#define AR933X_BOOTSTRAP_EEPBUSY BIT(4)
  31240. #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
  31241. #define AR934X_BOOTSTRAP_SW_OPTION8 BIT(23)
  31242. @@ -398,8 +652,17 @@
  31243. #define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  31244. #define AR934X_BOOTSTRAP_DDR1 BIT(0)
  31245. +#define QCA953X_BOOTSTRAP_SW_OPTION2 BIT(12)
  31246. +#define QCA953X_BOOTSTRAP_SW_OPTION1 BIT(11)
  31247. +#define QCA953X_BOOTSTRAP_EJTAG_MODE BIT(5)
  31248. +#define QCA953X_BOOTSTRAP_REF_CLK_40 BIT(4)
  31249. +#define QCA953X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  31250. +#define QCA953X_BOOTSTRAP_DDR1 BIT(0)
  31251. +
  31252. #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
  31253. +#define QCA956X_BOOTSTRAP_REF_CLK_40 BIT(2)
  31254. +
  31255. #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  31256. #define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  31257. #define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  31258. @@ -418,6 +681,24 @@
  31259. AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
  31260. AR934X_PCIE_WMAC_INT_PCIE_RC3)
  31261. +#define QCA953X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  31262. +#define QCA953X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  31263. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  31264. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXHP BIT(3)
  31265. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC BIT(4)
  31266. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC0 BIT(5)
  31267. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC1 BIT(6)
  31268. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC2 BIT(7)
  31269. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC3 BIT(8)
  31270. +#define QCA953X_PCIE_WMAC_INT_WMAC_ALL \
  31271. + (QCA953X_PCIE_WMAC_INT_WMAC_MISC | QCA953X_PCIE_WMAC_INT_WMAC_TX | \
  31272. + QCA953X_PCIE_WMAC_INT_WMAC_RXLP | QCA953X_PCIE_WMAC_INT_WMAC_RXHP)
  31273. +
  31274. +#define QCA953X_PCIE_WMAC_INT_PCIE_ALL \
  31275. + (QCA953X_PCIE_WMAC_INT_PCIE_RC | QCA953X_PCIE_WMAC_INT_PCIE_RC0 | \
  31276. + QCA953X_PCIE_WMAC_INT_PCIE_RC1 | QCA953X_PCIE_WMAC_INT_PCIE_RC2 | \
  31277. + QCA953X_PCIE_WMAC_INT_PCIE_RC3)
  31278. +
  31279. #define QCA955X_EXT_INT_WMAC_MISC BIT(0)
  31280. #define QCA955X_EXT_INT_WMAC_TX BIT(1)
  31281. #define QCA955X_EXT_INT_WMAC_RXLP BIT(2)
  31282. @@ -449,6 +730,37 @@
  31283. QCA955X_EXT_INT_PCIE_RC2_INT1 | QCA955X_EXT_INT_PCIE_RC2_INT2 | \
  31284. QCA955X_EXT_INT_PCIE_RC2_INT3)
  31285. +#define QCA956X_EXT_INT_WMAC_MISC BIT(0)
  31286. +#define QCA956X_EXT_INT_WMAC_TX BIT(1)
  31287. +#define QCA956X_EXT_INT_WMAC_RXLP BIT(2)
  31288. +#define QCA956X_EXT_INT_WMAC_RXHP BIT(3)
  31289. +#define QCA956X_EXT_INT_PCIE_RC1 BIT(4)
  31290. +#define QCA956X_EXT_INT_PCIE_RC1_INT0 BIT(5)
  31291. +#define QCA956X_EXT_INT_PCIE_RC1_INT1 BIT(6)
  31292. +#define QCA956X_EXT_INT_PCIE_RC1_INT2 BIT(7)
  31293. +#define QCA956X_EXT_INT_PCIE_RC1_INT3 BIT(8)
  31294. +#define QCA956X_EXT_INT_PCIE_RC2 BIT(12)
  31295. +#define QCA956X_EXT_INT_PCIE_RC2_INT0 BIT(13)
  31296. +#define QCA956X_EXT_INT_PCIE_RC2_INT1 BIT(14)
  31297. +#define QCA956X_EXT_INT_PCIE_RC2_INT2 BIT(15)
  31298. +#define QCA956X_EXT_INT_PCIE_RC2_INT3 BIT(16)
  31299. +#define QCA956X_EXT_INT_USB1 BIT(24)
  31300. +#define QCA956X_EXT_INT_USB2 BIT(28)
  31301. +
  31302. +#define QCA956X_EXT_INT_WMAC_ALL \
  31303. + (QCA956X_EXT_INT_WMAC_MISC | QCA956X_EXT_INT_WMAC_TX | \
  31304. + QCA956X_EXT_INT_WMAC_RXLP | QCA956X_EXT_INT_WMAC_RXHP)
  31305. +
  31306. +#define QCA956X_EXT_INT_PCIE_RC1_ALL \
  31307. + (QCA956X_EXT_INT_PCIE_RC1 | QCA956X_EXT_INT_PCIE_RC1_INT0 | \
  31308. + QCA956X_EXT_INT_PCIE_RC1_INT1 | QCA956X_EXT_INT_PCIE_RC1_INT2 | \
  31309. + QCA956X_EXT_INT_PCIE_RC1_INT3)
  31310. +
  31311. +#define QCA956X_EXT_INT_PCIE_RC2_ALL \
  31312. + (QCA956X_EXT_INT_PCIE_RC2 | QCA956X_EXT_INT_PCIE_RC2_INT0 | \
  31313. + QCA956X_EXT_INT_PCIE_RC2_INT1 | QCA956X_EXT_INT_PCIE_RC2_INT2 | \
  31314. + QCA956X_EXT_INT_PCIE_RC2_INT3)
  31315. +
  31316. #define REV_ID_MAJOR_MASK 0xfff0
  31317. #define REV_ID_MAJOR_AR71XX 0x00a0
  31318. #define REV_ID_MAJOR_AR913X 0x00b0
  31319. @@ -460,8 +772,12 @@
  31320. #define REV_ID_MAJOR_AR9341 0x0120
  31321. #define REV_ID_MAJOR_AR9342 0x1120
  31322. #define REV_ID_MAJOR_AR9344 0x2120
  31323. +#define REV_ID_MAJOR_QCA9533 0x0140
  31324. +#define REV_ID_MAJOR_QCA9533_V2 0x0160
  31325. #define REV_ID_MAJOR_QCA9556 0x0130
  31326. #define REV_ID_MAJOR_QCA9558 0x1130
  31327. +#define REV_ID_MAJOR_TP9343 0x0150
  31328. +#define REV_ID_MAJOR_QCA9561 0x1150
  31329. #define AR71XX_REV_ID_MINOR_MASK 0x3
  31330. #define AR71XX_REV_ID_MINOR_AR7130 0x0
  31331. @@ -482,8 +798,12 @@
  31332. #define AR934X_REV_ID_REVISION_MASK 0xf
  31333. +#define QCA953X_REV_ID_REVISION_MASK 0xf
  31334. +
  31335. #define QCA955X_REV_ID_REVISION_MASK 0xf
  31336. +#define QCA956X_REV_ID_REVISION_MASK 0xf
  31337. +
  31338. /*
  31339. * SPI block
  31340. */
  31341. @@ -520,16 +840,65 @@
  31342. #define AR71XX_GPIO_REG_INT_PENDING 0x20
  31343. #define AR71XX_GPIO_REG_INT_ENABLE 0x24
  31344. #define AR71XX_GPIO_REG_FUNC 0x28
  31345. +#define AR71XX_GPIO_REG_FUNC_2 0x30
  31346. +#define AR934X_GPIO_REG_OUT_FUNC0 0x2c
  31347. +#define AR934X_GPIO_REG_OUT_FUNC1 0x30
  31348. +#define AR934X_GPIO_REG_OUT_FUNC2 0x34
  31349. +#define AR934X_GPIO_REG_OUT_FUNC3 0x38
  31350. +#define AR934X_GPIO_REG_OUT_FUNC4 0x3c
  31351. +#define AR934X_GPIO_REG_OUT_FUNC5 0x40
  31352. #define AR934X_GPIO_REG_FUNC 0x6c
  31353. +#define QCA953X_GPIO_REG_OUT_FUNC0 0x2c
  31354. +#define QCA953X_GPIO_REG_OUT_FUNC1 0x30
  31355. +#define QCA953X_GPIO_REG_OUT_FUNC2 0x34
  31356. +#define QCA953X_GPIO_REG_OUT_FUNC3 0x38
  31357. +#define QCA953X_GPIO_REG_OUT_FUNC4 0x3c
  31358. +#define QCA953X_GPIO_REG_IN_ENABLE0 0x44
  31359. +#define QCA953X_GPIO_REG_FUNC 0x6c
  31360. +
  31361. +#define QCA953X_GPIO_OUT_MUX_SPI_CS1 10
  31362. +#define QCA953X_GPIO_OUT_MUX_SPI_CS2 11
  31363. +#define QCA953X_GPIO_OUT_MUX_SPI_CS0 9
  31364. +#define QCA953X_GPIO_OUT_MUX_SPI_CLK 8
  31365. +#define QCA953X_GPIO_OUT_MUX_SPI_MOSI 12
  31366. +#define QCA953X_GPIO_OUT_MUX_LED_LINK1 41
  31367. +#define QCA953X_GPIO_OUT_MUX_LED_LINK2 42
  31368. +#define QCA953X_GPIO_OUT_MUX_LED_LINK3 43
  31369. +#define QCA953X_GPIO_OUT_MUX_LED_LINK4 44
  31370. +#define QCA953X_GPIO_OUT_MUX_LED_LINK5 45
  31371. +
  31372. +#define QCA955X_GPIO_REG_OUT_FUNC0 0x2c
  31373. +#define QCA955X_GPIO_REG_OUT_FUNC1 0x30
  31374. +#define QCA955X_GPIO_REG_OUT_FUNC2 0x34
  31375. +#define QCA955X_GPIO_REG_OUT_FUNC3 0x38
  31376. +#define QCA955X_GPIO_REG_OUT_FUNC4 0x3c
  31377. +#define QCA955X_GPIO_REG_OUT_FUNC5 0x40
  31378. +#define QCA955X_GPIO_REG_FUNC 0x6c
  31379. +
  31380. +#define QCA956X_GPIO_REG_OUT_FUNC0 0x2c
  31381. +#define QCA956X_GPIO_REG_OUT_FUNC1 0x30
  31382. +#define QCA956X_GPIO_REG_OUT_FUNC2 0x34
  31383. +#define QCA956X_GPIO_REG_OUT_FUNC3 0x38
  31384. +#define QCA956X_GPIO_REG_OUT_FUNC4 0x3c
  31385. +#define QCA956X_GPIO_REG_OUT_FUNC5 0x40
  31386. +#define QCA956X_GPIO_REG_IN_ENABLE0 0x44
  31387. +#define QCA956X_GPIO_REG_IN_ENABLE3 0x50
  31388. +#define QCA956X_GPIO_REG_FUNC 0x6c
  31389. +
  31390. +#define QCA956X_GPIO_OUT_MUX_GE0_MDO 32
  31391. +#define QCA956X_GPIO_OUT_MUX_GE0_MDC 33
  31392. +
  31393. #define AR71XX_GPIO_COUNT 16
  31394. #define AR7240_GPIO_COUNT 18
  31395. #define AR7241_GPIO_COUNT 20
  31396. #define AR913X_GPIO_COUNT 22
  31397. #define AR933X_GPIO_COUNT 30
  31398. #define AR934X_GPIO_COUNT 23
  31399. +#define QCA953X_GPIO_COUNT 18
  31400. #define QCA955X_GPIO_COUNT 24
  31401. +#define QCA956X_GPIO_COUNT 23
  31402. /*
  31403. * SRIF block
  31404. @@ -552,4 +921,185 @@
  31405. #define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
  31406. #define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
  31407. +#define QCA953X_SRIF_CPU_DPLL1_REG 0x1c0
  31408. +#define QCA953X_SRIF_CPU_DPLL2_REG 0x1c4
  31409. +#define QCA953X_SRIF_CPU_DPLL3_REG 0x1c8
  31410. +
  31411. +#define QCA953X_SRIF_DDR_DPLL1_REG 0x240
  31412. +#define QCA953X_SRIF_DDR_DPLL2_REG 0x244
  31413. +#define QCA953X_SRIF_DDR_DPLL3_REG 0x248
  31414. +
  31415. +#define QCA953X_SRIF_DPLL1_REFDIV_SHIFT 27
  31416. +#define QCA953X_SRIF_DPLL1_REFDIV_MASK 0x1f
  31417. +#define QCA953X_SRIF_DPLL1_NINT_SHIFT 18
  31418. +#define QCA953X_SRIF_DPLL1_NINT_MASK 0x1ff
  31419. +#define QCA953X_SRIF_DPLL1_NFRAC_MASK 0x0003ffff
  31420. +
  31421. +#define QCA953X_SRIF_DPLL2_LOCAL_PLL BIT(30)
  31422. +#define QCA953X_SRIF_DPLL2_OUTDIV_SHIFT 13
  31423. +#define QCA953X_SRIF_DPLL2_OUTDIV_MASK 0x7
  31424. +
  31425. +#define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
  31426. +#define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
  31427. +#define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
  31428. +#define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
  31429. +#define AR71XX_GPIO_FUNC_UART_EN BIT(8)
  31430. +#define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
  31431. +#define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
  31432. +
  31433. +#define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
  31434. +#define AR724X_GPIO_FUNC_SPI_EN BIT(18)
  31435. +#define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
  31436. +#define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
  31437. +#define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
  31438. +#define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
  31439. +#define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
  31440. +#define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
  31441. +#define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
  31442. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
  31443. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
  31444. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
  31445. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
  31446. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
  31447. +#define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
  31448. +#define AR724X_GPIO_FUNC_UART_EN BIT(1)
  31449. +#define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
  31450. +
  31451. +#define AR933X_GPIO_FUNC2_JUMPSTART_DISABLE BIT(9)
  31452. +
  31453. +#define AR913X_GPIO_FUNC_WMAC_LED_EN BIT(22)
  31454. +#define AR913X_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
  31455. +#define AR913X_GPIO_FUNC_I2S_REFCLKEN BIT(20)
  31456. +#define AR913X_GPIO_FUNC_I2S_MCKEN BIT(19)
  31457. +#define AR913X_GPIO_FUNC_I2S1_EN BIT(18)
  31458. +#define AR913X_GPIO_FUNC_I2S0_EN BIT(17)
  31459. +#define AR913X_GPIO_FUNC_SLIC_EN BIT(16)
  31460. +#define AR913X_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
  31461. +#define AR913X_GPIO_FUNC_UART_EN BIT(8)
  31462. +#define AR913X_GPIO_FUNC_USB_CLK_EN BIT(4)
  31463. +
  31464. +#define AR933X_GPIO_FUNC_SPDIF2TCK BIT(31)
  31465. +#define AR933X_GPIO_FUNC_SPDIF_EN BIT(30)
  31466. +#define AR933X_GPIO_FUNC_I2SO_22_18_EN BIT(29)
  31467. +#define AR933X_GPIO_FUNC_I2S_MCK_EN BIT(27)
  31468. +#define AR933X_GPIO_FUNC_I2SO_EN BIT(26)
  31469. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_DUPL BIT(25)
  31470. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_COLL BIT(24)
  31471. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_ACT BIT(23)
  31472. +#define AR933X_GPIO_FUNC_SPI_EN BIT(18)
  31473. +#define AR933X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
  31474. +#define AR933X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
  31475. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
  31476. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
  31477. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
  31478. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
  31479. +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
  31480. +#define AR933X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
  31481. +#define AR933X_GPIO_FUNC_UART_EN BIT(1)
  31482. +#define AR933X_GPIO_FUNC_JTAG_DISABLE BIT(0)
  31483. +
  31484. +#define AR934X_GPIO_FUNC_CLK_OBS7_EN BIT(9)
  31485. +#define AR934X_GPIO_FUNC_CLK_OBS6_EN BIT(8)
  31486. +#define AR934X_GPIO_FUNC_CLK_OBS5_EN BIT(7)
  31487. +#define AR934X_GPIO_FUNC_CLK_OBS4_EN BIT(6)
  31488. +#define AR934X_GPIO_FUNC_CLK_OBS3_EN BIT(5)
  31489. +#define AR934X_GPIO_FUNC_CLK_OBS2_EN BIT(4)
  31490. +#define AR934X_GPIO_FUNC_CLK_OBS1_EN BIT(3)
  31491. +#define AR934X_GPIO_FUNC_CLK_OBS0_EN BIT(2)
  31492. +#define AR934X_GPIO_FUNC_JTAG_DISABLE BIT(1)
  31493. +
  31494. +#define AR934X_GPIO_OUT_GPIO 0
  31495. +#define AR934X_GPIO_OUT_SPI_CS1 7
  31496. +#define AR934X_GPIO_OUT_LED_LINK0 41
  31497. +#define AR934X_GPIO_OUT_LED_LINK1 42
  31498. +#define AR934X_GPIO_OUT_LED_LINK2 43
  31499. +#define AR934X_GPIO_OUT_LED_LINK3 44
  31500. +#define AR934X_GPIO_OUT_LED_LINK4 45
  31501. +#define AR934X_GPIO_OUT_EXT_LNA0 46
  31502. +#define AR934X_GPIO_OUT_EXT_LNA1 47
  31503. +
  31504. +#define QCA955X_GPIO_OUT_GPIO 0
  31505. +
  31506. +/*
  31507. + * MII_CTRL block
  31508. + */
  31509. +#define AR71XX_MII_REG_MII0_CTRL 0x00
  31510. +#define AR71XX_MII_REG_MII1_CTRL 0x04
  31511. +
  31512. +#define AR71XX_MII_CTRL_IF_MASK 3
  31513. +#define AR71XX_MII_CTRL_SPEED_SHIFT 4
  31514. +#define AR71XX_MII_CTRL_SPEED_MASK 3
  31515. +#define AR71XX_MII_CTRL_SPEED_10 0
  31516. +#define AR71XX_MII_CTRL_SPEED_100 1
  31517. +#define AR71XX_MII_CTRL_SPEED_1000 2
  31518. +
  31519. +#define AR71XX_MII0_CTRL_IF_GMII 0
  31520. +#define AR71XX_MII0_CTRL_IF_MII 1
  31521. +#define AR71XX_MII0_CTRL_IF_RGMII 2
  31522. +#define AR71XX_MII0_CTRL_IF_RMII 3
  31523. +
  31524. +#define AR71XX_MII1_CTRL_IF_RGMII 0
  31525. +#define AR71XX_MII1_CTRL_IF_RMII 1
  31526. +
  31527. +/*
  31528. + * AR933X GMAC interface
  31529. + */
  31530. +#define AR933X_GMAC_REG_ETH_CFG 0x00
  31531. +
  31532. +#define AR933X_ETH_CFG_RGMII_GE0 BIT(0)
  31533. +#define AR933X_ETH_CFG_MII_GE0 BIT(1)
  31534. +#define AR933X_ETH_CFG_GMII_GE0 BIT(2)
  31535. +#define AR933X_ETH_CFG_MII_GE0_MASTER BIT(3)
  31536. +#define AR933X_ETH_CFG_MII_GE0_SLAVE BIT(4)
  31537. +#define AR933X_ETH_CFG_MII_GE0_ERR_EN BIT(5)
  31538. +#define AR933X_ETH_CFG_SW_PHY_SWAP BIT(7)
  31539. +#define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP BIT(8)
  31540. +#define AR933X_ETH_CFG_RMII_GE0 BIT(9)
  31541. +#define AR933X_ETH_CFG_RMII_GE0_SPD_10 0
  31542. +#define AR933X_ETH_CFG_RMII_GE0_SPD_100 BIT(10)
  31543. +
  31544. +/*
  31545. + * AR934X GMAC Interface
  31546. + */
  31547. +#define AR934X_GMAC_REG_ETH_CFG 0x00
  31548. +
  31549. +#define AR934X_ETH_CFG_RGMII_GMAC0 BIT(0)
  31550. +#define AR934X_ETH_CFG_MII_GMAC0 BIT(1)
  31551. +#define AR934X_ETH_CFG_GMII_GMAC0 BIT(2)
  31552. +#define AR934X_ETH_CFG_MII_GMAC0_MASTER BIT(3)
  31553. +#define AR934X_ETH_CFG_MII_GMAC0_SLAVE BIT(4)
  31554. +#define AR934X_ETH_CFG_MII_GMAC0_ERR_EN BIT(5)
  31555. +#define AR934X_ETH_CFG_SW_ONLY_MODE BIT(6)
  31556. +#define AR934X_ETH_CFG_SW_PHY_SWAP BIT(7)
  31557. +#define AR934X_ETH_CFG_SW_APB_ACCESS BIT(9)
  31558. +#define AR934X_ETH_CFG_RMII_GMAC0 BIT(10)
  31559. +#define AR933X_ETH_CFG_MII_CNTL_SPEED BIT(11)
  31560. +#define AR934X_ETH_CFG_RMII_GMAC0_MASTER BIT(12)
  31561. +#define AR933X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
  31562. +#define AR934X_ETH_CFG_RXD_DELAY BIT(14)
  31563. +#define AR934X_ETH_CFG_RXD_DELAY_MASK 0x3
  31564. +#define AR934X_ETH_CFG_RXD_DELAY_SHIFT 14
  31565. +#define AR934X_ETH_CFG_RDV_DELAY BIT(16)
  31566. +#define AR934X_ETH_CFG_RDV_DELAY_MASK 0x3
  31567. +#define AR934X_ETH_CFG_RDV_DELAY_SHIFT 16
  31568. +
  31569. +/*
  31570. + * QCA953X GMAC Interface
  31571. + */
  31572. +#define QCA953X_GMAC_REG_ETH_CFG 0x00
  31573. +
  31574. +#define QCA953X_ETH_CFG_SW_ONLY_MODE BIT(6)
  31575. +#define QCA953X_ETH_CFG_SW_PHY_SWAP BIT(7)
  31576. +#define QCA953X_ETH_CFG_SW_APB_ACCESS BIT(9)
  31577. +#define QCA953X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
  31578. +
  31579. +/*
  31580. + * QCA955X GMAC Interface
  31581. + */
  31582. +
  31583. +#define QCA955X_GMAC_REG_ETH_CFG 0x00
  31584. +
  31585. +#define QCA955X_ETH_CFG_RGMII_EN BIT(0)
  31586. +#define QCA955X_ETH_CFG_GE0_SGMII BIT(6)
  31587. +
  31588. #endif /* __ASM_MACH_AR71XX_REGS_H */
  31589. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ath79.h linux-4.1.13/arch/mips/include/asm/mach-ath79/ath79.h
  31590. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ath79.h 2015-11-09 23:34:10.000000000 +0100
  31591. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/ath79.h 2015-12-04 19:57:04.482071652 +0100
  31592. @@ -32,8 +32,11 @@
  31593. ATH79_SOC_AR9341,
  31594. ATH79_SOC_AR9342,
  31595. ATH79_SOC_AR9344,
  31596. + ATH79_SOC_QCA9533,
  31597. ATH79_SOC_QCA9556,
  31598. ATH79_SOC_QCA9558,
  31599. + ATH79_SOC_TP9343,
  31600. + ATH79_SOC_QCA9561,
  31601. };
  31602. extern enum ath79_soc_type ath79_soc;
  31603. @@ -100,6 +103,16 @@
  31604. return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  31605. }
  31606. +static inline int soc_is_qca9533(void)
  31607. +{
  31608. + return ath79_soc == ATH79_SOC_QCA9533;
  31609. +}
  31610. +
  31611. +static inline int soc_is_qca953x(void)
  31612. +{
  31613. + return soc_is_qca9533();
  31614. +}
  31615. +
  31616. static inline int soc_is_qca9556(void)
  31617. {
  31618. return ath79_soc == ATH79_SOC_QCA9556;
  31619. @@ -115,7 +128,23 @@
  31620. return soc_is_qca9556() || soc_is_qca9558();
  31621. }
  31622. +static inline int soc_is_tp9343(void)
  31623. +{
  31624. + return ath79_soc == ATH79_SOC_TP9343;
  31625. +}
  31626. +
  31627. +static inline int soc_is_qca9561(void)
  31628. +{
  31629. + return ath79_soc == ATH79_SOC_QCA9561;
  31630. +}
  31631. +
  31632. +static inline int soc_is_qca956x(void)
  31633. +{
  31634. + return soc_is_tp9343() || soc_is_qca9561();
  31635. +}
  31636. +
  31637. extern void __iomem *ath79_ddr_base;
  31638. +extern void __iomem *ath79_gpio_base;
  31639. extern void __iomem *ath79_pll_base;
  31640. extern void __iomem *ath79_reset_base;
  31641. @@ -132,6 +161,7 @@
  31642. static inline void ath79_reset_wr(unsigned reg, u32 val)
  31643. {
  31644. __raw_writel(val, ath79_reset_base + reg);
  31645. + (void) __raw_readl(ath79_reset_base + reg); /* flush */
  31646. }
  31647. static inline u32 ath79_reset_rr(unsigned reg)
  31648. @@ -141,5 +171,9 @@
  31649. void ath79_device_reset_set(u32 mask);
  31650. void ath79_device_reset_clear(u32 mask);
  31651. +u32 ath79_device_reset_get(u32 mask);
  31652. +
  31653. +void ath79_flash_acquire(void);
  31654. +void ath79_flash_release(void);
  31655. #endif /* __ASM_MACH_ATH79_H */
  31656. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h linux-4.1.13/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
  31657. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h 2015-11-09 23:34:10.000000000 +0100
  31658. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h 2015-12-04 19:57:03.962105671 +0100
  31659. @@ -16,8 +16,15 @@
  31660. unsigned num_chipselect;
  31661. };
  31662. +enum ath79_spi_cs_type {
  31663. + ATH79_SPI_CS_TYPE_INTERNAL,
  31664. + ATH79_SPI_CS_TYPE_GPIO,
  31665. +};
  31666. +
  31667. struct ath79_spi_controller_data {
  31668. - unsigned gpio;
  31669. + enum ath79_spi_cs_type cs_type;
  31670. + unsigned cs_line;
  31671. + bool is_flash;
  31672. };
  31673. #endif /* _ATH79_SPI_PLATFORM_H */
  31674. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h linux-4.1.13/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
  31675. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h 2015-11-09 23:34:10.000000000 +0100
  31676. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h 2015-12-04 19:57:03.826114569 +0100
  31677. @@ -36,6 +36,7 @@
  31678. #define cpu_has_mdmx 0
  31679. #define cpu_has_mips3d 0
  31680. #define cpu_has_smartmips 0
  31681. +#define cpu_has_rixi 0
  31682. #define cpu_has_mips32r1 1
  31683. #define cpu_has_mips32r2 1
  31684. @@ -43,6 +44,7 @@
  31685. #define cpu_has_mips64r2 0
  31686. #define cpu_has_mipsmt 0
  31687. +#define cpu_has_userlocal 0
  31688. #define cpu_has_64bits 0
  31689. #define cpu_has_64bit_zero_reg 0
  31690. @@ -51,5 +53,9 @@
  31691. #define cpu_dcache_line_size() 32
  31692. #define cpu_icache_line_size() 32
  31693. +#define cpu_has_vtag_icache 0
  31694. +#define cpu_has_dc_aliases 1
  31695. +#define cpu_has_ic_fills_f_dc 0
  31696. +#define cpu_has_pindexed_dcache 0
  31697. #endif /* __ASM_MACH_ATH79_CPU_FEATURE_OVERRIDES_H */
  31698. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/irq.h linux-4.1.13/arch/mips/include/asm/mach-ath79/irq.h
  31699. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/irq.h 2015-11-09 23:34:10.000000000 +0100
  31700. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/irq.h 2015-12-04 19:57:05.370013557 +0100
  31701. @@ -10,7 +10,7 @@
  31702. #define __ASM_MACH_ATH79_IRQ_H
  31703. #define MIPS_CPU_IRQ_BASE 0
  31704. -#define NR_IRQS 51
  31705. +#define NR_IRQS 83
  31706. #define ATH79_CPU_IRQ(_x) (MIPS_CPU_IRQ_BASE + (_x))
  31707. @@ -30,6 +30,10 @@
  31708. #define ATH79_IP3_IRQ_COUNT 3
  31709. #define ATH79_IP3_IRQ(_x) (ATH79_IP3_IRQ_BASE + (_x))
  31710. +#define ATH79_GPIO_IRQ_BASE (ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT)
  31711. +#define ATH79_GPIO_IRQ_COUNT 32
  31712. +#define ATH79_GPIO_IRQ(_x) (ATH79_GPIO_IRQ_BASE + (_x))
  31713. +
  31714. #include_next <irq.h>
  31715. #endif /* __ASM_MACH_ATH79_IRQ_H */
  31716. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/mach-rb750.h linux-4.1.13/arch/mips/include/asm/mach-ath79/mach-rb750.h
  31717. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/mach-rb750.h 1970-01-01 01:00:00.000000000 +0100
  31718. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/mach-rb750.h 2015-09-13 20:04:35.072523889 +0200
  31719. @@ -0,0 +1,84 @@
  31720. +/*
  31721. + * MikroTik RouterBOARD 750 definitions
  31722. + *
  31723. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  31724. + *
  31725. + * This program is free software; you can redistribute it and/or modify it
  31726. + * under the terms of the GNU General Public License version 2 as published
  31727. + * by the Free Software Foundation.
  31728. + */
  31729. +#ifndef _MACH_RB750_H
  31730. +#define _MACH_RB750_H
  31731. +
  31732. +#include <linux/bitops.h>
  31733. +
  31734. +#define RB750_GPIO_LVC573_LE 0 /* Latch enable on LVC573 */
  31735. +#define RB750_GPIO_NAND_IO0 1 /* NAND I/O 0 */
  31736. +#define RB750_GPIO_NAND_IO1 2 /* NAND I/O 1 */
  31737. +#define RB750_GPIO_NAND_IO2 3 /* NAND I/O 2 */
  31738. +#define RB750_GPIO_NAND_IO3 4 /* NAND I/O 3 */
  31739. +#define RB750_GPIO_NAND_IO4 5 /* NAND I/O 4 */
  31740. +#define RB750_GPIO_NAND_IO5 6 /* NAND I/O 5 */
  31741. +#define RB750_GPIO_NAND_IO6 7 /* NAND I/O 6 */
  31742. +#define RB750_GPIO_NAND_IO7 8 /* NAND I/O 7 */
  31743. +#define RB750_GPIO_NAND_NCE 11 /* NAND Chip Enable (active low) */
  31744. +#define RB750_GPIO_NAND_RDY 12 /* NAND Ready */
  31745. +#define RB750_GPIO_NAND_CLE 14 /* NAND Command Latch Enable */
  31746. +#define RB750_GPIO_NAND_ALE 15 /* NAND Address Latch Enable */
  31747. +#define RB750_GPIO_NAND_NRE 16 /* NAND Read Enable (active low) */
  31748. +#define RB750_GPIO_NAND_NWE 17 /* NAND Write Enable (active low) */
  31749. +
  31750. +#define RB750_GPIO_BTN_RESET 1
  31751. +#define RB750_GPIO_SPI_CS0 2
  31752. +#define RB750_GPIO_LED_ACT 12
  31753. +#define RB750_GPIO_LED_PORT1 13
  31754. +#define RB750_GPIO_LED_PORT2 14
  31755. +#define RB750_GPIO_LED_PORT3 15
  31756. +#define RB750_GPIO_LED_PORT4 16
  31757. +#define RB750_GPIO_LED_PORT5 17
  31758. +
  31759. +#define RB750_LED_ACT BIT(RB750_GPIO_LED_ACT)
  31760. +#define RB750_LED_PORT1 BIT(RB750_GPIO_LED_PORT1)
  31761. +#define RB750_LED_PORT2 BIT(RB750_GPIO_LED_PORT2)
  31762. +#define RB750_LED_PORT3 BIT(RB750_GPIO_LED_PORT3)
  31763. +#define RB750_LED_PORT4 BIT(RB750_GPIO_LED_PORT4)
  31764. +#define RB750_LED_PORT5 BIT(RB750_GPIO_LED_PORT5)
  31765. +#define RB750_NAND_NCE BIT(RB750_GPIO_NAND_NCE)
  31766. +
  31767. +#define RB750_LVC573_LE BIT(RB750_GPIO_LVC573_LE)
  31768. +
  31769. +#define RB750_LED_BITS (RB750_LED_PORT1 | RB750_LED_PORT2 | RB750_LED_PORT3 | \
  31770. + RB750_LED_PORT4 | RB750_LED_PORT5 | RB750_LED_ACT)
  31771. +
  31772. +#define RB7XX_GPIO_NAND_NCE 0
  31773. +#define RB7XX_GPIO_MON 9
  31774. +#define RB7XX_GPIO_LED_ACT 11
  31775. +#define RB7XX_GPIO_USB_POWERON 13
  31776. +
  31777. +#define RB7XX_NAND_NCE BIT(RB7XX_GPIO_NAND_NCE)
  31778. +#define RB7XX_LED_ACT BIT(RB7XX_GPIO_LED_ACT)
  31779. +#define RB7XX_MONITOR BIT(RB7XX_GPIO_MON)
  31780. +#define RB7XX_USB_POWERON BIT(RB7XX_GPIO_USB_POWERON)
  31781. +
  31782. +struct rb750_led_data {
  31783. + char *name;
  31784. + char *default_trigger;
  31785. + u32 mask;
  31786. + int active_low;
  31787. +};
  31788. +
  31789. +struct rb750_led_platform_data {
  31790. + int num_leds;
  31791. + struct rb750_led_data *leds;
  31792. + void (*latch_change)(u32 clear, u32 set);
  31793. +};
  31794. +
  31795. +struct rb7xx_nand_platform_data {
  31796. + u32 nce_line;
  31797. +
  31798. + void (*enable_pins)(void);
  31799. + void (*disable_pins)(void);
  31800. + void (*latch_change)(u32, u32);
  31801. +};
  31802. +
  31803. +#endif /* _MACH_RB750_H */
  31804. \ No newline at end of file
  31805. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/mangle-port.h linux-4.1.13/arch/mips/include/asm/mach-ath79/mangle-port.h
  31806. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/mangle-port.h 1970-01-01 01:00:00.000000000 +0100
  31807. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/mangle-port.h 2015-12-04 19:57:03.970105148 +0100
  31808. @@ -0,0 +1,37 @@
  31809. +/*
  31810. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  31811. + *
  31812. + * This file was derived from: inlude/asm-mips/mach-generic/mangle-port.h
  31813. + * Copyright (C) 2003, 2004 Ralf Baechle
  31814. + *
  31815. + * This program is free software; you can redistribute it and/or modify it
  31816. + * under the terms of the GNU General Public License version 2 as published
  31817. + * by the Free Software Foundation.
  31818. + */
  31819. +
  31820. +#ifndef __ASM_MACH_ATH79_MANGLE_PORT_H
  31821. +#define __ASM_MACH_ATH79_MANGLE_PORT_H
  31822. +
  31823. +#ifdef CONFIG_PCI
  31824. +extern unsigned long (ath79_pci_swizzle_b)(unsigned long port);
  31825. +extern unsigned long (ath79_pci_swizzle_w)(unsigned long port);
  31826. +#else
  31827. +#define ath79_pci_swizzle_b(port) (port)
  31828. +#define ath79_pci_swizzle_w(port) (port)
  31829. +#endif
  31830. +
  31831. +#define __swizzle_addr_b(port) ath79_pci_swizzle_b(port)
  31832. +#define __swizzle_addr_w(port) ath79_pci_swizzle_w(port)
  31833. +#define __swizzle_addr_l(port) (port)
  31834. +#define __swizzle_addr_q(port) (port)
  31835. +
  31836. +# define ioswabb(a, x) (x)
  31837. +# define __mem_ioswabb(a, x) (x)
  31838. +# define ioswabw(a, x) (x)
  31839. +# define __mem_ioswabw(a, x) cpu_to_le16(x)
  31840. +# define ioswabl(a, x) (x)
  31841. +# define __mem_ioswabl(a, x) cpu_to_le32(x)
  31842. +# define ioswabq(a, x) (x)
  31843. +# define __mem_ioswabq(a, x) cpu_to_le64(x)
  31844. +
  31845. +#endif /* __ASM_MACH_ATH79_MANGLE_PORT_H */
  31846. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h linux-4.1.13/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h
  31847. --- linux-4.1.13.orig/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h 1970-01-01 01:00:00.000000000 +0100
  31848. +++ linux-4.1.13/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h 2015-09-13 20:04:35.072523889 +0200
  31849. @@ -0,0 +1,48 @@
  31850. +/*
  31851. + * SPI driver definitions for the CPLD chip on the Mikrotik RB4xx boards
  31852. + *
  31853. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  31854. + *
  31855. + * This file was based on the patches for Linux 2.6.27.39 published by
  31856. + * MikroTik for their RouterBoard 4xx series devices.
  31857. + *
  31858. + * This program is free software; you can redistribute it and/or modify it
  31859. + * under the terms of the GNU General Public License version 2 as published
  31860. + * by the Free Software Foundation.
  31861. + */
  31862. +
  31863. +#define CPLD_GPIO_nLED1 0
  31864. +#define CPLD_GPIO_nLED2 1
  31865. +#define CPLD_GPIO_nLED3 2
  31866. +#define CPLD_GPIO_nLED4 3
  31867. +#define CPLD_GPIO_FAN 4
  31868. +#define CPLD_GPIO_ALE 5
  31869. +#define CPLD_GPIO_CLE 6
  31870. +#define CPLD_GPIO_nCE 7
  31871. +#define CPLD_GPIO_nLED5 8
  31872. +
  31873. +#define CPLD_NUM_GPIOS 9
  31874. +
  31875. +#define CPLD_CFG_nLED1 BIT(CPLD_GPIO_nLED1)
  31876. +#define CPLD_CFG_nLED2 BIT(CPLD_GPIO_nLED2)
  31877. +#define CPLD_CFG_nLED3 BIT(CPLD_GPIO_nLED3)
  31878. +#define CPLD_CFG_nLED4 BIT(CPLD_GPIO_nLED4)
  31879. +#define CPLD_CFG_FAN BIT(CPLD_GPIO_FAN)
  31880. +#define CPLD_CFG_ALE BIT(CPLD_GPIO_ALE)
  31881. +#define CPLD_CFG_CLE BIT(CPLD_GPIO_CLE)
  31882. +#define CPLD_CFG_nCE BIT(CPLD_GPIO_nCE)
  31883. +#define CPLD_CFG_nLED5 BIT(CPLD_GPIO_nLED5)
  31884. +
  31885. +struct rb4xx_cpld_platform_data {
  31886. + unsigned gpio_base;
  31887. +};
  31888. +
  31889. +extern int rb4xx_cpld_change_cfg(unsigned mask, unsigned value);
  31890. +extern int rb4xx_cpld_read(unsigned char *rx_buf,
  31891. + const unsigned char *verify_buf,
  31892. + unsigned cnt);
  31893. +extern int rb4xx_cpld_read_from(unsigned addr,
  31894. + unsigned char *rx_buf,
  31895. + const unsigned char *verify_buf,
  31896. + unsigned cnt);
  31897. +extern int rb4xx_cpld_write(const unsigned char *buf, unsigned count);
  31898. diff -Nur linux-4.1.13.orig/arch/mips/include/asm/mips_machine.h linux-4.1.13/arch/mips/include/asm/mips_machine.h
  31899. --- linux-4.1.13.orig/arch/mips/include/asm/mips_machine.h 2015-11-09 23:34:10.000000000 +0100
  31900. +++ linux-4.1.13/arch/mips/include/asm/mips_machine.h 2015-12-04 19:57:03.826114569 +0100
  31901. @@ -36,6 +36,18 @@
  31902. .mach_setup = _setup, \
  31903. };
  31904. +#define MIPS_MACHINE_NONAME(_type, _id, _setup) \
  31905. +static const char machine_id_##_type[] __initconst \
  31906. + __aligned(1) = _id; \
  31907. +static struct mips_machine machine_##_type \
  31908. + __used __section(.mips.machines.init) = \
  31909. +{ \
  31910. + .mach_type = _type, \
  31911. + .mach_id = machine_id_##_type, \
  31912. + .mach_name = NULL, \
  31913. + .mach_setup = _setup, \
  31914. +};
  31915. +
  31916. extern long __mips_machines_start;
  31917. extern long __mips_machines_end;
  31918. diff -Nur linux-4.1.13.orig/arch/mips/Kconfig linux-4.1.13/arch/mips/Kconfig
  31919. --- linux-4.1.13.orig/arch/mips/Kconfig 2015-11-09 23:34:10.000000000 +0100
  31920. +++ linux-4.1.13/arch/mips/Kconfig 2015-12-04 19:57:03.986104101 +0100
  31921. @@ -1070,6 +1070,9 @@
  31922. config MIPS_NILE4
  31923. bool
  31924. +config MYLOADER
  31925. + bool
  31926. +
  31927. config SYNC_R4K
  31928. bool
  31929. diff -Nur linux-4.1.13.orig/arch/mips/Makefile linux-4.1.13/arch/mips/Makefile
  31930. --- linux-4.1.13.orig/arch/mips/Makefile 2015-11-09 23:34:10.000000000 +0100
  31931. +++ linux-4.1.13/arch/mips/Makefile 2015-12-04 19:57:03.982104363 +0100
  31932. @@ -216,6 +216,7 @@
  31933. #
  31934. libs-$(CONFIG_FW_ARC) += arch/mips/fw/arc/
  31935. libs-$(CONFIG_FW_CFE) += arch/mips/fw/cfe/
  31936. +libs-$(CONFIG_MYLOADER) += arch/mips/fw/myloader/
  31937. libs-$(CONFIG_FW_SNIPROM) += arch/mips/fw/sni/
  31938. libs-y += arch/mips/fw/lib/
  31939. diff -Nur linux-4.1.13.orig/drivers/gpio/gpio-74x164.c linux-4.1.13/drivers/gpio/gpio-74x164.c
  31940. --- linux-4.1.13.orig/drivers/gpio/gpio-74x164.c 2015-11-09 23:34:10.000000000 +0100
  31941. +++ linux-4.1.13/drivers/gpio/gpio-74x164.c 2015-12-04 19:57:03.930107765 +0100
  31942. @@ -12,6 +12,7 @@
  31943. #include <linux/init.h>
  31944. #include <linux/mutex.h>
  31945. #include <linux/spi/spi.h>
  31946. +#include <linux/spi/74x164.h>
  31947. #include <linux/gpio.h>
  31948. #include <linux/of_gpio.h>
  31949. #include <linux/slab.h>
  31950. @@ -107,8 +108,18 @@
  31951. static int gen_74x164_probe(struct spi_device *spi)
  31952. {
  31953. struct gen_74x164_chip *chip;
  31954. + struct gen_74x164_chip_platform_data *pdata;
  31955. + struct device_node *np;
  31956. int ret;
  31957. + pdata = spi->dev.platform_data;
  31958. + np = spi->dev.of_node;
  31959. +
  31960. + if (!np && !pdata) {
  31961. + dev_err(&spi->dev, "No configuration data available.\n");
  31962. + return -EINVAL;
  31963. + }
  31964. +
  31965. /*
  31966. * bits_per_word cannot be configured in platform data
  31967. */
  31968. @@ -130,18 +141,28 @@
  31969. chip->gpio_chip.set = gen_74x164_set_value;
  31970. chip->gpio_chip.base = -1;
  31971. - if (of_property_read_u32(spi->dev.of_node, "registers-number",
  31972. - &chip->registers)) {
  31973. - dev_err(&spi->dev,
  31974. - "Missing registers-number property in the DT.\n");
  31975. - return -EINVAL;
  31976. + if (np) {
  31977. + if (of_property_read_u32(spi->dev.of_node, "registers-number", &chip->registers)) {
  31978. + dev_err(&spi->dev, "Missing registers-number property in the DT.\n");
  31979. + ret = -EINVAL;
  31980. + goto exit_destroy;
  31981. + }
  31982. + } else if (pdata) {
  31983. + chip->gpio_chip.base = pdata->base;
  31984. + chip->registers = pdata->num_registers;
  31985. }
  31986. + if (!chip->registers)
  31987. + chip->registers = 1;
  31988. +
  31989. chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
  31990. chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
  31991. if (!chip->buffer)
  31992. return -ENOMEM;
  31993. + if (pdata && pdata->init_data)
  31994. + memcpy(chip->buffer, pdata->init_data, chip->registers);
  31995. +
  31996. chip->gpio_chip.can_sleep = true;
  31997. chip->gpio_chip.dev = &spi->dev;
  31998. chip->gpio_chip.owner = THIS_MODULE;
  31999. @@ -174,17 +195,19 @@
  32000. return 0;
  32001. }
  32002. +#ifdef CONFIG_OF
  32003. static const struct of_device_id gen_74x164_dt_ids[] = {
  32004. { .compatible = "fairchild,74hc595" },
  32005. {},
  32006. };
  32007. MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
  32008. +#endif /* CONFIG_OF */
  32009. static struct spi_driver gen_74x164_driver = {
  32010. .driver = {
  32011. .name = "74x164",
  32012. .owner = THIS_MODULE,
  32013. - .of_match_table = gen_74x164_dt_ids,
  32014. + .of_match_table = of_match_ptr(gen_74x164_dt_ids),
  32015. },
  32016. .probe = gen_74x164_probe,
  32017. .remove = gen_74x164_remove,
  32018. diff -Nur linux-4.1.13.orig/drivers/gpio/gpio-latch.c linux-4.1.13/drivers/gpio/gpio-latch.c
  32019. --- linux-4.1.13.orig/drivers/gpio/gpio-latch.c 1970-01-01 01:00:00.000000000 +0100
  32020. +++ linux-4.1.13/drivers/gpio/gpio-latch.c 2015-09-13 20:04:35.072523889 +0200
  32021. @@ -0,0 +1,220 @@
  32022. +/*
  32023. + * GPIO latch driver
  32024. + *
  32025. + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  32026. + *
  32027. + * This program is free software; you can redistribute it and/or modify it
  32028. + * under the terms of the GNU General Public License version 2 as published
  32029. + * by the Free Software Foundation.
  32030. + */
  32031. +
  32032. +#include <linux/kernel.h>
  32033. +#include <linux/init.h>
  32034. +#include <linux/module.h>
  32035. +#include <linux/types.h>
  32036. +#include <linux/gpio.h>
  32037. +#include <linux/slab.h>
  32038. +#include <linux/platform_device.h>
  32039. +
  32040. +#include <linux/platform_data/gpio-latch.h>
  32041. +
  32042. +struct gpio_latch_chip {
  32043. + struct gpio_chip gc;
  32044. +
  32045. + struct mutex mutex;
  32046. + struct mutex latch_mutex;
  32047. + bool latch_enabled;
  32048. + int le_gpio;
  32049. + bool le_active_low;
  32050. + int *gpios;
  32051. +};
  32052. +
  32053. +static inline struct gpio_latch_chip *to_gpio_latch_chip(struct gpio_chip *gc)
  32054. +{
  32055. + return container_of(gc, struct gpio_latch_chip, gc);
  32056. +}
  32057. +
  32058. +static void gpio_latch_lock(struct gpio_latch_chip *glc, bool enable)
  32059. +{
  32060. + mutex_lock(&glc->mutex);
  32061. +
  32062. + if (enable)
  32063. + glc->latch_enabled = true;
  32064. +
  32065. + if (glc->latch_enabled)
  32066. + mutex_lock(&glc->latch_mutex);
  32067. +}
  32068. +
  32069. +static void gpio_latch_unlock(struct gpio_latch_chip *glc, bool disable)
  32070. +{
  32071. + if (glc->latch_enabled)
  32072. + mutex_unlock(&glc->latch_mutex);
  32073. +
  32074. + if (disable)
  32075. + glc->latch_enabled = true;
  32076. +
  32077. + mutex_unlock(&glc->mutex);
  32078. +}
  32079. +
  32080. +static int
  32081. +gpio_latch_get(struct gpio_chip *gc, unsigned offset)
  32082. +{
  32083. + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
  32084. + int ret;
  32085. +
  32086. + gpio_latch_lock(glc, false);
  32087. + ret = gpio_get_value(glc->gpios[offset]);
  32088. + gpio_latch_unlock(glc, false);
  32089. +
  32090. + return ret;
  32091. +}
  32092. +
  32093. +static void
  32094. +gpio_latch_set(struct gpio_chip *gc, unsigned offset, int value)
  32095. +{
  32096. + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
  32097. + bool enable_latch = false;
  32098. + bool disable_latch = false;
  32099. + int gpio;
  32100. +
  32101. + gpio = glc->gpios[offset];
  32102. +
  32103. + if (gpio == glc->le_gpio) {
  32104. + enable_latch = value ^ glc->le_active_low;
  32105. + disable_latch = !enable_latch;
  32106. + }
  32107. +
  32108. + gpio_latch_lock(glc, enable_latch);
  32109. + gpio_set_value(gpio, value);
  32110. + gpio_latch_unlock(glc, disable_latch);
  32111. +}
  32112. +
  32113. +static int
  32114. +gpio_latch_direction_input(struct gpio_chip *gc, unsigned offset)
  32115. +{
  32116. + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
  32117. + int ret;
  32118. +
  32119. + gpio_latch_lock(glc, false);
  32120. + ret = gpio_direction_input(glc->gpios[offset]);
  32121. + gpio_latch_unlock(glc, false);
  32122. +
  32123. + return ret;
  32124. +}
  32125. +
  32126. +static int
  32127. +gpio_latch_direction_output(struct gpio_chip *gc, unsigned offset, int value)
  32128. +{
  32129. + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
  32130. + bool enable_latch = false;
  32131. + bool disable_latch = false;
  32132. + int gpio;
  32133. + int ret;
  32134. +
  32135. + gpio = glc->gpios[offset];
  32136. +
  32137. + if (gpio == glc->le_gpio) {
  32138. + enable_latch = value ^ glc->le_active_low;
  32139. + disable_latch = !enable_latch;
  32140. + }
  32141. +
  32142. + gpio_latch_lock(glc, enable_latch);
  32143. + ret = gpio_direction_output(gpio, value);
  32144. + gpio_latch_unlock(glc, disable_latch);
  32145. +
  32146. + return ret;
  32147. +}
  32148. +
  32149. +static int gpio_latch_probe(struct platform_device *pdev)
  32150. +{
  32151. + struct gpio_latch_chip *glc;
  32152. + struct gpio_latch_platform_data *pdata;
  32153. + struct gpio_chip *gc;
  32154. + int size;
  32155. + int ret;
  32156. + int i;
  32157. +
  32158. + pdata = dev_get_platdata(&pdev->dev);
  32159. + if (!pdata)
  32160. + return -EINVAL;
  32161. +
  32162. + if (pdata->le_gpio_index >= pdata->num_gpios ||
  32163. + !pdata->num_gpios ||
  32164. + !pdata->gpios)
  32165. + return -EINVAL;
  32166. +
  32167. + for (i = 0; i < pdata->num_gpios; i++) {
  32168. + int gpio = pdata->gpios[i];
  32169. +
  32170. + ret = devm_gpio_request(&pdev->dev, gpio,
  32171. + GPIO_LATCH_DRIVER_NAME);
  32172. + if (ret)
  32173. + return ret;
  32174. + }
  32175. +
  32176. + glc = devm_kzalloc(&pdev->dev, sizeof(*glc), GFP_KERNEL);
  32177. + if (!glc)
  32178. + return -ENOMEM;
  32179. +
  32180. + mutex_init(&glc->mutex);
  32181. + mutex_init(&glc->latch_mutex);
  32182. +
  32183. + size = pdata->num_gpios * sizeof(glc->gpios[0]);
  32184. + glc->gpios = devm_kzalloc(&pdev->dev, size , GFP_KERNEL);
  32185. + if (!glc->gpios)
  32186. + return -ENOMEM;
  32187. +
  32188. + memcpy(glc->gpios, pdata->gpios, size);
  32189. +
  32190. + glc->le_gpio = glc->gpios[pdata->le_gpio_index];
  32191. + glc->le_active_low = pdata->le_active_low;
  32192. +
  32193. + gc = &glc->gc;
  32194. +
  32195. + gc->label = GPIO_LATCH_DRIVER_NAME;
  32196. + gc->base = pdata->base;
  32197. + gc->can_sleep = true;
  32198. + gc->ngpio = pdata->num_gpios;
  32199. + gc->get = gpio_latch_get;
  32200. + gc->set = gpio_latch_set;
  32201. + gc->direction_input = gpio_latch_direction_input,
  32202. + gc->direction_output = gpio_latch_direction_output;
  32203. +
  32204. + platform_set_drvdata(pdev, glc);
  32205. +
  32206. + ret = gpiochip_add(&glc->gc);
  32207. + if (ret)
  32208. + return ret;
  32209. +
  32210. + return 0;
  32211. +}
  32212. +
  32213. +static int gpio_latch_remove(struct platform_device *pdev)
  32214. +{
  32215. + struct gpio_latch_chip *glc = platform_get_drvdata(pdev);
  32216. +
  32217. + gpiochip_remove(&glc->gc);
  32218. + return 0;
  32219. +}
  32220. +
  32221. +
  32222. +static struct platform_driver gpio_latch_driver = {
  32223. + .probe = gpio_latch_probe,
  32224. + .remove = gpio_latch_remove,
  32225. + .driver = {
  32226. + .name = GPIO_LATCH_DRIVER_NAME,
  32227. + .owner = THIS_MODULE,
  32228. + },
  32229. +};
  32230. +
  32231. +static int __init gpio_latch_init(void)
  32232. +{
  32233. + return platform_driver_register(&gpio_latch_driver);
  32234. +}
  32235. +
  32236. +postcore_initcall(gpio_latch_init);
  32237. +
  32238. +MODULE_DESCRIPTION("GPIO latch driver");
  32239. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  32240. +MODULE_LICENSE("GPL v2");
  32241. +MODULE_ALIAS("platform:" GPIO_LATCH_DRIVER_NAME);
  32242. diff -Nur linux-4.1.13.orig/drivers/gpio/gpio-nxp-74hc153.c linux-4.1.13/drivers/gpio/gpio-nxp-74hc153.c
  32243. --- linux-4.1.13.orig/drivers/gpio/gpio-nxp-74hc153.c 1970-01-01 01:00:00.000000000 +0100
  32244. +++ linux-4.1.13/drivers/gpio/gpio-nxp-74hc153.c 2015-09-13 20:04:35.072523889 +0200
  32245. @@ -0,0 +1,251 @@
  32246. +/*
  32247. + * NXP 74HC153 - Dual 4-input multiplexer GPIO driver
  32248. + *
  32249. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  32250. + *
  32251. + * This program is free software; you can redistribute it and/or modify
  32252. + * it under the terms of the GNU General Public License version 2 as
  32253. + * published by the Free Software Foundation.
  32254. + */
  32255. +
  32256. +#include <linux/version.h>
  32257. +#include <linux/module.h>
  32258. +#include <linux/init.h>
  32259. +#include <linux/gpio.h>
  32260. +#include <linux/slab.h>
  32261. +#include <linux/platform_device.h>
  32262. +#include <linux/nxp_74hc153.h>
  32263. +
  32264. +#define NXP_74HC153_NUM_GPIOS 8
  32265. +#define NXP_74HC153_S0_MASK 0x1
  32266. +#define NXP_74HC153_S1_MASK 0x2
  32267. +#define NXP_74HC153_BANK_MASK 0x4
  32268. +
  32269. +struct nxp_74hc153_chip {
  32270. + struct device *parent;
  32271. + struct gpio_chip gpio_chip;
  32272. + struct mutex lock;
  32273. +};
  32274. +
  32275. +static struct nxp_74hc153_chip *gpio_to_nxp(struct gpio_chip *gc)
  32276. +{
  32277. + return container_of(gc, struct nxp_74hc153_chip, gpio_chip);
  32278. +}
  32279. +
  32280. +static int nxp_74hc153_direction_input(struct gpio_chip *gc, unsigned offset)
  32281. +{
  32282. + return 0;
  32283. +}
  32284. +
  32285. +static int nxp_74hc153_direction_output(struct gpio_chip *gc,
  32286. + unsigned offset, int val)
  32287. +{
  32288. + return -EINVAL;
  32289. +}
  32290. +
  32291. +static int nxp_74hc153_get_value(struct gpio_chip *gc, unsigned offset)
  32292. +{
  32293. + struct nxp_74hc153_chip *nxp;
  32294. + struct nxp_74hc153_platform_data *pdata;
  32295. + unsigned s0;
  32296. + unsigned s1;
  32297. + unsigned pin;
  32298. + int ret;
  32299. +
  32300. + nxp = gpio_to_nxp(gc);
  32301. + pdata = nxp->parent->platform_data;
  32302. +
  32303. + s0 = !!(offset & NXP_74HC153_S0_MASK);
  32304. + s1 = !!(offset & NXP_74HC153_S1_MASK);
  32305. + pin = (offset & NXP_74HC153_BANK_MASK) ? pdata->gpio_pin_2y
  32306. + : pdata->gpio_pin_1y;
  32307. +
  32308. + mutex_lock(&nxp->lock);
  32309. + gpio_set_value(pdata->gpio_pin_s0, s0);
  32310. + gpio_set_value(pdata->gpio_pin_s1, s1);
  32311. + ret = gpio_get_value(pin);
  32312. + mutex_unlock(&nxp->lock);
  32313. +
  32314. + return ret;
  32315. +}
  32316. +
  32317. +static void nxp_74hc153_set_value(struct gpio_chip *gc,
  32318. + unsigned offset, int val)
  32319. +{
  32320. + /* not supported */
  32321. +}
  32322. +
  32323. +static int nxp_74hc153_probe(struct platform_device *pdev)
  32324. +{
  32325. + struct nxp_74hc153_platform_data *pdata;
  32326. + struct nxp_74hc153_chip *nxp;
  32327. + struct gpio_chip *gc;
  32328. + int err;
  32329. +
  32330. + pdata = pdev->dev.platform_data;
  32331. + if (pdata == NULL) {
  32332. + dev_dbg(&pdev->dev, "no platform data specified\n");
  32333. + return -EINVAL;
  32334. + }
  32335. +
  32336. + nxp = kzalloc(sizeof(struct nxp_74hc153_chip), GFP_KERNEL);
  32337. + if (nxp == NULL) {
  32338. + dev_err(&pdev->dev, "no memory for private data\n");
  32339. + return -ENOMEM;
  32340. + }
  32341. +
  32342. + err = gpio_request(pdata->gpio_pin_s0, dev_name(&pdev->dev));
  32343. + if (err) {
  32344. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  32345. + pdata->gpio_pin_s0, err);
  32346. + goto err_free_nxp;
  32347. + }
  32348. +
  32349. + err = gpio_request(pdata->gpio_pin_s1, dev_name(&pdev->dev));
  32350. + if (err) {
  32351. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  32352. + pdata->gpio_pin_s1, err);
  32353. + goto err_free_s0;
  32354. + }
  32355. +
  32356. + err = gpio_request(pdata->gpio_pin_1y, dev_name(&pdev->dev));
  32357. + if (err) {
  32358. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  32359. + pdata->gpio_pin_1y, err);
  32360. + goto err_free_s1;
  32361. + }
  32362. +
  32363. + err = gpio_request(pdata->gpio_pin_2y, dev_name(&pdev->dev));
  32364. + if (err) {
  32365. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  32366. + pdata->gpio_pin_2y, err);
  32367. + goto err_free_1y;
  32368. + }
  32369. +
  32370. + err = gpio_direction_output(pdata->gpio_pin_s0, 0);
  32371. + if (err) {
  32372. + dev_err(&pdev->dev,
  32373. + "unable to set direction of gpio %u, err=%d\n",
  32374. + pdata->gpio_pin_s0, err);
  32375. + goto err_free_2y;
  32376. + }
  32377. +
  32378. + err = gpio_direction_output(pdata->gpio_pin_s1, 0);
  32379. + if (err) {
  32380. + dev_err(&pdev->dev,
  32381. + "unable to set direction of gpio %u, err=%d\n",
  32382. + pdata->gpio_pin_s1, err);
  32383. + goto err_free_2y;
  32384. + }
  32385. +
  32386. + err = gpio_direction_input(pdata->gpio_pin_1y);
  32387. + if (err) {
  32388. + dev_err(&pdev->dev,
  32389. + "unable to set direction of gpio %u, err=%d\n",
  32390. + pdata->gpio_pin_1y, err);
  32391. + goto err_free_2y;
  32392. + }
  32393. +
  32394. + err = gpio_direction_input(pdata->gpio_pin_2y);
  32395. + if (err) {
  32396. + dev_err(&pdev->dev,
  32397. + "unable to set direction of gpio %u, err=%d\n",
  32398. + pdata->gpio_pin_2y, err);
  32399. + goto err_free_2y;
  32400. + }
  32401. +
  32402. + nxp->parent = &pdev->dev;
  32403. + mutex_init(&nxp->lock);
  32404. +
  32405. + gc = &nxp->gpio_chip;
  32406. +
  32407. + gc->direction_input = nxp_74hc153_direction_input;
  32408. + gc->direction_output = nxp_74hc153_direction_output;
  32409. + gc->get = nxp_74hc153_get_value;
  32410. + gc->set = nxp_74hc153_set_value;
  32411. + gc->can_sleep = 1;
  32412. +
  32413. + gc->base = pdata->gpio_base;
  32414. + gc->ngpio = NXP_74HC153_NUM_GPIOS;
  32415. + gc->label = dev_name(nxp->parent);
  32416. + gc->dev = nxp->parent;
  32417. + gc->owner = THIS_MODULE;
  32418. +
  32419. + err = gpiochip_add(&nxp->gpio_chip);
  32420. + if (err) {
  32421. + dev_err(&pdev->dev, "unable to add gpio chip, err=%d\n", err);
  32422. + goto err_free_2y;
  32423. + }
  32424. +
  32425. + platform_set_drvdata(pdev, nxp);
  32426. + return 0;
  32427. +
  32428. +err_free_2y:
  32429. + gpio_free(pdata->gpio_pin_2y);
  32430. +err_free_1y:
  32431. + gpio_free(pdata->gpio_pin_1y);
  32432. +err_free_s1:
  32433. + gpio_free(pdata->gpio_pin_s1);
  32434. +err_free_s0:
  32435. + gpio_free(pdata->gpio_pin_s0);
  32436. +err_free_nxp:
  32437. + kfree(nxp);
  32438. + return err;
  32439. +}
  32440. +
  32441. +static int nxp_74hc153_remove(struct platform_device *pdev)
  32442. +{
  32443. + struct nxp_74hc153_chip *nxp = platform_get_drvdata(pdev);
  32444. + struct nxp_74hc153_platform_data *pdata = pdev->dev.platform_data;
  32445. +
  32446. + if (nxp) {
  32447. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
  32448. + int err;
  32449. +
  32450. + err = gpiochip_remove(&nxp->gpio_chip);
  32451. + if (err) {
  32452. + dev_err(&pdev->dev,
  32453. + "unable to remove gpio chip, err=%d\n",
  32454. + err);
  32455. + return err;
  32456. + }
  32457. +#else
  32458. + gpiochip_remove(&nxp->gpio_chip);
  32459. +#endif
  32460. + gpio_free(pdata->gpio_pin_2y);
  32461. + gpio_free(pdata->gpio_pin_1y);
  32462. + gpio_free(pdata->gpio_pin_s1);
  32463. + gpio_free(pdata->gpio_pin_s0);
  32464. +
  32465. + kfree(nxp);
  32466. + platform_set_drvdata(pdev, NULL);
  32467. + }
  32468. +
  32469. + return 0;
  32470. +}
  32471. +
  32472. +static struct platform_driver nxp_74hc153_driver = {
  32473. + .probe = nxp_74hc153_probe,
  32474. + .remove = nxp_74hc153_remove,
  32475. + .driver = {
  32476. + .name = NXP_74HC153_DRIVER_NAME,
  32477. + .owner = THIS_MODULE,
  32478. + },
  32479. +};
  32480. +
  32481. +static int __init nxp_74hc153_init(void)
  32482. +{
  32483. + return platform_driver_register(&nxp_74hc153_driver);
  32484. +}
  32485. +subsys_initcall(nxp_74hc153_init);
  32486. +
  32487. +static void __exit nxp_74hc153_exit(void)
  32488. +{
  32489. + platform_driver_unregister(&nxp_74hc153_driver);
  32490. +}
  32491. +module_exit(nxp_74hc153_exit);
  32492. +
  32493. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  32494. +MODULE_DESCRIPTION("GPIO expander driver for NXP 74HC153");
  32495. +MODULE_LICENSE("GPL v2");
  32496. +MODULE_ALIAS("platform:" NXP_74HC153_DRIVER_NAME);
  32497. diff -Nur linux-4.1.13.orig/drivers/gpio/Kconfig linux-4.1.13/drivers/gpio/Kconfig
  32498. --- linux-4.1.13.orig/drivers/gpio/Kconfig 2015-11-09 23:34:10.000000000 +0100
  32499. +++ linux-4.1.13/drivers/gpio/Kconfig 2015-12-04 19:57:03.934107503 +0100
  32500. @@ -941,7 +941,7 @@
  32501. config GPIO_74X164
  32502. tristate "74x164 serial-in/parallel-out 8-bits shift register"
  32503. - depends on SPI_MASTER && OF
  32504. + depends on SPI_MASTER
  32505. help
  32506. Driver for 74x164 compatible serial-in/parallel-out 8-outputs
  32507. shift registers. This driver can be used to provide access
  32508. @@ -988,4 +988,17 @@
  32509. endmenu
  32510. +comment "Other GPIO expanders"
  32511. +
  32512. +config GPIO_NXP_74HC153
  32513. + tristate "NXP 74HC153 Dual 4-input multiplexer"
  32514. + help
  32515. + Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This
  32516. + provides a GPIO interface supporting input mode only.
  32517. +
  32518. +config GPIO_LATCH
  32519. + tristate "GPIO latch driver"
  32520. + help
  32521. + Say yes here to enable a GPIO latch driver.
  32522. +
  32523. endif
  32524. diff -Nur linux-4.1.13.orig/drivers/gpio/Makefile linux-4.1.13/drivers/gpio/Makefile
  32525. --- linux-4.1.13.orig/drivers/gpio/Makefile 2015-11-09 23:34:10.000000000 +0100
  32526. +++ linux-4.1.13/drivers/gpio/Makefile 2015-12-04 19:57:03.934107503 +0100
  32527. @@ -42,6 +42,7 @@
  32528. obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o
  32529. obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o
  32530. obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o
  32531. +obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o
  32532. obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o
  32533. obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o
  32534. obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o
  32535. @@ -64,6 +65,7 @@
  32536. obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o
  32537. obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o
  32538. obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o
  32539. +obj-$(CONFIG_GPIO_NXP_74HC153) += gpio-nxp-74hc153.o
  32540. obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
  32541. obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o
  32542. obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o
  32543. diff -Nur linux-4.1.13.orig/drivers/leds/Kconfig linux-4.1.13/drivers/leds/Kconfig
  32544. --- linux-4.1.13.orig/drivers/leds/Kconfig 2015-11-09 23:34:10.000000000 +0100
  32545. +++ linux-4.1.13/drivers/leds/Kconfig 2015-12-04 19:57:03.926108026 +0100
  32546. @@ -534,6 +534,17 @@
  32547. This option enables support for the 'White' LED block
  32548. on Qualcomm PM8941 PMICs.
  32549. +config LEDS_WNDR3700_USB
  32550. + tristate "NETGEAR WNDR3700 USB LED driver"
  32551. + depends on LEDS_CLASS && ATH79_MACH_WNDR3700
  32552. + help
  32553. + This option enables support for the USB LED found on the
  32554. + NETGEAR WNDR3700 board.
  32555. +
  32556. +config LEDS_RB750
  32557. + tristate "LED driver for the Mikrotik RouterBOARD 750"
  32558. + depends on LEDS_CLASS && ATH79_MACH_RB750
  32559. +
  32560. comment "LED Triggers"
  32561. source "drivers/leds/trigger/Kconfig"
  32562. diff -Nur linux-4.1.13.orig/drivers/leds/leds-rb750.c linux-4.1.13/drivers/leds/leds-rb750.c
  32563. --- linux-4.1.13.orig/drivers/leds/leds-rb750.c 1970-01-01 01:00:00.000000000 +0100
  32564. +++ linux-4.1.13/drivers/leds/leds-rb750.c 2015-09-13 20:04:35.072523889 +0200
  32565. @@ -0,0 +1,144 @@
  32566. +/*
  32567. + * LED driver for the RouterBOARD 750
  32568. + *
  32569. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  32570. + *
  32571. + * This program is free software; you can redistribute it and/or modify
  32572. + * it under the terms of the GNU General Public License version 2 as
  32573. + * published by the Free Software Foundation.
  32574. + *
  32575. + */
  32576. +#include <linux/kernel.h>
  32577. +#include <linux/module.h>
  32578. +#include <linux/init.h>
  32579. +#include <linux/platform_device.h>
  32580. +#include <linux/leds.h>
  32581. +#include <linux/slab.h>
  32582. +
  32583. +#include <asm/mach-ath79/mach-rb750.h>
  32584. +
  32585. +#define DRV_NAME "leds-rb750"
  32586. +
  32587. +struct rb750_led_dev {
  32588. + struct led_classdev cdev;
  32589. + u32 mask;
  32590. + int active_low;
  32591. + void (*latch_change)(u32 clear, u32 set);
  32592. +};
  32593. +
  32594. +struct rb750_led_drvdata {
  32595. + struct rb750_led_dev *led_devs;
  32596. + int num_leds;
  32597. +};
  32598. +
  32599. +static inline struct rb750_led_dev *to_rbled(struct led_classdev *led_cdev)
  32600. +{
  32601. + return (struct rb750_led_dev *)container_of(led_cdev,
  32602. + struct rb750_led_dev, cdev);
  32603. +}
  32604. +
  32605. +static void rb750_led_brightness_set(struct led_classdev *led_cdev,
  32606. + enum led_brightness value)
  32607. +{
  32608. + struct rb750_led_dev *rbled = to_rbled(led_cdev);
  32609. + int level;
  32610. +
  32611. + level = (value == LED_OFF) ? 0 : 1;
  32612. + level ^= rbled->active_low;
  32613. +
  32614. + if (level)
  32615. + rbled->latch_change(0, rbled->mask);
  32616. + else
  32617. + rbled->latch_change(rbled->mask, 0);
  32618. +}
  32619. +
  32620. +static int rb750_led_probe(struct platform_device *pdev)
  32621. +{
  32622. + struct rb750_led_platform_data *pdata;
  32623. + struct rb750_led_drvdata *drvdata;
  32624. + int ret = 0;
  32625. + int i;
  32626. +
  32627. + pdata = pdev->dev.platform_data;
  32628. + if (!pdata)
  32629. + return -EINVAL;
  32630. +
  32631. + drvdata = kzalloc(sizeof(struct rb750_led_drvdata) +
  32632. + sizeof(struct rb750_led_dev) * pdata->num_leds,
  32633. + GFP_KERNEL);
  32634. + if (!drvdata)
  32635. + return -ENOMEM;
  32636. +
  32637. + drvdata->num_leds = pdata->num_leds;
  32638. + drvdata->led_devs = (struct rb750_led_dev *) &drvdata[1];
  32639. +
  32640. + for (i = 0; i < drvdata->num_leds; i++) {
  32641. + struct rb750_led_dev *rbled = &drvdata->led_devs[i];
  32642. + struct rb750_led_data *led_data = &pdata->leds[i];
  32643. +
  32644. + rbled->cdev.name = led_data->name;
  32645. + rbled->cdev.default_trigger = led_data->default_trigger;
  32646. + rbled->cdev.brightness_set = rb750_led_brightness_set;
  32647. + rbled->cdev.brightness = LED_OFF;
  32648. +
  32649. + rbled->mask = led_data->mask;
  32650. + rbled->active_low = !!led_data->active_low;
  32651. + rbled->latch_change = pdata->latch_change;
  32652. +
  32653. + ret = led_classdev_register(&pdev->dev, &rbled->cdev);
  32654. + if (ret)
  32655. + goto err;
  32656. + }
  32657. +
  32658. + platform_set_drvdata(pdev, drvdata);
  32659. + return 0;
  32660. +
  32661. +err:
  32662. + for (i = i - 1; i >= 0; i--)
  32663. + led_classdev_unregister(&drvdata->led_devs[i].cdev);
  32664. +
  32665. + kfree(drvdata);
  32666. + return ret;
  32667. +}
  32668. +
  32669. +static int rb750_led_remove(struct platform_device *pdev)
  32670. +{
  32671. + struct rb750_led_drvdata *drvdata;
  32672. + int i;
  32673. +
  32674. + drvdata = platform_get_drvdata(pdev);
  32675. + for (i = 0; i < drvdata->num_leds; i++)
  32676. + led_classdev_unregister(&drvdata->led_devs[i].cdev);
  32677. +
  32678. + kfree(drvdata);
  32679. + return 0;
  32680. +}
  32681. +
  32682. +static struct platform_driver rb750_led_driver = {
  32683. + .probe = rb750_led_probe,
  32684. + .remove = rb750_led_remove,
  32685. + .driver = {
  32686. + .name = DRV_NAME,
  32687. + .owner = THIS_MODULE,
  32688. + },
  32689. +};
  32690. +
  32691. +MODULE_ALIAS("platform:leds-rb750");
  32692. +
  32693. +static int __init rb750_led_init(void)
  32694. +{
  32695. + return platform_driver_register(&rb750_led_driver);
  32696. +}
  32697. +
  32698. +static void __exit rb750_led_exit(void)
  32699. +{
  32700. + platform_driver_unregister(&rb750_led_driver);
  32701. +}
  32702. +
  32703. +module_init(rb750_led_init);
  32704. +module_exit(rb750_led_exit);
  32705. +
  32706. +MODULE_DESCRIPTION(DRV_NAME);
  32707. +MODULE_DESCRIPTION("LED driver for the RouterBOARD 750");
  32708. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  32709. +MODULE_LICENSE("GPL v2");
  32710. diff -Nur linux-4.1.13.orig/drivers/leds/leds-wndr3700-usb.c linux-4.1.13/drivers/leds/leds-wndr3700-usb.c
  32711. --- linux-4.1.13.orig/drivers/leds/leds-wndr3700-usb.c 1970-01-01 01:00:00.000000000 +0100
  32712. +++ linux-4.1.13/drivers/leds/leds-wndr3700-usb.c 2015-09-13 20:04:35.072523889 +0200
  32713. @@ -0,0 +1,76 @@
  32714. +/*
  32715. + * USB LED driver for the NETGEAR WNDR3700
  32716. + *
  32717. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  32718. + *
  32719. + * This program is free software; you can redistribute it and/or modify it
  32720. + * under the terms of the GNU General Public License version 2 as published
  32721. + * by the Free Software Foundation.
  32722. + */
  32723. +
  32724. +#include <linux/leds.h>
  32725. +#include <linux/module.h>
  32726. +#include <linux/platform_device.h>
  32727. +
  32728. +#include <asm/mach-ath79/ar71xx_regs.h>
  32729. +#include <asm/mach-ath79/ath79.h>
  32730. +
  32731. +#define DRIVER_NAME "wndr3700-led-usb"
  32732. +
  32733. +static void wndr3700_usb_led_set(struct led_classdev *cdev,
  32734. + enum led_brightness brightness)
  32735. +{
  32736. + if (brightness)
  32737. + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
  32738. + else
  32739. + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
  32740. +}
  32741. +
  32742. +static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
  32743. +{
  32744. + return ath79_device_reset_get(AR71XX_RESET_GE1_PHY) ? LED_OFF : LED_FULL;
  32745. +}
  32746. +
  32747. +static struct led_classdev wndr3700_usb_led = {
  32748. + .name = "netgear:green:usb",
  32749. + .brightness_set = wndr3700_usb_led_set,
  32750. + .brightness_get = wndr3700_usb_led_get,
  32751. +};
  32752. +
  32753. +static int wndr3700_usb_led_probe(struct platform_device *pdev)
  32754. +{
  32755. + return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
  32756. +}
  32757. +
  32758. +static int wndr3700_usb_led_remove(struct platform_device *pdev)
  32759. +{
  32760. + led_classdev_unregister(&wndr3700_usb_led);
  32761. + return 0;
  32762. +}
  32763. +
  32764. +static struct platform_driver wndr3700_usb_led_driver = {
  32765. + .probe = wndr3700_usb_led_probe,
  32766. + .remove = wndr3700_usb_led_remove,
  32767. + .driver = {
  32768. + .name = DRIVER_NAME,
  32769. + .owner = THIS_MODULE,
  32770. + },
  32771. +};
  32772. +
  32773. +static int __init wndr3700_usb_led_init(void)
  32774. +{
  32775. + return platform_driver_register(&wndr3700_usb_led_driver);
  32776. +}
  32777. +
  32778. +static void __exit wndr3700_usb_led_exit(void)
  32779. +{
  32780. + platform_driver_unregister(&wndr3700_usb_led_driver);
  32781. +}
  32782. +
  32783. +module_init(wndr3700_usb_led_init);
  32784. +module_exit(wndr3700_usb_led_exit);
  32785. +
  32786. +MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
  32787. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  32788. +MODULE_LICENSE("GPL v2");
  32789. +MODULE_ALIAS("platform:" DRIVER_NAME);
  32790. diff -Nur linux-4.1.13.orig/drivers/leds/Makefile linux-4.1.13/drivers/leds/Makefile
  32791. --- linux-4.1.13.orig/drivers/leds/Makefile 2015-11-09 23:34:10.000000000 +0100
  32792. +++ linux-4.1.13/drivers/leds/Makefile 2015-12-04 19:57:03.926108026 +0100
  32793. @@ -43,12 +43,14 @@
  32794. obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
  32795. obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
  32796. obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
  32797. +obj-${CONFIG_LEDS_WNDR3700_USB} += leds-wndr3700-usb.o
  32798. obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o
  32799. obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o
  32800. obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o
  32801. obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
  32802. obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o
  32803. obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
  32804. +obj-$(CONFIG_LEDS_RB750) += leds-rb750.o
  32805. obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
  32806. obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
  32807. obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
  32808. diff -Nur linux-4.1.13.orig/drivers/Makefile linux-4.1.13/drivers/Makefile
  32809. --- linux-4.1.13.orig/drivers/Makefile 2015-11-09 23:34:10.000000000 +0100
  32810. +++ linux-4.1.13/drivers/Makefile 2015-12-04 19:57:03.890110382 +0100
  32811. @@ -71,8 +71,8 @@
  32812. obj-$(CONFIG_SCSI) += scsi/
  32813. obj-$(CONFIG_ATA) += ata/
  32814. obj-$(CONFIG_TARGET_CORE) += target/
  32815. -obj-$(CONFIG_MTD) += mtd/
  32816. obj-$(CONFIG_SPI) += spi/
  32817. +obj-$(CONFIG_MTD) += mtd/
  32818. obj-$(CONFIG_SPMI) += spmi/
  32819. obj-y += hsi/
  32820. obj-y += net/
  32821. diff -Nur linux-4.1.13.orig/drivers/mtd/chips/cfi_cmdset_0002.c linux-4.1.13/drivers/mtd/chips/cfi_cmdset_0002.c
  32822. --- linux-4.1.13.orig/drivers/mtd/chips/cfi_cmdset_0002.c 2015-11-09 23:34:10.000000000 +0100
  32823. +++ linux-4.1.13/drivers/mtd/chips/cfi_cmdset_0002.c 2015-12-04 19:57:03.878111167 +0100
  32824. @@ -40,7 +40,7 @@
  32825. #include <linux/mtd/xip.h>
  32826. #define AMD_BOOTLOC_BUG
  32827. -#define FORCE_WORD_WRITE 0
  32828. +#define FORCE_WORD_WRITE 1
  32829. #define MAX_WORD_RETRIES 3
  32830. @@ -51,7 +51,9 @@
  32831. static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
  32832. static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
  32833. +#if !FORCE_WORD_WRITE
  32834. static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
  32835. +#endif
  32836. static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *);
  32837. static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *);
  32838. static void cfi_amdstd_sync (struct mtd_info *);
  32839. @@ -202,6 +204,7 @@
  32840. }
  32841. #endif
  32842. +#if !FORCE_WORD_WRITE
  32843. static void fixup_use_write_buffers(struct mtd_info *mtd)
  32844. {
  32845. struct map_info *map = mtd->priv;
  32846. @@ -211,6 +214,7 @@
  32847. mtd->_write = cfi_amdstd_write_buffers;
  32848. }
  32849. }
  32850. +#endif /* !FORCE_WORD_WRITE */
  32851. /* Atmel chips don't use the same PRI format as AMD chips */
  32852. static void fixup_convert_atmel_pri(struct mtd_info *mtd)
  32853. @@ -1632,8 +1636,8 @@
  32854. break;
  32855. }
  32856. - if (chip_ready(map, adr))
  32857. - break;
  32858. + if (chip_good(map, adr, datum))
  32859. + goto enable_xip;
  32860. /* Latency issues. Drop the lock, wait a while and retry */
  32861. UDELAY(map, chip, adr, 1);
  32862. @@ -1649,6 +1653,8 @@
  32863. ret = -EIO;
  32864. }
  32865. +
  32866. + enable_xip:
  32867. xip_enable(map, chip, adr);
  32868. op_done:
  32869. if (mode == FL_OTP_WRITE)
  32870. @@ -1789,6 +1795,7 @@
  32871. /*
  32872. * FIXME: interleaved mode not tested, and probably not supported!
  32873. */
  32874. +#if !FORCE_WORD_WRITE
  32875. static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
  32876. unsigned long adr, const u_char *buf,
  32877. int len)
  32878. @@ -1916,7 +1923,6 @@
  32879. return ret;
  32880. }
  32881. -
  32882. static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
  32883. size_t *retlen, const u_char *buf)
  32884. {
  32885. @@ -1991,6 +1997,7 @@
  32886. return 0;
  32887. }
  32888. +#endif /* !FORCE_WORD_WRITE */
  32889. /*
  32890. * Wait for the flash chip to become ready to write data
  32891. @@ -2226,7 +2233,6 @@
  32892. return 0;
  32893. }
  32894. -
  32895. /*
  32896. * Handle devices with one erase region, that only implement
  32897. * the chip erase command.
  32898. @@ -2290,8 +2296,8 @@
  32899. chip->erase_suspended = 0;
  32900. }
  32901. - if (chip_ready(map, adr))
  32902. - break;
  32903. + if (chip_good(map, adr, map_word_ff(map)))
  32904. + goto op_done;
  32905. if (time_after(jiffies, timeo)) {
  32906. printk(KERN_WARNING "MTD %s(): software timeout\n",
  32907. @@ -2311,6 +2317,7 @@
  32908. ret = -EIO;
  32909. }
  32910. + op_done:
  32911. chip->state = FL_READY;
  32912. xip_enable(map, chip, adr);
  32913. DISABLE_VPP(map);
  32914. @@ -2379,9 +2386,9 @@
  32915. chip->erase_suspended = 0;
  32916. }
  32917. - if (chip_ready(map, adr)) {
  32918. + if (chip_good(map, adr, map_word_ff(map))) {
  32919. xip_enable(map, chip, adr);
  32920. - break;
  32921. + goto op_done;
  32922. }
  32923. if (time_after(jiffies, timeo)) {
  32924. @@ -2403,6 +2410,7 @@
  32925. ret = -EIO;
  32926. }
  32927. + op_done:
  32928. chip->state = FL_READY;
  32929. DISABLE_VPP(map);
  32930. put_chip(map, chip, adr);
  32931. diff -Nur linux-4.1.13.orig/drivers/mtd/chips/jedec_probe.c linux-4.1.13/drivers/mtd/chips/jedec_probe.c
  32932. --- linux-4.1.13.orig/drivers/mtd/chips/jedec_probe.c 2015-11-09 23:34:10.000000000 +0100
  32933. +++ linux-4.1.13/drivers/mtd/chips/jedec_probe.c 2015-12-04 19:57:03.834114045 +0100
  32934. @@ -148,6 +148,7 @@
  32935. #define SST39LF160 0x2782
  32936. #define SST39VF1601 0x234b
  32937. #define SST39VF3201 0x235b
  32938. +#define SST39VF6401B 0x236d
  32939. #define SST39WF1601 0x274b
  32940. #define SST39WF1602 0x274a
  32941. #define SST39LF512 0x00D4
  32942. @@ -1569,6 +1570,18 @@
  32943. ERASEINFO(0x10000,64),
  32944. }
  32945. }, {
  32946. + .mfr_id = CFI_MFR_SST,
  32947. + .dev_id = SST39VF6401B,
  32948. + .name = "SST 39VF6401B",
  32949. + .devtypes = CFI_DEVICETYPE_X16,
  32950. + .uaddr = MTD_UADDR_0xAAAA_0x5555,
  32951. + .dev_size = SIZE_8MiB,
  32952. + .cmd_set = P_ID_AMD_STD,
  32953. + .nr_regions = 1,
  32954. + .regions = {
  32955. + ERASEINFO(0x10000,128)
  32956. + }
  32957. + }, {
  32958. .mfr_id = CFI_MFR_ST,
  32959. .dev_id = M29F800AB,
  32960. .name = "ST M29F800AB",
  32961. diff -Nur linux-4.1.13.orig/drivers/mtd/cybertan_part.c linux-4.1.13/drivers/mtd/cybertan_part.c
  32962. --- linux-4.1.13.orig/drivers/mtd/cybertan_part.c 1970-01-01 01:00:00.000000000 +0100
  32963. +++ linux-4.1.13/drivers/mtd/cybertan_part.c 2015-09-13 20:04:35.072523889 +0200
  32964. @@ -0,0 +1,201 @@
  32965. +/*
  32966. + * Copyright (C) 2009 Christian Daniel <cd@maintech.de>
  32967. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  32968. + *
  32969. + * This program is free software; you can redistribute it and/or modify
  32970. + * it under the terms of the GNU General Public License as published by
  32971. + * the Free Software Foundation; either version 2 of the License, or
  32972. + * (at your option) any later version.
  32973. + *
  32974. + * This program is distributed in the hope that it will be useful,
  32975. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32976. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32977. + * GNU General Public License for more details.
  32978. + *
  32979. + * You should have received a copy of the GNU General Public License
  32980. + * along with this program; if not, write to the Free Software
  32981. + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  32982. + *
  32983. + * TRX flash partition table.
  32984. + * Based on ar7 map by Felix Fietkau <nbd@openwrt.org>
  32985. + *
  32986. + */
  32987. +
  32988. +#include <linux/kernel.h>
  32989. +#include <linux/module.h>
  32990. +#include <linux/slab.h>
  32991. +#include <linux/vmalloc.h>
  32992. +
  32993. +#include <linux/mtd/mtd.h>
  32994. +#include <linux/mtd/partitions.h>
  32995. +
  32996. +struct cybertan_header {
  32997. + char magic[4];
  32998. + u8 res1[4];
  32999. + char fw_date[3];
  33000. + char fw_ver[3];
  33001. + char id[4];
  33002. + char hw_ver;
  33003. + char unused;
  33004. + u8 flags[2];
  33005. + u8 res2[10];
  33006. +};
  33007. +
  33008. +#define TRX_PARTS 6
  33009. +#define TRX_MAGIC 0x30524448
  33010. +#define TRX_MAX_OFFSET 3
  33011. +
  33012. +struct trx_header {
  33013. + uint32_t magic; /* "HDR0" */
  33014. + uint32_t len; /* Length of file including header */
  33015. + uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
  33016. + uint32_t flag_version; /* 0:15 flags, 16:31 version */
  33017. + uint32_t offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
  33018. +};
  33019. +
  33020. +#define IH_MAGIC 0x27051956 /* Image Magic Number */
  33021. +#define IH_NMLEN 32 /* Image Name Length */
  33022. +
  33023. +struct uimage_header {
  33024. + uint32_t ih_magic; /* Image Header Magic Number */
  33025. + uint32_t ih_hcrc; /* Image Header CRC Checksum */
  33026. + uint32_t ih_time; /* Image Creation Timestamp */
  33027. + uint32_t ih_size; /* Image Data Size */
  33028. + uint32_t ih_load; /* Data» Load Address */
  33029. + uint32_t ih_ep; /* Entry Point Address */
  33030. + uint32_t ih_dcrc; /* Image Data CRC Checksum */
  33031. + uint8_t ih_os; /* Operating System */
  33032. + uint8_t ih_arch; /* CPU architecture */
  33033. + uint8_t ih_type; /* Image Type */
  33034. + uint8_t ih_comp; /* Compression Type */
  33035. + uint8_t ih_name[IH_NMLEN]; /* Image Name */
  33036. +};
  33037. +
  33038. +struct firmware_header {
  33039. + struct cybertan_header cybertan;
  33040. + struct trx_header trx;
  33041. + struct uimage_header uimage;
  33042. +} __packed;
  33043. +
  33044. +#define UBOOT_LEN 0x40000
  33045. +#define ART_LEN 0x10000
  33046. +#define NVRAM_LEN 0x10000
  33047. +
  33048. +static int cybertan_parse_partitions(struct mtd_info *master,
  33049. + struct mtd_partition **pparts,
  33050. + struct mtd_part_parser_data *data)
  33051. +{
  33052. + struct firmware_header *header;
  33053. + struct trx_header *theader;
  33054. + struct uimage_header *uheader;
  33055. + struct mtd_partition *trx_parts;
  33056. + size_t retlen;
  33057. + unsigned int kernel_len;
  33058. + unsigned int uboot_len;
  33059. + unsigned int nvram_len;
  33060. + unsigned int art_len;
  33061. + int ret;
  33062. +
  33063. + uboot_len = max_t(unsigned int, master->erasesize, UBOOT_LEN);
  33064. + nvram_len = max_t(unsigned int, master->erasesize, NVRAM_LEN);
  33065. + art_len = max_t(unsigned int, master->erasesize, ART_LEN);
  33066. +
  33067. + trx_parts = kzalloc(TRX_PARTS * sizeof(struct mtd_partition),
  33068. + GFP_KERNEL);
  33069. + if (!trx_parts) {
  33070. + ret = -ENOMEM;
  33071. + goto out;
  33072. + }
  33073. +
  33074. + header = vmalloc(sizeof(*header));
  33075. + if (!header) {
  33076. + return -ENOMEM;
  33077. + goto free_parts;
  33078. + }
  33079. +
  33080. + ret = mtd_read(master, uboot_len, sizeof(*header),
  33081. + &retlen, (void *) header);
  33082. + if (ret)
  33083. + goto free_hdr;
  33084. +
  33085. + if (retlen != sizeof(*header)) {
  33086. + ret = -EIO;
  33087. + goto free_hdr;
  33088. + }
  33089. +
  33090. + theader = &header->trx;
  33091. + if (le32_to_cpu(theader->magic) != TRX_MAGIC) {
  33092. + printk(KERN_NOTICE "%s: no TRX header found\n", master->name);
  33093. + goto free_hdr;
  33094. + }
  33095. +
  33096. + uheader = &header->uimage;
  33097. + if (uheader->ih_magic != IH_MAGIC) {
  33098. + printk(KERN_NOTICE "%s: no uImage found\n", master->name);
  33099. + goto free_hdr;
  33100. + }
  33101. +
  33102. + kernel_len = le32_to_cpu(theader->offsets[1]) +
  33103. + sizeof(struct cybertan_header);
  33104. +
  33105. + trx_parts[0].name = "u-boot";
  33106. + trx_parts[0].offset = 0;
  33107. + trx_parts[0].size = uboot_len;
  33108. + trx_parts[0].mask_flags = MTD_WRITEABLE;
  33109. +
  33110. + trx_parts[1].name = "kernel";
  33111. + trx_parts[1].offset = trx_parts[0].offset + trx_parts[0].size;
  33112. + trx_parts[1].size = kernel_len;
  33113. + trx_parts[1].mask_flags = 0;
  33114. +
  33115. + trx_parts[2].name = "rootfs";
  33116. + trx_parts[2].offset = trx_parts[1].offset + trx_parts[1].size;
  33117. + trx_parts[2].size = master->size - uboot_len - nvram_len - art_len -
  33118. + trx_parts[1].size;
  33119. + trx_parts[2].mask_flags = 0;
  33120. +
  33121. + trx_parts[3].name = "nvram";
  33122. + trx_parts[3].offset = master->size - nvram_len - art_len;
  33123. + trx_parts[3].size = nvram_len;
  33124. + trx_parts[3].mask_flags = MTD_WRITEABLE;
  33125. +
  33126. + trx_parts[4].name = "art";
  33127. + trx_parts[4].offset = master->size - art_len;
  33128. + trx_parts[4].size = art_len;
  33129. + trx_parts[4].mask_flags = MTD_WRITEABLE;
  33130. +
  33131. + trx_parts[5].name = "firmware";
  33132. + trx_parts[5].offset = uboot_len;
  33133. + trx_parts[5].size = master->size - uboot_len - nvram_len - art_len;
  33134. + trx_parts[5].mask_flags = 0;
  33135. +
  33136. + vfree(header);
  33137. +
  33138. + *pparts = trx_parts;
  33139. + return TRX_PARTS;
  33140. +
  33141. +free_hdr:
  33142. + vfree(header);
  33143. +free_parts:
  33144. + kfree(trx_parts);
  33145. +out:
  33146. + return ret;
  33147. +}
  33148. +
  33149. +static struct mtd_part_parser cybertan_parser = {
  33150. + .owner = THIS_MODULE,
  33151. + .parse_fn = cybertan_parse_partitions,
  33152. + .name = "cybertan",
  33153. +};
  33154. +
  33155. +static int __init cybertan_parser_init(void)
  33156. +{
  33157. + register_mtd_parser(&cybertan_parser);
  33158. +
  33159. + return 0;
  33160. +}
  33161. +
  33162. +module_init(cybertan_parser_init);
  33163. +
  33164. +MODULE_LICENSE("GPL");
  33165. +MODULE_AUTHOR("Christian Daniel <cd@maintech.de>");
  33166. diff -Nur linux-4.1.13.orig/drivers/mtd/devices/m25p80.c linux-4.1.13/drivers/mtd/devices/m25p80.c
  33167. --- linux-4.1.13.orig/drivers/mtd/devices/m25p80.c 2015-11-09 23:34:10.000000000 +0100
  33168. +++ linux-4.1.13/drivers/mtd/devices/m25p80.c 2015-12-04 19:57:03.966105410 +0100
  33169. @@ -139,10 +139,15 @@
  33170. flash->command[0] = nor->read_opcode;
  33171. m25p_addr2cmd(nor, from, flash->command);
  33172. + if (dummy == 1)
  33173. + t[0].dummy = true;
  33174. +
  33175. + t[0].type = SPI_TRANSFER_FLASH_READ_CMD;
  33176. t[0].tx_buf = flash->command;
  33177. t[0].len = m25p_cmdsz(nor) + dummy;
  33178. spi_message_add_tail(&t[0], &m);
  33179. + t[1].type = SPI_TRANSFER_FLASH_READ_DATA;
  33180. t[1].rx_buf = buf;
  33181. t[1].rx_nbits = m25p80_rx_nbits(nor);
  33182. t[1].len = len;
  33183. @@ -232,6 +237,7 @@
  33184. if (ret)
  33185. return ret;
  33186. + memset(&ppdata, '\0', sizeof(ppdata));
  33187. ppdata.of_node = spi->dev.of_node;
  33188. return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
  33189. diff -Nur linux-4.1.13.orig/drivers/mtd/Kconfig linux-4.1.13/drivers/mtd/Kconfig
  33190. --- linux-4.1.13.orig/drivers/mtd/Kconfig 2015-11-09 23:34:10.000000000 +0100
  33191. +++ linux-4.1.13/drivers/mtd/Kconfig 2015-12-04 19:57:03.850112998 +0100
  33192. @@ -155,6 +155,12 @@
  33193. This provides partitions parser for devices based on BCM47xx
  33194. boards.
  33195. +config MTD_TPLINK_PARTS
  33196. + tristate "TP-Link AR7XXX/AR9XXX partitioning support"
  33197. + depends on ATH79
  33198. + ---help---
  33199. + TBD.
  33200. +
  33201. comment "User Modules And Translation Layers"
  33202. #
  33203. diff -Nur linux-4.1.13.orig/drivers/mtd/maps/physmap.c linux-4.1.13/drivers/mtd/maps/physmap.c
  33204. --- linux-4.1.13.orig/drivers/mtd/maps/physmap.c 2015-11-09 23:34:10.000000000 +0100
  33205. +++ linux-4.1.13/drivers/mtd/maps/physmap.c 2015-12-04 19:57:03.830114307 +0100
  33206. @@ -31,6 +31,66 @@
  33207. int vpp_refcnt;
  33208. };
  33209. +static struct platform_device *physmap_map2pdev(struct map_info *map)
  33210. +{
  33211. + return (struct platform_device *) map->map_priv_1;
  33212. +}
  33213. +
  33214. +static void physmap_lock(struct map_info *map)
  33215. +{
  33216. + struct platform_device *pdev;
  33217. + struct physmap_flash_data *physmap_data;
  33218. +
  33219. + pdev = physmap_map2pdev(map);
  33220. + physmap_data = pdev->dev.platform_data;
  33221. + physmap_data->lock(pdev);
  33222. +}
  33223. +
  33224. +static void physmap_unlock(struct map_info *map)
  33225. +{
  33226. + struct platform_device *pdev;
  33227. + struct physmap_flash_data *physmap_data;
  33228. +
  33229. + pdev = physmap_map2pdev(map);
  33230. + physmap_data = pdev->dev.platform_data;
  33231. + physmap_data->unlock(pdev);
  33232. +}
  33233. +
  33234. +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
  33235. +{
  33236. + map_word ret;
  33237. +
  33238. + physmap_lock(map);
  33239. + ret = inline_map_read(map, ofs);
  33240. + physmap_unlock(map);
  33241. +
  33242. + return ret;
  33243. +}
  33244. +
  33245. +static void physmap_flash_write_lock(struct map_info *map, map_word d,
  33246. + unsigned long ofs)
  33247. +{
  33248. + physmap_lock(map);
  33249. + inline_map_write(map, d, ofs);
  33250. + physmap_unlock(map);
  33251. +}
  33252. +
  33253. +static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
  33254. + unsigned long from, ssize_t len)
  33255. +{
  33256. + physmap_lock(map);
  33257. + inline_map_copy_from(map, to, from, len);
  33258. + physmap_unlock(map);
  33259. +}
  33260. +
  33261. +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
  33262. + const void *from, ssize_t len)
  33263. +{
  33264. + physmap_lock(map);
  33265. + inline_map_copy_to(map, to, from, len);
  33266. + physmap_unlock(map);
  33267. +}
  33268. +
  33269. static int physmap_flash_remove(struct platform_device *dev)
  33270. {
  33271. struct physmap_flash_info *info;
  33272. @@ -153,6 +213,13 @@
  33273. simple_map_init(&info->map[i]);
  33274. + if (physmap_data->lock && physmap_data->unlock) {
  33275. + info->map[i].read = physmap_flash_read_lock;
  33276. + info->map[i].write = physmap_flash_write_lock;
  33277. + info->map[i].copy_from = physmap_flash_copy_from_lock;
  33278. + info->map[i].copy_to = physmap_flash_copy_to_lock;
  33279. + }
  33280. +
  33281. probe_type = rom_probe_types;
  33282. if (physmap_data->probe_type == NULL) {
  33283. for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
  33284. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/ar934x_nfc.c linux-4.1.13/drivers/mtd/nand/ar934x_nfc.c
  33285. --- linux-4.1.13.orig/drivers/mtd/nand/ar934x_nfc.c 1970-01-01 01:00:00.000000000 +0100
  33286. +++ linux-4.1.13/drivers/mtd/nand/ar934x_nfc.c 2015-09-13 20:04:35.076523692 +0200
  33287. @@ -0,0 +1,1508 @@
  33288. +/*
  33289. + * Driver for the built-in NAND controller of the Atheros AR934x SoCs
  33290. + *
  33291. + * Copyright (C) 2011-2013 Gabor Juhos <juhosg@openwrt.org>
  33292. + *
  33293. + * This program is free software; you can redistribute it and/or modify it
  33294. + * under the terms of the GNU General Public License version 2 as published
  33295. + * by the Free Software Foundation.
  33296. + */
  33297. +
  33298. +#include <linux/init.h>
  33299. +#include <linux/interrupt.h>
  33300. +#include <linux/module.h>
  33301. +#include <linux/dma-mapping.h>
  33302. +#include <linux/mtd/mtd.h>
  33303. +#include <linux/mtd/nand.h>
  33304. +#include <linux/mtd/partitions.h>
  33305. +#include <linux/platform_device.h>
  33306. +#include <linux/delay.h>
  33307. +#include <linux/slab.h>
  33308. +
  33309. +#include <linux/platform/ar934x_nfc.h>
  33310. +
  33311. +#define AR934X_NFC_REG_CMD 0x00
  33312. +#define AR934X_NFC_REG_CTRL 0x04
  33313. +#define AR934X_NFC_REG_STATUS 0x08
  33314. +#define AR934X_NFC_REG_INT_MASK 0x0c
  33315. +#define AR934X_NFC_REG_INT_STATUS 0x10
  33316. +#define AR934X_NFC_REG_ECC_CTRL 0x14
  33317. +#define AR934X_NFC_REG_ECC_OFFSET 0x18
  33318. +#define AR934X_NFC_REG_ADDR0_0 0x1c
  33319. +#define AR934X_NFC_REG_ADDR0_1 0x24
  33320. +#define AR934X_NFC_REG_ADDR1_0 0x20
  33321. +#define AR934X_NFC_REG_ADDR1_1 0x28
  33322. +#define AR934X_NFC_REG_SPARE_SIZE 0x30
  33323. +#define AR934X_NFC_REG_PROTECT 0x38
  33324. +#define AR934X_NFC_REG_LOOKUP_EN 0x40
  33325. +#define AR934X_NFC_REG_LOOKUP(_x) (0x44 + (_i) * 4)
  33326. +#define AR934X_NFC_REG_DMA_ADDR 0x64
  33327. +#define AR934X_NFC_REG_DMA_COUNT 0x68
  33328. +#define AR934X_NFC_REG_DMA_CTRL 0x6c
  33329. +#define AR934X_NFC_REG_MEM_CTRL 0x80
  33330. +#define AR934X_NFC_REG_DATA_SIZE 0x84
  33331. +#define AR934X_NFC_REG_READ_STATUS 0x88
  33332. +#define AR934X_NFC_REG_TIME_SEQ 0x8c
  33333. +#define AR934X_NFC_REG_TIMINGS_ASYN 0x90
  33334. +#define AR934X_NFC_REG_TIMINGS_SYN 0x94
  33335. +#define AR934X_NFC_REG_FIFO_DATA 0x98
  33336. +#define AR934X_NFC_REG_TIME_MODE 0x9c
  33337. +#define AR934X_NFC_REG_DMA_ADDR_OFFS 0xa0
  33338. +#define AR934X_NFC_REG_FIFO_INIT 0xb0
  33339. +#define AR934X_NFC_REG_GEN_SEQ_CTRL 0xb4
  33340. +
  33341. +#define AR934X_NFC_CMD_CMD_SEQ_S 0
  33342. +#define AR934X_NFC_CMD_CMD_SEQ_M 0x3f
  33343. +#define AR934X_NFC_CMD_SEQ_1C 0x00
  33344. +#define AR934X_NFC_CMD_SEQ_ERASE 0x0e
  33345. +#define AR934X_NFC_CMD_SEQ_12 0x0c
  33346. +#define AR934X_NFC_CMD_SEQ_1C1AXR 0x21
  33347. +#define AR934X_NFC_CMD_SEQ_S 0x24
  33348. +#define AR934X_NFC_CMD_SEQ_1C3AXR 0x27
  33349. +#define AR934X_NFC_CMD_SEQ_1C5A1CXR 0x2a
  33350. +#define AR934X_NFC_CMD_SEQ_18 0x32
  33351. +#define AR934X_NFC_CMD_INPUT_SEL_SIU 0
  33352. +#define AR934X_NFC_CMD_INPUT_SEL_DMA BIT(6)
  33353. +#define AR934X_NFC_CMD_ADDR_SEL_0 0
  33354. +#define AR934X_NFC_CMD_ADDR_SEL_1 BIT(7)
  33355. +#define AR934X_NFC_CMD_CMD0_S 8
  33356. +#define AR934X_NFC_CMD_CMD0_M 0xff
  33357. +#define AR934X_NFC_CMD_CMD1_S 16
  33358. +#define AR934X_NFC_CMD_CMD1_M 0xff
  33359. +#define AR934X_NFC_CMD_CMD2_S 24
  33360. +#define AR934X_NFC_CMD_CMD2_M 0xff
  33361. +
  33362. +#define AR934X_NFC_CTRL_ADDR_CYCLE0_M 0x7
  33363. +#define AR934X_NFC_CTRL_ADDR_CYCLE0_S 0
  33364. +#define AR934X_NFC_CTRL_SPARE_EN BIT(3)
  33365. +#define AR934X_NFC_CTRL_INT_EN BIT(4)
  33366. +#define AR934X_NFC_CTRL_ECC_EN BIT(5)
  33367. +#define AR934X_NFC_CTRL_BLOCK_SIZE_S 6
  33368. +#define AR934X_NFC_CTRL_BLOCK_SIZE_M 0x3
  33369. +#define AR934X_NFC_CTRL_BLOCK_SIZE_32 0
  33370. +#define AR934X_NFC_CTRL_BLOCK_SIZE_64 1
  33371. +#define AR934X_NFC_CTRL_BLOCK_SIZE_128 2
  33372. +#define AR934X_NFC_CTRL_BLOCK_SIZE_256 3
  33373. +#define AR934X_NFC_CTRL_PAGE_SIZE_S 8
  33374. +#define AR934X_NFC_CTRL_PAGE_SIZE_M 0x7
  33375. +#define AR934X_NFC_CTRL_PAGE_SIZE_256 0
  33376. +#define AR934X_NFC_CTRL_PAGE_SIZE_512 1
  33377. +#define AR934X_NFC_CTRL_PAGE_SIZE_1024 2
  33378. +#define AR934X_NFC_CTRL_PAGE_SIZE_2048 3
  33379. +#define AR934X_NFC_CTRL_PAGE_SIZE_4096 4
  33380. +#define AR934X_NFC_CTRL_PAGE_SIZE_8192 5
  33381. +#define AR934X_NFC_CTRL_PAGE_SIZE_16384 6
  33382. +#define AR934X_NFC_CTRL_CUSTOM_SIZE_EN BIT(11)
  33383. +#define AR934X_NFC_CTRL_IO_WIDTH_8BITS 0
  33384. +#define AR934X_NFC_CTRL_IO_WIDTH_16BITS BIT(12)
  33385. +#define AR934X_NFC_CTRL_LOOKUP_EN BIT(13)
  33386. +#define AR934X_NFC_CTRL_PROT_EN BIT(14)
  33387. +#define AR934X_NFC_CTRL_WORK_MODE_ASYNC 0
  33388. +#define AR934X_NFC_CTRL_WORK_MODE_SYNC BIT(15)
  33389. +#define AR934X_NFC_CTRL_ADDR0_AUTO_INC BIT(16)
  33390. +#define AR934X_NFC_CTRL_ADDR1_AUTO_INC BIT(17)
  33391. +#define AR934X_NFC_CTRL_ADDR_CYCLE1_M 0x7
  33392. +#define AR934X_NFC_CTRL_ADDR_CYCLE1_S 18
  33393. +#define AR934X_NFC_CTRL_SMALL_PAGE BIT(21)
  33394. +
  33395. +#define AR934X_NFC_DMA_CTRL_DMA_START BIT(7)
  33396. +#define AR934X_NFC_DMA_CTRL_DMA_DIR_WRITE 0
  33397. +#define AR934X_NFC_DMA_CTRL_DMA_DIR_READ BIT(6)
  33398. +#define AR934X_NFC_DMA_CTRL_DMA_MODE_SG BIT(5)
  33399. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_S 2
  33400. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_0 0
  33401. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_1 1
  33402. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_2 2
  33403. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_3 3
  33404. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_4 4
  33405. +#define AR934X_NFC_DMA_CTRL_DMA_BURST_5 5
  33406. +#define AR934X_NFC_DMA_CTRL_ERR_FLAG BIT(1)
  33407. +#define AR934X_NFC_DMA_CTRL_DMA_READY BIT(0)
  33408. +
  33409. +#define AR934X_NFC_INT_DEV_RDY(_x) BIT(4 + (_x))
  33410. +#define AR934X_NFC_INT_CMD_END BIT(1)
  33411. +
  33412. +#define AR934X_NFC_ECC_CTRL_ERR_THRES_S 8
  33413. +#define AR934X_NFC_ECC_CTRL_ERR_THRES_M 0x1f
  33414. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_S 5
  33415. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_M 0x7
  33416. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_2 0
  33417. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_4 1
  33418. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_6 2
  33419. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_8 3
  33420. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_10 4
  33421. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_12 5
  33422. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_14 6
  33423. +#define AR934X_NFC_ECC_CTRL_ECC_CAP_16 7
  33424. +#define AR934X_NFC_ECC_CTRL_ERR_OVER BIT(2)
  33425. +#define AR934X_NFC_ECC_CTRL_ERR_UNCORRECT BIT(1)
  33426. +#define AR934X_NFC_ECC_CTRL_ERR_CORRECT BIT(0)
  33427. +
  33428. +#define AR934X_NFC_ECC_OFFS_OFSET_M 0xffff
  33429. +
  33430. +/* default timing values */
  33431. +#define AR934X_NFC_TIME_SEQ_DEFAULT 0x7fff
  33432. +#define AR934X_NFC_TIMINGS_ASYN_DEFAULT 0x22
  33433. +#define AR934X_NFC_TIMINGS_SYN_DEFAULT 0xf
  33434. +
  33435. +#define AR934X_NFC_ID_BUF_SIZE 8
  33436. +#define AR934X_NFC_DEV_READY_TIMEOUT 25 /* msecs */
  33437. +#define AR934X_NFC_DMA_READY_TIMEOUT 25 /* msecs */
  33438. +#define AR934X_NFC_DONE_TIMEOUT 1000
  33439. +#define AR934X_NFC_DMA_RETRIES 20
  33440. +
  33441. +#define AR934X_NFC_USE_IRQ true
  33442. +#define AR934X_NFC_IRQ_MASK AR934X_NFC_INT_DEV_RDY(0)
  33443. +
  33444. +#define AR934X_NFC_GENSEQ_SMALL_PAGE_READ 0x30043
  33445. +
  33446. +#undef AR934X_NFC_DEBUG_DATA
  33447. +#undef AR934X_NFC_DEBUG
  33448. +
  33449. +struct ar934x_nfc;
  33450. +
  33451. +static inline __attribute__ ((format (printf, 2, 3)))
  33452. +void _nfc_dbg(struct ar934x_nfc *nfc, const char *fmt, ...)
  33453. +{
  33454. +}
  33455. +
  33456. +#ifdef AR934X_NFC_DEBUG
  33457. +#define nfc_dbg(_nfc, fmt, ...) \
  33458. + dev_info((_nfc)->parent, fmt, ##__VA_ARGS__)
  33459. +#else
  33460. +#define nfc_dbg(_nfc, fmt, ...) \
  33461. + _nfc_dbg((_nfc), fmt, ##__VA_ARGS__)
  33462. +#endif /* AR934X_NFC_DEBUG */
  33463. +
  33464. +#ifdef AR934X_NFC_DEBUG_DATA
  33465. +static void
  33466. +nfc_debug_data(const char *label, void *data, int len)
  33467. +{
  33468. + print_hex_dump(KERN_WARNING, label, DUMP_PREFIX_OFFSET, 16, 1,
  33469. + data, len, 0);
  33470. +}
  33471. +#else
  33472. +static inline void
  33473. +nfc_debug_data(const char *label, void *data, int len) {}
  33474. +#endif /* AR934X_NFC_DEBUG_DATA */
  33475. +
  33476. +struct ar934x_nfc {
  33477. + struct mtd_info mtd;
  33478. + struct nand_chip nand_chip;
  33479. + struct device *parent;
  33480. + void __iomem *base;
  33481. + void (*select_chip)(int chip_no);
  33482. + bool swap_dma;
  33483. + int irq;
  33484. + wait_queue_head_t irq_waitq;
  33485. +
  33486. + bool spurious_irq_expected;
  33487. + u32 irq_status;
  33488. +
  33489. + u32 ctrl_reg;
  33490. + u32 ecc_ctrl_reg;
  33491. + u32 ecc_offset_reg;
  33492. + u32 ecc_thres;
  33493. + u32 ecc_oob_pos;
  33494. +
  33495. + bool small_page;
  33496. + unsigned int addr_count0;
  33497. + unsigned int addr_count1;
  33498. +
  33499. + u8 *buf;
  33500. + dma_addr_t buf_dma;
  33501. + unsigned int buf_size;
  33502. + int buf_index;
  33503. +
  33504. + bool read_id;
  33505. +
  33506. + int erase1_page_addr;
  33507. +
  33508. + int rndout_page_addr;
  33509. + int rndout_read_cmd;
  33510. +
  33511. + int seqin_page_addr;
  33512. + int seqin_column;
  33513. + int seqin_read_cmd;
  33514. +};
  33515. +
  33516. +static void ar934x_nfc_restart(struct ar934x_nfc *nfc);
  33517. +
  33518. +static inline bool
  33519. +is_all_ff(u8 *buf, int len)
  33520. +{
  33521. + while (len--)
  33522. + if (buf[len] != 0xff)
  33523. + return false;
  33524. +
  33525. + return true;
  33526. +}
  33527. +
  33528. +static inline void
  33529. +ar934x_nfc_wr(struct ar934x_nfc *nfc, unsigned reg, u32 val)
  33530. +{
  33531. + __raw_writel(val, nfc->base + reg);
  33532. +}
  33533. +
  33534. +static inline u32
  33535. +ar934x_nfc_rr(struct ar934x_nfc *nfc, unsigned reg)
  33536. +{
  33537. + return __raw_readl(nfc->base + reg);
  33538. +}
  33539. +
  33540. +static inline struct ar934x_nfc_platform_data *
  33541. +ar934x_nfc_get_platform_data(struct ar934x_nfc *nfc)
  33542. +{
  33543. + return nfc->parent->platform_data;
  33544. +}
  33545. +
  33546. +static inline struct
  33547. +ar934x_nfc *mtd_to_ar934x_nfc(struct mtd_info *mtd)
  33548. +{
  33549. + return container_of(mtd, struct ar934x_nfc, mtd);
  33550. +}
  33551. +
  33552. +static inline bool ar934x_nfc_use_irq(struct ar934x_nfc *nfc)
  33553. +{
  33554. + return AR934X_NFC_USE_IRQ;
  33555. +}
  33556. +
  33557. +static inline void ar934x_nfc_write_cmd_reg(struct ar934x_nfc *nfc, u32 cmd_reg)
  33558. +{
  33559. + wmb();
  33560. +
  33561. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CMD, cmd_reg);
  33562. + /* flush write */
  33563. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_CMD);
  33564. +}
  33565. +
  33566. +static bool
  33567. +__ar934x_nfc_dev_ready(struct ar934x_nfc *nfc)
  33568. +{
  33569. + u32 status;
  33570. +
  33571. + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_STATUS);
  33572. + return (status & 0xff) == 0xff;
  33573. +}
  33574. +
  33575. +static inline bool
  33576. +__ar934x_nfc_is_dma_ready(struct ar934x_nfc *nfc)
  33577. +{
  33578. + u32 status;
  33579. +
  33580. + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_DMA_CTRL);
  33581. + return (status & AR934X_NFC_DMA_CTRL_DMA_READY) != 0;
  33582. +}
  33583. +
  33584. +static int
  33585. +ar934x_nfc_wait_dev_ready(struct ar934x_nfc *nfc)
  33586. +{
  33587. + unsigned long timeout;
  33588. +
  33589. + timeout = jiffies + msecs_to_jiffies(AR934X_NFC_DEV_READY_TIMEOUT);
  33590. + do {
  33591. + if (__ar934x_nfc_dev_ready(nfc))
  33592. + return 0;
  33593. + } while time_before(jiffies, timeout);
  33594. +
  33595. + nfc_dbg(nfc, "timeout waiting for device ready, status:%08x int:%08x\n",
  33596. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_STATUS),
  33597. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS));
  33598. + return -ETIMEDOUT;
  33599. +}
  33600. +
  33601. +static int
  33602. +ar934x_nfc_wait_dma_ready(struct ar934x_nfc *nfc)
  33603. +{
  33604. + unsigned long timeout;
  33605. +
  33606. + timeout = jiffies + msecs_to_jiffies(AR934X_NFC_DMA_READY_TIMEOUT);
  33607. + do {
  33608. + if (__ar934x_nfc_is_dma_ready(nfc))
  33609. + return 0;
  33610. + } while time_before(jiffies, timeout);
  33611. +
  33612. + nfc_dbg(nfc, "timeout waiting for DMA ready, dma_ctrl:%08x\n",
  33613. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_DMA_CTRL));
  33614. + return -ETIMEDOUT;
  33615. +}
  33616. +
  33617. +static int
  33618. +ar934x_nfc_wait_irq(struct ar934x_nfc *nfc)
  33619. +{
  33620. + long timeout;
  33621. + int ret;
  33622. +
  33623. + timeout = wait_event_timeout(nfc->irq_waitq,
  33624. + (nfc->irq_status & AR934X_NFC_IRQ_MASK) != 0,
  33625. + msecs_to_jiffies(AR934X_NFC_DEV_READY_TIMEOUT));
  33626. +
  33627. + ret = 0;
  33628. + if (!timeout) {
  33629. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_MASK, 0);
  33630. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  33631. + /* flush write */
  33632. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
  33633. +
  33634. + nfc_dbg(nfc,
  33635. + "timeout waiting for interrupt, status:%08x\n",
  33636. + nfc->irq_status);
  33637. + ret = -ETIMEDOUT;
  33638. + }
  33639. +
  33640. + nfc->irq_status = 0;
  33641. + return ret;
  33642. +}
  33643. +
  33644. +static int
  33645. +ar934x_nfc_wait_done(struct ar934x_nfc *nfc)
  33646. +{
  33647. + int ret;
  33648. +
  33649. + if (ar934x_nfc_use_irq(nfc))
  33650. + ret = ar934x_nfc_wait_irq(nfc);
  33651. + else
  33652. + ret = ar934x_nfc_wait_dev_ready(nfc);
  33653. +
  33654. + if (ret)
  33655. + return ret;
  33656. +
  33657. + return ar934x_nfc_wait_dma_ready(nfc);
  33658. +}
  33659. +
  33660. +static int
  33661. +ar934x_nfc_alloc_buf(struct ar934x_nfc *nfc, unsigned size)
  33662. +{
  33663. + nfc->buf = dma_alloc_coherent(nfc->parent, size,
  33664. + &nfc->buf_dma, GFP_KERNEL);
  33665. + if (nfc->buf == NULL) {
  33666. + dev_err(nfc->parent, "no memory for DMA buffer\n");
  33667. + return -ENOMEM;
  33668. + }
  33669. +
  33670. + nfc->buf_size = size;
  33671. + nfc_dbg(nfc, "buf:%p size:%u\n", nfc->buf, nfc->buf_size);
  33672. +
  33673. + return 0;
  33674. +}
  33675. +
  33676. +static void
  33677. +ar934x_nfc_free_buf(struct ar934x_nfc *nfc)
  33678. +{
  33679. + dma_free_coherent(nfc->parent, nfc->buf_size, nfc->buf, nfc->buf_dma);
  33680. +}
  33681. +
  33682. +static void
  33683. +ar934x_nfc_get_addr(struct ar934x_nfc *nfc, int column, int page_addr,
  33684. + u32 *addr0, u32 *addr1)
  33685. +{
  33686. + u32 a0, a1;
  33687. +
  33688. + a0 = 0;
  33689. + a1 = 0;
  33690. +
  33691. + if (column == -1) {
  33692. + /* ERASE1 */
  33693. + a0 = (page_addr & 0xffff) << 16;
  33694. + a1 = (page_addr >> 16) & 0xf;
  33695. + } else if (page_addr != -1) {
  33696. + /* SEQIN, READ0, etc.. */
  33697. +
  33698. + /* TODO: handle 16bit bus width */
  33699. + if (nfc->small_page) {
  33700. + a0 = column & 0xff;
  33701. + a0 |= (page_addr & 0xff) << 8;
  33702. + a0 |= ((page_addr >> 8) & 0xff) << 16;
  33703. + a0 |= ((page_addr >> 16) & 0xff) << 24;
  33704. + } else {
  33705. + a0 = column & 0x0FFF;
  33706. + a0 |= (page_addr & 0xffff) << 16;
  33707. +
  33708. + if (nfc->addr_count0 > 4)
  33709. + a1 = (page_addr >> 16) & 0xf;
  33710. + }
  33711. + }
  33712. +
  33713. + *addr0 = a0;
  33714. + *addr1 = a1;
  33715. +}
  33716. +
  33717. +static void
  33718. +ar934x_nfc_send_cmd(struct ar934x_nfc *nfc, unsigned command)
  33719. +{
  33720. + u32 cmd_reg;
  33721. +
  33722. + cmd_reg = AR934X_NFC_CMD_INPUT_SEL_SIU | AR934X_NFC_CMD_ADDR_SEL_0 |
  33723. + AR934X_NFC_CMD_SEQ_1C;
  33724. + cmd_reg |= (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
  33725. +
  33726. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  33727. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
  33728. +
  33729. + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
  33730. + ar934x_nfc_wait_dev_ready(nfc);
  33731. +}
  33732. +
  33733. +static int
  33734. +ar934x_nfc_do_rw_command(struct ar934x_nfc *nfc, int column, int page_addr,
  33735. + int len, u32 cmd_reg, u32 ctrl_reg, bool write)
  33736. +{
  33737. + u32 addr0, addr1;
  33738. + u32 dma_ctrl;
  33739. + int dir;
  33740. + int err;
  33741. + int retries = 0;
  33742. +
  33743. + WARN_ON(len & 3);
  33744. +
  33745. + if (WARN_ON(len > nfc->buf_size))
  33746. + dev_err(nfc->parent, "len=%d > buf_size=%d", len, nfc->buf_size);
  33747. +
  33748. + if (write) {
  33749. + dma_ctrl = AR934X_NFC_DMA_CTRL_DMA_DIR_WRITE;
  33750. + dir = DMA_TO_DEVICE;
  33751. + } else {
  33752. + dma_ctrl = AR934X_NFC_DMA_CTRL_DMA_DIR_READ;
  33753. + dir = DMA_FROM_DEVICE;
  33754. + }
  33755. +
  33756. + ar934x_nfc_get_addr(nfc, column, page_addr, &addr0, &addr1);
  33757. +
  33758. + dma_ctrl |= AR934X_NFC_DMA_CTRL_DMA_START |
  33759. + (AR934X_NFC_DMA_CTRL_DMA_BURST_3 <<
  33760. + AR934X_NFC_DMA_CTRL_DMA_BURST_S);
  33761. +
  33762. + cmd_reg |= AR934X_NFC_CMD_INPUT_SEL_DMA | AR934X_NFC_CMD_ADDR_SEL_0;
  33763. + ctrl_reg |= AR934X_NFC_CTRL_INT_EN;
  33764. +
  33765. + nfc_dbg(nfc, "%s a0:%08x a1:%08x len:%x cmd:%08x dma:%08x ctrl:%08x\n",
  33766. + (write) ? "write" : "read",
  33767. + addr0, addr1, len, cmd_reg, dma_ctrl, ctrl_reg);
  33768. +
  33769. +retry:
  33770. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  33771. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_0, addr0);
  33772. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_1, addr1);
  33773. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_ADDR, nfc->buf_dma);
  33774. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_COUNT, len);
  33775. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DATA_SIZE, len);
  33776. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, ctrl_reg);
  33777. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_CTRL, dma_ctrl);
  33778. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ECC_CTRL, nfc->ecc_ctrl_reg);
  33779. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ECC_OFFSET, nfc->ecc_offset_reg);
  33780. +
  33781. + if (ar934x_nfc_use_irq(nfc)) {
  33782. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_MASK, AR934X_NFC_IRQ_MASK);
  33783. + /* flush write */
  33784. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_MASK);
  33785. + }
  33786. +
  33787. + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
  33788. + err = ar934x_nfc_wait_done(nfc);
  33789. + if (err) {
  33790. + dev_dbg(nfc->parent, "%s operation stuck at page %d\n",
  33791. + (write) ? "write" : "read", page_addr);
  33792. +
  33793. + ar934x_nfc_restart(nfc);
  33794. + if (retries++ < AR934X_NFC_DMA_RETRIES)
  33795. + goto retry;
  33796. +
  33797. + dev_err(nfc->parent, "%s operation failed on page %d\n",
  33798. + (write) ? "write" : "read", page_addr);
  33799. + }
  33800. +
  33801. + return err;
  33802. +}
  33803. +
  33804. +static int
  33805. +ar934x_nfc_send_readid(struct ar934x_nfc *nfc, unsigned command)
  33806. +{
  33807. + u32 cmd_reg;
  33808. + int err;
  33809. +
  33810. + nfc_dbg(nfc, "readid, cmd:%02x\n", command);
  33811. +
  33812. + cmd_reg = AR934X_NFC_CMD_SEQ_1C1AXR;
  33813. + cmd_reg |= (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
  33814. +
  33815. + err = ar934x_nfc_do_rw_command(nfc, -1, -1, AR934X_NFC_ID_BUF_SIZE,
  33816. + cmd_reg, nfc->ctrl_reg, false);
  33817. +
  33818. + nfc_debug_data("[id] ", nfc->buf, AR934X_NFC_ID_BUF_SIZE);
  33819. +
  33820. + return err;
  33821. +}
  33822. +
  33823. +static int
  33824. +ar934x_nfc_send_read(struct ar934x_nfc *nfc, unsigned command, int column,
  33825. + int page_addr, int len)
  33826. +{
  33827. + u32 cmd_reg;
  33828. + int err;
  33829. +
  33830. + nfc_dbg(nfc, "read, column=%d page=%d len=%d\n",
  33831. + column, page_addr, len);
  33832. +
  33833. + cmd_reg = (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
  33834. +
  33835. + if (nfc->small_page) {
  33836. + cmd_reg |= AR934X_NFC_CMD_SEQ_18;
  33837. + } else {
  33838. + cmd_reg |= NAND_CMD_READSTART << AR934X_NFC_CMD_CMD1_S;
  33839. + cmd_reg |= AR934X_NFC_CMD_SEQ_1C5A1CXR;
  33840. + }
  33841. +
  33842. + err = ar934x_nfc_do_rw_command(nfc, column, page_addr, len,
  33843. + cmd_reg, nfc->ctrl_reg, false);
  33844. +
  33845. + nfc_debug_data("[data] ", nfc->buf, len);
  33846. +
  33847. + return err;
  33848. +}
  33849. +
  33850. +static void
  33851. +ar934x_nfc_send_erase(struct ar934x_nfc *nfc, unsigned command, int column,
  33852. + int page_addr)
  33853. +{
  33854. + u32 addr0, addr1;
  33855. + u32 ctrl_reg;
  33856. + u32 cmd_reg;
  33857. +
  33858. + ar934x_nfc_get_addr(nfc, column, page_addr, &addr0, &addr1);
  33859. +
  33860. + ctrl_reg = nfc->ctrl_reg;
  33861. + if (nfc->small_page) {
  33862. + /* override number of address cycles for the erase command */
  33863. + ctrl_reg &= ~(AR934X_NFC_CTRL_ADDR_CYCLE0_M <<
  33864. + AR934X_NFC_CTRL_ADDR_CYCLE0_S);
  33865. + ctrl_reg &= ~(AR934X_NFC_CTRL_ADDR_CYCLE1_M <<
  33866. + AR934X_NFC_CTRL_ADDR_CYCLE1_S);
  33867. + ctrl_reg &= ~(AR934X_NFC_CTRL_SMALL_PAGE);
  33868. + ctrl_reg |= (nfc->addr_count0 + 1) <<
  33869. + AR934X_NFC_CTRL_ADDR_CYCLE0_S;
  33870. + }
  33871. +
  33872. + cmd_reg = NAND_CMD_ERASE1 << AR934X_NFC_CMD_CMD0_S;
  33873. + cmd_reg |= command << AR934X_NFC_CMD_CMD1_S;
  33874. + cmd_reg |= AR934X_NFC_CMD_SEQ_ERASE;
  33875. +
  33876. + nfc_dbg(nfc, "erase page %d, a0:%08x a1:%08x cmd:%08x ctrl:%08x\n",
  33877. + page_addr, addr0, addr1, cmd_reg, ctrl_reg);
  33878. +
  33879. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  33880. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, ctrl_reg);
  33881. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_0, addr0);
  33882. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_1, addr1);
  33883. +
  33884. + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
  33885. + ar934x_nfc_wait_dev_ready(nfc);
  33886. +}
  33887. +
  33888. +static int
  33889. +ar934x_nfc_send_write(struct ar934x_nfc *nfc, unsigned command, int column,
  33890. + int page_addr, int len)
  33891. +{
  33892. + u32 cmd_reg;
  33893. +
  33894. + nfc_dbg(nfc, "write, column=%d page=%d len=%d\n",
  33895. + column, page_addr, len);
  33896. +
  33897. + nfc_debug_data("[data] ", nfc->buf, len);
  33898. +
  33899. + cmd_reg = NAND_CMD_SEQIN << AR934X_NFC_CMD_CMD0_S;
  33900. + cmd_reg |= command << AR934X_NFC_CMD_CMD1_S;
  33901. + cmd_reg |= AR934X_NFC_CMD_SEQ_12;
  33902. +
  33903. + return ar934x_nfc_do_rw_command(nfc, column, page_addr, len,
  33904. + cmd_reg, nfc->ctrl_reg, true);
  33905. +}
  33906. +
  33907. +static void
  33908. +ar934x_nfc_read_status(struct ar934x_nfc *nfc)
  33909. +{
  33910. + u32 cmd_reg;
  33911. + u32 status;
  33912. +
  33913. + cmd_reg = NAND_CMD_STATUS << AR934X_NFC_CMD_CMD0_S;
  33914. + cmd_reg |= AR934X_NFC_CMD_SEQ_S;
  33915. +
  33916. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  33917. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
  33918. +
  33919. + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
  33920. + ar934x_nfc_wait_dev_ready(nfc);
  33921. +
  33922. + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_READ_STATUS);
  33923. +
  33924. + nfc_dbg(nfc, "read status, cmd:%08x status:%02x\n",
  33925. + cmd_reg, (status & 0xff));
  33926. +
  33927. + if (nfc->swap_dma)
  33928. + nfc->buf[0 ^ 3] = status;
  33929. + else
  33930. + nfc->buf[0] = status;
  33931. +}
  33932. +
  33933. +static void
  33934. +ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command, int column,
  33935. + int page_addr)
  33936. +{
  33937. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  33938. + struct nand_chip *nand = mtd->priv;
  33939. +
  33940. + nfc->read_id = false;
  33941. + if (command != NAND_CMD_PAGEPROG)
  33942. + nfc->buf_index = 0;
  33943. +
  33944. + switch (command) {
  33945. + case NAND_CMD_RESET:
  33946. + ar934x_nfc_send_cmd(nfc, command);
  33947. + break;
  33948. +
  33949. + case NAND_CMD_READID:
  33950. + nfc->read_id = true;
  33951. + ar934x_nfc_send_readid(nfc, command);
  33952. + break;
  33953. +
  33954. + case NAND_CMD_READ0:
  33955. + case NAND_CMD_READ1:
  33956. + if (nfc->small_page) {
  33957. + ar934x_nfc_send_read(nfc, command, column, page_addr,
  33958. + mtd->writesize + mtd->oobsize);
  33959. + } else {
  33960. + ar934x_nfc_send_read(nfc, command, 0, page_addr,
  33961. + mtd->writesize + mtd->oobsize);
  33962. + nfc->buf_index = column;
  33963. + nfc->rndout_page_addr = page_addr;
  33964. + nfc->rndout_read_cmd = command;
  33965. + }
  33966. + break;
  33967. +
  33968. + case NAND_CMD_READOOB:
  33969. + if (nfc->small_page)
  33970. + ar934x_nfc_send_read(nfc, NAND_CMD_READOOB,
  33971. + column, page_addr,
  33972. + mtd->oobsize);
  33973. + else
  33974. + ar934x_nfc_send_read(nfc, NAND_CMD_READ0,
  33975. + mtd->writesize, page_addr,
  33976. + mtd->oobsize);
  33977. + break;
  33978. +
  33979. + case NAND_CMD_RNDOUT:
  33980. + if (WARN_ON(nfc->small_page))
  33981. + break;
  33982. +
  33983. + /* emulate subpage read */
  33984. + ar934x_nfc_send_read(nfc, nfc->rndout_read_cmd, 0,
  33985. + nfc->rndout_page_addr,
  33986. + mtd->writesize + mtd->oobsize);
  33987. + nfc->buf_index = column;
  33988. + break;
  33989. +
  33990. + case NAND_CMD_ERASE1:
  33991. + nfc->erase1_page_addr = page_addr;
  33992. + break;
  33993. +
  33994. + case NAND_CMD_ERASE2:
  33995. + ar934x_nfc_send_erase(nfc, command, -1, nfc->erase1_page_addr);
  33996. + break;
  33997. +
  33998. + case NAND_CMD_STATUS:
  33999. + ar934x_nfc_read_status(nfc);
  34000. + break;
  34001. +
  34002. + case NAND_CMD_SEQIN:
  34003. + if (nfc->small_page) {
  34004. + /* output read command */
  34005. + if (column >= mtd->writesize) {
  34006. + column -= mtd->writesize;
  34007. + nfc->seqin_read_cmd = NAND_CMD_READOOB;
  34008. + } else if (column < 256) {
  34009. + nfc->seqin_read_cmd = NAND_CMD_READ0;
  34010. + } else {
  34011. + column -= 256;
  34012. + nfc->seqin_read_cmd = NAND_CMD_READ1;
  34013. + }
  34014. + } else {
  34015. + nfc->seqin_read_cmd = NAND_CMD_READ0;
  34016. + }
  34017. + nfc->seqin_column = column;
  34018. + nfc->seqin_page_addr = page_addr;
  34019. + break;
  34020. +
  34021. + case NAND_CMD_PAGEPROG:
  34022. + if (nand->ecc.mode == NAND_ECC_HW) {
  34023. + /* the data is already written */
  34024. + break;
  34025. + }
  34026. +
  34027. + if (nfc->small_page)
  34028. + ar934x_nfc_send_cmd(nfc, nfc->seqin_read_cmd);
  34029. +
  34030. + ar934x_nfc_send_write(nfc, command, nfc->seqin_column,
  34031. + nfc->seqin_page_addr,
  34032. + nfc->buf_index);
  34033. + break;
  34034. +
  34035. + default:
  34036. + dev_err(nfc->parent,
  34037. + "unsupported command: %x, column:%d page_addr=%d\n",
  34038. + command, column, page_addr);
  34039. + break;
  34040. + }
  34041. +}
  34042. +
  34043. +static int
  34044. +ar934x_nfc_dev_ready(struct mtd_info *mtd)
  34045. +{
  34046. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34047. +
  34048. + return __ar934x_nfc_dev_ready(nfc);
  34049. +}
  34050. +
  34051. +static void
  34052. +ar934x_nfc_select_chip(struct mtd_info *mtd, int chip_no)
  34053. +{
  34054. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34055. +
  34056. + if (nfc->select_chip)
  34057. + nfc->select_chip(chip_no);
  34058. +}
  34059. +
  34060. +static u8
  34061. +ar934x_nfc_read_byte(struct mtd_info *mtd)
  34062. +{
  34063. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34064. + u8 data;
  34065. +
  34066. + WARN_ON(nfc->buf_index >= nfc->buf_size);
  34067. +
  34068. + if (nfc->swap_dma || nfc->read_id)
  34069. + data = nfc->buf[nfc->buf_index ^ 3];
  34070. + else
  34071. + data = nfc->buf[nfc->buf_index];
  34072. +
  34073. + nfc->buf_index++;
  34074. +
  34075. + return data;
  34076. +}
  34077. +
  34078. +static void
  34079. +ar934x_nfc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  34080. +{
  34081. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34082. + int i;
  34083. +
  34084. + WARN_ON(nfc->buf_index + len > nfc->buf_size);
  34085. +
  34086. + if (nfc->swap_dma) {
  34087. + for (i = 0; i < len; i++) {
  34088. + nfc->buf[nfc->buf_index ^ 3] = buf[i];
  34089. + nfc->buf_index++;
  34090. + }
  34091. + } else {
  34092. + for (i = 0; i < len; i++) {
  34093. + nfc->buf[nfc->buf_index] = buf[i];
  34094. + nfc->buf_index++;
  34095. + }
  34096. + }
  34097. +}
  34098. +
  34099. +static void
  34100. +ar934x_nfc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  34101. +{
  34102. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34103. + int buf_index;
  34104. + int i;
  34105. +
  34106. + WARN_ON(nfc->buf_index + len > nfc->buf_size);
  34107. +
  34108. + buf_index = nfc->buf_index;
  34109. +
  34110. + if (nfc->swap_dma || nfc->read_id) {
  34111. + for (i = 0; i < len; i++) {
  34112. + buf[i] = nfc->buf[buf_index ^ 3];
  34113. + buf_index++;
  34114. + }
  34115. + } else {
  34116. + for (i = 0; i < len; i++) {
  34117. + buf[i] = nfc->buf[buf_index];
  34118. + buf_index++;
  34119. + }
  34120. + }
  34121. +
  34122. + nfc->buf_index = buf_index;
  34123. +}
  34124. +
  34125. +static inline void
  34126. +ar934x_nfc_enable_hwecc(struct ar934x_nfc *nfc)
  34127. +{
  34128. + nfc->ctrl_reg |= AR934X_NFC_CTRL_ECC_EN;
  34129. + nfc->ctrl_reg &= ~AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
  34130. +}
  34131. +
  34132. +static inline void
  34133. +ar934x_nfc_disable_hwecc(struct ar934x_nfc *nfc)
  34134. +{
  34135. + nfc->ctrl_reg &= ~AR934X_NFC_CTRL_ECC_EN;
  34136. + nfc->ctrl_reg |= AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
  34137. +}
  34138. +
  34139. +static int
  34140. +ar934x_nfc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
  34141. + int page)
  34142. +{
  34143. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34144. + int err;
  34145. +
  34146. + nfc_dbg(nfc, "read_oob: page:%d\n", page);
  34147. +
  34148. + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, mtd->writesize, page,
  34149. + mtd->oobsize);
  34150. + if (err)
  34151. + return err;
  34152. +
  34153. + memcpy(chip->oob_poi, nfc->buf, mtd->oobsize);
  34154. +
  34155. + return 0;
  34156. +}
  34157. +
  34158. +static int
  34159. +ar934x_nfc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
  34160. + int page)
  34161. +{
  34162. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34163. +
  34164. + nfc_dbg(nfc, "write_oob: page:%d\n", page);
  34165. +
  34166. + memcpy(nfc->buf, chip->oob_poi, mtd->oobsize);
  34167. +
  34168. + return ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, mtd->writesize,
  34169. + page, mtd->oobsize);
  34170. +}
  34171. +
  34172. +static int
  34173. +ar934x_nfc_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  34174. + u8 *buf, int oob_required, int page)
  34175. +{
  34176. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34177. + int len;
  34178. + int err;
  34179. +
  34180. + nfc_dbg(nfc, "read_page_raw: page:%d oob:%d\n", page, oob_required);
  34181. +
  34182. + len = mtd->writesize;
  34183. + if (oob_required)
  34184. + len += mtd->oobsize;
  34185. +
  34186. + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, 0, page, len);
  34187. + if (err)
  34188. + return err;
  34189. +
  34190. + memcpy(buf, nfc->buf, mtd->writesize);
  34191. +
  34192. + if (oob_required)
  34193. + memcpy(chip->oob_poi, &nfc->buf[mtd->writesize], mtd->oobsize);
  34194. +
  34195. + return 0;
  34196. +}
  34197. +
  34198. +static int
  34199. +ar934x_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  34200. + u8 *buf, int oob_required, int page)
  34201. +{
  34202. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34203. + u32 ecc_ctrl;
  34204. + int max_bitflips = 0;
  34205. + bool ecc_failed;
  34206. + bool ecc_corrected;
  34207. + int err;
  34208. +
  34209. + nfc_dbg(nfc, "read_page: page:%d oob:%d\n", page, oob_required);
  34210. +
  34211. + ar934x_nfc_enable_hwecc(nfc);
  34212. + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, 0, page,
  34213. + mtd->writesize);
  34214. + ar934x_nfc_disable_hwecc(nfc);
  34215. +
  34216. + if (err)
  34217. + return err;
  34218. +
  34219. + /* TODO: optimize to avoid memcpy */
  34220. + memcpy(buf, nfc->buf, mtd->writesize);
  34221. +
  34222. + /* read the ECC status */
  34223. + ecc_ctrl = ar934x_nfc_rr(nfc, AR934X_NFC_REG_ECC_CTRL);
  34224. + ecc_failed = ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_UNCORRECT;
  34225. + ecc_corrected = ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_CORRECT;
  34226. +
  34227. + if (oob_required || ecc_failed) {
  34228. + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, mtd->writesize,
  34229. + page, mtd->oobsize);
  34230. + if (err)
  34231. + return err;
  34232. +
  34233. + if (oob_required)
  34234. + memcpy(chip->oob_poi, nfc->buf, mtd->oobsize);
  34235. + }
  34236. +
  34237. + if (ecc_failed) {
  34238. + /*
  34239. + * The hardware ECC engine reports uncorrectable errors
  34240. + * on empty pages. Check the ECC bytes and the data. If
  34241. + * both contains 0xff bytes only, dont report a failure.
  34242. + *
  34243. + * TODO: prebuild a buffer with 0xff bytes and use memcmp
  34244. + * for better performance?
  34245. + */
  34246. + if (!is_all_ff(&nfc->buf[nfc->ecc_oob_pos], chip->ecc.total) ||
  34247. + !is_all_ff(buf, mtd->writesize))
  34248. + mtd->ecc_stats.failed++;
  34249. + } else if (ecc_corrected) {
  34250. + /*
  34251. + * The hardware does not report the exact count of the
  34252. + * corrected bitflips, use assumptions based on the
  34253. + * threshold.
  34254. + */
  34255. + if (ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_OVER) {
  34256. + /*
  34257. + * The number of corrected bitflips exceeds the
  34258. + * threshold. Assume the maximum.
  34259. + */
  34260. + max_bitflips = chip->ecc.strength * chip->ecc.steps;
  34261. + } else {
  34262. + max_bitflips = nfc->ecc_thres * chip->ecc.steps;
  34263. + }
  34264. +
  34265. + mtd->ecc_stats.corrected += max_bitflips;
  34266. + }
  34267. +
  34268. + return max_bitflips;
  34269. +}
  34270. +
  34271. +static int
  34272. +ar934x_nfc_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  34273. + const u8 *buf, int oob_required)
  34274. +{
  34275. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34276. + int page;
  34277. + int len;
  34278. +
  34279. + page = nfc->seqin_page_addr;
  34280. +
  34281. + nfc_dbg(nfc, "write_page_raw: page:%d oob:%d\n", page, oob_required);
  34282. +
  34283. + memcpy(nfc->buf, buf, mtd->writesize);
  34284. + len = mtd->writesize;
  34285. +
  34286. + if (oob_required) {
  34287. + memcpy(&nfc->buf[mtd->writesize], chip->oob_poi, mtd->oobsize);
  34288. + len += mtd->oobsize;
  34289. + }
  34290. +
  34291. + return ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, 0, page, len);
  34292. +}
  34293. +
  34294. +static int
  34295. +ar934x_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  34296. + const u8 *buf, int oob_required)
  34297. +{
  34298. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34299. + int page;
  34300. + int err;
  34301. +
  34302. + page = nfc->seqin_page_addr;
  34303. +
  34304. + nfc_dbg(nfc, "write_page: page:%d oob:%d\n", page, oob_required);
  34305. +
  34306. + /* write OOB first */
  34307. + if (oob_required &&
  34308. + !is_all_ff(chip->oob_poi, mtd->oobsize)) {
  34309. + err = ar934x_nfc_write_oob(mtd, chip, page);
  34310. + if (err)
  34311. + return err;
  34312. + }
  34313. +
  34314. + /* TODO: optimize to avoid memcopy */
  34315. + memcpy(nfc->buf, buf, mtd->writesize);
  34316. +
  34317. + ar934x_nfc_enable_hwecc(nfc);
  34318. + err = ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, 0, page,
  34319. + mtd->writesize);
  34320. + ar934x_nfc_disable_hwecc(nfc);
  34321. +
  34322. + return err;
  34323. +}
  34324. +
  34325. +static void
  34326. +ar934x_nfc_hw_init(struct ar934x_nfc *nfc)
  34327. +{
  34328. + struct ar934x_nfc_platform_data *pdata;
  34329. +
  34330. + pdata = ar934x_nfc_get_platform_data(nfc);
  34331. + if (pdata->hw_reset) {
  34332. + pdata->hw_reset(true);
  34333. + pdata->hw_reset(false);
  34334. + }
  34335. +
  34336. + /*
  34337. + * setup timings
  34338. + * TODO: make it configurable via platform data
  34339. + */
  34340. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIME_SEQ,
  34341. + AR934X_NFC_TIME_SEQ_DEFAULT);
  34342. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIMINGS_ASYN,
  34343. + AR934X_NFC_TIMINGS_ASYN_DEFAULT);
  34344. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIMINGS_SYN,
  34345. + AR934X_NFC_TIMINGS_SYN_DEFAULT);
  34346. +
  34347. + /* disable WP on all chips, and select chip 0 */
  34348. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_MEM_CTRL, 0xff00);
  34349. +
  34350. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_ADDR_OFFS, 0);
  34351. +
  34352. + /* initialize Control register */
  34353. + nfc->ctrl_reg = AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
  34354. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
  34355. +
  34356. + if (nfc->small_page) {
  34357. + /* Setup generic sequence register for small page reads. */
  34358. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_GEN_SEQ_CTRL,
  34359. + AR934X_NFC_GENSEQ_SMALL_PAGE_READ);
  34360. + }
  34361. +}
  34362. +
  34363. +static void
  34364. +ar934x_nfc_restart(struct ar934x_nfc *nfc)
  34365. +{
  34366. + u32 ctrl_reg;
  34367. +
  34368. + if (nfc->select_chip)
  34369. + nfc->select_chip(-1);
  34370. +
  34371. + ctrl_reg = nfc->ctrl_reg;
  34372. + ar934x_nfc_hw_init(nfc);
  34373. + nfc->ctrl_reg = ctrl_reg;
  34374. +
  34375. + if (nfc->select_chip)
  34376. + nfc->select_chip(0);
  34377. +
  34378. + ar934x_nfc_send_cmd(nfc, NAND_CMD_RESET);
  34379. +}
  34380. +
  34381. +static irqreturn_t
  34382. +ar934x_nfc_irq_handler(int irq, void *data)
  34383. +{
  34384. + struct ar934x_nfc *nfc = data;
  34385. + u32 status;
  34386. +
  34387. + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
  34388. +
  34389. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
  34390. + /* flush write */
  34391. + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
  34392. +
  34393. + status &= ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_MASK);
  34394. + if (status) {
  34395. + nfc_dbg(nfc, "got IRQ, status:%08x\n", status);
  34396. +
  34397. + nfc->irq_status = status;
  34398. + nfc->spurious_irq_expected = true;
  34399. + wake_up(&nfc->irq_waitq);
  34400. + } else {
  34401. + if (nfc->spurious_irq_expected) {
  34402. + nfc->spurious_irq_expected = false;
  34403. + } else {
  34404. + dev_warn(nfc->parent, "spurious interrupt\n");
  34405. + }
  34406. + }
  34407. +
  34408. + return IRQ_HANDLED;
  34409. +}
  34410. +
  34411. +static int
  34412. +ar934x_nfc_init_tail(struct mtd_info *mtd)
  34413. +{
  34414. + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
  34415. + struct nand_chip *chip = &nfc->nand_chip;
  34416. + u32 ctrl;
  34417. + u32 t;
  34418. + int err;
  34419. +
  34420. + switch (mtd->oobsize) {
  34421. + case 16:
  34422. + case 64:
  34423. + case 128:
  34424. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_SPARE_SIZE, mtd->oobsize);
  34425. + break;
  34426. +
  34427. + default:
  34428. + dev_err(nfc->parent, "unsupported OOB size: %d bytes\n",
  34429. + mtd->oobsize);
  34430. + return -ENXIO;
  34431. + }
  34432. +
  34433. + ctrl = AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
  34434. +
  34435. + switch (mtd->erasesize / mtd->writesize) {
  34436. + case 32:
  34437. + t = AR934X_NFC_CTRL_BLOCK_SIZE_32;
  34438. + break;
  34439. +
  34440. + case 64:
  34441. + t = AR934X_NFC_CTRL_BLOCK_SIZE_64;
  34442. + break;
  34443. +
  34444. + case 128:
  34445. + t = AR934X_NFC_CTRL_BLOCK_SIZE_128;
  34446. + break;
  34447. +
  34448. + case 256:
  34449. + t = AR934X_NFC_CTRL_BLOCK_SIZE_256;
  34450. + break;
  34451. +
  34452. + default:
  34453. + dev_err(nfc->parent, "unsupported block size: %u\n",
  34454. + mtd->erasesize / mtd->writesize);
  34455. + return -ENXIO;
  34456. + }
  34457. +
  34458. + ctrl |= t << AR934X_NFC_CTRL_BLOCK_SIZE_S;
  34459. +
  34460. + switch (mtd->writesize) {
  34461. + case 256:
  34462. + nfc->small_page = 1;
  34463. + t = AR934X_NFC_CTRL_PAGE_SIZE_256;
  34464. + break;
  34465. +
  34466. + case 512:
  34467. + nfc->small_page = 1;
  34468. + t = AR934X_NFC_CTRL_PAGE_SIZE_512;
  34469. + break;
  34470. +
  34471. + case 1024:
  34472. + t = AR934X_NFC_CTRL_PAGE_SIZE_1024;
  34473. + break;
  34474. +
  34475. + case 2048:
  34476. + t = AR934X_NFC_CTRL_PAGE_SIZE_2048;
  34477. + break;
  34478. +
  34479. + case 4096:
  34480. + t = AR934X_NFC_CTRL_PAGE_SIZE_4096;
  34481. + break;
  34482. +
  34483. + case 8192:
  34484. + t = AR934X_NFC_CTRL_PAGE_SIZE_8192;
  34485. + break;
  34486. +
  34487. + case 16384:
  34488. + t = AR934X_NFC_CTRL_PAGE_SIZE_16384;
  34489. + break;
  34490. +
  34491. + default:
  34492. + dev_err(nfc->parent, "unsupported write size: %d bytes\n",
  34493. + mtd->writesize);
  34494. + return -ENXIO;
  34495. + }
  34496. +
  34497. + ctrl |= t << AR934X_NFC_CTRL_PAGE_SIZE_S;
  34498. +
  34499. + if (nfc->small_page) {
  34500. + ctrl |= AR934X_NFC_CTRL_SMALL_PAGE;
  34501. +
  34502. + if (chip->chipsize > (32 << 20)) {
  34503. + nfc->addr_count0 = 4;
  34504. + nfc->addr_count1 = 3;
  34505. + } else if (chip->chipsize > (2 << 16)) {
  34506. + nfc->addr_count0 = 3;
  34507. + nfc->addr_count1 = 2;
  34508. + } else {
  34509. + nfc->addr_count0 = 2;
  34510. + nfc->addr_count1 = 1;
  34511. + }
  34512. + } else {
  34513. + if (chip->chipsize > (128 << 20)) {
  34514. + nfc->addr_count0 = 5;
  34515. + nfc->addr_count1 = 3;
  34516. + } else if (chip->chipsize > (8 << 16)) {
  34517. + nfc->addr_count0 = 4;
  34518. + nfc->addr_count1 = 2;
  34519. + } else {
  34520. + nfc->addr_count0 = 3;
  34521. + nfc->addr_count1 = 1;
  34522. + }
  34523. + }
  34524. +
  34525. + ctrl |= nfc->addr_count0 << AR934X_NFC_CTRL_ADDR_CYCLE0_S;
  34526. + ctrl |= nfc->addr_count1 << AR934X_NFC_CTRL_ADDR_CYCLE1_S;
  34527. +
  34528. + nfc->ctrl_reg = ctrl;
  34529. + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
  34530. +
  34531. + ar934x_nfc_free_buf(nfc);
  34532. + err = ar934x_nfc_alloc_buf(nfc, mtd->writesize + mtd->oobsize);
  34533. +
  34534. + return err;
  34535. +}
  34536. +
  34537. +static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = {
  34538. + .eccbytes = 28,
  34539. + .eccpos = {
  34540. + 20, 21, 22, 23, 24, 25, 26,
  34541. + 27, 28, 29, 30, 31, 32, 33,
  34542. + 34, 35, 36, 37, 38, 39, 40,
  34543. + 41, 42, 43, 44, 45, 46, 47,
  34544. + },
  34545. + .oobfree = {
  34546. + {
  34547. + .offset = 4,
  34548. + .length = 16,
  34549. + },
  34550. + {
  34551. + .offset = 48,
  34552. + .length = 16,
  34553. + },
  34554. + },
  34555. +};
  34556. +
  34557. +static int
  34558. +ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
  34559. +{
  34560. + struct nand_chip *nand = &nfc->nand_chip;
  34561. + u32 ecc_cap;
  34562. + u32 ecc_thres;
  34563. +
  34564. + if (!config_enabled(CONFIG_MTD_NAND_AR934X_HW_ECC)) {
  34565. + dev_err(nfc->parent, "hardware ECC support is disabled\n");
  34566. + return -EINVAL;
  34567. + }
  34568. +
  34569. + switch (nfc->mtd.writesize) {
  34570. + case 2048:
  34571. + /*
  34572. + * Writing a subpage separately is not supported, because
  34573. + * the controller only does ECC on full-page accesses.
  34574. + */
  34575. + nand->options = NAND_NO_SUBPAGE_WRITE;
  34576. +
  34577. + nand->ecc.size = 512;
  34578. + nand->ecc.bytes = 7;
  34579. + nand->ecc.strength = 4;
  34580. + nand->ecc.layout = &ar934x_nfc_oob_64_hwecc;
  34581. + break;
  34582. +
  34583. + default:
  34584. + dev_err(nfc->parent,
  34585. + "hardware ECC is not available for %d byte pages\n",
  34586. + nfc->mtd.writesize);
  34587. + return -EINVAL;
  34588. + }
  34589. +
  34590. + BUG_ON(!nand->ecc.layout);
  34591. +
  34592. + switch (nand->ecc.strength) {
  34593. + case 4:
  34594. + ecc_cap = AR934X_NFC_ECC_CTRL_ECC_CAP_4;
  34595. + ecc_thres = 4;
  34596. + break;
  34597. +
  34598. + default:
  34599. + dev_err(nfc->parent, "unsupported ECC strength %u\n",
  34600. + nand->ecc.strength);
  34601. + return -EINVAL;
  34602. + }
  34603. +
  34604. + nfc->ecc_thres = ecc_thres;
  34605. + nfc->ecc_oob_pos = nand->ecc.layout->eccpos[0];
  34606. +
  34607. + nfc->ecc_ctrl_reg = ecc_cap << AR934X_NFC_ECC_CTRL_ECC_CAP_S;
  34608. + nfc->ecc_ctrl_reg |= ecc_thres << AR934X_NFC_ECC_CTRL_ERR_THRES_S;
  34609. +
  34610. + nfc->ecc_offset_reg = nfc->mtd.writesize + nfc->ecc_oob_pos;
  34611. +
  34612. + nand->ecc.mode = NAND_ECC_HW;
  34613. + nand->ecc.read_page = ar934x_nfc_read_page;
  34614. + nand->ecc.read_page_raw = ar934x_nfc_read_page_raw;
  34615. + nand->ecc.write_page = ar934x_nfc_write_page;
  34616. + nand->ecc.write_page_raw = ar934x_nfc_write_page_raw;
  34617. + nand->ecc.read_oob = ar934x_nfc_read_oob;
  34618. + nand->ecc.write_oob = ar934x_nfc_write_oob;
  34619. +
  34620. + return 0;
  34621. +}
  34622. +
  34623. +static int
  34624. +ar934x_nfc_probe(struct platform_device *pdev)
  34625. +{
  34626. + static const char *part_probes[] = { "cmdlinepart", NULL, };
  34627. + struct ar934x_nfc_platform_data *pdata;
  34628. + struct ar934x_nfc *nfc;
  34629. + struct resource *res;
  34630. + struct mtd_info *mtd;
  34631. + struct nand_chip *nand;
  34632. + struct mtd_part_parser_data ppdata;
  34633. + int ret;
  34634. +
  34635. + pdata = pdev->dev.platform_data;
  34636. + if (pdata == NULL) {
  34637. + dev_err(&pdev->dev, "no platform data defined\n");
  34638. + return -EINVAL;
  34639. + }
  34640. +
  34641. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  34642. + if (!res) {
  34643. + dev_err(&pdev->dev, "failed to get I/O memory\n");
  34644. + return -EINVAL;
  34645. + }
  34646. +
  34647. + nfc = devm_kzalloc(&pdev->dev, sizeof(struct ar934x_nfc), GFP_KERNEL);
  34648. + if (!nfc) {
  34649. + dev_err(&pdev->dev, "failed to allocate driver data\n");
  34650. + return -ENOMEM;
  34651. + }
  34652. +
  34653. + nfc->base = devm_ioremap_resource(&pdev->dev, res);
  34654. + if (IS_ERR(nfc->base)) {
  34655. + dev_err(&pdev->dev, "failed to remap I/O memory\n");
  34656. + return PTR_ERR(nfc->base);
  34657. + }
  34658. +
  34659. + nfc->irq = platform_get_irq(pdev, 0);
  34660. + if (nfc->irq < 0) {
  34661. + dev_err(&pdev->dev, "no IRQ resource specified\n");
  34662. + return -EINVAL;
  34663. + }
  34664. +
  34665. + init_waitqueue_head(&nfc->irq_waitq);
  34666. + ret = request_irq(nfc->irq, ar934x_nfc_irq_handler, 0,
  34667. + dev_name(&pdev->dev), nfc);
  34668. + if (ret) {
  34669. + dev_err(&pdev->dev, "requast_irq failed, err:%d\n", ret);
  34670. + return ret;
  34671. + }
  34672. +
  34673. + nfc->parent = &pdev->dev;
  34674. + nfc->select_chip = pdata->select_chip;
  34675. + nfc->swap_dma = pdata->swap_dma;
  34676. +
  34677. + nand = &nfc->nand_chip;
  34678. + mtd = &nfc->mtd;
  34679. +
  34680. + mtd->priv = nand;
  34681. + mtd->owner = THIS_MODULE;
  34682. + if (pdata->name)
  34683. + mtd->name = pdata->name;
  34684. + else
  34685. + mtd->name = dev_name(&pdev->dev);
  34686. +
  34687. + nand->chip_delay = 25;
  34688. +
  34689. + nand->dev_ready = ar934x_nfc_dev_ready;
  34690. + nand->cmdfunc = ar934x_nfc_cmdfunc;
  34691. + nand->read_byte = ar934x_nfc_read_byte;
  34692. + nand->write_buf = ar934x_nfc_write_buf;
  34693. + nand->read_buf = ar934x_nfc_read_buf;
  34694. + nand->select_chip = ar934x_nfc_select_chip;
  34695. +
  34696. + ret = ar934x_nfc_alloc_buf(nfc, AR934X_NFC_ID_BUF_SIZE);
  34697. + if (ret)
  34698. + goto err_free_irq;
  34699. +
  34700. + platform_set_drvdata(pdev, nfc);
  34701. +
  34702. + ar934x_nfc_hw_init(nfc);
  34703. +
  34704. + ret = nand_scan_ident(mtd, 1, NULL);
  34705. + if (ret) {
  34706. + dev_err(&pdev->dev, "nand_scan_ident failed, err:%d\n", ret);
  34707. + goto err_free_buf;
  34708. + }
  34709. +
  34710. + ret = ar934x_nfc_init_tail(mtd);
  34711. + if (ret) {
  34712. + dev_err(&pdev->dev, "init tail failed, err:%d\n", ret);
  34713. + goto err_free_buf;
  34714. + }
  34715. +
  34716. + if (pdata->scan_fixup) {
  34717. + ret = pdata->scan_fixup(mtd);
  34718. + if (ret)
  34719. + goto err_free_buf;
  34720. + }
  34721. +
  34722. + switch (pdata->ecc_mode) {
  34723. + case AR934X_NFC_ECC_SOFT:
  34724. + nand->ecc.mode = NAND_ECC_SOFT;
  34725. + break;
  34726. +
  34727. + case AR934X_NFC_ECC_SOFT_BCH:
  34728. + nand->ecc.mode = NAND_ECC_SOFT_BCH;
  34729. + break;
  34730. +
  34731. + case AR934X_NFC_ECC_HW:
  34732. + ret = ar934x_nfc_setup_hwecc(nfc);
  34733. + if (ret)
  34734. + goto err_free_buf;
  34735. +
  34736. + break;
  34737. +
  34738. + default:
  34739. + dev_err(nfc->parent, "unknown ECC mode %d\n", pdata->ecc_mode);
  34740. + return -EINVAL;
  34741. + }
  34742. +
  34743. + ret = nand_scan_tail(mtd);
  34744. + if (ret) {
  34745. + dev_err(&pdev->dev, "scan tail failed, err:%d\n", ret);
  34746. + goto err_free_buf;
  34747. + }
  34748. +
  34749. + memset(&ppdata, '\0', sizeof(ppdata));
  34750. + ret = mtd_device_parse_register(mtd, part_probes, &ppdata,
  34751. + pdata->parts, pdata->nr_parts);
  34752. + if (ret) {
  34753. + dev_err(&pdev->dev, "unable to register mtd, err:%d\n", ret);
  34754. + goto err_free_buf;
  34755. + }
  34756. +
  34757. + return 0;
  34758. +
  34759. +err_free_buf:
  34760. + ar934x_nfc_free_buf(nfc);
  34761. +err_free_irq:
  34762. + free_irq(nfc->irq, nfc);
  34763. + return ret;
  34764. +}
  34765. +
  34766. +static int
  34767. +ar934x_nfc_remove(struct platform_device *pdev)
  34768. +{
  34769. + struct ar934x_nfc *nfc;
  34770. +
  34771. + nfc = platform_get_drvdata(pdev);
  34772. + if (nfc) {
  34773. + nand_release(&nfc->mtd);
  34774. + ar934x_nfc_free_buf(nfc);
  34775. + free_irq(nfc->irq, nfc);
  34776. + }
  34777. +
  34778. + return 0;
  34779. +}
  34780. +
  34781. +static struct platform_driver ar934x_nfc_driver = {
  34782. + .probe = ar934x_nfc_probe,
  34783. + .remove = ar934x_nfc_remove,
  34784. + .driver = {
  34785. + .name = AR934X_NFC_DRIVER_NAME,
  34786. + .owner = THIS_MODULE,
  34787. + },
  34788. +};
  34789. +
  34790. +module_platform_driver(ar934x_nfc_driver);
  34791. +
  34792. +MODULE_LICENSE("GPL v2");
  34793. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  34794. +MODULE_DESCRIPTION("Atheros AR934x NAND Flash Controller driver");
  34795. +MODULE_ALIAS("platform:" AR934X_NFC_DRIVER_NAME);
  34796. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/Kconfig linux-4.1.13/drivers/mtd/nand/Kconfig
  34797. --- linux-4.1.13.orig/drivers/mtd/nand/Kconfig 2015-11-09 23:34:10.000000000 +0100
  34798. +++ linux-4.1.13/drivers/mtd/nand/Kconfig 2015-12-04 19:57:03.882110905 +0100
  34799. @@ -530,4 +530,24 @@
  34800. help
  34801. Enables support for NAND controller on Hisilicon SoC Hip04.
  34802. +config MTD_NAND_RB4XX
  34803. + tristate "NAND flash driver for RouterBoard 4xx series"
  34804. + depends on MTD_NAND && ATH79_MACH_RB4XX
  34805. +
  34806. +config MTD_NAND_RB750
  34807. + tristate "NAND flash driver for the RouterBoard 750"
  34808. + depends on MTD_NAND && ATH79_MACH_RB750
  34809. +
  34810. +config MTD_NAND_RB91X
  34811. + tristate "NAND flash driver for the RouterBOARD 91x series"
  34812. + depends on MTD_NAND && ATH79_MACH_RB91X
  34813. +
  34814. +config MTD_NAND_AR934X
  34815. + tristate "NAND flash driver for the Qualcomm Atheros AR934x/QCA955x SoCs"
  34816. + depends on (SOC_AR934X || SOC_QCA955X)
  34817. +
  34818. +config MTD_NAND_AR934X_HW_ECC
  34819. + bool "Hardware ECC support for the AR934X NAND Controller (EXPERIMENTAL)"
  34820. + depends on MTD_NAND_AR934X
  34821. +
  34822. endif # MTD_NAND
  34823. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/Makefile linux-4.1.13/drivers/mtd/nand/Makefile
  34824. --- linux-4.1.13.orig/drivers/mtd/nand/Makefile 2015-11-09 23:34:10.000000000 +0100
  34825. +++ linux-4.1.13/drivers/mtd/nand/Makefile 2015-12-04 19:57:03.882110905 +0100
  34826. @@ -13,6 +13,7 @@
  34827. obj-$(CONFIG_MTD_NAND_DENALI) += denali.o
  34828. obj-$(CONFIG_MTD_NAND_DENALI_PCI) += denali_pci.o
  34829. obj-$(CONFIG_MTD_NAND_DENALI_DT) += denali_dt.o
  34830. +obj-$(CONFIG_MTD_NAND_AR934X) += ar934x_nfc.o
  34831. obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
  34832. obj-$(CONFIG_MTD_NAND_BF5XX) += bf5xx_nand.o
  34833. obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
  34834. @@ -32,6 +33,9 @@
  34835. obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
  34836. obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
  34837. obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  34838. +obj-$(CONFIG_MTD_NAND_RB4XX) += rb4xx_nand.o
  34839. +obj-$(CONFIG_MTD_NAND_RB750) += rb750_nand.o
  34840. +obj-$(CONFIG_MTD_NAND_RB91X) += rb91x_nand.o
  34841. obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
  34842. obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
  34843. obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o
  34844. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/rb4xx_nand.c linux-4.1.13/drivers/mtd/nand/rb4xx_nand.c
  34845. --- linux-4.1.13.orig/drivers/mtd/nand/rb4xx_nand.c 1970-01-01 01:00:00.000000000 +0100
  34846. +++ linux-4.1.13/drivers/mtd/nand/rb4xx_nand.c 2015-09-13 20:04:35.076523692 +0200
  34847. @@ -0,0 +1,305 @@
  34848. +/*
  34849. + * NAND flash driver for the MikroTik RouterBoard 4xx series
  34850. + *
  34851. + * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  34852. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  34853. + *
  34854. + * This file was based on the driver for Linux 2.6.22 published by
  34855. + * MikroTik for their RouterBoard 4xx series devices.
  34856. + *
  34857. + * This program is free software; you can redistribute it and/or modify it
  34858. + * under the terms of the GNU General Public License version 2 as published
  34859. + * by the Free Software Foundation.
  34860. + */
  34861. +
  34862. +#include <linux/kernel.h>
  34863. +#include <linux/module.h>
  34864. +#include <linux/init.h>
  34865. +#include <linux/mtd/nand.h>
  34866. +#include <linux/mtd/mtd.h>
  34867. +#include <linux/mtd/partitions.h>
  34868. +#include <linux/platform_device.h>
  34869. +#include <linux/delay.h>
  34870. +#include <linux/io.h>
  34871. +#include <linux/gpio.h>
  34872. +#include <linux/slab.h>
  34873. +
  34874. +#include <asm/mach-ath79/ath79.h>
  34875. +#include <asm/mach-ath79/rb4xx_cpld.h>
  34876. +
  34877. +#define DRV_NAME "rb4xx-nand"
  34878. +#define DRV_VERSION "0.2.0"
  34879. +#define DRV_DESC "NAND flash driver for RouterBoard 4xx series"
  34880. +
  34881. +#define RB4XX_NAND_GPIO_READY 5
  34882. +#define RB4XX_NAND_GPIO_ALE 37
  34883. +#define RB4XX_NAND_GPIO_CLE 38
  34884. +#define RB4XX_NAND_GPIO_NCE 39
  34885. +
  34886. +struct rb4xx_nand_info {
  34887. + struct nand_chip chip;
  34888. + struct mtd_info mtd;
  34889. +};
  34890. +
  34891. +/*
  34892. + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  34893. + * will not be able to find the kernel that we load.
  34894. + */
  34895. +static struct nand_ecclayout rb4xx_nand_ecclayout = {
  34896. + .eccbytes = 6,
  34897. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  34898. + .oobavail = 9,
  34899. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  34900. +};
  34901. +
  34902. +static struct mtd_partition rb4xx_nand_partitions[] = {
  34903. + {
  34904. + .name = "booter",
  34905. + .offset = 0,
  34906. + .size = (256 * 1024),
  34907. + .mask_flags = MTD_WRITEABLE,
  34908. + },
  34909. + {
  34910. + .name = "kernel",
  34911. + .offset = (256 * 1024),
  34912. + .size = (4 * 1024 * 1024) - (256 * 1024),
  34913. + },
  34914. + {
  34915. + .name = "rootfs",
  34916. + .offset = MTDPART_OFS_NXTBLK,
  34917. + .size = MTDPART_SIZ_FULL,
  34918. + },
  34919. +};
  34920. +
  34921. +static int rb4xx_nand_dev_ready(struct mtd_info *mtd)
  34922. +{
  34923. + return gpio_get_value_cansleep(RB4XX_NAND_GPIO_READY);
  34924. +}
  34925. +
  34926. +static void rb4xx_nand_write_cmd(unsigned char cmd)
  34927. +{
  34928. + unsigned char data = cmd;
  34929. + int err;
  34930. +
  34931. + err = rb4xx_cpld_write(&data, 1);
  34932. + if (err)
  34933. + pr_err("rb4xx_nand: write cmd failed, err=%d\n", err);
  34934. +}
  34935. +
  34936. +static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  34937. + unsigned int ctrl)
  34938. +{
  34939. + if (ctrl & NAND_CTRL_CHANGE) {
  34940. + gpio_set_value_cansleep(RB4XX_NAND_GPIO_CLE,
  34941. + (ctrl & NAND_CLE) ? 1 : 0);
  34942. + gpio_set_value_cansleep(RB4XX_NAND_GPIO_ALE,
  34943. + (ctrl & NAND_ALE) ? 1 : 0);
  34944. + gpio_set_value_cansleep(RB4XX_NAND_GPIO_NCE,
  34945. + (ctrl & NAND_NCE) ? 0 : 1);
  34946. + }
  34947. +
  34948. + if (cmd != NAND_CMD_NONE)
  34949. + rb4xx_nand_write_cmd(cmd);
  34950. +}
  34951. +
  34952. +static unsigned char rb4xx_nand_read_byte(struct mtd_info *mtd)
  34953. +{
  34954. + unsigned char data = 0;
  34955. + int err;
  34956. +
  34957. + err = rb4xx_cpld_read(&data, NULL, 1);
  34958. + if (err) {
  34959. + pr_err("rb4xx_nand: read data failed, err=%d\n", err);
  34960. + data = 0xff;
  34961. + }
  34962. +
  34963. + return data;
  34964. +}
  34965. +
  34966. +static void rb4xx_nand_write_buf(struct mtd_info *mtd, const unsigned char *buf,
  34967. + int len)
  34968. +{
  34969. + int err;
  34970. +
  34971. + err = rb4xx_cpld_write(buf, len);
  34972. + if (err)
  34973. + pr_err("rb4xx_nand: write buf failed, err=%d\n", err);
  34974. +}
  34975. +
  34976. +static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf,
  34977. + int len)
  34978. +{
  34979. + int err;
  34980. +
  34981. + err = rb4xx_cpld_read(buf, NULL, len);
  34982. + if (err)
  34983. + pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
  34984. +}
  34985. +
  34986. +static int rb4xx_nand_probe(struct platform_device *pdev)
  34987. +{
  34988. + struct rb4xx_nand_info *info;
  34989. + int ret;
  34990. +
  34991. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  34992. +
  34993. + ret = gpio_request(RB4XX_NAND_GPIO_READY, "NAND RDY");
  34994. + if (ret) {
  34995. + dev_err(&pdev->dev, "unable to request gpio %d\n",
  34996. + RB4XX_NAND_GPIO_READY);
  34997. + goto err;
  34998. + }
  34999. +
  35000. + ret = gpio_direction_input(RB4XX_NAND_GPIO_READY);
  35001. + if (ret) {
  35002. + dev_err(&pdev->dev, "unable to set input mode on gpio %d\n",
  35003. + RB4XX_NAND_GPIO_READY);
  35004. + goto err_free_gpio_ready;
  35005. + }
  35006. +
  35007. + ret = gpio_request(RB4XX_NAND_GPIO_ALE, "NAND ALE");
  35008. + if (ret) {
  35009. + dev_err(&pdev->dev, "unable to request gpio %d\n",
  35010. + RB4XX_NAND_GPIO_ALE);
  35011. + goto err_free_gpio_ready;
  35012. + }
  35013. +
  35014. + ret = gpio_direction_output(RB4XX_NAND_GPIO_ALE, 0);
  35015. + if (ret) {
  35016. + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
  35017. + RB4XX_NAND_GPIO_ALE);
  35018. + goto err_free_gpio_ale;
  35019. + }
  35020. +
  35021. + ret = gpio_request(RB4XX_NAND_GPIO_CLE, "NAND CLE");
  35022. + if (ret) {
  35023. + dev_err(&pdev->dev, "unable to request gpio %d\n",
  35024. + RB4XX_NAND_GPIO_CLE);
  35025. + goto err_free_gpio_ale;
  35026. + }
  35027. +
  35028. + ret = gpio_direction_output(RB4XX_NAND_GPIO_CLE, 0);
  35029. + if (ret) {
  35030. + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
  35031. + RB4XX_NAND_GPIO_CLE);
  35032. + goto err_free_gpio_cle;
  35033. + }
  35034. +
  35035. + ret = gpio_request(RB4XX_NAND_GPIO_NCE, "NAND NCE");
  35036. + if (ret) {
  35037. + dev_err(&pdev->dev, "unable to request gpio %d\n",
  35038. + RB4XX_NAND_GPIO_NCE);
  35039. + goto err_free_gpio_cle;
  35040. + }
  35041. +
  35042. + ret = gpio_direction_output(RB4XX_NAND_GPIO_NCE, 1);
  35043. + if (ret) {
  35044. + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
  35045. + RB4XX_NAND_GPIO_ALE);
  35046. + goto err_free_gpio_nce;
  35047. + }
  35048. +
  35049. + info = kzalloc(sizeof(*info), GFP_KERNEL);
  35050. + if (!info) {
  35051. + dev_err(&pdev->dev, "rb4xx-nand: no memory for private data\n");
  35052. + ret = -ENOMEM;
  35053. + goto err_free_gpio_nce;
  35054. + }
  35055. +
  35056. + info->chip.priv = &info;
  35057. + info->mtd.priv = &info->chip;
  35058. + info->mtd.owner = THIS_MODULE;
  35059. +
  35060. + info->chip.cmd_ctrl = rb4xx_nand_cmd_ctrl;
  35061. + info->chip.dev_ready = rb4xx_nand_dev_ready;
  35062. + info->chip.read_byte = rb4xx_nand_read_byte;
  35063. + info->chip.write_buf = rb4xx_nand_write_buf;
  35064. + info->chip.read_buf = rb4xx_nand_read_buf;
  35065. +
  35066. + info->chip.chip_delay = 25;
  35067. + info->chip.ecc.mode = NAND_ECC_SOFT;
  35068. +
  35069. + platform_set_drvdata(pdev, info);
  35070. +
  35071. + ret = nand_scan_ident(&info->mtd, 1, NULL);
  35072. + if (ret) {
  35073. + ret = -ENXIO;
  35074. + goto err_free_info;
  35075. + }
  35076. +
  35077. + if (info->mtd.writesize == 512)
  35078. + info->chip.ecc.layout = &rb4xx_nand_ecclayout;
  35079. +
  35080. + ret = nand_scan_tail(&info->mtd);
  35081. + if (ret) {
  35082. + return -ENXIO;
  35083. + goto err_set_drvdata;
  35084. + }
  35085. +
  35086. + mtd_device_register(&info->mtd, rb4xx_nand_partitions,
  35087. + ARRAY_SIZE(rb4xx_nand_partitions));
  35088. + if (ret)
  35089. + goto err_release_nand;
  35090. +
  35091. + return 0;
  35092. +
  35093. +err_release_nand:
  35094. + nand_release(&info->mtd);
  35095. +err_set_drvdata:
  35096. + platform_set_drvdata(pdev, NULL);
  35097. +err_free_info:
  35098. + kfree(info);
  35099. +err_free_gpio_nce:
  35100. + gpio_free(RB4XX_NAND_GPIO_NCE);
  35101. +err_free_gpio_cle:
  35102. + gpio_free(RB4XX_NAND_GPIO_CLE);
  35103. +err_free_gpio_ale:
  35104. + gpio_free(RB4XX_NAND_GPIO_ALE);
  35105. +err_free_gpio_ready:
  35106. + gpio_free(RB4XX_NAND_GPIO_READY);
  35107. +err:
  35108. + return ret;
  35109. +}
  35110. +
  35111. +static int rb4xx_nand_remove(struct platform_device *pdev)
  35112. +{
  35113. + struct rb4xx_nand_info *info = platform_get_drvdata(pdev);
  35114. +
  35115. + nand_release(&info->mtd);
  35116. + platform_set_drvdata(pdev, NULL);
  35117. + kfree(info);
  35118. + gpio_free(RB4XX_NAND_GPIO_NCE);
  35119. + gpio_free(RB4XX_NAND_GPIO_CLE);
  35120. + gpio_free(RB4XX_NAND_GPIO_ALE);
  35121. + gpio_free(RB4XX_NAND_GPIO_READY);
  35122. +
  35123. + return 0;
  35124. +}
  35125. +
  35126. +static struct platform_driver rb4xx_nand_driver = {
  35127. + .probe = rb4xx_nand_probe,
  35128. + .remove = rb4xx_nand_remove,
  35129. + .driver = {
  35130. + .name = DRV_NAME,
  35131. + .owner = THIS_MODULE,
  35132. + },
  35133. +};
  35134. +
  35135. +static int __init rb4xx_nand_init(void)
  35136. +{
  35137. + return platform_driver_register(&rb4xx_nand_driver);
  35138. +}
  35139. +
  35140. +static void __exit rb4xx_nand_exit(void)
  35141. +{
  35142. + platform_driver_unregister(&rb4xx_nand_driver);
  35143. +}
  35144. +
  35145. +module_init(rb4xx_nand_init);
  35146. +module_exit(rb4xx_nand_exit);
  35147. +
  35148. +MODULE_DESCRIPTION(DRV_DESC);
  35149. +MODULE_VERSION(DRV_VERSION);
  35150. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  35151. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
  35152. +MODULE_LICENSE("GPL v2");
  35153. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/rb750_nand.c linux-4.1.13/drivers/mtd/nand/rb750_nand.c
  35154. --- linux-4.1.13.orig/drivers/mtd/nand/rb750_nand.c 1970-01-01 01:00:00.000000000 +0100
  35155. +++ linux-4.1.13/drivers/mtd/nand/rb750_nand.c 2015-09-13 20:04:35.076523692 +0200
  35156. @@ -0,0 +1,354 @@
  35157. +/*
  35158. + * NAND flash driver for the MikroTik RouterBOARD 750
  35159. + *
  35160. + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  35161. + *
  35162. + * This program is free software; you can redistribute it and/or modify it
  35163. + * under the terms of the GNU General Public License version 2 as published
  35164. + * by the Free Software Foundation.
  35165. + */
  35166. +
  35167. +#include <linux/kernel.h>
  35168. +#include <linux/module.h>
  35169. +#include <linux/mtd/nand.h>
  35170. +#include <linux/mtd/mtd.h>
  35171. +#include <linux/mtd/partitions.h>
  35172. +#include <linux/platform_device.h>
  35173. +#include <linux/io.h>
  35174. +#include <linux/slab.h>
  35175. +
  35176. +#include <asm/mach-ath79/ar71xx_regs.h>
  35177. +#include <asm/mach-ath79/ath79.h>
  35178. +#include <asm/mach-ath79/mach-rb750.h>
  35179. +
  35180. +#define DRV_NAME "rb750-nand"
  35181. +#define DRV_VERSION "0.1.0"
  35182. +#define DRV_DESC "NAND flash driver for the RouterBOARD 750"
  35183. +
  35184. +#define RB750_NAND_IO0 BIT(RB750_GPIO_NAND_IO0)
  35185. +#define RB750_NAND_ALE BIT(RB750_GPIO_NAND_ALE)
  35186. +#define RB750_NAND_CLE BIT(RB750_GPIO_NAND_CLE)
  35187. +#define RB750_NAND_NRE BIT(RB750_GPIO_NAND_NRE)
  35188. +#define RB750_NAND_NWE BIT(RB750_GPIO_NAND_NWE)
  35189. +#define RB750_NAND_RDY BIT(RB750_GPIO_NAND_RDY)
  35190. +
  35191. +#define RB750_NAND_DATA_SHIFT 1
  35192. +#define RB750_NAND_DATA_BITS (0xff << RB750_NAND_DATA_SHIFT)
  35193. +#define RB750_NAND_INPUT_BITS (RB750_NAND_DATA_BITS | RB750_NAND_RDY)
  35194. +#define RB750_NAND_OUTPUT_BITS (RB750_NAND_ALE | RB750_NAND_CLE | \
  35195. + RB750_NAND_NRE | RB750_NAND_NWE)
  35196. +
  35197. +struct rb750_nand_info {
  35198. + struct nand_chip chip;
  35199. + struct mtd_info mtd;
  35200. + struct rb7xx_nand_platform_data *pdata;
  35201. +};
  35202. +
  35203. +static inline struct rb750_nand_info *mtd_to_rbinfo(struct mtd_info *mtd)
  35204. +{
  35205. + return container_of(mtd, struct rb750_nand_info, mtd);
  35206. +}
  35207. +
  35208. +/*
  35209. + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  35210. + * will not be able to find the kernel that we load.
  35211. + */
  35212. +static struct nand_ecclayout rb750_nand_ecclayout = {
  35213. + .eccbytes = 6,
  35214. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  35215. + .oobavail = 9,
  35216. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  35217. +};
  35218. +
  35219. +static struct mtd_partition rb750_nand_partitions[] = {
  35220. + {
  35221. + .name = "booter",
  35222. + .offset = 0,
  35223. + .size = (256 * 1024),
  35224. + .mask_flags = MTD_WRITEABLE,
  35225. + }, {
  35226. + .name = "kernel",
  35227. + .offset = (256 * 1024),
  35228. + .size = (4 * 1024 * 1024) - (256 * 1024),
  35229. + }, {
  35230. + .name = "rootfs",
  35231. + .offset = MTDPART_OFS_NXTBLK,
  35232. + .size = MTDPART_SIZ_FULL,
  35233. + },
  35234. +};
  35235. +
  35236. +static void rb750_nand_write(const u8 *buf, unsigned len)
  35237. +{
  35238. + void __iomem *base = ath79_gpio_base;
  35239. + u32 out;
  35240. + u32 t;
  35241. + unsigned i;
  35242. +
  35243. + /* set data lines to output mode */
  35244. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35245. + __raw_writel(t | RB750_NAND_DATA_BITS, base + AR71XX_GPIO_REG_OE);
  35246. +
  35247. + out = __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35248. + out &= ~(RB750_NAND_DATA_BITS | RB750_NAND_NWE);
  35249. + for (i = 0; i != len; i++) {
  35250. + u32 data;
  35251. +
  35252. + data = buf[i];
  35253. + data <<= RB750_NAND_DATA_SHIFT;
  35254. + data |= out;
  35255. + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
  35256. +
  35257. + __raw_writel(data | RB750_NAND_NWE, base + AR71XX_GPIO_REG_OUT);
  35258. + /* flush write */
  35259. + __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35260. + }
  35261. +
  35262. + /* set data lines to input mode */
  35263. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35264. + __raw_writel(t & ~RB750_NAND_DATA_BITS, base + AR71XX_GPIO_REG_OE);
  35265. + /* flush write */
  35266. + __raw_readl(base + AR71XX_GPIO_REG_OE);
  35267. +}
  35268. +
  35269. +static void rb750_nand_read(u8 *read_buf, unsigned len)
  35270. +{
  35271. + void __iomem *base = ath79_gpio_base;
  35272. + unsigned i;
  35273. +
  35274. + for (i = 0; i < len; i++) {
  35275. + u8 data;
  35276. +
  35277. + /* activate RE line */
  35278. + __raw_writel(RB750_NAND_NRE, base + AR71XX_GPIO_REG_CLEAR);
  35279. + /* flush write */
  35280. + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
  35281. +
  35282. + /* read input lines */
  35283. + data = __raw_readl(base + AR71XX_GPIO_REG_IN) >>
  35284. + RB750_NAND_DATA_SHIFT;
  35285. +
  35286. + /* deactivate RE line */
  35287. + __raw_writel(RB750_NAND_NRE, base + AR71XX_GPIO_REG_SET);
  35288. +
  35289. + read_buf[i] = data;
  35290. + }
  35291. +}
  35292. +
  35293. +static void rb750_nand_select_chip(struct mtd_info *mtd, int chip)
  35294. +{
  35295. + struct rb750_nand_info *rbinfo = mtd_to_rbinfo(mtd);
  35296. + void __iomem *base = ath79_gpio_base;
  35297. + u32 t;
  35298. +
  35299. + if (chip >= 0) {
  35300. + rbinfo->pdata->enable_pins();
  35301. +
  35302. + /* set input mode for data lines */
  35303. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35304. + __raw_writel(t & ~RB750_NAND_INPUT_BITS,
  35305. + base + AR71XX_GPIO_REG_OE);
  35306. +
  35307. + /* deactivate RE and WE lines */
  35308. + __raw_writel(RB750_NAND_NRE | RB750_NAND_NWE,
  35309. + base + AR71XX_GPIO_REG_SET);
  35310. + /* flush write */
  35311. + (void) __raw_readl(base + AR71XX_GPIO_REG_SET);
  35312. +
  35313. + /* activate CE line */
  35314. + __raw_writel(rbinfo->pdata->nce_line,
  35315. + base + AR71XX_GPIO_REG_CLEAR);
  35316. + } else {
  35317. + /* deactivate CE line */
  35318. + __raw_writel(rbinfo->pdata->nce_line,
  35319. + base + AR71XX_GPIO_REG_SET);
  35320. + /* flush write */
  35321. + (void) __raw_readl(base + AR71XX_GPIO_REG_SET);
  35322. +
  35323. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35324. + __raw_writel(t | RB750_NAND_IO0 | RB750_NAND_RDY,
  35325. + base + AR71XX_GPIO_REG_OE);
  35326. +
  35327. + rbinfo->pdata->disable_pins();
  35328. + }
  35329. +}
  35330. +
  35331. +static int rb750_nand_dev_ready(struct mtd_info *mtd)
  35332. +{
  35333. + void __iomem *base = ath79_gpio_base;
  35334. +
  35335. + return !!(__raw_readl(base + AR71XX_GPIO_REG_IN) & RB750_NAND_RDY);
  35336. +}
  35337. +
  35338. +static void rb750_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  35339. + unsigned int ctrl)
  35340. +{
  35341. + if (ctrl & NAND_CTRL_CHANGE) {
  35342. + void __iomem *base = ath79_gpio_base;
  35343. + u32 t;
  35344. +
  35345. + t = __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35346. +
  35347. + t &= ~(RB750_NAND_CLE | RB750_NAND_ALE);
  35348. + t |= (ctrl & NAND_CLE) ? RB750_NAND_CLE : 0;
  35349. + t |= (ctrl & NAND_ALE) ? RB750_NAND_ALE : 0;
  35350. +
  35351. + __raw_writel(t, base + AR71XX_GPIO_REG_OUT);
  35352. + /* flush write */
  35353. + __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35354. + }
  35355. +
  35356. + if (cmd != NAND_CMD_NONE) {
  35357. + u8 t = cmd;
  35358. + rb750_nand_write(&t, 1);
  35359. + }
  35360. +}
  35361. +
  35362. +static u8 rb750_nand_read_byte(struct mtd_info *mtd)
  35363. +{
  35364. + u8 data = 0;
  35365. + rb750_nand_read(&data, 1);
  35366. + return data;
  35367. +}
  35368. +
  35369. +static void rb750_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  35370. +{
  35371. + rb750_nand_read(buf, len);
  35372. +}
  35373. +
  35374. +static void rb750_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  35375. +{
  35376. + rb750_nand_write(buf, len);
  35377. +}
  35378. +
  35379. +static void __init rb750_nand_gpio_init(struct rb750_nand_info *info)
  35380. +{
  35381. + void __iomem *base = ath79_gpio_base;
  35382. + u32 out;
  35383. + u32 t;
  35384. +
  35385. + out = __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35386. +
  35387. + /* setup output levels */
  35388. + __raw_writel(RB750_NAND_NCE | RB750_NAND_NRE | RB750_NAND_NWE,
  35389. + base + AR71XX_GPIO_REG_SET);
  35390. +
  35391. + __raw_writel(RB750_NAND_ALE | RB750_NAND_CLE,
  35392. + base + AR71XX_GPIO_REG_CLEAR);
  35393. +
  35394. + /* setup input lines */
  35395. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35396. + __raw_writel(t & ~(RB750_NAND_INPUT_BITS), base + AR71XX_GPIO_REG_OE);
  35397. +
  35398. + /* setup output lines */
  35399. + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35400. + t |= RB750_NAND_OUTPUT_BITS;
  35401. + t |= info->pdata->nce_line;
  35402. + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
  35403. +
  35404. + info->pdata->latch_change(~out & RB750_NAND_IO0, out & RB750_NAND_IO0);
  35405. +}
  35406. +
  35407. +static int rb750_nand_probe(struct platform_device *pdev)
  35408. +{
  35409. + struct rb750_nand_info *info;
  35410. + struct rb7xx_nand_platform_data *pdata;
  35411. + int ret;
  35412. +
  35413. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  35414. +
  35415. + pdata = pdev->dev.platform_data;
  35416. + if (!pdata)
  35417. + return -EINVAL;
  35418. +
  35419. + info = kzalloc(sizeof(*info), GFP_KERNEL);
  35420. + if (!info)
  35421. + return -ENOMEM;
  35422. +
  35423. + info->chip.priv = &info;
  35424. + info->mtd.priv = &info->chip;
  35425. + info->mtd.owner = THIS_MODULE;
  35426. +
  35427. + info->chip.select_chip = rb750_nand_select_chip;
  35428. + info->chip.cmd_ctrl = rb750_nand_cmd_ctrl;
  35429. + info->chip.dev_ready = rb750_nand_dev_ready;
  35430. + info->chip.read_byte = rb750_nand_read_byte;
  35431. + info->chip.write_buf = rb750_nand_write_buf;
  35432. + info->chip.read_buf = rb750_nand_read_buf;
  35433. +
  35434. + info->chip.chip_delay = 25;
  35435. + info->chip.ecc.mode = NAND_ECC_SOFT;
  35436. +
  35437. + info->pdata = pdata;
  35438. +
  35439. + platform_set_drvdata(pdev, info);
  35440. +
  35441. + rb750_nand_gpio_init(info);
  35442. +
  35443. + ret = nand_scan_ident(&info->mtd, 1, NULL);
  35444. + if (ret) {
  35445. + ret = -ENXIO;
  35446. + goto err_free_info;
  35447. + }
  35448. +
  35449. + if (info->mtd.writesize == 512)
  35450. + info->chip.ecc.layout = &rb750_nand_ecclayout;
  35451. +
  35452. + ret = nand_scan_tail(&info->mtd);
  35453. + if (ret) {
  35454. + return -ENXIO;
  35455. + goto err_set_drvdata;
  35456. + }
  35457. +
  35458. + ret = mtd_device_register(&info->mtd, rb750_nand_partitions,
  35459. + ARRAY_SIZE(rb750_nand_partitions));
  35460. + if (ret)
  35461. + goto err_release_nand;
  35462. +
  35463. + return 0;
  35464. +
  35465. +err_release_nand:
  35466. + nand_release(&info->mtd);
  35467. +err_set_drvdata:
  35468. + platform_set_drvdata(pdev, NULL);
  35469. +err_free_info:
  35470. + kfree(info);
  35471. + return ret;
  35472. +}
  35473. +
  35474. +static int rb750_nand_remove(struct platform_device *pdev)
  35475. +{
  35476. + struct rb750_nand_info *info = platform_get_drvdata(pdev);
  35477. +
  35478. + nand_release(&info->mtd);
  35479. + platform_set_drvdata(pdev, NULL);
  35480. + kfree(info);
  35481. +
  35482. + return 0;
  35483. +}
  35484. +
  35485. +static struct platform_driver rb750_nand_driver = {
  35486. + .probe = rb750_nand_probe,
  35487. + .remove = rb750_nand_remove,
  35488. + .driver = {
  35489. + .name = DRV_NAME,
  35490. + .owner = THIS_MODULE,
  35491. + },
  35492. +};
  35493. +
  35494. +static int __init rb750_nand_init(void)
  35495. +{
  35496. + return platform_driver_register(&rb750_nand_driver);
  35497. +}
  35498. +
  35499. +static void __exit rb750_nand_exit(void)
  35500. +{
  35501. + platform_driver_unregister(&rb750_nand_driver);
  35502. +}
  35503. +
  35504. +module_init(rb750_nand_init);
  35505. +module_exit(rb750_nand_exit);
  35506. +
  35507. +MODULE_DESCRIPTION(DRV_DESC);
  35508. +MODULE_VERSION(DRV_VERSION);
  35509. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  35510. +MODULE_LICENSE("GPL v2");
  35511. diff -Nur linux-4.1.13.orig/drivers/mtd/nand/rb91x_nand.c linux-4.1.13/drivers/mtd/nand/rb91x_nand.c
  35512. --- linux-4.1.13.orig/drivers/mtd/nand/rb91x_nand.c 1970-01-01 01:00:00.000000000 +0100
  35513. +++ linux-4.1.13/drivers/mtd/nand/rb91x_nand.c 2015-09-13 20:04:35.076523692 +0200
  35514. @@ -0,0 +1,377 @@
  35515. +/*
  35516. + * NAND flash driver for the MikroTik RouterBOARD 91x series
  35517. + *
  35518. + * Copyright (C) 2013-2014 Gabor Juhos <juhosg@openwrt.org>
  35519. + *
  35520. + * This program is free software; you can redistribute it and/or modify it
  35521. + * under the terms of the GNU General Public License version 2 as published
  35522. + * by the Free Software Foundation.
  35523. + */
  35524. +
  35525. +#include <linux/kernel.h>
  35526. +#include <linux/spinlock.h>
  35527. +#include <linux/module.h>
  35528. +#include <linux/mtd/nand.h>
  35529. +#include <linux/mtd/mtd.h>
  35530. +#include <linux/mtd/partitions.h>
  35531. +#include <linux/platform_device.h>
  35532. +#include <linux/io.h>
  35533. +#include <linux/slab.h>
  35534. +#include <linux/gpio.h>
  35535. +#include <linux/platform_data/rb91x_nand.h>
  35536. +
  35537. +#include <asm/mach-ath79/ar71xx_regs.h>
  35538. +#include <asm/mach-ath79/ath79.h>
  35539. +
  35540. +#define DRV_DESC "NAND flash driver for the RouterBOARD 91x series"
  35541. +
  35542. +#define RB91X_NAND_NRWE BIT(12)
  35543. +
  35544. +#define RB91X_NAND_DATA_BITS (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) |\
  35545. + BIT(13) | BIT(14) | BIT(15))
  35546. +
  35547. +#define RB91X_NAND_INPUT_BITS (RB91X_NAND_DATA_BITS | RB91X_NAND_RDY)
  35548. +#define RB91X_NAND_OUTPUT_BITS (RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE)
  35549. +
  35550. +#define RB91X_NAND_LOW_DATA_MASK 0x1f
  35551. +#define RB91X_NAND_HIGH_DATA_MASK 0xe0
  35552. +#define RB91X_NAND_HIGH_DATA_SHIFT 8
  35553. +
  35554. +struct rb91x_nand_info {
  35555. + struct nand_chip chip;
  35556. + struct mtd_info mtd;
  35557. + struct device *dev;
  35558. +
  35559. + int gpio_nce;
  35560. + int gpio_ale;
  35561. + int gpio_cle;
  35562. + int gpio_rdy;
  35563. + int gpio_read;
  35564. + int gpio_nrw;
  35565. + int gpio_nle;
  35566. +};
  35567. +
  35568. +static inline struct rb91x_nand_info *mtd_to_rbinfo(struct mtd_info *mtd)
  35569. +{
  35570. + return container_of(mtd, struct rb91x_nand_info, mtd);
  35571. +}
  35572. +
  35573. +/*
  35574. + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  35575. + * will not be able to find the kernel that we load.
  35576. + */
  35577. +static struct nand_ecclayout rb91x_nand_ecclayout = {
  35578. + .eccbytes = 6,
  35579. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  35580. + .oobavail = 9,
  35581. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  35582. +};
  35583. +
  35584. +static struct mtd_partition rb91x_nand_partitions[] = {
  35585. + {
  35586. + .name = "booter",
  35587. + .offset = 0,
  35588. + .size = (256 * 1024),
  35589. + .mask_flags = MTD_WRITEABLE,
  35590. + }, {
  35591. + .name = "kernel",
  35592. + .offset = (256 * 1024),
  35593. + .size = (4 * 1024 * 1024) - (256 * 1024),
  35594. + }, {
  35595. + .name = "rootfs",
  35596. + .offset = MTDPART_OFS_NXTBLK,
  35597. + .size = MTDPART_SIZ_FULL,
  35598. + },
  35599. +};
  35600. +
  35601. +static void rb91x_nand_write(struct rb91x_nand_info *rbni,
  35602. + const u8 *buf,
  35603. + unsigned len)
  35604. +{
  35605. + void __iomem *base = ath79_gpio_base;
  35606. + u32 oe_reg;
  35607. + u32 out_reg;
  35608. + u32 out;
  35609. + unsigned i;
  35610. +
  35611. + /* enable the latch */
  35612. + gpio_set_value_cansleep(rbni->gpio_nle, 0);
  35613. +
  35614. + oe_reg = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35615. + out_reg = __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35616. +
  35617. + /* set data lines to output mode */
  35618. + __raw_writel(oe_reg & ~(RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE),
  35619. + base + AR71XX_GPIO_REG_OE);
  35620. +
  35621. + out = out_reg & ~(RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE);
  35622. + for (i = 0; i != len; i++) {
  35623. + u32 data;
  35624. +
  35625. + data = (buf[i] & RB91X_NAND_HIGH_DATA_MASK) <<
  35626. + RB91X_NAND_HIGH_DATA_SHIFT;
  35627. + data |= buf[i] & RB91X_NAND_LOW_DATA_MASK;
  35628. + data |= out;
  35629. + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
  35630. +
  35631. + /* deactivate WE line */
  35632. + data |= RB91X_NAND_NRWE;
  35633. + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
  35634. + /* flush write */
  35635. + __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35636. + }
  35637. +
  35638. + /* restore registers */
  35639. + __raw_writel(out_reg, base + AR71XX_GPIO_REG_OUT);
  35640. + __raw_writel(oe_reg, base + AR71XX_GPIO_REG_OE);
  35641. + /* flush write */
  35642. + __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35643. +
  35644. + /* disable the latch */
  35645. + gpio_set_value_cansleep(rbni->gpio_nle, 1);
  35646. +}
  35647. +
  35648. +static void rb91x_nand_read(struct rb91x_nand_info *rbni,
  35649. + u8 *read_buf,
  35650. + unsigned len)
  35651. +{
  35652. + void __iomem *base = ath79_gpio_base;
  35653. + u32 oe_reg;
  35654. + u32 out_reg;
  35655. + unsigned i;
  35656. +
  35657. + /* enable read mode */
  35658. + gpio_set_value_cansleep(rbni->gpio_read, 1);
  35659. +
  35660. + /* enable latch */
  35661. + gpio_set_value_cansleep(rbni->gpio_nle, 0);
  35662. +
  35663. + /* save registers */
  35664. + oe_reg = __raw_readl(base + AR71XX_GPIO_REG_OE);
  35665. + out_reg = __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35666. +
  35667. + /* set data lines to input mode */
  35668. + __raw_writel(oe_reg | RB91X_NAND_DATA_BITS,
  35669. + base + AR71XX_GPIO_REG_OE);
  35670. +
  35671. + for (i = 0; i < len; i++) {
  35672. + u32 in;
  35673. + u8 data;
  35674. +
  35675. + /* activate RE line */
  35676. + __raw_writel(RB91X_NAND_NRWE, base + AR71XX_GPIO_REG_CLEAR);
  35677. + /* flush write */
  35678. + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
  35679. +
  35680. + /* read input lines */
  35681. + in = __raw_readl(base + AR71XX_GPIO_REG_IN);
  35682. +
  35683. + /* deactivate RE line */
  35684. + __raw_writel(RB91X_NAND_NRWE, base + AR71XX_GPIO_REG_SET);
  35685. +
  35686. + data = (in & RB91X_NAND_LOW_DATA_MASK);
  35687. + data |= (in >> RB91X_NAND_HIGH_DATA_SHIFT) &
  35688. + RB91X_NAND_HIGH_DATA_MASK;
  35689. +
  35690. + read_buf[i] = data;
  35691. + }
  35692. +
  35693. + /* restore registers */
  35694. + __raw_writel(out_reg, base + AR71XX_GPIO_REG_OUT);
  35695. + __raw_writel(oe_reg, base + AR71XX_GPIO_REG_OE);
  35696. + /* flush write */
  35697. + __raw_readl(base + AR71XX_GPIO_REG_OUT);
  35698. +
  35699. + /* disable latch */
  35700. + gpio_set_value_cansleep(rbni->gpio_nle, 1);
  35701. +
  35702. + /* disable read mode */
  35703. + gpio_set_value_cansleep(rbni->gpio_read, 0);
  35704. +}
  35705. +
  35706. +static int rb91x_nand_dev_ready(struct mtd_info *mtd)
  35707. +{
  35708. + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
  35709. +
  35710. + return gpio_get_value_cansleep(rbni->gpio_rdy);
  35711. +}
  35712. +
  35713. +static void rb91x_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  35714. + unsigned int ctrl)
  35715. +{
  35716. + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
  35717. +
  35718. + if (ctrl & NAND_CTRL_CHANGE) {
  35719. + gpio_set_value_cansleep(rbni->gpio_cle,
  35720. + (ctrl & NAND_CLE) ? 1 : 0);
  35721. + gpio_set_value_cansleep(rbni->gpio_ale,
  35722. + (ctrl & NAND_ALE) ? 1 : 0);
  35723. + gpio_set_value_cansleep(rbni->gpio_nce,
  35724. + (ctrl & NAND_NCE) ? 0 : 1);
  35725. + }
  35726. +
  35727. + if (cmd != NAND_CMD_NONE) {
  35728. + u8 t = cmd;
  35729. +
  35730. + rb91x_nand_write(rbni, &t, 1);
  35731. + }
  35732. +}
  35733. +
  35734. +static u8 rb91x_nand_read_byte(struct mtd_info *mtd)
  35735. +{
  35736. + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
  35737. + u8 data = 0xff;
  35738. +
  35739. + rb91x_nand_read(rbni, &data, 1);
  35740. +
  35741. + return data;
  35742. +}
  35743. +
  35744. +static void rb91x_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  35745. +{
  35746. + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
  35747. +
  35748. + rb91x_nand_read(rbni, buf, len);
  35749. +}
  35750. +
  35751. +static void rb91x_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  35752. +{
  35753. + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
  35754. +
  35755. + rb91x_nand_write(rbni, buf, len);
  35756. +}
  35757. +
  35758. +static int rb91x_nand_gpio_init(struct rb91x_nand_info *info)
  35759. +{
  35760. + int ret;
  35761. +
  35762. + /*
  35763. + * Ensure that the LATCH is disabled before initializing
  35764. + * control lines.
  35765. + */
  35766. + ret = devm_gpio_request_one(info->dev, info->gpio_nle,
  35767. + GPIOF_OUT_INIT_HIGH, "LATCH enable");
  35768. + if (ret)
  35769. + return ret;
  35770. +
  35771. + ret = devm_gpio_request_one(info->dev, info->gpio_nce,
  35772. + GPIOF_OUT_INIT_HIGH, "NAND nCE");
  35773. + if (ret)
  35774. + return ret;
  35775. +
  35776. + ret = devm_gpio_request_one(info->dev, info->gpio_nrw,
  35777. + GPIOF_OUT_INIT_HIGH, "NAND nRW");
  35778. + if (ret)
  35779. + return ret;
  35780. +
  35781. + ret = devm_gpio_request_one(info->dev, info->gpio_cle,
  35782. + GPIOF_OUT_INIT_LOW, "NAND CLE");
  35783. + if (ret)
  35784. + return ret;
  35785. +
  35786. + ret = devm_gpio_request_one(info->dev, info->gpio_ale,
  35787. + GPIOF_OUT_INIT_LOW, "NAND ALE");
  35788. + if (ret)
  35789. + return ret;
  35790. +
  35791. + ret = devm_gpio_request_one(info->dev, info->gpio_read,
  35792. + GPIOF_OUT_INIT_LOW, "NAND READ");
  35793. + if (ret)
  35794. + return ret;
  35795. +
  35796. + ret = devm_gpio_request_one(info->dev, info->gpio_rdy,
  35797. + GPIOF_IN, "NAND RDY");
  35798. + return ret;
  35799. +}
  35800. +
  35801. +static int rb91x_nand_probe(struct platform_device *pdev)
  35802. +{
  35803. + struct rb91x_nand_info *rbni;
  35804. + struct rb91x_nand_platform_data *pdata;
  35805. + int ret;
  35806. +
  35807. + pr_info(DRV_DESC "\n");
  35808. +
  35809. + pdata = dev_get_platdata(&pdev->dev);
  35810. + if (!pdata)
  35811. + return -EINVAL;
  35812. +
  35813. + rbni = devm_kzalloc(&pdev->dev, sizeof(*rbni), GFP_KERNEL);
  35814. + if (!rbni)
  35815. + return -ENOMEM;
  35816. +
  35817. + rbni->dev = &pdev->dev;
  35818. + rbni->gpio_nce = pdata->gpio_nce;
  35819. + rbni->gpio_ale = pdata->gpio_ale;
  35820. + rbni->gpio_cle = pdata->gpio_cle;
  35821. + rbni->gpio_read = pdata->gpio_read;
  35822. + rbni->gpio_nrw = pdata->gpio_nrw;
  35823. + rbni->gpio_rdy = pdata->gpio_rdy;
  35824. + rbni->gpio_nle = pdata->gpio_nle;
  35825. +
  35826. + rbni->chip.priv = &rbni;
  35827. + rbni->mtd.priv = &rbni->chip;
  35828. + rbni->mtd.owner = THIS_MODULE;
  35829. +
  35830. + rbni->chip.cmd_ctrl = rb91x_nand_cmd_ctrl;
  35831. + rbni->chip.dev_ready = rb91x_nand_dev_ready;
  35832. + rbni->chip.read_byte = rb91x_nand_read_byte;
  35833. + rbni->chip.write_buf = rb91x_nand_write_buf;
  35834. + rbni->chip.read_buf = rb91x_nand_read_buf;
  35835. +
  35836. + rbni->chip.chip_delay = 25;
  35837. + rbni->chip.ecc.mode = NAND_ECC_SOFT;
  35838. +
  35839. + platform_set_drvdata(pdev, rbni);
  35840. +
  35841. + ret = rb91x_nand_gpio_init(rbni);
  35842. + if (ret)
  35843. + return ret;
  35844. +
  35845. + ret = nand_scan_ident(&rbni->mtd, 1, NULL);
  35846. + if (ret)
  35847. + return ret;
  35848. +
  35849. + if (rbni->mtd.writesize == 512)
  35850. + rbni->chip.ecc.layout = &rb91x_nand_ecclayout;
  35851. +
  35852. + ret = nand_scan_tail(&rbni->mtd);
  35853. + if (ret)
  35854. + return ret;
  35855. +
  35856. + ret = mtd_device_register(&rbni->mtd, rb91x_nand_partitions,
  35857. + ARRAY_SIZE(rb91x_nand_partitions));
  35858. + if (ret)
  35859. + goto err_release_nand;
  35860. +
  35861. + return 0;
  35862. +
  35863. +err_release_nand:
  35864. + nand_release(&rbni->mtd);
  35865. + return ret;
  35866. +}
  35867. +
  35868. +static int rb91x_nand_remove(struct platform_device *pdev)
  35869. +{
  35870. + struct rb91x_nand_info *info = platform_get_drvdata(pdev);
  35871. +
  35872. + nand_release(&info->mtd);
  35873. +
  35874. + return 0;
  35875. +}
  35876. +
  35877. +static struct platform_driver rb91x_nand_driver = {
  35878. + .probe = rb91x_nand_probe,
  35879. + .remove = rb91x_nand_remove,
  35880. + .driver = {
  35881. + .name = RB91X_NAND_DRIVER_NAME,
  35882. + .owner = THIS_MODULE,
  35883. + },
  35884. +};
  35885. +
  35886. +module_platform_driver(rb91x_nand_driver);
  35887. +
  35888. +MODULE_DESCRIPTION(DRV_DESC);
  35889. +MODULE_VERSION(DRV_VERSION);
  35890. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  35891. +MODULE_LICENSE("GPL v2");
  35892. diff -Nur linux-4.1.13.orig/drivers/mtd/redboot.c linux-4.1.13/drivers/mtd/redboot.c
  35893. --- linux-4.1.13.orig/drivers/mtd/redboot.c 2015-11-09 23:34:10.000000000 +0100
  35894. +++ linux-4.1.13/drivers/mtd/redboot.c 2015-12-04 19:57:03.870111690 +0100
  35895. @@ -76,12 +76,18 @@
  35896. static char nullstring[] = "unallocated";
  35897. #endif
  35898. + buf = vmalloc(master->erasesize);
  35899. + if (!buf)
  35900. + return -ENOMEM;
  35901. +
  35902. + restart:
  35903. if ( directory < 0 ) {
  35904. offset = master->size + directory * master->erasesize;
  35905. while (mtd_block_isbad(master, offset)) {
  35906. if (!offset) {
  35907. nogood:
  35908. printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
  35909. + vfree(buf);
  35910. return -EIO;
  35911. }
  35912. offset -= master->erasesize;
  35913. @@ -94,10 +100,6 @@
  35914. goto nogood;
  35915. }
  35916. }
  35917. - buf = vmalloc(master->erasesize);
  35918. -
  35919. - if (!buf)
  35920. - return -ENOMEM;
  35921. printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
  35922. master->name, offset);
  35923. @@ -170,6 +172,11 @@
  35924. }
  35925. if (i == numslots) {
  35926. /* Didn't find it */
  35927. + if (offset + master->erasesize < master->size) {
  35928. + /* not at the end of the flash yet, maybe next block :) */
  35929. + directory++;
  35930. + goto restart;
  35931. + }
  35932. printk(KERN_NOTICE "No RedBoot partition table detected in %s\n",
  35933. master->name);
  35934. ret = 0;
  35935. diff -Nur linux-4.1.13.orig/drivers/mtd/tplinkpart.c linux-4.1.13/drivers/mtd/tplinkpart.c
  35936. --- linux-4.1.13.orig/drivers/mtd/tplinkpart.c 1970-01-01 01:00:00.000000000 +0100
  35937. +++ linux-4.1.13/drivers/mtd/tplinkpart.c 2015-09-13 20:04:35.076523692 +0200
  35938. @@ -0,0 +1,222 @@
  35939. +/*
  35940. + * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
  35941. + *
  35942. + * This program is free software; you can redistribute it and/or modify it
  35943. + * under the terms of the GNU General Public License version 2 as published
  35944. + * by the Free Software Foundation.
  35945. + *
  35946. + */
  35947. +
  35948. +#include <linux/kernel.h>
  35949. +#include <linux/module.h>
  35950. +#include <linux/slab.h>
  35951. +#include <linux/vmalloc.h>
  35952. +#include <linux/magic.h>
  35953. +
  35954. +#include <linux/mtd/mtd.h>
  35955. +#include <linux/mtd/partitions.h>
  35956. +
  35957. +#define TPLINK_NUM_PARTS 5
  35958. +#define TPLINK_HEADER_V1 0x01000000
  35959. +#define TPLINK_HEADER_V2 0x02000000
  35960. +#define MD5SUM_LEN 16
  35961. +
  35962. +#define TPLINK_ART_LEN 0x10000
  35963. +#define TPLINK_KERNEL_OFFS 0x20000
  35964. +#define TPLINK_64K_KERNEL_OFFS 0x10000
  35965. +
  35966. +struct tplink_fw_header {
  35967. + uint32_t version; /* header version */
  35968. + char vendor_name[24];
  35969. + char fw_version[36];
  35970. + uint32_t hw_id; /* hardware id */
  35971. + uint32_t hw_rev; /* hardware revision */
  35972. + uint32_t unk1;
  35973. + uint8_t md5sum1[MD5SUM_LEN];
  35974. + uint32_t unk2;
  35975. + uint8_t md5sum2[MD5SUM_LEN];
  35976. + uint32_t unk3;
  35977. + uint32_t kernel_la; /* kernel load address */
  35978. + uint32_t kernel_ep; /* kernel entry point */
  35979. + uint32_t fw_length; /* total length of the firmware */
  35980. + uint32_t kernel_ofs; /* kernel data offset */
  35981. + uint32_t kernel_len; /* kernel data length */
  35982. + uint32_t rootfs_ofs; /* rootfs data offset */
  35983. + uint32_t rootfs_len; /* rootfs data length */
  35984. + uint32_t boot_ofs; /* bootloader data offset */
  35985. + uint32_t boot_len; /* bootloader data length */
  35986. + uint8_t pad[360];
  35987. +} __attribute__ ((packed));
  35988. +
  35989. +static struct tplink_fw_header *
  35990. +tplink_read_header(struct mtd_info *mtd, size_t offset)
  35991. +{
  35992. + struct tplink_fw_header *header;
  35993. + size_t header_len;
  35994. + size_t retlen;
  35995. + int ret;
  35996. + u32 t;
  35997. +
  35998. + header = vmalloc(sizeof(*header));
  35999. + if (!header)
  36000. + goto err;
  36001. +
  36002. + header_len = sizeof(struct tplink_fw_header);
  36003. + ret = mtd_read(mtd, offset, header_len, &retlen,
  36004. + (unsigned char *) header);
  36005. + if (ret)
  36006. + goto err_free_header;
  36007. +
  36008. + if (retlen != header_len)
  36009. + goto err_free_header;
  36010. +
  36011. + /* sanity checks */
  36012. + t = be32_to_cpu(header->version);
  36013. + if ((t != TPLINK_HEADER_V1) && (t != TPLINK_HEADER_V2))
  36014. + goto err_free_header;
  36015. +
  36016. + t = be32_to_cpu(header->kernel_ofs);
  36017. + if (t != header_len)
  36018. + goto err_free_header;
  36019. +
  36020. + return header;
  36021. +
  36022. +err_free_header:
  36023. + vfree(header);
  36024. +err:
  36025. + return NULL;
  36026. +}
  36027. +
  36028. +static int tplink_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
  36029. +{
  36030. + u32 magic;
  36031. + size_t retlen;
  36032. + int ret;
  36033. +
  36034. + ret = mtd_read(mtd, offset, sizeof(magic), &retlen,
  36035. + (unsigned char *) &magic);
  36036. + if (ret)
  36037. + return ret;
  36038. +
  36039. + if (retlen != sizeof(magic))
  36040. + return -EIO;
  36041. +
  36042. + if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
  36043. + magic != 0x19852003)
  36044. + return -EINVAL;
  36045. +
  36046. + return 0;
  36047. +}
  36048. +
  36049. +static int tplink_parse_partitions_offset(struct mtd_info *master,
  36050. + struct mtd_partition **pparts,
  36051. + struct mtd_part_parser_data *data,
  36052. + size_t offset)
  36053. +{
  36054. + struct mtd_partition *parts;
  36055. + struct tplink_fw_header *header;
  36056. + int nr_parts;
  36057. + size_t art_offset;
  36058. + size_t rootfs_offset;
  36059. + size_t squashfs_offset;
  36060. + int ret;
  36061. +
  36062. + nr_parts = TPLINK_NUM_PARTS;
  36063. + parts = kzalloc(nr_parts * sizeof(struct mtd_partition), GFP_KERNEL);
  36064. + if (!parts) {
  36065. + ret = -ENOMEM;
  36066. + goto err;
  36067. + }
  36068. +
  36069. + header = tplink_read_header(master, offset);
  36070. + if (!header) {
  36071. + pr_notice("%s: no TP-Link header found\n", master->name);
  36072. + ret = -ENODEV;
  36073. + goto err_free_parts;
  36074. + }
  36075. +
  36076. + squashfs_offset = offset + sizeof(struct tplink_fw_header) +
  36077. + be32_to_cpu(header->kernel_len);
  36078. +
  36079. + ret = tplink_check_rootfs_magic(master, squashfs_offset);
  36080. + if (ret == 0)
  36081. + rootfs_offset = squashfs_offset;
  36082. + else
  36083. + rootfs_offset = offset + be32_to_cpu(header->rootfs_ofs);
  36084. +
  36085. + art_offset = master->size - TPLINK_ART_LEN;
  36086. +
  36087. + parts[0].name = "u-boot";
  36088. + parts[0].offset = 0;
  36089. + parts[0].size = offset;
  36090. + parts[0].mask_flags = MTD_WRITEABLE;
  36091. +
  36092. + parts[1].name = "kernel";
  36093. + parts[1].offset = offset;
  36094. + parts[1].size = rootfs_offset - offset;
  36095. +
  36096. + parts[2].name = "rootfs";
  36097. + parts[2].offset = rootfs_offset;
  36098. + parts[2].size = art_offset - rootfs_offset;
  36099. +
  36100. + parts[3].name = "art";
  36101. + parts[3].offset = art_offset;
  36102. + parts[3].size = TPLINK_ART_LEN;
  36103. + parts[3].mask_flags = MTD_WRITEABLE;
  36104. +
  36105. + parts[4].name = "firmware";
  36106. + parts[4].offset = offset;
  36107. + parts[4].size = art_offset - offset;
  36108. +
  36109. + vfree(header);
  36110. +
  36111. + *pparts = parts;
  36112. + return nr_parts;
  36113. +
  36114. +err_free_parts:
  36115. + kfree(parts);
  36116. +err:
  36117. + *pparts = NULL;
  36118. + return ret;
  36119. +}
  36120. +
  36121. +static int tplink_parse_partitions(struct mtd_info *master,
  36122. + struct mtd_partition **pparts,
  36123. + struct mtd_part_parser_data *data)
  36124. +{
  36125. + return tplink_parse_partitions_offset(master, pparts, data,
  36126. + TPLINK_KERNEL_OFFS);
  36127. +}
  36128. +
  36129. +static int tplink_parse_64k_partitions(struct mtd_info *master,
  36130. + struct mtd_partition **pparts,
  36131. + struct mtd_part_parser_data *data)
  36132. +{
  36133. + return tplink_parse_partitions_offset(master, pparts, data,
  36134. + TPLINK_64K_KERNEL_OFFS);
  36135. +}
  36136. +
  36137. +static struct mtd_part_parser tplink_parser = {
  36138. + .owner = THIS_MODULE,
  36139. + .parse_fn = tplink_parse_partitions,
  36140. + .name = "tp-link",
  36141. +};
  36142. +
  36143. +static struct mtd_part_parser tplink_64k_parser = {
  36144. + .owner = THIS_MODULE,
  36145. + .parse_fn = tplink_parse_64k_partitions,
  36146. + .name = "tp-link-64k",
  36147. +};
  36148. +
  36149. +static int __init tplink_parser_init(void)
  36150. +{
  36151. + register_mtd_parser(&tplink_parser);
  36152. + register_mtd_parser(&tplink_64k_parser);
  36153. +
  36154. + return 0;
  36155. +}
  36156. +
  36157. +module_init(tplink_parser_init);
  36158. +
  36159. +MODULE_LICENSE("GPL v2");
  36160. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  36161. diff -Nur linux-4.1.13.orig/drivers/net/dsa/Kconfig linux-4.1.13/drivers/net/dsa/Kconfig
  36162. --- linux-4.1.13.orig/drivers/net/dsa/Kconfig 2015-11-09 23:34:10.000000000 +0100
  36163. +++ linux-4.1.13/drivers/net/dsa/Kconfig 2015-12-04 19:57:03.886110643 +0100
  36164. @@ -13,6 +13,13 @@
  36165. This enables support for the Marvell 88E6060 ethernet switch
  36166. chip.
  36167. +config NET_DSA_MV88E6063
  36168. + bool "Marvell 88E6063 ethernet switch chip support"
  36169. + select NET_DSA_TAG_TRAILER
  36170. + ---help---
  36171. + This enables support for the Marvell 88E6063 ethernet switch
  36172. + chip
  36173. +
  36174. config NET_DSA_MV88E6XXX_NEED_PPU
  36175. bool
  36176. default n
  36177. diff -Nur linux-4.1.13.orig/drivers/net/dsa/Makefile linux-4.1.13/drivers/net/dsa/Makefile
  36178. --- linux-4.1.13.orig/drivers/net/dsa/Makefile 2015-11-09 23:34:10.000000000 +0100
  36179. +++ linux-4.1.13/drivers/net/dsa/Makefile 2015-12-04 19:57:03.886110643 +0100
  36180. @@ -1,4 +1,5 @@
  36181. obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
  36182. +obj-$(CONFIG_NET_DSA_MV88E6063) += mv88e6063.o
  36183. obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
  36184. mv88e6xxx_drv-y += mv88e6xxx.o
  36185. ifdef CONFIG_NET_DSA_MV88E6123_61_65
  36186. diff -Nur linux-4.1.13.orig/drivers/net/dsa/mv88e6063.c linux-4.1.13/drivers/net/dsa/mv88e6063.c
  36187. --- linux-4.1.13.orig/drivers/net/dsa/mv88e6063.c 1970-01-01 01:00:00.000000000 +0100
  36188. +++ linux-4.1.13/drivers/net/dsa/mv88e6063.c 2015-09-13 20:04:35.076523692 +0200
  36189. @@ -0,0 +1,311 @@
  36190. +/*
  36191. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6063 switch chips
  36192. + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
  36193. + *
  36194. + * This driver was base on: net/dsa/mv88e6060.c
  36195. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6060 switch chips
  36196. + * Copyright (c) 2008-2009 Marvell Semiconductor
  36197. + *
  36198. + * This program is free software; you can redistribute it and/or modify
  36199. + * it under the terms of the GNU General Public License as published by
  36200. + * the Free Software Foundation; either version 2 of the License, or
  36201. + * (at your option) any later version.
  36202. + */
  36203. +
  36204. +#include <linux/version.h>
  36205. +#include <linux/list.h>
  36206. +#include <linux/netdevice.h>
  36207. +#include <linux/phy.h>
  36208. +#include <net/dsa.h>
  36209. +
  36210. +#define REG_BASE 0x10
  36211. +#define REG_PHY(p) (REG_BASE + (p))
  36212. +#define REG_PORT(p) (REG_BASE + 8 + (p))
  36213. +#define REG_GLOBAL (REG_BASE + 0x0f)
  36214. +#define NUM_PORTS 7
  36215. +
  36216. +static int reg_read(struct dsa_switch *ds, int addr, int reg)
  36217. +{
  36218. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
  36219. + return mdiobus_read(ds->master_mii_bus, addr, reg);
  36220. +#else
  36221. + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
  36222. + return mdiobus_read(bus, addr, reg);
  36223. +#endif
  36224. +}
  36225. +
  36226. +#define REG_READ(addr, reg) \
  36227. + ({ \
  36228. + int __ret; \
  36229. + \
  36230. + __ret = reg_read(ds, addr, reg); \
  36231. + if (__ret < 0) \
  36232. + return __ret; \
  36233. + __ret; \
  36234. + })
  36235. +
  36236. +
  36237. +static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
  36238. +{
  36239. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
  36240. + return mdiobus_write(ds->master_mii_bus, addr, reg, val);
  36241. +#else
  36242. + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
  36243. + return mdiobus_write(bus, addr, reg, val);
  36244. +#endif
  36245. +}
  36246. +
  36247. +#define REG_WRITE(addr, reg, val) \
  36248. + ({ \
  36249. + int __ret; \
  36250. + \
  36251. + __ret = reg_write(ds, addr, reg, val); \
  36252. + if (__ret < 0) \
  36253. + return __ret; \
  36254. + })
  36255. +
  36256. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
  36257. +static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
  36258. +{
  36259. +#else
  36260. +static char *mv88e6063_probe(struct device *host_dev, int sw_addr)
  36261. +{
  36262. + struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
  36263. +#endif
  36264. + int ret;
  36265. +
  36266. + ret = mdiobus_read(bus, REG_PORT(0), 0x03);
  36267. + if (ret >= 0) {
  36268. + ret &= 0xfff0;
  36269. + if (ret == 0x1530)
  36270. + return "Marvell 88E6063";
  36271. + }
  36272. +
  36273. + return NULL;
  36274. +}
  36275. +
  36276. +static int mv88e6063_switch_reset(struct dsa_switch *ds)
  36277. +{
  36278. + int i;
  36279. + int ret;
  36280. +
  36281. + /*
  36282. + * Set all ports to the disabled state.
  36283. + */
  36284. + for (i = 0; i < NUM_PORTS; i++) {
  36285. + ret = REG_READ(REG_PORT(i), 0x04);
  36286. + REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
  36287. + }
  36288. +
  36289. + /*
  36290. + * Wait for transmit queues to drain.
  36291. + */
  36292. + msleep(2);
  36293. +
  36294. + /*
  36295. + * Reset the switch.
  36296. + */
  36297. + REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
  36298. +
  36299. + /*
  36300. + * Wait up to one second for reset to complete.
  36301. + */
  36302. + for (i = 0; i < 1000; i++) {
  36303. + ret = REG_READ(REG_GLOBAL, 0x00);
  36304. + if ((ret & 0x8000) == 0x0000)
  36305. + break;
  36306. +
  36307. + msleep(1);
  36308. + }
  36309. + if (i == 1000)
  36310. + return -ETIMEDOUT;
  36311. +
  36312. + return 0;
  36313. +}
  36314. +
  36315. +static int mv88e6063_setup_global(struct dsa_switch *ds)
  36316. +{
  36317. + /*
  36318. + * Disable discarding of frames with excessive collisions,
  36319. + * set the maximum frame size to 1536 bytes, and mask all
  36320. + * interrupt sources.
  36321. + */
  36322. + REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
  36323. +
  36324. + /*
  36325. + * Enable automatic address learning, set the address
  36326. + * database size to 1024 entries, and set the default aging
  36327. + * time to 5 minutes.
  36328. + */
  36329. + REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
  36330. +
  36331. + return 0;
  36332. +}
  36333. +
  36334. +static int mv88e6063_setup_port(struct dsa_switch *ds, int p)
  36335. +{
  36336. + int addr = REG_PORT(p);
  36337. +
  36338. + /*
  36339. + * Do not force flow control, disable Ingress and Egress
  36340. + * Header tagging, disable VLAN tunneling, and set the port
  36341. + * state to Forwarding. Additionally, if this is the CPU
  36342. + * port, enable Ingress and Egress Trailer tagging mode.
  36343. + */
  36344. + REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ? 0x4103 : 0x0003);
  36345. +
  36346. + /*
  36347. + * Port based VLAN map: give each port its own address
  36348. + * database, allow the CPU port to talk to each of the 'real'
  36349. + * ports, and allow each of the 'real' ports to only talk to
  36350. + * the CPU port.
  36351. + */
  36352. + REG_WRITE(addr, 0x06,
  36353. + ((p & 0xf) << 12) |
  36354. + (dsa_is_cpu_port(ds, p) ?
  36355. + ds->phys_port_mask :
  36356. + (1 << ds->dst->cpu_port)));
  36357. +
  36358. + /*
  36359. + * Port Association Vector: when learning source addresses
  36360. + * of packets, add the address to the address database using
  36361. + * a port bitmap that has only the bit for this port set and
  36362. + * the other bits clear.
  36363. + */
  36364. + REG_WRITE(addr, 0x0b, 1 << p);
  36365. +
  36366. + return 0;
  36367. +}
  36368. +
  36369. +static int mv88e6063_setup(struct dsa_switch *ds)
  36370. +{
  36371. + int i;
  36372. + int ret;
  36373. +
  36374. + ret = mv88e6063_switch_reset(ds);
  36375. + if (ret < 0)
  36376. + return ret;
  36377. +
  36378. + /* @@@ initialise atu */
  36379. +
  36380. + ret = mv88e6063_setup_global(ds);
  36381. + if (ret < 0)
  36382. + return ret;
  36383. +
  36384. + for (i = 0; i < NUM_PORTS; i++) {
  36385. + ret = mv88e6063_setup_port(ds, i);
  36386. + if (ret < 0)
  36387. + return ret;
  36388. + }
  36389. +
  36390. + return 0;
  36391. +}
  36392. +
  36393. +static int mv88e6063_set_addr(struct dsa_switch *ds, u8 *addr)
  36394. +{
  36395. + REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
  36396. + REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
  36397. + REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);
  36398. +
  36399. + return 0;
  36400. +}
  36401. +
  36402. +static int mv88e6063_port_to_phy_addr(int port)
  36403. +{
  36404. + if (port >= 0 && port <= NUM_PORTS)
  36405. + return REG_PHY(port);
  36406. + return -1;
  36407. +}
  36408. +
  36409. +static int mv88e6063_phy_read(struct dsa_switch *ds, int port, int regnum)
  36410. +{
  36411. + int addr;
  36412. +
  36413. + addr = mv88e6063_port_to_phy_addr(port);
  36414. + if (addr == -1)
  36415. + return 0xffff;
  36416. +
  36417. + return reg_read(ds, addr, regnum);
  36418. +}
  36419. +
  36420. +static int
  36421. +mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
  36422. +{
  36423. + int addr;
  36424. +
  36425. + addr = mv88e6063_port_to_phy_addr(port);
  36426. + if (addr == -1)
  36427. + return 0xffff;
  36428. +
  36429. + return reg_write(ds, addr, regnum, val);
  36430. +}
  36431. +
  36432. +static void mv88e6063_poll_link(struct dsa_switch *ds)
  36433. +{
  36434. + int i;
  36435. +
  36436. + for (i = 0; i < DSA_MAX_PORTS; i++) {
  36437. + struct net_device *dev;
  36438. + int uninitialized_var(port_status);
  36439. + int link;
  36440. + int speed;
  36441. + int duplex;
  36442. + int fc;
  36443. +
  36444. + dev = ds->ports[i];
  36445. + if (dev == NULL)
  36446. + continue;
  36447. +
  36448. + link = 0;
  36449. + if (dev->flags & IFF_UP) {
  36450. + port_status = reg_read(ds, REG_PORT(i), 0x00);
  36451. + if (port_status < 0)
  36452. + continue;
  36453. +
  36454. + link = !!(port_status & 0x1000);
  36455. + }
  36456. +
  36457. + if (!link) {
  36458. + if (netif_carrier_ok(dev)) {
  36459. + printk(KERN_INFO "%s: link down\n", dev->name);
  36460. + netif_carrier_off(dev);
  36461. + }
  36462. + continue;
  36463. + }
  36464. +
  36465. + speed = (port_status & 0x0100) ? 100 : 10;
  36466. + duplex = (port_status & 0x0200) ? 1 : 0;
  36467. + fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
  36468. +
  36469. + if (!netif_carrier_ok(dev)) {
  36470. + printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
  36471. + "flow control %sabled\n", dev->name,
  36472. + speed, duplex ? "full" : "half",
  36473. + fc ? "en" : "dis");
  36474. + netif_carrier_on(dev);
  36475. + }
  36476. + }
  36477. +}
  36478. +
  36479. +static struct dsa_switch_driver mv88e6063_switch_driver = {
  36480. + .tag_protocol = htons(ETH_P_TRAILER),
  36481. + .probe = mv88e6063_probe,
  36482. + .setup = mv88e6063_setup,
  36483. + .set_addr = mv88e6063_set_addr,
  36484. + .phy_read = mv88e6063_phy_read,
  36485. + .phy_write = mv88e6063_phy_write,
  36486. + .poll_link = mv88e6063_poll_link,
  36487. +};
  36488. +
  36489. +static int __init mv88e6063_init(void)
  36490. +{
  36491. + register_switch_driver(&mv88e6063_switch_driver);
  36492. + return 0;
  36493. +}
  36494. +module_init(mv88e6063_init);
  36495. +
  36496. +static void __exit mv88e6063_cleanup(void)
  36497. +{
  36498. + unregister_switch_driver(&mv88e6063_switch_driver);
  36499. +}
  36500. +module_exit(mv88e6063_cleanup);
  36501. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
  36502. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c 1970-01-01 01:00:00.000000000 +0100
  36503. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c 2015-09-13 20:04:35.076523692 +0200
  36504. @@ -0,0 +1,1229 @@
  36505. +/*
  36506. + * Driver for the built-in ethernet switch of the Atheros AR7240 SoC
  36507. + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
  36508. + * Copyright (c) 2010 Felix Fietkau <nbd@openwrt.org>
  36509. + *
  36510. + * This program is free software; you can redistribute it and/or modify it
  36511. + * under the terms of the GNU General Public License version 2 as published
  36512. + * by the Free Software Foundation.
  36513. + *
  36514. + */
  36515. +
  36516. +#include <linux/etherdevice.h>
  36517. +#include <linux/list.h>
  36518. +#include <linux/netdevice.h>
  36519. +#include <linux/phy.h>
  36520. +#include <linux/mii.h>
  36521. +#include <linux/bitops.h>
  36522. +#include <linux/switch.h>
  36523. +#include "ag71xx.h"
  36524. +
  36525. +#define BITM(_count) (BIT(_count) - 1)
  36526. +#define BITS(_shift, _count) (BITM(_count) << _shift)
  36527. +
  36528. +#define AR7240_REG_MASK_CTRL 0x00
  36529. +#define AR7240_MASK_CTRL_REVISION_M BITM(8)
  36530. +#define AR7240_MASK_CTRL_VERSION_M BITM(8)
  36531. +#define AR7240_MASK_CTRL_VERSION_S 8
  36532. +#define AR7240_MASK_CTRL_VERSION_AR7240 0x01
  36533. +#define AR7240_MASK_CTRL_VERSION_AR934X 0x02
  36534. +#define AR7240_MASK_CTRL_SOFT_RESET BIT(31)
  36535. +
  36536. +#define AR7240_REG_MAC_ADDR0 0x20
  36537. +#define AR7240_REG_MAC_ADDR1 0x24
  36538. +
  36539. +#define AR7240_REG_FLOOD_MASK 0x2c
  36540. +#define AR7240_FLOOD_MASK_BROAD_TO_CPU BIT(26)
  36541. +
  36542. +#define AR7240_REG_GLOBAL_CTRL 0x30
  36543. +#define AR7240_GLOBAL_CTRL_MTU_M BITM(11)
  36544. +#define AR9340_GLOBAL_CTRL_MTU_M BITM(14)
  36545. +
  36546. +#define AR7240_REG_VTU 0x0040
  36547. +#define AR7240_VTU_OP BITM(3)
  36548. +#define AR7240_VTU_OP_NOOP 0x0
  36549. +#define AR7240_VTU_OP_FLUSH 0x1
  36550. +#define AR7240_VTU_OP_LOAD 0x2
  36551. +#define AR7240_VTU_OP_PURGE 0x3
  36552. +#define AR7240_VTU_OP_REMOVE_PORT 0x4
  36553. +#define AR7240_VTU_ACTIVE BIT(3)
  36554. +#define AR7240_VTU_FULL BIT(4)
  36555. +#define AR7240_VTU_PORT BITS(8, 4)
  36556. +#define AR7240_VTU_PORT_S 8
  36557. +#define AR7240_VTU_VID BITS(16, 12)
  36558. +#define AR7240_VTU_VID_S 16
  36559. +#define AR7240_VTU_PRIO BITS(28, 3)
  36560. +#define AR7240_VTU_PRIO_S 28
  36561. +#define AR7240_VTU_PRIO_EN BIT(31)
  36562. +
  36563. +#define AR7240_REG_VTU_DATA 0x0044
  36564. +#define AR7240_VTUDATA_MEMBER BITS(0, 10)
  36565. +#define AR7240_VTUDATA_VALID BIT(11)
  36566. +
  36567. +#define AR7240_REG_ATU 0x50
  36568. +#define AR7240_ATU_FLUSH_ALL 0x1
  36569. +
  36570. +#define AR7240_REG_AT_CTRL 0x5c
  36571. +#define AR7240_AT_CTRL_AGE_TIME BITS(0, 15)
  36572. +#define AR7240_AT_CTRL_AGE_EN BIT(17)
  36573. +#define AR7240_AT_CTRL_LEARN_CHANGE BIT(18)
  36574. +#define AR7240_AT_CTRL_RESERVED BIT(19)
  36575. +#define AR7240_AT_CTRL_ARP_EN BIT(20)
  36576. +
  36577. +#define AR7240_REG_TAG_PRIORITY 0x70
  36578. +
  36579. +#define AR7240_REG_SERVICE_TAG 0x74
  36580. +#define AR7240_SERVICE_TAG_M BITM(16)
  36581. +
  36582. +#define AR7240_REG_CPU_PORT 0x78
  36583. +#define AR7240_MIRROR_PORT_S 4
  36584. +#define AR7240_CPU_PORT_EN BIT(8)
  36585. +
  36586. +#define AR7240_REG_MIB_FUNCTION0 0x80
  36587. +#define AR7240_MIB_TIMER_M BITM(16)
  36588. +#define AR7240_MIB_AT_HALF_EN BIT(16)
  36589. +#define AR7240_MIB_BUSY BIT(17)
  36590. +#define AR7240_MIB_FUNC_S 24
  36591. +#define AR7240_MIB_FUNC_M BITM(3)
  36592. +#define AR7240_MIB_FUNC_NO_OP 0x0
  36593. +#define AR7240_MIB_FUNC_FLUSH 0x1
  36594. +#define AR7240_MIB_FUNC_CAPTURE 0x3
  36595. +
  36596. +#define AR7240_REG_MDIO_CTRL 0x98
  36597. +#define AR7240_MDIO_CTRL_DATA_M BITM(16)
  36598. +#define AR7240_MDIO_CTRL_REG_ADDR_S 16
  36599. +#define AR7240_MDIO_CTRL_PHY_ADDR_S 21
  36600. +#define AR7240_MDIO_CTRL_CMD_WRITE 0
  36601. +#define AR7240_MDIO_CTRL_CMD_READ BIT(27)
  36602. +#define AR7240_MDIO_CTRL_MASTER_EN BIT(30)
  36603. +#define AR7240_MDIO_CTRL_BUSY BIT(31)
  36604. +
  36605. +#define AR7240_REG_PORT_BASE(_port) (0x100 + (_port) * 0x100)
  36606. +
  36607. +#define AR7240_REG_PORT_STATUS(_port) (AR7240_REG_PORT_BASE((_port)) + 0x00)
  36608. +#define AR7240_PORT_STATUS_SPEED_S 0
  36609. +#define AR7240_PORT_STATUS_SPEED_M BITM(2)
  36610. +#define AR7240_PORT_STATUS_SPEED_10 0
  36611. +#define AR7240_PORT_STATUS_SPEED_100 1
  36612. +#define AR7240_PORT_STATUS_SPEED_1000 2
  36613. +#define AR7240_PORT_STATUS_TXMAC BIT(2)
  36614. +#define AR7240_PORT_STATUS_RXMAC BIT(3)
  36615. +#define AR7240_PORT_STATUS_TXFLOW BIT(4)
  36616. +#define AR7240_PORT_STATUS_RXFLOW BIT(5)
  36617. +#define AR7240_PORT_STATUS_DUPLEX BIT(6)
  36618. +#define AR7240_PORT_STATUS_LINK_UP BIT(8)
  36619. +#define AR7240_PORT_STATUS_LINK_AUTO BIT(9)
  36620. +#define AR7240_PORT_STATUS_LINK_PAUSE BIT(10)
  36621. +
  36622. +#define AR7240_REG_PORT_CTRL(_port) (AR7240_REG_PORT_BASE((_port)) + 0x04)
  36623. +#define AR7240_PORT_CTRL_STATE_M BITM(3)
  36624. +#define AR7240_PORT_CTRL_STATE_DISABLED 0
  36625. +#define AR7240_PORT_CTRL_STATE_BLOCK 1
  36626. +#define AR7240_PORT_CTRL_STATE_LISTEN 2
  36627. +#define AR7240_PORT_CTRL_STATE_LEARN 3
  36628. +#define AR7240_PORT_CTRL_STATE_FORWARD 4
  36629. +#define AR7240_PORT_CTRL_LEARN_LOCK BIT(7)
  36630. +#define AR7240_PORT_CTRL_VLAN_MODE_S 8
  36631. +#define AR7240_PORT_CTRL_VLAN_MODE_KEEP 0
  36632. +#define AR7240_PORT_CTRL_VLAN_MODE_STRIP 1
  36633. +#define AR7240_PORT_CTRL_VLAN_MODE_ADD 2
  36634. +#define AR7240_PORT_CTRL_VLAN_MODE_DOUBLE_TAG 3
  36635. +#define AR7240_PORT_CTRL_IGMP_SNOOP BIT(10)
  36636. +#define AR7240_PORT_CTRL_HEADER BIT(11)
  36637. +#define AR7240_PORT_CTRL_MAC_LOOP BIT(12)
  36638. +#define AR7240_PORT_CTRL_SINGLE_VLAN BIT(13)
  36639. +#define AR7240_PORT_CTRL_LEARN BIT(14)
  36640. +#define AR7240_PORT_CTRL_DOUBLE_TAG BIT(15)
  36641. +#define AR7240_PORT_CTRL_MIRROR_TX BIT(16)
  36642. +#define AR7240_PORT_CTRL_MIRROR_RX BIT(17)
  36643. +
  36644. +#define AR7240_REG_PORT_VLAN(_port) (AR7240_REG_PORT_BASE((_port)) + 0x08)
  36645. +
  36646. +#define AR7240_PORT_VLAN_DEFAULT_ID_S 0
  36647. +#define AR7240_PORT_VLAN_DEST_PORTS_S 16
  36648. +#define AR7240_PORT_VLAN_MODE_S 30
  36649. +#define AR7240_PORT_VLAN_MODE_PORT_ONLY 0
  36650. +#define AR7240_PORT_VLAN_MODE_PORT_FALLBACK 1
  36651. +#define AR7240_PORT_VLAN_MODE_VLAN_ONLY 2
  36652. +#define AR7240_PORT_VLAN_MODE_SECURE 3
  36653. +
  36654. +
  36655. +#define AR7240_REG_STATS_BASE(_port) (0x20000 + (_port) * 0x100)
  36656. +
  36657. +#define AR7240_STATS_RXBROAD 0x00
  36658. +#define AR7240_STATS_RXPAUSE 0x04
  36659. +#define AR7240_STATS_RXMULTI 0x08
  36660. +#define AR7240_STATS_RXFCSERR 0x0c
  36661. +#define AR7240_STATS_RXALIGNERR 0x10
  36662. +#define AR7240_STATS_RXRUNT 0x14
  36663. +#define AR7240_STATS_RXFRAGMENT 0x18
  36664. +#define AR7240_STATS_RX64BYTE 0x1c
  36665. +#define AR7240_STATS_RX128BYTE 0x20
  36666. +#define AR7240_STATS_RX256BYTE 0x24
  36667. +#define AR7240_STATS_RX512BYTE 0x28
  36668. +#define AR7240_STATS_RX1024BYTE 0x2c
  36669. +#define AR7240_STATS_RX1518BYTE 0x30
  36670. +#define AR7240_STATS_RXMAXBYTE 0x34
  36671. +#define AR7240_STATS_RXTOOLONG 0x38
  36672. +#define AR7240_STATS_RXGOODBYTE 0x3c
  36673. +#define AR7240_STATS_RXBADBYTE 0x44
  36674. +#define AR7240_STATS_RXOVERFLOW 0x4c
  36675. +#define AR7240_STATS_FILTERED 0x50
  36676. +#define AR7240_STATS_TXBROAD 0x54
  36677. +#define AR7240_STATS_TXPAUSE 0x58
  36678. +#define AR7240_STATS_TXMULTI 0x5c
  36679. +#define AR7240_STATS_TXUNDERRUN 0x60
  36680. +#define AR7240_STATS_TX64BYTE 0x64
  36681. +#define AR7240_STATS_TX128BYTE 0x68
  36682. +#define AR7240_STATS_TX256BYTE 0x6c
  36683. +#define AR7240_STATS_TX512BYTE 0x70
  36684. +#define AR7240_STATS_TX1024BYTE 0x74
  36685. +#define AR7240_STATS_TX1518BYTE 0x78
  36686. +#define AR7240_STATS_TXMAXBYTE 0x7c
  36687. +#define AR7240_STATS_TXOVERSIZE 0x80
  36688. +#define AR7240_STATS_TXBYTE 0x84
  36689. +#define AR7240_STATS_TXCOLLISION 0x8c
  36690. +#define AR7240_STATS_TXABORTCOL 0x90
  36691. +#define AR7240_STATS_TXMULTICOL 0x94
  36692. +#define AR7240_STATS_TXSINGLECOL 0x98
  36693. +#define AR7240_STATS_TXEXCDEFER 0x9c
  36694. +#define AR7240_STATS_TXDEFER 0xa0
  36695. +#define AR7240_STATS_TXLATECOL 0xa4
  36696. +
  36697. +#define AR7240_PORT_CPU 0
  36698. +#define AR7240_NUM_PORTS 6
  36699. +#define AR7240_NUM_PHYS 5
  36700. +
  36701. +#define AR7240_PHY_ID1 0x004d
  36702. +#define AR7240_PHY_ID2 0xd041
  36703. +
  36704. +#define AR934X_PHY_ID1 0x004d
  36705. +#define AR934X_PHY_ID2 0xd042
  36706. +
  36707. +#define AR7240_MAX_VLANS 16
  36708. +
  36709. +#define AR934X_REG_OPER_MODE0 0x04
  36710. +#define AR934X_OPER_MODE0_MAC_GMII_EN BIT(6)
  36711. +#define AR934X_OPER_MODE0_PHY_MII_EN BIT(10)
  36712. +
  36713. +#define AR934X_REG_OPER_MODE1 0x08
  36714. +#define AR934X_REG_OPER_MODE1_PHY4_MII_EN BIT(28)
  36715. +
  36716. +#define AR934X_REG_FLOOD_MASK 0x2c
  36717. +#define AR934X_FLOOD_MASK_MC_DP(_p) BIT(16 + (_p))
  36718. +#define AR934X_FLOOD_MASK_BC_DP(_p) BIT(25 + (_p))
  36719. +
  36720. +#define AR934X_REG_QM_CTRL 0x3c
  36721. +#define AR934X_QM_CTRL_ARP_EN BIT(15)
  36722. +
  36723. +#define AR934X_REG_AT_CTRL 0x5c
  36724. +#define AR934X_AT_CTRL_AGE_TIME BITS(0, 15)
  36725. +#define AR934X_AT_CTRL_AGE_EN BIT(17)
  36726. +#define AR934X_AT_CTRL_LEARN_CHANGE BIT(18)
  36727. +
  36728. +#define AR934X_MIB_ENABLE BIT(30)
  36729. +
  36730. +#define AR934X_REG_PORT_BASE(_port) (0x100 + (_port) * 0x100)
  36731. +
  36732. +#define AR934X_REG_PORT_VLAN1(_port) (AR934X_REG_PORT_BASE((_port)) + 0x08)
  36733. +#define AR934X_PORT_VLAN1_DEFAULT_SVID_S 0
  36734. +#define AR934X_PORT_VLAN1_FORCE_DEFAULT_VID_EN BIT(12)
  36735. +#define AR934X_PORT_VLAN1_PORT_TLS_MODE BIT(13)
  36736. +#define AR934X_PORT_VLAN1_PORT_VLAN_PROP_EN BIT(14)
  36737. +#define AR934X_PORT_VLAN1_PORT_CLONE_EN BIT(15)
  36738. +#define AR934X_PORT_VLAN1_DEFAULT_CVID_S 16
  36739. +#define AR934X_PORT_VLAN1_FORCE_PORT_VLAN_EN BIT(28)
  36740. +#define AR934X_PORT_VLAN1_ING_PORT_PRI_S 29
  36741. +
  36742. +#define AR934X_REG_PORT_VLAN2(_port) (AR934X_REG_PORT_BASE((_port)) + 0x0c)
  36743. +#define AR934X_PORT_VLAN2_PORT_VID_MEM_S 16
  36744. +#define AR934X_PORT_VLAN2_8021Q_MODE_S 30
  36745. +#define AR934X_PORT_VLAN2_8021Q_MODE_PORT_ONLY 0
  36746. +#define AR934X_PORT_VLAN2_8021Q_MODE_PORT_FALLBACK 1
  36747. +#define AR934X_PORT_VLAN2_8021Q_MODE_VLAN_ONLY 2
  36748. +#define AR934X_PORT_VLAN2_8021Q_MODE_SECURE 3
  36749. +
  36750. +#define sw_to_ar7240(_dev) container_of(_dev, struct ar7240sw, swdev)
  36751. +
  36752. +struct ar7240sw_port_stat {
  36753. + unsigned long rx_broadcast;
  36754. + unsigned long rx_pause;
  36755. + unsigned long rx_multicast;
  36756. + unsigned long rx_fcs_error;
  36757. + unsigned long rx_align_error;
  36758. + unsigned long rx_runt;
  36759. + unsigned long rx_fragments;
  36760. + unsigned long rx_64byte;
  36761. + unsigned long rx_128byte;
  36762. + unsigned long rx_256byte;
  36763. + unsigned long rx_512byte;
  36764. + unsigned long rx_1024byte;
  36765. + unsigned long rx_1518byte;
  36766. + unsigned long rx_maxbyte;
  36767. + unsigned long rx_toolong;
  36768. + unsigned long rx_good_byte;
  36769. + unsigned long rx_bad_byte;
  36770. + unsigned long rx_overflow;
  36771. + unsigned long filtered;
  36772. +
  36773. + unsigned long tx_broadcast;
  36774. + unsigned long tx_pause;
  36775. + unsigned long tx_multicast;
  36776. + unsigned long tx_underrun;
  36777. + unsigned long tx_64byte;
  36778. + unsigned long tx_128byte;
  36779. + unsigned long tx_256byte;
  36780. + unsigned long tx_512byte;
  36781. + unsigned long tx_1024byte;
  36782. + unsigned long tx_1518byte;
  36783. + unsigned long tx_maxbyte;
  36784. + unsigned long tx_oversize;
  36785. + unsigned long tx_byte;
  36786. + unsigned long tx_collision;
  36787. + unsigned long tx_abortcol;
  36788. + unsigned long tx_multicol;
  36789. + unsigned long tx_singlecol;
  36790. + unsigned long tx_excdefer;
  36791. + unsigned long tx_defer;
  36792. + unsigned long tx_xlatecol;
  36793. +};
  36794. +
  36795. +struct ar7240sw {
  36796. + struct mii_bus *mii_bus;
  36797. + struct ag71xx_switch_platform_data *swdata;
  36798. + struct switch_dev swdev;
  36799. + int num_ports;
  36800. + u8 ver;
  36801. + bool vlan;
  36802. + u16 vlan_id[AR7240_MAX_VLANS];
  36803. + u8 vlan_table[AR7240_MAX_VLANS];
  36804. + u8 vlan_tagged;
  36805. + u16 pvid[AR7240_NUM_PORTS];
  36806. + char buf[80];
  36807. +
  36808. + rwlock_t stats_lock;
  36809. + struct ar7240sw_port_stat port_stats[AR7240_NUM_PORTS];
  36810. +};
  36811. +
  36812. +struct ar7240sw_hw_stat {
  36813. + char string[ETH_GSTRING_LEN];
  36814. + int sizeof_stat;
  36815. + int reg;
  36816. +};
  36817. +
  36818. +static DEFINE_MUTEX(reg_mutex);
  36819. +
  36820. +static inline int sw_is_ar7240(struct ar7240sw *as)
  36821. +{
  36822. + return as->ver == AR7240_MASK_CTRL_VERSION_AR7240;
  36823. +}
  36824. +
  36825. +static inline int sw_is_ar934x(struct ar7240sw *as)
  36826. +{
  36827. + return as->ver == AR7240_MASK_CTRL_VERSION_AR934X;
  36828. +}
  36829. +
  36830. +static inline u32 ar7240sw_port_mask(struct ar7240sw *as, int port)
  36831. +{
  36832. + return BIT(port);
  36833. +}
  36834. +
  36835. +static inline u32 ar7240sw_port_mask_all(struct ar7240sw *as)
  36836. +{
  36837. + return BIT(as->swdev.ports) - 1;
  36838. +}
  36839. +
  36840. +static inline u32 ar7240sw_port_mask_but(struct ar7240sw *as, int port)
  36841. +{
  36842. + return ar7240sw_port_mask_all(as) & ~BIT(port);
  36843. +}
  36844. +
  36845. +static inline u16 mk_phy_addr(u32 reg)
  36846. +{
  36847. + return 0x17 & ((reg >> 4) | 0x10);
  36848. +}
  36849. +
  36850. +static inline u16 mk_phy_reg(u32 reg)
  36851. +{
  36852. + return (reg << 1) & 0x1e;
  36853. +}
  36854. +
  36855. +static inline u16 mk_high_addr(u32 reg)
  36856. +{
  36857. + return (reg >> 7) & 0x1ff;
  36858. +}
  36859. +
  36860. +static u32 __ar7240sw_reg_read(struct mii_bus *mii, u32 reg)
  36861. +{
  36862. + unsigned long flags;
  36863. + u16 phy_addr;
  36864. + u16 phy_reg;
  36865. + u32 hi, lo;
  36866. +
  36867. + reg = (reg & 0xfffffffc) >> 2;
  36868. + phy_addr = mk_phy_addr(reg);
  36869. + phy_reg = mk_phy_reg(reg);
  36870. +
  36871. + local_irq_save(flags);
  36872. + ag71xx_mdio_mii_write(mii->priv, 0x1f, 0x10, mk_high_addr(reg));
  36873. + lo = (u32) ag71xx_mdio_mii_read(mii->priv, phy_addr, phy_reg);
  36874. + hi = (u32) ag71xx_mdio_mii_read(mii->priv, phy_addr, phy_reg + 1);
  36875. + local_irq_restore(flags);
  36876. +
  36877. + return (hi << 16) | lo;
  36878. +}
  36879. +
  36880. +static void __ar7240sw_reg_write(struct mii_bus *mii, u32 reg, u32 val)
  36881. +{
  36882. + unsigned long flags;
  36883. + u16 phy_addr;
  36884. + u16 phy_reg;
  36885. +
  36886. + reg = (reg & 0xfffffffc) >> 2;
  36887. + phy_addr = mk_phy_addr(reg);
  36888. + phy_reg = mk_phy_reg(reg);
  36889. +
  36890. + local_irq_save(flags);
  36891. + ag71xx_mdio_mii_write(mii->priv, 0x1f, 0x10, mk_high_addr(reg));
  36892. + ag71xx_mdio_mii_write(mii->priv, phy_addr, phy_reg + 1, (val >> 16));
  36893. + ag71xx_mdio_mii_write(mii->priv, phy_addr, phy_reg, (val & 0xffff));
  36894. + local_irq_restore(flags);
  36895. +}
  36896. +
  36897. +static u32 ar7240sw_reg_read(struct mii_bus *mii, u32 reg_addr)
  36898. +{
  36899. + u32 ret;
  36900. +
  36901. + mutex_lock(&reg_mutex);
  36902. + ret = __ar7240sw_reg_read(mii, reg_addr);
  36903. + mutex_unlock(&reg_mutex);
  36904. +
  36905. + return ret;
  36906. +}
  36907. +
  36908. +static void ar7240sw_reg_write(struct mii_bus *mii, u32 reg_addr, u32 reg_val)
  36909. +{
  36910. + mutex_lock(&reg_mutex);
  36911. + __ar7240sw_reg_write(mii, reg_addr, reg_val);
  36912. + mutex_unlock(&reg_mutex);
  36913. +}
  36914. +
  36915. +static u32 ar7240sw_reg_rmw(struct mii_bus *mii, u32 reg, u32 mask, u32 val)
  36916. +{
  36917. + u32 t;
  36918. +
  36919. + mutex_lock(&reg_mutex);
  36920. + t = __ar7240sw_reg_read(mii, reg);
  36921. + t &= ~mask;
  36922. + t |= val;
  36923. + __ar7240sw_reg_write(mii, reg, t);
  36924. + mutex_unlock(&reg_mutex);
  36925. +
  36926. + return t;
  36927. +}
  36928. +
  36929. +static void ar7240sw_reg_set(struct mii_bus *mii, u32 reg, u32 val)
  36930. +{
  36931. + u32 t;
  36932. +
  36933. + mutex_lock(&reg_mutex);
  36934. + t = __ar7240sw_reg_read(mii, reg);
  36935. + t |= val;
  36936. + __ar7240sw_reg_write(mii, reg, t);
  36937. + mutex_unlock(&reg_mutex);
  36938. +}
  36939. +
  36940. +static int __ar7240sw_reg_wait(struct mii_bus *mii, u32 reg, u32 mask, u32 val,
  36941. + unsigned timeout)
  36942. +{
  36943. + int i;
  36944. +
  36945. + for (i = 0; i < timeout; i++) {
  36946. + u32 t;
  36947. +
  36948. + t = __ar7240sw_reg_read(mii, reg);
  36949. + if ((t & mask) == val)
  36950. + return 0;
  36951. +
  36952. + usleep_range(1000, 2000);
  36953. + }
  36954. +
  36955. + return -ETIMEDOUT;
  36956. +}
  36957. +
  36958. +static int ar7240sw_reg_wait(struct mii_bus *mii, u32 reg, u32 mask, u32 val,
  36959. + unsigned timeout)
  36960. +{
  36961. + int ret;
  36962. +
  36963. + mutex_lock(&reg_mutex);
  36964. + ret = __ar7240sw_reg_wait(mii, reg, mask, val, timeout);
  36965. + mutex_unlock(&reg_mutex);
  36966. + return ret;
  36967. +}
  36968. +
  36969. +u16 ar7240sw_phy_read(struct mii_bus *mii, unsigned phy_addr,
  36970. + unsigned reg_addr)
  36971. +{
  36972. + u32 t, val = 0xffff;
  36973. + int err;
  36974. +
  36975. + if (phy_addr >= AR7240_NUM_PHYS)
  36976. + return 0xffff;
  36977. +
  36978. + mutex_lock(&reg_mutex);
  36979. + t = (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
  36980. + (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
  36981. + AR7240_MDIO_CTRL_MASTER_EN |
  36982. + AR7240_MDIO_CTRL_BUSY |
  36983. + AR7240_MDIO_CTRL_CMD_READ;
  36984. +
  36985. + __ar7240sw_reg_write(mii, AR7240_REG_MDIO_CTRL, t);
  36986. + err = __ar7240sw_reg_wait(mii, AR7240_REG_MDIO_CTRL,
  36987. + AR7240_MDIO_CTRL_BUSY, 0, 5);
  36988. + if (!err)
  36989. + val = __ar7240sw_reg_read(mii, AR7240_REG_MDIO_CTRL);
  36990. + mutex_unlock(&reg_mutex);
  36991. +
  36992. + return val & AR7240_MDIO_CTRL_DATA_M;
  36993. +}
  36994. +
  36995. +int ar7240sw_phy_write(struct mii_bus *mii, unsigned phy_addr,
  36996. + unsigned reg_addr, u16 reg_val)
  36997. +{
  36998. + u32 t;
  36999. + int ret;
  37000. +
  37001. + if (phy_addr >= AR7240_NUM_PHYS)
  37002. + return -EINVAL;
  37003. +
  37004. + mutex_lock(&reg_mutex);
  37005. + t = (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
  37006. + (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
  37007. + AR7240_MDIO_CTRL_MASTER_EN |
  37008. + AR7240_MDIO_CTRL_BUSY |
  37009. + AR7240_MDIO_CTRL_CMD_WRITE |
  37010. + reg_val;
  37011. +
  37012. + __ar7240sw_reg_write(mii, AR7240_REG_MDIO_CTRL, t);
  37013. + ret = __ar7240sw_reg_wait(mii, AR7240_REG_MDIO_CTRL,
  37014. + AR7240_MDIO_CTRL_BUSY, 0, 5);
  37015. + mutex_unlock(&reg_mutex);
  37016. +
  37017. + return ret;
  37018. +}
  37019. +
  37020. +static int ar7240sw_capture_stats(struct ar7240sw *as)
  37021. +{
  37022. + struct mii_bus *mii = as->mii_bus;
  37023. + int port;
  37024. + int ret;
  37025. +
  37026. + write_lock(&as->stats_lock);
  37027. +
  37028. + /* Capture the hardware statistics for all ports */
  37029. + ar7240sw_reg_rmw(mii, AR7240_REG_MIB_FUNCTION0,
  37030. + (AR7240_MIB_FUNC_M << AR7240_MIB_FUNC_S),
  37031. + (AR7240_MIB_FUNC_CAPTURE << AR7240_MIB_FUNC_S));
  37032. +
  37033. + /* Wait for the capturing to complete. */
  37034. + ret = ar7240sw_reg_wait(mii, AR7240_REG_MIB_FUNCTION0,
  37035. + AR7240_MIB_BUSY, 0, 10);
  37036. +
  37037. + if (ret)
  37038. + goto unlock;
  37039. +
  37040. + for (port = 0; port < AR7240_NUM_PORTS; port++) {
  37041. + unsigned int base;
  37042. + struct ar7240sw_port_stat *stats;
  37043. +
  37044. + base = AR7240_REG_STATS_BASE(port);
  37045. + stats = &as->port_stats[port];
  37046. +
  37047. +#define READ_STAT(_r) ar7240sw_reg_read(mii, base + AR7240_STATS_ ## _r)
  37048. +
  37049. + stats->rx_good_byte += READ_STAT(RXGOODBYTE);
  37050. + stats->tx_byte += READ_STAT(TXBYTE);
  37051. +
  37052. +#undef READ_STAT
  37053. + }
  37054. +
  37055. + ret = 0;
  37056. +
  37057. +unlock:
  37058. + write_unlock(&as->stats_lock);
  37059. + return ret;
  37060. +}
  37061. +
  37062. +static void ar7240sw_disable_port(struct ar7240sw *as, unsigned port)
  37063. +{
  37064. + ar7240sw_reg_write(as->mii_bus, AR7240_REG_PORT_CTRL(port),
  37065. + AR7240_PORT_CTRL_STATE_DISABLED);
  37066. +}
  37067. +
  37068. +static void ar7240sw_setup(struct ar7240sw *as)
  37069. +{
  37070. + struct mii_bus *mii = as->mii_bus;
  37071. +
  37072. + /* Enable CPU port, and disable mirror port */
  37073. + ar7240sw_reg_write(mii, AR7240_REG_CPU_PORT,
  37074. + AR7240_CPU_PORT_EN |
  37075. + (15 << AR7240_MIRROR_PORT_S));
  37076. +
  37077. + /* Setup TAG priority mapping */
  37078. + ar7240sw_reg_write(mii, AR7240_REG_TAG_PRIORITY, 0xfa50);
  37079. +
  37080. + if (sw_is_ar934x(as)) {
  37081. + /* Enable aging, MAC replacing */
  37082. + ar7240sw_reg_write(mii, AR934X_REG_AT_CTRL,
  37083. + 0x2b /* 5 min age time */ |
  37084. + AR934X_AT_CTRL_AGE_EN |
  37085. + AR934X_AT_CTRL_LEARN_CHANGE);
  37086. + /* Enable ARP frame acknowledge */
  37087. + ar7240sw_reg_set(mii, AR934X_REG_QM_CTRL,
  37088. + AR934X_QM_CTRL_ARP_EN);
  37089. + /* Enable Broadcast/Multicast frames transmitted to the CPU */
  37090. + ar7240sw_reg_set(mii, AR934X_REG_FLOOD_MASK,
  37091. + AR934X_FLOOD_MASK_BC_DP(0) |
  37092. + AR934X_FLOOD_MASK_MC_DP(0));
  37093. +
  37094. + /* setup MTU */
  37095. + ar7240sw_reg_rmw(mii, AR7240_REG_GLOBAL_CTRL,
  37096. + AR9340_GLOBAL_CTRL_MTU_M,
  37097. + AR9340_GLOBAL_CTRL_MTU_M);
  37098. +
  37099. + /* Enable MIB counters */
  37100. + ar7240sw_reg_set(mii, AR7240_REG_MIB_FUNCTION0,
  37101. + AR934X_MIB_ENABLE);
  37102. +
  37103. + } else {
  37104. + /* Enable ARP frame acknowledge, aging, MAC replacing */
  37105. + ar7240sw_reg_write(mii, AR7240_REG_AT_CTRL,
  37106. + AR7240_AT_CTRL_RESERVED |
  37107. + 0x2b /* 5 min age time */ |
  37108. + AR7240_AT_CTRL_AGE_EN |
  37109. + AR7240_AT_CTRL_ARP_EN |
  37110. + AR7240_AT_CTRL_LEARN_CHANGE);
  37111. + /* Enable Broadcast frames transmitted to the CPU */
  37112. + ar7240sw_reg_set(mii, AR7240_REG_FLOOD_MASK,
  37113. + AR7240_FLOOD_MASK_BROAD_TO_CPU);
  37114. +
  37115. + /* setup MTU */
  37116. + ar7240sw_reg_rmw(mii, AR7240_REG_GLOBAL_CTRL,
  37117. + AR7240_GLOBAL_CTRL_MTU_M,
  37118. + AR7240_GLOBAL_CTRL_MTU_M);
  37119. + }
  37120. +
  37121. + /* setup Service TAG */
  37122. + ar7240sw_reg_rmw(mii, AR7240_REG_SERVICE_TAG, AR7240_SERVICE_TAG_M, 0);
  37123. +}
  37124. +
  37125. +/* inspired by phy_poll_reset in drivers/net/phy/phy_device.c */
  37126. +static int
  37127. +ar7240sw_phy_poll_reset(struct mii_bus *bus)
  37128. +{
  37129. + const unsigned int sleep_msecs = 20;
  37130. + int ret, elapsed, i;
  37131. +
  37132. + for (elapsed = sleep_msecs; elapsed <= 600;
  37133. + elapsed += sleep_msecs) {
  37134. + msleep(sleep_msecs);
  37135. + for (i = 0; i < AR7240_NUM_PHYS; i++) {
  37136. + ret = ar7240sw_phy_read(bus, i, MII_BMCR);
  37137. + if (ret < 0)
  37138. + return ret;
  37139. + if (ret & BMCR_RESET)
  37140. + break;
  37141. + if (i == AR7240_NUM_PHYS - 1) {
  37142. + usleep_range(1000, 2000);
  37143. + return 0;
  37144. + }
  37145. + }
  37146. + }
  37147. + return -ETIMEDOUT;
  37148. +}
  37149. +
  37150. +static int ar7240sw_reset(struct ar7240sw *as)
  37151. +{
  37152. + struct mii_bus *mii = as->mii_bus;
  37153. + int ret;
  37154. + int i;
  37155. +
  37156. + /* Set all ports to disabled state. */
  37157. + for (i = 0; i < AR7240_NUM_PORTS; i++)
  37158. + ar7240sw_disable_port(as, i);
  37159. +
  37160. + /* Wait for transmit queues to drain. */
  37161. + usleep_range(2000, 3000);
  37162. +
  37163. + /* Reset the switch. */
  37164. + ar7240sw_reg_write(mii, AR7240_REG_MASK_CTRL,
  37165. + AR7240_MASK_CTRL_SOFT_RESET);
  37166. +
  37167. + ret = ar7240sw_reg_wait(mii, AR7240_REG_MASK_CTRL,
  37168. + AR7240_MASK_CTRL_SOFT_RESET, 0, 1000);
  37169. +
  37170. + /* setup PHYs */
  37171. + for (i = 0; i < AR7240_NUM_PHYS; i++) {
  37172. + ar7240sw_phy_write(mii, i, MII_ADVERTISE,
  37173. + ADVERTISE_ALL | ADVERTISE_PAUSE_CAP |
  37174. + ADVERTISE_PAUSE_ASYM);
  37175. + ar7240sw_phy_write(mii, i, MII_BMCR,
  37176. + BMCR_RESET | BMCR_ANENABLE);
  37177. + }
  37178. + ret = ar7240sw_phy_poll_reset(mii);
  37179. + if (ret)
  37180. + return ret;
  37181. +
  37182. + ar7240sw_setup(as);
  37183. + return ret;
  37184. +}
  37185. +
  37186. +static void ar7240sw_setup_port(struct ar7240sw *as, unsigned port, u8 portmask)
  37187. +{
  37188. + struct mii_bus *mii = as->mii_bus;
  37189. + u32 ctrl;
  37190. + u32 vid, mode;
  37191. +
  37192. + ctrl = AR7240_PORT_CTRL_STATE_FORWARD | AR7240_PORT_CTRL_LEARN |
  37193. + AR7240_PORT_CTRL_SINGLE_VLAN;
  37194. +
  37195. + if (port == AR7240_PORT_CPU) {
  37196. + ar7240sw_reg_write(mii, AR7240_REG_PORT_STATUS(port),
  37197. + AR7240_PORT_STATUS_SPEED_1000 |
  37198. + AR7240_PORT_STATUS_TXFLOW |
  37199. + AR7240_PORT_STATUS_RXFLOW |
  37200. + AR7240_PORT_STATUS_TXMAC |
  37201. + AR7240_PORT_STATUS_RXMAC |
  37202. + AR7240_PORT_STATUS_DUPLEX);
  37203. + } else {
  37204. + ar7240sw_reg_write(mii, AR7240_REG_PORT_STATUS(port),
  37205. + AR7240_PORT_STATUS_LINK_AUTO);
  37206. + }
  37207. +
  37208. + /* Set the default VID for this port */
  37209. + if (as->vlan) {
  37210. + vid = as->vlan_id[as->pvid[port]];
  37211. + mode = AR7240_PORT_VLAN_MODE_SECURE;
  37212. + } else {
  37213. + vid = port;
  37214. + mode = AR7240_PORT_VLAN_MODE_PORT_ONLY;
  37215. + }
  37216. +
  37217. + if (as->vlan) {
  37218. + if (as->vlan_tagged & BIT(port))
  37219. + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_ADD <<
  37220. + AR7240_PORT_CTRL_VLAN_MODE_S;
  37221. + else
  37222. + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_STRIP <<
  37223. + AR7240_PORT_CTRL_VLAN_MODE_S;
  37224. + } else {
  37225. + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_KEEP <<
  37226. + AR7240_PORT_CTRL_VLAN_MODE_S;
  37227. + }
  37228. +
  37229. + if (!portmask) {
  37230. + if (port == AR7240_PORT_CPU)
  37231. + portmask = ar7240sw_port_mask_but(as, AR7240_PORT_CPU);
  37232. + else
  37233. + portmask = ar7240sw_port_mask(as, AR7240_PORT_CPU);
  37234. + }
  37235. +
  37236. + /* allow the port to talk to all other ports, but exclude its
  37237. + * own ID to prevent frames from being reflected back to the
  37238. + * port that they came from */
  37239. + portmask &= ar7240sw_port_mask_but(as, port);
  37240. +
  37241. + ar7240sw_reg_write(mii, AR7240_REG_PORT_CTRL(port), ctrl);
  37242. + if (sw_is_ar934x(as)) {
  37243. + u32 vlan1, vlan2;
  37244. +
  37245. + vlan1 = (vid << AR934X_PORT_VLAN1_DEFAULT_CVID_S);
  37246. + vlan2 = (portmask << AR934X_PORT_VLAN2_PORT_VID_MEM_S) |
  37247. + (mode << AR934X_PORT_VLAN2_8021Q_MODE_S);
  37248. + ar7240sw_reg_write(mii, AR934X_REG_PORT_VLAN1(port), vlan1);
  37249. + ar7240sw_reg_write(mii, AR934X_REG_PORT_VLAN2(port), vlan2);
  37250. + } else {
  37251. + u32 vlan;
  37252. +
  37253. + vlan = vid | (mode << AR7240_PORT_VLAN_MODE_S) |
  37254. + (portmask << AR7240_PORT_VLAN_DEST_PORTS_S);
  37255. +
  37256. + ar7240sw_reg_write(mii, AR7240_REG_PORT_VLAN(port), vlan);
  37257. + }
  37258. +}
  37259. +
  37260. +static int ar7240_set_addr(struct ar7240sw *as, u8 *addr)
  37261. +{
  37262. + struct mii_bus *mii = as->mii_bus;
  37263. + u32 t;
  37264. +
  37265. + t = (addr[4] << 8) | addr[5];
  37266. + ar7240sw_reg_write(mii, AR7240_REG_MAC_ADDR0, t);
  37267. +
  37268. + t = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3];
  37269. + ar7240sw_reg_write(mii, AR7240_REG_MAC_ADDR1, t);
  37270. +
  37271. + return 0;
  37272. +}
  37273. +
  37274. +static int
  37275. +ar7240_set_vid(struct switch_dev *dev, const struct switch_attr *attr,
  37276. + struct switch_val *val)
  37277. +{
  37278. + struct ar7240sw *as = sw_to_ar7240(dev);
  37279. + as->vlan_id[val->port_vlan] = val->value.i;
  37280. + return 0;
  37281. +}
  37282. +
  37283. +static int
  37284. +ar7240_get_vid(struct switch_dev *dev, const struct switch_attr *attr,
  37285. + struct switch_val *val)
  37286. +{
  37287. + struct ar7240sw *as = sw_to_ar7240(dev);
  37288. + val->value.i = as->vlan_id[val->port_vlan];
  37289. + return 0;
  37290. +}
  37291. +
  37292. +static int
  37293. +ar7240_set_pvid(struct switch_dev *dev, int port, int vlan)
  37294. +{
  37295. + struct ar7240sw *as = sw_to_ar7240(dev);
  37296. +
  37297. + /* make sure no invalid PVIDs get set */
  37298. +
  37299. + if (vlan >= dev->vlans)
  37300. + return -EINVAL;
  37301. +
  37302. + as->pvid[port] = vlan;
  37303. + return 0;
  37304. +}
  37305. +
  37306. +static int
  37307. +ar7240_get_pvid(struct switch_dev *dev, int port, int *vlan)
  37308. +{
  37309. + struct ar7240sw *as = sw_to_ar7240(dev);
  37310. + *vlan = as->pvid[port];
  37311. + return 0;
  37312. +}
  37313. +
  37314. +static int
  37315. +ar7240_get_ports(struct switch_dev *dev, struct switch_val *val)
  37316. +{
  37317. + struct ar7240sw *as = sw_to_ar7240(dev);
  37318. + u8 ports = as->vlan_table[val->port_vlan];
  37319. + int i;
  37320. +
  37321. + val->len = 0;
  37322. + for (i = 0; i < as->swdev.ports; i++) {
  37323. + struct switch_port *p;
  37324. +
  37325. + if (!(ports & (1 << i)))
  37326. + continue;
  37327. +
  37328. + p = &val->value.ports[val->len++];
  37329. + p->id = i;
  37330. + if (as->vlan_tagged & (1 << i))
  37331. + p->flags = (1 << SWITCH_PORT_FLAG_TAGGED);
  37332. + else
  37333. + p->flags = 0;
  37334. + }
  37335. + return 0;
  37336. +}
  37337. +
  37338. +static int
  37339. +ar7240_set_ports(struct switch_dev *dev, struct switch_val *val)
  37340. +{
  37341. + struct ar7240sw *as = sw_to_ar7240(dev);
  37342. + u8 *vt = &as->vlan_table[val->port_vlan];
  37343. + int i, j;
  37344. +
  37345. + *vt = 0;
  37346. + for (i = 0; i < val->len; i++) {
  37347. + struct switch_port *p = &val->value.ports[i];
  37348. +
  37349. + if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED))
  37350. + as->vlan_tagged |= (1 << p->id);
  37351. + else {
  37352. + as->vlan_tagged &= ~(1 << p->id);
  37353. + as->pvid[p->id] = val->port_vlan;
  37354. +
  37355. + /* make sure that an untagged port does not
  37356. + * appear in other vlans */
  37357. + for (j = 0; j < AR7240_MAX_VLANS; j++) {
  37358. + if (j == val->port_vlan)
  37359. + continue;
  37360. + as->vlan_table[j] &= ~(1 << p->id);
  37361. + }
  37362. + }
  37363. +
  37364. + *vt |= 1 << p->id;
  37365. + }
  37366. + return 0;
  37367. +}
  37368. +
  37369. +static int
  37370. +ar7240_set_vlan(struct switch_dev *dev, const struct switch_attr *attr,
  37371. + struct switch_val *val)
  37372. +{
  37373. + struct ar7240sw *as = sw_to_ar7240(dev);
  37374. + as->vlan = !!val->value.i;
  37375. + return 0;
  37376. +}
  37377. +
  37378. +static int
  37379. +ar7240_get_vlan(struct switch_dev *dev, const struct switch_attr *attr,
  37380. + struct switch_val *val)
  37381. +{
  37382. + struct ar7240sw *as = sw_to_ar7240(dev);
  37383. + val->value.i = as->vlan;
  37384. + return 0;
  37385. +}
  37386. +
  37387. +static void
  37388. +ar7240_vtu_op(struct ar7240sw *as, u32 op, u32 val)
  37389. +{
  37390. + struct mii_bus *mii = as->mii_bus;
  37391. +
  37392. + if (ar7240sw_reg_wait(mii, AR7240_REG_VTU, AR7240_VTU_ACTIVE, 0, 5))
  37393. + return;
  37394. +
  37395. + if ((op & AR7240_VTU_OP) == AR7240_VTU_OP_LOAD) {
  37396. + val &= AR7240_VTUDATA_MEMBER;
  37397. + val |= AR7240_VTUDATA_VALID;
  37398. + ar7240sw_reg_write(mii, AR7240_REG_VTU_DATA, val);
  37399. + }
  37400. + op |= AR7240_VTU_ACTIVE;
  37401. + ar7240sw_reg_write(mii, AR7240_REG_VTU, op);
  37402. +}
  37403. +
  37404. +static int
  37405. +ar7240_hw_apply(struct switch_dev *dev)
  37406. +{
  37407. + struct ar7240sw *as = sw_to_ar7240(dev);
  37408. + u8 portmask[AR7240_NUM_PORTS];
  37409. + int i, j;
  37410. +
  37411. + /* flush all vlan translation unit entries */
  37412. + ar7240_vtu_op(as, AR7240_VTU_OP_FLUSH, 0);
  37413. +
  37414. + memset(portmask, 0, sizeof(portmask));
  37415. + if (as->vlan) {
  37416. + /* calculate the port destination masks and load vlans
  37417. + * into the vlan translation unit */
  37418. + for (j = 0; j < AR7240_MAX_VLANS; j++) {
  37419. + u8 vp = as->vlan_table[j];
  37420. +
  37421. + if (!vp)
  37422. + continue;
  37423. +
  37424. + for (i = 0; i < as->swdev.ports; i++) {
  37425. + u8 mask = (1 << i);
  37426. + if (vp & mask)
  37427. + portmask[i] |= vp & ~mask;
  37428. + }
  37429. +
  37430. + ar7240_vtu_op(as,
  37431. + AR7240_VTU_OP_LOAD |
  37432. + (as->vlan_id[j] << AR7240_VTU_VID_S),
  37433. + as->vlan_table[j]);
  37434. + }
  37435. + } else {
  37436. + /* vlan disabled:
  37437. + * isolate all ports, but connect them to the cpu port */
  37438. + for (i = 0; i < as->swdev.ports; i++) {
  37439. + if (i == AR7240_PORT_CPU)
  37440. + continue;
  37441. +
  37442. + portmask[i] = 1 << AR7240_PORT_CPU;
  37443. + portmask[AR7240_PORT_CPU] |= (1 << i);
  37444. + }
  37445. + }
  37446. +
  37447. + /* update the port destination mask registers and tag settings */
  37448. + for (i = 0; i < as->swdev.ports; i++)
  37449. + ar7240sw_setup_port(as, i, portmask[i]);
  37450. +
  37451. + return 0;
  37452. +}
  37453. +
  37454. +static int
  37455. +ar7240_reset_switch(struct switch_dev *dev)
  37456. +{
  37457. + struct ar7240sw *as = sw_to_ar7240(dev);
  37458. + ar7240sw_reset(as);
  37459. + return 0;
  37460. +}
  37461. +
  37462. +static int
  37463. +ar7240_get_port_link(struct switch_dev *dev, int port,
  37464. + struct switch_port_link *link)
  37465. +{
  37466. + struct ar7240sw *as = sw_to_ar7240(dev);
  37467. + struct mii_bus *mii = as->mii_bus;
  37468. + u32 status;
  37469. +
  37470. + if (port > AR7240_NUM_PORTS)
  37471. + return -EINVAL;
  37472. +
  37473. + status = ar7240sw_reg_read(mii, AR7240_REG_PORT_STATUS(port));
  37474. + link->aneg = !!(status & AR7240_PORT_STATUS_LINK_AUTO);
  37475. + if (link->aneg) {
  37476. + link->link = !!(status & AR7240_PORT_STATUS_LINK_UP);
  37477. + if (!link->link)
  37478. + return 0;
  37479. + } else {
  37480. + link->link = true;
  37481. + }
  37482. +
  37483. + link->duplex = !!(status & AR7240_PORT_STATUS_DUPLEX);
  37484. + link->tx_flow = !!(status & AR7240_PORT_STATUS_TXFLOW);
  37485. + link->rx_flow = !!(status & AR7240_PORT_STATUS_RXFLOW);
  37486. + switch (status & AR7240_PORT_STATUS_SPEED_M) {
  37487. + case AR7240_PORT_STATUS_SPEED_10:
  37488. + link->speed = SWITCH_PORT_SPEED_10;
  37489. + break;
  37490. + case AR7240_PORT_STATUS_SPEED_100:
  37491. + link->speed = SWITCH_PORT_SPEED_100;
  37492. + break;
  37493. + case AR7240_PORT_STATUS_SPEED_1000:
  37494. + link->speed = SWITCH_PORT_SPEED_1000;
  37495. + break;
  37496. + }
  37497. +
  37498. + return 0;
  37499. +}
  37500. +
  37501. +static int
  37502. +ar7240_get_port_stats(struct switch_dev *dev, int port,
  37503. + struct switch_port_stats *stats)
  37504. +{
  37505. + struct ar7240sw *as = sw_to_ar7240(dev);
  37506. +
  37507. + if (port > AR7240_NUM_PORTS)
  37508. + return -EINVAL;
  37509. +
  37510. + ar7240sw_capture_stats(as);
  37511. +
  37512. + read_lock(&as->stats_lock);
  37513. + stats->rx_bytes = as->port_stats[port].rx_good_byte;
  37514. + stats->tx_bytes = as->port_stats[port].tx_byte;
  37515. + read_unlock(&as->stats_lock);
  37516. +
  37517. + return 0;
  37518. +}
  37519. +
  37520. +static struct switch_attr ar7240_globals[] = {
  37521. + {
  37522. + .type = SWITCH_TYPE_INT,
  37523. + .name = "enable_vlan",
  37524. + .description = "Enable VLAN mode",
  37525. + .set = ar7240_set_vlan,
  37526. + .get = ar7240_get_vlan,
  37527. + .max = 1
  37528. + },
  37529. +};
  37530. +
  37531. +static struct switch_attr ar7240_port[] = {
  37532. +};
  37533. +
  37534. +static struct switch_attr ar7240_vlan[] = {
  37535. + {
  37536. + .type = SWITCH_TYPE_INT,
  37537. + .name = "vid",
  37538. + .description = "VLAN ID",
  37539. + .set = ar7240_set_vid,
  37540. + .get = ar7240_get_vid,
  37541. + .max = 4094,
  37542. + },
  37543. +};
  37544. +
  37545. +static const struct switch_dev_ops ar7240_ops = {
  37546. + .attr_global = {
  37547. + .attr = ar7240_globals,
  37548. + .n_attr = ARRAY_SIZE(ar7240_globals),
  37549. + },
  37550. + .attr_port = {
  37551. + .attr = ar7240_port,
  37552. + .n_attr = ARRAY_SIZE(ar7240_port),
  37553. + },
  37554. + .attr_vlan = {
  37555. + .attr = ar7240_vlan,
  37556. + .n_attr = ARRAY_SIZE(ar7240_vlan),
  37557. + },
  37558. + .get_port_pvid = ar7240_get_pvid,
  37559. + .set_port_pvid = ar7240_set_pvid,
  37560. + .get_vlan_ports = ar7240_get_ports,
  37561. + .set_vlan_ports = ar7240_set_ports,
  37562. + .apply_config = ar7240_hw_apply,
  37563. + .reset_switch = ar7240_reset_switch,
  37564. + .get_port_link = ar7240_get_port_link,
  37565. + .get_port_stats = ar7240_get_port_stats,
  37566. +};
  37567. +
  37568. +static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
  37569. +{
  37570. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  37571. + struct mii_bus *mii = ag->mii_bus;
  37572. + struct ar7240sw *as;
  37573. + struct switch_dev *swdev;
  37574. + u32 ctrl;
  37575. + u16 phy_id1;
  37576. + u16 phy_id2;
  37577. + int i;
  37578. +
  37579. + phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
  37580. + phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
  37581. + if ((phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) &&
  37582. + (phy_id1 != AR934X_PHY_ID1 || phy_id2 != AR934X_PHY_ID2)) {
  37583. + pr_err("%s: unknown phy id '%04x:%04x'\n",
  37584. + dev_name(&mii->dev), phy_id1, phy_id2);
  37585. + return NULL;
  37586. + }
  37587. +
  37588. + as = kzalloc(sizeof(*as), GFP_KERNEL);
  37589. + if (!as)
  37590. + return NULL;
  37591. +
  37592. + as->mii_bus = mii;
  37593. + as->swdata = pdata->switch_data;
  37594. +
  37595. + swdev = &as->swdev;
  37596. +
  37597. + ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
  37598. + as->ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) &
  37599. + AR7240_MASK_CTRL_VERSION_M;
  37600. +
  37601. + if (sw_is_ar7240(as)) {
  37602. + swdev->name = "AR7240/AR9330 built-in switch";
  37603. + swdev->ports = AR7240_NUM_PORTS - 1;
  37604. + } else if (sw_is_ar934x(as)) {
  37605. + swdev->name = "AR934X built-in switch";
  37606. +
  37607. + if (pdata->phy_if_mode == PHY_INTERFACE_MODE_GMII) {
  37608. + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE0,
  37609. + AR934X_OPER_MODE0_MAC_GMII_EN);
  37610. + } else if (pdata->phy_if_mode == PHY_INTERFACE_MODE_MII) {
  37611. + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE0,
  37612. + AR934X_OPER_MODE0_PHY_MII_EN);
  37613. + } else {
  37614. + pr_err("%s: invalid PHY interface mode\n",
  37615. + dev_name(&mii->dev));
  37616. + goto err_free;
  37617. + }
  37618. +
  37619. + if (as->swdata->phy4_mii_en) {
  37620. + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE1,
  37621. + AR934X_REG_OPER_MODE1_PHY4_MII_EN);
  37622. + swdev->ports = AR7240_NUM_PORTS - 1;
  37623. + } else {
  37624. + swdev->ports = AR7240_NUM_PORTS;
  37625. + }
  37626. + } else {
  37627. + pr_err("%s: unsupported chip, ctrl=%08x\n",
  37628. + dev_name(&mii->dev), ctrl);
  37629. + goto err_free;
  37630. + }
  37631. +
  37632. + swdev->cpu_port = AR7240_PORT_CPU;
  37633. + swdev->vlans = AR7240_MAX_VLANS;
  37634. + swdev->ops = &ar7240_ops;
  37635. +
  37636. + if (register_switch(&as->swdev, ag->dev) < 0)
  37637. + goto err_free;
  37638. +
  37639. + pr_info("%s: Found an %s\n", dev_name(&mii->dev), swdev->name);
  37640. +
  37641. + /* initialize defaults */
  37642. + for (i = 0; i < AR7240_MAX_VLANS; i++)
  37643. + as->vlan_id[i] = i;
  37644. +
  37645. + as->vlan_table[0] = ar7240sw_port_mask_all(as);
  37646. +
  37647. + return as;
  37648. +
  37649. +err_free:
  37650. + kfree(as);
  37651. + return NULL;
  37652. +}
  37653. +
  37654. +static void link_function(struct work_struct *work) {
  37655. + struct ag71xx *ag = container_of(work, struct ag71xx, link_work.work);
  37656. + struct ar7240sw *as = ag->phy_priv;
  37657. + unsigned long flags;
  37658. + u8 mask;
  37659. + int i;
  37660. + int status = 0;
  37661. +
  37662. + mask = ~as->swdata->phy_poll_mask;
  37663. + for (i = 0; i < AR7240_NUM_PHYS; i++) {
  37664. + int link;
  37665. +
  37666. + if (!(mask & BIT(i)))
  37667. + continue;
  37668. +
  37669. + link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
  37670. + if (link & BMSR_LSTATUS) {
  37671. + status = 1;
  37672. + break;
  37673. + }
  37674. + }
  37675. +
  37676. + spin_lock_irqsave(&ag->lock, flags);
  37677. + if (status != ag->link) {
  37678. + ag->link = status;
  37679. + ag71xx_link_adjust(ag);
  37680. + }
  37681. + spin_unlock_irqrestore(&ag->lock, flags);
  37682. +
  37683. + schedule_delayed_work(&ag->link_work, HZ / 2);
  37684. +}
  37685. +
  37686. +void ag71xx_ar7240_start(struct ag71xx *ag)
  37687. +{
  37688. + struct ar7240sw *as = ag->phy_priv;
  37689. +
  37690. + ar7240sw_reset(as);
  37691. +
  37692. + ag->speed = SPEED_1000;
  37693. + ag->duplex = 1;
  37694. +
  37695. + ar7240_set_addr(as, ag->dev->dev_addr);
  37696. + ar7240_hw_apply(&as->swdev);
  37697. +
  37698. + schedule_delayed_work(&ag->link_work, HZ / 10);
  37699. +}
  37700. +
  37701. +void ag71xx_ar7240_stop(struct ag71xx *ag)
  37702. +{
  37703. + cancel_delayed_work_sync(&ag->link_work);
  37704. +}
  37705. +
  37706. +int ag71xx_ar7240_init(struct ag71xx *ag)
  37707. +{
  37708. + struct ar7240sw *as;
  37709. +
  37710. + as = ar7240_probe(ag);
  37711. + if (!as)
  37712. + return -ENODEV;
  37713. +
  37714. + ag->phy_priv = as;
  37715. + ar7240sw_reset(as);
  37716. +
  37717. + rwlock_init(&as->stats_lock);
  37718. + INIT_DELAYED_WORK(&ag->link_work, link_function);
  37719. +
  37720. + return 0;
  37721. +}
  37722. +
  37723. +void ag71xx_ar7240_cleanup(struct ag71xx *ag)
  37724. +{
  37725. + struct ar7240sw *as = ag->phy_priv;
  37726. +
  37727. + if (!as)
  37728. + return;
  37729. +
  37730. + unregister_switch(&as->swdev);
  37731. + kfree(as);
  37732. + ag->phy_priv = NULL;
  37733. +}
  37734. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c
  37735. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c 1970-01-01 01:00:00.000000000 +0100
  37736. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c 2015-09-13 20:04:35.076523692 +0200
  37737. @@ -0,0 +1,44 @@
  37738. +/*
  37739. + * Atheros AR71xx built-in ethernet mac driver
  37740. + * Special support for the Atheros ar8216 switch chip
  37741. + *
  37742. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  37743. + *
  37744. + * Based on Atheros' AG7100 driver
  37745. + *
  37746. + * This program is free software; you can redistribute it and/or modify it
  37747. + * under the terms of the GNU General Public License version 2 as published
  37748. + * by the Free Software Foundation.
  37749. + */
  37750. +
  37751. +#include "ag71xx.h"
  37752. +
  37753. +#define AR8216_PACKET_TYPE_MASK 0xf
  37754. +#define AR8216_PACKET_TYPE_NORMAL 0
  37755. +
  37756. +#define AR8216_HEADER_LEN 2
  37757. +
  37758. +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb)
  37759. +{
  37760. + skb_push(skb, AR8216_HEADER_LEN);
  37761. + skb->data[0] = 0x10;
  37762. + skb->data[1] = 0x80;
  37763. +}
  37764. +
  37765. +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
  37766. + int pktlen)
  37767. +{
  37768. + u8 type;
  37769. +
  37770. + type = skb->data[1] & AR8216_PACKET_TYPE_MASK;
  37771. + switch (type) {
  37772. + case AR8216_PACKET_TYPE_NORMAL:
  37773. + break;
  37774. +
  37775. + default:
  37776. + return -EINVAL;
  37777. + }
  37778. +
  37779. + skb_pull(skb, AR8216_HEADER_LEN);
  37780. + return 0;
  37781. +}
  37782. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
  37783. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c 1970-01-01 01:00:00.000000000 +0100
  37784. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c 2015-09-13 20:04:35.076523692 +0200
  37785. @@ -0,0 +1,285 @@
  37786. +/*
  37787. + * Atheros AR71xx built-in ethernet mac driver
  37788. + *
  37789. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  37790. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  37791. + *
  37792. + * Based on Atheros' AG7100 driver
  37793. + *
  37794. + * This program is free software; you can redistribute it and/or modify it
  37795. + * under the terms of the GNU General Public License version 2 as published
  37796. + * by the Free Software Foundation.
  37797. + */
  37798. +
  37799. +#include <linux/debugfs.h>
  37800. +
  37801. +#include "ag71xx.h"
  37802. +
  37803. +static struct dentry *ag71xx_debugfs_root;
  37804. +
  37805. +static int ag71xx_debugfs_generic_open(struct inode *inode, struct file *file)
  37806. +{
  37807. + file->private_data = inode->i_private;
  37808. + return 0;
  37809. +}
  37810. +
  37811. +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status)
  37812. +{
  37813. + if (status)
  37814. + ag->debug.int_stats.total++;
  37815. + if (status & AG71XX_INT_TX_PS)
  37816. + ag->debug.int_stats.tx_ps++;
  37817. + if (status & AG71XX_INT_TX_UR)
  37818. + ag->debug.int_stats.tx_ur++;
  37819. + if (status & AG71XX_INT_TX_BE)
  37820. + ag->debug.int_stats.tx_be++;
  37821. + if (status & AG71XX_INT_RX_PR)
  37822. + ag->debug.int_stats.rx_pr++;
  37823. + if (status & AG71XX_INT_RX_OF)
  37824. + ag->debug.int_stats.rx_of++;
  37825. + if (status & AG71XX_INT_RX_BE)
  37826. + ag->debug.int_stats.rx_be++;
  37827. +}
  37828. +
  37829. +static ssize_t read_file_int_stats(struct file *file, char __user *user_buf,
  37830. + size_t count, loff_t *ppos)
  37831. +{
  37832. +#define PR_INT_STAT(_label, _field) \
  37833. + len += snprintf(buf + len, sizeof(buf) - len, \
  37834. + "%20s: %10lu\n", _label, ag->debug.int_stats._field);
  37835. +
  37836. + struct ag71xx *ag = file->private_data;
  37837. + char buf[256];
  37838. + unsigned int len = 0;
  37839. +
  37840. + PR_INT_STAT("TX Packet Sent", tx_ps);
  37841. + PR_INT_STAT("TX Underrun", tx_ur);
  37842. + PR_INT_STAT("TX Bus Error", tx_be);
  37843. + PR_INT_STAT("RX Packet Received", rx_pr);
  37844. + PR_INT_STAT("RX Overflow", rx_of);
  37845. + PR_INT_STAT("RX Bus Error", rx_be);
  37846. + len += snprintf(buf + len, sizeof(buf) - len, "\n");
  37847. + PR_INT_STAT("Total", total);
  37848. +
  37849. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  37850. +#undef PR_INT_STAT
  37851. +}
  37852. +
  37853. +static const struct file_operations ag71xx_fops_int_stats = {
  37854. + .open = ag71xx_debugfs_generic_open,
  37855. + .read = read_file_int_stats,
  37856. + .owner = THIS_MODULE
  37857. +};
  37858. +
  37859. +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx)
  37860. +{
  37861. + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
  37862. +
  37863. + if (rx) {
  37864. + stats->rx_count++;
  37865. + stats->rx_packets += rx;
  37866. + if (rx <= AG71XX_NAPI_WEIGHT)
  37867. + stats->rx[rx]++;
  37868. + if (rx > stats->rx_packets_max)
  37869. + stats->rx_packets_max = rx;
  37870. + }
  37871. +
  37872. + if (tx) {
  37873. + stats->tx_count++;
  37874. + stats->tx_packets += tx;
  37875. + if (tx <= AG71XX_NAPI_WEIGHT)
  37876. + stats->tx[tx]++;
  37877. + if (tx > stats->tx_packets_max)
  37878. + stats->tx_packets_max = tx;
  37879. + }
  37880. +}
  37881. +
  37882. +static ssize_t read_file_napi_stats(struct file *file, char __user *user_buf,
  37883. + size_t count, loff_t *ppos)
  37884. +{
  37885. + struct ag71xx *ag = file->private_data;
  37886. + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
  37887. + char *buf;
  37888. + unsigned int buflen;
  37889. + unsigned int len = 0;
  37890. + unsigned long rx_avg = 0;
  37891. + unsigned long tx_avg = 0;
  37892. + int ret;
  37893. + int i;
  37894. +
  37895. + buflen = 2048;
  37896. + buf = kmalloc(buflen, GFP_KERNEL);
  37897. + if (!buf)
  37898. + return -ENOMEM;
  37899. +
  37900. + if (stats->rx_count)
  37901. + rx_avg = stats->rx_packets / stats->rx_count;
  37902. +
  37903. + if (stats->tx_count)
  37904. + tx_avg = stats->tx_packets / stats->tx_count;
  37905. +
  37906. + len += snprintf(buf + len, buflen - len, "%3s %10s %10s\n",
  37907. + "len", "rx", "tx");
  37908. +
  37909. + for (i = 1; i <= AG71XX_NAPI_WEIGHT; i++)
  37910. + len += snprintf(buf + len, buflen - len,
  37911. + "%3d: %10lu %10lu\n",
  37912. + i, stats->rx[i], stats->tx[i]);
  37913. +
  37914. + len += snprintf(buf + len, buflen - len, "\n");
  37915. +
  37916. + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
  37917. + "sum", stats->rx_count, stats->tx_count);
  37918. + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
  37919. + "avg", rx_avg, tx_avg);
  37920. + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
  37921. + "max", stats->rx_packets_max, stats->tx_packets_max);
  37922. + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
  37923. + "pkt", stats->rx_packets, stats->tx_packets);
  37924. +
  37925. + ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  37926. + kfree(buf);
  37927. +
  37928. + return ret;
  37929. +}
  37930. +
  37931. +static const struct file_operations ag71xx_fops_napi_stats = {
  37932. + .open = ag71xx_debugfs_generic_open,
  37933. + .read = read_file_napi_stats,
  37934. + .owner = THIS_MODULE
  37935. +};
  37936. +
  37937. +#define DESC_PRINT_LEN 64
  37938. +
  37939. +static ssize_t read_file_ring(struct file *file, char __user *user_buf,
  37940. + size_t count, loff_t *ppos,
  37941. + struct ag71xx *ag,
  37942. + struct ag71xx_ring *ring,
  37943. + unsigned desc_reg)
  37944. +{
  37945. + char *buf;
  37946. + unsigned int buflen;
  37947. + unsigned int len = 0;
  37948. + unsigned long flags;
  37949. + ssize_t ret;
  37950. + int curr;
  37951. + int dirty;
  37952. + u32 desc_hw;
  37953. + int i;
  37954. +
  37955. + buflen = (ring->size * DESC_PRINT_LEN);
  37956. + buf = kmalloc(buflen, GFP_KERNEL);
  37957. + if (!buf)
  37958. + return -ENOMEM;
  37959. +
  37960. + len += snprintf(buf + len, buflen - len,
  37961. + "Idx ... %-8s %-8s %-8s %-8s . %-10s\n",
  37962. + "desc", "next", "data", "ctrl", "timestamp");
  37963. +
  37964. + spin_lock_irqsave(&ag->lock, flags);
  37965. +
  37966. + curr = (ring->curr % ring->size);
  37967. + dirty = (ring->dirty % ring->size);
  37968. + desc_hw = ag71xx_rr(ag, desc_reg);
  37969. + for (i = 0; i < ring->size; i++) {
  37970. + struct ag71xx_buf *ab = &ring->buf[i];
  37971. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  37972. + u32 desc_dma = ((u32) ring->descs_dma) + i * ring->desc_size;
  37973. +
  37974. + len += snprintf(buf + len, buflen - len,
  37975. + "%3d %c%c%c %08x %08x %08x %08x %c %10lu\n",
  37976. + i,
  37977. + (i == curr) ? 'C' : ' ',
  37978. + (i == dirty) ? 'D' : ' ',
  37979. + (desc_hw == desc_dma) ? 'H' : ' ',
  37980. + desc_dma,
  37981. + desc->next,
  37982. + desc->data,
  37983. + desc->ctrl,
  37984. + (desc->ctrl & DESC_EMPTY) ? 'E' : '*',
  37985. + ab->timestamp);
  37986. + }
  37987. +
  37988. + spin_unlock_irqrestore(&ag->lock, flags);
  37989. +
  37990. + ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  37991. + kfree(buf);
  37992. +
  37993. + return ret;
  37994. +}
  37995. +
  37996. +static ssize_t read_file_tx_ring(struct file *file, char __user *user_buf,
  37997. + size_t count, loff_t *ppos)
  37998. +{
  37999. + struct ag71xx *ag = file->private_data;
  38000. +
  38001. + return read_file_ring(file, user_buf, count, ppos, ag, &ag->tx_ring,
  38002. + AG71XX_REG_TX_DESC);
  38003. +}
  38004. +
  38005. +static const struct file_operations ag71xx_fops_tx_ring = {
  38006. + .open = ag71xx_debugfs_generic_open,
  38007. + .read = read_file_tx_ring,
  38008. + .owner = THIS_MODULE
  38009. +};
  38010. +
  38011. +static ssize_t read_file_rx_ring(struct file *file, char __user *user_buf,
  38012. + size_t count, loff_t *ppos)
  38013. +{
  38014. + struct ag71xx *ag = file->private_data;
  38015. +
  38016. + return read_file_ring(file, user_buf, count, ppos, ag, &ag->rx_ring,
  38017. + AG71XX_REG_RX_DESC);
  38018. +}
  38019. +
  38020. +static const struct file_operations ag71xx_fops_rx_ring = {
  38021. + .open = ag71xx_debugfs_generic_open,
  38022. + .read = read_file_rx_ring,
  38023. + .owner = THIS_MODULE
  38024. +};
  38025. +
  38026. +void ag71xx_debugfs_exit(struct ag71xx *ag)
  38027. +{
  38028. + debugfs_remove_recursive(ag->debug.debugfs_dir);
  38029. +}
  38030. +
  38031. +int ag71xx_debugfs_init(struct ag71xx *ag)
  38032. +{
  38033. + struct device *dev = &ag->pdev->dev;
  38034. +
  38035. + ag->debug.debugfs_dir = debugfs_create_dir(dev_name(dev),
  38036. + ag71xx_debugfs_root);
  38037. + if (!ag->debug.debugfs_dir) {
  38038. + dev_err(dev, "unable to create debugfs directory\n");
  38039. + return -ENOENT;
  38040. + }
  38041. +
  38042. + debugfs_create_file("int_stats", S_IRUGO, ag->debug.debugfs_dir,
  38043. + ag, &ag71xx_fops_int_stats);
  38044. + debugfs_create_file("napi_stats", S_IRUGO, ag->debug.debugfs_dir,
  38045. + ag, &ag71xx_fops_napi_stats);
  38046. + debugfs_create_file("tx_ring", S_IRUGO, ag->debug.debugfs_dir,
  38047. + ag, &ag71xx_fops_tx_ring);
  38048. + debugfs_create_file("rx_ring", S_IRUGO, ag->debug.debugfs_dir,
  38049. + ag, &ag71xx_fops_rx_ring);
  38050. +
  38051. + return 0;
  38052. +}
  38053. +
  38054. +int ag71xx_debugfs_root_init(void)
  38055. +{
  38056. + if (ag71xx_debugfs_root)
  38057. + return -EBUSY;
  38058. +
  38059. + ag71xx_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
  38060. + if (!ag71xx_debugfs_root)
  38061. + return -ENOENT;
  38062. +
  38063. + return 0;
  38064. +}
  38065. +
  38066. +void ag71xx_debugfs_root_exit(void)
  38067. +{
  38068. + debugfs_remove(ag71xx_debugfs_root);
  38069. + ag71xx_debugfs_root = NULL;
  38070. +}
  38071. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
  38072. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c 1970-01-01 01:00:00.000000000 +0100
  38073. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c 2015-09-13 20:04:35.076523692 +0200
  38074. @@ -0,0 +1,130 @@
  38075. +/*
  38076. + * Atheros AR71xx built-in ethernet mac driver
  38077. + *
  38078. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  38079. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  38080. + *
  38081. + * Based on Atheros' AG7100 driver
  38082. + *
  38083. + * This program is free software; you can redistribute it and/or modify it
  38084. + * under the terms of the GNU General Public License version 2 as published
  38085. + * by the Free Software Foundation.
  38086. + */
  38087. +
  38088. +#include "ag71xx.h"
  38089. +
  38090. +static int ag71xx_ethtool_get_settings(struct net_device *dev,
  38091. + struct ethtool_cmd *cmd)
  38092. +{
  38093. + struct ag71xx *ag = netdev_priv(dev);
  38094. + struct phy_device *phydev = ag->phy_dev;
  38095. +
  38096. + if (!phydev)
  38097. + return -ENODEV;
  38098. +
  38099. + return phy_ethtool_gset(phydev, cmd);
  38100. +}
  38101. +
  38102. +static int ag71xx_ethtool_set_settings(struct net_device *dev,
  38103. + struct ethtool_cmd *cmd)
  38104. +{
  38105. + struct ag71xx *ag = netdev_priv(dev);
  38106. + struct phy_device *phydev = ag->phy_dev;
  38107. +
  38108. + if (!phydev)
  38109. + return -ENODEV;
  38110. +
  38111. + return phy_ethtool_sset(phydev, cmd);
  38112. +}
  38113. +
  38114. +static void ag71xx_ethtool_get_drvinfo(struct net_device *dev,
  38115. + struct ethtool_drvinfo *info)
  38116. +{
  38117. + struct ag71xx *ag = netdev_priv(dev);
  38118. +
  38119. + strcpy(info->driver, ag->pdev->dev.driver->name);
  38120. + strcpy(info->version, AG71XX_DRV_VERSION);
  38121. + strcpy(info->bus_info, dev_name(&ag->pdev->dev));
  38122. +}
  38123. +
  38124. +static u32 ag71xx_ethtool_get_msglevel(struct net_device *dev)
  38125. +{
  38126. + struct ag71xx *ag = netdev_priv(dev);
  38127. +
  38128. + return ag->msg_enable;
  38129. +}
  38130. +
  38131. +static void ag71xx_ethtool_set_msglevel(struct net_device *dev, u32 msg_level)
  38132. +{
  38133. + struct ag71xx *ag = netdev_priv(dev);
  38134. +
  38135. + ag->msg_enable = msg_level;
  38136. +}
  38137. +
  38138. +static void ag71xx_ethtool_get_ringparam(struct net_device *dev,
  38139. + struct ethtool_ringparam *er)
  38140. +{
  38141. + struct ag71xx *ag = netdev_priv(dev);
  38142. +
  38143. + er->tx_max_pending = AG71XX_TX_RING_SIZE_MAX;
  38144. + er->rx_max_pending = AG71XX_RX_RING_SIZE_MAX;
  38145. + er->rx_mini_max_pending = 0;
  38146. + er->rx_jumbo_max_pending = 0;
  38147. +
  38148. + er->tx_pending = ag->tx_ring.size;
  38149. + er->rx_pending = ag->rx_ring.size;
  38150. + er->rx_mini_pending = 0;
  38151. + er->rx_jumbo_pending = 0;
  38152. +
  38153. + if (ag->tx_ring.desc_split)
  38154. + er->tx_pending /= AG71XX_TX_RING_DS_PER_PKT;
  38155. +}
  38156. +
  38157. +static int ag71xx_ethtool_set_ringparam(struct net_device *dev,
  38158. + struct ethtool_ringparam *er)
  38159. +{
  38160. + struct ag71xx *ag = netdev_priv(dev);
  38161. + unsigned tx_size;
  38162. + unsigned rx_size;
  38163. + int err;
  38164. +
  38165. + if (er->rx_mini_pending != 0||
  38166. + er->rx_jumbo_pending != 0 ||
  38167. + er->rx_pending == 0 ||
  38168. + er->tx_pending == 0)
  38169. + return -EINVAL;
  38170. +
  38171. + tx_size = er->tx_pending < AG71XX_TX_RING_SIZE_MAX ?
  38172. + er->tx_pending : AG71XX_TX_RING_SIZE_MAX;
  38173. +
  38174. + rx_size = er->rx_pending < AG71XX_RX_RING_SIZE_MAX ?
  38175. + er->rx_pending : AG71XX_RX_RING_SIZE_MAX;
  38176. +
  38177. + if (netif_running(dev)) {
  38178. + err = dev->netdev_ops->ndo_stop(dev);
  38179. + if (err)
  38180. + return err;
  38181. + }
  38182. +
  38183. + if (ag->tx_ring.desc_split)
  38184. + tx_size *= AG71XX_TX_RING_DS_PER_PKT;
  38185. +
  38186. + ag->tx_ring.size = tx_size;
  38187. + ag->rx_ring.size = rx_size;
  38188. +
  38189. + if (netif_running(dev))
  38190. + err = dev->netdev_ops->ndo_open(dev);
  38191. +
  38192. + return err;
  38193. +}
  38194. +
  38195. +struct ethtool_ops ag71xx_ethtool_ops = {
  38196. + .set_settings = ag71xx_ethtool_set_settings,
  38197. + .get_settings = ag71xx_ethtool_get_settings,
  38198. + .get_drvinfo = ag71xx_ethtool_get_drvinfo,
  38199. + .get_msglevel = ag71xx_ethtool_get_msglevel,
  38200. + .set_msglevel = ag71xx_ethtool_set_msglevel,
  38201. + .get_ringparam = ag71xx_ethtool_get_ringparam,
  38202. + .set_ringparam = ag71xx_ethtool_set_ringparam,
  38203. + .get_link = ethtool_op_get_link,
  38204. +};
  38205. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx.h linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
  38206. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 1970-01-01 01:00:00.000000000 +0100
  38207. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 2015-09-13 20:04:35.076523692 +0200
  38208. @@ -0,0 +1,485 @@
  38209. +/*
  38210. + * Atheros AR71xx built-in ethernet mac driver
  38211. + *
  38212. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  38213. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  38214. + *
  38215. + * Based on Atheros' AG7100 driver
  38216. + *
  38217. + * This program is free software; you can redistribute it and/or modify it
  38218. + * under the terms of the GNU General Public License version 2 as published
  38219. + * by the Free Software Foundation.
  38220. + */
  38221. +
  38222. +#ifndef __AG71XX_H
  38223. +#define __AG71XX_H
  38224. +
  38225. +#include <linux/kernel.h>
  38226. +#include <linux/version.h>
  38227. +#include <linux/module.h>
  38228. +#include <linux/init.h>
  38229. +#include <linux/types.h>
  38230. +#include <linux/random.h>
  38231. +#include <linux/spinlock.h>
  38232. +#include <linux/interrupt.h>
  38233. +#include <linux/platform_device.h>
  38234. +#include <linux/ethtool.h>
  38235. +#include <linux/etherdevice.h>
  38236. +#include <linux/if_vlan.h>
  38237. +#include <linux/phy.h>
  38238. +#include <linux/skbuff.h>
  38239. +#include <linux/dma-mapping.h>
  38240. +#include <linux/workqueue.h>
  38241. +
  38242. +#include <linux/bitops.h>
  38243. +
  38244. +#include <asm/mach-ath79/ar71xx_regs.h>
  38245. +#include <asm/mach-ath79/ath79.h>
  38246. +#include <asm/mach-ath79/ag71xx_platform.h>
  38247. +
  38248. +#define AG71XX_DRV_NAME "ag71xx"
  38249. +#define AG71XX_DRV_VERSION "0.5.35"
  38250. +
  38251. +#define AG71XX_NAPI_WEIGHT 64
  38252. +#define AG71XX_OOM_REFILL (1 + HZ/10)
  38253. +
  38254. +#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
  38255. +#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
  38256. +#define AG71XX_INT_RX (AG71XX_INT_RX_PR | AG71XX_INT_RX_OF)
  38257. +
  38258. +#define AG71XX_INT_POLL (AG71XX_INT_RX | AG71XX_INT_TX)
  38259. +#define AG71XX_INT_INIT (AG71XX_INT_ERR | AG71XX_INT_POLL)
  38260. +
  38261. +#define AG71XX_TX_MTU_LEN 1540
  38262. +
  38263. +#define AG71XX_TX_RING_SPLIT 512
  38264. +#define AG71XX_TX_RING_DS_PER_PKT DIV_ROUND_UP(AG71XX_TX_MTU_LEN, \
  38265. + AG71XX_TX_RING_SPLIT)
  38266. +#define AG71XX_TX_RING_SIZE_DEFAULT 48
  38267. +#define AG71XX_RX_RING_SIZE_DEFAULT 128
  38268. +
  38269. +#define AG71XX_TX_RING_SIZE_MAX 48
  38270. +#define AG71XX_RX_RING_SIZE_MAX 128
  38271. +
  38272. +#ifdef CONFIG_AG71XX_DEBUG
  38273. +#define DBG(fmt, args...) pr_debug(fmt, ## args)
  38274. +#else
  38275. +#define DBG(fmt, args...) do {} while (0)
  38276. +#endif
  38277. +
  38278. +#define ag71xx_assert(_cond) \
  38279. +do { \
  38280. + if (_cond) \
  38281. + break; \
  38282. + printk("%s,%d: assertion failed\n", __FILE__, __LINE__); \
  38283. + BUG(); \
  38284. +} while (0)
  38285. +
  38286. +struct ag71xx_desc {
  38287. + u32 data;
  38288. + u32 ctrl;
  38289. +#define DESC_EMPTY BIT(31)
  38290. +#define DESC_MORE BIT(24)
  38291. +#define DESC_PKTLEN_M 0xfff
  38292. + u32 next;
  38293. + u32 pad;
  38294. +} __attribute__((aligned(4)));
  38295. +
  38296. +struct ag71xx_buf {
  38297. + union {
  38298. + struct sk_buff *skb;
  38299. + void *rx_buf;
  38300. + };
  38301. + union {
  38302. + dma_addr_t dma_addr;
  38303. + unsigned long timestamp;
  38304. + };
  38305. + unsigned int len;
  38306. +};
  38307. +
  38308. +struct ag71xx_ring {
  38309. + struct ag71xx_buf *buf;
  38310. + u8 *descs_cpu;
  38311. + dma_addr_t descs_dma;
  38312. + u16 desc_split;
  38313. + u16 desc_size;
  38314. + unsigned int curr;
  38315. + unsigned int dirty;
  38316. + unsigned int size;
  38317. +};
  38318. +
  38319. +struct ag71xx_mdio {
  38320. + struct mii_bus *mii_bus;
  38321. + int mii_irq[PHY_MAX_ADDR];
  38322. + void __iomem *mdio_base;
  38323. + struct ag71xx_mdio_platform_data *pdata;
  38324. +};
  38325. +
  38326. +struct ag71xx_int_stats {
  38327. + unsigned long rx_pr;
  38328. + unsigned long rx_be;
  38329. + unsigned long rx_of;
  38330. + unsigned long tx_ps;
  38331. + unsigned long tx_be;
  38332. + unsigned long tx_ur;
  38333. + unsigned long total;
  38334. +};
  38335. +
  38336. +struct ag71xx_napi_stats {
  38337. + unsigned long napi_calls;
  38338. + unsigned long rx_count;
  38339. + unsigned long rx_packets;
  38340. + unsigned long rx_packets_max;
  38341. + unsigned long tx_count;
  38342. + unsigned long tx_packets;
  38343. + unsigned long tx_packets_max;
  38344. +
  38345. + unsigned long rx[AG71XX_NAPI_WEIGHT + 1];
  38346. + unsigned long tx[AG71XX_NAPI_WEIGHT + 1];
  38347. +};
  38348. +
  38349. +struct ag71xx_debug {
  38350. + struct dentry *debugfs_dir;
  38351. +
  38352. + struct ag71xx_int_stats int_stats;
  38353. + struct ag71xx_napi_stats napi_stats;
  38354. +};
  38355. +
  38356. +struct ag71xx {
  38357. + void __iomem *mac_base;
  38358. +
  38359. + spinlock_t lock;
  38360. + struct platform_device *pdev;
  38361. + struct net_device *dev;
  38362. + struct napi_struct napi;
  38363. + u32 msg_enable;
  38364. +
  38365. + struct ag71xx_desc *stop_desc;
  38366. + dma_addr_t stop_desc_dma;
  38367. +
  38368. + struct ag71xx_ring rx_ring;
  38369. + struct ag71xx_ring tx_ring;
  38370. +
  38371. + struct mii_bus *mii_bus;
  38372. + struct phy_device *phy_dev;
  38373. + void *phy_priv;
  38374. +
  38375. + unsigned int link;
  38376. + unsigned int speed;
  38377. + int duplex;
  38378. +
  38379. + unsigned int max_frame_len;
  38380. + unsigned int desc_pktlen_mask;
  38381. + unsigned int rx_buf_size;
  38382. +
  38383. + struct work_struct restart_work;
  38384. + struct delayed_work link_work;
  38385. + struct timer_list oom_timer;
  38386. +
  38387. +#ifdef CONFIG_AG71XX_DEBUG_FS
  38388. + struct ag71xx_debug debug;
  38389. +#endif
  38390. +};
  38391. +
  38392. +extern struct ethtool_ops ag71xx_ethtool_ops;
  38393. +void ag71xx_link_adjust(struct ag71xx *ag);
  38394. +
  38395. +int ag71xx_mdio_driver_init(void) __init;
  38396. +void ag71xx_mdio_driver_exit(void);
  38397. +
  38398. +int ag71xx_phy_connect(struct ag71xx *ag);
  38399. +void ag71xx_phy_disconnect(struct ag71xx *ag);
  38400. +void ag71xx_phy_start(struct ag71xx *ag);
  38401. +void ag71xx_phy_stop(struct ag71xx *ag);
  38402. +
  38403. +static inline struct ag71xx_platform_data *ag71xx_get_pdata(struct ag71xx *ag)
  38404. +{
  38405. + return ag->pdev->dev.platform_data;
  38406. +}
  38407. +
  38408. +static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
  38409. +{
  38410. + return (desc->ctrl & DESC_EMPTY) != 0;
  38411. +}
  38412. +
  38413. +static inline struct ag71xx_desc *
  38414. +ag71xx_ring_desc(struct ag71xx_ring *ring, int idx)
  38415. +{
  38416. + return (struct ag71xx_desc *) &ring->descs_cpu[idx * ring->desc_size];
  38417. +}
  38418. +
  38419. +/* Register offsets */
  38420. +#define AG71XX_REG_MAC_CFG1 0x0000
  38421. +#define AG71XX_REG_MAC_CFG2 0x0004
  38422. +#define AG71XX_REG_MAC_IPG 0x0008
  38423. +#define AG71XX_REG_MAC_HDX 0x000c
  38424. +#define AG71XX_REG_MAC_MFL 0x0010
  38425. +#define AG71XX_REG_MII_CFG 0x0020
  38426. +#define AG71XX_REG_MII_CMD 0x0024
  38427. +#define AG71XX_REG_MII_ADDR 0x0028
  38428. +#define AG71XX_REG_MII_CTRL 0x002c
  38429. +#define AG71XX_REG_MII_STATUS 0x0030
  38430. +#define AG71XX_REG_MII_IND 0x0034
  38431. +#define AG71XX_REG_MAC_IFCTL 0x0038
  38432. +#define AG71XX_REG_MAC_ADDR1 0x0040
  38433. +#define AG71XX_REG_MAC_ADDR2 0x0044
  38434. +#define AG71XX_REG_FIFO_CFG0 0x0048
  38435. +#define AG71XX_REG_FIFO_CFG1 0x004c
  38436. +#define AG71XX_REG_FIFO_CFG2 0x0050
  38437. +#define AG71XX_REG_FIFO_CFG3 0x0054
  38438. +#define AG71XX_REG_FIFO_CFG4 0x0058
  38439. +#define AG71XX_REG_FIFO_CFG5 0x005c
  38440. +#define AG71XX_REG_FIFO_RAM0 0x0060
  38441. +#define AG71XX_REG_FIFO_RAM1 0x0064
  38442. +#define AG71XX_REG_FIFO_RAM2 0x0068
  38443. +#define AG71XX_REG_FIFO_RAM3 0x006c
  38444. +#define AG71XX_REG_FIFO_RAM4 0x0070
  38445. +#define AG71XX_REG_FIFO_RAM5 0x0074
  38446. +#define AG71XX_REG_FIFO_RAM6 0x0078
  38447. +#define AG71XX_REG_FIFO_RAM7 0x007c
  38448. +
  38449. +#define AG71XX_REG_TX_CTRL 0x0180
  38450. +#define AG71XX_REG_TX_DESC 0x0184
  38451. +#define AG71XX_REG_TX_STATUS 0x0188
  38452. +#define AG71XX_REG_RX_CTRL 0x018c
  38453. +#define AG71XX_REG_RX_DESC 0x0190
  38454. +#define AG71XX_REG_RX_STATUS 0x0194
  38455. +#define AG71XX_REG_INT_ENABLE 0x0198
  38456. +#define AG71XX_REG_INT_STATUS 0x019c
  38457. +
  38458. +#define AG71XX_REG_FIFO_DEPTH 0x01a8
  38459. +#define AG71XX_REG_RX_SM 0x01b0
  38460. +#define AG71XX_REG_TX_SM 0x01b4
  38461. +
  38462. +#define MAC_CFG1_TXE BIT(0) /* Tx Enable */
  38463. +#define MAC_CFG1_STX BIT(1) /* Synchronize Tx Enable */
  38464. +#define MAC_CFG1_RXE BIT(2) /* Rx Enable */
  38465. +#define MAC_CFG1_SRX BIT(3) /* Synchronize Rx Enable */
  38466. +#define MAC_CFG1_TFC BIT(4) /* Tx Flow Control Enable */
  38467. +#define MAC_CFG1_RFC BIT(5) /* Rx Flow Control Enable */
  38468. +#define MAC_CFG1_LB BIT(8) /* Loopback mode */
  38469. +#define MAC_CFG1_SR BIT(31) /* Soft Reset */
  38470. +
  38471. +#define MAC_CFG2_FDX BIT(0)
  38472. +#define MAC_CFG2_CRC_EN BIT(1)
  38473. +#define MAC_CFG2_PAD_CRC_EN BIT(2)
  38474. +#define MAC_CFG2_LEN_CHECK BIT(4)
  38475. +#define MAC_CFG2_HUGE_FRAME_EN BIT(5)
  38476. +#define MAC_CFG2_IF_1000 BIT(9)
  38477. +#define MAC_CFG2_IF_10_100 BIT(8)
  38478. +
  38479. +#define FIFO_CFG0_WTM BIT(0) /* Watermark Module */
  38480. +#define FIFO_CFG0_RXS BIT(1) /* Rx System Module */
  38481. +#define FIFO_CFG0_RXF BIT(2) /* Rx Fabric Module */
  38482. +#define FIFO_CFG0_TXS BIT(3) /* Tx System Module */
  38483. +#define FIFO_CFG0_TXF BIT(4) /* Tx Fabric Module */
  38484. +#define FIFO_CFG0_ALL (FIFO_CFG0_WTM | FIFO_CFG0_RXS | FIFO_CFG0_RXF \
  38485. + | FIFO_CFG0_TXS | FIFO_CFG0_TXF)
  38486. +
  38487. +#define FIFO_CFG0_ENABLE_SHIFT 8
  38488. +
  38489. +#define FIFO_CFG4_DE BIT(0) /* Drop Event */
  38490. +#define FIFO_CFG4_DV BIT(1) /* RX_DV Event */
  38491. +#define FIFO_CFG4_FC BIT(2) /* False Carrier */
  38492. +#define FIFO_CFG4_CE BIT(3) /* Code Error */
  38493. +#define FIFO_CFG4_CR BIT(4) /* CRC error */
  38494. +#define FIFO_CFG4_LM BIT(5) /* Length Mismatch */
  38495. +#define FIFO_CFG4_LO BIT(6) /* Length out of range */
  38496. +#define FIFO_CFG4_OK BIT(7) /* Packet is OK */
  38497. +#define FIFO_CFG4_MC BIT(8) /* Multicast Packet */
  38498. +#define FIFO_CFG4_BC BIT(9) /* Broadcast Packet */
  38499. +#define FIFO_CFG4_DR BIT(10) /* Dribble */
  38500. +#define FIFO_CFG4_LE BIT(11) /* Long Event */
  38501. +#define FIFO_CFG4_CF BIT(12) /* Control Frame */
  38502. +#define FIFO_CFG4_PF BIT(13) /* Pause Frame */
  38503. +#define FIFO_CFG4_UO BIT(14) /* Unsupported Opcode */
  38504. +#define FIFO_CFG4_VT BIT(15) /* VLAN tag detected */
  38505. +#define FIFO_CFG4_FT BIT(16) /* Frame Truncated */
  38506. +#define FIFO_CFG4_UC BIT(17) /* Unicast Packet */
  38507. +
  38508. +#define FIFO_CFG5_DE BIT(0) /* Drop Event */
  38509. +#define FIFO_CFG5_DV BIT(1) /* RX_DV Event */
  38510. +#define FIFO_CFG5_FC BIT(2) /* False Carrier */
  38511. +#define FIFO_CFG5_CE BIT(3) /* Code Error */
  38512. +#define FIFO_CFG5_LM BIT(4) /* Length Mismatch */
  38513. +#define FIFO_CFG5_LO BIT(5) /* Length Out of Range */
  38514. +#define FIFO_CFG5_OK BIT(6) /* Packet is OK */
  38515. +#define FIFO_CFG5_MC BIT(7) /* Multicast Packet */
  38516. +#define FIFO_CFG5_BC BIT(8) /* Broadcast Packet */
  38517. +#define FIFO_CFG5_DR BIT(9) /* Dribble */
  38518. +#define FIFO_CFG5_CF BIT(10) /* Control Frame */
  38519. +#define FIFO_CFG5_PF BIT(11) /* Pause Frame */
  38520. +#define FIFO_CFG5_UO BIT(12) /* Unsupported Opcode */
  38521. +#define FIFO_CFG5_VT BIT(13) /* VLAN tag detected */
  38522. +#define FIFO_CFG5_LE BIT(14) /* Long Event */
  38523. +#define FIFO_CFG5_FT BIT(15) /* Frame Truncated */
  38524. +#define FIFO_CFG5_16 BIT(16) /* unknown */
  38525. +#define FIFO_CFG5_17 BIT(17) /* unknown */
  38526. +#define FIFO_CFG5_SF BIT(18) /* Short Frame */
  38527. +#define FIFO_CFG5_BM BIT(19) /* Byte Mode */
  38528. +
  38529. +#define AG71XX_INT_TX_PS BIT(0)
  38530. +#define AG71XX_INT_TX_UR BIT(1)
  38531. +#define AG71XX_INT_TX_BE BIT(3)
  38532. +#define AG71XX_INT_RX_PR BIT(4)
  38533. +#define AG71XX_INT_RX_OF BIT(6)
  38534. +#define AG71XX_INT_RX_BE BIT(7)
  38535. +
  38536. +#define MAC_IFCTL_SPEED BIT(16)
  38537. +
  38538. +#define MII_CFG_CLK_DIV_4 0
  38539. +#define MII_CFG_CLK_DIV_6 2
  38540. +#define MII_CFG_CLK_DIV_8 3
  38541. +#define MII_CFG_CLK_DIV_10 4
  38542. +#define MII_CFG_CLK_DIV_14 5
  38543. +#define MII_CFG_CLK_DIV_20 6
  38544. +#define MII_CFG_CLK_DIV_28 7
  38545. +#define MII_CFG_CLK_DIV_34 8
  38546. +#define MII_CFG_CLK_DIV_42 9
  38547. +#define MII_CFG_CLK_DIV_50 10
  38548. +#define MII_CFG_CLK_DIV_58 11
  38549. +#define MII_CFG_CLK_DIV_66 12
  38550. +#define MII_CFG_CLK_DIV_74 13
  38551. +#define MII_CFG_CLK_DIV_82 14
  38552. +#define MII_CFG_CLK_DIV_98 15
  38553. +#define MII_CFG_RESET BIT(31)
  38554. +
  38555. +#define MII_CMD_WRITE 0x0
  38556. +#define MII_CMD_READ 0x1
  38557. +#define MII_ADDR_SHIFT 8
  38558. +#define MII_IND_BUSY BIT(0)
  38559. +#define MII_IND_INVALID BIT(2)
  38560. +
  38561. +#define TX_CTRL_TXE BIT(0) /* Tx Enable */
  38562. +
  38563. +#define TX_STATUS_PS BIT(0) /* Packet Sent */
  38564. +#define TX_STATUS_UR BIT(1) /* Tx Underrun */
  38565. +#define TX_STATUS_BE BIT(3) /* Bus Error */
  38566. +
  38567. +#define RX_CTRL_RXE BIT(0) /* Rx Enable */
  38568. +
  38569. +#define RX_STATUS_PR BIT(0) /* Packet Received */
  38570. +#define RX_STATUS_OF BIT(2) /* Rx Overflow */
  38571. +#define RX_STATUS_BE BIT(3) /* Bus Error */
  38572. +
  38573. +static inline void ag71xx_check_reg_offset(struct ag71xx *ag, unsigned reg)
  38574. +{
  38575. + switch (reg) {
  38576. + case AG71XX_REG_MAC_CFG1 ... AG71XX_REG_MAC_MFL:
  38577. + case AG71XX_REG_MAC_IFCTL ... AG71XX_REG_TX_SM:
  38578. + case AG71XX_REG_MII_CFG:
  38579. + break;
  38580. +
  38581. + default:
  38582. + BUG();
  38583. + }
  38584. +}
  38585. +
  38586. +static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
  38587. +{
  38588. + ag71xx_check_reg_offset(ag, reg);
  38589. +
  38590. + __raw_writel(value, ag->mac_base + reg);
  38591. + /* flush write */
  38592. + (void) __raw_readl(ag->mac_base + reg);
  38593. +}
  38594. +
  38595. +static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
  38596. +{
  38597. + ag71xx_check_reg_offset(ag, reg);
  38598. +
  38599. + return __raw_readl(ag->mac_base + reg);
  38600. +}
  38601. +
  38602. +static inline void ag71xx_sb(struct ag71xx *ag, unsigned reg, u32 mask)
  38603. +{
  38604. + void __iomem *r;
  38605. +
  38606. + ag71xx_check_reg_offset(ag, reg);
  38607. +
  38608. + r = ag->mac_base + reg;
  38609. + __raw_writel(__raw_readl(r) | mask, r);
  38610. + /* flush write */
  38611. + (void)__raw_readl(r);
  38612. +}
  38613. +
  38614. +static inline void ag71xx_cb(struct ag71xx *ag, unsigned reg, u32 mask)
  38615. +{
  38616. + void __iomem *r;
  38617. +
  38618. + ag71xx_check_reg_offset(ag, reg);
  38619. +
  38620. + r = ag->mac_base + reg;
  38621. + __raw_writel(__raw_readl(r) & ~mask, r);
  38622. + /* flush write */
  38623. + (void) __raw_readl(r);
  38624. +}
  38625. +
  38626. +static inline void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
  38627. +{
  38628. + ag71xx_sb(ag, AG71XX_REG_INT_ENABLE, ints);
  38629. +}
  38630. +
  38631. +static inline void ag71xx_int_disable(struct ag71xx *ag, u32 ints)
  38632. +{
  38633. + ag71xx_cb(ag, AG71XX_REG_INT_ENABLE, ints);
  38634. +}
  38635. +
  38636. +#ifdef CONFIG_AG71XX_AR8216_SUPPORT
  38637. +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb);
  38638. +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
  38639. + int pktlen);
  38640. +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
  38641. +{
  38642. + return ag71xx_get_pdata(ag)->has_ar8216;
  38643. +}
  38644. +#else
  38645. +static inline void ag71xx_add_ar8216_header(struct ag71xx *ag,
  38646. + struct sk_buff *skb)
  38647. +{
  38648. +}
  38649. +
  38650. +static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
  38651. + struct sk_buff *skb,
  38652. + int pktlen)
  38653. +{
  38654. + return 0;
  38655. +}
  38656. +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
  38657. +{
  38658. + return 0;
  38659. +}
  38660. +#endif
  38661. +
  38662. +#ifdef CONFIG_AG71XX_DEBUG_FS
  38663. +int ag71xx_debugfs_root_init(void);
  38664. +void ag71xx_debugfs_root_exit(void);
  38665. +int ag71xx_debugfs_init(struct ag71xx *ag);
  38666. +void ag71xx_debugfs_exit(struct ag71xx *ag);
  38667. +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status);
  38668. +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx);
  38669. +#else
  38670. +static inline int ag71xx_debugfs_root_init(void) { return 0; }
  38671. +static inline void ag71xx_debugfs_root_exit(void) {}
  38672. +static inline int ag71xx_debugfs_init(struct ag71xx *ag) { return 0; }
  38673. +static inline void ag71xx_debugfs_exit(struct ag71xx *ag) {}
  38674. +static inline void ag71xx_debugfs_update_int_stats(struct ag71xx *ag,
  38675. + u32 status) {}
  38676. +static inline void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag,
  38677. + int rx, int tx) {}
  38678. +#endif /* CONFIG_AG71XX_DEBUG_FS */
  38679. +
  38680. +void ag71xx_ar7240_start(struct ag71xx *ag);
  38681. +void ag71xx_ar7240_stop(struct ag71xx *ag);
  38682. +int ag71xx_ar7240_init(struct ag71xx *ag);
  38683. +void ag71xx_ar7240_cleanup(struct ag71xx *ag);
  38684. +
  38685. +int ag71xx_mdio_mii_read(struct ag71xx_mdio *am, int addr, int reg);
  38686. +void ag71xx_mdio_mii_write(struct ag71xx_mdio *am, int addr, int reg, u16 val);
  38687. +
  38688. +u16 ar7240sw_phy_read(struct mii_bus *mii, unsigned phy_addr,
  38689. + unsigned reg_addr);
  38690. +int ar7240sw_phy_write(struct mii_bus *mii, unsigned phy_addr,
  38691. + unsigned reg_addr, u16 reg_val);
  38692. +
  38693. +#endif /* _AG71XX_H */
  38694. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
  38695. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 1970-01-01 01:00:00.000000000 +0100
  38696. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 2015-09-13 20:04:35.076523692 +0200
  38697. @@ -0,0 +1,1406 @@
  38698. +/*
  38699. + * Atheros AR71xx built-in ethernet mac driver
  38700. + *
  38701. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  38702. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  38703. + *
  38704. + * Based on Atheros' AG7100 driver
  38705. + *
  38706. + * This program is free software; you can redistribute it and/or modify it
  38707. + * under the terms of the GNU General Public License version 2 as published
  38708. + * by the Free Software Foundation.
  38709. + */
  38710. +
  38711. +#include "ag71xx.h"
  38712. +
  38713. +#define AG71XX_DEFAULT_MSG_ENABLE \
  38714. + (NETIF_MSG_DRV \
  38715. + | NETIF_MSG_PROBE \
  38716. + | NETIF_MSG_LINK \
  38717. + | NETIF_MSG_TIMER \
  38718. + | NETIF_MSG_IFDOWN \
  38719. + | NETIF_MSG_IFUP \
  38720. + | NETIF_MSG_RX_ERR \
  38721. + | NETIF_MSG_TX_ERR)
  38722. +
  38723. +static int ag71xx_msg_level = -1;
  38724. +
  38725. +module_param_named(msg_level, ag71xx_msg_level, int, 0);
  38726. +MODULE_PARM_DESC(msg_level, "Message level (-1=defaults,0=none,...,16=all)");
  38727. +
  38728. +#define ETH_SWITCH_HEADER_LEN 2
  38729. +
  38730. +static inline unsigned int ag71xx_max_frame_len(unsigned int mtu)
  38731. +{
  38732. + return ETH_SWITCH_HEADER_LEN + ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN;
  38733. +}
  38734. +
  38735. +static void ag71xx_dump_dma_regs(struct ag71xx *ag)
  38736. +{
  38737. + DBG("%s: dma_tx_ctrl=%08x, dma_tx_desc=%08x, dma_tx_status=%08x\n",
  38738. + ag->dev->name,
  38739. + ag71xx_rr(ag, AG71XX_REG_TX_CTRL),
  38740. + ag71xx_rr(ag, AG71XX_REG_TX_DESC),
  38741. + ag71xx_rr(ag, AG71XX_REG_TX_STATUS));
  38742. +
  38743. + DBG("%s: dma_rx_ctrl=%08x, dma_rx_desc=%08x, dma_rx_status=%08x\n",
  38744. + ag->dev->name,
  38745. + ag71xx_rr(ag, AG71XX_REG_RX_CTRL),
  38746. + ag71xx_rr(ag, AG71XX_REG_RX_DESC),
  38747. + ag71xx_rr(ag, AG71XX_REG_RX_STATUS));
  38748. +}
  38749. +
  38750. +static void ag71xx_dump_regs(struct ag71xx *ag)
  38751. +{
  38752. + DBG("%s: mac_cfg1=%08x, mac_cfg2=%08x, ipg=%08x, hdx=%08x, mfl=%08x\n",
  38753. + ag->dev->name,
  38754. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG1),
  38755. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
  38756. + ag71xx_rr(ag, AG71XX_REG_MAC_IPG),
  38757. + ag71xx_rr(ag, AG71XX_REG_MAC_HDX),
  38758. + ag71xx_rr(ag, AG71XX_REG_MAC_MFL));
  38759. + DBG("%s: mac_ifctl=%08x, mac_addr1=%08x, mac_addr2=%08x\n",
  38760. + ag->dev->name,
  38761. + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
  38762. + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR1),
  38763. + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR2));
  38764. + DBG("%s: fifo_cfg0=%08x, fifo_cfg1=%08x, fifo_cfg2=%08x\n",
  38765. + ag->dev->name,
  38766. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
  38767. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
  38768. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
  38769. + DBG("%s: fifo_cfg3=%08x, fifo_cfg4=%08x, fifo_cfg5=%08x\n",
  38770. + ag->dev->name,
  38771. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
  38772. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
  38773. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
  38774. +}
  38775. +
  38776. +static inline void ag71xx_dump_intr(struct ag71xx *ag, char *label, u32 intr)
  38777. +{
  38778. + DBG("%s: %s intr=%08x %s%s%s%s%s%s\n",
  38779. + ag->dev->name, label, intr,
  38780. + (intr & AG71XX_INT_TX_PS) ? "TXPS " : "",
  38781. + (intr & AG71XX_INT_TX_UR) ? "TXUR " : "",
  38782. + (intr & AG71XX_INT_TX_BE) ? "TXBE " : "",
  38783. + (intr & AG71XX_INT_RX_PR) ? "RXPR " : "",
  38784. + (intr & AG71XX_INT_RX_OF) ? "RXOF " : "",
  38785. + (intr & AG71XX_INT_RX_BE) ? "RXBE " : "");
  38786. +}
  38787. +
  38788. +static void ag71xx_ring_free(struct ag71xx_ring *ring)
  38789. +{
  38790. + kfree(ring->buf);
  38791. +
  38792. + if (ring->descs_cpu)
  38793. + dma_free_coherent(NULL, ring->size * ring->desc_size,
  38794. + ring->descs_cpu, ring->descs_dma);
  38795. +}
  38796. +
  38797. +static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
  38798. +{
  38799. + int err;
  38800. +
  38801. + ring->desc_size = sizeof(struct ag71xx_desc);
  38802. + if (ring->desc_size % cache_line_size()) {
  38803. + DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
  38804. + ring, ring->desc_size,
  38805. + roundup(ring->desc_size, cache_line_size()));
  38806. + ring->desc_size = roundup(ring->desc_size, cache_line_size());
  38807. + }
  38808. +
  38809. + ring->descs_cpu = dma_alloc_coherent(NULL, ring->size * ring->desc_size,
  38810. + &ring->descs_dma, GFP_ATOMIC);
  38811. + if (!ring->descs_cpu) {
  38812. + err = -ENOMEM;
  38813. + goto err;
  38814. + }
  38815. +
  38816. +
  38817. + ring->buf = kzalloc(ring->size * sizeof(*ring->buf), GFP_KERNEL);
  38818. + if (!ring->buf) {
  38819. + err = -ENOMEM;
  38820. + goto err;
  38821. + }
  38822. +
  38823. + return 0;
  38824. +
  38825. +err:
  38826. + return err;
  38827. +}
  38828. +
  38829. +static void ag71xx_ring_tx_clean(struct ag71xx *ag)
  38830. +{
  38831. + struct ag71xx_ring *ring = &ag->tx_ring;
  38832. + struct net_device *dev = ag->dev;
  38833. + u32 bytes_compl = 0, pkts_compl = 0;
  38834. +
  38835. + while (ring->curr != ring->dirty) {
  38836. + struct ag71xx_desc *desc;
  38837. + u32 i = ring->dirty % ring->size;
  38838. +
  38839. + desc = ag71xx_ring_desc(ring, i);
  38840. + if (!ag71xx_desc_empty(desc)) {
  38841. + desc->ctrl = 0;
  38842. + dev->stats.tx_errors++;
  38843. + }
  38844. +
  38845. + if (ring->buf[i].skb) {
  38846. + bytes_compl += ring->buf[i].len;
  38847. + pkts_compl++;
  38848. + dev_kfree_skb_any(ring->buf[i].skb);
  38849. + }
  38850. + ring->buf[i].skb = NULL;
  38851. + ring->dirty++;
  38852. + }
  38853. +
  38854. + /* flush descriptors */
  38855. + wmb();
  38856. +
  38857. + netdev_completed_queue(dev, pkts_compl, bytes_compl);
  38858. +}
  38859. +
  38860. +static void ag71xx_ring_tx_init(struct ag71xx *ag)
  38861. +{
  38862. + struct ag71xx_ring *ring = &ag->tx_ring;
  38863. + int i;
  38864. +
  38865. + for (i = 0; i < ring->size; i++) {
  38866. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  38867. +
  38868. + desc->next = (u32) (ring->descs_dma +
  38869. + ring->desc_size * ((i + 1) % ring->size));
  38870. +
  38871. + desc->ctrl = DESC_EMPTY;
  38872. + ring->buf[i].skb = NULL;
  38873. + }
  38874. +
  38875. + /* flush descriptors */
  38876. + wmb();
  38877. +
  38878. + ring->curr = 0;
  38879. + ring->dirty = 0;
  38880. + netdev_reset_queue(ag->dev);
  38881. +}
  38882. +
  38883. +static void ag71xx_ring_rx_clean(struct ag71xx *ag)
  38884. +{
  38885. + struct ag71xx_ring *ring = &ag->rx_ring;
  38886. + int i;
  38887. +
  38888. + if (!ring->buf)
  38889. + return;
  38890. +
  38891. + for (i = 0; i < ring->size; i++)
  38892. + if (ring->buf[i].rx_buf) {
  38893. + dma_unmap_single(&ag->dev->dev, ring->buf[i].dma_addr,
  38894. + ag->rx_buf_size, DMA_FROM_DEVICE);
  38895. + kfree(ring->buf[i].rx_buf);
  38896. + }
  38897. +}
  38898. +
  38899. +static int ag71xx_buffer_offset(struct ag71xx *ag)
  38900. +{
  38901. + int offset = NET_SKB_PAD;
  38902. +
  38903. + /*
  38904. + * On AR71xx/AR91xx packets must be 4-byte aligned.
  38905. + *
  38906. + * When using builtin AR8216 support, hardware adds a 2-byte header,
  38907. + * so we don't need any extra alignment in that case.
  38908. + */
  38909. + if (!ag71xx_get_pdata(ag)->is_ar724x || ag71xx_has_ar8216(ag))
  38910. + return offset;
  38911. +
  38912. + return offset + NET_IP_ALIGN;
  38913. +}
  38914. +
  38915. +static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct ag71xx_buf *buf,
  38916. + int offset)
  38917. +{
  38918. + struct ag71xx_ring *ring = &ag->rx_ring;
  38919. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, buf - &ring->buf[0]);
  38920. + void *data;
  38921. +
  38922. + data = kmalloc(ag->rx_buf_size +
  38923. + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
  38924. + GFP_ATOMIC);
  38925. + if (!data)
  38926. + return false;
  38927. +
  38928. + buf->rx_buf = data;
  38929. + buf->dma_addr = dma_map_single(&ag->dev->dev, data, ag->rx_buf_size,
  38930. + DMA_FROM_DEVICE);
  38931. + desc->data = (u32) buf->dma_addr + offset;
  38932. + return true;
  38933. +}
  38934. +
  38935. +static int ag71xx_ring_rx_init(struct ag71xx *ag)
  38936. +{
  38937. + struct ag71xx_ring *ring = &ag->rx_ring;
  38938. + unsigned int i;
  38939. + int ret;
  38940. + int offset = ag71xx_buffer_offset(ag);
  38941. +
  38942. + ret = 0;
  38943. + for (i = 0; i < ring->size; i++) {
  38944. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  38945. +
  38946. + desc->next = (u32) (ring->descs_dma +
  38947. + ring->desc_size * ((i + 1) % ring->size));
  38948. +
  38949. + DBG("ag71xx: RX desc at %p, next is %08x\n",
  38950. + desc, desc->next);
  38951. + }
  38952. +
  38953. + for (i = 0; i < ring->size; i++) {
  38954. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  38955. +
  38956. + if (!ag71xx_fill_rx_buf(ag, &ring->buf[i], offset)) {
  38957. + ret = -ENOMEM;
  38958. + break;
  38959. + }
  38960. +
  38961. + desc->ctrl = DESC_EMPTY;
  38962. + }
  38963. +
  38964. + /* flush descriptors */
  38965. + wmb();
  38966. +
  38967. + ring->curr = 0;
  38968. + ring->dirty = 0;
  38969. +
  38970. + return ret;
  38971. +}
  38972. +
  38973. +static int ag71xx_ring_rx_refill(struct ag71xx *ag)
  38974. +{
  38975. + struct ag71xx_ring *ring = &ag->rx_ring;
  38976. + unsigned int count;
  38977. + int offset = ag71xx_buffer_offset(ag);
  38978. +
  38979. + count = 0;
  38980. + for (; ring->curr - ring->dirty > 0; ring->dirty++) {
  38981. + struct ag71xx_desc *desc;
  38982. + unsigned int i;
  38983. +
  38984. + i = ring->dirty % ring->size;
  38985. + desc = ag71xx_ring_desc(ring, i);
  38986. +
  38987. + if (!ring->buf[i].rx_buf &&
  38988. + !ag71xx_fill_rx_buf(ag, &ring->buf[i], offset))
  38989. + break;
  38990. +
  38991. + desc->ctrl = DESC_EMPTY;
  38992. + count++;
  38993. + }
  38994. +
  38995. + /* flush descriptors */
  38996. + wmb();
  38997. +
  38998. + DBG("%s: %u rx descriptors refilled\n", ag->dev->name, count);
  38999. +
  39000. + return count;
  39001. +}
  39002. +
  39003. +static int ag71xx_rings_init(struct ag71xx *ag)
  39004. +{
  39005. + int ret;
  39006. +
  39007. + ret = ag71xx_ring_alloc(&ag->tx_ring);
  39008. + if (ret)
  39009. + return ret;
  39010. +
  39011. + ag71xx_ring_tx_init(ag);
  39012. +
  39013. + ret = ag71xx_ring_alloc(&ag->rx_ring);
  39014. + if (ret)
  39015. + return ret;
  39016. +
  39017. + ret = ag71xx_ring_rx_init(ag);
  39018. + return ret;
  39019. +}
  39020. +
  39021. +static void ag71xx_rings_cleanup(struct ag71xx *ag)
  39022. +{
  39023. + ag71xx_ring_rx_clean(ag);
  39024. + ag71xx_ring_free(&ag->rx_ring);
  39025. +
  39026. + ag71xx_ring_tx_clean(ag);
  39027. + netdev_reset_queue(ag->dev);
  39028. + ag71xx_ring_free(&ag->tx_ring);
  39029. +}
  39030. +
  39031. +static unsigned char *ag71xx_speed_str(struct ag71xx *ag)
  39032. +{
  39033. + switch (ag->speed) {
  39034. + case SPEED_1000:
  39035. + return "1000";
  39036. + case SPEED_100:
  39037. + return "100";
  39038. + case SPEED_10:
  39039. + return "10";
  39040. + }
  39041. +
  39042. + return "?";
  39043. +}
  39044. +
  39045. +static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
  39046. +{
  39047. + u32 t;
  39048. +
  39049. + t = (((u32) mac[5]) << 24) | (((u32) mac[4]) << 16)
  39050. + | (((u32) mac[3]) << 8) | ((u32) mac[2]);
  39051. +
  39052. + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR1, t);
  39053. +
  39054. + t = (((u32) mac[1]) << 24) | (((u32) mac[0]) << 16);
  39055. + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR2, t);
  39056. +}
  39057. +
  39058. +static void ag71xx_dma_reset(struct ag71xx *ag)
  39059. +{
  39060. + u32 val;
  39061. + int i;
  39062. +
  39063. + ag71xx_dump_dma_regs(ag);
  39064. +
  39065. + /* stop RX and TX */
  39066. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
  39067. + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
  39068. +
  39069. + /*
  39070. + * give the hardware some time to really stop all rx/tx activity
  39071. + * clearing the descriptors too early causes random memory corruption
  39072. + */
  39073. + mdelay(1);
  39074. +
  39075. + /* clear descriptor addresses */
  39076. + ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->stop_desc_dma);
  39077. + ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->stop_desc_dma);
  39078. +
  39079. + /* clear pending RX/TX interrupts */
  39080. + for (i = 0; i < 256; i++) {
  39081. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
  39082. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
  39083. + }
  39084. +
  39085. + /* clear pending errors */
  39086. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE | RX_STATUS_OF);
  39087. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE | TX_STATUS_UR);
  39088. +
  39089. + val = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
  39090. + if (val)
  39091. + pr_alert("%s: unable to clear DMA Rx status: %08x\n",
  39092. + ag->dev->name, val);
  39093. +
  39094. + val = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
  39095. +
  39096. + /* mask out reserved bits */
  39097. + val &= ~0xff000000;
  39098. +
  39099. + if (val)
  39100. + pr_alert("%s: unable to clear DMA Tx status: %08x\n",
  39101. + ag->dev->name, val);
  39102. +
  39103. + ag71xx_dump_dma_regs(ag);
  39104. +}
  39105. +
  39106. +#define MAC_CFG1_INIT (MAC_CFG1_RXE | MAC_CFG1_TXE | \
  39107. + MAC_CFG1_SRX | MAC_CFG1_STX)
  39108. +
  39109. +#define FIFO_CFG0_INIT (FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT)
  39110. +
  39111. +#define FIFO_CFG4_INIT (FIFO_CFG4_DE | FIFO_CFG4_DV | FIFO_CFG4_FC | \
  39112. + FIFO_CFG4_CE | FIFO_CFG4_CR | FIFO_CFG4_LM | \
  39113. + FIFO_CFG4_LO | FIFO_CFG4_OK | FIFO_CFG4_MC | \
  39114. + FIFO_CFG4_BC | FIFO_CFG4_DR | FIFO_CFG4_LE | \
  39115. + FIFO_CFG4_CF | FIFO_CFG4_PF | FIFO_CFG4_UO | \
  39116. + FIFO_CFG4_VT)
  39117. +
  39118. +#define FIFO_CFG5_INIT (FIFO_CFG5_DE | FIFO_CFG5_DV | FIFO_CFG5_FC | \
  39119. + FIFO_CFG5_CE | FIFO_CFG5_LO | FIFO_CFG5_OK | \
  39120. + FIFO_CFG5_MC | FIFO_CFG5_BC | FIFO_CFG5_DR | \
  39121. + FIFO_CFG5_CF | FIFO_CFG5_PF | FIFO_CFG5_VT | \
  39122. + FIFO_CFG5_LE | FIFO_CFG5_FT | FIFO_CFG5_16 | \
  39123. + FIFO_CFG5_17 | FIFO_CFG5_SF)
  39124. +
  39125. +static void ag71xx_hw_stop(struct ag71xx *ag)
  39126. +{
  39127. + /* disable all interrupts and stop the rx/tx engine */
  39128. + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, 0);
  39129. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
  39130. + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
  39131. +}
  39132. +
  39133. +static void ag71xx_hw_setup(struct ag71xx *ag)
  39134. +{
  39135. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39136. +
  39137. + /* setup MAC configuration registers */
  39138. + ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_INIT);
  39139. +
  39140. + ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
  39141. + MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
  39142. +
  39143. + /* setup max frame length to zero */
  39144. + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, 0);
  39145. +
  39146. + /* setup FIFO configuration registers */
  39147. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT);
  39148. + if (pdata->is_ar724x) {
  39149. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, pdata->fifo_cfg1);
  39150. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, pdata->fifo_cfg2);
  39151. + } else {
  39152. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, 0x0fff0000);
  39153. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, 0x00001fff);
  39154. + }
  39155. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG4, FIFO_CFG4_INIT);
  39156. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, FIFO_CFG5_INIT);
  39157. +}
  39158. +
  39159. +static void ag71xx_hw_init(struct ag71xx *ag)
  39160. +{
  39161. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39162. + u32 reset_mask = pdata->reset_bit;
  39163. +
  39164. + ag71xx_hw_stop(ag);
  39165. +
  39166. + if (pdata->is_ar724x) {
  39167. + u32 reset_phy = reset_mask;
  39168. +
  39169. + reset_phy &= AR71XX_RESET_GE0_PHY | AR71XX_RESET_GE1_PHY;
  39170. + reset_mask &= ~(AR71XX_RESET_GE0_PHY | AR71XX_RESET_GE1_PHY);
  39171. +
  39172. + ath79_device_reset_set(reset_phy);
  39173. + msleep(50);
  39174. + ath79_device_reset_clear(reset_phy);
  39175. + msleep(200);
  39176. + }
  39177. +
  39178. + ag71xx_sb(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_SR);
  39179. + udelay(20);
  39180. +
  39181. + ath79_device_reset_set(reset_mask);
  39182. + msleep(100);
  39183. + ath79_device_reset_clear(reset_mask);
  39184. + msleep(200);
  39185. +
  39186. + ag71xx_hw_setup(ag);
  39187. +
  39188. + ag71xx_dma_reset(ag);
  39189. +}
  39190. +
  39191. +static void ag71xx_fast_reset(struct ag71xx *ag)
  39192. +{
  39193. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39194. + struct net_device *dev = ag->dev;
  39195. + u32 reset_mask = pdata->reset_bit;
  39196. + u32 rx_ds, tx_ds;
  39197. + u32 mii_reg;
  39198. +
  39199. + reset_mask &= AR71XX_RESET_GE0_MAC | AR71XX_RESET_GE1_MAC;
  39200. +
  39201. + mii_reg = ag71xx_rr(ag, AG71XX_REG_MII_CFG);
  39202. + rx_ds = ag71xx_rr(ag, AG71XX_REG_RX_DESC);
  39203. + tx_ds = ag71xx_rr(ag, AG71XX_REG_TX_DESC);
  39204. +
  39205. + ath79_device_reset_set(reset_mask);
  39206. + udelay(10);
  39207. + ath79_device_reset_clear(reset_mask);
  39208. + udelay(10);
  39209. +
  39210. + ag71xx_dma_reset(ag);
  39211. + ag71xx_hw_setup(ag);
  39212. +
  39213. + /* setup max frame length */
  39214. + ag71xx_wr(ag, AG71XX_REG_MAC_MFL,
  39215. + ag71xx_max_frame_len(ag->dev->mtu));
  39216. +
  39217. + ag71xx_wr(ag, AG71XX_REG_RX_DESC, rx_ds);
  39218. + ag71xx_wr(ag, AG71XX_REG_TX_DESC, tx_ds);
  39219. + ag71xx_wr(ag, AG71XX_REG_MII_CFG, mii_reg);
  39220. +
  39221. + ag71xx_hw_set_macaddr(ag, dev->dev_addr);
  39222. +}
  39223. +
  39224. +static void ag71xx_hw_start(struct ag71xx *ag)
  39225. +{
  39226. + /* start RX engine */
  39227. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
  39228. +
  39229. + /* enable interrupts */
  39230. + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, AG71XX_INT_INIT);
  39231. +}
  39232. +
  39233. +void ag71xx_link_adjust(struct ag71xx *ag)
  39234. +{
  39235. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39236. + u32 cfg2;
  39237. + u32 ifctl;
  39238. + u32 fifo5;
  39239. + u32 fifo3;
  39240. +
  39241. + if (!ag->link) {
  39242. + ag71xx_hw_stop(ag);
  39243. + netif_carrier_off(ag->dev);
  39244. + if (netif_msg_link(ag))
  39245. + pr_info("%s: link down\n", ag->dev->name);
  39246. + return;
  39247. + }
  39248. +
  39249. + if (pdata->is_ar724x)
  39250. + ag71xx_fast_reset(ag);
  39251. +
  39252. + cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
  39253. + cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
  39254. + cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
  39255. +
  39256. + ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
  39257. + ifctl &= ~(MAC_IFCTL_SPEED);
  39258. +
  39259. + fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
  39260. + fifo5 &= ~FIFO_CFG5_BM;
  39261. +
  39262. + switch (ag->speed) {
  39263. + case SPEED_1000:
  39264. + cfg2 |= MAC_CFG2_IF_1000;
  39265. + fifo5 |= FIFO_CFG5_BM;
  39266. + break;
  39267. + case SPEED_100:
  39268. + cfg2 |= MAC_CFG2_IF_10_100;
  39269. + ifctl |= MAC_IFCTL_SPEED;
  39270. + break;
  39271. + case SPEED_10:
  39272. + cfg2 |= MAC_CFG2_IF_10_100;
  39273. + break;
  39274. + default:
  39275. + BUG();
  39276. + return;
  39277. + }
  39278. +
  39279. + if (pdata->is_ar91xx)
  39280. + fifo3 = 0x00780fff;
  39281. + else if (pdata->is_ar724x)
  39282. + fifo3 = pdata->fifo_cfg3;
  39283. + else
  39284. + fifo3 = 0x008001ff;
  39285. +
  39286. + if (ag->tx_ring.desc_split) {
  39287. + fifo3 &= 0xffff;
  39288. + fifo3 |= ((2048 - ag->tx_ring.desc_split) / 4) << 16;
  39289. + }
  39290. +
  39291. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, fifo3);
  39292. +
  39293. + if (pdata->set_speed)
  39294. + pdata->set_speed(ag->speed);
  39295. +
  39296. + ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
  39297. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
  39298. + ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
  39299. + ag71xx_hw_start(ag);
  39300. +
  39301. + netif_carrier_on(ag->dev);
  39302. + if (netif_msg_link(ag))
  39303. + pr_info("%s: link up (%sMbps/%s duplex)\n",
  39304. + ag->dev->name,
  39305. + ag71xx_speed_str(ag),
  39306. + (DUPLEX_FULL == ag->duplex) ? "Full" : "Half");
  39307. +
  39308. + DBG("%s: fifo_cfg0=%#x, fifo_cfg1=%#x, fifo_cfg2=%#x\n",
  39309. + ag->dev->name,
  39310. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
  39311. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
  39312. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
  39313. +
  39314. + DBG("%s: fifo_cfg3=%#x, fifo_cfg4=%#x, fifo_cfg5=%#x\n",
  39315. + ag->dev->name,
  39316. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
  39317. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
  39318. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
  39319. +
  39320. + DBG("%s: mac_cfg2=%#x, mac_ifctl=%#x\n",
  39321. + ag->dev->name,
  39322. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
  39323. + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL));
  39324. +}
  39325. +
  39326. +static int ag71xx_open(struct net_device *dev)
  39327. +{
  39328. + struct ag71xx *ag = netdev_priv(dev);
  39329. + unsigned int max_frame_len;
  39330. + int ret;
  39331. +
  39332. + max_frame_len = ag71xx_max_frame_len(dev->mtu);
  39333. + ag->rx_buf_size = max_frame_len + NET_SKB_PAD + NET_IP_ALIGN;
  39334. +
  39335. + /* setup max frame length */
  39336. + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, max_frame_len);
  39337. +
  39338. + ret = ag71xx_rings_init(ag);
  39339. + if (ret)
  39340. + goto err;
  39341. +
  39342. + napi_enable(&ag->napi);
  39343. +
  39344. + netif_carrier_off(dev);
  39345. + ag71xx_phy_start(ag);
  39346. +
  39347. + ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->tx_ring.descs_dma);
  39348. + ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->rx_ring.descs_dma);
  39349. +
  39350. + ag71xx_hw_set_macaddr(ag, dev->dev_addr);
  39351. +
  39352. + netif_start_queue(dev);
  39353. +
  39354. + return 0;
  39355. +
  39356. +err:
  39357. + ag71xx_rings_cleanup(ag);
  39358. + return ret;
  39359. +}
  39360. +
  39361. +static int ag71xx_stop(struct net_device *dev)
  39362. +{
  39363. + struct ag71xx *ag = netdev_priv(dev);
  39364. + unsigned long flags;
  39365. +
  39366. + netif_carrier_off(dev);
  39367. + ag71xx_phy_stop(ag);
  39368. +
  39369. + spin_lock_irqsave(&ag->lock, flags);
  39370. +
  39371. + netif_stop_queue(dev);
  39372. +
  39373. + ag71xx_hw_stop(ag);
  39374. + ag71xx_dma_reset(ag);
  39375. +
  39376. + napi_disable(&ag->napi);
  39377. + del_timer_sync(&ag->oom_timer);
  39378. +
  39379. + spin_unlock_irqrestore(&ag->lock, flags);
  39380. +
  39381. + ag71xx_rings_cleanup(ag);
  39382. +
  39383. + return 0;
  39384. +}
  39385. +
  39386. +static int ag71xx_fill_dma_desc(struct ag71xx_ring *ring, u32 addr, int len)
  39387. +{
  39388. + int i;
  39389. + struct ag71xx_desc *desc;
  39390. + int ndesc = 0;
  39391. + int split = ring->desc_split;
  39392. +
  39393. + if (!split)
  39394. + split = len;
  39395. +
  39396. + while (len > 0) {
  39397. + unsigned int cur_len = len;
  39398. +
  39399. + i = (ring->curr + ndesc) % ring->size;
  39400. + desc = ag71xx_ring_desc(ring, i);
  39401. +
  39402. + if (!ag71xx_desc_empty(desc))
  39403. + return -1;
  39404. +
  39405. + if (cur_len > split) {
  39406. + cur_len = split;
  39407. +
  39408. + /*
  39409. + * TX will hang if DMA transfers <= 4 bytes,
  39410. + * make sure next segment is more than 4 bytes long.
  39411. + */
  39412. + if (len <= split + 4)
  39413. + cur_len -= 4;
  39414. + }
  39415. +
  39416. + desc->data = addr;
  39417. + addr += cur_len;
  39418. + len -= cur_len;
  39419. +
  39420. + if (len > 0)
  39421. + cur_len |= DESC_MORE;
  39422. +
  39423. + /* prevent early tx attempt of this descriptor */
  39424. + if (!ndesc)
  39425. + cur_len |= DESC_EMPTY;
  39426. +
  39427. + desc->ctrl = cur_len;
  39428. + ndesc++;
  39429. + }
  39430. +
  39431. + return ndesc;
  39432. +}
  39433. +
  39434. +static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
  39435. + struct net_device *dev)
  39436. +{
  39437. + struct ag71xx *ag = netdev_priv(dev);
  39438. + struct ag71xx_ring *ring = &ag->tx_ring;
  39439. + struct ag71xx_desc *desc;
  39440. + dma_addr_t dma_addr;
  39441. + int i, n, ring_min;
  39442. +
  39443. + if (ag71xx_has_ar8216(ag))
  39444. + ag71xx_add_ar8216_header(ag, skb);
  39445. +
  39446. + if (skb->len <= 4) {
  39447. + DBG("%s: packet len is too small\n", ag->dev->name);
  39448. + goto err_drop;
  39449. + }
  39450. +
  39451. + dma_addr = dma_map_single(&dev->dev, skb->data, skb->len,
  39452. + DMA_TO_DEVICE);
  39453. +
  39454. + i = ring->curr % ring->size;
  39455. + desc = ag71xx_ring_desc(ring, i);
  39456. +
  39457. + /* setup descriptor fields */
  39458. + n = ag71xx_fill_dma_desc(ring, (u32) dma_addr, skb->len & ag->desc_pktlen_mask);
  39459. + if (n < 0)
  39460. + goto err_drop_unmap;
  39461. +
  39462. + i = (ring->curr + n - 1) % ring->size;
  39463. + ring->buf[i].len = skb->len;
  39464. + ring->buf[i].skb = skb;
  39465. + ring->buf[i].timestamp = jiffies;
  39466. +
  39467. + netdev_sent_queue(dev, skb->len);
  39468. +
  39469. + desc->ctrl &= ~DESC_EMPTY;
  39470. + ring->curr += n;
  39471. +
  39472. + /* flush descriptor */
  39473. + wmb();
  39474. +
  39475. + ring_min = 2;
  39476. + if (ring->desc_split)
  39477. + ring_min *= AG71XX_TX_RING_DS_PER_PKT;
  39478. +
  39479. + if (ring->curr - ring->dirty >= ring->size - ring_min) {
  39480. + DBG("%s: tx queue full\n", dev->name);
  39481. + netif_stop_queue(dev);
  39482. + }
  39483. +
  39484. + DBG("%s: packet injected into TX queue\n", ag->dev->name);
  39485. +
  39486. + /* enable TX engine */
  39487. + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
  39488. +
  39489. + return NETDEV_TX_OK;
  39490. +
  39491. +err_drop_unmap:
  39492. + dma_unmap_single(&dev->dev, dma_addr, skb->len, DMA_TO_DEVICE);
  39493. +
  39494. +err_drop:
  39495. + dev->stats.tx_dropped++;
  39496. +
  39497. + dev_kfree_skb(skb);
  39498. + return NETDEV_TX_OK;
  39499. +}
  39500. +
  39501. +static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  39502. +{
  39503. + struct ag71xx *ag = netdev_priv(dev);
  39504. + int ret;
  39505. +
  39506. + switch (cmd) {
  39507. + case SIOCETHTOOL:
  39508. + if (ag->phy_dev == NULL)
  39509. + break;
  39510. +
  39511. + spin_lock_irq(&ag->lock);
  39512. + ret = phy_ethtool_ioctl(ag->phy_dev, (void *) ifr->ifr_data);
  39513. + spin_unlock_irq(&ag->lock);
  39514. + return ret;
  39515. +
  39516. + case SIOCSIFHWADDR:
  39517. + if (copy_from_user
  39518. + (dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
  39519. + return -EFAULT;
  39520. + return 0;
  39521. +
  39522. + case SIOCGIFHWADDR:
  39523. + if (copy_to_user
  39524. + (ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
  39525. + return -EFAULT;
  39526. + return 0;
  39527. +
  39528. + case SIOCGMIIPHY:
  39529. + case SIOCGMIIREG:
  39530. + case SIOCSMIIREG:
  39531. + if (ag->phy_dev == NULL)
  39532. + break;
  39533. +
  39534. + return phy_mii_ioctl(ag->phy_dev, ifr, cmd);
  39535. +
  39536. + default:
  39537. + break;
  39538. + }
  39539. +
  39540. + return -EOPNOTSUPP;
  39541. +}
  39542. +
  39543. +static void ag71xx_oom_timer_handler(unsigned long data)
  39544. +{
  39545. + struct net_device *dev = (struct net_device *) data;
  39546. + struct ag71xx *ag = netdev_priv(dev);
  39547. +
  39548. + napi_schedule(&ag->napi);
  39549. +}
  39550. +
  39551. +static void ag71xx_tx_timeout(struct net_device *dev)
  39552. +{
  39553. + struct ag71xx *ag = netdev_priv(dev);
  39554. +
  39555. + if (netif_msg_tx_err(ag))
  39556. + pr_info("%s: tx timeout\n", ag->dev->name);
  39557. +
  39558. + schedule_work(&ag->restart_work);
  39559. +}
  39560. +
  39561. +static void ag71xx_restart_work_func(struct work_struct *work)
  39562. +{
  39563. + struct ag71xx *ag = container_of(work, struct ag71xx, restart_work);
  39564. +
  39565. + if (ag71xx_get_pdata(ag)->is_ar724x) {
  39566. + ag->link = 0;
  39567. + ag71xx_link_adjust(ag);
  39568. + return;
  39569. + }
  39570. +
  39571. + ag71xx_stop(ag->dev);
  39572. + ag71xx_open(ag->dev);
  39573. +}
  39574. +
  39575. +static bool ag71xx_check_dma_stuck(struct ag71xx *ag, unsigned long timestamp)
  39576. +{
  39577. + u32 rx_sm, tx_sm, rx_fd;
  39578. +
  39579. + if (likely(time_before(jiffies, timestamp + HZ/10)))
  39580. + return false;
  39581. +
  39582. + if (!netif_carrier_ok(ag->dev))
  39583. + return false;
  39584. +
  39585. + rx_sm = ag71xx_rr(ag, AG71XX_REG_RX_SM);
  39586. + if ((rx_sm & 0x7) == 0x3 && ((rx_sm >> 4) & 0x7) == 0x6)
  39587. + return true;
  39588. +
  39589. + tx_sm = ag71xx_rr(ag, AG71XX_REG_TX_SM);
  39590. + rx_fd = ag71xx_rr(ag, AG71XX_REG_FIFO_DEPTH);
  39591. + if (((tx_sm >> 4) & 0x7) == 0 && ((rx_sm & 0x7) == 0) &&
  39592. + ((rx_sm >> 4) & 0x7) == 0 && rx_fd == 0)
  39593. + return true;
  39594. +
  39595. + return false;
  39596. +}
  39597. +
  39598. +static int ag71xx_tx_packets(struct ag71xx *ag)
  39599. +{
  39600. + struct ag71xx_ring *ring = &ag->tx_ring;
  39601. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39602. + int sent = 0;
  39603. + int bytes_compl = 0;
  39604. + int n = 0;
  39605. +
  39606. + DBG("%s: processing TX ring\n", ag->dev->name);
  39607. +
  39608. + while (ring->dirty + n != ring->curr) {
  39609. + unsigned int i = (ring->dirty + n) % ring->size;
  39610. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  39611. + struct sk_buff *skb = ring->buf[i].skb;
  39612. +
  39613. + if (!ag71xx_desc_empty(desc)) {
  39614. + if (pdata->is_ar7240 &&
  39615. + ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp))
  39616. + schedule_work(&ag->restart_work);
  39617. + break;
  39618. + }
  39619. +
  39620. + n++;
  39621. + if (!skb)
  39622. + continue;
  39623. +
  39624. + dev_kfree_skb_any(skb);
  39625. + ring->buf[i].skb = NULL;
  39626. +
  39627. + bytes_compl += ring->buf[i].len;
  39628. +
  39629. + sent++;
  39630. + ring->dirty += n;
  39631. +
  39632. + while (n > 0) {
  39633. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
  39634. + n--;
  39635. + }
  39636. + }
  39637. +
  39638. + DBG("%s: %d packets sent out\n", ag->dev->name, sent);
  39639. +
  39640. + ag->dev->stats.tx_bytes += bytes_compl;
  39641. + ag->dev->stats.tx_packets += sent;
  39642. +
  39643. + if (!sent)
  39644. + return 0;
  39645. +
  39646. + netdev_completed_queue(ag->dev, sent, bytes_compl);
  39647. + if ((ring->curr - ring->dirty) < (ring->size * 3) / 4)
  39648. + netif_wake_queue(ag->dev);
  39649. +
  39650. + return sent;
  39651. +}
  39652. +
  39653. +static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
  39654. +{
  39655. + struct net_device *dev = ag->dev;
  39656. + struct ag71xx_ring *ring = &ag->rx_ring;
  39657. + int offset = ag71xx_buffer_offset(ag);
  39658. + unsigned int pktlen_mask = ag->desc_pktlen_mask;
  39659. + int done = 0;
  39660. +
  39661. + DBG("%s: rx packets, limit=%d, curr=%u, dirty=%u\n",
  39662. + dev->name, limit, ring->curr, ring->dirty);
  39663. +
  39664. + while (done < limit) {
  39665. + unsigned int i = ring->curr % ring->size;
  39666. + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
  39667. + struct sk_buff *skb;
  39668. + int pktlen;
  39669. + int err = 0;
  39670. +
  39671. + if (ag71xx_desc_empty(desc))
  39672. + break;
  39673. +
  39674. + if ((ring->dirty + ring->size) == ring->curr) {
  39675. + ag71xx_assert(0);
  39676. + break;
  39677. + }
  39678. +
  39679. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
  39680. +
  39681. + pktlen = desc->ctrl & pktlen_mask;
  39682. + pktlen -= ETH_FCS_LEN;
  39683. +
  39684. + dma_unmap_single(&dev->dev, ring->buf[i].dma_addr,
  39685. + ag->rx_buf_size, DMA_FROM_DEVICE);
  39686. +
  39687. + dev->stats.rx_packets++;
  39688. + dev->stats.rx_bytes += pktlen;
  39689. +
  39690. + skb = build_skb(ring->buf[i].rx_buf, 0);
  39691. + if (!skb) {
  39692. + kfree(ring->buf[i].rx_buf);
  39693. + goto next;
  39694. + }
  39695. +
  39696. + skb_reserve(skb, offset);
  39697. + skb_put(skb, pktlen);
  39698. +
  39699. + if (ag71xx_has_ar8216(ag))
  39700. + err = ag71xx_remove_ar8216_header(ag, skb, pktlen);
  39701. +
  39702. + if (err) {
  39703. + dev->stats.rx_dropped++;
  39704. + kfree_skb(skb);
  39705. + } else {
  39706. + skb->dev = dev;
  39707. + skb->ip_summed = CHECKSUM_NONE;
  39708. + skb->protocol = eth_type_trans(skb, dev);
  39709. + netif_receive_skb(skb);
  39710. + }
  39711. +
  39712. +next:
  39713. + ring->buf[i].rx_buf = NULL;
  39714. + done++;
  39715. +
  39716. + ring->curr++;
  39717. + }
  39718. +
  39719. + ag71xx_ring_rx_refill(ag);
  39720. +
  39721. + DBG("%s: rx finish, curr=%u, dirty=%u, done=%d\n",
  39722. + dev->name, ring->curr, ring->dirty, done);
  39723. +
  39724. + return done;
  39725. +}
  39726. +
  39727. +static int ag71xx_poll(struct napi_struct *napi, int limit)
  39728. +{
  39729. + struct ag71xx *ag = container_of(napi, struct ag71xx, napi);
  39730. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  39731. + struct net_device *dev = ag->dev;
  39732. + struct ag71xx_ring *rx_ring;
  39733. + unsigned long flags;
  39734. + u32 status;
  39735. + int tx_done;
  39736. + int rx_done;
  39737. +
  39738. + pdata->ddr_flush();
  39739. + tx_done = ag71xx_tx_packets(ag);
  39740. +
  39741. + DBG("%s: processing RX ring\n", dev->name);
  39742. + rx_done = ag71xx_rx_packets(ag, limit);
  39743. +
  39744. + ag71xx_debugfs_update_napi_stats(ag, rx_done, tx_done);
  39745. +
  39746. + rx_ring = &ag->rx_ring;
  39747. + if (rx_ring->buf[rx_ring->dirty % rx_ring->size].rx_buf == NULL)
  39748. + goto oom;
  39749. +
  39750. + status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
  39751. + if (unlikely(status & RX_STATUS_OF)) {
  39752. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_OF);
  39753. + dev->stats.rx_fifo_errors++;
  39754. +
  39755. + /* restart RX */
  39756. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
  39757. + }
  39758. +
  39759. + if (rx_done < limit) {
  39760. + if (status & RX_STATUS_PR)
  39761. + goto more;
  39762. +
  39763. + status = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
  39764. + if (status & TX_STATUS_PS)
  39765. + goto more;
  39766. +
  39767. + DBG("%s: disable polling mode, rx=%d, tx=%d,limit=%d\n",
  39768. + dev->name, rx_done, tx_done, limit);
  39769. +
  39770. + napi_complete(napi);
  39771. +
  39772. + /* enable interrupts */
  39773. + spin_lock_irqsave(&ag->lock, flags);
  39774. + ag71xx_int_enable(ag, AG71XX_INT_POLL);
  39775. + spin_unlock_irqrestore(&ag->lock, flags);
  39776. + return rx_done;
  39777. + }
  39778. +
  39779. +more:
  39780. + DBG("%s: stay in polling mode, rx=%d, tx=%d, limit=%d\n",
  39781. + dev->name, rx_done, tx_done, limit);
  39782. + return limit;
  39783. +
  39784. +oom:
  39785. + if (netif_msg_rx_err(ag))
  39786. + pr_info("%s: out of memory\n", dev->name);
  39787. +
  39788. + mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
  39789. + napi_complete(napi);
  39790. + return 0;
  39791. +}
  39792. +
  39793. +static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
  39794. +{
  39795. + struct net_device *dev = dev_id;
  39796. + struct ag71xx *ag = netdev_priv(dev);
  39797. + u32 status;
  39798. +
  39799. + status = ag71xx_rr(ag, AG71XX_REG_INT_STATUS);
  39800. + ag71xx_dump_intr(ag, "raw", status);
  39801. +
  39802. + if (unlikely(!status))
  39803. + return IRQ_NONE;
  39804. +
  39805. + if (unlikely(status & AG71XX_INT_ERR)) {
  39806. + if (status & AG71XX_INT_TX_BE) {
  39807. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE);
  39808. + dev_err(&dev->dev, "TX BUS error\n");
  39809. + }
  39810. + if (status & AG71XX_INT_RX_BE) {
  39811. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE);
  39812. + dev_err(&dev->dev, "RX BUS error\n");
  39813. + }
  39814. + }
  39815. +
  39816. + if (likely(status & AG71XX_INT_POLL)) {
  39817. + ag71xx_int_disable(ag, AG71XX_INT_POLL);
  39818. + DBG("%s: enable polling mode\n", dev->name);
  39819. + napi_schedule(&ag->napi);
  39820. + }
  39821. +
  39822. + ag71xx_debugfs_update_int_stats(ag, status);
  39823. +
  39824. + return IRQ_HANDLED;
  39825. +}
  39826. +
  39827. +#ifdef CONFIG_NET_POLL_CONTROLLER
  39828. +/*
  39829. + * Polling 'interrupt' - used by things like netconsole to send skbs
  39830. + * without having to re-enable interrupts. It's not called while
  39831. + * the interrupt routine is executing.
  39832. + */
  39833. +static void ag71xx_netpoll(struct net_device *dev)
  39834. +{
  39835. + disable_irq(dev->irq);
  39836. + ag71xx_interrupt(dev->irq, dev);
  39837. + enable_irq(dev->irq);
  39838. +}
  39839. +#endif
  39840. +
  39841. +static int ag71xx_change_mtu(struct net_device *dev, int new_mtu)
  39842. +{
  39843. + struct ag71xx *ag = netdev_priv(dev);
  39844. + unsigned int max_frame_len;
  39845. +
  39846. + max_frame_len = ag71xx_max_frame_len(new_mtu);
  39847. + if (new_mtu < 68 || max_frame_len > ag->max_frame_len)
  39848. + return -EINVAL;
  39849. +
  39850. + if (netif_running(dev))
  39851. + return -EBUSY;
  39852. +
  39853. + dev->mtu = new_mtu;
  39854. + return 0;
  39855. +}
  39856. +
  39857. +static const struct net_device_ops ag71xx_netdev_ops = {
  39858. + .ndo_open = ag71xx_open,
  39859. + .ndo_stop = ag71xx_stop,
  39860. + .ndo_start_xmit = ag71xx_hard_start_xmit,
  39861. + .ndo_do_ioctl = ag71xx_do_ioctl,
  39862. + .ndo_tx_timeout = ag71xx_tx_timeout,
  39863. + .ndo_change_mtu = ag71xx_change_mtu,
  39864. + .ndo_set_mac_address = eth_mac_addr,
  39865. + .ndo_validate_addr = eth_validate_addr,
  39866. +#ifdef CONFIG_NET_POLL_CONTROLLER
  39867. + .ndo_poll_controller = ag71xx_netpoll,
  39868. +#endif
  39869. +};
  39870. +
  39871. +static const char *ag71xx_get_phy_if_mode_name(phy_interface_t mode)
  39872. +{
  39873. + switch (mode) {
  39874. + case PHY_INTERFACE_MODE_MII:
  39875. + return "MII";
  39876. + case PHY_INTERFACE_MODE_GMII:
  39877. + return "GMII";
  39878. + case PHY_INTERFACE_MODE_RMII:
  39879. + return "RMII";
  39880. + case PHY_INTERFACE_MODE_RGMII:
  39881. + return "RGMII";
  39882. + case PHY_INTERFACE_MODE_SGMII:
  39883. + return "SGMII";
  39884. + default:
  39885. + break;
  39886. + }
  39887. +
  39888. + return "unknown";
  39889. +}
  39890. +
  39891. +
  39892. +static int ag71xx_probe(struct platform_device *pdev)
  39893. +{
  39894. + struct net_device *dev;
  39895. + struct resource *res;
  39896. + struct ag71xx *ag;
  39897. + struct ag71xx_platform_data *pdata;
  39898. + int err;
  39899. +
  39900. + pdata = pdev->dev.platform_data;
  39901. + if (!pdata) {
  39902. + dev_err(&pdev->dev, "no platform data specified\n");
  39903. + err = -ENXIO;
  39904. + goto err_out;
  39905. + }
  39906. +
  39907. + if (pdata->mii_bus_dev == NULL && pdata->phy_mask) {
  39908. + dev_err(&pdev->dev, "no MII bus device specified\n");
  39909. + err = -EINVAL;
  39910. + goto err_out;
  39911. + }
  39912. +
  39913. + dev = alloc_etherdev(sizeof(*ag));
  39914. + if (!dev) {
  39915. + dev_err(&pdev->dev, "alloc_etherdev failed\n");
  39916. + err = -ENOMEM;
  39917. + goto err_out;
  39918. + }
  39919. +
  39920. + if (!pdata->max_frame_len || !pdata->desc_pktlen_mask)
  39921. + return -EINVAL;
  39922. +
  39923. + SET_NETDEV_DEV(dev, &pdev->dev);
  39924. +
  39925. + ag = netdev_priv(dev);
  39926. + ag->pdev = pdev;
  39927. + ag->dev = dev;
  39928. + ag->msg_enable = netif_msg_init(ag71xx_msg_level,
  39929. + AG71XX_DEFAULT_MSG_ENABLE);
  39930. + spin_lock_init(&ag->lock);
  39931. +
  39932. + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base");
  39933. + if (!res) {
  39934. + dev_err(&pdev->dev, "no mac_base resource found\n");
  39935. + err = -ENXIO;
  39936. + goto err_out;
  39937. + }
  39938. +
  39939. + ag->mac_base = ioremap_nocache(res->start, res->end - res->start + 1);
  39940. + if (!ag->mac_base) {
  39941. + dev_err(&pdev->dev, "unable to ioremap mac_base\n");
  39942. + err = -ENOMEM;
  39943. + goto err_free_dev;
  39944. + }
  39945. +
  39946. + dev->irq = platform_get_irq(pdev, 0);
  39947. + err = request_irq(dev->irq, ag71xx_interrupt,
  39948. + 0x0,
  39949. + dev->name, dev);
  39950. + if (err) {
  39951. + dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq);
  39952. + goto err_unmap_base;
  39953. + }
  39954. +
  39955. + dev->base_addr = (unsigned long)ag->mac_base;
  39956. + dev->netdev_ops = &ag71xx_netdev_ops;
  39957. + dev->ethtool_ops = &ag71xx_ethtool_ops;
  39958. +
  39959. + INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
  39960. +
  39961. + init_timer(&ag->oom_timer);
  39962. + ag->oom_timer.data = (unsigned long) dev;
  39963. + ag->oom_timer.function = ag71xx_oom_timer_handler;
  39964. +
  39965. + ag->tx_ring.size = AG71XX_TX_RING_SIZE_DEFAULT;
  39966. + ag->rx_ring.size = AG71XX_RX_RING_SIZE_DEFAULT;
  39967. +
  39968. + ag->max_frame_len = pdata->max_frame_len;
  39969. + ag->desc_pktlen_mask = pdata->desc_pktlen_mask;
  39970. +
  39971. + if (!pdata->is_ar724x && !pdata->is_ar91xx) {
  39972. + ag->tx_ring.desc_split = AG71XX_TX_RING_SPLIT;
  39973. + ag->tx_ring.size *= AG71XX_TX_RING_DS_PER_PKT;
  39974. + }
  39975. +
  39976. + ag->stop_desc = dma_alloc_coherent(NULL,
  39977. + sizeof(struct ag71xx_desc), &ag->stop_desc_dma, GFP_KERNEL);
  39978. +
  39979. + if (!ag->stop_desc)
  39980. + goto err_free_irq;
  39981. +
  39982. + ag->stop_desc->data = 0;
  39983. + ag->stop_desc->ctrl = 0;
  39984. + ag->stop_desc->next = (u32) ag->stop_desc_dma;
  39985. +
  39986. + memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN);
  39987. +
  39988. + netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT);
  39989. +
  39990. + ag71xx_dump_regs(ag);
  39991. +
  39992. + ag71xx_hw_init(ag);
  39993. +
  39994. + ag71xx_dump_regs(ag);
  39995. +
  39996. + err = ag71xx_phy_connect(ag);
  39997. + if (err)
  39998. + goto err_free_desc;
  39999. +
  40000. + err = ag71xx_debugfs_init(ag);
  40001. + if (err)
  40002. + goto err_phy_disconnect;
  40003. +
  40004. + platform_set_drvdata(pdev, dev);
  40005. +
  40006. + err = register_netdev(dev);
  40007. + if (err) {
  40008. + dev_err(&pdev->dev, "unable to register net device\n");
  40009. + goto err_debugfs_exit;
  40010. + }
  40011. +
  40012. + pr_info("%s: Atheros AG71xx at 0x%08lx, irq %d, mode:%s\n",
  40013. + dev->name, dev->base_addr, dev->irq,
  40014. + ag71xx_get_phy_if_mode_name(pdata->phy_if_mode));
  40015. +
  40016. + return 0;
  40017. +
  40018. +err_debugfs_exit:
  40019. + ag71xx_debugfs_exit(ag);
  40020. +err_phy_disconnect:
  40021. + ag71xx_phy_disconnect(ag);
  40022. +err_free_desc:
  40023. + dma_free_coherent(NULL, sizeof(struct ag71xx_desc), ag->stop_desc,
  40024. + ag->stop_desc_dma);
  40025. +err_free_irq:
  40026. + free_irq(dev->irq, dev);
  40027. +err_unmap_base:
  40028. + iounmap(ag->mac_base);
  40029. +err_free_dev:
  40030. + kfree(dev);
  40031. +err_out:
  40032. + platform_set_drvdata(pdev, NULL);
  40033. + return err;
  40034. +}
  40035. +
  40036. +static int ag71xx_remove(struct platform_device *pdev)
  40037. +{
  40038. + struct net_device *dev = platform_get_drvdata(pdev);
  40039. +
  40040. + if (dev) {
  40041. + struct ag71xx *ag = netdev_priv(dev);
  40042. +
  40043. + ag71xx_debugfs_exit(ag);
  40044. + ag71xx_phy_disconnect(ag);
  40045. + unregister_netdev(dev);
  40046. + free_irq(dev->irq, dev);
  40047. + iounmap(ag->mac_base);
  40048. + kfree(dev);
  40049. + platform_set_drvdata(pdev, NULL);
  40050. + }
  40051. +
  40052. + return 0;
  40053. +}
  40054. +
  40055. +static struct platform_driver ag71xx_driver = {
  40056. + .probe = ag71xx_probe,
  40057. + .remove = ag71xx_remove,
  40058. + .driver = {
  40059. + .name = AG71XX_DRV_NAME,
  40060. + }
  40061. +};
  40062. +
  40063. +static int __init ag71xx_module_init(void)
  40064. +{
  40065. + int ret;
  40066. +
  40067. + ret = ag71xx_debugfs_root_init();
  40068. + if (ret)
  40069. + goto err_out;
  40070. +
  40071. + ret = ag71xx_mdio_driver_init();
  40072. + if (ret)
  40073. + goto err_debugfs_exit;
  40074. +
  40075. + ret = platform_driver_register(&ag71xx_driver);
  40076. + if (ret)
  40077. + goto err_mdio_exit;
  40078. +
  40079. + return 0;
  40080. +
  40081. +err_mdio_exit:
  40082. + ag71xx_mdio_driver_exit();
  40083. +err_debugfs_exit:
  40084. + ag71xx_debugfs_root_exit();
  40085. +err_out:
  40086. + return ret;
  40087. +}
  40088. +
  40089. +static void __exit ag71xx_module_exit(void)
  40090. +{
  40091. + platform_driver_unregister(&ag71xx_driver);
  40092. + ag71xx_mdio_driver_exit();
  40093. + ag71xx_debugfs_root_exit();
  40094. +}
  40095. +
  40096. +module_init(ag71xx_module_init);
  40097. +module_exit(ag71xx_module_exit);
  40098. +
  40099. +MODULE_VERSION(AG71XX_DRV_VERSION);
  40100. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  40101. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
  40102. +MODULE_LICENSE("GPL v2");
  40103. +MODULE_ALIAS("platform:" AG71XX_DRV_NAME);
  40104. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
  40105. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c 1970-01-01 01:00:00.000000000 +0100
  40106. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c 2015-09-13 20:04:35.076523692 +0200
  40107. @@ -0,0 +1,318 @@
  40108. +/*
  40109. + * Atheros AR71xx built-in ethernet mac driver
  40110. + *
  40111. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  40112. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  40113. + *
  40114. + * Based on Atheros' AG7100 driver
  40115. + *
  40116. + * This program is free software; you can redistribute it and/or modify it
  40117. + * under the terms of the GNU General Public License version 2 as published
  40118. + * by the Free Software Foundation.
  40119. + */
  40120. +
  40121. +#include "ag71xx.h"
  40122. +
  40123. +#define AG71XX_MDIO_RETRY 1000
  40124. +#define AG71XX_MDIO_DELAY 5
  40125. +
  40126. +static inline void ag71xx_mdio_wr(struct ag71xx_mdio *am, unsigned reg,
  40127. + u32 value)
  40128. +{
  40129. + void __iomem *r;
  40130. +
  40131. + r = am->mdio_base + reg;
  40132. + __raw_writel(value, r);
  40133. +
  40134. + /* flush write */
  40135. + (void) __raw_readl(r);
  40136. +}
  40137. +
  40138. +static inline u32 ag71xx_mdio_rr(struct ag71xx_mdio *am, unsigned reg)
  40139. +{
  40140. + return __raw_readl(am->mdio_base + reg);
  40141. +}
  40142. +
  40143. +static void ag71xx_mdio_dump_regs(struct ag71xx_mdio *am)
  40144. +{
  40145. + DBG("%s: mii_cfg=%08x, mii_cmd=%08x, mii_addr=%08x\n",
  40146. + am->mii_bus->name,
  40147. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CFG),
  40148. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CMD),
  40149. + ag71xx_mdio_rr(am, AG71XX_REG_MII_ADDR));
  40150. + DBG("%s: mii_ctrl=%08x, mii_status=%08x, mii_ind=%08x\n",
  40151. + am->mii_bus->name,
  40152. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CTRL),
  40153. + ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS),
  40154. + ag71xx_mdio_rr(am, AG71XX_REG_MII_IND));
  40155. +}
  40156. +
  40157. +static int ag71xx_mdio_wait_busy(struct ag71xx_mdio *am)
  40158. +{
  40159. + int i;
  40160. +
  40161. + for (i = 0; i < AG71XX_MDIO_RETRY; i++) {
  40162. + u32 busy;
  40163. +
  40164. + udelay(AG71XX_MDIO_DELAY);
  40165. +
  40166. + busy = ag71xx_mdio_rr(am, AG71XX_REG_MII_IND);
  40167. + if (!busy)
  40168. + return 0;
  40169. +
  40170. + udelay(AG71XX_MDIO_DELAY);
  40171. + }
  40172. +
  40173. + pr_err("%s: MDIO operation timed out\n", am->mii_bus->name);
  40174. +
  40175. + return -ETIMEDOUT;
  40176. +}
  40177. +
  40178. +int ag71xx_mdio_mii_read(struct ag71xx_mdio *am, int addr, int reg)
  40179. +{
  40180. + int err;
  40181. + int ret;
  40182. +
  40183. + err = ag71xx_mdio_wait_busy(am);
  40184. + if (err)
  40185. + return 0xffff;
  40186. +
  40187. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
  40188. + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
  40189. + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
  40190. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_READ);
  40191. +
  40192. + err = ag71xx_mdio_wait_busy(am);
  40193. + if (err)
  40194. + return 0xffff;
  40195. +
  40196. + ret = ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS) & 0xffff;
  40197. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
  40198. +
  40199. + DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, ret);
  40200. +
  40201. + return ret;
  40202. +}
  40203. +
  40204. +void ag71xx_mdio_mii_write(struct ag71xx_mdio *am, int addr, int reg, u16 val)
  40205. +{
  40206. + DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val);
  40207. +
  40208. + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
  40209. + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
  40210. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CTRL, val);
  40211. +
  40212. + ag71xx_mdio_wait_busy(am);
  40213. +}
  40214. +
  40215. +static const u32 ar71xx_mdio_div_table[] = {
  40216. + 4, 4, 6, 8, 10, 14, 20, 28,
  40217. +};
  40218. +
  40219. +static const u32 ar7240_mdio_div_table[] = {
  40220. + 2, 2, 4, 6, 8, 12, 18, 26, 32, 40, 48, 56, 62, 70, 78, 96,
  40221. +};
  40222. +
  40223. +static const u32 ar933x_mdio_div_table[] = {
  40224. + 4, 4, 6, 8, 10, 14, 20, 28, 34, 42, 50, 58, 66, 74, 82, 98,
  40225. +};
  40226. +
  40227. +static int ag71xx_mdio_get_divider(struct ag71xx_mdio *am, u32 *div)
  40228. +{
  40229. + unsigned long ref_clock, mdio_clock;
  40230. + const u32 *table;
  40231. + int ndivs;
  40232. + int i;
  40233. +
  40234. + ref_clock = am->pdata->ref_clock;
  40235. + mdio_clock = am->pdata->mdio_clock;
  40236. +
  40237. + if (!ref_clock || !mdio_clock)
  40238. + return -EINVAL;
  40239. +
  40240. + if (am->pdata->is_ar9330 || am->pdata->is_ar934x) {
  40241. + table = ar933x_mdio_div_table;
  40242. + ndivs = ARRAY_SIZE(ar933x_mdio_div_table);
  40243. + } else if (am->pdata->is_ar7240) {
  40244. + table = ar7240_mdio_div_table;
  40245. + ndivs = ARRAY_SIZE(ar7240_mdio_div_table);
  40246. + } else {
  40247. + table = ar71xx_mdio_div_table;
  40248. + ndivs = ARRAY_SIZE(ar71xx_mdio_div_table);
  40249. + }
  40250. +
  40251. + for (i = 0; i < ndivs; i++) {
  40252. + unsigned long t;
  40253. +
  40254. + t = ref_clock / table[i];
  40255. + if (t <= mdio_clock) {
  40256. + *div = i;
  40257. + return 0;
  40258. + }
  40259. + }
  40260. +
  40261. + dev_err(&am->mii_bus->dev, "no divider found for %lu/%lu\n",
  40262. + ref_clock, mdio_clock);
  40263. + return -ENOENT;
  40264. +}
  40265. +
  40266. +static int ag71xx_mdio_reset(struct mii_bus *bus)
  40267. +{
  40268. + struct ag71xx_mdio *am = bus->priv;
  40269. + u32 t;
  40270. + int err;
  40271. +
  40272. + err = ag71xx_mdio_get_divider(am, &t);
  40273. + if (err) {
  40274. + /* fallback */
  40275. + if (am->pdata->is_ar7240)
  40276. + t = MII_CFG_CLK_DIV_6;
  40277. + else if (am->pdata->builtin_switch && !am->pdata->is_ar934x)
  40278. + t = MII_CFG_CLK_DIV_10;
  40279. + else if (!am->pdata->builtin_switch && am->pdata->is_ar934x)
  40280. + t = MII_CFG_CLK_DIV_58;
  40281. + else
  40282. + t = MII_CFG_CLK_DIV_28;
  40283. + }
  40284. +
  40285. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t | MII_CFG_RESET);
  40286. + udelay(100);
  40287. +
  40288. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t);
  40289. + udelay(100);
  40290. +
  40291. + if (am->pdata->reset)
  40292. + am->pdata->reset(bus);
  40293. +
  40294. + return 0;
  40295. +}
  40296. +
  40297. +static int ag71xx_mdio_read(struct mii_bus *bus, int addr, int reg)
  40298. +{
  40299. + struct ag71xx_mdio *am = bus->priv;
  40300. +
  40301. + if (am->pdata->builtin_switch)
  40302. + return ar7240sw_phy_read(bus, addr, reg);
  40303. + else
  40304. + return ag71xx_mdio_mii_read(am, addr, reg);
  40305. +}
  40306. +
  40307. +static int ag71xx_mdio_write(struct mii_bus *bus, int addr, int reg, u16 val)
  40308. +{
  40309. + struct ag71xx_mdio *am = bus->priv;
  40310. +
  40311. + if (am->pdata->builtin_switch)
  40312. + ar7240sw_phy_write(bus, addr, reg, val);
  40313. + else
  40314. + ag71xx_mdio_mii_write(am, addr, reg, val);
  40315. + return 0;
  40316. +}
  40317. +
  40318. +static int ag71xx_mdio_probe(struct platform_device *pdev)
  40319. +{
  40320. + struct ag71xx_mdio_platform_data *pdata;
  40321. + struct ag71xx_mdio *am;
  40322. + struct resource *res;
  40323. + int i;
  40324. + int err;
  40325. +
  40326. + pdata = pdev->dev.platform_data;
  40327. + if (!pdata) {
  40328. + dev_err(&pdev->dev, "no platform data specified\n");
  40329. + return -EINVAL;
  40330. + }
  40331. +
  40332. + am = kzalloc(sizeof(*am), GFP_KERNEL);
  40333. + if (!am) {
  40334. + err = -ENOMEM;
  40335. + goto err_out;
  40336. + }
  40337. +
  40338. + am->pdata = pdata;
  40339. +
  40340. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  40341. + if (!res) {
  40342. + dev_err(&pdev->dev, "no iomem resource found\n");
  40343. + err = -ENXIO;
  40344. + goto err_out;
  40345. + }
  40346. +
  40347. + am->mdio_base = ioremap_nocache(res->start, res->end - res->start + 1);
  40348. + if (!am->mdio_base) {
  40349. + dev_err(&pdev->dev, "unable to ioremap registers\n");
  40350. + err = -ENOMEM;
  40351. + goto err_free_mdio;
  40352. + }
  40353. +
  40354. + am->mii_bus = mdiobus_alloc();
  40355. + if (am->mii_bus == NULL) {
  40356. + err = -ENOMEM;
  40357. + goto err_iounmap;
  40358. + }
  40359. +
  40360. + am->mii_bus->name = "ag71xx_mdio";
  40361. + am->mii_bus->read = ag71xx_mdio_read;
  40362. + am->mii_bus->write = ag71xx_mdio_write;
  40363. + am->mii_bus->reset = ag71xx_mdio_reset;
  40364. + am->mii_bus->irq = am->mii_irq;
  40365. + am->mii_bus->priv = am;
  40366. + am->mii_bus->parent = &pdev->dev;
  40367. + snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev));
  40368. + am->mii_bus->phy_mask = pdata->phy_mask;
  40369. +
  40370. + for (i = 0; i < PHY_MAX_ADDR; i++)
  40371. + am->mii_irq[i] = PHY_POLL;
  40372. +
  40373. + ag71xx_mdio_wr(am, AG71XX_REG_MAC_CFG1, 0);
  40374. +
  40375. + err = mdiobus_register(am->mii_bus);
  40376. + if (err)
  40377. + goto err_free_bus;
  40378. +
  40379. + ag71xx_mdio_dump_regs(am);
  40380. +
  40381. + platform_set_drvdata(pdev, am);
  40382. + return 0;
  40383. +
  40384. +err_free_bus:
  40385. + mdiobus_free(am->mii_bus);
  40386. +err_iounmap:
  40387. + iounmap(am->mdio_base);
  40388. +err_free_mdio:
  40389. + kfree(am);
  40390. +err_out:
  40391. + return err;
  40392. +}
  40393. +
  40394. +static int ag71xx_mdio_remove(struct platform_device *pdev)
  40395. +{
  40396. + struct ag71xx_mdio *am = platform_get_drvdata(pdev);
  40397. +
  40398. + if (am) {
  40399. + mdiobus_unregister(am->mii_bus);
  40400. + mdiobus_free(am->mii_bus);
  40401. + iounmap(am->mdio_base);
  40402. + kfree(am);
  40403. + platform_set_drvdata(pdev, NULL);
  40404. + }
  40405. +
  40406. + return 0;
  40407. +}
  40408. +
  40409. +static struct platform_driver ag71xx_mdio_driver = {
  40410. + .probe = ag71xx_mdio_probe,
  40411. + .remove = ag71xx_mdio_remove,
  40412. + .driver = {
  40413. + .name = "ag71xx-mdio",
  40414. + }
  40415. +};
  40416. +
  40417. +int __init ag71xx_mdio_driver_init(void)
  40418. +{
  40419. + return platform_driver_register(&ag71xx_mdio_driver);
  40420. +}
  40421. +
  40422. +void ag71xx_mdio_driver_exit(void)
  40423. +{
  40424. + platform_driver_unregister(&ag71xx_mdio_driver);
  40425. +}
  40426. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
  40427. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c 1970-01-01 01:00:00.000000000 +0100
  40428. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c 2015-09-13 20:04:35.076523692 +0200
  40429. @@ -0,0 +1,235 @@
  40430. +/*
  40431. + * Atheros AR71xx built-in ethernet mac driver
  40432. + *
  40433. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  40434. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  40435. + *
  40436. + * Based on Atheros' AG7100 driver
  40437. + *
  40438. + * This program is free software; you can redistribute it and/or modify it
  40439. + * under the terms of the GNU General Public License version 2 as published
  40440. + * by the Free Software Foundation.
  40441. + */
  40442. +
  40443. +#include "ag71xx.h"
  40444. +
  40445. +static void ag71xx_phy_link_adjust(struct net_device *dev)
  40446. +{
  40447. + struct ag71xx *ag = netdev_priv(dev);
  40448. + struct phy_device *phydev = ag->phy_dev;
  40449. + unsigned long flags;
  40450. + int status_change = 0;
  40451. +
  40452. + spin_lock_irqsave(&ag->lock, flags);
  40453. +
  40454. + if (phydev->link) {
  40455. + if (ag->duplex != phydev->duplex
  40456. + || ag->speed != phydev->speed) {
  40457. + status_change = 1;
  40458. + }
  40459. + }
  40460. +
  40461. + if (phydev->link != ag->link)
  40462. + status_change = 1;
  40463. +
  40464. + ag->link = phydev->link;
  40465. + ag->duplex = phydev->duplex;
  40466. + ag->speed = phydev->speed;
  40467. +
  40468. + if (status_change)
  40469. + ag71xx_link_adjust(ag);
  40470. +
  40471. + spin_unlock_irqrestore(&ag->lock, flags);
  40472. +}
  40473. +
  40474. +void ag71xx_phy_start(struct ag71xx *ag)
  40475. +{
  40476. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40477. +
  40478. + if (ag->phy_dev) {
  40479. + phy_start(ag->phy_dev);
  40480. + } else if (pdata->mii_bus_dev && pdata->switch_data) {
  40481. + ag71xx_ar7240_start(ag);
  40482. + } else {
  40483. + ag->link = 1;
  40484. + ag71xx_link_adjust(ag);
  40485. + }
  40486. +}
  40487. +
  40488. +void ag71xx_phy_stop(struct ag71xx *ag)
  40489. +{
  40490. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40491. + unsigned long flags;
  40492. +
  40493. + if (ag->phy_dev)
  40494. + phy_stop(ag->phy_dev);
  40495. + else if (pdata->mii_bus_dev && pdata->switch_data)
  40496. + ag71xx_ar7240_stop(ag);
  40497. +
  40498. + spin_lock_irqsave(&ag->lock, flags);
  40499. + if (ag->link) {
  40500. + ag->link = 0;
  40501. + ag71xx_link_adjust(ag);
  40502. + }
  40503. + spin_unlock_irqrestore(&ag->lock, flags);
  40504. +}
  40505. +
  40506. +static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
  40507. +{
  40508. + struct device *dev = &ag->pdev->dev;
  40509. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40510. + int ret = 0;
  40511. +
  40512. + /* use fixed settings */
  40513. + switch (pdata->speed) {
  40514. + case SPEED_10:
  40515. + case SPEED_100:
  40516. + case SPEED_1000:
  40517. + break;
  40518. + default:
  40519. + dev_err(dev, "invalid speed specified\n");
  40520. + ret = -EINVAL;
  40521. + break;
  40522. + }
  40523. +
  40524. + dev_dbg(dev, "using fixed link parameters\n");
  40525. +
  40526. + ag->duplex = pdata->duplex;
  40527. + ag->speed = pdata->speed;
  40528. +
  40529. + return ret;
  40530. +}
  40531. +
  40532. +static int ag71xx_phy_connect_multi(struct ag71xx *ag)
  40533. +{
  40534. + struct device *dev = &ag->pdev->dev;
  40535. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40536. + struct phy_device *phydev = NULL;
  40537. + int phy_addr;
  40538. + int ret = 0;
  40539. +
  40540. + for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
  40541. + if (!(pdata->phy_mask & (1 << phy_addr)))
  40542. + continue;
  40543. +
  40544. + if (ag->mii_bus->phy_map[phy_addr] == NULL)
  40545. + continue;
  40546. +
  40547. + DBG("%s: PHY found at %s, uid=%08x\n",
  40548. + dev_name(dev),
  40549. + dev_name(&ag->mii_bus->phy_map[phy_addr]->dev),
  40550. + ag->mii_bus->phy_map[phy_addr]->phy_id);
  40551. +
  40552. + if (phydev == NULL)
  40553. + phydev = ag->mii_bus->phy_map[phy_addr];
  40554. + }
  40555. +
  40556. + if (!phydev) {
  40557. + dev_err(dev, "no PHY found with phy_mask=%08x\n",
  40558. + pdata->phy_mask);
  40559. + return -ENODEV;
  40560. + }
  40561. +
  40562. + ag->phy_dev = phy_connect(ag->dev, dev_name(&phydev->dev),
  40563. + &ag71xx_phy_link_adjust,
  40564. + pdata->phy_if_mode);
  40565. +
  40566. + if (IS_ERR(ag->phy_dev)) {
  40567. + dev_err(dev, "could not connect to PHY at %s\n",
  40568. + dev_name(&phydev->dev));
  40569. + return PTR_ERR(ag->phy_dev);
  40570. + }
  40571. +
  40572. + /* mask with MAC supported features */
  40573. + if (pdata->has_gbit)
  40574. + phydev->supported &= PHY_GBIT_FEATURES;
  40575. + else
  40576. + phydev->supported &= PHY_BASIC_FEATURES;
  40577. +
  40578. + phydev->advertising = phydev->supported;
  40579. +
  40580. + dev_info(dev, "connected to PHY at %s [uid=%08x, driver=%s]\n",
  40581. + dev_name(&phydev->dev), phydev->phy_id, phydev->drv->name);
  40582. +
  40583. + ag->link = 0;
  40584. + ag->speed = 0;
  40585. + ag->duplex = -1;
  40586. +
  40587. + return ret;
  40588. +}
  40589. +
  40590. +static int dev_is_class(struct device *dev, void *class)
  40591. +{
  40592. + if (dev->class != NULL && !strcmp(dev->class->name, class))
  40593. + return 1;
  40594. +
  40595. + return 0;
  40596. +}
  40597. +
  40598. +static struct device *dev_find_class(struct device *parent, char *class)
  40599. +{
  40600. + if (dev_is_class(parent, class)) {
  40601. + get_device(parent);
  40602. + return parent;
  40603. + }
  40604. +
  40605. + return device_find_child(parent, class, dev_is_class);
  40606. +}
  40607. +
  40608. +static struct mii_bus *dev_to_mii_bus(struct device *dev)
  40609. +{
  40610. + struct device *d;
  40611. +
  40612. + d = dev_find_class(dev, "mdio_bus");
  40613. + if (d != NULL) {
  40614. + struct mii_bus *bus;
  40615. +
  40616. + bus = to_mii_bus(d);
  40617. + put_device(d);
  40618. +
  40619. + return bus;
  40620. + }
  40621. +
  40622. + return NULL;
  40623. +}
  40624. +
  40625. +int ag71xx_phy_connect(struct ag71xx *ag)
  40626. +{
  40627. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40628. +
  40629. + if (pdata->mii_bus_dev == NULL ||
  40630. + pdata->mii_bus_dev->bus == NULL )
  40631. + return ag71xx_phy_connect_fixed(ag);
  40632. +
  40633. + ag->mii_bus = dev_to_mii_bus(pdata->mii_bus_dev);
  40634. + if (ag->mii_bus == NULL) {
  40635. + dev_err(&ag->pdev->dev, "unable to find MII bus on device '%s'\n",
  40636. + dev_name(pdata->mii_bus_dev));
  40637. + return -ENODEV;
  40638. + }
  40639. +
  40640. + /* Reset the mdio bus explicitly */
  40641. + if (ag->mii_bus->reset) {
  40642. + mutex_lock(&ag->mii_bus->mdio_lock);
  40643. + ag->mii_bus->reset(ag->mii_bus);
  40644. + mutex_unlock(&ag->mii_bus->mdio_lock);
  40645. + }
  40646. +
  40647. + if (pdata->switch_data)
  40648. + return ag71xx_ar7240_init(ag);
  40649. +
  40650. + if (pdata->phy_mask)
  40651. + return ag71xx_phy_connect_multi(ag);
  40652. +
  40653. + return ag71xx_phy_connect_fixed(ag);
  40654. +}
  40655. +
  40656. +void ag71xx_phy_disconnect(struct ag71xx *ag)
  40657. +{
  40658. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  40659. +
  40660. + if (pdata->switch_data)
  40661. + ag71xx_ar7240_cleanup(ag);
  40662. + else if (ag->phy_dev)
  40663. + phy_disconnect(ag->phy_dev);
  40664. +}
  40665. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/Kconfig linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/Kconfig
  40666. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
  40667. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/Kconfig 2015-09-13 20:04:35.076523692 +0200
  40668. @@ -0,0 +1,33 @@
  40669. +config AG71XX
  40670. + tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
  40671. + depends on ATH79
  40672. + select PHYLIB
  40673. + help
  40674. + If you wish to compile a kernel for AR7XXX/91XXX and enable
  40675. + ethernet support, then you should always answer Y to this.
  40676. +
  40677. +if AG71XX
  40678. +
  40679. +config AG71XX_DEBUG
  40680. + bool "Atheros AR71xx built-in ethernet driver debugging"
  40681. + default n
  40682. + help
  40683. + Atheros AR71xx built-in ethernet driver debugging messages.
  40684. +
  40685. +config AG71XX_DEBUG_FS
  40686. + bool "Atheros AR71xx built-in ethernet driver debugfs support"
  40687. + depends on DEBUG_FS
  40688. + default n
  40689. + help
  40690. + Say Y, if you need access to various statistics provided by
  40691. + the ag71xx driver.
  40692. +
  40693. +config AG71XX_AR8216_SUPPORT
  40694. + bool "special support for the Atheros AR8216 switch"
  40695. + default n
  40696. + default y if ATH79_MACH_WNR2000 || ATH79_MACH_MZK_W04NU
  40697. + help
  40698. + Say 'y' here if you want to enable special support for the
  40699. + Atheros AR8216 switch found on some boards.
  40700. +
  40701. +endif
  40702. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/Makefile linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/Makefile
  40703. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/ag71xx/Makefile 1970-01-01 01:00:00.000000000 +0100
  40704. +++ linux-4.1.13/drivers/net/ethernet/atheros/ag71xx/Makefile 2015-09-13 20:04:35.076523692 +0200
  40705. @@ -0,0 +1,15 @@
  40706. +#
  40707. +# Makefile for the Atheros AR71xx built-in ethernet macs
  40708. +#
  40709. +
  40710. +ag71xx-y += ag71xx_main.o
  40711. +ag71xx-y += ag71xx_ethtool.o
  40712. +ag71xx-y += ag71xx_phy.o
  40713. +ag71xx-y += ag71xx_mdio.o
  40714. +ag71xx-y += ag71xx_ar7240.o
  40715. +
  40716. +ag71xx-$(CONFIG_AG71XX_DEBUG_FS) += ag71xx_debugfs.o
  40717. +ag71xx-$(CONFIG_AG71XX_AR8216_SUPPORT) += ag71xx_ar8216.o
  40718. +
  40719. +obj-$(CONFIG_AG71XX) += ag71xx.o
  40720. +
  40721. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/Kconfig linux-4.1.13/drivers/net/ethernet/atheros/Kconfig
  40722. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/Kconfig 2015-11-09 23:34:10.000000000 +0100
  40723. +++ linux-4.1.13/drivers/net/ethernet/atheros/Kconfig 2015-12-04 19:57:03.882110905 +0100
  40724. @@ -5,7 +5,7 @@
  40725. config NET_VENDOR_ATHEROS
  40726. bool "Atheros devices"
  40727. default y
  40728. - depends on PCI
  40729. + depends on (PCI || ATH79)
  40730. ---help---
  40731. If you have a network (Ethernet) card belonging to this class, say Y
  40732. and read the Ethernet-HOWTO, available from
  40733. @@ -80,4 +80,6 @@
  40734. To compile this driver as a module, choose M here. The module
  40735. will be called alx.
  40736. +source drivers/net/ethernet/atheros/ag71xx/Kconfig
  40737. +
  40738. endif # NET_VENDOR_ATHEROS
  40739. diff -Nur linux-4.1.13.orig/drivers/net/ethernet/atheros/Makefile linux-4.1.13/drivers/net/ethernet/atheros/Makefile
  40740. --- linux-4.1.13.orig/drivers/net/ethernet/atheros/Makefile 2015-11-09 23:34:10.000000000 +0100
  40741. +++ linux-4.1.13/drivers/net/ethernet/atheros/Makefile 2015-12-04 19:57:03.882110905 +0100
  40742. @@ -2,6 +2,7 @@
  40743. # Makefile for the Atheros network device drivers.
  40744. #
  40745. +obj-$(CONFIG_AG71XX) += ag71xx/
  40746. obj-$(CONFIG_ATL1) += atlx/
  40747. obj-$(CONFIG_ATL2) += atlx/
  40748. obj-$(CONFIG_ATL1E) += atl1e/
  40749. diff -Nur linux-4.1.13.orig/drivers/net/phy/at803x.c linux-4.1.13/drivers/net/phy/at803x.c
  40750. --- linux-4.1.13.orig/drivers/net/phy/at803x.c 2015-11-09 23:34:10.000000000 +0100
  40751. +++ linux-4.1.13/drivers/net/phy/at803x.c 2015-12-04 19:57:03.890110382 +0100
  40752. @@ -12,12 +12,14 @@
  40753. */
  40754. #include <linux/phy.h>
  40755. +#include <linux/mdio.h>
  40756. #include <linux/module.h>
  40757. #include <linux/string.h>
  40758. #include <linux/netdevice.h>
  40759. #include <linux/etherdevice.h>
  40760. #include <linux/of_gpio.h>
  40761. #include <linux/gpio/consumer.h>
  40762. +#include <linux/platform_data/phy-at803x.h>
  40763. #define AT803X_INTR_ENABLE 0x12
  40764. #define AT803X_INTR_STATUS 0x13
  40765. @@ -34,8 +36,16 @@
  40766. #define AT803X_INER 0x0012
  40767. #define AT803X_INER_INIT 0xec00
  40768. #define AT803X_INSR 0x0013
  40769. +
  40770. +#define AT803X_PCS_SMART_EEE_CTRL3 0x805D
  40771. +#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3
  40772. +#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT 12
  40773. +#define AT803X_SMART_EEE_CTRL3_LPI_EN BIT(8)
  40774. +
  40775. #define AT803X_DEBUG_ADDR 0x1D
  40776. #define AT803X_DEBUG_DATA 0x1E
  40777. +#define AT803X_DBG0_REG 0x00
  40778. +#define AT803X_DEBUG_RGMII_RX_CLK_DLY BIT(8)
  40779. #define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05
  40780. #define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8)
  40781. @@ -50,6 +60,7 @@
  40782. struct at803x_priv {
  40783. bool phy_reset:1;
  40784. struct gpio_desc *gpiod_reset;
  40785. + int prev_speed;
  40786. };
  40787. struct at803x_context {
  40788. @@ -61,6 +72,43 @@
  40789. u16 led_control;
  40790. };
  40791. +static u16
  40792. +at803x_dbg_reg_rmw(struct phy_device *phydev, u16 reg, u16 clear, u16 set)
  40793. +{
  40794. + struct mii_bus *bus = phydev->bus;
  40795. + int val;
  40796. +
  40797. + mutex_lock(&bus->mdio_lock);
  40798. +
  40799. + bus->write(bus, phydev->addr, AT803X_DEBUG_ADDR, reg);
  40800. + val = bus->read(bus, phydev->addr, AT803X_DEBUG_DATA);
  40801. + if (val < 0) {
  40802. + val = 0xffff;
  40803. + goto out;
  40804. + }
  40805. +
  40806. + val &= ~clear;
  40807. + val |= set;
  40808. + bus->write(bus, phydev->addr, AT803X_DEBUG_DATA, val);
  40809. +
  40810. +out:
  40811. + mutex_unlock(&bus->mdio_lock);
  40812. + return val;
  40813. +}
  40814. +
  40815. +static inline void
  40816. +at803x_dbg_reg_set(struct phy_device *phydev, u16 reg, u16 set)
  40817. +{
  40818. + at803x_dbg_reg_rmw(phydev, reg, 0, set);
  40819. +}
  40820. +
  40821. +static inline void
  40822. +at803x_dbg_reg_clr(struct phy_device *phydev, u16 reg, u16 clear)
  40823. +{
  40824. + at803x_dbg_reg_rmw(phydev, reg, clear, 0);
  40825. +}
  40826. +
  40827. +
  40828. /* save relevant PHY registers to private copy */
  40829. static void at803x_context_save(struct phy_device *phydev,
  40830. struct at803x_context *context)
  40831. @@ -209,8 +257,16 @@
  40832. return 0;
  40833. }
  40834. +static void at803x_disable_smarteee(struct phy_device *phydev)
  40835. +{
  40836. + phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_PCS_SMART_EEE_CTRL3,
  40837. + 1 << AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT);
  40838. + phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0);
  40839. +}
  40840. +
  40841. static int at803x_config_init(struct phy_device *phydev)
  40842. {
  40843. + struct at803x_platform_data *pdata;
  40844. int ret;
  40845. ret = genphy_config_init(phydev);
  40846. @@ -228,6 +284,26 @@
  40847. return ret;
  40848. }
  40849. + pdata = dev_get_platdata(&phydev->dev);
  40850. + if (pdata) {
  40851. + if (pdata->disable_smarteee)
  40852. + at803x_disable_smarteee(phydev);
  40853. +
  40854. + if (pdata->enable_rgmii_rx_delay)
  40855. + at803x_dbg_reg_set(phydev, AT803X_DBG0_REG,
  40856. + AT803X_DEBUG_RGMII_RX_CLK_DLY);
  40857. + else
  40858. + at803x_dbg_reg_clr(phydev, AT803X_DBG0_REG,
  40859. + AT803X_DEBUG_RGMII_RX_CLK_DLY);
  40860. +
  40861. + if (pdata->enable_rgmii_tx_delay)
  40862. + at803x_dbg_reg_set(phydev, AT803X_DEBUG_SYSTEM_MODE_CTRL,
  40863. + AT803X_DEBUG_RGMII_TX_CLK_DLY);
  40864. + else
  40865. + at803x_dbg_reg_clr(phydev, AT803X_DEBUG_SYSTEM_MODE_CTRL,
  40866. + AT803X_DEBUG_RGMII_TX_CLK_DLY);
  40867. + }
  40868. +
  40869. return 0;
  40870. }
  40871. @@ -259,6 +335,8 @@
  40872. static void at803x_link_change_notify(struct phy_device *phydev)
  40873. {
  40874. struct at803x_priv *priv = phydev->priv;
  40875. + struct at803x_platform_data *pdata;
  40876. + pdata = dev_get_platdata(&phydev->dev);
  40877. /*
  40878. * Conduct a hardware reset for AT8030 every time a link loss is
  40879. @@ -289,6 +367,26 @@
  40880. priv->phy_reset = false;
  40881. }
  40882. }
  40883. + if (pdata && pdata->fixup_rgmii_tx_delay &&
  40884. + phydev->speed != priv->prev_speed) {
  40885. + switch (phydev->speed) {
  40886. + case SPEED_10:
  40887. + case SPEED_100:
  40888. + at803x_dbg_reg_set(phydev,
  40889. + AT803X_DEBUG_SYSTEM_MODE_CTRL,
  40890. + AT803X_DEBUG_RGMII_TX_CLK_DLY);
  40891. + break;
  40892. + case SPEED_1000:
  40893. + at803x_dbg_reg_clr(phydev,
  40894. + AT803X_DEBUG_SYSTEM_MODE_CTRL,
  40895. + AT803X_DEBUG_RGMII_TX_CLK_DLY);
  40896. + break;
  40897. + default:
  40898. + break;
  40899. + }
  40900. +
  40901. + priv->prev_speed = phydev->speed;
  40902. + }
  40903. }
  40904. static struct phy_driver at803x_driver[] = {
  40905. diff -Nur linux-4.1.13.orig/drivers/net/phy/Kconfig linux-4.1.13/drivers/net/phy/Kconfig
  40906. --- linux-4.1.13.orig/drivers/net/phy/Kconfig 2015-11-09 23:34:10.000000000 +0100
  40907. +++ linux-4.1.13/drivers/net/phy/Kconfig 2015-12-04 21:33:39.755626859 +0100
  40908. @@ -12,6 +12,16 @@
  40909. if PHYLIB
  40910. +config SWCONFIG
  40911. + tristate "Switch configuration API"
  40912. + ---help---
  40913. + Switch configuration API using netlink. This allows
  40914. + you to configure the VLAN features of certain switches.
  40915. +
  40916. +config SWCONFIG_LEDS
  40917. + bool "Switch LED trigger support"
  40918. + depends on (SWCONFIG && LEDS_TRIGGERS)
  40919. +
  40920. comment "MII PHY device drivers"
  40921. config AT803X_PHY
  40922. diff -Nur linux-4.1.13.orig/drivers/net/phy/Makefile linux-4.1.13/drivers/net/phy/Makefile
  40923. --- linux-4.1.13.orig/drivers/net/phy/Makefile 2015-11-09 23:34:10.000000000 +0100
  40924. +++ linux-4.1.13/drivers/net/phy/Makefile 2015-12-04 21:33:39.775625531 +0100
  40925. @@ -3,6 +3,7 @@
  40926. libphy-objs := phy.o phy_device.o mdio_bus.o
  40927. obj-$(CONFIG_PHYLIB) += libphy.o
  40928. +obj-$(CONFIG_SWCONFIG) += swconfig.o
  40929. obj-$(CONFIG_MARVELL_PHY) += marvell.o
  40930. obj-$(CONFIG_DAVICOM_PHY) += davicom.o
  40931. obj-$(CONFIG_CICADA_PHY) += cicada.o
  40932. diff -Nur linux-4.1.13.orig/drivers/net/phy/mdio-bitbang.c linux-4.1.13/drivers/net/phy/mdio-bitbang.c
  40933. --- linux-4.1.13.orig/drivers/net/phy/mdio-bitbang.c 2015-11-09 23:34:10.000000000 +0100
  40934. +++ linux-4.1.13/drivers/net/phy/mdio-bitbang.c 2015-12-04 19:57:05.909978229 +0100
  40935. @@ -17,6 +17,7 @@
  40936. * kind, whether express or implied.
  40937. */
  40938. +#include <linux/irqflags.h>
  40939. #include <linux/module.h>
  40940. #include <linux/mdio-bitbang.h>
  40941. #include <linux/types.h>
  40942. @@ -156,7 +157,9 @@
  40943. {
  40944. struct mdiobb_ctrl *ctrl = bus->priv;
  40945. int ret, i;
  40946. + long flags;
  40947. + local_irq_save(flags);
  40948. if (reg & MII_ADDR_C45) {
  40949. reg = mdiobb_cmd_addr(ctrl, phy, reg);
  40950. mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
  40951. @@ -165,26 +168,21 @@
  40952. ctrl->ops->set_mdio_dir(ctrl, 0);
  40953. - /* check the turnaround bit: the PHY should be driving it to zero */
  40954. - if (mdiobb_get_bit(ctrl) != 0) {
  40955. - /* PHY didn't drive TA low -- flush any bits it
  40956. - * may be trying to send.
  40957. - */
  40958. - for (i = 0; i < 32; i++)
  40959. - mdiobb_get_bit(ctrl);
  40960. -
  40961. - return 0xffff;
  40962. - }
  40963. + mdiobb_get_bit(ctrl);
  40964. ret = mdiobb_get_num(ctrl, 16);
  40965. mdiobb_get_bit(ctrl);
  40966. + local_irq_restore(flags);
  40967. +
  40968. return ret;
  40969. }
  40970. static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
  40971. {
  40972. struct mdiobb_ctrl *ctrl = bus->priv;
  40973. + long flags;
  40974. + local_irq_save(flags);
  40975. if (reg & MII_ADDR_C45) {
  40976. reg = mdiobb_cmd_addr(ctrl, phy, reg);
  40977. mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
  40978. @@ -199,6 +197,8 @@
  40979. ctrl->ops->set_mdio_dir(ctrl, 0);
  40980. mdiobb_get_bit(ctrl);
  40981. + local_irq_restore(flags);
  40982. +
  40983. return 0;
  40984. }
  40985. diff -Nur linux-4.1.13.orig/drivers/net/phy/phy.c linux-4.1.13/drivers/net/phy/phy.c
  40986. --- linux-4.1.13.orig/drivers/net/phy/phy.c 2015-11-09 23:34:10.000000000 +0100
  40987. +++ linux-4.1.13/drivers/net/phy/phy.c 2015-12-04 20:31:10.856994541 +0100
  40988. @@ -357,6 +357,50 @@
  40989. }
  40990. EXPORT_SYMBOL(phy_ethtool_gset);
  40991. +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
  40992. +{
  40993. + u32 cmd;
  40994. + int tmp;
  40995. + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
  40996. + struct ethtool_value edata = { ETHTOOL_GLINK };
  40997. +
  40998. + if (get_user(cmd, (u32 *) useraddr))
  40999. + return -EFAULT;
  41000. +
  41001. + switch (cmd) {
  41002. + case ETHTOOL_GSET:
  41003. + phy_ethtool_gset(phydev, &ecmd);
  41004. + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
  41005. + return -EFAULT;
  41006. + return 0;
  41007. +
  41008. + case ETHTOOL_SSET:
  41009. + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
  41010. + return -EFAULT;
  41011. + return phy_ethtool_sset(phydev, &ecmd);
  41012. +
  41013. + case ETHTOOL_NWAY_RST:
  41014. + /* if autoneg is off, it's an error */
  41015. + tmp = phy_read(phydev, MII_BMCR);
  41016. + if (tmp & BMCR_ANENABLE) {
  41017. + tmp |= (BMCR_ANRESTART);
  41018. + phy_write(phydev, MII_BMCR, tmp);
  41019. + return 0;
  41020. + }
  41021. + return -EINVAL;
  41022. +
  41023. + case ETHTOOL_GLINK:
  41024. + edata.data = (phy_read(phydev,
  41025. + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
  41026. + if (copy_to_user(useraddr, &edata, sizeof(edata)))
  41027. + return -EFAULT;
  41028. + return 0;
  41029. + }
  41030. +
  41031. + return -EOPNOTSUPP;
  41032. +}
  41033. +EXPORT_SYMBOL(phy_ethtool_ioctl);
  41034. +
  41035. /**
  41036. * phy_mii_ioctl - generic PHY MII ioctl interface
  41037. * @phydev: the phy_device struct
  41038. diff -Nur linux-4.1.13.orig/drivers/net/phy/swconfig.c linux-4.1.13/drivers/net/phy/swconfig.c
  41039. --- linux-4.1.13.orig/drivers/net/phy/swconfig.c 1970-01-01 01:00:00.000000000 +0100
  41040. +++ linux-4.1.13/drivers/net/phy/swconfig.c 2015-12-04 21:18:34.855186030 +0100
  41041. @@ -0,0 +1,1153 @@
  41042. +/*
  41043. + * swconfig.c: Switch configuration API
  41044. + *
  41045. + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
  41046. + *
  41047. + * This program is free software; you can redistribute it and/or
  41048. + * modify it under the terms of the GNU General Public License
  41049. + * as published by the Free Software Foundation; either version 2
  41050. + * of the License, or (at your option) any later version.
  41051. + *
  41052. + * This program is distributed in the hope that it will be useful,
  41053. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41054. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41055. + * GNU General Public License for more details.
  41056. + */
  41057. +
  41058. +#include <linux/types.h>
  41059. +#include <linux/module.h>
  41060. +#include <linux/init.h>
  41061. +#include <linux/list.h>
  41062. +#include <linux/if.h>
  41063. +#include <linux/if_ether.h>
  41064. +#include <linux/capability.h>
  41065. +#include <linux/skbuff.h>
  41066. +#include <linux/switch.h>
  41067. +#include <linux/of.h>
  41068. +#include <linux/version.h>
  41069. +
  41070. +#define SWCONFIG_DEVNAME "switch%d"
  41071. +
  41072. +#include "swconfig_leds.c"
  41073. +
  41074. +MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
  41075. +MODULE_LICENSE("GPL");
  41076. +
  41077. +static int swdev_id;
  41078. +static struct list_head swdevs;
  41079. +static DEFINE_SPINLOCK(swdevs_lock);
  41080. +struct swconfig_callback;
  41081. +
  41082. +struct swconfig_callback {
  41083. + struct sk_buff *msg;
  41084. + struct genlmsghdr *hdr;
  41085. + struct genl_info *info;
  41086. + int cmd;
  41087. +
  41088. + /* callback for filling in the message data */
  41089. + int (*fill)(struct swconfig_callback *cb, void *arg);
  41090. +
  41091. + /* callback for closing the message before sending it */
  41092. + int (*close)(struct swconfig_callback *cb, void *arg);
  41093. +
  41094. + struct nlattr *nest[4];
  41095. + int args[4];
  41096. +};
  41097. +
  41098. +/* defaults */
  41099. +
  41100. +static int
  41101. +swconfig_get_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr,
  41102. + struct switch_val *val)
  41103. +{
  41104. + int ret;
  41105. + if (val->port_vlan >= dev->vlans)
  41106. + return -EINVAL;
  41107. +
  41108. + if (!dev->ops->get_vlan_ports)
  41109. + return -EOPNOTSUPP;
  41110. +
  41111. + ret = dev->ops->get_vlan_ports(dev, val);
  41112. + return ret;
  41113. +}
  41114. +
  41115. +static int
  41116. +swconfig_set_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr,
  41117. + struct switch_val *val)
  41118. +{
  41119. + struct switch_port *ports = val->value.ports;
  41120. + const struct switch_dev_ops *ops = dev->ops;
  41121. + int i;
  41122. +
  41123. + if (val->port_vlan >= dev->vlans)
  41124. + return -EINVAL;
  41125. +
  41126. + /* validate ports */
  41127. + if (val->len > dev->ports)
  41128. + return -EINVAL;
  41129. +
  41130. + if (!ops->set_vlan_ports)
  41131. + return -EOPNOTSUPP;
  41132. +
  41133. + for (i = 0; i < val->len; i++) {
  41134. + if (ports[i].id >= dev->ports)
  41135. + return -EINVAL;
  41136. +
  41137. + if (ops->set_port_pvid &&
  41138. + !(ports[i].flags & (1 << SWITCH_PORT_FLAG_TAGGED)))
  41139. + ops->set_port_pvid(dev, ports[i].id, val->port_vlan);
  41140. + }
  41141. +
  41142. + return ops->set_vlan_ports(dev, val);
  41143. +}
  41144. +
  41145. +static int
  41146. +swconfig_set_pvid(struct switch_dev *dev, const struct switch_attr *attr,
  41147. + struct switch_val *val)
  41148. +{
  41149. + if (val->port_vlan >= dev->ports)
  41150. + return -EINVAL;
  41151. +
  41152. + if (!dev->ops->set_port_pvid)
  41153. + return -EOPNOTSUPP;
  41154. +
  41155. + return dev->ops->set_port_pvid(dev, val->port_vlan, val->value.i);
  41156. +}
  41157. +
  41158. +static int
  41159. +swconfig_get_pvid(struct switch_dev *dev, const struct switch_attr *attr,
  41160. + struct switch_val *val)
  41161. +{
  41162. + if (val->port_vlan >= dev->ports)
  41163. + return -EINVAL;
  41164. +
  41165. + if (!dev->ops->get_port_pvid)
  41166. + return -EOPNOTSUPP;
  41167. +
  41168. + return dev->ops->get_port_pvid(dev, val->port_vlan, &val->value.i);
  41169. +}
  41170. +
  41171. +static const char *
  41172. +swconfig_speed_str(enum switch_port_speed speed)
  41173. +{
  41174. + switch (speed) {
  41175. + case SWITCH_PORT_SPEED_10:
  41176. + return "10baseT";
  41177. + case SWITCH_PORT_SPEED_100:
  41178. + return "100baseT";
  41179. + case SWITCH_PORT_SPEED_1000:
  41180. + return "1000baseT";
  41181. + default:
  41182. + break;
  41183. + }
  41184. +
  41185. + return "unknown";
  41186. +}
  41187. +
  41188. +static int
  41189. +swconfig_get_link(struct switch_dev *dev, const struct switch_attr *attr,
  41190. + struct switch_val *val)
  41191. +{
  41192. + struct switch_port_link link;
  41193. + int len;
  41194. + int ret;
  41195. +
  41196. + if (val->port_vlan >= dev->ports)
  41197. + return -EINVAL;
  41198. +
  41199. + if (!dev->ops->get_port_link)
  41200. + return -EOPNOTSUPP;
  41201. +
  41202. + memset(&link, 0, sizeof(link));
  41203. + ret = dev->ops->get_port_link(dev, val->port_vlan, &link);
  41204. + if (ret)
  41205. + return ret;
  41206. +
  41207. + memset(dev->buf, 0, sizeof(dev->buf));
  41208. +
  41209. + if (link.link)
  41210. + len = snprintf(dev->buf, sizeof(dev->buf),
  41211. + "port:%d link:up speed:%s %s-duplex %s%s%s%s%s",
  41212. + val->port_vlan,
  41213. + swconfig_speed_str(link.speed),
  41214. + link.duplex ? "full" : "half",
  41215. + link.tx_flow ? "txflow " : "",
  41216. + link.rx_flow ? "rxflow " : "",
  41217. + link.eee & ADVERTISED_100baseT_Full ? "eee100 " : "",
  41218. + link.eee & ADVERTISED_1000baseT_Full ? "eee1000 " : "",
  41219. + link.aneg ? "auto" : "");
  41220. + else
  41221. + len = snprintf(dev->buf, sizeof(dev->buf), "port:%d link:down",
  41222. + val->port_vlan);
  41223. +
  41224. + val->value.s = dev->buf;
  41225. + val->len = len;
  41226. +
  41227. + return 0;
  41228. +}
  41229. +
  41230. +static int
  41231. +swconfig_apply_config(struct switch_dev *dev, const struct switch_attr *attr,
  41232. + struct switch_val *val)
  41233. +{
  41234. + /* don't complain if not supported by the switch driver */
  41235. + if (!dev->ops->apply_config)
  41236. + return 0;
  41237. +
  41238. + return dev->ops->apply_config(dev);
  41239. +}
  41240. +
  41241. +static int
  41242. +swconfig_reset_switch(struct switch_dev *dev, const struct switch_attr *attr,
  41243. + struct switch_val *val)
  41244. +{
  41245. + /* don't complain if not supported by the switch driver */
  41246. + if (!dev->ops->reset_switch)
  41247. + return 0;
  41248. +
  41249. + return dev->ops->reset_switch(dev);
  41250. +}
  41251. +
  41252. +enum global_defaults {
  41253. + GLOBAL_APPLY,
  41254. + GLOBAL_RESET,
  41255. +};
  41256. +
  41257. +enum vlan_defaults {
  41258. + VLAN_PORTS,
  41259. +};
  41260. +
  41261. +enum port_defaults {
  41262. + PORT_PVID,
  41263. + PORT_LINK,
  41264. +};
  41265. +
  41266. +static struct switch_attr default_global[] = {
  41267. + [GLOBAL_APPLY] = {
  41268. + .type = SWITCH_TYPE_NOVAL,
  41269. + .name = "apply",
  41270. + .description = "Activate changes in the hardware",
  41271. + .set = swconfig_apply_config,
  41272. + },
  41273. + [GLOBAL_RESET] = {
  41274. + .type = SWITCH_TYPE_NOVAL,
  41275. + .name = "reset",
  41276. + .description = "Reset the switch",
  41277. + .set = swconfig_reset_switch,
  41278. + }
  41279. +};
  41280. +
  41281. +static struct switch_attr default_port[] = {
  41282. + [PORT_PVID] = {
  41283. + .type = SWITCH_TYPE_INT,
  41284. + .name = "pvid",
  41285. + .description = "Primary VLAN ID",
  41286. + .set = swconfig_set_pvid,
  41287. + .get = swconfig_get_pvid,
  41288. + },
  41289. + [PORT_LINK] = {
  41290. + .type = SWITCH_TYPE_STRING,
  41291. + .name = "link",
  41292. + .description = "Get port link information",
  41293. + .set = NULL,
  41294. + .get = swconfig_get_link,
  41295. + }
  41296. +};
  41297. +
  41298. +static struct switch_attr default_vlan[] = {
  41299. + [VLAN_PORTS] = {
  41300. + .type = SWITCH_TYPE_PORTS,
  41301. + .name = "ports",
  41302. + .description = "VLAN port mapping",
  41303. + .set = swconfig_set_vlan_ports,
  41304. + .get = swconfig_get_vlan_ports,
  41305. + },
  41306. +};
  41307. +
  41308. +static const struct switch_attr *
  41309. +swconfig_find_attr_by_name(const struct switch_attrlist *alist,
  41310. + const char *name)
  41311. +{
  41312. + int i;
  41313. +
  41314. + for (i = 0; i < alist->n_attr; i++)
  41315. + if (strcmp(name, alist->attr[i].name) == 0)
  41316. + return &alist->attr[i];
  41317. +
  41318. + return NULL;
  41319. +}
  41320. +
  41321. +static void swconfig_defaults_init(struct switch_dev *dev)
  41322. +{
  41323. + const struct switch_dev_ops *ops = dev->ops;
  41324. +
  41325. + dev->def_global = 0;
  41326. + dev->def_vlan = 0;
  41327. + dev->def_port = 0;
  41328. +
  41329. + if (ops->get_vlan_ports || ops->set_vlan_ports)
  41330. + set_bit(VLAN_PORTS, &dev->def_vlan);
  41331. +
  41332. + if (ops->get_port_pvid || ops->set_port_pvid)
  41333. + set_bit(PORT_PVID, &dev->def_port);
  41334. +
  41335. + if (ops->get_port_link &&
  41336. + !swconfig_find_attr_by_name(&ops->attr_port, "link"))
  41337. + set_bit(PORT_LINK, &dev->def_port);
  41338. +
  41339. + /* always present, can be no-op */
  41340. + set_bit(GLOBAL_APPLY, &dev->def_global);
  41341. + set_bit(GLOBAL_RESET, &dev->def_global);
  41342. +}
  41343. +
  41344. +
  41345. +static struct genl_family switch_fam = {
  41346. + .id = GENL_ID_GENERATE,
  41347. + .name = "switch",
  41348. + .hdrsize = 0,
  41349. + .version = 1,
  41350. + .maxattr = SWITCH_ATTR_MAX,
  41351. +};
  41352. +
  41353. +static const struct nla_policy switch_policy[SWITCH_ATTR_MAX+1] = {
  41354. + [SWITCH_ATTR_ID] = { .type = NLA_U32 },
  41355. + [SWITCH_ATTR_OP_ID] = { .type = NLA_U32 },
  41356. + [SWITCH_ATTR_OP_PORT] = { .type = NLA_U32 },
  41357. + [SWITCH_ATTR_OP_VLAN] = { .type = NLA_U32 },
  41358. + [SWITCH_ATTR_OP_VALUE_INT] = { .type = NLA_U32 },
  41359. + [SWITCH_ATTR_OP_VALUE_STR] = { .type = NLA_NUL_STRING },
  41360. + [SWITCH_ATTR_OP_VALUE_PORTS] = { .type = NLA_NESTED },
  41361. + [SWITCH_ATTR_TYPE] = { .type = NLA_U32 },
  41362. +};
  41363. +
  41364. +static const struct nla_policy port_policy[SWITCH_PORT_ATTR_MAX+1] = {
  41365. + [SWITCH_PORT_ID] = { .type = NLA_U32 },
  41366. + [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG },
  41367. +};
  41368. +
  41369. +static inline void
  41370. +swconfig_lock(void)
  41371. +{
  41372. + spin_lock(&swdevs_lock);
  41373. +}
  41374. +
  41375. +static inline void
  41376. +swconfig_unlock(void)
  41377. +{
  41378. + spin_unlock(&swdevs_lock);
  41379. +}
  41380. +
  41381. +static struct switch_dev *
  41382. +swconfig_get_dev(struct genl_info *info)
  41383. +{
  41384. + struct switch_dev *dev = NULL;
  41385. + struct switch_dev *p;
  41386. + int id;
  41387. +
  41388. + if (!info->attrs[SWITCH_ATTR_ID])
  41389. + goto done;
  41390. +
  41391. + id = nla_get_u32(info->attrs[SWITCH_ATTR_ID]);
  41392. + swconfig_lock();
  41393. + list_for_each_entry(p, &swdevs, dev_list) {
  41394. + if (id != p->id)
  41395. + continue;
  41396. +
  41397. + dev = p;
  41398. + break;
  41399. + }
  41400. + if (dev)
  41401. + mutex_lock(&dev->sw_mutex);
  41402. + else
  41403. + pr_debug("device %d not found\n", id);
  41404. + swconfig_unlock();
  41405. +done:
  41406. + return dev;
  41407. +}
  41408. +
  41409. +static inline void
  41410. +swconfig_put_dev(struct switch_dev *dev)
  41411. +{
  41412. + mutex_unlock(&dev->sw_mutex);
  41413. +}
  41414. +
  41415. +static int
  41416. +swconfig_dump_attr(struct swconfig_callback *cb, void *arg)
  41417. +{
  41418. + struct switch_attr *op = arg;
  41419. + struct genl_info *info = cb->info;
  41420. + struct sk_buff *msg = cb->msg;
  41421. + int id = cb->args[0];
  41422. + void *hdr;
  41423. +
  41424. + hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam,
  41425. + NLM_F_MULTI, SWITCH_CMD_NEW_ATTR);
  41426. + if (IS_ERR(hdr))
  41427. + return -1;
  41428. +
  41429. + if (nla_put_u32(msg, SWITCH_ATTR_OP_ID, id))
  41430. + goto nla_put_failure;
  41431. + if (nla_put_u32(msg, SWITCH_ATTR_OP_TYPE, op->type))
  41432. + goto nla_put_failure;
  41433. + if (nla_put_string(msg, SWITCH_ATTR_OP_NAME, op->name))
  41434. + goto nla_put_failure;
  41435. + if (op->description)
  41436. + if (nla_put_string(msg, SWITCH_ATTR_OP_DESCRIPTION,
  41437. + op->description))
  41438. + goto nla_put_failure;
  41439. +
  41440. + genlmsg_end(msg, hdr);
  41441. + return msg->len;
  41442. +nla_put_failure:
  41443. + genlmsg_cancel(msg, hdr);
  41444. + return -EMSGSIZE;
  41445. +}
  41446. +
  41447. +/* spread multipart messages across multiple message buffers */
  41448. +static int
  41449. +swconfig_send_multipart(struct swconfig_callback *cb, void *arg)
  41450. +{
  41451. + struct genl_info *info = cb->info;
  41452. + int restart = 0;
  41453. + int err;
  41454. +
  41455. + do {
  41456. + if (!cb->msg) {
  41457. + cb->msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  41458. + if (cb->msg == NULL)
  41459. + goto error;
  41460. + }
  41461. +
  41462. + if (!(cb->fill(cb, arg) < 0))
  41463. + break;
  41464. +
  41465. + /* fill failed, check if this was already the second attempt */
  41466. + if (restart)
  41467. + goto error;
  41468. +
  41469. + /* try again in a new message, send the current one */
  41470. + restart = 1;
  41471. + if (cb->close) {
  41472. + if (cb->close(cb, arg) < 0)
  41473. + goto error;
  41474. + }
  41475. + err = genlmsg_reply(cb->msg, info);
  41476. + cb->msg = NULL;
  41477. + if (err < 0)
  41478. + goto error;
  41479. +
  41480. + } while (restart);
  41481. +
  41482. + return 0;
  41483. +
  41484. +error:
  41485. + if (cb->msg)
  41486. + nlmsg_free(cb->msg);
  41487. + return -1;
  41488. +}
  41489. +
  41490. +static int
  41491. +swconfig_list_attrs(struct sk_buff *skb, struct genl_info *info)
  41492. +{
  41493. + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
  41494. + const struct switch_attrlist *alist;
  41495. + struct switch_dev *dev;
  41496. + struct swconfig_callback cb;
  41497. + int err = -EINVAL;
  41498. + int i;
  41499. +
  41500. + /* defaults */
  41501. + struct switch_attr *def_list;
  41502. + unsigned long *def_active;
  41503. + int n_def;
  41504. +
  41505. + dev = swconfig_get_dev(info);
  41506. + if (!dev)
  41507. + return -EINVAL;
  41508. +
  41509. + switch (hdr->cmd) {
  41510. + case SWITCH_CMD_LIST_GLOBAL:
  41511. + alist = &dev->ops->attr_global;
  41512. + def_list = default_global;
  41513. + def_active = &dev->def_global;
  41514. + n_def = ARRAY_SIZE(default_global);
  41515. + break;
  41516. + case SWITCH_CMD_LIST_VLAN:
  41517. + alist = &dev->ops->attr_vlan;
  41518. + def_list = default_vlan;
  41519. + def_active = &dev->def_vlan;
  41520. + n_def = ARRAY_SIZE(default_vlan);
  41521. + break;
  41522. + case SWITCH_CMD_LIST_PORT:
  41523. + alist = &dev->ops->attr_port;
  41524. + def_list = default_port;
  41525. + def_active = &dev->def_port;
  41526. + n_def = ARRAY_SIZE(default_port);
  41527. + break;
  41528. + default:
  41529. + WARN_ON(1);
  41530. + goto out;
  41531. + }
  41532. +
  41533. + memset(&cb, 0, sizeof(cb));
  41534. + cb.info = info;
  41535. + cb.fill = swconfig_dump_attr;
  41536. + for (i = 0; i < alist->n_attr; i++) {
  41537. + if (alist->attr[i].disabled)
  41538. + continue;
  41539. + cb.args[0] = i;
  41540. + err = swconfig_send_multipart(&cb, (void *) &alist->attr[i]);
  41541. + if (err < 0)
  41542. + goto error;
  41543. + }
  41544. +
  41545. + /* defaults */
  41546. + for (i = 0; i < n_def; i++) {
  41547. + if (!test_bit(i, def_active))
  41548. + continue;
  41549. + cb.args[0] = SWITCH_ATTR_DEFAULTS_OFFSET + i;
  41550. + err = swconfig_send_multipart(&cb, (void *) &def_list[i]);
  41551. + if (err < 0)
  41552. + goto error;
  41553. + }
  41554. + swconfig_put_dev(dev);
  41555. +
  41556. + if (!cb.msg)
  41557. + return 0;
  41558. +
  41559. + return genlmsg_reply(cb.msg, info);
  41560. +
  41561. +error:
  41562. + if (cb.msg)
  41563. + nlmsg_free(cb.msg);
  41564. +out:
  41565. + swconfig_put_dev(dev);
  41566. + return err;
  41567. +}
  41568. +
  41569. +static const struct switch_attr *
  41570. +swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
  41571. + struct switch_val *val)
  41572. +{
  41573. + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
  41574. + const struct switch_attrlist *alist;
  41575. + const struct switch_attr *attr = NULL;
  41576. + int attr_id;
  41577. +
  41578. + /* defaults */
  41579. + struct switch_attr *def_list;
  41580. + unsigned long *def_active;
  41581. + int n_def;
  41582. +
  41583. + if (!info->attrs[SWITCH_ATTR_OP_ID])
  41584. + goto done;
  41585. +
  41586. + switch (hdr->cmd) {
  41587. + case SWITCH_CMD_SET_GLOBAL:
  41588. + case SWITCH_CMD_GET_GLOBAL:
  41589. + alist = &dev->ops->attr_global;
  41590. + def_list = default_global;
  41591. + def_active = &dev->def_global;
  41592. + n_def = ARRAY_SIZE(default_global);
  41593. + break;
  41594. + case SWITCH_CMD_SET_VLAN:
  41595. + case SWITCH_CMD_GET_VLAN:
  41596. + alist = &dev->ops->attr_vlan;
  41597. + def_list = default_vlan;
  41598. + def_active = &dev->def_vlan;
  41599. + n_def = ARRAY_SIZE(default_vlan);
  41600. + if (!info->attrs[SWITCH_ATTR_OP_VLAN])
  41601. + goto done;
  41602. + val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]);
  41603. + if (val->port_vlan >= dev->vlans)
  41604. + goto done;
  41605. + break;
  41606. + case SWITCH_CMD_SET_PORT:
  41607. + case SWITCH_CMD_GET_PORT:
  41608. + alist = &dev->ops->attr_port;
  41609. + def_list = default_port;
  41610. + def_active = &dev->def_port;
  41611. + n_def = ARRAY_SIZE(default_port);
  41612. + if (!info->attrs[SWITCH_ATTR_OP_PORT])
  41613. + goto done;
  41614. + val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]);
  41615. + if (val->port_vlan >= dev->ports)
  41616. + goto done;
  41617. + break;
  41618. + default:
  41619. + WARN_ON(1);
  41620. + goto done;
  41621. + }
  41622. +
  41623. + if (!alist)
  41624. + goto done;
  41625. +
  41626. + attr_id = nla_get_u32(info->attrs[SWITCH_ATTR_OP_ID]);
  41627. + if (attr_id >= SWITCH_ATTR_DEFAULTS_OFFSET) {
  41628. + attr_id -= SWITCH_ATTR_DEFAULTS_OFFSET;
  41629. + if (attr_id >= n_def)
  41630. + goto done;
  41631. + if (!test_bit(attr_id, def_active))
  41632. + goto done;
  41633. + attr = &def_list[attr_id];
  41634. + } else {
  41635. + if (attr_id >= alist->n_attr)
  41636. + goto done;
  41637. + attr = &alist->attr[attr_id];
  41638. + }
  41639. +
  41640. + if (attr->disabled)
  41641. + attr = NULL;
  41642. +
  41643. +done:
  41644. + if (!attr)
  41645. + pr_debug("attribute lookup failed\n");
  41646. + val->attr = attr;
  41647. + return attr;
  41648. +}
  41649. +
  41650. +static int
  41651. +swconfig_parse_ports(struct sk_buff *msg, struct nlattr *head,
  41652. + struct switch_val *val, int max)
  41653. +{
  41654. + struct nlattr *nla;
  41655. + int rem;
  41656. +
  41657. + val->len = 0;
  41658. + nla_for_each_nested(nla, head, rem) {
  41659. + struct nlattr *tb[SWITCH_PORT_ATTR_MAX+1];
  41660. + struct switch_port *port = &val->value.ports[val->len];
  41661. +
  41662. + if (val->len >= max)
  41663. + return -EINVAL;
  41664. +
  41665. + if (nla_parse_nested(tb, SWITCH_PORT_ATTR_MAX, nla,
  41666. + port_policy))
  41667. + return -EINVAL;
  41668. +
  41669. + if (!tb[SWITCH_PORT_ID])
  41670. + return -EINVAL;
  41671. +
  41672. + port->id = nla_get_u32(tb[SWITCH_PORT_ID]);
  41673. + if (tb[SWITCH_PORT_FLAG_TAGGED])
  41674. + port->flags |= (1 << SWITCH_PORT_FLAG_TAGGED);
  41675. + val->len++;
  41676. + }
  41677. +
  41678. + return 0;
  41679. +}
  41680. +
  41681. +static int
  41682. +swconfig_set_attr(struct sk_buff *skb, struct genl_info *info)
  41683. +{
  41684. + const struct switch_attr *attr;
  41685. + struct switch_dev *dev;
  41686. + struct switch_val val;
  41687. + int err = -EINVAL;
  41688. +
  41689. + dev = swconfig_get_dev(info);
  41690. + if (!dev)
  41691. + return -EINVAL;
  41692. +
  41693. + memset(&val, 0, sizeof(val));
  41694. + attr = swconfig_lookup_attr(dev, info, &val);
  41695. + if (!attr || !attr->set)
  41696. + goto error;
  41697. +
  41698. + val.attr = attr;
  41699. + switch (attr->type) {
  41700. + case SWITCH_TYPE_NOVAL:
  41701. + break;
  41702. + case SWITCH_TYPE_INT:
  41703. + if (!info->attrs[SWITCH_ATTR_OP_VALUE_INT])
  41704. + goto error;
  41705. + val.value.i =
  41706. + nla_get_u32(info->attrs[SWITCH_ATTR_OP_VALUE_INT]);
  41707. + break;
  41708. + case SWITCH_TYPE_STRING:
  41709. + if (!info->attrs[SWITCH_ATTR_OP_VALUE_STR])
  41710. + goto error;
  41711. + val.value.s =
  41712. + nla_data(info->attrs[SWITCH_ATTR_OP_VALUE_STR]);
  41713. + break;
  41714. + case SWITCH_TYPE_PORTS:
  41715. + val.value.ports = dev->portbuf;
  41716. + memset(dev->portbuf, 0,
  41717. + sizeof(struct switch_port) * dev->ports);
  41718. +
  41719. + /* TODO: implement multipart? */
  41720. + if (info->attrs[SWITCH_ATTR_OP_VALUE_PORTS]) {
  41721. + err = swconfig_parse_ports(skb,
  41722. + info->attrs[SWITCH_ATTR_OP_VALUE_PORTS],
  41723. + &val, dev->ports);
  41724. + if (err < 0)
  41725. + goto error;
  41726. + } else {
  41727. + val.len = 0;
  41728. + err = 0;
  41729. + }
  41730. + break;
  41731. + default:
  41732. + goto error;
  41733. + }
  41734. +
  41735. + err = attr->set(dev, attr, &val);
  41736. +error:
  41737. + swconfig_put_dev(dev);
  41738. + return err;
  41739. +}
  41740. +
  41741. +static int
  41742. +swconfig_close_portlist(struct swconfig_callback *cb, void *arg)
  41743. +{
  41744. + if (cb->nest[0])
  41745. + nla_nest_end(cb->msg, cb->nest[0]);
  41746. + return 0;
  41747. +}
  41748. +
  41749. +static int
  41750. +swconfig_send_port(struct swconfig_callback *cb, void *arg)
  41751. +{
  41752. + const struct switch_port *port = arg;
  41753. + struct nlattr *p = NULL;
  41754. +
  41755. + if (!cb->nest[0]) {
  41756. + cb->nest[0] = nla_nest_start(cb->msg, cb->cmd);
  41757. + if (!cb->nest[0])
  41758. + return -1;
  41759. + }
  41760. +
  41761. + p = nla_nest_start(cb->msg, SWITCH_ATTR_PORT);
  41762. + if (!p)
  41763. + goto error;
  41764. +
  41765. + if (nla_put_u32(cb->msg, SWITCH_PORT_ID, port->id))
  41766. + goto nla_put_failure;
  41767. + if (port->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) {
  41768. + if (nla_put_flag(cb->msg, SWITCH_PORT_FLAG_TAGGED))
  41769. + goto nla_put_failure;
  41770. + }
  41771. +
  41772. + nla_nest_end(cb->msg, p);
  41773. + return 0;
  41774. +
  41775. +nla_put_failure:
  41776. + nla_nest_cancel(cb->msg, p);
  41777. +error:
  41778. + nla_nest_cancel(cb->msg, cb->nest[0]);
  41779. + return -1;
  41780. +}
  41781. +
  41782. +static int
  41783. +swconfig_send_ports(struct sk_buff **msg, struct genl_info *info, int attr,
  41784. + const struct switch_val *val)
  41785. +{
  41786. + struct swconfig_callback cb;
  41787. + int err = 0;
  41788. + int i;
  41789. +
  41790. + if (!val->value.ports)
  41791. + return -EINVAL;
  41792. +
  41793. + memset(&cb, 0, sizeof(cb));
  41794. + cb.cmd = attr;
  41795. + cb.msg = *msg;
  41796. + cb.info = info;
  41797. + cb.fill = swconfig_send_port;
  41798. + cb.close = swconfig_close_portlist;
  41799. +
  41800. + cb.nest[0] = nla_nest_start(cb.msg, cb.cmd);
  41801. + for (i = 0; i < val->len; i++) {
  41802. + err = swconfig_send_multipart(&cb, &val->value.ports[i]);
  41803. + if (err)
  41804. + goto done;
  41805. + }
  41806. + err = val->len;
  41807. + swconfig_close_portlist(&cb, NULL);
  41808. + *msg = cb.msg;
  41809. +
  41810. +done:
  41811. + return err;
  41812. +}
  41813. +
  41814. +static int
  41815. +swconfig_get_attr(struct sk_buff *skb, struct genl_info *info)
  41816. +{
  41817. + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
  41818. + const struct switch_attr *attr;
  41819. + struct switch_dev *dev;
  41820. + struct sk_buff *msg = NULL;
  41821. + struct switch_val val;
  41822. + int err = -EINVAL;
  41823. + int cmd = hdr->cmd;
  41824. +
  41825. + dev = swconfig_get_dev(info);
  41826. + if (!dev)
  41827. + return -EINVAL;
  41828. +
  41829. + memset(&val, 0, sizeof(val));
  41830. + attr = swconfig_lookup_attr(dev, info, &val);
  41831. + if (!attr || !attr->get)
  41832. + goto error;
  41833. +
  41834. + if (attr->type == SWITCH_TYPE_PORTS) {
  41835. + val.value.ports = dev->portbuf;
  41836. + memset(dev->portbuf, 0,
  41837. + sizeof(struct switch_port) * dev->ports);
  41838. + }
  41839. +
  41840. + err = attr->get(dev, attr, &val);
  41841. + if (err)
  41842. + goto error;
  41843. +
  41844. + msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  41845. + if (!msg)
  41846. + goto error;
  41847. +
  41848. + hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam,
  41849. + 0, cmd);
  41850. + if (IS_ERR(hdr))
  41851. + goto nla_put_failure;
  41852. +
  41853. + switch (attr->type) {
  41854. + case SWITCH_TYPE_INT:
  41855. + if (nla_put_u32(msg, SWITCH_ATTR_OP_VALUE_INT, val.value.i))
  41856. + goto nla_put_failure;
  41857. + break;
  41858. + case SWITCH_TYPE_STRING:
  41859. + if (nla_put_string(msg, SWITCH_ATTR_OP_VALUE_STR, val.value.s))
  41860. + goto nla_put_failure;
  41861. + break;
  41862. + case SWITCH_TYPE_PORTS:
  41863. + err = swconfig_send_ports(&msg, info,
  41864. + SWITCH_ATTR_OP_VALUE_PORTS, &val);
  41865. + if (err < 0)
  41866. + goto nla_put_failure;
  41867. + break;
  41868. + default:
  41869. + pr_debug("invalid type in attribute\n");
  41870. + err = -EINVAL;
  41871. + goto error;
  41872. + }
  41873. + genlmsg_end(msg, hdr);
  41874. + err = msg->len;
  41875. + if (err < 0)
  41876. + goto nla_put_failure;
  41877. +
  41878. + swconfig_put_dev(dev);
  41879. + return genlmsg_reply(msg, info);
  41880. +
  41881. +nla_put_failure:
  41882. + if (msg)
  41883. + nlmsg_free(msg);
  41884. +error:
  41885. + swconfig_put_dev(dev);
  41886. + if (!err)
  41887. + err = -ENOMEM;
  41888. + return err;
  41889. +}
  41890. +
  41891. +static int
  41892. +swconfig_send_switch(struct sk_buff *msg, u32 pid, u32 seq, int flags,
  41893. + const struct switch_dev *dev)
  41894. +{
  41895. + struct nlattr *p = NULL, *m = NULL;
  41896. + void *hdr;
  41897. + int i;
  41898. +
  41899. + hdr = genlmsg_put(msg, pid, seq, &switch_fam, flags,
  41900. + SWITCH_CMD_NEW_ATTR);
  41901. + if (IS_ERR(hdr))
  41902. + return -1;
  41903. +
  41904. + if (nla_put_u32(msg, SWITCH_ATTR_ID, dev->id))
  41905. + goto nla_put_failure;
  41906. + if (nla_put_string(msg, SWITCH_ATTR_DEV_NAME, dev->devname))
  41907. + goto nla_put_failure;
  41908. + if (nla_put_string(msg, SWITCH_ATTR_ALIAS, dev->alias))
  41909. + goto nla_put_failure;
  41910. + if (nla_put_string(msg, SWITCH_ATTR_NAME, dev->name))
  41911. + goto nla_put_failure;
  41912. + if (nla_put_u32(msg, SWITCH_ATTR_VLANS, dev->vlans))
  41913. + goto nla_put_failure;
  41914. + if (nla_put_u32(msg, SWITCH_ATTR_PORTS, dev->ports))
  41915. + goto nla_put_failure;
  41916. + if (nla_put_u32(msg, SWITCH_ATTR_CPU_PORT, dev->cpu_port))
  41917. + goto nla_put_failure;
  41918. +
  41919. + m = nla_nest_start(msg, SWITCH_ATTR_PORTMAP);
  41920. + if (!m)
  41921. + goto nla_put_failure;
  41922. + for (i = 0; i < dev->ports; i++) {
  41923. + p = nla_nest_start(msg, SWITCH_ATTR_PORTS);
  41924. + if (!p)
  41925. + continue;
  41926. + if (dev->portmap[i].s) {
  41927. + if (nla_put_string(msg, SWITCH_PORTMAP_SEGMENT,
  41928. + dev->portmap[i].s))
  41929. + goto nla_put_failure;
  41930. + if (nla_put_u32(msg, SWITCH_PORTMAP_VIRT,
  41931. + dev->portmap[i].virt))
  41932. + goto nla_put_failure;
  41933. + }
  41934. + nla_nest_end(msg, p);
  41935. + }
  41936. + nla_nest_end(msg, m);
  41937. + genlmsg_end(msg, hdr);
  41938. + return msg->len;
  41939. +nla_put_failure:
  41940. + genlmsg_cancel(msg, hdr);
  41941. + return -EMSGSIZE;
  41942. +}
  41943. +
  41944. +static int swconfig_dump_switches(struct sk_buff *skb,
  41945. + struct netlink_callback *cb)
  41946. +{
  41947. + struct switch_dev *dev;
  41948. + int start = cb->args[0];
  41949. + int idx = 0;
  41950. +
  41951. + swconfig_lock();
  41952. + list_for_each_entry(dev, &swdevs, dev_list) {
  41953. + if (++idx <= start)
  41954. + continue;
  41955. + if (swconfig_send_switch(skb, NETLINK_CB(cb->skb).portid,
  41956. + cb->nlh->nlmsg_seq, NLM_F_MULTI,
  41957. + dev) < 0)
  41958. + break;
  41959. + }
  41960. + swconfig_unlock();
  41961. + cb->args[0] = idx;
  41962. +
  41963. + return skb->len;
  41964. +}
  41965. +
  41966. +static int
  41967. +swconfig_done(struct netlink_callback *cb)
  41968. +{
  41969. + return 0;
  41970. +}
  41971. +
  41972. +static struct genl_ops swconfig_ops[] = {
  41973. + {
  41974. + .cmd = SWITCH_CMD_LIST_GLOBAL,
  41975. + .doit = swconfig_list_attrs,
  41976. + .policy = switch_policy,
  41977. + },
  41978. + {
  41979. + .cmd = SWITCH_CMD_LIST_VLAN,
  41980. + .doit = swconfig_list_attrs,
  41981. + .policy = switch_policy,
  41982. + },
  41983. + {
  41984. + .cmd = SWITCH_CMD_LIST_PORT,
  41985. + .doit = swconfig_list_attrs,
  41986. + .policy = switch_policy,
  41987. + },
  41988. + {
  41989. + .cmd = SWITCH_CMD_GET_GLOBAL,
  41990. + .doit = swconfig_get_attr,
  41991. + .policy = switch_policy,
  41992. + },
  41993. + {
  41994. + .cmd = SWITCH_CMD_GET_VLAN,
  41995. + .doit = swconfig_get_attr,
  41996. + .policy = switch_policy,
  41997. + },
  41998. + {
  41999. + .cmd = SWITCH_CMD_GET_PORT,
  42000. + .doit = swconfig_get_attr,
  42001. + .policy = switch_policy,
  42002. + },
  42003. + {
  42004. + .cmd = SWITCH_CMD_SET_GLOBAL,
  42005. + .doit = swconfig_set_attr,
  42006. + .policy = switch_policy,
  42007. + },
  42008. + {
  42009. + .cmd = SWITCH_CMD_SET_VLAN,
  42010. + .doit = swconfig_set_attr,
  42011. + .policy = switch_policy,
  42012. + },
  42013. + {
  42014. + .cmd = SWITCH_CMD_SET_PORT,
  42015. + .doit = swconfig_set_attr,
  42016. + .policy = switch_policy,
  42017. + },
  42018. + {
  42019. + .cmd = SWITCH_CMD_GET_SWITCH,
  42020. + .dumpit = swconfig_dump_switches,
  42021. + .policy = switch_policy,
  42022. + .done = swconfig_done,
  42023. + }
  42024. +};
  42025. +
  42026. +#ifdef CONFIG_OF
  42027. +void
  42028. +of_switch_load_portmap(struct switch_dev *dev)
  42029. +{
  42030. + struct device_node *port;
  42031. +
  42032. + if (!dev->of_node)
  42033. + return;
  42034. +
  42035. + for_each_child_of_node(dev->of_node, port) {
  42036. + const __be32 *prop;
  42037. + const char *segment;
  42038. + int size, phys;
  42039. +
  42040. + if (!of_device_is_compatible(port, "swconfig,port"))
  42041. + continue;
  42042. +
  42043. + if (of_property_read_string(port, "swconfig,segment", &segment))
  42044. + continue;
  42045. +
  42046. + prop = of_get_property(port, "swconfig,portmap", &size);
  42047. + if (!prop)
  42048. + continue;
  42049. +
  42050. + if (size != (2 * sizeof(*prop))) {
  42051. + pr_err("%s: failed to parse port mapping\n",
  42052. + port->name);
  42053. + continue;
  42054. + }
  42055. +
  42056. + phys = be32_to_cpup(prop++);
  42057. + if ((phys < 0) | (phys >= dev->ports)) {
  42058. + pr_err("%s: physical port index out of range\n",
  42059. + port->name);
  42060. + continue;
  42061. + }
  42062. +
  42063. + dev->portmap[phys].s = kstrdup(segment, GFP_KERNEL);
  42064. + dev->portmap[phys].virt = be32_to_cpup(prop);
  42065. + pr_debug("Found port: %s, physical: %d, virtual: %d\n",
  42066. + segment, phys, dev->portmap[phys].virt);
  42067. + }
  42068. +}
  42069. +#endif
  42070. +
  42071. +int
  42072. +register_switch(struct switch_dev *dev, struct net_device *netdev)
  42073. +{
  42074. + struct switch_dev *sdev;
  42075. + const int max_switches = 8 * sizeof(unsigned long);
  42076. + unsigned long in_use = 0;
  42077. + int err;
  42078. + int i;
  42079. +
  42080. + INIT_LIST_HEAD(&dev->dev_list);
  42081. + if (netdev) {
  42082. + dev->netdev = netdev;
  42083. + if (!dev->alias)
  42084. + dev->alias = netdev->name;
  42085. + }
  42086. + BUG_ON(!dev->alias);
  42087. +
  42088. + if (dev->ports > 0) {
  42089. + dev->portbuf = kzalloc(sizeof(struct switch_port) *
  42090. + dev->ports, GFP_KERNEL);
  42091. + if (!dev->portbuf)
  42092. + return -ENOMEM;
  42093. + dev->portmap = kzalloc(sizeof(struct switch_portmap) *
  42094. + dev->ports, GFP_KERNEL);
  42095. + if (!dev->portmap) {
  42096. + kfree(dev->portbuf);
  42097. + return -ENOMEM;
  42098. + }
  42099. + }
  42100. + swconfig_defaults_init(dev);
  42101. + mutex_init(&dev->sw_mutex);
  42102. + swconfig_lock();
  42103. + dev->id = ++swdev_id;
  42104. +
  42105. + list_for_each_entry(sdev, &swdevs, dev_list) {
  42106. + if (!sscanf(sdev->devname, SWCONFIG_DEVNAME, &i))
  42107. + continue;
  42108. + if (i < 0 || i > max_switches)
  42109. + continue;
  42110. +
  42111. + set_bit(i, &in_use);
  42112. + }
  42113. + i = find_first_zero_bit(&in_use, max_switches);
  42114. +
  42115. + if (i == max_switches) {
  42116. + swconfig_unlock();
  42117. + return -ENFILE;
  42118. + }
  42119. +
  42120. +#ifdef CONFIG_OF
  42121. + if (dev->ports)
  42122. + of_switch_load_portmap(dev);
  42123. +#endif
  42124. +
  42125. + /* fill device name */
  42126. + snprintf(dev->devname, IFNAMSIZ, SWCONFIG_DEVNAME, i);
  42127. +
  42128. + list_add_tail(&dev->dev_list, &swdevs);
  42129. + swconfig_unlock();
  42130. +
  42131. + err = swconfig_create_led_trigger(dev);
  42132. + if (err)
  42133. + return err;
  42134. +
  42135. + return 0;
  42136. +}
  42137. +EXPORT_SYMBOL_GPL(register_switch);
  42138. +
  42139. +void
  42140. +unregister_switch(struct switch_dev *dev)
  42141. +{
  42142. + swconfig_destroy_led_trigger(dev);
  42143. + kfree(dev->portbuf);
  42144. + mutex_lock(&dev->sw_mutex);
  42145. + swconfig_lock();
  42146. + list_del(&dev->dev_list);
  42147. + swconfig_unlock();
  42148. + mutex_unlock(&dev->sw_mutex);
  42149. +}
  42150. +EXPORT_SYMBOL_GPL(unregister_switch);
  42151. +
  42152. +
  42153. +static int __init
  42154. +swconfig_init(void)
  42155. +{
  42156. + int err;
  42157. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0))
  42158. + int i;
  42159. +#endif
  42160. +
  42161. + INIT_LIST_HEAD(&swdevs);
  42162. +
  42163. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0))
  42164. + err = genl_register_family(&switch_fam);
  42165. + if (err)
  42166. + return err;
  42167. +
  42168. + for (i = 0; i < ARRAY_SIZE(swconfig_ops); i++) {
  42169. + err = genl_register_ops(&switch_fam, &swconfig_ops[i]);
  42170. + if (err)
  42171. + goto unregister;
  42172. + }
  42173. + return 0;
  42174. +
  42175. +unregister:
  42176. + genl_unregister_family(&switch_fam);
  42177. + return err;
  42178. +#else
  42179. + err = genl_register_family_with_ops(&switch_fam, swconfig_ops);
  42180. + if (err)
  42181. + return err;
  42182. + return 0;
  42183. +#endif
  42184. +}
  42185. +
  42186. +static void __exit
  42187. +swconfig_exit(void)
  42188. +{
  42189. + genl_unregister_family(&switch_fam);
  42190. +}
  42191. +
  42192. +module_init(swconfig_init);
  42193. +module_exit(swconfig_exit);
  42194. +
  42195. diff -Nur linux-4.1.13.orig/drivers/net/phy/swconfig_leds.c linux-4.1.13/drivers/net/phy/swconfig_leds.c
  42196. --- linux-4.1.13.orig/drivers/net/phy/swconfig_leds.c 1970-01-01 01:00:00.000000000 +0100
  42197. +++ linux-4.1.13/drivers/net/phy/swconfig_leds.c 2015-12-04 21:45:30.824406773 +0100
  42198. @@ -0,0 +1,354 @@
  42199. +/*
  42200. + * swconfig_led.c: LED trigger support for the switch configuration API
  42201. + *
  42202. + * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
  42203. + *
  42204. + * This program is free software; you can redistribute it and/or
  42205. + * modify it under the terms of the GNU General Public License
  42206. + * as published by the Free Software Foundation; either version 2
  42207. + * of the License, or (at your option) any later version.
  42208. + *
  42209. + */
  42210. +
  42211. +#ifdef CONFIG_SWCONFIG_LEDS
  42212. +
  42213. +#include <linux/leds.h>
  42214. +#include <linux/ctype.h>
  42215. +#include <linux/device.h>
  42216. +#include <linux/workqueue.h>
  42217. +
  42218. +#define SWCONFIG_LED_TIMER_INTERVAL (HZ / 10)
  42219. +#define SWCONFIG_LED_NUM_PORTS 32
  42220. +
  42221. +struct switch_led_trigger {
  42222. + struct led_trigger trig;
  42223. + struct switch_dev *swdev;
  42224. +
  42225. + struct delayed_work sw_led_work;
  42226. + u32 port_mask;
  42227. + u32 port_link;
  42228. + unsigned long port_traffic[SWCONFIG_LED_NUM_PORTS];
  42229. +};
  42230. +
  42231. +struct swconfig_trig_data {
  42232. + struct led_classdev *led_cdev;
  42233. + struct switch_dev *swdev;
  42234. +
  42235. + rwlock_t lock;
  42236. + u32 port_mask;
  42237. +
  42238. + bool prev_link;
  42239. + unsigned long prev_traffic;
  42240. + enum led_brightness prev_brightness;
  42241. +};
  42242. +
  42243. +static void
  42244. +swconfig_trig_set_brightness(struct swconfig_trig_data *trig_data,
  42245. + enum led_brightness brightness)
  42246. +{
  42247. + led_set_brightness(trig_data->led_cdev, brightness);
  42248. + trig_data->prev_brightness = brightness;
  42249. +}
  42250. +
  42251. +static void
  42252. +swconfig_trig_update_port_mask(struct led_trigger *trigger)
  42253. +{
  42254. + struct list_head *entry;
  42255. + struct switch_led_trigger *sw_trig;
  42256. + u32 port_mask;
  42257. +
  42258. + if (!trigger)
  42259. + return;
  42260. +
  42261. + sw_trig = (void *) trigger;
  42262. +
  42263. + port_mask = 0;
  42264. + read_lock(&trigger->leddev_list_lock);
  42265. + list_for_each(entry, &trigger->led_cdevs) {
  42266. + struct led_classdev *led_cdev;
  42267. + struct swconfig_trig_data *trig_data;
  42268. +
  42269. + led_cdev = list_entry(entry, struct led_classdev, trig_list);
  42270. + trig_data = led_cdev->trigger_data;
  42271. + if (trig_data) {
  42272. + read_lock(&trig_data->lock);
  42273. + port_mask |= trig_data->port_mask;
  42274. + read_unlock(&trig_data->lock);
  42275. + }
  42276. + }
  42277. + read_unlock(&trigger->leddev_list_lock);
  42278. +
  42279. + sw_trig->port_mask = port_mask;
  42280. +
  42281. + if (port_mask)
  42282. + schedule_delayed_work(&sw_trig->sw_led_work,
  42283. + SWCONFIG_LED_TIMER_INTERVAL);
  42284. + else
  42285. + cancel_delayed_work_sync(&sw_trig->sw_led_work);
  42286. +}
  42287. +
  42288. +static ssize_t
  42289. +swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr,
  42290. + const char *buf, size_t size)
  42291. +{
  42292. + struct led_classdev *led_cdev = dev_get_drvdata(dev);
  42293. + struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
  42294. + unsigned long port_mask;
  42295. + ssize_t ret = -EINVAL;
  42296. + char *after;
  42297. + size_t count;
  42298. +
  42299. + port_mask = simple_strtoul(buf, &after, 16);
  42300. + count = after - buf;
  42301. +
  42302. + if (*after && isspace(*after))
  42303. + count++;
  42304. +
  42305. + if (count == size) {
  42306. + bool changed;
  42307. +
  42308. + write_lock(&trig_data->lock);
  42309. +
  42310. + changed = (trig_data->port_mask != port_mask);
  42311. + if (changed) {
  42312. + trig_data->port_mask = port_mask;
  42313. + if (port_mask == 0)
  42314. + swconfig_trig_set_brightness(trig_data, LED_OFF);
  42315. + }
  42316. +
  42317. + write_unlock(&trig_data->lock);
  42318. +
  42319. + if (changed)
  42320. + swconfig_trig_update_port_mask(led_cdev->trigger);
  42321. +
  42322. + ret = count;
  42323. + }
  42324. +
  42325. + return ret;
  42326. +}
  42327. +
  42328. +static ssize_t
  42329. +swconfig_trig_port_mask_show(struct device *dev, struct device_attribute *attr,
  42330. + char *buf)
  42331. +{
  42332. + struct led_classdev *led_cdev = dev_get_drvdata(dev);
  42333. + struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
  42334. +
  42335. + read_lock(&trig_data->lock);
  42336. + sprintf(buf, "%#x\n", trig_data->port_mask);
  42337. + read_unlock(&trig_data->lock);
  42338. +
  42339. + return strlen(buf) + 1;
  42340. +}
  42341. +
  42342. +static DEVICE_ATTR(port_mask, 0644, swconfig_trig_port_mask_show,
  42343. + swconfig_trig_port_mask_store);
  42344. +
  42345. +static void
  42346. +swconfig_trig_activate(struct led_classdev *led_cdev)
  42347. +{
  42348. + struct switch_led_trigger *sw_trig;
  42349. + struct swconfig_trig_data *trig_data;
  42350. + int err;
  42351. +
  42352. + if (led_cdev->trigger->activate != swconfig_trig_activate)
  42353. + return;
  42354. +
  42355. + trig_data = kzalloc(sizeof(struct swconfig_trig_data), GFP_KERNEL);
  42356. + if (!trig_data)
  42357. + return;
  42358. +
  42359. + sw_trig = (void *) led_cdev->trigger;
  42360. +
  42361. + rwlock_init(&trig_data->lock);
  42362. + trig_data->led_cdev = led_cdev;
  42363. + trig_data->swdev = sw_trig->swdev;
  42364. + led_cdev->trigger_data = trig_data;
  42365. +
  42366. + err = device_create_file(led_cdev->dev, &dev_attr_port_mask);
  42367. + if (err)
  42368. + goto err_free;
  42369. +
  42370. + return;
  42371. +
  42372. +err_free:
  42373. + led_cdev->trigger_data = NULL;
  42374. + kfree(trig_data);
  42375. +}
  42376. +
  42377. +static void
  42378. +swconfig_trig_deactivate(struct led_classdev *led_cdev)
  42379. +{
  42380. + struct swconfig_trig_data *trig_data;
  42381. +
  42382. + swconfig_trig_update_port_mask(led_cdev->trigger);
  42383. +
  42384. + trig_data = (void *) led_cdev->trigger_data;
  42385. + if (trig_data) {
  42386. + device_remove_file(led_cdev->dev, &dev_attr_port_mask);
  42387. + kfree(trig_data);
  42388. + }
  42389. +}
  42390. +
  42391. +static void
  42392. +swconfig_trig_led_event(struct switch_led_trigger *sw_trig,
  42393. + struct led_classdev *led_cdev)
  42394. +{
  42395. + struct swconfig_trig_data *trig_data;
  42396. + u32 port_mask;
  42397. + bool link;
  42398. +
  42399. + trig_data = led_cdev->trigger_data;
  42400. + if (!trig_data)
  42401. + return;
  42402. +
  42403. + read_lock(&trig_data->lock);
  42404. + port_mask = trig_data->port_mask;
  42405. + read_unlock(&trig_data->lock);
  42406. +
  42407. + link = !!(sw_trig->port_link & port_mask);
  42408. + if (!link) {
  42409. + if (link != trig_data->prev_link)
  42410. + swconfig_trig_set_brightness(trig_data, LED_OFF);
  42411. + } else {
  42412. + unsigned long traffic;
  42413. + int i;
  42414. +
  42415. + traffic = 0;
  42416. + for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) {
  42417. + if (port_mask & (1 << i))
  42418. + traffic += sw_trig->port_traffic[i];
  42419. + }
  42420. +
  42421. + if (trig_data->prev_brightness != LED_FULL)
  42422. + swconfig_trig_set_brightness(trig_data, LED_FULL);
  42423. + else if (traffic != trig_data->prev_traffic)
  42424. + swconfig_trig_set_brightness(trig_data, LED_OFF);
  42425. +
  42426. + trig_data->prev_traffic = traffic;
  42427. + }
  42428. +
  42429. + trig_data->prev_link = link;
  42430. +}
  42431. +
  42432. +static void
  42433. +swconfig_trig_update_leds(struct switch_led_trigger *sw_trig)
  42434. +{
  42435. + struct list_head *entry;
  42436. + struct led_trigger *trigger;
  42437. +
  42438. + trigger = &sw_trig->trig;
  42439. + read_lock(&trigger->leddev_list_lock);
  42440. + list_for_each(entry, &trigger->led_cdevs) {
  42441. + struct led_classdev *led_cdev;
  42442. +
  42443. + led_cdev = list_entry(entry, struct led_classdev, trig_list);
  42444. + swconfig_trig_led_event(sw_trig, led_cdev);
  42445. + }
  42446. + read_unlock(&trigger->leddev_list_lock);
  42447. +}
  42448. +
  42449. +static void
  42450. +swconfig_led_work_func(struct work_struct *work)
  42451. +{
  42452. + struct switch_led_trigger *sw_trig;
  42453. + struct switch_dev *swdev;
  42454. + u32 port_mask;
  42455. + u32 link;
  42456. + int i;
  42457. +
  42458. + sw_trig = container_of(work, struct switch_led_trigger,
  42459. + sw_led_work.work);
  42460. +
  42461. + port_mask = sw_trig->port_mask;
  42462. + swdev = sw_trig->swdev;
  42463. +
  42464. + link = 0;
  42465. + for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) {
  42466. + u32 port_bit;
  42467. +
  42468. + port_bit = BIT(i);
  42469. + if ((port_mask & port_bit) == 0)
  42470. + continue;
  42471. +
  42472. + if (swdev->ops->get_port_link) {
  42473. + struct switch_port_link port_link;
  42474. +
  42475. + memset(&port_link, '\0', sizeof(port_link));
  42476. + swdev->ops->get_port_link(swdev, i, &port_link);
  42477. +
  42478. + if (port_link.link)
  42479. + link |= port_bit;
  42480. + }
  42481. +
  42482. + if (swdev->ops->get_port_stats) {
  42483. + struct switch_port_stats port_stats;
  42484. +
  42485. + memset(&port_stats, '\0', sizeof(port_stats));
  42486. + swdev->ops->get_port_stats(swdev, i, &port_stats);
  42487. + sw_trig->port_traffic[i] = port_stats.tx_bytes +
  42488. + port_stats.rx_bytes;
  42489. + }
  42490. + }
  42491. +
  42492. + sw_trig->port_link = link;
  42493. +
  42494. + swconfig_trig_update_leds(sw_trig);
  42495. +
  42496. + schedule_delayed_work(&sw_trig->sw_led_work,
  42497. + SWCONFIG_LED_TIMER_INTERVAL);
  42498. +}
  42499. +
  42500. +static int
  42501. +swconfig_create_led_trigger(struct switch_dev *swdev)
  42502. +{
  42503. + struct switch_led_trigger *sw_trig;
  42504. + int err;
  42505. +
  42506. + if (!swdev->ops->get_port_link)
  42507. + return 0;
  42508. +
  42509. + sw_trig = kzalloc(sizeof(struct switch_led_trigger), GFP_KERNEL);
  42510. + if (!sw_trig)
  42511. + return -ENOMEM;
  42512. +
  42513. + sw_trig->swdev = swdev;
  42514. + sw_trig->trig.name = swdev->devname;
  42515. + sw_trig->trig.activate = swconfig_trig_activate;
  42516. + sw_trig->trig.deactivate = swconfig_trig_deactivate;
  42517. +
  42518. + INIT_DELAYED_WORK(&sw_trig->sw_led_work, swconfig_led_work_func);
  42519. +
  42520. + err = led_trigger_register(&sw_trig->trig);
  42521. + if (err)
  42522. + goto err_free;
  42523. +
  42524. + swdev->led_trigger = sw_trig;
  42525. +
  42526. + return 0;
  42527. +
  42528. +err_free:
  42529. + kfree(sw_trig);
  42530. + return err;
  42531. +}
  42532. +
  42533. +static void
  42534. +swconfig_destroy_led_trigger(struct switch_dev *swdev)
  42535. +{
  42536. + struct switch_led_trigger *sw_trig;
  42537. +
  42538. + sw_trig = swdev->led_trigger;
  42539. + if (sw_trig) {
  42540. + cancel_delayed_work_sync(&sw_trig->sw_led_work);
  42541. + led_trigger_unregister(&sw_trig->trig);
  42542. + kfree(sw_trig);
  42543. + }
  42544. +}
  42545. +
  42546. +#else /* SWCONFIG_LEDS */
  42547. +static inline int
  42548. +swconfig_create_led_trigger(struct switch_dev *swdev) { return 0; }
  42549. +
  42550. +static inline void
  42551. +swconfig_destroy_led_trigger(struct switch_dev *swdev) { }
  42552. +#endif /* CONFIG_SWCONFIG_LEDS */
  42553. diff -Nur linux-4.1.13.orig/drivers/spi/Kconfig linux-4.1.13/drivers/spi/Kconfig
  42554. --- linux-4.1.13.orig/drivers/spi/Kconfig 2015-11-09 23:34:10.000000000 +0100
  42555. +++ linux-4.1.13/drivers/spi/Kconfig 2015-12-04 19:57:03.922108288 +0100
  42556. @@ -59,6 +59,14 @@
  42557. help
  42558. This is the driver for the Altera SPI Controller.
  42559. +config SPI_AP83
  42560. + tristate "Atheros AP83 specific SPI Controller"
  42561. + depends on SPI_MASTER && ATH79_MACH_AP83
  42562. + select SPI_BITBANG
  42563. + help
  42564. + This is a specific SPI controller driver for the Atheros AP83
  42565. + reference board.
  42566. +
  42567. config SPI_ATH79
  42568. tristate "Atheros AR71XX/AR724X/AR913X SPI controller driver"
  42569. depends on ATH79 && GPIOLIB
  42570. @@ -448,6 +456,12 @@
  42571. This driver can also be built as a module. If so, the module
  42572. will be called spi_qup.
  42573. +config SPI_RB4XX
  42574. + tristate "Mikrotik RB4XX SPI master"
  42575. + depends on SPI_MASTER && ATH79_MACH_RB4XX
  42576. + help
  42577. + SPI controller driver for the Mikrotik RB4xx series boards.
  42578. +
  42579. config SPI_S3C24XX
  42580. tristate "Samsung S3C24XX series SPI"
  42581. depends on ARCH_S3C24XX
  42582. @@ -661,6 +675,18 @@
  42583. sysfs interface, with each line presented as a kind of GPIO
  42584. exposing both switch control and diagnostic feedback.
  42585. +config SPI_RB4XX_CPLD
  42586. + tristate "MikroTik RB4XX CPLD driver"
  42587. + depends on ATH79_MACH_RB4XX
  42588. + help
  42589. + SPI driver for the Xilinx CPLD chip present on the
  42590. + MikroTik RB4xx boards.
  42591. +
  42592. +config SPI_VSC7385
  42593. + tristate "Vitesse VSC7385 ethernet switch driver"
  42594. + help
  42595. + SPI driver for the Vitesse VSC7385 ethernet switch.
  42596. +
  42597. #
  42598. # Add new SPI protocol masters in alphabetical order above this line
  42599. #
  42600. diff -Nur linux-4.1.13.orig/drivers/spi/Makefile linux-4.1.13/drivers/spi/Makefile
  42601. --- linux-4.1.13.orig/drivers/spi/Makefile 2015-11-09 23:34:10.000000000 +0100
  42602. +++ linux-4.1.13/drivers/spi/Makefile 2015-12-04 19:57:03.922108288 +0100
  42603. @@ -12,6 +12,7 @@
  42604. # SPI master controller drivers (bus)
  42605. obj-$(CONFIG_SPI_ALTERA) += spi-altera.o
  42606. obj-$(CONFIG_SPI_ATMEL) += spi-atmel.o
  42607. +obj-$(CONFIG_SPI_AP83) += spi-ap83.o
  42608. obj-$(CONFIG_SPI_ATH79) += spi-ath79.o
  42609. obj-$(CONFIG_SPI_AU1550) += spi-au1550.o
  42610. obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o
  42611. @@ -64,6 +65,8 @@
  42612. spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_DMA) += spi-pxa2xx-dma.o
  42613. obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-platform.o
  42614. obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o
  42615. +obj-$(CONFIG_SPI_RB4XX) += spi-rb4xx.o
  42616. +obj-$(CONFIG_SPI_RB4XX_CPLD) += spi-rb4xx-cpld.o
  42617. obj-$(CONFIG_SPI_QUP) += spi-qup.o
  42618. obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o
  42619. obj-$(CONFIG_SPI_RSPI) += spi-rspi.o
  42620. @@ -86,6 +89,7 @@
  42621. obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o
  42622. obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o
  42623. obj-$(CONFIG_SPI_TXX9) += spi-txx9.o
  42624. +obj-$(CONFIG_SPI_VSC7385) += spi-vsc7385.o
  42625. obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o
  42626. obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o
  42627. obj-$(CONFIG_SPI_XTENSA_XTFPGA) += spi-xtensa-xtfpga.o
  42628. diff -Nur linux-4.1.13.orig/drivers/spi/spi-ap83.c linux-4.1.13/drivers/spi/spi-ap83.c
  42629. --- linux-4.1.13.orig/drivers/spi/spi-ap83.c 1970-01-01 01:00:00.000000000 +0100
  42630. +++ linux-4.1.13/drivers/spi/spi-ap83.c 2015-09-13 20:04:35.076523692 +0200
  42631. @@ -0,0 +1,283 @@
  42632. +/*
  42633. + * Atheros AP83 board specific SPI Controller driver
  42634. + *
  42635. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  42636. + *
  42637. + * This program is free software; you can redistribute it and/or modify
  42638. + * it under the terms of the GNU General Public License version 2 as
  42639. + * published by the Free Software Foundation.
  42640. + *
  42641. + */
  42642. +
  42643. +#include <linux/kernel.h>
  42644. +#include <linux/module.h>
  42645. +#include <linux/init.h>
  42646. +#include <linux/delay.h>
  42647. +#include <linux/spinlock.h>
  42648. +#include <linux/workqueue.h>
  42649. +#include <linux/platform_device.h>
  42650. +#include <linux/io.h>
  42651. +#include <linux/spi/spi.h>
  42652. +#include <linux/spi/spi_bitbang.h>
  42653. +#include <linux/bitops.h>
  42654. +#include <linux/gpio.h>
  42655. +
  42656. +#include <asm/mach-ath79/ath79.h>
  42657. +
  42658. +#define DRV_DESC "Atheros AP83 board SPI Controller driver"
  42659. +#define DRV_VERSION "0.1.0"
  42660. +#define DRV_NAME "ap83-spi"
  42661. +
  42662. +#define AP83_SPI_CLK_HIGH (1 << 23)
  42663. +#define AP83_SPI_CLK_LOW 0
  42664. +#define AP83_SPI_MOSI_HIGH (1 << 22)
  42665. +#define AP83_SPI_MOSI_LOW 0
  42666. +
  42667. +#define AP83_SPI_GPIO_CS 1
  42668. +#define AP83_SPI_GPIO_MISO 3
  42669. +
  42670. +struct ap83_spi {
  42671. + struct spi_bitbang bitbang;
  42672. + void __iomem *base;
  42673. + u32 addr;
  42674. +
  42675. + struct platform_device *pdev;
  42676. +};
  42677. +
  42678. +static inline u32 ap83_spi_rr(struct ap83_spi *sp, u32 reg)
  42679. +{
  42680. + return __raw_readl(sp->base + reg);
  42681. +}
  42682. +
  42683. +static inline struct ap83_spi *spidev_to_sp(struct spi_device *spi)
  42684. +{
  42685. + return spi_master_get_devdata(spi->master);
  42686. +}
  42687. +
  42688. +static inline void setsck(struct spi_device *spi, int val)
  42689. +{
  42690. + struct ap83_spi *sp = spidev_to_sp(spi);
  42691. +
  42692. + if (val)
  42693. + sp->addr |= AP83_SPI_CLK_HIGH;
  42694. + else
  42695. + sp->addr &= ~AP83_SPI_CLK_HIGH;
  42696. +
  42697. + dev_dbg(&spi->dev, "addr=%08x, SCK set to %s\n",
  42698. + sp->addr, (val) ? "HIGH" : "LOW");
  42699. +
  42700. + ap83_spi_rr(sp, sp->addr);
  42701. +}
  42702. +
  42703. +static inline void setmosi(struct spi_device *spi, int val)
  42704. +{
  42705. + struct ap83_spi *sp = spidev_to_sp(spi);
  42706. +
  42707. + if (val)
  42708. + sp->addr |= AP83_SPI_MOSI_HIGH;
  42709. + else
  42710. + sp->addr &= ~AP83_SPI_MOSI_HIGH;
  42711. +
  42712. + dev_dbg(&spi->dev, "addr=%08x, MOSI set to %s\n",
  42713. + sp->addr, (val) ? "HIGH" : "LOW");
  42714. +
  42715. + ap83_spi_rr(sp, sp->addr);
  42716. +}
  42717. +
  42718. +static inline u32 getmiso(struct spi_device *spi)
  42719. +{
  42720. + u32 ret;
  42721. +
  42722. + ret = gpio_get_value(AP83_SPI_GPIO_MISO) ? 1 : 0;
  42723. + dev_dbg(&spi->dev, "get MISO: %d\n", ret);
  42724. +
  42725. + return ret;
  42726. +}
  42727. +
  42728. +static inline void do_spidelay(struct spi_device *spi, unsigned nsecs)
  42729. +{
  42730. + ndelay(nsecs);
  42731. +}
  42732. +
  42733. +static void ap83_spi_chipselect(struct spi_device *spi, int on)
  42734. +{
  42735. + struct ap83_spi *sp = spidev_to_sp(spi);
  42736. +
  42737. + dev_dbg(&spi->dev, "set CS to %d\n", (on) ? 0 : 1);
  42738. +
  42739. + if (on) {
  42740. + ath79_flash_acquire();
  42741. +
  42742. + sp->addr = 0;
  42743. + ap83_spi_rr(sp, sp->addr);
  42744. +
  42745. + gpio_set_value(AP83_SPI_GPIO_CS, 0);
  42746. + } else {
  42747. + gpio_set_value(AP83_SPI_GPIO_CS, 1);
  42748. + ath79_flash_release();
  42749. + }
  42750. +}
  42751. +
  42752. +#define spidelay(nsecs) \
  42753. + do { \
  42754. + /* Steal the spi_device pointer from our caller. \
  42755. + * The bitbang-API should probably get fixed here... */ \
  42756. + do_spidelay(spi, nsecs); \
  42757. + } while (0)
  42758. +
  42759. +#define EXPAND_BITBANG_TXRX
  42760. +#include <linux/spi/spi_bitbang.h>
  42761. +#include "spi-bitbang-txrx.h"
  42762. +
  42763. +static u32 ap83_spi_txrx_mode0(struct spi_device *spi,
  42764. + unsigned nsecs, u32 word, u8 bits)
  42765. +{
  42766. + dev_dbg(&spi->dev, "TXRX0 word=%08x, bits=%u\n", word, bits);
  42767. + return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
  42768. +}
  42769. +
  42770. +static u32 ap83_spi_txrx_mode1(struct spi_device *spi,
  42771. + unsigned nsecs, u32 word, u8 bits)
  42772. +{
  42773. + dev_dbg(&spi->dev, "TXRX1 word=%08x, bits=%u\n", word, bits);
  42774. + return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
  42775. +}
  42776. +
  42777. +static u32 ap83_spi_txrx_mode2(struct spi_device *spi,
  42778. + unsigned nsecs, u32 word, u8 bits)
  42779. +{
  42780. + dev_dbg(&spi->dev, "TXRX2 word=%08x, bits=%u\n", word, bits);
  42781. + return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
  42782. +}
  42783. +
  42784. +static u32 ap83_spi_txrx_mode3(struct spi_device *spi,
  42785. + unsigned nsecs, u32 word, u8 bits)
  42786. +{
  42787. + dev_dbg(&spi->dev, "TXRX3 word=%08x, bits=%u\n", word, bits);
  42788. + return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
  42789. +}
  42790. +
  42791. +static int ap83_spi_probe(struct platform_device *pdev)
  42792. +{
  42793. + struct spi_master *master;
  42794. + struct ap83_spi *sp;
  42795. + struct ap83_spi_platform_data *pdata;
  42796. + struct resource *r;
  42797. + int ret;
  42798. +
  42799. + ret = gpio_request(AP83_SPI_GPIO_MISO, "spi-miso");
  42800. + if (ret) {
  42801. + dev_err(&pdev->dev, "gpio request failed for MISO\n");
  42802. + return ret;
  42803. + }
  42804. +
  42805. + ret = gpio_request(AP83_SPI_GPIO_CS, "spi-cs");
  42806. + if (ret) {
  42807. + dev_err(&pdev->dev, "gpio request failed for CS\n");
  42808. + goto err_free_miso;
  42809. + }
  42810. +
  42811. + ret = gpio_direction_input(AP83_SPI_GPIO_MISO);
  42812. + if (ret) {
  42813. + dev_err(&pdev->dev, "unable to set direction of MISO\n");
  42814. + goto err_free_cs;
  42815. + }
  42816. +
  42817. + ret = gpio_direction_output(AP83_SPI_GPIO_CS, 0);
  42818. + if (ret) {
  42819. + dev_err(&pdev->dev, "unable to set direction of CS\n");
  42820. + goto err_free_cs;
  42821. + }
  42822. +
  42823. + master = spi_alloc_master(&pdev->dev, sizeof(*sp));
  42824. + if (master == NULL) {
  42825. + dev_err(&pdev->dev, "failed to allocate spi master\n");
  42826. + return -ENOMEM;
  42827. + }
  42828. +
  42829. + sp = spi_master_get_devdata(master);
  42830. + platform_set_drvdata(pdev, sp);
  42831. +
  42832. + pdata = pdev->dev.platform_data;
  42833. +
  42834. + sp->bitbang.master = spi_master_get(master);
  42835. + sp->bitbang.chipselect = ap83_spi_chipselect;
  42836. + sp->bitbang.txrx_word[SPI_MODE_0] = ap83_spi_txrx_mode0;
  42837. + sp->bitbang.txrx_word[SPI_MODE_1] = ap83_spi_txrx_mode1;
  42838. + sp->bitbang.txrx_word[SPI_MODE_2] = ap83_spi_txrx_mode2;
  42839. + sp->bitbang.txrx_word[SPI_MODE_3] = ap83_spi_txrx_mode3;
  42840. +
  42841. + sp->bitbang.master->bus_num = pdev->id;
  42842. + sp->bitbang.master->num_chipselect = 1;
  42843. +
  42844. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  42845. + if (r == NULL) {
  42846. + ret = -ENOENT;
  42847. + goto err_spi_put;
  42848. + }
  42849. +
  42850. + sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
  42851. + if (!sp->base) {
  42852. + ret = -ENXIO;
  42853. + goto err_spi_put;
  42854. + }
  42855. +
  42856. + ret = spi_bitbang_start(&sp->bitbang);
  42857. + if (!ret)
  42858. + goto err_unmap;
  42859. +
  42860. + dev_info(&pdev->dev, "AP83 SPI adapter at %08x\n", r->start);
  42861. +
  42862. + return 0;
  42863. +
  42864. +err_unmap:
  42865. + iounmap(sp->base);
  42866. +err_spi_put:
  42867. + platform_set_drvdata(pdev, NULL);
  42868. + spi_master_put(sp->bitbang.master);
  42869. +
  42870. +err_free_cs:
  42871. + gpio_free(AP83_SPI_GPIO_CS);
  42872. +err_free_miso:
  42873. + gpio_free(AP83_SPI_GPIO_MISO);
  42874. + return ret;
  42875. +}
  42876. +
  42877. +static int ap83_spi_remove(struct platform_device *pdev)
  42878. +{
  42879. + struct ap83_spi *sp = platform_get_drvdata(pdev);
  42880. +
  42881. + spi_bitbang_stop(&sp->bitbang);
  42882. + iounmap(sp->base);
  42883. + platform_set_drvdata(pdev, NULL);
  42884. + spi_master_put(sp->bitbang.master);
  42885. +
  42886. + return 0;
  42887. +}
  42888. +
  42889. +static struct platform_driver ap83_spi_drv = {
  42890. + .probe = ap83_spi_probe,
  42891. + .remove = ap83_spi_remove,
  42892. + .driver = {
  42893. + .name = DRV_NAME,
  42894. + .owner = THIS_MODULE,
  42895. + },
  42896. +};
  42897. +
  42898. +static int __init ap83_spi_init(void)
  42899. +{
  42900. + return platform_driver_register(&ap83_spi_drv);
  42901. +}
  42902. +module_init(ap83_spi_init);
  42903. +
  42904. +static void __exit ap83_spi_exit(void)
  42905. +{
  42906. + platform_driver_unregister(&ap83_spi_drv);
  42907. +}
  42908. +module_exit(ap83_spi_exit);
  42909. +
  42910. +MODULE_ALIAS("platform:" DRV_NAME);
  42911. +MODULE_DESCRIPTION(DRV_DESC);
  42912. +MODULE_VERSION(DRV_VERSION);
  42913. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  42914. +MODULE_LICENSE("GPL v2");
  42915. diff -Nur linux-4.1.13.orig/drivers/spi/spi-ath79.c linux-4.1.13/drivers/spi/spi-ath79.c
  42916. --- linux-4.1.13.orig/drivers/spi/spi-ath79.c 2015-11-09 23:34:10.000000000 +0100
  42917. +++ linux-4.1.13/drivers/spi/spi-ath79.c 2015-12-04 19:57:03.966105410 +0100
  42918. @@ -33,6 +33,13 @@
  42919. #define ATH79_SPI_RRW_DELAY_FACTOR 12000
  42920. #define MHZ (1000 * 1000)
  42921. +#define ATH79_SPI_CS_LINE_MAX 2
  42922. +
  42923. +enum ath79_spi_state {
  42924. + ATH79_SPI_STATE_WAIT_CMD = 0,
  42925. + ATH79_SPI_STATE_WAIT_READ,
  42926. +};
  42927. +
  42928. struct ath79_spi {
  42929. struct spi_bitbang bitbang;
  42930. u32 ioc_base;
  42931. @@ -40,6 +47,11 @@
  42932. void __iomem *base;
  42933. struct clk *clk;
  42934. unsigned rrw_delay;
  42935. +
  42936. + enum ath79_spi_state state;
  42937. + u32 clk_div;
  42938. + unsigned long read_addr;
  42939. + unsigned long ahb_rate;
  42940. };
  42941. static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned reg)
  42942. @@ -67,6 +79,7 @@
  42943. {
  42944. struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  42945. int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active;
  42946. + struct ath79_spi_controller_data *cdata = spi->controller_data;
  42947. if (is_active) {
  42948. /* set initial clock polarity */
  42949. @@ -78,20 +91,24 @@
  42950. ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
  42951. }
  42952. - if (spi->chip_select) {
  42953. - struct ath79_spi_controller_data *cdata = spi->controller_data;
  42954. -
  42955. - /* SPI is normally active-low */
  42956. - gpio_set_value(cdata->gpio, cs_high);
  42957. - } else {
  42958. + switch (cdata->cs_type) {
  42959. + case ATH79_SPI_CS_TYPE_INTERNAL:
  42960. if (cs_high)
  42961. - sp->ioc_base |= AR71XX_SPI_IOC_CS0;
  42962. + sp->ioc_base |= AR71XX_SPI_IOC_CS(cdata->cs_line);
  42963. else
  42964. - sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
  42965. + sp->ioc_base &= ~AR71XX_SPI_IOC_CS(cdata->cs_line);
  42966. ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
  42967. - }
  42968. + break;
  42969. + case ATH79_SPI_CS_TYPE_GPIO:
  42970. + /* SPI is normally active-low */
  42971. + if (gpio_cansleep(cdata->cs_line))
  42972. + gpio_set_value_cansleep(cdata->cs_line, cs_high);
  42973. + else
  42974. + gpio_set_value(cdata->cs_line, cs_high);
  42975. + break;
  42976. + }
  42977. }
  42978. static void ath79_spi_enable(struct ath79_spi *sp)
  42979. @@ -102,9 +119,6 @@
  42980. /* save CTRL register */
  42981. sp->reg_ctrl = ath79_spi_rr(sp, AR71XX_SPI_REG_CTRL);
  42982. sp->ioc_base = ath79_spi_rr(sp, AR71XX_SPI_REG_IOC);
  42983. -
  42984. - /* TODO: setup speed? */
  42985. - ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43);
  42986. }
  42987. static void ath79_spi_disable(struct ath79_spi *sp)
  42988. @@ -118,24 +132,30 @@
  42989. static int ath79_spi_setup_cs(struct spi_device *spi)
  42990. {
  42991. struct ath79_spi_controller_data *cdata;
  42992. + unsigned long flags;
  42993. int status;
  42994. cdata = spi->controller_data;
  42995. - if (spi->chip_select && !cdata)
  42996. + if (!cdata)
  42997. return -EINVAL;
  42998. status = 0;
  42999. - if (spi->chip_select) {
  43000. - unsigned long flags;
  43001. + switch (cdata->cs_type) {
  43002. + case ATH79_SPI_CS_TYPE_INTERNAL:
  43003. + if (cdata->cs_line > ATH79_SPI_CS_LINE_MAX)
  43004. + status = -EINVAL;
  43005. + break;
  43006. + case ATH79_SPI_CS_TYPE_GPIO:
  43007. flags = GPIOF_DIR_OUT;
  43008. if (spi->mode & SPI_CS_HIGH)
  43009. flags |= GPIOF_INIT_LOW;
  43010. else
  43011. flags |= GPIOF_INIT_HIGH;
  43012. - status = gpio_request_one(cdata->gpio, flags,
  43013. + status = gpio_request_one(cdata->cs_line, flags,
  43014. dev_name(&spi->dev));
  43015. + break;
  43016. }
  43017. return status;
  43018. @@ -143,9 +163,19 @@
  43019. static void ath79_spi_cleanup_cs(struct spi_device *spi)
  43020. {
  43021. - if (spi->chip_select) {
  43022. - struct ath79_spi_controller_data *cdata = spi->controller_data;
  43023. - gpio_free(cdata->gpio);
  43024. + struct ath79_spi_controller_data *cdata;
  43025. +
  43026. + cdata = spi->controller_data;
  43027. + if (!cdata)
  43028. + return;
  43029. +
  43030. + switch (cdata->cs_type) {
  43031. + case ATH79_SPI_CS_TYPE_INTERNAL:
  43032. + /* nothing to do */
  43033. + break;
  43034. + case ATH79_SPI_CS_TYPE_GPIO:
  43035. + gpio_free(cdata->cs_line);
  43036. + break;
  43037. }
  43038. }
  43039. @@ -201,6 +231,114 @@
  43040. return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS);
  43041. }
  43042. +static int ath79_spi_do_read_flash_data(struct spi_device *spi,
  43043. + struct spi_transfer *t)
  43044. +{
  43045. + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  43046. +
  43047. + /* disable GPIO mode */
  43048. + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
  43049. +
  43050. + memcpy_fromio(t->rx_buf, sp->base + sp->read_addr, t->len);
  43051. +
  43052. + /* enable GPIO mode */
  43053. + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
  43054. +
  43055. + /* restore IOC register */
  43056. + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
  43057. +
  43058. + return t->len;
  43059. +}
  43060. +
  43061. +static int ath79_spi_do_read_flash_cmd(struct spi_device *spi,
  43062. + struct spi_transfer *t)
  43063. +{
  43064. + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  43065. + int len;
  43066. + const u8 *p;
  43067. +
  43068. + sp->read_addr = 0;
  43069. +
  43070. + len = t->len - 1;
  43071. +
  43072. + if (t->dummy)
  43073. + len -= 1;
  43074. +
  43075. + p = t->tx_buf;
  43076. +
  43077. + while (len--) {
  43078. + p++;
  43079. + sp->read_addr <<= 8;
  43080. + sp->read_addr |= *p;
  43081. + }
  43082. +
  43083. + return t->len;
  43084. +}
  43085. +
  43086. +static bool ath79_spi_is_read_cmd(struct spi_device *spi,
  43087. + struct spi_transfer *t)
  43088. +{
  43089. + return t->type == SPI_TRANSFER_FLASH_READ_CMD;
  43090. +}
  43091. +
  43092. +static bool ath79_spi_is_data_read(struct spi_device *spi,
  43093. + struct spi_transfer *t)
  43094. +{
  43095. + return t->type == SPI_TRANSFER_FLASH_READ_DATA;
  43096. +}
  43097. +
  43098. +static int ath79_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
  43099. +{
  43100. + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  43101. + int ret;
  43102. +
  43103. + switch (sp->state) {
  43104. + case ATH79_SPI_STATE_WAIT_CMD:
  43105. + if (ath79_spi_is_read_cmd(spi, t)) {
  43106. + ret = ath79_spi_do_read_flash_cmd(spi, t);
  43107. + sp->state = ATH79_SPI_STATE_WAIT_READ;
  43108. + } else {
  43109. + ret = spi_bitbang_bufs(spi, t);
  43110. + }
  43111. + break;
  43112. +
  43113. + case ATH79_SPI_STATE_WAIT_READ:
  43114. + if (ath79_spi_is_data_read(spi, t)) {
  43115. + ret = ath79_spi_do_read_flash_data(spi, t);
  43116. + } else {
  43117. + dev_warn(&spi->dev, "flash data read expected\n");
  43118. + ret = -EIO;
  43119. + }
  43120. + sp->state = ATH79_SPI_STATE_WAIT_CMD;
  43121. + break;
  43122. +
  43123. + default:
  43124. + BUG();
  43125. + }
  43126. +
  43127. + return ret;
  43128. +}
  43129. +
  43130. +static int ath79_spi_setup_transfer(struct spi_device *spi,
  43131. + struct spi_transfer *t)
  43132. +{
  43133. + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  43134. + struct ath79_spi_controller_data *cdata;
  43135. + int ret;
  43136. +
  43137. + ret = spi_bitbang_setup_transfer(spi, t);
  43138. + if (ret)
  43139. + return ret;
  43140. +
  43141. + cdata = spi->controller_data;
  43142. + if (cdata->is_flash)
  43143. + sp->bitbang.txrx_bufs = ath79_spi_txrx_bufs;
  43144. + else
  43145. + sp->bitbang.txrx_bufs = spi_bitbang_bufs;
  43146. +
  43147. + return ret;
  43148. +}
  43149. +
  43150. static int ath79_spi_probe(struct platform_device *pdev)
  43151. {
  43152. struct spi_master *master;
  43153. @@ -210,6 +348,10 @@
  43154. unsigned long rate;
  43155. int ret;
  43156. + pdata = pdev->dev.platform_data;
  43157. + if (!pdata)
  43158. + return -EINVAL;
  43159. +
  43160. master = spi_alloc_master(&pdev->dev, sizeof(*sp));
  43161. if (master == NULL) {
  43162. dev_err(&pdev->dev, "failed to allocate spi master\n");
  43163. @@ -219,20 +361,18 @@
  43164. sp = spi_master_get_devdata(master);
  43165. platform_set_drvdata(pdev, sp);
  43166. - pdata = dev_get_platdata(&pdev->dev);
  43167. + sp->state = ATH79_SPI_STATE_WAIT_CMD;
  43168. master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
  43169. master->setup = ath79_spi_setup;
  43170. master->cleanup = ath79_spi_cleanup;
  43171. - if (pdata) {
  43172. - master->bus_num = pdata->bus_num;
  43173. - master->num_chipselect = pdata->num_chipselect;
  43174. - }
  43175. + master->bus_num = pdata->bus_num;
  43176. + master->num_chipselect = pdata->num_chipselect;
  43177. sp->bitbang.master = master;
  43178. sp->bitbang.chipselect = ath79_spi_chipselect;
  43179. sp->bitbang.txrx_word[SPI_MODE_0] = ath79_spi_txrx_mode0;
  43180. - sp->bitbang.setup_transfer = spi_bitbang_setup_transfer;
  43181. + sp->bitbang.setup_transfer = ath79_spi_setup_transfer;
  43182. sp->bitbang.flags = SPI_CS_HIGH;
  43183. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  43184. @@ -257,7 +397,8 @@
  43185. if (ret)
  43186. goto err_put_master;
  43187. - rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
  43188. + sp->ahb_rate = clk_get_rate(sp->clk);
  43189. + rate = DIV_ROUND_UP(sp->ahb_rate, MHZ);
  43190. if (!rate) {
  43191. ret = -EINVAL;
  43192. goto err_clk_disable;
  43193. diff -Nur linux-4.1.13.orig/drivers/spi/spi-bitbang.c linux-4.1.13/drivers/spi/spi-bitbang.c
  43194. --- linux-4.1.13.orig/drivers/spi/spi-bitbang.c 2015-11-09 23:34:10.000000000 +0100
  43195. +++ linux-4.1.13/drivers/spi/spi-bitbang.c 2015-12-04 19:57:03.934107503 +0100
  43196. @@ -230,13 +230,14 @@
  43197. }
  43198. EXPORT_SYMBOL_GPL(spi_bitbang_cleanup);
  43199. -static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
  43200. +int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
  43201. {
  43202. struct spi_bitbang_cs *cs = spi->controller_state;
  43203. unsigned nsecs = cs->nsecs;
  43204. return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t);
  43205. }
  43206. +EXPORT_SYMBOL_GPL(spi_bitbang_bufs);
  43207. /*----------------------------------------------------------------------*/
  43208. diff -Nur linux-4.1.13.orig/drivers/spi/spi-rb4xx.c linux-4.1.13/drivers/spi/spi-rb4xx.c
  43209. --- linux-4.1.13.orig/drivers/spi/spi-rb4xx.c 1970-01-01 01:00:00.000000000 +0100
  43210. +++ linux-4.1.13/drivers/spi/spi-rb4xx.c 2015-09-13 20:04:35.076523692 +0200
  43211. @@ -0,0 +1,507 @@
  43212. +/*
  43213. + * SPI controller driver for the Mikrotik RB4xx boards
  43214. + *
  43215. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  43216. + *
  43217. + * This file was based on the patches for Linux 2.6.27.39 published by
  43218. + * MikroTik for their RouterBoard 4xx series devices.
  43219. + *
  43220. + * This program is free software; you can redistribute it and/or modify
  43221. + * it under the terms of the GNU General Public License version 2 as
  43222. + * published by the Free Software Foundation.
  43223. + *
  43224. + */
  43225. +
  43226. +#include <linux/clk.h>
  43227. +#include <linux/err.h>
  43228. +#include <linux/kernel.h>
  43229. +#include <linux/module.h>
  43230. +#include <linux/init.h>
  43231. +#include <linux/delay.h>
  43232. +#include <linux/spinlock.h>
  43233. +#include <linux/workqueue.h>
  43234. +#include <linux/platform_device.h>
  43235. +#include <linux/spi/spi.h>
  43236. +
  43237. +#include <asm/mach-ath79/ar71xx_regs.h>
  43238. +#include <asm/mach-ath79/ath79.h>
  43239. +
  43240. +#define DRV_NAME "rb4xx-spi"
  43241. +#define DRV_DESC "Mikrotik RB4xx SPI controller driver"
  43242. +#define DRV_VERSION "0.1.0"
  43243. +
  43244. +#define SPI_CTRL_FASTEST 0x40
  43245. +#define SPI_FLASH_HZ 33333334
  43246. +#define SPI_CPLD_HZ 33333334
  43247. +
  43248. +#define CPLD_CMD_READ_FAST 0x0b
  43249. +
  43250. +#undef RB4XX_SPI_DEBUG
  43251. +
  43252. +struct rb4xx_spi {
  43253. + void __iomem *base;
  43254. + struct spi_master *master;
  43255. +
  43256. + unsigned spi_ctrl_flash;
  43257. + unsigned spi_ctrl_fread;
  43258. +
  43259. + struct clk *ahb_clk;
  43260. + unsigned long ahb_freq;
  43261. +
  43262. + spinlock_t lock;
  43263. + struct list_head queue;
  43264. + int busy:1;
  43265. + int cs_wait;
  43266. +};
  43267. +
  43268. +static unsigned spi_clk_low = AR71XX_SPI_IOC_CS1;
  43269. +
  43270. +#ifdef RB4XX_SPI_DEBUG
  43271. +static inline void do_spi_delay(void)
  43272. +{
  43273. + ndelay(20000);
  43274. +}
  43275. +#else
  43276. +static inline void do_spi_delay(void) { }
  43277. +#endif
  43278. +
  43279. +static inline void do_spi_init(struct spi_device *spi)
  43280. +{
  43281. + unsigned cs = AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1;
  43282. +
  43283. + if (!(spi->mode & SPI_CS_HIGH))
  43284. + cs ^= (spi->chip_select == 2) ? AR71XX_SPI_IOC_CS1 :
  43285. + AR71XX_SPI_IOC_CS0;
  43286. +
  43287. + spi_clk_low = cs;
  43288. +}
  43289. +
  43290. +static inline void do_spi_finish(void __iomem *base)
  43291. +{
  43292. + do_spi_delay();
  43293. + __raw_writel(AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1,
  43294. + base + AR71XX_SPI_REG_IOC);
  43295. +}
  43296. +
  43297. +static inline void do_spi_clk(void __iomem *base, int bit)
  43298. +{
  43299. + unsigned bval = spi_clk_low | ((bit & 1) ? AR71XX_SPI_IOC_DO : 0);
  43300. +
  43301. + do_spi_delay();
  43302. + __raw_writel(bval, base + AR71XX_SPI_REG_IOC);
  43303. + do_spi_delay();
  43304. + __raw_writel(bval | AR71XX_SPI_IOC_CLK, base + AR71XX_SPI_REG_IOC);
  43305. +}
  43306. +
  43307. +static void do_spi_byte(void __iomem *base, unsigned char byte)
  43308. +{
  43309. + do_spi_clk(base, byte >> 7);
  43310. + do_spi_clk(base, byte >> 6);
  43311. + do_spi_clk(base, byte >> 5);
  43312. + do_spi_clk(base, byte >> 4);
  43313. + do_spi_clk(base, byte >> 3);
  43314. + do_spi_clk(base, byte >> 2);
  43315. + do_spi_clk(base, byte >> 1);
  43316. + do_spi_clk(base, byte);
  43317. +
  43318. + pr_debug("spi_byte sent 0x%02x got 0x%02x\n",
  43319. + (unsigned)byte,
  43320. + (unsigned char)__raw_readl(base + AR71XX_SPI_REG_RDS));
  43321. +}
  43322. +
  43323. +static inline void do_spi_clk_fast(void __iomem *base, unsigned bit1,
  43324. + unsigned bit2)
  43325. +{
  43326. + unsigned bval = (spi_clk_low |
  43327. + ((bit1 & 1) ? AR71XX_SPI_IOC_DO : 0) |
  43328. + ((bit2 & 1) ? AR71XX_SPI_IOC_CS2 : 0));
  43329. + do_spi_delay();
  43330. + __raw_writel(bval, base + AR71XX_SPI_REG_IOC);
  43331. + do_spi_delay();
  43332. + __raw_writel(bval | AR71XX_SPI_IOC_CLK, base + AR71XX_SPI_REG_IOC);
  43333. +}
  43334. +
  43335. +static void do_spi_byte_fast(void __iomem *base, unsigned char byte)
  43336. +{
  43337. + do_spi_clk_fast(base, byte >> 7, byte >> 6);
  43338. + do_spi_clk_fast(base, byte >> 5, byte >> 4);
  43339. + do_spi_clk_fast(base, byte >> 3, byte >> 2);
  43340. + do_spi_clk_fast(base, byte >> 1, byte >> 0);
  43341. +
  43342. + pr_debug("spi_byte_fast sent 0x%02x got 0x%02x\n",
  43343. + (unsigned)byte,
  43344. + (unsigned char) __raw_readl(base + AR71XX_SPI_REG_RDS));
  43345. +}
  43346. +
  43347. +static int rb4xx_spi_txrx(void __iomem *base, struct spi_transfer *t)
  43348. +{
  43349. + const unsigned char *rxv_ptr = NULL;
  43350. + const unsigned char *tx_ptr = t->tx_buf;
  43351. + unsigned char *rx_ptr = t->rx_buf;
  43352. + unsigned i;
  43353. +
  43354. + pr_debug("spi_txrx len %u tx %u rx %u\n",
  43355. + t->len,
  43356. + (t->tx_buf ? 1 : 0),
  43357. + (t->rx_buf ? 1 : 0));
  43358. +
  43359. + if (t->verify) {
  43360. + rxv_ptr = tx_ptr;
  43361. + tx_ptr = NULL;
  43362. + }
  43363. +
  43364. + for (i = 0; i < t->len; ++i) {
  43365. + unsigned char sdata = tx_ptr ? tx_ptr[i] : 0;
  43366. +
  43367. + if (t->fast_write)
  43368. + do_spi_byte_fast(base, sdata);
  43369. + else
  43370. + do_spi_byte(base, sdata);
  43371. +
  43372. + if (rx_ptr) {
  43373. + rx_ptr[i] = __raw_readl(base + AR71XX_SPI_REG_RDS) & 0xff;
  43374. + } else if (rxv_ptr) {
  43375. + unsigned char c = __raw_readl(base + AR71XX_SPI_REG_RDS);
  43376. + if (rxv_ptr[i] != c)
  43377. + return i;
  43378. + }
  43379. + }
  43380. +
  43381. + return i;
  43382. +}
  43383. +
  43384. +static int rb4xx_spi_read_fast(struct rb4xx_spi *rbspi,
  43385. + struct spi_message *m)
  43386. +{
  43387. + struct spi_transfer *t;
  43388. + const unsigned char *tx_ptr;
  43389. + unsigned addr;
  43390. + void __iomem *base = rbspi->base;
  43391. +
  43392. + /* check for exactly two transfers */
  43393. + if (list_empty(&m->transfers) ||
  43394. + list_is_last(m->transfers.next, &m->transfers) ||
  43395. + !list_is_last(m->transfers.next->next, &m->transfers)) {
  43396. + return -1;
  43397. + }
  43398. +
  43399. + /* first transfer contains command and address */
  43400. + t = list_entry(m->transfers.next,
  43401. + struct spi_transfer, transfer_list);
  43402. +
  43403. + if (t->len != 5 || t->tx_buf == NULL)
  43404. + return -1;
  43405. +
  43406. + tx_ptr = t->tx_buf;
  43407. + if (tx_ptr[0] != CPLD_CMD_READ_FAST)
  43408. + return -1;
  43409. +
  43410. + addr = tx_ptr[1];
  43411. + addr = tx_ptr[2] | (addr << 8);
  43412. + addr = tx_ptr[3] | (addr << 8);
  43413. + addr += (unsigned) base;
  43414. +
  43415. + m->actual_length += t->len;
  43416. +
  43417. + /* second transfer contains data itself */
  43418. + t = list_entry(m->transfers.next->next,
  43419. + struct spi_transfer, transfer_list);
  43420. +
  43421. + if (t->tx_buf && !t->verify)
  43422. + return -1;
  43423. +
  43424. + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
  43425. + __raw_writel(rbspi->spi_ctrl_fread, base + AR71XX_SPI_REG_CTRL);
  43426. + __raw_writel(0, base + AR71XX_SPI_REG_FS);
  43427. +
  43428. + if (t->rx_buf) {
  43429. + memcpy(t->rx_buf, (const void *)addr, t->len);
  43430. + } else if (t->tx_buf) {
  43431. + unsigned char buf[t->len];
  43432. + memcpy(buf, (const void *)addr, t->len);
  43433. + if (memcmp(t->tx_buf, buf, t->len) != 0)
  43434. + m->status = -EMSGSIZE;
  43435. + }
  43436. + m->actual_length += t->len;
  43437. +
  43438. + if (rbspi->spi_ctrl_flash != rbspi->spi_ctrl_fread) {
  43439. + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
  43440. + __raw_writel(rbspi->spi_ctrl_flash, base + AR71XX_SPI_REG_CTRL);
  43441. + __raw_writel(0, base + AR71XX_SPI_REG_FS);
  43442. + }
  43443. +
  43444. + return 0;
  43445. +}
  43446. +
  43447. +static int rb4xx_spi_msg(struct rb4xx_spi *rbspi, struct spi_message *m)
  43448. +{
  43449. + struct spi_transfer *t = NULL;
  43450. + void __iomem *base = rbspi->base;
  43451. +
  43452. + m->status = 0;
  43453. + if (list_empty(&m->transfers))
  43454. + return -1;
  43455. +
  43456. + if (m->fast_read)
  43457. + if (rb4xx_spi_read_fast(rbspi, m) == 0)
  43458. + return -1;
  43459. +
  43460. + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
  43461. + __raw_writel(SPI_CTRL_FASTEST, base + AR71XX_SPI_REG_CTRL);
  43462. + do_spi_init(m->spi);
  43463. +
  43464. + list_for_each_entry(t, &m->transfers, transfer_list) {
  43465. + int len;
  43466. +
  43467. + len = rb4xx_spi_txrx(base, t);
  43468. + if (len != t->len) {
  43469. + m->status = -EMSGSIZE;
  43470. + break;
  43471. + }
  43472. + m->actual_length += len;
  43473. +
  43474. + if (t->cs_change) {
  43475. + if (list_is_last(&t->transfer_list, &m->transfers)) {
  43476. + /* wait for continuation */
  43477. + return m->spi->chip_select;
  43478. + }
  43479. + do_spi_finish(base);
  43480. + ndelay(100);
  43481. + }
  43482. + }
  43483. +
  43484. + do_spi_finish(base);
  43485. + __raw_writel(rbspi->spi_ctrl_flash, base + AR71XX_SPI_REG_CTRL);
  43486. + __raw_writel(0, base + AR71XX_SPI_REG_FS);
  43487. + return -1;
  43488. +}
  43489. +
  43490. +static void rb4xx_spi_process_queue_locked(struct rb4xx_spi *rbspi,
  43491. + unsigned long *flags)
  43492. +{
  43493. + int cs = rbspi->cs_wait;
  43494. +
  43495. + rbspi->busy = 1;
  43496. + while (!list_empty(&rbspi->queue)) {
  43497. + struct spi_message *m;
  43498. +
  43499. + list_for_each_entry(m, &rbspi->queue, queue)
  43500. + if (cs < 0 || cs == m->spi->chip_select)
  43501. + break;
  43502. +
  43503. + if (&m->queue == &rbspi->queue)
  43504. + break;
  43505. +
  43506. + list_del_init(&m->queue);
  43507. + spin_unlock_irqrestore(&rbspi->lock, *flags);
  43508. +
  43509. + cs = rb4xx_spi_msg(rbspi, m);
  43510. + m->complete(m->context);
  43511. +
  43512. + spin_lock_irqsave(&rbspi->lock, *flags);
  43513. + }
  43514. +
  43515. + rbspi->cs_wait = cs;
  43516. + rbspi->busy = 0;
  43517. +
  43518. + if (cs >= 0) {
  43519. + /* TODO: add timer to unlock cs after 1s inactivity */
  43520. + }
  43521. +}
  43522. +
  43523. +static int rb4xx_spi_transfer(struct spi_device *spi,
  43524. + struct spi_message *m)
  43525. +{
  43526. + struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master);
  43527. + unsigned long flags;
  43528. +
  43529. + m->actual_length = 0;
  43530. + m->status = -EINPROGRESS;
  43531. +
  43532. + spin_lock_irqsave(&rbspi->lock, flags);
  43533. + list_add_tail(&m->queue, &rbspi->queue);
  43534. + if (rbspi->busy ||
  43535. + (rbspi->cs_wait >= 0 && rbspi->cs_wait != m->spi->chip_select)) {
  43536. + /* job will be done later */
  43537. + spin_unlock_irqrestore(&rbspi->lock, flags);
  43538. + return 0;
  43539. + }
  43540. +
  43541. + /* process job in current context */
  43542. + rb4xx_spi_process_queue_locked(rbspi, &flags);
  43543. + spin_unlock_irqrestore(&rbspi->lock, flags);
  43544. +
  43545. + return 0;
  43546. +}
  43547. +
  43548. +static int rb4xx_spi_setup(struct spi_device *spi)
  43549. +{
  43550. + struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master);
  43551. + unsigned long flags;
  43552. +
  43553. + if (spi->mode & ~(SPI_CS_HIGH)) {
  43554. + dev_err(&spi->dev, "mode %x not supported\n",
  43555. + (unsigned) spi->mode);
  43556. + return -EINVAL;
  43557. + }
  43558. +
  43559. + if (spi->bits_per_word != 8 && spi->bits_per_word != 0) {
  43560. + dev_err(&spi->dev, "bits_per_word %u not supported\n",
  43561. + (unsigned) spi->bits_per_word);
  43562. + return -EINVAL;
  43563. + }
  43564. +
  43565. + spin_lock_irqsave(&rbspi->lock, flags);
  43566. + if (rbspi->cs_wait == spi->chip_select && !rbspi->busy) {
  43567. + rbspi->cs_wait = -1;
  43568. + rb4xx_spi_process_queue_locked(rbspi, &flags);
  43569. + }
  43570. + spin_unlock_irqrestore(&rbspi->lock, flags);
  43571. +
  43572. + return 0;
  43573. +}
  43574. +
  43575. +static unsigned get_spi_ctrl(struct rb4xx_spi *rbspi, unsigned hz_max,
  43576. + const char *name)
  43577. +{
  43578. + unsigned div;
  43579. +
  43580. + div = (rbspi->ahb_freq - 1) / (2 * hz_max);
  43581. +
  43582. + /*
  43583. + * CPU has a bug at (div == 0) - first bit read is random
  43584. + */
  43585. + if (div == 0)
  43586. + ++div;
  43587. +
  43588. + if (name) {
  43589. + unsigned ahb_khz = (rbspi->ahb_freq + 500) / 1000;
  43590. + unsigned div_real = 2 * (div + 1);
  43591. + pr_debug("rb4xx: %s SPI clock %u kHz (AHB %u kHz / %u)\n",
  43592. + name,
  43593. + ahb_khz / div_real,
  43594. + ahb_khz, div_real);
  43595. + }
  43596. +
  43597. + return SPI_CTRL_FASTEST + div;
  43598. +}
  43599. +
  43600. +static int rb4xx_spi_probe(struct platform_device *pdev)
  43601. +{
  43602. + struct spi_master *master;
  43603. + struct rb4xx_spi *rbspi;
  43604. + struct resource *r;
  43605. + int err = 0;
  43606. +
  43607. + master = spi_alloc_master(&pdev->dev, sizeof(*rbspi));
  43608. + if (master == NULL) {
  43609. + dev_err(&pdev->dev, "no memory for spi_master\n");
  43610. + err = -ENOMEM;
  43611. + goto err_out;
  43612. + }
  43613. +
  43614. + master->bus_num = 0;
  43615. + master->num_chipselect = 3;
  43616. + master->setup = rb4xx_spi_setup;
  43617. + master->transfer = rb4xx_spi_transfer;
  43618. +
  43619. + rbspi = spi_master_get_devdata(master);
  43620. +
  43621. + rbspi->ahb_clk = clk_get(&pdev->dev, "ahb");
  43622. + if (IS_ERR(rbspi->ahb_clk)) {
  43623. + err = PTR_ERR(rbspi->ahb_clk);
  43624. + goto err_put_master;
  43625. + }
  43626. +
  43627. + err = clk_enable(rbspi->ahb_clk);
  43628. + if (err)
  43629. + goto err_clk_put;
  43630. +
  43631. + rbspi->ahb_freq = clk_get_rate(rbspi->ahb_clk);
  43632. + if (!rbspi->ahb_freq) {
  43633. + err = -EINVAL;
  43634. + goto err_clk_disable;
  43635. + }
  43636. +
  43637. + platform_set_drvdata(pdev, rbspi);
  43638. +
  43639. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  43640. + if (r == NULL) {
  43641. + err = -ENOENT;
  43642. + goto err_clk_disable;
  43643. + }
  43644. +
  43645. + rbspi->base = ioremap(r->start, r->end - r->start + 1);
  43646. + if (!rbspi->base) {
  43647. + err = -ENXIO;
  43648. + goto err_clk_disable;
  43649. + }
  43650. +
  43651. + rbspi->master = master;
  43652. + rbspi->spi_ctrl_flash = get_spi_ctrl(rbspi, SPI_FLASH_HZ, "FLASH");
  43653. + rbspi->spi_ctrl_fread = get_spi_ctrl(rbspi, SPI_CPLD_HZ, "CPLD");
  43654. + rbspi->cs_wait = -1;
  43655. +
  43656. + spin_lock_init(&rbspi->lock);
  43657. + INIT_LIST_HEAD(&rbspi->queue);
  43658. +
  43659. + err = spi_register_master(master);
  43660. + if (err) {
  43661. + dev_err(&pdev->dev, "failed to register SPI master\n");
  43662. + goto err_iounmap;
  43663. + }
  43664. +
  43665. + return 0;
  43666. +
  43667. +err_iounmap:
  43668. + iounmap(rbspi->base);
  43669. +err_clk_disable:
  43670. + clk_disable(rbspi->ahb_clk);
  43671. +err_clk_put:
  43672. + clk_put(rbspi->ahb_clk);
  43673. +err_put_master:
  43674. + platform_set_drvdata(pdev, NULL);
  43675. + spi_master_put(master);
  43676. +err_out:
  43677. + return err;
  43678. +}
  43679. +
  43680. +static int rb4xx_spi_remove(struct platform_device *pdev)
  43681. +{
  43682. + struct rb4xx_spi *rbspi = platform_get_drvdata(pdev);
  43683. +
  43684. + iounmap(rbspi->base);
  43685. + clk_disable(rbspi->ahb_clk);
  43686. + clk_put(rbspi->ahb_clk);
  43687. + platform_set_drvdata(pdev, NULL);
  43688. + spi_master_put(rbspi->master);
  43689. +
  43690. + return 0;
  43691. +}
  43692. +
  43693. +static struct platform_driver rb4xx_spi_drv = {
  43694. + .probe = rb4xx_spi_probe,
  43695. + .remove = rb4xx_spi_remove,
  43696. + .driver = {
  43697. + .name = DRV_NAME,
  43698. + .owner = THIS_MODULE,
  43699. + },
  43700. +};
  43701. +
  43702. +static int __init rb4xx_spi_init(void)
  43703. +{
  43704. + return platform_driver_register(&rb4xx_spi_drv);
  43705. +}
  43706. +subsys_initcall(rb4xx_spi_init);
  43707. +
  43708. +static void __exit rb4xx_spi_exit(void)
  43709. +{
  43710. + platform_driver_unregister(&rb4xx_spi_drv);
  43711. +}
  43712. +
  43713. +module_exit(rb4xx_spi_exit);
  43714. +
  43715. +MODULE_DESCRIPTION(DRV_DESC);
  43716. +MODULE_VERSION(DRV_VERSION);
  43717. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  43718. +MODULE_LICENSE("GPL v2");
  43719. diff -Nur linux-4.1.13.orig/drivers/spi/spi-rb4xx-cpld.c linux-4.1.13/drivers/spi/spi-rb4xx-cpld.c
  43720. --- linux-4.1.13.orig/drivers/spi/spi-rb4xx-cpld.c 1970-01-01 01:00:00.000000000 +0100
  43721. +++ linux-4.1.13/drivers/spi/spi-rb4xx-cpld.c 2015-09-13 20:04:35.076523692 +0200
  43722. @@ -0,0 +1,441 @@
  43723. +/*
  43724. + * SPI driver for the CPLD chip on the Mikrotik RB4xx boards
  43725. + *
  43726. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  43727. + *
  43728. + * This file was based on the patches for Linux 2.6.27.39 published by
  43729. + * MikroTik for their RouterBoard 4xx series devices.
  43730. + *
  43731. + * This program is free software; you can redistribute it and/or modify it
  43732. + * under the terms of the GNU General Public License version 2 as published
  43733. + * by the Free Software Foundation.
  43734. + */
  43735. +
  43736. +#include <linux/types.h>
  43737. +#include <linux/kernel.h>
  43738. +#include <linux/module.h>
  43739. +#include <linux/init.h>
  43740. +#include <linux/module.h>
  43741. +#include <linux/device.h>
  43742. +#include <linux/bitops.h>
  43743. +#include <linux/spi/spi.h>
  43744. +#include <linux/gpio.h>
  43745. +#include <linux/slab.h>
  43746. +
  43747. +#include <asm/mach-ath79/rb4xx_cpld.h>
  43748. +
  43749. +#define DRV_NAME "spi-rb4xx-cpld"
  43750. +#define DRV_DESC "RB4xx CPLD driver"
  43751. +#define DRV_VERSION "0.1.0"
  43752. +
  43753. +#define CPLD_CMD_WRITE_NAND 0x08 /* send cmd, n x send data, send indle */
  43754. +#define CPLD_CMD_WRITE_CFG 0x09 /* send cmd, n x send cfg */
  43755. +#define CPLD_CMD_READ_NAND 0x0a /* send cmd, send idle, n x read data */
  43756. +#define CPLD_CMD_READ_FAST 0x0b /* send cmd, 4 x idle, n x read data */
  43757. +#define CPLD_CMD_LED5_ON 0x0c /* send cmd */
  43758. +#define CPLD_CMD_LED5_OFF 0x0d /* send cmd */
  43759. +
  43760. +struct rb4xx_cpld {
  43761. + struct spi_device *spi;
  43762. + struct mutex lock;
  43763. + struct gpio_chip chip;
  43764. + unsigned int config;
  43765. +};
  43766. +
  43767. +static struct rb4xx_cpld *rb4xx_cpld;
  43768. +
  43769. +static inline struct rb4xx_cpld *gpio_to_cpld(struct gpio_chip *chip)
  43770. +{
  43771. + return container_of(chip, struct rb4xx_cpld, chip);
  43772. +}
  43773. +
  43774. +static int rb4xx_cpld_write_cmd(struct rb4xx_cpld *cpld, unsigned char cmd)
  43775. +{
  43776. + struct spi_transfer t[1];
  43777. + struct spi_message m;
  43778. + unsigned char tx_buf[1];
  43779. + int err;
  43780. +
  43781. + spi_message_init(&m);
  43782. + memset(&t, 0, sizeof(t));
  43783. +
  43784. + t[0].tx_buf = tx_buf;
  43785. + t[0].len = sizeof(tx_buf);
  43786. + spi_message_add_tail(&t[0], &m);
  43787. +
  43788. + tx_buf[0] = cmd;
  43789. +
  43790. + err = spi_sync(cpld->spi, &m);
  43791. + return err;
  43792. +}
  43793. +
  43794. +static int rb4xx_cpld_write_cfg(struct rb4xx_cpld *cpld, unsigned char config)
  43795. +{
  43796. + struct spi_transfer t[1];
  43797. + struct spi_message m;
  43798. + unsigned char cmd[2];
  43799. + int err;
  43800. +
  43801. + spi_message_init(&m);
  43802. + memset(&t, 0, sizeof(t));
  43803. +
  43804. + t[0].tx_buf = cmd;
  43805. + t[0].len = sizeof(cmd);
  43806. + spi_message_add_tail(&t[0], &m);
  43807. +
  43808. + cmd[0] = CPLD_CMD_WRITE_CFG;
  43809. + cmd[1] = config;
  43810. +
  43811. + err = spi_sync(cpld->spi, &m);
  43812. + return err;
  43813. +}
  43814. +
  43815. +static int __rb4xx_cpld_change_cfg(struct rb4xx_cpld *cpld, unsigned mask,
  43816. + unsigned value)
  43817. +{
  43818. + unsigned int config;
  43819. + int err;
  43820. +
  43821. + config = cpld->config & ~mask;
  43822. + config |= value;
  43823. +
  43824. + if ((cpld->config ^ config) & 0xff) {
  43825. + err = rb4xx_cpld_write_cfg(cpld, config);
  43826. + if (err)
  43827. + return err;
  43828. + }
  43829. +
  43830. + if ((cpld->config ^ config) & CPLD_CFG_nLED5) {
  43831. + err = rb4xx_cpld_write_cmd(cpld, (value) ? CPLD_CMD_LED5_ON :
  43832. + CPLD_CMD_LED5_OFF);
  43833. + if (err)
  43834. + return err;
  43835. + }
  43836. +
  43837. + cpld->config = config;
  43838. + return 0;
  43839. +}
  43840. +
  43841. +int rb4xx_cpld_change_cfg(unsigned mask, unsigned value)
  43842. +{
  43843. + int ret;
  43844. +
  43845. + if (rb4xx_cpld == NULL)
  43846. + return -ENODEV;
  43847. +
  43848. + mutex_lock(&rb4xx_cpld->lock);
  43849. + ret = __rb4xx_cpld_change_cfg(rb4xx_cpld, mask, value);
  43850. + mutex_unlock(&rb4xx_cpld->lock);
  43851. +
  43852. + return ret;
  43853. +}
  43854. +EXPORT_SYMBOL_GPL(rb4xx_cpld_change_cfg);
  43855. +
  43856. +int rb4xx_cpld_read_from(unsigned addr, unsigned char *rx_buf,
  43857. + const unsigned char *verify_buf, unsigned count)
  43858. +{
  43859. + const unsigned char cmd[5] = {
  43860. + CPLD_CMD_READ_FAST,
  43861. + (addr >> 16) & 0xff,
  43862. + (addr >> 8) & 0xff,
  43863. + addr & 0xff,
  43864. + 0
  43865. + };
  43866. + struct spi_transfer t[2] = {
  43867. + {
  43868. + .tx_buf = &cmd,
  43869. + .len = 5,
  43870. + },
  43871. + {
  43872. + .tx_buf = verify_buf,
  43873. + .rx_buf = rx_buf,
  43874. + .len = count,
  43875. + .verify = (verify_buf != NULL),
  43876. + },
  43877. + };
  43878. + struct spi_message m;
  43879. +
  43880. + if (rb4xx_cpld == NULL)
  43881. + return -ENODEV;
  43882. +
  43883. + spi_message_init(&m);
  43884. + m.fast_read = 1;
  43885. + spi_message_add_tail(&t[0], &m);
  43886. + spi_message_add_tail(&t[1], &m);
  43887. + return spi_sync(rb4xx_cpld->spi, &m);
  43888. +}
  43889. +EXPORT_SYMBOL_GPL(rb4xx_cpld_read_from);
  43890. +
  43891. +#if 0
  43892. +int rb4xx_cpld_read(unsigned char *buf, unsigned char *verify_buf,
  43893. + unsigned count)
  43894. +{
  43895. + struct spi_transfer t[2];
  43896. + struct spi_message m;
  43897. + unsigned char cmd[2];
  43898. +
  43899. + if (rb4xx_cpld == NULL)
  43900. + return -ENODEV;
  43901. +
  43902. + spi_message_init(&m);
  43903. + memset(&t, 0, sizeof(t));
  43904. +
  43905. + /* send command */
  43906. + t[0].tx_buf = cmd;
  43907. + t[0].len = sizeof(cmd);
  43908. + spi_message_add_tail(&t[0], &m);
  43909. +
  43910. + cmd[0] = CPLD_CMD_READ_NAND;
  43911. + cmd[1] = 0;
  43912. +
  43913. + /* read data */
  43914. + t[1].rx_buf = buf;
  43915. + t[1].len = count;
  43916. + spi_message_add_tail(&t[1], &m);
  43917. +
  43918. + return spi_sync(rb4xx_cpld->spi, &m);
  43919. +}
  43920. +#else
  43921. +int rb4xx_cpld_read(unsigned char *rx_buf, const unsigned char *verify_buf,
  43922. + unsigned count)
  43923. +{
  43924. + static const unsigned char cmd[2] = { CPLD_CMD_READ_NAND, 0 };
  43925. + struct spi_transfer t[2] = {
  43926. + {
  43927. + .tx_buf = &cmd,
  43928. + .len = 2,
  43929. + }, {
  43930. + .tx_buf = verify_buf,
  43931. + .rx_buf = rx_buf,
  43932. + .len = count,
  43933. + .verify = (verify_buf != NULL),
  43934. + },
  43935. + };
  43936. + struct spi_message m;
  43937. +
  43938. + if (rb4xx_cpld == NULL)
  43939. + return -ENODEV;
  43940. +
  43941. + spi_message_init(&m);
  43942. + spi_message_add_tail(&t[0], &m);
  43943. + spi_message_add_tail(&t[1], &m);
  43944. + return spi_sync(rb4xx_cpld->spi, &m);
  43945. +}
  43946. +#endif
  43947. +EXPORT_SYMBOL_GPL(rb4xx_cpld_read);
  43948. +
  43949. +int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
  43950. +{
  43951. +#if 0
  43952. + struct spi_transfer t[3];
  43953. + struct spi_message m;
  43954. + unsigned char cmd[1];
  43955. +
  43956. + if (rb4xx_cpld == NULL)
  43957. + return -ENODEV;
  43958. +
  43959. + memset(&t, 0, sizeof(t));
  43960. + spi_message_init(&m);
  43961. +
  43962. + /* send command */
  43963. + t[0].tx_buf = cmd;
  43964. + t[0].len = sizeof(cmd);
  43965. + spi_message_add_tail(&t[0], &m);
  43966. +
  43967. + cmd[0] = CPLD_CMD_WRITE_NAND;
  43968. +
  43969. + /* write data */
  43970. + t[1].tx_buf = buf;
  43971. + t[1].len = count;
  43972. + spi_message_add_tail(&t[1], &m);
  43973. +
  43974. + /* send idle */
  43975. + t[2].len = 1;
  43976. + spi_message_add_tail(&t[2], &m);
  43977. +
  43978. + return spi_sync(rb4xx_cpld->spi, &m);
  43979. +#else
  43980. + static const unsigned char cmd = CPLD_CMD_WRITE_NAND;
  43981. + struct spi_transfer t[3] = {
  43982. + {
  43983. + .tx_buf = &cmd,
  43984. + .len = 1,
  43985. + }, {
  43986. + .tx_buf = buf,
  43987. + .len = count,
  43988. + .fast_write = 1,
  43989. + }, {
  43990. + .len = 1,
  43991. + .fast_write = 1,
  43992. + },
  43993. + };
  43994. + struct spi_message m;
  43995. +
  43996. + if (rb4xx_cpld == NULL)
  43997. + return -ENODEV;
  43998. +
  43999. + spi_message_init(&m);
  44000. + spi_message_add_tail(&t[0], &m);
  44001. + spi_message_add_tail(&t[1], &m);
  44002. + spi_message_add_tail(&t[2], &m);
  44003. + return spi_sync(rb4xx_cpld->spi, &m);
  44004. +#endif
  44005. +}
  44006. +EXPORT_SYMBOL_GPL(rb4xx_cpld_write);
  44007. +
  44008. +static int rb4xx_cpld_gpio_get(struct gpio_chip *chip, unsigned offset)
  44009. +{
  44010. + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
  44011. + int ret;
  44012. +
  44013. + mutex_lock(&cpld->lock);
  44014. + ret = (cpld->config >> offset) & 1;
  44015. + mutex_unlock(&cpld->lock);
  44016. +
  44017. + return ret;
  44018. +}
  44019. +
  44020. +static void rb4xx_cpld_gpio_set(struct gpio_chip *chip, unsigned offset,
  44021. + int value)
  44022. +{
  44023. + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
  44024. +
  44025. + mutex_lock(&cpld->lock);
  44026. + __rb4xx_cpld_change_cfg(cpld, (1 << offset), !!value << offset);
  44027. + mutex_unlock(&cpld->lock);
  44028. +}
  44029. +
  44030. +static int rb4xx_cpld_gpio_direction_input(struct gpio_chip *chip,
  44031. + unsigned offset)
  44032. +{
  44033. + return -EOPNOTSUPP;
  44034. +}
  44035. +
  44036. +static int rb4xx_cpld_gpio_direction_output(struct gpio_chip *chip,
  44037. + unsigned offset,
  44038. + int value)
  44039. +{
  44040. + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
  44041. + int ret;
  44042. +
  44043. + mutex_lock(&cpld->lock);
  44044. + ret = __rb4xx_cpld_change_cfg(cpld, (1 << offset), !!value << offset);
  44045. + mutex_unlock(&cpld->lock);
  44046. +
  44047. + return ret;
  44048. +}
  44049. +
  44050. +static int rb4xx_cpld_gpio_init(struct rb4xx_cpld *cpld, unsigned int base)
  44051. +{
  44052. + int err;
  44053. +
  44054. + /* init config */
  44055. + cpld->config = CPLD_CFG_nLED1 | CPLD_CFG_nLED2 | CPLD_CFG_nLED3 |
  44056. + CPLD_CFG_nLED4 | CPLD_CFG_nCE;
  44057. + rb4xx_cpld_write_cfg(cpld, cpld->config);
  44058. +
  44059. + /* setup GPIO chip */
  44060. + cpld->chip.label = DRV_NAME;
  44061. +
  44062. + cpld->chip.get = rb4xx_cpld_gpio_get;
  44063. + cpld->chip.set = rb4xx_cpld_gpio_set;
  44064. + cpld->chip.direction_input = rb4xx_cpld_gpio_direction_input;
  44065. + cpld->chip.direction_output = rb4xx_cpld_gpio_direction_output;
  44066. +
  44067. + cpld->chip.base = base;
  44068. + cpld->chip.ngpio = CPLD_NUM_GPIOS;
  44069. + cpld->chip.can_sleep = 1;
  44070. + cpld->chip.dev = &cpld->spi->dev;
  44071. + cpld->chip.owner = THIS_MODULE;
  44072. +
  44073. + err = gpiochip_add(&cpld->chip);
  44074. + if (err)
  44075. + dev_err(&cpld->spi->dev, "adding GPIO chip failed, err=%d\n",
  44076. + err);
  44077. +
  44078. + return err;
  44079. +}
  44080. +
  44081. +static int rb4xx_cpld_probe(struct spi_device *spi)
  44082. +{
  44083. + struct rb4xx_cpld *cpld;
  44084. + struct rb4xx_cpld_platform_data *pdata;
  44085. + int err;
  44086. +
  44087. + pdata = spi->dev.platform_data;
  44088. + if (!pdata) {
  44089. + dev_dbg(&spi->dev, "no platform data\n");
  44090. + return -EINVAL;
  44091. + }
  44092. +
  44093. + cpld = kzalloc(sizeof(*cpld), GFP_KERNEL);
  44094. + if (!cpld) {
  44095. + dev_err(&spi->dev, "no memory for private data\n");
  44096. + return -ENOMEM;
  44097. + }
  44098. +
  44099. + mutex_init(&cpld->lock);
  44100. + cpld->spi = spi_dev_get(spi);
  44101. + dev_set_drvdata(&spi->dev, cpld);
  44102. +
  44103. + spi->mode = SPI_MODE_0;
  44104. + spi->bits_per_word = 8;
  44105. + err = spi_setup(spi);
  44106. + if (err) {
  44107. + dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
  44108. + goto err_drvdata;
  44109. + }
  44110. +
  44111. + err = rb4xx_cpld_gpio_init(cpld, pdata->gpio_base);
  44112. + if (err)
  44113. + goto err_drvdata;
  44114. +
  44115. + rb4xx_cpld = cpld;
  44116. +
  44117. + return 0;
  44118. +
  44119. +err_drvdata:
  44120. + dev_set_drvdata(&spi->dev, NULL);
  44121. + kfree(cpld);
  44122. +
  44123. + return err;
  44124. +}
  44125. +
  44126. +static int rb4xx_cpld_remove(struct spi_device *spi)
  44127. +{
  44128. + struct rb4xx_cpld *cpld;
  44129. +
  44130. + rb4xx_cpld = NULL;
  44131. + cpld = dev_get_drvdata(&spi->dev);
  44132. + dev_set_drvdata(&spi->dev, NULL);
  44133. + kfree(cpld);
  44134. +
  44135. + return 0;
  44136. +}
  44137. +
  44138. +static struct spi_driver rb4xx_cpld_driver = {
  44139. + .driver = {
  44140. + .name = DRV_NAME,
  44141. + .bus = &spi_bus_type,
  44142. + .owner = THIS_MODULE,
  44143. + },
  44144. + .probe = rb4xx_cpld_probe,
  44145. + .remove = rb4xx_cpld_remove,
  44146. +};
  44147. +
  44148. +static int __init rb4xx_cpld_init(void)
  44149. +{
  44150. + return spi_register_driver(&rb4xx_cpld_driver);
  44151. +}
  44152. +module_init(rb4xx_cpld_init);
  44153. +
  44154. +static void __exit rb4xx_cpld_exit(void)
  44155. +{
  44156. + spi_unregister_driver(&rb4xx_cpld_driver);
  44157. +}
  44158. +module_exit(rb4xx_cpld_exit);
  44159. +
  44160. +MODULE_DESCRIPTION(DRV_DESC);
  44161. +MODULE_VERSION(DRV_VERSION);
  44162. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  44163. +MODULE_LICENSE("GPL v2");
  44164. diff -Nur linux-4.1.13.orig/drivers/spi/spi-vsc7385.c linux-4.1.13/drivers/spi/spi-vsc7385.c
  44165. --- linux-4.1.13.orig/drivers/spi/spi-vsc7385.c 1970-01-01 01:00:00.000000000 +0100
  44166. +++ linux-4.1.13/drivers/spi/spi-vsc7385.c 2015-09-13 20:04:35.076523692 +0200
  44167. @@ -0,0 +1,621 @@
  44168. +/*
  44169. + * SPI driver for the Vitesse VSC7385 ethernet switch
  44170. + *
  44171. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  44172. + *
  44173. + * Parts of this file are based on Atheros' 2.6.15 BSP
  44174. + *
  44175. + * This program is free software; you can redistribute it and/or modify it
  44176. + * under the terms of the GNU General Public License version 2 as published
  44177. + * by the Free Software Foundation.
  44178. + */
  44179. +
  44180. +#include <linux/types.h>
  44181. +#include <linux/kernel.h>
  44182. +#include <linux/init.h>
  44183. +#include <linux/module.h>
  44184. +#include <linux/delay.h>
  44185. +#include <linux/device.h>
  44186. +#include <linux/bitops.h>
  44187. +#include <linux/firmware.h>
  44188. +#include <linux/spi/spi.h>
  44189. +#include <linux/spi/vsc7385.h>
  44190. +
  44191. +#define DRV_NAME "spi-vsc7385"
  44192. +#define DRV_DESC "Vitesse VSC7385 Gbit ethernet switch driver"
  44193. +#define DRV_VERSION "0.1.0"
  44194. +
  44195. +#define VSC73XX_BLOCK_MAC 0x1
  44196. +#define VSC73XX_BLOCK_2 0x2
  44197. +#define VSC73XX_BLOCK_MII 0x3
  44198. +#define VSC73XX_BLOCK_4 0x4
  44199. +#define VSC73XX_BLOCK_5 0x5
  44200. +#define VSC73XX_BLOCK_SYSTEM 0x7
  44201. +
  44202. +#define VSC73XX_SUBBLOCK_PORT_0 0
  44203. +#define VSC73XX_SUBBLOCK_PORT_1 1
  44204. +#define VSC73XX_SUBBLOCK_PORT_2 2
  44205. +#define VSC73XX_SUBBLOCK_PORT_3 3
  44206. +#define VSC73XX_SUBBLOCK_PORT_4 4
  44207. +#define VSC73XX_SUBBLOCK_PORT_MAC 6
  44208. +
  44209. +/* MAC Block registers */
  44210. +#define VSC73XX_MAC_CFG 0x0
  44211. +#define VSC73XX_ADVPORTM 0x19
  44212. +#define VSC73XX_RXOCT 0x50
  44213. +#define VSC73XX_TXOCT 0x51
  44214. +#define VSC73XX_C_RX0 0x52
  44215. +#define VSC73XX_C_RX1 0x53
  44216. +#define VSC73XX_C_RX2 0x54
  44217. +#define VSC73XX_C_TX0 0x55
  44218. +#define VSC73XX_C_TX1 0x56
  44219. +#define VSC73XX_C_TX2 0x57
  44220. +#define VSC73XX_C_CFG 0x58
  44221. +
  44222. +/* MAC_CFG register bits */
  44223. +#define VSC73XX_MAC_CFG_WEXC_DIS (1 << 31)
  44224. +#define VSC73XX_MAC_CFG_PORT_RST (1 << 29)
  44225. +#define VSC73XX_MAC_CFG_TX_EN (1 << 28)
  44226. +#define VSC73XX_MAC_CFG_SEED_LOAD (1 << 27)
  44227. +#define VSC73XX_MAC_CFG_FDX (1 << 18)
  44228. +#define VSC73XX_MAC_CFG_GIGE (1 << 17)
  44229. +#define VSC73XX_MAC_CFG_RX_EN (1 << 16)
  44230. +#define VSC73XX_MAC_CFG_VLAN_DBLAWR (1 << 15)
  44231. +#define VSC73XX_MAC_CFG_VLAN_AWR (1 << 14)
  44232. +#define VSC73XX_MAC_CFG_100_BASE_T (1 << 13)
  44233. +#define VSC73XX_MAC_CFG_TX_IPG(x) (((x) & 0x1f) << 6)
  44234. +#define VSC73XX_MAC_CFG_MAC_RX_RST (1 << 5)
  44235. +#define VSC73XX_MAC_CFG_MAC_TX_RST (1 << 4)
  44236. +#define VSC73XX_MAC_CFG_BIT2 (1 << 2)
  44237. +#define VSC73XX_MAC_CFG_CLK_SEL(x) ((x) & 0x3)
  44238. +
  44239. +/* ADVPORTM register bits */
  44240. +#define VSC73XX_ADVPORTM_IFG_PPM (1 << 7)
  44241. +#define VSC73XX_ADVPORTM_EXC_COL_CONT (1 << 6)
  44242. +#define VSC73XX_ADVPORTM_EXT_PORT (1 << 5)
  44243. +#define VSC73XX_ADVPORTM_INV_GTX (1 << 4)
  44244. +#define VSC73XX_ADVPORTM_ENA_GTX (1 << 3)
  44245. +#define VSC73XX_ADVPORTM_DDR_MODE (1 << 2)
  44246. +#define VSC73XX_ADVPORTM_IO_LOOPBACK (1 << 1)
  44247. +#define VSC73XX_ADVPORTM_HOST_LOOPBACK (1 << 0)
  44248. +
  44249. +/* MII Block registers */
  44250. +#define VSC73XX_MII_STAT 0x0
  44251. +#define VSC73XX_MII_CMD 0x1
  44252. +#define VSC73XX_MII_DATA 0x2
  44253. +
  44254. +/* System Block registers */
  44255. +#define VSC73XX_ICPU_SIPAD 0x01
  44256. +#define VSC73XX_ICPU_CLOCK_DELAY 0x05
  44257. +#define VSC73XX_ICPU_CTRL 0x10
  44258. +#define VSC73XX_ICPU_ADDR 0x11
  44259. +#define VSC73XX_ICPU_SRAM 0x12
  44260. +#define VSC73XX_ICPU_MBOX_VAL 0x15
  44261. +#define VSC73XX_ICPU_MBOX_SET 0x16
  44262. +#define VSC73XX_ICPU_MBOX_CLR 0x17
  44263. +#define VSC73XX_ICPU_CHIPID 0x18
  44264. +#define VSC73XX_ICPU_GPIO 0x34
  44265. +
  44266. +#define VSC73XX_ICPU_CTRL_CLK_DIV (1 << 8)
  44267. +#define VSC73XX_ICPU_CTRL_SRST_HOLD (1 << 7)
  44268. +#define VSC73XX_ICPU_CTRL_BOOT_EN (1 << 3)
  44269. +#define VSC73XX_ICPU_CTRL_EXT_ACC_EN (1 << 2)
  44270. +#define VSC73XX_ICPU_CTRL_CLK_EN (1 << 1)
  44271. +#define VSC73XX_ICPU_CTRL_SRST (1 << 0)
  44272. +
  44273. +#define VSC73XX_ICPU_CHIPID_ID_SHIFT 12
  44274. +#define VSC73XX_ICPU_CHIPID_ID_MASK 0xffff
  44275. +#define VSC73XX_ICPU_CHIPID_REV_SHIFT 28
  44276. +#define VSC73XX_ICPU_CHIPID_REV_MASK 0xf
  44277. +#define VSC73XX_ICPU_CHIPID_ID_7385 0x7385
  44278. +#define VSC73XX_ICPU_CHIPID_ID_7395 0x7395
  44279. +
  44280. +#define VSC73XX_CMD_MODE_READ 0
  44281. +#define VSC73XX_CMD_MODE_WRITE 1
  44282. +#define VSC73XX_CMD_MODE_SHIFT 4
  44283. +#define VSC73XX_CMD_BLOCK_SHIFT 5
  44284. +#define VSC73XX_CMD_BLOCK_MASK 0x7
  44285. +#define VSC73XX_CMD_SUBBLOCK_MASK 0xf
  44286. +
  44287. +#define VSC7385_CLOCK_DELAY ((3 << 4) | 3)
  44288. +#define VSC7385_CLOCK_DELAY_MASK ((3 << 4) | 3)
  44289. +
  44290. +#define VSC73XX_ICPU_CTRL_STOP (VSC73XX_ICPU_CTRL_SRST_HOLD | \
  44291. + VSC73XX_ICPU_CTRL_BOOT_EN | \
  44292. + VSC73XX_ICPU_CTRL_EXT_ACC_EN)
  44293. +
  44294. +#define VSC73XX_ICPU_CTRL_START (VSC73XX_ICPU_CTRL_CLK_DIV | \
  44295. + VSC73XX_ICPU_CTRL_BOOT_EN | \
  44296. + VSC73XX_ICPU_CTRL_CLK_EN | \
  44297. + VSC73XX_ICPU_CTRL_SRST)
  44298. +
  44299. +#define VSC7385_ADVPORTM_MASK (VSC73XX_ADVPORTM_IFG_PPM | \
  44300. + VSC73XX_ADVPORTM_EXC_COL_CONT | \
  44301. + VSC73XX_ADVPORTM_EXT_PORT | \
  44302. + VSC73XX_ADVPORTM_INV_GTX | \
  44303. + VSC73XX_ADVPORTM_ENA_GTX | \
  44304. + VSC73XX_ADVPORTM_DDR_MODE | \
  44305. + VSC73XX_ADVPORTM_IO_LOOPBACK | \
  44306. + VSC73XX_ADVPORTM_HOST_LOOPBACK)
  44307. +
  44308. +#define VSC7385_ADVPORTM_INIT (VSC73XX_ADVPORTM_EXT_PORT | \
  44309. + VSC73XX_ADVPORTM_ENA_GTX | \
  44310. + VSC73XX_ADVPORTM_DDR_MODE)
  44311. +
  44312. +#define VSC7385_MAC_CFG_RESET (VSC73XX_MAC_CFG_PORT_RST | \
  44313. + VSC73XX_MAC_CFG_MAC_RX_RST | \
  44314. + VSC73XX_MAC_CFG_MAC_TX_RST)
  44315. +
  44316. +#define VSC73XX_MAC_CFG_INIT (VSC73XX_MAC_CFG_TX_EN | \
  44317. + VSC73XX_MAC_CFG_FDX | \
  44318. + VSC73XX_MAC_CFG_GIGE | \
  44319. + VSC73XX_MAC_CFG_RX_EN)
  44320. +
  44321. +#define VSC73XX_RESET_DELAY 100
  44322. +
  44323. +struct vsc7385 {
  44324. + struct spi_device *spi;
  44325. + struct mutex lock;
  44326. + struct vsc7385_platform_data *pdata;
  44327. +};
  44328. +
  44329. +static int vsc7385_is_addr_valid(u8 block, u8 subblock)
  44330. +{
  44331. + switch (block) {
  44332. + case VSC73XX_BLOCK_MAC:
  44333. + switch (subblock) {
  44334. + case 0 ... 4:
  44335. + case 6:
  44336. + return 1;
  44337. + }
  44338. + break;
  44339. +
  44340. + case VSC73XX_BLOCK_2:
  44341. + case VSC73XX_BLOCK_SYSTEM:
  44342. + switch (subblock) {
  44343. + case 0:
  44344. + return 1;
  44345. + }
  44346. + break;
  44347. +
  44348. + case VSC73XX_BLOCK_MII:
  44349. + case VSC73XX_BLOCK_4:
  44350. + case VSC73XX_BLOCK_5:
  44351. + switch (subblock) {
  44352. + case 0 ... 1:
  44353. + return 1;
  44354. + }
  44355. + break;
  44356. + }
  44357. +
  44358. + return 0;
  44359. +}
  44360. +
  44361. +static inline u8 vsc7385_make_addr(u8 mode, u8 block, u8 subblock)
  44362. +{
  44363. + u8 ret;
  44364. +
  44365. + ret = (block & VSC73XX_CMD_BLOCK_MASK) << VSC73XX_CMD_BLOCK_SHIFT;
  44366. + ret |= (mode & 1) << VSC73XX_CMD_MODE_SHIFT;
  44367. + ret |= subblock & VSC73XX_CMD_SUBBLOCK_MASK;
  44368. +
  44369. + return ret;
  44370. +}
  44371. +
  44372. +static int vsc7385_read(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
  44373. + u32 *value)
  44374. +{
  44375. + u8 cmd[4];
  44376. + u8 buf[4];
  44377. + struct spi_transfer t[2];
  44378. + struct spi_message m;
  44379. + int err;
  44380. +
  44381. + if (!vsc7385_is_addr_valid(block, subblock))
  44382. + return -EINVAL;
  44383. +
  44384. + spi_message_init(&m);
  44385. +
  44386. + memset(&t, 0, sizeof(t));
  44387. +
  44388. + t[0].tx_buf = cmd;
  44389. + t[0].len = sizeof(cmd);
  44390. + spi_message_add_tail(&t[0], &m);
  44391. +
  44392. + t[1].rx_buf = buf;
  44393. + t[1].len = sizeof(buf);
  44394. + spi_message_add_tail(&t[1], &m);
  44395. +
  44396. + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_READ, block, subblock);
  44397. + cmd[1] = reg;
  44398. + cmd[2] = 0;
  44399. + cmd[3] = 0;
  44400. +
  44401. + mutex_lock(&vsc->lock);
  44402. + err = spi_sync(vsc->spi, &m);
  44403. + mutex_unlock(&vsc->lock);
  44404. +
  44405. + if (err)
  44406. + return err;
  44407. +
  44408. + *value = (((u32) buf[0]) << 24) | (((u32) buf[1]) << 16) |
  44409. + (((u32) buf[2]) << 8) | ((u32) buf[3]);
  44410. +
  44411. + return 0;
  44412. +}
  44413. +
  44414. +
  44415. +static int vsc7385_write(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
  44416. + u32 value)
  44417. +{
  44418. + u8 cmd[2];
  44419. + u8 buf[4];
  44420. + struct spi_transfer t[2];
  44421. + struct spi_message m;
  44422. + int err;
  44423. +
  44424. + if (!vsc7385_is_addr_valid(block, subblock))
  44425. + return -EINVAL;
  44426. +
  44427. + spi_message_init(&m);
  44428. +
  44429. + memset(&t, 0, sizeof(t));
  44430. +
  44431. + t[0].tx_buf = cmd;
  44432. + t[0].len = sizeof(cmd);
  44433. + spi_message_add_tail(&t[0], &m);
  44434. +
  44435. + t[1].tx_buf = buf;
  44436. + t[1].len = sizeof(buf);
  44437. + spi_message_add_tail(&t[1], &m);
  44438. +
  44439. + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_WRITE, block, subblock);
  44440. + cmd[1] = reg;
  44441. +
  44442. + buf[0] = (value >> 24) & 0xff;
  44443. + buf[1] = (value >> 16) & 0xff;
  44444. + buf[2] = (value >> 8) & 0xff;
  44445. + buf[3] = value & 0xff;
  44446. +
  44447. + mutex_lock(&vsc->lock);
  44448. + err = spi_sync(vsc->spi, &m);
  44449. + mutex_unlock(&vsc->lock);
  44450. +
  44451. + return err;
  44452. +}
  44453. +
  44454. +static inline int vsc7385_write_verify(struct vsc7385 *vsc, u8 block,
  44455. + u8 subblock, u8 reg, u32 value,
  44456. + u32 read_mask, u32 read_val)
  44457. +{
  44458. + struct spi_device *spi = vsc->spi;
  44459. + u32 t;
  44460. + int err;
  44461. +
  44462. + err = vsc7385_write(vsc, block, subblock, reg, value);
  44463. + if (err)
  44464. + return err;
  44465. +
  44466. + err = vsc7385_read(vsc, block, subblock, reg, &t);
  44467. + if (err)
  44468. + return err;
  44469. +
  44470. + if ((t & read_mask) != read_val) {
  44471. + dev_err(&spi->dev, "register write error\n");
  44472. + return -EIO;
  44473. + }
  44474. +
  44475. + return 0;
  44476. +}
  44477. +
  44478. +static inline int vsc7385_set_clock_delay(struct vsc7385 *vsc, u32 val)
  44479. +{
  44480. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44481. + VSC73XX_ICPU_CLOCK_DELAY, val);
  44482. +}
  44483. +
  44484. +static inline int vsc7385_get_clock_delay(struct vsc7385 *vsc, u32 *val)
  44485. +{
  44486. + return vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44487. + VSC73XX_ICPU_CLOCK_DELAY, val);
  44488. +}
  44489. +
  44490. +static inline int vsc7385_icpu_stop(struct vsc7385 *vsc)
  44491. +{
  44492. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
  44493. + VSC73XX_ICPU_CTRL_STOP);
  44494. +}
  44495. +
  44496. +static inline int vsc7385_icpu_start(struct vsc7385 *vsc)
  44497. +{
  44498. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
  44499. + VSC73XX_ICPU_CTRL_START);
  44500. +}
  44501. +
  44502. +static inline int vsc7385_icpu_reset(struct vsc7385 *vsc)
  44503. +{
  44504. + int rc;
  44505. +
  44506. + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_ADDR,
  44507. + 0x0000);
  44508. + if (rc)
  44509. + dev_err(&vsc->spi->dev,
  44510. + "could not reset microcode, err=%d\n", rc);
  44511. +
  44512. + return rc;
  44513. +}
  44514. +
  44515. +static int vsc7385_upload_ucode(struct vsc7385 *vsc)
  44516. +{
  44517. + struct spi_device *spi = vsc->spi;
  44518. + const struct firmware *firmware;
  44519. + char *ucode_name;
  44520. + unsigned char *dp;
  44521. + unsigned int curVal;
  44522. + int i;
  44523. + int diffs;
  44524. + int rc;
  44525. +
  44526. + ucode_name = (vsc->pdata->ucode_name) ? vsc->pdata->ucode_name
  44527. + : "vsc7385_ucode.bin";
  44528. + rc = request_firmware(&firmware, ucode_name, &spi->dev);
  44529. + if (rc) {
  44530. + dev_err(&spi->dev, "request_firmware failed, err=%d\n",
  44531. + rc);
  44532. + return rc;
  44533. + }
  44534. +
  44535. + rc = vsc7385_icpu_stop(vsc);
  44536. + if (rc)
  44537. + goto out;
  44538. +
  44539. + rc = vsc7385_icpu_reset(vsc);
  44540. + if (rc)
  44541. + goto out;
  44542. +
  44543. + dev_info(&spi->dev, "uploading microcode...\n");
  44544. +
  44545. + dp = (unsigned char *) firmware->data;
  44546. + for (i = 0; i < firmware->size; i++) {
  44547. + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44548. + VSC73XX_ICPU_SRAM, *dp++);
  44549. + if (rc) {
  44550. + dev_err(&spi->dev, "could not load microcode, err=%d\n",
  44551. + rc);
  44552. + goto out;
  44553. + }
  44554. + }
  44555. +
  44556. + rc = vsc7385_icpu_reset(vsc);
  44557. + if (rc)
  44558. + goto out;
  44559. +
  44560. + dev_info(&spi->dev, "verifying microcode...\n");
  44561. +
  44562. + dp = (unsigned char *) firmware->data;
  44563. + diffs = 0;
  44564. + for (i = 0; i < firmware->size; i++) {
  44565. + rc = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44566. + VSC73XX_ICPU_SRAM, &curVal);
  44567. + if (rc) {
  44568. + dev_err(&spi->dev, "could not read microcode %d\n",
  44569. + rc);
  44570. + goto out;
  44571. + }
  44572. +
  44573. + if (curVal > 0xff) {
  44574. + dev_err(&spi->dev, "bad val read: %04x : %02x %02x\n",
  44575. + i, *dp, curVal);
  44576. + rc = -EIO;
  44577. + goto out;
  44578. + }
  44579. +
  44580. + if ((curVal & 0xff) != *dp) {
  44581. + diffs++;
  44582. + dev_err(&spi->dev, "verify error: %04x : %02x %02x\n",
  44583. + i, *dp, curVal);
  44584. +
  44585. + if (diffs > 4)
  44586. + break;
  44587. + }
  44588. + dp++;
  44589. + }
  44590. +
  44591. + if (diffs) {
  44592. + dev_err(&spi->dev, "microcode verification failed\n");
  44593. + rc = -EIO;
  44594. + goto out;
  44595. + }
  44596. +
  44597. + dev_info(&spi->dev, "microcode uploaded\n");
  44598. +
  44599. + rc = vsc7385_icpu_start(vsc);
  44600. +
  44601. +out:
  44602. + release_firmware(firmware);
  44603. + return rc;
  44604. +}
  44605. +
  44606. +static int vsc7385_setup(struct vsc7385 *vsc)
  44607. +{
  44608. + struct vsc7385_platform_data *pdata = vsc->pdata;
  44609. + u32 t;
  44610. + int err;
  44611. +
  44612. + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44613. + VSC73XX_ICPU_CLOCK_DELAY,
  44614. + VSC7385_CLOCK_DELAY,
  44615. + VSC7385_CLOCK_DELAY_MASK,
  44616. + VSC7385_CLOCK_DELAY);
  44617. + if (err)
  44618. + goto err;
  44619. +
  44620. + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_MAC,
  44621. + VSC73XX_SUBBLOCK_PORT_MAC, VSC73XX_ADVPORTM,
  44622. + VSC7385_ADVPORTM_INIT,
  44623. + VSC7385_ADVPORTM_MASK,
  44624. + VSC7385_ADVPORTM_INIT);
  44625. + if (err)
  44626. + goto err;
  44627. +
  44628. + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
  44629. + VSC73XX_MAC_CFG, VSC7385_MAC_CFG_RESET);
  44630. + if (err)
  44631. + goto err;
  44632. +
  44633. + t = VSC73XX_MAC_CFG_INIT;
  44634. + t |= VSC73XX_MAC_CFG_TX_IPG(pdata->mac_cfg.tx_ipg);
  44635. + t |= VSC73XX_MAC_CFG_CLK_SEL(pdata->mac_cfg.clk_sel);
  44636. + if (pdata->mac_cfg.bit2)
  44637. + t |= VSC73XX_MAC_CFG_BIT2;
  44638. +
  44639. + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
  44640. + VSC73XX_MAC_CFG, t);
  44641. + if (err)
  44642. + goto err;
  44643. +
  44644. + return 0;
  44645. +
  44646. +err:
  44647. + return err;
  44648. +}
  44649. +
  44650. +static int vsc7385_detect(struct vsc7385 *vsc)
  44651. +{
  44652. + struct spi_device *spi = vsc->spi;
  44653. + u32 t;
  44654. + u32 id;
  44655. + u32 rev;
  44656. + int err;
  44657. +
  44658. + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44659. + VSC73XX_ICPU_MBOX_VAL, &t);
  44660. + if (err) {
  44661. + dev_err(&spi->dev, "unable to read mailbox, err=%d\n", err);
  44662. + return err;
  44663. + }
  44664. +
  44665. + if (t == 0xffffffff) {
  44666. + dev_dbg(&spi->dev, "assert chip reset\n");
  44667. + if (vsc->pdata->reset)
  44668. + vsc->pdata->reset();
  44669. +
  44670. + }
  44671. +
  44672. + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  44673. + VSC73XX_ICPU_CHIPID, &t);
  44674. + if (err) {
  44675. + dev_err(&spi->dev, "unable to read chip id, err=%d\n", err);
  44676. + return err;
  44677. + }
  44678. +
  44679. + id = (t >> VSC73XX_ICPU_CHIPID_ID_SHIFT) & VSC73XX_ICPU_CHIPID_ID_MASK;
  44680. + switch (id) {
  44681. + case VSC73XX_ICPU_CHIPID_ID_7385:
  44682. + case VSC73XX_ICPU_CHIPID_ID_7395:
  44683. + break;
  44684. + default:
  44685. + dev_err(&spi->dev, "unsupported chip, id=%04x\n", id);
  44686. + return -ENODEV;
  44687. + }
  44688. +
  44689. + rev = (t >> VSC73XX_ICPU_CHIPID_REV_SHIFT) &
  44690. + VSC73XX_ICPU_CHIPID_REV_MASK;
  44691. + dev_info(&spi->dev, "VSC%04X (rev. %d) switch found\n", id, rev);
  44692. +
  44693. + return 0;
  44694. +}
  44695. +
  44696. +static int vsc7385_probe(struct spi_device *spi)
  44697. +{
  44698. + struct vsc7385 *vsc;
  44699. + struct vsc7385_platform_data *pdata;
  44700. + int err;
  44701. +
  44702. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
  44703. +
  44704. + pdata = spi->dev.platform_data;
  44705. + if (!pdata) {
  44706. + dev_err(&spi->dev, "no platform data specified\n");
  44707. + return -ENODEV;
  44708. + }
  44709. +
  44710. + vsc = kzalloc(sizeof(*vsc), GFP_KERNEL);
  44711. + if (!vsc) {
  44712. + dev_err(&spi->dev, "no memory for private data\n");
  44713. + return -ENOMEM;
  44714. + }
  44715. +
  44716. + mutex_init(&vsc->lock);
  44717. + vsc->pdata = pdata;
  44718. + vsc->spi = spi_dev_get(spi);
  44719. + dev_set_drvdata(&spi->dev, vsc);
  44720. +
  44721. + spi->mode = SPI_MODE_0;
  44722. + spi->bits_per_word = 8;
  44723. + err = spi_setup(spi);
  44724. + if (err) {
  44725. + dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
  44726. + goto err_drvdata;
  44727. + }
  44728. +
  44729. + err = vsc7385_detect(vsc);
  44730. + if (err) {
  44731. + dev_err(&spi->dev, "no chip found, err=%d\n", err);
  44732. + goto err_drvdata;
  44733. + }
  44734. +
  44735. + err = vsc7385_upload_ucode(vsc);
  44736. + if (err)
  44737. + goto err_drvdata;
  44738. +
  44739. + err = vsc7385_setup(vsc);
  44740. + if (err)
  44741. + goto err_drvdata;
  44742. +
  44743. + return 0;
  44744. +
  44745. +err_drvdata:
  44746. + dev_set_drvdata(&spi->dev, NULL);
  44747. + kfree(vsc);
  44748. + return err;
  44749. +}
  44750. +
  44751. +static int vsc7385_remove(struct spi_device *spi)
  44752. +{
  44753. + struct vsc7385_data *vsc;
  44754. +
  44755. + vsc = dev_get_drvdata(&spi->dev);
  44756. + dev_set_drvdata(&spi->dev, NULL);
  44757. + kfree(vsc);
  44758. +
  44759. + return 0;
  44760. +}
  44761. +
  44762. +static struct spi_driver vsc7385_driver = {
  44763. + .driver = {
  44764. + .name = DRV_NAME,
  44765. + .bus = &spi_bus_type,
  44766. + .owner = THIS_MODULE,
  44767. + },
  44768. + .probe = vsc7385_probe,
  44769. + .remove = vsc7385_remove,
  44770. +};
  44771. +
  44772. +static int __init vsc7385_init(void)
  44773. +{
  44774. + return spi_register_driver(&vsc7385_driver);
  44775. +}
  44776. +module_init(vsc7385_init);
  44777. +
  44778. +static void __exit vsc7385_exit(void)
  44779. +{
  44780. + spi_unregister_driver(&vsc7385_driver);
  44781. +}
  44782. +module_exit(vsc7385_exit);
  44783. +
  44784. +MODULE_DESCRIPTION(DRV_DESC);
  44785. +MODULE_VERSION(DRV_VERSION);
  44786. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  44787. +MODULE_LICENSE("GPL v2");
  44788. +
  44789. diff -Nur linux-4.1.13.orig/drivers/tty/serial/serial_core.c linux-4.1.13/drivers/tty/serial/serial_core.c
  44790. --- linux-4.1.13.orig/drivers/tty/serial/serial_core.c 2015-11-09 23:34:10.000000000 +0100
  44791. +++ linux-4.1.13/drivers/tty/serial/serial_core.c 2015-12-04 19:57:05.897979014 +0100
  44792. @@ -164,6 +164,8 @@
  44793. if (retval == 0) {
  44794. if (uart_console(uport) && uport->cons->cflag) {
  44795. tty->termios.c_cflag = uport->cons->cflag;
  44796. + tty->termios.c_ospeed = uport->cons->baud;
  44797. + tty->termios.c_ispeed = uport->cons->baud;
  44798. uport->cons->cflag = 0;
  44799. }
  44800. /*
  44801. @@ -1901,7 +1903,7 @@
  44802. { 4800, B4800 },
  44803. { 2400, B2400 },
  44804. { 1200, B1200 },
  44805. - { 0, B38400 }
  44806. + { 0, BOTHER }
  44807. };
  44808. /**
  44809. @@ -1940,10 +1942,13 @@
  44810. * Construct a cflag setting.
  44811. */
  44812. for (i = 0; baud_rates[i].rate; i++)
  44813. - if (baud_rates[i].rate <= baud)
  44814. + if (baud_rates[i].rate == baud)
  44815. break;
  44816. termios.c_cflag |= baud_rates[i].cflag;
  44817. + if (!baud_rates[i].rate) {
  44818. + termios.c_ospeed = baud;
  44819. + }
  44820. if (bits == 7)
  44821. termios.c_cflag |= CS7;
  44822. @@ -1973,8 +1978,10 @@
  44823. * Allow the setting of the UART parameters with a NULL console
  44824. * too:
  44825. */
  44826. - if (co)
  44827. + if (co) {
  44828. co->cflag = termios.c_cflag;
  44829. + co->baud = baud;
  44830. + }
  44831. return 0;
  44832. }
  44833. diff -Nur linux-4.1.13.orig/drivers/usb/host/ehci-hcd.c linux-4.1.13/drivers/usb/host/ehci-hcd.c
  44834. --- linux-4.1.13.orig/drivers/usb/host/ehci-hcd.c 2015-11-09 23:34:10.000000000 +0100
  44835. +++ linux-4.1.13/drivers/usb/host/ehci-hcd.c 2015-12-04 19:57:03.974104886 +0100
  44836. @@ -252,6 +252,37 @@
  44837. command |= CMD_RESET;
  44838. dbg_cmd (ehci, "reset", command);
  44839. ehci_writel(ehci, command, &ehci->regs->command);
  44840. +
  44841. + if (ehci->qca_force_host_mode) {
  44842. + u32 usbmode;
  44843. +
  44844. + udelay(1000);
  44845. +
  44846. + usbmode = ehci_readl(ehci, &ehci->regs->usbmode);
  44847. + usbmode |= USBMODE_CM_HC | (1 << 4);
  44848. + ehci_writel(ehci, usbmode, &ehci->regs->usbmode);
  44849. +
  44850. + ehci_dbg(ehci, "forced host mode, usbmode: %08x\n",
  44851. + ehci_readl(ehci, &ehci->regs->usbmode));
  44852. + }
  44853. +
  44854. + if (ehci->qca_force_16bit_ptw) {
  44855. + u32 port_status;
  44856. +
  44857. + udelay(1000);
  44858. +
  44859. + /* enable 16-bit UTMI interface */
  44860. + port_status = ehci_readl(ehci, &ehci->regs->port_status[0]);
  44861. + port_status |= BIT(28);
  44862. + ehci_writel(ehci, port_status, &ehci->regs->port_status[0]);
  44863. +
  44864. + ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n",
  44865. + ehci_readl(ehci, &ehci->regs->port_status[0]));
  44866. + }
  44867. +
  44868. + if (ehci->reset_notifier)
  44869. + ehci->reset_notifier(ehci_to_hcd(ehci));
  44870. +
  44871. ehci->rh_state = EHCI_RH_HALTED;
  44872. ehci->next_statechange = jiffies;
  44873. retval = ehci_handshake(ehci, &ehci->regs->command,
  44874. diff -Nur linux-4.1.13.orig/drivers/usb/host/ehci-platform.c linux-4.1.13/drivers/usb/host/ehci-platform.c
  44875. --- linux-4.1.13.orig/drivers/usb/host/ehci-platform.c 2015-11-09 23:34:10.000000000 +0100
  44876. +++ linux-4.1.13/drivers/usb/host/ehci-platform.c 2015-12-04 19:57:03.978104624 +0100
  44877. @@ -49,6 +49,14 @@
  44878. static const char hcd_name[] = "ehci-platform";
  44879. +static void ehci_platform_reset_notifier(struct usb_hcd *hcd)
  44880. +{
  44881. + struct platform_device *pdev = to_platform_device(hcd->self.controller);
  44882. + struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
  44883. +
  44884. + pdata->reset_notifier(pdev);
  44885. +}
  44886. +
  44887. static int ehci_platform_reset(struct usb_hcd *hcd)
  44888. {
  44889. struct platform_device *pdev = to_platform_device(hcd->self.controller);
  44890. diff -Nur linux-4.1.13.orig/drivers/watchdog/ath79_wdt.c linux-4.1.13/drivers/watchdog/ath79_wdt.c
  44891. --- linux-4.1.13.orig/drivers/watchdog/ath79_wdt.c 2015-11-09 23:34:10.000000000 +0100
  44892. +++ linux-4.1.13/drivers/watchdog/ath79_wdt.c 2015-12-04 19:57:04.398077147 +0100
  44893. @@ -114,10 +114,14 @@
  44894. static int ath79_wdt_set_timeout(int val)
  44895. {
  44896. - if (val < 1 || val > max_timeout)
  44897. + if (val < 1)
  44898. return -EINVAL;
  44899. - timeout = val;
  44900. + if (val > max_timeout)
  44901. + timeout = max_timeout;
  44902. + else
  44903. + timeout = val;
  44904. +
  44905. ath79_wdt_keepalive();
  44906. return 0;
  44907. diff -Nur linux-4.1.13.orig/include/linux/console.h linux-4.1.13/include/linux/console.h
  44908. --- linux-4.1.13.orig/include/linux/console.h 2015-11-09 23:34:10.000000000 +0100
  44909. +++ linux-4.1.13/include/linux/console.h 2015-12-04 19:57:05.901978752 +0100
  44910. @@ -127,6 +127,7 @@
  44911. short flags;
  44912. short index;
  44913. int cflag;
  44914. + int baud;
  44915. void *data;
  44916. struct console *next;
  44917. };
  44918. diff -Nur linux-4.1.13.orig/include/linux/ipv6.h linux-4.1.13/include/linux/ipv6.h
  44919. --- linux-4.1.13.orig/include/linux/ipv6.h 2015-11-09 23:34:10.000000000 +0100
  44920. +++ linux-4.1.13/include/linux/ipv6.h 2015-12-04 19:57:05.917977705 +0100
  44921. @@ -5,6 +5,7 @@
  44922. #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
  44923. #define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
  44924. +
  44925. /*
  44926. * This structure contains configuration options per IPv6 link.
  44927. */
  44928. diff -Nur linux-4.1.13.orig/include/linux/mtd/physmap.h linux-4.1.13/include/linux/mtd/physmap.h
  44929. --- linux-4.1.13.orig/include/linux/mtd/physmap.h 2015-11-09 23:34:10.000000000 +0100
  44930. +++ linux-4.1.13/include/linux/mtd/physmap.h 2015-12-04 19:57:03.830114307 +0100
  44931. @@ -25,6 +25,8 @@
  44932. unsigned int width;
  44933. int (*init)(struct platform_device *);
  44934. void (*exit)(struct platform_device *);
  44935. + void (*lock)(struct platform_device *);
  44936. + void (*unlock)(struct platform_device *);
  44937. void (*set_vpp)(struct platform_device *, int);
  44938. unsigned int nr_parts;
  44939. unsigned int pfow_base;
  44940. diff -Nur linux-4.1.13.orig/include/linux/myloader.h linux-4.1.13/include/linux/myloader.h
  44941. --- linux-4.1.13.orig/include/linux/myloader.h 1970-01-01 01:00:00.000000000 +0100
  44942. +++ linux-4.1.13/include/linux/myloader.h 2015-12-04 20:10:00.684874021 +0100
  44943. @@ -0,0 +1,121 @@
  44944. +/*
  44945. + * Compex's MyLoader specific definitions
  44946. + *
  44947. + * Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
  44948. + *
  44949. + * This program is free software; you can redistribute it and/or modify it
  44950. + * under the terms of the GNU General Public License version 2 as published
  44951. + * by the Free Software Foundation.
  44952. + *
  44953. + */
  44954. +
  44955. +#ifndef _MYLOADER_H_
  44956. +#define _MYLOADER_H_
  44957. +
  44958. +/* Myloader specific magic numbers */
  44959. +#define MYLO_MAGIC_SYS_PARAMS 0x20021107
  44960. +#define MYLO_MAGIC_PARTITIONS 0x20021103
  44961. +#define MYLO_MAGIC_BOARD_PARAMS 0x20021103
  44962. +
  44963. +/* Vendor ID's (seems to be same as the PCI vendor ID's) */
  44964. +#define VENID_COMPEX 0x11F6
  44965. +
  44966. +/* Devices based on the ADM5120 */
  44967. +#define DEVID_COMPEX_NP27G 0x0078
  44968. +#define DEVID_COMPEX_NP28G 0x044C
  44969. +#define DEVID_COMPEX_NP28GHS 0x044E
  44970. +#define DEVID_COMPEX_WP54Gv1C 0x0514
  44971. +#define DEVID_COMPEX_WP54G 0x0515
  44972. +#define DEVID_COMPEX_WP54AG 0x0546
  44973. +#define DEVID_COMPEX_WPP54AG 0x0550
  44974. +#define DEVID_COMPEX_WPP54G 0x0555
  44975. +
  44976. +/* Devices based on the Atheros AR2317 */
  44977. +#define DEVID_COMPEX_NP25G 0x05E6
  44978. +#define DEVID_COMPEX_WPE53G 0x05DC
  44979. +
  44980. +/* Devices based on the Atheros AR71xx */
  44981. +#define DEVID_COMPEX_WP543 0x0640
  44982. +#define DEVID_COMPEX_WPE72 0x0672
  44983. +
  44984. +/* Devices based on the IXP422 */
  44985. +#define DEVID_COMPEX_WP18 0x047E
  44986. +#define DEVID_COMPEX_NP18A 0x0489
  44987. +
  44988. +/* Other devices */
  44989. +#define DEVID_COMPEX_NP26G8M 0x03E8
  44990. +#define DEVID_COMPEX_NP26G16M 0x03E9
  44991. +
  44992. +struct mylo_partition {
  44993. + uint16_t flags; /* partition flags */
  44994. + uint16_t type; /* type of the partition */
  44995. + uint32_t addr; /* relative address of the partition from the
  44996. + flash start */
  44997. + uint32_t size; /* size of the partition in bytes */
  44998. + uint32_t param; /* if this is the active partition, the
  44999. + MyLoader load code to this address */
  45000. +};
  45001. +
  45002. +#define PARTITION_FLAG_ACTIVE 0x8000 /* this is the active partition,
  45003. + * MyLoader loads firmware from here */
  45004. +#define PARTITION_FLAG_ISRAM 0x2000 /* FIXME: this is a RAM partition? */
  45005. +#define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
  45006. +#define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
  45007. + * before decompression */
  45008. +#define PARTITION_FLAG_LZMA 0x0100 /* partition data compressed by LZMA */
  45009. +#define PARTITION_FLAG_HAVEHDR 0x0002 /* the partition data have a header */
  45010. +
  45011. +#define PARTITION_TYPE_FREE 0
  45012. +#define PARTITION_TYPE_USED 1
  45013. +
  45014. +#define MYLO_MAX_PARTITIONS 8 /* maximum number of partitions in the
  45015. + partition table */
  45016. +
  45017. +struct mylo_partition_table {
  45018. + uint32_t magic; /* must be MYLO_MAGIC_PARTITIONS */
  45019. + uint32_t res0; /* unknown/unused */
  45020. + uint32_t res1; /* unknown/unused */
  45021. + uint32_t res2; /* unknown/unused */
  45022. + struct mylo_partition partitions[MYLO_MAX_PARTITIONS];
  45023. +};
  45024. +
  45025. +struct mylo_partition_header {
  45026. + uint32_t len; /* length of the partition data */
  45027. + uint32_t crc; /* CRC value of the partition data */
  45028. +};
  45029. +
  45030. +struct mylo_system_params {
  45031. + uint32_t magic; /* must be MYLO_MAGIC_SYS_PARAMS */
  45032. + uint32_t res0;
  45033. + uint32_t res1;
  45034. + uint32_t mylo_ver;
  45035. + uint16_t vid; /* Vendor ID */
  45036. + uint16_t did; /* Device ID */
  45037. + uint16_t svid; /* Sub Vendor ID */
  45038. + uint16_t sdid; /* Sub Device ID */
  45039. + uint32_t rev; /* device revision */
  45040. + uint32_t fwhi;
  45041. + uint32_t fwlo;
  45042. + uint32_t tftp_addr;
  45043. + uint32_t prog_start;
  45044. + uint32_t flash_size; /* size of boot FLASH in bytes */
  45045. + uint32_t dram_size; /* size of onboard RAM in bytes */
  45046. +};
  45047. +
  45048. +struct mylo_eth_addr {
  45049. + uint8_t mac[6];
  45050. + uint8_t csum[2];
  45051. +};
  45052. +
  45053. +#define MYLO_ETHADDR_COUNT 8 /* maximum number of ethernet address
  45054. + in the board parameters */
  45055. +
  45056. +struct mylo_board_params {
  45057. + uint32_t magic; /* must be MYLO_MAGIC_BOARD_PARAMS */
  45058. + uint32_t res0;
  45059. + uint32_t res1;
  45060. + uint32_t res2;
  45061. + struct mylo_eth_addr addr[MYLO_ETHADDR_COUNT];
  45062. +};
  45063. +
  45064. +#endif /* _MYLOADER_H_*/
  45065. diff -Nur linux-4.1.13.orig/include/linux/nxp_74hc153.h linux-4.1.13/include/linux/nxp_74hc153.h
  45066. --- linux-4.1.13.orig/include/linux/nxp_74hc153.h 1970-01-01 01:00:00.000000000 +0100
  45067. +++ linux-4.1.13/include/linux/nxp_74hc153.h 2015-09-13 20:04:35.076523692 +0200
  45068. @@ -0,0 +1,24 @@
  45069. +/*
  45070. + * NXP 74HC153 - Dual 4-input multiplexer defines
  45071. + *
  45072. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  45073. + *
  45074. + * This program is free software; you can redistribute it and/or modify
  45075. + * it under the terms of the GNU General Public License version 2 as
  45076. + * published by the Free Software Foundation.
  45077. + */
  45078. +
  45079. +#ifndef _NXP_74HC153_H
  45080. +#define _NXP_74HC153_H
  45081. +
  45082. +#define NXP_74HC153_DRIVER_NAME "nxp-74hc153"
  45083. +
  45084. +struct nxp_74hc153_platform_data {
  45085. + unsigned gpio_base;
  45086. + unsigned gpio_pin_s0;
  45087. + unsigned gpio_pin_s1;
  45088. + unsigned gpio_pin_1y;
  45089. + unsigned gpio_pin_2y;
  45090. +};
  45091. +
  45092. +#endif /* _NXP_74HC153_H */
  45093. diff -Nur linux-4.1.13.orig/include/linux/phy.h linux-4.1.13/include/linux/phy.h
  45094. --- linux-4.1.13.orig/include/linux/phy.h 2015-11-09 23:34:10.000000000 +0100
  45095. +++ linux-4.1.13/include/linux/phy.h 2015-12-04 20:31:10.916990579 +0100
  45096. @@ -762,6 +762,7 @@
  45097. void phy_stop_machine(struct phy_device *phydev);
  45098. int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  45099. int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  45100. +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
  45101. int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
  45102. int phy_start_interrupts(struct phy_device *phydev);
  45103. void phy_print_status(struct phy_device *phydev);
  45104. diff -Nur linux-4.1.13.orig/include/linux/platform/ar934x_nfc.h linux-4.1.13/include/linux/platform/ar934x_nfc.h
  45105. --- linux-4.1.13.orig/include/linux/platform/ar934x_nfc.h 1970-01-01 01:00:00.000000000 +0100
  45106. +++ linux-4.1.13/include/linux/platform/ar934x_nfc.h 2015-09-13 20:04:35.076523692 +0200
  45107. @@ -0,0 +1,39 @@
  45108. +/*
  45109. + * Platform data definition for the built-in NAND controller of the
  45110. + * Atheros AR934x SoCs
  45111. + *
  45112. + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  45113. + *
  45114. + * This program is free software; you can redistribute it and/or modify it
  45115. + * under the terms of the GNU General Public License version 2 as published
  45116. + * by the Free Software Foundation.
  45117. + */
  45118. +
  45119. +#ifndef _AR934X_NFC_PLATFORM_H
  45120. +#define _AR934X_NFC_PLATFORM_H
  45121. +
  45122. +#define AR934X_NFC_DRIVER_NAME "ar934x-nfc"
  45123. +
  45124. +struct mtd_info;
  45125. +struct mtd_partition;
  45126. +
  45127. +enum ar934x_nfc_ecc_mode {
  45128. + AR934X_NFC_ECC_SOFT = 0,
  45129. + AR934X_NFC_ECC_HW,
  45130. + AR934X_NFC_ECC_SOFT_BCH,
  45131. +};
  45132. +
  45133. +struct ar934x_nfc_platform_data {
  45134. + const char *name;
  45135. + struct mtd_partition *parts;
  45136. + int nr_parts;
  45137. +
  45138. + bool swap_dma;
  45139. + enum ar934x_nfc_ecc_mode ecc_mode;
  45140. +
  45141. + void (*hw_reset)(bool active);
  45142. + void (*select_chip)(int chip_no);
  45143. + int (*scan_fixup)(struct mtd_info *mtd);
  45144. +};
  45145. +
  45146. +#endif /* _AR934X_NFC_PLATFORM_H */
  45147. diff -Nur linux-4.1.13.orig/include/linux/platform_data/gpio-latch.h linux-4.1.13/include/linux/platform_data/gpio-latch.h
  45148. --- linux-4.1.13.orig/include/linux/platform_data/gpio-latch.h 1970-01-01 01:00:00.000000000 +0100
  45149. +++ linux-4.1.13/include/linux/platform_data/gpio-latch.h 2015-09-13 20:04:35.076523692 +0200
  45150. @@ -0,0 +1,14 @@
  45151. +#ifndef _GPIO_LATCH_H_
  45152. +#define _GPIO_LATCH_H_
  45153. +
  45154. +#define GPIO_LATCH_DRIVER_NAME "gpio-latch"
  45155. +
  45156. +struct gpio_latch_platform_data {
  45157. + int base;
  45158. + int num_gpios;
  45159. + int *gpios;
  45160. + int le_gpio_index;
  45161. + bool le_active_low;
  45162. +};
  45163. +
  45164. +#endif /* _GPIO_LATCH_H_ */
  45165. diff -Nur linux-4.1.13.orig/include/linux/platform_data/phy-at803x.h linux-4.1.13/include/linux/platform_data/phy-at803x.h
  45166. --- linux-4.1.13.orig/include/linux/platform_data/phy-at803x.h 1970-01-01 01:00:00.000000000 +0100
  45167. +++ linux-4.1.13/include/linux/platform_data/phy-at803x.h 2015-12-04 19:57:03.890110382 +0100
  45168. @@ -0,0 +1,11 @@
  45169. +#ifndef _PHY_AT803X_PDATA_H
  45170. +#define _PHY_AT803X_PDATA_H
  45171. +
  45172. +struct at803x_platform_data {
  45173. + int disable_smarteee:1;
  45174. + int enable_rgmii_tx_delay:1;
  45175. + int enable_rgmii_rx_delay:1;
  45176. + int fixup_rgmii_tx_delay:1;
  45177. +};
  45178. +
  45179. +#endif /* _PHY_AT803X_PDATA_H */
  45180. diff -Nur linux-4.1.13.orig/include/linux/platform_data/rb91x_nand.h linux-4.1.13/include/linux/platform_data/rb91x_nand.h
  45181. --- linux-4.1.13.orig/include/linux/platform_data/rb91x_nand.h 1970-01-01 01:00:00.000000000 +0100
  45182. +++ linux-4.1.13/include/linux/platform_data/rb91x_nand.h 2015-09-13 20:04:35.076523692 +0200
  45183. @@ -0,0 +1,16 @@
  45184. +#ifndef _RB91X_NAND_H_
  45185. +#define _RB91X_NAND_H_
  45186. +
  45187. +#define RB91X_NAND_DRIVER_NAME "rb91x-nand"
  45188. +
  45189. +struct rb91x_nand_platform_data {
  45190. + int gpio_nce; /* chip enable, active low */
  45191. + int gpio_ale; /* address latch enable */
  45192. + int gpio_cle; /* command latch enable */
  45193. + int gpio_rdy;
  45194. + int gpio_read;
  45195. + int gpio_nrw; /* read/write enable, active low */
  45196. + int gpio_nle; /* latch enable, active low */
  45197. +};
  45198. +
  45199. +#endif /* _RB91X_NAND_H_ */
  45200. \ No newline at end of file
  45201. diff -Nur linux-4.1.13.orig/include/linux/rle.h linux-4.1.13/include/linux/rle.h
  45202. --- linux-4.1.13.orig/include/linux/rle.h 1970-01-01 01:00:00.000000000 +0100
  45203. +++ linux-4.1.13/include/linux/rle.h 2015-12-04 19:57:03.830114307 +0100
  45204. @@ -0,0 +1,18 @@
  45205. +#ifndef _RLE_H_
  45206. +#define _RLE_H_
  45207. +
  45208. +#ifdef CONFIG_RLE_DECOMPRESS
  45209. +int rle_decode(const unsigned char *src, size_t srclen,
  45210. + unsigned char *dst, size_t dstlen,
  45211. + size_t *src_done, size_t *dst_done);
  45212. +#else
  45213. +static inline int
  45214. +rle_decode(const unsigned char *src, size_t srclen,
  45215. + unsigned char *dst, size_t dstlen,
  45216. + size_t *src_done, size_t *dst_done)
  45217. +{
  45218. + return -ENOTSUPP;
  45219. +}
  45220. +#endif /* CONFIG_RLE_DECOMPRESS */
  45221. +
  45222. +#endif /* _RLE_H_ */
  45223. diff -Nur linux-4.1.13.orig/include/linux/spi/74x164.h linux-4.1.13/include/linux/spi/74x164.h
  45224. --- linux-4.1.13.orig/include/linux/spi/74x164.h 1970-01-01 01:00:00.000000000 +0100
  45225. +++ linux-4.1.13/include/linux/spi/74x164.h 2015-12-04 19:57:03.930107765 +0100
  45226. @@ -0,0 +1,13 @@
  45227. +#ifndef LINUX_SPI_74X164_H
  45228. +#define LINUX_SPI_74X164_H
  45229. +
  45230. +struct gen_74x164_chip_platform_data {
  45231. + /* number assigned to the first GPIO */
  45232. + unsigned base;
  45233. + /* number of chained registers */
  45234. + unsigned num_registers;
  45235. + /* address of a buffer containing initial data */
  45236. + u8 *init_data;
  45237. +};
  45238. +
  45239. +#endif
  45240. diff -Nur linux-4.1.13.orig/include/linux/spi/flash.h linux-4.1.13/include/linux/spi/flash.h
  45241. --- linux-4.1.13.orig/include/linux/spi/flash.h 2015-11-09 23:34:10.000000000 +0100
  45242. +++ linux-4.1.13/include/linux/spi/flash.h 2015-12-04 19:57:03.854112737 +0100
  45243. @@ -24,6 +24,7 @@
  45244. unsigned int nr_parts;
  45245. char *type;
  45246. + const char **part_probes;
  45247. /* we'll likely add more ... use JEDEC IDs, etc */
  45248. };
  45249. diff -Nur linux-4.1.13.orig/include/linux/spi/spi_bitbang.h linux-4.1.13/include/linux/spi/spi_bitbang.h
  45250. --- linux-4.1.13.orig/include/linux/spi/spi_bitbang.h 2015-11-09 23:34:10.000000000 +0100
  45251. +++ linux-4.1.13/include/linux/spi/spi_bitbang.h 2015-12-04 19:57:03.934107503 +0100
  45252. @@ -39,6 +39,7 @@
  45253. extern void spi_bitbang_cleanup(struct spi_device *spi);
  45254. extern int spi_bitbang_setup_transfer(struct spi_device *spi,
  45255. struct spi_transfer *t);
  45256. +extern int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t);
  45257. /* start or stop queue processing */
  45258. extern int spi_bitbang_start(struct spi_bitbang *spi);
  45259. diff -Nur linux-4.1.13.orig/include/linux/spi/spi.h linux-4.1.13/include/linux/spi/spi.h
  45260. --- linux-4.1.13.orig/include/linux/spi/spi.h 2015-11-09 23:34:10.000000000 +0100
  45261. +++ linux-4.1.13/include/linux/spi/spi.h 2015-12-04 19:57:03.966105410 +0100
  45262. @@ -506,6 +506,12 @@
  45263. /*---------------------------------------------------------------------------*/
  45264. +enum spi_transfer_type {
  45265. + SPI_TRANSFER_GENERIC = 0,
  45266. + SPI_TRANSFER_FLASH_READ_CMD,
  45267. + SPI_TRANSFER_FLASH_READ_DATA,
  45268. +};
  45269. +
  45270. /*
  45271. * I/O INTERFACE between SPI controller and protocol drivers
  45272. *
  45273. @@ -618,12 +624,16 @@
  45274. unsigned cs_change:1;
  45275. unsigned tx_nbits:3;
  45276. unsigned rx_nbits:3;
  45277. + unsigned verify:1;
  45278. + unsigned fast_write:1;
  45279. #define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
  45280. #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
  45281. #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
  45282. u8 bits_per_word;
  45283. u16 delay_usecs;
  45284. u32 speed_hz;
  45285. + enum spi_transfer_type type;
  45286. + bool dummy;
  45287. struct list_head transfer_list;
  45288. };
  45289. @@ -663,6 +673,7 @@
  45290. struct spi_device *spi;
  45291. unsigned is_dma_mapped:1;
  45292. + unsigned fast_read:1;
  45293. /* REVISIT: we might want a flag affecting the behavior of the
  45294. * last transfer ... allowing things like "read 16 bit length L"
  45295. diff -Nur linux-4.1.13.orig/include/linux/spi/vsc7385.h linux-4.1.13/include/linux/spi/vsc7385.h
  45296. --- linux-4.1.13.orig/include/linux/spi/vsc7385.h 1970-01-01 01:00:00.000000000 +0100
  45297. +++ linux-4.1.13/include/linux/spi/vsc7385.h 2015-09-13 20:04:35.076523692 +0200
  45298. @@ -0,0 +1,19 @@
  45299. +/*
  45300. + * Platform data definition for the Vitesse VSC7385 ethernet switch driver
  45301. + *
  45302. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  45303. + *
  45304. + * This program is free software; you can redistribute it and/or modify it
  45305. + * under the terms of the GNU General Public License version 2 as published
  45306. + * by the Free Software Foundation.
  45307. + */
  45308. +
  45309. +struct vsc7385_platform_data {
  45310. + void (*reset)(void);
  45311. + char *ucode_name;
  45312. + struct {
  45313. + u32 tx_ipg:5;
  45314. + u32 bit2:1;
  45315. + u32 clk_sel:3;
  45316. + } mac_cfg;
  45317. +};
  45318. diff -Nur linux-4.1.13.orig/include/linux/switch.h linux-4.1.13/include/linux/switch.h
  45319. --- linux-4.1.13.orig/include/linux/switch.h 1970-01-01 01:00:00.000000000 +0100
  45320. +++ linux-4.1.13/include/linux/switch.h 2015-12-04 20:52:15.735681740 +0100
  45321. @@ -0,0 +1,169 @@
  45322. +/*
  45323. + * switch.h: Switch configuration API
  45324. + *
  45325. + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
  45326. + *
  45327. + * This program is free software; you can redistribute it and/or
  45328. + * modify it under the terms of the GNU General Public License
  45329. + * as published by the Free Software Foundation; either version 2
  45330. + * of the License, or (at your option) any later version.
  45331. + *
  45332. + * This program is distributed in the hope that it will be useful,
  45333. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  45334. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  45335. + * GNU General Public License for more details.
  45336. + */
  45337. +#ifndef _LINUX_SWITCH_H
  45338. +#define _LINUX_SWITCH_H
  45339. +
  45340. +#include <net/genetlink.h>
  45341. +#include <uapi/linux/switch.h>
  45342. +
  45343. +struct switch_dev;
  45344. +struct switch_op;
  45345. +struct switch_val;
  45346. +struct switch_attr;
  45347. +struct switch_attrlist;
  45348. +struct switch_led_trigger;
  45349. +
  45350. +int register_switch(struct switch_dev *dev, struct net_device *netdev);
  45351. +void unregister_switch(struct switch_dev *dev);
  45352. +
  45353. +/**
  45354. + * struct switch_attrlist - attribute list
  45355. + *
  45356. + * @n_attr: number of attributes
  45357. + * @attr: pointer to the attributes array
  45358. + */
  45359. +struct switch_attrlist {
  45360. + int n_attr;
  45361. + const struct switch_attr *attr;
  45362. +};
  45363. +
  45364. +enum switch_port_speed {
  45365. + SWITCH_PORT_SPEED_UNKNOWN = 0,
  45366. + SWITCH_PORT_SPEED_10 = 10,
  45367. + SWITCH_PORT_SPEED_100 = 100,
  45368. + SWITCH_PORT_SPEED_1000 = 1000,
  45369. +};
  45370. +
  45371. +struct switch_port_link {
  45372. + bool link;
  45373. + bool duplex;
  45374. + bool aneg;
  45375. + bool tx_flow;
  45376. + bool rx_flow;
  45377. + enum switch_port_speed speed;
  45378. + /* in ethtool adv_t format */
  45379. + u32 eee;
  45380. +};
  45381. +
  45382. +struct switch_port_stats {
  45383. + unsigned long tx_bytes;
  45384. + unsigned long rx_bytes;
  45385. +};
  45386. +
  45387. +/**
  45388. + * struct switch_dev_ops - switch driver operations
  45389. + *
  45390. + * @attr_global: global switch attribute list
  45391. + * @attr_port: port attribute list
  45392. + * @attr_vlan: vlan attribute list
  45393. + *
  45394. + * Callbacks:
  45395. + *
  45396. + * @get_vlan_ports: read the port list of a VLAN
  45397. + * @set_vlan_ports: set the port list of a VLAN
  45398. + *
  45399. + * @get_port_pvid: get the primary VLAN ID of a port
  45400. + * @set_port_pvid: set the primary VLAN ID of a port
  45401. + *
  45402. + * @apply_config: apply all changed settings to the switch
  45403. + * @reset_switch: resetting the switch
  45404. + */
  45405. +struct switch_dev_ops {
  45406. + struct switch_attrlist attr_global, attr_port, attr_vlan;
  45407. +
  45408. + int (*get_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
  45409. + int (*set_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
  45410. +
  45411. + int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
  45412. + int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
  45413. +
  45414. + int (*apply_config)(struct switch_dev *dev);
  45415. + int (*reset_switch)(struct switch_dev *dev);
  45416. +
  45417. + int (*get_port_link)(struct switch_dev *dev, int port,
  45418. + struct switch_port_link *link);
  45419. + int (*get_port_stats)(struct switch_dev *dev, int port,
  45420. + struct switch_port_stats *stats);
  45421. +};
  45422. +
  45423. +struct switch_dev {
  45424. + struct device_node *of_node;
  45425. + const struct switch_dev_ops *ops;
  45426. + /* will be automatically filled */
  45427. + char devname[IFNAMSIZ];
  45428. +
  45429. + const char *name;
  45430. + /* NB: either alias or netdev must be set */
  45431. + const char *alias;
  45432. + struct net_device *netdev;
  45433. +
  45434. + int ports;
  45435. + int vlans;
  45436. + int cpu_port;
  45437. +
  45438. + /* the following fields are internal for swconfig */
  45439. + int id;
  45440. + struct list_head dev_list;
  45441. + unsigned long def_global, def_port, def_vlan;
  45442. +
  45443. + struct mutex sw_mutex;
  45444. + struct switch_port *portbuf;
  45445. + struct switch_portmap *portmap;
  45446. +
  45447. + char buf[128];
  45448. +
  45449. +#ifdef CONFIG_SWCONFIG_LEDS
  45450. + struct switch_led_trigger *led_trigger;
  45451. +#endif
  45452. +};
  45453. +
  45454. +struct switch_port {
  45455. + u32 id;
  45456. + u32 flags;
  45457. +};
  45458. +
  45459. +struct switch_portmap {
  45460. + u32 virt;
  45461. + const char *s;
  45462. +};
  45463. +
  45464. +struct switch_val {
  45465. + const struct switch_attr *attr;
  45466. + int port_vlan;
  45467. + int len;
  45468. + union {
  45469. + const char *s;
  45470. + u32 i;
  45471. + struct switch_port *ports;
  45472. + } value;
  45473. +};
  45474. +
  45475. +struct switch_attr {
  45476. + int disabled;
  45477. + int type;
  45478. + const char *name;
  45479. + const char *description;
  45480. +
  45481. + int (*set)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val);
  45482. + int (*get)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val);
  45483. +
  45484. + /* for driver internal use */
  45485. + int id;
  45486. + int ofs;
  45487. + int max;
  45488. +};
  45489. +
  45490. +#endif /* _LINUX_SWITCH_H */
  45491. diff -Nur linux-4.1.13.orig/include/linux/types.h linux-4.1.13/include/linux/types.h
  45492. --- linux-4.1.13.orig/include/linux/types.h 2015-11-09 23:34:10.000000000 +0100
  45493. +++ linux-4.1.13/include/linux/types.h 2015-12-04 19:57:05.925977182 +0100
  45494. @@ -215,5 +215,11 @@
  45495. /* clocksource cycle base type */
  45496. typedef u64 cycle_t;
  45497. +struct net_hdr_word {
  45498. + u32 words[1];
  45499. +} __attribute__((packed, aligned(2)));
  45500. +
  45501. +#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0])
  45502. +
  45503. #endif /* __ASSEMBLY__ */
  45504. #endif /* _LINUX_TYPES_H */
  45505. diff -Nur linux-4.1.13.orig/include/linux/usb/ehci_pdriver.h linux-4.1.13/include/linux/usb/ehci_pdriver.h
  45506. --- linux-4.1.13.orig/include/linux/usb/ehci_pdriver.h 2015-11-09 23:34:10.000000000 +0100
  45507. +++ linux-4.1.13/include/linux/usb/ehci_pdriver.h 2015-12-04 20:18:56.085517295 +0100
  45508. @@ -49,6 +49,8 @@
  45509. unsigned no_io_watchdog:1;
  45510. unsigned reset_on_resume:1;
  45511. unsigned dma_mask_64:1;
  45512. + unsigned qca_force_host_mode:1;
  45513. + unsigned qca_force_16bit_ptw:1;
  45514. /* Turn on all power and clocks */
  45515. int (*power_on)(struct platform_device *pdev);
  45516. @@ -58,6 +60,7 @@
  45517. * turn off everything else */
  45518. void (*power_suspend)(struct platform_device *pdev);
  45519. int (*pre_setup)(struct usb_hcd *hcd);
  45520. + void (*reset_notifier)(struct platform_device *pdev);
  45521. };
  45522. #endif /* __USB_CORE_EHCI_PDRIVER_H */
  45523. diff -Nur linux-4.1.13.orig/include/net/addrconf.h linux-4.1.13/include/net/addrconf.h
  45524. --- linux-4.1.13.orig/include/net/addrconf.h 2015-11-09 23:34:10.000000000 +0100
  45525. +++ linux-4.1.13/include/net/addrconf.h 2015-12-04 19:57:05.929976920 +0100
  45526. @@ -43,7 +43,7 @@
  45527. __be32 reserved2;
  45528. struct in6_addr prefix;
  45529. -};
  45530. +} __attribute__((packed, aligned(2)));
  45531. #include <linux/netdevice.h>
  45532. diff -Nur linux-4.1.13.orig/include/net/inet_ecn.h linux-4.1.13/include/net/inet_ecn.h
  45533. --- linux-4.1.13.orig/include/net/inet_ecn.h 2015-11-09 23:34:10.000000000 +0100
  45534. +++ linux-4.1.13/include/net/inet_ecn.h 2015-12-04 19:57:05.929976920 +0100
  45535. @@ -115,13 +115,13 @@
  45536. {
  45537. if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph)))
  45538. return 0;
  45539. - *(__be32*)iph |= htonl(INET_ECN_CE << 20);
  45540. + net_hdr_word(iph) |= htonl(INET_ECN_CE << 20);
  45541. return 1;
  45542. }
  45543. static inline void IP6_ECN_clear(struct ipv6hdr *iph)
  45544. {
  45545. - *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
  45546. + net_hdr_word(iph) &= ~htonl(INET_ECN_MASK << 20);
  45547. }
  45548. static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
  45549. diff -Nur linux-4.1.13.orig/include/net/ipv6.h linux-4.1.13/include/net/ipv6.h
  45550. --- linux-4.1.13.orig/include/net/ipv6.h 2015-11-09 23:34:10.000000000 +0100
  45551. +++ linux-4.1.13/include/net/ipv6.h 2015-12-04 19:57:05.929976920 +0100
  45552. @@ -107,7 +107,7 @@
  45553. __u8 reserved;
  45554. __be16 frag_off;
  45555. __be32 identification;
  45556. -};
  45557. +} __attribute__((packed, aligned(2)));
  45558. #define IP6_MF 0x0001
  45559. #define IP6_OFFSET 0xFFF8
  45560. @@ -396,8 +396,8 @@
  45561. }
  45562. #endif
  45563. #endif
  45564. - addr[0] = wh;
  45565. - addr[1] = wl;
  45566. + net_hdr_word(&addr[0]) = wh;
  45567. + net_hdr_word(&addr[1]) = wl;
  45568. }
  45569. static inline void ipv6_addr_set(struct in6_addr *addr,
  45570. @@ -456,6 +456,8 @@
  45571. const __be32 *a1 = addr1->s6_addr32;
  45572. const __be32 *a2 = addr2->s6_addr32;
  45573. unsigned int pdw, pbi;
  45574. + /* Used for last <32-bit fraction of prefix */
  45575. + u32 pbia1, pbia2;
  45576. /* check complete u32 in prefix */
  45577. pdw = prefixlen >> 5;
  45578. @@ -464,7 +466,9 @@
  45579. /* check incomplete u32 in prefix */
  45580. pbi = prefixlen & 0x1f;
  45581. - if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
  45582. + pbia1 = net_hdr_word(&a1[pdw]);
  45583. + pbia2 = net_hdr_word(&a2[pdw]);
  45584. + if (pbi && ((pbia1 ^ pbia2) & htonl((0xffffffff) << (32 - pbi))))
  45585. return false;
  45586. return true;
  45587. @@ -607,13 +611,13 @@
  45588. */
  45589. static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen)
  45590. {
  45591. - const __be32 *a1 = token1, *a2 = token2;
  45592. + const struct in6_addr *a1 = token1, *a2 = token2;
  45593. int i;
  45594. addrlen >>= 2;
  45595. for (i = 0; i < addrlen; i++) {
  45596. - __be32 xb = a1[i] ^ a2[i];
  45597. + __be32 xb = a1->s6_addr32[i] ^ a2->s6_addr32[i];
  45598. if (xb)
  45599. return i * 32 + 31 - __fls(ntohl(xb));
  45600. }
  45601. @@ -739,17 +743,18 @@
  45602. static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
  45603. __be32 flowlabel)
  45604. {
  45605. - *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | flowlabel;
  45606. + net_hdr_word((__be32 *)hdr) =
  45607. + htonl(0x60000000 | (tclass << 20)) | flowlabel;
  45608. }
  45609. static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
  45610. {
  45611. - return *(__be32 *)hdr & IPV6_FLOWINFO_MASK;
  45612. + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWINFO_MASK;
  45613. }
  45614. static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
  45615. {
  45616. - return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK;
  45617. + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWLABEL_MASK;
  45618. }
  45619. static inline u8 ip6_tclass(__be32 flowinfo)
  45620. diff -Nur linux-4.1.13.orig/include/net/ndisc.h linux-4.1.13/include/net/ndisc.h
  45621. --- linux-4.1.13.orig/include/net/ndisc.h 2015-11-09 23:34:10.000000000 +0100
  45622. +++ linux-4.1.13/include/net/ndisc.h 2015-12-04 19:57:05.929976920 +0100
  45623. @@ -76,7 +76,7 @@
  45624. struct icmp6hdr icmph;
  45625. __be32 reachable_time;
  45626. __be32 retrans_timer;
  45627. -};
  45628. +} __attribute__((packed, aligned(2)));
  45629. struct rd_msg {
  45630. struct icmp6hdr icmph;
  45631. @@ -148,10 +148,10 @@
  45632. {
  45633. const u32 *p32 = pkey;
  45634. - return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
  45635. - (p32[1] * hash_rnd[1]) +
  45636. - (p32[2] * hash_rnd[2]) +
  45637. - (p32[3] * hash_rnd[3]));
  45638. + return (((net_hdr_word(&p32[0]) ^ hash32_ptr(dev)) * hash_rnd[0]) +
  45639. + (net_hdr_word(&p32[1]) * hash_rnd[1]) +
  45640. + (net_hdr_word(&p32[2]) * hash_rnd[2]) +
  45641. + (net_hdr_word(&p32[3]) * hash_rnd[3]));
  45642. }
  45643. static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
  45644. diff -Nur linux-4.1.13.orig/include/net/neighbour.h linux-4.1.13/include/net/neighbour.h
  45645. --- linux-4.1.13.orig/include/net/neighbour.h 2015-11-09 23:34:10.000000000 +0100
  45646. +++ linux-4.1.13/include/net/neighbour.h 2015-12-04 19:57:05.933976659 +0100
  45647. @@ -262,8 +262,10 @@
  45648. const u32 *n32 = (const u32 *)n->primary_key;
  45649. const u32 *p32 = pkey;
  45650. - return ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
  45651. - (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0;
  45652. + return ((n32[0] ^ net_hdr_word(&p32[0])) |
  45653. + (n32[1] ^ net_hdr_word(&p32[1])) |
  45654. + (n32[2] ^ net_hdr_word(&p32[2])) |
  45655. + (n32[3] ^ net_hdr_word(&p32[3]))) == 0;
  45656. }
  45657. static inline struct neighbour *___neigh_lookup_noref(
  45658. diff -Nur linux-4.1.13.orig/include/net/secure_seq.h linux-4.1.13/include/net/secure_seq.h
  45659. --- linux-4.1.13.orig/include/net/secure_seq.h 2015-11-09 23:34:10.000000000 +0100
  45660. +++ linux-4.1.13/include/net/secure_seq.h 2015-12-04 19:57:05.929976920 +0100
  45661. @@ -2,6 +2,7 @@
  45662. #define _NET_SECURE_SEQ
  45663. #include <linux/types.h>
  45664. +#include <linux/in6.h>
  45665. u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
  45666. u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
  45667. diff -Nur linux-4.1.13.orig/include/uapi/linux/icmp.h linux-4.1.13/include/uapi/linux/icmp.h
  45668. --- linux-4.1.13.orig/include/uapi/linux/icmp.h 2015-11-09 23:34:10.000000000 +0100
  45669. +++ linux-4.1.13/include/uapi/linux/icmp.h 2015-12-04 19:57:05.917977705 +0100
  45670. @@ -80,7 +80,7 @@
  45671. __be16 mtu;
  45672. } frag;
  45673. } un;
  45674. -};
  45675. +} __attribute__((packed, aligned(2)));
  45676. /*
  45677. diff -Nur linux-4.1.13.orig/include/uapi/linux/icmpv6.h linux-4.1.13/include/uapi/linux/icmpv6.h
  45678. --- linux-4.1.13.orig/include/uapi/linux/icmpv6.h 2015-11-09 23:34:10.000000000 +0100
  45679. +++ linux-4.1.13/include/uapi/linux/icmpv6.h 2015-12-04 19:57:05.929976920 +0100
  45680. @@ -76,7 +76,7 @@
  45681. #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
  45682. #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
  45683. #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
  45684. -};
  45685. +} __attribute__((packed, aligned(2)));
  45686. #define ICMPV6_ROUTER_PREF_LOW 0x3
  45687. diff -Nur linux-4.1.13.orig/include/uapi/linux/if_pppox.h linux-4.1.13/include/uapi/linux/if_pppox.h
  45688. --- linux-4.1.13.orig/include/uapi/linux/if_pppox.h 2015-11-09 23:34:10.000000000 +0100
  45689. +++ linux-4.1.13/include/uapi/linux/if_pppox.h 2015-12-04 19:57:05.933976659 +0100
  45690. @@ -47,6 +47,7 @@
  45691. */
  45692. struct pptp_addr {
  45693. __u16 call_id;
  45694. + __u16 pad;
  45695. struct in_addr sin_addr;
  45696. };
  45697. diff -Nur linux-4.1.13.orig/include/uapi/linux/igmp.h linux-4.1.13/include/uapi/linux/igmp.h
  45698. --- linux-4.1.13.orig/include/uapi/linux/igmp.h 2015-11-09 23:34:10.000000000 +0100
  45699. +++ linux-4.1.13/include/uapi/linux/igmp.h 2015-12-04 19:57:05.929976920 +0100
  45700. @@ -32,7 +32,7 @@
  45701. __u8 code; /* For newer IGMP */
  45702. __sum16 csum;
  45703. __be32 group;
  45704. -};
  45705. +} __attribute__((packed, aligned(2)));
  45706. /* V3 group record types [grec_type] */
  45707. #define IGMPV3_MODE_IS_INCLUDE 1
  45708. @@ -48,7 +48,7 @@
  45709. __be16 grec_nsrcs;
  45710. __be32 grec_mca;
  45711. __be32 grec_src[0];
  45712. -};
  45713. +} __attribute__((packed, aligned(2)));
  45714. struct igmpv3_report {
  45715. __u8 type;
  45716. @@ -57,7 +57,7 @@
  45717. __be16 resv2;
  45718. __be16 ngrec;
  45719. struct igmpv3_grec grec[0];
  45720. -};
  45721. +} __attribute__((packed, aligned(2)));
  45722. struct igmpv3_query {
  45723. __u8 type;
  45724. @@ -78,7 +78,7 @@
  45725. __u8 qqic;
  45726. __be16 nsrcs;
  45727. __be32 srcs[0];
  45728. -};
  45729. +} __attribute__((packed, aligned(2)));
  45730. #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
  45731. #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
  45732. diff -Nur linux-4.1.13.orig/include/uapi/linux/in6.h linux-4.1.13/include/uapi/linux/in6.h
  45733. --- linux-4.1.13.orig/include/uapi/linux/in6.h 2015-11-09 23:34:10.000000000 +0100
  45734. +++ linux-4.1.13/include/uapi/linux/in6.h 2015-12-04 19:57:05.917977705 +0100
  45735. @@ -42,7 +42,7 @@
  45736. #define s6_addr16 in6_u.u6_addr16
  45737. #define s6_addr32 in6_u.u6_addr32
  45738. #endif
  45739. -};
  45740. +} __attribute__((packed, aligned(2)));
  45741. #endif /* __UAPI_DEF_IN6_ADDR */
  45742. #if __UAPI_DEF_SOCKADDR_IN6
  45743. diff -Nur linux-4.1.13.orig/include/uapi/linux/in.h linux-4.1.13/include/uapi/linux/in.h
  45744. --- linux-4.1.13.orig/include/uapi/linux/in.h 2015-11-09 23:34:10.000000000 +0100
  45745. +++ linux-4.1.13/include/uapi/linux/in.h 2015-12-04 19:57:57.978571564 +0100
  45746. @@ -78,7 +78,7 @@
  45747. /* Internet address. */
  45748. struct in_addr {
  45749. __be32 s_addr;
  45750. -};
  45751. +} __attribute__((packed, aligned(2)));
  45752. #define IP_TOS 1
  45753. #define IP_TTL 2
  45754. diff -Nur linux-4.1.13.orig/include/uapi/linux/ip.h linux-4.1.13/include/uapi/linux/ip.h
  45755. --- linux-4.1.13.orig/include/uapi/linux/ip.h 2015-11-09 23:34:10.000000000 +0100
  45756. +++ linux-4.1.13/include/uapi/linux/ip.h 2015-12-04 19:57:05.913977967 +0100
  45757. @@ -102,7 +102,7 @@
  45758. __be32 saddr;
  45759. __be32 daddr;
  45760. /*The options start here. */
  45761. -};
  45762. +} __attribute__((packed, aligned(2)));
  45763. struct ip_auth_hdr {
  45764. diff -Nur linux-4.1.13.orig/include/uapi/linux/ipv6.h linux-4.1.13/include/uapi/linux/ipv6.h
  45765. --- linux-4.1.13.orig/include/uapi/linux/ipv6.h 2015-11-09 23:34:10.000000000 +0100
  45766. +++ linux-4.1.13/include/uapi/linux/ipv6.h 2015-12-04 19:57:05.913977967 +0100
  45767. @@ -129,7 +129,7 @@
  45768. struct in6_addr saddr;
  45769. struct in6_addr daddr;
  45770. -};
  45771. +} __attribute__((packed, aligned(2)));
  45772. /* index values for the variables in ipv6_devconf */
  45773. diff -Nur linux-4.1.13.orig/include/uapi/linux/Kbuild linux-4.1.13/include/uapi/linux/Kbuild
  45774. --- linux-4.1.13.orig/include/uapi/linux/Kbuild 2015-11-09 23:34:10.000000000 +0100
  45775. +++ linux-4.1.13/include/uapi/linux/Kbuild 2015-12-04 21:33:39.775625531 +0100
  45776. @@ -380,6 +380,7 @@
  45777. header-y += string.h
  45778. header-y += suspend_ioctls.h
  45779. header-y += swab.h
  45780. +header-y += switch.h
  45781. header-y += synclink.h
  45782. header-y += sysctl.h
  45783. header-y += sysinfo.h
  45784. diff -Nur linux-4.1.13.orig/include/uapi/linux/netfilter_arp/arp_tables.h linux-4.1.13/include/uapi/linux/netfilter_arp/arp_tables.h
  45785. --- linux-4.1.13.orig/include/uapi/linux/netfilter_arp/arp_tables.h 2015-11-09 23:34:10.000000000 +0100
  45786. +++ linux-4.1.13/include/uapi/linux/netfilter_arp/arp_tables.h 2015-12-04 19:57:05.933976659 +0100
  45787. @@ -68,7 +68,7 @@
  45788. __u8 flags;
  45789. /* Inverse flags */
  45790. __u16 invflags;
  45791. -};
  45792. +} __attribute__((aligned(4)));
  45793. /* Values for "flag" field in struct arpt_ip (general arp structure).
  45794. * No flags defined yet.
  45795. diff -Nur linux-4.1.13.orig/include/uapi/linux/switch.h linux-4.1.13/include/uapi/linux/switch.h
  45796. --- linux-4.1.13.orig/include/uapi/linux/switch.h 1970-01-01 01:00:00.000000000 +0100
  45797. +++ linux-4.1.13/include/uapi/linux/switch.h 2015-12-04 20:52:30.298718052 +0100
  45798. @@ -0,0 +1,103 @@
  45799. +/*
  45800. + * switch.h: Switch configuration API
  45801. + *
  45802. + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
  45803. + *
  45804. + * This program is free software; you can redistribute it and/or
  45805. + * modify it under the terms of the GNU General Public License
  45806. + * as published by the Free Software Foundation; either version 2
  45807. + * of the License, or (at your option) any later version.
  45808. + *
  45809. + * This program is distributed in the hope that it will be useful,
  45810. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  45811. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  45812. + * GNU General Public License for more details.
  45813. + */
  45814. +
  45815. +#ifndef _UAPI_LINUX_SWITCH_H
  45816. +#define _UAPI_LINUX_SWITCH_H
  45817. +
  45818. +#include <linux/types.h>
  45819. +#include <linux/netdevice.h>
  45820. +#include <linux/netlink.h>
  45821. +#include <linux/genetlink.h>
  45822. +#ifndef __KERNEL__
  45823. +#include <netlink/netlink.h>
  45824. +#include <netlink/genl/genl.h>
  45825. +#include <netlink/genl/ctrl.h>
  45826. +#endif
  45827. +
  45828. +/* main attributes */
  45829. +enum {
  45830. + SWITCH_ATTR_UNSPEC,
  45831. + /* global */
  45832. + SWITCH_ATTR_TYPE,
  45833. + /* device */
  45834. + SWITCH_ATTR_ID,
  45835. + SWITCH_ATTR_DEV_NAME,
  45836. + SWITCH_ATTR_ALIAS,
  45837. + SWITCH_ATTR_NAME,
  45838. + SWITCH_ATTR_VLANS,
  45839. + SWITCH_ATTR_PORTS,
  45840. + SWITCH_ATTR_PORTMAP,
  45841. + SWITCH_ATTR_CPU_PORT,
  45842. + /* attributes */
  45843. + SWITCH_ATTR_OP_ID,
  45844. + SWITCH_ATTR_OP_TYPE,
  45845. + SWITCH_ATTR_OP_NAME,
  45846. + SWITCH_ATTR_OP_PORT,
  45847. + SWITCH_ATTR_OP_VLAN,
  45848. + SWITCH_ATTR_OP_VALUE_INT,
  45849. + SWITCH_ATTR_OP_VALUE_STR,
  45850. + SWITCH_ATTR_OP_VALUE_PORTS,
  45851. + SWITCH_ATTR_OP_DESCRIPTION,
  45852. + /* port lists */
  45853. + SWITCH_ATTR_PORT,
  45854. + SWITCH_ATTR_MAX
  45855. +};
  45856. +
  45857. +enum {
  45858. + /* port map */
  45859. + SWITCH_PORTMAP_PORTS,
  45860. + SWITCH_PORTMAP_SEGMENT,
  45861. + SWITCH_PORTMAP_VIRT,
  45862. + SWITCH_PORTMAP_MAX
  45863. +};
  45864. +
  45865. +/* commands */
  45866. +enum {
  45867. + SWITCH_CMD_UNSPEC,
  45868. + SWITCH_CMD_GET_SWITCH,
  45869. + SWITCH_CMD_NEW_ATTR,
  45870. + SWITCH_CMD_LIST_GLOBAL,
  45871. + SWITCH_CMD_GET_GLOBAL,
  45872. + SWITCH_CMD_SET_GLOBAL,
  45873. + SWITCH_CMD_LIST_PORT,
  45874. + SWITCH_CMD_GET_PORT,
  45875. + SWITCH_CMD_SET_PORT,
  45876. + SWITCH_CMD_LIST_VLAN,
  45877. + SWITCH_CMD_GET_VLAN,
  45878. + SWITCH_CMD_SET_VLAN
  45879. +};
  45880. +
  45881. +/* data types */
  45882. +enum switch_val_type {
  45883. + SWITCH_TYPE_UNSPEC,
  45884. + SWITCH_TYPE_INT,
  45885. + SWITCH_TYPE_STRING,
  45886. + SWITCH_TYPE_PORTS,
  45887. + SWITCH_TYPE_NOVAL,
  45888. +};
  45889. +
  45890. +/* port nested attributes */
  45891. +enum {
  45892. + SWITCH_PORT_UNSPEC,
  45893. + SWITCH_PORT_ID,
  45894. + SWITCH_PORT_FLAG_TAGGED,
  45895. + SWITCH_PORT_ATTR_MAX
  45896. +};
  45897. +
  45898. +#define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000
  45899. +
  45900. +
  45901. +#endif /* _UAPI_LINUX_SWITCH_H */
  45902. diff -Nur linux-4.1.13.orig/include/uapi/linux/tcp.h linux-4.1.13/include/uapi/linux/tcp.h
  45903. --- linux-4.1.13.orig/include/uapi/linux/tcp.h 2015-11-09 23:34:10.000000000 +0100
  45904. +++ linux-4.1.13/include/uapi/linux/tcp.h 2015-12-04 19:57:05.913977967 +0100
  45905. @@ -54,7 +54,7 @@
  45906. __be16 window;
  45907. __sum16 check;
  45908. __be16 urg_ptr;
  45909. -};
  45910. +} __attribute__((packed, aligned(2)));
  45911. /*
  45912. * The union cast uses a gcc extension to avoid aliasing problems
  45913. @@ -64,7 +64,7 @@
  45914. union tcp_word_hdr {
  45915. struct tcphdr hdr;
  45916. __be32 words[5];
  45917. -};
  45918. +} __attribute__((packed, aligned(2)));
  45919. #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
  45920. diff -Nur linux-4.1.13.orig/include/uapi/linux/udp.h linux-4.1.13/include/uapi/linux/udp.h
  45921. --- linux-4.1.13.orig/include/uapi/linux/udp.h 2015-11-09 23:34:10.000000000 +0100
  45922. +++ linux-4.1.13/include/uapi/linux/udp.h 2015-12-04 19:57:05.917977705 +0100
  45923. @@ -24,7 +24,7 @@
  45924. __be16 dest;
  45925. __be16 len;
  45926. __sum16 check;
  45927. -};
  45928. +} __attribute__((packed, aligned(2)));
  45929. /* UDP socket options */
  45930. #define UDP_CORK 1 /* Never send partially complete segments */
  45931. diff -Nur linux-4.1.13.orig/lib/Kconfig linux-4.1.13/lib/Kconfig
  45932. --- linux-4.1.13.orig/lib/Kconfig 2015-11-09 23:34:10.000000000 +0100
  45933. +++ linux-4.1.13/lib/Kconfig 2015-12-04 19:57:03.826114569 +0100
  45934. @@ -235,6 +235,9 @@
  45935. source "lib/xz/Kconfig"
  45936. +config RLE_DECOMPRESS
  45937. + tristate
  45938. +
  45939. #
  45940. # These all provide a common interface (hence the apparent duplication with
  45941. # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
  45942. diff -Nur linux-4.1.13.orig/lib/rle.c linux-4.1.13/lib/rle.c
  45943. --- linux-4.1.13.orig/lib/rle.c 1970-01-01 01:00:00.000000000 +0100
  45944. +++ linux-4.1.13/lib/rle.c 2015-12-04 19:57:03.830114307 +0100
  45945. @@ -0,0 +1,78 @@
  45946. +/*
  45947. + * RLE decoding routine
  45948. + *
  45949. + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  45950. + *
  45951. + * This program is free software; you can redistribute it and/or modify it
  45952. + * under the terms of the GNU General Public License version 2 as published
  45953. + * by the Free Software Foundation.
  45954. + */
  45955. +
  45956. +#include <linux/kernel.h>
  45957. +#include <linux/module.h>
  45958. +#include <linux/rle.h>
  45959. +
  45960. +int rle_decode(const unsigned char *src, size_t srclen,
  45961. + unsigned char *dst, size_t dstlen,
  45962. + size_t *src_done, size_t *dst_done)
  45963. +{
  45964. + size_t srcpos, dstpos;
  45965. + int ret;
  45966. +
  45967. + srcpos = 0;
  45968. + dstpos = 0;
  45969. + ret = -EINVAL;
  45970. +
  45971. + /* sanity checks */
  45972. + if (!src || !srclen || !dst || !dstlen)
  45973. + goto out;
  45974. +
  45975. + while (1) {
  45976. + char count;
  45977. +
  45978. + if (srcpos >= srclen)
  45979. + break;
  45980. +
  45981. + count = (char) src[srcpos++];
  45982. + if (count == 0) {
  45983. + ret = 0;
  45984. + break;
  45985. + }
  45986. +
  45987. + if (count > 0) {
  45988. + unsigned char c;
  45989. +
  45990. + if (srcpos >= srclen)
  45991. + break;
  45992. +
  45993. + c = src[srcpos++];
  45994. +
  45995. + while (count--) {
  45996. + if (dstpos >= dstlen)
  45997. + break;
  45998. +
  45999. + dst[dstpos++] = c;
  46000. + }
  46001. + } else {
  46002. + count *= -1;
  46003. +
  46004. + while (count--) {
  46005. + if (srcpos >= srclen)
  46006. + break;
  46007. + if (dstpos >= dstlen)
  46008. + break;
  46009. + dst[dstpos++] = src[srcpos++];
  46010. + }
  46011. + }
  46012. + }
  46013. +
  46014. +out:
  46015. + if (src_done)
  46016. + *src_done = srcpos;
  46017. + if (dst_done)
  46018. + *dst_done = dstpos;
  46019. +
  46020. + return ret;
  46021. +}
  46022. +
  46023. +EXPORT_SYMBOL_GPL(rle_decode);
  46024. diff -Nur linux-4.1.13.orig/net/core/flow_dissector.c linux-4.1.13/net/core/flow_dissector.c
  46025. --- linux-4.1.13.orig/net/core/flow_dissector.c 2015-11-09 23:34:10.000000000 +0100
  46026. +++ linux-4.1.13/net/core/flow_dissector.c 2015-12-04 19:57:05.929976920 +0100
  46027. @@ -53,7 +53,7 @@
  46028. ports = __skb_header_pointer(skb, thoff + poff,
  46029. sizeof(_ports), data, hlen, &_ports);
  46030. if (ports)
  46031. - return *ports;
  46032. + return (__be32)net_hdr_word(ports);
  46033. }
  46034. return 0;
  46035. diff -Nur linux-4.1.13.orig/net/core/secure_seq.c linux-4.1.13/net/core/secure_seq.c
  46036. --- linux-4.1.13.orig/net/core/secure_seq.c 2015-11-09 23:34:10.000000000 +0100
  46037. +++ linux-4.1.13/net/core/secure_seq.c 2015-12-04 19:57:05.929976920 +0100
  46038. @@ -46,11 +46,12 @@
  46039. u32 secret[MD5_MESSAGE_BYTES / 4];
  46040. u32 hash[MD5_DIGEST_WORDS];
  46041. u32 i;
  46042. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  46043. net_secret_init();
  46044. memcpy(hash, saddr, 16);
  46045. for (i = 0; i < 4; i++)
  46046. - secret[i] = net_secret[i] + (__force u32)daddr[i];
  46047. + secret[i] = net_secret[i] + (__force u32)daddr6->s6_addr32[i];
  46048. secret[4] = net_secret[4] +
  46049. (((__force u16)sport << 16) + (__force u16)dport);
  46050. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  46051. @@ -68,11 +69,12 @@
  46052. u32 secret[MD5_MESSAGE_BYTES / 4];
  46053. u32 hash[MD5_DIGEST_WORDS];
  46054. u32 i;
  46055. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  46056. net_secret_init();
  46057. memcpy(hash, saddr, 16);
  46058. for (i = 0; i < 4; i++)
  46059. - secret[i] = net_secret[i] + (__force u32) daddr[i];
  46060. + secret[i] = net_secret[i] + (__force u32) daddr6->s6_addr32[i];
  46061. secret[4] = net_secret[4] + (__force u32)dport;
  46062. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  46063. secret[i] = net_secret[i];
  46064. @@ -150,11 +152,12 @@
  46065. u32 hash[MD5_DIGEST_WORDS];
  46066. u64 seq;
  46067. u32 i;
  46068. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  46069. net_secret_init();
  46070. memcpy(hash, saddr, 16);
  46071. for (i = 0; i < 4; i++)
  46072. - secret[i] = net_secret[i] + daddr[i];
  46073. + secret[i] = net_secret[i] + daddr6->s6_addr32[i];
  46074. secret[4] = net_secret[4] +
  46075. (((__force u16)sport << 16) + (__force u16)dport);
  46076. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  46077. diff -Nur linux-4.1.13.orig/net/dsa/mv88e6063.c linux-4.1.13/net/dsa/mv88e6063.c
  46078. --- linux-4.1.13.orig/net/dsa/mv88e6063.c 1970-01-01 01:00:00.000000000 +0100
  46079. +++ linux-4.1.13/net/dsa/mv88e6063.c 2015-09-13 20:04:35.076523692 +0200
  46080. @@ -0,0 +1,294 @@
  46081. +/*
  46082. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6063 switch chips
  46083. + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
  46084. + *
  46085. + * This driver was base on: net/dsa/mv88e6060.c
  46086. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6060 switch chips
  46087. + * Copyright (c) 2008-2009 Marvell Semiconductor
  46088. + *
  46089. + * This program is free software; you can redistribute it and/or modify
  46090. + * it under the terms of the GNU General Public License as published by
  46091. + * the Free Software Foundation; either version 2 of the License, or
  46092. + * (at your option) any later version.
  46093. + */
  46094. +
  46095. +#include <linux/list.h>
  46096. +#include <linux/netdevice.h>
  46097. +#include <linux/phy.h>
  46098. +#include "dsa_priv.h"
  46099. +
  46100. +#define REG_BASE 0x10
  46101. +#define REG_PHY(p) (REG_BASE + (p))
  46102. +#define REG_PORT(p) (REG_BASE + 8 + (p))
  46103. +#define REG_GLOBAL (REG_BASE + 0x0f)
  46104. +#define NUM_PORTS 7
  46105. +
  46106. +static int reg_read(struct dsa_switch *ds, int addr, int reg)
  46107. +{
  46108. + return mdiobus_read(ds->master_mii_bus, addr, reg);
  46109. +}
  46110. +
  46111. +#define REG_READ(addr, reg) \
  46112. + ({ \
  46113. + int __ret; \
  46114. + \
  46115. + __ret = reg_read(ds, addr, reg); \
  46116. + if (__ret < 0) \
  46117. + return __ret; \
  46118. + __ret; \
  46119. + })
  46120. +
  46121. +
  46122. +static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
  46123. +{
  46124. + return mdiobus_write(ds->master_mii_bus, addr, reg, val);
  46125. +}
  46126. +
  46127. +#define REG_WRITE(addr, reg, val) \
  46128. + ({ \
  46129. + int __ret; \
  46130. + \
  46131. + __ret = reg_write(ds, addr, reg, val); \
  46132. + if (__ret < 0) \
  46133. + return __ret; \
  46134. + })
  46135. +
  46136. +static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
  46137. +{
  46138. + int ret;
  46139. +
  46140. + ret = mdiobus_read(bus, REG_PORT(0), 0x03);
  46141. + if (ret >= 0) {
  46142. + ret &= 0xfff0;
  46143. + if (ret == 0x1530)
  46144. + return "Marvell 88E6063";
  46145. + }
  46146. +
  46147. + return NULL;
  46148. +}
  46149. +
  46150. +static int mv88e6063_switch_reset(struct dsa_switch *ds)
  46151. +{
  46152. + int i;
  46153. + int ret;
  46154. +
  46155. + /*
  46156. + * Set all ports to the disabled state.
  46157. + */
  46158. + for (i = 0; i < NUM_PORTS; i++) {
  46159. + ret = REG_READ(REG_PORT(i), 0x04);
  46160. + REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
  46161. + }
  46162. +
  46163. + /*
  46164. + * Wait for transmit queues to drain.
  46165. + */
  46166. + msleep(2);
  46167. +
  46168. + /*
  46169. + * Reset the switch.
  46170. + */
  46171. + REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
  46172. +
  46173. + /*
  46174. + * Wait up to one second for reset to complete.
  46175. + */
  46176. + for (i = 0; i < 1000; i++) {
  46177. + ret = REG_READ(REG_GLOBAL, 0x00);
  46178. + if ((ret & 0x8000) == 0x0000)
  46179. + break;
  46180. +
  46181. + msleep(1);
  46182. + }
  46183. + if (i == 1000)
  46184. + return -ETIMEDOUT;
  46185. +
  46186. + return 0;
  46187. +}
  46188. +
  46189. +static int mv88e6063_setup_global(struct dsa_switch *ds)
  46190. +{
  46191. + /*
  46192. + * Disable discarding of frames with excessive collisions,
  46193. + * set the maximum frame size to 1536 bytes, and mask all
  46194. + * interrupt sources.
  46195. + */
  46196. + REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
  46197. +
  46198. + /*
  46199. + * Enable automatic address learning, set the address
  46200. + * database size to 1024 entries, and set the default aging
  46201. + * time to 5 minutes.
  46202. + */
  46203. + REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
  46204. +
  46205. + return 0;
  46206. +}
  46207. +
  46208. +static int mv88e6063_setup_port(struct dsa_switch *ds, int p)
  46209. +{
  46210. + int addr = REG_PORT(p);
  46211. +
  46212. + /*
  46213. + * Do not force flow control, disable Ingress and Egress
  46214. + * Header tagging, disable VLAN tunneling, and set the port
  46215. + * state to Forwarding. Additionally, if this is the CPU
  46216. + * port, enable Ingress and Egress Trailer tagging mode.
  46217. + */
  46218. + REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ? 0x4103 : 0x0003);
  46219. +
  46220. + /*
  46221. + * Port based VLAN map: give each port its own address
  46222. + * database, allow the CPU port to talk to each of the 'real'
  46223. + * ports, and allow each of the 'real' ports to only talk to
  46224. + * the CPU port.
  46225. + */
  46226. + REG_WRITE(addr, 0x06,
  46227. + ((p & 0xf) << 12) |
  46228. + (dsa_is_cpu_port(ds, p) ?
  46229. + ds->phys_port_mask :
  46230. + (1 << ds->dst->cpu_port)));
  46231. +
  46232. + /*
  46233. + * Port Association Vector: when learning source addresses
  46234. + * of packets, add the address to the address database using
  46235. + * a port bitmap that has only the bit for this port set and
  46236. + * the other bits clear.
  46237. + */
  46238. + REG_WRITE(addr, 0x0b, 1 << p);
  46239. +
  46240. + return 0;
  46241. +}
  46242. +
  46243. +static int mv88e6063_setup(struct dsa_switch *ds)
  46244. +{
  46245. + int i;
  46246. + int ret;
  46247. +
  46248. + ret = mv88e6063_switch_reset(ds);
  46249. + if (ret < 0)
  46250. + return ret;
  46251. +
  46252. + /* @@@ initialise atu */
  46253. +
  46254. + ret = mv88e6063_setup_global(ds);
  46255. + if (ret < 0)
  46256. + return ret;
  46257. +
  46258. + for (i = 0; i < NUM_PORTS; i++) {
  46259. + ret = mv88e6063_setup_port(ds, i);
  46260. + if (ret < 0)
  46261. + return ret;
  46262. + }
  46263. +
  46264. + return 0;
  46265. +}
  46266. +
  46267. +static int mv88e6063_set_addr(struct dsa_switch *ds, u8 *addr)
  46268. +{
  46269. + REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
  46270. + REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
  46271. + REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);
  46272. +
  46273. + return 0;
  46274. +}
  46275. +
  46276. +static int mv88e6063_port_to_phy_addr(int port)
  46277. +{
  46278. + if (port >= 0 && port <= NUM_PORTS)
  46279. + return REG_PHY(port);
  46280. + return -1;
  46281. +}
  46282. +
  46283. +static int mv88e6063_phy_read(struct dsa_switch *ds, int port, int regnum)
  46284. +{
  46285. + int addr;
  46286. +
  46287. + addr = mv88e6063_port_to_phy_addr(port);
  46288. + if (addr == -1)
  46289. + return 0xffff;
  46290. +
  46291. + return reg_read(ds, addr, regnum);
  46292. +}
  46293. +
  46294. +static int
  46295. +mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
  46296. +{
  46297. + int addr;
  46298. +
  46299. + addr = mv88e6063_port_to_phy_addr(port);
  46300. + if (addr == -1)
  46301. + return 0xffff;
  46302. +
  46303. + return reg_write(ds, addr, regnum, val);
  46304. +}
  46305. +
  46306. +static void mv88e6063_poll_link(struct dsa_switch *ds)
  46307. +{
  46308. + int i;
  46309. +
  46310. + for (i = 0; i < DSA_MAX_PORTS; i++) {
  46311. + struct net_device *dev;
  46312. + int uninitialized_var(port_status);
  46313. + int link;
  46314. + int speed;
  46315. + int duplex;
  46316. + int fc;
  46317. +
  46318. + dev = ds->ports[i];
  46319. + if (dev == NULL)
  46320. + continue;
  46321. +
  46322. + link = 0;
  46323. + if (dev->flags & IFF_UP) {
  46324. + port_status = reg_read(ds, REG_PORT(i), 0x00);
  46325. + if (port_status < 0)
  46326. + continue;
  46327. +
  46328. + link = !!(port_status & 0x1000);
  46329. + }
  46330. +
  46331. + if (!link) {
  46332. + if (netif_carrier_ok(dev)) {
  46333. + printk(KERN_INFO "%s: link down\n", dev->name);
  46334. + netif_carrier_off(dev);
  46335. + }
  46336. + continue;
  46337. + }
  46338. +
  46339. + speed = (port_status & 0x0100) ? 100 : 10;
  46340. + duplex = (port_status & 0x0200) ? 1 : 0;
  46341. + fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
  46342. +
  46343. + if (!netif_carrier_ok(dev)) {
  46344. + printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
  46345. + "flow control %sabled\n", dev->name,
  46346. + speed, duplex ? "full" : "half",
  46347. + fc ? "en" : "dis");
  46348. + netif_carrier_on(dev);
  46349. + }
  46350. + }
  46351. +}
  46352. +
  46353. +static struct dsa_switch_driver mv88e6063_switch_driver = {
  46354. + .tag_protocol = htons(ETH_P_TRAILER),
  46355. + .probe = mv88e6063_probe,
  46356. + .setup = mv88e6063_setup,
  46357. + .set_addr = mv88e6063_set_addr,
  46358. + .phy_read = mv88e6063_phy_read,
  46359. + .phy_write = mv88e6063_phy_write,
  46360. + .poll_link = mv88e6063_poll_link,
  46361. +};
  46362. +
  46363. +static int __init mv88e6063_init(void)
  46364. +{
  46365. + register_switch_driver(&mv88e6063_switch_driver);
  46366. + return 0;
  46367. +}
  46368. +module_init(mv88e6063_init);
  46369. +
  46370. +static void __exit mv88e6063_cleanup(void)
  46371. +{
  46372. + unregister_switch_driver(&mv88e6063_switch_driver);
  46373. +}
  46374. +module_exit(mv88e6063_cleanup);
  46375. diff -Nur linux-4.1.13.orig/net/dsa/tag_trailer.c linux-4.1.13/net/dsa/tag_trailer.c
  46376. --- linux-4.1.13.orig/net/dsa/tag_trailer.c 2015-11-09 23:34:10.000000000 +0100
  46377. +++ linux-4.1.13/net/dsa/tag_trailer.c 2015-12-04 19:57:03.886110643 +0100
  46378. @@ -84,7 +84,7 @@
  46379. trailer = skb_tail_pointer(skb) - 4;
  46380. if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
  46381. - (trailer[3] & 0xef) != 0x00 || trailer[3] != 0x00)
  46382. + (trailer[2] & 0xef) != 0x00 || (trailer[3] & 0xfe) != 0x00)
  46383. goto out_drop;
  46384. source_port = trailer[1] & 7;
  46385. diff -Nur linux-4.1.13.orig/net/ipv4/af_inet.c linux-4.1.13/net/ipv4/af_inet.c
  46386. --- linux-4.1.13.orig/net/ipv4/af_inet.c 2015-11-09 23:34:10.000000000 +0100
  46387. +++ linux-4.1.13/net/ipv4/af_inet.c 2015-12-04 19:57:05.925977182 +0100
  46388. @@ -1323,8 +1323,8 @@
  46389. if (unlikely(ip_fast_csum((u8 *)iph, 5)))
  46390. goto out_unlock;
  46391. - id = ntohl(*(__be32 *)&iph->id);
  46392. - flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));
  46393. + id = ntohl(net_hdr_word(&iph->id));
  46394. + flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id & ~IP_DF));
  46395. id >>= 16;
  46396. for (p = *head; p; p = p->next) {
  46397. diff -Nur linux-4.1.13.orig/net/ipv4/igmp.c linux-4.1.13/net/ipv4/igmp.c
  46398. --- linux-4.1.13.orig/net/ipv4/igmp.c 2015-11-09 23:34:10.000000000 +0100
  46399. +++ linux-4.1.13/net/ipv4/igmp.c 2015-12-04 19:57:05.929976920 +0100
  46400. @@ -496,7 +496,7 @@
  46401. if (!skb)
  46402. return NULL;
  46403. psrc = (__be32 *)skb_put(skb, sizeof(__be32));
  46404. - *psrc = psf->sf_inaddr;
  46405. + net_hdr_word(psrc) = psf->sf_inaddr;
  46406. scount++; stotal++;
  46407. if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
  46408. type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
  46409. diff -Nur linux-4.1.13.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux-4.1.13/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
  46410. --- linux-4.1.13.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2015-11-09 23:34:10.000000000 +0100
  46411. +++ linux-4.1.13/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2015-12-04 19:57:05.917977705 +0100
  46412. @@ -41,8 +41,8 @@
  46413. if (ap == NULL)
  46414. return false;
  46415. - tuple->src.u3.ip = ap[0];
  46416. - tuple->dst.u3.ip = ap[1];
  46417. + tuple->src.u3.ip = net_hdr_word(ap++);
  46418. + tuple->dst.u3.ip = net_hdr_word(ap);
  46419. return true;
  46420. }
  46421. diff -Nur linux-4.1.13.orig/net/ipv4/route.c linux-4.1.13/net/ipv4/route.c
  46422. --- linux-4.1.13.orig/net/ipv4/route.c 2015-11-09 23:34:10.000000000 +0100
  46423. +++ linux-4.1.13/net/ipv4/route.c 2015-12-04 19:57:05.925977182 +0100
  46424. @@ -450,7 +450,7 @@
  46425. else if (skb)
  46426. pkey = &ip_hdr(skb)->daddr;
  46427. - n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey);
  46428. + n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey));
  46429. if (n)
  46430. return n;
  46431. return neigh_create(&arp_tbl, pkey, dev);
  46432. diff -Nur linux-4.1.13.orig/net/ipv4/tcp_input.c linux-4.1.13/net/ipv4/tcp_input.c
  46433. --- linux-4.1.13.orig/net/ipv4/tcp_input.c 2015-11-09 23:34:10.000000000 +0100
  46434. +++ linux-4.1.13/net/ipv4/tcp_input.c 2015-12-04 19:57:05.933976659 +0100
  46435. @@ -3760,14 +3760,16 @@
  46436. {
  46437. const __be32 *ptr = (const __be32 *)(th + 1);
  46438. - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
  46439. - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
  46440. + if (net_hdr_word(ptr) ==
  46441. + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  46442. + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
  46443. tp->rx_opt.saw_tstamp = 1;
  46444. ++ptr;
  46445. - tp->rx_opt.rcv_tsval = ntohl(*ptr);
  46446. + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr);
  46447. ++ptr;
  46448. - if (*ptr)
  46449. - tp->rx_opt.rcv_tsecr = ntohl(*ptr) - tp->tsoffset;
  46450. + if (net_hdr_word(ptr))
  46451. + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr) -
  46452. + tp->tsoffset;
  46453. else
  46454. tp->rx_opt.rcv_tsecr = 0;
  46455. return true;
  46456. diff -Nur linux-4.1.13.orig/net/ipv4/tcp_output.c linux-4.1.13/net/ipv4/tcp_output.c
  46457. --- linux-4.1.13.orig/net/ipv4/tcp_output.c 2015-11-09 23:34:10.000000000 +0100
  46458. +++ linux-4.1.13/net/ipv4/tcp_output.c 2015-12-04 19:57:05.929976920 +0100
  46459. @@ -452,48 +452,53 @@
  46460. u16 options = opts->options; /* mungable copy */
  46461. if (unlikely(OPTION_MD5 & options)) {
  46462. - *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  46463. - (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
  46464. + net_hdr_word(ptr++) =
  46465. + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  46466. + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
  46467. /* overload cookie hash location */
  46468. opts->hash_location = (__u8 *)ptr;
  46469. ptr += 4;
  46470. }
  46471. if (unlikely(opts->mss)) {
  46472. - *ptr++ = htonl((TCPOPT_MSS << 24) |
  46473. - (TCPOLEN_MSS << 16) |
  46474. - opts->mss);
  46475. + net_hdr_word(ptr++) =
  46476. + htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) |
  46477. + opts->mss);
  46478. }
  46479. if (likely(OPTION_TS & options)) {
  46480. if (unlikely(OPTION_SACK_ADVERTISE & options)) {
  46481. - *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
  46482. - (TCPOLEN_SACK_PERM << 16) |
  46483. - (TCPOPT_TIMESTAMP << 8) |
  46484. - TCPOLEN_TIMESTAMP);
  46485. + net_hdr_word(ptr++) =
  46486. + htonl((TCPOPT_SACK_PERM << 24) |
  46487. + (TCPOLEN_SACK_PERM << 16) |
  46488. + (TCPOPT_TIMESTAMP << 8) |
  46489. + TCPOLEN_TIMESTAMP);
  46490. options &= ~OPTION_SACK_ADVERTISE;
  46491. } else {
  46492. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  46493. - (TCPOPT_NOP << 16) |
  46494. - (TCPOPT_TIMESTAMP << 8) |
  46495. - TCPOLEN_TIMESTAMP);
  46496. + net_hdr_word(ptr++) =
  46497. + htonl((TCPOPT_NOP << 24) |
  46498. + (TCPOPT_NOP << 16) |
  46499. + (TCPOPT_TIMESTAMP << 8) |
  46500. + TCPOLEN_TIMESTAMP);
  46501. }
  46502. - *ptr++ = htonl(opts->tsval);
  46503. - *ptr++ = htonl(opts->tsecr);
  46504. + net_hdr_word(ptr++) = htonl(opts->tsval);
  46505. + net_hdr_word(ptr++) = htonl(opts->tsecr);
  46506. }
  46507. if (unlikely(OPTION_SACK_ADVERTISE & options)) {
  46508. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  46509. - (TCPOPT_NOP << 16) |
  46510. - (TCPOPT_SACK_PERM << 8) |
  46511. - TCPOLEN_SACK_PERM);
  46512. + net_hdr_word(ptr++) =
  46513. + htonl((TCPOPT_NOP << 24) |
  46514. + (TCPOPT_NOP << 16) |
  46515. + (TCPOPT_SACK_PERM << 8) |
  46516. + TCPOLEN_SACK_PERM);
  46517. }
  46518. if (unlikely(OPTION_WSCALE & options)) {
  46519. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  46520. - (TCPOPT_WINDOW << 16) |
  46521. - (TCPOLEN_WINDOW << 8) |
  46522. - opts->ws);
  46523. + net_hdr_word(ptr++) =
  46524. + htonl((TCPOPT_NOP << 24) |
  46525. + (TCPOPT_WINDOW << 16) |
  46526. + (TCPOLEN_WINDOW << 8) |
  46527. + opts->ws);
  46528. }
  46529. if (unlikely(opts->num_sack_blocks)) {
  46530. @@ -501,16 +506,17 @@
  46531. tp->duplicate_sack : tp->selective_acks;
  46532. int this_sack;
  46533. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  46534. - (TCPOPT_NOP << 16) |
  46535. - (TCPOPT_SACK << 8) |
  46536. - (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
  46537. + net_hdr_word(ptr++) =
  46538. + htonl((TCPOPT_NOP << 24) |
  46539. + (TCPOPT_NOP << 16) |
  46540. + (TCPOPT_SACK << 8) |
  46541. + (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
  46542. TCPOLEN_SACK_PERBLOCK)));
  46543. for (this_sack = 0; this_sack < opts->num_sack_blocks;
  46544. ++this_sack) {
  46545. - *ptr++ = htonl(sp[this_sack].start_seq);
  46546. - *ptr++ = htonl(sp[this_sack].end_seq);
  46547. + net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq);
  46548. + net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq);
  46549. }
  46550. tp->rx_opt.dsack = 0;
  46551. @@ -523,13 +529,14 @@
  46552. if (foc->exp) {
  46553. len = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
  46554. - *ptr = htonl((TCPOPT_EXP << 24) | (len << 16) |
  46555. + net_hdr_word(ptr) =
  46556. + htonl((TCPOPT_EXP << 24) | (len << 16) |
  46557. TCPOPT_FASTOPEN_MAGIC);
  46558. p += TCPOLEN_EXP_FASTOPEN_BASE;
  46559. } else {
  46560. len = TCPOLEN_FASTOPEN_BASE + foc->len;
  46561. - *p++ = TCPOPT_FASTOPEN;
  46562. - *p++ = len;
  46563. + net_hdr_word(p++) = TCPOPT_FASTOPEN;
  46564. + net_hdr_word(p++) = len;
  46565. }
  46566. memcpy(p, foc->val, foc->len);
  46567. diff -Nur linux-4.1.13.orig/net/ipv6/datagram.c linux-4.1.13/net/ipv6/datagram.c
  46568. --- linux-4.1.13.orig/net/ipv6/datagram.c 2015-11-09 23:34:10.000000000 +0100
  46569. +++ linux-4.1.13/net/ipv6/datagram.c 2015-12-04 19:57:05.921977444 +0100
  46570. @@ -424,7 +424,7 @@
  46571. ipv6_iface_scope_id(&sin->sin6_addr,
  46572. IP6CB(skb)->iif);
  46573. } else {
  46574. - ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),
  46575. + ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset),
  46576. &sin->sin6_addr);
  46577. sin->sin6_scope_id = 0;
  46578. }
  46579. @@ -761,12 +761,12 @@
  46580. }
  46581. if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
  46582. - if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
  46583. + if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) {
  46584. err = -EINVAL;
  46585. goto exit_f;
  46586. }
  46587. }
  46588. - fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
  46589. + fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg));
  46590. break;
  46591. case IPV6_2292HOPOPTS:
  46592. diff -Nur linux-4.1.13.orig/net/ipv6/exthdrs.c linux-4.1.13/net/ipv6/exthdrs.c
  46593. --- linux-4.1.13.orig/net/ipv6/exthdrs.c 2015-11-09 23:34:10.000000000 +0100
  46594. +++ linux-4.1.13/net/ipv6/exthdrs.c 2015-12-04 19:57:05.921977444 +0100
  46595. @@ -573,7 +573,7 @@
  46596. goto drop;
  46597. }
  46598. - pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
  46599. + pkt_len = ntohl(net_hdr_word(nh + optoff + 2));
  46600. if (pkt_len <= IPV6_MAXPLEN) {
  46601. IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
  46602. IPSTATS_MIB_INHDRERRORS);
  46603. diff -Nur linux-4.1.13.orig/net/ipv6/ip6_fib.c linux-4.1.13/net/ipv6/ip6_fib.c
  46604. --- linux-4.1.13.orig/net/ipv6/ip6_fib.c 2015-11-09 23:34:10.000000000 +0100
  46605. +++ linux-4.1.13/net/ipv6/ip6_fib.c 2015-12-04 19:57:05.929976920 +0100
  46606. @@ -137,7 +137,7 @@
  46607. * See include/asm-generic/bitops/le.h.
  46608. */
  46609. return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) &
  46610. - addr[fn_bit >> 5];
  46611. + net_hdr_word(&addr[fn_bit >> 5]);
  46612. }
  46613. static struct fib6_node *node_alloc(void)
  46614. diff -Nur linux-4.1.13.orig/net/ipv6/ip6_gre.c linux-4.1.13/net/ipv6/ip6_gre.c
  46615. --- linux-4.1.13.orig/net/ipv6/ip6_gre.c 2015-11-09 23:34:10.000000000 +0100
  46616. +++ linux-4.1.13/net/ipv6/ip6_gre.c 2015-12-04 19:57:05.921977444 +0100
  46617. @@ -394,7 +394,7 @@
  46618. t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
  46619. flags & GRE_KEY ?
  46620. - *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
  46621. + net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1) : 0,
  46622. p[1]);
  46623. if (!t)
  46624. return;
  46625. @@ -476,11 +476,11 @@
  46626. offset += 4;
  46627. }
  46628. if (flags&GRE_KEY) {
  46629. - key = *(__be32 *)(h + offset);
  46630. + key = net_hdr_word(h + offset);
  46631. offset += 4;
  46632. }
  46633. if (flags&GRE_SEQ) {
  46634. - seqno = ntohl(*(__be32 *)(h + offset));
  46635. + seqno = ntohl(net_hdr_word(h + offset));
  46636. offset += 4;
  46637. }
  46638. }
  46639. @@ -745,7 +745,7 @@
  46640. if (tunnel->parms.o_flags&GRE_SEQ) {
  46641. ++tunnel->o_seqno;
  46642. - *ptr = htonl(tunnel->o_seqno);
  46643. + net_hdr_word(ptr) = htonl(tunnel->o_seqno);
  46644. ptr--;
  46645. }
  46646. if (tunnel->parms.o_flags&GRE_KEY) {
  46647. @@ -841,7 +841,7 @@
  46648. dsfield = ipv6_get_dsfield(ipv6h);
  46649. if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
  46650. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
  46651. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
  46652. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
  46653. fl6.flowlabel |= ip6_flowlabel(ipv6h);
  46654. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
  46655. diff -Nur linux-4.1.13.orig/net/ipv6/ip6_offload.c linux-4.1.13/net/ipv6/ip6_offload.c
  46656. --- linux-4.1.13.orig/net/ipv6/ip6_offload.c 2015-11-09 23:34:10.000000000 +0100
  46657. +++ linux-4.1.13/net/ipv6/ip6_offload.c 2015-12-04 19:57:05.929976920 +0100
  46658. @@ -221,7 +221,7 @@
  46659. continue;
  46660. iph2 = (struct ipv6hdr *)(p->data + off);
  46661. - first_word = *(__be32 *)iph ^ *(__be32 *)iph2;
  46662. + first_word = net_hdr_word(iph) ^ net_hdr_word(iph2);
  46663. /* All fields must match except length and Traffic Class.
  46664. * XXX skbs on the gro_list have all been parsed and pulled
  46665. diff -Nur linux-4.1.13.orig/net/ipv6/ip6_tunnel.c linux-4.1.13/net/ipv6/ip6_tunnel.c
  46666. --- linux-4.1.13.orig/net/ipv6/ip6_tunnel.c 2015-11-09 23:34:10.000000000 +0100
  46667. +++ linux-4.1.13/net/ipv6/ip6_tunnel.c 2015-12-04 19:57:05.921977444 +0100
  46668. @@ -1190,7 +1190,7 @@
  46669. dsfield = ipv6_get_dsfield(ipv6h);
  46670. if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
  46671. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
  46672. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
  46673. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
  46674. fl6.flowlabel |= ip6_flowlabel(ipv6h);
  46675. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
  46676. diff -Nur linux-4.1.13.orig/net/ipv6/netfilter/nf_log_ipv6.c linux-4.1.13/net/ipv6/netfilter/nf_log_ipv6.c
  46677. --- linux-4.1.13.orig/net/ipv6/netfilter/nf_log_ipv6.c 2015-11-09 23:34:10.000000000 +0100
  46678. +++ linux-4.1.13/net/ipv6/netfilter/nf_log_ipv6.c 2015-12-04 19:57:05.933976659 +0100
  46679. @@ -66,9 +66,9 @@
  46680. /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
  46681. nf_log_buf_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
  46682. ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
  46683. - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
  46684. + (ntohl(net_hdr_word(ih)) & 0x0ff00000) >> 20,
  46685. ih->hop_limit,
  46686. - (ntohl(*(__be32 *)ih) & 0x000fffff));
  46687. + (ntohl(net_hdr_word(ih)) & 0x000fffff));
  46688. fragment = 0;
  46689. ptr = ip6hoff + sizeof(struct ipv6hdr);
  46690. diff -Nur linux-4.1.13.orig/net/ipv6/tcp_ipv6.c linux-4.1.13/net/ipv6/tcp_ipv6.c
  46691. --- linux-4.1.13.orig/net/ipv6/tcp_ipv6.c 2015-11-09 23:34:10.000000000 +0100
  46692. +++ linux-4.1.13/net/ipv6/tcp_ipv6.c 2015-12-04 19:57:05.917977705 +0100
  46693. @@ -39,6 +39,7 @@
  46694. #include <linux/ipsec.h>
  46695. #include <linux/times.h>
  46696. #include <linux/slab.h>
  46697. +#include <asm/unaligned.h>
  46698. #include <linux/uaccess.h>
  46699. #include <linux/ipv6.h>
  46700. #include <linux/icmpv6.h>
  46701. @@ -772,10 +773,10 @@
  46702. topt = (__be32 *)(t1 + 1);
  46703. if (tsecr) {
  46704. - *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  46705. - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
  46706. - *topt++ = htonl(tsval);
  46707. - *topt++ = htonl(tsecr);
  46708. + put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  46709. + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++);
  46710. + put_unaligned_be32(tsval, topt++);
  46711. + put_unaligned_be32(tsecr, topt++);
  46712. }
  46713. #ifdef CONFIG_TCP_MD5SIG
  46714. diff -Nur linux-4.1.13.orig/net/netfilter/nf_conntrack_proto_tcp.c linux-4.1.13/net/netfilter/nf_conntrack_proto_tcp.c
  46715. --- linux-4.1.13.orig/net/netfilter/nf_conntrack_proto_tcp.c 2015-11-09 23:34:10.000000000 +0100
  46716. +++ linux-4.1.13/net/netfilter/nf_conntrack_proto_tcp.c 2015-12-04 19:57:05.929976920 +0100
  46717. @@ -453,7 +453,7 @@
  46718. /* Fast path for timestamp-only option */
  46719. if (length == TCPOLEN_TSTAMP_ALIGNED
  46720. - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24)
  46721. + && net_hdr_word(ptr) == htonl((TCPOPT_NOP << 24)
  46722. | (TCPOPT_NOP << 16)
  46723. | (TCPOPT_TIMESTAMP << 8)
  46724. | TCPOLEN_TIMESTAMP))
  46725. diff -Nur linux-4.1.13.orig/net/sched/cls_u32.c linux-4.1.13/net/sched/cls_u32.c
  46726. --- linux-4.1.13.orig/net/sched/cls_u32.c 2015-11-09 23:34:10.000000000 +0100
  46727. +++ linux-4.1.13/net/sched/cls_u32.c 2015-12-04 19:57:05.929976920 +0100
  46728. @@ -151,7 +151,7 @@
  46729. data = skb_header_pointer(skb, toff, 4, &hdata);
  46730. if (!data)
  46731. goto out;
  46732. - if ((*data ^ key->val) & key->mask) {
  46733. + if ((net_hdr_word(data) ^ key->val) & key->mask) {
  46734. n = rcu_dereference_bh(n->next);
  46735. goto next_knode;
  46736. }
  46737. @@ -204,8 +204,8 @@
  46738. &hdata);
  46739. if (!data)
  46740. goto out;
  46741. - sel = ht->divisor & u32_hash_fold(*data, &n->sel,
  46742. - n->fshift);
  46743. + sel = ht->divisor & u32_hash_fold(net_hdr_word(data),
  46744. + &n->sel, n->fshift);
  46745. }
  46746. if (!(n->sel.flags & (TC_U32_VAROFFSET | TC_U32_OFFSET | TC_U32_EAT)))
  46747. goto next_ht;
  46748. diff -Nur linux-4.1.13.orig/net/xfrm/xfrm_input.c linux-4.1.13/net/xfrm/xfrm_input.c
  46749. --- linux-4.1.13.orig/net/xfrm/xfrm_input.c 2015-11-09 23:34:10.000000000 +0100
  46750. +++ linux-4.1.13/net/xfrm/xfrm_input.c 2015-12-04 19:57:05.929976920 +0100
  46751. @@ -154,8 +154,8 @@
  46752. if (!pskb_may_pull(skb, hlen))
  46753. return -EINVAL;
  46754. - *spi = *(__be32 *)(skb_transport_header(skb) + offset);
  46755. - *seq = *(__be32 *)(skb_transport_header(skb) + offset_seq);
  46756. + *spi = net_hdr_word(skb_transport_header(skb) + offset);
  46757. + *seq = net_hdr_word(skb_transport_header(skb) + offset_seq);
  46758. return 0;
  46759. }