ipu_idmac.c 45 KB

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