isp.c 59 KB

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