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