rbppc.patch 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046
  1. diff -Nur linux-4.4.302.orig/arch/powerpc/boot/dts/rb333.dts linux-4.4.302/arch/powerpc/boot/dts/rb333.dts
  2. --- linux-4.4.302.orig/arch/powerpc/boot/dts/rb333.dts 1970-01-01 01:00:00.000000000 +0100
  3. +++ linux-4.4.302/arch/powerpc/boot/dts/rb333.dts 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/boot/dts/rb600.dts linux-4.4.302/arch/powerpc/boot/dts/rb600.dts
  461. --- linux-4.4.302.orig/arch/powerpc/boot/dts/rb600.dts 1970-01-01 01:00:00.000000000 +0100
  462. +++ linux-4.4.302/arch/powerpc/boot/dts/rb600.dts 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/boot/Makefile linux-4.4.302/arch/powerpc/boot/Makefile
  809. --- linux-4.4.302.orig/arch/powerpc/boot/Makefile 2022-02-03 09:27:54.000000000 +0100
  810. +++ linux-4.4.302/arch/powerpc/boot/Makefile 2026-04-25 20:56:36.237233987 +0200
  811. @@ -115,6 +115,8 @@
  812. src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
  813. src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += 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. @@ -276,9 +278,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-4.4.302.orig/arch/powerpc/boot/rbppc.c linux-4.4.302/arch/powerpc/boot/rbppc.c
  831. --- linux-4.4.302.orig/arch/powerpc/boot/rbppc.c 1970-01-01 01:00:00.000000000 +0100
  832. +++ linux-4.4.302/arch/powerpc/boot/rbppc.c 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/boot/wrapper linux-4.4.302/arch/powerpc/boot/wrapper
  1030. --- linux-4.4.302.orig/arch/powerpc/boot/wrapper 2022-02-03 09:27:54.000000000 +0100
  1031. +++ linux-4.4.302/arch/powerpc/boot/wrapper 2026-04-25 20:56:36.237233987 +0200
  1032. @@ -278,6 +278,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-4.4.302.orig/arch/powerpc/Kconfig linux-4.4.302/arch/powerpc/Kconfig
  1045. --- linux-4.4.302.orig/arch/powerpc/Kconfig 2022-02-03 09:27:54.000000000 +0100
  1046. +++ linux-4.4.302/arch/powerpc/Kconfig 2026-04-25 20:56:36.237233987 +0200
  1047. @@ -793,6 +793,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-4.4.302.orig/arch/powerpc/platforms/83xx/Kconfig linux-4.4.302/arch/powerpc/platforms/83xx/Kconfig
  1057. --- linux-4.4.302.orig/arch/powerpc/platforms/83xx/Kconfig 2022-02-03 09:27:54.000000000 +0100
  1058. +++ linux-4.4.302/arch/powerpc/platforms/83xx/Kconfig 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/platforms/83xx/Makefile linux-4.4.302/arch/powerpc/platforms/83xx/Makefile
  1090. --- linux-4.4.302.orig/arch/powerpc/platforms/83xx/Makefile 2022-02-03 09:27:54.000000000 +0100
  1091. +++ linux-4.4.302/arch/powerpc/platforms/83xx/Makefile 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/platforms/83xx/rb333.c linux-4.4.302/arch/powerpc/platforms/83xx/rb333.c
  1104. --- linux-4.4.302.orig/arch/powerpc/platforms/83xx/rb333.c 1970-01-01 01:00:00.000000000 +0100
  1105. +++ linux-4.4.302/arch/powerpc/platforms/83xx/rb333.c 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/platforms/83xx/rb600.c linux-4.4.302/arch/powerpc/platforms/83xx/rb600.c
  1247. --- linux-4.4.302.orig/arch/powerpc/platforms/83xx/rb600.c 1970-01-01 01:00:00.000000000 +0100
  1248. +++ linux-4.4.302/arch/powerpc/platforms/83xx/rb600.c 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/sysdev/Makefile linux-4.4.302/arch/powerpc/sysdev/Makefile
  1384. --- linux-4.4.302.orig/arch/powerpc/sysdev/Makefile 2022-02-03 09:27:54.000000000 +0100
  1385. +++ linux-4.4.302/arch/powerpc/sysdev/Makefile 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/arch/powerpc/sysdev/rbppc_pci.c linux-4.4.302/arch/powerpc/sysdev/rbppc_pci.c
  1395. --- linux-4.4.302.orig/arch/powerpc/sysdev/rbppc_pci.c 1970-01-01 01:00:00.000000000 +0100
  1396. +++ linux-4.4.302/arch/powerpc/sysdev/rbppc_pci.c 2026-04-25 20:56:36.237233987 +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-4.4.302.orig/drivers/ata/Kconfig linux-4.4.302/drivers/ata/Kconfig
  1458. --- linux-4.4.302.orig/drivers/ata/Kconfig 2022-02-03 09:27:54.000000000 +0100
  1459. +++ linux-4.4.302/drivers/ata/Kconfig 2026-04-26 00:13:34.561901488 +0200
  1460. @@ -996,6 +996,13 @@
  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
  1466. + help
  1467. + This option enables support for PATA devices on MikroTik RouterBOARD
  1468. + Freescale MPC83xx/MPC85xx-based platforms, such as RB600 and RB800.
  1469. +
  1470. comment "Generic fallback / legacy drivers"
  1471. config PATA_ACPI
  1472. diff -Nur linux-4.4.302.orig/drivers/ata/Makefile linux-4.4.302/drivers/ata/Makefile
  1473. --- linux-4.4.302.orig/drivers/ata/Makefile 2022-02-03 09:27:54.000000000 +0100
  1474. +++ linux-4.4.302/drivers/ata/Makefile 2026-04-25 20:56:36.237233987 +0200
  1475. @@ -101,6 +101,7 @@
  1476. obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
  1477. obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o
  1478. obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o
  1479. +obj-$(CONFIG_PATA_RBPPC_UPM) += pata_rbppc_upm.o
  1480. obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o
  1481. obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o
  1482. diff -Nur linux-4.4.302.orig/drivers/ata/pata_rbppc_upm.c linux-4.4.302/drivers/ata/pata_rbppc_upm.c
  1483. --- linux-4.4.302.orig/drivers/ata/pata_rbppc_upm.c 1970-01-01 01:00:00.000000000 +0100
  1484. +++ linux-4.4.302/drivers/ata/pata_rbppc_upm.c 2026-04-25 20:56:36.237233987 +0200
  1485. @@ -0,0 +1,866 @@
  1486. +/*
  1487. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  1488. + * Copyright (C) Mikrotik 2007
  1489. + *
  1490. + * This program is free software; you can redistribute it and/or modify it
  1491. + * under the terms of the GNU General Public License as published by the
  1492. + * Free Software Foundation; either version 2 of the License, or (at your
  1493. + * option) any later version.
  1494. + */
  1495. +
  1496. +#include <linux/kernel.h>
  1497. +#include <linux/slab.h>
  1498. +#include <linux/module.h>
  1499. +#include <linux/libata.h>
  1500. +#include <linux/of_platform.h>
  1501. +#include <linux/of_address.h>
  1502. +#include <linux/of_irq.h>
  1503. +
  1504. +#include <asm/fsl_lbc.h>
  1505. +
  1506. +#define DRV_NAME "pata_rbppc_upm"
  1507. +#define DRV_VERSION "0.1.0"
  1508. +
  1509. +/*
  1510. + * Constants related to M[ABC]MR UPM operation.
  1511. + *
  1512. + * These might belong in fsl_upm.h.
  1513. + */
  1514. +#define MxMR_OP 0x30000000 /* Operation mask */
  1515. +#define MxMR_RLF_SHIFT 14 /* Read loop field */
  1516. +#define MxMR_WLF_SHIFT 10 /* Write loop field */
  1517. +
  1518. +/*
  1519. + * UPM programming constants.
  1520. + *
  1521. + * Some of these also probably belong in fsl_upm.h (aliased to more suitable
  1522. + * names, like those found in the MPC83xx documentation).
  1523. + */
  1524. +#define INST_N_BASE 0x00f00000 /* G0L, LGPL0 negated, first half
  1525. + phase */
  1526. +#define INST_N_CS 0xf0000000 /* Chip-select timing (LCSn) mask */
  1527. +#define INST_N_CS_H1 0xc0000000 /* CST1/2, first half phase */
  1528. +#define INST_N_CS_H2 0x30000000 /* CST3/4, second half phase */
  1529. +#define INST_N_WE 0x0f000000 /* Byte-select timing (LBSn) mask */
  1530. +#define INST_N_WE_H1 0x0c000000 /* BST1/2, first half phase */
  1531. +#define INST_N_WE_H2 0x03000000 /* BST3/4, second half phase */
  1532. +#define INST_N_OE 0x00030000 /* G2 (LGPL2) mask */
  1533. +#define INST_N_OE_H1 0x00020000 /* G2T1, first half phase */
  1534. +#define INST_N_OE_H2 0x00010000 /* G2T3, second half phase */
  1535. +#define INST_WAEN 0x00001000 /* Enable LUPWAIT */
  1536. +#define INST_REDO_2 0x00000100 /* REDO 2x */
  1537. +#define INST_REDO_3 0x00000200 /* REDO 3x */
  1538. +#define INST_REDO_4 0x00000300 /* REDO 4x */
  1539. +#define INST_LOOP 0x00000080 /* First time LOOP is set starts,
  1540. + next ends */
  1541. +#define INST_NA 0x00000008 /* Next burst address */
  1542. +#define INST_UTA 0x00000004 /* Transfer acknowledge */
  1543. +#define INST_LAST 0x00000001 /* End of pattern */
  1544. +
  1545. +#define INST_READ_BASE (INST_N_BASE | INST_N_WE)
  1546. +#define INST_WRITE_BASE (INST_N_BASE | INST_N_OE)
  1547. +#define INST_EMPTY (INST_N_BASE | INST_N_CS | INST_N_OE | INST_N_WE | INST_LAST)
  1548. +
  1549. +#define X_INST_TABLE_END 0
  1550. +#define X_INST_ANOTHER_TIMING 1
  1551. +
  1552. +#define OA_CPUIN_MIN (1 << 0)
  1553. +#define OA_CPUOUT_MAX (1 << 1)
  1554. +#define OD_CPUOUT_MIN (1 << 2)
  1555. +#define OA_CPUOUT_DELTA (OD_CPUOUT_MIN | OA_CPUOUT_MAX)
  1556. +#define OA_EXTDEL_MAX (1 << 3)
  1557. +#define OD_EXTDEL_MIN (1 << 4)
  1558. +#define OA_EXTDEL_DELTA (OD_EXTDEL_MIN | OA_EXTDEL_MAX)
  1559. +#define O_MIN_CYCLE_TIME (1 << 5)
  1560. +#define O_MINUS_PREV (1 << 6)
  1561. +#define O_HALF_CYCLE (1 << 7)
  1562. +
  1563. +#define REDOS(mult) (INST_REDO_2 * ((mult) - 1))
  1564. +#define REDO_MAX_MULT 4
  1565. +
  1566. +#define LOOPS 4
  1567. +
  1568. +/*
  1569. + * This is extremely convoluted code that does some sort of alignment with what
  1570. + * appears to be arbitrary memory offsets. It used to be part of rb_iomap.c, but
  1571. + * it was only used for ATA operations so it's been migrated here instead (where
  1572. + * it might actually make some small amount of sense).
  1573. + */
  1574. +#define REG_OFFSET(base, reg) ((base) + (((reg) << 16) | ((((reg) ^ 8) & 8) << 17)))
  1575. +
  1576. +/*
  1577. + * Since multiple ATA hosts use the same UPM, we need to make sure we only
  1578. + * program a UPM to operate in a higher PIO mode when all hosts registered on
  1579. + * that UPM are ready to use that mode. Otherwise, we have to pick the lowest
  1580. + * mode that all of them support and generate timings from there.
  1581. + */
  1582. +struct pata_rbppc_upm_pio_status {
  1583. + int configured_mode;
  1584. + int actual_mode;
  1585. + struct pata_rbppc_upm_prv *prv;
  1586. +
  1587. + struct pata_rbppc_upm_pio_status *next;
  1588. +};
  1589. +
  1590. +static DEFINE_MUTEX(pio_status_mutex);
  1591. +
  1592. +static struct pata_rbppc_upm_pio_status *pio_statuses = NULL;
  1593. +
  1594. +/*
  1595. + * These represent custom additional board-specific timings specified in the
  1596. + * device tree.
  1597. + */
  1598. +struct pata_rbppc_upm_localbus_timing {
  1599. + u32 cpuin_min;
  1600. + u32 cpuout_min;
  1601. + u32 cpuout_max;
  1602. + u32 extdel_min;
  1603. + u32 extdel_max;
  1604. +};
  1605. +
  1606. +struct pata_rbppc_upm_prv {
  1607. + struct fsl_upm upm;
  1608. + u32 timing;
  1609. + struct pata_rbppc_upm_localbus_timing localbus_timings;
  1610. + int irq;
  1611. + struct pata_rbppc_upm_pio_status pio_status;
  1612. +
  1613. + struct fsl_lbc_ctrl *ctrl;
  1614. + struct ata_host *host;
  1615. +
  1616. + struct device *dev;
  1617. +};
  1618. +
  1619. +#define UPM_P_RSS 0x00 /* Read single-beat */
  1620. +#define UPM_P_RBS 0x08 /* Read burst */
  1621. +#define UPM_P_WSS 0x18 /* Write single-beat */
  1622. +#define UPM_P_WBS 0x20 /* Write burst */
  1623. +#define UPM_P_RTS 0x30 /* Refresh timer */
  1624. +#define UPM_P_EXS 0x3c /* Exception condition */
  1625. +#define UPM_P_SIZE 0x40 /* UPM program RAM is 64 32-bit words */
  1626. +
  1627. +struct pata_rbppc_upm_program {
  1628. + u32 program[UPM_P_SIZE];
  1629. + void __iomem *io_addr;
  1630. +};
  1631. +
  1632. +struct pata_rbppc_upm_cfg {
  1633. + unsigned value;
  1634. + unsigned timings[7]; /* PIO modes 0 - 6, in nanoseconds */
  1635. + unsigned clk_minus;
  1636. + unsigned group_size;
  1637. + unsigned options;
  1638. +};
  1639. +
  1640. +static const struct pata_rbppc_upm_cfg pata_rbppc_upm_read_table[] = {
  1641. + { INST_READ_BASE | INST_N_OE,
  1642. + /* t1 - ADDR setup time */
  1643. + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1644. + OA_EXTDEL_MAX) },
  1645. + { INST_READ_BASE | INST_N_OE_H1,
  1646. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1647. + { INST_READ_BASE,
  1648. + /* t2 - OE0 time */
  1649. + { 290, 290, 290, 80, 70, 65, 55 }, 0, 2, (OA_CPUOUT_MAX |
  1650. + OA_CPUIN_MIN) },
  1651. + { INST_READ_BASE | INST_WAEN,
  1652. + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
  1653. + { INST_READ_BASE | INST_UTA,
  1654. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1655. + { INST_READ_BASE | INST_N_OE,
  1656. + /* t9 - ADDR hold time */
  1657. + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1658. + OD_EXTDEL_MIN) },
  1659. + { INST_READ_BASE | INST_N_OE | INST_N_CS_H2,
  1660. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1661. + { INST_READ_BASE | INST_N_OE | INST_N_CS,
  1662. + /* t6Z -IORD data tristate */
  1663. + { 30, 30, 30, 30, 30, 20, 20 }, 1, 1, O_MINUS_PREV },
  1664. + { X_INST_ANOTHER_TIMING,
  1665. + /* t2i -IORD recovery time */
  1666. + { 0, 0, 0, 70, 25, 25, 20 }, 2, 0, 0 },
  1667. + { X_INST_ANOTHER_TIMING,
  1668. + /* CS 0 -> 1 MAX */
  1669. + { 0, 0, 0, 0, 0, 0, 0 }, 1, 0, (OA_CPUOUT_DELTA |
  1670. + OA_EXTDEL_MAX) },
  1671. + { INST_READ_BASE | INST_N_OE | INST_N_CS | INST_LAST,
  1672. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1673. + { X_INST_TABLE_END,
  1674. + /* min total cycle time - includes turnaround and ALE cycle */
  1675. + { 600, 383, 240, 180, 120, 100, 80 }, 2, 0, O_MIN_CYCLE_TIME },
  1676. +};
  1677. +
  1678. +static const struct pata_rbppc_upm_cfg pata_rbppc_upm_write_table[] = {
  1679. + { INST_WRITE_BASE | INST_N_WE,
  1680. + /* t1 - ADDR setup time */
  1681. + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1682. + OA_EXTDEL_MAX) },
  1683. + { INST_WRITE_BASE | INST_N_WE_H1,
  1684. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1685. + { INST_WRITE_BASE,
  1686. + /* t2 - WE0 time */
  1687. + { 290, 290, 290, 80, 70, 65, 55 }, 0, 1, OA_CPUOUT_DELTA },
  1688. + { INST_WRITE_BASE | INST_WAEN,
  1689. + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
  1690. + { INST_WRITE_BASE | INST_N_WE,
  1691. + /* t9 - ADDR hold time */
  1692. + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
  1693. + OD_EXTDEL_MIN) },
  1694. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS_H2,
  1695. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
  1696. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS,
  1697. + /* t4 - DATA hold time */
  1698. + { 30, 20, 15, 10, 10, 10, 10 }, 0, 1, O_MINUS_PREV },
  1699. + { X_INST_ANOTHER_TIMING,
  1700. + /* t2i -IOWR recovery time */
  1701. + { 0, 0, 0, 70, 25, 25, 20 }, 1, 0, 0 },
  1702. + { X_INST_ANOTHER_TIMING,
  1703. + /* CS 0 -> 1 MAX */
  1704. + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, (OA_CPUOUT_DELTA |
  1705. + OA_EXTDEL_MAX) },
  1706. + { INST_WRITE_BASE | INST_N_WE | INST_N_CS | INST_UTA | INST_LAST,
  1707. + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
  1708. + /* min total cycle time - includes ALE cycle */
  1709. + { X_INST_TABLE_END,
  1710. + { 600, 383, 240, 180, 120, 100, 80 }, 1, 0, O_MIN_CYCLE_TIME },
  1711. +};
  1712. +
  1713. +struct __upm_timing {
  1714. + int clk, ps;
  1715. + const struct pata_rbppc_upm_cfg *cfg;
  1716. +};
  1717. +
  1718. +static int __ps_to_clk(int ps, u32 bus_timing) {
  1719. + int ps_over;
  1720. + if (ps <= 0)
  1721. + return 0;
  1722. +
  1723. + /* Round down if we're less than 2% over clk border, but no more than
  1724. + * 1/4 clk cycle. */
  1725. + ps_over = ps * 2 / 100;
  1726. + if (4 * ps_over > bus_timing)
  1727. + ps_over = bus_timing / 4;
  1728. +
  1729. + return (ps + bus_timing - 1 - ps_over) / bus_timing;
  1730. +}
  1731. +
  1732. +static void __upm_table_populate_times(struct __upm_timing *timings, int mode,
  1733. + u32 bus_timing,
  1734. + struct pata_rbppc_upm_localbus_timing *localbus_timings)
  1735. +{
  1736. + int i = 0, group_i = 0;
  1737. + struct __upm_timing *last = NULL, *group = NULL;
  1738. +
  1739. + do {
  1740. + const struct pata_rbppc_upm_cfg *cfg = timings[i].cfg;
  1741. +
  1742. + int ps = cfg->timings[mode] * 1000
  1743. + - cfg->clk_minus * bus_timing;
  1744. +
  1745. + if (cfg->options & OA_CPUIN_MIN)
  1746. + ps += localbus_timings->cpuin_min;
  1747. + if (cfg->options & OD_CPUOUT_MIN)
  1748. + ps -= localbus_timings->cpuout_min;
  1749. + if (cfg->options & OA_CPUOUT_MAX)
  1750. + ps += localbus_timings->cpuout_max;
  1751. + if (cfg->options & OD_EXTDEL_MIN)
  1752. + ps -= localbus_timings->extdel_min;
  1753. + if (cfg->options & OA_EXTDEL_MAX)
  1754. + ps += localbus_timings->extdel_max;
  1755. +
  1756. + if (last && cfg->value == X_INST_ANOTHER_TIMING) {
  1757. + if (last->ps < ps)
  1758. + last->ps = ps;
  1759. +
  1760. + timings[i].ps = 0;
  1761. + } else {
  1762. + if (cfg->group_size) {
  1763. + group = &timings[i];
  1764. + group_i = cfg->group_size;
  1765. + } else if (group && group_i > 0) {
  1766. + int clk = __ps_to_clk(ps, bus_timing);
  1767. + group->ps -= clk * bus_timing;
  1768. + group_i--;
  1769. + }
  1770. +
  1771. + if (cfg->options & O_MINUS_PREV) {
  1772. + int clk = __ps_to_clk(last->ps, bus_timing);
  1773. + ps -= clk * bus_timing;
  1774. + }
  1775. +
  1776. + timings[i].ps = ps;
  1777. + last = &timings[i];
  1778. + }
  1779. + } while (timings[i++].cfg->value != X_INST_TABLE_END);
  1780. +}
  1781. +
  1782. +static inline int __free_half(struct __upm_timing *timing, u32 bus_timing)
  1783. +{
  1784. + return timing->clk < 2
  1785. + ? 0
  1786. + : (timing->clk * bus_timing - timing->ps) * 2 >= bus_timing;
  1787. +}
  1788. +
  1789. +static void __upm_table_populate_clks(struct __upm_timing *timings,
  1790. + u32 bus_timing)
  1791. +{
  1792. + int i;
  1793. + int clk_total = 0;
  1794. +
  1795. + /*
  1796. + * Convert picoseconds determined from table/local bus timings to actual
  1797. + * clock cycles.
  1798. + */
  1799. + for (i = 0; timings[i].cfg->value != X_INST_TABLE_END; i++) {
  1800. + timings[i].clk = __ps_to_clk(timings[i].ps, bus_timing);
  1801. + clk_total += timings[i].clk;
  1802. + }
  1803. +
  1804. + /*
  1805. + * Check whether we have free half cycles surrounding an operation.
  1806. + *
  1807. + * We need at least three operations in the table for this to make
  1808. + * sense.
  1809. + */
  1810. + if (i >= 2) {
  1811. + int j;
  1812. +
  1813. + for (j = 1; timings[j + 1].cfg->value != X_INST_TABLE_END;
  1814. + j++) {
  1815. + if (timings[j].cfg->options & O_HALF_CYCLE &&
  1816. + __free_half(&timings[j - 1], bus_timing) &&
  1817. + __free_half(&timings[j + 1], bus_timing)) {
  1818. + timings[j].clk++;
  1819. + timings[j - 1].clk--;
  1820. + timings[j + 1].clk--;
  1821. + }
  1822. + }
  1823. + }
  1824. +
  1825. + /*
  1826. + * Finally see if we need to adjust any timings to meet the minimum
  1827. + * requirements for standards.
  1828. + */
  1829. + if (timings[i].cfg->options & O_MIN_CYCLE_TIME) {
  1830. + int j = 0;
  1831. +
  1832. + timings[i].clk = __ps_to_clk(timings[i].ps, bus_timing);
  1833. +
  1834. + while (clk_total < timings[i].clk) {
  1835. + if (timings[j].cfg->value == X_INST_TABLE_END)
  1836. + j = 0;
  1837. +
  1838. + if (timings[j].clk > 0) {
  1839. + timings[j].clk++;
  1840. + clk_total++;
  1841. + }
  1842. +
  1843. + j++;
  1844. + }
  1845. + }
  1846. +}
  1847. +
  1848. +static void __upm_table_populate_value(u32 value, int *clk, u32 **program)
  1849. +{
  1850. + if (*clk == 0)
  1851. + /* Nothing to do. */;
  1852. + else if (*clk >= LOOPS * 2) {
  1853. + int times, times_r1, times_r2;
  1854. +
  1855. + times = *clk / LOOPS;
  1856. + if (times > REDO_MAX_MULT * 2)
  1857. + times = REDO_MAX_MULT * 2;
  1858. +
  1859. + times_r1 = times / 2;
  1860. + times_r2 = times - times_r1;
  1861. +
  1862. + value |= INST_LOOP;
  1863. + **program = value | REDOS(times_r1);
  1864. + (*program)++;
  1865. + **program = value | REDOS(times_r2);
  1866. + (*program)++;
  1867. +
  1868. + *clk -= times * LOOPS;
  1869. + } else {
  1870. + int clk_for_value = *clk < REDO_MAX_MULT ? *clk : REDO_MAX_MULT;
  1871. +
  1872. + value |= REDOS(clk_for_value);
  1873. + *clk -= clk_for_value;
  1874. +
  1875. + **program = value;
  1876. + (*program)++;
  1877. + }
  1878. +}
  1879. +
  1880. +static void __upm_table_populate_values(struct __upm_timing *timings,
  1881. + struct pata_rbppc_upm_program *program,
  1882. + int offset)
  1883. +{
  1884. + int i;
  1885. +
  1886. + u32 *wr = &program->program[offset];
  1887. + for (i = 0; timings[i].cfg->value != X_INST_TABLE_END; i++) {
  1888. + int clk = timings[i].clk;
  1889. + while (clk > 0)
  1890. + __upm_table_populate_value(timings[i].cfg->value, &clk,
  1891. + &wr);
  1892. + }
  1893. +}
  1894. +
  1895. +static int __upm_table_to_program(struct pata_rbppc_upm_prv *prv,
  1896. + struct __upm_timing *timings, int mode,
  1897. + struct pata_rbppc_upm_program *program,
  1898. + int offset)
  1899. +{
  1900. + __upm_table_populate_times(timings, mode, prv->timing,
  1901. + &prv->localbus_timings);
  1902. + __upm_table_populate_clks(timings, prv->timing);
  1903. + __upm_table_populate_values(timings, program, offset);
  1904. +
  1905. + return 0;
  1906. +}
  1907. +
  1908. +static int pata_rbppc_upm_get_program(struct pata_rbppc_upm_prv *prv, int mode,
  1909. + struct pata_rbppc_upm_program *program)
  1910. +{
  1911. + int i;
  1912. + int retval;
  1913. + struct __upm_timing read_timings[ARRAY_SIZE(pata_rbppc_upm_read_table)];
  1914. + struct __upm_timing write_timings[ARRAY_SIZE(pata_rbppc_upm_write_table)];
  1915. +
  1916. + /*
  1917. + * Initialize program to empty values.
  1918. + */
  1919. + for (i = 0; i < UPM_P_SIZE; i++) {
  1920. + program->program[i] = INST_EMPTY;
  1921. + }
  1922. +
  1923. + /*
  1924. + * Initialize the timing data and map it to our table.
  1925. + */
  1926. +#define INITIALIZE_TIMINGS(timings, table) \
  1927. + do { \
  1928. + int i = 0; \
  1929. + do { \
  1930. + (timings)[i].clk = 0; \
  1931. + (timings)[i].ps = 0; \
  1932. + (timings)[i].cfg = &(table)[i]; \
  1933. + } while ((table)[i++].value != X_INST_TABLE_END); \
  1934. + } while(0)
  1935. + INITIALIZE_TIMINGS(read_timings, pata_rbppc_upm_read_table);
  1936. + INITIALIZE_TIMINGS(write_timings, pata_rbppc_upm_write_table);
  1937. +
  1938. + /*
  1939. + * Build read/write programs from our table structures.
  1940. + */
  1941. + retval = __upm_table_to_program(prv, read_timings, mode, program,
  1942. + UPM_P_RSS);
  1943. + if (retval) {
  1944. + dev_err(prv->dev, "Could not generate read program for PIO "
  1945. + "mode %u\n", mode);
  1946. + return retval;
  1947. + }
  1948. +
  1949. + retval = __upm_table_to_program(prv, write_timings, mode, program,
  1950. + UPM_P_WSS);
  1951. + if (retval) {
  1952. + dev_err(prv->dev, "Could not generate write program for PIO "
  1953. + "mode %u\n", mode);
  1954. + }
  1955. +
  1956. + return 0;
  1957. +}
  1958. +
  1959. +static void pata_rbppc_upm_program(struct pata_rbppc_upm_prv *prv,
  1960. + struct pata_rbppc_upm_program *program)
  1961. +{
  1962. + u32 i;
  1963. +
  1964. + clrsetbits_be32(prv->upm.mxmr, MxMR_MAD, MxMR_OP_WA);
  1965. + in_be32(prv->upm.mxmr);
  1966. +
  1967. + for (i = 0; i < UPM_P_SIZE; i++) {
  1968. + out_be32(&prv->ctrl->regs->mdr, program->program[i]);
  1969. + in_be32(&prv->ctrl->regs->mdr);
  1970. +
  1971. + out_8(program->io_addr, 0x0);
  1972. +
  1973. + while ((in_be32(prv->upm.mxmr) ^ (i + 1)) & MxMR_MAD)
  1974. + cpu_relax();
  1975. + }
  1976. +
  1977. + clrsetbits_be32(prv->upm.mxmr, MxMR_MAD | MxMR_OP,
  1978. + MxMR_OP_NO | (LOOPS << MxMR_RLF_SHIFT) |
  1979. + (LOOPS << MxMR_WLF_SHIFT));
  1980. + in_be32(prv->upm.mxmr);
  1981. +}
  1982. +
  1983. +static int pata_rbppc_upm_program_for_piomode(struct pata_rbppc_upm_prv *prv,
  1984. + int mode)
  1985. +{
  1986. + struct pata_rbppc_upm_program program;
  1987. + int retval;
  1988. +
  1989. + retval = pata_rbppc_upm_get_program(prv, mode, &program);
  1990. + if (retval)
  1991. + return retval;
  1992. +
  1993. + program.io_addr = prv->host->ports[0]->ioaddr.cmd_addr;
  1994. + pata_rbppc_upm_program(prv, &program);
  1995. +
  1996. + return 0;
  1997. +}
  1998. +
  1999. +static void pata_rbppc_upm_set_piomode(struct ata_port *ap, struct ata_device *adev)
  2000. +{
  2001. + struct pata_rbppc_upm_prv *prv = ap->host->private_data;
  2002. + struct pata_rbppc_upm_pio_status *pio_status;
  2003. + int requested_mode = adev->pio_mode - XFER_PIO_0;
  2004. + int actual_mode = requested_mode;
  2005. + int retval;
  2006. +
  2007. + if (requested_mode < 0 || requested_mode > 6) {
  2008. + dev_err(prv->dev, "Illegal PIO mode %u\n", requested_mode);
  2009. + return;
  2010. + }
  2011. +
  2012. + prv->pio_status.configured_mode = requested_mode;
  2013. +
  2014. + mutex_lock(&pio_status_mutex);
  2015. +
  2016. + /*
  2017. + * Find other hosts that are on the same UPM as this one, and make sure
  2018. + * they're all configured for the PIO mode we want.
  2019. + */
  2020. + for (pio_status = pio_statuses; pio_status != NULL;
  2021. + pio_status = pio_status->next) {
  2022. + if (pio_status->prv == prv)
  2023. + continue;
  2024. + else if (pio_status->prv->upm.mxmr == prv->upm.mxmr &&
  2025. + pio_status->configured_mode < actual_mode)
  2026. + actual_mode = pio_status->configured_mode;
  2027. + }
  2028. +
  2029. + if (actual_mode < 0) {
  2030. + dev_info(prv->dev, "Waiting until another device comes up to "
  2031. + "program UPM for new PIO mode\n");
  2032. + goto out;
  2033. + } else if (actual_mode < requested_mode) {
  2034. + dev_info(prv->dev, "Requested PIO mode %u, but UPM can only be "
  2035. + "configured at PIO mode %u\n", requested_mode,
  2036. + actual_mode);
  2037. + }
  2038. +
  2039. + retval = pata_rbppc_upm_program_for_piomode(prv, actual_mode);
  2040. + if (retval) {
  2041. + dev_err(prv->dev, "Could not update PIO mode: %d\n", retval);
  2042. + goto out;
  2043. + }
  2044. +
  2045. + /*
  2046. + * Now update everything on the UPM to have the new actual mode.
  2047. + */
  2048. + for (pio_status = pio_statuses; pio_status != NULL;
  2049. + pio_status = pio_status->next) {
  2050. + if (pio_status->prv->upm.mxmr == prv->upm.mxmr) {
  2051. + pio_status->actual_mode = actual_mode;
  2052. + dev_info(pio_status->prv->dev,
  2053. + "PIO mode changed to %u\n", actual_mode);
  2054. + }
  2055. + }
  2056. +
  2057. +out:
  2058. + mutex_unlock(&pio_status_mutex);
  2059. +}
  2060. +
  2061. +static u8 pata_rbppc_upm_check_status(struct ata_port *ap) {
  2062. + u8 val = ioread8(ap->ioaddr.status_addr);
  2063. + if (val == 0xF9)
  2064. + val = 0x7F;
  2065. + return val;
  2066. +}
  2067. +
  2068. +static u8 pata_rbppc_upm_check_altstatus(struct ata_port *ap) {
  2069. + u8 val = ioread8(ap->ioaddr.altstatus_addr);
  2070. + if (val == 0xF9)
  2071. + val = 0x7F;
  2072. + return val;
  2073. +}
  2074. +
  2075. +static irqreturn_t pata_rbppc_upm_interrupt(int irq, void *dev_instance)
  2076. +{
  2077. + irqreturn_t retval = ata_sff_interrupt(irq, dev_instance);
  2078. + if (retval == IRQ_RETVAL(0)) {
  2079. + struct ata_host *host = dev_instance;
  2080. + struct ata_port *ap = host->ports[0];
  2081. +
  2082. + /* Clear interrupt. */
  2083. + ap->ops->sff_check_status(ap);
  2084. +
  2085. + ata_port_printk(ap, KERN_WARNING, "IRQ %d not handled\n", irq);
  2086. + }
  2087. +
  2088. + return retval;
  2089. +}
  2090. +
  2091. +static struct scsi_host_template pata_rbppc_upm_sht = {
  2092. + ATA_BASE_SHT(DRV_NAME),
  2093. + .dma_boundary = ATA_DMA_BOUNDARY,
  2094. +};
  2095. +
  2096. +static struct ata_port_operations pata_rbppc_upm_port_ops = {
  2097. + .inherits = &ata_sff_port_ops,
  2098. +
  2099. + .set_piomode = pata_rbppc_upm_set_piomode,
  2100. +
  2101. + .sff_check_status = pata_rbppc_upm_check_status,
  2102. + .sff_check_altstatus = pata_rbppc_upm_check_altstatus,
  2103. +};
  2104. +
  2105. +static int pata_rbppc_upm_probe_timings(struct pata_rbppc_upm_prv *prv)
  2106. +{
  2107. + struct device *dev = prv->dev;
  2108. + struct device_node *dn_soc;
  2109. + const u32 *prop;
  2110. + int prop_size;
  2111. + u32 bus_frequency, lcrr_clkdiv;
  2112. + int retval = 0;
  2113. +
  2114. + dn_soc = of_find_node_by_type(NULL, "soc");
  2115. + if (!dn_soc) {
  2116. + dev_err(dev, "Could not find SoC node\n");
  2117. + return -EINVAL;
  2118. + }
  2119. +
  2120. + prop = of_get_property(dn_soc, "bus-frequency", NULL);
  2121. + if (!prop || !*prop) {
  2122. + dev_err(dev, "Could not determine bus frequency\n");
  2123. + retval = -EINVAL;
  2124. + goto out;
  2125. + }
  2126. +
  2127. + bus_frequency = *prop;
  2128. +
  2129. + /*
  2130. + * The actual speed is determined by the ratio between the bus frequency
  2131. + * and the CLKDIV register.
  2132. + */
  2133. + lcrr_clkdiv = (in_be32(&prv->ctrl->regs->lcrr) & LCRR_CLKDIV)
  2134. + >> LCRR_CLKDIV_SHIFT;
  2135. + bus_frequency /= lcrr_clkdiv;
  2136. +
  2137. + /* (picoseconds / kHz) */
  2138. + prv->timing = 1000000000 / (bus_frequency / 1000);
  2139. +
  2140. + /*
  2141. + * Additional timings are set up in the device node itself, also in
  2142. + * picoseconds.
  2143. + */
  2144. + prop = of_get_property(dev->of_node, "rb,pata-upm-localbus-timings",
  2145. + &prop_size);
  2146. + if (prop && prop_size == 5 * sizeof(u32)) {
  2147. + prv->localbus_timings.cpuin_min = prop[0];
  2148. + prv->localbus_timings.cpuout_min = prop[1];
  2149. + prv->localbus_timings.cpuout_max = prop[2];
  2150. + prv->localbus_timings.extdel_min = prop[3];
  2151. + prv->localbus_timings.extdel_max = prop[4];
  2152. + }
  2153. +
  2154. +out:
  2155. + of_node_put(dn_soc);
  2156. + return retval;
  2157. +}
  2158. +
  2159. +static int pata_rbppc_upm_probe(struct platform_device *pdev)
  2160. +{
  2161. + struct device *dev = &pdev->dev;
  2162. + struct pata_rbppc_upm_prv *prv;
  2163. + struct ata_host *host;
  2164. + struct ata_port *ap;
  2165. + struct ata_ioports *aio;
  2166. + struct device_node *dn = dev->of_node;
  2167. + struct resource res;
  2168. + void __iomem *io_addr;
  2169. + int retval;
  2170. +
  2171. + printk(KERN_INFO "MikroTik RouterBOARD UPM PATA driver for "
  2172. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2173. +
  2174. + if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
  2175. + return -ENODEV;
  2176. +
  2177. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2178. + if (!prv) {
  2179. + dev_err(dev, "Can't allocate memory!\n");
  2180. + return -ENOMEM;
  2181. + }
  2182. +
  2183. + prv->ctrl = fsl_lbc_ctrl_dev;
  2184. + prv->dev = dev;
  2185. +
  2186. + retval = pata_rbppc_upm_probe_timings(prv);
  2187. + if (retval) {
  2188. + dev_err(dev, "Could not initialize timing data from SoC\n");
  2189. + return retval;
  2190. + }
  2191. +
  2192. + retval = of_address_to_resource(dn, 0, &res);
  2193. + if (retval) {
  2194. + dev_err(dev, "No reg property found\n");
  2195. + return retval;
  2196. + }
  2197. +
  2198. + retval = fsl_upm_find(res.start, &prv->upm);
  2199. + if (retval) {
  2200. + dev_err(dev, "Could not find UPM\n");
  2201. + return retval;
  2202. + }
  2203. +
  2204. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1,
  2205. + DRV_NAME)) {
  2206. + dev_err(dev, "Could not request region\n");
  2207. + return -EBUSY;
  2208. + }
  2209. +
  2210. + io_addr = devm_ioremap(dev, res.start, res.end - res.start + 1);
  2211. + if (!io_addr) {
  2212. + dev_err(dev, "Could not map IO region\n");
  2213. + return -ENOMEM;
  2214. + }
  2215. +
  2216. + host = ata_host_alloc(dev, 1);
  2217. + if (!host) {
  2218. + dev_err(dev, "Can't allocate memory!\n");
  2219. + return -ENOMEM;
  2220. + }
  2221. +
  2222. + host->private_data = prv;
  2223. +
  2224. + ap = host->ports[0];
  2225. + ap->ops = &pata_rbppc_upm_port_ops;
  2226. + ap->pio_mask = ATA_PIO6;
  2227. + ap->udma_mask = 0;
  2228. + ap->mwdma_mask = 0;
  2229. +
  2230. + /*
  2231. + * This is sort of halfheartedly based on the extremely strange logic in
  2232. + * rb_iomap.c. I think setting these to the values they eventually get
  2233. + * mapped to (look at localbus_regoff() if you're curious) should
  2234. + * eliminate the need for RouterBOARD-specific iomapping.
  2235. + */
  2236. + aio = &ap->ioaddr;
  2237. + aio->cmd_addr = REG_OFFSET(io_addr, 0);
  2238. + aio->data_addr = REG_OFFSET(io_addr, ATA_REG_DATA);
  2239. + aio->error_addr = REG_OFFSET(io_addr, ATA_REG_ERR);
  2240. + aio->feature_addr = REG_OFFSET(io_addr, ATA_REG_FEATURE);
  2241. + aio->nsect_addr = REG_OFFSET(io_addr, ATA_REG_NSECT);
  2242. + aio->lbal_addr = REG_OFFSET(io_addr, ATA_REG_LBAL);
  2243. + aio->lbam_addr = REG_OFFSET(io_addr, ATA_REG_LBAM);
  2244. + aio->lbah_addr = REG_OFFSET(io_addr, ATA_REG_LBAH);
  2245. + aio->device_addr = REG_OFFSET(io_addr, ATA_REG_DEVICE);
  2246. + aio->status_addr = REG_OFFSET(io_addr, ATA_REG_STATUS);
  2247. + aio->command_addr = REG_OFFSET(io_addr, ATA_REG_CMD);
  2248. + aio->ctl_addr = REG_OFFSET(io_addr, 14);
  2249. + aio->altstatus_addr = aio->ctl_addr;
  2250. +
  2251. + prv->irq = irq_of_parse_and_map(dev->of_node, 0);
  2252. + if (prv->irq == NO_IRQ) {
  2253. + dev_err(dev, "Could not acquire IRQ\n");
  2254. + return -EINVAL;
  2255. + }
  2256. +
  2257. + retval = ata_host_activate(host, prv->irq, pata_rbppc_upm_interrupt,
  2258. + IRQF_TRIGGER_LOW, &pata_rbppc_upm_sht);
  2259. + if (retval) {
  2260. + irq_dispose_mapping(prv->irq);
  2261. + dev_err(dev, "Could not activate ATA host\n");
  2262. + return retval;
  2263. + }
  2264. +
  2265. + prv->host = host;
  2266. +
  2267. + /*
  2268. + * Set up the PIO mode tracking mechanism.
  2269. + */
  2270. + prv->pio_status.configured_mode = -1;
  2271. + prv->pio_status.actual_mode = -1;
  2272. + prv->pio_status.prv = prv;
  2273. +
  2274. + mutex_lock(&pio_status_mutex);
  2275. +
  2276. + prv->pio_status.next = pio_statuses;
  2277. + pio_statuses = &prv->pio_status;
  2278. +
  2279. + mutex_unlock(&pio_status_mutex);
  2280. +
  2281. + return 0;
  2282. +}
  2283. +
  2284. +static int pata_rbppc_upm_remove(struct platform_device *pdev)
  2285. +{
  2286. + struct device *dev = &pdev->dev;
  2287. + struct ata_host *host = dev_get_drvdata(dev);
  2288. + struct pata_rbppc_upm_prv *prv = host->private_data;
  2289. + struct pata_rbppc_upm_pio_status *pio_status;
  2290. +
  2291. + /*
  2292. + * Remove PIO mode tracking.
  2293. + */
  2294. + mutex_lock(&pio_status_mutex);
  2295. +
  2296. + if (!pio_statuses->next)
  2297. + pio_statuses = NULL;
  2298. + else {
  2299. + for (pio_status = pio_statuses; pio_status != NULL;
  2300. + pio_status = pio_status->next) {
  2301. + if (pio_status->next && pio_status->next->prv == prv) {
  2302. + pio_status->next = pio_status->next->next;
  2303. + break;
  2304. + }
  2305. + }
  2306. + }
  2307. +
  2308. + mutex_unlock(&pio_status_mutex);
  2309. +
  2310. + /*
  2311. + * And clean up all the things we allocated. ALL THE THINGS.
  2312. + */
  2313. + ata_host_detach(host);
  2314. + irq_dispose_mapping(prv->irq);
  2315. +
  2316. + return 0;
  2317. +}
  2318. +
  2319. +static struct of_device_id pata_rbppc_upm_ids[] = {
  2320. + { .compatible = "rb,pata-upm", },
  2321. + { },
  2322. +};
  2323. +
  2324. +static struct platform_driver pata_rbppc_upm_driver = {
  2325. + .probe = pata_rbppc_upm_probe,
  2326. + .remove = pata_rbppc_upm_remove,
  2327. + .driver = {
  2328. + .name = "rbppc-upm",
  2329. + .owner = THIS_MODULE,
  2330. + .of_match_table = pata_rbppc_upm_ids,
  2331. + },
  2332. +};
  2333. +
  2334. +static int __init pata_rbppc_upm_init(void)
  2335. +{
  2336. + return platform_driver_register(&pata_rbppc_upm_driver);
  2337. +}
  2338. +
  2339. +static void __exit pata_rbppc_upm_exit(void)
  2340. +{
  2341. + platform_driver_unregister(&pata_rbppc_upm_driver);
  2342. +}
  2343. +
  2344. +MODULE_AUTHOR("Mikrotikls SIA");
  2345. +MODULE_AUTHOR("Noah Fontes");
  2346. +MODULE_DESCRIPTION("MikroTik RouterBOARD UPM PATA driver for MPC83xx/MPC85xx-based platforms");
  2347. +MODULE_LICENSE("GPL");
  2348. +MODULE_VERSION(DRV_VERSION);
  2349. +
  2350. +module_init(pata_rbppc_upm_init);
  2351. +module_exit(pata_rbppc_upm_exit);
  2352. diff -Nur linux-4.4.302.orig/drivers/input/misc/Kconfig linux-4.4.302/drivers/input/misc/Kconfig
  2353. --- linux-4.4.302.orig/drivers/input/misc/Kconfig 2022-02-03 09:27:54.000000000 +0100
  2354. +++ linux-4.4.302/drivers/input/misc/Kconfig 2026-04-25 20:56:36.237233987 +0200
  2355. @@ -796,4 +796,12 @@
  2356. To compile this driver as a module, choose M here: the
  2357. module will be called drv2667-haptics.
  2358. +config INPUT_RBPPC_GTM_BEEPER
  2359. + tristate "MikroTik RouterBOARD GTM speaker support for Freescale MPC83xx/MPC85xx-based platforms"
  2360. + depends on FSL_GTM && PPC_OF && (GPIOLIB || !RB333)
  2361. + help
  2362. + This option enables support for the on-board speaker device on
  2363. + MikroTik RouterBOARD Freescale MPC83xx/MPC85xx-based platforms, such
  2364. + as RB333, RB600, and RB800.
  2365. +
  2366. endif
  2367. diff -Nur linux-4.4.302.orig/drivers/input/misc/Makefile linux-4.4.302/drivers/input/misc/Makefile
  2368. --- linux-4.4.302.orig/drivers/input/misc/Makefile 2022-02-03 09:27:54.000000000 +0100
  2369. +++ linux-4.4.302/drivers/input/misc/Makefile 2026-04-25 20:56:36.237233987 +0200
  2370. @@ -75,3 +75,4 @@
  2371. obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
  2372. obj-$(CONFIG_INPUT_YEALINK) += yealink.o
  2373. obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
  2374. +obj-$(CONFIG_INPUT_RBPPC_GTM_BEEPER) += rbppc_gtm_beeper.o
  2375. diff -Nur linux-4.4.302.orig/drivers/input/misc/rbppc_gtm_beeper.c linux-4.4.302/drivers/input/misc/rbppc_gtm_beeper.c
  2376. --- linux-4.4.302.orig/drivers/input/misc/rbppc_gtm_beeper.c 1970-01-01 01:00:00.000000000 +0100
  2377. +++ linux-4.4.302/drivers/input/misc/rbppc_gtm_beeper.c 2026-04-25 20:56:36.237233987 +0200
  2378. @@ -0,0 +1,260 @@
  2379. +/*
  2380. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  2381. + * Copyright (C) Mikrotik 2007
  2382. + *
  2383. + * This program is free software; you can redistribute it and/or modify it
  2384. + * under the terms of the GNU General Public License as published by the
  2385. + * Free Software Foundation; either version 2 of the License, or (at your
  2386. + * option) any later version.
  2387. + */
  2388. +
  2389. +#include <linux/kernel.h>
  2390. +#include <linux/module.h>
  2391. +#include <linux/init.h>
  2392. +#include <linux/input.h>
  2393. +#include <linux/interrupt.h>
  2394. +#include <linux/gpio.h>
  2395. +#include <linux/of_platform.h>
  2396. +#include <linux/of_gpio.h>
  2397. +
  2398. +#include <asm/fsl_gtm.h>
  2399. +
  2400. +#define DRV_NAME "rbppc_gtm_beeper"
  2401. +#define DRV_VERSION "0.1.0"
  2402. +
  2403. +struct rbppc_gtm_beeper_prv {
  2404. + int gpio, gpio_toggle;
  2405. + int irq;
  2406. +
  2407. + struct gtm_timer *timer;
  2408. + struct input_dev *input;
  2409. +
  2410. + struct device *dev;
  2411. +};
  2412. +
  2413. +static irqreturn_t rbppc_gtm_beeper_interrupt(int irq, void *data)
  2414. +{
  2415. + struct rbppc_gtm_beeper_prv *prv = data;
  2416. +
  2417. + if (gpio_is_valid(prv->gpio)) {
  2418. + gpio_set_value(prv->gpio, prv->gpio_toggle);
  2419. + prv->gpio_toggle ^= 1;
  2420. + }
  2421. +
  2422. + if (prv->timer)
  2423. + gtm_ack_timer16(prv->timer, 0xFFFF);
  2424. +
  2425. + return IRQ_HANDLED;
  2426. +}
  2427. +
  2428. +static int rbppc_gtm_beeper_event(struct input_dev *input, unsigned int type,
  2429. + unsigned int code, int value)
  2430. +{
  2431. + struct rbppc_gtm_beeper_prv *prv = input_get_drvdata(input);
  2432. +
  2433. + if (type != EV_SND || value < 0)
  2434. + return -EINVAL;
  2435. +
  2436. + switch (code) {
  2437. + case SND_BELL:
  2438. + value = value ? 1000 : 0;
  2439. + break;
  2440. + case SND_TONE:
  2441. + break;
  2442. + default:
  2443. + return -EINVAL;
  2444. + }
  2445. +
  2446. + if (value == 0)
  2447. + gtm_stop_timer16(prv->timer);
  2448. + else
  2449. + /*
  2450. + * "reload" is actually "free run", despite what the API
  2451. + * documentation claims.
  2452. + */
  2453. + gtm_set_timer16(prv->timer, value, true);
  2454. +
  2455. + return 0;
  2456. +}
  2457. +
  2458. +static int rbppc_gtm_beeper_probe_input(struct rbppc_gtm_beeper_prv *prv)
  2459. +{
  2460. + int retval = 0;
  2461. +
  2462. + prv->input = input_allocate_device();
  2463. + if (!prv->input) {
  2464. + dev_err(prv->dev, "Can't allocate memory!\n");
  2465. + return -ENOMEM;
  2466. + }
  2467. +
  2468. + prv->input->name = "rbppc-gtm-beeper";
  2469. + prv->input->phys = "rbppc/input0";
  2470. + prv->input->id.bustype = BUS_HOST;
  2471. + prv->input->id.vendor = 0x001f;
  2472. + prv->input->id.product = 0x0001;
  2473. + prv->input->id.version = 0x0100;
  2474. +
  2475. + prv->input->evbit[0] = BIT_MASK(EV_SND);
  2476. + prv->input->sndbit[0] = BIT_MASK(SND_TONE) | BIT_MASK(SND_BELL);
  2477. +
  2478. + prv->input->event = rbppc_gtm_beeper_event;
  2479. +
  2480. + input_set_drvdata(prv->input, prv);
  2481. +
  2482. + retval = input_register_device(prv->input);
  2483. + if (retval) {
  2484. + dev_err(prv->dev, "Could not register input device\n");
  2485. + input_free_device(prv->input);
  2486. + }
  2487. +
  2488. + return retval;
  2489. +}
  2490. +
  2491. +static int rbppc_gtm_beeper_probe(struct platform_device *pdev)
  2492. +{
  2493. + struct device *dev = &pdev->dev;
  2494. + struct device_node *dn_timer, *dn = dev->of_node;
  2495. + struct gtm *gtm;
  2496. + struct rbppc_gtm_beeper_prv *prv;
  2497. + const __be32 *prop;
  2498. + int size, retval;
  2499. +
  2500. + printk(KERN_INFO "MikroTik RouterBOARD GTM speaker driver for "
  2501. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2502. +
  2503. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2504. + if (!prv) {
  2505. + dev_err(dev, "Can't allocate memory!\n");
  2506. + return -ENOMEM;
  2507. + }
  2508. +
  2509. + prv->dev = dev;
  2510. +
  2511. + prop = of_get_property(dn, "timer", &size);
  2512. + if (size != 2 * sizeof(*prop)) {
  2513. + dev_err(dev, "Invalid timer property\n");
  2514. + return -EINVAL;
  2515. + }
  2516. +
  2517. + dn_timer = of_find_node_by_phandle(be32_to_cpu(prop[0]));
  2518. + if (!dn_timer) {
  2519. + dev_err(dev, "No GTM found\n");
  2520. + return -EINVAL;
  2521. + } else if (!dn_timer->data) {
  2522. + /*
  2523. + * The FSL GTM initialization routines map the GTM to the ->data
  2524. + * property of the OF node.
  2525. + */
  2526. + dev_err(dev, "GTM node has not been initialized\n");
  2527. + of_node_put(dn_timer);
  2528. + return -EINVAL;
  2529. + }
  2530. +
  2531. + gtm = dn_timer->data;
  2532. +
  2533. + of_node_put(dn_timer);
  2534. +
  2535. + prv->timer = gtm_get_specific_timer16(gtm, be32_to_cpu(prop[1]));
  2536. + if (IS_ERR(prv->timer)) {
  2537. + dev_err(dev, "Could not request specific timer on GTM\n");
  2538. + return PTR_ERR(prv->timer);
  2539. + }
  2540. +
  2541. + /*
  2542. + * On the RB333, we need to toggle some GPIO pins every time we get an
  2543. + * interrupt.
  2544. + */
  2545. + prv->gpio = -1;
  2546. + if (of_device_is_compatible(dn, "rb,rb333-gtm-beeper")) {
  2547. + int gpio;
  2548. + gpio = of_get_gpio(dn, 0);
  2549. + if (!gpio_is_valid(gpio)) {
  2550. + dev_err(dev, "No GPIO found\n");
  2551. + retval = gpio;
  2552. + goto err_after_get_timer;
  2553. + }
  2554. +
  2555. + retval = gpio_request(gpio, "RouterBOARD Speaker");
  2556. + if (retval) {
  2557. + dev_err(dev, "Couldn't request GPIO for speaker\n");
  2558. + goto err_after_get_timer;
  2559. + }
  2560. + gpio_direction_output(gpio, 0);
  2561. + prv->gpio = gpio;
  2562. + prv->gpio_toggle = 0;
  2563. + }
  2564. +
  2565. + retval = devm_request_irq(dev, prv->timer->irq,
  2566. + rbppc_gtm_beeper_interrupt, 0, DRV_NAME, prv);
  2567. + if (retval) {
  2568. + dev_err(dev, "Could not request IRQ for speaker\n");
  2569. + goto err_after_request_gpio;
  2570. + }
  2571. +
  2572. + retval = rbppc_gtm_beeper_probe_input(prv);
  2573. + if (retval) {
  2574. + dev_err(dev, "Could not create input device for speaker\n");
  2575. + goto err_after_request_gpio;
  2576. + }
  2577. +
  2578. + dev_set_drvdata(dev, prv);
  2579. +
  2580. + return 0;
  2581. +
  2582. +err_after_request_gpio:
  2583. + if (gpio_is_valid(prv->gpio))
  2584. + gpio_free(prv->gpio);
  2585. +err_after_get_timer:
  2586. + gtm_put_timer16(prv->timer);
  2587. + return retval;
  2588. +}
  2589. +
  2590. +static int rbppc_gtm_beeper_remove(struct platform_device *pdev)
  2591. +{
  2592. + struct device *dev = &pdev->dev;
  2593. + struct rbppc_gtm_beeper_prv *prv = dev_get_drvdata(dev);
  2594. +
  2595. + input_unregister_device(prv->input);
  2596. + gtm_put_timer16(prv->timer);
  2597. +
  2598. + if (gpio_is_valid(prv->gpio))
  2599. + gpio_free(prv->gpio);
  2600. +
  2601. + dev_set_drvdata(dev, NULL);
  2602. +
  2603. + return 0;
  2604. +}
  2605. +
  2606. +static struct of_device_id rbppc_gtm_beeper_ids[] = {
  2607. + { .compatible = "rb,gtm-beeper", },
  2608. + { },
  2609. +};
  2610. +
  2611. +static struct platform_driver rbppc_gtm_beeper_driver = {
  2612. + .probe = rbppc_gtm_beeper_probe,
  2613. + .remove = rbppc_gtm_beeper_remove,
  2614. + .driver = {
  2615. + .name = "rbppc-gtm-beeper",
  2616. + .owner = THIS_MODULE,
  2617. + .of_match_table = rbppc_gtm_beeper_ids,
  2618. + },
  2619. +};
  2620. +
  2621. +static int __init rbppc_gtm_beeper_init(void)
  2622. +{
  2623. + return platform_driver_register(&rbppc_gtm_beeper_driver);
  2624. +}
  2625. +
  2626. +static void __exit rbppc_gtm_beeper_exit(void)
  2627. +{
  2628. + platform_driver_unregister(&rbppc_gtm_beeper_driver);
  2629. +}
  2630. +
  2631. +MODULE_AUTHOR("Mikrotikls SIA");
  2632. +MODULE_AUTHOR("Noah Fontes");
  2633. +MODULE_DESCRIPTION("MikroTik RouterBOARD GTM speaker driver for MPC83xx/MPC85xx-based platforms");
  2634. +MODULE_LICENSE("GPL");
  2635. +MODULE_VERSION(DRV_VERSION);
  2636. +
  2637. +module_init(rbppc_gtm_beeper_init);
  2638. +module_exit(rbppc_gtm_beeper_exit);
  2639. diff -Nur linux-4.4.302.orig/drivers/mtd/nand/Kconfig linux-4.4.302/drivers/mtd/nand/Kconfig
  2640. --- linux-4.4.302.orig/drivers/mtd/nand/Kconfig 2022-02-03 09:27:54.000000000 +0100
  2641. +++ linux-4.4.302/drivers/mtd/nand/Kconfig 2026-04-26 00:12:57.389877861 +0200
  2642. @@ -415,6 +415,14 @@
  2643. devices. You will need to provide platform-specific functions
  2644. via platform_data.
  2645. +config MTD_NAND_RBPPC
  2646. + tristate "MikroTik RouterBOARD NAND support for Freescale MPC83xx/MPC85xx-based platforms"
  2647. + depends on GPIOLIB
  2648. + help
  2649. + This option enables support for the NAND device on MikroTik
  2650. + RouterBOARD Freescale MPC83xx/MPC85xx-based platforms, such as RB333,
  2651. + RB600, and RB800.
  2652. +
  2653. config MTD_NAND_ORION
  2654. tristate "NAND Flash support for Marvell Orion SoC"
  2655. depends on PLAT_ORION
  2656. diff -Nur linux-4.4.302.orig/drivers/mtd/nand/Makefile linux-4.4.302/drivers/mtd/nand/Makefile
  2657. --- linux-4.4.302.orig/drivers/mtd/nand/Makefile 2022-02-03 09:27:54.000000000 +0100
  2658. +++ linux-4.4.302/drivers/mtd/nand/Makefile 2026-04-25 20:56:36.237233987 +0200
  2659. @@ -33,6 +33,7 @@
  2660. obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
  2661. obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
  2662. obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  2663. +obj-$(CONFIG_MTD_NAND_RBPPC) += rbppc_nand.o
  2664. obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
  2665. obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
  2666. obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o
  2667. diff -Nur linux-4.4.302.orig/drivers/mtd/nand/rbppc_nand.c linux-4.4.302/drivers/mtd/nand/rbppc_nand.c
  2668. --- linux-4.4.302.orig/drivers/mtd/nand/rbppc_nand.c 1970-01-01 01:00:00.000000000 +0100
  2669. +++ linux-4.4.302/drivers/mtd/nand/rbppc_nand.c 2026-04-25 20:56:36.237233987 +0200
  2670. @@ -0,0 +1,367 @@
  2671. +/*
  2672. + * Copyright (C) 2008-2011 Noah Fontes <nfontes@invectorate.com>
  2673. + * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  2674. + * Copyright (C) Mikrotik 2007
  2675. + *
  2676. + * This program is free software; you can redistribute it and/or modify it
  2677. + * under the terms of the GNU General Public License as published by the
  2678. + * Free Software Foundation; either version 2 of the License, or (at your
  2679. + * option) any later version.
  2680. + *
  2681. + * This is a strange driver indeed. Instead of using a rational layout for
  2682. + * handling NAND operations (like, say, the fsl_upm driver), this driver uses
  2683. + * two separate UPMs plus four pins on GPIO_1. One of the UPMs is responsible
  2684. + * for actual read/write operations; the other one seems to be for ensuring
  2685. + * commands are executed serially (i.e., a sync buffer). It's referred to as as
  2686. + * either "localbus" or "nnand" in MikroTik's own code -- neither name makes
  2687. + * much sense to me. The GPIO is used for R/B and CLE/ALE/nCE.
  2688. + */
  2689. +
  2690. +#include <linux/init.h>
  2691. +#include <linux/slab.h>
  2692. +#include <linux/module.h>
  2693. +#include <linux/gpio.h>
  2694. +#include <linux/io.h>
  2695. +#include <linux/mtd/nand.h>
  2696. +#include <linux/mtd/mtd.h>
  2697. +#include <linux/mtd/partitions.h>
  2698. +#include <linux/of_platform.h>
  2699. +#include <linux/of_address.h>
  2700. +#include <linux/of_gpio.h>
  2701. +
  2702. +#define DRV_NAME "rbppc_nand"
  2703. +#define DRV_VERSION "0.1.1"
  2704. +
  2705. +struct rbppc_nand_prv {
  2706. + struct mtd_info mtd;
  2707. + struct nand_chip chip;
  2708. +
  2709. + int rnb_gpio;
  2710. +
  2711. + int nce_gpio;
  2712. + int cle_gpio;
  2713. + int ale_gpio;
  2714. +
  2715. + void __iomem *cmd_sync;
  2716. +
  2717. + struct device *dev;
  2718. +};
  2719. +
  2720. +/*
  2721. + * We must use the OOB layout from yaffs 1 if we want this to be recognized
  2722. + * properly. Borrowed from the OpenWRT patches for the RB532.
  2723. + *
  2724. + * See <https://dev.openwrt.org/browser/trunk/target/linux/rb532/
  2725. + * patches-2.6.28/025-rb532_nand_fixup.patch> for more details.
  2726. + */
  2727. +static struct nand_ecclayout rbppc_nand_oob_16 = {
  2728. + .eccbytes = 6,
  2729. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  2730. + .oobavail = 9,
  2731. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } },
  2732. +};
  2733. +
  2734. +static inline void rbppc_nand_sync(struct rbppc_nand_prv *prv) {
  2735. + /*
  2736. + * My understanding from reading the GPIO NAND driver (gpio.c) is that
  2737. + * this enforces a MEMBAR that the CPU itself can't provide; in other
  2738. + * words, it forces commands to be executed synchronously.
  2739. + */
  2740. + readb(prv->cmd_sync);
  2741. +}
  2742. +
  2743. +static int rbppc_nand_dev_ready(struct mtd_info *mtd) {
  2744. + struct nand_chip *chip = mtd->priv;
  2745. + struct rbppc_nand_prv *prv = chip->priv;
  2746. +
  2747. + return gpio_get_value(prv->rnb_gpio);
  2748. +}
  2749. +
  2750. +static void rbppc_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) {
  2751. + struct nand_chip *chip = mtd->priv;
  2752. + struct rbppc_nand_prv *prv = chip->priv;
  2753. +
  2754. + rbppc_nand_sync(prv);
  2755. +
  2756. + if (ctrl & NAND_CTRL_CHANGE) {
  2757. + gpio_set_value(prv->nce_gpio, !(ctrl & NAND_NCE));
  2758. + gpio_set_value(prv->cle_gpio, !!(ctrl & NAND_CLE));
  2759. + gpio_set_value(prv->ale_gpio, !!(ctrl & NAND_ALE));
  2760. +
  2761. + rbppc_nand_sync(prv);
  2762. + }
  2763. + if (cmd == NAND_CMD_NONE)
  2764. + return;
  2765. +
  2766. + writeb(cmd, chip->IO_ADDR_W);
  2767. + rbppc_nand_sync(prv);
  2768. +}
  2769. +
  2770. +static void rbppc_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
  2771. +{
  2772. + struct nand_chip *chip = mtd->priv;
  2773. +
  2774. + readsb(chip->IO_ADDR_R, buf, len);
  2775. +}
  2776. +
  2777. +static void rbppc_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
  2778. +{
  2779. + struct nand_chip *chip = mtd->priv;
  2780. +
  2781. + writesb(chip->IO_ADDR_W, buf, len);
  2782. +}
  2783. +
  2784. +static void rbppc_nand_free_gpio(struct rbppc_nand_prv *prv)
  2785. +{
  2786. + if (gpio_is_valid(prv->rnb_gpio))
  2787. + gpio_free(prv->rnb_gpio);
  2788. + if (gpio_is_valid(prv->nce_gpio))
  2789. + gpio_free(prv->nce_gpio);
  2790. + if (gpio_is_valid(prv->cle_gpio))
  2791. + gpio_free(prv->cle_gpio);
  2792. + if (gpio_is_valid(prv->ale_gpio))
  2793. + gpio_free(prv->ale_gpio);
  2794. +}
  2795. +
  2796. +static int rbppc_nand_probe_gpio(struct rbppc_nand_prv *prv, int rnb_gpio, int nce_gpio, int cle_gpio, int ale_gpio)
  2797. +{
  2798. + struct device *dev = prv->dev;
  2799. + int retval = 0;
  2800. +
  2801. + prv->rnb_gpio = -1;
  2802. + prv->nce_gpio = -1;
  2803. + prv->cle_gpio = -1;
  2804. + prv->ale_gpio = -1;
  2805. +
  2806. + retval = gpio_request(rnb_gpio, "RouterBOARD NAND R/B");
  2807. + if (retval) {
  2808. + dev_err(dev, "Couldn't request R/B GPIO\n");
  2809. + goto err;
  2810. + }
  2811. + gpio_direction_input(rnb_gpio);
  2812. + prv->rnb_gpio = rnb_gpio;
  2813. +
  2814. + retval = gpio_request(nce_gpio, "RouterBOARD NAND nCE");
  2815. + if (retval) {
  2816. + dev_err(dev, "Couldn't request nCE GPIO\n");
  2817. + goto err;
  2818. + }
  2819. + gpio_direction_output(nce_gpio, 1);
  2820. + prv->nce_gpio = nce_gpio;
  2821. +
  2822. + retval = gpio_request(cle_gpio, "RouterBOARD NAND CLE");
  2823. + if (retval) {
  2824. + dev_err(dev, "Couldn't request CLE GPIO\n");
  2825. + goto err;
  2826. + }
  2827. + gpio_direction_output(cle_gpio, 0);
  2828. + prv->cle_gpio = cle_gpio;
  2829. +
  2830. + retval = gpio_request(ale_gpio, "RouterBOARD NAND ALE");
  2831. + if (retval) {
  2832. + dev_err(dev, "Couldn't request ALE GPIO\n");
  2833. + goto err;
  2834. + }
  2835. + gpio_direction_output(ale_gpio, 0);
  2836. + prv->ale_gpio = ale_gpio;
  2837. +
  2838. + return 0;
  2839. +
  2840. +err:
  2841. + rbppc_nand_free_gpio(prv);
  2842. + return retval;
  2843. +}
  2844. +
  2845. +static int rbppc_nand_probe(struct platform_device *pdev)
  2846. +{
  2847. + struct device *dev = &pdev->dev;
  2848. + struct rbppc_nand_prv *prv;
  2849. + struct mtd_info *mtd;
  2850. + struct nand_chip *chip;
  2851. + struct device_node *dn = dev->of_node;
  2852. + struct device_node *dn_partitions;
  2853. + struct resource res;
  2854. + int rnb_gpio, nce_gpio, cle_gpio, ale_gpio;
  2855. + void __iomem *io_addr;
  2856. + void __iomem *sync_addr;
  2857. + struct mtd_part_parser_data pp_data;
  2858. + int retval;
  2859. +
  2860. + printk(KERN_INFO "MikroTik RouterBOARD NAND driver for "
  2861. + "MPC83xx/MPC85xx-based platforms, version " DRV_VERSION "\n");
  2862. +
  2863. + prv = devm_kzalloc(dev, sizeof(*prv), GFP_KERNEL);
  2864. + if (!prv) {
  2865. + dev_err(dev, "Can't allocate memory!\n");
  2866. + return -ENOMEM;
  2867. + }
  2868. +
  2869. + prv->dev = dev;
  2870. +
  2871. + chip = &prv->chip;
  2872. + chip->priv = prv;
  2873. +
  2874. + mtd = &prv->mtd;
  2875. + mtd->name = DRV_NAME;
  2876. + mtd->priv = chip;
  2877. + mtd->owner = THIS_MODULE;
  2878. +
  2879. + rnb_gpio = of_get_gpio(dn, 0);
  2880. + if (!gpio_is_valid(rnb_gpio)) {
  2881. + dev_err(dev, "No R/B GPIO (0) found\n");
  2882. + return rnb_gpio;
  2883. + }
  2884. +
  2885. + nce_gpio = of_get_gpio(dn, 1);
  2886. + if (!gpio_is_valid(nce_gpio)) {
  2887. + dev_err(dev, "No nCE GPIO (1) found\n");
  2888. + return nce_gpio;
  2889. + }
  2890. +
  2891. + cle_gpio = of_get_gpio(dn, 2);
  2892. + if (!gpio_is_valid(cle_gpio)) {
  2893. + dev_err(dev, "No CLE GPIO (2) found\n");
  2894. + return cle_gpio;
  2895. + }
  2896. +
  2897. + ale_gpio = of_get_gpio(dn, 3);
  2898. + if (!gpio_is_valid(ale_gpio)) {
  2899. + dev_err(dev, "No ALE GPIO (3) found\n");
  2900. + return ale_gpio;
  2901. + }
  2902. +
  2903. + retval = rbppc_nand_probe_gpio(prv, rnb_gpio, nce_gpio, cle_gpio, ale_gpio);
  2904. + if (retval)
  2905. + return retval;
  2906. +
  2907. + /*
  2908. + * Allocate IO resource.
  2909. + */
  2910. + retval = of_address_to_resource(dn, 0, &res);
  2911. + if (retval) {
  2912. + dev_err(dev, "No reg property found for IO (0)\n");
  2913. + goto err_after_probe_gpio;
  2914. + }
  2915. +
  2916. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1, DRV_NAME)) {
  2917. + dev_err(dev, "Could not reserve NAND memory\n");
  2918. + retval = -EBUSY;
  2919. + goto err_after_probe_gpio;
  2920. + }
  2921. +
  2922. + io_addr = devm_ioremap_nocache(dev, res.start, res.end - res.start + 1);
  2923. + if (!io_addr) {
  2924. + dev_err(dev, "Could not map NAND memory\n");
  2925. + retval = -ENOMEM;
  2926. + goto err_after_probe_gpio;
  2927. + }
  2928. +
  2929. + /*
  2930. + * Allocate sync resource.
  2931. + */
  2932. + retval = of_address_to_resource(dn, 1, &res);
  2933. + if (retval) {
  2934. + dev_err(dev, "No reg property found for sync (1)\n");
  2935. + goto err_after_probe_gpio;
  2936. + }
  2937. +
  2938. + if (!devm_request_mem_region(dev, res.start, res.end - res.start + 1, DRV_NAME)) {
  2939. + dev_err(dev, "Could not reserve sync memory\n");
  2940. + retval = -EBUSY;
  2941. + goto err_after_probe_gpio;
  2942. + }
  2943. +
  2944. + sync_addr = devm_ioremap_nocache(dev, res.start, res.end - res.start + 1);
  2945. + if (!sync_addr) {
  2946. + dev_err(dev, "Could not map sync memory\n");
  2947. + retval = -ENOMEM;
  2948. + goto err_after_probe_gpio;
  2949. + }
  2950. +
  2951. + chip->dev_ready = rbppc_nand_dev_ready;
  2952. + chip->cmd_ctrl = rbppc_nand_cmd_ctrl;
  2953. + chip->read_buf = rbppc_nand_read_buf;
  2954. + chip->write_buf = rbppc_nand_write_buf;
  2955. + chip->IO_ADDR_W = io_addr;
  2956. + chip->IO_ADDR_R = io_addr;
  2957. + chip->chip_delay = 25;
  2958. + chip->ecc.mode = NAND_ECC_SOFT;
  2959. + chip->ecc.layout = &rbppc_nand_oob_16;
  2960. +
  2961. + prv->cmd_sync = sync_addr;
  2962. +
  2963. + retval = nand_scan(mtd, 1);
  2964. + if (retval) {
  2965. + dev_err(dev, "RouterBOARD NAND device not found\n");
  2966. + goto err_after_probe_gpio;
  2967. + }
  2968. +
  2969. + /*
  2970. + * Parse partitions and register device.
  2971. + */
  2972. + dn_partitions = of_get_next_child(dn, NULL);
  2973. +
  2974. + pp_data.of_node = dn_partitions;
  2975. + retval = mtd_device_parse_register(&prv->mtd, NULL, &pp_data, NULL, 0);
  2976. + of_node_put(dn_partitions);
  2977. + if (retval) {
  2978. + dev_err(dev, "Could not register new MTD device\n");
  2979. + goto err_after_probe_gpio;
  2980. + }
  2981. +
  2982. + dev_set_drvdata(dev, prv);
  2983. +
  2984. + return 0;
  2985. +
  2986. +err_after_probe_gpio:
  2987. + rbppc_nand_free_gpio(prv);
  2988. + return retval;
  2989. +}
  2990. +
  2991. +static int rbppc_nand_remove(struct platform_device *pdev)
  2992. +{
  2993. + struct device *dev = &pdev->dev;
  2994. + struct rbppc_nand_prv *prv = dev_get_drvdata(dev);
  2995. +
  2996. + nand_release(&prv->mtd);
  2997. + rbppc_nand_free_gpio(prv);
  2998. +
  2999. + dev_set_drvdata(dev, NULL);
  3000. +
  3001. + return 0;
  3002. +}
  3003. +
  3004. +static struct of_device_id rbppc_nand_ids[] = {
  3005. + { .compatible = "rb,nand", },
  3006. + {},
  3007. +};
  3008. +
  3009. +static struct platform_driver rbppc_nand_driver = {
  3010. + .probe = rbppc_nand_probe,
  3011. + .remove = rbppc_nand_remove,
  3012. + .driver = {
  3013. + .name = "rbppc-nand",
  3014. + .owner = THIS_MODULE,
  3015. + .of_match_table = rbppc_nand_ids,
  3016. + },
  3017. +};
  3018. +
  3019. +static int __init rbppc_nand_init(void)
  3020. +{
  3021. + return platform_driver_register(&rbppc_nand_driver);
  3022. +}
  3023. +
  3024. +static void __exit rbppc_nand_exit(void)
  3025. +{
  3026. + platform_driver_unregister(&rbppc_nand_driver);
  3027. +}
  3028. +
  3029. +MODULE_AUTHOR("Mikrotikls SIA");
  3030. +MODULE_AUTHOR("Noah Fontes");
  3031. +MODULE_AUTHOR("Michael Guntsche");
  3032. +MODULE_DESCRIPTION("MikroTik RouterBOARD NAND driver for MPC83xx/MPC85xx-based platforms");
  3033. +MODULE_LICENSE("GPL");
  3034. +MODULE_VERSION(DRV_VERSION);
  3035. +
  3036. +module_init(rbppc_nand_init);
  3037. +module_exit(rbppc_nand_exit);