isp.c 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252
  1. /*
  2. * isp.c
  3. *
  4. * TI OMAP3 ISP - Core
  5. *
  6. * Copyright (C) 2006-2010 Nokia Corporation
  7. * Copyright (C) 2007-2009 Texas Instruments, Inc.
  8. *
  9. * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  10. * Sakari Ailus <sakari.ailus@iki.fi>
  11. *
  12. * Contributors:
  13. * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  14. * Sakari Ailus <sakari.ailus@iki.fi>
  15. * David Cohen <dacohen@gmail.com>
  16. * Stanimir Varbanov <svarbanov@mm-sol.com>
  17. * Vimarsh Zutshi <vimarsh.zutshi@gmail.com>
  18. * Tuukka Toivonen <tuukkat76@gmail.com>
  19. * Sergio Aguirre <saaguirre@ti.com>
  20. * Antti Koskipaa <akoskipa@gmail.com>
  21. * Ivan T. Ivanov <iivanov@mm-sol.com>
  22. * RaniSuneela <r-m@ti.com>
  23. * Atanas Filipov <afilipov@mm-sol.com>
  24. * Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
  25. * Hiroshi DOYU <hiroshi.doyu@nokia.com>
  26. * Nayden Kanchev <nkanchev@mm-sol.com>
  27. * Phil Carmody <ext-phil.2.carmody@nokia.com>
  28. * Artem Bityutskiy <artem.bityutskiy@nokia.com>
  29. * Dominic Curran <dcurran@ti.com>
  30. * Ilkka Myllyperkio <ilkka.myllyperkio@sofica.fi>
  31. * Pallavi Kulkarni <p-kulkarni@ti.com>
  32. * Vaibhav Hiremath <hvaibhav@ti.com>
  33. * Mohit Jalori <mjalori@ti.com>
  34. * Sameer Venkatraman <sameerv@ti.com>
  35. * Senthilvadivu Guruswamy <svadivu@ti.com>
  36. * Thara Gopinath <thara@ti.com>
  37. * Toni Leinonen <toni.leinonen@nokia.com>
  38. * Troy Laramy <t-laramy@ti.com>
  39. *
  40. * This program is free software; you can redistribute it and/or modify
  41. * it under the terms of the GNU General Public License version 2 as
  42. * published by the Free Software Foundation.
  43. *
  44. * This program is distributed in the hope that it will be useful, but
  45. * WITHOUT ANY WARRANTY; without even the implied warranty of
  46. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  47. * General Public License for more details.
  48. *
  49. * You should have received a copy of the GNU General Public License
  50. * along with this program; if not, write to the Free Software
  51. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  52. * 02110-1301 USA
  53. */
  54. #include <asm/cacheflush.h>
  55. #include <linux/clk.h>
  56. #include <linux/delay.h>
  57. #include <linux/device.h>
  58. #include <linux/dma-mapping.h>
  59. #include <linux/i2c.h>
  60. #include <linux/interrupt.h>
  61. #include <linux/module.h>
  62. #include <linux/platform_device.h>
  63. #include <linux/regulator/consumer.h>
  64. #include <linux/slab.h>
  65. #include <linux/sched.h>
  66. #include <linux/vmalloc.h>
  67. #include <media/v4l2-common.h>
  68. #include <media/v4l2-device.h>
  69. #include "isp.h"
  70. #include "ispreg.h"
  71. #include "ispccdc.h"
  72. #include "isppreview.h"
  73. #include "ispresizer.h"
  74. #include "ispcsi2.h"
  75. #include "ispccp2.h"
  76. #include "isph3a.h"
  77. #include "isphist.h"
  78. static unsigned int autoidle;
  79. module_param(autoidle, int, 0444);
  80. MODULE_PARM_DESC(autoidle, "Enable OMAP3ISP AUTOIDLE support");
  81. static void isp_save_ctx(struct isp_device *isp);
  82. static void isp_restore_ctx(struct isp_device *isp);
  83. static const struct isp_res_mapping isp_res_maps[] = {
  84. {
  85. .isp_rev = ISP_REVISION_2_0,
  86. .map = 1 << OMAP3_ISP_IOMEM_MAIN |
  87. 1 << OMAP3_ISP_IOMEM_CCP2 |
  88. 1 << OMAP3_ISP_IOMEM_CCDC |
  89. 1 << OMAP3_ISP_IOMEM_HIST |
  90. 1 << OMAP3_ISP_IOMEM_H3A |
  91. 1 << OMAP3_ISP_IOMEM_PREV |
  92. 1 << OMAP3_ISP_IOMEM_RESZ |
  93. 1 << OMAP3_ISP_IOMEM_SBL |
  94. 1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 |
  95. 1 << OMAP3_ISP_IOMEM_CSIPHY2,
  96. },
  97. {
  98. .isp_rev = ISP_REVISION_15_0,
  99. .map = 1 << OMAP3_ISP_IOMEM_MAIN |
  100. 1 << OMAP3_ISP_IOMEM_CCP2 |
  101. 1 << OMAP3_ISP_IOMEM_CCDC |
  102. 1 << OMAP3_ISP_IOMEM_HIST |
  103. 1 << OMAP3_ISP_IOMEM_H3A |
  104. 1 << OMAP3_ISP_IOMEM_PREV |
  105. 1 << OMAP3_ISP_IOMEM_RESZ |
  106. 1 << OMAP3_ISP_IOMEM_SBL |
  107. 1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 |
  108. 1 << OMAP3_ISP_IOMEM_CSIPHY2 |
  109. 1 << OMAP3_ISP_IOMEM_CSI2A_REGS2 |
  110. 1 << OMAP3_ISP_IOMEM_CSI2C_REGS1 |
  111. 1 << OMAP3_ISP_IOMEM_CSIPHY1 |
  112. 1 << OMAP3_ISP_IOMEM_CSI2C_REGS2,
  113. },
  114. };
  115. /* Structure for saving/restoring ISP module registers */
  116. static struct isp_reg isp_reg_list[] = {
  117. {OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG, 0},
  118. {OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, 0},
  119. {OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, 0},
  120. {0, ISP_TOK_TERM, 0}
  121. };
  122. /*
  123. * omap3isp_flush - Post pending L3 bus writes by doing a register readback
  124. * @isp: OMAP3 ISP device
  125. *
  126. * In order to force posting of pending writes, we need to write and
  127. * readback the same register, in this case the revision register.
  128. *
  129. * See this link for reference:
  130. * http://www.mail-archive.com/linux-omap@vger.kernel.org/msg08149.html
  131. */
  132. void omap3isp_flush(struct isp_device *isp)
  133. {
  134. isp_reg_writel(isp, 0, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
  135. isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
  136. }
  137. /*
  138. * isp_enable_interrupts - Enable ISP interrupts.
  139. * @isp: OMAP3 ISP device
  140. */
  141. static void isp_enable_interrupts(struct isp_device *isp)
  142. {
  143. static const u32 irq = IRQ0ENABLE_CSIA_IRQ
  144. | IRQ0ENABLE_CSIB_IRQ
  145. | IRQ0ENABLE_CCDC_LSC_PREF_ERR_IRQ
  146. | IRQ0ENABLE_CCDC_LSC_DONE_IRQ
  147. | IRQ0ENABLE_CCDC_VD0_IRQ
  148. | IRQ0ENABLE_CCDC_VD1_IRQ
  149. | IRQ0ENABLE_HS_VS_IRQ
  150. | IRQ0ENABLE_HIST_DONE_IRQ
  151. | IRQ0ENABLE_H3A_AWB_DONE_IRQ
  152. | IRQ0ENABLE_H3A_AF_DONE_IRQ
  153. | IRQ0ENABLE_PRV_DONE_IRQ
  154. | IRQ0ENABLE_RSZ_DONE_IRQ;
  155. isp_reg_writel(isp, irq, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
  156. isp_reg_writel(isp, irq, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0ENABLE);
  157. }
  158. /*
  159. * isp_disable_interrupts - Disable ISP interrupts.
  160. * @isp: OMAP3 ISP device
  161. */
  162. static void isp_disable_interrupts(struct isp_device *isp)
  163. {
  164. isp_reg_writel(isp, 0, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0ENABLE);
  165. }
  166. /**
  167. * isp_set_xclk - Configures the specified cam_xclk to the desired frequency.
  168. * @isp: OMAP3 ISP device
  169. * @xclk: Desired frequency of the clock in Hz. 0 = stable low, 1 is stable high
  170. * @xclksel: XCLK to configure (0 = A, 1 = B).
  171. *
  172. * Configures the specified MCLK divisor in the ISP timing control register
  173. * (TCTRL_CTRL) to generate the desired xclk clock value.
  174. *
  175. * Divisor = cam_mclk_hz / xclk
  176. *
  177. * Returns the final frequency that is actually being generated
  178. **/
  179. static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel)
  180. {
  181. u32 divisor;
  182. u32 currentxclk;
  183. unsigned long mclk_hz;
  184. if (!omap3isp_get(isp))
  185. return 0;
  186. mclk_hz = clk_get_rate(isp->clock[ISP_CLK_CAM_MCLK]);
  187. if (xclk >= mclk_hz) {
  188. divisor = ISPTCTRL_CTRL_DIV_BYPASS;
  189. currentxclk = mclk_hz;
  190. } else if (xclk >= 2) {
  191. divisor = mclk_hz / xclk;
  192. if (divisor >= ISPTCTRL_CTRL_DIV_BYPASS)
  193. divisor = ISPTCTRL_CTRL_DIV_BYPASS - 1;
  194. currentxclk = mclk_hz / divisor;
  195. } else {
  196. divisor = xclk;
  197. currentxclk = 0;
  198. }
  199. switch (xclksel) {
  200. case ISP_XCLK_A:
  201. isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
  202. ISPTCTRL_CTRL_DIVA_MASK,
  203. divisor << ISPTCTRL_CTRL_DIVA_SHIFT);
  204. dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n",
  205. currentxclk);
  206. break;
  207. case ISP_XCLK_B:
  208. isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
  209. ISPTCTRL_CTRL_DIVB_MASK,
  210. divisor << ISPTCTRL_CTRL_DIVB_SHIFT);
  211. dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n",
  212. currentxclk);
  213. break;
  214. case ISP_XCLK_NONE:
  215. default:
  216. omap3isp_put(isp);
  217. dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested "
  218. "xclk. Must be 0 (A) or 1 (B).\n");
  219. return -EINVAL;
  220. }
  221. /* Do we go from stable whatever to clock? */
  222. if (divisor >= 2 && isp->xclk_divisor[xclksel - 1] < 2)
  223. omap3isp_get(isp);
  224. /* Stopping the clock. */
  225. else if (divisor < 2 && isp->xclk_divisor[xclksel - 1] >= 2)
  226. omap3isp_put(isp);
  227. isp->xclk_divisor[xclksel - 1] = divisor;
  228. omap3isp_put(isp);
  229. return currentxclk;
  230. }
  231. /*
  232. * isp_power_settings - Sysconfig settings, for Power Management.
  233. * @isp: OMAP3 ISP device
  234. * @idle: Consider idle state.
  235. *
  236. * Sets the power settings for the ISP, and SBL bus.
  237. */
  238. static void isp_power_settings(struct isp_device *isp, int idle)
  239. {
  240. isp_reg_writel(isp,
  241. ((idle ? ISP_SYSCONFIG_MIDLEMODE_SMARTSTANDBY :
  242. ISP_SYSCONFIG_MIDLEMODE_FORCESTANDBY) <<
  243. ISP_SYSCONFIG_MIDLEMODE_SHIFT) |
  244. ((isp->revision == ISP_REVISION_15_0) ?
  245. ISP_SYSCONFIG_AUTOIDLE : 0),
  246. OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
  247. if (isp->autoidle)
  248. isp_reg_writel(isp, ISPCTRL_SBL_AUTOIDLE, OMAP3_ISP_IOMEM_MAIN,
  249. ISP_CTRL);
  250. }
  251. /*
  252. * Configure the bridge and lane shifter. Valid inputs are
  253. *
  254. * CCDC_INPUT_PARALLEL: Parallel interface
  255. * CCDC_INPUT_CSI2A: CSI2a receiver
  256. * CCDC_INPUT_CCP2B: CCP2b receiver
  257. * CCDC_INPUT_CSI2C: CSI2c receiver
  258. *
  259. * The bridge and lane shifter are configured according to the selected input
  260. * and the ISP platform data.
  261. */
  262. void omap3isp_configure_bridge(struct isp_device *isp,
  263. enum ccdc_input_entity input,
  264. const struct isp_parallel_platform_data *pdata,
  265. unsigned int shift)
  266. {
  267. u32 ispctrl_val;
  268. ispctrl_val = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL);
  269. ispctrl_val &= ~ISPCTRL_SHIFT_MASK;
  270. ispctrl_val &= ~ISPCTRL_PAR_CLK_POL_INV;
  271. ispctrl_val &= ~ISPCTRL_PAR_SER_CLK_SEL_MASK;
  272. ispctrl_val &= ~ISPCTRL_PAR_BRIDGE_MASK;
  273. switch (input) {
  274. case CCDC_INPUT_PARALLEL:
  275. ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
  276. ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
  277. ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT;
  278. shift += pdata->data_lane_shift * 2;
  279. break;
  280. case CCDC_INPUT_CSI2A:
  281. ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_CSIA;
  282. break;
  283. case CCDC_INPUT_CCP2B:
  284. ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_CSIB;
  285. break;
  286. case CCDC_INPUT_CSI2C:
  287. ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_CSIC;
  288. break;
  289. default:
  290. return;
  291. }
  292. ispctrl_val |= ((shift/2) << ISPCTRL_SHIFT_SHIFT) & ISPCTRL_SHIFT_MASK;
  293. ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK;
  294. ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE;
  295. isp_reg_writel(isp, ispctrl_val, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL);
  296. }
  297. /**
  298. * isp_set_pixel_clock - Configures the ISP pixel clock
  299. * @isp: OMAP3 ISP device
  300. * @pixelclk: Average pixel clock in Hz
  301. *
  302. * Set the average pixel clock required by the sensor. The ISP will use the
  303. * lowest possible memory bandwidth settings compatible with the clock.
  304. **/
  305. static void isp_set_pixel_clock(struct isp_device *isp, unsigned int pixelclk)
  306. {
  307. isp->isp_ccdc.vpcfg.pixelclk = pixelclk;
  308. }
  309. void omap3isp_hist_dma_done(struct isp_device *isp)
  310. {
  311. if (omap3isp_ccdc_busy(&isp->isp_ccdc) ||
  312. omap3isp_stat_pcr_busy(&isp->isp_hist)) {
  313. /* Histogram cannot be enabled in this frame anymore */
  314. atomic_set(&isp->isp_hist.buf_err, 1);
  315. dev_dbg(isp->dev, "hist: Out of synchronization with "
  316. "CCDC. Ignoring next buffer.\n");
  317. }
  318. }
  319. static inline void isp_isr_dbg(struct isp_device *isp, u32 irqstatus)
  320. {
  321. static const char *name[] = {
  322. "CSIA_IRQ",
  323. "res1",
  324. "res2",
  325. "CSIB_LCM_IRQ",
  326. "CSIB_IRQ",
  327. "res5",
  328. "res6",
  329. "res7",
  330. "CCDC_VD0_IRQ",
  331. "CCDC_VD1_IRQ",
  332. "CCDC_VD2_IRQ",
  333. "CCDC_ERR_IRQ",
  334. "H3A_AF_DONE_IRQ",
  335. "H3A_AWB_DONE_IRQ",
  336. "res14",
  337. "res15",
  338. "HIST_DONE_IRQ",
  339. "CCDC_LSC_DONE",
  340. "CCDC_LSC_PREFETCH_COMPLETED",
  341. "CCDC_LSC_PREFETCH_ERROR",
  342. "PRV_DONE_IRQ",
  343. "CBUFF_IRQ",
  344. "res22",
  345. "res23",
  346. "RSZ_DONE_IRQ",
  347. "OVF_IRQ",
  348. "res26",
  349. "res27",
  350. "MMU_ERR_IRQ",
  351. "OCP_ERR_IRQ",
  352. "SEC_ERR_IRQ",
  353. "HS_VS_IRQ",
  354. };
  355. int i;
  356. dev_dbg(isp->dev, "ISP IRQ: ");
  357. for (i = 0; i < ARRAY_SIZE(name); i++) {
  358. if ((1 << i) & irqstatus)
  359. printk(KERN_CONT "%s ", name[i]);
  360. }
  361. printk(KERN_CONT "\n");
  362. }
  363. static void isp_isr_sbl(struct isp_device *isp)
  364. {
  365. struct device *dev = isp->dev;
  366. struct isp_pipeline *pipe;
  367. u32 sbl_pcr;
  368. /*
  369. * Handle shared buffer logic overflows for video buffers.
  370. * ISPSBL_PCR_CCDCPRV_2_RSZ_OVF can be safely ignored.
  371. */
  372. sbl_pcr = isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_PCR);
  373. isp_reg_writel(isp, sbl_pcr, OMAP3_ISP_IOMEM_SBL, ISPSBL_PCR);
  374. sbl_pcr &= ~ISPSBL_PCR_CCDCPRV_2_RSZ_OVF;
  375. if (sbl_pcr)
  376. dev_dbg(dev, "SBL overflow (PCR = 0x%08x)\n", sbl_pcr);
  377. if (sbl_pcr & ISPSBL_PCR_CSIB_WBL_OVF) {
  378. pipe = to_isp_pipeline(&isp->isp_ccp2.subdev.entity);
  379. if (pipe != NULL)
  380. pipe->error = true;
  381. }
  382. if (sbl_pcr & ISPSBL_PCR_CSIA_WBL_OVF) {
  383. pipe = to_isp_pipeline(&isp->isp_csi2a.subdev.entity);
  384. if (pipe != NULL)
  385. pipe->error = true;
  386. }
  387. if (sbl_pcr & ISPSBL_PCR_CCDC_WBL_OVF) {
  388. pipe = to_isp_pipeline(&isp->isp_ccdc.subdev.entity);
  389. if (pipe != NULL)
  390. pipe->error = true;
  391. }
  392. if (sbl_pcr & ISPSBL_PCR_PRV_WBL_OVF) {
  393. pipe = to_isp_pipeline(&isp->isp_prev.subdev.entity);
  394. if (pipe != NULL)
  395. pipe->error = true;
  396. }
  397. if (sbl_pcr & (ISPSBL_PCR_RSZ1_WBL_OVF
  398. | ISPSBL_PCR_RSZ2_WBL_OVF
  399. | ISPSBL_PCR_RSZ3_WBL_OVF
  400. | ISPSBL_PCR_RSZ4_WBL_OVF)) {
  401. pipe = to_isp_pipeline(&isp->isp_res.subdev.entity);
  402. if (pipe != NULL)
  403. pipe->error = true;
  404. }
  405. if (sbl_pcr & ISPSBL_PCR_H3A_AF_WBL_OVF)
  406. omap3isp_stat_sbl_overflow(&isp->isp_af);
  407. if (sbl_pcr & ISPSBL_PCR_H3A_AEAWB_WBL_OVF)
  408. omap3isp_stat_sbl_overflow(&isp->isp_aewb);
  409. }
  410. /*
  411. * isp_isr - Interrupt Service Routine for Camera ISP module.
  412. * @irq: Not used currently.
  413. * @_isp: Pointer to the OMAP3 ISP device
  414. *
  415. * Handles the corresponding callback if plugged in.
  416. *
  417. * Returns IRQ_HANDLED when IRQ was correctly handled, or IRQ_NONE when the
  418. * IRQ wasn't handled.
  419. */
  420. static irqreturn_t isp_isr(int irq, void *_isp)
  421. {
  422. static const u32 ccdc_events = IRQ0STATUS_CCDC_LSC_PREF_ERR_IRQ |
  423. IRQ0STATUS_CCDC_LSC_DONE_IRQ |
  424. IRQ0STATUS_CCDC_VD0_IRQ |
  425. IRQ0STATUS_CCDC_VD1_IRQ |
  426. IRQ0STATUS_HS_VS_IRQ;
  427. struct isp_device *isp = _isp;
  428. u32 irqstatus;
  429. irqstatus = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
  430. isp_reg_writel(isp, irqstatus, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
  431. isp_isr_sbl(isp);
  432. if (irqstatus & IRQ0STATUS_CSIA_IRQ)
  433. omap3isp_csi2_isr(&isp->isp_csi2a);
  434. if (irqstatus & IRQ0STATUS_CSIB_IRQ)
  435. omap3isp_ccp2_isr(&isp->isp_ccp2);
  436. if (irqstatus & IRQ0STATUS_CCDC_VD0_IRQ) {
  437. if (isp->isp_ccdc.output & CCDC_OUTPUT_PREVIEW)
  438. omap3isp_preview_isr_frame_sync(&isp->isp_prev);
  439. if (isp->isp_ccdc.output & CCDC_OUTPUT_RESIZER)
  440. omap3isp_resizer_isr_frame_sync(&isp->isp_res);
  441. omap3isp_stat_isr_frame_sync(&isp->isp_aewb);
  442. omap3isp_stat_isr_frame_sync(&isp->isp_af);
  443. omap3isp_stat_isr_frame_sync(&isp->isp_hist);
  444. }
  445. if (irqstatus & ccdc_events)
  446. omap3isp_ccdc_isr(&isp->isp_ccdc, irqstatus & ccdc_events);
  447. if (irqstatus & IRQ0STATUS_PRV_DONE_IRQ) {
  448. if (isp->isp_prev.output & PREVIEW_OUTPUT_RESIZER)
  449. omap3isp_resizer_isr_frame_sync(&isp->isp_res);
  450. omap3isp_preview_isr(&isp->isp_prev);
  451. }
  452. if (irqstatus & IRQ0STATUS_RSZ_DONE_IRQ)
  453. omap3isp_resizer_isr(&isp->isp_res);
  454. if (irqstatus & IRQ0STATUS_H3A_AWB_DONE_IRQ)
  455. omap3isp_stat_isr(&isp->isp_aewb);
  456. if (irqstatus & IRQ0STATUS_H3A_AF_DONE_IRQ)
  457. omap3isp_stat_isr(&isp->isp_af);
  458. if (irqstatus & IRQ0STATUS_HIST_DONE_IRQ)
  459. omap3isp_stat_isr(&isp->isp_hist);
  460. omap3isp_flush(isp);
  461. #if defined(DEBUG) && defined(ISP_ISR_DEBUG)
  462. isp_isr_dbg(isp, irqstatus);
  463. #endif
  464. return IRQ_HANDLED;
  465. }
  466. /* -----------------------------------------------------------------------------
  467. * Pipeline power management
  468. *
  469. * Entities must be powered up when part of a pipeline that contains at least
  470. * one open video device node.
  471. *
  472. * To achieve this use the entity use_count field to track the number of users.
  473. * For entities corresponding to video device nodes the use_count field stores
  474. * the users count of the node. For entities corresponding to subdevs the
  475. * use_count field stores the total number of users of all video device nodes
  476. * in the pipeline.
  477. *
  478. * The omap3isp_pipeline_pm_use() function must be called in the open() and
  479. * close() handlers of video device nodes. It increments or decrements the use
  480. * count of all subdev entities in the pipeline.
  481. *
  482. * To react to link management on powered pipelines, the link setup notification
  483. * callback updates the use count of all entities in the source and sink sides
  484. * of the link.
  485. */
  486. /*
  487. * isp_pipeline_pm_use_count - Count the number of users of a pipeline
  488. * @entity: The entity
  489. *
  490. * Return the total number of users of all video device nodes in the pipeline.
  491. */
  492. static int isp_pipeline_pm_use_count(struct media_entity *entity)
  493. {
  494. struct media_entity_graph graph;
  495. int use = 0;
  496. media_entity_graph_walk_start(&graph, entity);
  497. while ((entity = media_entity_graph_walk_next(&graph))) {
  498. if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE)
  499. use += entity->use_count;
  500. }
  501. return use;
  502. }
  503. /*
  504. * isp_pipeline_pm_power_one - Apply power change to an entity
  505. * @entity: The entity
  506. * @change: Use count change
  507. *
  508. * Change the entity use count by @change. If the entity is a subdev update its
  509. * power state by calling the core::s_power operation when the use count goes
  510. * from 0 to != 0 or from != 0 to 0.
  511. *
  512. * Return 0 on success or a negative error code on failure.
  513. */
  514. static int isp_pipeline_pm_power_one(struct media_entity *entity, int change)
  515. {
  516. struct v4l2_subdev *subdev;
  517. int ret;
  518. subdev = media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV
  519. ? media_entity_to_v4l2_subdev(entity) : NULL;
  520. if (entity->use_count == 0 && change > 0 && subdev != NULL) {
  521. ret = v4l2_subdev_call(subdev, core, s_power, 1);
  522. if (ret < 0 && ret != -ENOIOCTLCMD)
  523. return ret;
  524. }
  525. entity->use_count += change;
  526. WARN_ON(entity->use_count < 0);
  527. if (entity->use_count == 0 && change < 0 && subdev != NULL)
  528. v4l2_subdev_call(subdev, core, s_power, 0);
  529. return 0;
  530. }
  531. /*
  532. * isp_pipeline_pm_power - Apply power change to all entities in a pipeline
  533. * @entity: The entity
  534. * @change: Use count change
  535. *
  536. * Walk the pipeline to update the use count and the power state of all non-node
  537. * entities.
  538. *
  539. * Return 0 on success or a negative error code on failure.
  540. */
  541. static int isp_pipeline_pm_power(struct media_entity *entity, int change)
  542. {
  543. struct media_entity_graph graph;
  544. struct media_entity *first = entity;
  545. int ret = 0;
  546. if (!change)
  547. return 0;
  548. media_entity_graph_walk_start(&graph, entity);
  549. while (!ret && (entity = media_entity_graph_walk_next(&graph)))
  550. if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE)
  551. ret = isp_pipeline_pm_power_one(entity, change);
  552. if (!ret)
  553. return 0;
  554. media_entity_graph_walk_start(&graph, first);
  555. while ((first = media_entity_graph_walk_next(&graph))
  556. && first != entity)
  557. if (media_entity_type(first) != MEDIA_ENT_T_DEVNODE)
  558. isp_pipeline_pm_power_one(first, -change);
  559. return ret;
  560. }
  561. /*
  562. * omap3isp_pipeline_pm_use - Update the use count of an entity
  563. * @entity: The entity
  564. * @use: Use (1) or stop using (0) the entity
  565. *
  566. * Update the use count of all entities in the pipeline and power entities on or
  567. * off accordingly.
  568. *
  569. * Return 0 on success or a negative error code on failure. Powering entities
  570. * off is assumed to never fail. No failure can occur when the use parameter is
  571. * set to 0.
  572. */
  573. int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
  574. {
  575. int change = use ? 1 : -1;
  576. int ret;
  577. mutex_lock(&entity->parent->graph_mutex);
  578. /* Apply use count to node. */
  579. entity->use_count += change;
  580. WARN_ON(entity->use_count < 0);
  581. /* Apply power change to connected non-nodes. */
  582. ret = isp_pipeline_pm_power(entity, change);
  583. if (ret < 0)
  584. entity->use_count -= change;
  585. mutex_unlock(&entity->parent->graph_mutex);
  586. return ret;
  587. }
  588. /*
  589. * isp_pipeline_link_notify - Link management notification callback
  590. * @source: Pad at the start of the link
  591. * @sink: Pad at the end of the link
  592. * @flags: New link flags that will be applied
  593. *
  594. * React to link management on powered pipelines by updating the use count of
  595. * all entities in the source and sink sides of the link. Entities are powered
  596. * on or off accordingly.
  597. *
  598. * Return 0 on success or a negative error code on failure. Powering entities
  599. * off is assumed to never fail. This function will not fail for disconnection
  600. * events.
  601. */
  602. static int isp_pipeline_link_notify(struct media_pad *source,
  603. struct media_pad *sink, u32 flags)
  604. {
  605. int source_use = isp_pipeline_pm_use_count(source->entity);
  606. int sink_use = isp_pipeline_pm_use_count(sink->entity);
  607. int ret;
  608. if (!(flags & MEDIA_LNK_FL_ENABLED)) {
  609. /* Powering off entities is assumed to never fail. */
  610. isp_pipeline_pm_power(source->entity, -sink_use);
  611. isp_pipeline_pm_power(sink->entity, -source_use);
  612. return 0;
  613. }
  614. ret = isp_pipeline_pm_power(source->entity, sink_use);
  615. if (ret < 0)
  616. return ret;
  617. ret = isp_pipeline_pm_power(sink->entity, source_use);
  618. if (ret < 0)
  619. isp_pipeline_pm_power(source->entity, -sink_use);
  620. return ret;
  621. }
  622. /* -----------------------------------------------------------------------------
  623. * Pipeline stream management
  624. */
  625. /*
  626. * isp_pipeline_enable - Enable streaming on a pipeline
  627. * @pipe: ISP pipeline
  628. * @mode: Stream mode (single shot or continuous)
  629. *
  630. * Walk the entities chain starting at the pipeline output video node and start
  631. * all modules in the chain in the given mode.
  632. *
  633. * Return 0 if successful, or the return value of the failed video::s_stream
  634. * operation otherwise.
  635. */
  636. static int isp_pipeline_enable(struct isp_pipeline *pipe,
  637. enum isp_pipeline_stream_state mode)
  638. {
  639. struct isp_device *isp = pipe->output->isp;
  640. struct media_entity *entity;
  641. struct media_pad *pad;
  642. struct v4l2_subdev *subdev;
  643. unsigned long flags;
  644. int ret;
  645. /* If the preview engine crashed it might not respond to read/write
  646. * operations on the L4 bus. This would result in a bus fault and a
  647. * kernel oops. Refuse to start streaming in that case. This check must
  648. * be performed before the loop below to avoid starting entities if the
  649. * pipeline won't start anyway (those entities would then likely fail to
  650. * stop, making the problem worse).
  651. */
  652. if ((pipe->entities & isp->crashed) &
  653. (1U << isp->isp_prev.subdev.entity.id))
  654. return -EIO;
  655. spin_lock_irqsave(&pipe->lock, flags);
  656. pipe->state &= ~(ISP_PIPELINE_IDLE_INPUT | ISP_PIPELINE_IDLE_OUTPUT);
  657. spin_unlock_irqrestore(&pipe->lock, flags);
  658. pipe->do_propagation = false;
  659. entity = &pipe->output->video.entity;
  660. while (1) {
  661. pad = &entity->pads[0];
  662. if (!(pad->flags & MEDIA_PAD_FL_SINK))
  663. break;
  664. pad = media_entity_remote_source(pad);
  665. if (pad == NULL ||
  666. media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
  667. break;
  668. entity = pad->entity;
  669. subdev = media_entity_to_v4l2_subdev(entity);
  670. ret = v4l2_subdev_call(subdev, video, s_stream, mode);
  671. if (ret < 0 && ret != -ENOIOCTLCMD)
  672. return ret;
  673. if (subdev == &isp->isp_ccdc.subdev) {
  674. v4l2_subdev_call(&isp->isp_aewb.subdev, video,
  675. s_stream, mode);
  676. v4l2_subdev_call(&isp->isp_af.subdev, video,
  677. s_stream, mode);
  678. v4l2_subdev_call(&isp->isp_hist.subdev, video,
  679. s_stream, mode);
  680. pipe->do_propagation = true;
  681. }
  682. }
  683. /* Frame number propagation. In continuous streaming mode the number
  684. * is incremented in the frame start ISR. In mem-to-mem mode
  685. * singleshot is used and frame start IRQs are not available.
  686. * Thus we have to increment the number here.
  687. */
  688. if (pipe->do_propagation && mode == ISP_PIPELINE_STREAM_SINGLESHOT)
  689. atomic_inc(&pipe->frame_number);
  690. return 0;
  691. }
  692. static int isp_pipeline_wait_resizer(struct isp_device *isp)
  693. {
  694. return omap3isp_resizer_busy(&isp->isp_res);
  695. }
  696. static int isp_pipeline_wait_preview(struct isp_device *isp)
  697. {
  698. return omap3isp_preview_busy(&isp->isp_prev);
  699. }
  700. static int isp_pipeline_wait_ccdc(struct isp_device *isp)
  701. {
  702. return omap3isp_stat_busy(&isp->isp_af)
  703. || omap3isp_stat_busy(&isp->isp_aewb)
  704. || omap3isp_stat_busy(&isp->isp_hist)
  705. || omap3isp_ccdc_busy(&isp->isp_ccdc);
  706. }
  707. #define ISP_STOP_TIMEOUT msecs_to_jiffies(1000)
  708. static int isp_pipeline_wait(struct isp_device *isp,
  709. int(*busy)(struct isp_device *isp))
  710. {
  711. unsigned long timeout = jiffies + ISP_STOP_TIMEOUT;
  712. while (!time_after(jiffies, timeout)) {
  713. if (!busy(isp))
  714. return 0;
  715. }
  716. return 1;
  717. }
  718. /*
  719. * isp_pipeline_disable - Disable streaming on a pipeline
  720. * @pipe: ISP pipeline
  721. *
  722. * Walk the entities chain starting at the pipeline output video node and stop
  723. * all modules in the chain. Wait synchronously for the modules to be stopped if
  724. * necessary.
  725. *
  726. * Return 0 if all modules have been properly stopped, or -ETIMEDOUT if a module
  727. * can't be stopped (in which case a software reset of the ISP is probably
  728. * necessary).
  729. */
  730. static int isp_pipeline_disable(struct isp_pipeline *pipe)
  731. {
  732. struct isp_device *isp = pipe->output->isp;
  733. struct media_entity *entity;
  734. struct media_pad *pad;
  735. struct v4l2_subdev *subdev;
  736. int failure = 0;
  737. int ret;
  738. /*
  739. * We need to stop all the modules after CCDC first or they'll
  740. * never stop since they may not get a full frame from CCDC.
  741. */
  742. entity = &pipe->output->video.entity;
  743. while (1) {
  744. pad = &entity->pads[0];
  745. if (!(pad->flags & MEDIA_PAD_FL_SINK))
  746. break;
  747. pad = media_entity_remote_source(pad);
  748. if (pad == NULL ||
  749. media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
  750. break;
  751. entity = pad->entity;
  752. subdev = media_entity_to_v4l2_subdev(entity);
  753. if (subdev == &isp->isp_ccdc.subdev) {
  754. v4l2_subdev_call(&isp->isp_aewb.subdev,
  755. video, s_stream, 0);
  756. v4l2_subdev_call(&isp->isp_af.subdev,
  757. video, s_stream, 0);
  758. v4l2_subdev_call(&isp->isp_hist.subdev,
  759. video, s_stream, 0);
  760. }
  761. v4l2_subdev_call(subdev, video, s_stream, 0);
  762. if (subdev == &isp->isp_res.subdev)
  763. ret = isp_pipeline_wait(isp, isp_pipeline_wait_resizer);
  764. else if (subdev == &isp->isp_prev.subdev)
  765. ret = isp_pipeline_wait(isp, isp_pipeline_wait_preview);
  766. else if (subdev == &isp->isp_ccdc.subdev)
  767. ret = isp_pipeline_wait(isp, isp_pipeline_wait_ccdc);
  768. else
  769. ret = 0;
  770. if (ret) {
  771. dev_info(isp->dev, "Unable to stop %s\n", subdev->name);
  772. /* If the entity failed to stopped, assume it has
  773. * crashed. Mark it as such, the ISP will be reset when
  774. * applications will release it.
  775. */
  776. isp->crashed |= 1U << subdev->entity.id;
  777. failure = -ETIMEDOUT;
  778. }
  779. }
  780. return failure;
  781. }
  782. /*
  783. * omap3isp_pipeline_set_stream - Enable/disable streaming on a pipeline
  784. * @pipe: ISP pipeline
  785. * @state: Stream state (stopped, single shot or continuous)
  786. *
  787. * Set the pipeline to the given stream state. Pipelines can be started in
  788. * single-shot or continuous mode.
  789. *
  790. * Return 0 if successful, or the return value of the failed video::s_stream
  791. * operation otherwise. The pipeline state is not updated when the operation
  792. * fails, except when stopping the pipeline.
  793. */
  794. int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
  795. enum isp_pipeline_stream_state state)
  796. {
  797. int ret;
  798. if (state == ISP_PIPELINE_STREAM_STOPPED)
  799. ret = isp_pipeline_disable(pipe);
  800. else
  801. ret = isp_pipeline_enable(pipe, state);
  802. if (ret == 0 || state == ISP_PIPELINE_STREAM_STOPPED)
  803. pipe->stream_state = state;
  804. return ret;
  805. }
  806. /*
  807. * isp_pipeline_resume - Resume streaming on a pipeline
  808. * @pipe: ISP pipeline
  809. *
  810. * Resume video output and input and re-enable pipeline.
  811. */
  812. static void isp_pipeline_resume(struct isp_pipeline *pipe)
  813. {
  814. int singleshot = pipe->stream_state == ISP_PIPELINE_STREAM_SINGLESHOT;
  815. omap3isp_video_resume(pipe->output, !singleshot);
  816. if (singleshot)
  817. omap3isp_video_resume(pipe->input, 0);
  818. isp_pipeline_enable(pipe, pipe->stream_state);
  819. }
  820. /*
  821. * isp_pipeline_suspend - Suspend streaming on a pipeline
  822. * @pipe: ISP pipeline
  823. *
  824. * Suspend pipeline.
  825. */
  826. static void isp_pipeline_suspend(struct isp_pipeline *pipe)
  827. {
  828. isp_pipeline_disable(pipe);
  829. }
  830. /*
  831. * isp_pipeline_is_last - Verify if entity has an enabled link to the output
  832. * video node
  833. * @me: ISP module's media entity
  834. *
  835. * Returns 1 if the entity has an enabled link to the output video node or 0
  836. * otherwise. It's true only while pipeline can have no more than one output
  837. * node.
  838. */
  839. static int isp_pipeline_is_last(struct media_entity *me)
  840. {
  841. struct isp_pipeline *pipe;
  842. struct media_pad *pad;
  843. if (!me->pipe)
  844. return 0;
  845. pipe = to_isp_pipeline(me);
  846. if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED)
  847. return 0;
  848. pad = media_entity_remote_source(&pipe->output->pad);
  849. return pad->entity == me;
  850. }
  851. /*
  852. * isp_suspend_module_pipeline - Suspend pipeline to which belongs the module
  853. * @me: ISP module's media entity
  854. *
  855. * Suspend the whole pipeline if module's entity has an enabled link to the
  856. * output video node. It works only while pipeline can have no more than one
  857. * output node.
  858. */
  859. static void isp_suspend_module_pipeline(struct media_entity *me)
  860. {
  861. if (isp_pipeline_is_last(me))
  862. isp_pipeline_suspend(to_isp_pipeline(me));
  863. }
  864. /*
  865. * isp_resume_module_pipeline - Resume pipeline to which belongs the module
  866. * @me: ISP module's media entity
  867. *
  868. * Resume the whole pipeline if module's entity has an enabled link to the
  869. * output video node. It works only while pipeline can have no more than one
  870. * output node.
  871. */
  872. static void isp_resume_module_pipeline(struct media_entity *me)
  873. {
  874. if (isp_pipeline_is_last(me))
  875. isp_pipeline_resume(to_isp_pipeline(me));
  876. }
  877. /*
  878. * isp_suspend_modules - Suspend ISP submodules.
  879. * @isp: OMAP3 ISP device
  880. *
  881. * Returns 0 if suspend left in idle state all the submodules properly,
  882. * or returns 1 if a general Reset is required to suspend the submodules.
  883. */
  884. static int isp_suspend_modules(struct isp_device *isp)
  885. {
  886. unsigned long timeout;
  887. omap3isp_stat_suspend(&isp->isp_aewb);
  888. omap3isp_stat_suspend(&isp->isp_af);
  889. omap3isp_stat_suspend(&isp->isp_hist);
  890. isp_suspend_module_pipeline(&isp->isp_res.subdev.entity);
  891. isp_suspend_module_pipeline(&isp->isp_prev.subdev.entity);
  892. isp_suspend_module_pipeline(&isp->isp_ccdc.subdev.entity);
  893. isp_suspend_module_pipeline(&isp->isp_csi2a.subdev.entity);
  894. isp_suspend_module_pipeline(&isp->isp_ccp2.subdev.entity);
  895. timeout = jiffies + ISP_STOP_TIMEOUT;
  896. while (omap3isp_stat_busy(&isp->isp_af)
  897. || omap3isp_stat_busy(&isp->isp_aewb)
  898. || omap3isp_stat_busy(&isp->isp_hist)
  899. || omap3isp_preview_busy(&isp->isp_prev)
  900. || omap3isp_resizer_busy(&isp->isp_res)
  901. || omap3isp_ccdc_busy(&isp->isp_ccdc)) {
  902. if (time_after(jiffies, timeout)) {
  903. dev_info(isp->dev, "can't stop modules.\n");
  904. return 1;
  905. }
  906. msleep(1);
  907. }
  908. return 0;
  909. }
  910. /*
  911. * isp_resume_modules - Resume ISP submodules.
  912. * @isp: OMAP3 ISP device
  913. */
  914. static void isp_resume_modules(struct isp_device *isp)
  915. {
  916. omap3isp_stat_resume(&isp->isp_aewb);
  917. omap3isp_stat_resume(&isp->isp_af);
  918. omap3isp_stat_resume(&isp->isp_hist);
  919. isp_resume_module_pipeline(&isp->isp_res.subdev.entity);
  920. isp_resume_module_pipeline(&isp->isp_prev.subdev.entity);
  921. isp_resume_module_pipeline(&isp->isp_ccdc.subdev.entity);
  922. isp_resume_module_pipeline(&isp->isp_csi2a.subdev.entity);
  923. isp_resume_module_pipeline(&isp->isp_ccp2.subdev.entity);
  924. }
  925. /*
  926. * isp_reset - Reset ISP with a timeout wait for idle.
  927. * @isp: OMAP3 ISP device
  928. */
  929. static int isp_reset(struct isp_device *isp)
  930. {
  931. unsigned long timeout = 0;
  932. isp_reg_writel(isp,
  933. isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG)
  934. | ISP_SYSCONFIG_SOFTRESET,
  935. OMAP3_ISP_IOMEM_MAIN, ISP_SYSCONFIG);
  936. while (!(isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN,
  937. ISP_SYSSTATUS) & 0x1)) {
  938. if (timeout++ > 10000) {
  939. dev_alert(isp->dev, "cannot reset ISP\n");
  940. return -ETIMEDOUT;
  941. }
  942. udelay(1);
  943. }
  944. isp->crashed = 0;
  945. return 0;
  946. }
  947. /*
  948. * isp_save_context - Saves the values of the ISP module registers.
  949. * @isp: OMAP3 ISP device
  950. * @reg_list: Structure containing pairs of register address and value to
  951. * modify on OMAP.
  952. */
  953. static void
  954. isp_save_context(struct isp_device *isp, struct isp_reg *reg_list)
  955. {
  956. struct isp_reg *next = reg_list;
  957. for (; next->reg != ISP_TOK_TERM; next++)
  958. next->val = isp_reg_readl(isp, next->mmio_range, next->reg);
  959. }
  960. /*
  961. * isp_restore_context - Restores the values of the ISP module registers.
  962. * @isp: OMAP3 ISP device
  963. * @reg_list: Structure containing pairs of register address and value to
  964. * modify on OMAP.
  965. */
  966. static void
  967. isp_restore_context(struct isp_device *isp, struct isp_reg *reg_list)
  968. {
  969. struct isp_reg *next = reg_list;
  970. for (; next->reg != ISP_TOK_TERM; next++)
  971. isp_reg_writel(isp, next->val, next->mmio_range, next->reg);
  972. }
  973. /*
  974. * isp_save_ctx - Saves ISP, CCDC, HIST, H3A, PREV, RESZ & MMU context.
  975. * @isp: OMAP3 ISP device
  976. *
  977. * Routine for saving the context of each module in the ISP.
  978. * CCDC, HIST, H3A, PREV, RESZ and MMU.
  979. */
  980. static void isp_save_ctx(struct isp_device *isp)
  981. {
  982. isp_save_context(isp, isp_reg_list);
  983. omap_iommu_save_ctx(isp->dev);
  984. }
  985. /*
  986. * isp_restore_ctx - Restores ISP, CCDC, HIST, H3A, PREV, RESZ & MMU context.
  987. * @isp: OMAP3 ISP device
  988. *
  989. * Routine for restoring the context of each module in the ISP.
  990. * CCDC, HIST, H3A, PREV, RESZ and MMU.
  991. */
  992. static void isp_restore_ctx(struct isp_device *isp)
  993. {
  994. isp_restore_context(isp, isp_reg_list);
  995. omap_iommu_restore_ctx(isp->dev);
  996. omap3isp_ccdc_restore_context(isp);
  997. omap3isp_preview_restore_context(isp);
  998. }
  999. /* -----------------------------------------------------------------------------
  1000. * SBL resources management
  1001. */
  1002. #define OMAP3_ISP_SBL_READ (OMAP3_ISP_SBL_CSI1_READ | \
  1003. OMAP3_ISP_SBL_CCDC_LSC_READ | \
  1004. OMAP3_ISP_SBL_PREVIEW_READ | \
  1005. OMAP3_ISP_SBL_RESIZER_READ)
  1006. #define OMAP3_ISP_SBL_WRITE (OMAP3_ISP_SBL_CSI1_WRITE | \
  1007. OMAP3_ISP_SBL_CSI2A_WRITE | \
  1008. OMAP3_ISP_SBL_CSI2C_WRITE | \
  1009. OMAP3_ISP_SBL_CCDC_WRITE | \
  1010. OMAP3_ISP_SBL_PREVIEW_WRITE)
  1011. void omap3isp_sbl_enable(struct isp_device *isp, enum isp_sbl_resource res)
  1012. {
  1013. u32 sbl = 0;
  1014. isp->sbl_resources |= res;
  1015. if (isp->sbl_resources & OMAP3_ISP_SBL_CSI1_READ)
  1016. sbl |= ISPCTRL_SBL_SHARED_RPORTA;
  1017. if (isp->sbl_resources & OMAP3_ISP_SBL_CCDC_LSC_READ)
  1018. sbl |= ISPCTRL_SBL_SHARED_RPORTB;
  1019. if (isp->sbl_resources & OMAP3_ISP_SBL_CSI2C_WRITE)
  1020. sbl |= ISPCTRL_SBL_SHARED_WPORTC;
  1021. if (isp->sbl_resources & OMAP3_ISP_SBL_RESIZER_WRITE)
  1022. sbl |= ISPCTRL_SBL_WR0_RAM_EN;
  1023. if (isp->sbl_resources & OMAP3_ISP_SBL_WRITE)
  1024. sbl |= ISPCTRL_SBL_WR1_RAM_EN;
  1025. if (isp->sbl_resources & OMAP3_ISP_SBL_READ)
  1026. sbl |= ISPCTRL_SBL_RD_RAM_EN;
  1027. isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, sbl);
  1028. }
  1029. void omap3isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource res)
  1030. {
  1031. u32 sbl = 0;
  1032. isp->sbl_resources &= ~res;
  1033. if (!(isp->sbl_resources & OMAP3_ISP_SBL_CSI1_READ))
  1034. sbl |= ISPCTRL_SBL_SHARED_RPORTA;
  1035. if (!(isp->sbl_resources & OMAP3_ISP_SBL_CCDC_LSC_READ))
  1036. sbl |= ISPCTRL_SBL_SHARED_RPORTB;
  1037. if (!(isp->sbl_resources & OMAP3_ISP_SBL_CSI2C_WRITE))
  1038. sbl |= ISPCTRL_SBL_SHARED_WPORTC;
  1039. if (!(isp->sbl_resources & OMAP3_ISP_SBL_RESIZER_WRITE))
  1040. sbl |= ISPCTRL_SBL_WR0_RAM_EN;
  1041. if (!(isp->sbl_resources & OMAP3_ISP_SBL_WRITE))
  1042. sbl |= ISPCTRL_SBL_WR1_RAM_EN;
  1043. if (!(isp->sbl_resources & OMAP3_ISP_SBL_READ))
  1044. sbl |= ISPCTRL_SBL_RD_RAM_EN;
  1045. isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, sbl);
  1046. }
  1047. /*
  1048. * isp_module_sync_idle - Helper to sync module with its idle state
  1049. * @me: ISP submodule's media entity
  1050. * @wait: ISP submodule's wait queue for streamoff/interrupt synchronization
  1051. * @stopping: flag which tells module wants to stop
  1052. *
  1053. * This function checks if ISP submodule needs to wait for next interrupt. If
  1054. * yes, makes the caller to sleep while waiting for such event.
  1055. */
  1056. int omap3isp_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
  1057. atomic_t *stopping)
  1058. {
  1059. struct isp_pipeline *pipe = to_isp_pipeline(me);
  1060. if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED ||
  1061. (pipe->stream_state == ISP_PIPELINE_STREAM_SINGLESHOT &&
  1062. !isp_pipeline_ready(pipe)))
  1063. return 0;
  1064. /*
  1065. * atomic_set() doesn't include memory barrier on ARM platform for SMP
  1066. * scenario. We'll call it here to avoid race conditions.
  1067. */
  1068. atomic_set(stopping, 1);
  1069. smp_mb();
  1070. /*
  1071. * If module is the last one, it's writing to memory. In this case,
  1072. * it's necessary to check if the module is already paused due to
  1073. * DMA queue underrun or if it has to wait for next interrupt to be
  1074. * idle.
  1075. * If it isn't the last one, the function won't sleep but *stopping
  1076. * will still be set to warn next submodule caller's interrupt the
  1077. * module wants to be idle.
  1078. */
  1079. if (isp_pipeline_is_last(me)) {
  1080. struct isp_video *video = pipe->output;
  1081. unsigned long flags;
  1082. spin_lock_irqsave(&video->queue->irqlock, flags);
  1083. if (video->dmaqueue_flags & ISP_VIDEO_DMAQUEUE_UNDERRUN) {
  1084. spin_unlock_irqrestore(&video->queue->irqlock, flags);
  1085. atomic_set(stopping, 0);
  1086. smp_mb();
  1087. return 0;
  1088. }
  1089. spin_unlock_irqrestore(&video->queue->irqlock, flags);
  1090. if (!wait_event_timeout(*wait, !atomic_read(stopping),
  1091. msecs_to_jiffies(1000))) {
  1092. atomic_set(stopping, 0);
  1093. smp_mb();
  1094. return -ETIMEDOUT;
  1095. }
  1096. }
  1097. return 0;
  1098. }
  1099. /*
  1100. * omap3isp_module_sync_is_stopped - Helper to verify if module was stopping
  1101. * @wait: ISP submodule's wait queue for streamoff/interrupt synchronization
  1102. * @stopping: flag which tells module wants to stop
  1103. *
  1104. * This function checks if ISP submodule was stopping. In case of yes, it
  1105. * notices the caller by setting stopping to 0 and waking up the wait queue.
  1106. * Returns 1 if it was stopping or 0 otherwise.
  1107. */
  1108. int omap3isp_module_sync_is_stopping(wait_queue_head_t *wait,
  1109. atomic_t *stopping)
  1110. {
  1111. if (atomic_cmpxchg(stopping, 1, 0)) {
  1112. wake_up(wait);
  1113. return 1;
  1114. }
  1115. return 0;
  1116. }
  1117. /* --------------------------------------------------------------------------
  1118. * Clock management
  1119. */
  1120. #define ISPCTRL_CLKS_MASK (ISPCTRL_H3A_CLK_EN | \
  1121. ISPCTRL_HIST_CLK_EN | \
  1122. ISPCTRL_RSZ_CLK_EN | \
  1123. (ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN) | \
  1124. (ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN))
  1125. static void __isp_subclk_update(struct isp_device *isp)
  1126. {
  1127. u32 clk = 0;
  1128. if (isp->subclk_resources & OMAP3_ISP_SUBCLK_H3A)
  1129. clk |= ISPCTRL_H3A_CLK_EN;
  1130. if (isp->subclk_resources & OMAP3_ISP_SUBCLK_HIST)
  1131. clk |= ISPCTRL_HIST_CLK_EN;
  1132. if (isp->subclk_resources & OMAP3_ISP_SUBCLK_RESIZER)
  1133. clk |= ISPCTRL_RSZ_CLK_EN;
  1134. /* NOTE: For CCDC & Preview submodules, we need to affect internal
  1135. * RAM as well.
  1136. */
  1137. if (isp->subclk_resources & OMAP3_ISP_SUBCLK_CCDC)
  1138. clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN;
  1139. if (isp->subclk_resources & OMAP3_ISP_SUBCLK_PREVIEW)
  1140. clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN;
  1141. isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL,
  1142. ISPCTRL_CLKS_MASK, clk);
  1143. }
  1144. void omap3isp_subclk_enable(struct isp_device *isp,
  1145. enum isp_subclk_resource res)
  1146. {
  1147. isp->subclk_resources |= res;
  1148. __isp_subclk_update(isp);
  1149. }
  1150. void omap3isp_subclk_disable(struct isp_device *isp,
  1151. enum isp_subclk_resource res)
  1152. {
  1153. isp->subclk_resources &= ~res;
  1154. __isp_subclk_update(isp);
  1155. }
  1156. /*
  1157. * isp_enable_clocks - Enable ISP clocks
  1158. * @isp: OMAP3 ISP device
  1159. *
  1160. * Return 0 if successful, or clk_enable return value if any of tthem fails.
  1161. */
  1162. static int isp_enable_clocks(struct isp_device *isp)
  1163. {
  1164. int r;
  1165. unsigned long rate;
  1166. int divisor;
  1167. /*
  1168. * cam_mclk clock chain:
  1169. * dpll4 -> dpll4_m5 -> dpll4_m5x2 -> cam_mclk
  1170. *
  1171. * In OMAP3630 dpll4_m5x2 != 2 x dpll4_m5 but both are
  1172. * set to the same value. Hence the rate set for dpll4_m5
  1173. * has to be twice of what is set on OMAP3430 to get
  1174. * the required value for cam_mclk
  1175. */
  1176. if (cpu_is_omap3630())
  1177. divisor = 1;
  1178. else
  1179. divisor = 2;
  1180. r = clk_enable(isp->clock[ISP_CLK_CAM_ICK]);
  1181. if (r) {
  1182. dev_err(isp->dev, "clk_enable cam_ick failed\n");
  1183. goto out_clk_enable_ick;
  1184. }
  1185. r = clk_set_rate(isp->clock[ISP_CLK_DPLL4_M5_CK],
  1186. CM_CAM_MCLK_HZ/divisor);
  1187. if (r) {
  1188. dev_err(isp->dev, "clk_set_rate for dpll4_m5_ck failed\n");
  1189. goto out_clk_enable_mclk;
  1190. }
  1191. r = clk_enable(isp->clock[ISP_CLK_CAM_MCLK]);
  1192. if (r) {
  1193. dev_err(isp->dev, "clk_enable cam_mclk failed\n");
  1194. goto out_clk_enable_mclk;
  1195. }
  1196. rate = clk_get_rate(isp->clock[ISP_CLK_CAM_MCLK]);
  1197. if (rate != CM_CAM_MCLK_HZ)
  1198. dev_warn(isp->dev, "unexpected cam_mclk rate:\n"
  1199. " expected : %d\n"
  1200. " actual : %ld\n", CM_CAM_MCLK_HZ, rate);
  1201. r = clk_enable(isp->clock[ISP_CLK_CSI2_FCK]);
  1202. if (r) {
  1203. dev_err(isp->dev, "clk_enable csi2_fck failed\n");
  1204. goto out_clk_enable_csi2_fclk;
  1205. }
  1206. return 0;
  1207. out_clk_enable_csi2_fclk:
  1208. clk_disable(isp->clock[ISP_CLK_CAM_MCLK]);
  1209. out_clk_enable_mclk:
  1210. clk_disable(isp->clock[ISP_CLK_CAM_ICK]);
  1211. out_clk_enable_ick:
  1212. return r;
  1213. }
  1214. /*
  1215. * isp_disable_clocks - Disable ISP clocks
  1216. * @isp: OMAP3 ISP device
  1217. */
  1218. static void isp_disable_clocks(struct isp_device *isp)
  1219. {
  1220. clk_disable(isp->clock[ISP_CLK_CAM_ICK]);
  1221. clk_disable(isp->clock[ISP_CLK_CAM_MCLK]);
  1222. clk_disable(isp->clock[ISP_CLK_CSI2_FCK]);
  1223. }
  1224. static const char *isp_clocks[] = {
  1225. "cam_ick",
  1226. "cam_mclk",
  1227. "dpll4_m5_ck",
  1228. "csi2_96m_fck",
  1229. "l3_ick",
  1230. };
  1231. static void isp_put_clocks(struct isp_device *isp)
  1232. {
  1233. unsigned int i;
  1234. for (i = 0; i < ARRAY_SIZE(isp_clocks); ++i) {
  1235. if (isp->clock[i]) {
  1236. clk_put(isp->clock[i]);
  1237. isp->clock[i] = NULL;
  1238. }
  1239. }
  1240. }
  1241. static int isp_get_clocks(struct isp_device *isp)
  1242. {
  1243. struct clk *clk;
  1244. unsigned int i;
  1245. for (i = 0; i < ARRAY_SIZE(isp_clocks); ++i) {
  1246. clk = clk_get(isp->dev, isp_clocks[i]);
  1247. if (IS_ERR(clk)) {
  1248. dev_err(isp->dev, "clk_get %s failed\n", isp_clocks[i]);
  1249. isp_put_clocks(isp);
  1250. return PTR_ERR(clk);
  1251. }
  1252. isp->clock[i] = clk;
  1253. }
  1254. return 0;
  1255. }
  1256. /*
  1257. * omap3isp_get - Acquire the ISP resource.
  1258. *
  1259. * Initializes the clocks for the first acquire.
  1260. *
  1261. * Increment the reference count on the ISP. If the first reference is taken,
  1262. * enable clocks and power-up all submodules.
  1263. *
  1264. * Return a pointer to the ISP device structure, or NULL if an error occurred.
  1265. */
  1266. struct isp_device *omap3isp_get(struct isp_device *isp)
  1267. {
  1268. struct isp_device *__isp = isp;
  1269. if (isp == NULL)
  1270. return NULL;
  1271. mutex_lock(&isp->isp_mutex);
  1272. if (isp->ref_count > 0)
  1273. goto out;
  1274. if (isp_enable_clocks(isp) < 0) {
  1275. __isp = NULL;
  1276. goto out;
  1277. }
  1278. /* We don't want to restore context before saving it! */
  1279. if (isp->has_context)
  1280. isp_restore_ctx(isp);
  1281. else
  1282. isp->has_context = 1;
  1283. isp_enable_interrupts(isp);
  1284. out:
  1285. if (__isp != NULL)
  1286. isp->ref_count++;
  1287. mutex_unlock(&isp->isp_mutex);
  1288. return __isp;
  1289. }
  1290. /*
  1291. * omap3isp_put - Release the ISP
  1292. *
  1293. * Decrement the reference count on the ISP. If the last reference is released,
  1294. * power-down all submodules, disable clocks and free temporary buffers.
  1295. */
  1296. void omap3isp_put(struct isp_device *isp)
  1297. {
  1298. if (isp == NULL)
  1299. return;
  1300. mutex_lock(&isp->isp_mutex);
  1301. BUG_ON(isp->ref_count == 0);
  1302. if (--isp->ref_count == 0) {
  1303. isp_disable_interrupts(isp);
  1304. if (isp->domain)
  1305. isp_save_ctx(isp);
  1306. /* Reset the ISP if an entity has failed to stop. This is the
  1307. * only way to recover from such conditions.
  1308. */
  1309. if (isp->crashed)
  1310. isp_reset(isp);
  1311. isp_disable_clocks(isp);
  1312. }
  1313. mutex_unlock(&isp->isp_mutex);
  1314. }
  1315. /* --------------------------------------------------------------------------
  1316. * Platform device driver
  1317. */
  1318. /*
  1319. * omap3isp_print_status - Prints the values of the ISP Control Module registers
  1320. * @isp: OMAP3 ISP device
  1321. */
  1322. #define ISP_PRINT_REGISTER(isp, name)\
  1323. dev_dbg(isp->dev, "###ISP " #name "=0x%08x\n", \
  1324. isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_##name))
  1325. #define SBL_PRINT_REGISTER(isp, name)\
  1326. dev_dbg(isp->dev, "###SBL " #name "=0x%08x\n", \
  1327. isp_reg_readl(isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_##name))
  1328. void omap3isp_print_status(struct isp_device *isp)
  1329. {
  1330. dev_dbg(isp->dev, "-------------ISP Register dump--------------\n");
  1331. ISP_PRINT_REGISTER(isp, SYSCONFIG);
  1332. ISP_PRINT_REGISTER(isp, SYSSTATUS);
  1333. ISP_PRINT_REGISTER(isp, IRQ0ENABLE);
  1334. ISP_PRINT_REGISTER(isp, IRQ0STATUS);
  1335. ISP_PRINT_REGISTER(isp, TCTRL_GRESET_LENGTH);
  1336. ISP_PRINT_REGISTER(isp, TCTRL_PSTRB_REPLAY);
  1337. ISP_PRINT_REGISTER(isp, CTRL);
  1338. ISP_PRINT_REGISTER(isp, TCTRL_CTRL);
  1339. ISP_PRINT_REGISTER(isp, TCTRL_FRAME);
  1340. ISP_PRINT_REGISTER(isp, TCTRL_PSTRB_DELAY);
  1341. ISP_PRINT_REGISTER(isp, TCTRL_STRB_DELAY);
  1342. ISP_PRINT_REGISTER(isp, TCTRL_SHUT_DELAY);
  1343. ISP_PRINT_REGISTER(isp, TCTRL_PSTRB_LENGTH);
  1344. ISP_PRINT_REGISTER(isp, TCTRL_STRB_LENGTH);
  1345. ISP_PRINT_REGISTER(isp, TCTRL_SHUT_LENGTH);
  1346. SBL_PRINT_REGISTER(isp, PCR);
  1347. SBL_PRINT_REGISTER(isp, SDR_REQ_EXP);
  1348. dev_dbg(isp->dev, "--------------------------------------------\n");
  1349. }
  1350. #ifdef CONFIG_PM
  1351. /*
  1352. * Power management support.
  1353. *
  1354. * As the ISP can't properly handle an input video stream interruption on a non
  1355. * frame boundary, the ISP pipelines need to be stopped before sensors get
  1356. * suspended. However, as suspending the sensors can require a running clock,
  1357. * which can be provided by the ISP, the ISP can't be completely suspended
  1358. * before the sensor.
  1359. *
  1360. * To solve this problem power management support is split into prepare/complete
  1361. * and suspend/resume operations. The pipelines are stopped in prepare() and the
  1362. * ISP clocks get disabled in suspend(). Similarly, the clocks are reenabled in
  1363. * resume(), and the the pipelines are restarted in complete().
  1364. *
  1365. * TODO: PM dependencies between the ISP and sensors are not modeled explicitly
  1366. * yet.
  1367. */
  1368. static int isp_pm_prepare(struct device *dev)
  1369. {
  1370. struct isp_device *isp = dev_get_drvdata(dev);
  1371. int reset;
  1372. WARN_ON(mutex_is_locked(&isp->isp_mutex));
  1373. if (isp->ref_count == 0)
  1374. return 0;
  1375. reset = isp_suspend_modules(isp);
  1376. isp_disable_interrupts(isp);
  1377. isp_save_ctx(isp);
  1378. if (reset)
  1379. isp_reset(isp);
  1380. return 0;
  1381. }
  1382. static int isp_pm_suspend(struct device *dev)
  1383. {
  1384. struct isp_device *isp = dev_get_drvdata(dev);
  1385. WARN_ON(mutex_is_locked(&isp->isp_mutex));
  1386. if (isp->ref_count)
  1387. isp_disable_clocks(isp);
  1388. return 0;
  1389. }
  1390. static int isp_pm_resume(struct device *dev)
  1391. {
  1392. struct isp_device *isp = dev_get_drvdata(dev);
  1393. if (isp->ref_count == 0)
  1394. return 0;
  1395. return isp_enable_clocks(isp);
  1396. }
  1397. static void isp_pm_complete(struct device *dev)
  1398. {
  1399. struct isp_device *isp = dev_get_drvdata(dev);
  1400. if (isp->ref_count == 0)
  1401. return;
  1402. isp_restore_ctx(isp);
  1403. isp_enable_interrupts(isp);
  1404. isp_resume_modules(isp);
  1405. }
  1406. #else
  1407. #define isp_pm_prepare NULL
  1408. #define isp_pm_suspend NULL
  1409. #define isp_pm_resume NULL
  1410. #define isp_pm_complete NULL
  1411. #endif /* CONFIG_PM */
  1412. static void isp_unregister_entities(struct isp_device *isp)
  1413. {
  1414. omap3isp_csi2_unregister_entities(&isp->isp_csi2a);
  1415. omap3isp_ccp2_unregister_entities(&isp->isp_ccp2);
  1416. omap3isp_ccdc_unregister_entities(&isp->isp_ccdc);
  1417. omap3isp_preview_unregister_entities(&isp->isp_prev);
  1418. omap3isp_resizer_unregister_entities(&isp->isp_res);
  1419. omap3isp_stat_unregister_entities(&isp->isp_aewb);
  1420. omap3isp_stat_unregister_entities(&isp->isp_af);
  1421. omap3isp_stat_unregister_entities(&isp->isp_hist);
  1422. v4l2_device_unregister(&isp->v4l2_dev);
  1423. media_device_unregister(&isp->media_dev);
  1424. }
  1425. /*
  1426. * isp_register_subdev_group - Register a group of subdevices
  1427. * @isp: OMAP3 ISP device
  1428. * @board_info: I2C subdevs board information array
  1429. *
  1430. * Register all I2C subdevices in the board_info array. The array must be
  1431. * terminated by a NULL entry, and the first entry must be the sensor.
  1432. *
  1433. * Return a pointer to the sensor media entity if it has been successfully
  1434. * registered, or NULL otherwise.
  1435. */
  1436. static struct v4l2_subdev *
  1437. isp_register_subdev_group(struct isp_device *isp,
  1438. struct isp_subdev_i2c_board_info *board_info)
  1439. {
  1440. struct v4l2_subdev *sensor = NULL;
  1441. unsigned int first;
  1442. if (board_info->board_info == NULL)
  1443. return NULL;
  1444. for (first = 1; board_info->board_info; ++board_info, first = 0) {
  1445. struct v4l2_subdev *subdev;
  1446. struct i2c_adapter *adapter;
  1447. adapter = i2c_get_adapter(board_info->i2c_adapter_id);
  1448. if (adapter == NULL) {
  1449. printk(KERN_ERR "%s: Unable to get I2C adapter %d for "
  1450. "device %s\n", __func__,
  1451. board_info->i2c_adapter_id,
  1452. board_info->board_info->type);
  1453. continue;
  1454. }
  1455. subdev = v4l2_i2c_new_subdev_board(&isp->v4l2_dev, adapter,
  1456. board_info->board_info, NULL);
  1457. if (subdev == NULL) {
  1458. printk(KERN_ERR "%s: Unable to register subdev %s\n",
  1459. __func__, board_info->board_info->type);
  1460. continue;
  1461. }
  1462. if (first)
  1463. sensor = subdev;
  1464. }
  1465. return sensor;
  1466. }
  1467. static int isp_register_entities(struct isp_device *isp)
  1468. {
  1469. struct isp_platform_data *pdata = isp->pdata;
  1470. struct isp_v4l2_subdevs_group *subdevs;
  1471. int ret;
  1472. isp->media_dev.dev = isp->dev;
  1473. strlcpy(isp->media_dev.model, "TI OMAP3 ISP",
  1474. sizeof(isp->media_dev.model));
  1475. isp->media_dev.hw_revision = isp->revision;
  1476. isp->media_dev.link_notify = isp_pipeline_link_notify;
  1477. ret = media_device_register(&isp->media_dev);
  1478. if (ret < 0) {
  1479. printk(KERN_ERR "%s: Media device registration failed (%d)\n",
  1480. __func__, ret);
  1481. return ret;
  1482. }
  1483. isp->v4l2_dev.mdev = &isp->media_dev;
  1484. ret = v4l2_device_register(isp->dev, &isp->v4l2_dev);
  1485. if (ret < 0) {
  1486. printk(KERN_ERR "%s: V4L2 device registration failed (%d)\n",
  1487. __func__, ret);
  1488. goto done;
  1489. }
  1490. /* Register internal entities */
  1491. ret = omap3isp_ccp2_register_entities(&isp->isp_ccp2, &isp->v4l2_dev);
  1492. if (ret < 0)
  1493. goto done;
  1494. ret = omap3isp_csi2_register_entities(&isp->isp_csi2a, &isp->v4l2_dev);
  1495. if (ret < 0)
  1496. goto done;
  1497. ret = omap3isp_ccdc_register_entities(&isp->isp_ccdc, &isp->v4l2_dev);
  1498. if (ret < 0)
  1499. goto done;
  1500. ret = omap3isp_preview_register_entities(&isp->isp_prev,
  1501. &isp->v4l2_dev);
  1502. if (ret < 0)
  1503. goto done;
  1504. ret = omap3isp_resizer_register_entities(&isp->isp_res, &isp->v4l2_dev);
  1505. if (ret < 0)
  1506. goto done;
  1507. ret = omap3isp_stat_register_entities(&isp->isp_aewb, &isp->v4l2_dev);
  1508. if (ret < 0)
  1509. goto done;
  1510. ret = omap3isp_stat_register_entities(&isp->isp_af, &isp->v4l2_dev);
  1511. if (ret < 0)
  1512. goto done;
  1513. ret = omap3isp_stat_register_entities(&isp->isp_hist, &isp->v4l2_dev);
  1514. if (ret < 0)
  1515. goto done;
  1516. /* Register external entities */
  1517. for (subdevs = pdata->subdevs; subdevs && subdevs->subdevs; ++subdevs) {
  1518. struct v4l2_subdev *sensor;
  1519. struct media_entity *input;
  1520. unsigned int flags;
  1521. unsigned int pad;
  1522. sensor = isp_register_subdev_group(isp, subdevs->subdevs);
  1523. if (sensor == NULL)
  1524. continue;
  1525. sensor->host_priv = subdevs;
  1526. /* Connect the sensor to the correct interface module. Parallel
  1527. * sensors are connected directly to the CCDC, while serial
  1528. * sensors are connected to the CSI2a, CCP2b or CSI2c receiver
  1529. * through CSIPHY1 or CSIPHY2.
  1530. */
  1531. switch (subdevs->interface) {
  1532. case ISP_INTERFACE_PARALLEL:
  1533. input = &isp->isp_ccdc.subdev.entity;
  1534. pad = CCDC_PAD_SINK;
  1535. flags = 0;
  1536. break;
  1537. case ISP_INTERFACE_CSI2A_PHY2:
  1538. input = &isp->isp_csi2a.subdev.entity;
  1539. pad = CSI2_PAD_SINK;
  1540. flags = MEDIA_LNK_FL_IMMUTABLE
  1541. | MEDIA_LNK_FL_ENABLED;
  1542. break;
  1543. case ISP_INTERFACE_CCP2B_PHY1:
  1544. case ISP_INTERFACE_CCP2B_PHY2:
  1545. input = &isp->isp_ccp2.subdev.entity;
  1546. pad = CCP2_PAD_SINK;
  1547. flags = 0;
  1548. break;
  1549. case ISP_INTERFACE_CSI2C_PHY1:
  1550. input = &isp->isp_csi2c.subdev.entity;
  1551. pad = CSI2_PAD_SINK;
  1552. flags = MEDIA_LNK_FL_IMMUTABLE
  1553. | MEDIA_LNK_FL_ENABLED;
  1554. break;
  1555. default:
  1556. printk(KERN_ERR "%s: invalid interface type %u\n",
  1557. __func__, subdevs->interface);
  1558. ret = -EINVAL;
  1559. goto done;
  1560. }
  1561. ret = media_entity_create_link(&sensor->entity, 0, input, pad,
  1562. flags);
  1563. if (ret < 0)
  1564. goto done;
  1565. }
  1566. ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
  1567. done:
  1568. if (ret < 0)
  1569. isp_unregister_entities(isp);
  1570. return ret;
  1571. }
  1572. static void isp_cleanup_modules(struct isp_device *isp)
  1573. {
  1574. omap3isp_h3a_aewb_cleanup(isp);
  1575. omap3isp_h3a_af_cleanup(isp);
  1576. omap3isp_hist_cleanup(isp);
  1577. omap3isp_resizer_cleanup(isp);
  1578. omap3isp_preview_cleanup(isp);
  1579. omap3isp_ccdc_cleanup(isp);
  1580. omap3isp_ccp2_cleanup(isp);
  1581. omap3isp_csi2_cleanup(isp);
  1582. }
  1583. static int isp_initialize_modules(struct isp_device *isp)
  1584. {
  1585. int ret;
  1586. ret = omap3isp_csiphy_init(isp);
  1587. if (ret < 0) {
  1588. dev_err(isp->dev, "CSI PHY initialization failed\n");
  1589. goto error_csiphy;
  1590. }
  1591. ret = omap3isp_csi2_init(isp);
  1592. if (ret < 0) {
  1593. dev_err(isp->dev, "CSI2 initialization failed\n");
  1594. goto error_csi2;
  1595. }
  1596. ret = omap3isp_ccp2_init(isp);
  1597. if (ret < 0) {
  1598. dev_err(isp->dev, "CCP2 initialization failed\n");
  1599. goto error_ccp2;
  1600. }
  1601. ret = omap3isp_ccdc_init(isp);
  1602. if (ret < 0) {
  1603. dev_err(isp->dev, "CCDC initialization failed\n");
  1604. goto error_ccdc;
  1605. }
  1606. ret = omap3isp_preview_init(isp);
  1607. if (ret < 0) {
  1608. dev_err(isp->dev, "Preview initialization failed\n");
  1609. goto error_preview;
  1610. }
  1611. ret = omap3isp_resizer_init(isp);
  1612. if (ret < 0) {
  1613. dev_err(isp->dev, "Resizer initialization failed\n");
  1614. goto error_resizer;
  1615. }
  1616. ret = omap3isp_hist_init(isp);
  1617. if (ret < 0) {
  1618. dev_err(isp->dev, "Histogram initialization failed\n");
  1619. goto error_hist;
  1620. }
  1621. ret = omap3isp_h3a_aewb_init(isp);
  1622. if (ret < 0) {
  1623. dev_err(isp->dev, "H3A AEWB initialization failed\n");
  1624. goto error_h3a_aewb;
  1625. }
  1626. ret = omap3isp_h3a_af_init(isp);
  1627. if (ret < 0) {
  1628. dev_err(isp->dev, "H3A AF initialization failed\n");
  1629. goto error_h3a_af;
  1630. }
  1631. /* Connect the submodules. */
  1632. ret = media_entity_create_link(
  1633. &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
  1634. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
  1635. if (ret < 0)
  1636. goto error_link;
  1637. ret = media_entity_create_link(
  1638. &isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE,
  1639. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
  1640. if (ret < 0)
  1641. goto error_link;
  1642. ret = media_entity_create_link(
  1643. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
  1644. &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0);
  1645. if (ret < 0)
  1646. goto error_link;
  1647. ret = media_entity_create_link(
  1648. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF,
  1649. &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
  1650. if (ret < 0)
  1651. goto error_link;
  1652. ret = media_entity_create_link(
  1653. &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE,
  1654. &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
  1655. if (ret < 0)
  1656. goto error_link;
  1657. ret = media_entity_create_link(
  1658. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
  1659. &isp->isp_aewb.subdev.entity, 0,
  1660. MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
  1661. if (ret < 0)
  1662. goto error_link;
  1663. ret = media_entity_create_link(
  1664. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
  1665. &isp->isp_af.subdev.entity, 0,
  1666. MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
  1667. if (ret < 0)
  1668. goto error_link;
  1669. ret = media_entity_create_link(
  1670. &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
  1671. &isp->isp_hist.subdev.entity, 0,
  1672. MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
  1673. if (ret < 0)
  1674. goto error_link;
  1675. return 0;
  1676. error_link:
  1677. omap3isp_h3a_af_cleanup(isp);
  1678. error_h3a_af:
  1679. omap3isp_h3a_aewb_cleanup(isp);
  1680. error_h3a_aewb:
  1681. omap3isp_hist_cleanup(isp);
  1682. error_hist:
  1683. omap3isp_resizer_cleanup(isp);
  1684. error_resizer:
  1685. omap3isp_preview_cleanup(isp);
  1686. error_preview:
  1687. omap3isp_ccdc_cleanup(isp);
  1688. error_ccdc:
  1689. omap3isp_ccp2_cleanup(isp);
  1690. error_ccp2:
  1691. omap3isp_csi2_cleanup(isp);
  1692. error_csi2:
  1693. error_csiphy:
  1694. return ret;
  1695. }
  1696. /*
  1697. * isp_remove - Remove ISP platform device
  1698. * @pdev: Pointer to ISP platform device
  1699. *
  1700. * Always returns 0.
  1701. */
  1702. static int isp_remove(struct platform_device *pdev)
  1703. {
  1704. struct isp_device *isp = platform_get_drvdata(pdev);
  1705. int i;
  1706. isp_unregister_entities(isp);
  1707. isp_cleanup_modules(isp);
  1708. omap3isp_get(isp);
  1709. iommu_detach_device(isp->domain, &pdev->dev);
  1710. iommu_domain_free(isp->domain);
  1711. isp->domain = NULL;
  1712. omap3isp_put(isp);
  1713. free_irq(isp->irq_num, isp);
  1714. isp_put_clocks(isp);
  1715. for (i = 0; i < OMAP3_ISP_IOMEM_LAST; i++) {
  1716. if (isp->mmio_base[i]) {
  1717. iounmap(isp->mmio_base[i]);
  1718. isp->mmio_base[i] = NULL;
  1719. }
  1720. if (isp->mmio_base_phys[i]) {
  1721. release_mem_region(isp->mmio_base_phys[i],
  1722. isp->mmio_size[i]);
  1723. isp->mmio_base_phys[i] = 0;
  1724. }
  1725. }
  1726. regulator_put(isp->isp_csiphy1.vdd);
  1727. regulator_put(isp->isp_csiphy2.vdd);
  1728. kfree(isp);
  1729. return 0;
  1730. }
  1731. static int isp_map_mem_resource(struct platform_device *pdev,
  1732. struct isp_device *isp,
  1733. enum isp_mem_resources res)
  1734. {
  1735. struct resource *mem;
  1736. /* request the mem region for the camera registers */
  1737. mem = platform_get_resource(pdev, IORESOURCE_MEM, res);
  1738. if (!mem) {
  1739. dev_err(isp->dev, "no mem resource?\n");
  1740. return -ENODEV;
  1741. }
  1742. if (!request_mem_region(mem->start, resource_size(mem), pdev->name)) {
  1743. dev_err(isp->dev,
  1744. "cannot reserve camera register I/O region\n");
  1745. return -ENODEV;
  1746. }
  1747. isp->mmio_base_phys[res] = mem->start;
  1748. isp->mmio_size[res] = resource_size(mem);
  1749. /* map the region */
  1750. isp->mmio_base[res] = ioremap_nocache(isp->mmio_base_phys[res],
  1751. isp->mmio_size[res]);
  1752. if (!isp->mmio_base[res]) {
  1753. dev_err(isp->dev, "cannot map camera register I/O region\n");
  1754. return -ENODEV;
  1755. }
  1756. return 0;
  1757. }
  1758. /*
  1759. * isp_probe - Probe ISP platform device
  1760. * @pdev: Pointer to ISP platform device
  1761. *
  1762. * Returns 0 if successful,
  1763. * -ENOMEM if no memory available,
  1764. * -ENODEV if no platform device resources found
  1765. * or no space for remapping registers,
  1766. * -EINVAL if couldn't install ISR,
  1767. * or clk_get return error value.
  1768. */
  1769. static int isp_probe(struct platform_device *pdev)
  1770. {
  1771. struct isp_platform_data *pdata = pdev->dev.platform_data;
  1772. struct isp_device *isp;
  1773. int ret;
  1774. int i, m;
  1775. if (pdata == NULL)
  1776. return -EINVAL;
  1777. isp = kzalloc(sizeof(*isp), GFP_KERNEL);
  1778. if (!isp) {
  1779. dev_err(&pdev->dev, "could not allocate memory\n");
  1780. return -ENOMEM;
  1781. }
  1782. isp->autoidle = autoidle;
  1783. isp->platform_cb.set_xclk = isp_set_xclk;
  1784. isp->platform_cb.set_pixel_clock = isp_set_pixel_clock;
  1785. mutex_init(&isp->isp_mutex);
  1786. spin_lock_init(&isp->stat_lock);
  1787. isp->dev = &pdev->dev;
  1788. isp->pdata = pdata;
  1789. isp->ref_count = 0;
  1790. isp->raw_dmamask = DMA_BIT_MASK(32);
  1791. isp->dev->dma_mask = &isp->raw_dmamask;
  1792. isp->dev->coherent_dma_mask = DMA_BIT_MASK(32);
  1793. platform_set_drvdata(pdev, isp);
  1794. /* Regulators */
  1795. isp->isp_csiphy1.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY1");
  1796. isp->isp_csiphy2.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY2");
  1797. /* Clocks */
  1798. ret = isp_map_mem_resource(pdev, isp, OMAP3_ISP_IOMEM_MAIN);
  1799. if (ret < 0)
  1800. goto error;
  1801. ret = isp_get_clocks(isp);
  1802. if (ret < 0)
  1803. goto error;
  1804. if (omap3isp_get(isp) == NULL)
  1805. goto error;
  1806. ret = isp_reset(isp);
  1807. if (ret < 0)
  1808. goto error_isp;
  1809. /* Memory resources */
  1810. isp->revision = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
  1811. dev_info(isp->dev, "Revision %d.%d found\n",
  1812. (isp->revision & 0xf0) >> 4, isp->revision & 0x0f);
  1813. for (m = 0; m < ARRAY_SIZE(isp_res_maps); m++)
  1814. if (isp->revision == isp_res_maps[m].isp_rev)
  1815. break;
  1816. if (m == ARRAY_SIZE(isp_res_maps)) {
  1817. dev_err(isp->dev, "No resource map found for ISP rev %d.%d\n",
  1818. (isp->revision & 0xf0) >> 4, isp->revision & 0xf);
  1819. ret = -ENODEV;
  1820. goto error_isp;
  1821. }
  1822. for (i = 1; i < OMAP3_ISP_IOMEM_LAST; i++) {
  1823. if (isp_res_maps[m].map & 1 << i) {
  1824. ret = isp_map_mem_resource(pdev, isp, i);
  1825. if (ret)
  1826. goto error_isp;
  1827. }
  1828. }
  1829. isp->domain = iommu_domain_alloc(pdev->dev.bus);
  1830. if (!isp->domain) {
  1831. dev_err(isp->dev, "can't alloc iommu domain\n");
  1832. ret = -ENOMEM;
  1833. goto error_isp;
  1834. }
  1835. ret = iommu_attach_device(isp->domain, &pdev->dev);
  1836. if (ret) {
  1837. dev_err(&pdev->dev, "can't attach iommu device: %d\n", ret);
  1838. goto free_domain;
  1839. }
  1840. /* Interrupt */
  1841. isp->irq_num = platform_get_irq(pdev, 0);
  1842. if (isp->irq_num <= 0) {
  1843. dev_err(isp->dev, "No IRQ resource\n");
  1844. ret = -ENODEV;
  1845. goto detach_dev;
  1846. }
  1847. if (request_irq(isp->irq_num, isp_isr, IRQF_SHARED, "OMAP3 ISP", isp)) {
  1848. dev_err(isp->dev, "Unable to request IRQ\n");
  1849. ret = -EINVAL;
  1850. goto detach_dev;
  1851. }
  1852. /* Entities */
  1853. ret = isp_initialize_modules(isp);
  1854. if (ret < 0)
  1855. goto error_irq;
  1856. ret = isp_register_entities(isp);
  1857. if (ret < 0)
  1858. goto error_modules;
  1859. isp_power_settings(isp, 1);
  1860. omap3isp_put(isp);
  1861. return 0;
  1862. error_modules:
  1863. isp_cleanup_modules(isp);
  1864. error_irq:
  1865. free_irq(isp->irq_num, isp);
  1866. detach_dev:
  1867. iommu_detach_device(isp->domain, &pdev->dev);
  1868. free_domain:
  1869. iommu_domain_free(isp->domain);
  1870. error_isp:
  1871. omap3isp_put(isp);
  1872. error:
  1873. isp_put_clocks(isp);
  1874. for (i = 0; i < OMAP3_ISP_IOMEM_LAST; i++) {
  1875. if (isp->mmio_base[i]) {
  1876. iounmap(isp->mmio_base[i]);
  1877. isp->mmio_base[i] = NULL;
  1878. }
  1879. if (isp->mmio_base_phys[i]) {
  1880. release_mem_region(isp->mmio_base_phys[i],
  1881. isp->mmio_size[i]);
  1882. isp->mmio_base_phys[i] = 0;
  1883. }
  1884. }
  1885. regulator_put(isp->isp_csiphy2.vdd);
  1886. regulator_put(isp->isp_csiphy1.vdd);
  1887. platform_set_drvdata(pdev, NULL);
  1888. mutex_destroy(&isp->isp_mutex);
  1889. kfree(isp);
  1890. return ret;
  1891. }
  1892. static const struct dev_pm_ops omap3isp_pm_ops = {
  1893. .prepare = isp_pm_prepare,
  1894. .suspend = isp_pm_suspend,
  1895. .resume = isp_pm_resume,
  1896. .complete = isp_pm_complete,
  1897. };
  1898. static struct platform_device_id omap3isp_id_table[] = {
  1899. { "omap3isp", 0 },
  1900. { },
  1901. };
  1902. MODULE_DEVICE_TABLE(platform, omap3isp_id_table);
  1903. static struct platform_driver omap3isp_driver = {
  1904. .probe = isp_probe,
  1905. .remove = isp_remove,
  1906. .id_table = omap3isp_id_table,
  1907. .driver = {
  1908. .owner = THIS_MODULE,
  1909. .name = "omap3isp",
  1910. .pm = &omap3isp_pm_ops,
  1911. },
  1912. };
  1913. module_platform_driver(omap3isp_driver);
  1914. MODULE_AUTHOR("Nokia Corporation");
  1915. MODULE_DESCRIPTION("TI OMAP3 ISP driver");
  1916. MODULE_LICENSE("GPL");
  1917. MODULE_VERSION(ISP_VIDEO_DRIVER_VERSION);