ipu_idmac.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  1. /*
  2. * Copyright (C) 2008
  3. * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
  4. *
  5. * Copyright (C) 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/err.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/delay.h>
  16. #include <linux/list.h>
  17. #include <linux/clk.h>
  18. #include <linux/vmalloc.h>
  19. #include <linux/string.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/io.h>
  22. #include <mach/ipu.h>
  23. #include "ipu_intern.h"
  24. #define FS_VF_IN_VALID 0x00000002
  25. #define FS_ENC_IN_VALID 0x00000001
  26. /*
  27. * There can be only one, we could allocate it dynamically, but then we'd have
  28. * to add an extra parameter to some functions, and use something as ugly as
  29. * struct ipu *ipu = to_ipu(to_idmac(ichan->dma_chan.device));
  30. * in the ISR
  31. */
  32. static struct ipu ipu_data;
  33. #define to_ipu(id) container_of(id, struct ipu, idmac)
  34. static u32 __idmac_read_icreg(struct ipu *ipu, unsigned long reg)
  35. {
  36. return __raw_readl(ipu->reg_ic + reg);
  37. }
  38. #define idmac_read_icreg(ipu, reg) __idmac_read_icreg(ipu, reg - IC_CONF)
  39. static void __idmac_write_icreg(struct ipu *ipu, u32 value, unsigned long reg)
  40. {
  41. __raw_writel(value, ipu->reg_ic + reg);
  42. }
  43. #define idmac_write_icreg(ipu, v, reg) __idmac_write_icreg(ipu, v, reg - IC_CONF)
  44. static u32 idmac_read_ipureg(struct ipu *ipu, unsigned long reg)
  45. {
  46. return __raw_readl(ipu->reg_ipu + reg);
  47. }
  48. static void idmac_write_ipureg(struct ipu *ipu, u32 value, unsigned long reg)
  49. {
  50. __raw_writel(value, ipu->reg_ipu + reg);
  51. }
  52. /*****************************************************************************
  53. * IPU / IC common functions
  54. */
  55. static void dump_idmac_reg(struct ipu *ipu)
  56. {
  57. dev_dbg(ipu->dev, "IDMAC_CONF 0x%x, IC_CONF 0x%x, IDMAC_CHA_EN 0x%x, "
  58. "IDMAC_CHA_PRI 0x%x, IDMAC_CHA_BUSY 0x%x\n",
  59. idmac_read_icreg(ipu, IDMAC_CONF),
  60. idmac_read_icreg(ipu, IC_CONF),
  61. idmac_read_icreg(ipu, IDMAC_CHA_EN),
  62. idmac_read_icreg(ipu, IDMAC_CHA_PRI),
  63. idmac_read_icreg(ipu, IDMAC_CHA_BUSY));
  64. dev_dbg(ipu->dev, "BUF0_RDY 0x%x, BUF1_RDY 0x%x, CUR_BUF 0x%x, "
  65. "DB_MODE 0x%x, TASKS_STAT 0x%x\n",
  66. idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY),
  67. idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY),
  68. idmac_read_ipureg(ipu, IPU_CHA_CUR_BUF),
  69. idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL),
  70. idmac_read_ipureg(ipu, IPU_TASKS_STAT));
  71. }
  72. static uint32_t bytes_per_pixel(enum pixel_fmt fmt)
  73. {
  74. switch (fmt) {
  75. case IPU_PIX_FMT_GENERIC: /* generic data */
  76. case IPU_PIX_FMT_RGB332:
  77. case IPU_PIX_FMT_YUV420P:
  78. case IPU_PIX_FMT_YUV422P:
  79. default:
  80. return 1;
  81. case IPU_PIX_FMT_RGB565:
  82. case IPU_PIX_FMT_YUYV:
  83. case IPU_PIX_FMT_UYVY:
  84. return 2;
  85. case IPU_PIX_FMT_BGR24:
  86. case IPU_PIX_FMT_RGB24:
  87. return 3;
  88. case IPU_PIX_FMT_GENERIC_32: /* generic data */
  89. case IPU_PIX_FMT_BGR32:
  90. case IPU_PIX_FMT_RGB32:
  91. case IPU_PIX_FMT_ABGR32:
  92. return 4;
  93. }
  94. }
  95. /* Enable direct write to memory by the Camera Sensor Interface */
  96. static void ipu_ic_enable_task(struct ipu *ipu, enum ipu_channel channel)
  97. {
  98. uint32_t ic_conf, mask;
  99. switch (channel) {
  100. case IDMAC_IC_0:
  101. mask = IC_CONF_PRPENC_EN;
  102. break;
  103. case IDMAC_IC_7:
  104. mask = IC_CONF_RWS_EN | IC_CONF_PRPENC_EN;
  105. break;
  106. default:
  107. return;
  108. }
  109. ic_conf = idmac_read_icreg(ipu, IC_CONF) | mask;
  110. idmac_write_icreg(ipu, ic_conf, IC_CONF);
  111. }
  112. /* Called under spin_lock_irqsave(&ipu_data.lock) */
  113. static void ipu_ic_disable_task(struct ipu *ipu, enum ipu_channel channel)
  114. {
  115. uint32_t ic_conf, mask;
  116. switch (channel) {
  117. case IDMAC_IC_0:
  118. mask = IC_CONF_PRPENC_EN;
  119. break;
  120. case IDMAC_IC_7:
  121. mask = IC_CONF_RWS_EN | IC_CONF_PRPENC_EN;
  122. break;
  123. default:
  124. return;
  125. }
  126. ic_conf = idmac_read_icreg(ipu, IC_CONF) & ~mask;
  127. idmac_write_icreg(ipu, ic_conf, IC_CONF);
  128. }
  129. static uint32_t ipu_channel_status(struct ipu *ipu, enum ipu_channel channel)
  130. {
  131. uint32_t stat = TASK_STAT_IDLE;
  132. uint32_t task_stat_reg = idmac_read_ipureg(ipu, IPU_TASKS_STAT);
  133. switch (channel) {
  134. case IDMAC_IC_7:
  135. stat = (task_stat_reg & TSTAT_CSI2MEM_MASK) >>
  136. TSTAT_CSI2MEM_OFFSET;
  137. break;
  138. case IDMAC_IC_0:
  139. case IDMAC_SDC_0:
  140. case IDMAC_SDC_1:
  141. default:
  142. break;
  143. }
  144. return stat;
  145. }
  146. struct chan_param_mem_planar {
  147. /* Word 0 */
  148. u32 xv:10;
  149. u32 yv:10;
  150. u32 xb:12;
  151. u32 yb:12;
  152. u32 res1:2;
  153. u32 nsb:1;
  154. u32 lnpb:6;
  155. u32 ubo_l:11;
  156. u32 ubo_h:15;
  157. u32 vbo_l:17;
  158. u32 vbo_h:9;
  159. u32 res2:3;
  160. u32 fw:12;
  161. u32 fh_l:8;
  162. u32 fh_h:4;
  163. u32 res3:28;
  164. /* Word 1 */
  165. u32 eba0;
  166. u32 eba1;
  167. u32 bpp:3;
  168. u32 sl:14;
  169. u32 pfs:3;
  170. u32 bam:3;
  171. u32 res4:2;
  172. u32 npb:6;
  173. u32 res5:1;
  174. u32 sat:2;
  175. u32 res6:30;
  176. } __attribute__ ((packed));
  177. struct chan_param_mem_interleaved {
  178. /* Word 0 */
  179. u32 xv:10;
  180. u32 yv:10;
  181. u32 xb:12;
  182. u32 yb:12;
  183. u32 sce:1;
  184. u32 res1:1;
  185. u32 nsb:1;
  186. u32 lnpb:6;
  187. u32 sx:10;
  188. u32 sy_l:1;
  189. u32 sy_h:9;
  190. u32 ns:10;
  191. u32 sm:10;
  192. u32 sdx_l:3;
  193. u32 sdx_h:2;
  194. u32 sdy:5;
  195. u32 sdrx:1;
  196. u32 sdry:1;
  197. u32 sdr1:1;
  198. u32 res2:2;
  199. u32 fw:12;
  200. u32 fh_l:8;
  201. u32 fh_h:4;
  202. u32 res3:28;
  203. /* Word 1 */
  204. u32 eba0;
  205. u32 eba1;
  206. u32 bpp:3;
  207. u32 sl:14;
  208. u32 pfs:3;
  209. u32 bam:3;
  210. u32 res4:2;
  211. u32 npb:6;
  212. u32 res5:1;
  213. u32 sat:2;
  214. u32 scc:1;
  215. u32 ofs0:5;
  216. u32 ofs1:5;
  217. u32 ofs2:5;
  218. u32 ofs3:5;
  219. u32 wid0:3;
  220. u32 wid1:3;
  221. u32 wid2:3;
  222. u32 wid3:3;
  223. u32 dec_sel:1;
  224. u32 res6:28;
  225. } __attribute__ ((packed));
  226. union chan_param_mem {
  227. struct chan_param_mem_planar pp;
  228. struct chan_param_mem_interleaved ip;
  229. };
  230. static void ipu_ch_param_set_plane_offset(union chan_param_mem *params,
  231. u32 u_offset, u32 v_offset)
  232. {
  233. params->pp.ubo_l = u_offset & 0x7ff;
  234. params->pp.ubo_h = u_offset >> 11;
  235. params->pp.vbo_l = v_offset & 0x1ffff;
  236. params->pp.vbo_h = v_offset >> 17;
  237. }
  238. static void ipu_ch_param_set_size(union chan_param_mem *params,
  239. uint32_t pixel_fmt, uint16_t width,
  240. uint16_t height, uint16_t stride)
  241. {
  242. u32 u_offset;
  243. u32 v_offset;
  244. params->pp.fw = width - 1;
  245. params->pp.fh_l = height - 1;
  246. params->pp.fh_h = (height - 1) >> 8;
  247. params->pp.sl = stride - 1;
  248. switch (pixel_fmt) {
  249. case IPU_PIX_FMT_GENERIC:
  250. /*Represents 8-bit Generic data */
  251. params->pp.bpp = 3;
  252. params->pp.pfs = 7;
  253. params->pp.npb = 31;
  254. params->pp.sat = 2; /* SAT = use 32-bit access */
  255. break;
  256. case IPU_PIX_FMT_GENERIC_32:
  257. /*Represents 32-bit Generic data */
  258. params->pp.bpp = 0;
  259. params->pp.pfs = 7;
  260. params->pp.npb = 7;
  261. params->pp.sat = 2; /* SAT = use 32-bit access */
  262. break;
  263. case IPU_PIX_FMT_RGB565:
  264. params->ip.bpp = 2;
  265. params->ip.pfs = 4;
  266. params->ip.npb = 7;
  267. params->ip.sat = 2; /* SAT = 32-bit access */
  268. params->ip.ofs0 = 0; /* Red bit offset */
  269. params->ip.ofs1 = 5; /* Green bit offset */
  270. params->ip.ofs2 = 11; /* Blue bit offset */
  271. params->ip.ofs3 = 16; /* Alpha bit offset */
  272. params->ip.wid0 = 4; /* Red bit width - 1 */
  273. params->ip.wid1 = 5; /* Green bit width - 1 */
  274. params->ip.wid2 = 4; /* Blue bit width - 1 */
  275. break;
  276. case IPU_PIX_FMT_BGR24:
  277. params->ip.bpp = 1; /* 24 BPP & RGB PFS */
  278. params->ip.pfs = 4;
  279. params->ip.npb = 7;
  280. params->ip.sat = 2; /* SAT = 32-bit access */
  281. params->ip.ofs0 = 0; /* Red bit offset */
  282. params->ip.ofs1 = 8; /* Green bit offset */
  283. params->ip.ofs2 = 16; /* Blue bit offset */
  284. params->ip.ofs3 = 24; /* Alpha bit offset */
  285. params->ip.wid0 = 7; /* Red bit width - 1 */
  286. params->ip.wid1 = 7; /* Green bit width - 1 */
  287. params->ip.wid2 = 7; /* Blue bit width - 1 */
  288. break;
  289. case IPU_PIX_FMT_RGB24:
  290. params->ip.bpp = 1; /* 24 BPP & RGB PFS */
  291. params->ip.pfs = 4;
  292. params->ip.npb = 7;
  293. params->ip.sat = 2; /* SAT = 32-bit access */
  294. params->ip.ofs0 = 16; /* Red bit offset */
  295. params->ip.ofs1 = 8; /* Green bit offset */
  296. params->ip.ofs2 = 0; /* Blue bit offset */
  297. params->ip.ofs3 = 24; /* Alpha bit offset */
  298. params->ip.wid0 = 7; /* Red bit width - 1 */
  299. params->ip.wid1 = 7; /* Green bit width - 1 */
  300. params->ip.wid2 = 7; /* Blue bit width - 1 */
  301. break;
  302. case IPU_PIX_FMT_BGRA32:
  303. case IPU_PIX_FMT_BGR32:
  304. params->ip.bpp = 0;
  305. params->ip.pfs = 4;
  306. params->ip.npb = 7;
  307. params->ip.sat = 2; /* SAT = 32-bit access */
  308. params->ip.ofs0 = 8; /* Red bit offset */
  309. params->ip.ofs1 = 16; /* Green bit offset */
  310. params->ip.ofs2 = 24; /* Blue bit offset */
  311. params->ip.ofs3 = 0; /* Alpha bit offset */
  312. params->ip.wid0 = 7; /* Red bit width - 1 */
  313. params->ip.wid1 = 7; /* Green bit width - 1 */
  314. params->ip.wid2 = 7; /* Blue bit width - 1 */
  315. params->ip.wid3 = 7; /* Alpha bit width - 1 */
  316. break;
  317. case IPU_PIX_FMT_RGBA32:
  318. case IPU_PIX_FMT_RGB32:
  319. params->ip.bpp = 0;
  320. params->ip.pfs = 4;
  321. params->ip.npb = 7;
  322. params->ip.sat = 2; /* SAT = 32-bit access */
  323. params->ip.ofs0 = 24; /* Red bit offset */
  324. params->ip.ofs1 = 16; /* Green bit offset */
  325. params->ip.ofs2 = 8; /* Blue bit offset */
  326. params->ip.ofs3 = 0; /* Alpha bit offset */
  327. params->ip.wid0 = 7; /* Red bit width - 1 */
  328. params->ip.wid1 = 7; /* Green bit width - 1 */
  329. params->ip.wid2 = 7; /* Blue bit width - 1 */
  330. params->ip.wid3 = 7; /* Alpha bit width - 1 */
  331. break;
  332. case IPU_PIX_FMT_ABGR32:
  333. params->ip.bpp = 0;
  334. params->ip.pfs = 4;
  335. params->ip.npb = 7;
  336. params->ip.sat = 2; /* SAT = 32-bit access */
  337. params->ip.ofs0 = 8; /* Red bit offset */
  338. params->ip.ofs1 = 16; /* Green bit offset */
  339. params->ip.ofs2 = 24; /* Blue bit offset */
  340. params->ip.ofs3 = 0; /* Alpha bit offset */
  341. params->ip.wid0 = 7; /* Red bit width - 1 */
  342. params->ip.wid1 = 7; /* Green bit width - 1 */
  343. params->ip.wid2 = 7; /* Blue bit width - 1 */
  344. params->ip.wid3 = 7; /* Alpha bit width - 1 */
  345. break;
  346. case IPU_PIX_FMT_UYVY:
  347. params->ip.bpp = 2;
  348. params->ip.pfs = 6;
  349. params->ip.npb = 7;
  350. params->ip.sat = 2; /* SAT = 32-bit access */
  351. break;
  352. case IPU_PIX_FMT_YUV420P2:
  353. case IPU_PIX_FMT_YUV420P:
  354. params->ip.bpp = 3;
  355. params->ip.pfs = 3;
  356. params->ip.npb = 7;
  357. params->ip.sat = 2; /* SAT = 32-bit access */
  358. u_offset = stride * height;
  359. v_offset = u_offset + u_offset / 4;
  360. ipu_ch_param_set_plane_offset(params, u_offset, v_offset);
  361. break;
  362. case IPU_PIX_FMT_YVU422P:
  363. params->ip.bpp = 3;
  364. params->ip.pfs = 2;
  365. params->ip.npb = 7;
  366. params->ip.sat = 2; /* SAT = 32-bit access */
  367. v_offset = stride * height;
  368. u_offset = v_offset + v_offset / 2;
  369. ipu_ch_param_set_plane_offset(params, u_offset, v_offset);
  370. break;
  371. case IPU_PIX_FMT_YUV422P:
  372. params->ip.bpp = 3;
  373. params->ip.pfs = 2;
  374. params->ip.npb = 7;
  375. params->ip.sat = 2; /* SAT = 32-bit access */
  376. u_offset = stride * height;
  377. v_offset = u_offset + u_offset / 2;
  378. ipu_ch_param_set_plane_offset(params, u_offset, v_offset);
  379. break;
  380. default:
  381. dev_err(ipu_data.dev,
  382. "mx3 ipu: unimplemented pixel format %d\n", pixel_fmt);
  383. break;
  384. }
  385. params->pp.nsb = 1;
  386. }
  387. static void ipu_ch_param_set_burst_size(union chan_param_mem *params,
  388. uint16_t burst_pixels)
  389. {
  390. params->pp.npb = burst_pixels - 1;
  391. }
  392. static void ipu_ch_param_set_buffer(union chan_param_mem *params,
  393. dma_addr_t buf0, dma_addr_t buf1)
  394. {
  395. params->pp.eba0 = buf0;
  396. params->pp.eba1 = buf1;
  397. }
  398. static void ipu_ch_param_set_rotation(union chan_param_mem *params,
  399. enum ipu_rotate_mode rotate)
  400. {
  401. params->pp.bam = rotate;
  402. }
  403. static void ipu_write_param_mem(uint32_t addr, uint32_t *data,
  404. uint32_t num_words)
  405. {
  406. for (; num_words > 0; num_words--) {
  407. dev_dbg(ipu_data.dev,
  408. "write param mem - addr = 0x%08X, data = 0x%08X\n",
  409. addr, *data);
  410. idmac_write_ipureg(&ipu_data, addr, IPU_IMA_ADDR);
  411. idmac_write_ipureg(&ipu_data, *data++, IPU_IMA_DATA);
  412. addr++;
  413. if ((addr & 0x7) == 5) {
  414. addr &= ~0x7; /* set to word 0 */
  415. addr += 8; /* increment to next row */
  416. }
  417. }
  418. }
  419. static int calc_resize_coeffs(uint32_t in_size, uint32_t out_size,
  420. uint32_t *resize_coeff,
  421. uint32_t *downsize_coeff)
  422. {
  423. uint32_t temp_size;
  424. uint32_t temp_downsize;
  425. *resize_coeff = 1 << 13;
  426. *downsize_coeff = 1 << 13;
  427. /* Cannot downsize more than 8:1 */
  428. if (out_size << 3 < in_size)
  429. return -EINVAL;
  430. /* compute downsizing coefficient */
  431. temp_downsize = 0;
  432. temp_size = in_size;
  433. while (temp_size >= out_size * 2 && temp_downsize < 2) {
  434. temp_size >>= 1;
  435. temp_downsize++;
  436. }
  437. *downsize_coeff = temp_downsize;
  438. /*
  439. * compute resizing coefficient using the following formula:
  440. * resize_coeff = M*(SI -1)/(SO - 1)
  441. * where M = 2^13, SI - input size, SO - output size
  442. */
  443. *resize_coeff = (8192L * (temp_size - 1)) / (out_size - 1);
  444. if (*resize_coeff >= 16384L) {
  445. dev_err(ipu_data.dev, "Warning! Overflow on resize coeff.\n");
  446. *resize_coeff = 0x3FFF;
  447. }
  448. dev_dbg(ipu_data.dev, "resizing from %u -> %u pixels, "
  449. "downsize=%u, resize=%u.%lu (reg=%u)\n", in_size, out_size,
  450. *downsize_coeff, *resize_coeff >= 8192L ? 1 : 0,
  451. ((*resize_coeff & 0x1FFF) * 10000L) / 8192L, *resize_coeff);
  452. return 0;
  453. }
  454. static enum ipu_color_space format_to_colorspace(enum pixel_fmt fmt)
  455. {
  456. switch (fmt) {
  457. case IPU_PIX_FMT_RGB565:
  458. case IPU_PIX_FMT_BGR24:
  459. case IPU_PIX_FMT_RGB24:
  460. case IPU_PIX_FMT_BGR32:
  461. case IPU_PIX_FMT_RGB32:
  462. return IPU_COLORSPACE_RGB;
  463. default:
  464. return IPU_COLORSPACE_YCBCR;
  465. }
  466. }
  467. static int ipu_ic_init_prpenc(struct ipu *ipu,
  468. union ipu_channel_param *params, bool src_is_csi)
  469. {
  470. uint32_t reg, ic_conf;
  471. uint32_t downsize_coeff, resize_coeff;
  472. enum ipu_color_space in_fmt, out_fmt;
  473. /* Setup vertical resizing */
  474. calc_resize_coeffs(params->video.in_height,
  475. params->video.out_height,
  476. &resize_coeff, &downsize_coeff);
  477. reg = (downsize_coeff << 30) | (resize_coeff << 16);
  478. /* Setup horizontal resizing */
  479. calc_resize_coeffs(params->video.in_width,
  480. params->video.out_width,
  481. &resize_coeff, &downsize_coeff);
  482. reg |= (downsize_coeff << 14) | resize_coeff;
  483. /* Setup color space conversion */
  484. in_fmt = format_to_colorspace(params->video.in_pixel_fmt);
  485. out_fmt = format_to_colorspace(params->video.out_pixel_fmt);
  486. /*
  487. * Colourspace conversion unsupported yet - see _init_csc() in
  488. * Freescale sources
  489. */
  490. if (in_fmt != out_fmt) {
  491. dev_err(ipu->dev, "Colourspace conversion unsupported!\n");
  492. return -EOPNOTSUPP;
  493. }
  494. idmac_write_icreg(ipu, reg, IC_PRP_ENC_RSC);
  495. ic_conf = idmac_read_icreg(ipu, IC_CONF);
  496. if (src_is_csi)
  497. ic_conf &= ~IC_CONF_RWS_EN;
  498. else
  499. ic_conf |= IC_CONF_RWS_EN;
  500. idmac_write_icreg(ipu, ic_conf, IC_CONF);
  501. return 0;
  502. }
  503. static uint32_t dma_param_addr(uint32_t dma_ch)
  504. {
  505. /* Channel Parameter Memory */
  506. return 0x10000 | (dma_ch << 4);
  507. }
  508. static void ipu_channel_set_priority(struct ipu *ipu, enum ipu_channel channel,
  509. bool prio)
  510. {
  511. u32 reg = idmac_read_icreg(ipu, IDMAC_CHA_PRI);
  512. if (prio)
  513. reg |= 1UL << channel;
  514. else
  515. reg &= ~(1UL << channel);
  516. idmac_write_icreg(ipu, reg, IDMAC_CHA_PRI);
  517. dump_idmac_reg(ipu);
  518. }
  519. static uint32_t ipu_channel_conf_mask(enum ipu_channel channel)
  520. {
  521. uint32_t mask;
  522. switch (channel) {
  523. case IDMAC_IC_0:
  524. case IDMAC_IC_7:
  525. mask = IPU_CONF_CSI_EN | IPU_CONF_IC_EN;
  526. break;
  527. case IDMAC_SDC_0:
  528. case IDMAC_SDC_1:
  529. mask = IPU_CONF_SDC_EN | IPU_CONF_DI_EN;
  530. break;
  531. default:
  532. mask = 0;
  533. break;
  534. }
  535. return mask;
  536. }
  537. /**
  538. * ipu_enable_channel() - enable an IPU channel.
  539. * @idmac: IPU DMAC context.
  540. * @ichan: IDMAC channel.
  541. * @return: 0 on success or negative error code on failure.
  542. */
  543. static int ipu_enable_channel(struct idmac *idmac, struct idmac_channel *ichan)
  544. {
  545. struct ipu *ipu = to_ipu(idmac);
  546. enum ipu_channel channel = ichan->dma_chan.chan_id;
  547. uint32_t reg;
  548. unsigned long flags;
  549. spin_lock_irqsave(&ipu->lock, flags);
  550. /* Reset to buffer 0 */
  551. idmac_write_ipureg(ipu, 1UL << channel, IPU_CHA_CUR_BUF);
  552. ichan->active_buffer = 0;
  553. ichan->status = IPU_CHANNEL_ENABLED;
  554. switch (channel) {
  555. case IDMAC_SDC_0:
  556. case IDMAC_SDC_1:
  557. case IDMAC_IC_7:
  558. ipu_channel_set_priority(ipu, channel, true);
  559. default:
  560. break;
  561. }
  562. reg = idmac_read_icreg(ipu, IDMAC_CHA_EN);
  563. idmac_write_icreg(ipu, reg | (1UL << channel), IDMAC_CHA_EN);
  564. ipu_ic_enable_task(ipu, channel);
  565. spin_unlock_irqrestore(&ipu->lock, flags);
  566. return 0;
  567. }
  568. /**
  569. * ipu_init_channel_buffer() - initialize a buffer for logical IPU channel.
  570. * @ichan: IDMAC channel.
  571. * @pixel_fmt: pixel format of buffer. Pixel format is a FOURCC ASCII code.
  572. * @width: width of buffer in pixels.
  573. * @height: height of buffer in pixels.
  574. * @stride: stride length of buffer in pixels.
  575. * @rot_mode: rotation mode of buffer. A rotation setting other than
  576. * IPU_ROTATE_VERT_FLIP should only be used for input buffers of
  577. * rotation channels.
  578. * @phyaddr_0: buffer 0 physical address.
  579. * @phyaddr_1: buffer 1 physical address. Setting this to a value other than
  580. * NULL enables double buffering mode.
  581. * @return: 0 on success or negative error code on failure.
  582. */
  583. static int ipu_init_channel_buffer(struct idmac_channel *ichan,
  584. enum pixel_fmt pixel_fmt,
  585. uint16_t width, uint16_t height,
  586. uint32_t stride,
  587. enum ipu_rotate_mode rot_mode,
  588. dma_addr_t phyaddr_0, dma_addr_t phyaddr_1)
  589. {
  590. enum ipu_channel channel = ichan->dma_chan.chan_id;
  591. struct idmac *idmac = to_idmac(ichan->dma_chan.device);
  592. struct ipu *ipu = to_ipu(idmac);
  593. union chan_param_mem params = {};
  594. unsigned long flags;
  595. uint32_t reg;
  596. uint32_t stride_bytes;
  597. stride_bytes = stride * bytes_per_pixel(pixel_fmt);
  598. if (stride_bytes % 4) {
  599. dev_err(ipu->dev,
  600. "Stride length must be 32-bit aligned, stride = %d, bytes = %d\n",
  601. stride, stride_bytes);
  602. return -EINVAL;
  603. }
  604. /* IC channel's stride must be a multiple of 8 pixels */
  605. if ((channel <= IDMAC_IC_13) && (stride % 8)) {
  606. dev_err(ipu->dev, "Stride must be 8 pixel multiple\n");
  607. return -EINVAL;
  608. }
  609. /* Build parameter memory data for DMA channel */
  610. ipu_ch_param_set_size(&params, pixel_fmt, width, height, stride_bytes);
  611. ipu_ch_param_set_buffer(&params, phyaddr_0, phyaddr_1);
  612. ipu_ch_param_set_rotation(&params, rot_mode);
  613. /* Some channels (rotation) have restriction on burst length */
  614. switch (channel) {
  615. case IDMAC_IC_7: /* Hangs with burst 8, 16, other values
  616. invalid - Table 44-30 */
  617. /*
  618. ipu_ch_param_set_burst_size(&params, 8);
  619. */
  620. break;
  621. case IDMAC_SDC_0:
  622. case IDMAC_SDC_1:
  623. /* In original code only IPU_PIX_FMT_RGB565 was setting burst */
  624. ipu_ch_param_set_burst_size(&params, 16);
  625. break;
  626. case IDMAC_IC_0:
  627. default:
  628. break;
  629. }
  630. spin_lock_irqsave(&ipu->lock, flags);
  631. ipu_write_param_mem(dma_param_addr(channel), (uint32_t *)&params, 10);
  632. reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL);
  633. if (phyaddr_1)
  634. reg |= 1UL << channel;
  635. else
  636. reg &= ~(1UL << channel);
  637. idmac_write_ipureg(ipu, reg, IPU_CHA_DB_MODE_SEL);
  638. ichan->status = IPU_CHANNEL_READY;
  639. spin_unlock_irqrestore(&ipu->lock, flags);
  640. return 0;
  641. }
  642. /**
  643. * ipu_select_buffer() - mark a channel's buffer as ready.
  644. * @channel: channel ID.
  645. * @buffer_n: buffer number to mark ready.
  646. */
  647. static void ipu_select_buffer(enum ipu_channel channel, int buffer_n)
  648. {
  649. /* No locking - this is a write-one-to-set register, cleared by IPU */
  650. if (buffer_n == 0)
  651. /* Mark buffer 0 as ready. */
  652. idmac_write_ipureg(&ipu_data, 1UL << channel, IPU_CHA_BUF0_RDY);
  653. else
  654. /* Mark buffer 1 as ready. */
  655. idmac_write_ipureg(&ipu_data, 1UL << channel, IPU_CHA_BUF1_RDY);
  656. }
  657. /**
  658. * ipu_update_channel_buffer() - update physical address of a channel buffer.
  659. * @ichan: IDMAC channel.
  660. * @buffer_n: buffer number to update.
  661. * 0 or 1 are the only valid values.
  662. * @phyaddr: buffer physical address.
  663. * @return: Returns 0 on success or negative error code on failure. This
  664. * function will fail if the buffer is set to ready.
  665. */
  666. /* Called under spin_lock(_irqsave)(&ichan->lock) */
  667. static int ipu_update_channel_buffer(enum ipu_channel channel,
  668. int buffer_n, dma_addr_t phyaddr)
  669. {
  670. uint32_t reg;
  671. unsigned long flags;
  672. spin_lock_irqsave(&ipu_data.lock, flags);
  673. if (buffer_n == 0) {
  674. reg = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF0_RDY);
  675. if (reg & (1UL << channel)) {
  676. spin_unlock_irqrestore(&ipu_data.lock, flags);
  677. return -EACCES;
  678. }
  679. /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 0) */
  680. idmac_write_ipureg(&ipu_data, dma_param_addr(channel) +
  681. 0x0008UL, IPU_IMA_ADDR);
  682. idmac_write_ipureg(&ipu_data, phyaddr, IPU_IMA_DATA);
  683. } else {
  684. reg = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF1_RDY);
  685. if (reg & (1UL << channel)) {
  686. spin_unlock_irqrestore(&ipu_data.lock, flags);
  687. return -EACCES;
  688. }
  689. /* Check if double-buffering is already enabled */
  690. reg = idmac_read_ipureg(&ipu_data, IPU_CHA_DB_MODE_SEL);
  691. if (!(reg & (1UL << channel)))
  692. idmac_write_ipureg(&ipu_data, reg | (1UL << channel),
  693. IPU_CHA_DB_MODE_SEL);
  694. /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 1) */
  695. idmac_write_ipureg(&ipu_data, dma_param_addr(channel) +
  696. 0x0009UL, IPU_IMA_ADDR);
  697. idmac_write_ipureg(&ipu_data, phyaddr, IPU_IMA_DATA);
  698. }
  699. spin_unlock_irqrestore(&ipu_data.lock, flags);
  700. return 0;
  701. }
  702. /* Called under spin_lock_irqsave(&ichan->lock) */
  703. static int ipu_submit_channel_buffers(struct idmac_channel *ichan,
  704. struct idmac_tx_desc *desc)
  705. {
  706. struct scatterlist *sg;
  707. int i, ret = 0;
  708. for (i = 0, sg = desc->sg; i < 2 && sg; i++) {
  709. if (!ichan->sg[i]) {
  710. ichan->sg[i] = sg;
  711. /*
  712. * On first invocation this shouldn't be necessary, the
  713. * call to ipu_init_channel_buffer() above will set
  714. * addresses for us, so we could make it conditional
  715. * on status >= IPU_CHANNEL_ENABLED, but doing it again
  716. * shouldn't hurt either.
  717. */
  718. ret = ipu_update_channel_buffer(ichan->dma_chan.chan_id, i,
  719. sg_dma_address(sg));
  720. if (ret < 0)
  721. return ret;
  722. ipu_select_buffer(ichan->dma_chan.chan_id, i);
  723. sg = sg_next(sg);
  724. }
  725. }
  726. return ret;
  727. }
  728. static dma_cookie_t idmac_tx_submit(struct dma_async_tx_descriptor *tx)
  729. {
  730. struct idmac_tx_desc *desc = to_tx_desc(tx);
  731. struct idmac_channel *ichan = to_idmac_chan(tx->chan);
  732. struct idmac *idmac = to_idmac(tx->chan->device);
  733. struct ipu *ipu = to_ipu(idmac);
  734. dma_cookie_t cookie;
  735. unsigned long flags;
  736. /* Sanity check */
  737. if (!list_empty(&desc->list)) {
  738. /* The descriptor doesn't belong to client */
  739. dev_err(&ichan->dma_chan.dev->device,
  740. "Descriptor %p not prepared!\n", tx);
  741. return -EBUSY;
  742. }
  743. mutex_lock(&ichan->chan_mutex);
  744. if (ichan->status < IPU_CHANNEL_READY) {
  745. struct idmac_video_param *video = &ichan->params.video;
  746. /*
  747. * Initial buffer assignment - the first two sg-entries from
  748. * the descriptor will end up in the IDMAC buffers
  749. */
  750. dma_addr_t dma_1 = sg_is_last(desc->sg) ? 0 :
  751. sg_dma_address(&desc->sg[1]);
  752. WARN_ON(ichan->sg[0] || ichan->sg[1]);
  753. cookie = ipu_init_channel_buffer(ichan,
  754. video->out_pixel_fmt,
  755. video->out_width,
  756. video->out_height,
  757. video->out_stride,
  758. IPU_ROTATE_NONE,
  759. sg_dma_address(&desc->sg[0]),
  760. dma_1);
  761. if (cookie < 0)
  762. goto out;
  763. }
  764. /* ipu->lock can be taken under ichan->lock, but not v.v. */
  765. spin_lock_irqsave(&ichan->lock, flags);
  766. /* submit_buffers() atomically verifies and fills empty sg slots */
  767. cookie = ipu_submit_channel_buffers(ichan, desc);
  768. spin_unlock_irqrestore(&ichan->lock, flags);
  769. if (cookie < 0)
  770. goto out;
  771. cookie = ichan->dma_chan.cookie;
  772. if (++cookie < 0)
  773. cookie = 1;
  774. /* from dmaengine.h: "last cookie value returned to client" */
  775. ichan->dma_chan.cookie = cookie;
  776. tx->cookie = cookie;
  777. spin_lock_irqsave(&ichan->lock, flags);
  778. list_add_tail(&desc->list, &ichan->queue);
  779. spin_unlock_irqrestore(&ichan->lock, flags);
  780. if (ichan->status < IPU_CHANNEL_ENABLED) {
  781. int ret = ipu_enable_channel(idmac, ichan);
  782. if (ret < 0) {
  783. cookie = ret;
  784. spin_lock_irqsave(&ichan->lock, flags);
  785. list_del_init(&desc->list);
  786. spin_unlock_irqrestore(&ichan->lock, flags);
  787. tx->cookie = cookie;
  788. ichan->dma_chan.cookie = cookie;
  789. }
  790. }
  791. dump_idmac_reg(ipu);
  792. out:
  793. mutex_unlock(&ichan->chan_mutex);
  794. return cookie;
  795. }
  796. /* Called with ichan->chan_mutex held */
  797. static int idmac_desc_alloc(struct idmac_channel *ichan, int n)
  798. {
  799. struct idmac_tx_desc *desc = vmalloc(n * sizeof(struct idmac_tx_desc));
  800. struct idmac *idmac = to_idmac(ichan->dma_chan.device);
  801. if (!desc)
  802. return -ENOMEM;
  803. /* No interrupts, just disable the tasklet for a moment */
  804. tasklet_disable(&to_ipu(idmac)->tasklet);
  805. ichan->n_tx_desc = n;
  806. ichan->desc = desc;
  807. INIT_LIST_HEAD(&ichan->queue);
  808. INIT_LIST_HEAD(&ichan->free_list);
  809. while (n--) {
  810. struct dma_async_tx_descriptor *txd = &desc->txd;
  811. memset(txd, 0, sizeof(*txd));
  812. dma_async_tx_descriptor_init(txd, &ichan->dma_chan);
  813. txd->tx_submit = idmac_tx_submit;
  814. txd->chan = &ichan->dma_chan;
  815. INIT_LIST_HEAD(&txd->tx_list);
  816. list_add(&desc->list, &ichan->free_list);
  817. desc++;
  818. }
  819. tasklet_enable(&to_ipu(idmac)->tasklet);
  820. return 0;
  821. }
  822. /**
  823. * ipu_init_channel() - initialize an IPU channel.
  824. * @idmac: IPU DMAC context.
  825. * @ichan: pointer to the channel object.
  826. * @return 0 on success or negative error code on failure.
  827. */
  828. static int ipu_init_channel(struct idmac *idmac, struct idmac_channel *ichan)
  829. {
  830. union ipu_channel_param *params = &ichan->params;
  831. uint32_t ipu_conf;
  832. enum ipu_channel channel = ichan->dma_chan.chan_id;
  833. unsigned long flags;
  834. uint32_t reg;
  835. struct ipu *ipu = to_ipu(idmac);
  836. int ret = 0, n_desc = 0;
  837. dev_dbg(ipu->dev, "init channel = %d\n", channel);
  838. if (channel != IDMAC_SDC_0 && channel != IDMAC_SDC_1 &&
  839. channel != IDMAC_IC_7)
  840. return -EINVAL;
  841. spin_lock_irqsave(&ipu->lock, flags);
  842. switch (channel) {
  843. case IDMAC_IC_7:
  844. n_desc = 16;
  845. reg = idmac_read_icreg(ipu, IC_CONF);
  846. idmac_write_icreg(ipu, reg & ~IC_CONF_CSI_MEM_WR_EN, IC_CONF);
  847. break;
  848. case IDMAC_IC_0:
  849. n_desc = 16;
  850. reg = idmac_read_ipureg(ipu, IPU_FS_PROC_FLOW);
  851. idmac_write_ipureg(ipu, reg & ~FS_ENC_IN_VALID, IPU_FS_PROC_FLOW);
  852. ret = ipu_ic_init_prpenc(ipu, params, true);
  853. break;
  854. case IDMAC_SDC_0:
  855. case IDMAC_SDC_1:
  856. n_desc = 4;
  857. default:
  858. break;
  859. }
  860. ipu->channel_init_mask |= 1L << channel;
  861. /* Enable IPU sub module */
  862. ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) |
  863. ipu_channel_conf_mask(channel);
  864. idmac_write_ipureg(ipu, ipu_conf, IPU_CONF);
  865. spin_unlock_irqrestore(&ipu->lock, flags);
  866. if (n_desc && !ichan->desc)
  867. ret = idmac_desc_alloc(ichan, n_desc);
  868. dump_idmac_reg(ipu);
  869. return ret;
  870. }
  871. /**
  872. * ipu_uninit_channel() - uninitialize an IPU channel.
  873. * @idmac: IPU DMAC context.
  874. * @ichan: pointer to the channel object.
  875. */
  876. static void ipu_uninit_channel(struct idmac *idmac, struct idmac_channel *ichan)
  877. {
  878. enum ipu_channel channel = ichan->dma_chan.chan_id;
  879. unsigned long flags;
  880. uint32_t reg;
  881. unsigned long chan_mask = 1UL << channel;
  882. uint32_t ipu_conf;
  883. struct ipu *ipu = to_ipu(idmac);
  884. spin_lock_irqsave(&ipu->lock, flags);
  885. if (!(ipu->channel_init_mask & chan_mask)) {
  886. dev_err(ipu->dev, "Channel already uninitialized %d\n",
  887. channel);
  888. spin_unlock_irqrestore(&ipu->lock, flags);
  889. return;
  890. }
  891. /* Reset the double buffer */
  892. reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL);
  893. idmac_write_ipureg(ipu, reg & ~chan_mask, IPU_CHA_DB_MODE_SEL);
  894. ichan->sec_chan_en = false;
  895. switch (channel) {
  896. case IDMAC_IC_7:
  897. reg = idmac_read_icreg(ipu, IC_CONF);
  898. idmac_write_icreg(ipu, reg & ~(IC_CONF_RWS_EN | IC_CONF_PRPENC_EN),
  899. IC_CONF);
  900. break;
  901. case IDMAC_IC_0:
  902. reg = idmac_read_icreg(ipu, IC_CONF);
  903. idmac_write_icreg(ipu, reg & ~(IC_CONF_PRPENC_EN | IC_CONF_PRPENC_CSC1),
  904. IC_CONF);
  905. break;
  906. case IDMAC_SDC_0:
  907. case IDMAC_SDC_1:
  908. default:
  909. break;
  910. }
  911. ipu->channel_init_mask &= ~(1L << channel);
  912. ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) &
  913. ~ipu_channel_conf_mask(channel);
  914. idmac_write_ipureg(ipu, ipu_conf, IPU_CONF);
  915. spin_unlock_irqrestore(&ipu->lock, flags);
  916. ichan->n_tx_desc = 0;
  917. vfree(ichan->desc);
  918. ichan->desc = NULL;
  919. }
  920. /**
  921. * ipu_disable_channel() - disable an IPU channel.
  922. * @idmac: IPU DMAC context.
  923. * @ichan: channel object pointer.
  924. * @wait_for_stop: flag to set whether to wait for channel end of frame or
  925. * return immediately.
  926. * @return: 0 on success or negative error code on failure.
  927. */
  928. static int ipu_disable_channel(struct idmac *idmac, struct idmac_channel *ichan,
  929. bool wait_for_stop)
  930. {
  931. enum ipu_channel channel = ichan->dma_chan.chan_id;
  932. struct ipu *ipu = to_ipu(idmac);
  933. uint32_t reg;
  934. unsigned long flags;
  935. unsigned long chan_mask = 1UL << channel;
  936. unsigned int timeout;
  937. if (wait_for_stop && channel != IDMAC_SDC_1 && channel != IDMAC_SDC_0) {
  938. timeout = 40;
  939. /* This waiting always fails. Related to spurious irq problem */
  940. while ((idmac_read_icreg(ipu, IDMAC_CHA_BUSY) & chan_mask) ||
  941. (ipu_channel_status(ipu, channel) == TASK_STAT_ACTIVE)) {
  942. timeout--;
  943. msleep(10);
  944. if (!timeout) {
  945. dev_dbg(ipu->dev,
  946. "Warning: timeout waiting for channel %u to "
  947. "stop: buf0_rdy = 0x%08X, buf1_rdy = 0x%08X, "
  948. "busy = 0x%08X, tstat = 0x%08X\n", channel,
  949. idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY),
  950. idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY),
  951. idmac_read_icreg(ipu, IDMAC_CHA_BUSY),
  952. idmac_read_ipureg(ipu, IPU_TASKS_STAT));
  953. break;
  954. }
  955. }
  956. dev_dbg(ipu->dev, "timeout = %d * 10ms\n", 40 - timeout);
  957. }
  958. /* SDC BG and FG must be disabled before DMA is disabled */
  959. if (wait_for_stop && (channel == IDMAC_SDC_0 ||
  960. channel == IDMAC_SDC_1)) {
  961. for (timeout = 5;
  962. timeout && !ipu_irq_status(ichan->eof_irq); timeout--)
  963. msleep(5);
  964. }
  965. spin_lock_irqsave(&ipu->lock, flags);
  966. /* Disable IC task */
  967. ipu_ic_disable_task(ipu, channel);
  968. /* Disable DMA channel(s) */
  969. reg = idmac_read_icreg(ipu, IDMAC_CHA_EN);
  970. idmac_write_icreg(ipu, reg & ~chan_mask, IDMAC_CHA_EN);
  971. /*
  972. * Problem (observed with channel DMAIC_7): after enabling the channel
  973. * and initialising buffers, there comes an interrupt with current still
  974. * pointing at buffer 0, whereas it should use buffer 0 first and only
  975. * generate an interrupt when it is done, then current should already
  976. * point to buffer 1. This spurious interrupt also comes on channel
  977. * DMASDC_0. With DMAIC_7 normally, is we just leave the ISR after the
  978. * first interrupt, there comes the second with current correctly
  979. * pointing to buffer 1 this time. But sometimes this second interrupt
  980. * doesn't come and the channel hangs. Clearing BUFx_RDY when disabling
  981. * the channel seems to prevent the channel from hanging, but it doesn't
  982. * prevent the spurious interrupt. This might also be unsafe. Think
  983. * about the IDMAC controller trying to switch to a buffer, when we
  984. * clear the ready bit, and re-enable it a moment later.
  985. */
  986. reg = idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY);
  987. idmac_write_ipureg(ipu, 0, IPU_CHA_BUF0_RDY);
  988. idmac_write_ipureg(ipu, reg & ~(1UL << channel), IPU_CHA_BUF0_RDY);
  989. reg = idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY);
  990. idmac_write_ipureg(ipu, 0, IPU_CHA_BUF1_RDY);
  991. idmac_write_ipureg(ipu, reg & ~(1UL << channel), IPU_CHA_BUF1_RDY);
  992. spin_unlock_irqrestore(&ipu->lock, flags);
  993. return 0;
  994. }
  995. /*
  996. * We have several possibilities here:
  997. * current BUF next BUF
  998. *
  999. * not last sg next not last sg
  1000. * not last sg next last sg
  1001. * last sg first sg from next descriptor
  1002. * last sg NULL
  1003. *
  1004. * Besides, the descriptor queue might be empty or not. We process all these
  1005. * cases carefully.
  1006. */
  1007. static irqreturn_t idmac_interrupt(int irq, void *dev_id)
  1008. {
  1009. struct idmac_channel *ichan = dev_id;
  1010. unsigned int chan_id = ichan->dma_chan.chan_id;
  1011. struct scatterlist **sg, *sgnext, *sgnew = NULL;
  1012. /* Next transfer descriptor */
  1013. struct idmac_tx_desc *desc = NULL, *descnew;
  1014. dma_async_tx_callback callback;
  1015. void *callback_param;
  1016. bool done = false;
  1017. u32 ready0 = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF0_RDY),
  1018. ready1 = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF1_RDY),
  1019. curbuf = idmac_read_ipureg(&ipu_data, IPU_CHA_CUR_BUF);
  1020. /* IDMAC has cleared the respective BUFx_RDY bit, we manage the buffer */
  1021. pr_debug("IDMAC irq %d\n", irq);
  1022. /* Other interrupts do not interfere with this channel */
  1023. spin_lock(&ichan->lock);
  1024. if (unlikely(chan_id != IDMAC_SDC_0 && chan_id != IDMAC_SDC_1 &&
  1025. ((curbuf >> chan_id) & 1) == ichan->active_buffer)) {
  1026. int i = 100;
  1027. /* This doesn't help. See comment in ipu_disable_channel() */
  1028. while (--i) {
  1029. curbuf = idmac_read_ipureg(&ipu_data, IPU_CHA_CUR_BUF);
  1030. if (((curbuf >> chan_id) & 1) != ichan->active_buffer)
  1031. break;
  1032. cpu_relax();
  1033. }
  1034. if (!i) {
  1035. spin_unlock(&ichan->lock);
  1036. dev_dbg(ichan->dma_chan.device->dev,
  1037. "IRQ on active buffer on channel %x, active "
  1038. "%d, ready %x, %x, current %x!\n", chan_id,
  1039. ichan->active_buffer, ready0, ready1, curbuf);
  1040. return IRQ_NONE;
  1041. }
  1042. }
  1043. if (unlikely((ichan->active_buffer && (ready1 >> chan_id) & 1) ||
  1044. (!ichan->active_buffer && (ready0 >> chan_id) & 1)
  1045. )) {
  1046. spin_unlock(&ichan->lock);
  1047. dev_dbg(ichan->dma_chan.device->dev,
  1048. "IRQ with active buffer still ready on channel %x, "
  1049. "active %d, ready %x, %x!\n", chan_id,
  1050. ichan->active_buffer, ready0, ready1);
  1051. return IRQ_NONE;
  1052. }
  1053. if (unlikely(list_empty(&ichan->queue))) {
  1054. spin_unlock(&ichan->lock);
  1055. dev_err(ichan->dma_chan.device->dev,
  1056. "IRQ without queued buffers on channel %x, active %d, "
  1057. "ready %x, %x!\n", chan_id,
  1058. ichan->active_buffer, ready0, ready1);
  1059. return IRQ_NONE;
  1060. }
  1061. /*
  1062. * active_buffer is a software flag, it shows which buffer we are
  1063. * currently expecting back from the hardware, IDMAC should be
  1064. * processing the other buffer already
  1065. */
  1066. sg = &ichan->sg[ichan->active_buffer];
  1067. sgnext = ichan->sg[!ichan->active_buffer];
  1068. /*
  1069. * if sgnext == NULL sg must be the last element in a scatterlist and
  1070. * queue must be empty
  1071. */
  1072. if (unlikely(!sgnext)) {
  1073. if (unlikely(sg_next(*sg))) {
  1074. dev_err(ichan->dma_chan.device->dev,
  1075. "Broken buffer-update locking on channel %x!\n",
  1076. chan_id);
  1077. /* We'll let the user catch up */
  1078. } else {
  1079. /* Underrun */
  1080. ipu_ic_disable_task(&ipu_data, chan_id);
  1081. dev_dbg(ichan->dma_chan.device->dev,
  1082. "Underrun on channel %x\n", chan_id);
  1083. ichan->status = IPU_CHANNEL_READY;
  1084. /* Continue to check for complete descriptor */
  1085. }
  1086. }
  1087. desc = list_entry(ichan->queue.next, struct idmac_tx_desc, list);
  1088. /* First calculate and submit the next sg element */
  1089. if (likely(sgnext))
  1090. sgnew = sg_next(sgnext);
  1091. if (unlikely(!sgnew)) {
  1092. /* Start a new scatterlist, if any queued */
  1093. if (likely(desc->list.next != &ichan->queue)) {
  1094. descnew = list_entry(desc->list.next,
  1095. struct idmac_tx_desc, list);
  1096. sgnew = &descnew->sg[0];
  1097. }
  1098. }
  1099. if (unlikely(!sg_next(*sg)) || !sgnext) {
  1100. /*
  1101. * Last element in scatterlist done, remove from the queue,
  1102. * _init for debugging
  1103. */
  1104. list_del_init(&desc->list);
  1105. done = true;
  1106. }
  1107. *sg = sgnew;
  1108. if (likely(sgnew)) {
  1109. int ret;
  1110. ret = ipu_update_channel_buffer(chan_id, ichan->active_buffer,
  1111. sg_dma_address(*sg));
  1112. if (ret < 0)
  1113. dev_err(ichan->dma_chan.device->dev,
  1114. "Failed to update buffer on channel %x buffer %d!\n",
  1115. chan_id, ichan->active_buffer);
  1116. else
  1117. ipu_select_buffer(chan_id, ichan->active_buffer);
  1118. }
  1119. /* Flip the active buffer - even if update above failed */
  1120. ichan->active_buffer = !ichan->active_buffer;
  1121. if (done)
  1122. ichan->completed = desc->txd.cookie;
  1123. callback = desc->txd.callback;
  1124. callback_param = desc->txd.callback_param;
  1125. spin_unlock(&ichan->lock);
  1126. if (done && (desc->txd.flags & DMA_PREP_INTERRUPT) && callback)
  1127. callback(callback_param);
  1128. return IRQ_HANDLED;
  1129. }
  1130. static void ipu_gc_tasklet(unsigned long arg)
  1131. {
  1132. struct ipu *ipu = (struct ipu *)arg;
  1133. int i;
  1134. for (i = 0; i < IPU_CHANNELS_NUM; i++) {
  1135. struct idmac_channel *ichan = ipu->channel + i;
  1136. struct idmac_tx_desc *desc;
  1137. unsigned long flags;
  1138. int j;
  1139. for (j = 0; j < ichan->n_tx_desc; j++) {
  1140. desc = ichan->desc + j;
  1141. spin_lock_irqsave(&ichan->lock, flags);
  1142. if (async_tx_test_ack(&desc->txd)) {
  1143. list_move(&desc->list, &ichan->free_list);
  1144. async_tx_clear_ack(&desc->txd);
  1145. }
  1146. spin_unlock_irqrestore(&ichan->lock, flags);
  1147. }
  1148. }
  1149. }
  1150. /* Allocate and initialise a transfer descriptor. */
  1151. static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan,
  1152. struct scatterlist *sgl, unsigned int sg_len,
  1153. enum dma_data_direction direction, unsigned long tx_flags)
  1154. {
  1155. struct idmac_channel *ichan = to_idmac_chan(chan);
  1156. struct idmac_tx_desc *desc = NULL;
  1157. struct dma_async_tx_descriptor *txd = NULL;
  1158. unsigned long flags;
  1159. /* We only can handle these three channels so far */
  1160. if (ichan->dma_chan.chan_id != IDMAC_SDC_0 && ichan->dma_chan.chan_id != IDMAC_SDC_1 &&
  1161. ichan->dma_chan.chan_id != IDMAC_IC_7)
  1162. return NULL;
  1163. if (direction != DMA_FROM_DEVICE && direction != DMA_TO_DEVICE) {
  1164. dev_err(chan->device->dev, "Invalid DMA direction %d!\n", direction);
  1165. return NULL;
  1166. }
  1167. mutex_lock(&ichan->chan_mutex);
  1168. spin_lock_irqsave(&ichan->lock, flags);
  1169. if (!list_empty(&ichan->free_list)) {
  1170. desc = list_entry(ichan->free_list.next,
  1171. struct idmac_tx_desc, list);
  1172. list_del_init(&desc->list);
  1173. desc->sg_len = sg_len;
  1174. desc->sg = sgl;
  1175. txd = &desc->txd;
  1176. txd->flags = tx_flags;
  1177. }
  1178. spin_unlock_irqrestore(&ichan->lock, flags);
  1179. mutex_unlock(&ichan->chan_mutex);
  1180. tasklet_schedule(&to_ipu(to_idmac(chan->device))->tasklet);
  1181. return txd;
  1182. }
  1183. /* Re-select the current buffer and re-activate the channel */
  1184. static void idmac_issue_pending(struct dma_chan *chan)
  1185. {
  1186. struct idmac_channel *ichan = to_idmac_chan(chan);
  1187. struct idmac *idmac = to_idmac(chan->device);
  1188. struct ipu *ipu = to_ipu(idmac);
  1189. unsigned long flags;
  1190. /* This is not always needed, but doesn't hurt either */
  1191. spin_lock_irqsave(&ipu->lock, flags);
  1192. ipu_select_buffer(ichan->dma_chan.chan_id, ichan->active_buffer);
  1193. spin_unlock_irqrestore(&ipu->lock, flags);
  1194. /*
  1195. * Might need to perform some parts of initialisation from
  1196. * ipu_enable_channel(), but not all, we do not want to reset to buffer
  1197. * 0, don't need to set priority again either, but re-enabling the task
  1198. * and the channel might be a good idea.
  1199. */
  1200. }
  1201. static void __idmac_terminate_all(struct dma_chan *chan)
  1202. {
  1203. struct idmac_channel *ichan = to_idmac_chan(chan);
  1204. struct idmac *idmac = to_idmac(chan->device);
  1205. unsigned long flags;
  1206. int i;
  1207. ipu_disable_channel(idmac, ichan,
  1208. ichan->status >= IPU_CHANNEL_ENABLED);
  1209. tasklet_disable(&to_ipu(idmac)->tasklet);
  1210. /* ichan->queue is modified in ISR, have to spinlock */
  1211. spin_lock_irqsave(&ichan->lock, flags);
  1212. list_splice_init(&ichan->queue, &ichan->free_list);
  1213. if (ichan->desc)
  1214. for (i = 0; i < ichan->n_tx_desc; i++) {
  1215. struct idmac_tx_desc *desc = ichan->desc + i;
  1216. if (list_empty(&desc->list))
  1217. /* Descriptor was prepared, but not submitted */
  1218. list_add(&desc->list, &ichan->free_list);
  1219. async_tx_clear_ack(&desc->txd);
  1220. }
  1221. ichan->sg[0] = NULL;
  1222. ichan->sg[1] = NULL;
  1223. spin_unlock_irqrestore(&ichan->lock, flags);
  1224. tasklet_enable(&to_ipu(idmac)->tasklet);
  1225. ichan->status = IPU_CHANNEL_INITIALIZED;
  1226. }
  1227. static void idmac_terminate_all(struct dma_chan *chan)
  1228. {
  1229. struct idmac_channel *ichan = to_idmac_chan(chan);
  1230. mutex_lock(&ichan->chan_mutex);
  1231. __idmac_terminate_all(chan);
  1232. mutex_unlock(&ichan->chan_mutex);
  1233. }
  1234. static int idmac_alloc_chan_resources(struct dma_chan *chan)
  1235. {
  1236. struct idmac_channel *ichan = to_idmac_chan(chan);
  1237. struct idmac *idmac = to_idmac(chan->device);
  1238. int ret;
  1239. /* dmaengine.c now guarantees to only offer free channels */
  1240. BUG_ON(chan->client_count > 1);
  1241. WARN_ON(ichan->status != IPU_CHANNEL_FREE);
  1242. chan->cookie = 1;
  1243. ichan->completed = -ENXIO;
  1244. ret = ipu_irq_map(ichan->dma_chan.chan_id);
  1245. if (ret < 0)
  1246. goto eimap;
  1247. ichan->eof_irq = ret;
  1248. ret = request_irq(ichan->eof_irq, idmac_interrupt, 0,
  1249. ichan->eof_name, ichan);
  1250. if (ret < 0)
  1251. goto erirq;
  1252. ret = ipu_init_channel(idmac, ichan);
  1253. if (ret < 0)
  1254. goto eichan;
  1255. ichan->status = IPU_CHANNEL_INITIALIZED;
  1256. dev_dbg(&ichan->dma_chan.dev->device, "Found channel 0x%x, irq %d\n",
  1257. ichan->dma_chan.chan_id, ichan->eof_irq);
  1258. return ret;
  1259. eichan:
  1260. free_irq(ichan->eof_irq, ichan);
  1261. erirq:
  1262. ipu_irq_unmap(ichan->dma_chan.chan_id);
  1263. eimap:
  1264. return ret;
  1265. }
  1266. static void idmac_free_chan_resources(struct dma_chan *chan)
  1267. {
  1268. struct idmac_channel *ichan = to_idmac_chan(chan);
  1269. struct idmac *idmac = to_idmac(chan->device);
  1270. mutex_lock(&ichan->chan_mutex);
  1271. __idmac_terminate_all(chan);
  1272. if (ichan->status > IPU_CHANNEL_FREE) {
  1273. free_irq(ichan->eof_irq, ichan);
  1274. ipu_irq_unmap(ichan->dma_chan.chan_id);
  1275. }
  1276. ichan->status = IPU_CHANNEL_FREE;
  1277. ipu_uninit_channel(idmac, ichan);
  1278. mutex_unlock(&ichan->chan_mutex);
  1279. tasklet_schedule(&to_ipu(idmac)->tasklet);
  1280. }
  1281. static enum dma_status idmac_is_tx_complete(struct dma_chan *chan,
  1282. dma_cookie_t cookie, dma_cookie_t *done, dma_cookie_t *used)
  1283. {
  1284. struct idmac_channel *ichan = to_idmac_chan(chan);
  1285. if (done)
  1286. *done = ichan->completed;
  1287. if (used)
  1288. *used = chan->cookie;
  1289. if (cookie != chan->cookie)
  1290. return DMA_ERROR;
  1291. return DMA_SUCCESS;
  1292. }
  1293. static int __init ipu_idmac_init(struct ipu *ipu)
  1294. {
  1295. struct idmac *idmac = &ipu->idmac;
  1296. struct dma_device *dma = &idmac->dma;
  1297. int i;
  1298. dma_cap_set(DMA_SLAVE, dma->cap_mask);
  1299. dma_cap_set(DMA_PRIVATE, dma->cap_mask);
  1300. /* Compulsory common fields */
  1301. dma->dev = ipu->dev;
  1302. dma->device_alloc_chan_resources = idmac_alloc_chan_resources;
  1303. dma->device_free_chan_resources = idmac_free_chan_resources;
  1304. dma->device_is_tx_complete = idmac_is_tx_complete;
  1305. dma->device_issue_pending = idmac_issue_pending;
  1306. /* Compulsory for DMA_SLAVE fields */
  1307. dma->device_prep_slave_sg = idmac_prep_slave_sg;
  1308. dma->device_terminate_all = idmac_terminate_all;
  1309. INIT_LIST_HEAD(&dma->channels);
  1310. for (i = 0; i < IPU_CHANNELS_NUM; i++) {
  1311. struct idmac_channel *ichan = ipu->channel + i;
  1312. struct dma_chan *dma_chan = &ichan->dma_chan;
  1313. spin_lock_init(&ichan->lock);
  1314. mutex_init(&ichan->chan_mutex);
  1315. ichan->status = IPU_CHANNEL_FREE;
  1316. ichan->sec_chan_en = false;
  1317. ichan->completed = -ENXIO;
  1318. snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
  1319. dma_chan->device = &idmac->dma;
  1320. dma_chan->cookie = 1;
  1321. dma_chan->chan_id = i;
  1322. list_add_tail(&ichan->dma_chan.device_node, &dma->channels);
  1323. }
  1324. idmac_write_icreg(ipu, 0x00000070, IDMAC_CONF);
  1325. return dma_async_device_register(&idmac->dma);
  1326. }
  1327. static void __exit ipu_idmac_exit(struct ipu *ipu)
  1328. {
  1329. int i;
  1330. struct idmac *idmac = &ipu->idmac;
  1331. for (i = 0; i < IPU_CHANNELS_NUM; i++) {
  1332. struct idmac_channel *ichan = ipu->channel + i;
  1333. idmac_terminate_all(&ichan->dma_chan);
  1334. idmac_prep_slave_sg(&ichan->dma_chan, NULL, 0, DMA_NONE, 0);
  1335. }
  1336. dma_async_device_unregister(&idmac->dma);
  1337. }
  1338. /*****************************************************************************
  1339. * IPU common probe / remove
  1340. */
  1341. static int __init ipu_probe(struct platform_device *pdev)
  1342. {
  1343. struct ipu_platform_data *pdata = pdev->dev.platform_data;
  1344. struct resource *mem_ipu, *mem_ic;
  1345. int ret;
  1346. spin_lock_init(&ipu_data.lock);
  1347. mem_ipu = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1348. mem_ic = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  1349. if (!pdata || !mem_ipu || !mem_ic)
  1350. return -EINVAL;
  1351. ipu_data.dev = &pdev->dev;
  1352. platform_set_drvdata(pdev, &ipu_data);
  1353. ret = platform_get_irq(pdev, 0);
  1354. if (ret < 0)
  1355. goto err_noirq;
  1356. ipu_data.irq_fn = ret;
  1357. ret = platform_get_irq(pdev, 1);
  1358. if (ret < 0)
  1359. goto err_noirq;
  1360. ipu_data.irq_err = ret;
  1361. ipu_data.irq_base = pdata->irq_base;
  1362. dev_dbg(&pdev->dev, "fn irq %u, err irq %u, irq-base %u\n",
  1363. ipu_data.irq_fn, ipu_data.irq_err, ipu_data.irq_base);
  1364. /* Remap IPU common registers */
  1365. ipu_data.reg_ipu = ioremap(mem_ipu->start,
  1366. mem_ipu->end - mem_ipu->start + 1);
  1367. if (!ipu_data.reg_ipu) {
  1368. ret = -ENOMEM;
  1369. goto err_ioremap_ipu;
  1370. }
  1371. /* Remap Image Converter and Image DMA Controller registers */
  1372. ipu_data.reg_ic = ioremap(mem_ic->start,
  1373. mem_ic->end - mem_ic->start + 1);
  1374. if (!ipu_data.reg_ic) {
  1375. ret = -ENOMEM;
  1376. goto err_ioremap_ic;
  1377. }
  1378. /* Get IPU clock */
  1379. ipu_data.ipu_clk = clk_get(&pdev->dev, "ipu_clk");
  1380. if (IS_ERR(ipu_data.ipu_clk)) {
  1381. ret = PTR_ERR(ipu_data.ipu_clk);
  1382. goto err_clk_get;
  1383. }
  1384. /* Make sure IPU HSP clock is running */
  1385. clk_enable(ipu_data.ipu_clk);
  1386. /* Disable all interrupts */
  1387. idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_1);
  1388. idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_2);
  1389. idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_3);
  1390. idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_4);
  1391. idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_5);
  1392. dev_dbg(&pdev->dev, "%s @ 0x%08lx, fn irq %u, err irq %u\n", pdev->name,
  1393. (unsigned long)mem_ipu->start, ipu_data.irq_fn, ipu_data.irq_err);
  1394. ret = ipu_irq_attach_irq(&ipu_data, pdev);
  1395. if (ret < 0)
  1396. goto err_attach_irq;
  1397. /* Initialize DMA engine */
  1398. ret = ipu_idmac_init(&ipu_data);
  1399. if (ret < 0)
  1400. goto err_idmac_init;
  1401. tasklet_init(&ipu_data.tasklet, ipu_gc_tasklet, (unsigned long)&ipu_data);
  1402. ipu_data.dev = &pdev->dev;
  1403. dev_dbg(ipu_data.dev, "IPU initialized\n");
  1404. return 0;
  1405. err_idmac_init:
  1406. err_attach_irq:
  1407. ipu_irq_detach_irq(&ipu_data, pdev);
  1408. clk_disable(ipu_data.ipu_clk);
  1409. clk_put(ipu_data.ipu_clk);
  1410. err_clk_get:
  1411. iounmap(ipu_data.reg_ic);
  1412. err_ioremap_ic:
  1413. iounmap(ipu_data.reg_ipu);
  1414. err_ioremap_ipu:
  1415. err_noirq:
  1416. dev_err(&pdev->dev, "Failed to probe IPU: %d\n", ret);
  1417. return ret;
  1418. }
  1419. static int __exit ipu_remove(struct platform_device *pdev)
  1420. {
  1421. struct ipu *ipu = platform_get_drvdata(pdev);
  1422. ipu_idmac_exit(ipu);
  1423. ipu_irq_detach_irq(ipu, pdev);
  1424. clk_disable(ipu->ipu_clk);
  1425. clk_put(ipu->ipu_clk);
  1426. iounmap(ipu->reg_ic);
  1427. iounmap(ipu->reg_ipu);
  1428. tasklet_kill(&ipu->tasklet);
  1429. platform_set_drvdata(pdev, NULL);
  1430. return 0;
  1431. }
  1432. /*
  1433. * We need two MEM resources - with IPU-common and Image Converter registers,
  1434. * including PF_CONF and IDMAC_* registers, and two IRQs - function and error
  1435. */
  1436. static struct platform_driver ipu_platform_driver = {
  1437. .driver = {
  1438. .name = "ipu-core",
  1439. .owner = THIS_MODULE,
  1440. },
  1441. .remove = __exit_p(ipu_remove),
  1442. };
  1443. static int __init ipu_init(void)
  1444. {
  1445. return platform_driver_probe(&ipu_platform_driver, ipu_probe);
  1446. }
  1447. subsys_initcall(ipu_init);
  1448. MODULE_DESCRIPTION("IPU core driver");
  1449. MODULE_LICENSE("GPL v2");
  1450. MODULE_AUTHOR("Guennadi Liakhovetski <lg@denx.de>");
  1451. MODULE_ALIAS("platform:ipu-core");