rmk.patch 211 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601
  1. diff -Nur linux-3.16.6.orig/arch/arm/boot/dts/imx6dl-hummingboard.dts linux-3.16.6/arch/arm/boot/dts/imx6dl-hummingboard.dts
  2. --- linux-3.16.6.orig/arch/arm/boot/dts/imx6dl-hummingboard.dts 2014-10-15 05:05:43.000000000 -0500
  3. +++ linux-3.16.6/arch/arm/boot/dts/imx6dl-hummingboard.dts 2014-10-23 12:37:45.114220003 -0500
  4. @@ -56,15 +56,32 @@
  5. };
  6. };
  7. + sound-sgtl5000 {
  8. + audio-codec = <&sgtl5000>;
  9. + audio-routing =
  10. + "MIC_IN", "Mic Jack",
  11. + "Mic Jack", "Mic Bias",
  12. + "Headphone Jack", "HP_OUT";
  13. + compatible = "fsl,imx-audio-sgtl5000";
  14. + model = "On-board Codec";
  15. + mux-ext-port = <5>;
  16. + mux-int-port = <1>;
  17. + ssi-controller = <&ssi1>;
  18. + };
  19. +
  20. sound-spdif {
  21. compatible = "fsl,imx-audio-spdif";
  22. - model = "imx-spdif";
  23. + model = "On-board SPDIF";
  24. /* IMX6 doesn't implement this yet */
  25. spdif-controller = <&spdif>;
  26. spdif-out;
  27. };
  28. };
  29. +&audmux {
  30. + status = "okay";
  31. +};
  32. +
  33. &can1 {
  34. pinctrl-names = "default";
  35. pinctrl-0 = <&pinctrl_hummingboard_flexcan1>;
  36. @@ -81,16 +98,24 @@
  37. &i2c1 {
  38. pinctrl-names = "default";
  39. pinctrl-0 = <&pinctrl_hummingboard_i2c1>;
  40. -
  41. - /*
  42. - * Not fitted on Carrier-1 board... yet
  43. status = "okay";
  44. + /* Pro model */
  45. rtc: pcf8523@68 {
  46. compatible = "nxp,pcf8523";
  47. reg = <0x68>;
  48. };
  49. - */
  50. +
  51. + /* Pro model */
  52. + sgtl5000: sgtl5000@0a {
  53. + clocks = <&clks 201>;
  54. + compatible = "fsl,sgtl5000";
  55. + pinctrl-names = "default";
  56. + pinctrl-0 = <&pinctrl_hummingboard_sgtl5000>;
  57. + reg = <0x0a>;
  58. + VDDA-supply = <&reg_3p3v>;
  59. + VDDIO-supply = <&reg_3p3v>;
  60. + };
  61. };
  62. &i2c2 {
  63. @@ -135,6 +160,16 @@
  64. >;
  65. };
  66. + pinctrl_hummingboard_sgtl5000: hummingboard-sgtl5000 {
  67. + fsl,pins = <
  68. + MX6QDL_PAD_DISP0_DAT19__AUD5_RXD 0x130b0 /*brk*/
  69. + MX6QDL_PAD_KEY_COL0__AUD5_TXC 0x130b0 /*ok*/
  70. + MX6QDL_PAD_KEY_ROW0__AUD5_TXD 0x110b0 /*brk*/
  71. + MX6QDL_PAD_KEY_COL1__AUD5_TXFS 0x130b0 /*ok*/
  72. + MX6QDL_PAD_GPIO_5__CCM_CLKO1 0x130b0
  73. + >;
  74. + };
  75. +
  76. pinctrl_hummingboard_spdif: hummingboard-spdif {
  77. fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
  78. };
  79. @@ -180,12 +215,19 @@
  80. status = "okay";
  81. };
  82. +&ssi1 {
  83. + fsl,mode = "i2s-slave";
  84. + status = "okay";
  85. +};
  86. +
  87. &usbh1 {
  88. + disable-over-current;
  89. vbus-supply = <&reg_usbh1_vbus>;
  90. status = "okay";
  91. };
  92. &usbotg {
  93. + disable-over-current;
  94. pinctrl-names = "default";
  95. pinctrl-0 = <&pinctrl_hummingboard_usbotg_id>;
  96. vbus-supply = <&reg_usbotg_vbus>;
  97. diff -Nur linux-3.16.6.orig/arch/arm/boot/dts/imx6q-cubox-i.dts linux-3.16.6/arch/arm/boot/dts/imx6q-cubox-i.dts
  98. --- linux-3.16.6.orig/arch/arm/boot/dts/imx6q-cubox-i.dts 2014-10-15 05:05:43.000000000 -0500
  99. +++ linux-3.16.6/arch/arm/boot/dts/imx6q-cubox-i.dts 2014-10-23 12:26:42.106220014 -0500
  100. @@ -13,4 +13,8 @@
  101. &sata {
  102. status = "okay";
  103. + fsl,transmit-level-mV = <1104>;
  104. + fsl,transmit-boost-mdB = <0>;
  105. + fsl,transmit-atten-16ths = <9>;
  106. + fsl,no-spread-spectrum;
  107. };
  108. diff -Nur linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi linux-3.16.6/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi
  109. --- linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi 2014-10-15 05:05:43.000000000 -0500
  110. +++ linux-3.16.6/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi 2014-10-23 12:34:41.266219992 -0500
  111. @@ -61,7 +61,7 @@
  112. sound-spdif {
  113. compatible = "fsl,imx-audio-spdif";
  114. - model = "imx-spdif";
  115. + model = "Integrated SPDIF";
  116. /* IMX6 doesn't implement this yet */
  117. spdif-controller = <&spdif>;
  118. spdif-out;
  119. @@ -130,16 +130,23 @@
  120. fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
  121. };
  122. + pinctrl_cubox_i_usbh1: cubox-i-usbh1 {
  123. + fsl,pins = <MX6QDL_PAD_GPIO_3__USB_H1_OC 0x1b0b0>;
  124. + };
  125. +
  126. pinctrl_cubox_i_usbh1_vbus: cubox-i-usbh1-vbus {
  127. fsl,pins = <MX6QDL_PAD_GPIO_0__GPIO1_IO00 0x4001b0b0>;
  128. };
  129. - pinctrl_cubox_i_usbotg_id: cubox-i-usbotg-id {
  130. + pinctrl_cubox_i_usbotg: cubox-i-usbotg {
  131. /*
  132. - * The Cubox-i pulls this low, but as it's pointless
  133. + * The Cubox-i pulls ID low, but as it's pointless
  134. * leaving it as a pull-up, even if it is just 10uA.
  135. */
  136. - fsl,pins = <MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x13059>;
  137. + fsl,pins = <
  138. + MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x13059
  139. + MX6QDL_PAD_KEY_COL4__USB_OTG_OC 0x1b0b0
  140. + >;
  141. };
  142. pinctrl_cubox_i_usbotg_vbus: cubox-i-usbotg-vbus {
  143. @@ -163,6 +170,28 @@
  144. MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x13059
  145. >;
  146. };
  147. +
  148. + pinctrl_cubox_i_usdhc2_100mhz: cubox-i-usdhc2-100mhz {
  149. + fsl,pins = <
  150. + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x170b9
  151. + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x100b9
  152. + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x170b9
  153. + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x170b9
  154. + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x170b9
  155. + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x130b9
  156. + >;
  157. + };
  158. +
  159. + pinctrl_cubox_i_usdhc2_200mhz: cubox-i-usdhc2-200mhz {
  160. + fsl,pins = <
  161. + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x170f9
  162. + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x100f9
  163. + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x170f9
  164. + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x170f9
  165. + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x170f9
  166. + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x130f9
  167. + >;
  168. + };
  169. };
  170. };
  171. @@ -173,20 +202,24 @@
  172. };
  173. &usbh1 {
  174. + pinctrl-names = "default";
  175. + pinctrl-0 = <&pinctrl_cubox_i_usbh1>;
  176. vbus-supply = <&reg_usbh1_vbus>;
  177. status = "okay";
  178. };
  179. &usbotg {
  180. pinctrl-names = "default";
  181. - pinctrl-0 = <&pinctrl_cubox_i_usbotg_id>;
  182. + pinctrl-0 = <&pinctrl_cubox_i_usbotg>;
  183. vbus-supply = <&reg_usbotg_vbus>;
  184. status = "okay";
  185. };
  186. &usdhc2 {
  187. - pinctrl-names = "default";
  188. + pinctrl-names = "default", "state_100mhz", "state_200mhz";
  189. pinctrl-0 = <&pinctrl_cubox_i_usdhc2_aux &pinctrl_cubox_i_usdhc2>;
  190. + pinctrl-1 = <&pinctrl_cubox_i_usdhc2_aux &pinctrl_cubox_i_usdhc2_100mhz>;
  191. + pinctrl-2 = <&pinctrl_cubox_i_usdhc2_aux &pinctrl_cubox_i_usdhc2_200mhz>;
  192. vmmc-supply = <&reg_3p3v>;
  193. cd-gpios = <&gpio1 4 0>;
  194. status = "okay";
  195. diff -Nur linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi.orig linux-3.16.6/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi.orig
  196. --- linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi.orig 1969-12-31 18:00:00.000000000 -0600
  197. +++ linux-3.16.6/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi.orig 2014-10-23 12:27:10.986220036 -0500
  198. @@ -0,0 +1,202 @@
  199. +/*
  200. + * Copyright (C) 2014 Russell King
  201. + */
  202. +#include "imx6qdl-microsom.dtsi"
  203. +#include "imx6qdl-microsom-ar8035.dtsi"
  204. +
  205. +/ {
  206. + ir_recv: ir-receiver {
  207. + compatible = "gpio-ir-receiver";
  208. + gpios = <&gpio3 9 1>;
  209. + pinctrl-names = "default";
  210. + pinctrl-0 = <&pinctrl_cubox_i_ir>;
  211. + };
  212. +
  213. + pwmleds {
  214. + compatible = "pwm-leds";
  215. + pinctrl-names = "default";
  216. + pinctrl-0 = <&pinctrl_cubox_i_pwm1>;
  217. +
  218. + front {
  219. + active-low;
  220. + label = "imx6:red:front";
  221. + max-brightness = <248>;
  222. + pwms = <&pwm1 0 50000>;
  223. + };
  224. + };
  225. +
  226. + regulators {
  227. + compatible = "simple-bus";
  228. +
  229. + reg_3p3v: 3p3v {
  230. + compatible = "regulator-fixed";
  231. + regulator-name = "3P3V";
  232. + regulator-min-microvolt = <3300000>;
  233. + regulator-max-microvolt = <3300000>;
  234. + regulator-always-on;
  235. + };
  236. +
  237. + reg_usbh1_vbus: usb-h1-vbus {
  238. + compatible = "regulator-fixed";
  239. + enable-active-high;
  240. + gpio = <&gpio1 0 0>;
  241. + pinctrl-names = "default";
  242. + pinctrl-0 = <&pinctrl_cubox_i_usbh1_vbus>;
  243. + regulator-name = "usb_h1_vbus";
  244. + regulator-min-microvolt = <5000000>;
  245. + regulator-max-microvolt = <5000000>;
  246. + };
  247. +
  248. + reg_usbotg_vbus: usb-otg-vbus {
  249. + compatible = "regulator-fixed";
  250. + enable-active-high;
  251. + gpio = <&gpio3 22 0>;
  252. + pinctrl-names = "default";
  253. + pinctrl-0 = <&pinctrl_cubox_i_usbotg_vbus>;
  254. + regulator-name = "usb_otg_vbus";
  255. + regulator-min-microvolt = <5000000>;
  256. + regulator-max-microvolt = <5000000>;
  257. + };
  258. + };
  259. +
  260. + sound-spdif {
  261. + compatible = "fsl,imx-audio-spdif";
  262. + model = "Integrated SPDIF";
  263. + /* IMX6 doesn't implement this yet */
  264. + spdif-controller = <&spdif>;
  265. + spdif-out;
  266. + };
  267. +};
  268. +
  269. +&hdmi {
  270. + pinctrl-names = "default";
  271. + pinctrl-0 = <&pinctrl_cubox_i_hdmi>;
  272. + ddc-i2c-bus = <&i2c2>;
  273. + status = "okay";
  274. +};
  275. +
  276. +&i2c2 {
  277. + clock-frequency = <100000>;
  278. + pinctrl-names = "default";
  279. + pinctrl-0 = <&pinctrl_cubox_i_i2c2>;
  280. + status = "okay";
  281. +};
  282. +
  283. +&i2c3 {
  284. + pinctrl-names = "default";
  285. + pinctrl-0 = <&pinctrl_cubox_i_i2c3>;
  286. +
  287. + status = "okay";
  288. +
  289. + rtc: pcf8523@68 {
  290. + compatible = "nxp,pcf8523";
  291. + reg = <0x68>;
  292. + };
  293. +};
  294. +
  295. +&iomuxc {
  296. + cubox_i {
  297. + pinctrl_cubox_i_hdmi: cubox-i-hdmi {
  298. + fsl,pins = <
  299. + MX6QDL_PAD_KEY_ROW2__HDMI_TX_CEC_LINE 0x1f8b0
  300. + >;
  301. + };
  302. +
  303. + pinctrl_cubox_i_i2c2: cubox-i-i2c2 {
  304. + fsl,pins = <
  305. + MX6QDL_PAD_KEY_COL3__I2C2_SCL 0x4001b8b1
  306. + MX6QDL_PAD_KEY_ROW3__I2C2_SDA 0x4001b8b1
  307. + >;
  308. + };
  309. +
  310. + pinctrl_cubox_i_i2c3: cubox-i-i2c3 {
  311. + fsl,pins = <
  312. + MX6QDL_PAD_EIM_D17__I2C3_SCL 0x4001b8b1
  313. + MX6QDL_PAD_EIM_D18__I2C3_SDA 0x4001b8b1
  314. + >;
  315. + };
  316. +
  317. + pinctrl_cubox_i_ir: cubox-i-ir {
  318. + fsl,pins = <
  319. + MX6QDL_PAD_EIM_DA9__GPIO3_IO09 0x80000000
  320. + >;
  321. + };
  322. +
  323. + pinctrl_cubox_i_pwm1: cubox-i-pwm1-front-led {
  324. + fsl,pins = <MX6QDL_PAD_DISP0_DAT8__PWM1_OUT 0x1b0b0>;
  325. + };
  326. +
  327. + pinctrl_cubox_i_spdif: cubox-i-spdif {
  328. + fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
  329. + };
  330. +
  331. + pinctrl_cubox_i_usbh1: cubox-i-usbh1 {
  332. + fsl,pins = <MX6QDL_PAD_GPIO_3__USB_H1_OC 0x1b0b0>;
  333. + };
  334. +
  335. + pinctrl_cubox_i_usbh1_vbus: cubox-i-usbh1-vbus {
  336. + fsl,pins = <MX6QDL_PAD_GPIO_0__GPIO1_IO00 0x4001b0b0>;
  337. + };
  338. +
  339. + pinctrl_cubox_i_usbotg: cubox-i-usbotg {
  340. + /*
  341. + * The Cubox-i pulls ID low, but as it's pointless
  342. + * leaving it as a pull-up, even if it is just 10uA.
  343. + */
  344. + fsl,pins = <
  345. + MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x13059
  346. + MX6QDL_PAD_KEY_COL4__USB_OTG_OC 0x1b0b0
  347. + >;
  348. + };
  349. +
  350. + pinctrl_cubox_i_usbotg_vbus: cubox-i-usbotg-vbus {
  351. + fsl,pins = <MX6QDL_PAD_EIM_D22__GPIO3_IO22 0x4001b0b0>;
  352. + };
  353. +
  354. + pinctrl_cubox_i_usdhc2_aux: cubox-i-usdhc2-aux {
  355. + fsl,pins = <
  356. + MX6QDL_PAD_GPIO_4__GPIO1_IO04 0x1f071
  357. + MX6QDL_PAD_KEY_ROW1__SD2_VSELECT 0x1b071
  358. + >;
  359. + };
  360. +
  361. + pinctrl_cubox_i_usdhc2: cubox-i-usdhc2 {
  362. + fsl,pins = <
  363. + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x17059
  364. + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x10059
  365. + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x17059
  366. + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17059
  367. + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17059
  368. + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x13059
  369. + >;
  370. + };
  371. + };
  372. +};
  373. +
  374. +&spdif {
  375. + pinctrl-names = "default";
  376. + pinctrl-0 = <&pinctrl_cubox_i_spdif>;
  377. + status = "okay";
  378. +};
  379. +
  380. +&usbh1 {
  381. + pinctrl-names = "default";
  382. + pinctrl-0 = <&pinctrl_cubox_i_usbh1>;
  383. + vbus-supply = <&reg_usbh1_vbus>;
  384. + status = "okay";
  385. +};
  386. +
  387. +&usbotg {
  388. + pinctrl-names = "default";
  389. + pinctrl-0 = <&pinctrl_cubox_i_usbotg>;
  390. + vbus-supply = <&reg_usbotg_vbus>;
  391. + status = "okay";
  392. +};
  393. +
  394. +&usdhc2 {
  395. + pinctrl-names = "default";
  396. + pinctrl-0 = <&pinctrl_cubox_i_usdhc2_aux &pinctrl_cubox_i_usdhc2>;
  397. + vmmc-supply = <&reg_3p3v>;
  398. + cd-gpios = <&gpio1 4 0>;
  399. + status = "okay";
  400. +};
  401. diff -Nur linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-microsom.dtsi linux-3.16.6/arch/arm/boot/dts/imx6qdl-microsom.dtsi
  402. --- linux-3.16.6.orig/arch/arm/boot/dts/imx6qdl-microsom.dtsi 2014-10-15 05:05:43.000000000 -0500
  403. +++ linux-3.16.6/arch/arm/boot/dts/imx6qdl-microsom.dtsi 2014-10-23 12:34:48.394220240 -0500
  404. @@ -1,15 +1,95 @@
  405. /*
  406. * Copyright (C) 2013,2014 Russell King
  407. */
  408. +#include <dt-bindings/gpio/gpio.h>
  409. +/ {
  410. + regulators {
  411. + compatible = "simple-bus";
  412. +
  413. + reg_brcm_osc: brcm-osc-reg {
  414. + compatible = "regulator-fixed";
  415. + enable-active-high;
  416. + gpio = <&gpio5 5 0>;
  417. + pinctrl-names = "default";
  418. + pinctrl-0 = <&pinctrl_microsom_brcm_osc_reg>;
  419. + regulator-name = "brcm_osc_reg";
  420. + regulator-min-microvolt = <3300000>;
  421. + regulator-max-microvolt = <3300000>;
  422. + regulator-always-on;
  423. + regulator-boot-on;
  424. + };
  425. +
  426. + reg_brcm: brcm-reg {
  427. + compatible = "regulator-fixed";
  428. + enable-active-high;
  429. + gpio = <&gpio3 19 0>;
  430. + pinctrl-names = "default";
  431. + pinctrl-0 = <&pinctrl_microsom_brcm_reg>;
  432. + regulator-name = "brcm_reg";
  433. + regulator-min-microvolt = <3300000>;
  434. + regulator-max-microvolt = <3300000>;
  435. + startup-delay-us = <200000>;
  436. + };
  437. + };
  438. +};
  439. &iomuxc {
  440. microsom {
  441. + pinctrl_microsom_brcm_bt: microsom-brcm-bt {
  442. + fsl,pins = <
  443. + MX6QDL_PAD_CSI0_DAT14__GPIO6_IO00 0x40013070
  444. + MX6QDL_PAD_CSI0_DAT15__GPIO6_IO01 0x40013070
  445. + MX6QDL_PAD_CSI0_DAT18__GPIO6_IO04 0x40013070
  446. + >;
  447. + };
  448. +
  449. + pinctrl_microsom_brcm_osc_reg: microsom-brcm-osc-reg {
  450. + fsl,pins = <
  451. + MX6QDL_PAD_DISP0_DAT11__GPIO5_IO05 0x40013070
  452. + >;
  453. + };
  454. +
  455. + pinctrl_microsom_brcm_reg: microsom-brcm-reg {
  456. + fsl,pins = <
  457. + MX6QDL_PAD_EIM_D19__GPIO3_IO19 0x40013070
  458. + >;
  459. + };
  460. +
  461. + pinctrl_microsom_brcm_wifi: microsom-brcm-wifi {
  462. + fsl,pins = <
  463. + MX6QDL_PAD_GPIO_8__XTALOSC_REF_CLK_32K 0x1b0b0
  464. + MX6QDL_PAD_CSI0_DATA_EN__GPIO5_IO20 0x40013070
  465. + MX6QDL_PAD_CSI0_DAT8__GPIO5_IO26 0x40013070
  466. + MX6QDL_PAD_CSI0_DAT9__GPIO5_IO27 0x40013070
  467. + >;
  468. + };
  469. +
  470. pinctrl_microsom_uart1: microsom-uart1 {
  471. fsl,pins = <
  472. MX6QDL_PAD_CSI0_DAT10__UART1_TX_DATA 0x1b0b1
  473. MX6QDL_PAD_CSI0_DAT11__UART1_RX_DATA 0x1b0b1
  474. >;
  475. };
  476. +
  477. + pinctrl_microsom_uart4_1: microsom-uart4 {
  478. + fsl,pins = <
  479. + MX6QDL_PAD_CSI0_DAT12__UART4_TX_DATA 0x1b0b1
  480. + MX6QDL_PAD_CSI0_DAT13__UART4_RX_DATA 0x1b0b1
  481. + MX6QDL_PAD_CSI0_DAT16__UART4_RTS_B 0x1b0b1
  482. + MX6QDL_PAD_CSI0_DAT17__UART4_CTS_B 0x1b0b1
  483. + >;
  484. + };
  485. +
  486. + pinctrl_microsom_usdhc1: microsom-usdhc1 {
  487. + fsl,pins = <
  488. + MX6QDL_PAD_SD1_CMD__SD1_CMD 0x17059
  489. + MX6QDL_PAD_SD1_CLK__SD1_CLK 0x10059
  490. + MX6QDL_PAD_SD1_DAT0__SD1_DATA0 0x17059
  491. + MX6QDL_PAD_SD1_DAT1__SD1_DATA1 0x17059
  492. + MX6QDL_PAD_SD1_DAT2__SD1_DATA2 0x17059
  493. + MX6QDL_PAD_SD1_DAT3__SD1_DATA3 0x17059
  494. + >;
  495. + };
  496. };
  497. };
  498. @@ -18,3 +98,23 @@
  499. pinctrl-0 = <&pinctrl_microsom_uart1>;
  500. status = "okay";
  501. };
  502. +
  503. +/* UART4 - Connected to optional BRCM Wifi/BT/FM */
  504. +&uart4 {
  505. + pinctrl-names = "default";
  506. + pinctrl-0 = <&pinctrl_microsom_brcm_bt &pinctrl_microsom_uart4_1>;
  507. + fsl,uart-has-rtscts;
  508. + status = "okay";
  509. +};
  510. +
  511. +/* USDHC1 - Connected to optional BRCM Wifi/BT/FM */
  512. +&usdhc1 {
  513. + card-external-vcc-supply = <&reg_brcm>;
  514. + card-reset-gpios = <&gpio5 26 GPIO_ACTIVE_LOW>, <&gpio6 0 GPIO_ACTIVE_LOW>;
  515. + keep-power-in-suspend;
  516. + non-removable;
  517. + pinctrl-names = "default";
  518. + pinctrl-0 = <&pinctrl_microsom_brcm_wifi &pinctrl_microsom_usdhc1>;
  519. + vmmc-supply = <&reg_brcm>;
  520. + status = "okay";
  521. +};
  522. diff -Nur linux-3.16.6.orig/arch/arm/mach-imx/clk-imx6q.c linux-3.16.6/arch/arm/mach-imx/clk-imx6q.c
  523. --- linux-3.16.6.orig/arch/arm/mach-imx/clk-imx6q.c 2014-10-15 05:05:43.000000000 -0500
  524. +++ linux-3.16.6/arch/arm/mach-imx/clk-imx6q.c 2014-10-23 12:36:09.214219998 -0500
  525. @@ -461,6 +461,9 @@
  526. clk_set_parent(clk[ipu2_di0_sel], clk[ipu2_di0_pre]);
  527. clk_set_parent(clk[ipu2_di1_sel], clk[ipu2_di1_pre]);
  528. + if (cpu_is_imx6dl())
  529. + clk_set_parent(clk[ipu1_sel], clk[pll3_pfd1_540m]);
  530. +
  531. /*
  532. * The gpmi needs 100MHz frequency in the EDO/Sync mode,
  533. * We can not get the 100MHz from the pll2_pfd0_352m.
  534. diff -Nur linux-3.16.6.orig/arch/arm/mach-imx/clk-pllv3.c linux-3.16.6/arch/arm/mach-imx/clk-pllv3.c
  535. --- linux-3.16.6.orig/arch/arm/mach-imx/clk-pllv3.c 2014-10-15 05:05:43.000000000 -0500
  536. +++ linux-3.16.6/arch/arm/mach-imx/clk-pllv3.c 2014-10-23 12:36:01.390219997 -0500
  537. @@ -273,9 +273,10 @@
  538. struct clk_pllv3 *pll = to_clk_pllv3(hw);
  539. unsigned long min_rate = parent_rate * 27;
  540. unsigned long max_rate = parent_rate * 54;
  541. - u32 val, div;
  542. + u32 val, newval, div;
  543. u32 mfn, mfd = 1000000;
  544. s64 temp64;
  545. + int ret;
  546. if (rate < min_rate || rate > max_rate)
  547. return -EINVAL;
  548. @@ -287,13 +288,27 @@
  549. mfn = temp64;
  550. val = readl_relaxed(pll->base);
  551. - val &= ~pll->div_mask;
  552. - val |= div;
  553. - writel_relaxed(val, pll->base);
  554. +
  555. + /* set the PLL into bypass mode */
  556. + newval = val | BM_PLL_BYPASS;
  557. + writel_relaxed(newval, pll->base);
  558. +
  559. + /* configure the new frequency */
  560. + newval &= ~pll->div_mask;
  561. + newval |= div;
  562. + writel_relaxed(newval, pll->base);
  563. writel_relaxed(mfn, pll->base + PLL_NUM_OFFSET);
  564. - writel_relaxed(mfd, pll->base + PLL_DENOM_OFFSET);
  565. + writel(mfd, pll->base + PLL_DENOM_OFFSET);
  566. +
  567. + ret = clk_pllv3_wait_lock(pll);
  568. + if (ret == 0 && val & BM_PLL_POWER) {
  569. + /* only if it locked can we switch back to the PLL */
  570. + newval &= ~BM_PLL_BYPASS;
  571. + newval |= val & BM_PLL_BYPASS;
  572. + writel(newval, pll->base);
  573. + }
  574. - return clk_pllv3_wait_lock(pll);
  575. + return ret;
  576. }
  577. static const struct clk_ops clk_pllv3_av_ops = {
  578. diff -Nur linux-3.16.6.orig/Documentation/devicetree/bindings/ata/ahci-platform.txt linux-3.16.6/Documentation/devicetree/bindings/ata/ahci-platform.txt
  579. --- linux-3.16.6.orig/Documentation/devicetree/bindings/ata/ahci-platform.txt 2014-10-15 05:05:43.000000000 -0500
  580. +++ linux-3.16.6/Documentation/devicetree/bindings/ata/ahci-platform.txt 2014-10-23 12:15:35.154220017 -0500
  581. @@ -6,8 +6,6 @@
  582. Required properties:
  583. - compatible : compatible string, one of:
  584. - "allwinner,sun4i-a10-ahci"
  585. - - "fsl,imx53-ahci"
  586. - - "fsl,imx6q-ahci"
  587. - "hisilicon,hisi-ahci"
  588. - "ibm,476gtr-ahci"
  589. - "marvell,armada-380-ahci"
  590. @@ -22,10 +20,6 @@
  591. - clocks : a list of phandle + clock specifier pairs
  592. - target-supply : regulator for SATA target power
  593. -"fsl,imx53-ahci", "fsl,imx6q-ahci" required properties:
  594. -- clocks : must contain the sata, sata_ref and ahb clocks
  595. -- clock-names : must contain "ahb" for the ahb clock
  596. -
  597. Examples:
  598. sata@ffe08000 {
  599. compatible = "snps,spear-ahci";
  600. diff -Nur linux-3.16.6.orig/Documentation/devicetree/bindings/ata/imx-sata.txt linux-3.16.6/Documentation/devicetree/bindings/ata/imx-sata.txt
  601. --- linux-3.16.6.orig/Documentation/devicetree/bindings/ata/imx-sata.txt 1969-12-31 18:00:00.000000000 -0600
  602. +++ linux-3.16.6/Documentation/devicetree/bindings/ata/imx-sata.txt 2014-10-23 12:26:27.434219953 -0500
  603. @@ -0,0 +1,36 @@
  604. +* Freescale i.MX AHCI SATA Controller
  605. +
  606. +The Freescale i.MX SATA controller mostly conforms to the AHCI interface
  607. +with some special extensions at integration level.
  608. +
  609. +Required properties:
  610. +- compatible : should be one of the following:
  611. + - "fsl,imx53-ahci" for i.MX53 SATA controller
  612. + - "fsl,imx6q-ahci" for i.MX6Q SATA controller
  613. +- interrupts : interrupt mapping for SATA IRQ
  614. +- reg : registers mapping
  615. +- clocks : list of clock specifiers, must contain an entry for each
  616. + required entry in clock-names
  617. +- clock-names : should include "sata", "sata_ref" and "ahb" entries
  618. +
  619. +Optional properties:
  620. +- fsl,transmit-level-mV : transmit voltage level, in millivolts.
  621. +- fsl,transmit-boost-mdB : transmit boost level, in milli-decibels
  622. +- fsl,transmit-atten-16ths : transmit attenuation, in 16ths
  623. +- fsl,receive-eq-mdB : receive equalisation, in milli-decibels
  624. + Please refer to the technical documentation or the driver source code
  625. + for the list of legal values for these options.
  626. +- fsl,no-spread-spectrum : disable spread-spectrum clocking on the SATA
  627. + link.
  628. +
  629. +Examples:
  630. +
  631. +sata@02200000 {
  632. + compatible = "fsl,imx6q-ahci";
  633. + reg = <0x02200000 0x4000>;
  634. + interrupts = <0 39 IRQ_TYPE_LEVEL_HIGH>;
  635. + clocks = <&clks IMX6QDL_CLK_SATA>,
  636. + <&clks IMX6QDL_CLK_SATA_REF_100M>,
  637. + <&clks IMX6QDL_CLK_AHB>;
  638. + clock-names = "sata", "sata_ref", "ahb";
  639. +};
  640. diff -Nur linux-3.16.6.orig/Documentation/devicetree/bindings/mmc/mmc.txt linux-3.16.6/Documentation/devicetree/bindings/mmc/mmc.txt
  641. --- linux-3.16.6.orig/Documentation/devicetree/bindings/mmc/mmc.txt 2014-10-15 05:05:43.000000000 -0500
  642. +++ linux-3.16.6/Documentation/devicetree/bindings/mmc/mmc.txt 2014-10-23 12:34:18.694220003 -0500
  643. @@ -5,6 +5,8 @@
  644. Interpreted by the OF core:
  645. - reg: Registers location and length.
  646. - interrupts: Interrupts used by the MMC controller.
  647. +- clocks: Clocks needed for the host controller, if any.
  648. +- clock-names: Goes with clocks above.
  649. Card detection:
  650. If no property below is supplied, host native card detect is used.
  651. @@ -41,6 +43,15 @@
  652. - mmc-hs400-1_8v: eMMC HS400 mode(1.8V I/O) is supported
  653. - mmc-hs400-1_2v: eMMC HS400 mode(1.2V I/O) is supported
  654. +Card power and reset control:
  655. +The following properties can be specified for cases where the MMC
  656. +peripheral needs additional reset, regulator and clock lines. It is for
  657. +example common for WiFi/BT adapters to have these separate from the main
  658. +MMC bus:
  659. + - card-reset-gpios: Specify GPIOs for card reset (reset active low)
  660. + - card-external-vcc-supply: Regulator to drive (independent) card VCC
  661. + - clock with name "card_ext_clock": External clock provided to the card
  662. +
  663. *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
  664. polarity properties, we have to fix the meaning of the "normal" and "inverted"
  665. line levels. We choose to follow the SDHCI standard, which specifies both those
  666. diff -Nur linux-3.16.6.orig/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt linux-3.16.6/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
  667. --- linux-3.16.6.orig/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt 2014-10-15 05:05:43.000000000 -0500
  668. +++ linux-3.16.6/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt 2014-10-23 12:35:30.946219998 -0500
  669. @@ -60,8 +60,8 @@
  670. - compatible: Should be "fsl,imx-parallel-display"
  671. Optional properties:
  672. - interface_pix_fmt: How this display is connected to the
  673. - display interface. Currently supported types: "rgb24", "rgb565", "bgr666"
  674. - and "lvds666".
  675. + display interface. Currently supported types: "rgb24", "rgb565", "bgr666",
  676. + "rgb666" and "lvds666".
  677. - edid: verbatim EDID data block describing attached display.
  678. - ddc: phandle describing the i2c bus handling the display data
  679. channel
  680. diff -Nur linux-3.16.6.orig/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml linux-3.16.6/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
  681. --- linux-3.16.6.orig/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml 2014-10-15 05:05:43.000000000 -0500
  682. +++ linux-3.16.6/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml 2014-10-23 12:35:23.678220004 -0500
  683. @@ -279,6 +279,45 @@
  684. <entry></entry>
  685. <entry></entry>
  686. </row>
  687. + <row id="V4L2-PIX-FMT-RGB666">
  688. + <entry><constant>V4L2_PIX_FMT_RGB666</constant></entry>
  689. + <entry>'RGBH'</entry>
  690. + <entry></entry>
  691. + <entry>r<subscript>5</subscript></entry>
  692. + <entry>r<subscript>4</subscript></entry>
  693. + <entry>r<subscript>3</subscript></entry>
  694. + <entry>r<subscript>2</subscript></entry>
  695. + <entry>r<subscript>1</subscript></entry>
  696. + <entry>r<subscript>0</subscript></entry>
  697. + <entry>g<subscript>5</subscript></entry>
  698. + <entry>g<subscript>4</subscript></entry>
  699. + <entry></entry>
  700. + <entry>g<subscript>3</subscript></entry>
  701. + <entry>g<subscript>2</subscript></entry>
  702. + <entry>g<subscript>1</subscript></entry>
  703. + <entry>g<subscript>0</subscript></entry>
  704. + <entry>b<subscript>5</subscript></entry>
  705. + <entry>b<subscript>4</subscript></entry>
  706. + <entry>b<subscript>3</subscript></entry>
  707. + <entry>b<subscript>2</subscript></entry>
  708. + <entry></entry>
  709. + <entry>b<subscript>1</subscript></entry>
  710. + <entry>b<subscript>0</subscript></entry>
  711. + <entry></entry>
  712. + <entry></entry>
  713. + <entry></entry>
  714. + <entry></entry>
  715. + <entry></entry>
  716. + <entry></entry>
  717. + <entry></entry>
  718. + <entry></entry>
  719. + <entry></entry>
  720. + <entry></entry>
  721. + <entry></entry>
  722. + <entry></entry>
  723. + <entry></entry>
  724. + <entry></entry>
  725. + </row>
  726. <row id="V4L2-PIX-FMT-BGR24">
  727. <entry><constant>V4L2_PIX_FMT_BGR24</constant></entry>
  728. <entry>'BGR3'</entry>
  729. diff -Nur linux-3.16.6.orig/drivers/ata/ahci_imx.c linux-3.16.6/drivers/ata/ahci_imx.c
  730. --- linux-3.16.6.orig/drivers/ata/ahci_imx.c 2014-10-15 05:05:43.000000000 -0500
  731. +++ linux-3.16.6/drivers/ata/ahci_imx.c 2014-10-23 12:26:19.770220044 -0500
  732. @@ -64,6 +64,7 @@
  733. struct regmap *gpr;
  734. bool no_device;
  735. bool first_time;
  736. + u32 phy_params;
  737. };
  738. static int ahci_imx_hotplug;
  739. @@ -248,14 +249,7 @@
  740. IMX6Q_GPR13_SATA_TX_LVL_MASK |
  741. IMX6Q_GPR13_SATA_MPLL_CLK_EN |
  742. IMX6Q_GPR13_SATA_TX_EDGE_RATE,
  743. - IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB |
  744. - IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M |
  745. - IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F |
  746. - IMX6Q_GPR13_SATA_SPD_MODE_3P0G |
  747. - IMX6Q_GPR13_SATA_MPLL_SS_EN |
  748. - IMX6Q_GPR13_SATA_TX_ATTEN_9_16 |
  749. - IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB |
  750. - IMX6Q_GPR13_SATA_TX_LVL_1_025_V);
  751. + imxpriv->phy_params);
  752. regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13,
  753. IMX6Q_GPR13_SATA_MPLL_CLK_EN,
  754. IMX6Q_GPR13_SATA_MPLL_CLK_EN);
  755. @@ -369,6 +363,165 @@
  756. };
  757. MODULE_DEVICE_TABLE(of, imx_ahci_of_match);
  758. +struct reg_value {
  759. + u32 of_value;
  760. + u32 reg_value;
  761. +};
  762. +
  763. +struct reg_property {
  764. + const char *name;
  765. + const struct reg_value *values;
  766. + size_t num_values;
  767. + u32 def_value;
  768. + u32 set_value;
  769. +};
  770. +
  771. +static const struct reg_value gpr13_tx_level[] = {
  772. + { 937, IMX6Q_GPR13_SATA_TX_LVL_0_937_V },
  773. + { 947, IMX6Q_GPR13_SATA_TX_LVL_0_947_V },
  774. + { 957, IMX6Q_GPR13_SATA_TX_LVL_0_957_V },
  775. + { 966, IMX6Q_GPR13_SATA_TX_LVL_0_966_V },
  776. + { 976, IMX6Q_GPR13_SATA_TX_LVL_0_976_V },
  777. + { 986, IMX6Q_GPR13_SATA_TX_LVL_0_986_V },
  778. + { 996, IMX6Q_GPR13_SATA_TX_LVL_0_996_V },
  779. + { 1005, IMX6Q_GPR13_SATA_TX_LVL_1_005_V },
  780. + { 1015, IMX6Q_GPR13_SATA_TX_LVL_1_015_V },
  781. + { 1025, IMX6Q_GPR13_SATA_TX_LVL_1_025_V },
  782. + { 1035, IMX6Q_GPR13_SATA_TX_LVL_1_035_V },
  783. + { 1045, IMX6Q_GPR13_SATA_TX_LVL_1_045_V },
  784. + { 1054, IMX6Q_GPR13_SATA_TX_LVL_1_054_V },
  785. + { 1064, IMX6Q_GPR13_SATA_TX_LVL_1_064_V },
  786. + { 1074, IMX6Q_GPR13_SATA_TX_LVL_1_074_V },
  787. + { 1084, IMX6Q_GPR13_SATA_TX_LVL_1_084_V },
  788. + { 1094, IMX6Q_GPR13_SATA_TX_LVL_1_094_V },
  789. + { 1104, IMX6Q_GPR13_SATA_TX_LVL_1_104_V },
  790. + { 1113, IMX6Q_GPR13_SATA_TX_LVL_1_113_V },
  791. + { 1123, IMX6Q_GPR13_SATA_TX_LVL_1_123_V },
  792. + { 1133, IMX6Q_GPR13_SATA_TX_LVL_1_133_V },
  793. + { 1143, IMX6Q_GPR13_SATA_TX_LVL_1_143_V },
  794. + { 1152, IMX6Q_GPR13_SATA_TX_LVL_1_152_V },
  795. + { 1162, IMX6Q_GPR13_SATA_TX_LVL_1_162_V },
  796. + { 1172, IMX6Q_GPR13_SATA_TX_LVL_1_172_V },
  797. + { 1182, IMX6Q_GPR13_SATA_TX_LVL_1_182_V },
  798. + { 1191, IMX6Q_GPR13_SATA_TX_LVL_1_191_V },
  799. + { 1201, IMX6Q_GPR13_SATA_TX_LVL_1_201_V },
  800. + { 1211, IMX6Q_GPR13_SATA_TX_LVL_1_211_V },
  801. + { 1221, IMX6Q_GPR13_SATA_TX_LVL_1_221_V },
  802. + { 1230, IMX6Q_GPR13_SATA_TX_LVL_1_230_V },
  803. + { 1240, IMX6Q_GPR13_SATA_TX_LVL_1_240_V }
  804. +};
  805. +
  806. +static const struct reg_value gpr13_tx_boost[] = {
  807. + { 0, IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB },
  808. + { 370, IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB },
  809. + { 740, IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB },
  810. + { 1110, IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB },
  811. + { 1480, IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB },
  812. + { 1850, IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB },
  813. + { 2220, IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB },
  814. + { 2590, IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB },
  815. + { 2960, IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB },
  816. + { 3330, IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB },
  817. + { 3700, IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB },
  818. + { 4070, IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB },
  819. + { 4440, IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB },
  820. + { 4810, IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB },
  821. + { 5280, IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB },
  822. + { 5750, IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB }
  823. +};
  824. +
  825. +static const struct reg_value gpr13_tx_atten[] = {
  826. + { 8, IMX6Q_GPR13_SATA_TX_ATTEN_8_16 },
  827. + { 9, IMX6Q_GPR13_SATA_TX_ATTEN_9_16 },
  828. + { 10, IMX6Q_GPR13_SATA_TX_ATTEN_10_16 },
  829. + { 12, IMX6Q_GPR13_SATA_TX_ATTEN_12_16 },
  830. + { 14, IMX6Q_GPR13_SATA_TX_ATTEN_14_16 },
  831. + { 16, IMX6Q_GPR13_SATA_TX_ATTEN_16_16 },
  832. +};
  833. +
  834. +static const struct reg_value gpr13_rx_eq[] = {
  835. + { 500, IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB },
  836. + { 1000, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB },
  837. + { 1500, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB },
  838. + { 2000, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB },
  839. + { 2500, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB },
  840. + { 3000, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB },
  841. + { 3500, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB },
  842. + { 4000, IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB },
  843. +};
  844. +
  845. +static const struct reg_property gpr13_props[] = {
  846. + {
  847. + .name = "fsl,transmit-level-mV",
  848. + .values = gpr13_tx_level,
  849. + .num_values = ARRAY_SIZE(gpr13_tx_level),
  850. + .def_value = IMX6Q_GPR13_SATA_TX_LVL_1_025_V,
  851. + }, {
  852. + .name = "fsl,transmit-boost-mdB",
  853. + .values = gpr13_tx_boost,
  854. + .num_values = ARRAY_SIZE(gpr13_tx_boost),
  855. + .def_value = IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB,
  856. + }, {
  857. + .name = "fsl,transmit-atten-16ths",
  858. + .values = gpr13_tx_atten,
  859. + .num_values = ARRAY_SIZE(gpr13_tx_atten),
  860. + .def_value = IMX6Q_GPR13_SATA_TX_ATTEN_9_16,
  861. + }, {
  862. + .name = "fsl,receive-eq-mdB",
  863. + .values = gpr13_rx_eq,
  864. + .num_values = ARRAY_SIZE(gpr13_rx_eq),
  865. + .def_value = IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB,
  866. + }, {
  867. + .name = "fsl,no-spread-spectrum",
  868. + .def_value = IMX6Q_GPR13_SATA_MPLL_SS_EN,
  869. + .set_value = 0,
  870. + },
  871. +};
  872. +
  873. +static u32 imx_ahci_parse_props(struct device *dev,
  874. + const struct reg_property *prop, size_t num)
  875. +{
  876. + struct device_node *np = dev->of_node;
  877. + u32 reg_value = 0;
  878. + int i, j;
  879. +
  880. + for (i = 0; i < num; i++, prop++) {
  881. + u32 of_val;
  882. +
  883. + if (prop->num_values == 0) {
  884. + if (of_property_read_bool(np, prop->name))
  885. + reg_value |= prop->set_value;
  886. + else
  887. + reg_value |= prop->def_value;
  888. + continue;
  889. + }
  890. +
  891. + if (of_property_read_u32(np, prop->name, &of_val)) {
  892. + dev_info(dev, "%s not specified, using %08x\n",
  893. + prop->name, prop->def_value);
  894. + reg_value |= prop->def_value;
  895. + continue;
  896. + }
  897. +
  898. + for (j = 0; j < prop->num_values; j++) {
  899. + if (prop->values[j].of_value == of_val) {
  900. + dev_info(dev, "%s value %u, using %08x\n",
  901. + prop->name, of_val, prop->values[j].reg_value);
  902. + reg_value |= prop->values[j].reg_value;
  903. + break;
  904. + }
  905. + }
  906. +
  907. + if (j == prop->num_values) {
  908. + dev_err(dev, "DT property %s is not a valid value\n",
  909. + prop->name);
  910. + reg_value |= prop->def_value;
  911. + }
  912. + }
  913. +
  914. + return reg_value;
  915. +}
  916. +
  917. static int imx_ahci_probe(struct platform_device *pdev)
  918. {
  919. struct device *dev = &pdev->dev;
  920. @@ -410,6 +563,8 @@
  921. }
  922. if (imxpriv->type == AHCI_IMX6Q) {
  923. + u32 reg_value;
  924. +
  925. imxpriv->gpr = syscon_regmap_lookup_by_compatible(
  926. "fsl,imx6q-iomuxc-gpr");
  927. if (IS_ERR(imxpriv->gpr)) {
  928. @@ -417,6 +572,15 @@
  929. "failed to find fsl,imx6q-iomux-gpr regmap\n");
  930. return PTR_ERR(imxpriv->gpr);
  931. }
  932. +
  933. + reg_value = imx_ahci_parse_props(dev, gpr13_props,
  934. + ARRAY_SIZE(gpr13_props));
  935. +
  936. + imxpriv->phy_params =
  937. + IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M |
  938. + IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F |
  939. + IMX6Q_GPR13_SATA_SPD_MODE_3P0G |
  940. + reg_value;
  941. }
  942. hpriv = ahci_platform_get_resources(pdev);
  943. diff -Nur linux-3.16.6.orig/drivers/ata/ahci_imx.c.orig linux-3.16.6/drivers/ata/ahci_imx.c.orig
  944. --- linux-3.16.6.orig/drivers/ata/ahci_imx.c.orig 1969-12-31 18:00:00.000000000 -0600
  945. +++ linux-3.16.6/drivers/ata/ahci_imx.c.orig 2014-10-23 12:18:59.602219672 -0500
  946. @@ -0,0 +1,679 @@
  947. +/*
  948. + * copyright (c) 2013 Freescale Semiconductor, Inc.
  949. + * Freescale IMX AHCI SATA platform driver
  950. + *
  951. + * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov
  952. + *
  953. + * This program is free software; you can redistribute it and/or modify it
  954. + * under the terms and conditions of the GNU General Public License,
  955. + * version 2, as published by the Free Software Foundation.
  956. + *
  957. + * This program is distributed in the hope it will be useful, but WITHOUT
  958. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  959. + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  960. + * more details.
  961. + *
  962. + * You should have received a copy of the GNU General Public License along with
  963. + * this program. If not, see <http://www.gnu.org/licenses/>.
  964. + */
  965. +
  966. +#include <linux/kernel.h>
  967. +#include <linux/module.h>
  968. +#include <linux/platform_device.h>
  969. +#include <linux/regmap.h>
  970. +#include <linux/ahci_platform.h>
  971. +#include <linux/of_device.h>
  972. +#include <linux/mfd/syscon.h>
  973. +#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
  974. +#include <linux/libata.h>
  975. +#include "ahci.h"
  976. +
  977. +enum {
  978. + /* Timer 1-ms Register */
  979. + IMX_TIMER1MS = 0x00e0,
  980. + /* Port0 PHY Control Register */
  981. + IMX_P0PHYCR = 0x0178,
  982. + IMX_P0PHYCR_TEST_PDDQ = 1 << 20,
  983. + IMX_P0PHYCR_CR_READ = 1 << 19,
  984. + IMX_P0PHYCR_CR_WRITE = 1 << 18,
  985. + IMX_P0PHYCR_CR_CAP_DATA = 1 << 17,
  986. + IMX_P0PHYCR_CR_CAP_ADDR = 1 << 16,
  987. + /* Port0 PHY Status Register */
  988. + IMX_P0PHYSR = 0x017c,
  989. + IMX_P0PHYSR_CR_ACK = 1 << 18,
  990. + IMX_P0PHYSR_CR_DATA_OUT = 0xffff << 0,
  991. + /* Lane0 Output Status Register */
  992. + IMX_LANE0_OUT_STAT = 0x2003,
  993. + IMX_LANE0_OUT_STAT_RX_PLL_STATE = 1 << 1,
  994. + /* Clock Reset Register */
  995. + IMX_CLOCK_RESET = 0x7f3f,
  996. + IMX_CLOCK_RESET_RESET = 1 << 0,
  997. +};
  998. +
  999. +enum ahci_imx_type {
  1000. + AHCI_IMX53,
  1001. + AHCI_IMX6Q,
  1002. +};
  1003. +
  1004. +struct imx_ahci_priv {
  1005. + struct platform_device *ahci_pdev;
  1006. + enum ahci_imx_type type;
  1007. + struct clk *sata_clk;
  1008. + struct clk *sata_ref_clk;
  1009. + struct clk *ahb_clk;
  1010. + struct regmap *gpr;
  1011. + bool no_device;
  1012. + bool first_time;
  1013. + u32 phy_params;
  1014. +};
  1015. +
  1016. +static int ahci_imx_hotplug;
  1017. +module_param_named(hotplug, ahci_imx_hotplug, int, 0644);
  1018. +MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)");
  1019. +
  1020. +static void ahci_imx_host_stop(struct ata_host *host);
  1021. +
  1022. +static int imx_phy_crbit_assert(void __iomem *mmio, u32 bit, bool assert)
  1023. +{
  1024. + int timeout = 10;
  1025. + u32 crval;
  1026. + u32 srval;
  1027. +
  1028. + /* Assert or deassert the bit */
  1029. + crval = readl(mmio + IMX_P0PHYCR);
  1030. + if (assert)
  1031. + crval |= bit;
  1032. + else
  1033. + crval &= ~bit;
  1034. + writel(crval, mmio + IMX_P0PHYCR);
  1035. +
  1036. + /* Wait for the cr_ack signal */
  1037. + do {
  1038. + srval = readl(mmio + IMX_P0PHYSR);
  1039. + if ((assert ? srval : ~srval) & IMX_P0PHYSR_CR_ACK)
  1040. + break;
  1041. + usleep_range(100, 200);
  1042. + } while (--timeout);
  1043. +
  1044. + return timeout ? 0 : -ETIMEDOUT;
  1045. +}
  1046. +
  1047. +static int imx_phy_reg_addressing(u16 addr, void __iomem *mmio)
  1048. +{
  1049. + u32 crval = addr;
  1050. + int ret;
  1051. +
  1052. + /* Supply the address on cr_data_in */
  1053. + writel(crval, mmio + IMX_P0PHYCR);
  1054. +
  1055. + /* Assert the cr_cap_addr signal */
  1056. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, true);
  1057. + if (ret)
  1058. + return ret;
  1059. +
  1060. + /* Deassert cr_cap_addr */
  1061. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, false);
  1062. + if (ret)
  1063. + return ret;
  1064. +
  1065. + return 0;
  1066. +}
  1067. +
  1068. +static int imx_phy_reg_write(u16 val, void __iomem *mmio)
  1069. +{
  1070. + u32 crval = val;
  1071. + int ret;
  1072. +
  1073. + /* Supply the data on cr_data_in */
  1074. + writel(crval, mmio + IMX_P0PHYCR);
  1075. +
  1076. + /* Assert the cr_cap_data signal */
  1077. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, true);
  1078. + if (ret)
  1079. + return ret;
  1080. +
  1081. + /* Deassert cr_cap_data */
  1082. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, false);
  1083. + if (ret)
  1084. + return ret;
  1085. +
  1086. + if (val & IMX_CLOCK_RESET_RESET) {
  1087. + /*
  1088. + * In case we're resetting the phy, it's unable to acknowledge,
  1089. + * so we return immediately here.
  1090. + */
  1091. + crval |= IMX_P0PHYCR_CR_WRITE;
  1092. + writel(crval, mmio + IMX_P0PHYCR);
  1093. + goto out;
  1094. + }
  1095. +
  1096. + /* Assert the cr_write signal */
  1097. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, true);
  1098. + if (ret)
  1099. + return ret;
  1100. +
  1101. + /* Deassert cr_write */
  1102. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, false);
  1103. + if (ret)
  1104. + return ret;
  1105. +
  1106. +out:
  1107. + return 0;
  1108. +}
  1109. +
  1110. +static int imx_phy_reg_read(u16 *val, void __iomem *mmio)
  1111. +{
  1112. + int ret;
  1113. +
  1114. + /* Assert the cr_read signal */
  1115. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, true);
  1116. + if (ret)
  1117. + return ret;
  1118. +
  1119. + /* Capture the data from cr_data_out[] */
  1120. + *val = readl(mmio + IMX_P0PHYSR) & IMX_P0PHYSR_CR_DATA_OUT;
  1121. +
  1122. + /* Deassert cr_read */
  1123. + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, false);
  1124. + if (ret)
  1125. + return ret;
  1126. +
  1127. + return 0;
  1128. +}
  1129. +
  1130. +static int imx_sata_phy_reset(struct ahci_host_priv *hpriv)
  1131. +{
  1132. + void __iomem *mmio = hpriv->mmio;
  1133. + int timeout = 10;
  1134. + u16 val;
  1135. + int ret;
  1136. +
  1137. + /* Reset SATA PHY by setting RESET bit of PHY register CLOCK_RESET */
  1138. + ret = imx_phy_reg_addressing(IMX_CLOCK_RESET, mmio);
  1139. + if (ret)
  1140. + return ret;
  1141. + ret = imx_phy_reg_write(IMX_CLOCK_RESET_RESET, mmio);
  1142. + if (ret)
  1143. + return ret;
  1144. +
  1145. + /* Wait for PHY RX_PLL to be stable */
  1146. + do {
  1147. + usleep_range(100, 200);
  1148. + ret = imx_phy_reg_addressing(IMX_LANE0_OUT_STAT, mmio);
  1149. + if (ret)
  1150. + return ret;
  1151. + ret = imx_phy_reg_read(&val, mmio);
  1152. + if (ret)
  1153. + return ret;
  1154. + if (val & IMX_LANE0_OUT_STAT_RX_PLL_STATE)
  1155. + break;
  1156. + } while (--timeout);
  1157. +
  1158. + return timeout ? 0 : -ETIMEDOUT;
  1159. +}
  1160. +
  1161. +static int imx_sata_enable(struct ahci_host_priv *hpriv)
  1162. +{
  1163. + struct imx_ahci_priv *imxpriv = hpriv->plat_data;
  1164. + struct device *dev = &imxpriv->ahci_pdev->dev;
  1165. + int ret;
  1166. +
  1167. + if (imxpriv->no_device)
  1168. + return 0;
  1169. +
  1170. + if (hpriv->target_pwr) {
  1171. + ret = regulator_enable(hpriv->target_pwr);
  1172. + if (ret)
  1173. + return ret;
  1174. + }
  1175. +
  1176. + ret = clk_prepare_enable(imxpriv->sata_ref_clk);
  1177. + if (ret < 0)
  1178. + goto disable_regulator;
  1179. +
  1180. + if (imxpriv->type == AHCI_IMX6Q) {
  1181. + /*
  1182. + * set PHY Paremeters, two steps to configure the GPR13,
  1183. + * one write for rest of parameters, mask of first write
  1184. + * is 0x07ffffff, and the other one write for setting
  1185. + * the mpll_clk_en.
  1186. + */
  1187. + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13,
  1188. + IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK |
  1189. + IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK |
  1190. + IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK |
  1191. + IMX6Q_GPR13_SATA_SPD_MODE_MASK |
  1192. + IMX6Q_GPR13_SATA_MPLL_SS_EN |
  1193. + IMX6Q_GPR13_SATA_TX_ATTEN_MASK |
  1194. + IMX6Q_GPR13_SATA_TX_BOOST_MASK |
  1195. + IMX6Q_GPR13_SATA_TX_LVL_MASK |
  1196. + IMX6Q_GPR13_SATA_MPLL_CLK_EN |
  1197. + IMX6Q_GPR13_SATA_TX_EDGE_RATE,
  1198. + imxpriv->phy_params);
  1199. + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13,
  1200. + IMX6Q_GPR13_SATA_MPLL_CLK_EN,
  1201. + IMX6Q_GPR13_SATA_MPLL_CLK_EN);
  1202. +
  1203. + usleep_range(100, 200);
  1204. +
  1205. + ret = imx_sata_phy_reset(hpriv);
  1206. + if (ret) {
  1207. + dev_err(dev, "failed to reset phy: %d\n", ret);
  1208. + goto disable_regulator;
  1209. + }
  1210. + }
  1211. +
  1212. + usleep_range(1000, 2000);
  1213. +
  1214. + return 0;
  1215. +
  1216. +disable_regulator:
  1217. + if (hpriv->target_pwr)
  1218. + regulator_disable(hpriv->target_pwr);
  1219. +
  1220. + return ret;
  1221. +}
  1222. +
  1223. +static void imx_sata_disable(struct ahci_host_priv *hpriv)
  1224. +{
  1225. + struct imx_ahci_priv *imxpriv = hpriv->plat_data;
  1226. +
  1227. + if (imxpriv->no_device)
  1228. + return;
  1229. +
  1230. + if (imxpriv->type == AHCI_IMX6Q) {
  1231. + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13,
  1232. + IMX6Q_GPR13_SATA_MPLL_CLK_EN,
  1233. + !IMX6Q_GPR13_SATA_MPLL_CLK_EN);
  1234. + }
  1235. +
  1236. + clk_disable_unprepare(imxpriv->sata_ref_clk);
  1237. +
  1238. + if (hpriv->target_pwr)
  1239. + regulator_disable(hpriv->target_pwr);
  1240. +}
  1241. +
  1242. +static void ahci_imx_error_handler(struct ata_port *ap)
  1243. +{
  1244. + u32 reg_val;
  1245. + struct ata_device *dev;
  1246. + struct ata_host *host = dev_get_drvdata(ap->dev);
  1247. + struct ahci_host_priv *hpriv = host->private_data;
  1248. + void __iomem *mmio = hpriv->mmio;
  1249. + struct imx_ahci_priv *imxpriv = hpriv->plat_data;
  1250. +
  1251. + ahci_error_handler(ap);
  1252. +
  1253. + if (!(imxpriv->first_time) || ahci_imx_hotplug)
  1254. + return;
  1255. +
  1256. + imxpriv->first_time = false;
  1257. +
  1258. + ata_for_each_dev(dev, &ap->link, ENABLED)
  1259. + return;
  1260. + /*
  1261. + * Disable link to save power. An imx ahci port can't be recovered
  1262. + * without full reset once the pddq mode is enabled making it
  1263. + * impossible to use as part of libata LPM.
  1264. + */
  1265. + reg_val = readl(mmio + IMX_P0PHYCR);
  1266. + writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR);
  1267. + imx_sata_disable(hpriv);
  1268. + imxpriv->no_device = true;
  1269. +
  1270. + dev_info(ap->dev, "no device found, disabling link.\n");
  1271. + dev_info(ap->dev, "pass " MODULE_PARAM_PREFIX ".hotplug=1 to enable hotplug\n");
  1272. +}
  1273. +
  1274. +static int ahci_imx_softreset(struct ata_link *link, unsigned int *class,
  1275. + unsigned long deadline)
  1276. +{
  1277. + struct ata_port *ap = link->ap;
  1278. + struct ata_host *host = dev_get_drvdata(ap->dev);
  1279. + struct ahci_host_priv *hpriv = host->private_data;
  1280. + struct imx_ahci_priv *imxpriv = hpriv->plat_data;
  1281. + int ret = -EIO;
  1282. +
  1283. + if (imxpriv->type == AHCI_IMX53)
  1284. + ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline);
  1285. + else if (imxpriv->type == AHCI_IMX6Q)
  1286. + ret = ahci_ops.softreset(link, class, deadline);
  1287. +
  1288. + return ret;
  1289. +}
  1290. +
  1291. +static struct ata_port_operations ahci_imx_ops = {
  1292. + .inherits = &ahci_ops,
  1293. + .host_stop = ahci_imx_host_stop,
  1294. + .error_handler = ahci_imx_error_handler,
  1295. + .softreset = ahci_imx_softreset,
  1296. +};
  1297. +
  1298. +static const struct ata_port_info ahci_imx_port_info = {
  1299. + .flags = AHCI_FLAG_COMMON,
  1300. + .pio_mask = ATA_PIO4,
  1301. + .udma_mask = ATA_UDMA6,
  1302. + .port_ops = &ahci_imx_ops,
  1303. +};
  1304. +
  1305. +static const struct of_device_id imx_ahci_of_match[] = {
  1306. + { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 },
  1307. + { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q },
  1308. + {},
  1309. +};
  1310. +MODULE_DEVICE_TABLE(of, imx_ahci_of_match);
  1311. +
  1312. +struct reg_value {
  1313. + u32 of_value;
  1314. + u32 reg_value;
  1315. +};
  1316. +
  1317. +struct reg_property {
  1318. + const char *name;
  1319. + const struct reg_value *values;
  1320. + size_t num_values;
  1321. + u32 def_value;
  1322. +};
  1323. +
  1324. +static const struct reg_value gpr13_tx_level[] = {
  1325. + { 937, IMX6Q_GPR13_SATA_TX_LVL_0_937_V },
  1326. + { 947, IMX6Q_GPR13_SATA_TX_LVL_0_947_V },
  1327. + { 957, IMX6Q_GPR13_SATA_TX_LVL_0_957_V },
  1328. + { 966, IMX6Q_GPR13_SATA_TX_LVL_0_966_V },
  1329. + { 976, IMX6Q_GPR13_SATA_TX_LVL_0_976_V },
  1330. + { 986, IMX6Q_GPR13_SATA_TX_LVL_0_986_V },
  1331. + { 996, IMX6Q_GPR13_SATA_TX_LVL_0_996_V },
  1332. + { 1005, IMX6Q_GPR13_SATA_TX_LVL_1_005_V },
  1333. + { 1015, IMX6Q_GPR13_SATA_TX_LVL_1_015_V },
  1334. + { 1025, IMX6Q_GPR13_SATA_TX_LVL_1_025_V },
  1335. + { 1035, IMX6Q_GPR13_SATA_TX_LVL_1_035_V },
  1336. + { 1045, IMX6Q_GPR13_SATA_TX_LVL_1_045_V },
  1337. + { 1054, IMX6Q_GPR13_SATA_TX_LVL_1_054_V },
  1338. + { 1064, IMX6Q_GPR13_SATA_TX_LVL_1_064_V },
  1339. + { 1074, IMX6Q_GPR13_SATA_TX_LVL_1_074_V },
  1340. + { 1084, IMX6Q_GPR13_SATA_TX_LVL_1_084_V },
  1341. + { 1094, IMX6Q_GPR13_SATA_TX_LVL_1_094_V },
  1342. + { 1104, IMX6Q_GPR13_SATA_TX_LVL_1_104_V },
  1343. + { 1113, IMX6Q_GPR13_SATA_TX_LVL_1_113_V },
  1344. + { 1123, IMX6Q_GPR13_SATA_TX_LVL_1_123_V },
  1345. + { 1133, IMX6Q_GPR13_SATA_TX_LVL_1_133_V },
  1346. + { 1143, IMX6Q_GPR13_SATA_TX_LVL_1_143_V },
  1347. + { 1152, IMX6Q_GPR13_SATA_TX_LVL_1_152_V },
  1348. + { 1162, IMX6Q_GPR13_SATA_TX_LVL_1_162_V },
  1349. + { 1172, IMX6Q_GPR13_SATA_TX_LVL_1_172_V },
  1350. + { 1182, IMX6Q_GPR13_SATA_TX_LVL_1_182_V },
  1351. + { 1191, IMX6Q_GPR13_SATA_TX_LVL_1_191_V },
  1352. + { 1201, IMX6Q_GPR13_SATA_TX_LVL_1_201_V },
  1353. + { 1211, IMX6Q_GPR13_SATA_TX_LVL_1_211_V },
  1354. + { 1221, IMX6Q_GPR13_SATA_TX_LVL_1_221_V },
  1355. + { 1230, IMX6Q_GPR13_SATA_TX_LVL_1_230_V },
  1356. + { 1240, IMX6Q_GPR13_SATA_TX_LVL_1_240_V }
  1357. +};
  1358. +
  1359. +static const struct reg_value gpr13_tx_boost[] = {
  1360. + { 0, IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB },
  1361. + { 370, IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB },
  1362. + { 740, IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB },
  1363. + { 1110, IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB },
  1364. + { 1480, IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB },
  1365. + { 1850, IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB },
  1366. + { 2220, IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB },
  1367. + { 2590, IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB },
  1368. + { 2960, IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB },
  1369. + { 3330, IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB },
  1370. + { 3700, IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB },
  1371. + { 4070, IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB },
  1372. + { 4440, IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB },
  1373. + { 4810, IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB },
  1374. + { 5280, IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB },
  1375. + { 5750, IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB }
  1376. +};
  1377. +
  1378. +static const struct reg_value gpr13_tx_atten[] = {
  1379. + { 8, IMX6Q_GPR13_SATA_TX_ATTEN_8_16 },
  1380. + { 9, IMX6Q_GPR13_SATA_TX_ATTEN_9_16 },
  1381. + { 10, IMX6Q_GPR13_SATA_TX_ATTEN_10_16 },
  1382. + { 12, IMX6Q_GPR13_SATA_TX_ATTEN_12_16 },
  1383. + { 14, IMX6Q_GPR13_SATA_TX_ATTEN_14_16 },
  1384. + { 16, IMX6Q_GPR13_SATA_TX_ATTEN_16_16 },
  1385. +};
  1386. +
  1387. +static const struct reg_value gpr13_rx_eq[] = {
  1388. + { 500, IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB },
  1389. + { 1000, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB },
  1390. + { 1500, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB },
  1391. + { 2000, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB },
  1392. + { 2500, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB },
  1393. + { 3000, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB },
  1394. + { 3500, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB },
  1395. + { 4000, IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB },
  1396. +};
  1397. +
  1398. +static const struct reg_property gpr13_props[] = {
  1399. + {
  1400. + .name = "fsl,transmit-level-mV",
  1401. + .values = gpr13_tx_level,
  1402. + .num_values = ARRAY_SIZE(gpr13_tx_level),
  1403. + .def_value = IMX6Q_GPR13_SATA_TX_LVL_1_025_V,
  1404. + }, {
  1405. + .name = "fsl,transmit-boost-mdB",
  1406. + .values = gpr13_tx_boost,
  1407. + .num_values = ARRAY_SIZE(gpr13_tx_boost),
  1408. + .def_value = IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB,
  1409. + }, {
  1410. + .name = "fsl,transmit-atten-16ths",
  1411. + .values = gpr13_tx_atten,
  1412. + .num_values = ARRAY_SIZE(gpr13_tx_atten),
  1413. + .def_value = IMX6Q_GPR13_SATA_TX_ATTEN_9_16,
  1414. + }, {
  1415. + .name = "fsl,receive-eq-mdB",
  1416. + .values = gpr13_rx_eq,
  1417. + .num_values = ARRAY_SIZE(gpr13_rx_eq),
  1418. + .def_value = IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB,
  1419. + },
  1420. +};
  1421. +
  1422. +static u32 imx_ahci_parse_props(struct device *dev,
  1423. + const struct reg_property *prop, size_t num)
  1424. +{
  1425. + struct device_node *np = dev->of_node;
  1426. + u32 reg_value = 0;
  1427. + int i, j;
  1428. +
  1429. + for (i = 0; i < num; i++, prop++) {
  1430. + u32 of_val;
  1431. +
  1432. + if (of_property_read_u32(np, prop->name, &of_val)) {
  1433. + dev_info(dev, "%s not specified, using %08x\n",
  1434. + prop->name, prop->def_value);
  1435. + reg_value |= prop->def_value;
  1436. + continue;
  1437. + }
  1438. +
  1439. + for (j = 0; j < prop->num_values; j++) {
  1440. + if (prop->values[j].of_value == of_val) {
  1441. + dev_info(dev, "%s value %u, using %08x\n",
  1442. + prop->name, of_val, prop->values[j].reg_value);
  1443. + reg_value |= prop->values[j].reg_value;
  1444. + break;
  1445. + }
  1446. + }
  1447. +
  1448. + if (j == prop->num_values) {
  1449. + dev_err(dev, "DT property %s is not a valid value\n",
  1450. + prop->name);
  1451. + reg_value |= prop->def_value;
  1452. + }
  1453. + }
  1454. +
  1455. + return reg_value;
  1456. +}
  1457. +
  1458. +static int imx_ahci_probe(struct platform_device *pdev)
  1459. +{
  1460. + struct device *dev = &pdev->dev;
  1461. + const struct of_device_id *of_id;
  1462. + struct ahci_host_priv *hpriv;
  1463. + struct imx_ahci_priv *imxpriv;
  1464. + unsigned int reg_val;
  1465. + int ret;
  1466. +
  1467. + of_id = of_match_device(imx_ahci_of_match, dev);
  1468. + if (!of_id)
  1469. + return -EINVAL;
  1470. +
  1471. + imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL);
  1472. + if (!imxpriv)
  1473. + return -ENOMEM;
  1474. +
  1475. + imxpriv->ahci_pdev = pdev;
  1476. + imxpriv->no_device = false;
  1477. + imxpriv->first_time = true;
  1478. + imxpriv->type = (enum ahci_imx_type)of_id->data;
  1479. +
  1480. + imxpriv->sata_clk = devm_clk_get(dev, "sata");
  1481. + if (IS_ERR(imxpriv->sata_clk)) {
  1482. + dev_err(dev, "can't get sata clock.\n");
  1483. + return PTR_ERR(imxpriv->sata_clk);
  1484. + }
  1485. +
  1486. + imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref");
  1487. + if (IS_ERR(imxpriv->sata_ref_clk)) {
  1488. + dev_err(dev, "can't get sata_ref clock.\n");
  1489. + return PTR_ERR(imxpriv->sata_ref_clk);
  1490. + }
  1491. +
  1492. + imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
  1493. + if (IS_ERR(imxpriv->ahb_clk)) {
  1494. + dev_err(dev, "can't get ahb clock.\n");
  1495. + return PTR_ERR(imxpriv->ahb_clk);
  1496. + }
  1497. +
  1498. + if (imxpriv->type == AHCI_IMX6Q) {
  1499. + u32 reg_value;
  1500. +
  1501. + imxpriv->gpr = syscon_regmap_lookup_by_compatible(
  1502. + "fsl,imx6q-iomuxc-gpr");
  1503. + if (IS_ERR(imxpriv->gpr)) {
  1504. + dev_err(dev,
  1505. + "failed to find fsl,imx6q-iomux-gpr regmap\n");
  1506. + return PTR_ERR(imxpriv->gpr);
  1507. + }
  1508. +
  1509. + reg_value = imx_ahci_parse_props(dev, gpr13_props,
  1510. + ARRAY_SIZE(gpr13_props));
  1511. +
  1512. + imxpriv->phy_params =
  1513. + IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M |
  1514. + IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F |
  1515. + IMX6Q_GPR13_SATA_SPD_MODE_3P0G |
  1516. + IMX6Q_GPR13_SATA_MPLL_SS_EN |
  1517. + reg_value;
  1518. + }
  1519. +
  1520. + hpriv = ahci_platform_get_resources(pdev);
  1521. + if (IS_ERR(hpriv))
  1522. + return PTR_ERR(hpriv);
  1523. +
  1524. + hpriv->plat_data = imxpriv;
  1525. +
  1526. + ret = clk_prepare_enable(imxpriv->sata_clk);
  1527. + if (ret)
  1528. + return ret;
  1529. +
  1530. + ret = imx_sata_enable(hpriv);
  1531. + if (ret)
  1532. + goto disable_clk;
  1533. +
  1534. + /*
  1535. + * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
  1536. + * and IP vendor specific register IMX_TIMER1MS.
  1537. + * Configure CAP_SSS (support stagered spin up).
  1538. + * Implement the port0.
  1539. + * Get the ahb clock rate, and configure the TIMER1MS register.
  1540. + */
  1541. + reg_val = readl(hpriv->mmio + HOST_CAP);
  1542. + if (!(reg_val & HOST_CAP_SSS)) {
  1543. + reg_val |= HOST_CAP_SSS;
  1544. + writel(reg_val, hpriv->mmio + HOST_CAP);
  1545. + }
  1546. + reg_val = readl(hpriv->mmio + HOST_PORTS_IMPL);
  1547. + if (!(reg_val & 0x1)) {
  1548. + reg_val |= 0x1;
  1549. + writel(reg_val, hpriv->mmio + HOST_PORTS_IMPL);
  1550. + }
  1551. +
  1552. + reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
  1553. + writel(reg_val, hpriv->mmio + IMX_TIMER1MS);
  1554. +
  1555. + ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info,
  1556. + 0, 0, 0);
  1557. + if (ret)
  1558. + goto disable_sata;
  1559. +
  1560. + return 0;
  1561. +
  1562. +disable_sata:
  1563. + imx_sata_disable(hpriv);
  1564. +disable_clk:
  1565. + clk_disable_unprepare(imxpriv->sata_clk);
  1566. + return ret;
  1567. +}
  1568. +
  1569. +static void ahci_imx_host_stop(struct ata_host *host)
  1570. +{
  1571. + struct ahci_host_priv *hpriv = host->private_data;
  1572. + struct imx_ahci_priv *imxpriv = hpriv->plat_data;
  1573. +
  1574. + imx_sata_disable(hpriv);
  1575. + clk_disable_unprepare(imxpriv->sata_clk);
  1576. +}
  1577. +
  1578. +#ifdef CONFIG_PM_SLEEP
  1579. +static int imx_ahci_suspend(struct device *dev)
  1580. +{
  1581. + struct ata_host *host = dev_get_drvdata(dev);
  1582. + struct ahci_host_priv *hpriv = host->private_data;
  1583. + int ret;
  1584. +
  1585. + ret = ahci_platform_suspend_host(dev);
  1586. + if (ret)
  1587. + return ret;
  1588. +
  1589. + imx_sata_disable(hpriv);
  1590. +
  1591. + return 0;
  1592. +}
  1593. +
  1594. +static int imx_ahci_resume(struct device *dev)
  1595. +{
  1596. + struct ata_host *host = dev_get_drvdata(dev);
  1597. + struct ahci_host_priv *hpriv = host->private_data;
  1598. + int ret;
  1599. +
  1600. + ret = imx_sata_enable(hpriv);
  1601. + if (ret)
  1602. + return ret;
  1603. +
  1604. + return ahci_platform_resume_host(dev);
  1605. +}
  1606. +#endif
  1607. +
  1608. +static SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume);
  1609. +
  1610. +static struct platform_driver imx_ahci_driver = {
  1611. + .probe = imx_ahci_probe,
  1612. + .remove = ata_platform_remove_one,
  1613. + .driver = {
  1614. + .name = "ahci-imx",
  1615. + .owner = THIS_MODULE,
  1616. + .of_match_table = imx_ahci_of_match,
  1617. + .pm = &ahci_imx_pm_ops,
  1618. + },
  1619. +};
  1620. +module_platform_driver(imx_ahci_driver);
  1621. +
  1622. +MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver");
  1623. +MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@freescale.com>");
  1624. +MODULE_LICENSE("GPL");
  1625. +MODULE_ALIAS("ahci:imx");
  1626. diff -Nur linux-3.16.6.orig/drivers/cec/cec-dev.c linux-3.16.6/drivers/cec/cec-dev.c
  1627. --- linux-3.16.6.orig/drivers/cec/cec-dev.c 1969-12-31 18:00:00.000000000 -0600
  1628. +++ linux-3.16.6/drivers/cec/cec-dev.c 2014-10-23 12:37:18.374219998 -0500
  1629. @@ -0,0 +1,384 @@
  1630. +/*
  1631. + * HDMI Consumer Electronics Control
  1632. + *
  1633. + * This provides the user API for communication with HDMI CEC complaint
  1634. + * devices in kernel drivers, and is based upon the protocol developed
  1635. + * by Freescale for their i.MX SoCs.
  1636. + *
  1637. + * This program is free software; you can redistribute it and/or modify
  1638. + * it under the terms of the GNU General Public License version 2 as
  1639. + * published by the Free Software Foundation.
  1640. + */
  1641. +#include <linux/cec-dev.h>
  1642. +#include <linux/device.h>
  1643. +#include <linux/fs.h>
  1644. +#include <linux/module.h>
  1645. +#include <linux/poll.h>
  1646. +#include <linux/sched.h>
  1647. +#include <linux/slab.h>
  1648. +
  1649. +struct cec_event {
  1650. + struct cec_user_event usr;
  1651. + struct list_head node;
  1652. +};
  1653. +
  1654. +static struct class *cec_class;
  1655. +static int cec_major;
  1656. +
  1657. +static void cec_dev_send_message(struct cec_dev *cec_dev, u8 *msg,
  1658. + size_t count)
  1659. +{
  1660. + unsigned long flags;
  1661. +
  1662. + spin_lock_irqsave(&cec_dev->lock, flags);
  1663. + cec_dev->retries = 5;
  1664. + cec_dev->write_busy = 1;
  1665. + cec_dev->send_message(cec_dev, msg, count);
  1666. + spin_unlock_irqrestore(&cec_dev->lock, flags);
  1667. +}
  1668. +
  1669. +void cec_dev_event(struct cec_dev *cec_dev, int type, u8 *msg, size_t len)
  1670. +{
  1671. + struct cec_event *event;
  1672. + unsigned long flags;
  1673. +
  1674. + event = kzalloc(sizeof(*event), GFP_ATOMIC);
  1675. + if (event) {
  1676. + event->usr.event_type = type;
  1677. + event->usr.msg_len = len;
  1678. + if (msg)
  1679. + memcpy(event->usr.msg, msg, len);
  1680. +
  1681. + spin_lock_irqsave(&cec_dev->lock, flags);
  1682. + list_add_tail(&event->node, &cec_dev->events);
  1683. + spin_unlock_irqrestore(&cec_dev->lock, flags);
  1684. + wake_up(&cec_dev->waitq);
  1685. + }
  1686. +}
  1687. +EXPORT_SYMBOL_GPL(cec_dev_event);
  1688. +
  1689. +static int cec_dev_lock_write(struct cec_dev *cec_dev, struct file *file)
  1690. + __acquires(cec_dev->mutex)
  1691. +{
  1692. + int ret;
  1693. +
  1694. + do {
  1695. + if (file->f_flags & O_NONBLOCK) {
  1696. + if (cec_dev->write_busy)
  1697. + return -EAGAIN;
  1698. + } else {
  1699. + ret = wait_event_interruptible(cec_dev->waitq,
  1700. + !cec_dev->write_busy);
  1701. + if (ret)
  1702. + break;
  1703. + }
  1704. +
  1705. + ret = mutex_lock_interruptible(&cec_dev->mutex);
  1706. + if (ret)
  1707. + break;
  1708. +
  1709. + if (!cec_dev->write_busy)
  1710. + break;
  1711. +
  1712. + mutex_unlock(&cec_dev->mutex);
  1713. + } while (1);
  1714. +
  1715. + return ret;
  1716. +}
  1717. +
  1718. +static ssize_t cec_dev_read(struct file *file, char __user *buf,
  1719. + size_t count, loff_t *ppos)
  1720. +{
  1721. + struct cec_dev *cec_dev = file->private_data;
  1722. + ssize_t ret;
  1723. +
  1724. + if (count > sizeof(struct cec_user_event))
  1725. + count = sizeof(struct cec_user_event);
  1726. +
  1727. + if (!access_ok(VERIFY_WRITE, buf, count))
  1728. + return -EFAULT;
  1729. +
  1730. + do {
  1731. + struct cec_event *event = NULL;
  1732. + unsigned long flags;
  1733. +
  1734. + spin_lock_irqsave(&cec_dev->lock, flags);
  1735. + if (!list_empty(&cec_dev->events)) {
  1736. + event = list_first_entry(&cec_dev->events,
  1737. + struct cec_event, node);
  1738. + list_del(&event->node);
  1739. + }
  1740. + spin_unlock_irqrestore(&cec_dev->lock, flags);
  1741. +
  1742. + if (event) {
  1743. + ret = __copy_to_user(buf, &event->usr, count) ?
  1744. + -EFAULT : count;
  1745. + kfree(event);
  1746. + break;
  1747. + }
  1748. +
  1749. + if (file->f_flags & O_NONBLOCK) {
  1750. + ret = -EAGAIN;
  1751. + break;
  1752. + }
  1753. +
  1754. + ret = wait_event_interruptible(cec_dev->waitq,
  1755. + !list_empty(&cec_dev->events));
  1756. + if (ret)
  1757. + break;
  1758. + } while (1);
  1759. +
  1760. + return ret;
  1761. +}
  1762. +
  1763. +static ssize_t cec_dev_write(struct file *file, const char __user *buf,
  1764. + size_t count, loff_t *ppos)
  1765. +{
  1766. + struct cec_dev *cec_dev = file->private_data;
  1767. + u8 msg[MAX_MESSAGE_LEN];
  1768. + int ret;
  1769. +
  1770. + if (count > sizeof(msg))
  1771. + return -E2BIG;
  1772. +
  1773. + if (copy_from_user(msg, buf, count))
  1774. + return -EFAULT;
  1775. +
  1776. + ret = cec_dev_lock_write(cec_dev, file);
  1777. + if (ret)
  1778. + return ret;
  1779. +
  1780. + cec_dev_send_message(cec_dev, msg, count);
  1781. +
  1782. + mutex_unlock(&cec_dev->mutex);
  1783. +
  1784. + return count;
  1785. +}
  1786. +
  1787. +static long cec_dev_ioctl(struct file *file, u_int cmd, unsigned long arg)
  1788. +{
  1789. + struct cec_dev *cec_dev = file->private_data;
  1790. + int ret;
  1791. +
  1792. + switch (cmd) {
  1793. + case HDMICEC_IOC_O_SETLOGICALADDRESS:
  1794. + case HDMICEC_IOC_SETLOGICALADDRESS:
  1795. + if (arg > 15) {
  1796. + ret = -EINVAL;
  1797. + break;
  1798. + }
  1799. +
  1800. + ret = cec_dev_lock_write(cec_dev, file);
  1801. + if (ret == 0) {
  1802. + unsigned char msg[1];
  1803. +
  1804. + cec_dev->addresses = BIT(arg);
  1805. + cec_dev->set_address(cec_dev, cec_dev->addresses);
  1806. +
  1807. + /*
  1808. + * Send a ping message with the source and destination
  1809. + * set to our address; the result indicates whether
  1810. + * unit has chosen our address simultaneously.
  1811. + */
  1812. + msg[0] = arg << 4 | arg;
  1813. + cec_dev_send_message(cec_dev, msg, sizeof(msg));
  1814. + mutex_unlock(&cec_dev->mutex);
  1815. + }
  1816. + break;
  1817. +
  1818. + case HDMICEC_IOC_STARTDEVICE:
  1819. + ret = mutex_lock_interruptible(&cec_dev->mutex);
  1820. + if (ret == 0) {
  1821. + cec_dev->addresses = BIT(15);
  1822. + cec_dev->set_address(cec_dev, cec_dev->addresses);
  1823. + mutex_unlock(&cec_dev->mutex);
  1824. + }
  1825. + break;
  1826. +
  1827. + case HDMICEC_IOC_STOPDEVICE:
  1828. + ret = 0;
  1829. + break;
  1830. +
  1831. + case HDMICEC_IOC_GETPHYADDRESS:
  1832. + ret = put_user(cec_dev->physical, (u16 __user *)arg);
  1833. + ret = -ENOIOCTLCMD;
  1834. + break;
  1835. +
  1836. + default:
  1837. + ret = -ENOIOCTLCMD;
  1838. + break;
  1839. + }
  1840. +
  1841. + return ret;
  1842. +}
  1843. +
  1844. +static unsigned cec_dev_poll(struct file *file, poll_table *wait)
  1845. +{
  1846. + struct cec_dev *cec_dev = file->private_data;
  1847. + unsigned mask = 0;
  1848. +
  1849. + poll_wait(file, &cec_dev->waitq, wait);
  1850. +
  1851. + if (cec_dev->write_busy == 0)
  1852. + mask |= POLLOUT | POLLWRNORM;
  1853. + if (!list_empty(&cec_dev->events))
  1854. + mask |= POLLIN | POLLRDNORM;
  1855. +
  1856. + return mask;
  1857. +}
  1858. +
  1859. +static int cec_dev_release(struct inode *inode, struct file *file)
  1860. +{
  1861. + struct cec_dev *cec_dev = file->private_data;
  1862. +
  1863. + mutex_lock(&cec_dev->mutex);
  1864. + if (cec_dev->users >= 1)
  1865. + cec_dev->users -= 1;
  1866. + if (cec_dev->users == 0) {
  1867. + /*
  1868. + * Wait for any write to complete before shutting down.
  1869. + * A message should complete in a maximum of 2.75ms *
  1870. + * 160 bits + 4.7ms, or 444.7ms. Let's call that 500ms.
  1871. + * If we time out, shutdown anyway.
  1872. + */
  1873. + wait_event_timeout(cec_dev->waitq, !cec_dev->write_busy,
  1874. + msecs_to_jiffies(500));
  1875. +
  1876. + cec_dev->release(cec_dev);
  1877. +
  1878. + while (!list_empty(&cec_dev->events)) {
  1879. + struct cec_event *event;
  1880. +
  1881. + event = list_first_entry(&cec_dev->events,
  1882. + struct cec_event, node);
  1883. + list_del(&event->node);
  1884. + kfree(event);
  1885. + }
  1886. + }
  1887. + mutex_unlock(&cec_dev->mutex);
  1888. + return 0;
  1889. +}
  1890. +
  1891. +static int cec_dev_open(struct inode *inode, struct file *file)
  1892. +{
  1893. + struct cec_dev *cec_dev = container_of(inode->i_cdev, struct cec_dev,
  1894. + cdev);
  1895. + int ret = 0;
  1896. +
  1897. + nonseekable_open(inode, file);
  1898. +
  1899. + file->private_data = cec_dev;
  1900. +
  1901. + ret = mutex_lock_interruptible(&cec_dev->mutex);
  1902. + if (ret)
  1903. + return ret;
  1904. +
  1905. + if (cec_dev->users++ == 0) {
  1906. + cec_dev->addresses = BIT(15);
  1907. +
  1908. + ret = cec_dev->open(cec_dev);
  1909. + if (ret < 0)
  1910. + cec_dev->users = 0;
  1911. + }
  1912. + mutex_unlock(&cec_dev->mutex);
  1913. +
  1914. + return ret;
  1915. +}
  1916. +
  1917. +static const struct file_operations hdmi_cec_fops = {
  1918. + .owner = THIS_MODULE,
  1919. + .read = cec_dev_read,
  1920. + .write = cec_dev_write,
  1921. + .open = cec_dev_open,
  1922. + .unlocked_ioctl = cec_dev_ioctl,
  1923. + .release = cec_dev_release,
  1924. + .poll = cec_dev_poll,
  1925. +};
  1926. +
  1927. +void cec_dev_init(struct cec_dev *cec_dev, struct module *module)
  1928. +{
  1929. + cec_dev->devn = MKDEV(cec_major, 0);
  1930. +
  1931. + INIT_LIST_HEAD(&cec_dev->events);
  1932. + init_waitqueue_head(&cec_dev->waitq);
  1933. + spin_lock_init(&cec_dev->lock);
  1934. + mutex_init(&cec_dev->mutex);
  1935. +
  1936. + cec_dev->addresses = BIT(15);
  1937. +
  1938. + cdev_init(&cec_dev->cdev, &hdmi_cec_fops);
  1939. + cec_dev->cdev.owner = module;
  1940. +}
  1941. +EXPORT_SYMBOL_GPL(cec_dev_init);
  1942. +
  1943. +int cec_dev_add(struct cec_dev *cec_dev, struct device *dev, const char *name)
  1944. +{
  1945. + struct device *cd;
  1946. + int ret;
  1947. +
  1948. + ret = cdev_add(&cec_dev->cdev, cec_dev->devn, 1);
  1949. + if (ret < 0)
  1950. + goto err_cdev;
  1951. +
  1952. + cd = device_create(cec_class, dev, cec_dev->devn, NULL, name);
  1953. + if (IS_ERR(cd)) {
  1954. + ret = PTR_ERR(cd);
  1955. + dev_err(dev, "can't create device: %d\n", ret);
  1956. + goto err_dev;
  1957. + }
  1958. +
  1959. + return 0;
  1960. +
  1961. + err_dev:
  1962. + cdev_del(&cec_dev->cdev);
  1963. + err_cdev:
  1964. + return ret;
  1965. +}
  1966. +EXPORT_SYMBOL_GPL(cec_dev_add);
  1967. +
  1968. +void cec_dev_remove(struct cec_dev *cec_dev)
  1969. +{
  1970. + device_destroy(cec_class, cec_dev->devn);
  1971. + cdev_del(&cec_dev->cdev);
  1972. +}
  1973. +EXPORT_SYMBOL_GPL(cec_dev_remove);
  1974. +
  1975. +static int cec_init(void)
  1976. +{
  1977. + dev_t dev;
  1978. + int ret;
  1979. +
  1980. + cec_class = class_create(THIS_MODULE, "hdmi-cec");
  1981. + if (IS_ERR(cec_class)) {
  1982. + ret = PTR_ERR(cec_class);
  1983. + pr_err("cec: can't create cec class: %d\n", ret);
  1984. + goto err_class;
  1985. + }
  1986. +
  1987. + ret = alloc_chrdev_region(&dev, 0, 1, "hdmi-cec");
  1988. + if (ret) {
  1989. + pr_err("cec: can't create character devices: %d\n", ret);
  1990. + goto err_chrdev;
  1991. + }
  1992. +
  1993. + cec_major = MAJOR(dev);
  1994. +
  1995. + return 0;
  1996. +
  1997. + err_chrdev:
  1998. + class_destroy(cec_class);
  1999. + err_class:
  2000. + return ret;
  2001. +}
  2002. +subsys_initcall(cec_init);
  2003. +
  2004. +static void cec_exit(void)
  2005. +{
  2006. + unregister_chrdev_region(MKDEV(cec_major, 0), 1);
  2007. + class_destroy(cec_class);
  2008. +}
  2009. +module_exit(cec_exit);
  2010. +
  2011. +MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
  2012. +MODULE_DESCRIPTION("Generic HDMI CEC driver");
  2013. +MODULE_LICENSE("GPL");
  2014. diff -Nur linux-3.16.6.orig/drivers/cec/Kconfig linux-3.16.6/drivers/cec/Kconfig
  2015. --- linux-3.16.6.orig/drivers/cec/Kconfig 1969-12-31 18:00:00.000000000 -0600
  2016. +++ linux-3.16.6/drivers/cec/Kconfig 2014-10-23 12:37:18.350220009 -0500
  2017. @@ -0,0 +1,14 @@
  2018. +#
  2019. +# Consumer Electroncs Control support
  2020. +#
  2021. +
  2022. +menu "Consumer Electronics Control devices"
  2023. +
  2024. +config CEC
  2025. + bool
  2026. +
  2027. +config HDMI_CEC_CORE
  2028. + tristate
  2029. + select CEC
  2030. +
  2031. +endmenu
  2032. diff -Nur linux-3.16.6.orig/drivers/cec/Makefile linux-3.16.6/drivers/cec/Makefile
  2033. --- linux-3.16.6.orig/drivers/cec/Makefile 1969-12-31 18:00:00.000000000 -0600
  2034. +++ linux-3.16.6/drivers/cec/Makefile 2014-10-23 12:37:18.374219998 -0500
  2035. @@ -0,0 +1 @@
  2036. +obj-$(CONFIG_HDMI_CEC_CORE) += cec-dev.o
  2037. diff -Nur linux-3.16.6.orig/drivers/dma/imx-sdma.c linux-3.16.6/drivers/dma/imx-sdma.c
  2038. --- linux-3.16.6.orig/drivers/dma/imx-sdma.c 2014-10-15 05:05:43.000000000 -0500
  2039. +++ linux-3.16.6/drivers/dma/imx-sdma.c 2014-10-23 12:35:52.990220019 -0500
  2040. @@ -255,7 +255,6 @@
  2041. enum dma_slave_buswidth word_size;
  2042. unsigned int buf_tail;
  2043. unsigned int num_bd;
  2044. - unsigned int period_len;
  2045. struct sdma_buffer_descriptor *bd;
  2046. dma_addr_t bd_phys;
  2047. unsigned int pc_from_device, pc_to_device;
  2048. @@ -594,12 +593,6 @@
  2049. static void sdma_handle_channel_loop(struct sdma_channel *sdmac)
  2050. {
  2051. - if (sdmac->desc.callback)
  2052. - sdmac->desc.callback(sdmac->desc.callback_param);
  2053. -}
  2054. -
  2055. -static void sdma_update_channel_loop(struct sdma_channel *sdmac)
  2056. -{
  2057. struct sdma_buffer_descriptor *bd;
  2058. /*
  2059. @@ -618,6 +611,9 @@
  2060. bd->mode.status |= BD_DONE;
  2061. sdmac->buf_tail++;
  2062. sdmac->buf_tail %= sdmac->num_bd;
  2063. +
  2064. + if (sdmac->desc.callback)
  2065. + sdmac->desc.callback(sdmac->desc.callback_param);
  2066. }
  2067. }
  2068. @@ -673,9 +669,6 @@
  2069. int channel = fls(stat) - 1;
  2070. struct sdma_channel *sdmac = &sdma->channel[channel];
  2071. - if (sdmac->flags & IMX_DMA_SG_LOOP)
  2072. - sdma_update_channel_loop(sdmac);
  2073. -
  2074. tasklet_schedule(&sdmac->tasklet);
  2075. __clear_bit(channel, &stat);
  2076. @@ -1136,7 +1129,6 @@
  2077. sdmac->status = DMA_IN_PROGRESS;
  2078. sdmac->buf_tail = 0;
  2079. - sdmac->period_len = period_len;
  2080. sdmac->flags |= IMX_DMA_SG_LOOP;
  2081. sdmac->direction = direction;
  2082. @@ -1233,15 +1225,9 @@
  2083. struct dma_tx_state *txstate)
  2084. {
  2085. struct sdma_channel *sdmac = to_sdma_chan(chan);
  2086. - u32 residue;
  2087. -
  2088. - if (sdmac->flags & IMX_DMA_SG_LOOP)
  2089. - residue = (sdmac->num_bd - sdmac->buf_tail) * sdmac->period_len;
  2090. - else
  2091. - residue = sdmac->chn_count - sdmac->chn_real_count;
  2092. dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
  2093. - residue);
  2094. + sdmac->chn_count - sdmac->chn_real_count);
  2095. return sdmac->status;
  2096. }
  2097. diff -Nur linux-3.16.6.orig/drivers/dma/imx-sdma.c.orig linux-3.16.6/drivers/dma/imx-sdma.c.orig
  2098. --- linux-3.16.6.orig/drivers/dma/imx-sdma.c.orig 1969-12-31 18:00:00.000000000 -0600
  2099. +++ linux-3.16.6/drivers/dma/imx-sdma.c.orig 2014-10-15 05:05:43.000000000 -0500
  2100. @@ -0,0 +1,1656 @@
  2101. +/*
  2102. + * drivers/dma/imx-sdma.c
  2103. + *
  2104. + * This file contains a driver for the Freescale Smart DMA engine
  2105. + *
  2106. + * Copyright 2010 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
  2107. + *
  2108. + * Based on code from Freescale:
  2109. + *
  2110. + * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
  2111. + *
  2112. + * The code contained herein is licensed under the GNU General Public
  2113. + * License. You may obtain a copy of the GNU General Public License
  2114. + * Version 2 or later at the following locations:
  2115. + *
  2116. + * http://www.opensource.org/licenses/gpl-license.html
  2117. + * http://www.gnu.org/copyleft/gpl.html
  2118. + */
  2119. +
  2120. +#include <linux/init.h>
  2121. +#include <linux/module.h>
  2122. +#include <linux/types.h>
  2123. +#include <linux/bitops.h>
  2124. +#include <linux/mm.h>
  2125. +#include <linux/interrupt.h>
  2126. +#include <linux/clk.h>
  2127. +#include <linux/delay.h>
  2128. +#include <linux/sched.h>
  2129. +#include <linux/semaphore.h>
  2130. +#include <linux/spinlock.h>
  2131. +#include <linux/device.h>
  2132. +#include <linux/dma-mapping.h>
  2133. +#include <linux/firmware.h>
  2134. +#include <linux/slab.h>
  2135. +#include <linux/platform_device.h>
  2136. +#include <linux/dmaengine.h>
  2137. +#include <linux/of.h>
  2138. +#include <linux/of_device.h>
  2139. +#include <linux/of_dma.h>
  2140. +
  2141. +#include <asm/irq.h>
  2142. +#include <linux/platform_data/dma-imx-sdma.h>
  2143. +#include <linux/platform_data/dma-imx.h>
  2144. +
  2145. +#include "dmaengine.h"
  2146. +
  2147. +/* SDMA registers */
  2148. +#define SDMA_H_C0PTR 0x000
  2149. +#define SDMA_H_INTR 0x004
  2150. +#define SDMA_H_STATSTOP 0x008
  2151. +#define SDMA_H_START 0x00c
  2152. +#define SDMA_H_EVTOVR 0x010
  2153. +#define SDMA_H_DSPOVR 0x014
  2154. +#define SDMA_H_HOSTOVR 0x018
  2155. +#define SDMA_H_EVTPEND 0x01c
  2156. +#define SDMA_H_DSPENBL 0x020
  2157. +#define SDMA_H_RESET 0x024
  2158. +#define SDMA_H_EVTERR 0x028
  2159. +#define SDMA_H_INTRMSK 0x02c
  2160. +#define SDMA_H_PSW 0x030
  2161. +#define SDMA_H_EVTERRDBG 0x034
  2162. +#define SDMA_H_CONFIG 0x038
  2163. +#define SDMA_ONCE_ENB 0x040
  2164. +#define SDMA_ONCE_DATA 0x044
  2165. +#define SDMA_ONCE_INSTR 0x048
  2166. +#define SDMA_ONCE_STAT 0x04c
  2167. +#define SDMA_ONCE_CMD 0x050
  2168. +#define SDMA_EVT_MIRROR 0x054
  2169. +#define SDMA_ILLINSTADDR 0x058
  2170. +#define SDMA_CHN0ADDR 0x05c
  2171. +#define SDMA_ONCE_RTB 0x060
  2172. +#define SDMA_XTRIG_CONF1 0x070
  2173. +#define SDMA_XTRIG_CONF2 0x074
  2174. +#define SDMA_CHNENBL0_IMX35 0x200
  2175. +#define SDMA_CHNENBL0_IMX31 0x080
  2176. +#define SDMA_CHNPRI_0 0x100
  2177. +
  2178. +/*
  2179. + * Buffer descriptor status values.
  2180. + */
  2181. +#define BD_DONE 0x01
  2182. +#define BD_WRAP 0x02
  2183. +#define BD_CONT 0x04
  2184. +#define BD_INTR 0x08
  2185. +#define BD_RROR 0x10
  2186. +#define BD_LAST 0x20
  2187. +#define BD_EXTD 0x80
  2188. +
  2189. +/*
  2190. + * Data Node descriptor status values.
  2191. + */
  2192. +#define DND_END_OF_FRAME 0x80
  2193. +#define DND_END_OF_XFER 0x40
  2194. +#define DND_DONE 0x20
  2195. +#define DND_UNUSED 0x01
  2196. +
  2197. +/*
  2198. + * IPCV2 descriptor status values.
  2199. + */
  2200. +#define BD_IPCV2_END_OF_FRAME 0x40
  2201. +
  2202. +#define IPCV2_MAX_NODES 50
  2203. +/*
  2204. + * Error bit set in the CCB status field by the SDMA,
  2205. + * in setbd routine, in case of a transfer error
  2206. + */
  2207. +#define DATA_ERROR 0x10000000
  2208. +
  2209. +/*
  2210. + * Buffer descriptor commands.
  2211. + */
  2212. +#define C0_ADDR 0x01
  2213. +#define C0_LOAD 0x02
  2214. +#define C0_DUMP 0x03
  2215. +#define C0_SETCTX 0x07
  2216. +#define C0_GETCTX 0x03
  2217. +#define C0_SETDM 0x01
  2218. +#define C0_SETPM 0x04
  2219. +#define C0_GETDM 0x02
  2220. +#define C0_GETPM 0x08
  2221. +/*
  2222. + * Change endianness indicator in the BD command field
  2223. + */
  2224. +#define CHANGE_ENDIANNESS 0x80
  2225. +
  2226. +/*
  2227. + * Mode/Count of data node descriptors - IPCv2
  2228. + */
  2229. +struct sdma_mode_count {
  2230. + u32 count : 16; /* size of the buffer pointed by this BD */
  2231. + u32 status : 8; /* E,R,I,C,W,D status bits stored here */
  2232. + u32 command : 8; /* command mostlky used for channel 0 */
  2233. +};
  2234. +
  2235. +/*
  2236. + * Buffer descriptor
  2237. + */
  2238. +struct sdma_buffer_descriptor {
  2239. + struct sdma_mode_count mode;
  2240. + u32 buffer_addr; /* address of the buffer described */
  2241. + u32 ext_buffer_addr; /* extended buffer address */
  2242. +} __attribute__ ((packed));
  2243. +
  2244. +/**
  2245. + * struct sdma_channel_control - Channel control Block
  2246. + *
  2247. + * @current_bd_ptr current buffer descriptor processed
  2248. + * @base_bd_ptr first element of buffer descriptor array
  2249. + * @unused padding. The SDMA engine expects an array of 128 byte
  2250. + * control blocks
  2251. + */
  2252. +struct sdma_channel_control {
  2253. + u32 current_bd_ptr;
  2254. + u32 base_bd_ptr;
  2255. + u32 unused[2];
  2256. +} __attribute__ ((packed));
  2257. +
  2258. +/**
  2259. + * struct sdma_state_registers - SDMA context for a channel
  2260. + *
  2261. + * @pc: program counter
  2262. + * @t: test bit: status of arithmetic & test instruction
  2263. + * @rpc: return program counter
  2264. + * @sf: source fault while loading data
  2265. + * @spc: loop start program counter
  2266. + * @df: destination fault while storing data
  2267. + * @epc: loop end program counter
  2268. + * @lm: loop mode
  2269. + */
  2270. +struct sdma_state_registers {
  2271. + u32 pc :14;
  2272. + u32 unused1: 1;
  2273. + u32 t : 1;
  2274. + u32 rpc :14;
  2275. + u32 unused0: 1;
  2276. + u32 sf : 1;
  2277. + u32 spc :14;
  2278. + u32 unused2: 1;
  2279. + u32 df : 1;
  2280. + u32 epc :14;
  2281. + u32 lm : 2;
  2282. +} __attribute__ ((packed));
  2283. +
  2284. +/**
  2285. + * struct sdma_context_data - sdma context specific to a channel
  2286. + *
  2287. + * @channel_state: channel state bits
  2288. + * @gReg: general registers
  2289. + * @mda: burst dma destination address register
  2290. + * @msa: burst dma source address register
  2291. + * @ms: burst dma status register
  2292. + * @md: burst dma data register
  2293. + * @pda: peripheral dma destination address register
  2294. + * @psa: peripheral dma source address register
  2295. + * @ps: peripheral dma status register
  2296. + * @pd: peripheral dma data register
  2297. + * @ca: CRC polynomial register
  2298. + * @cs: CRC accumulator register
  2299. + * @dda: dedicated core destination address register
  2300. + * @dsa: dedicated core source address register
  2301. + * @ds: dedicated core status register
  2302. + * @dd: dedicated core data register
  2303. + */
  2304. +struct sdma_context_data {
  2305. + struct sdma_state_registers channel_state;
  2306. + u32 gReg[8];
  2307. + u32 mda;
  2308. + u32 msa;
  2309. + u32 ms;
  2310. + u32 md;
  2311. + u32 pda;
  2312. + u32 psa;
  2313. + u32 ps;
  2314. + u32 pd;
  2315. + u32 ca;
  2316. + u32 cs;
  2317. + u32 dda;
  2318. + u32 dsa;
  2319. + u32 ds;
  2320. + u32 dd;
  2321. + u32 scratch0;
  2322. + u32 scratch1;
  2323. + u32 scratch2;
  2324. + u32 scratch3;
  2325. + u32 scratch4;
  2326. + u32 scratch5;
  2327. + u32 scratch6;
  2328. + u32 scratch7;
  2329. +} __attribute__ ((packed));
  2330. +
  2331. +#define NUM_BD (int)(PAGE_SIZE / sizeof(struct sdma_buffer_descriptor))
  2332. +
  2333. +struct sdma_engine;
  2334. +
  2335. +/**
  2336. + * struct sdma_channel - housekeeping for a SDMA channel
  2337. + *
  2338. + * @sdma pointer to the SDMA engine for this channel
  2339. + * @channel the channel number, matches dmaengine chan_id + 1
  2340. + * @direction transfer type. Needed for setting SDMA script
  2341. + * @peripheral_type Peripheral type. Needed for setting SDMA script
  2342. + * @event_id0 aka dma request line
  2343. + * @event_id1 for channels that use 2 events
  2344. + * @word_size peripheral access size
  2345. + * @buf_tail ID of the buffer that was processed
  2346. + * @num_bd max NUM_BD. number of descriptors currently handling
  2347. + */
  2348. +struct sdma_channel {
  2349. + struct sdma_engine *sdma;
  2350. + unsigned int channel;
  2351. + enum dma_transfer_direction direction;
  2352. + enum sdma_peripheral_type peripheral_type;
  2353. + unsigned int event_id0;
  2354. + unsigned int event_id1;
  2355. + enum dma_slave_buswidth word_size;
  2356. + unsigned int buf_tail;
  2357. + unsigned int num_bd;
  2358. + unsigned int period_len;
  2359. + struct sdma_buffer_descriptor *bd;
  2360. + dma_addr_t bd_phys;
  2361. + unsigned int pc_from_device, pc_to_device;
  2362. + unsigned long flags;
  2363. + dma_addr_t per_address;
  2364. + unsigned long event_mask[2];
  2365. + unsigned long watermark_level;
  2366. + u32 shp_addr, per_addr;
  2367. + struct dma_chan chan;
  2368. + spinlock_t lock;
  2369. + struct dma_async_tx_descriptor desc;
  2370. + enum dma_status status;
  2371. + unsigned int chn_count;
  2372. + unsigned int chn_real_count;
  2373. + struct tasklet_struct tasklet;
  2374. +};
  2375. +
  2376. +#define IMX_DMA_SG_LOOP BIT(0)
  2377. +
  2378. +#define MAX_DMA_CHANNELS 32
  2379. +#define MXC_SDMA_DEFAULT_PRIORITY 1
  2380. +#define MXC_SDMA_MIN_PRIORITY 1
  2381. +#define MXC_SDMA_MAX_PRIORITY 7
  2382. +
  2383. +#define SDMA_FIRMWARE_MAGIC 0x414d4453
  2384. +
  2385. +/**
  2386. + * struct sdma_firmware_header - Layout of the firmware image
  2387. + *
  2388. + * @magic "SDMA"
  2389. + * @version_major increased whenever layout of struct sdma_script_start_addrs
  2390. + * changes.
  2391. + * @version_minor firmware minor version (for binary compatible changes)
  2392. + * @script_addrs_start offset of struct sdma_script_start_addrs in this image
  2393. + * @num_script_addrs Number of script addresses in this image
  2394. + * @ram_code_start offset of SDMA ram image in this firmware image
  2395. + * @ram_code_size size of SDMA ram image
  2396. + * @script_addrs Stores the start address of the SDMA scripts
  2397. + * (in SDMA memory space)
  2398. + */
  2399. +struct sdma_firmware_header {
  2400. + u32 magic;
  2401. + u32 version_major;
  2402. + u32 version_minor;
  2403. + u32 script_addrs_start;
  2404. + u32 num_script_addrs;
  2405. + u32 ram_code_start;
  2406. + u32 ram_code_size;
  2407. +};
  2408. +
  2409. +struct sdma_driver_data {
  2410. + int chnenbl0;
  2411. + int num_events;
  2412. + struct sdma_script_start_addrs *script_addrs;
  2413. +};
  2414. +
  2415. +struct sdma_engine {
  2416. + struct device *dev;
  2417. + struct device_dma_parameters dma_parms;
  2418. + struct sdma_channel channel[MAX_DMA_CHANNELS];
  2419. + struct sdma_channel_control *channel_control;
  2420. + void __iomem *regs;
  2421. + struct sdma_context_data *context;
  2422. + dma_addr_t context_phys;
  2423. + struct dma_device dma_device;
  2424. + struct clk *clk_ipg;
  2425. + struct clk *clk_ahb;
  2426. + spinlock_t channel_0_lock;
  2427. + u32 script_number;
  2428. + struct sdma_script_start_addrs *script_addrs;
  2429. + const struct sdma_driver_data *drvdata;
  2430. +};
  2431. +
  2432. +static struct sdma_driver_data sdma_imx31 = {
  2433. + .chnenbl0 = SDMA_CHNENBL0_IMX31,
  2434. + .num_events = 32,
  2435. +};
  2436. +
  2437. +static struct sdma_script_start_addrs sdma_script_imx25 = {
  2438. + .ap_2_ap_addr = 729,
  2439. + .uart_2_mcu_addr = 904,
  2440. + .per_2_app_addr = 1255,
  2441. + .mcu_2_app_addr = 834,
  2442. + .uartsh_2_mcu_addr = 1120,
  2443. + .per_2_shp_addr = 1329,
  2444. + .mcu_2_shp_addr = 1048,
  2445. + .ata_2_mcu_addr = 1560,
  2446. + .mcu_2_ata_addr = 1479,
  2447. + .app_2_per_addr = 1189,
  2448. + .app_2_mcu_addr = 770,
  2449. + .shp_2_per_addr = 1407,
  2450. + .shp_2_mcu_addr = 979,
  2451. +};
  2452. +
  2453. +static struct sdma_driver_data sdma_imx25 = {
  2454. + .chnenbl0 = SDMA_CHNENBL0_IMX35,
  2455. + .num_events = 48,
  2456. + .script_addrs = &sdma_script_imx25,
  2457. +};
  2458. +
  2459. +static struct sdma_driver_data sdma_imx35 = {
  2460. + .chnenbl0 = SDMA_CHNENBL0_IMX35,
  2461. + .num_events = 48,
  2462. +};
  2463. +
  2464. +static struct sdma_script_start_addrs sdma_script_imx51 = {
  2465. + .ap_2_ap_addr = 642,
  2466. + .uart_2_mcu_addr = 817,
  2467. + .mcu_2_app_addr = 747,
  2468. + .mcu_2_shp_addr = 961,
  2469. + .ata_2_mcu_addr = 1473,
  2470. + .mcu_2_ata_addr = 1392,
  2471. + .app_2_per_addr = 1033,
  2472. + .app_2_mcu_addr = 683,
  2473. + .shp_2_per_addr = 1251,
  2474. + .shp_2_mcu_addr = 892,
  2475. +};
  2476. +
  2477. +static struct sdma_driver_data sdma_imx51 = {
  2478. + .chnenbl0 = SDMA_CHNENBL0_IMX35,
  2479. + .num_events = 48,
  2480. + .script_addrs = &sdma_script_imx51,
  2481. +};
  2482. +
  2483. +static struct sdma_script_start_addrs sdma_script_imx53 = {
  2484. + .ap_2_ap_addr = 642,
  2485. + .app_2_mcu_addr = 683,
  2486. + .mcu_2_app_addr = 747,
  2487. + .uart_2_mcu_addr = 817,
  2488. + .shp_2_mcu_addr = 891,
  2489. + .mcu_2_shp_addr = 960,
  2490. + .uartsh_2_mcu_addr = 1032,
  2491. + .spdif_2_mcu_addr = 1100,
  2492. + .mcu_2_spdif_addr = 1134,
  2493. + .firi_2_mcu_addr = 1193,
  2494. + .mcu_2_firi_addr = 1290,
  2495. +};
  2496. +
  2497. +static struct sdma_driver_data sdma_imx53 = {
  2498. + .chnenbl0 = SDMA_CHNENBL0_IMX35,
  2499. + .num_events = 48,
  2500. + .script_addrs = &sdma_script_imx53,
  2501. +};
  2502. +
  2503. +static struct sdma_script_start_addrs sdma_script_imx6q = {
  2504. + .ap_2_ap_addr = 642,
  2505. + .uart_2_mcu_addr = 817,
  2506. + .mcu_2_app_addr = 747,
  2507. + .per_2_per_addr = 6331,
  2508. + .uartsh_2_mcu_addr = 1032,
  2509. + .mcu_2_shp_addr = 960,
  2510. + .app_2_mcu_addr = 683,
  2511. + .shp_2_mcu_addr = 891,
  2512. + .spdif_2_mcu_addr = 1100,
  2513. + .mcu_2_spdif_addr = 1134,
  2514. +};
  2515. +
  2516. +static struct sdma_driver_data sdma_imx6q = {
  2517. + .chnenbl0 = SDMA_CHNENBL0_IMX35,
  2518. + .num_events = 48,
  2519. + .script_addrs = &sdma_script_imx6q,
  2520. +};
  2521. +
  2522. +static struct platform_device_id sdma_devtypes[] = {
  2523. + {
  2524. + .name = "imx25-sdma",
  2525. + .driver_data = (unsigned long)&sdma_imx25,
  2526. + }, {
  2527. + .name = "imx31-sdma",
  2528. + .driver_data = (unsigned long)&sdma_imx31,
  2529. + }, {
  2530. + .name = "imx35-sdma",
  2531. + .driver_data = (unsigned long)&sdma_imx35,
  2532. + }, {
  2533. + .name = "imx51-sdma",
  2534. + .driver_data = (unsigned long)&sdma_imx51,
  2535. + }, {
  2536. + .name = "imx53-sdma",
  2537. + .driver_data = (unsigned long)&sdma_imx53,
  2538. + }, {
  2539. + .name = "imx6q-sdma",
  2540. + .driver_data = (unsigned long)&sdma_imx6q,
  2541. + }, {
  2542. + /* sentinel */
  2543. + }
  2544. +};
  2545. +MODULE_DEVICE_TABLE(platform, sdma_devtypes);
  2546. +
  2547. +static const struct of_device_id sdma_dt_ids[] = {
  2548. + { .compatible = "fsl,imx6q-sdma", .data = &sdma_imx6q, },
  2549. + { .compatible = "fsl,imx53-sdma", .data = &sdma_imx53, },
  2550. + { .compatible = "fsl,imx51-sdma", .data = &sdma_imx51, },
  2551. + { .compatible = "fsl,imx35-sdma", .data = &sdma_imx35, },
  2552. + { .compatible = "fsl,imx31-sdma", .data = &sdma_imx31, },
  2553. + { .compatible = "fsl,imx25-sdma", .data = &sdma_imx25, },
  2554. + { /* sentinel */ }
  2555. +};
  2556. +MODULE_DEVICE_TABLE(of, sdma_dt_ids);
  2557. +
  2558. +#define SDMA_H_CONFIG_DSPDMA BIT(12) /* indicates if the DSPDMA is used */
  2559. +#define SDMA_H_CONFIG_RTD_PINS BIT(11) /* indicates if Real-Time Debug pins are enabled */
  2560. +#define SDMA_H_CONFIG_ACR BIT(4) /* indicates if AHB freq /core freq = 2 or 1 */
  2561. +#define SDMA_H_CONFIG_CSM (3) /* indicates which context switch mode is selected*/
  2562. +
  2563. +static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event)
  2564. +{
  2565. + u32 chnenbl0 = sdma->drvdata->chnenbl0;
  2566. + return chnenbl0 + event * 4;
  2567. +}
  2568. +
  2569. +static int sdma_config_ownership(struct sdma_channel *sdmac,
  2570. + bool event_override, bool mcu_override, bool dsp_override)
  2571. +{
  2572. + struct sdma_engine *sdma = sdmac->sdma;
  2573. + int channel = sdmac->channel;
  2574. + unsigned long evt, mcu, dsp;
  2575. +
  2576. + if (event_override && mcu_override && dsp_override)
  2577. + return -EINVAL;
  2578. +
  2579. + evt = readl_relaxed(sdma->regs + SDMA_H_EVTOVR);
  2580. + mcu = readl_relaxed(sdma->regs + SDMA_H_HOSTOVR);
  2581. + dsp = readl_relaxed(sdma->regs + SDMA_H_DSPOVR);
  2582. +
  2583. + if (dsp_override)
  2584. + __clear_bit(channel, &dsp);
  2585. + else
  2586. + __set_bit(channel, &dsp);
  2587. +
  2588. + if (event_override)
  2589. + __clear_bit(channel, &evt);
  2590. + else
  2591. + __set_bit(channel, &evt);
  2592. +
  2593. + if (mcu_override)
  2594. + __clear_bit(channel, &mcu);
  2595. + else
  2596. + __set_bit(channel, &mcu);
  2597. +
  2598. + writel_relaxed(evt, sdma->regs + SDMA_H_EVTOVR);
  2599. + writel_relaxed(mcu, sdma->regs + SDMA_H_HOSTOVR);
  2600. + writel_relaxed(dsp, sdma->regs + SDMA_H_DSPOVR);
  2601. +
  2602. + return 0;
  2603. +}
  2604. +
  2605. +static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
  2606. +{
  2607. + writel(BIT(channel), sdma->regs + SDMA_H_START);
  2608. +}
  2609. +
  2610. +/*
  2611. + * sdma_run_channel0 - run a channel and wait till it's done
  2612. + */
  2613. +static int sdma_run_channel0(struct sdma_engine *sdma)
  2614. +{
  2615. + int ret;
  2616. + unsigned long timeout = 500;
  2617. +
  2618. + sdma_enable_channel(sdma, 0);
  2619. +
  2620. + while (!(ret = readl_relaxed(sdma->regs + SDMA_H_INTR) & 1)) {
  2621. + if (timeout-- <= 0)
  2622. + break;
  2623. + udelay(1);
  2624. + }
  2625. +
  2626. + if (ret) {
  2627. + /* Clear the interrupt status */
  2628. + writel_relaxed(ret, sdma->regs + SDMA_H_INTR);
  2629. + } else {
  2630. + dev_err(sdma->dev, "Timeout waiting for CH0 ready\n");
  2631. + }
  2632. +
  2633. + return ret ? 0 : -ETIMEDOUT;
  2634. +}
  2635. +
  2636. +static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
  2637. + u32 address)
  2638. +{
  2639. + struct sdma_buffer_descriptor *bd0 = sdma->channel[0].bd;
  2640. + void *buf_virt;
  2641. + dma_addr_t buf_phys;
  2642. + int ret;
  2643. + unsigned long flags;
  2644. +
  2645. + buf_virt = dma_alloc_coherent(NULL,
  2646. + size,
  2647. + &buf_phys, GFP_KERNEL);
  2648. + if (!buf_virt) {
  2649. + return -ENOMEM;
  2650. + }
  2651. +
  2652. + spin_lock_irqsave(&sdma->channel_0_lock, flags);
  2653. +
  2654. + bd0->mode.command = C0_SETPM;
  2655. + bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
  2656. + bd0->mode.count = size / 2;
  2657. + bd0->buffer_addr = buf_phys;
  2658. + bd0->ext_buffer_addr = address;
  2659. +
  2660. + memcpy(buf_virt, buf, size);
  2661. +
  2662. + ret = sdma_run_channel0(sdma);
  2663. +
  2664. + spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
  2665. +
  2666. + dma_free_coherent(NULL, size, buf_virt, buf_phys);
  2667. +
  2668. + return ret;
  2669. +}
  2670. +
  2671. +static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
  2672. +{
  2673. + struct sdma_engine *sdma = sdmac->sdma;
  2674. + int channel = sdmac->channel;
  2675. + unsigned long val;
  2676. + u32 chnenbl = chnenbl_ofs(sdma, event);
  2677. +
  2678. + val = readl_relaxed(sdma->regs + chnenbl);
  2679. + __set_bit(channel, &val);
  2680. + writel_relaxed(val, sdma->regs + chnenbl);
  2681. +}
  2682. +
  2683. +static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
  2684. +{
  2685. + struct sdma_engine *sdma = sdmac->sdma;
  2686. + int channel = sdmac->channel;
  2687. + u32 chnenbl = chnenbl_ofs(sdma, event);
  2688. + unsigned long val;
  2689. +
  2690. + val = readl_relaxed(sdma->regs + chnenbl);
  2691. + __clear_bit(channel, &val);
  2692. + writel_relaxed(val, sdma->regs + chnenbl);
  2693. +}
  2694. +
  2695. +static void sdma_handle_channel_loop(struct sdma_channel *sdmac)
  2696. +{
  2697. + if (sdmac->desc.callback)
  2698. + sdmac->desc.callback(sdmac->desc.callback_param);
  2699. +}
  2700. +
  2701. +static void sdma_update_channel_loop(struct sdma_channel *sdmac)
  2702. +{
  2703. + struct sdma_buffer_descriptor *bd;
  2704. +
  2705. + /*
  2706. + * loop mode. Iterate over descriptors, re-setup them and
  2707. + * call callback function.
  2708. + */
  2709. + while (1) {
  2710. + bd = &sdmac->bd[sdmac->buf_tail];
  2711. +
  2712. + if (bd->mode.status & BD_DONE)
  2713. + break;
  2714. +
  2715. + if (bd->mode.status & BD_RROR)
  2716. + sdmac->status = DMA_ERROR;
  2717. +
  2718. + bd->mode.status |= BD_DONE;
  2719. + sdmac->buf_tail++;
  2720. + sdmac->buf_tail %= sdmac->num_bd;
  2721. + }
  2722. +}
  2723. +
  2724. +static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
  2725. +{
  2726. + struct sdma_buffer_descriptor *bd;
  2727. + int i, error = 0;
  2728. +
  2729. + sdmac->chn_real_count = 0;
  2730. + /*
  2731. + * non loop mode. Iterate over all descriptors, collect
  2732. + * errors and call callback function
  2733. + */
  2734. + for (i = 0; i < sdmac->num_bd; i++) {
  2735. + bd = &sdmac->bd[i];
  2736. +
  2737. + if (bd->mode.status & (BD_DONE | BD_RROR))
  2738. + error = -EIO;
  2739. + sdmac->chn_real_count += bd->mode.count;
  2740. + }
  2741. +
  2742. + if (error)
  2743. + sdmac->status = DMA_ERROR;
  2744. + else
  2745. + sdmac->status = DMA_COMPLETE;
  2746. +
  2747. + dma_cookie_complete(&sdmac->desc);
  2748. + if (sdmac->desc.callback)
  2749. + sdmac->desc.callback(sdmac->desc.callback_param);
  2750. +}
  2751. +
  2752. +static void sdma_tasklet(unsigned long data)
  2753. +{
  2754. + struct sdma_channel *sdmac = (struct sdma_channel *) data;
  2755. +
  2756. + if (sdmac->flags & IMX_DMA_SG_LOOP)
  2757. + sdma_handle_channel_loop(sdmac);
  2758. + else
  2759. + mxc_sdma_handle_channel_normal(sdmac);
  2760. +}
  2761. +
  2762. +static irqreturn_t sdma_int_handler(int irq, void *dev_id)
  2763. +{
  2764. + struct sdma_engine *sdma = dev_id;
  2765. + unsigned long stat;
  2766. +
  2767. + stat = readl_relaxed(sdma->regs + SDMA_H_INTR);
  2768. + /* not interested in channel 0 interrupts */
  2769. + stat &= ~1;
  2770. + writel_relaxed(stat, sdma->regs + SDMA_H_INTR);
  2771. +
  2772. + while (stat) {
  2773. + int channel = fls(stat) - 1;
  2774. + struct sdma_channel *sdmac = &sdma->channel[channel];
  2775. +
  2776. + if (sdmac->flags & IMX_DMA_SG_LOOP)
  2777. + sdma_update_channel_loop(sdmac);
  2778. +
  2779. + tasklet_schedule(&sdmac->tasklet);
  2780. +
  2781. + __clear_bit(channel, &stat);
  2782. + }
  2783. +
  2784. + return IRQ_HANDLED;
  2785. +}
  2786. +
  2787. +/*
  2788. + * sets the pc of SDMA script according to the peripheral type
  2789. + */
  2790. +static void sdma_get_pc(struct sdma_channel *sdmac,
  2791. + enum sdma_peripheral_type peripheral_type)
  2792. +{
  2793. + struct sdma_engine *sdma = sdmac->sdma;
  2794. + int per_2_emi = 0, emi_2_per = 0;
  2795. + /*
  2796. + * These are needed once we start to support transfers between
  2797. + * two peripherals or memory-to-memory transfers
  2798. + */
  2799. + int per_2_per = 0, emi_2_emi = 0;
  2800. +
  2801. + sdmac->pc_from_device = 0;
  2802. + sdmac->pc_to_device = 0;
  2803. +
  2804. + switch (peripheral_type) {
  2805. + case IMX_DMATYPE_MEMORY:
  2806. + emi_2_emi = sdma->script_addrs->ap_2_ap_addr;
  2807. + break;
  2808. + case IMX_DMATYPE_DSP:
  2809. + emi_2_per = sdma->script_addrs->bp_2_ap_addr;
  2810. + per_2_emi = sdma->script_addrs->ap_2_bp_addr;
  2811. + break;
  2812. + case IMX_DMATYPE_FIRI:
  2813. + per_2_emi = sdma->script_addrs->firi_2_mcu_addr;
  2814. + emi_2_per = sdma->script_addrs->mcu_2_firi_addr;
  2815. + break;
  2816. + case IMX_DMATYPE_UART:
  2817. + per_2_emi = sdma->script_addrs->uart_2_mcu_addr;
  2818. + emi_2_per = sdma->script_addrs->mcu_2_app_addr;
  2819. + break;
  2820. + case IMX_DMATYPE_UART_SP:
  2821. + per_2_emi = sdma->script_addrs->uartsh_2_mcu_addr;
  2822. + emi_2_per = sdma->script_addrs->mcu_2_shp_addr;
  2823. + break;
  2824. + case IMX_DMATYPE_ATA:
  2825. + per_2_emi = sdma->script_addrs->ata_2_mcu_addr;
  2826. + emi_2_per = sdma->script_addrs->mcu_2_ata_addr;
  2827. + break;
  2828. + case IMX_DMATYPE_CSPI:
  2829. + case IMX_DMATYPE_EXT:
  2830. + case IMX_DMATYPE_SSI:
  2831. + per_2_emi = sdma->script_addrs->app_2_mcu_addr;
  2832. + emi_2_per = sdma->script_addrs->mcu_2_app_addr;
  2833. + break;
  2834. + case IMX_DMATYPE_SSI_DUAL:
  2835. + per_2_emi = sdma->script_addrs->ssish_2_mcu_addr;
  2836. + emi_2_per = sdma->script_addrs->mcu_2_ssish_addr;
  2837. + break;
  2838. + case IMX_DMATYPE_SSI_SP:
  2839. + case IMX_DMATYPE_MMC:
  2840. + case IMX_DMATYPE_SDHC:
  2841. + case IMX_DMATYPE_CSPI_SP:
  2842. + case IMX_DMATYPE_ESAI:
  2843. + case IMX_DMATYPE_MSHC_SP:
  2844. + per_2_emi = sdma->script_addrs->shp_2_mcu_addr;
  2845. + emi_2_per = sdma->script_addrs->mcu_2_shp_addr;
  2846. + break;
  2847. + case IMX_DMATYPE_ASRC:
  2848. + per_2_emi = sdma->script_addrs->asrc_2_mcu_addr;
  2849. + emi_2_per = sdma->script_addrs->asrc_2_mcu_addr;
  2850. + per_2_per = sdma->script_addrs->per_2_per_addr;
  2851. + break;
  2852. + case IMX_DMATYPE_MSHC:
  2853. + per_2_emi = sdma->script_addrs->mshc_2_mcu_addr;
  2854. + emi_2_per = sdma->script_addrs->mcu_2_mshc_addr;
  2855. + break;
  2856. + case IMX_DMATYPE_CCM:
  2857. + per_2_emi = sdma->script_addrs->dptc_dvfs_addr;
  2858. + break;
  2859. + case IMX_DMATYPE_SPDIF:
  2860. + per_2_emi = sdma->script_addrs->spdif_2_mcu_addr;
  2861. + emi_2_per = sdma->script_addrs->mcu_2_spdif_addr;
  2862. + break;
  2863. + case IMX_DMATYPE_IPU_MEMORY:
  2864. + emi_2_per = sdma->script_addrs->ext_mem_2_ipu_addr;
  2865. + break;
  2866. + default:
  2867. + break;
  2868. + }
  2869. +
  2870. + sdmac->pc_from_device = per_2_emi;
  2871. + sdmac->pc_to_device = emi_2_per;
  2872. +}
  2873. +
  2874. +static int sdma_load_context(struct sdma_channel *sdmac)
  2875. +{
  2876. + struct sdma_engine *sdma = sdmac->sdma;
  2877. + int channel = sdmac->channel;
  2878. + int load_address;
  2879. + struct sdma_context_data *context = sdma->context;
  2880. + struct sdma_buffer_descriptor *bd0 = sdma->channel[0].bd;
  2881. + int ret;
  2882. + unsigned long flags;
  2883. +
  2884. + if (sdmac->direction == DMA_DEV_TO_MEM) {
  2885. + load_address = sdmac->pc_from_device;
  2886. + } else {
  2887. + load_address = sdmac->pc_to_device;
  2888. + }
  2889. +
  2890. + if (load_address < 0)
  2891. + return load_address;
  2892. +
  2893. + dev_dbg(sdma->dev, "load_address = %d\n", load_address);
  2894. + dev_dbg(sdma->dev, "wml = 0x%08x\n", (u32)sdmac->watermark_level);
  2895. + dev_dbg(sdma->dev, "shp_addr = 0x%08x\n", sdmac->shp_addr);
  2896. + dev_dbg(sdma->dev, "per_addr = 0x%08x\n", sdmac->per_addr);
  2897. + dev_dbg(sdma->dev, "event_mask0 = 0x%08x\n", (u32)sdmac->event_mask[0]);
  2898. + dev_dbg(sdma->dev, "event_mask1 = 0x%08x\n", (u32)sdmac->event_mask[1]);
  2899. +
  2900. + spin_lock_irqsave(&sdma->channel_0_lock, flags);
  2901. +
  2902. + memset(context, 0, sizeof(*context));
  2903. + context->channel_state.pc = load_address;
  2904. +
  2905. + /* Send by context the event mask,base address for peripheral
  2906. + * and watermark level
  2907. + */
  2908. + context->gReg[0] = sdmac->event_mask[1];
  2909. + context->gReg[1] = sdmac->event_mask[0];
  2910. + context->gReg[2] = sdmac->per_addr;
  2911. + context->gReg[6] = sdmac->shp_addr;
  2912. + context->gReg[7] = sdmac->watermark_level;
  2913. +
  2914. + bd0->mode.command = C0_SETDM;
  2915. + bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
  2916. + bd0->mode.count = sizeof(*context) / 4;
  2917. + bd0->buffer_addr = sdma->context_phys;
  2918. + bd0->ext_buffer_addr = 2048 + (sizeof(*context) / 4) * channel;
  2919. + ret = sdma_run_channel0(sdma);
  2920. +
  2921. + spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
  2922. +
  2923. + return ret;
  2924. +}
  2925. +
  2926. +static void sdma_disable_channel(struct sdma_channel *sdmac)
  2927. +{
  2928. + struct sdma_engine *sdma = sdmac->sdma;
  2929. + int channel = sdmac->channel;
  2930. +
  2931. + writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
  2932. + sdmac->status = DMA_ERROR;
  2933. +}
  2934. +
  2935. +static int sdma_config_channel(struct sdma_channel *sdmac)
  2936. +{
  2937. + int ret;
  2938. +
  2939. + sdma_disable_channel(sdmac);
  2940. +
  2941. + sdmac->event_mask[0] = 0;
  2942. + sdmac->event_mask[1] = 0;
  2943. + sdmac->shp_addr = 0;
  2944. + sdmac->per_addr = 0;
  2945. +
  2946. + if (sdmac->event_id0) {
  2947. + if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
  2948. + return -EINVAL;
  2949. + sdma_event_enable(sdmac, sdmac->event_id0);
  2950. + }
  2951. +
  2952. + switch (sdmac->peripheral_type) {
  2953. + case IMX_DMATYPE_DSP:
  2954. + sdma_config_ownership(sdmac, false, true, true);
  2955. + break;
  2956. + case IMX_DMATYPE_MEMORY:
  2957. + sdma_config_ownership(sdmac, false, true, false);
  2958. + break;
  2959. + default:
  2960. + sdma_config_ownership(sdmac, true, true, false);
  2961. + break;
  2962. + }
  2963. +
  2964. + sdma_get_pc(sdmac, sdmac->peripheral_type);
  2965. +
  2966. + if ((sdmac->peripheral_type != IMX_DMATYPE_MEMORY) &&
  2967. + (sdmac->peripheral_type != IMX_DMATYPE_DSP)) {
  2968. + /* Handle multiple event channels differently */
  2969. + if (sdmac->event_id1) {
  2970. + sdmac->event_mask[1] = BIT(sdmac->event_id1 % 32);
  2971. + if (sdmac->event_id1 > 31)
  2972. + __set_bit(31, &sdmac->watermark_level);
  2973. + sdmac->event_mask[0] = BIT(sdmac->event_id0 % 32);
  2974. + if (sdmac->event_id0 > 31)
  2975. + __set_bit(30, &sdmac->watermark_level);
  2976. + } else {
  2977. + __set_bit(sdmac->event_id0, sdmac->event_mask);
  2978. + }
  2979. + /* Watermark Level */
  2980. + sdmac->watermark_level |= sdmac->watermark_level;
  2981. + /* Address */
  2982. + sdmac->shp_addr = sdmac->per_address;
  2983. + } else {
  2984. + sdmac->watermark_level = 0; /* FIXME: M3_BASE_ADDRESS */
  2985. + }
  2986. +
  2987. + ret = sdma_load_context(sdmac);
  2988. +
  2989. + return ret;
  2990. +}
  2991. +
  2992. +static int sdma_set_channel_priority(struct sdma_channel *sdmac,
  2993. + unsigned int priority)
  2994. +{
  2995. + struct sdma_engine *sdma = sdmac->sdma;
  2996. + int channel = sdmac->channel;
  2997. +
  2998. + if (priority < MXC_SDMA_MIN_PRIORITY
  2999. + || priority > MXC_SDMA_MAX_PRIORITY) {
  3000. + return -EINVAL;
  3001. + }
  3002. +
  3003. + writel_relaxed(priority, sdma->regs + SDMA_CHNPRI_0 + 4 * channel);
  3004. +
  3005. + return 0;
  3006. +}
  3007. +
  3008. +static int sdma_request_channel(struct sdma_channel *sdmac)
  3009. +{
  3010. + struct sdma_engine *sdma = sdmac->sdma;
  3011. + int channel = sdmac->channel;
  3012. + int ret = -EBUSY;
  3013. +
  3014. + sdmac->bd = dma_alloc_coherent(NULL, PAGE_SIZE, &sdmac->bd_phys, GFP_KERNEL);
  3015. + if (!sdmac->bd) {
  3016. + ret = -ENOMEM;
  3017. + goto out;
  3018. + }
  3019. +
  3020. + memset(sdmac->bd, 0, PAGE_SIZE);
  3021. +
  3022. + sdma->channel_control[channel].base_bd_ptr = sdmac->bd_phys;
  3023. + sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
  3024. +
  3025. + sdma_set_channel_priority(sdmac, MXC_SDMA_DEFAULT_PRIORITY);
  3026. + return 0;
  3027. +out:
  3028. +
  3029. + return ret;
  3030. +}
  3031. +
  3032. +static struct sdma_channel *to_sdma_chan(struct dma_chan *chan)
  3033. +{
  3034. + return container_of(chan, struct sdma_channel, chan);
  3035. +}
  3036. +
  3037. +static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx)
  3038. +{
  3039. + unsigned long flags;
  3040. + struct sdma_channel *sdmac = to_sdma_chan(tx->chan);
  3041. + dma_cookie_t cookie;
  3042. +
  3043. + spin_lock_irqsave(&sdmac->lock, flags);
  3044. +
  3045. + cookie = dma_cookie_assign(tx);
  3046. +
  3047. + spin_unlock_irqrestore(&sdmac->lock, flags);
  3048. +
  3049. + return cookie;
  3050. +}
  3051. +
  3052. +static int sdma_alloc_chan_resources(struct dma_chan *chan)
  3053. +{
  3054. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3055. + struct imx_dma_data *data = chan->private;
  3056. + int prio, ret;
  3057. +
  3058. + if (!data)
  3059. + return -EINVAL;
  3060. +
  3061. + switch (data->priority) {
  3062. + case DMA_PRIO_HIGH:
  3063. + prio = 3;
  3064. + break;
  3065. + case DMA_PRIO_MEDIUM:
  3066. + prio = 2;
  3067. + break;
  3068. + case DMA_PRIO_LOW:
  3069. + default:
  3070. + prio = 1;
  3071. + break;
  3072. + }
  3073. +
  3074. + sdmac->peripheral_type = data->peripheral_type;
  3075. + sdmac->event_id0 = data->dma_request;
  3076. +
  3077. + clk_enable(sdmac->sdma->clk_ipg);
  3078. + clk_enable(sdmac->sdma->clk_ahb);
  3079. +
  3080. + ret = sdma_request_channel(sdmac);
  3081. + if (ret)
  3082. + return ret;
  3083. +
  3084. + ret = sdma_set_channel_priority(sdmac, prio);
  3085. + if (ret)
  3086. + return ret;
  3087. +
  3088. + dma_async_tx_descriptor_init(&sdmac->desc, chan);
  3089. + sdmac->desc.tx_submit = sdma_tx_submit;
  3090. + /* txd.flags will be overwritten in prep funcs */
  3091. + sdmac->desc.flags = DMA_CTRL_ACK;
  3092. +
  3093. + return 0;
  3094. +}
  3095. +
  3096. +static void sdma_free_chan_resources(struct dma_chan *chan)
  3097. +{
  3098. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3099. + struct sdma_engine *sdma = sdmac->sdma;
  3100. +
  3101. + sdma_disable_channel(sdmac);
  3102. +
  3103. + if (sdmac->event_id0)
  3104. + sdma_event_disable(sdmac, sdmac->event_id0);
  3105. + if (sdmac->event_id1)
  3106. + sdma_event_disable(sdmac, sdmac->event_id1);
  3107. +
  3108. + sdmac->event_id0 = 0;
  3109. + sdmac->event_id1 = 0;
  3110. +
  3111. + sdma_set_channel_priority(sdmac, 0);
  3112. +
  3113. + dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
  3114. +
  3115. + clk_disable(sdma->clk_ipg);
  3116. + clk_disable(sdma->clk_ahb);
  3117. +}
  3118. +
  3119. +static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
  3120. + struct dma_chan *chan, struct scatterlist *sgl,
  3121. + unsigned int sg_len, enum dma_transfer_direction direction,
  3122. + unsigned long flags, void *context)
  3123. +{
  3124. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3125. + struct sdma_engine *sdma = sdmac->sdma;
  3126. + int ret, i, count;
  3127. + int channel = sdmac->channel;
  3128. + struct scatterlist *sg;
  3129. +
  3130. + if (sdmac->status == DMA_IN_PROGRESS)
  3131. + return NULL;
  3132. + sdmac->status = DMA_IN_PROGRESS;
  3133. +
  3134. + sdmac->flags = 0;
  3135. +
  3136. + sdmac->buf_tail = 0;
  3137. +
  3138. + dev_dbg(sdma->dev, "setting up %d entries for channel %d.\n",
  3139. + sg_len, channel);
  3140. +
  3141. + sdmac->direction = direction;
  3142. + ret = sdma_load_context(sdmac);
  3143. + if (ret)
  3144. + goto err_out;
  3145. +
  3146. + if (sg_len > NUM_BD) {
  3147. + dev_err(sdma->dev, "SDMA channel %d: maximum number of sg exceeded: %d > %d\n",
  3148. + channel, sg_len, NUM_BD);
  3149. + ret = -EINVAL;
  3150. + goto err_out;
  3151. + }
  3152. +
  3153. + sdmac->chn_count = 0;
  3154. + for_each_sg(sgl, sg, sg_len, i) {
  3155. + struct sdma_buffer_descriptor *bd = &sdmac->bd[i];
  3156. + int param;
  3157. +
  3158. + bd->buffer_addr = sg->dma_address;
  3159. +
  3160. + count = sg_dma_len(sg);
  3161. +
  3162. + if (count > 0xffff) {
  3163. + dev_err(sdma->dev, "SDMA channel %d: maximum bytes for sg entry exceeded: %d > %d\n",
  3164. + channel, count, 0xffff);
  3165. + ret = -EINVAL;
  3166. + goto err_out;
  3167. + }
  3168. +
  3169. + bd->mode.count = count;
  3170. + sdmac->chn_count += count;
  3171. +
  3172. + if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) {
  3173. + ret = -EINVAL;
  3174. + goto err_out;
  3175. + }
  3176. +
  3177. + switch (sdmac->word_size) {
  3178. + case DMA_SLAVE_BUSWIDTH_4_BYTES:
  3179. + bd->mode.command = 0;
  3180. + if (count & 3 || sg->dma_address & 3)
  3181. + return NULL;
  3182. + break;
  3183. + case DMA_SLAVE_BUSWIDTH_2_BYTES:
  3184. + bd->mode.command = 2;
  3185. + if (count & 1 || sg->dma_address & 1)
  3186. + return NULL;
  3187. + break;
  3188. + case DMA_SLAVE_BUSWIDTH_1_BYTE:
  3189. + bd->mode.command = 1;
  3190. + break;
  3191. + default:
  3192. + return NULL;
  3193. + }
  3194. +
  3195. + param = BD_DONE | BD_EXTD | BD_CONT;
  3196. +
  3197. + if (i + 1 == sg_len) {
  3198. + param |= BD_INTR;
  3199. + param |= BD_LAST;
  3200. + param &= ~BD_CONT;
  3201. + }
  3202. +
  3203. + dev_dbg(sdma->dev, "entry %d: count: %d dma: %#llx %s%s\n",
  3204. + i, count, (u64)sg->dma_address,
  3205. + param & BD_WRAP ? "wrap" : "",
  3206. + param & BD_INTR ? " intr" : "");
  3207. +
  3208. + bd->mode.status = param;
  3209. + }
  3210. +
  3211. + sdmac->num_bd = sg_len;
  3212. + sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
  3213. +
  3214. + return &sdmac->desc;
  3215. +err_out:
  3216. + sdmac->status = DMA_ERROR;
  3217. + return NULL;
  3218. +}
  3219. +
  3220. +static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic(
  3221. + struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
  3222. + size_t period_len, enum dma_transfer_direction direction,
  3223. + unsigned long flags, void *context)
  3224. +{
  3225. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3226. + struct sdma_engine *sdma = sdmac->sdma;
  3227. + int num_periods = buf_len / period_len;
  3228. + int channel = sdmac->channel;
  3229. + int ret, i = 0, buf = 0;
  3230. +
  3231. + dev_dbg(sdma->dev, "%s channel: %d\n", __func__, channel);
  3232. +
  3233. + if (sdmac->status == DMA_IN_PROGRESS)
  3234. + return NULL;
  3235. +
  3236. + sdmac->status = DMA_IN_PROGRESS;
  3237. +
  3238. + sdmac->buf_tail = 0;
  3239. + sdmac->period_len = period_len;
  3240. +
  3241. + sdmac->flags |= IMX_DMA_SG_LOOP;
  3242. + sdmac->direction = direction;
  3243. + ret = sdma_load_context(sdmac);
  3244. + if (ret)
  3245. + goto err_out;
  3246. +
  3247. + if (num_periods > NUM_BD) {
  3248. + dev_err(sdma->dev, "SDMA channel %d: maximum number of sg exceeded: %d > %d\n",
  3249. + channel, num_periods, NUM_BD);
  3250. + goto err_out;
  3251. + }
  3252. +
  3253. + if (period_len > 0xffff) {
  3254. + dev_err(sdma->dev, "SDMA channel %d: maximum period size exceeded: %d > %d\n",
  3255. + channel, period_len, 0xffff);
  3256. + goto err_out;
  3257. + }
  3258. +
  3259. + while (buf < buf_len) {
  3260. + struct sdma_buffer_descriptor *bd = &sdmac->bd[i];
  3261. + int param;
  3262. +
  3263. + bd->buffer_addr = dma_addr;
  3264. +
  3265. + bd->mode.count = period_len;
  3266. +
  3267. + if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES)
  3268. + goto err_out;
  3269. + if (sdmac->word_size == DMA_SLAVE_BUSWIDTH_4_BYTES)
  3270. + bd->mode.command = 0;
  3271. + else
  3272. + bd->mode.command = sdmac->word_size;
  3273. +
  3274. + param = BD_DONE | BD_EXTD | BD_CONT | BD_INTR;
  3275. + if (i + 1 == num_periods)
  3276. + param |= BD_WRAP;
  3277. +
  3278. + dev_dbg(sdma->dev, "entry %d: count: %d dma: %#llx %s%s\n",
  3279. + i, period_len, (u64)dma_addr,
  3280. + param & BD_WRAP ? "wrap" : "",
  3281. + param & BD_INTR ? " intr" : "");
  3282. +
  3283. + bd->mode.status = param;
  3284. +
  3285. + dma_addr += period_len;
  3286. + buf += period_len;
  3287. +
  3288. + i++;
  3289. + }
  3290. +
  3291. + sdmac->num_bd = num_periods;
  3292. + sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
  3293. +
  3294. + return &sdmac->desc;
  3295. +err_out:
  3296. + sdmac->status = DMA_ERROR;
  3297. + return NULL;
  3298. +}
  3299. +
  3300. +static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
  3301. + unsigned long arg)
  3302. +{
  3303. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3304. + struct dma_slave_config *dmaengine_cfg = (void *)arg;
  3305. +
  3306. + switch (cmd) {
  3307. + case DMA_TERMINATE_ALL:
  3308. + sdma_disable_channel(sdmac);
  3309. + return 0;
  3310. + case DMA_SLAVE_CONFIG:
  3311. + if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
  3312. + sdmac->per_address = dmaengine_cfg->src_addr;
  3313. + sdmac->watermark_level = dmaengine_cfg->src_maxburst *
  3314. + dmaengine_cfg->src_addr_width;
  3315. + sdmac->word_size = dmaengine_cfg->src_addr_width;
  3316. + } else {
  3317. + sdmac->per_address = dmaengine_cfg->dst_addr;
  3318. + sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
  3319. + dmaengine_cfg->dst_addr_width;
  3320. + sdmac->word_size = dmaengine_cfg->dst_addr_width;
  3321. + }
  3322. + sdmac->direction = dmaengine_cfg->direction;
  3323. + return sdma_config_channel(sdmac);
  3324. + default:
  3325. + return -ENOSYS;
  3326. + }
  3327. +
  3328. + return -EINVAL;
  3329. +}
  3330. +
  3331. +static enum dma_status sdma_tx_status(struct dma_chan *chan,
  3332. + dma_cookie_t cookie,
  3333. + struct dma_tx_state *txstate)
  3334. +{
  3335. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3336. + u32 residue;
  3337. +
  3338. + if (sdmac->flags & IMX_DMA_SG_LOOP)
  3339. + residue = (sdmac->num_bd - sdmac->buf_tail) * sdmac->period_len;
  3340. + else
  3341. + residue = sdmac->chn_count - sdmac->chn_real_count;
  3342. +
  3343. + dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
  3344. + residue);
  3345. +
  3346. + return sdmac->status;
  3347. +}
  3348. +
  3349. +static void sdma_issue_pending(struct dma_chan *chan)
  3350. +{
  3351. + struct sdma_channel *sdmac = to_sdma_chan(chan);
  3352. + struct sdma_engine *sdma = sdmac->sdma;
  3353. +
  3354. + if (sdmac->status == DMA_IN_PROGRESS)
  3355. + sdma_enable_channel(sdma, sdmac->channel);
  3356. +}
  3357. +
  3358. +#define SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1 34
  3359. +#define SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V2 38
  3360. +
  3361. +static void sdma_add_scripts(struct sdma_engine *sdma,
  3362. + const struct sdma_script_start_addrs *addr)
  3363. +{
  3364. + s32 *addr_arr = (u32 *)addr;
  3365. + s32 *saddr_arr = (u32 *)sdma->script_addrs;
  3366. + int i;
  3367. +
  3368. + /* use the default firmware in ROM if missing external firmware */
  3369. + if (!sdma->script_number)
  3370. + sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1;
  3371. +
  3372. + for (i = 0; i < sdma->script_number; i++)
  3373. + if (addr_arr[i] > 0)
  3374. + saddr_arr[i] = addr_arr[i];
  3375. +}
  3376. +
  3377. +static void sdma_load_firmware(const struct firmware *fw, void *context)
  3378. +{
  3379. + struct sdma_engine *sdma = context;
  3380. + const struct sdma_firmware_header *header;
  3381. + const struct sdma_script_start_addrs *addr;
  3382. + unsigned short *ram_code;
  3383. +
  3384. + if (!fw) {
  3385. + dev_err(sdma->dev, "firmware not found\n");
  3386. + return;
  3387. + }
  3388. +
  3389. + if (fw->size < sizeof(*header))
  3390. + goto err_firmware;
  3391. +
  3392. + header = (struct sdma_firmware_header *)fw->data;
  3393. +
  3394. + if (header->magic != SDMA_FIRMWARE_MAGIC)
  3395. + goto err_firmware;
  3396. + if (header->ram_code_start + header->ram_code_size > fw->size)
  3397. + goto err_firmware;
  3398. + switch (header->version_major) {
  3399. + case 1:
  3400. + sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1;
  3401. + break;
  3402. + case 2:
  3403. + sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V2;
  3404. + break;
  3405. + default:
  3406. + dev_err(sdma->dev, "unknown firmware version\n");
  3407. + goto err_firmware;
  3408. + }
  3409. +
  3410. + addr = (void *)header + header->script_addrs_start;
  3411. + ram_code = (void *)header + header->ram_code_start;
  3412. +
  3413. + clk_enable(sdma->clk_ipg);
  3414. + clk_enable(sdma->clk_ahb);
  3415. + /* download the RAM image for SDMA */
  3416. + sdma_load_script(sdma, ram_code,
  3417. + header->ram_code_size,
  3418. + addr->ram_code_start_addr);
  3419. + clk_disable(sdma->clk_ipg);
  3420. + clk_disable(sdma->clk_ahb);
  3421. +
  3422. + sdma_add_scripts(sdma, addr);
  3423. +
  3424. + dev_info(sdma->dev, "loaded firmware %d.%d\n",
  3425. + header->version_major,
  3426. + header->version_minor);
  3427. +
  3428. +err_firmware:
  3429. + release_firmware(fw);
  3430. +}
  3431. +
  3432. +static int __init sdma_get_firmware(struct sdma_engine *sdma,
  3433. + const char *fw_name)
  3434. +{
  3435. + int ret;
  3436. +
  3437. + ret = request_firmware_nowait(THIS_MODULE,
  3438. + FW_ACTION_HOTPLUG, fw_name, sdma->dev,
  3439. + GFP_KERNEL, sdma, sdma_load_firmware);
  3440. +
  3441. + return ret;
  3442. +}
  3443. +
  3444. +static int __init sdma_init(struct sdma_engine *sdma)
  3445. +{
  3446. + int i, ret;
  3447. + dma_addr_t ccb_phys;
  3448. +
  3449. + clk_enable(sdma->clk_ipg);
  3450. + clk_enable(sdma->clk_ahb);
  3451. +
  3452. + /* Be sure SDMA has not started yet */
  3453. + writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
  3454. +
  3455. + sdma->channel_control = dma_alloc_coherent(NULL,
  3456. + MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
  3457. + sizeof(struct sdma_context_data),
  3458. + &ccb_phys, GFP_KERNEL);
  3459. +
  3460. + if (!sdma->channel_control) {
  3461. + ret = -ENOMEM;
  3462. + goto err_dma_alloc;
  3463. + }
  3464. +
  3465. + sdma->context = (void *)sdma->channel_control +
  3466. + MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control);
  3467. + sdma->context_phys = ccb_phys +
  3468. + MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control);
  3469. +
  3470. + /* Zero-out the CCB structures array just allocated */
  3471. + memset(sdma->channel_control, 0,
  3472. + MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control));
  3473. +
  3474. + /* disable all channels */
  3475. + for (i = 0; i < sdma->drvdata->num_events; i++)
  3476. + writel_relaxed(0, sdma->regs + chnenbl_ofs(sdma, i));
  3477. +
  3478. + /* All channels have priority 0 */
  3479. + for (i = 0; i < MAX_DMA_CHANNELS; i++)
  3480. + writel_relaxed(0, sdma->regs + SDMA_CHNPRI_0 + i * 4);
  3481. +
  3482. + ret = sdma_request_channel(&sdma->channel[0]);
  3483. + if (ret)
  3484. + goto err_dma_alloc;
  3485. +
  3486. + sdma_config_ownership(&sdma->channel[0], false, true, false);
  3487. +
  3488. + /* Set Command Channel (Channel Zero) */
  3489. + writel_relaxed(0x4050, sdma->regs + SDMA_CHN0ADDR);
  3490. +
  3491. + /* Set bits of CONFIG register but with static context switching */
  3492. + /* FIXME: Check whether to set ACR bit depending on clock ratios */
  3493. + writel_relaxed(0, sdma->regs + SDMA_H_CONFIG);
  3494. +
  3495. + writel_relaxed(ccb_phys, sdma->regs + SDMA_H_C0PTR);
  3496. +
  3497. + /* Set bits of CONFIG register with given context switching mode */
  3498. + writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
  3499. +
  3500. + /* Initializes channel's priorities */
  3501. + sdma_set_channel_priority(&sdma->channel[0], 7);
  3502. +
  3503. + clk_disable(sdma->clk_ipg);
  3504. + clk_disable(sdma->clk_ahb);
  3505. +
  3506. + return 0;
  3507. +
  3508. +err_dma_alloc:
  3509. + clk_disable(sdma->clk_ipg);
  3510. + clk_disable(sdma->clk_ahb);
  3511. + dev_err(sdma->dev, "initialisation failed with %d\n", ret);
  3512. + return ret;
  3513. +}
  3514. +
  3515. +static bool sdma_filter_fn(struct dma_chan *chan, void *fn_param)
  3516. +{
  3517. + struct imx_dma_data *data = fn_param;
  3518. +
  3519. + if (!imx_dma_is_general_purpose(chan))
  3520. + return false;
  3521. +
  3522. + chan->private = data;
  3523. +
  3524. + return true;
  3525. +}
  3526. +
  3527. +static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec,
  3528. + struct of_dma *ofdma)
  3529. +{
  3530. + struct sdma_engine *sdma = ofdma->of_dma_data;
  3531. + dma_cap_mask_t mask = sdma->dma_device.cap_mask;
  3532. + struct imx_dma_data data;
  3533. +
  3534. + if (dma_spec->args_count != 3)
  3535. + return NULL;
  3536. +
  3537. + data.dma_request = dma_spec->args[0];
  3538. + data.peripheral_type = dma_spec->args[1];
  3539. + data.priority = dma_spec->args[2];
  3540. +
  3541. + return dma_request_channel(mask, sdma_filter_fn, &data);
  3542. +}
  3543. +
  3544. +static int __init sdma_probe(struct platform_device *pdev)
  3545. +{
  3546. + const struct of_device_id *of_id =
  3547. + of_match_device(sdma_dt_ids, &pdev->dev);
  3548. + struct device_node *np = pdev->dev.of_node;
  3549. + const char *fw_name;
  3550. + int ret;
  3551. + int irq;
  3552. + struct resource *iores;
  3553. + struct sdma_platform_data *pdata = dev_get_platdata(&pdev->dev);
  3554. + int i;
  3555. + struct sdma_engine *sdma;
  3556. + s32 *saddr_arr;
  3557. + const struct sdma_driver_data *drvdata = NULL;
  3558. +
  3559. + if (of_id)
  3560. + drvdata = of_id->data;
  3561. + else if (pdev->id_entry)
  3562. + drvdata = (void *)pdev->id_entry->driver_data;
  3563. +
  3564. + if (!drvdata) {
  3565. + dev_err(&pdev->dev, "unable to find driver data\n");
  3566. + return -EINVAL;
  3567. + }
  3568. +
  3569. + ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
  3570. + if (ret)
  3571. + return ret;
  3572. +
  3573. + sdma = kzalloc(sizeof(*sdma), GFP_KERNEL);
  3574. + if (!sdma)
  3575. + return -ENOMEM;
  3576. +
  3577. + spin_lock_init(&sdma->channel_0_lock);
  3578. +
  3579. + sdma->dev = &pdev->dev;
  3580. + sdma->drvdata = drvdata;
  3581. +
  3582. + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  3583. + irq = platform_get_irq(pdev, 0);
  3584. + if (!iores || irq < 0) {
  3585. + ret = -EINVAL;
  3586. + goto err_irq;
  3587. + }
  3588. +
  3589. + if (!request_mem_region(iores->start, resource_size(iores), pdev->name)) {
  3590. + ret = -EBUSY;
  3591. + goto err_request_region;
  3592. + }
  3593. +
  3594. + sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
  3595. + if (IS_ERR(sdma->clk_ipg)) {
  3596. + ret = PTR_ERR(sdma->clk_ipg);
  3597. + goto err_clk;
  3598. + }
  3599. +
  3600. + sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
  3601. + if (IS_ERR(sdma->clk_ahb)) {
  3602. + ret = PTR_ERR(sdma->clk_ahb);
  3603. + goto err_clk;
  3604. + }
  3605. +
  3606. + clk_prepare(sdma->clk_ipg);
  3607. + clk_prepare(sdma->clk_ahb);
  3608. +
  3609. + sdma->regs = ioremap(iores->start, resource_size(iores));
  3610. + if (!sdma->regs) {
  3611. + ret = -ENOMEM;
  3612. + goto err_ioremap;
  3613. + }
  3614. +
  3615. + ret = request_irq(irq, sdma_int_handler, 0, "sdma", sdma);
  3616. + if (ret)
  3617. + goto err_request_irq;
  3618. +
  3619. + sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
  3620. + if (!sdma->script_addrs) {
  3621. + ret = -ENOMEM;
  3622. + goto err_alloc;
  3623. + }
  3624. +
  3625. + /* initially no scripts available */
  3626. + saddr_arr = (s32 *)sdma->script_addrs;
  3627. + for (i = 0; i < SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; i++)
  3628. + saddr_arr[i] = -EINVAL;
  3629. +
  3630. + dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask);
  3631. + dma_cap_set(DMA_CYCLIC, sdma->dma_device.cap_mask);
  3632. +
  3633. + INIT_LIST_HEAD(&sdma->dma_device.channels);
  3634. + /* Initialize channel parameters */
  3635. + for (i = 0; i < MAX_DMA_CHANNELS; i++) {
  3636. + struct sdma_channel *sdmac = &sdma->channel[i];
  3637. +
  3638. + sdmac->sdma = sdma;
  3639. + spin_lock_init(&sdmac->lock);
  3640. +
  3641. + sdmac->chan.device = &sdma->dma_device;
  3642. + dma_cookie_init(&sdmac->chan);
  3643. + sdmac->channel = i;
  3644. +
  3645. + tasklet_init(&sdmac->tasklet, sdma_tasklet,
  3646. + (unsigned long) sdmac);
  3647. + /*
  3648. + * Add the channel to the DMAC list. Do not add channel 0 though
  3649. + * because we need it internally in the SDMA driver. This also means
  3650. + * that channel 0 in dmaengine counting matches sdma channel 1.
  3651. + */
  3652. + if (i)
  3653. + list_add_tail(&sdmac->chan.device_node,
  3654. + &sdma->dma_device.channels);
  3655. + }
  3656. +
  3657. + ret = sdma_init(sdma);
  3658. + if (ret)
  3659. + goto err_init;
  3660. +
  3661. + if (sdma->drvdata->script_addrs)
  3662. + sdma_add_scripts(sdma, sdma->drvdata->script_addrs);
  3663. + if (pdata && pdata->script_addrs)
  3664. + sdma_add_scripts(sdma, pdata->script_addrs);
  3665. +
  3666. + if (pdata) {
  3667. + ret = sdma_get_firmware(sdma, pdata->fw_name);
  3668. + if (ret)
  3669. + dev_warn(&pdev->dev, "failed to get firmware from platform data\n");
  3670. + } else {
  3671. + /*
  3672. + * Because that device tree does not encode ROM script address,
  3673. + * the RAM script in firmware is mandatory for device tree
  3674. + * probe, otherwise it fails.
  3675. + */
  3676. + ret = of_property_read_string(np, "fsl,sdma-ram-script-name",
  3677. + &fw_name);
  3678. + if (ret)
  3679. + dev_warn(&pdev->dev, "failed to get firmware name\n");
  3680. + else {
  3681. + ret = sdma_get_firmware(sdma, fw_name);
  3682. + if (ret)
  3683. + dev_warn(&pdev->dev, "failed to get firmware from device tree\n");
  3684. + }
  3685. + }
  3686. +
  3687. + sdma->dma_device.dev = &pdev->dev;
  3688. +
  3689. + sdma->dma_device.device_alloc_chan_resources = sdma_alloc_chan_resources;
  3690. + sdma->dma_device.device_free_chan_resources = sdma_free_chan_resources;
  3691. + sdma->dma_device.device_tx_status = sdma_tx_status;
  3692. + sdma->dma_device.device_prep_slave_sg = sdma_prep_slave_sg;
  3693. + sdma->dma_device.device_prep_dma_cyclic = sdma_prep_dma_cyclic;
  3694. + sdma->dma_device.device_control = sdma_control;
  3695. + sdma->dma_device.device_issue_pending = sdma_issue_pending;
  3696. + sdma->dma_device.dev->dma_parms = &sdma->dma_parms;
  3697. + dma_set_max_seg_size(sdma->dma_device.dev, 65535);
  3698. +
  3699. + ret = dma_async_device_register(&sdma->dma_device);
  3700. + if (ret) {
  3701. + dev_err(&pdev->dev, "unable to register\n");
  3702. + goto err_init;
  3703. + }
  3704. +
  3705. + if (np) {
  3706. + ret = of_dma_controller_register(np, sdma_xlate, sdma);
  3707. + if (ret) {
  3708. + dev_err(&pdev->dev, "failed to register controller\n");
  3709. + goto err_register;
  3710. + }
  3711. + }
  3712. +
  3713. + dev_info(sdma->dev, "initialized\n");
  3714. +
  3715. + return 0;
  3716. +
  3717. +err_register:
  3718. + dma_async_device_unregister(&sdma->dma_device);
  3719. +err_init:
  3720. + kfree(sdma->script_addrs);
  3721. +err_alloc:
  3722. + free_irq(irq, sdma);
  3723. +err_request_irq:
  3724. + iounmap(sdma->regs);
  3725. +err_ioremap:
  3726. +err_clk:
  3727. + release_mem_region(iores->start, resource_size(iores));
  3728. +err_request_region:
  3729. +err_irq:
  3730. + kfree(sdma);
  3731. + return ret;
  3732. +}
  3733. +
  3734. +static int sdma_remove(struct platform_device *pdev)
  3735. +{
  3736. + return -EBUSY;
  3737. +}
  3738. +
  3739. +static struct platform_driver sdma_driver = {
  3740. + .driver = {
  3741. + .name = "imx-sdma",
  3742. + .of_match_table = sdma_dt_ids,
  3743. + },
  3744. + .id_table = sdma_devtypes,
  3745. + .remove = sdma_remove,
  3746. +};
  3747. +
  3748. +static int __init sdma_module_init(void)
  3749. +{
  3750. + return platform_driver_probe(&sdma_driver, sdma_probe);
  3751. +}
  3752. +module_init(sdma_module_init);
  3753. +
  3754. +MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
  3755. +MODULE_DESCRIPTION("i.MX SDMA driver");
  3756. +MODULE_LICENSE("GPL");
  3757. diff -Nur linux-3.16.6.orig/drivers/gpu/ipu-v3/ipu-dc.c linux-3.16.6/drivers/gpu/ipu-v3/ipu-dc.c
  3758. --- linux-3.16.6.orig/drivers/gpu/ipu-v3/ipu-dc.c 2014-10-15 05:05:43.000000000 -0500
  3759. +++ linux-3.16.6/drivers/gpu/ipu-v3/ipu-dc.c 2014-10-23 12:35:30.966220009 -0500
  3760. @@ -93,6 +93,7 @@
  3761. IPU_DC_MAP_BGR666,
  3762. IPU_DC_MAP_LVDS666,
  3763. IPU_DC_MAP_BGR24,
  3764. + IPU_DC_MAP_RGB666,
  3765. };
  3766. struct ipu_dc {
  3767. @@ -161,6 +162,8 @@
  3768. return IPU_DC_MAP_LVDS666;
  3769. case V4L2_PIX_FMT_BGR24:
  3770. return IPU_DC_MAP_BGR24;
  3771. + case V4L2_PIX_FMT_RGB666:
  3772. + return IPU_DC_MAP_RGB666;
  3773. default:
  3774. return -EINVAL;
  3775. }
  3776. @@ -452,6 +455,12 @@
  3777. ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 1, 15, 0xff); /* green */
  3778. ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 0, 23, 0xff); /* blue */
  3779. + /* rgb666 */
  3780. + ipu_dc_map_clear(priv, IPU_DC_MAP_RGB666);
  3781. + ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 0, 5, 0xfc); /* blue */
  3782. + ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 1, 11, 0xfc); /* green */
  3783. + ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 2, 17, 0xfc); /* red */
  3784. +
  3785. return 0;
  3786. }
  3787. diff -Nur linux-3.16.6.orig/drivers/gpu/ipu-v3/ipu-di.c linux-3.16.6/drivers/gpu/ipu-v3/ipu-di.c
  3788. --- linux-3.16.6.orig/drivers/gpu/ipu-v3/ipu-di.c 2014-10-15 05:05:43.000000000 -0500
  3789. +++ linux-3.16.6/drivers/gpu/ipu-v3/ipu-di.c 2014-10-23 12:35:38.078220007 -0500
  3790. @@ -595,7 +595,7 @@
  3791. }
  3792. }
  3793. - if (sig->clk_pol)
  3794. + if (sig->clk_pol == CLK_POL_POSEDGE)
  3795. di_gen |= DI_GEN_POLARITY_DISP_CLK;
  3796. ipu_di_write(di, di_gen, DI_GENERAL);
  3797. @@ -606,7 +606,7 @@
  3798. reg = ipu_di_read(di, DI_POL);
  3799. reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);
  3800. - if (sig->enable_pol)
  3801. + if (sig->enable_pol == ENABLE_POL_HIGH)
  3802. reg |= DI_POL_DRDY_POLARITY_15;
  3803. if (sig->data_pol)
  3804. reg |= DI_POL_DRDY_DATA_POLARITY;
  3805. diff -Nur linux-3.16.6.orig/drivers/Kconfig linux-3.16.6/drivers/Kconfig
  3806. --- linux-3.16.6.orig/drivers/Kconfig 2014-10-15 05:05:43.000000000 -0500
  3807. +++ linux-3.16.6/drivers/Kconfig 2014-10-23 12:37:18.314220004 -0500
  3808. @@ -176,4 +176,6 @@
  3809. source "drivers/mcb/Kconfig"
  3810. +source "drivers/cec/Kconfig"
  3811. +
  3812. endmenu
  3813. diff -Nur linux-3.16.6.orig/drivers/Makefile linux-3.16.6/drivers/Makefile
  3814. --- linux-3.16.6.orig/drivers/Makefile 2014-10-15 05:05:43.000000000 -0500
  3815. +++ linux-3.16.6/drivers/Makefile 2014-10-23 12:37:18.350220009 -0500
  3816. @@ -158,3 +158,4 @@
  3817. obj-$(CONFIG_FMC) += fmc/
  3818. obj-$(CONFIG_POWERCAP) += powercap/
  3819. obj-$(CONFIG_MCB) += mcb/
  3820. +obj-$(CONFIG_CEC) += cec/
  3821. diff -Nur linux-3.16.6.orig/drivers/mmc/core/core.c linux-3.16.6/drivers/mmc/core/core.c
  3822. --- linux-3.16.6.orig/drivers/mmc/core/core.c 2014-10-15 05:05:43.000000000 -0500
  3823. +++ linux-3.16.6/drivers/mmc/core/core.c 2014-10-23 12:34:18.710219997 -0500
  3824. @@ -13,11 +13,13 @@
  3825. #include <linux/module.h>
  3826. #include <linux/init.h>
  3827. #include <linux/interrupt.h>
  3828. +#include <linux/clk.h>
  3829. #include <linux/completion.h>
  3830. #include <linux/device.h>
  3831. #include <linux/delay.h>
  3832. #include <linux/pagemap.h>
  3833. #include <linux/err.h>
  3834. +#include <linux/gpio/consumer.h>
  3835. #include <linux/leds.h>
  3836. #include <linux/scatterlist.h>
  3837. #include <linux/log2.h>
  3838. @@ -1515,6 +1517,43 @@
  3839. mmc_host_clk_release(host);
  3840. }
  3841. +static void mmc_card_power_up(struct mmc_host *host)
  3842. +{
  3843. + int i;
  3844. + struct gpio_desc **gds = host->card_reset_gpios;
  3845. +
  3846. + for (i = 0; i < ARRAY_SIZE(host->card_reset_gpios); i++) {
  3847. + if (gds[i]) {
  3848. + dev_dbg(host->parent, "Asserting reset line %d", i);
  3849. + gpiod_set_value(gds[i], 1);
  3850. + }
  3851. + }
  3852. +
  3853. + if (host->card_regulator) {
  3854. + dev_dbg(host->parent, "Enabling external regulator");
  3855. + if (regulator_enable(host->card_regulator))
  3856. + dev_err(host->parent, "Failed to enable external regulator");
  3857. + }
  3858. +
  3859. + if (host->card_clk) {
  3860. + dev_dbg(host->parent, "Enabling external clock");
  3861. + clk_prepare_enable(host->card_clk);
  3862. + }
  3863. +
  3864. + /* 2ms delay to let clocks and power settle */
  3865. + mmc_delay(20);
  3866. +
  3867. + for (i = 0; i < ARRAY_SIZE(host->card_reset_gpios); i++) {
  3868. + if (gds[i]) {
  3869. + dev_dbg(host->parent, "Deasserting reset line %d", i);
  3870. + gpiod_set_value(gds[i], 0);
  3871. + }
  3872. + }
  3873. +
  3874. + /* 2ms delay to after reset release */
  3875. + mmc_delay(20);
  3876. +}
  3877. +
  3878. /*
  3879. * Apply power to the MMC stack. This is a two-stage process.
  3880. * First, we enable power to the card without the clock running.
  3881. @@ -1531,6 +1570,9 @@
  3882. if (host->ios.power_mode == MMC_POWER_ON)
  3883. return;
  3884. + /* Power up the card/module first, if needed */
  3885. + mmc_card_power_up(host);
  3886. +
  3887. mmc_host_clk_hold(host);
  3888. host->ios.vdd = fls(ocr) - 1;
  3889. diff -Nur linux-3.16.6.orig/drivers/mmc/core/host.c linux-3.16.6/drivers/mmc/core/host.c
  3890. --- linux-3.16.6.orig/drivers/mmc/core/host.c 2014-10-15 05:05:43.000000000 -0500
  3891. +++ linux-3.16.6/drivers/mmc/core/host.c 2014-10-23 12:34:34.134220000 -0500
  3892. @@ -12,14 +12,18 @@
  3893. * MMC host class device management
  3894. */
  3895. +#include <linux/kernel.h>
  3896. +#include <linux/clk.h>
  3897. #include <linux/device.h>
  3898. #include <linux/err.h>
  3899. +#include <linux/gpio/consumer.h>
  3900. #include <linux/idr.h>
  3901. #include <linux/of.h>
  3902. #include <linux/of_gpio.h>
  3903. #include <linux/pagemap.h>
  3904. #include <linux/export.h>
  3905. #include <linux/leds.h>
  3906. +#include <linux/regulator/consumer.h>
  3907. #include <linux/slab.h>
  3908. #include <linux/suspend.h>
  3909. @@ -461,6 +465,66 @@
  3910. EXPORT_SYMBOL(mmc_of_parse);
  3911. +static int mmc_of_parse_child(struct mmc_host *host)
  3912. +{
  3913. + struct device_node *np;
  3914. + struct clk *clk;
  3915. + int i;
  3916. +
  3917. + if (!host->parent || !host->parent->of_node)
  3918. + return 0;
  3919. +
  3920. + np = host->parent->of_node;
  3921. +
  3922. + host->card_regulator = regulator_get(host->parent, "card-external-vcc");
  3923. + if (IS_ERR(host->card_regulator)) {
  3924. + if (PTR_ERR(host->card_regulator) == -EPROBE_DEFER)
  3925. + return PTR_ERR(host->card_regulator);
  3926. + host->card_regulator = NULL;
  3927. + }
  3928. +
  3929. + /* Parse card power/reset/clock control */
  3930. + if (of_find_property(np, "card-reset-gpios", NULL)) {
  3931. + struct gpio_desc *gpd;
  3932. + int level = 0;
  3933. +
  3934. + /*
  3935. + * If the regulator is enabled, then we can hold the
  3936. + * card in reset with an active high resets. Otherwise,
  3937. + * hold the resets low.
  3938. + */
  3939. + if (host->card_regulator && regulator_is_enabled(host->card_regulator))
  3940. + level = 1;
  3941. +
  3942. + for (i = 0; i < ARRAY_SIZE(host->card_reset_gpios); i++) {
  3943. + gpd = devm_gpiod_get_index(host->parent, "card-reset", i);
  3944. + if (IS_ERR(gpd)) {
  3945. + if (PTR_ERR(gpd) == -EPROBE_DEFER)
  3946. + return PTR_ERR(gpd);
  3947. + break;
  3948. + }
  3949. + gpiod_direction_output(gpd, gpiod_is_active_low(gpd) | level);
  3950. + host->card_reset_gpios[i] = gpd;
  3951. + }
  3952. +
  3953. + gpd = devm_gpiod_get_index(host->parent, "card-reset", ARRAY_SIZE(host->card_reset_gpios));
  3954. + if (!IS_ERR(gpd)) {
  3955. + dev_warn(host->parent, "More reset gpios than we can handle");
  3956. + gpiod_put(gpd);
  3957. + }
  3958. + }
  3959. +
  3960. + clk = of_clk_get_by_name(np, "card_ext_clock");
  3961. + if (IS_ERR(clk)) {
  3962. + if (PTR_ERR(clk) == -EPROBE_DEFER)
  3963. + return PTR_ERR(clk);
  3964. + clk = NULL;
  3965. + }
  3966. + host->card_clk = clk;
  3967. +
  3968. + return 0;
  3969. +}
  3970. +
  3971. /**
  3972. * mmc_alloc_host - initialise the per-host structure.
  3973. * @extra: sizeof private data structure
  3974. @@ -540,6 +604,10 @@
  3975. {
  3976. int err;
  3977. + err = mmc_of_parse_child(host);
  3978. + if (err)
  3979. + return err;
  3980. +
  3981. WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
  3982. !host->ops->enable_sdio_irq);
  3983. diff -Nur linux-3.16.6.orig/drivers/mmc/host/dw_mmc.c linux-3.16.6/drivers/mmc/host/dw_mmc.c
  3984. --- linux-3.16.6.orig/drivers/mmc/host/dw_mmc.c 2014-10-15 05:05:43.000000000 -0500
  3985. +++ linux-3.16.6/drivers/mmc/host/dw_mmc.c 2014-10-23 12:34:26.238219996 -0500
  3986. @@ -2049,6 +2049,8 @@
  3987. if (!mmc)
  3988. return -ENOMEM;
  3989. + mmc_of_parse(mmc);
  3990. +
  3991. slot = mmc_priv(mmc);
  3992. slot->id = id;
  3993. slot->mmc = mmc;
  3994. diff -Nur linux-3.16.6.orig/drivers/mmc/host/Kconfig linux-3.16.6/drivers/mmc/host/Kconfig
  3995. --- linux-3.16.6.orig/drivers/mmc/host/Kconfig 2014-10-15 05:05:43.000000000 -0500
  3996. +++ linux-3.16.6/drivers/mmc/host/Kconfig 2014-10-23 12:34:04.318220041 -0500
  3997. @@ -25,8 +25,7 @@
  3998. If unsure, say N.
  3999. config MMC_SDHCI
  4000. - tristate "Secure Digital Host Controller Interface support"
  4001. - depends on HAS_DMA
  4002. + tristate
  4003. help
  4004. This selects the generic Secure Digital Host Controller Interface.
  4005. It is used by manufacturers such as Texas Instruments(R), Ricoh(R)
  4006. @@ -59,7 +58,8 @@
  4007. config MMC_SDHCI_PCI
  4008. tristate "SDHCI support on PCI bus"
  4009. - depends on MMC_SDHCI && PCI
  4010. + depends on PCI && HAS_DMA
  4011. + select MMC_SDHCI
  4012. help
  4013. This selects the PCI Secure Digital Host Controller Interface.
  4014. Most controllers found today are PCI devices.
  4015. @@ -83,7 +83,8 @@
  4016. config MMC_SDHCI_ACPI
  4017. tristate "SDHCI support for ACPI enumerated SDHCI controllers"
  4018. - depends on MMC_SDHCI && ACPI
  4019. + depends on ACPI && HAS_DMA
  4020. + select MMC_SDHCI
  4021. help
  4022. This selects support for ACPI enumerated SDHCI controllers,
  4023. identified by ACPI Compatibility ID PNP0D40 or specific
  4024. @@ -94,8 +95,8 @@
  4025. If unsure, say N.
  4026. config MMC_SDHCI_PLTFM
  4027. - tristate "SDHCI platform and OF driver helper"
  4028. - depends on MMC_SDHCI
  4029. + tristate
  4030. + select MMC_SDHCI
  4031. help
  4032. This selects the common helper functions support for Secure Digital
  4033. Host Controller Interface based platform and OF drivers.
  4034. @@ -106,8 +107,8 @@
  4035. config MMC_SDHCI_OF_ARASAN
  4036. tristate "SDHCI OF support for the Arasan SDHCI controllers"
  4037. - depends on MMC_SDHCI_PLTFM
  4038. - depends on OF
  4039. + depends on OF && HAS_DMA
  4040. + select MMC_SDHCI_PLTFM
  4041. help
  4042. This selects the Arasan Secure Digital Host Controller Interface
  4043. (SDHCI). This hardware is found e.g. in Xilinx' Zynq SoC.
  4044. @@ -118,9 +119,9 @@
  4045. config MMC_SDHCI_OF_ESDHC
  4046. tristate "SDHCI OF support for the Freescale eSDHC controller"
  4047. - depends on MMC_SDHCI_PLTFM
  4048. - depends on PPC_OF
  4049. + depends on PPC_OF && HAS_DMA
  4050. select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
  4051. + select MMC_SDHCI_PLTFM
  4052. help
  4053. This selects the Freescale eSDHC controller support.
  4054. @@ -130,9 +131,9 @@
  4055. config MMC_SDHCI_OF_HLWD
  4056. tristate "SDHCI OF support for the Nintendo Wii SDHCI controllers"
  4057. - depends on MMC_SDHCI_PLTFM
  4058. - depends on PPC_OF
  4059. + depends on PPC_OF && HAS_DMA
  4060. select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
  4061. + select MMC_SDHCI_PLTFM
  4062. help
  4063. This selects the Secure Digital Host Controller Interface (SDHCI)
  4064. found in the "Hollywood" chipset of the Nintendo Wii video game
  4065. @@ -144,8 +145,8 @@
  4066. config MMC_SDHCI_CNS3XXX
  4067. tristate "SDHCI support on the Cavium Networks CNS3xxx SoC"
  4068. - depends on ARCH_CNS3XXX
  4069. - depends on MMC_SDHCI_PLTFM
  4070. + depends on ARCH_CNS3XXX && HAS_DMA
  4071. + select MMC_SDHCI_PLTFM
  4072. help
  4073. This selects the SDHCI support for CNS3xxx System-on-Chip devices.
  4074. @@ -155,9 +156,9 @@
  4075. config MMC_SDHCI_ESDHC_IMX
  4076. tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller"
  4077. - depends on ARCH_MXC
  4078. - depends on MMC_SDHCI_PLTFM
  4079. + depends on ARCH_MXC && HAS_DMA
  4080. select MMC_SDHCI_IO_ACCESSORS
  4081. + select MMC_SDHCI_PLTFM
  4082. help
  4083. This selects the Freescale eSDHC/uSDHC controller support
  4084. found on i.MX25, i.MX35 i.MX5x and i.MX6x.
  4085. @@ -168,9 +169,9 @@
  4086. config MMC_SDHCI_DOVE
  4087. tristate "SDHCI support on Marvell's Dove SoC"
  4088. - depends on ARCH_DOVE || MACH_DOVE
  4089. - depends on MMC_SDHCI_PLTFM
  4090. + depends on (ARCH_DOVE || MACH_DOVE) && HAS_DMA
  4091. select MMC_SDHCI_IO_ACCESSORS
  4092. + select MMC_SDHCI_PLTFM
  4093. help
  4094. This selects the Secure Digital Host Controller Interface in
  4095. Marvell's Dove SoC.
  4096. @@ -181,9 +182,9 @@
  4097. config MMC_SDHCI_TEGRA
  4098. tristate "SDHCI platform support for the Tegra SD/MMC Controller"
  4099. - depends on ARCH_TEGRA
  4100. - depends on MMC_SDHCI_PLTFM
  4101. + depends on ARCH_TEGRA && HAS_DMA
  4102. select MMC_SDHCI_IO_ACCESSORS
  4103. + select MMC_SDHCI_PLTFM
  4104. help
  4105. This selects the Tegra SD/MMC controller. If you have a Tegra
  4106. platform with SD or MMC devices, say Y or M here.
  4107. @@ -192,7 +193,8 @@
  4108. config MMC_SDHCI_S3C
  4109. tristate "SDHCI support on Samsung S3C SoC"
  4110. - depends on MMC_SDHCI && PLAT_SAMSUNG
  4111. + depends on PLAT_SAMSUNG && HAS_DMA
  4112. + select MMC_SDHCI
  4113. help
  4114. This selects the Secure Digital Host Controller Interface (SDHCI)
  4115. often referrered to as the HSMMC block in some of the Samsung S3C
  4116. @@ -204,8 +206,8 @@
  4117. config MMC_SDHCI_SIRF
  4118. tristate "SDHCI support on CSR SiRFprimaII and SiRFmarco SoCs"
  4119. - depends on ARCH_SIRF
  4120. - depends on MMC_SDHCI_PLTFM
  4121. + depends on ARCH_SIRF && HAS_DMA
  4122. + select MMC_SDHCI_PLTFM
  4123. help
  4124. This selects the SDHCI support for SiRF System-on-Chip devices.
  4125. @@ -215,8 +217,8 @@
  4126. config MMC_SDHCI_PXAV3
  4127. tristate "Marvell MMP2 SD Host Controller support (PXAV3)"
  4128. - depends on CLKDEV_LOOKUP
  4129. - depends on MMC_SDHCI_PLTFM
  4130. + depends on CLKDEV_LOOKUP && HAS_DMA
  4131. + select MMC_SDHCI_PLTFM
  4132. default CPU_MMP2
  4133. help
  4134. This selects the Marvell(R) PXAV3 SD Host Controller.
  4135. @@ -227,8 +229,8 @@
  4136. config MMC_SDHCI_PXAV2
  4137. tristate "Marvell PXA9XX SD Host Controller support (PXAV2)"
  4138. - depends on CLKDEV_LOOKUP
  4139. - depends on MMC_SDHCI_PLTFM
  4140. + depends on CLKDEV_LOOKUP && HAS_DMA
  4141. + select MMC_SDHCI_PLTFM
  4142. default CPU_PXA910
  4143. help
  4144. This selects the Marvell(R) PXAV2 SD Host Controller.
  4145. @@ -239,7 +241,8 @@
  4146. config MMC_SDHCI_SPEAR
  4147. tristate "SDHCI support on ST SPEAr platform"
  4148. - depends on MMC_SDHCI && PLAT_SPEAR
  4149. + depends on PLAT_SPEAR && HAS_DMA
  4150. + select MMC_SDHCI
  4151. help
  4152. This selects the Secure Digital Host Controller Interface (SDHCI)
  4153. often referrered to as the HSMMC block in some of the ST SPEAR range
  4154. @@ -261,8 +264,8 @@
  4155. config MMC_SDHCI_BCM_KONA
  4156. tristate "SDHCI support on Broadcom KONA platform"
  4157. - depends on ARCH_BCM_MOBILE
  4158. - depends on MMC_SDHCI_PLTFM
  4159. + depends on ARCH_BCM_MOBILE && HAS_DMA
  4160. + select MMC_SDHCI_PLTFM
  4161. help
  4162. This selects the Broadcom Kona Secure Digital Host Controller
  4163. Interface(SDHCI) support.
  4164. @@ -272,9 +275,9 @@
  4165. config MMC_SDHCI_BCM2835
  4166. tristate "SDHCI platform support for the BCM2835 SD/MMC Controller"
  4167. - depends on ARCH_BCM2835
  4168. - depends on MMC_SDHCI_PLTFM
  4169. + depends on ARCH_BCM2835 && HAS_DMA
  4170. select MMC_SDHCI_IO_ACCESSORS
  4171. + select MMC_SDHCI_PLTFM
  4172. help
  4173. This selects the BCM2835 SD/MMC controller. If you have a BCM2835
  4174. platform with SD or MMC devices, say Y or M here.
  4175. diff -Nur linux-3.16.6.orig/drivers/mmc/host/sdhci.c linux-3.16.6/drivers/mmc/host/sdhci.c
  4176. --- linux-3.16.6.orig/drivers/mmc/host/sdhci.c 2014-10-15 05:05:43.000000000 -0500
  4177. +++ linux-3.16.6/drivers/mmc/host/sdhci.c 2014-10-23 12:34:10.650220104 -0500
  4178. @@ -1530,7 +1530,6 @@
  4179. host->ops->set_clock(host, host->clock);
  4180. }
  4181. -
  4182. /* Reset SD Clock Enable */
  4183. clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
  4184. clk &= ~SDHCI_CLOCK_CARD_EN;
  4185. @@ -1763,9 +1762,6 @@
  4186. ctrl |= SDHCI_CTRL_VDD_180;
  4187. sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
  4188. - /* Wait for 5ms */
  4189. - usleep_range(5000, 5500);
  4190. -
  4191. /* 1.8V regulator output should be stable within 5 ms */
  4192. ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
  4193. if (ctrl & SDHCI_CTRL_VDD_180)
  4194. diff -Nur linux-3.16.6.orig/drivers/regulator/anatop-regulator.c linux-3.16.6/drivers/regulator/anatop-regulator.c
  4195. --- linux-3.16.6.orig/drivers/regulator/anatop-regulator.c 2014-10-15 05:05:43.000000000 -0500
  4196. +++ linux-3.16.6/drivers/regulator/anatop-regulator.c 2014-10-23 12:36:22.798219997 -0500
  4197. @@ -267,6 +267,7 @@
  4198. config.driver_data = sreg;
  4199. config.of_node = pdev->dev.of_node;
  4200. config.regmap = sreg->anatop;
  4201. + config.ena_gpio = -EINVAL;
  4202. /* Only core regulators have the ramp up delay configuration. */
  4203. if (sreg->control_reg && sreg->delay_bit_width) {
  4204. diff -Nur linux-3.16.6.orig/drivers/regulator/core.c linux-3.16.6/drivers/regulator/core.c
  4205. --- linux-3.16.6.orig/drivers/regulator/core.c 2014-10-15 05:05:43.000000000 -0500
  4206. +++ linux-3.16.6/drivers/regulator/core.c 2014-10-23 12:36:22.802220004 -0500
  4207. @@ -24,6 +24,7 @@
  4208. #include <linux/suspend.h>
  4209. #include <linux/delay.h>
  4210. #include <linux/gpio.h>
  4211. +#include <linux/gpio/consumer.h>
  4212. #include <linux/of.h>
  4213. #include <linux/regmap.h>
  4214. #include <linux/regulator/of_regulator.h>
  4215. @@ -77,7 +78,7 @@
  4216. */
  4217. struct regulator_enable_gpio {
  4218. struct list_head list;
  4219. - int gpio;
  4220. + struct gpio_desc *gpiod;
  4221. u32 enable_count; /* a number of enabled shared GPIO */
  4222. u32 request_count; /* a number of requested shared GPIO */
  4223. unsigned int ena_gpio_invert:1;
  4224. @@ -1660,10 +1661,13 @@
  4225. const struct regulator_config *config)
  4226. {
  4227. struct regulator_enable_gpio *pin;
  4228. + struct gpio_desc *gpiod;
  4229. int ret;
  4230. + gpiod = gpio_to_desc(config->ena_gpio);
  4231. +
  4232. list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
  4233. - if (pin->gpio == config->ena_gpio) {
  4234. + if (pin->gpiod == gpiod) {
  4235. rdev_dbg(rdev, "GPIO %d is already used\n",
  4236. config->ena_gpio);
  4237. goto update_ena_gpio_to_rdev;
  4238. @@ -1682,7 +1686,7 @@
  4239. return -ENOMEM;
  4240. }
  4241. - pin->gpio = config->ena_gpio;
  4242. + pin->gpiod = gpiod;
  4243. pin->ena_gpio_invert = config->ena_gpio_invert;
  4244. list_add(&pin->list, &regulator_ena_gpio_list);
  4245. @@ -1701,10 +1705,10 @@
  4246. /* Free the GPIO only in case of no use */
  4247. list_for_each_entry_safe(pin, n, &regulator_ena_gpio_list, list) {
  4248. - if (pin->gpio == rdev->ena_pin->gpio) {
  4249. + if (pin->gpiod == rdev->ena_pin->gpiod) {
  4250. if (pin->request_count <= 1) {
  4251. pin->request_count = 0;
  4252. - gpio_free(pin->gpio);
  4253. + gpiod_put(pin->gpiod);
  4254. list_del(&pin->list);
  4255. kfree(pin);
  4256. } else {
  4257. @@ -1732,8 +1736,8 @@
  4258. if (enable) {
  4259. /* Enable GPIO at initial use */
  4260. if (pin->enable_count == 0)
  4261. - gpio_set_value_cansleep(pin->gpio,
  4262. - !pin->ena_gpio_invert);
  4263. + gpiod_set_value_cansleep(pin->gpiod,
  4264. + !pin->ena_gpio_invert);
  4265. pin->enable_count++;
  4266. } else {
  4267. @@ -1744,8 +1748,8 @@
  4268. /* Disable GPIO if not used */
  4269. if (pin->enable_count <= 1) {
  4270. - gpio_set_value_cansleep(pin->gpio,
  4271. - pin->ena_gpio_invert);
  4272. + gpiod_set_value_cansleep(pin->gpiod,
  4273. + pin->ena_gpio_invert);
  4274. pin->enable_count = 0;
  4275. }
  4276. }
  4277. @@ -3470,7 +3474,7 @@
  4278. dev_set_drvdata(&rdev->dev, rdev);
  4279. - if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) {
  4280. + if (gpio_is_valid(config->ena_gpio)) {
  4281. ret = regulator_ena_gpio_request(rdev, config);
  4282. if (ret != 0) {
  4283. rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
  4284. diff -Nur linux-3.16.6.orig/drivers/regulator/dummy.c linux-3.16.6/drivers/regulator/dummy.c
  4285. --- linux-3.16.6.orig/drivers/regulator/dummy.c 2014-10-15 05:05:43.000000000 -0500
  4286. +++ linux-3.16.6/drivers/regulator/dummy.c 2014-10-23 12:36:22.810220006 -0500
  4287. @@ -48,6 +48,7 @@
  4288. config.dev = &pdev->dev;
  4289. config.init_data = &dummy_initdata;
  4290. + config.ena_gpio = -EINVAL;
  4291. dummy_regulator_rdev = regulator_register(&dummy_desc, &config);
  4292. if (IS_ERR(dummy_regulator_rdev)) {
  4293. diff -Nur linux-3.16.6.orig/drivers/regulator/fixed.c linux-3.16.6/drivers/regulator/fixed.c
  4294. --- linux-3.16.6.orig/drivers/regulator/fixed.c 2014-10-15 05:05:43.000000000 -0500
  4295. +++ linux-3.16.6/drivers/regulator/fixed.c 2014-10-23 12:36:22.810220006 -0500
  4296. @@ -156,9 +156,7 @@
  4297. drvdata->desc.n_voltages = 1;
  4298. drvdata->desc.fixed_uV = config->microvolts;
  4299. -
  4300. - if (config->gpio >= 0)
  4301. - cfg.ena_gpio = config->gpio;
  4302. + cfg.ena_gpio = config->gpio;
  4303. cfg.ena_gpio_invert = !config->enable_high;
  4304. if (config->enabled_at_boot) {
  4305. if (config->enable_high)
  4306. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/drm-ddc-connector.c linux-3.16.6/drivers/staging/imx-drm/drm-ddc-connector.c
  4307. --- linux-3.16.6.orig/drivers/staging/imx-drm/drm-ddc-connector.c 1969-12-31 18:00:00.000000000 -0600
  4308. +++ linux-3.16.6/drivers/staging/imx-drm/drm-ddc-connector.c 2014-10-23 12:37:30.178219970 -0500
  4309. @@ -0,0 +1,88 @@
  4310. +#include <linux/i2c.h>
  4311. +#include <linux/module.h>
  4312. +#include <drm/drmP.h>
  4313. +#include <drm/drm_crtc_helper.h>
  4314. +#include <drm/drm_edid.h>
  4315. +
  4316. +#include "drm-ddc-connector.h"
  4317. +
  4318. +enum drm_connector_status
  4319. +drm_ddc_connector_always_connected(struct drm_connector *connector, bool force)
  4320. +{
  4321. + return connector_status_connected;
  4322. +}
  4323. +EXPORT_SYMBOL_GPL(drm_ddc_connector_always_connected);
  4324. +
  4325. +int drm_ddc_connector_get_modes(struct drm_connector *connector)
  4326. +{
  4327. + struct drm_ddc_connector *ddc_conn = to_ddc_conn(connector);
  4328. + struct edid *edid;
  4329. + int ret = 0;
  4330. +
  4331. + if (!ddc_conn->ddc)
  4332. + return 0;
  4333. +
  4334. + edid = drm_get_edid(connector, ddc_conn->ddc);
  4335. + if (edid) {
  4336. + drm_mode_connector_update_edid_property(connector, edid);
  4337. + ret = drm_add_edid_modes(connector, edid);
  4338. + /* Store the ELD */
  4339. + drm_edid_to_eld(connector, edid);
  4340. + kfree(edid);
  4341. + }
  4342. +
  4343. + return ret;
  4344. +}
  4345. +EXPORT_SYMBOL_GPL(drm_ddc_connector_get_modes);
  4346. +
  4347. +void drm_ddc_connector_destroy(struct drm_connector *connector)
  4348. +{
  4349. + struct drm_ddc_connector *ddc_conn = to_ddc_conn(connector);
  4350. +
  4351. + pr_info("%s: %p\n", __func__, ddc_conn);
  4352. +
  4353. + drm_sysfs_connector_remove(connector);
  4354. + drm_connector_cleanup(connector);
  4355. + if (ddc_conn->ddc)
  4356. + i2c_put_adapter(ddc_conn->ddc);
  4357. + kfree(ddc_conn);
  4358. +}
  4359. +EXPORT_SYMBOL_GPL(drm_ddc_connector_destroy);
  4360. +
  4361. +void drm_ddc_connector_add(struct drm_device *drm,
  4362. + struct drm_ddc_connector *ddc_conn,
  4363. + struct drm_connector_funcs *funcs, int connector_type)
  4364. +{
  4365. + drm_connector_init(drm, &ddc_conn->connector, funcs, connector_type);
  4366. +}
  4367. +EXPORT_SYMBOL_GPL(drm_ddc_connector_add);
  4368. +
  4369. +struct drm_ddc_connector *drm_ddc_connector_create(struct drm_device *drm,
  4370. + struct device_node *np, void *private)
  4371. +{
  4372. + struct drm_ddc_connector *ddc_conn;
  4373. + struct device_node *ddc_node;
  4374. +
  4375. + ddc_conn = kzalloc(sizeof(*ddc_conn), GFP_KERNEL);
  4376. + if (!ddc_conn)
  4377. + return ERR_PTR(-ENOMEM);
  4378. +
  4379. + ddc_conn->private = private;
  4380. +
  4381. + ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
  4382. + if (ddc_node) {
  4383. + ddc_conn->ddc = of_find_i2c_adapter_by_node(ddc_node);
  4384. + of_node_put(ddc_node);
  4385. + if (!ddc_conn->ddc) {
  4386. + kfree(ddc_conn);
  4387. + return ERR_PTR(-EPROBE_DEFER);
  4388. + }
  4389. + }
  4390. +
  4391. + return ddc_conn;
  4392. +}
  4393. +EXPORT_SYMBOL_GPL(drm_ddc_connector_create);
  4394. +
  4395. +MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
  4396. +MODULE_DESCRIPTION("Generic DRM DDC connector module");
  4397. +MODULE_LICENSE("GPL v2");
  4398. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/drm-ddc-connector.h linux-3.16.6/drivers/staging/imx-drm/drm-ddc-connector.h
  4399. --- linux-3.16.6.orig/drivers/staging/imx-drm/drm-ddc-connector.h 1969-12-31 18:00:00.000000000 -0600
  4400. +++ linux-3.16.6/drivers/staging/imx-drm/drm-ddc-connector.h 2014-10-23 12:37:30.178219970 -0500
  4401. @@ -0,0 +1,31 @@
  4402. +#ifndef DRM_DDC_CONNECTOR_H
  4403. +#define DRM_DDC_CONNECTOR_H
  4404. +
  4405. +#include <drm/drm_crtc.h>
  4406. +
  4407. +struct drm_ddc_connector {
  4408. + struct i2c_adapter *ddc;
  4409. + struct drm_connector connector;
  4410. + void *private;
  4411. +};
  4412. +
  4413. +#define to_ddc_conn(c) container_of(c, struct drm_ddc_connector, connector)
  4414. +
  4415. +enum drm_connector_status drm_ddc_connector_always_connected(
  4416. + struct drm_connector *connector, bool force);
  4417. +int drm_ddc_connector_get_modes(struct drm_connector *connector);
  4418. +void drm_ddc_connector_add(struct drm_device *drm,
  4419. + struct drm_ddc_connector *ddc_conn,
  4420. + struct drm_connector_funcs *funcs, int connector_type);
  4421. +void drm_ddc_connector_destroy(struct drm_connector *connector);
  4422. +struct drm_ddc_connector *drm_ddc_connector_create(struct drm_device *drm,
  4423. + struct device_node *np, void *private);
  4424. +
  4425. +static inline void *drm_ddc_private(struct drm_connector *connector)
  4426. +{
  4427. + struct drm_ddc_connector *ddc_conn = to_ddc_conn(connector);
  4428. +
  4429. + return ddc_conn->private;
  4430. +}
  4431. +
  4432. +#endif
  4433. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-audio.c linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-audio.c
  4434. --- linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-audio.c 1969-12-31 18:00:00.000000000 -0600
  4435. +++ linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-audio.c 2014-10-23 12:37:11.394219951 -0500
  4436. @@ -0,0 +1,654 @@
  4437. +/*
  4438. + * DesignWare HDMI audio driver
  4439. + *
  4440. + * This program is free software; you can redistribute it and/or modify
  4441. + * it under the terms of the GNU General Public License version 2 as
  4442. + * published by the Free Software Foundation.
  4443. + *
  4444. + * Written and tested against the (alleged) DW HDMI Tx found in iMX6S.
  4445. + */
  4446. +#include <linux/delay.h>
  4447. +#include <linux/io.h>
  4448. +#include <linux/interrupt.h>
  4449. +#include <linux/module.h>
  4450. +#include <linux/platform_device.h>
  4451. +
  4452. +#include <sound/asoundef.h>
  4453. +#include <sound/core.h>
  4454. +#include <sound/initval.h>
  4455. +#include <sound/pcm.h>
  4456. +
  4457. +#include "dw-hdmi-audio.h"
  4458. +
  4459. +#define DRIVER_NAME "dw-hdmi-audio"
  4460. +
  4461. +/* Provide some bits rather than bit offsets */
  4462. +enum {
  4463. + HDMI_AHB_DMA_CONF0_SW_FIFO_RST = BIT(7),
  4464. + HDMI_AHB_DMA_CONF0_EN_HLOCK = BIT(3),
  4465. + HDMI_AHB_DMA_START_START = BIT(0),
  4466. + HDMI_AHB_DMA_STOP_STOP = BIT(0),
  4467. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_ERROR = BIT(5),
  4468. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_LOST = BIT(4),
  4469. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_RETRY = BIT(3),
  4470. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_DONE = BIT(2),
  4471. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_BUFFFULL = BIT(1),
  4472. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_BUFFEMPTY = BIT(0),
  4473. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL =
  4474. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_ERROR |
  4475. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_LOST |
  4476. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_RETRY |
  4477. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_DONE |
  4478. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_BUFFFULL |
  4479. + HDMI_IH_MUTE_AHBDMAAUD_STAT0_BUFFEMPTY,
  4480. + HDMI_IH_AHBDMAAUD_STAT0_ERROR = BIT(5),
  4481. + HDMI_IH_AHBDMAAUD_STAT0_LOST = BIT(4),
  4482. + HDMI_IH_AHBDMAAUD_STAT0_RETRY = BIT(3),
  4483. + HDMI_IH_AHBDMAAUD_STAT0_DONE = BIT(2),
  4484. + HDMI_IH_AHBDMAAUD_STAT0_BUFFFULL = BIT(1),
  4485. + HDMI_IH_AHBDMAAUD_STAT0_BUFFEMPTY = BIT(0),
  4486. + HDMI_IH_AHBDMAAUD_STAT0_ALL =
  4487. + HDMI_IH_AHBDMAAUD_STAT0_ERROR |
  4488. + HDMI_IH_AHBDMAAUD_STAT0_LOST |
  4489. + HDMI_IH_AHBDMAAUD_STAT0_RETRY |
  4490. + HDMI_IH_AHBDMAAUD_STAT0_DONE |
  4491. + HDMI_IH_AHBDMAAUD_STAT0_BUFFFULL |
  4492. + HDMI_IH_AHBDMAAUD_STAT0_BUFFEMPTY,
  4493. + HDMI_AHB_DMA_CONF0_INCR16 = 2 << 1,
  4494. + HDMI_AHB_DMA_CONF0_INCR8 = 1 << 1,
  4495. + HDMI_AHB_DMA_CONF0_INCR4 = 0,
  4496. + HDMI_AHB_DMA_CONF0_BURST_MODE = BIT(0),
  4497. + HDMI_AHB_DMA_MASK_DONE = BIT(7),
  4498. + HDMI_REVISION_ID = 0x0001,
  4499. + HDMI_IH_AHBDMAAUD_STAT0 = 0x0109,
  4500. + HDMI_IH_MUTE_AHBDMAAUD_STAT0 = 0x0189,
  4501. + HDMI_AUD_N1 = 0x3200,
  4502. + HDMI_AUD_CTS1 = 0x3203,
  4503. + HDMI_AHB_DMA_CONF0 = 0x3600,
  4504. + HDMI_AHB_DMA_START = 0x3601,
  4505. + HDMI_AHB_DMA_STOP = 0x3602,
  4506. + HDMI_AHB_DMA_THRSLD = 0x3603,
  4507. + HDMI_AHB_DMA_STRADDR0 = 0x3604,
  4508. + HDMI_AHB_DMA_STPADDR0 = 0x3608,
  4509. + HDMI_AHB_DMA_STAT = 0x3612,
  4510. + HDMI_AHB_DMA_STAT_FULL = BIT(1),
  4511. + HDMI_AHB_DMA_MASK = 0x3614,
  4512. + HDMI_AHB_DMA_POL = 0x3615,
  4513. + HDMI_AHB_DMA_CONF1 = 0x3616,
  4514. + HDMI_AHB_DMA_BUFFPOL = 0x361a,
  4515. +};
  4516. +
  4517. +struct snd_dw_hdmi {
  4518. + struct snd_card *card;
  4519. + struct snd_pcm *pcm;
  4520. + struct dw_hdmi_audio_data data;
  4521. + struct snd_pcm_substream *substream;
  4522. + void (*reformat)(struct snd_dw_hdmi *, size_t, size_t);
  4523. + void *buf_src;
  4524. + void *buf_dst;
  4525. + dma_addr_t buf_addr;
  4526. + unsigned buf_offset;
  4527. + unsigned buf_period;
  4528. + unsigned buf_size;
  4529. + unsigned channels;
  4530. + uint8_t revision;
  4531. + uint8_t iec_offset;
  4532. + uint8_t cs[192][8];
  4533. +};
  4534. +
  4535. +static void dw_hdmi_writel(unsigned long val, void __iomem *ptr)
  4536. +{
  4537. + writeb_relaxed(val, ptr);
  4538. + writeb_relaxed(val >> 8, ptr + 1);
  4539. + writeb_relaxed(val >> 16, ptr + 2);
  4540. + writeb_relaxed(val >> 24, ptr + 3);
  4541. +}
  4542. +
  4543. +/*
  4544. + * Convert to hardware format: The userspace buffer contains IEC958 samples,
  4545. + * with the PCUV bits in bits 31..28 and audio samples in bits 27..4. We
  4546. + * need these to be in bits 27..24, with the IEC B bit in bit 28, and audio
  4547. + * samples in 23..0.
  4548. + *
  4549. + * Default preamble in bits 3..0: 8 = block start, 4 = even 2 = odd
  4550. + *
  4551. + * Ideally, we could do with having the data properly formatted in userspace.
  4552. + */
  4553. +static void dw_hdmi_reformat_iec958(struct snd_dw_hdmi *dw,
  4554. + size_t offset, size_t bytes)
  4555. +{
  4556. + uint32_t *src = dw->buf_src + offset;
  4557. + uint32_t *dst = dw->buf_dst + offset;
  4558. + uint32_t *end = dw->buf_src + offset + bytes;
  4559. +
  4560. + do {
  4561. + uint32_t b, sample = *src++;
  4562. +
  4563. + b = (sample & 8) << (28 - 3);
  4564. +
  4565. + sample >>= 4;
  4566. +
  4567. + *dst++ = sample | b;
  4568. + } while (src < end);
  4569. +}
  4570. +
  4571. +static uint32_t parity(uint32_t sample)
  4572. +{
  4573. + sample ^= sample >> 16;
  4574. + sample ^= sample >> 8;
  4575. + sample ^= sample >> 4;
  4576. + sample ^= sample >> 2;
  4577. + sample ^= sample >> 1;
  4578. + return (sample & 1) << 27;
  4579. +}
  4580. +
  4581. +static void dw_hdmi_reformat_s24(struct snd_dw_hdmi *dw,
  4582. + size_t offset, size_t bytes)
  4583. +{
  4584. + uint32_t *src = dw->buf_src + offset;
  4585. + uint32_t *dst = dw->buf_dst + offset;
  4586. + uint32_t *end = dw->buf_src + offset + bytes;
  4587. +
  4588. + do {
  4589. + unsigned i;
  4590. + uint8_t *cs;
  4591. +
  4592. + cs = dw->cs[dw->iec_offset++];
  4593. + if (dw->iec_offset >= 192)
  4594. + dw->iec_offset = 0;
  4595. +
  4596. + i = dw->channels;
  4597. + do {
  4598. + uint32_t sample = *src++;
  4599. +
  4600. + sample &= ~0xff000000;
  4601. + sample |= *cs++ << 24;
  4602. + sample |= parity(sample & ~0xf8000000);
  4603. +
  4604. + *dst++ = sample;
  4605. + } while (--i);
  4606. + } while (src < end);
  4607. +}
  4608. +
  4609. +static void dw_hdmi_create_cs(struct snd_dw_hdmi *dw,
  4610. + struct snd_pcm_runtime *runtime)
  4611. +{
  4612. + uint8_t cs[4];
  4613. + unsigned ch, i, j;
  4614. +
  4615. + cs[0] = IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_NONE;
  4616. + cs[1] = IEC958_AES1_CON_GENERAL;
  4617. + cs[2] = IEC958_AES2_CON_SOURCE_UNSPEC;
  4618. + cs[3] = IEC958_AES3_CON_CLOCK_1000PPM;
  4619. +
  4620. + switch (runtime->rate) {
  4621. + case 32000:
  4622. + cs[3] |= IEC958_AES3_CON_FS_32000;
  4623. + break;
  4624. + case 44100:
  4625. + cs[3] |= IEC958_AES3_CON_FS_44100;
  4626. + break;
  4627. + case 48000:
  4628. + cs[3] |= IEC958_AES3_CON_FS_48000;
  4629. + break;
  4630. + case 88200:
  4631. + cs[3] |= IEC958_AES3_CON_FS_88200;
  4632. + break;
  4633. + case 96000:
  4634. + cs[3] |= IEC958_AES3_CON_FS_96000;
  4635. + break;
  4636. + case 176400:
  4637. + cs[3] |= IEC958_AES3_CON_FS_176400;
  4638. + break;
  4639. + case 192000:
  4640. + cs[3] |= IEC958_AES3_CON_FS_192000;
  4641. + break;
  4642. + }
  4643. +
  4644. + memset(dw->cs, 0, sizeof(dw->cs));
  4645. +
  4646. + for (ch = 0; ch < 8; ch++) {
  4647. + cs[2] &= ~IEC958_AES2_CON_CHANNEL;
  4648. + cs[2] |= (ch + 1) << 4;
  4649. +
  4650. + for (i = 0; i < ARRAY_SIZE(cs); i++) {
  4651. + unsigned c = cs[i];
  4652. +
  4653. + for (j = 0; j < 8; j++, c >>= 1)
  4654. + dw->cs[i * 8 + j][ch] = (c & 1) << 2;
  4655. + }
  4656. + }
  4657. + dw->cs[0][0] |= BIT(4);
  4658. +}
  4659. +
  4660. +static void dw_hdmi_start_dma(struct snd_dw_hdmi *dw)
  4661. +{
  4662. + void __iomem *base = dw->data.base;
  4663. + unsigned offset = dw->buf_offset;
  4664. + unsigned period = dw->buf_period;
  4665. + u32 start, stop;
  4666. +
  4667. + dw->reformat(dw, offset, period);
  4668. +
  4669. + /* Clear all irqs before enabling irqs and starting DMA */
  4670. + writeb_relaxed(HDMI_IH_AHBDMAAUD_STAT0_ALL,
  4671. + base + HDMI_IH_AHBDMAAUD_STAT0);
  4672. +
  4673. + start = dw->buf_addr + offset;
  4674. + stop = start + period - 1;
  4675. +
  4676. + /* Setup the hardware start/stop addresses */
  4677. + dw_hdmi_writel(start, base + HDMI_AHB_DMA_STRADDR0);
  4678. + dw_hdmi_writel(stop, base + HDMI_AHB_DMA_STPADDR0);
  4679. +
  4680. + writeb_relaxed((u8)~HDMI_AHB_DMA_MASK_DONE, base + HDMI_AHB_DMA_MASK);
  4681. + writeb(HDMI_AHB_DMA_START_START, base + HDMI_AHB_DMA_START);
  4682. +
  4683. + offset += period;
  4684. + if (offset >= dw->buf_size)
  4685. + offset = 0;
  4686. + dw->buf_offset = offset;
  4687. +}
  4688. +
  4689. +static void dw_hdmi_stop_dma(struct snd_dw_hdmi *dw)
  4690. +{
  4691. + dw->substream = NULL;
  4692. +
  4693. + /* Disable interrupts before disabling DMA */
  4694. + writeb_relaxed(~0, dw->data.base + HDMI_AHB_DMA_MASK);
  4695. + writeb_relaxed(HDMI_AHB_DMA_STOP_STOP, dw->data.base + HDMI_AHB_DMA_STOP);
  4696. + synchronize_irq(dw->data.irq);
  4697. +}
  4698. +
  4699. +static irqreturn_t snd_dw_hdmi_irq(int irq, void *data)
  4700. +{
  4701. + struct snd_dw_hdmi *dw = data;
  4702. + struct snd_pcm_substream *substream;
  4703. + unsigned stat;
  4704. +
  4705. + stat = readb_relaxed(dw->data.base + HDMI_IH_AHBDMAAUD_STAT0);
  4706. + if (!stat)
  4707. + return IRQ_NONE;
  4708. +
  4709. + writeb_relaxed(stat, dw->data.base + HDMI_IH_AHBDMAAUD_STAT0);
  4710. +
  4711. + substream = dw->substream;
  4712. + if (stat & HDMI_IH_AHBDMAAUD_STAT0_DONE && substream) {
  4713. + snd_pcm_period_elapsed(substream);
  4714. + if (dw->substream)
  4715. + dw_hdmi_start_dma(dw);
  4716. + }
  4717. +
  4718. + return IRQ_HANDLED;
  4719. +}
  4720. +
  4721. +static struct snd_pcm_hardware dw_hdmi_hw = {
  4722. + .info = SNDRV_PCM_INFO_INTERLEAVED |
  4723. + SNDRV_PCM_INFO_BLOCK_TRANSFER |
  4724. + SNDRV_PCM_INFO_MMAP |
  4725. + SNDRV_PCM_INFO_MMAP_VALID,
  4726. + .formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE |
  4727. + SNDRV_PCM_FMTBIT_S24_LE,
  4728. + .rates = SNDRV_PCM_RATE_32000 |
  4729. + SNDRV_PCM_RATE_44100 |
  4730. + SNDRV_PCM_RATE_48000 |
  4731. + SNDRV_PCM_RATE_88200 |
  4732. + SNDRV_PCM_RATE_96000 |
  4733. + SNDRV_PCM_RATE_176400 |
  4734. + SNDRV_PCM_RATE_192000,
  4735. + .channels_min = 2,
  4736. + .channels_max = 8,
  4737. + .buffer_bytes_max = 64 * 1024,
  4738. + .period_bytes_min = 256,
  4739. + .period_bytes_max = 8192, /* ERR004323: must limit to 8k */
  4740. + .periods_min = 2,
  4741. + .periods_max = 16,
  4742. + .fifo_size = 0,
  4743. +};
  4744. +
  4745. +static unsigned rates_mask[] = {
  4746. + SNDRV_PCM_RATE_32000,
  4747. + SNDRV_PCM_RATE_44100,
  4748. + SNDRV_PCM_RATE_48000,
  4749. + SNDRV_PCM_RATE_88200,
  4750. + SNDRV_PCM_RATE_96000,
  4751. + SNDRV_PCM_RATE_176400,
  4752. + SNDRV_PCM_RATE_192000,
  4753. +};
  4754. +
  4755. +static void dw_hdmi_parse_eld(struct snd_dw_hdmi *dw,
  4756. + struct snd_pcm_runtime *runtime)
  4757. +{
  4758. + u8 *sad, *eld = dw->data.eld;
  4759. + unsigned eld_ver, mnl, sad_count, rates, rate_mask, i;
  4760. + unsigned max_channels;
  4761. +
  4762. + eld_ver = eld[0] >> 3;
  4763. + if (eld_ver != 2 && eld_ver != 31)
  4764. + return;
  4765. +
  4766. + mnl = eld[4] & 0x1f;
  4767. + if (mnl > 16)
  4768. + return;
  4769. +
  4770. + sad_count = eld[5] >> 4;
  4771. + sad = eld + 20 + mnl;
  4772. +
  4773. + /* Start from the basic audio settings */
  4774. + max_channels = 2;
  4775. + rates = 7;
  4776. + while (sad_count > 0) {
  4777. + switch (sad[0] & 0x78) {
  4778. + case 0x08: /* PCM */
  4779. + max_channels = max(max_channels, (sad[0] & 7) + 1u);
  4780. + rates |= sad[1];
  4781. + break;
  4782. + }
  4783. + sad += 3;
  4784. + sad_count -= 1;
  4785. + }
  4786. +
  4787. + for (rate_mask = i = 0; i < ARRAY_SIZE(rates_mask); i++)
  4788. + if (rates & 1 << i)
  4789. + rate_mask |= rates_mask[i];
  4790. +
  4791. + runtime->hw.rates &= rate_mask;
  4792. + runtime->hw.channels_max = min(runtime->hw.channels_max, max_channels);
  4793. +}
  4794. +
  4795. +static int dw_hdmi_open(struct snd_pcm_substream *substream)
  4796. +{
  4797. + struct snd_pcm_runtime *runtime = substream->runtime;
  4798. + struct snd_dw_hdmi *dw = substream->private_data;
  4799. + void __iomem *base = dw->data.base;
  4800. + int ret;
  4801. +
  4802. + /* Clear FIFO */
  4803. + writeb_relaxed(HDMI_AHB_DMA_CONF0_SW_FIFO_RST,
  4804. + base + HDMI_AHB_DMA_CONF0);
  4805. +
  4806. + /* Configure interrupt polarities */
  4807. + writeb_relaxed(~0, base + HDMI_AHB_DMA_POL);
  4808. + writeb_relaxed(~0, base + HDMI_AHB_DMA_BUFFPOL);
  4809. +
  4810. + /* Keep interrupts masked, and clear any pending */
  4811. + writeb_relaxed(~0, base + HDMI_AHB_DMA_MASK);
  4812. + writeb_relaxed(~0, base + HDMI_IH_AHBDMAAUD_STAT0);
  4813. +
  4814. + ret = request_irq(dw->data.irq, snd_dw_hdmi_irq, IRQF_SHARED,
  4815. + "dw-hdmi-audio", dw);
  4816. + if (ret)
  4817. + return ret;
  4818. +
  4819. + /* Un-mute done interrupt */
  4820. + writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL &
  4821. + ~HDMI_IH_MUTE_AHBDMAAUD_STAT0_DONE,
  4822. + base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
  4823. +
  4824. + runtime->hw = dw_hdmi_hw;
  4825. + dw_hdmi_parse_eld(dw, runtime);
  4826. + snd_pcm_limit_hw_rates(runtime);
  4827. + snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
  4828. +
  4829. + return 0;
  4830. +}
  4831. +
  4832. +static int dw_hdmi_close(struct snd_pcm_substream *substream)
  4833. +{
  4834. + struct snd_dw_hdmi *dw = substream->private_data;
  4835. +
  4836. + /* Mute all interrupts */
  4837. + writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
  4838. + dw->data.base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
  4839. +
  4840. + free_irq(dw->data.irq, dw);
  4841. +
  4842. + return 0;
  4843. +}
  4844. +
  4845. +static int dw_hdmi_hw_free(struct snd_pcm_substream *substream)
  4846. +{
  4847. + return snd_pcm_lib_free_vmalloc_buffer(substream);
  4848. +}
  4849. +
  4850. +static int dw_hdmi_hw_params(struct snd_pcm_substream *substream,
  4851. + struct snd_pcm_hw_params *params)
  4852. +{
  4853. + return snd_pcm_lib_alloc_vmalloc_buffer(substream,
  4854. + params_buffer_bytes(params));
  4855. +}
  4856. +
  4857. +static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
  4858. +{
  4859. + struct snd_pcm_runtime *runtime = substream->runtime;
  4860. + struct snd_dw_hdmi *dw = substream->private_data;
  4861. + uint8_t threshold, conf0, conf1;
  4862. +
  4863. + /* Setup as per 3.0.5 FSL 4.1.0 BSP */
  4864. + switch (dw->revision) {
  4865. + case 0x0a:
  4866. + conf0 = HDMI_AHB_DMA_CONF0_BURST_MODE |
  4867. + HDMI_AHB_DMA_CONF0_INCR4;
  4868. + if (runtime->channels == 2)
  4869. + threshold = 126;
  4870. + else
  4871. + threshold = 124;
  4872. + break;
  4873. + case 0x1a:
  4874. + conf0 = HDMI_AHB_DMA_CONF0_BURST_MODE |
  4875. + HDMI_AHB_DMA_CONF0_INCR8;
  4876. + threshold = 128;
  4877. + break;
  4878. + default:
  4879. + /* NOTREACHED */
  4880. + return -EINVAL;
  4881. + }
  4882. +
  4883. + dw->data.set_sample_rate(dw->data.hdmi, runtime->rate);
  4884. +
  4885. + /* Minimum number of bytes in the fifo. */
  4886. + runtime->hw.fifo_size = threshold * 32;
  4887. +
  4888. + conf0 |= HDMI_AHB_DMA_CONF0_EN_HLOCK;
  4889. + conf1 = (1 << runtime->channels) - 1;
  4890. +
  4891. + writeb_relaxed(threshold, dw->data.base + HDMI_AHB_DMA_THRSLD);
  4892. + writeb_relaxed(conf0, dw->data.base + HDMI_AHB_DMA_CONF0);
  4893. + writeb_relaxed(conf1, dw->data.base + HDMI_AHB_DMA_CONF1);
  4894. +
  4895. + switch (runtime->format) {
  4896. + case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE:
  4897. + dw->reformat = dw_hdmi_reformat_iec958;
  4898. + break;
  4899. + case SNDRV_PCM_FORMAT_S24_LE:
  4900. + dw_hdmi_create_cs(dw, runtime);
  4901. + dw->reformat = dw_hdmi_reformat_s24;
  4902. + break;
  4903. + }
  4904. + dw->iec_offset = 0;
  4905. + dw->channels = runtime->channels;
  4906. + dw->buf_src = runtime->dma_area;
  4907. + dw->buf_dst = substream->dma_buffer.area;
  4908. + dw->buf_addr = substream->dma_buffer.addr;
  4909. + dw->buf_period = snd_pcm_lib_period_bytes(substream);
  4910. + dw->buf_size = snd_pcm_lib_buffer_bytes(substream);
  4911. +
  4912. + return 0;
  4913. +}
  4914. +
  4915. +static int dw_hdmi_trigger(struct snd_pcm_substream *substream, int cmd)
  4916. +{
  4917. + struct snd_dw_hdmi *dw = substream->private_data;
  4918. + void __iomem *base = dw->data.base;
  4919. + unsigned n[3], cts[3];
  4920. + int ret = 0, i;
  4921. + bool err005174;
  4922. +
  4923. + switch (cmd) {
  4924. + case SNDRV_PCM_TRIGGER_START:
  4925. + err005174 = dw->revision == 0x0a;
  4926. + if (err005174) {
  4927. + for (i = 2; i >= 1; i--) {
  4928. + n[i] = readb_relaxed(base + HDMI_AUD_N1 + i);
  4929. + cts[i] = readb_relaxed(base + HDMI_AUD_CTS1 + i);
  4930. + writeb_relaxed(0, base + HDMI_AUD_N1 + i);
  4931. + writeb_relaxed(0, base + HDMI_AUD_CTS1 + i);
  4932. + }
  4933. + }
  4934. +
  4935. + dw->buf_offset = 0;
  4936. + dw->substream = substream;
  4937. + dw_hdmi_start_dma(dw);
  4938. +
  4939. + if (err005174) {
  4940. + for (i = 2; i >= 1; i--)
  4941. + writeb_relaxed(cts[i], base + HDMI_AUD_CTS1 + i);
  4942. + for (i = 2; i >= 1; i--)
  4943. + writeb_relaxed(n[i], base + HDMI_AUD_N1 + i);
  4944. + }
  4945. +
  4946. + substream->runtime->delay = substream->runtime->period_size;
  4947. + break;
  4948. +
  4949. + case SNDRV_PCM_TRIGGER_STOP:
  4950. + dw_hdmi_stop_dma(dw);
  4951. + break;
  4952. +
  4953. + default:
  4954. + ret = -EINVAL;
  4955. + break;
  4956. + }
  4957. +
  4958. + return ret;
  4959. +}
  4960. +
  4961. +static snd_pcm_uframes_t dw_hdmi_pointer(struct snd_pcm_substream *substream)
  4962. +{
  4963. + struct snd_pcm_runtime *runtime = substream->runtime;
  4964. + struct snd_dw_hdmi *dw = substream->private_data;
  4965. +
  4966. + return bytes_to_frames(runtime, dw->buf_offset);
  4967. +}
  4968. +
  4969. +static struct snd_pcm_ops snd_dw_hdmi_ops = {
  4970. + .open = dw_hdmi_open,
  4971. + .close = dw_hdmi_close,
  4972. + .ioctl = snd_pcm_lib_ioctl,
  4973. + .hw_params = dw_hdmi_hw_params,
  4974. + .hw_free = dw_hdmi_hw_free,
  4975. + .prepare = dw_hdmi_prepare,
  4976. + .trigger = dw_hdmi_trigger,
  4977. + .pointer = dw_hdmi_pointer,
  4978. + .page = snd_pcm_lib_get_vmalloc_page,
  4979. +};
  4980. +
  4981. +static int snd_dw_hdmi_probe(struct platform_device *pdev)
  4982. +{
  4983. + const struct dw_hdmi_audio_data *data = pdev->dev.platform_data;
  4984. + struct device *dev = pdev->dev.parent;
  4985. + struct snd_dw_hdmi *dw;
  4986. + struct snd_card *card;
  4987. + struct snd_pcm *pcm;
  4988. + unsigned revision;
  4989. + int ret;
  4990. +
  4991. + writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
  4992. + data->base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
  4993. + revision = readb_relaxed(data->base + HDMI_REVISION_ID);
  4994. + if (revision != 0x0a && revision != 0x1a) {
  4995. + dev_err(dev, "dw-hdmi-audio: unknown revision 0x%02x\n",
  4996. + revision);
  4997. + return -ENXIO;
  4998. + }
  4999. +
  5000. + ret = snd_card_new(dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
  5001. + THIS_MODULE, sizeof(struct snd_dw_hdmi), &card);
  5002. + if (ret < 0)
  5003. + return ret;
  5004. +
  5005. + strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
  5006. + strlcpy(card->shortname, "DW-HDMI", sizeof(card->shortname));
  5007. + snprintf(card->longname, sizeof(card->longname),
  5008. + "%s rev 0x%02x, irq %d", card->shortname, revision,
  5009. + data->irq);
  5010. +
  5011. + dw = card->private_data;
  5012. + dw->card = card;
  5013. + dw->data = *data;
  5014. + dw->revision = revision;
  5015. +
  5016. + ret = snd_pcm_new(card, "DW HDMI", 0, 1, 0, &pcm);
  5017. + if (ret < 0)
  5018. + goto err;
  5019. +
  5020. + dw->pcm = pcm;
  5021. + pcm->private_data = dw;
  5022. + strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name));
  5023. + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dw_hdmi_ops);
  5024. +
  5025. + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
  5026. + dev, 64 * 1024, 64 * 1024);
  5027. +
  5028. + ret = snd_card_register(card);
  5029. + if (ret < 0)
  5030. + goto err;
  5031. +
  5032. + platform_set_drvdata(pdev, dw);
  5033. +
  5034. + return 0;
  5035. +
  5036. +err:
  5037. + snd_card_free(card);
  5038. + return ret;
  5039. +}
  5040. +
  5041. +static int snd_dw_hdmi_remove(struct platform_device *pdev)
  5042. +{
  5043. + struct snd_dw_hdmi *dw = platform_get_drvdata(pdev);
  5044. +
  5045. + snd_card_free(dw->card);
  5046. +
  5047. + return 0;
  5048. +}
  5049. +
  5050. +#ifdef CONFIG_PM_SLEEP
  5051. +static int snd_dw_hdmi_suspend(struct device *dev)
  5052. +{
  5053. + struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
  5054. +
  5055. + snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold);
  5056. + snd_pcm_suspend_all(dw->pcm);
  5057. +
  5058. + return 0;
  5059. +}
  5060. +
  5061. +static int snd_dw_hdmi_resume(struct device *dev)
  5062. +{
  5063. + struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
  5064. +
  5065. + snd_power_change_state(dw->card, SNDRV_CTL_POWER_D0);
  5066. +
  5067. + return 0;
  5068. +}
  5069. +
  5070. +static SIMPLE_DEV_PM_OPS(snd_dw_hdmi_pm, snd_dw_hdmi_suspend,
  5071. + snd_dw_hdmi_resume);
  5072. +#define PM_OPS &snd_dw_hdmi_pm
  5073. +#else
  5074. +#define PM_OPS NULL
  5075. +#endif
  5076. +
  5077. +static struct platform_driver snd_dw_hdmi_driver = {
  5078. + .probe = snd_dw_hdmi_probe,
  5079. + .remove = snd_dw_hdmi_remove,
  5080. + .driver = {
  5081. + .name = "dw-hdmi-audio",
  5082. + .owner = THIS_MODULE,
  5083. + .pm = PM_OPS,
  5084. + },
  5085. +};
  5086. +
  5087. +module_platform_driver(snd_dw_hdmi_driver);
  5088. +
  5089. +MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
  5090. +MODULE_LICENSE("GPL");
  5091. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-audio.h linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-audio.h
  5092. --- linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-audio.h 1969-12-31 18:00:00.000000000 -0600
  5093. +++ linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-audio.h 2014-10-23 12:36:44.258220010 -0500
  5094. @@ -0,0 +1,15 @@
  5095. +#ifndef DW_HDMI_AUDIO_H
  5096. +#define DW_HDMI_AUDIO_H
  5097. +
  5098. +struct imx_hdmi;
  5099. +
  5100. +struct dw_hdmi_audio_data {
  5101. + phys_addr_t phys;
  5102. + void __iomem *base;
  5103. + int irq;
  5104. + struct imx_hdmi *hdmi;
  5105. + u8 *eld;
  5106. + void (*set_sample_rate)(struct imx_hdmi *, unsigned);
  5107. +};
  5108. +
  5109. +#endif
  5110. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-cec.c linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-cec.c
  5111. --- linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-cec.c 1969-12-31 18:00:00.000000000 -0600
  5112. +++ linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-cec.c 2014-10-23 12:37:23.890220362 -0500
  5113. @@ -0,0 +1,207 @@
  5114. +/* http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/mxc/hdmi-cec/mxc_hdmi-cec.c?h=imx_3.0.35_4.1.0 */
  5115. +#include <linux/cec-dev.h>
  5116. +#include <linux/interrupt.h>
  5117. +#include <linux/io.h>
  5118. +#include <linux/module.h>
  5119. +#include <linux/platform_device.h>
  5120. +#include <linux/sched.h>
  5121. +#include <linux/slab.h>
  5122. +
  5123. +#include "imx-hdmi.h"
  5124. +#include "dw-hdmi-cec.h"
  5125. +
  5126. +#define DEV_NAME "mxc_hdmi_cec"
  5127. +
  5128. +enum {
  5129. + CEC_STAT_DONE = BIT(0),
  5130. + CEC_STAT_EOM = BIT(1),
  5131. + CEC_STAT_NACK = BIT(2),
  5132. + CEC_STAT_ARBLOST = BIT(3),
  5133. + CEC_STAT_ERROR_INIT = BIT(4),
  5134. + CEC_STAT_ERROR_FOLL = BIT(5),
  5135. + CEC_STAT_WAKEUP = BIT(6),
  5136. +
  5137. + CEC_CTRL_START = BIT(0),
  5138. + CEC_CTRL_NORMAL = 1 << 1,
  5139. +};
  5140. +
  5141. +struct dw_hdmi_cec {
  5142. + struct cec_dev cec;
  5143. +
  5144. + struct device *dev;
  5145. + void __iomem *base;
  5146. + const struct dw_hdmi_cec_ops *ops;
  5147. + void *ops_data;
  5148. + int irq;
  5149. +};
  5150. +
  5151. +static void dw_hdmi_set_address(struct cec_dev *cec_dev, unsigned addresses)
  5152. +{
  5153. + struct dw_hdmi_cec *cec = container_of(cec_dev, struct dw_hdmi_cec, cec);
  5154. +
  5155. + writeb(addresses & 255, cec->base + HDMI_CEC_ADDR_L);
  5156. + writeb(addresses >> 8, cec->base + HDMI_CEC_ADDR_H);
  5157. +}
  5158. +
  5159. +static void dw_hdmi_send_message(struct cec_dev *cec_dev, u8 *msg,
  5160. + size_t count)
  5161. +{
  5162. + struct dw_hdmi_cec *cec = container_of(cec_dev, struct dw_hdmi_cec, cec);
  5163. + unsigned i;
  5164. +
  5165. + for (i = 0; i < count; i++)
  5166. + writeb(msg[i], cec->base + HDMI_CEC_TX_DATA0 + i);
  5167. +
  5168. + writeb(count, cec->base + HDMI_CEC_TX_CNT);
  5169. + writeb(CEC_CTRL_NORMAL | CEC_CTRL_START, cec->base + HDMI_CEC_CTRL);
  5170. +}
  5171. +
  5172. +static irqreturn_t dw_hdmi_cec_irq(int irq, void *data)
  5173. +{
  5174. + struct dw_hdmi_cec *cec = data;
  5175. + struct cec_dev *cec_dev = &cec->cec;
  5176. + unsigned stat = readb(cec->base + HDMI_IH_CEC_STAT0);
  5177. +
  5178. + if (stat == 0)
  5179. + return IRQ_NONE;
  5180. +
  5181. + writeb(stat, cec->base + HDMI_IH_CEC_STAT0);
  5182. +
  5183. + if (stat & CEC_STAT_ERROR_INIT) {
  5184. + if (cec->cec.retries) {
  5185. + unsigned v = readb(cec->base + HDMI_CEC_CTRL);
  5186. + writeb(v | CEC_CTRL_START, cec->base + HDMI_CEC_CTRL);
  5187. + cec->cec.retries -= 1;
  5188. + } else {
  5189. + cec->cec.write_busy = 0;
  5190. + cec_dev_event(cec_dev, MESSAGE_TYPE_SEND_ERROR, NULL, 0);
  5191. + }
  5192. + } else if (stat & (CEC_STAT_DONE | CEC_STAT_NACK))
  5193. + cec_dev_send_complete(cec_dev, stat & CEC_STAT_DONE);
  5194. +
  5195. + if (stat & CEC_STAT_EOM) {
  5196. + unsigned len, i;
  5197. + u8 msg[MAX_MESSAGE_LEN];
  5198. +
  5199. + len = readb(cec->base + HDMI_CEC_RX_CNT);
  5200. + if (len > sizeof(msg))
  5201. + len = sizeof(msg);
  5202. +
  5203. + for (i = 0; i < len; i++)
  5204. + msg[i] = readb(cec->base + HDMI_CEC_RX_DATA0 + i);
  5205. +
  5206. + writeb(0, cec->base + HDMI_CEC_LOCK);
  5207. +
  5208. + cec_dev_receive(cec_dev, msg, len);
  5209. + }
  5210. +
  5211. + return IRQ_HANDLED;
  5212. +}
  5213. +EXPORT_SYMBOL(dw_hdmi_cec_irq);
  5214. +
  5215. +static void dw_hdmi_cec_release(struct cec_dev *cec_dev)
  5216. +{
  5217. + struct dw_hdmi_cec *cec = container_of(cec_dev, struct dw_hdmi_cec, cec);
  5218. +
  5219. + writeb(~0, cec->base + HDMI_CEC_MASK);
  5220. + writeb(~0, cec->base + HDMI_IH_MUTE_CEC_STAT0);
  5221. + writeb(0, cec->base + HDMI_CEC_POLARITY);
  5222. +
  5223. + free_irq(cec->irq, cec);
  5224. +
  5225. + cec->ops->disable(cec->ops_data);
  5226. +}
  5227. +
  5228. +static int dw_hdmi_cec_open(struct cec_dev *cec_dev)
  5229. +{
  5230. + struct dw_hdmi_cec *cec = container_of(cec_dev, struct dw_hdmi_cec, cec);
  5231. + unsigned irqs;
  5232. + int ret;
  5233. +
  5234. + writeb(0, cec->base + HDMI_CEC_CTRL);
  5235. + writeb(~0, cec->base + HDMI_IH_CEC_STAT0);
  5236. + writeb(0, cec->base + HDMI_CEC_LOCK);
  5237. +
  5238. + ret = request_irq(cec->irq, dw_hdmi_cec_irq, IRQF_SHARED,
  5239. + DEV_NAME, cec);
  5240. + if (ret < 0)
  5241. + return ret;
  5242. +
  5243. + dw_hdmi_set_address(cec_dev, cec_dev->addresses);
  5244. +
  5245. + cec->ops->enable(cec->ops_data);
  5246. +
  5247. + irqs = CEC_STAT_ERROR_INIT | CEC_STAT_NACK | CEC_STAT_EOM |
  5248. + CEC_STAT_DONE;
  5249. + writeb(irqs, cec->base + HDMI_CEC_POLARITY);
  5250. + writeb(~irqs, cec->base + HDMI_CEC_MASK);
  5251. + writeb(~irqs, cec->base + HDMI_IH_MUTE_CEC_STAT0);
  5252. +
  5253. + return 0;
  5254. +}
  5255. +
  5256. +static int dw_hdmi_cec_probe(struct platform_device *pdev)
  5257. +{
  5258. + struct dw_hdmi_cec_data *data = dev_get_platdata(&pdev->dev);
  5259. + struct dw_hdmi_cec *cec;
  5260. +
  5261. + if (!data)
  5262. + return -ENXIO;
  5263. +
  5264. + cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL);
  5265. + if (!cec)
  5266. + return -ENOMEM;
  5267. +
  5268. + cec->dev = &pdev->dev;
  5269. + cec->base = data->base;
  5270. + cec->irq = data->irq;
  5271. + cec->ops = data->ops;
  5272. + cec->ops_data = data->ops_data;
  5273. + cec->cec.open = dw_hdmi_cec_open;
  5274. + cec->cec.release = dw_hdmi_cec_release;
  5275. + cec->cec.send_message = dw_hdmi_send_message;
  5276. + cec->cec.set_address = dw_hdmi_set_address;
  5277. +
  5278. + cec_dev_init(&cec->cec, THIS_MODULE);
  5279. +
  5280. + /* FIXME: soft-reset the CEC interface */
  5281. +
  5282. + dw_hdmi_set_address(&cec->cec, cec->cec.addresses);
  5283. + writeb(0, cec->base + HDMI_CEC_TX_CNT);
  5284. + writeb(~0, cec->base + HDMI_CEC_MASK);
  5285. + writeb(~0, cec->base + HDMI_IH_MUTE_CEC_STAT0);
  5286. + writeb(0, cec->base + HDMI_CEC_POLARITY);
  5287. +
  5288. + platform_set_drvdata(pdev, cec);
  5289. +
  5290. + /*
  5291. + * Our device is just a convenience - we want to link to the real
  5292. + * hardware device here, so that userspace can see the association
  5293. + * between the HDMI hardware and its associated CEC chardev.
  5294. + */
  5295. + return cec_dev_add(&cec->cec, cec->dev->parent, DEV_NAME);
  5296. +}
  5297. +
  5298. +static int dw_hdmi_cec_remove(struct platform_device *pdev)
  5299. +{
  5300. + struct dw_hdmi_cec *cec = platform_get_drvdata(pdev);
  5301. +
  5302. + cec_dev_remove(&cec->cec);
  5303. +
  5304. + return 0;
  5305. +}
  5306. +
  5307. +static struct platform_driver dw_hdmi_cec_driver = {
  5308. + .probe = dw_hdmi_cec_probe,
  5309. + .remove = dw_hdmi_cec_remove,
  5310. + .driver = {
  5311. + .name = "dw-hdmi-cec",
  5312. + .owner = THIS_MODULE,
  5313. + },
  5314. +};
  5315. +module_platform_driver(dw_hdmi_cec_driver);
  5316. +
  5317. +MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
  5318. +MODULE_DESCRIPTION("Synopsis Designware HDMI CEC driver for i.MX");
  5319. +MODULE_LICENSE("GPL");
  5320. +MODULE_ALIAS(PLATFORM_MODULE_PREFIX "dw-hdmi-cec");
  5321. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-cec.h linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-cec.h
  5322. --- linux-3.16.6.orig/drivers/staging/imx-drm/dw-hdmi-cec.h 1969-12-31 18:00:00.000000000 -0600
  5323. +++ linux-3.16.6/drivers/staging/imx-drm/dw-hdmi-cec.h 2014-10-23 12:37:23.890220362 -0500
  5324. @@ -0,0 +1,16 @@
  5325. +#ifndef DW_HDMI_CEC_H
  5326. +#define DW_HDMI_CEC_H
  5327. +
  5328. +struct dw_hdmi_cec_ops {
  5329. + void (*enable)(void *);
  5330. + void (*disable)(void *);
  5331. +};
  5332. +
  5333. +struct dw_hdmi_cec_data {
  5334. + void __iomem *base;
  5335. + int irq;
  5336. + const struct dw_hdmi_cec_ops *ops;
  5337. + void *ops_data;
  5338. +};
  5339. +
  5340. +#endif
  5341. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-drm-core.c linux-3.16.6/drivers/staging/imx-drm/imx-drm-core.c
  5342. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-drm-core.c 2014-10-15 05:05:43.000000000 -0500
  5343. +++ linux-3.16.6/drivers/staging/imx-drm/imx-drm-core.c 2014-10-23 12:37:37.690220197 -0500
  5344. @@ -115,8 +115,7 @@
  5345. helper = &imx_crtc->imx_drm_helper_funcs;
  5346. if (helper->set_interface_pix_fmt)
  5347. return helper->set_interface_pix_fmt(encoder->crtc,
  5348. - encoder->encoder_type, interface_pix_fmt,
  5349. - hsync_pin, vsync_pin);
  5350. + interface_pix_fmt, hsync_pin, vsync_pin);
  5351. return 0;
  5352. }
  5353. EXPORT_SYMBOL_GPL(imx_drm_panel_format_pins);
  5354. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-drm.h linux-3.16.6/drivers/staging/imx-drm/imx-drm.h
  5355. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-drm.h 2014-10-15 05:05:43.000000000 -0500
  5356. +++ linux-3.16.6/drivers/staging/imx-drm/imx-drm.h 2014-10-23 12:37:37.690220197 -0500
  5357. @@ -17,7 +17,7 @@
  5358. struct imx_drm_crtc_helper_funcs {
  5359. int (*enable_vblank)(struct drm_crtc *crtc);
  5360. void (*disable_vblank)(struct drm_crtc *crtc);
  5361. - int (*set_interface_pix_fmt)(struct drm_crtc *crtc, u32 encoder_type,
  5362. + int (*set_interface_pix_fmt)(struct drm_crtc *crtc,
  5363. u32 pix_fmt, int hsync_pin, int vsync_pin);
  5364. const struct drm_crtc_helper_funcs *crtc_helper_funcs;
  5365. const struct drm_crtc_funcs *crtc_funcs;
  5366. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-hdmi.c linux-3.16.6/drivers/staging/imx-drm/imx-hdmi.c
  5367. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-hdmi.c 2014-10-15 05:05:43.000000000 -0500
  5368. +++ linux-3.16.6/drivers/staging/imx-drm/imx-hdmi.c 2014-10-23 12:37:30.178219970 -0500
  5369. @@ -29,6 +29,9 @@
  5370. #include <drm/drm_encoder_slave.h>
  5371. #include <video/imx-ipu-v3.h>
  5372. +#include "drm-ddc-connector.h"
  5373. +#include "dw-hdmi-audio.h"
  5374. +#include "dw-hdmi-cec.h"
  5375. #include "imx-hdmi.h"
  5376. #include "imx-drm.h"
  5377. @@ -112,9 +115,11 @@
  5378. };
  5379. struct imx_hdmi {
  5380. - struct drm_connector connector;
  5381. + struct drm_ddc_connector *ddc_conn;
  5382. struct drm_encoder encoder;
  5383. + struct platform_device *audio;
  5384. + struct platform_device *cec;
  5385. enum imx_hdmi_devtype dev_type;
  5386. struct device *dev;
  5387. struct clk *isfr_clk;
  5388. @@ -124,13 +129,13 @@
  5389. int vic;
  5390. u8 edid[HDMI_EDID_LEN];
  5391. + u8 mc_clkdis;
  5392. bool cable_plugin;
  5393. bool phy_enabled;
  5394. struct drm_display_mode previous_mode;
  5395. struct regmap *regmap;
  5396. - struct i2c_adapter *ddc;
  5397. void __iomem *regs;
  5398. unsigned int sample_rate;
  5399. @@ -361,6 +366,12 @@
  5400. hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock);
  5401. }
  5402. +static void imx_hdmi_set_sample_rate(struct imx_hdmi *hdmi, unsigned rate)
  5403. +{
  5404. + hdmi->sample_rate = rate;
  5405. + hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock);
  5406. +}
  5407. +
  5408. /*
  5409. * this submodule is responsible for the video data synchronization.
  5410. * for example, for RGB 4:4:4 input, the data map is defined as
  5411. @@ -1144,8 +1155,6 @@
  5412. /* HDMI Initialization Step B.4 */
  5413. static void imx_hdmi_enable_video_path(struct imx_hdmi *hdmi)
  5414. {
  5415. - u8 clkdis;
  5416. -
  5417. /* control period minimum duration */
  5418. hdmi_writeb(hdmi, 12, HDMI_FC_CTRLDUR);
  5419. hdmi_writeb(hdmi, 32, HDMI_FC_EXCTRLDUR);
  5420. @@ -1157,23 +1166,28 @@
  5421. hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM);
  5422. /* Enable pixel clock and tmds data path */
  5423. - clkdis = 0x7F;
  5424. - clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE;
  5425. - hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS);
  5426. + hdmi->mc_clkdis |= HDMI_MC_CLKDIS_HDCPCLK_DISABLE |
  5427. + HDMI_MC_CLKDIS_CSCCLK_DISABLE |
  5428. + HDMI_MC_CLKDIS_AUDCLK_DISABLE |
  5429. + HDMI_MC_CLKDIS_PREPCLK_DISABLE |
  5430. + HDMI_MC_CLKDIS_TMDSCLK_DISABLE;
  5431. + hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE;
  5432. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5433. - clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE;
  5434. - hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS);
  5435. + hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE;
  5436. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5437. /* Enable csc path */
  5438. if (is_color_space_conversion(hdmi)) {
  5439. - clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE;
  5440. - hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS);
  5441. + hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE;
  5442. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5443. }
  5444. }
  5445. static void hdmi_enable_audio_clk(struct imx_hdmi *hdmi)
  5446. {
  5447. - hdmi_modb(hdmi, 0, HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS);
  5448. + hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_AUDCLK_DISABLE;
  5449. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5450. }
  5451. /* Workaround to clear the overflow condition */
  5452. @@ -1376,43 +1390,16 @@
  5453. static enum drm_connector_status imx_hdmi_connector_detect(struct drm_connector
  5454. *connector, bool force)
  5455. {
  5456. - struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi,
  5457. - connector);
  5458. + struct imx_hdmi *hdmi = drm_ddc_private(connector);
  5459. return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ?
  5460. connector_status_connected : connector_status_disconnected;
  5461. }
  5462. -static int imx_hdmi_connector_get_modes(struct drm_connector *connector)
  5463. -{
  5464. - struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi,
  5465. - connector);
  5466. - struct edid *edid;
  5467. - int ret;
  5468. -
  5469. - if (!hdmi->ddc)
  5470. - return 0;
  5471. -
  5472. - edid = drm_get_edid(connector, hdmi->ddc);
  5473. - if (edid) {
  5474. - dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
  5475. - edid->width_cm, edid->height_cm);
  5476. -
  5477. - drm_mode_connector_update_edid_property(connector, edid);
  5478. - ret = drm_add_edid_modes(connector, edid);
  5479. - kfree(edid);
  5480. - } else {
  5481. - dev_dbg(hdmi->dev, "failed to get edid\n");
  5482. - }
  5483. -
  5484. - return 0;
  5485. -}
  5486. -
  5487. static struct drm_encoder *imx_hdmi_connector_best_encoder(struct drm_connector
  5488. *connector)
  5489. {
  5490. - struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi,
  5491. - connector);
  5492. + struct imx_hdmi *hdmi = drm_ddc_private(connector);
  5493. return &hdmi->encoder;
  5494. }
  5495. @@ -1485,11 +1472,11 @@
  5496. .dpms = drm_helper_connector_dpms,
  5497. .fill_modes = drm_helper_probe_single_connector_modes,
  5498. .detect = imx_hdmi_connector_detect,
  5499. - .destroy = imx_drm_connector_destroy,
  5500. + .destroy = drm_ddc_connector_destroy,
  5501. };
  5502. static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = {
  5503. - .get_modes = imx_hdmi_connector_get_modes,
  5504. + .get_modes = drm_ddc_connector_get_modes,
  5505. .best_encoder = imx_hdmi_connector_best_encoder,
  5506. };
  5507. @@ -1530,7 +1517,7 @@
  5508. imx_hdmi_poweroff(hdmi);
  5509. }
  5510. - drm_helper_hpd_irq_event(hdmi->connector.dev);
  5511. + drm_helper_hpd_irq_event(hdmi->ddc_conn->connector.dev);
  5512. }
  5513. hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
  5514. @@ -1548,24 +1535,43 @@
  5515. if (ret)
  5516. return ret;
  5517. - hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
  5518. + hdmi->ddc_conn->connector.polled = DRM_CONNECTOR_POLL_HPD;
  5519. drm_encoder_helper_add(&hdmi->encoder, &imx_hdmi_encoder_helper_funcs);
  5520. drm_encoder_init(drm, &hdmi->encoder, &imx_hdmi_encoder_funcs,
  5521. DRM_MODE_ENCODER_TMDS);
  5522. - drm_connector_helper_add(&hdmi->connector,
  5523. + drm_connector_helper_add(&hdmi->ddc_conn->connector,
  5524. &imx_hdmi_connector_helper_funcs);
  5525. - drm_connector_init(drm, &hdmi->connector, &imx_hdmi_connector_funcs,
  5526. - DRM_MODE_CONNECTOR_HDMIA);
  5527. + drm_ddc_connector_add(drm, hdmi->ddc_conn, &imx_hdmi_connector_funcs,
  5528. + DRM_MODE_CONNECTOR_HDMIA);
  5529. - hdmi->connector.encoder = &hdmi->encoder;
  5530. -
  5531. - drm_mode_connector_attach_encoder(&hdmi->connector, &hdmi->encoder);
  5532. + drm_mode_connector_attach_encoder(&hdmi->ddc_conn->connector, &hdmi->encoder);
  5533. return 0;
  5534. }
  5535. +static void imx_hdmi_cec_enable(void *data)
  5536. +{
  5537. + struct imx_hdmi *hdmi = data;
  5538. +
  5539. + hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CECCLK_DISABLE;
  5540. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5541. +}
  5542. +
  5543. +static void imx_hdmi_cec_disable(void *data)
  5544. +{
  5545. + struct imx_hdmi *hdmi = data;
  5546. +
  5547. + hdmi->mc_clkdis |= HDMI_MC_CLKDIS_CECCLK_DISABLE;
  5548. + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
  5549. +}
  5550. +
  5551. +static const struct dw_hdmi_cec_ops imx_hdmi_cec_ops = {
  5552. + .enable = imx_hdmi_cec_enable,
  5553. + .disable = imx_hdmi_cec_disable,
  5554. +};
  5555. +
  5556. static struct platform_device_id imx_hdmi_devtype[] = {
  5557. {
  5558. .name = "imx6q-hdmi",
  5559. @@ -1587,11 +1593,13 @@
  5560. static int imx_hdmi_bind(struct device *dev, struct device *master, void *data)
  5561. {
  5562. struct platform_device *pdev = to_platform_device(dev);
  5563. + struct platform_device_info pdevinfo;
  5564. const struct of_device_id *of_id =
  5565. of_match_device(imx_hdmi_dt_ids, dev);
  5566. struct drm_device *drm = data;
  5567. struct device_node *np = dev->of_node;
  5568. - struct device_node *ddc_node;
  5569. + struct dw_hdmi_audio_data audio;
  5570. + struct dw_hdmi_cec_data cec;
  5571. struct imx_hdmi *hdmi;
  5572. struct resource *iores;
  5573. int ret, irq;
  5574. @@ -1600,9 +1608,14 @@
  5575. if (!hdmi)
  5576. return -ENOMEM;
  5577. + hdmi->ddc_conn = drm_ddc_connector_create(drm, np, hdmi);
  5578. + if (IS_ERR(hdmi->ddc_conn))
  5579. + return PTR_ERR(hdmi->ddc_conn);
  5580. +
  5581. hdmi->dev = dev;
  5582. hdmi->sample_rate = 48000;
  5583. hdmi->ratio = 100;
  5584. + hdmi->mc_clkdis = 0x7f;
  5585. if (of_id) {
  5586. const struct platform_device_id *device_id = of_id->data;
  5587. @@ -1610,17 +1623,6 @@
  5588. hdmi->dev_type = device_id->driver_data;
  5589. }
  5590. - ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
  5591. - if (ddc_node) {
  5592. - hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
  5593. - if (!hdmi->ddc)
  5594. - dev_dbg(hdmi->dev, "failed to read ddc node\n");
  5595. -
  5596. - of_node_put(ddc_node);
  5597. - } else {
  5598. - dev_dbg(hdmi->dev, "no ddc property found\n");
  5599. - }
  5600. -
  5601. irq = platform_get_irq(pdev, 0);
  5602. if (irq < 0)
  5603. return irq;
  5604. @@ -1706,6 +1708,35 @@
  5605. /* Unmute interrupts */
  5606. hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
  5607. + memset(&pdevinfo, 0, sizeof(pdevinfo));
  5608. + pdevinfo.parent = dev;
  5609. + pdevinfo.id = PLATFORM_DEVID_AUTO;
  5610. +
  5611. + audio.phys = iores->start;
  5612. + audio.base = hdmi->regs;
  5613. + audio.irq = irq;
  5614. + audio.hdmi = hdmi;
  5615. + audio.eld = hdmi->ddc_conn->connector.eld;
  5616. + audio.set_sample_rate = imx_hdmi_set_sample_rate;
  5617. +
  5618. + pdevinfo.name = "dw-hdmi-audio";
  5619. + pdevinfo.data = &audio;
  5620. + pdevinfo.size_data = sizeof(audio);
  5621. + pdevinfo.dma_mask = DMA_BIT_MASK(32);
  5622. + hdmi->audio = platform_device_register_full(&pdevinfo);
  5623. +
  5624. + cec.base = hdmi->regs;
  5625. + cec.irq = irq;
  5626. + cec.ops = &imx_hdmi_cec_ops;
  5627. + cec.ops_data = hdmi;
  5628. +
  5629. + pdevinfo.name = "dw-hdmi-cec";
  5630. + pdevinfo.data = &cec;
  5631. + pdevinfo.size_data = sizeof(cec);
  5632. + pdevinfo.dma_mask = 0;
  5633. +
  5634. + hdmi->cec = platform_device_register_full(&pdevinfo);
  5635. +
  5636. dev_set_drvdata(dev, hdmi);
  5637. return 0;
  5638. @@ -1723,15 +1754,18 @@
  5639. {
  5640. struct imx_hdmi *hdmi = dev_get_drvdata(dev);
  5641. + if (!IS_ERR(hdmi->audio))
  5642. + platform_device_unregister(hdmi->audio);
  5643. + if (!IS_ERR(hdmi->cec))
  5644. + platform_device_unregister(hdmi->cec);
  5645. +
  5646. /* Disable all interrupts */
  5647. hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0);
  5648. - hdmi->connector.funcs->destroy(&hdmi->connector);
  5649. hdmi->encoder.funcs->destroy(&hdmi->encoder);
  5650. clk_disable_unprepare(hdmi->iahb_clk);
  5651. clk_disable_unprepare(hdmi->isfr_clk);
  5652. - i2c_put_adapter(hdmi->ddc);
  5653. }
  5654. static const struct component_ops hdmi_ops = {
  5655. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-ldb.c linux-3.16.6/drivers/staging/imx-drm/imx-ldb.c
  5656. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-ldb.c 2014-10-15 05:05:43.000000000 -0500
  5657. +++ linux-3.16.6/drivers/staging/imx-drm/imx-ldb.c 2014-10-23 12:35:16.922220006 -0500
  5658. @@ -24,6 +24,7 @@
  5659. #include <drm/drmP.h>
  5660. #include <drm/drm_fb_helper.h>
  5661. #include <drm/drm_crtc_helper.h>
  5662. +#include <drm/drm_panel.h>
  5663. #include <linux/mfd/syscon.h>
  5664. #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
  5665. #include <linux/of_address.h>
  5666. @@ -60,6 +61,7 @@
  5667. struct imx_ldb *ldb;
  5668. struct drm_connector connector;
  5669. struct drm_encoder encoder;
  5670. + struct drm_panel *panel;
  5671. struct device_node *child;
  5672. int chno;
  5673. void *edid;
  5674. @@ -96,6 +98,13 @@
  5675. struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
  5676. int num_modes = 0;
  5677. + if (imx_ldb_ch->panel && imx_ldb_ch->panel->funcs &&
  5678. + imx_ldb_ch->panel->funcs->get_modes) {
  5679. + num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
  5680. + if (num_modes > 0)
  5681. + return num_modes;
  5682. + }
  5683. +
  5684. if (imx_ldb_ch->edid) {
  5685. drm_mode_connector_update_edid_property(connector,
  5686. imx_ldb_ch->edid);
  5687. @@ -243,6 +252,8 @@
  5688. }
  5689. regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
  5690. +
  5691. + drm_panel_enable(imx_ldb_ch->panel);
  5692. }
  5693. static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder,
  5694. @@ -294,6 +305,8 @@
  5695. (ldb->ldb_ctrl & LDB_CH1_MODE_EN_MASK) == 0)
  5696. return;
  5697. + drm_panel_disable(imx_ldb_ch->panel);
  5698. +
  5699. if (imx_ldb_ch == &ldb->channel[0])
  5700. ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
  5701. else if (imx_ldb_ch == &ldb->channel[1])
  5702. @@ -378,6 +391,9 @@
  5703. drm_connector_init(drm, &imx_ldb_ch->connector,
  5704. &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
  5705. + if (imx_ldb_ch->panel)
  5706. + drm_panel_attach(imx_ldb_ch->panel, &imx_ldb_ch->connector);
  5707. +
  5708. drm_mode_connector_attach_encoder(&imx_ldb_ch->connector,
  5709. &imx_ldb_ch->encoder);
  5710. @@ -492,6 +508,7 @@
  5711. for_each_child_of_node(np, child) {
  5712. struct imx_ldb_channel *channel;
  5713. + struct device_node *panel_node;
  5714. ret = of_property_read_u32(child, "reg", &i);
  5715. if (ret || i < 0 || i > 1)
  5716. @@ -555,6 +572,10 @@
  5717. return -EINVAL;
  5718. }
  5719. + panel_node = of_parse_phandle(child, "fsl,panel", 0);
  5720. + if (panel_node)
  5721. + channel->panel = of_drm_find_panel(panel_node);
  5722. +
  5723. ret = imx_ldb_register(drm, channel);
  5724. if (ret)
  5725. return ret;
  5726. @@ -574,9 +595,6 @@
  5727. for (i = 0; i < 2; i++) {
  5728. struct imx_ldb_channel *channel = &imx_ldb->channel[i];
  5729. - if (!channel->connector.funcs)
  5730. - continue;
  5731. -
  5732. channel->connector.funcs->destroy(&channel->connector);
  5733. channel->encoder.funcs->destroy(&channel->encoder);
  5734. }
  5735. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-ldb.c.orig linux-3.16.6/drivers/staging/imx-drm/imx-ldb.c.orig
  5736. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-ldb.c.orig 1969-12-31 18:00:00.000000000 -0600
  5737. +++ linux-3.16.6/drivers/staging/imx-drm/imx-ldb.c.orig 2014-10-15 05:05:43.000000000 -0500
  5738. @@ -0,0 +1,616 @@
  5739. +/*
  5740. + * i.MX drm driver - LVDS display bridge
  5741. + *
  5742. + * Copyright (C) 2012 Sascha Hauer, Pengutronix
  5743. + *
  5744. + * This program is free software; you can redistribute it and/or
  5745. + * modify it under the terms of the GNU General Public License
  5746. + * as published by the Free Software Foundation; either version 2
  5747. + * of the License, or (at your option) any later version.
  5748. + * This program is distributed in the hope that it will be useful,
  5749. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5750. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5751. + * GNU General Public License for more details.
  5752. + *
  5753. + * You should have received a copy of the GNU General Public License
  5754. + * along with this program; if not, write to the Free Software
  5755. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  5756. + * MA 02110-1301, USA.
  5757. + */
  5758. +
  5759. +#include <linux/module.h>
  5760. +#include <linux/clk.h>
  5761. +#include <linux/component.h>
  5762. +#include <drm/drmP.h>
  5763. +#include <drm/drm_fb_helper.h>
  5764. +#include <drm/drm_crtc_helper.h>
  5765. +#include <linux/mfd/syscon.h>
  5766. +#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
  5767. +#include <linux/of_address.h>
  5768. +#include <linux/of_device.h>
  5769. +#include <video/of_videomode.h>
  5770. +#include <linux/regmap.h>
  5771. +#include <linux/videodev2.h>
  5772. +
  5773. +#include "imx-drm.h"
  5774. +
  5775. +#define DRIVER_NAME "imx-ldb"
  5776. +
  5777. +#define LDB_CH0_MODE_EN_TO_DI0 (1 << 0)
  5778. +#define LDB_CH0_MODE_EN_TO_DI1 (3 << 0)
  5779. +#define LDB_CH0_MODE_EN_MASK (3 << 0)
  5780. +#define LDB_CH1_MODE_EN_TO_DI0 (1 << 2)
  5781. +#define LDB_CH1_MODE_EN_TO_DI1 (3 << 2)
  5782. +#define LDB_CH1_MODE_EN_MASK (3 << 2)
  5783. +#define LDB_SPLIT_MODE_EN (1 << 4)
  5784. +#define LDB_DATA_WIDTH_CH0_24 (1 << 5)
  5785. +#define LDB_BIT_MAP_CH0_JEIDA (1 << 6)
  5786. +#define LDB_DATA_WIDTH_CH1_24 (1 << 7)
  5787. +#define LDB_BIT_MAP_CH1_JEIDA (1 << 8)
  5788. +#define LDB_DI0_VS_POL_ACT_LOW (1 << 9)
  5789. +#define LDB_DI1_VS_POL_ACT_LOW (1 << 10)
  5790. +#define LDB_BGREF_RMODE_INT (1 << 15)
  5791. +
  5792. +#define con_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, connector)
  5793. +#define enc_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, encoder)
  5794. +
  5795. +struct imx_ldb;
  5796. +
  5797. +struct imx_ldb_channel {
  5798. + struct imx_ldb *ldb;
  5799. + struct drm_connector connector;
  5800. + struct drm_encoder encoder;
  5801. + struct device_node *child;
  5802. + int chno;
  5803. + void *edid;
  5804. + int edid_len;
  5805. + struct drm_display_mode mode;
  5806. + int mode_valid;
  5807. +};
  5808. +
  5809. +struct bus_mux {
  5810. + int reg;
  5811. + int shift;
  5812. + int mask;
  5813. +};
  5814. +
  5815. +struct imx_ldb {
  5816. + struct regmap *regmap;
  5817. + struct device *dev;
  5818. + struct imx_ldb_channel channel[2];
  5819. + struct clk *clk[2]; /* our own clock */
  5820. + struct clk *clk_sel[4]; /* parent of display clock */
  5821. + struct clk *clk_pll[2]; /* upstream clock we can adjust */
  5822. + u32 ldb_ctrl;
  5823. + const struct bus_mux *lvds_mux;
  5824. +};
  5825. +
  5826. +static enum drm_connector_status imx_ldb_connector_detect(
  5827. + struct drm_connector *connector, bool force)
  5828. +{
  5829. + return connector_status_connected;
  5830. +}
  5831. +
  5832. +static int imx_ldb_connector_get_modes(struct drm_connector *connector)
  5833. +{
  5834. + struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
  5835. + int num_modes = 0;
  5836. +
  5837. + if (imx_ldb_ch->edid) {
  5838. + drm_mode_connector_update_edid_property(connector,
  5839. + imx_ldb_ch->edid);
  5840. + num_modes = drm_add_edid_modes(connector, imx_ldb_ch->edid);
  5841. + }
  5842. +
  5843. + if (imx_ldb_ch->mode_valid) {
  5844. + struct drm_display_mode *mode;
  5845. +
  5846. + mode = drm_mode_create(connector->dev);
  5847. + if (!mode)
  5848. + return -EINVAL;
  5849. + drm_mode_copy(mode, &imx_ldb_ch->mode);
  5850. + mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
  5851. + drm_mode_probed_add(connector, mode);
  5852. + num_modes++;
  5853. + }
  5854. +
  5855. + return num_modes;
  5856. +}
  5857. +
  5858. +static struct drm_encoder *imx_ldb_connector_best_encoder(
  5859. + struct drm_connector *connector)
  5860. +{
  5861. + struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
  5862. +
  5863. + return &imx_ldb_ch->encoder;
  5864. +}
  5865. +
  5866. +static void imx_ldb_encoder_dpms(struct drm_encoder *encoder, int mode)
  5867. +{
  5868. +}
  5869. +
  5870. +static bool imx_ldb_encoder_mode_fixup(struct drm_encoder *encoder,
  5871. + const struct drm_display_mode *mode,
  5872. + struct drm_display_mode *adjusted_mode)
  5873. +{
  5874. + return true;
  5875. +}
  5876. +
  5877. +static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
  5878. + unsigned long serial_clk, unsigned long di_clk)
  5879. +{
  5880. + int ret;
  5881. +
  5882. + dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
  5883. + clk_get_rate(ldb->clk_pll[chno]), serial_clk);
  5884. + clk_set_rate(ldb->clk_pll[chno], serial_clk);
  5885. +
  5886. + dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
  5887. + clk_get_rate(ldb->clk_pll[chno]));
  5888. +
  5889. + dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
  5890. + clk_get_rate(ldb->clk[chno]),
  5891. + (long int)di_clk);
  5892. + clk_set_rate(ldb->clk[chno], di_clk);
  5893. +
  5894. + dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
  5895. + clk_get_rate(ldb->clk[chno]));
  5896. +
  5897. + /* set display clock mux to LDB input clock */
  5898. + ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]);
  5899. + if (ret)
  5900. + dev_err(ldb->dev,
  5901. + "unable to set di%d parent clock to ldb_di%d\n", mux,
  5902. + chno);
  5903. +}
  5904. +
  5905. +static void imx_ldb_encoder_prepare(struct drm_encoder *encoder)
  5906. +{
  5907. + struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
  5908. + struct imx_ldb *ldb = imx_ldb_ch->ldb;
  5909. + struct drm_display_mode *mode = &encoder->crtc->mode;
  5910. + u32 pixel_fmt;
  5911. + unsigned long serial_clk;
  5912. + unsigned long di_clk = mode->clock * 1000;
  5913. + int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->child, encoder);
  5914. +
  5915. + if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
  5916. + /* dual channel LVDS mode */
  5917. + serial_clk = 3500UL * mode->clock;
  5918. + imx_ldb_set_clock(ldb, mux, 0, serial_clk, di_clk);
  5919. + imx_ldb_set_clock(ldb, mux, 1, serial_clk, di_clk);
  5920. + } else {
  5921. + serial_clk = 7000UL * mode->clock;
  5922. + imx_ldb_set_clock(ldb, mux, imx_ldb_ch->chno, serial_clk,
  5923. + di_clk);
  5924. + }
  5925. +
  5926. + switch (imx_ldb_ch->chno) {
  5927. + case 0:
  5928. + pixel_fmt = (ldb->ldb_ctrl & LDB_DATA_WIDTH_CH0_24) ?
  5929. + V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_BGR666;
  5930. + break;
  5931. + case 1:
  5932. + pixel_fmt = (ldb->ldb_ctrl & LDB_DATA_WIDTH_CH1_24) ?
  5933. + V4L2_PIX_FMT_RGB24 : V4L2_PIX_FMT_BGR666;
  5934. + break;
  5935. + default:
  5936. + dev_err(ldb->dev, "unable to config di%d panel format\n",
  5937. + imx_ldb_ch->chno);
  5938. + pixel_fmt = V4L2_PIX_FMT_RGB24;
  5939. + }
  5940. +
  5941. + imx_drm_panel_format(encoder, pixel_fmt);
  5942. +}
  5943. +
  5944. +static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
  5945. +{
  5946. + struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
  5947. + struct imx_ldb *ldb = imx_ldb_ch->ldb;
  5948. + int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
  5949. + int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->child, encoder);
  5950. +
  5951. + if (dual) {
  5952. + clk_prepare_enable(ldb->clk[0]);
  5953. + clk_prepare_enable(ldb->clk[1]);
  5954. + }
  5955. +
  5956. + if (imx_ldb_ch == &ldb->channel[0] || dual) {
  5957. + ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
  5958. + if (mux == 0 || ldb->lvds_mux)
  5959. + ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI0;
  5960. + else if (mux == 1)
  5961. + ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI1;
  5962. + }
  5963. + if (imx_ldb_ch == &ldb->channel[1] || dual) {
  5964. + ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
  5965. + if (mux == 1 || ldb->lvds_mux)
  5966. + ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI1;
  5967. + else if (mux == 0)
  5968. + ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI0;
  5969. + }
  5970. +
  5971. + if (ldb->lvds_mux) {
  5972. + const struct bus_mux *lvds_mux = NULL;
  5973. +
  5974. + if (imx_ldb_ch == &ldb->channel[0])
  5975. + lvds_mux = &ldb->lvds_mux[0];
  5976. + else if (imx_ldb_ch == &ldb->channel[1])
  5977. + lvds_mux = &ldb->lvds_mux[1];
  5978. +
  5979. + regmap_update_bits(ldb->regmap, lvds_mux->reg, lvds_mux->mask,
  5980. + mux << lvds_mux->shift);
  5981. + }
  5982. +
  5983. + regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
  5984. +}
  5985. +
  5986. +static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder,
  5987. + struct drm_display_mode *mode,
  5988. + struct drm_display_mode *adjusted_mode)
  5989. +{
  5990. + struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
  5991. + struct imx_ldb *ldb = imx_ldb_ch->ldb;
  5992. + int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
  5993. +
  5994. + if (mode->clock > 170000) {
  5995. + dev_warn(ldb->dev,
  5996. + "%s: mode exceeds 170 MHz pixel clock\n", __func__);
  5997. + }
  5998. + if (mode->clock > 85000 && !dual) {
  5999. + dev_warn(ldb->dev,
  6000. + "%s: mode exceeds 85 MHz pixel clock\n", __func__);
  6001. + }
  6002. +
  6003. + /* FIXME - assumes straight connections DI0 --> CH0, DI1 --> CH1 */
  6004. + if (imx_ldb_ch == &ldb->channel[0]) {
  6005. + if (mode->flags & DRM_MODE_FLAG_NVSYNC)
  6006. + ldb->ldb_ctrl |= LDB_DI0_VS_POL_ACT_LOW;
  6007. + else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
  6008. + ldb->ldb_ctrl &= ~LDB_DI0_VS_POL_ACT_LOW;
  6009. + }
  6010. + if (imx_ldb_ch == &ldb->channel[1]) {
  6011. + if (mode->flags & DRM_MODE_FLAG_NVSYNC)
  6012. + ldb->ldb_ctrl |= LDB_DI1_VS_POL_ACT_LOW;
  6013. + else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
  6014. + ldb->ldb_ctrl &= ~LDB_DI1_VS_POL_ACT_LOW;
  6015. + }
  6016. +}
  6017. +
  6018. +static void imx_ldb_encoder_disable(struct drm_encoder *encoder)
  6019. +{
  6020. + struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
  6021. + struct imx_ldb *ldb = imx_ldb_ch->ldb;
  6022. +
  6023. + /*
  6024. + * imx_ldb_encoder_disable is called by
  6025. + * drm_helper_disable_unused_functions without
  6026. + * the encoder being enabled before.
  6027. + */
  6028. + if (imx_ldb_ch == &ldb->channel[0] &&
  6029. + (ldb->ldb_ctrl & LDB_CH0_MODE_EN_MASK) == 0)
  6030. + return;
  6031. + else if (imx_ldb_ch == &ldb->channel[1] &&
  6032. + (ldb->ldb_ctrl & LDB_CH1_MODE_EN_MASK) == 0)
  6033. + return;
  6034. +
  6035. + if (imx_ldb_ch == &ldb->channel[0])
  6036. + ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
  6037. + else if (imx_ldb_ch == &ldb->channel[1])
  6038. + ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
  6039. +
  6040. + regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
  6041. +
  6042. + if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
  6043. + clk_disable_unprepare(ldb->clk[0]);
  6044. + clk_disable_unprepare(ldb->clk[1]);
  6045. + }
  6046. +}
  6047. +
  6048. +static struct drm_connector_funcs imx_ldb_connector_funcs = {
  6049. + .dpms = drm_helper_connector_dpms,
  6050. + .fill_modes = drm_helper_probe_single_connector_modes,
  6051. + .detect = imx_ldb_connector_detect,
  6052. + .destroy = imx_drm_connector_destroy,
  6053. +};
  6054. +
  6055. +static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
  6056. + .get_modes = imx_ldb_connector_get_modes,
  6057. + .best_encoder = imx_ldb_connector_best_encoder,
  6058. +};
  6059. +
  6060. +static struct drm_encoder_funcs imx_ldb_encoder_funcs = {
  6061. + .destroy = imx_drm_encoder_destroy,
  6062. +};
  6063. +
  6064. +static struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
  6065. + .dpms = imx_ldb_encoder_dpms,
  6066. + .mode_fixup = imx_ldb_encoder_mode_fixup,
  6067. + .prepare = imx_ldb_encoder_prepare,
  6068. + .commit = imx_ldb_encoder_commit,
  6069. + .mode_set = imx_ldb_encoder_mode_set,
  6070. + .disable = imx_ldb_encoder_disable,
  6071. +};
  6072. +
  6073. +static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno)
  6074. +{
  6075. + char clkname[16];
  6076. +
  6077. + snprintf(clkname, sizeof(clkname), "di%d", chno);
  6078. + ldb->clk[chno] = devm_clk_get(ldb->dev, clkname);
  6079. + if (IS_ERR(ldb->clk[chno]))
  6080. + return PTR_ERR(ldb->clk[chno]);
  6081. +
  6082. + snprintf(clkname, sizeof(clkname), "di%d_pll", chno);
  6083. + ldb->clk_pll[chno] = devm_clk_get(ldb->dev, clkname);
  6084. +
  6085. + return PTR_ERR_OR_ZERO(ldb->clk_pll[chno]);
  6086. +}
  6087. +
  6088. +static int imx_ldb_register(struct drm_device *drm,
  6089. + struct imx_ldb_channel *imx_ldb_ch)
  6090. +{
  6091. + struct imx_ldb *ldb = imx_ldb_ch->ldb;
  6092. + int ret;
  6093. +
  6094. + ret = imx_drm_encoder_parse_of(drm, &imx_ldb_ch->encoder,
  6095. + imx_ldb_ch->child);
  6096. + if (ret)
  6097. + return ret;
  6098. +
  6099. + ret = imx_ldb_get_clk(ldb, imx_ldb_ch->chno);
  6100. + if (ret)
  6101. + return ret;
  6102. +
  6103. + if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
  6104. + ret = imx_ldb_get_clk(ldb, 1);
  6105. + if (ret)
  6106. + return ret;
  6107. + }
  6108. +
  6109. + drm_encoder_helper_add(&imx_ldb_ch->encoder,
  6110. + &imx_ldb_encoder_helper_funcs);
  6111. + drm_encoder_init(drm, &imx_ldb_ch->encoder, &imx_ldb_encoder_funcs,
  6112. + DRM_MODE_ENCODER_LVDS);
  6113. +
  6114. + drm_connector_helper_add(&imx_ldb_ch->connector,
  6115. + &imx_ldb_connector_helper_funcs);
  6116. + drm_connector_init(drm, &imx_ldb_ch->connector,
  6117. + &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
  6118. +
  6119. + drm_mode_connector_attach_encoder(&imx_ldb_ch->connector,
  6120. + &imx_ldb_ch->encoder);
  6121. +
  6122. + return 0;
  6123. +}
  6124. +
  6125. +enum {
  6126. + LVDS_BIT_MAP_SPWG,
  6127. + LVDS_BIT_MAP_JEIDA
  6128. +};
  6129. +
  6130. +static const char * const imx_ldb_bit_mappings[] = {
  6131. + [LVDS_BIT_MAP_SPWG] = "spwg",
  6132. + [LVDS_BIT_MAP_JEIDA] = "jeida",
  6133. +};
  6134. +
  6135. +static const int of_get_data_mapping(struct device_node *np)
  6136. +{
  6137. + const char *bm;
  6138. + int ret, i;
  6139. +
  6140. + ret = of_property_read_string(np, "fsl,data-mapping", &bm);
  6141. + if (ret < 0)
  6142. + return ret;
  6143. +
  6144. + for (i = 0; i < ARRAY_SIZE(imx_ldb_bit_mappings); i++)
  6145. + if (!strcasecmp(bm, imx_ldb_bit_mappings[i]))
  6146. + return i;
  6147. +
  6148. + return -EINVAL;
  6149. +}
  6150. +
  6151. +static struct bus_mux imx6q_lvds_mux[2] = {
  6152. + {
  6153. + .reg = IOMUXC_GPR3,
  6154. + .shift = 6,
  6155. + .mask = IMX6Q_GPR3_LVDS0_MUX_CTL_MASK,
  6156. + }, {
  6157. + .reg = IOMUXC_GPR3,
  6158. + .shift = 8,
  6159. + .mask = IMX6Q_GPR3_LVDS1_MUX_CTL_MASK,
  6160. + }
  6161. +};
  6162. +
  6163. +/*
  6164. + * For a device declaring compatible = "fsl,imx6q-ldb", "fsl,imx53-ldb",
  6165. + * of_match_device will walk through this list and take the first entry
  6166. + * matching any of its compatible values. Therefore, the more generic
  6167. + * entries (in this case fsl,imx53-ldb) need to be ordered last.
  6168. + */
  6169. +static const struct of_device_id imx_ldb_dt_ids[] = {
  6170. + { .compatible = "fsl,imx6q-ldb", .data = imx6q_lvds_mux, },
  6171. + { .compatible = "fsl,imx53-ldb", .data = NULL, },
  6172. + { }
  6173. +};
  6174. +MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids);
  6175. +
  6176. +static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
  6177. +{
  6178. + struct drm_device *drm = data;
  6179. + struct device_node *np = dev->of_node;
  6180. + const struct of_device_id *of_id =
  6181. + of_match_device(imx_ldb_dt_ids, dev);
  6182. + struct device_node *child;
  6183. + const u8 *edidp;
  6184. + struct imx_ldb *imx_ldb;
  6185. + int datawidth;
  6186. + int mapping;
  6187. + int dual;
  6188. + int ret;
  6189. + int i;
  6190. +
  6191. + imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL);
  6192. + if (!imx_ldb)
  6193. + return -ENOMEM;
  6194. +
  6195. + imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
  6196. + if (IS_ERR(imx_ldb->regmap)) {
  6197. + dev_err(dev, "failed to get parent regmap\n");
  6198. + return PTR_ERR(imx_ldb->regmap);
  6199. + }
  6200. +
  6201. + imx_ldb->dev = dev;
  6202. +
  6203. + if (of_id)
  6204. + imx_ldb->lvds_mux = of_id->data;
  6205. +
  6206. + dual = of_property_read_bool(np, "fsl,dual-channel");
  6207. + if (dual)
  6208. + imx_ldb->ldb_ctrl |= LDB_SPLIT_MODE_EN;
  6209. +
  6210. + /*
  6211. + * There are three different possible clock mux configurations:
  6212. + * i.MX53: ipu1_di0_sel, ipu1_di1_sel
  6213. + * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel
  6214. + * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel
  6215. + * Map them all to di0_sel...di3_sel.
  6216. + */
  6217. + for (i = 0; i < 4; i++) {
  6218. + char clkname[16];
  6219. +
  6220. + sprintf(clkname, "di%d_sel", i);
  6221. + imx_ldb->clk_sel[i] = devm_clk_get(imx_ldb->dev, clkname);
  6222. + if (IS_ERR(imx_ldb->clk_sel[i])) {
  6223. + ret = PTR_ERR(imx_ldb->clk_sel[i]);
  6224. + imx_ldb->clk_sel[i] = NULL;
  6225. + break;
  6226. + }
  6227. + }
  6228. + if (i == 0)
  6229. + return ret;
  6230. +
  6231. + for_each_child_of_node(np, child) {
  6232. + struct imx_ldb_channel *channel;
  6233. +
  6234. + ret = of_property_read_u32(child, "reg", &i);
  6235. + if (ret || i < 0 || i > 1)
  6236. + return -EINVAL;
  6237. +
  6238. + if (dual && i > 0) {
  6239. + dev_warn(dev, "dual-channel mode, ignoring second output\n");
  6240. + continue;
  6241. + }
  6242. +
  6243. + if (!of_device_is_available(child))
  6244. + continue;
  6245. +
  6246. + channel = &imx_ldb->channel[i];
  6247. + channel->ldb = imx_ldb;
  6248. + channel->chno = i;
  6249. + channel->child = child;
  6250. +
  6251. + edidp = of_get_property(child, "edid", &channel->edid_len);
  6252. + if (edidp) {
  6253. + channel->edid = kmemdup(edidp, channel->edid_len,
  6254. + GFP_KERNEL);
  6255. + } else {
  6256. + ret = of_get_drm_display_mode(child, &channel->mode, 0);
  6257. + if (!ret)
  6258. + channel->mode_valid = 1;
  6259. + }
  6260. +
  6261. + ret = of_property_read_u32(child, "fsl,data-width", &datawidth);
  6262. + if (ret)
  6263. + datawidth = 0;
  6264. + else if (datawidth != 18 && datawidth != 24)
  6265. + return -EINVAL;
  6266. +
  6267. + mapping = of_get_data_mapping(child);
  6268. + switch (mapping) {
  6269. + case LVDS_BIT_MAP_SPWG:
  6270. + if (datawidth == 24) {
  6271. + if (i == 0 || dual)
  6272. + imx_ldb->ldb_ctrl |=
  6273. + LDB_DATA_WIDTH_CH0_24;
  6274. + if (i == 1 || dual)
  6275. + imx_ldb->ldb_ctrl |=
  6276. + LDB_DATA_WIDTH_CH1_24;
  6277. + }
  6278. + break;
  6279. + case LVDS_BIT_MAP_JEIDA:
  6280. + if (datawidth == 18) {
  6281. + dev_err(dev, "JEIDA standard only supported in 24 bit\n");
  6282. + return -EINVAL;
  6283. + }
  6284. + if (i == 0 || dual)
  6285. + imx_ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 |
  6286. + LDB_BIT_MAP_CH0_JEIDA;
  6287. + if (i == 1 || dual)
  6288. + imx_ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 |
  6289. + LDB_BIT_MAP_CH1_JEIDA;
  6290. + break;
  6291. + default:
  6292. + dev_err(dev, "data mapping not specified or invalid\n");
  6293. + return -EINVAL;
  6294. + }
  6295. +
  6296. + ret = imx_ldb_register(drm, channel);
  6297. + if (ret)
  6298. + return ret;
  6299. + }
  6300. +
  6301. + dev_set_drvdata(dev, imx_ldb);
  6302. +
  6303. + return 0;
  6304. +}
  6305. +
  6306. +static void imx_ldb_unbind(struct device *dev, struct device *master,
  6307. + void *data)
  6308. +{
  6309. + struct imx_ldb *imx_ldb = dev_get_drvdata(dev);
  6310. + int i;
  6311. +
  6312. + for (i = 0; i < 2; i++) {
  6313. + struct imx_ldb_channel *channel = &imx_ldb->channel[i];
  6314. +
  6315. + if (!channel->connector.funcs)
  6316. + continue;
  6317. +
  6318. + channel->connector.funcs->destroy(&channel->connector);
  6319. + channel->encoder.funcs->destroy(&channel->encoder);
  6320. + }
  6321. +}
  6322. +
  6323. +static const struct component_ops imx_ldb_ops = {
  6324. + .bind = imx_ldb_bind,
  6325. + .unbind = imx_ldb_unbind,
  6326. +};
  6327. +
  6328. +static int imx_ldb_probe(struct platform_device *pdev)
  6329. +{
  6330. + return component_add(&pdev->dev, &imx_ldb_ops);
  6331. +}
  6332. +
  6333. +static int imx_ldb_remove(struct platform_device *pdev)
  6334. +{
  6335. + component_del(&pdev->dev, &imx_ldb_ops);
  6336. + return 0;
  6337. +}
  6338. +
  6339. +static struct platform_driver imx_ldb_driver = {
  6340. + .probe = imx_ldb_probe,
  6341. + .remove = imx_ldb_remove,
  6342. + .driver = {
  6343. + .of_match_table = imx_ldb_dt_ids,
  6344. + .name = DRIVER_NAME,
  6345. + .owner = THIS_MODULE,
  6346. + },
  6347. +};
  6348. +
  6349. +module_platform_driver(imx_ldb_driver);
  6350. +
  6351. +MODULE_DESCRIPTION("i.MX LVDS driver");
  6352. +MODULE_AUTHOR("Sascha Hauer, Pengutronix");
  6353. +MODULE_LICENSE("GPL");
  6354. +MODULE_ALIAS("platform:" DRIVER_NAME);
  6355. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/imx-tve.c linux-3.16.6/drivers/staging/imx-drm/imx-tve.c
  6356. --- linux-3.16.6.orig/drivers/staging/imx-drm/imx-tve.c 2014-10-15 05:05:43.000000000 -0500
  6357. +++ linux-3.16.6/drivers/staging/imx-drm/imx-tve.c 2014-10-23 12:37:30.182220005 -0500
  6358. @@ -22,7 +22,6 @@
  6359. #include <linux/clk-provider.h>
  6360. #include <linux/component.h>
  6361. #include <linux/module.h>
  6362. -#include <linux/i2c.h>
  6363. #include <linux/regmap.h>
  6364. #include <linux/regulator/consumer.h>
  6365. #include <linux/spinlock.h>
  6366. @@ -32,6 +31,7 @@
  6367. #include <drm/drm_crtc_helper.h>
  6368. #include <video/imx-ipu-v3.h>
  6369. +#include "drm-ddc-connector.h"
  6370. #include "imx-drm.h"
  6371. #define TVE_COM_CONF_REG 0x00
  6372. @@ -111,7 +111,7 @@
  6373. };
  6374. struct imx_tve {
  6375. - struct drm_connector connector;
  6376. + struct drm_ddc_connector *ddc_conn;
  6377. struct drm_encoder encoder;
  6378. struct device *dev;
  6379. spinlock_t lock; /* register lock */
  6380. @@ -120,7 +120,6 @@
  6381. struct regmap *regmap;
  6382. struct regulator *dac_reg;
  6383. - struct i2c_adapter *ddc;
  6384. struct clk *clk;
  6385. struct clk *di_sel_clk;
  6386. struct clk_hw clk_hw_di;
  6387. @@ -219,35 +218,10 @@
  6388. return 0;
  6389. }
  6390. -static enum drm_connector_status imx_tve_connector_detect(
  6391. - struct drm_connector *connector, bool force)
  6392. -{
  6393. - return connector_status_connected;
  6394. -}
  6395. -
  6396. -static int imx_tve_connector_get_modes(struct drm_connector *connector)
  6397. -{
  6398. - struct imx_tve *tve = con_to_tve(connector);
  6399. - struct edid *edid;
  6400. - int ret = 0;
  6401. -
  6402. - if (!tve->ddc)
  6403. - return 0;
  6404. -
  6405. - edid = drm_get_edid(connector, tve->ddc);
  6406. - if (edid) {
  6407. - drm_mode_connector_update_edid_property(connector, edid);
  6408. - ret = drm_add_edid_modes(connector, edid);
  6409. - kfree(edid);
  6410. - }
  6411. -
  6412. - return ret;
  6413. -}
  6414. -
  6415. static int imx_tve_connector_mode_valid(struct drm_connector *connector,
  6416. struct drm_display_mode *mode)
  6417. {
  6418. - struct imx_tve *tve = con_to_tve(connector);
  6419. + struct imx_tve *tve = to_ddc_conn(connector)->private;
  6420. unsigned long rate;
  6421. /* pixel clock with 2x oversampling */
  6422. @@ -269,7 +243,7 @@
  6423. static struct drm_encoder *imx_tve_connector_best_encoder(
  6424. struct drm_connector *connector)
  6425. {
  6426. - struct imx_tve *tve = con_to_tve(connector);
  6427. + struct imx_tve *tve = drm_ddc_private(connector);
  6428. return &tve->encoder;
  6429. }
  6430. @@ -360,12 +334,12 @@
  6431. static struct drm_connector_funcs imx_tve_connector_funcs = {
  6432. .dpms = drm_helper_connector_dpms,
  6433. .fill_modes = drm_helper_probe_single_connector_modes,
  6434. - .detect = imx_tve_connector_detect,
  6435. - .destroy = imx_drm_connector_destroy,
  6436. + .detect = drm_ddc_connector_always_connected,
  6437. + .destroy = drm_ddc_connector_destroy,
  6438. };
  6439. static struct drm_connector_helper_funcs imx_tve_connector_helper_funcs = {
  6440. - .get_modes = imx_tve_connector_get_modes,
  6441. + .get_modes = drm_ddc_connector_get_modes,
  6442. .best_encoder = imx_tve_connector_best_encoder,
  6443. .mode_valid = imx_tve_connector_mode_valid,
  6444. };
  6445. @@ -508,12 +482,13 @@
  6446. drm_encoder_init(drm, &tve->encoder, &imx_tve_encoder_funcs,
  6447. encoder_type);
  6448. - drm_connector_helper_add(&tve->connector,
  6449. + drm_connector_helper_add(&tve->ddc_conn->connector,
  6450. &imx_tve_connector_helper_funcs);
  6451. - drm_connector_init(drm, &tve->connector, &imx_tve_connector_funcs,
  6452. - DRM_MODE_CONNECTOR_VGA);
  6453. + drm_ddc_connector_add(drm, tve->ddc_conn, &imx_tve_connector_funcs,
  6454. + DRM_MODE_CONNECTOR_VGA);
  6455. - drm_mode_connector_attach_encoder(&tve->connector, &tve->encoder);
  6456. + drm_mode_connector_attach_encoder(&tve->ddc_conn->connector,
  6457. + &tve->encoder);
  6458. return 0;
  6459. }
  6460. @@ -562,7 +537,6 @@
  6461. struct platform_device *pdev = to_platform_device(dev);
  6462. struct drm_device *drm = data;
  6463. struct device_node *np = dev->of_node;
  6464. - struct device_node *ddc_node;
  6465. struct imx_tve *tve;
  6466. struct resource *res;
  6467. void __iomem *base;
  6468. @@ -574,15 +548,13 @@
  6469. if (!tve)
  6470. return -ENOMEM;
  6471. + tve->ddc_conn = drm_ddc_connector_create(drm, np, tve);
  6472. + if (IS_ERR(tve->ddc_conn))
  6473. + return PTR_ERR(tve->ddc_conn);
  6474. +
  6475. tve->dev = dev;
  6476. spin_lock_init(&tve->lock);
  6477. - ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
  6478. - if (ddc_node) {
  6479. - tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
  6480. - of_node_put(ddc_node);
  6481. - }
  6482. -
  6483. tve->mode = of_get_tve_mode(np);
  6484. if (tve->mode != TVE_MODE_VGA) {
  6485. dev_err(dev, "only VGA mode supported, currently\n");
  6486. @@ -689,7 +661,6 @@
  6487. {
  6488. struct imx_tve *tve = dev_get_drvdata(dev);
  6489. - tve->connector.funcs->destroy(&tve->connector);
  6490. tve->encoder.funcs->destroy(&tve->encoder);
  6491. if (!IS_ERR(tve->dac_reg))
  6492. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-crtc.c linux-3.16.6/drivers/staging/imx-drm/ipuv3-crtc.c
  6493. --- linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-crtc.c 2014-10-15 05:05:43.000000000 -0500
  6494. +++ linux-3.16.6/drivers/staging/imx-drm/ipuv3-crtc.c 2014-10-23 12:37:37.690220197 -0500
  6495. @@ -51,7 +51,6 @@
  6496. struct drm_framebuffer *newfb;
  6497. int irq;
  6498. u32 interface_pix_fmt;
  6499. - unsigned long di_clkflags;
  6500. int di_hsync_pin;
  6501. int di_vsync_pin;
  6502. };
  6503. @@ -146,10 +145,13 @@
  6504. int x, int y,
  6505. struct drm_framebuffer *old_fb)
  6506. {
  6507. + struct drm_device *dev = crtc->dev;
  6508. + struct drm_encoder *encoder;
  6509. struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
  6510. - int ret;
  6511. struct ipu_di_signal_cfg sig_cfg = {};
  6512. + unsigned long encoder_types = 0;
  6513. u32 out_pixel_fmt;
  6514. + int ret;
  6515. dev_dbg(ipu_crtc->dev, "%s: mode->hdisplay: %d\n", __func__,
  6516. mode->hdisplay);
  6517. @@ -165,8 +167,26 @@
  6518. if (mode->flags & DRM_MODE_FLAG_PVSYNC)
  6519. sig_cfg.Vsync_pol = 1;
  6520. - sig_cfg.enable_pol = 1;
  6521. - sig_cfg.clk_pol = 0;
  6522. + list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
  6523. + if (encoder->crtc == crtc)
  6524. + encoder_types |= BIT(encoder->encoder_type);
  6525. +
  6526. + dev_dbg(ipu_crtc->dev, "%s: attached to encoder types 0x%lx\n",
  6527. + __func__, encoder_types);
  6528. +
  6529. + /*
  6530. + * If we have DAC, TVDAC or LDB, then we need the IPU DI clock
  6531. + * to be the same as the LDB DI clock.
  6532. + */
  6533. + if (encoder_types & (BIT(DRM_MODE_ENCODER_DAC) |
  6534. + BIT(DRM_MODE_ENCODER_TVDAC) |
  6535. + BIT(DRM_MODE_ENCODER_LVDS)))
  6536. + sig_cfg.clkflags = IPU_DI_CLKMODE_SYNC | IPU_DI_CLKMODE_EXT;
  6537. + else
  6538. + sig_cfg.clkflags = 0;
  6539. +
  6540. + sig_cfg.enable_pol = ENABLE_POL_HIGH;
  6541. + sig_cfg.clk_pol = CLK_POL_NEGEDGE;
  6542. sig_cfg.width = mode->hdisplay;
  6543. sig_cfg.height = mode->vdisplay;
  6544. sig_cfg.pixel_fmt = out_pixel_fmt;
  6545. @@ -178,7 +198,6 @@
  6546. sig_cfg.v_sync_width = mode->vsync_end - mode->vsync_start;
  6547. sig_cfg.v_end_width = mode->vsync_start - mode->vdisplay;
  6548. sig_cfg.pixelclock = mode->clock * 1000;
  6549. - sig_cfg.clkflags = ipu_crtc->di_clkflags;
  6550. sig_cfg.v_to_h_sync = 0;
  6551. @@ -277,7 +296,7 @@
  6552. ipu_crtc->newfb = NULL;
  6553. }
  6554. -static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc, u32 encoder_type,
  6555. +static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc,
  6556. u32 pixfmt, int hsync_pin, int vsync_pin)
  6557. {
  6558. struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
  6559. @@ -286,19 +305,6 @@
  6560. ipu_crtc->di_hsync_pin = hsync_pin;
  6561. ipu_crtc->di_vsync_pin = vsync_pin;
  6562. - switch (encoder_type) {
  6563. - case DRM_MODE_ENCODER_DAC:
  6564. - case DRM_MODE_ENCODER_TVDAC:
  6565. - case DRM_MODE_ENCODER_LVDS:
  6566. - ipu_crtc->di_clkflags = IPU_DI_CLKMODE_SYNC |
  6567. - IPU_DI_CLKMODE_EXT;
  6568. - break;
  6569. - case DRM_MODE_ENCODER_TMDS:
  6570. - case DRM_MODE_ENCODER_NONE:
  6571. - ipu_crtc->di_clkflags = 0;
  6572. - break;
  6573. - }
  6574. -
  6575. return 0;
  6576. }
  6577. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-plane.c linux-3.16.6/drivers/staging/imx-drm/ipuv3-plane.c
  6578. --- linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-plane.c 2014-10-15 05:05:43.000000000 -0500
  6579. +++ linux-3.16.6/drivers/staging/imx-drm/ipuv3-plane.c 2014-10-23 12:35:00.842220709 -0500
  6580. @@ -281,8 +281,7 @@
  6581. ipu_idmac_put(ipu_plane->ipu_ch);
  6582. ipu_dmfc_put(ipu_plane->dmfc);
  6583. - if (ipu_plane->dp)
  6584. - ipu_dp_put(ipu_plane->dp);
  6585. + ipu_dp_put(ipu_plane->dp);
  6586. }
  6587. }
  6588. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-plane.c.orig linux-3.16.6/drivers/staging/imx-drm/ipuv3-plane.c.orig
  6589. --- linux-3.16.6.orig/drivers/staging/imx-drm/ipuv3-plane.c.orig 1969-12-31 18:00:00.000000000 -0600
  6590. +++ linux-3.16.6/drivers/staging/imx-drm/ipuv3-plane.c.orig 2014-10-15 05:05:43.000000000 -0500
  6591. @@ -0,0 +1,388 @@
  6592. +/*
  6593. + * i.MX IPUv3 DP Overlay Planes
  6594. + *
  6595. + * Copyright (C) 2013 Philipp Zabel, Pengutronix
  6596. + *
  6597. + * This program is free software; you can redistribute it and/or
  6598. + * modify it under the terms of the GNU General Public License
  6599. + * as published by the Free Software Foundation; either version 2
  6600. + * of the License, or (at your option) any later version.
  6601. + * This program is distributed in the hope that it will be useful,
  6602. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6603. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6604. + * GNU General Public License for more details.
  6605. + */
  6606. +
  6607. +#include <drm/drmP.h>
  6608. +#include <drm/drm_fb_cma_helper.h>
  6609. +#include <drm/drm_gem_cma_helper.h>
  6610. +
  6611. +#include "video/imx-ipu-v3.h"
  6612. +#include "ipuv3-plane.h"
  6613. +
  6614. +#define to_ipu_plane(x) container_of(x, struct ipu_plane, base)
  6615. +
  6616. +static const uint32_t ipu_plane_formats[] = {
  6617. + DRM_FORMAT_XRGB1555,
  6618. + DRM_FORMAT_XBGR1555,
  6619. + DRM_FORMAT_ARGB8888,
  6620. + DRM_FORMAT_XRGB8888,
  6621. + DRM_FORMAT_ABGR8888,
  6622. + DRM_FORMAT_XBGR8888,
  6623. + DRM_FORMAT_YUYV,
  6624. + DRM_FORMAT_YVYU,
  6625. + DRM_FORMAT_YUV420,
  6626. + DRM_FORMAT_YVU420,
  6627. +};
  6628. +
  6629. +int ipu_plane_irq(struct ipu_plane *ipu_plane)
  6630. +{
  6631. + return ipu_idmac_channel_irq(ipu_plane->ipu, ipu_plane->ipu_ch,
  6632. + IPU_IRQ_EOF);
  6633. +}
  6634. +
  6635. +static int calc_vref(struct drm_display_mode *mode)
  6636. +{
  6637. + unsigned long htotal, vtotal;
  6638. +
  6639. + htotal = mode->htotal;
  6640. + vtotal = mode->vtotal;
  6641. +
  6642. + if (!htotal || !vtotal)
  6643. + return 60;
  6644. +
  6645. + return DIV_ROUND_UP(mode->clock * 1000, vtotal * htotal);
  6646. +}
  6647. +
  6648. +static inline int calc_bandwidth(int width, int height, unsigned int vref)
  6649. +{
  6650. + return width * height * vref;
  6651. +}
  6652. +
  6653. +int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb,
  6654. + int x, int y)
  6655. +{
  6656. + struct ipu_ch_param __iomem *cpmem;
  6657. + struct drm_gem_cma_object *cma_obj;
  6658. + unsigned long eba;
  6659. +
  6660. + cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
  6661. + if (!cma_obj) {
  6662. + DRM_DEBUG_KMS("entry is null.\n");
  6663. + return -EFAULT;
  6664. + }
  6665. +
  6666. + dev_dbg(ipu_plane->base.dev->dev, "phys = %pad, x = %d, y = %d",
  6667. + &cma_obj->paddr, x, y);
  6668. +
  6669. + cpmem = ipu_get_cpmem(ipu_plane->ipu_ch);
  6670. + ipu_cpmem_set_stride(cpmem, fb->pitches[0]);
  6671. +
  6672. + eba = cma_obj->paddr + fb->offsets[0] +
  6673. + fb->pitches[0] * y + (fb->bits_per_pixel >> 3) * x;
  6674. + ipu_cpmem_set_buffer(cpmem, 0, eba);
  6675. + ipu_cpmem_set_buffer(cpmem, 1, eba);
  6676. +
  6677. + /* cache offsets for subsequent pageflips */
  6678. + ipu_plane->x = x;
  6679. + ipu_plane->y = y;
  6680. +
  6681. + return 0;
  6682. +}
  6683. +
  6684. +int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc,
  6685. + struct drm_display_mode *mode,
  6686. + struct drm_framebuffer *fb, int crtc_x, int crtc_y,
  6687. + unsigned int crtc_w, unsigned int crtc_h,
  6688. + uint32_t src_x, uint32_t src_y,
  6689. + uint32_t src_w, uint32_t src_h)
  6690. +{
  6691. + struct ipu_ch_param __iomem *cpmem;
  6692. + struct device *dev = ipu_plane->base.dev->dev;
  6693. + int ret;
  6694. +
  6695. + /* no scaling */
  6696. + if (src_w != crtc_w || src_h != crtc_h)
  6697. + return -EINVAL;
  6698. +
  6699. + /* clip to crtc bounds */
  6700. + if (crtc_x < 0) {
  6701. + if (-crtc_x > crtc_w)
  6702. + return -EINVAL;
  6703. + src_x += -crtc_x;
  6704. + src_w -= -crtc_x;
  6705. + crtc_w -= -crtc_x;
  6706. + crtc_x = 0;
  6707. + }
  6708. + if (crtc_y < 0) {
  6709. + if (-crtc_y > crtc_h)
  6710. + return -EINVAL;
  6711. + src_y += -crtc_y;
  6712. + src_h -= -crtc_y;
  6713. + crtc_h -= -crtc_y;
  6714. + crtc_y = 0;
  6715. + }
  6716. + if (crtc_x + crtc_w > mode->hdisplay) {
  6717. + if (crtc_x > mode->hdisplay)
  6718. + return -EINVAL;
  6719. + crtc_w = mode->hdisplay - crtc_x;
  6720. + src_w = crtc_w;
  6721. + }
  6722. + if (crtc_y + crtc_h > mode->vdisplay) {
  6723. + if (crtc_y > mode->vdisplay)
  6724. + return -EINVAL;
  6725. + crtc_h = mode->vdisplay - crtc_y;
  6726. + src_h = crtc_h;
  6727. + }
  6728. + /* full plane minimum width is 13 pixels */
  6729. + if (crtc_w < 13 && (ipu_plane->dp_flow != IPU_DP_FLOW_SYNC_FG))
  6730. + return -EINVAL;
  6731. + if (crtc_h < 2)
  6732. + return -EINVAL;
  6733. +
  6734. + switch (ipu_plane->dp_flow) {
  6735. + case IPU_DP_FLOW_SYNC_BG:
  6736. + ret = ipu_dp_setup_channel(ipu_plane->dp,
  6737. + IPUV3_COLORSPACE_RGB,
  6738. + IPUV3_COLORSPACE_RGB);
  6739. + if (ret) {
  6740. + dev_err(dev,
  6741. + "initializing display processor failed with %d\n",
  6742. + ret);
  6743. + return ret;
  6744. + }
  6745. + ipu_dp_set_global_alpha(ipu_plane->dp, 1, 0, 1);
  6746. + break;
  6747. + case IPU_DP_FLOW_SYNC_FG:
  6748. + ipu_dp_setup_channel(ipu_plane->dp,
  6749. + ipu_drm_fourcc_to_colorspace(fb->pixel_format),
  6750. + IPUV3_COLORSPACE_UNKNOWN);
  6751. + ipu_dp_set_window_pos(ipu_plane->dp, crtc_x, crtc_y);
  6752. + break;
  6753. + }
  6754. +
  6755. + ret = ipu_dmfc_init_channel(ipu_plane->dmfc, crtc_w);
  6756. + if (ret) {
  6757. + dev_err(dev, "initializing dmfc channel failed with %d\n", ret);
  6758. + return ret;
  6759. + }
  6760. +
  6761. + ret = ipu_dmfc_alloc_bandwidth(ipu_plane->dmfc,
  6762. + calc_bandwidth(crtc_w, crtc_h,
  6763. + calc_vref(mode)), 64);
  6764. + if (ret) {
  6765. + dev_err(dev, "allocating dmfc bandwidth failed with %d\n", ret);
  6766. + return ret;
  6767. + }
  6768. +
  6769. + cpmem = ipu_get_cpmem(ipu_plane->ipu_ch);
  6770. + ipu_ch_param_zero(cpmem);
  6771. + ipu_cpmem_set_resolution(cpmem, src_w, src_h);
  6772. + ret = ipu_cpmem_set_fmt(cpmem, fb->pixel_format);
  6773. + if (ret < 0) {
  6774. + dev_err(dev, "unsupported pixel format 0x%08x\n",
  6775. + fb->pixel_format);
  6776. + return ret;
  6777. + }
  6778. + ipu_cpmem_set_high_priority(ipu_plane->ipu_ch);
  6779. +
  6780. + ret = ipu_plane_set_base(ipu_plane, fb, src_x, src_y);
  6781. + if (ret < 0)
  6782. + return ret;
  6783. +
  6784. + return 0;
  6785. +}
  6786. +
  6787. +void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
  6788. +{
  6789. + if (!IS_ERR_OR_NULL(ipu_plane->dp))
  6790. + ipu_dp_put(ipu_plane->dp);
  6791. + if (!IS_ERR_OR_NULL(ipu_plane->dmfc))
  6792. + ipu_dmfc_put(ipu_plane->dmfc);
  6793. + if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch))
  6794. + ipu_idmac_put(ipu_plane->ipu_ch);
  6795. +}
  6796. +
  6797. +int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
  6798. +{
  6799. + int ret;
  6800. +
  6801. + ipu_plane->ipu_ch = ipu_idmac_get(ipu_plane->ipu, ipu_plane->dma);
  6802. + if (IS_ERR(ipu_plane->ipu_ch)) {
  6803. + ret = PTR_ERR(ipu_plane->ipu_ch);
  6804. + DRM_ERROR("failed to get idmac channel: %d\n", ret);
  6805. + return ret;
  6806. + }
  6807. +
  6808. + ipu_plane->dmfc = ipu_dmfc_get(ipu_plane->ipu, ipu_plane->dma);
  6809. + if (IS_ERR(ipu_plane->dmfc)) {
  6810. + ret = PTR_ERR(ipu_plane->dmfc);
  6811. + DRM_ERROR("failed to get dmfc: ret %d\n", ret);
  6812. + goto err_out;
  6813. + }
  6814. +
  6815. + if (ipu_plane->dp_flow >= 0) {
  6816. + ipu_plane->dp = ipu_dp_get(ipu_plane->ipu, ipu_plane->dp_flow);
  6817. + if (IS_ERR(ipu_plane->dp)) {
  6818. + ret = PTR_ERR(ipu_plane->dp);
  6819. + DRM_ERROR("failed to get dp flow: %d\n", ret);
  6820. + goto err_out;
  6821. + }
  6822. + }
  6823. +
  6824. + return 0;
  6825. +err_out:
  6826. + ipu_plane_put_resources(ipu_plane);
  6827. +
  6828. + return ret;
  6829. +}
  6830. +
  6831. +void ipu_plane_enable(struct ipu_plane *ipu_plane)
  6832. +{
  6833. + if (ipu_plane->dp)
  6834. + ipu_dp_enable(ipu_plane->ipu);
  6835. + ipu_dmfc_enable_channel(ipu_plane->dmfc);
  6836. + ipu_idmac_enable_channel(ipu_plane->ipu_ch);
  6837. + if (ipu_plane->dp)
  6838. + ipu_dp_enable_channel(ipu_plane->dp);
  6839. +
  6840. + ipu_plane->enabled = true;
  6841. +}
  6842. +
  6843. +void ipu_plane_disable(struct ipu_plane *ipu_plane)
  6844. +{
  6845. + ipu_plane->enabled = false;
  6846. +
  6847. + ipu_idmac_wait_busy(ipu_plane->ipu_ch, 50);
  6848. +
  6849. + if (ipu_plane->dp)
  6850. + ipu_dp_disable_channel(ipu_plane->dp);
  6851. + ipu_idmac_disable_channel(ipu_plane->ipu_ch);
  6852. + ipu_dmfc_disable_channel(ipu_plane->dmfc);
  6853. + if (ipu_plane->dp)
  6854. + ipu_dp_disable(ipu_plane->ipu);
  6855. +}
  6856. +
  6857. +static void ipu_plane_dpms(struct ipu_plane *ipu_plane, int mode)
  6858. +{
  6859. + bool enable;
  6860. +
  6861. + DRM_DEBUG_KMS("mode = %d", mode);
  6862. +
  6863. + enable = (mode == DRM_MODE_DPMS_ON);
  6864. +
  6865. + if (enable == ipu_plane->enabled)
  6866. + return;
  6867. +
  6868. + if (enable) {
  6869. + ipu_plane_enable(ipu_plane);
  6870. + } else {
  6871. + ipu_plane_disable(ipu_plane);
  6872. +
  6873. + ipu_idmac_put(ipu_plane->ipu_ch);
  6874. + ipu_dmfc_put(ipu_plane->dmfc);
  6875. + if (ipu_plane->dp)
  6876. + ipu_dp_put(ipu_plane->dp);
  6877. + }
  6878. +}
  6879. +
  6880. +/*
  6881. + * drm_plane API
  6882. + */
  6883. +
  6884. +static int ipu_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
  6885. + struct drm_framebuffer *fb, int crtc_x, int crtc_y,
  6886. + unsigned int crtc_w, unsigned int crtc_h,
  6887. + uint32_t src_x, uint32_t src_y,
  6888. + uint32_t src_w, uint32_t src_h)
  6889. +{
  6890. + struct ipu_plane *ipu_plane = to_ipu_plane(plane);
  6891. + int ret = 0;
  6892. +
  6893. + DRM_DEBUG_KMS("plane - %p\n", plane);
  6894. +
  6895. + if (!ipu_plane->enabled)
  6896. + ret = ipu_plane_get_resources(ipu_plane);
  6897. + if (ret < 0)
  6898. + return ret;
  6899. +
  6900. + ret = ipu_plane_mode_set(ipu_plane, crtc, &crtc->hwmode, fb,
  6901. + crtc_x, crtc_y, crtc_w, crtc_h,
  6902. + src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16);
  6903. + if (ret < 0) {
  6904. + ipu_plane_put_resources(ipu_plane);
  6905. + return ret;
  6906. + }
  6907. +
  6908. + if (crtc != plane->crtc)
  6909. + dev_info(plane->dev->dev, "crtc change: %p -> %p\n",
  6910. + plane->crtc, crtc);
  6911. + plane->crtc = crtc;
  6912. +
  6913. + ipu_plane_dpms(ipu_plane, DRM_MODE_DPMS_ON);
  6914. +
  6915. + return 0;
  6916. +}
  6917. +
  6918. +static int ipu_disable_plane(struct drm_plane *plane)
  6919. +{
  6920. + struct ipu_plane *ipu_plane = to_ipu_plane(plane);
  6921. +
  6922. + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
  6923. +
  6924. + ipu_plane_dpms(ipu_plane, DRM_MODE_DPMS_OFF);
  6925. +
  6926. + ipu_plane_put_resources(ipu_plane);
  6927. +
  6928. + return 0;
  6929. +}
  6930. +
  6931. +static void ipu_plane_destroy(struct drm_plane *plane)
  6932. +{
  6933. + struct ipu_plane *ipu_plane = to_ipu_plane(plane);
  6934. +
  6935. + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
  6936. +
  6937. + ipu_disable_plane(plane);
  6938. + drm_plane_cleanup(plane);
  6939. + kfree(ipu_plane);
  6940. +}
  6941. +
  6942. +static struct drm_plane_funcs ipu_plane_funcs = {
  6943. + .update_plane = ipu_update_plane,
  6944. + .disable_plane = ipu_disable_plane,
  6945. + .destroy = ipu_plane_destroy,
  6946. +};
  6947. +
  6948. +struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
  6949. + int dma, int dp, unsigned int possible_crtcs,
  6950. + bool priv)
  6951. +{
  6952. + struct ipu_plane *ipu_plane;
  6953. + int ret;
  6954. +
  6955. + DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
  6956. + dma, dp, possible_crtcs);
  6957. +
  6958. + ipu_plane = kzalloc(sizeof(*ipu_plane), GFP_KERNEL);
  6959. + if (!ipu_plane) {
  6960. + DRM_ERROR("failed to allocate plane\n");
  6961. + return ERR_PTR(-ENOMEM);
  6962. + }
  6963. +
  6964. + ipu_plane->ipu = ipu;
  6965. + ipu_plane->dma = dma;
  6966. + ipu_plane->dp_flow = dp;
  6967. +
  6968. + ret = drm_plane_init(dev, &ipu_plane->base, possible_crtcs,
  6969. + &ipu_plane_funcs, ipu_plane_formats,
  6970. + ARRAY_SIZE(ipu_plane_formats),
  6971. + priv);
  6972. + if (ret) {
  6973. + DRM_ERROR("failed to initialize plane\n");
  6974. + kfree(ipu_plane);
  6975. + return ERR_PTR(ret);
  6976. + }
  6977. +
  6978. + return ipu_plane;
  6979. +}
  6980. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/Kconfig linux-3.16.6/drivers/staging/imx-drm/Kconfig
  6981. --- linux-3.16.6.orig/drivers/staging/imx-drm/Kconfig 2014-10-15 05:05:43.000000000 -0500
  6982. +++ linux-3.16.6/drivers/staging/imx-drm/Kconfig 2014-10-23 12:37:23.890220362 -0500
  6983. @@ -35,6 +35,7 @@
  6984. config DRM_IMX_LDB
  6985. tristate "Support for LVDS displays"
  6986. depends on DRM_IMX && MFD_SYSCON
  6987. + select DRM_PANEL
  6988. help
  6989. Choose this to enable the internal LVDS Display Bridge (LDB)
  6990. found on i.MX53 and i.MX6 processors.
  6991. @@ -51,3 +52,20 @@
  6992. depends on DRM_IMX
  6993. help
  6994. Choose this if you want to use HDMI on i.MX6.
  6995. +
  6996. +config DRM_DW_HDMI_AUDIO
  6997. + tristate "Synopsis Designware Audio interface"
  6998. + depends on DRM_IMX_HDMI != n
  6999. + help
  7000. + Support the Audio interface which is part of the Synopsis
  7001. + Designware HDMI block. This is used in conjunction with
  7002. + the i.MX HDMI driver.
  7003. +
  7004. +config DRM_DW_HDMI_CEC
  7005. + tristate "Synopsis Designware CEC interface"
  7006. + depends on DRM_IMX_HDMI != n
  7007. + select HDMI_CEC_CORE
  7008. + help
  7009. + Support the CEC interface which is part of the Synposis
  7010. + Designware HDMI block. This is used in conjunction with
  7011. + the i.MX HDMI driver.
  7012. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/Kconfig.orig linux-3.16.6/drivers/staging/imx-drm/Kconfig.orig
  7013. --- linux-3.16.6.orig/drivers/staging/imx-drm/Kconfig.orig 1969-12-31 18:00:00.000000000 -0600
  7014. +++ linux-3.16.6/drivers/staging/imx-drm/Kconfig.orig 2014-10-23 12:35:45.310219999 -0500
  7015. @@ -0,0 +1,62 @@
  7016. +config DRM_IMX
  7017. + tristate "DRM Support for Freescale i.MX"
  7018. + select DRM_KMS_HELPER
  7019. + select DRM_KMS_FB_HELPER
  7020. + select VIDEOMODE_HELPERS
  7021. + select DRM_GEM_CMA_HELPER
  7022. + select DRM_KMS_CMA_HELPER
  7023. + depends on DRM && (ARCH_MXC || ARCH_MULTIPLATFORM)
  7024. + help
  7025. + enable i.MX graphics support
  7026. +
  7027. +config DRM_IMX_FB_HELPER
  7028. + tristate "provide legacy framebuffer /dev/fb0"
  7029. + select DRM_KMS_CMA_HELPER
  7030. + depends on DRM_IMX
  7031. + help
  7032. + The DRM framework can provide a legacy /dev/fb0 framebuffer
  7033. + for your device. This is necessary to get a framebuffer console
  7034. + and also for applications using the legacy framebuffer API
  7035. +
  7036. +config DRM_IMX_PARALLEL_DISPLAY
  7037. + tristate "Support for parallel displays"
  7038. + select DRM_PANEL
  7039. + depends on DRM_IMX
  7040. + select VIDEOMODE_HELPERS
  7041. +
  7042. +config DRM_IMX_TVE
  7043. + tristate "Support for TV and VGA displays"
  7044. + depends on DRM_IMX
  7045. + select REGMAP_MMIO
  7046. + help
  7047. + Choose this to enable the internal Television Encoder (TVe)
  7048. + found on i.MX53 processors.
  7049. +
  7050. +config DRM_IMX_LDB
  7051. + tristate "Support for LVDS displays"
  7052. + depends on DRM_IMX && MFD_SYSCON
  7053. + select DRM_PANEL
  7054. + help
  7055. + Choose this to enable the internal LVDS Display Bridge (LDB)
  7056. + found on i.MX53 and i.MX6 processors.
  7057. +
  7058. +config DRM_IMX_IPUV3
  7059. + tristate "DRM Support for i.MX IPUv3"
  7060. + depends on DRM_IMX
  7061. + depends on IMX_IPUV3_CORE
  7062. + help
  7063. + Choose this if you have a i.MX5 or i.MX6 processor.
  7064. +
  7065. +config DRM_IMX_HDMI
  7066. + tristate "Freescale i.MX DRM HDMI"
  7067. + depends on DRM_IMX
  7068. + help
  7069. + Choose this if you want to use HDMI on i.MX6.
  7070. +
  7071. +config DRM_DW_HDMI_AUDIO
  7072. + tristate "Synopsis Designware Audio interface"
  7073. + depends on DRM_IMX_HDMI != n
  7074. + help
  7075. + Support the Audio interface which is part of the Synopsis
  7076. + Designware HDMI block. This is used in conjunction with
  7077. + the i.MX HDMI driver.
  7078. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/Makefile linux-3.16.6/drivers/staging/imx-drm/Makefile
  7079. --- linux-3.16.6.orig/drivers/staging/imx-drm/Makefile 2014-10-15 05:05:43.000000000 -0500
  7080. +++ linux-3.16.6/drivers/staging/imx-drm/Makefile 2014-10-23 12:37:30.178219970 -0500
  7081. @@ -3,6 +3,7 @@
  7082. obj-$(CONFIG_DRM_IMX) += imxdrm.o
  7083. +obj-$(CONFIG_DRM_IMX) += drm-ddc-connector.o
  7084. obj-$(CONFIG_DRM_IMX_PARALLEL_DISPLAY) += parallel-display.o
  7085. obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o
  7086. obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
  7087. @@ -10,3 +11,5 @@
  7088. imx-ipuv3-crtc-objs := ipuv3-crtc.o ipuv3-plane.o
  7089. obj-$(CONFIG_DRM_IMX_IPUV3) += imx-ipuv3-crtc.o
  7090. obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
  7091. +obj-$(CONFIG_DRM_DW_HDMI_AUDIO) += dw-hdmi-audio.o
  7092. +obj-$(CONFIG_DRM_DW_HDMI_CEC) += dw-hdmi-cec.o
  7093. diff -Nur linux-3.16.6.orig/drivers/staging/imx-drm/parallel-display.c linux-3.16.6/drivers/staging/imx-drm/parallel-display.c
  7094. --- linux-3.16.6.orig/drivers/staging/imx-drm/parallel-display.c 2014-10-15 05:05:43.000000000 -0500
  7095. +++ linux-3.16.6/drivers/staging/imx-drm/parallel-display.c 2014-10-23 12:35:30.986219995 -0500
  7096. @@ -225,6 +225,8 @@
  7097. imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
  7098. else if (!strcmp(fmt, "bgr666"))
  7099. imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
  7100. + else if (!strcmp(fmt, "rgb666"))
  7101. + imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB666;
  7102. else if (!strcmp(fmt, "lvds666"))
  7103. imxpd->interface_pix_fmt = v4l2_fourcc('L', 'V', 'D', '6');
  7104. }
  7105. diff -Nur linux-3.16.6.orig/include/linux/cec-dev.h linux-3.16.6/include/linux/cec-dev.h
  7106. --- linux-3.16.6.orig/include/linux/cec-dev.h 1969-12-31 18:00:00.000000000 -0600
  7107. +++ linux-3.16.6/include/linux/cec-dev.h 2014-10-23 12:37:18.374219998 -0500
  7108. @@ -0,0 +1,69 @@
  7109. +#ifndef _LINUX_CEC_DEV_H
  7110. +#define _LINUX_CEC_DEV_H
  7111. +
  7112. +#include <linux/cdev.h>
  7113. +#include <linux/list.h>
  7114. +#include <linux/mutex.h>
  7115. +#include <linux/spinlock.h>
  7116. +#include <linux/wait.h>
  7117. +
  7118. +#include <uapi/linux/cec-dev.h>
  7119. +
  7120. +struct device;
  7121. +
  7122. +struct cec_dev {
  7123. + struct cdev cdev;
  7124. + dev_t devn;
  7125. +
  7126. + struct mutex mutex;
  7127. + unsigned users;
  7128. +
  7129. + spinlock_t lock;
  7130. + wait_queue_head_t waitq;
  7131. + struct list_head events;
  7132. + u8 write_busy;
  7133. +
  7134. + u8 retries;
  7135. + u16 addresses;
  7136. + u16 physical;
  7137. +
  7138. + int (*open)(struct cec_dev *);
  7139. + void (*release)(struct cec_dev *);
  7140. + void (*send_message)(struct cec_dev *, u8 *, size_t);
  7141. + void (*set_address)(struct cec_dev *, unsigned);
  7142. +};
  7143. +
  7144. +void cec_dev_event(struct cec_dev *cec_dev, int type, u8 *msg, size_t len);
  7145. +
  7146. +static inline void cec_dev_receive(struct cec_dev *cec_dev, u8 *msg,
  7147. + unsigned len)
  7148. +{
  7149. + cec_dev_event(cec_dev, MESSAGE_TYPE_RECEIVE_SUCCESS, msg, len);
  7150. +}
  7151. +
  7152. +static inline void cec_dev_send_complete(struct cec_dev *cec_dev, int ack)
  7153. +{
  7154. + cec_dev->retries = 0;
  7155. + cec_dev->write_busy = 0;
  7156. +
  7157. + cec_dev_event(cec_dev, ack ? MESSAGE_TYPE_SEND_SUCCESS :
  7158. + MESSAGE_TYPE_NOACK, NULL, 0);
  7159. +}
  7160. +
  7161. +static inline void cec_dev_disconnect(struct cec_dev *cec_dev)
  7162. +{
  7163. + cec_dev->physical = 0;
  7164. + cec_dev_event(cec_dev, MESSAGE_TYPE_DISCONNECTED, NULL, 0);
  7165. +}
  7166. +
  7167. +static inline void cec_dev_connect(struct cec_dev *cec_dev, u32 phys)
  7168. +{
  7169. + cec_dev->physical = phys;
  7170. + cec_dev_event(cec_dev, MESSAGE_TYPE_CONNECTED, NULL, 0);
  7171. +}
  7172. +
  7173. +void cec_dev_init(struct cec_dev *cec_dev, struct module *);
  7174. +int cec_dev_add(struct cec_dev *cec_dev, struct device *, const char *name);
  7175. +void cec_dev_remove(struct cec_dev *cec_dev);
  7176. +
  7177. +#endif
  7178. diff -Nur linux-3.16.6.orig/include/linux/mmc/host.h linux-3.16.6/include/linux/mmc/host.h
  7179. --- linux-3.16.6.orig/include/linux/mmc/host.h 2014-10-15 05:05:43.000000000 -0500
  7180. +++ linux-3.16.6/include/linux/mmc/host.h 2014-10-23 12:34:18.742220000 -0500
  7181. @@ -298,6 +298,11 @@
  7182. unsigned long clkgate_delay;
  7183. #endif
  7184. + /* card specific properties to deal with power and reset */
  7185. + struct regulator *card_regulator; /* External VCC needed by the card */
  7186. + struct gpio_desc *card_reset_gpios[2]; /* External resets, active low */
  7187. + struct clk *card_clk; /* External clock needed by the card */
  7188. +
  7189. /* host specific block data */
  7190. unsigned int max_seg_size; /* see blk_queue_max_segment_size */
  7191. unsigned short max_segs; /* see blk_queue_max_segments */
  7192. diff -Nur linux-3.16.6.orig/include/uapi/linux/cec-dev.h linux-3.16.6/include/uapi/linux/cec-dev.h
  7193. --- linux-3.16.6.orig/include/uapi/linux/cec-dev.h 1969-12-31 18:00:00.000000000 -0600
  7194. +++ linux-3.16.6/include/uapi/linux/cec-dev.h 2014-10-23 12:37:18.374219998 -0500
  7195. @@ -0,0 +1,34 @@
  7196. +#ifndef _UAPI_LINUX_CEC_DEV_H
  7197. +#define _UAPI_LINUX_CEC_DEV_H
  7198. +
  7199. +#include <linux/ioctl.h>
  7200. +#include <linux/types.h>
  7201. +
  7202. +#define MAX_MESSAGE_LEN 16
  7203. +
  7204. +enum {
  7205. + HDMICEC_IOC_MAGIC = 'H',
  7206. + /* This is wrong: we pass the argument as a number, not a pointer */
  7207. + HDMICEC_IOC_O_SETLOGICALADDRESS = _IOW(HDMICEC_IOC_MAGIC, 1, unsigned char),
  7208. + HDMICEC_IOC_SETLOGICALADDRESS = _IO(HDMICEC_IOC_MAGIC, 1),
  7209. + HDMICEC_IOC_STARTDEVICE = _IO(HDMICEC_IOC_MAGIC, 2),
  7210. + HDMICEC_IOC_STOPDEVICE = _IO(HDMICEC_IOC_MAGIC, 3),
  7211. + HDMICEC_IOC_GETPHYADDRESS = _IOR(HDMICEC_IOC_MAGIC, 4, unsigned char[4]),
  7212. +};
  7213. +
  7214. +enum {
  7215. + MESSAGE_TYPE_RECEIVE_SUCCESS = 1,
  7216. + MESSAGE_TYPE_NOACK,
  7217. + MESSAGE_TYPE_DISCONNECTED,
  7218. + MESSAGE_TYPE_CONNECTED,
  7219. + MESSAGE_TYPE_SEND_SUCCESS,
  7220. + MESSAGE_TYPE_SEND_ERROR,
  7221. +};
  7222. +
  7223. +struct cec_user_event {
  7224. + __u32 event_type;
  7225. + __u32 msg_len;
  7226. + __u8 msg[MAX_MESSAGE_LEN];
  7227. +};
  7228. +
  7229. +#endif
  7230. diff -Nur linux-3.16.6.orig/include/uapi/linux/videodev2.h linux-3.16.6/include/uapi/linux/videodev2.h
  7231. --- linux-3.16.6.orig/include/uapi/linux/videodev2.h 2014-10-15 05:05:43.000000000 -0500
  7232. +++ linux-3.16.6/include/uapi/linux/videodev2.h 2014-10-23 12:35:23.722220002 -0500
  7233. @@ -299,6 +299,7 @@
  7234. #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
  7235. #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
  7236. #define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H') /* 18 BGR-6-6-6 */
  7237. +#define V4L2_PIX_FMT_RGB666 v4l2_fourcc('R', 'G', 'B', 'H') /* 18 RGB-6-6-6 */
  7238. #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
  7239. #define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
  7240. #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
  7241. diff -Nur linux-3.16.6.orig/include/video/imx-ipu-v3.h linux-3.16.6/include/video/imx-ipu-v3.h
  7242. --- linux-3.16.6.orig/include/video/imx-ipu-v3.h 2014-10-15 05:05:43.000000000 -0500
  7243. +++ linux-3.16.6/include/video/imx-ipu-v3.h 2014-10-23 12:35:38.090219994 -0500
  7244. @@ -27,6 +27,12 @@
  7245. #define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3')
  7246. +#define CLK_POL_NEGEDGE 0
  7247. +#define CLK_POL_POSEDGE 1
  7248. +
  7249. +#define ENABLE_POL_LOW 0
  7250. +#define ENABLE_POL_HIGH 1
  7251. +
  7252. /*
  7253. * Bitfield of Display Interface signal polarities.
  7254. */
  7255. @@ -37,7 +43,7 @@
  7256. unsigned clksel_en:1;
  7257. unsigned clkidle_en:1;
  7258. unsigned data_pol:1; /* true = inverted */
  7259. - unsigned clk_pol:1; /* true = rising edge */
  7260. + unsigned clk_pol:1;
  7261. unsigned enable_pol:1;
  7262. unsigned Hsync_pol:1; /* true = active high */
  7263. unsigned Vsync_pol:1;
  7264. diff -Nur linux-3.16.6.orig/sound/soc/codecs/sgtl5000.c linux-3.16.6/sound/soc/codecs/sgtl5000.c
  7265. --- linux-3.16.6.orig/sound/soc/codecs/sgtl5000.c 2014-10-15 05:05:43.000000000 -0500
  7266. +++ linux-3.16.6/sound/soc/codecs/sgtl5000.c 2014-10-23 12:37:45.114220003 -0500
  7267. @@ -773,7 +773,7 @@
  7268. struct ldo_regulator *ldo = rdev_get_drvdata(dev);
  7269. struct snd_soc_codec *codec = (struct snd_soc_codec *)ldo->codec_data;
  7270. int reg;
  7271. -
  7272. +dev_info(codec->dev, "%s(): enabled %u\n", __func__, ldo->enabled);
  7273. if (ldo_regulator_is_enabled(dev))
  7274. return 0;
  7275. @@ -805,10 +805,16 @@
  7276. {
  7277. struct ldo_regulator *ldo = rdev_get_drvdata(dev);
  7278. struct snd_soc_codec *codec = (struct snd_soc_codec *)ldo->codec_data;
  7279. +dev_info(codec->dev, "%s(): enabled %u\n", __func__, ldo->enabled);
  7280. +
  7281. + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
  7282. + SGTL5000_LINREG_SIMPLE_POWERUP,
  7283. + SGTL5000_LINREG_SIMPLE_POWERUP);
  7284. snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
  7285. SGTL5000_LINEREG_D_POWERUP,
  7286. 0);
  7287. +dev_info(codec->dev, "%s: ANA_POWER = 0x%04x\n", __func__, snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER));
  7288. /* clear voltage info */
  7289. snd_soc_update_bits(codec, SGTL5000_CHIP_LINREG_CTRL,
  7290. @@ -866,6 +872,7 @@
  7291. config.dev = codec->dev;
  7292. config.driver_data = ldo;
  7293. config.init_data = init_data;
  7294. + config.ena_gpio = -EINVAL;
  7295. ldo->dev = regulator_register(&ldo->desc, &config);
  7296. if (IS_ERR(ldo->dev)) {
  7297. @@ -1159,8 +1166,11 @@
  7298. * if vddio and vddd > 3.1v,
  7299. * charge pump should be clean before set ana_pwr
  7300. */
  7301. - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
  7302. - SGTL5000_VDDC_CHRGPMP_POWERUP, 0);
  7303. +// FIXME: this is total crap - we have read this register above into
  7304. +// ana_pwr, which we then modify (above), and then write back to the
  7305. +// register below. This modification just gets completely overwritten.
  7306. +// snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
  7307. +// SGTL5000_VDDC_CHRGPMP_POWERUP, 0);
  7308. /* VDDC use VDDIO rail */
  7309. lreg_ctrl |= SGTL5000_VDDC_ASSN_OVRD;
  7310. @@ -1304,6 +1314,9 @@
  7311. int ret;
  7312. struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
  7313. + if (!devres_open_group(codec->dev, NULL, GFP_KERNEL))
  7314. + return -ENOMEM;
  7315. +
  7316. ret = sgtl5000_enable_regulators(codec);
  7317. if (ret)
  7318. return ret;
  7319. @@ -1361,6 +1374,9 @@
  7320. err:
  7321. regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
  7322. sgtl5000->supplies);
  7323. +
  7324. + devres_release_group(codec->dev, NULL);
  7325. +
  7326. ldo_regulator_remove(codec);
  7327. return ret;
  7328. @@ -1374,6 +1390,9 @@
  7329. regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
  7330. sgtl5000->supplies);
  7331. +
  7332. + devres_release_group(codec->dev, NULL);
  7333. +
  7334. ldo_regulator_remove(codec);
  7335. return 0;
  7336. diff -Nur linux-3.16.6.orig/sound/soc/fsl/imx-pcm-dma.c linux-3.16.6/sound/soc/fsl/imx-pcm-dma.c
  7337. --- linux-3.16.6.orig/sound/soc/fsl/imx-pcm-dma.c 2014-10-15 05:05:43.000000000 -0500
  7338. +++ linux-3.16.6/sound/soc/fsl/imx-pcm-dma.c 2014-10-23 12:35:54.206220260 -0500
  7339. @@ -43,7 +43,7 @@
  7340. .buffer_bytes_max = IMX_SSI_DMABUF_SIZE,
  7341. .period_bytes_min = 128,
  7342. .period_bytes_max = 65535, /* Limited by SDMA engine */
  7343. - .periods_min = 2,
  7344. + .periods_min = 4,
  7345. .periods_max = 255,
  7346. .fifo_size = 0,
  7347. };
  7348. @@ -59,6 +59,7 @@
  7349. {
  7350. return devm_snd_dmaengine_pcm_register(&pdev->dev,
  7351. &imx_dmaengine_pcm_config,
  7352. + SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
  7353. SND_DMAENGINE_PCM_FLAG_COMPAT);
  7354. }
  7355. EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
  7356. diff -Nur linux-3.16.6.orig/sound/soc/fsl/imx-pcm-dma.c.orig linux-3.16.6/sound/soc/fsl/imx-pcm-dma.c.orig
  7357. --- linux-3.16.6.orig/sound/soc/fsl/imx-pcm-dma.c.orig 1969-12-31 18:00:00.000000000 -0600
  7358. +++ linux-3.16.6/sound/soc/fsl/imx-pcm-dma.c.orig 2014-10-23 12:26:49.542220041 -0500
  7359. @@ -0,0 +1,66 @@
  7360. +/*
  7361. + * imx-pcm-dma-mx2.c -- ALSA Soc Audio Layer
  7362. + *
  7363. + * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
  7364. + *
  7365. + * This code is based on code copyrighted by Freescale,
  7366. + * Liam Girdwood, Javier Martin and probably others.
  7367. + *
  7368. + * This program is free software; you can redistribute it and/or modify it
  7369. + * under the terms of the GNU General Public License as published by the
  7370. + * Free Software Foundation; either version 2 of the License, or (at your
  7371. + * option) any later version.
  7372. + */
  7373. +#include <linux/platform_device.h>
  7374. +#include <linux/dmaengine.h>
  7375. +#include <linux/types.h>
  7376. +#include <linux/module.h>
  7377. +
  7378. +#include <sound/core.h>
  7379. +#include <sound/pcm.h>
  7380. +#include <sound/soc.h>
  7381. +#include <sound/dmaengine_pcm.h>
  7382. +
  7383. +#include "imx-pcm.h"
  7384. +
  7385. +static bool filter(struct dma_chan *chan, void *param)
  7386. +{
  7387. + if (!imx_dma_is_general_purpose(chan))
  7388. + return false;
  7389. +
  7390. + chan->private = param;
  7391. +
  7392. + return true;
  7393. +}
  7394. +
  7395. +static const struct snd_pcm_hardware imx_pcm_hardware = {
  7396. + .info = SNDRV_PCM_INFO_INTERLEAVED |
  7397. + SNDRV_PCM_INFO_BLOCK_TRANSFER |
  7398. + SNDRV_PCM_INFO_MMAP |
  7399. + SNDRV_PCM_INFO_MMAP_VALID |
  7400. + SNDRV_PCM_INFO_PAUSE |
  7401. + SNDRV_PCM_INFO_RESUME,
  7402. + .buffer_bytes_max = IMX_SSI_DMABUF_SIZE,
  7403. + .period_bytes_min = 128,
  7404. + .period_bytes_max = 65535, /* Limited by SDMA engine */
  7405. + .periods_min = 4,
  7406. + .periods_max = 255,
  7407. + .fifo_size = 0,
  7408. +};
  7409. +
  7410. +static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
  7411. + .pcm_hardware = &imx_pcm_hardware,
  7412. + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  7413. + .compat_filter_fn = filter,
  7414. + .prealloc_buffer_size = IMX_SSI_DMABUF_SIZE,
  7415. +};
  7416. +
  7417. +int imx_pcm_dma_init(struct platform_device *pdev)
  7418. +{
  7419. + return devm_snd_dmaengine_pcm_register(&pdev->dev,
  7420. + &imx_dmaengine_pcm_config,
  7421. + SND_DMAENGINE_PCM_FLAG_COMPAT);
  7422. +}
  7423. +EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
  7424. +
  7425. +MODULE_LICENSE("GPL");