rbppc.patch 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047
  1. diff -Nur linux-3.16.85.orig/arch/powerpc/boot/dts/rb333.dts linux-3.16.85/arch/powerpc/boot/dts/rb333.dts
  2. --- linux-3.16.85.orig/arch/powerpc/boot/dts/rb333.dts 1970-01-01 01:00:00.000000000 +0100
  3. +++ linux-3.16.85/arch/powerpc/boot/dts/rb333.dts 2026-04-25 10:21:57.449901553 +0200
  4. @@ -0,0 +1,455 @@
  5. +/*
  6. + * RouterBOARD 333 series Device Tree Source
  7. + *
  8. + * Copyright (C) 2011 Noah Fontes <nfontes@invectorate.com>
  9. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  10. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  11. + *
  12. + * This program is free software; you can redistribute it and/or modify it
  13. + * under the terms of the GNU General Public License as published by the
  14. + * Free Software Foundation; either version 2 of the License, or (at your
  15. + * option) any later version.
  16. + */
  17. +
  18. +/dts-v1/;
  19. +
  20. +/ {
  21. + model = "RB333";
  22. + compatible = "RB333", "RBPPC";
  23. + #size-cells = <1>;
  24. + #address-cells = <1>;
  25. +
  26. + aliases {
  27. + ethernet0 = &enet0;
  28. + ethernet1 = &enet1;
  29. + ethernet2 = &enet2;
  30. + pci0 = &pci0;
  31. + };
  32. +
  33. + chosen {
  34. + bootargs = "console=ttyS0,115200 board=mpc8323";
  35. + linux,stdout-path = "/soc8323@e0000000/serial@4500";
  36. + };
  37. +
  38. + cpus {
  39. + #cpus = <1>;
  40. + #size-cells = <0>;
  41. + #address-cells = <1>;
  42. +
  43. + PowerPC,8323E@0 {
  44. + device_type = "cpu";
  45. + reg = <0x0>;
  46. + i-cache-size = <0x4000>;
  47. + d-cache-size = <0x4000>;
  48. + i-cache-line-size = <0x20>;
  49. + d-cache-line-size = <0x20>;
  50. + timebase-frequency = <0>; // Filled from the bootloader
  51. + clock-frequency = <0>; // Filled from the bootloader
  52. + 32-bit;
  53. + };
  54. + };
  55. +
  56. + memory {
  57. + device_type = "memory";
  58. + reg = <0 0>; // Filled from the bootloader
  59. + };
  60. +
  61. + voltage {
  62. + //voltage_gpio = <&gpio3 0x11>;
  63. + };
  64. +
  65. + fancon {
  66. + interrupts = <20 0x8>;
  67. + interrupt-parent = <&ipic>;
  68. + //fan_on = <&gpio0 0x10>;
  69. + };
  70. +
  71. + localbus@e0005000 {
  72. + #address-cells = <2>;
  73. + #size-cells = <1>;
  74. + compatible = "fsl,mpc8323e-localbus", "fsl,pq2pro-localbus", "simple-bus";
  75. + reg = <0xe0005000 0xe0>;
  76. + interrupts = <77 0x8>;
  77. + interrupt-parent = <&ipic>;
  78. + // FIXME: May not be correct (actual) ranges
  79. + ranges = <
  80. + 0x0 0x0 0xfe000000 0x00100000 // Flash
  81. + 0x1 0x0 0xf8000000 0x00008000 // NAND (IO base)
  82. + 0x2 0x0 0xf0000000 0x00008000>; // NAND (nNAND?)
  83. +
  84. + flash@0,0 {
  85. + reg = <0x0 0x0 0x20000>;
  86. + };
  87. +
  88. + nand@1,0 {
  89. + compatible = "rb,rb333-nand", "rb,nand";
  90. + reg = <
  91. + 0x1 0x0 0x1000 // IO
  92. + 0x2 0x0 0x1000>; // Sync
  93. +
  94. + gpios = <
  95. + &pio_gpio2 0 0 // R/B
  96. + &pio_gpio2 1 0 // nCE
  97. + &pio_gpio2 2 0 // CLE
  98. + &pio_gpio2 3 0>; // ALE
  99. +
  100. + partitions {
  101. + #address-cells = <1>;
  102. + #size-cells = <1>;
  103. +
  104. + kernel@0 {
  105. + label = "kernel";
  106. + reg = <0x00000000 0x00400000>;
  107. + };
  108. + rootfs@400000 {
  109. + label = "rootfs";
  110. + reg = <0x00400000 0x03c00000>;
  111. + };
  112. + };
  113. + };
  114. + };
  115. +
  116. + pci0: pci@e0008500 {
  117. + #address-cells = <3>;
  118. + #size-cells = <2>;
  119. + #interrupt-cells = <1>;
  120. + device_type = "pci";
  121. + compatible = "fsl,mpc8349-pci";
  122. + reg = <0xe0008500 0x100 0xe0008300 0x8>;
  123. + ranges = <
  124. + 0x02000000 0x0 0x80000000
  125. + 0x80000000 0x0 0x20000000
  126. + 0x01000000 0x0 0x00000000
  127. + 0xd0000000 0x0 0x04000000>;
  128. + bus-range = <0x0 0x0>;
  129. + interrupt-map = <
  130. + /* IDSEL 0x10 AD16 miniPCI slot 0 */
  131. + 0x8000 0x0 0x0 0x1 &ipic 0x11 0x8
  132. + 0x8000 0x0 0x0 0x2 &ipic 0x12 0x8
  133. +
  134. + /* IDSEL 0x11 AD17 miniPCI slot 1 */
  135. + 0x8800 0x0 0x0 0x1 &ipic 0x12 0x8
  136. + 0x8800 0x0 0x0 0x2 &ipic 0x13 0x8
  137. +
  138. + /* IDSEL 0x12 AD18 miniPCI slot 2 */
  139. + 0x9000 0x0 0x0 0x1 &ipic 0x13 0x8
  140. + 0x9000 0x0 0x0 0x2 &ipic 0x11 0x8>;
  141. + interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
  142. + interrupt-parent = <&ipic>;
  143. + };
  144. +
  145. + qe@e0100000 {
  146. + #size-cells = <1>;
  147. + #address-cells = <1>;
  148. + device_type = "qe";
  149. + compatible = "fsl,qe";
  150. + reg = <0xe0100000 0x480>;
  151. + ranges = <0x0 0xe0100000 0x100000>;
  152. + brg-frequency = <0>;
  153. + bus-frequency = <198000000>;
  154. + fsl,qe-num-riscs = <1>;
  155. + fsl,qe-num-snums = <28>;
  156. +
  157. + qeic: qeic@80 {
  158. + #address-cells = <0>;
  159. + #interrupt-cells = <1>;
  160. + device_type = "qeic";
  161. + compatible = "fsl,qe-ic";
  162. + reg = <0x80 0x80>;
  163. + big-endian;
  164. + built-in;
  165. + interrupts = <32 0x8 33 0x8>;
  166. + interrupt-parent = <&ipic>;
  167. + interrupt-controller;
  168. + };
  169. +
  170. + enet0: ucc@2200 {
  171. + device_type = "network";
  172. + compatible = "ucc_geth";
  173. + reg = <0x2200 0x200>;
  174. + tx-clock = <0x1a>;
  175. + rx-clock = <0x1f>;
  176. + mac-address = [00 00 00 00 00 00]; // Filled from the bootloader
  177. + interrupt-parent = <&qeic>;
  178. + interrupts = <0x22>;
  179. + device-id = <0x3>;
  180. + phy-handle = <&phy2>;
  181. + pio-handle = <&pio3>;
  182. + };
  183. +
  184. + enet1: ucc@3200 {
  185. + device_type = "network";
  186. + compatible = "ucc_geth";
  187. + reg = <0x3200 0x200>;
  188. + tx-clock = <0x22>;
  189. + rx-clock = <0x20>;
  190. + mac-address = [00 00 00 00 00 00]; // Filled from the bootloader
  191. + interrupt-parent = <&qeic>;
  192. + interrupts = <0x23>;
  193. + device-id = <0x4>;
  194. + phy-handle = <&phy3>;
  195. + pio-handle = <&pio4>;
  196. + };
  197. +
  198. + enet2: ucc@3000 {
  199. + tx-clock = <0x18>;
  200. + rx-clock = <0x17>;
  201. + mac-address = [00 00 00 00 00 00]; // Filled from the bootloader
  202. + interrupt-parent = <&qeic>;
  203. + interrupts = <0x21>;
  204. + reg = <0x3000 0x200>;
  205. + device-id = <0x2>;
  206. + compatible = "ucc_geth";
  207. + device_type = "network";
  208. + phy-handle = <&phy1>;
  209. + pio-handle = <&pio2>;
  210. + };
  211. +
  212. + mdio@3120 {
  213. + #address-cells = <1>;
  214. + #size-cells = <0>;
  215. + compatible = "ucc_geth_phy";
  216. + device_type = "mdio";
  217. + reg = <0x3120 0x18>;
  218. +
  219. + phy1: ethernet-phy@01 {
  220. + device_type = "ethernet-phy";
  221. + reg = <0x1>;
  222. + };
  223. +
  224. + phy2: ethernet-phy@02 {
  225. + device_type = "ethernet-phy";
  226. + reg = <0x2>;
  227. + };
  228. +
  229. + phy3: ethernet-phy@03 {
  230. + device_type = "ethernet-phy";
  231. + reg = <0x3>;
  232. + };
  233. + };
  234. +
  235. + spi@500 {
  236. + device_type = "spi";
  237. + compatible = "fsl,spi";
  238. + reg = <0x500 0x40>;
  239. + mode = "cpu";
  240. + interrupts = <1>;
  241. + interrupt-parent = <&qeic>;
  242. + };
  243. +
  244. + spi@4c0 {
  245. + device_type = "spi";
  246. + compatible = "fsl,spi";
  247. + reg = <0x4c0 0x40>;
  248. + mode = "cpu";
  249. + interrupts = <0x2>;
  250. + interrupt-parent = <&qeic>;
  251. + };
  252. +
  253. + muram@10000 {
  254. + #address-cells = <1>;
  255. + #size-cells = <1>;
  256. + device_type = "muram";
  257. + compatible = "fsl,qe-muram", "fsl,cpm-muram";
  258. + ranges = <0x0 0x10000 0x4000>;
  259. +
  260. + data-only@0 {
  261. + compatible = "fsl,qe-muram-data",
  262. + "fsl,cpm-muram-data";
  263. + reg = <0x0 0x4000>;
  264. + };
  265. + };
  266. + };
  267. +
  268. + soc8323@e0000000 {
  269. + #interrupt-cells = <0x2>;
  270. + #size-cells = <1>;
  271. + #address-cells = <1>;
  272. + device_type = "soc";
  273. + compatible = "simple-bus";
  274. + reg = <0xe0000000 0x200>;
  275. + ranges = <0x0 0xe0000000 0x100000>;
  276. + bus-frequency = <0>; // Filled from the bootloader
  277. +
  278. + gtm1: timer@500 {
  279. + compatible = "fsl,mpc8323e-gtm", "fsl,gtm";
  280. + reg = <0x500 0x40>;
  281. + interrupts = <90 0x8 78 0x8 84 0x8 72 0x8>;
  282. + interrupt-parent = <&ipic>;
  283. + clock-frequency = <0>; // Filled from the bootloader
  284. + };
  285. +
  286. + timer@600 {
  287. + compatible = "fsl,mpc8323e-gtm", "fsl,gtm";
  288. + reg = <0x600 0x40>;
  289. + interrupts = <91 0x8 79 0x8 85 0x8 73 0x8>;
  290. + interrupt-parent = <&ipic>;
  291. + clock-frequency = <0>; // Filled from the bootloader
  292. + };
  293. +
  294. + par_io@1400 {
  295. + #address-cells = <1>;
  296. + #size-cells = <1>;
  297. + device_type = "par_io";
  298. + compatible = "fsl,mpc8323-qe-pario";
  299. + reg = <0x1400 0x100>;
  300. + ranges = <
  301. + 0x0 0x1400 0x18
  302. + 0x1 0x1430 0x18
  303. + 0x2 0x1448 0x18>;
  304. + num-ports = <4>;
  305. +
  306. + pio_gpio1: gpio-controller@1400 {
  307. + #gpio-cells = <2>;
  308. + compatible = "fsl,mpc8323-qe-pario-bank";
  309. + reg = <0 0x18>;
  310. + gpio-controller;
  311. + };
  312. +
  313. + pio_gpio2: gpio-controller@1430 {
  314. + #gpio-cells = <2>;
  315. + compatible = "fsl,mpc8323-qe-pario-bank";
  316. + reg = <1 0x18>;
  317. + gpio-controller;
  318. + };
  319. +
  320. + pio_gpio3: gpio-controller@1448 {
  321. + #gpio-cells = <2>;
  322. + compatible = "fsl,mpc8323-qe-pario-bank";
  323. + reg = <2 0x18>;
  324. + gpio-controller;
  325. + };
  326. +
  327. + pio4: ucc_pin@04 {
  328. + pio-map = <
  329. + /* port pin dir open_drain assignment has_irq */
  330. + 1 18 1 0 1 0
  331. + 1 19 1 0 1 0
  332. + 1 20 1 0 1 0
  333. + 1 21 1 0 1 0
  334. + 1 30 1 0 1 0
  335. + 3 20 2 0 1 0
  336. + 1 30 2 0 1 0
  337. + 1 31 2 0 1 0
  338. + 1 22 2 0 1 0
  339. + 1 23 2 0 1 0
  340. + 1 24 2 0 1 0
  341. + 1 25 2 0 1 0
  342. + 1 28 2 0 1 0
  343. + 1 26 2 0 1 0
  344. + 3 21 2 0 1 0>;
  345. + };
  346. +
  347. + pio3: ucc_pin@03 {
  348. + pio-map = <
  349. + /* port pin dir open_drain assignment has_irq */
  350. + 1 0 1 0 1 0
  351. + 1 1 1 0 1 0
  352. + 1 2 1 0 1 0
  353. + 1 3 1 0 1 0
  354. + 1 12 1 0 1 0
  355. + 3 24 2 0 1 0
  356. + 1 11 2 0 1 0
  357. + 1 13 2 0 1 0
  358. + 1 4 2 0 1 0
  359. + 1 5 2 0 1 0
  360. + 1 6 2 0 1 0
  361. + 1 7 2 0 1 0
  362. + 1 10 2 0 1 0
  363. + 1 8 2 0 1 0
  364. + 3 29 2 0 1 0>;
  365. + };
  366. +
  367. + pio2: ucc_pin@02 {
  368. + pio-map = <
  369. + /* port pin dir open_drain assignment has_irq */
  370. + 3 4 3 0 2 0
  371. + 3 5 1 0 2 0
  372. + 0 18 1 0 1 0
  373. + 0 19 1 0 1 0
  374. + 0 20 1 0 1 0
  375. + 0 21 1 0 1 0
  376. + 0 30 1 0 1 0
  377. + 3 6 2 0 1 0
  378. + 0 29 2 0 1 0
  379. + 0 31 2 0 1 0
  380. + 0 22 2 0 1 0
  381. + 0 23 2 0 1 0
  382. + 0 24 2 0 1 0
  383. + 0 25 2 0 1 0
  384. + 0 28 2 0 1 0
  385. + 0 26 2 0 1 0
  386. + 3 31 2 0 1 0>;
  387. + };
  388. + };
  389. +
  390. + ipic: pic@700 {
  391. + #address-cells = <0x0>;
  392. + #interrupt-cells = <0x2>;
  393. + device_type = "ipic";
  394. + reg = <0x700 0x100>;
  395. + built-in;
  396. + interrupt-controller;
  397. + };
  398. +
  399. + serial@4500 {
  400. + interrupt-parent = <&ipic>;
  401. + interrupts = <0x9 0x8>;
  402. + clock-frequency = <0>; // Filled from the bootloader
  403. + reg = <0x4500 0x100>;
  404. + compatible = "ns16550";
  405. + device_type = "serial";
  406. + };
  407. +
  408. + dma@82a8 {
  409. + #address-cells = <1>;
  410. + #size-cells = <1>;
  411. + compatible = "fsl,mpc8323-dma", "fsl,elo-dma";
  412. + reg = <0x82a8 4>;
  413. + ranges = <0 0x8100 0x1a8>;
  414. + interrupt-parent = <&ipic>;
  415. + interrupts = <71 8>;
  416. + cell-index = <0>;
  417. + dma-channel@0 {
  418. + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
  419. + reg = <0 0x80>;
  420. + cell-index = <0>;
  421. + interrupt-parent = <&ipic>;
  422. + interrupts = <71 8>;
  423. + };
  424. + dma-channel@80 {
  425. + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
  426. + reg = <0x80 0x80>;
  427. + cell-index = <1>;
  428. + interrupt-parent = <&ipic>;
  429. + interrupts = <71 8>;
  430. + };
  431. + dma-channel@100 {
  432. + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
  433. + reg = <0x100 0x80>;
  434. + cell-index = <2>;
  435. + interrupt-parent = <&ipic>;
  436. + interrupts = <71 8>;
  437. + };
  438. + dma-channel@180 {
  439. + compatible = "fsl,mpc8323-dma-channel", "fsl,elo-dma-channel";
  440. + reg = <0x180 0x28>;
  441. + cell-index = <3>;
  442. + interrupt-parent = <&ipic>;
  443. + interrupts = <71 8>;
  444. + };
  445. + };
  446. +
  447. + wdt@200 {
  448. + reg = <0x200 0x100>;
  449. + compatible = "mpc83xx_wdt";
  450. + device_type = "watchdog";
  451. + };
  452. +
  453. + beeper {
  454. + compatible = "rb,rb333-gtm-beeper", "rb,gtm-beeper";
  455. + timer = <&gtm1 3>;
  456. + gpios = <&pio_gpio3 18 0>;
  457. + };
  458. + };
  459. +};
  460. diff -Nur linux-3.16.85.orig/arch/powerpc/boot/dts/rb600.dts linux-3.16.85/arch/powerpc/boot/dts/rb600.dts
  461. --- linux-3.16.85.orig/arch/powerpc/boot/dts/rb600.dts 1970-01-01 01:00:00.000000000 +0100
  462. +++ linux-3.16.85/arch/powerpc/boot/dts/rb600.dts 2026-04-25 10:21:57.449901553 +0200
  463. @@ -0,0 +1,344 @@
  464. +/*
  465. + * RouterBOARD 600 series Device Tree Source
  466. + *
  467. + * Copyright (C) 2011 Noah Fontes <nfontes@invectorate.com>
  468. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  469. + *
  470. + * This program is free software; you can redistribute it and/or modify it
  471. + * under the terms of the GNU General Public License as published by the
  472. + * Free Software Foundation; either version 2 of the License, or (at your
  473. + * option) any later version.
  474. + */
  475. +
  476. +/dts-v1/;
  477. +
  478. +/ {
  479. + model = "RB600";
  480. + compatible = "RB600", "RBPPC";
  481. + #address-cells = <1>;
  482. + #size-cells = <1>;
  483. +
  484. + aliases {
  485. + ethernet0 = &enet0;
  486. + ethernet1 = &enet1;
  487. + pci0 = &pci0;
  488. + };
  489. +
  490. + chosen {
  491. + bootargs = "console=ttyS0,115200 board=mpc8349";
  492. + linux,stdout-path = "/soc8343@e0000000/serial@4500";
  493. + };
  494. +
  495. + cpus {
  496. + #address-cells = <1>;
  497. + #size-cells = <0>;
  498. +
  499. + PowerPC,8343E@0 {
  500. + device_type = "cpu";
  501. + reg = <0x0>;
  502. + d-cache-line-size = <0x20>;
  503. + i-cache-line-size = <0x20>;
  504. + d-cache-size = <0x8000>;
  505. + i-cache-size = <0x8000>;
  506. + timebase-frequency = <0>; // Filled from the bootloader
  507. + clock-frequency = <0>; // Filled from the bootloader
  508. + };
  509. + };
  510. +
  511. + memory {
  512. + device_type = "memory";
  513. + reg = <0 0>; // Filled from the bootloader
  514. + };
  515. +
  516. + localbus@e0005000 {
  517. + #address-cells = <2>;
  518. + #size-cells = <1>;
  519. + compatible = "fsl,mpc8349-localbus", "fsl,pq2pro-localbus", "simple-bus";
  520. + reg = <0xe0005000 0xe0>;
  521. + interrupts = <77 0x8>;
  522. + interrupt-parent = <&ipic>;
  523. + ranges = <
  524. + 0x0 0x0 0xff800000 0x00100000 // Flash, GPCM
  525. + 0x1 0x0 0xf8000000 0x00008000 // NAND (IO base), UPMA
  526. + 0x2 0x0 0xf9000000 0x00020000 // CompactFlash (ATA), UPMC
  527. + 0x3 0x0 0xf9200000 0x00020000 // CompactFlash (ATA), UPMC
  528. + 0x4 0x0 0xf0000000 0x00008000>; // NAND (nNAND?), UPMB
  529. +
  530. + flash@0,0 {
  531. + reg = <0x0 0x0 0x20000>;
  532. + };
  533. +
  534. + nand@1,0 {
  535. + compatible = "rb,rb600-nand", "rb,nand";
  536. + reg = <
  537. + 0x1 0x0 0x1000 // IO
  538. + 0x4 0x0 0x1000>; // Sync
  539. +
  540. + gpios = <
  541. + &gpio1 3 0 // RNB
  542. + &gpio1 4 0 // NCE
  543. + &gpio1 5 0 // CLE
  544. + &gpio1 6 0>; // ALE
  545. +
  546. + partitions {
  547. + #address-cells = <1>;
  548. + #size-cells = <1>;
  549. +
  550. + kernel@0 {
  551. + label = "kernel";
  552. + reg = <0x00000000 0x00400000>;
  553. + };
  554. + rootfs@400000 {
  555. + label = "rootfs";
  556. + reg = <0x00400000 0x03c00000>;
  557. + };
  558. + };
  559. + };
  560. +
  561. + pata-upm@2,0 {
  562. + compatible = "rb,rb600-pata-upm", "rb,pata-upm";
  563. + reg = <0x2 0x0 0x200000>;
  564. + interrupts = <20 0x8>;
  565. + interrupt-parent = <&ipic>;
  566. +
  567. + rb,pata-upm-localbus-timings = <1500 1000 4500 1500 11000>;
  568. + };
  569. +
  570. + pata-upm@3,0 {
  571. + compatible = "rb,rb600-pata-upm", "rb,pata-upm";
  572. + reg = <0x3 0x0 0x200000>;
  573. + interrupts = <22 0x8>;
  574. + interrupt-parent = <&ipic>;
  575. +
  576. + rb,pata-upm-localbus-timings = <1500 1000 4500 1500 11000>;
  577. + };
  578. + };
  579. +
  580. + pci0: pci@e0008500 {
  581. + device_type = "pci";
  582. + compatible = "fsl,mpc8349-pci";
  583. + reg = <0xe0008500 0x100 0xe0008300 0x8>;
  584. + #address-cells = <3>;
  585. + #size-cells = <2>;
  586. + #interrupt-cells = <1>;
  587. + ranges = <0x2000000 0x0 0x80000000 0x80000000 0x0 0x20000000 0x1000000 0x0 0x0 0xd0000000 0x0 0x4000000>;
  588. + bus-range = <0x0 0x0>;
  589. + interrupt-map = <
  590. + 0x5800 0x0 0x0 0x1 &ipic 0x15 0x8
  591. + 0x6000 0x0 0x0 0x1 &ipic 0x30 0x8
  592. + 0x6000 0x0 0x0 0x2 &ipic 0x11 0x8
  593. + 0x6800 0x0 0x0 0x1 &ipic 0x11 0x8
  594. + 0x6800 0x0 0x0 0x2 &ipic 0x12 0x8
  595. + 0x7000 0x0 0x0 0x1 &ipic 0x12 0x8
  596. + 0x7000 0x0 0x0 0x2 &ipic 0x13 0x8
  597. + 0x7800 0x0 0x0 0x1 &ipic 0x13 0x8
  598. + 0x7800 0x0 0x0 0x2 &ipic 0x30 0x8
  599. + 0x8000 0x0 0x0 0x1 &ipic 0x30 0x8
  600. + 0x8000 0x0 0x0 0x2 &ipic 0x12 0x8
  601. + 0x8000 0x0 0x0 0x3 &ipic 0x11 0x8
  602. + 0x8000 0x0 0x0 0x4 &ipic 0x13 0x8
  603. + 0xa000 0x0 0x0 0x1 &ipic 0x30 0x8
  604. + 0xa000 0x0 0x0 0x2 &ipic 0x11 0x8
  605. + 0xa000 0x0 0x0 0x3 &ipic 0x12 0x8
  606. + 0xa000 0x0 0x0 0x4 &ipic 0x13 0x8
  607. + 0xa800 0x0 0x0 0x1 &ipic 0x11 0x8
  608. + 0xa800 0x0 0x0 0x2 &ipic 0x12 0x8
  609. + 0xa800 0x0 0x0 0x3 &ipic 0x13 0x8
  610. + 0xa800 0x0 0x0 0x4 &ipic 0x30 0x8>;
  611. + interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
  612. + interrupt-parent = <&ipic>;
  613. + };
  614. +
  615. + soc8343@e0000000 {
  616. + #address-cells = <1>;
  617. + #size-cells = <1>;
  618. + device_type = "soc";
  619. + compatible = "simple-bus";
  620. + ranges = <0x0 0xe0000000 0x100000>;
  621. + reg = <0xe0000000 0x200>;
  622. + bus-frequency = <0>; // Filled from the bootloader
  623. +
  624. + gtm1: timer@500 {
  625. + compatible = "fsl,mpc8349-gtm", "fsl,gtm";
  626. + reg = <0x500 0x40>;
  627. + interrupts = <90 0x8 78 0x8 84 0x8 72 0x8>;
  628. + interrupt-parent = <&ipic>;
  629. + clock-frequency = <0>; // Filled from the bootloader
  630. + };
  631. +
  632. + timer@600 {
  633. + compatible = "fsl,mpc8349-gtm", "fsl,gtm";
  634. + reg = <0x600 0x40>;
  635. + interrupts = <91 0x8 79 0x8 85 0x8 73 0x8>;
  636. + interrupt-parent = <&ipic>;
  637. + clock-frequency = <0>; // Filled from the bootloader
  638. + };
  639. +
  640. + gpio1: gpio-controller@c00 {
  641. + #gpio-cells = <2>;
  642. + compatible = "fsl,mpc8349-gpio";
  643. + reg = <0xc00 0x100>;
  644. + interrupts = <74 0x8>;
  645. + interrupt-parent = <&ipic>;
  646. + gpio-controller;
  647. + };
  648. +
  649. + gpio2: gpio-controller@d00 {
  650. + #gpio-cells = <2>;
  651. + compatible = "fsl,mpc8349-gpio";
  652. + reg = <0xd00 0x100>;
  653. + interrupts = <75 0x8>;
  654. + interrupt-parent = <&ipic>;
  655. + gpio-controller;
  656. + };
  657. +
  658. + dma@82a8 {
  659. + #address-cells = <1>;
  660. + #size-cells = <1>;
  661. + compatible = "fsl,mpc8349-dma", "fsl,elo-dma";
  662. + reg = <0x82a8 4>;
  663. + ranges = <0 0x8100 0x1a8>;
  664. + interrupt-parent = <&ipic>;
  665. + interrupts = <71 8>;
  666. + cell-index = <0>;
  667. + dma-channel@0 {
  668. + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
  669. + reg = <0 0x80>;
  670. + cell-index = <0>;
  671. + interrupt-parent = <&ipic>;
  672. + interrupts = <71 8>;
  673. + };
  674. + dma-channel@80 {
  675. + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
  676. + reg = <0x80 0x80>;
  677. + cell-index = <1>;
  678. + interrupt-parent = <&ipic>;
  679. + interrupts = <71 8>;
  680. + };
  681. + dma-channel@100 {
  682. + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
  683. + reg = <0x100 0x80>;
  684. + cell-index = <2>;
  685. + interrupt-parent = <&ipic>;
  686. + interrupts = <71 8>;
  687. + };
  688. + dma-channel@180 {
  689. + compatible = "fsl,mpc8349-dma-channel", "fsl,elo-dma-channel";
  690. + reg = <0x180 0x28>;
  691. + cell-index = <3>;
  692. + interrupt-parent = <&ipic>;
  693. + interrupts = <71 8>;
  694. + };
  695. + };
  696. +
  697. + enet0: ethernet@25000 {
  698. + #address-cells = <1>;
  699. + #size-cells = <1>;
  700. + cell-index = <0>;
  701. + phy-handle = <&phy0>;
  702. + tbi-handle = <&tbi0>;
  703. + interrupt-parent = <&ipic>;
  704. + interrupts = <0x23 0x8 0x24 0x8 0x25 0x8>;
  705. + local-mac-address = [00 00 00 00 00 00]; // Filled from the bootloader
  706. + reg = <0x25000 0x1000>;
  707. + ranges = <0x0 0x25000 0x1000>;
  708. + compatible = "gianfar";
  709. + model = "TSEC";
  710. + device_type = "network";
  711. +
  712. + mdio@520 {
  713. + #address-cells = <1>;
  714. + #size-cells = <0>;
  715. + compatible = "fsl,gianfar-tbi";
  716. + reg = <0x520 0x20>;
  717. +
  718. + tbi0: tbi-phy@11 {
  719. + reg = <0x11>;
  720. + device_type = "tbi-phy";
  721. + };
  722. + };
  723. + };
  724. +
  725. + enet1: ethernet@24000 {
  726. + #address-cells = <1>;
  727. + #size-cells = <1>;
  728. + cell-index = <1>;
  729. + phy-handle = <&phy1>;
  730. + tbi-handle = <&tbi1>;
  731. + interrupt-parent = <&ipic>;
  732. + interrupts = <0x20 0x8 0x21 0x8 0x22 0x8>;
  733. + local-mac-address = [00 00 00 00 00 00]; // Filled from the bootloader
  734. + reg = <0x24000 0x1000>;
  735. + ranges = <0x0 0x24000 0x1000>;
  736. + compatible = "gianfar";
  737. + model = "TSEC";
  738. + device_type = "network";
  739. +
  740. + mdio@520 {
  741. + #size-cells = <0x0>;
  742. + #address-cells = <0x1>;
  743. + reg = <0x520 0x20>;
  744. + compatible = "fsl,gianfar-mdio";
  745. +
  746. + phy0: ethernet-phy@0 {
  747. + device_type = "ethernet-phy";
  748. + reg = <0x0>;
  749. + };
  750. +
  751. + phy1: ethernet-phy@1 {
  752. + device_type = "ethernet-phy";
  753. + reg = <0x1>;
  754. + };
  755. +
  756. + tbi1: tbi-phy@11 {
  757. + reg = <0x11>;
  758. + device_type = "tbi-phy";
  759. + };
  760. + };
  761. + };
  762. +
  763. + ipic: pic@700 {
  764. + #address-cells = <0>;
  765. + #interrupt-cells = <2>;
  766. + device_type = "ipic";
  767. + reg = <0x700 0x100>;
  768. + interrupt-controller;
  769. + };
  770. +
  771. + serial@4500 {
  772. + device_type = "serial";
  773. + compatible = "ns16550";
  774. + reg = <0x4500 0x100>;
  775. + interrupts = <9 0x8>;
  776. + interrupt-parent = <&ipic>;
  777. + clock-frequency = <0>; // Filled from the bootloader
  778. + };
  779. +
  780. + wdt@200 {
  781. + device_type = "watchdog";
  782. + compatible = "mpc83xx_wdt";
  783. + reg = <0x200 0x100>;
  784. + };
  785. +
  786. + leds {
  787. + compatible = "gpio-leds";
  788. +
  789. + user-led {
  790. + gpios = <&gpio1 8 0>;
  791. + linux,default-trigger = "heartbeat";
  792. + };
  793. + };
  794. +
  795. + beeper {
  796. + compatible = "rb,rb600-gtm-beeper", "rb,gtm-beeper";
  797. + timer = <&gtm1 3>;
  798. + };
  799. + };
  800. +
  801. + fan-controller {
  802. + interrupt-parent = <&ipic>;
  803. + interrupts = <0x17 0x8>;
  804. + //sense = <&gpio 0x7>;
  805. + //fan_on = <&gpio 0x9>;
  806. + };
  807. +};
  808. diff -Nur linux-3.16.85.orig/arch/powerpc/boot/Makefile linux-3.16.85/arch/powerpc/boot/Makefile
  809. --- linux-3.16.85.orig/arch/powerpc/boot/Makefile 2020-06-11 20:06:00.000000000 +0200
  810. +++ linux-3.16.85/arch/powerpc/boot/Makefile 2026-04-25 10:22:52.765789806 +0200
  811. @@ -123,6 +123,8 @@
  812. src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
  813. src-plat-$(CONFIG_PPC_CELLEB) += pseries-head.S
  814. src-plat-$(CONFIG_PPC_CELL_QPACE) += pseries-head.S
  815. +src-plat-$(CONFIG_RB333) += rbppc.c
  816. +src-plat-$(CONFIG_RB600) += rbppc.c
  817. src-wlib := $(sort $(src-wlib-y))
  818. src-plat := $(sort $(src-plat-y))
  819. @@ -285,9 +287,11 @@
  820. # Board ports in arch/powerpc/platform/83xx/Kconfig
  821. image-$(CONFIG_MPC832x_MDS) += cuImage.mpc832x_mds
  822. image-$(CONFIG_MPC832x_RDB) += cuImage.mpc832x_rdb
  823. +image-$(CONFIG_RB333) += dtbImage.rb333
  824. image-$(CONFIG_MPC834x_ITX) += cuImage.mpc8349emitx \
  825. cuImage.mpc8349emitxgp
  826. image-$(CONFIG_MPC834x_MDS) += cuImage.mpc834x_mds
  827. +image-$(CONFIG_RB600) += dtbImage.rb600
  828. image-$(CONFIG_MPC836x_MDS) += cuImage.mpc836x_mds
  829. image-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot
  830. diff -Nur linux-3.16.85.orig/arch/powerpc/boot/rbppc.c linux-3.16.85/arch/powerpc/boot/rbppc.c
  831. --- linux-3.16.85.orig/arch/powerpc/boot/rbppc.c 1970-01-01 01:00:00.000000000 +0100
  832. +++ linux-3.16.85/arch/powerpc/boot/rbppc.c 2026-04-25 10:21:57.449901553 +0200
  833. @@ -0,0 +1,195 @@
  834. +/*
  835. + * The RouterBOARD platform -- for booting RouterBOARDs based on
  836. + * MPC83xx/MPC85xx SoC CPUs.
  837. + *
  838. + * Copyright (C) 2011 Noah Fontes <nfontes@invectorate.com>
  839. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  840. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  841. + *
  842. + * This program is free software; you can redistribute it and/or modify it
  843. + * under the terms of the GNU General Public License version 2 as published
  844. + * by the Free Software Foundation.
  845. + */
  846. +
  847. +#include "ops.h"
  848. +#include "types.h"
  849. +#include "io.h"
  850. +#include "stdio.h"
  851. +#include <libfdt.h>
  852. +
  853. +BSS_STACK(4096);
  854. +
  855. +const void *firmware_dtb_start;
  856. +u64 memsize64;
  857. +
  858. +struct rbppc_ethernet_map {
  859. + char *firmware_dtb_path;
  860. + char *alias;
  861. +};
  862. +
  863. +static const struct rbppc_ethernet_map ethernet_maps[] = {
  864. + /*
  865. + * RB333 (MPC832x/QE)
  866. + */
  867. + { .firmware_dtb_path = "/qe@e0100000/ucc@2200",
  868. + .alias = "ethernet0", },
  869. + { .firmware_dtb_path = "/qe@e0100000/ucc@3200",
  870. + .alias = "ethernet1", },
  871. + { .firmware_dtb_path = "/qe@e0100000/ucc@3000",
  872. + .alias = "ethernet2", },
  873. +
  874. + /*
  875. + * RB600 (MPC834x)
  876. + */
  877. + { .firmware_dtb_path = "/soc8343@e0000000/ethernet@24000",
  878. + .alias = "ethernet1", },
  879. + { .firmware_dtb_path = "/soc8343@e0000000/ethernet@25000",
  880. + .alias = "ethernet0", },
  881. +
  882. + { },
  883. +};
  884. +
  885. +static void rbppc_fixup_mac_addresses(void)
  886. +{
  887. + const struct rbppc_ethernet_map *maps = ethernet_maps;
  888. + struct rbppc_ethernet_map map;
  889. +
  890. + while((map = *maps++).firmware_dtb_path != NULL) {
  891. + const u32 *prop;
  892. + int node, size;
  893. +
  894. + node = fdt_path_offset(firmware_dtb_start,
  895. + map.firmware_dtb_path);
  896. + if (node < 0)
  897. + continue;
  898. +
  899. + prop = fdt_getprop(firmware_dtb_start, node, "mac-address",
  900. + &size);
  901. + if (size != 6 * sizeof(u8))
  902. + continue;
  903. +
  904. + dt_fixup_mac_address_by_alias(map.alias, (const u8 *)prop);
  905. + }
  906. +}
  907. +
  908. +static void rbppc_fixups(void)
  909. +{
  910. + u32 timebase_frequency, clock_frequency, bus_frequency;
  911. + void *dev;
  912. + int node, size;
  913. +
  914. + /*
  915. + * Assign memory address.
  916. + */
  917. + dt_fixup_memory(0, memsize64);
  918. +
  919. + /*
  920. + * Assign CPU clock frequency, time-base frequency, and bus frequency.
  921. + * The MPC834x documentation states that time-base frequency is equal
  922. + * to one-quarter bus frequency.
  923. + */
  924. + node = fdt_node_offset_by_prop_value(firmware_dtb_start, -1,
  925. + "device_type", "cpu",
  926. + sizeof("cpu"));
  927. + if (node < 0)
  928. + fatal("Cannot find CPU node\n\r");
  929. +
  930. + clock_frequency = *(const u32 *)fdt_getprop(firmware_dtb_start, node,
  931. + "clock-frequency", &size);
  932. + timebase_frequency = *(const u32 *)fdt_getprop(firmware_dtb_start, node,
  933. + "timebase-frequency",
  934. + &size);
  935. + bus_frequency = timebase_frequency * 4;
  936. +
  937. + dt_fixup_cpu_clocks(clock_frequency, timebase_frequency, bus_frequency);
  938. +
  939. + /*
  940. + * Assign bus frequency to SoC node, serial devices, and GTMs.
  941. + *
  942. + * Borrowed from cuboot-83xx.c.
  943. + */
  944. + dev = find_node_by_devtype(NULL, "soc");
  945. + if (dev) {
  946. + void *child;
  947. +
  948. + setprop_val(dev, "bus-frequency", bus_frequency);
  949. +
  950. + child = NULL;
  951. + while ((child = find_node_by_devtype(child, "serial"))) {
  952. + if (get_parent(child) != dev)
  953. + continue;
  954. +
  955. + setprop_val(child, "clock-frequency", bus_frequency);
  956. + }
  957. +
  958. + child = NULL;
  959. + while ((child = find_node_by_compatible(child, "fsl,gtm"))) {
  960. + if (get_parent(child) != dev)
  961. + continue;
  962. +
  963. + setprop_val(child, "clock-frequency", bus_frequency);
  964. + }
  965. + }
  966. +
  967. + /*
  968. + * Fix up NIC MAC addresses. RB333 and RB600 vary here.
  969. + */
  970. + rbppc_fixup_mac_addresses();
  971. +
  972. + /*
  973. + * Set up /chosen so it contains the boot parameters specified in the
  974. + * kernelparm segment of the image.
  975. + */
  976. + dev = finddevice("/chosen");
  977. + node = fdt_path_offset(firmware_dtb_start, "/chosen");
  978. + if (dev && node >= 0) {
  979. + const char *bootargs = fdt_getprop(firmware_dtb_start, node,
  980. + "bootargs", &size);
  981. + if (size > 0)
  982. + setprop_str(dev, "bootargs", bootargs);
  983. + }
  984. +}
  985. +
  986. +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  987. + unsigned long r6, unsigned long r7)
  988. +{
  989. + const u32 *reg;
  990. + int node, size;
  991. +
  992. + /*
  993. + * Make sure we're going to start with a device tree that's not insane.
  994. + */
  995. + if (fdt_check_header(_dtb_start) != 0)
  996. + fatal("Invalid device tree blob\n\r");
  997. +
  998. + firmware_dtb_start = (const void *)r3;
  999. +
  1000. + /*
  1001. + * Allocate memory based on the size that the bootloader device tree
  1002. + * reports.
  1003. + */
  1004. + node = fdt_node_offset_by_prop_value(firmware_dtb_start, -1,
  1005. + "device_type", "memory",
  1006. + sizeof("memory"));
  1007. + if (node < 0)
  1008. + fatal("Cannot find memory node\n\r");
  1009. +
  1010. + reg = fdt_getprop(firmware_dtb_start, node, "reg", &size);
  1011. + if (size != 2 * sizeof(u32))
  1012. + fatal("Cannot get memory range\n\r");
  1013. +
  1014. + memsize64 = reg[1];
  1015. + simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
  1016. +
  1017. + /*
  1018. + * Use our device-tree for actual initialization, like in simpleboot.
  1019. + */
  1020. + fdt_init(_dtb_start);
  1021. +
  1022. + /*
  1023. + * And finish everything up; we'll fixup our blob with correct values
  1024. + * for clocks and MAC address shortly.
  1025. + */
  1026. + serial_console_init();
  1027. + platform_ops.fixups = rbppc_fixups;
  1028. +}
  1029. diff -Nur linux-3.16.85.orig/arch/powerpc/boot/wrapper linux-3.16.85/arch/powerpc/boot/wrapper
  1030. --- linux-3.16.85.orig/arch/powerpc/boot/wrapper 2020-06-11 20:06:00.000000000 +0200
  1031. +++ linux-3.16.85/arch/powerpc/boot/wrapper 2026-04-25 10:21:57.449901553 +0200
  1032. @@ -261,6 +261,11 @@
  1033. platformo="$object/fixed-head.o $object/$platform.o"
  1034. binary=y
  1035. ;;
  1036. +rb600|rb333)
  1037. + platformo="$object/fixed-head.o $object/rbppc.o"
  1038. + link_address='0x498000'
  1039. + binary=y
  1040. + ;;
  1041. adder875-redboot)
  1042. platformo="$object/fixed-head.o $object/redboot-8xx.o"
  1043. binary=y
  1044. diff -Nur linux-3.16.85.orig/arch/powerpc/Kconfig linux-3.16.85/arch/powerpc/Kconfig
  1045. --- linux-3.16.85.orig/arch/powerpc/Kconfig 2020-06-11 20:06:00.000000000 +0200
  1046. +++ linux-3.16.85/arch/powerpc/Kconfig 2026-04-25 10:21:57.449901553 +0200
  1047. @@ -765,6 +765,9 @@
  1048. help
  1049. Freescale General-purpose Timers support
  1050. +config RBPPC_PCI
  1051. + bool
  1052. +
  1053. # Yes MCA RS/6000s exist but Linux-PPC does not currently support any
  1054. config MCA
  1055. bool
  1056. diff -Nur linux-3.16.85.orig/arch/powerpc/platforms/83xx/Kconfig linux-3.16.85/arch/powerpc/platforms/83xx/Kconfig
  1057. --- linux-3.16.85.orig/arch/powerpc/platforms/83xx/Kconfig 2020-06-11 20:06:00.000000000 +0200
  1058. +++ linux-3.16.85/arch/powerpc/platforms/83xx/Kconfig 2026-04-25 10:21:57.449901553 +0200
  1059. @@ -38,6 +38,30 @@
  1060. help
  1061. This option enables support for the MPC8323 RDB board.
  1062. +config RB333
  1063. + bool "MikroTik RouterBOARD 333 series"
  1064. + select RBPPC_PCI if PCI
  1065. + select PPC_MPC832x
  1066. + select QUICC_ENGINE
  1067. + select QE_GPIO
  1068. + select FSL_GTM
  1069. + select FSL_LBC
  1070. + help
  1071. + This option enables support for MikroTik RouterBOARD 333 series
  1072. + boards.
  1073. +
  1074. +config RB600
  1075. + bool "MikroTik RouterBOARD 600 series"
  1076. + select RBPPC_PCI if PCI
  1077. + select PPC_MPC834x
  1078. + select ARCH_REQUIRE_GPIOLIB
  1079. + select GPIO_MPC8XXX
  1080. + select FSL_GTM
  1081. + select FSL_LBC
  1082. + help
  1083. + This option enables support for MikroTik RouterBOARD 600 series
  1084. + boards.
  1085. +
  1086. config MPC834x_MDS
  1087. bool "Freescale MPC834x MDS"
  1088. select DEFAULT_UIMAGE
  1089. diff -Nur linux-3.16.85.orig/arch/powerpc/platforms/83xx/Makefile linux-3.16.85/arch/powerpc/platforms/83xx/Makefile
  1090. --- linux-3.16.85.orig/arch/powerpc/platforms/83xx/Makefile 2020-06-11 20:06:00.000000000 +0200
  1091. +++ linux-3.16.85/arch/powerpc/platforms/83xx/Makefile 2026-04-25 10:21:57.449901553 +0200
  1092. @@ -7,8 +7,10 @@
  1093. obj-$(CONFIG_MPC830x_RDB) += mpc830x_rdb.o
  1094. obj-$(CONFIG_MPC831x_RDB) += mpc831x_rdb.o
  1095. obj-$(CONFIG_MPC832x_RDB) += mpc832x_rdb.o
  1096. +obj-$(CONFIG_RB333) += rb333.o
  1097. obj-$(CONFIG_MPC834x_MDS) += mpc834x_mds.o
  1098. obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o
  1099. +obj-$(CONFIG_RB600) += rb600.o
  1100. obj-$(CONFIG_MPC836x_MDS) += mpc836x_mds.o
  1101. obj-$(CONFIG_MPC836x_RDK) += mpc836x_rdk.o
  1102. obj-$(CONFIG_MPC832x_MDS) += mpc832x_mds.o
  1103. diff -Nur linux-3.16.85.orig/arch/powerpc/platforms/83xx/rb333.c linux-3.16.85/arch/powerpc/platforms/83xx/rb333.c
  1104. --- linux-3.16.85.orig/arch/powerpc/platforms/83xx/rb333.c 1970-01-01 01:00:00.000000000 +0100
  1105. +++ linux-3.16.85/arch/powerpc/platforms/83xx/rb333.c 2026-04-25 10:21:57.449901553 +0200
  1106. @@ -0,0 +1,139 @@
  1107. +/*
  1108. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  1109. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  1110. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  1111. + * Copyright (C) Mikrotik 2007
  1112. + *
  1113. + * This program is free software; you can redistribute it and/or modify it
  1114. + * under the terms of the GNU General Public License as published by the
  1115. + * Free Software Foundation; either version 2 of the License, or (at your
  1116. + * option) any later version.
  1117. + */
  1118. +
  1119. +#include <linux/stddef.h>
  1120. +#include <linux/kernel.h>
  1121. +#include <linux/delay.h>
  1122. +#include <linux/root_dev.h>
  1123. +#include <linux/initrd.h>
  1124. +#include <linux/interrupt.h>
  1125. +#include <linux/of_platform.h>
  1126. +#include <linux/of_device.h>
  1127. +
  1128. +#include <asm/time.h>
  1129. +#include <asm/ipic.h>
  1130. +#include <asm/udbg.h>
  1131. +#include <asm/pci-bridge.h>
  1132. +#include <asm/io.h>
  1133. +#include <asm/qe.h>
  1134. +#include <asm/qe_ic.h>
  1135. +
  1136. +#include <sysdev/fsl_soc.h>
  1137. +#include <sysdev/fsl_pci.h>
  1138. +
  1139. +#include "mpc83xx.h"
  1140. +
  1141. +#define CPDIR1A_OFFS 0x1408
  1142. +#define CPDIR1A_DIR4_MASK 0x00c00000
  1143. +#define CPDIR1A_DIR4_OUT 0x00400000
  1144. +#define CPDATA_OFFS 0x1404
  1145. +#define CPDATA_D4_MASK 0x08000000
  1146. +
  1147. +static void __init rb333_setup_arch(void)
  1148. +{
  1149. +#if defined (CONFIG_PCI) || defined (CONFIG_QUICC_ENGINE)
  1150. + struct device_node *np;
  1151. +#endif
  1152. +
  1153. +#ifdef CONFIG_PCI
  1154. + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  1155. + mpc83xx_add_bridge(np);
  1156. +#endif
  1157. +
  1158. +#ifdef CONFIG_QUICC_ENGINE
  1159. + qe_reset();
  1160. +
  1161. + if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  1162. + par_io_init(np);
  1163. + of_node_put(np);
  1164. +
  1165. + for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  1166. + par_io_of_config(np);
  1167. + }
  1168. +#endif
  1169. +}
  1170. +
  1171. +static void __init rb333_init_IRQ(void)
  1172. +{
  1173. + struct device_node *np;
  1174. +
  1175. + np = of_find_node_by_type(NULL, "ipic");
  1176. + if (!np)
  1177. + return;
  1178. +
  1179. + ipic_init(np, 0);
  1180. + ipic_set_default_priority();
  1181. +
  1182. + of_node_put(np);
  1183. +
  1184. +#ifdef CONFIG_QUICC_ENGINE
  1185. + np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  1186. + if (!np)
  1187. + return;
  1188. +
  1189. + qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  1190. + of_node_put(np);
  1191. +#endif
  1192. +}
  1193. +
  1194. +static int __init rb333_probe(void)
  1195. +{
  1196. + unsigned long root = of_get_flat_dt_root();
  1197. +
  1198. + return of_flat_dt_is_compatible(root, "RB333");
  1199. +}
  1200. +
  1201. +static void rb333_restart(char *cmd)
  1202. +{
  1203. + void __iomem *cfg;
  1204. +
  1205. + cfg = ioremap(get_immrbase(), 0x2000);
  1206. + if (cfg) {
  1207. + local_irq_disable();
  1208. +
  1209. + /*
  1210. + * GPIO on QE port A (at 0x1400): Put the fifth pin into output
  1211. + * mode and zero it out.
  1212. + */
  1213. + clrsetbits_be32(cfg + CPDIR1A_OFFS, CPDIR1A_DIR4_MASK,
  1214. + CPDIR1A_DIR4_OUT);
  1215. + clrbits32(cfg + CPDATA_OFFS, CPDATA_D4_MASK);
  1216. +
  1217. + for (;;) ;
  1218. + }
  1219. + else
  1220. + mpc83xx_restart(cmd);
  1221. +}
  1222. +
  1223. +static struct of_device_id rb333_ids[] = {
  1224. + { .compatible = "fsl,pq2pro-localbus", },
  1225. + { .compatible = "simple-bus", },
  1226. + { .compatible = "fsl,qe", },
  1227. + { },
  1228. +};
  1229. +
  1230. +static int __init rb333_declare_of_platform_devices(void)
  1231. +{
  1232. + return of_platform_bus_probe(NULL, rb333_ids, NULL);
  1233. +}
  1234. +machine_device_initcall(rb333, rb333_declare_of_platform_devices);
  1235. +
  1236. +define_machine(rb333) {
  1237. + .name = "MikroTik RouterBOARD 333 series",
  1238. + .probe = rb333_probe,
  1239. + .setup_arch = rb333_setup_arch,
  1240. + .init_IRQ = rb333_init_IRQ,
  1241. + .get_irq = ipic_get_irq,
  1242. + .restart = rb333_restart,
  1243. + .time_init = mpc83xx_time_init,
  1244. + .calibrate_decr = generic_calibrate_decr,
  1245. +};
  1246. diff -Nur linux-3.16.85.orig/arch/powerpc/platforms/83xx/rb600.c linux-3.16.85/arch/powerpc/platforms/83xx/rb600.c
  1247. --- linux-3.16.85.orig/arch/powerpc/platforms/83xx/rb600.c 1970-01-01 01:00:00.000000000 +0100
  1248. +++ linux-3.16.85/arch/powerpc/platforms/83xx/rb600.c 2026-04-25 10:21:57.449901553 +0200
  1249. @@ -0,0 +1,133 @@
  1250. +/*
  1251. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  1252. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  1253. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  1254. + * Copyright (C) Mikrotik 2007
  1255. + *
  1256. + * This program is free software; you can redistribute it and/or modify it
  1257. + * under the terms of the GNU General Public License as published by the
  1258. + * Free Software Foundation; either version 2 of the License, or (at your
  1259. + * option) any later version.
  1260. + */
  1261. +
  1262. +#include <linux/stddef.h>
  1263. +#include <linux/kernel.h>
  1264. +#include <linux/delay.h>
  1265. +#include <linux/root_dev.h>
  1266. +#include <linux/initrd.h>
  1267. +#include <linux/interrupt.h>
  1268. +#include <linux/of_platform.h>
  1269. +#include <linux/of_device.h>
  1270. +
  1271. +#include <asm/time.h>
  1272. +#include <asm/ipic.h>
  1273. +#include <asm/udbg.h>
  1274. +#include <asm/pci-bridge.h>
  1275. +#include <asm/io.h>
  1276. +
  1277. +#include <sysdev/fsl_soc.h>
  1278. +#include <sysdev/fsl_pci.h>
  1279. +
  1280. +#include "mpc83xx.h"
  1281. +
  1282. +#define SICRL_GPIO1C_MASK 0x00800000
  1283. +#define SICRL_GPIO1L_MASK 0x00003000
  1284. +#define SICRL_GPIO1L_GTM1_TOUT4 0x00001000
  1285. +
  1286. +#define GP1DIR_OFFS 0xc00
  1287. +#define GP1DIR_MASK(pin) (1 << (31 - (pin)))
  1288. +#define GP1DAT_OFFS 0xc08
  1289. +#define GP1DAT_MASK(pin) (1 << (31 - (pin)))
  1290. +
  1291. +static void __init rb600_setup_arch(void) {
  1292. + void __iomem *cfg;
  1293. +#ifdef CONFIG_PCI
  1294. + struct device_node *np;
  1295. +#endif
  1296. +
  1297. + /*
  1298. + * We do have to configure GTM1_TOUT4 to be used instead of GPIO1[11] if
  1299. + * we want the speaker to work.
  1300. + */
  1301. + cfg = ioremap(get_immrbase(), 0x1000);
  1302. + if (cfg) {
  1303. + clrsetbits_be32(cfg + MPC83XX_SICRL_OFFS, SICRL_GPIO1L_MASK,
  1304. + SICRL_GPIO1L_GTM1_TOUT4);
  1305. + iounmap(cfg);
  1306. + }
  1307. +
  1308. +#ifdef CONFIG_PCI
  1309. + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  1310. + mpc83xx_add_bridge(np);
  1311. +#endif
  1312. +}
  1313. +
  1314. +static void __init rb600_init_IRQ(void)
  1315. +{
  1316. + struct device_node *np;
  1317. +
  1318. + np = of_find_node_by_type(NULL, "ipic");
  1319. + if (!np)
  1320. + return;
  1321. +
  1322. + ipic_init(np, 0);
  1323. + ipic_set_default_priority();
  1324. +
  1325. + of_node_put(np);
  1326. +}
  1327. +
  1328. +static int __init rb600_probe(void)
  1329. +{
  1330. + unsigned long root = of_get_flat_dt_root();
  1331. +
  1332. + return of_flat_dt_is_compatible(root, "RB600");
  1333. +}
  1334. +
  1335. +static void rb600_restart(char *cmd) {
  1336. + void __iomem *cfg;
  1337. +
  1338. + cfg = ioremap(get_immrbase(), 0x1000);
  1339. + if (cfg) {
  1340. + local_irq_disable();
  1341. +
  1342. + /*
  1343. + * Make sure GPIO1[2] is active.
  1344. + */
  1345. + clrbits32(cfg + MPC83XX_SICRL_OFFS, SICRL_GPIO1C_MASK);
  1346. +
  1347. + /*
  1348. + * Grab GPIO1 (at 0xc00), put the third pin into output mode,
  1349. + * and zero it out.
  1350. + */
  1351. + clrsetbits_be32(cfg + GP1DIR_OFFS, GP1DIR_MASK(2), GP1DIR_MASK(2));
  1352. + clrbits32(cfg + GP1DAT_OFFS, GP1DAT_MASK(2));
  1353. +
  1354. + for (;;) ;
  1355. + }
  1356. + else
  1357. + mpc83xx_restart(cmd);
  1358. +}
  1359. +
  1360. +static struct of_device_id rb600_ids[] = {
  1361. + { .compatible = "fsl,pq2pro-localbus", },
  1362. + { .compatible = "simple-bus", },
  1363. + { .compatible = "gianfar", },
  1364. + { },
  1365. +};
  1366. +
  1367. +static int __init rb600_declare_of_platform_devices(void)
  1368. +{
  1369. + return of_platform_bus_probe(NULL, rb600_ids, NULL);
  1370. +}
  1371. +machine_device_initcall(rb600, rb600_declare_of_platform_devices);
  1372. +
  1373. +define_machine(rb600) {
  1374. + .name = "MikroTik RouterBOARD 600 series",
  1375. + .probe = rb600_probe,
  1376. + .setup_arch = rb600_setup_arch,
  1377. + .init_IRQ = rb600_init_IRQ,
  1378. + .get_irq = ipic_get_irq,
  1379. + .restart = rb600_restart,
  1380. + .time_init = mpc83xx_time_init,
  1381. + .calibrate_decr = generic_calibrate_decr,
  1382. +};
  1383. diff -Nur linux-3.16.85.orig/arch/powerpc/sysdev/Makefile linux-3.16.85/arch/powerpc/sysdev/Makefile
  1384. --- linux-3.16.85.orig/arch/powerpc/sysdev/Makefile 2020-06-11 20:06:00.000000000 +0200
  1385. +++ linux-3.16.85/arch/powerpc/sysdev/Makefile 2026-04-25 10:21:57.449901553 +0200
  1386. @@ -22,6 +22,7 @@
  1387. obj-$(CONFIG_FSL_PMC) += fsl_pmc.o
  1388. obj-$(CONFIG_FSL_LBC) += fsl_lbc.o
  1389. obj-$(CONFIG_FSL_GTM) += fsl_gtm.o
  1390. +obj-$(CONFIG_RBPPC_PCI) += rbppc_pci.o
  1391. obj-$(CONFIG_FSL_85XX_CACHE_SRAM) += fsl_85xx_l2ctlr.o fsl_85xx_cache_sram.o
  1392. obj-$(CONFIG_SIMPLE_GPIO) += simple_gpio.o
  1393. obj-$(CONFIG_FSL_RIO) += fsl_rio.o fsl_rmu.o
  1394. diff -Nur linux-3.16.85.orig/arch/powerpc/sysdev/rbppc_pci.c linux-3.16.85/arch/powerpc/sysdev/rbppc_pci.c
  1395. --- linux-3.16.85.orig/arch/powerpc/sysdev/rbppc_pci.c 1970-01-01 01:00:00.000000000 +0100
  1396. +++ linux-3.16.85/arch/powerpc/sysdev/rbppc_pci.c 2026-04-25 10:21:57.449901553 +0200
  1397. @@ -0,0 +1,59 @@
  1398. +/*
  1399. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  1400. + * Copyright (C) Mikrotik 2007
  1401. + *
  1402. + * This program is free software; you can redistribute it and/or modify it
  1403. + * under the terms of the GNU General Public License as published by the
  1404. + * Free Software Foundation; either version 2 of the License, or (at your
  1405. + * option) any later version.
  1406. + */
  1407. +
  1408. +#include <linux/kernel.h>
  1409. +#include <linux/pci.h>
  1410. +
  1411. +static void fixup_pci(struct pci_dev *dev)
  1412. +{
  1413. + if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
  1414. + /*
  1415. + * Let the kernel itself set right memory windows.
  1416. + */
  1417. + pci_write_config_word(dev, PCI_MEMORY_BASE, 0);
  1418. + pci_write_config_word(dev, PCI_MEMORY_LIMIT, 0);
  1419. + pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0);
  1420. + pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
  1421. + pci_write_config_byte(dev, PCI_IO_BASE, 0);
  1422. + pci_write_config_byte(dev, PCI_IO_LIMIT, 4 << 4);
  1423. +
  1424. + pci_write_config_byte(dev, PCI_COMMAND, PCI_COMMAND_MASTER |
  1425. + PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
  1426. + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  1427. + } else if (dev->vendor == 0x1957 &&
  1428. + (dev->device == 0x32 || dev->device == 0x33)) {
  1429. + u16 val;
  1430. + pci_read_config_word(dev, 0x44, &val);
  1431. + pci_write_config_word(dev, 0x44, val | (1 << 10));
  1432. + pci_write_config_word(dev, PCI_LATENCY_TIMER, 0x00);
  1433. + } else
  1434. + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
  1435. +}
  1436. +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_pci)
  1437. +
  1438. +static void fixup_secondary_bridge(struct pci_dev *dev)
  1439. +{
  1440. + pci_write_config_byte(dev, PCI_COMMAND, PCI_COMMAND_MASTER |
  1441. + PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
  1442. +
  1443. + /*
  1444. + * Disable prefetched memory range.
  1445. + */
  1446. + pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
  1447. + pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0x10);
  1448. +
  1449. + pci_write_config_word(dev, PCI_BASE_ADDRESS_0, 0);
  1450. + pci_write_config_word(dev, PCI_BASE_ADDRESS_1, 0);
  1451. +
  1452. + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  1453. +
  1454. + pci_write_config_byte(dev, 0xc0, 0x01);
  1455. +}
  1456. +DECLARE_PCI_FIXUP_HEADER(0x3388, 0x0021, fixup_secondary_bridge)
  1457. diff -Nur linux-3.16.85.orig/drivers/ata/Kconfig linux-3.16.85/drivers/ata/Kconfig
  1458. --- linux-3.16.85.orig/drivers/ata/Kconfig 2020-06-11 20:06:00.000000000 +0200
  1459. +++ linux-3.16.85/drivers/ata/Kconfig 2026-04-25 10:21:57.453901547 +0200
  1460. @@ -964,6 +964,14 @@
  1461. Support for the Winbond W83759A controller on Vesa Local Bus
  1462. systems.
  1463. +config PATA_RBPPC_UPM
  1464. + tristate "MikroTik RouterBOARD PATA support for Freescale MPC83xx/MPC85xx-based platforms"
  1465. + depends on FSL_LBC && PPC_OF
  1466. + help
  1467. + This option enables support for PATA devices on MikroTik RouterBOARD
  1468. + Freescale MPC83xx/MPC85xx-based platforms, such as RB333, RB600, and
  1469. + RB800.
  1470. +
  1471. comment "Generic fallback / legacy drivers"
  1472. config PATA_ACPI
  1473. diff -Nur linux-3.16.85.orig/drivers/ata/Makefile linux-3.16.85/drivers/ata/Makefile
  1474. --- linux-3.16.85.orig/drivers/ata/Makefile 2020-06-11 20:06:00.000000000 +0200
  1475. +++ linux-3.16.85/drivers/ata/Makefile 2026-04-25 10:21:57.453901547 +0200
  1476. @@ -98,6 +98,7 @@
  1477. obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
  1478. obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o
  1479. obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o
  1480. +obj-$(CONFIG_PATA_RBPPC_UPM) += pata_rbppc_upm.o
  1481. obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o
  1482. obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o
  1483. diff -Nur linux-3.16.85.orig/drivers/ata/pata_rbppc_upm.c linux-3.16.85/drivers/ata/pata_rbppc_upm.c
  1484. --- linux-3.16.85.orig/drivers/ata/pata_rbppc_upm.c 1970-01-01 01:00:00.000000000 +0100
  1485. +++ linux-3.16.85/drivers/ata/pata_rbppc_upm.c 2026-04-25 10:21:57.453901547 +0200
  1486. @@ -0,0 +1,866 @@
  1487. +/*
  1488. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  1489. + * Copyright (C) Mikrotik 2007
  1490. + *
  1491. + * This program is free software; you can redistribute it and/or modify it
  1492. + * under the terms of the GNU General Public License as published by the
  1493. + * Free Software Foundation; either version 2 of the License, or (at your
  1494. + * option) any later version.
  1495. + */
  1496. +
  1497. +#include <linux/kernel.h>
  1498. +#include <linux/slab.h>
  1499. +#include <linux/module.h>
  1500. +#include <linux/libata.h>
  1501. +#include <linux/of_platform.h>
  1502. +#include <linux/of_address.h>
  1503. +#include <linux/of_irq.h>
  1504. +
  1505. +#include <asm/fsl_lbc.h>
  1506. +
  1507. +#define DRV_NAME "pata_rbppc_upm"
  1508. +#define DRV_VERSION "0.1.0"
  1509. +
  1510. +/*
  1511. + * Constants related to M[ABC]MR UPM operation.
  1512. + *
  1513. + * These might belong in fsl_upm.h.
  1514. + */
  1515. +#define MxMR_OP 0x30000000 /* Operation mask */
  1516. +#define MxMR_RLF_SHIFT 14 /* Read loop field */
  1517. +#define MxMR_WLF_SHIFT 10 /* Write loop field */
  1518. +
  1519. +/*
  1520. + * UPM programming constants.
  1521. + *
  1522. + * Some of these also probably belong in fsl_upm.h (aliased to more suitable
  1523. + * names, like those found in the MPC83xx documentation).
  1524. + */
  1525. +#define INST_N_BASE 0x00f00000 /* G0L, LGPL0 negated, first half
  1526. + phase */
  1527. +#define INST_N_CS 0xf0000000 /* Chip-select timing (LCSn) mask */
  1528. +#define INST_N_CS_H1 0xc0000000 /* CST1/2, first half phase */
  1529. +#define INST_N_CS_H2 0x30000000 /* CST3/4, second half phase */
  1530. +#define INST_N_WE 0x0f000000 /* Byte-select timing (LBSn) mask */
  1531. +#define INST_N_WE_H1 0x0c000000 /* BST1/2, first half phase */
  1532. +#define INST_N_WE_H2 0x03000000 /* BST3/4, second half phase */
  1533. +#define INST_N_OE 0x00030000 /* G2 (LGPL2) mask */
  1534. +#define INST_N_OE_H1 0x00020000 /* G2T1, first half phase */
  1535. +#define INST_N_OE_H2 0x00010000 /* G2T3, second half phase */
  1536. +#define INST_WAEN 0x00001000 /* Enable LUPWAIT */
  1537. +#define INST_REDO_2 0x00000100 /* REDO 2x */
  1538. +#define INST_REDO_3 0x00000200 /* REDO 3x */
  1539. +#define INST_REDO_4 0x00000300 /* REDO 4x */
  1540. +#define INST_LOOP 0x00000080 /* First time LOOP is set starts,
  1541. + next ends */
  1542. +#define INST_NA 0x00000008 /* Next burst address */
  1543. +#define INST_UTA 0x00000004 /* Transfer acknowledge */
  1544. +#define INST_LAST 0x00000001 /* End of pattern */
  1545. +
  1546. +#define INST_READ_BASE (INST_N_BASE | INST_N_WE)
  1547. +#define INST_WRITE_BASE (INST_N_BASE | INST_N_OE)
  1548. +#define INST_EMPTY (INST_N_BASE | INST_N_CS | INST_N_OE | INST_N_WE | INST_LAST)
  1549. +
  1550. +#define X_INST_TABLE_END 0
  1551. +#define X_INST_ANOTHER_TIMING 1
  1552. +
  1553. +#define OA_CPUIN_MIN (1 << 0)
  1554. +#define OA_CPUOUT_MAX (1 << 1)
  1555. +#define OD_CPUOUT_MIN (1 << 2)
  1556. +#define OA_CPUOUT_DELTA (OD_CPUOUT_MIN | OA_CPUOUT_MAX)
  1557. +#define OA_EXTDEL_MAX (1 << 3)
  1558. +#define OD_EXTDEL_MIN (1 << 4)
  1559. +#define OA_EXTDEL_DELTA (OD_EXTDEL_MIN | OA_EXTDEL_MAX)
  1560. +#define O_MIN_CYCLE_TIME (1 << 5)
  1561. +#define O_MINUS_PREV (1 << 6)
  1562. +#define O_HALF_CYCLE (1 << 7)
  1563. +
  1564. +#define REDOS(mult) (INST_REDO_2 * ((mult) - 1))
  1565. +#define REDO_MAX_MULT 4
  1566. +
  1567. +#define LOOPS 4
  1568. +
  1569. +/*
  1570. + * This is extremely convoluted code that does some sort of alignment with what
  1571. + * appears to be arbitrary memory offsets. It used to be part of rb_iomap.c, but
  1572. + * it was only used for ATA operations so it's been migrated here instead (where
  1573. + * it might actually make some small amount of sense).
  1574. + */
  1575. +#define REG_OFFSET(base, reg) ((base) + (((reg) << 16) | ((((reg) ^ 8) & 8) << 17)))
  1576. +
  1577. +/*
  1578. + * Since multiple ATA hosts use the same UPM, we need to make sure we only
  1579. + * program a UPM to operate in a higher PIO mode when all hosts registered on
  1580. + * that UPM are ready to use that mode. Otherwise, we have to pick the lowest
  1581. + * mode that all of them support and generate timings from there.
  1582. + */
  1583. +struct pata_rbppc_upm_pio_status {
  1584. + int configured_mode;
  1585. + int actual_mode;
  1586. + struct pata_rbppc_upm_prv *prv;
  1587. +
  1588. + struct pata_rbppc_upm_pio_status *next;
  1589. +};
  1590. +
  1591. +static DEFINE_MUTEX(pio_status_mutex);
  1592. +
  1593. +static struct pata_rbppc_upm_pio_status *pio_statuses = NULL;
  1594. +
  1595. +/*
  1596. + * These represent custom additional board-specific timings specified in the
  1597. + * device tree.
  1598. + */
  1599. +struct pata_rbppc_upm_localbus_timing {
  1600. + u32 cpuin_min;
  1601. + u32 cpuout_min;
  1602. + u32 cpuout_max;
  1603. + u32 extdel_min;
  1604. + u32 extdel_max;
  1605. +};
  1606. +
  1607. +struct pata_rbppc_upm_prv {
  1608. + struct fsl_upm upm;
  1609. + u32 timing;
  1610. + struct pata_rbppc_upm_localbus_timing localbus_timings;
  1611. + int irq;
  1612. + struct pata_rbppc_upm_pio_status pio_status;
  1613. +
  1614. + struct fsl_lbc_ctrl *ctrl;
  1615. + struct ata_host *host;
  1616. +
  1617. + struct device *dev;
  1618. +};
  1619. +
  1620. +#define UPM_P_RSS 0x00 /* Read single-beat */
  1621. +#define UPM_P_RBS 0x08 /* Read burst */
  1622. +#define UPM_P_WSS 0x18 /* Write single-beat */
  1623. +#define UPM_P_WBS 0x20 /* Write burst */
  1624. +#define UPM_P_RTS 0x30 /* Refresh timer */
  1625. +#define UPM_P_EXS 0x3c /* Exception condition */
  1626. +#define UPM_P_SIZE 0x40 /* UPM program RAM is 64 32-bit words */
  1627. +
  1628. +struct pata_rbppc_upm_program {
  1629. + u32 program[UPM_P_SIZE];
  1630. + void __iomem *io_addr;
  1631. +};
  1632. +
  1633. +struct pata_rbppc_upm_cfg {
  1634. + unsigned value;
  1635. + unsigned timings[7]; /* PIO modes 0 - 6, in nanoseconds */
  1636. + unsigned clk_minus;
  1637. + unsigned group_size;
  1638. + unsigned options;
  1639. +};
  1640. +
  1641. +static const struct pata_rbppc_upm_cfg pata_rbppc_upm_read_table[] = {
  1642. + { INST_READ_BASE | INST_N_OE,
  1643. + /* t1 - ADDR setup time */
  1644. + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1645. + OA_EXTDEL_MAX) },
  1646. + { INST_READ_BASE | INST_N_OE_H1,
  1647. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1648. + { INST_READ_BASE,
  1649. + /* t2 - OE0 time */
  1650. + { 290, 290, 290, 80, 70, 65, 55 }, 0, 2, (OA_CPUOUT_MAX |
  1651. + OA_CPUIN_MIN) },
  1652. + { INST_READ_BASE | INST_WAEN,
  1653. + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
  1654. + { INST_READ_BASE | INST_UTA,
  1655. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1656. + { INST_READ_BASE | INST_N_OE,
  1657. + /* t9 - ADDR hold time */
  1658. + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1659. + OD_EXTDEL_MIN) },
  1660. + { INST_READ_BASE | INST_N_OE | INST_N_CS_H2,
  1661. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1662. + { INST_READ_BASE | INST_N_OE | INST_N_CS,
  1663. + /* t6Z -IORD data tristate */
  1664. + { 30, 30, 30, 30, 30, 20, 20 }, 1, 1, O_MINUS_PREV },
  1665. + { X_INST_ANOTHER_TIMING,
  1666. + /* t2i -IORD recovery time */
  1667. + { 0, 0, 0, 70, 25, 25, 20 }, 2, 0, 0 },
  1668. + { X_INST_ANOTHER_TIMING,
  1669. + /* CS 0 -> 1 MAX */
  1670. + { 0, 0, 0, 0, 0, 0, 0 }, 1, 0, (OA_CPUOUT_DELTA |
  1671. + OA_EXTDEL_MAX) },
  1672. + { INST_READ_BASE | INST_N_OE | INST_N_CS | INST_LAST,
  1673. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1674. + { X_INST_TABLE_END,
  1675. + /* min total cycle time - includes turnaround and ALE cycle */
  1676. + { 600, 383, 240, 180, 120, 100, 80 }, 2, 0, O_MIN_CYCLE_TIME },
  1677. +};
  1678. +
  1679. +static const struct pata_rbppc_upm_cfg pata_rbppc_upm_write_table[] = {
  1680. + { INST_WRITE_BASE | INST_N_WE,
  1681. + /* t1 - ADDR setup time */
  1682. + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1683. + OA_EXTDEL_MAX) },
  1684. + { INST_WRITE_BASE | INST_N_WE_H1,
  1685. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1686. + { INST_WRITE_BASE,
  1687. + /* t2 - WE0 time */
  1688. + { 290, 290, 290, 80, 70, 65, 55 }, 0, 1, OA_CPUOUT_DELTA },
  1689. + { INST_WRITE_BASE | INST_WAEN,
  1690. + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
  1691. + { INST_WRITE_BASE | INST_N_WE,
  1692. + /* t9 - ADDR hold time */
  1693. + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1694. + OD_EXTDEL_MIN) },
  1695. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS_H2,
  1696. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1697. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS,
  1698. + /* t4 - DATA hold time */
  1699. + { 30, 20, 15, 10, 10, 10, 10 }, 0, 1, O_MINUS_PREV },
  1700. + { X_INST_ANOTHER_TIMING,
  1701. + /* t2i -IOWR recovery time */
  1702. + { 0, 0, 0, 70, 25, 25, 20 }, 1, 0, 0 },
  1703. + { X_INST_ANOTHER_TIMING,
  1704. + /* CS 0 -> 1 MAX */
  1705. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, (OA_CPUOUT_DELTA |
  1706. + OA_EXTDEL_MAX) },
  1707. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS | INST_UTA | INST_LAST,
  1708. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1709. + /* min total cycle time - includes ALE cycle */
  1710. + { X_INST_TABLE_END,
  1711. + { 600, 383, 240, 180, 120, 100, 80 }, 1, 0, O_MIN_CYCLE_TIME },
  1712. +};
  1713. +
  1714. +struct __upm_timing {
  1715. + int clk, ps;
  1716. + const struct pata_rbppc_upm_cfg *cfg;
  1717. +};
  1718. +
  1719. +static int __ps_to_clk(int ps, u32 bus_timing) {
  1720. + int ps_over;
  1721. + if (ps <= 0)
  1722. + return 0;
  1723. +
  1724. + /* Round down if we're less than 2% over clk border, but no more than
  1725. + * 1/4 clk cycle. */
  1726. + ps_over = ps * 2 / 100;
  1727. + if (4 * ps_over > bus_timing)
  1728. + ps_over = bus_timing / 4;
  1729. +
  1730. + return (ps + bus_timing - 1 - ps_over) / bus_timing;
  1731. +}
  1732. +
  1733. +static void __upm_table_populate_times(struct __upm_timing *timings, int mode,
  1734. + u32 bus_timing,
  1735. + struct pata_rbppc_upm_localbus_timing *localbus_timings)
  1736. +{
  1737. + int i = 0, group_i = 0;
  1738. + struct __upm_timing *last = NULL, *group = NULL;
  1739. +
  1740. + do {
  1741. + const struct pata_rbppc_upm_cfg *cfg = timings[i].cfg;
  1742. +
  1743. + int ps = cfg->timings[mode] * 1000
  1744. + - cfg->clk_minus * bus_timing;
  1745. +
  1746. + if (cfg->options & OA_CPUIN_MIN)
  1747. + ps += localbus_timings->cpuin_min;
  1748. + if (cfg->options & OD_CPUOUT_MIN)
  1749. + ps -= localbus_timings->cpuout_min;
  1750. + if (cfg->options & OA_CPUOUT_MAX)
  1751. + ps += localbus_timings->cpuout_max;
  1752. + if (cfg->options & OD_EXTDEL_MIN)
  1753. + ps -= localbus_timings->extdel_min;
  1754. + if (cfg->options & OA_EXTDEL_MAX)
  1755. + ps += localbus_timings->extdel_max;
  1756. +
  1757. + if (last && cfg->value == X_INST_ANOTHER_TIMING) {
  1758. + if (last->ps < ps)
  1759. + last->ps = ps;
  1760. +
  1761. + timings[i].ps = 0;
  1762. + } else {
  1763. + if (cfg->group_size) {
  1764. + group = &timings[i];
  1765. + group_i = cfg->group_size;
  1766. + } else if (group && group_i > 0) {
  1767. + int clk = __ps_to_clk(ps, bus_timing);
  1768. + group->ps -= clk * bus_timing;
  1769. + group_i--;
  1770. + }
  1771. +
  1772. + if (cfg->options & O_MINUS_PREV) {
  1773. + int clk = __ps_to_clk(last->ps, bus_timing);
  1774. + ps -= clk * bus_timing;
  1775. + }
  1776. +
  1777. + timings[i].ps = ps;
  1778. + last = &timings[i];
  1779. + }
  1780. + } while (timings[i++].cfg->value != X_INST_TABLE_END);
  1781. +}
  1782. +
  1783. +static inline int __free_half(struct __upm_timing *timing, u32 bus_timing)
  1784. +{
  1785. + return timing->clk < 2
  1786. + ? 0
  1787. + : (timing->clk * bus_timing - timing->ps) * 2 >= bus_timing;
  1788. +}
  1789. +
  1790. +static void __upm_table_populate_clks(struct __upm_timing *timings,
  1791. + u32 bus_timing)
  1792. +{
  1793. + int i;
  1794. + int clk_total = 0;
  1795. +
  1796. + /*
  1797. + * Convert picoseconds determined from table/local bus timings to actual
  1798. + * clock cycles.
  1799. + */
  1800. + for (i = 0; timings[i].cfg->value != X_INST_TABLE_END; i++) {
  1801. + timings[i].clk = __ps_to_clk(timings[i].ps, bus_timing);
  1802. + clk_total += timings[i].clk;
  1803. + }
  1804. +
  1805. + /*
  1806. + * Check whether we have free half cycles surrounding an operation.
  1807. + *
  1808. + * We need at least three operations in the table for this to make
  1809. + * sense.
  1810. + */
  1811. + if (i >= 2) {
  1812. + int j;
  1813. +
  1814. + for (j = 1; timings[j + 1].cfg->value != X_INST_TABLE_END;
  1815. + j++) {
  1816. + if (timings[j].cfg->options & O_HALF_CYCLE &&
  1817. + __free_half(&timings[j - 1], bus_timing) &&
  1818. + __free_half(&timings[j + 1], bus_timing)) {
  1819. + timings[j].clk++;
  1820. + timings[j - 1].clk--;
  1821. + timings[j + 1].clk--;
  1822. + }
  1823. + }
  1824. + }
  1825. +
  1826. + /*
  1827. + * Finally see if we need to adjust any timings to meet the minimum
  1828. + * requirements for standards.
  1829. + */
  1830. + if (timings[i].cfg->options & O_MIN_CYCLE_TIME) {
  1831. + int j = 0;
  1832. +
  1833. + timings[i].clk = __ps_to_clk(timings[i].ps, bus_timing);
  1834. +
  1835. + while (clk_total < timings[i].clk) {
  1836. + if (timings[j].cfg->value == X_INST_TABLE_END)
  1837. + j = 0;
  1838. +
  1839. + if (timings[j].clk > 0) {
  1840. + timings[j].clk++;
  1841. + clk_total++;
  1842. + }
  1843. +
  1844. + j++;
  1845. + }
  1846. + }
  1847. +}
  1848. +
  1849. +static void __upm_table_populate_value(u32 value, int *clk, u32 **program)
  1850. +{
  1851. + if (*clk == 0)
  1852. + /* Nothing to do. */;
  1853. + else if (*clk >= LOOPS * 2) {
  1854. + int times, times_r1, times_r2;
  1855. +
  1856. + times = *clk / LOOPS;
  1857. + if (times > REDO_MAX_MULT * 2)
  1858. + times = REDO_MAX_MULT * 2;
  1859. +
  1860. + times_r1 = times / 2;
  1861. + times_r2 = times - times_r1;
  1862. +
  1863. + value |= INST_LOOP;
  1864. + **program = value | REDOS(times_r1);
  1865. + (*program)++;
  1866. + **program = value | REDOS(times_r2);
  1867. + (*program)++;
  1868. +
  1869. + *clk -= times * LOOPS;
  1870. + } else {
  1871. + int clk_for_value = *clk < REDO_MAX_MULT ? *clk : REDO_MAX_MULT;
  1872. +
  1873. + value |= REDOS(clk_for_value);
  1874. + *clk -= clk_for_value;
  1875. +
  1876. + **program = value;
  1877. + (*program)++;
  1878. + }
  1879. +}
  1880. +
  1881. +static void __upm_table_populate_values(struct __upm_timing *timings,
  1882. + struct pata_rbppc_upm_program *program,
  1883. + int offset)
  1884. +{
  1885. + int i;
  1886. +
  1887. + u32 *wr = &program->program[offset];
  1888. + for (i = 0; timings[i].cfg->value != X_INST_TABLE_END; i++) {
  1889. + int clk = timings[i].clk;
  1890. + while (clk > 0)
  1891. + __upm_table_populate_value(timings[i].cfg->value, &clk,
  1892. + &wr);
  1893. + }
  1894. +}
  1895. +
  1896. +static int __upm_table_to_program(struct pata_rbppc_upm_prv *prv,
  1897. + struct __upm_timing *timings, int mode,
  1898. + struct pata_rbppc_upm_program *program,
  1899. + int offset)
  1900. +{
  1901. + __upm_table_populate_times(timings, mode, prv->timing,
  1902. + &prv->localbus_timings);
  1903. + __upm_table_populate_clks(timings, prv->timing);
  1904. + __upm_table_populate_values(timings, program, offset);
  1905. +
  1906. + return 0;
  1907. +}
  1908. +
  1909. +static int pata_rbppc_upm_get_program(struct pata_rbppc_upm_prv *prv, int mode,
  1910. + struct pata_rbppc_upm_program *program)
  1911. +{
  1912. + int i;
  1913. + int retval;
  1914. + struct __upm_timing read_timings[ARRAY_SIZE(pata_rbppc_upm_read_table)];
  1915. + struct __upm_timing write_timings[ARRAY_SIZE(pata_rbppc_upm_write_table)];
  1916. +
  1917. + /*
  1918. + * Initialize program to empty values.
  1919. + */
  1920. + for (i = 0; i < UPM_P_SIZE; i++) {
  1921. + program->program[i] = INST_EMPTY;
  1922. + }
  1923. +
  1924. + /*
  1925. + * Initialize the timing data and map it to our table.
  1926. + */
  1927. +#define INITIALIZE_TIMINGS(timings, table) \
  1928. + do { \
  1929. + int i = 0; \
  1930. + do { \
  1931. + (timings)[i].clk = 0; \
  1932. + (timings)[i].ps = 0; \
  1933. + (timings)[i].cfg = &(table)[i]; \
  1934. + } while ((table)[i++].value != X_INST_TABLE_END); \
  1935. + } while(0)
  1936. + INITIALIZE_TIMINGS(read_timings, pata_rbppc_upm_read_table);
  1937. + INITIALIZE_TIMINGS(write_timings, pata_rbppc_upm_write_table);
  1938. +
  1939. + /*
  1940. + * Build read/write programs from our table structures.
  1941. + */
  1942. + retval = __upm_table_to_program(prv, read_timings, mode, program,
  1943. + UPM_P_RSS);
  1944. + if (retval) {
  1945. + dev_err(prv->dev, "Could not generate read program for PIO "
  1946. + "mode %u\n", mode);
  1947. + return retval;
  1948. + }
  1949. +
  1950. + retval = __upm_table_to_program(prv, write_timings, mode, program,
  1951. + UPM_P_WSS);
  1952. + if (retval) {
  1953. + dev_err(prv->dev, "Could not generate write program for PIO "
  1954. + "mode %u\n", mode);
  1955. + }
  1956. +
  1957. + return 0;
  1958. +}
  1959. +
  1960. +static void pata_rbppc_upm_program(struct pata_rbppc_upm_prv *prv,
  1961. + struct pata_rbppc_upm_program *program)
  1962. +{
  1963. + u32 i;
  1964. +
  1965. + clrsetbits_be32(prv->upm.mxmr, MxMR_MAD, MxMR_OP_WA);
  1966. + in_be32(prv->upm.mxmr);
  1967. +
  1968. + for (i = 0; i < UPM_P_SIZE; i++) {
  1969. + out_be32(&prv->ctrl->regs->mdr, program->program[i]);
  1970. + in_be32(&prv->ctrl->regs->mdr);
  1971. +
  1972. + out_8(program->io_addr, 0x0);
  1973. +
  1974. + while ((in_be32(prv->upm.mxmr) ^ (i + 1)) & MxMR_MAD)
  1975. + cpu_relax();
  1976. + }
  1977. +
  1978. + clrsetbits_be32(prv->upm.mxmr, MxMR_MAD | MxMR_OP,
  1979. + MxMR_OP_NO | (LOOPS << MxMR_RLF_SHIFT) |
  1980. + (LOOPS << MxMR_WLF_SHIFT));
  1981. + in_be32(prv->upm.mxmr);
  1982. +}
  1983. +
  1984. +static int pata_rbppc_upm_program_for_piomode(struct pata_rbppc_upm_prv *prv,
  1985. + int mode)
  1986. +{
  1987. + struct pata_rbppc_upm_program program;
  1988. + int retval;
  1989. +
  1990. + retval = pata_rbppc_upm_get_program(prv, mode, &program);
  1991. + if (retval)
  1992. + return retval;
  1993. +
  1994. + program.io_addr = prv->host->ports[0]->ioaddr.cmd_addr;
  1995. + pata_rbppc_upm_program(prv, &program);
  1996. +
  1997. + return 0;
  1998. +}
  1999. +
  2000. +static void pata_rbppc_upm_set_piomode(struct ata_port *ap, struct ata_device *adev)
  2001. +{
  2002. + struct pata_rbppc_upm_prv *prv = ap->host->private_data;
  2003. + struct pata_rbppc_upm_pio_status *pio_status;
  2004. + int requested_mode = adev->pio_mode - XFER_PIO_0;
  2005. + int actual_mode = requested_mode;
  2006. + int retval;
  2007. +
  2008. + if (requested_mode < 0 || requested_mode > 6) {
  2009. + dev_err(prv->dev, "Illegal PIO mode %u\n", requested_mode);
  2010. + return;
  2011. + }
  2012. +
  2013. + prv->pio_status.configured_mode = requested_mode;
  2014. +
  2015. + mutex_lock(&pio_status_mutex);
  2016. +
  2017. + /*
  2018. + * Find other hosts that are on the same UPM as this one, and make sure
  2019. + * they're all configured for the PIO mode we want.
  2020. + */
  2021. + for (pio_status = pio_statuses; pio_status != NULL;
  2022. + pio_status = pio_status->next) {
  2023. + if (pio_status->prv == prv)
  2024. + continue;
  2025. + else if (pio_status->prv->upm.mxmr == prv->upm.mxmr &&
  2026. + pio_status->configured_mode < actual_mode)
  2027. + actual_mode = pio_status->configured_mode;
  2028. + }
  2029. +
  2030. + if (actual_mode < 0) {
  2031. + dev_info(prv->dev, "Waiting until another device comes up to "
  2032. + "program UPM for new PIO mode\n");
  2033. + goto out;
  2034. + } else if (actual_mode < requested_mode) {
  2035. + dev_info(prv->dev, "Requested PIO mode %u, but UPM can only be "
  2036. + "configured at PIO mode %u\n", requested_mode,
  2037. + actual_mode);
  2038. + }
  2039. +
  2040. + retval = pata_rbppc_upm_program_for_piomode(prv, actual_mode);
  2041. + if (retval) {
  2042. + dev_err(prv->dev, "Could not update PIO mode: %d\n", retval);
  2043. + goto out;
  2044. + }
  2045. +
  2046. + /*
  2047. + * Now update everything on the UPM to have the new actual mode.
  2048. + */
  2049. + for (pio_status = pio_statuses; pio_status != NULL;
  2050. + pio_status = pio_status->next) {
  2051. + if (pio_status->prv->upm.mxmr == prv->upm.mxmr) {
  2052. + pio_status->actual_mode = actual_mode;
  2053. + dev_info(pio_status->prv->dev,
  2054. + "PIO mode changed to %u\n", actual_mode);
  2055. + }
  2056. + }
  2057. +
  2058. +out:
  2059. + mutex_unlock(&pio_status_mutex);
  2060. +}
  2061. +
  2062. +static u8 pata_rbppc_upm_check_status(struct ata_port *ap) {
  2063. + u8 val = ioread8(ap->ioaddr.status_addr);
  2064. + if (val == 0xF9)
  2065. + val = 0x7F;
  2066. + return val;
  2067. +}
  2068. +
  2069. +static u8 pata_rbppc_upm_check_altstatus(struct ata_port *ap) {
  2070. + u8 val = ioread8(ap->ioaddr.altstatus_addr);
  2071. + if (val == 0xF9)
  2072. + val = 0x7F;
  2073. + return val;
  2074. +}
  2075. +
  2076. +static irqreturn_t pata_rbppc_upm_interrupt(int irq, void *dev_instance)
  2077. +{
  2078. + irqreturn_t retval = ata_sff_interrupt(irq, dev_instance);
  2079. + if (retval == IRQ_RETVAL(0)) {
  2080. + struct ata_host *host = dev_instance;
  2081. + struct ata_port *ap = host->ports[0];
  2082. +
  2083. + /* Clear interrupt. */
  2084. + ap->ops->sff_check_status(ap);
  2085. +
  2086. + ata_port_printk(ap, KERN_WARNING, "IRQ %d not handled\n", irq);
  2087. + }
  2088. +
  2089. + return retval;
  2090. +}
  2091. +
  2092. +static struct scsi_host_template pata_rbppc_upm_sht = {
  2093. + ATA_BASE_SHT(DRV_NAME),
  2094. + .dma_boundary = ATA_DMA_BOUNDARY,
  2095. +};
  2096. +
  2097. +static struct ata_port_operations pata_rbppc_upm_port_ops = {
  2098. + .inherits = &ata_sff_port_ops,
  2099. +
  2100. + .set_piomode = pata_rbppc_upm_set_piomode,
  2101. +
  2102. + .sff_check_status = pata_rbppc_upm_check_status,
  2103. + .sff_check_altstatus = pata_rbppc_upm_check_altstatus,
  2104. +};
  2105. +
  2106. +static int pata_rbppc_upm_probe_timings(struct pata_rbppc_upm_prv *prv)
  2107. +{
  2108. + struct device *dev = prv->dev;
  2109. + struct device_node *dn_soc;
  2110. + const u32 *prop;
  2111. + int prop_size;
  2112. + u32 bus_frequency, lcrr_clkdiv;
  2113. + int retval = 0;
  2114. +
  2115. + dn_soc = of_find_node_by_type(NULL, "soc");
  2116. + if (!dn_soc) {
  2117. + dev_err(dev, "Could not find SoC node\n");
  2118. + return -EINVAL;
  2119. + }
  2120. +
  2121. + prop = of_get_property(dn_soc, "bus-frequency", NULL);
  2122. + if (!prop || !*prop) {
  2123. + dev_err(dev, "Could not determine bus frequency\n");
  2124. + retval = -EINVAL;
  2125. + goto out;
  2126. + }
  2127. +
  2128. + bus_frequency = *prop;
  2129. +
  2130. + /*
  2131. + * The actual speed is determined by the ratio between the bus frequency
  2132. + * and the CLKDIV register.
  2133. + */
  2134. + lcrr_clkdiv = (in_be32(&prv->ctrl->regs->lcrr) & LCRR_CLKDIV)
  2135. + >> LCRR_CLKDIV_SHIFT;
  2136. + bus_frequency /= lcrr_clkdiv;
  2137. +
  2138. + /* (picoseconds / kHz) */
  2139. + prv->timing = 1000000000 / (bus_frequency / 1000);
  2140. +
  2141. + /*
  2142. + * Additional timings are set up in the device node itself, also in
  2143. + * picoseconds.
  2144. + */
  2145. + prop = of_get_property(dev->of_node, "rb,pata-upm-localbus-timings",
  2146. + &prop_size);
  2147. + if (prop && prop_size == 5 * sizeof(u32)) {
  2148. + prv->localbus_timings.cpuin_min = prop[0];
  2149. + prv->localbus_timings.cpuout_min = prop[1];
  2150. + prv->localbus_timings.cpuout_max = prop[2];
  2151. + prv->localbus_timings.extdel_min = prop[3];
  2152. + prv->localbus_timings.extdel_max = prop[4];
  2153. + }
  2154. +
  2155. +out:
  2156. + of_node_put(dn_soc);
  2157. + return retval;
  2158. +}
  2159. +
  2160. +static int pata_rbppc_upm_probe(struct platform_device *pdev)
  2161. +{
  2162. + struct device *dev = &pdev->dev;
  2163. + struct pata_rbppc_upm_prv *prv;
  2164. + struct ata_host *host;
  2165. + struct ata_port *ap;
  2166. + struct ata_ioports *aio;
  2167. + struct device_node *dn = dev->of_node;
  2168. + struct resource res;
  2169. + void __iomem *io_addr;
  2170. + int retval;
  2171. +
  2172. + printk(KERN_INFO "MikroTik RouterBOARD UPM PATA driver for "
  2173. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2174. +
  2175. + if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
  2176. + return -ENODEV;
  2177. +
  2178. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2179. + if (!prv) {
  2180. + dev_err(dev, "Can't allocate memory!\n");
  2181. + return -ENOMEM;
  2182. + }
  2183. +
  2184. + prv->ctrl = fsl_lbc_ctrl_dev;
  2185. + prv->dev = dev;
  2186. +
  2187. + retval = pata_rbppc_upm_probe_timings(prv);
  2188. + if (retval) {
  2189. + dev_err(dev, "Could not initialize timing data from SoC\n");
  2190. + return retval;
  2191. + }
  2192. +
  2193. + retval = of_address_to_resource(dn, 0, &res);
  2194. + if (retval) {
  2195. + dev_err(dev, "No reg property found\n");
  2196. + return retval;
  2197. + }
  2198. +
  2199. + retval = fsl_upm_find(res.start, &prv->upm);
  2200. + if (retval) {
  2201. + dev_err(dev, "Could not find UPM\n");
  2202. + return retval;
  2203. + }
  2204. +
  2205. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1,
  2206. + DRV_NAME)) {
  2207. + dev_err(dev, "Could not request region\n");
  2208. + return -EBUSY;
  2209. + }
  2210. +
  2211. + io_addr = devm_ioremap(dev, res.start, res.end - res.start + 1);
  2212. + if (!io_addr) {
  2213. + dev_err(dev, "Could not map IO region\n");
  2214. + return -ENOMEM;
  2215. + }
  2216. +
  2217. + host = ata_host_alloc(dev, 1);
  2218. + if (!host) {
  2219. + dev_err(dev, "Can't allocate memory!\n");
  2220. + return -ENOMEM;
  2221. + }
  2222. +
  2223. + host->private_data = prv;
  2224. +
  2225. + ap = host->ports[0];
  2226. + ap->ops = &pata_rbppc_upm_port_ops;
  2227. + ap->pio_mask = ATA_PIO6;
  2228. + ap->udma_mask = 0;
  2229. + ap->mwdma_mask = 0;
  2230. +
  2231. + /*
  2232. + * This is sort of halfheartedly based on the extremely strange logic in
  2233. + * rb_iomap.c. I think setting these to the values they eventually get
  2234. + * mapped to (look at localbus_regoff() if you're curious) should
  2235. + * eliminate the need for RouterBOARD-specific iomapping.
  2236. + */
  2237. + aio = &ap->ioaddr;
  2238. + aio->cmd_addr = REG_OFFSET(io_addr, 0);
  2239. + aio->data_addr = REG_OFFSET(io_addr, ATA_REG_DATA);
  2240. + aio->error_addr = REG_OFFSET(io_addr, ATA_REG_ERR);
  2241. + aio->feature_addr = REG_OFFSET(io_addr, ATA_REG_FEATURE);
  2242. + aio->nsect_addr = REG_OFFSET(io_addr, ATA_REG_NSECT);
  2243. + aio->lbal_addr = REG_OFFSET(io_addr, ATA_REG_LBAL);
  2244. + aio->lbam_addr = REG_OFFSET(io_addr, ATA_REG_LBAM);
  2245. + aio->lbah_addr = REG_OFFSET(io_addr, ATA_REG_LBAH);
  2246. + aio->device_addr = REG_OFFSET(io_addr, ATA_REG_DEVICE);
  2247. + aio->status_addr = REG_OFFSET(io_addr, ATA_REG_STATUS);
  2248. + aio->command_addr = REG_OFFSET(io_addr, ATA_REG_CMD);
  2249. + aio->ctl_addr = REG_OFFSET(io_addr, 14);
  2250. + aio->altstatus_addr = aio->ctl_addr;
  2251. +
  2252. + prv->irq = irq_of_parse_and_map(dev->of_node, 0);
  2253. + if (prv->irq == NO_IRQ) {
  2254. + dev_err(dev, "Could not acquire IRQ\n");
  2255. + return -EINVAL;
  2256. + }
  2257. +
  2258. + retval = ata_host_activate(host, prv->irq, pata_rbppc_upm_interrupt,
  2259. + IRQF_TRIGGER_LOW, &pata_rbppc_upm_sht);
  2260. + if (retval) {
  2261. + irq_dispose_mapping(prv->irq);
  2262. + dev_err(dev, "Could not activate ATA host\n");
  2263. + return retval;
  2264. + }
  2265. +
  2266. + prv->host = host;
  2267. +
  2268. + /*
  2269. + * Set up the PIO mode tracking mechanism.
  2270. + */
  2271. + prv->pio_status.configured_mode = -1;
  2272. + prv->pio_status.actual_mode = -1;
  2273. + prv->pio_status.prv = prv;
  2274. +
  2275. + mutex_lock(&pio_status_mutex);
  2276. +
  2277. + prv->pio_status.next = pio_statuses;
  2278. + pio_statuses = &prv->pio_status;
  2279. +
  2280. + mutex_unlock(&pio_status_mutex);
  2281. +
  2282. + return 0;
  2283. +}
  2284. +
  2285. +static int pata_rbppc_upm_remove(struct platform_device *pdev)
  2286. +{
  2287. + struct device *dev = &pdev->dev;
  2288. + struct ata_host *host = dev_get_drvdata(dev);
  2289. + struct pata_rbppc_upm_prv *prv = host->private_data;
  2290. + struct pata_rbppc_upm_pio_status *pio_status;
  2291. +
  2292. + /*
  2293. + * Remove PIO mode tracking.
  2294. + */
  2295. + mutex_lock(&pio_status_mutex);
  2296. +
  2297. + if (!pio_statuses->next)
  2298. + pio_statuses = NULL;
  2299. + else {
  2300. + for (pio_status = pio_statuses; pio_status != NULL;
  2301. + pio_status = pio_status->next) {
  2302. + if (pio_status->next && pio_status->next->prv == prv) {
  2303. + pio_status->next = pio_status->next->next;
  2304. + break;
  2305. + }
  2306. + }
  2307. + }
  2308. +
  2309. + mutex_unlock(&pio_status_mutex);
  2310. +
  2311. + /*
  2312. + * And clean up all the things we allocated. ALL THE THINGS.
  2313. + */
  2314. + ata_host_detach(host);
  2315. + irq_dispose_mapping(prv->irq);
  2316. +
  2317. + return 0;
  2318. +}
  2319. +
  2320. +static struct of_device_id pata_rbppc_upm_ids[] = {
  2321. + { .compatible = "rb,pata-upm", },
  2322. + { },
  2323. +};
  2324. +
  2325. +static struct platform_driver pata_rbppc_upm_driver = {
  2326. + .probe = pata_rbppc_upm_probe,
  2327. + .remove = pata_rbppc_upm_remove,
  2328. + .driver = {
  2329. + .name = "rbppc-upm",
  2330. + .owner = THIS_MODULE,
  2331. + .of_match_table = pata_rbppc_upm_ids,
  2332. + },
  2333. +};
  2334. +
  2335. +static int __init pata_rbppc_upm_init(void)
  2336. +{
  2337. + return platform_driver_register(&pata_rbppc_upm_driver);
  2338. +}
  2339. +
  2340. +static void __exit pata_rbppc_upm_exit(void)
  2341. +{
  2342. + platform_driver_unregister(&pata_rbppc_upm_driver);
  2343. +}
  2344. +
  2345. +MODULE_AUTHOR("Mikrotikls SIA");
  2346. +MODULE_AUTHOR("Noah Fontes");
  2347. +MODULE_DESCRIPTION("MikroTik RouterBOARD UPM PATA driver for MPC83xx/MPC85xx-based platforms");
  2348. +MODULE_LICENSE("GPL");
  2349. +MODULE_VERSION(DRV_VERSION);
  2350. +
  2351. +module_init(pata_rbppc_upm_init);
  2352. +module_exit(pata_rbppc_upm_exit);
  2353. diff -Nur linux-3.16.85.orig/drivers/input/misc/Kconfig linux-3.16.85/drivers/input/misc/Kconfig
  2354. --- linux-3.16.85.orig/drivers/input/misc/Kconfig 2020-06-11 20:06:00.000000000 +0200
  2355. +++ linux-3.16.85/drivers/input/misc/Kconfig 2026-04-25 10:21:57.453901547 +0200
  2356. @@ -676,4 +676,12 @@
  2357. To compile this driver as a module, choose M here: the
  2358. module will be called soc_button_array.
  2359. +config INPUT_RBPPC_GTM_BEEPER
  2360. + tristate "MikroTik RouterBOARD GTM speaker support for Freescale MPC83xx/MPC85xx-based platforms"
  2361. + depends on FSL_GTM && PPC_OF && (GPIOLIB || !RB333)
  2362. + help
  2363. + This option enables support for the on-board speaker device on
  2364. + MikroTik RouterBOARD Freescale MPC83xx/MPC85xx-based platforms, such
  2365. + as RB333, RB600, and RB800.
  2366. +
  2367. endif
  2368. diff -Nur linux-3.16.85.orig/drivers/input/misc/Makefile linux-3.16.85/drivers/input/misc/Makefile
  2369. --- linux-3.16.85.orig/drivers/input/misc/Makefile 2020-06-11 20:06:00.000000000 +0200
  2370. +++ linux-3.16.85/drivers/input/misc/Makefile 2026-04-25 10:21:57.453901547 +0200
  2371. @@ -64,3 +64,4 @@
  2372. obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
  2373. obj-$(CONFIG_INPUT_YEALINK) += yealink.o
  2374. obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
  2375. +obj-$(CONFIG_INPUT_RBPPC_GTM_BEEPER) += rbppc_gtm_beeper.o
  2376. diff -Nur linux-3.16.85.orig/drivers/input/misc/rbppc_gtm_beeper.c linux-3.16.85/drivers/input/misc/rbppc_gtm_beeper.c
  2377. --- linux-3.16.85.orig/drivers/input/misc/rbppc_gtm_beeper.c 1970-01-01 01:00:00.000000000 +0100
  2378. +++ linux-3.16.85/drivers/input/misc/rbppc_gtm_beeper.c 2026-04-25 10:21:57.453901547 +0200
  2379. @@ -0,0 +1,260 @@
  2380. +/*
  2381. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  2382. + * Copyright (C) Mikrotik 2007
  2383. + *
  2384. + * This program is free software; you can redistribute it and/or modify it
  2385. + * under the terms of the GNU General Public License as published by the
  2386. + * Free Software Foundation; either version 2 of the License, or (at your
  2387. + * option) any later version.
  2388. + */
  2389. +
  2390. +#include <linux/kernel.h>
  2391. +#include <linux/module.h>
  2392. +#include <linux/init.h>
  2393. +#include <linux/input.h>
  2394. +#include <linux/interrupt.h>
  2395. +#include <linux/gpio.h>
  2396. +#include <linux/of_platform.h>
  2397. +#include <linux/of_gpio.h>
  2398. +
  2399. +#include <asm/fsl_gtm.h>
  2400. +
  2401. +#define DRV_NAME "rbppc_gtm_beeper"
  2402. +#define DRV_VERSION "0.1.0"
  2403. +
  2404. +struct rbppc_gtm_beeper_prv {
  2405. + int gpio, gpio_toggle;
  2406. + int irq;
  2407. +
  2408. + struct gtm_timer *timer;
  2409. + struct input_dev *input;
  2410. +
  2411. + struct device *dev;
  2412. +};
  2413. +
  2414. +static irqreturn_t rbppc_gtm_beeper_interrupt(int irq, void *data)
  2415. +{
  2416. + struct rbppc_gtm_beeper_prv *prv = data;
  2417. +
  2418. + if (gpio_is_valid(prv->gpio)) {
  2419. + gpio_set_value(prv->gpio, prv->gpio_toggle);
  2420. + prv->gpio_toggle ^= 1;
  2421. + }
  2422. +
  2423. + if (prv->timer)
  2424. + gtm_ack_timer16(prv->timer, 0xFFFF);
  2425. +
  2426. + return IRQ_HANDLED;
  2427. +}
  2428. +
  2429. +static int rbppc_gtm_beeper_event(struct input_dev *input, unsigned int type,
  2430. + unsigned int code, int value)
  2431. +{
  2432. + struct rbppc_gtm_beeper_prv *prv = input_get_drvdata(input);
  2433. +
  2434. + if (type != EV_SND || value < 0)
  2435. + return -EINVAL;
  2436. +
  2437. + switch (code) {
  2438. + case SND_BELL:
  2439. + value = value ? 1000 : 0;
  2440. + break;
  2441. + case SND_TONE:
  2442. + break;
  2443. + default:
  2444. + return -EINVAL;
  2445. + }
  2446. +
  2447. + if (value == 0)
  2448. + gtm_stop_timer16(prv->timer);
  2449. + else
  2450. + /*
  2451. + * "reload" is actually "free run", despite what the API
  2452. + * documentation claims.
  2453. + */
  2454. + gtm_set_timer16(prv->timer, value, true);
  2455. +
  2456. + return 0;
  2457. +}
  2458. +
  2459. +static int rbppc_gtm_beeper_probe_input(struct rbppc_gtm_beeper_prv *prv)
  2460. +{
  2461. + int retval = 0;
  2462. +
  2463. + prv->input = input_allocate_device();
  2464. + if (!prv->input) {
  2465. + dev_err(prv->dev, "Can't allocate memory!\n");
  2466. + return -ENOMEM;
  2467. + }
  2468. +
  2469. + prv->input->name = "rbppc-gtm-beeper";
  2470. + prv->input->phys = "rbppc/input0";
  2471. + prv->input->id.bustype = BUS_HOST;
  2472. + prv->input->id.vendor = 0x001f;
  2473. + prv->input->id.product = 0x0001;
  2474. + prv->input->id.version = 0x0100;
  2475. +
  2476. + prv->input->evbit[0] = BIT_MASK(EV_SND);
  2477. + prv->input->sndbit[0] = BIT_MASK(SND_TONE) | BIT_MASK(SND_BELL);
  2478. +
  2479. + prv->input->event = rbppc_gtm_beeper_event;
  2480. +
  2481. + input_set_drvdata(prv->input, prv);
  2482. +
  2483. + retval = input_register_device(prv->input);
  2484. + if (retval) {
  2485. + dev_err(prv->dev, "Could not register input device\n");
  2486. + input_free_device(prv->input);
  2487. + }
  2488. +
  2489. + return retval;
  2490. +}
  2491. +
  2492. +static int rbppc_gtm_beeper_probe(struct platform_device *pdev)
  2493. +{
  2494. + struct device *dev = &pdev->dev;
  2495. + struct device_node *dn_timer, *dn = dev->of_node;
  2496. + struct gtm *gtm;
  2497. + struct rbppc_gtm_beeper_prv *prv;
  2498. + const __be32 *prop;
  2499. + int size, retval;
  2500. +
  2501. + printk(KERN_INFO "MikroTik RouterBOARD GTM speaker driver for "
  2502. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2503. +
  2504. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2505. + if (!prv) {
  2506. + dev_err(dev, "Can't allocate memory!\n");
  2507. + return -ENOMEM;
  2508. + }
  2509. +
  2510. + prv->dev = dev;
  2511. +
  2512. + prop = of_get_property(dn, "timer", &size);
  2513. + if (size != 2 * sizeof(*prop)) {
  2514. + dev_err(dev, "Invalid timer property\n");
  2515. + return -EINVAL;
  2516. + }
  2517. +
  2518. + dn_timer = of_find_node_by_phandle(be32_to_cpu(prop[0]));
  2519. + if (!dn_timer) {
  2520. + dev_err(dev, "No GTM found\n");
  2521. + return -EINVAL;
  2522. + } else if (!dn_timer->data) {
  2523. + /*
  2524. + * The FSL GTM initialization routines map the GTM to the ->data
  2525. + * property of the OF node.
  2526. + */
  2527. + dev_err(dev, "GTM node has not been initialized\n");
  2528. + of_node_put(dn_timer);
  2529. + return -EINVAL;
  2530. + }
  2531. +
  2532. + gtm = dn_timer->data;
  2533. +
  2534. + of_node_put(dn_timer);
  2535. +
  2536. + prv->timer = gtm_get_specific_timer16(gtm, be32_to_cpu(prop[1]));
  2537. + if (IS_ERR(prv->timer)) {
  2538. + dev_err(dev, "Could not request specific timer on GTM\n");
  2539. + return PTR_ERR(prv->timer);
  2540. + }
  2541. +
  2542. + /*
  2543. + * On the RB333, we need to toggle some GPIO pins every time we get an
  2544. + * interrupt.
  2545. + */
  2546. + prv->gpio = -1;
  2547. + if (of_device_is_compatible(dn, "rb,rb333-gtm-beeper")) {
  2548. + int gpio;
  2549. + gpio = of_get_gpio(dn, 0);
  2550. + if (!gpio_is_valid(gpio)) {
  2551. + dev_err(dev, "No GPIO found\n");
  2552. + retval = gpio;
  2553. + goto err_after_get_timer;
  2554. + }
  2555. +
  2556. + retval = gpio_request(gpio, "RouterBOARD Speaker");
  2557. + if (retval) {
  2558. + dev_err(dev, "Couldn't request GPIO for speaker\n");
  2559. + goto err_after_get_timer;
  2560. + }
  2561. + gpio_direction_output(gpio, 0);
  2562. + prv->gpio = gpio;
  2563. + prv->gpio_toggle = 0;
  2564. + }
  2565. +
  2566. + retval = devm_request_irq(dev, prv->timer->irq,
  2567. + rbppc_gtm_beeper_interrupt, 0, DRV_NAME, prv);
  2568. + if (retval) {
  2569. + dev_err(dev, "Could not request IRQ for speaker\n");
  2570. + goto err_after_request_gpio;
  2571. + }
  2572. +
  2573. + retval = rbppc_gtm_beeper_probe_input(prv);
  2574. + if (retval) {
  2575. + dev_err(dev, "Could not create input device for speaker\n");
  2576. + goto err_after_request_gpio;
  2577. + }
  2578. +
  2579. + dev_set_drvdata(dev, prv);
  2580. +
  2581. + return 0;
  2582. +
  2583. +err_after_request_gpio:
  2584. + if (gpio_is_valid(prv->gpio))
  2585. + gpio_free(prv->gpio);
  2586. +err_after_get_timer:
  2587. + gtm_put_timer16(prv->timer);
  2588. + return retval;
  2589. +}
  2590. +
  2591. +static int rbppc_gtm_beeper_remove(struct platform_device *pdev)
  2592. +{
  2593. + struct device *dev = &pdev->dev;
  2594. + struct rbppc_gtm_beeper_prv *prv = dev_get_drvdata(dev);
  2595. +
  2596. + input_unregister_device(prv->input);
  2597. + gtm_put_timer16(prv->timer);
  2598. +
  2599. + if (gpio_is_valid(prv->gpio))
  2600. + gpio_free(prv->gpio);
  2601. +
  2602. + dev_set_drvdata(dev, NULL);
  2603. +
  2604. + return 0;
  2605. +}
  2606. +
  2607. +static struct of_device_id rbppc_gtm_beeper_ids[] = {
  2608. + { .compatible = "rb,gtm-beeper", },
  2609. + { },
  2610. +};
  2611. +
  2612. +static struct platform_driver rbppc_gtm_beeper_driver = {
  2613. + .probe = rbppc_gtm_beeper_probe,
  2614. + .remove = rbppc_gtm_beeper_remove,
  2615. + .driver = {
  2616. + .name = "rbppc-gtm-beeper",
  2617. + .owner = THIS_MODULE,
  2618. + .of_match_table = rbppc_gtm_beeper_ids,
  2619. + },
  2620. +};
  2621. +
  2622. +static int __init rbppc_gtm_beeper_init(void)
  2623. +{
  2624. + return platform_driver_register(&rbppc_gtm_beeper_driver);
  2625. +}
  2626. +
  2627. +static void __exit rbppc_gtm_beeper_exit(void)
  2628. +{
  2629. + platform_driver_unregister(&rbppc_gtm_beeper_driver);
  2630. +}
  2631. +
  2632. +MODULE_AUTHOR("Mikrotikls SIA");
  2633. +MODULE_AUTHOR("Noah Fontes");
  2634. +MODULE_DESCRIPTION("MikroTik RouterBOARD GTM speaker driver for MPC83xx/MPC85xx-based platforms");
  2635. +MODULE_LICENSE("GPL");
  2636. +MODULE_VERSION(DRV_VERSION);
  2637. +
  2638. +module_init(rbppc_gtm_beeper_init);
  2639. +module_exit(rbppc_gtm_beeper_exit);
  2640. diff -Nur linux-3.16.85.orig/drivers/mtd/nand/Kconfig linux-3.16.85/drivers/mtd/nand/Kconfig
  2641. --- linux-3.16.85.orig/drivers/mtd/nand/Kconfig 2020-06-11 20:06:00.000000000 +0200
  2642. +++ linux-3.16.85/drivers/mtd/nand/Kconfig 2026-04-25 10:21:57.453901547 +0200
  2643. @@ -405,6 +405,14 @@
  2644. devices. You will need to provide platform-specific functions
  2645. via platform_data.
  2646. +config MTD_NAND_RBPPC
  2647. + tristate "MikroTik RouterBOARD NAND support for Freescale MPC83xx/MPC85xx-based platforms"
  2648. + depends on PPC_OF && GPIOLIB
  2649. + help
  2650. + This option enables support for the NAND device on MikroTik
  2651. + RouterBOARD Freescale MPC83xx/MPC85xx-based platforms, such as RB333,
  2652. + RB600, and RB800.
  2653. +
  2654. config MTD_NAND_ORION
  2655. tristate "NAND Flash support for Marvell Orion SoC"
  2656. depends on PLAT_ORION
  2657. diff -Nur linux-3.16.85.orig/drivers/mtd/nand/Makefile linux-3.16.85/drivers/mtd/nand/Makefile
  2658. --- linux-3.16.85.orig/drivers/mtd/nand/Makefile 2020-06-11 20:06:00.000000000 +0200
  2659. +++ linux-3.16.85/drivers/mtd/nand/Makefile 2026-04-25 10:21:57.453901547 +0200
  2660. @@ -31,6 +31,7 @@
  2661. obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
  2662. obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
  2663. obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  2664. +obj-$(CONFIG_MTD_NAND_RBPPC) += rbppc_nand.o
  2665. obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
  2666. obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
  2667. obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o
  2668. diff -Nur linux-3.16.85.orig/drivers/mtd/nand/rbppc_nand.c linux-3.16.85/drivers/mtd/nand/rbppc_nand.c
  2669. --- linux-3.16.85.orig/drivers/mtd/nand/rbppc_nand.c 1970-01-01 01:00:00.000000000 +0100
  2670. +++ linux-3.16.85/drivers/mtd/nand/rbppc_nand.c 2026-04-25 10:21:57.453901547 +0200
  2671. @@ -0,0 +1,367 @@
  2672. +/*
  2673. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  2674. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  2675. + * Copyright (C) Mikrotik 2007
  2676. + *
  2677. + * This program is free software; you can redistribute it and/or modify it
  2678. + * under the terms of the GNU General Public License as published by the
  2679. + * Free Software Foundation; either version 2 of the License, or (at your
  2680. + * option) any later version.
  2681. + *
  2682. + * This is a strange driver indeed. Instead of using a rational layout for
  2683. + * handling NAND operations (like, say, the fsl_upm driver), this driver uses
  2684. + * two separate UPMs plus four pins on GPIO_1. One of the UPMs is responsible
  2685. + * for actual read/write operations; the other one seems to be for ensuring
  2686. + * commands are executed serially (i.e., a sync buffer). It's referred to as as
  2687. + * either "localbus" or "nnand" in MikroTik's own code -- neither name makes
  2688. + * much sense to me. The GPIO is used for R/B and CLE/ALE/nCE.
  2689. + */
  2690. +
  2691. +#include <linux/init.h>
  2692. +#include <linux/slab.h>
  2693. +#include <linux/module.h>
  2694. +#include <linux/gpio.h>
  2695. +#include <linux/io.h>
  2696. +#include <linux/mtd/nand.h>
  2697. +#include <linux/mtd/mtd.h>
  2698. +#include <linux/mtd/partitions.h>
  2699. +#include <linux/of_platform.h>
  2700. +#include <linux/of_address.h>
  2701. +#include <linux/of_gpio.h>
  2702. +
  2703. +#define DRV_NAME "rbppc_nand"
  2704. +#define DRV_VERSION "0.1.1"
  2705. +
  2706. +struct rbppc_nand_prv {
  2707. + struct mtd_info mtd;
  2708. + struct nand_chip chip;
  2709. +
  2710. + int rnb_gpio;
  2711. +
  2712. + int nce_gpio;
  2713. + int cle_gpio;
  2714. + int ale_gpio;
  2715. +
  2716. + void __iomem *cmd_sync;
  2717. +
  2718. + struct device *dev;
  2719. +};
  2720. +
  2721. +/*
  2722. + * We must use the OOB layout from yaffs 1 if we want this to be recognized
  2723. + * properly. Borrowed from the OpenWRT patches for the RB532.
  2724. + *
  2725. + * See <https://dev.openwrt.org/browser/trunk/target/linux/rb532/
  2726. + * patches-2.6.28/025-rb532_nand_fixup.patch> for more details.
  2727. + */
  2728. +static struct nand_ecclayout rbppc_nand_oob_16 = {
  2729. + .eccbytes = 6,
  2730. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  2731. + .oobavail = 9,
  2732. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } },
  2733. +};
  2734. +
  2735. +static inline void rbppc_nand_sync(struct rbppc_nand_prv *prv) {
  2736. + /*
  2737. + * My understanding from reading the GPIO NAND driver (gpio.c) is that
  2738. + * this enforces a MEMBAR that the CPU itself can't provide; in other
  2739. + * words, it forces commands to be executed synchronously.
  2740. + */
  2741. + readb(prv->cmd_sync);
  2742. +}
  2743. +
  2744. +static int rbppc_nand_dev_ready(struct mtd_info *mtd) {
  2745. + struct nand_chip *chip = mtd->priv;
  2746. + struct rbppc_nand_prv *prv = chip->priv;
  2747. +
  2748. + return gpio_get_value(prv->rnb_gpio);
  2749. +}
  2750. +
  2751. +static void rbppc_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) {
  2752. + struct nand_chip *chip = mtd->priv;
  2753. + struct rbppc_nand_prv *prv = chip->priv;
  2754. +
  2755. + rbppc_nand_sync(prv);
  2756. +
  2757. + if (ctrl & NAND_CTRL_CHANGE) {
  2758. + gpio_set_value(prv->nce_gpio, !(ctrl & NAND_NCE));
  2759. + gpio_set_value(prv->cle_gpio, !!(ctrl & NAND_CLE));
  2760. + gpio_set_value(prv->ale_gpio, !!(ctrl & NAND_ALE));
  2761. +
  2762. + rbppc_nand_sync(prv);
  2763. + }
  2764. + if (cmd == NAND_CMD_NONE)
  2765. + return;
  2766. +
  2767. + writeb(cmd, chip->IO_ADDR_W);
  2768. + rbppc_nand_sync(prv);
  2769. +}
  2770. +
  2771. +static void rbppc_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
  2772. +{
  2773. + struct nand_chip *chip = mtd->priv;
  2774. +
  2775. + readsb(chip->IO_ADDR_R, buf, len);
  2776. +}
  2777. +
  2778. +static void rbppc_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
  2779. +{
  2780. + struct nand_chip *chip = mtd->priv;
  2781. +
  2782. + writesb(chip->IO_ADDR_W, buf, len);
  2783. +}
  2784. +
  2785. +static void rbppc_nand_free_gpio(struct rbppc_nand_prv *prv)
  2786. +{
  2787. + if (gpio_is_valid(prv->rnb_gpio))
  2788. + gpio_free(prv->rnb_gpio);
  2789. + if (gpio_is_valid(prv->nce_gpio))
  2790. + gpio_free(prv->nce_gpio);
  2791. + if (gpio_is_valid(prv->cle_gpio))
  2792. + gpio_free(prv->cle_gpio);
  2793. + if (gpio_is_valid(prv->ale_gpio))
  2794. + gpio_free(prv->ale_gpio);
  2795. +}
  2796. +
  2797. +static int rbppc_nand_probe_gpio(struct rbppc_nand_prv *prv, int rnb_gpio, int nce_gpio, int cle_gpio, int ale_gpio)
  2798. +{
  2799. + struct device *dev = prv->dev;
  2800. + int retval = 0;
  2801. +
  2802. + prv->rnb_gpio = -1;
  2803. + prv->nce_gpio = -1;
  2804. + prv->cle_gpio = -1;
  2805. + prv->ale_gpio = -1;
  2806. +
  2807. + retval = gpio_request(rnb_gpio, "RouterBOARD NAND R/B");
  2808. + if (retval) {
  2809. + dev_err(dev, "Couldn't request R/B GPIO\n");
  2810. + goto err;
  2811. + }
  2812. + gpio_direction_input(rnb_gpio);
  2813. + prv->rnb_gpio = rnb_gpio;
  2814. +
  2815. + retval = gpio_request(nce_gpio, "RouterBOARD NAND nCE");
  2816. + if (retval) {
  2817. + dev_err(dev, "Couldn't request nCE GPIO\n");
  2818. + goto err;
  2819. + }
  2820. + gpio_direction_output(nce_gpio, 1);
  2821. + prv->nce_gpio = nce_gpio;
  2822. +
  2823. + retval = gpio_request(cle_gpio, "RouterBOARD NAND CLE");
  2824. + if (retval) {
  2825. + dev_err(dev, "Couldn't request CLE GPIO\n");
  2826. + goto err;
  2827. + }
  2828. + gpio_direction_output(cle_gpio, 0);
  2829. + prv->cle_gpio = cle_gpio;
  2830. +
  2831. + retval = gpio_request(ale_gpio, "RouterBOARD NAND ALE");
  2832. + if (retval) {
  2833. + dev_err(dev, "Couldn't request ALE GPIO\n");
  2834. + goto err;
  2835. + }
  2836. + gpio_direction_output(ale_gpio, 0);
  2837. + prv->ale_gpio = ale_gpio;
  2838. +
  2839. + return 0;
  2840. +
  2841. +err:
  2842. + rbppc_nand_free_gpio(prv);
  2843. + return retval;
  2844. +}
  2845. +
  2846. +static int rbppc_nand_probe(struct platform_device *pdev)
  2847. +{
  2848. + struct device *dev = &pdev->dev;
  2849. + struct rbppc_nand_prv *prv;
  2850. + struct mtd_info *mtd;
  2851. + struct nand_chip *chip;
  2852. + struct device_node *dn = dev->of_node;
  2853. + struct device_node *dn_partitions;
  2854. + struct resource res;
  2855. + int rnb_gpio, nce_gpio, cle_gpio, ale_gpio;
  2856. + void __iomem *io_addr;
  2857. + void __iomem *sync_addr;
  2858. + struct mtd_part_parser_data pp_data;
  2859. + int retval;
  2860. +
  2861. + printk(KERN_INFO "MikroTik RouterBOARD NAND driver for "
  2862. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2863. +
  2864. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2865. + if (!prv) {
  2866. + dev_err(dev, "Can't allocate memory!\n");
  2867. + return -ENOMEM;
  2868. + }
  2869. +
  2870. + prv->dev = dev;
  2871. +
  2872. + chip = &prv->chip;
  2873. + chip->priv = prv;
  2874. +
  2875. + mtd = &prv->mtd;
  2876. + mtd->name = DRV_NAME;
  2877. + mtd->priv = chip;
  2878. + mtd->owner = THIS_MODULE;
  2879. +
  2880. + rnb_gpio = of_get_gpio(dn, 0);
  2881. + if (!gpio_is_valid(rnb_gpio)) {
  2882. + dev_err(dev, "No R/B GPIO (0) found\n");
  2883. + return rnb_gpio;
  2884. + }
  2885. +
  2886. + nce_gpio = of_get_gpio(dn, 1);
  2887. + if (!gpio_is_valid(nce_gpio)) {
  2888. + dev_err(dev, "No nCE GPIO (1) found\n");
  2889. + return nce_gpio;
  2890. + }
  2891. +
  2892. + cle_gpio = of_get_gpio(dn, 2);
  2893. + if (!gpio_is_valid(cle_gpio)) {
  2894. + dev_err(dev, "No CLE GPIO (2) found\n");
  2895. + return cle_gpio;
  2896. + }
  2897. +
  2898. + ale_gpio = of_get_gpio(dn, 3);
  2899. + if (!gpio_is_valid(ale_gpio)) {
  2900. + dev_err(dev, "No ALE GPIO (3) found\n");
  2901. + return ale_gpio;
  2902. + }
  2903. +
  2904. + retval = rbppc_nand_probe_gpio(prv, rnb_gpio, nce_gpio, cle_gpio, ale_gpio);
  2905. + if (retval)
  2906. + return retval;
  2907. +
  2908. + /*
  2909. + * Allocate IO resource.
  2910. + */
  2911. + retval = of_address_to_resource(dn, 0, &res);
  2912. + if (retval) {
  2913. + dev_err(dev, "No reg property found for IO (0)\n");
  2914. + goto err_after_probe_gpio;
  2915. + }
  2916. +
  2917. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1, DRV_NAME)) {
  2918. + dev_err(dev, "Could not reserve NAND memory\n");
  2919. + retval = -EBUSY;
  2920. + goto err_after_probe_gpio;
  2921. + }
  2922. +
  2923. + io_addr = devm_ioremap_nocache(dev, res.start, res.end - res.start + 1);
  2924. + if (!io_addr) {
  2925. + dev_err(dev, "Could not map NAND memory\n");
  2926. + retval = -ENOMEM;
  2927. + goto err_after_probe_gpio;
  2928. + }
  2929. +
  2930. + /*
  2931. + * Allocate sync resource.
  2932. + */
  2933. + retval = of_address_to_resource(dn, 1, &res);
  2934. + if (retval) {
  2935. + dev_err(dev, "No reg property found for sync (1)\n");
  2936. + goto err_after_probe_gpio;
  2937. + }
  2938. +
  2939. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1, DRV_NAME)) {
  2940. + dev_err(dev, "Could not reserve sync memory\n");
  2941. + retval = -EBUSY;
  2942. + goto err_after_probe_gpio;
  2943. + }
  2944. +
  2945. + sync_addr = devm_ioremap_nocache(dev, res.start, res.end - res.start + 1);
  2946. + if (!sync_addr) {
  2947. + dev_err(dev, "Could not map sync memory\n");
  2948. + retval = -ENOMEM;
  2949. + goto err_after_probe_gpio;
  2950. + }
  2951. +
  2952. + chip->dev_ready = rbppc_nand_dev_ready;
  2953. + chip->cmd_ctrl = rbppc_nand_cmd_ctrl;
  2954. + chip->read_buf = rbppc_nand_read_buf;
  2955. + chip->write_buf = rbppc_nand_write_buf;
  2956. + chip->IO_ADDR_W = io_addr;
  2957. + chip->IO_ADDR_R = io_addr;
  2958. + chip->chip_delay = 25;
  2959. + chip->ecc.mode = NAND_ECC_SOFT;
  2960. + chip->ecc.layout = &rbppc_nand_oob_16;
  2961. +
  2962. + prv->cmd_sync = sync_addr;
  2963. +
  2964. + retval = nand_scan(mtd, 1);
  2965. + if (retval) {
  2966. + dev_err(dev, "RouterBOARD NAND device not found\n");
  2967. + goto err_after_probe_gpio;
  2968. + }
  2969. +
  2970. + /*
  2971. + * Parse partitions and register device.
  2972. + */
  2973. + dn_partitions = of_get_next_child(dn, NULL);
  2974. +
  2975. + pp_data.of_node = dn_partitions;
  2976. + retval = mtd_device_parse_register(&prv->mtd, NULL, &pp_data, NULL, 0);
  2977. + of_node_put(dn_partitions);
  2978. + if (retval) {
  2979. + dev_err(dev, "Could not register new MTD device\n");
  2980. + goto err_after_probe_gpio;
  2981. + }
  2982. +
  2983. + dev_set_drvdata(dev, prv);
  2984. +
  2985. + return 0;
  2986. +
  2987. +err_after_probe_gpio:
  2988. + rbppc_nand_free_gpio(prv);
  2989. + return retval;
  2990. +}
  2991. +
  2992. +static int rbppc_nand_remove(struct platform_device *pdev)
  2993. +{
  2994. + struct device *dev = &pdev->dev;
  2995. + struct rbppc_nand_prv *prv = dev_get_drvdata(dev);
  2996. +
  2997. + nand_release(&prv->mtd);
  2998. + rbppc_nand_free_gpio(prv);
  2999. +
  3000. + dev_set_drvdata(dev, NULL);
  3001. +
  3002. + return 0;
  3003. +}
  3004. +
  3005. +static struct of_device_id rbppc_nand_ids[] = {
  3006. + { .compatible = "rb,nand", },
  3007. + {},
  3008. +};
  3009. +
  3010. +static struct platform_driver rbppc_nand_driver = {
  3011. + .probe = rbppc_nand_probe,
  3012. + .remove = rbppc_nand_remove,
  3013. + .driver = {
  3014. + .name = "rbppc-nand",
  3015. + .owner = THIS_MODULE,
  3016. + .of_match_table = rbppc_nand_ids,
  3017. + },
  3018. +};
  3019. +
  3020. +static int __init rbppc_nand_init(void)
  3021. +{
  3022. + return platform_driver_register(&rbppc_nand_driver);
  3023. +}
  3024. +
  3025. +static void __exit rbppc_nand_exit(void)
  3026. +{
  3027. + platform_driver_unregister(&rbppc_nand_driver);
  3028. +}
  3029. +
  3030. +MODULE_AUTHOR("Mikrotikls SIA");
  3031. +MODULE_AUTHOR("Noah Fontes");
  3032. +MODULE_AUTHOR("Michael Guntsche");
  3033. +MODULE_DESCRIPTION("MikroTik RouterBOARD NAND driver for MPC83xx/MPC85xx-based platforms");
  3034. +MODULE_LICENSE("GPL");
  3035. +MODULE_VERSION(DRV_VERSION);
  3036. +
  3037. +module_init(rbppc_nand_init);
  3038. +module_exit(rbppc_nand_exit);