hdmi_drv.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. /*
  2. * Samsung HDMI interface driver
  3. *
  4. * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
  5. *
  6. * Tomasz Stanislawski, <t.stanislaws@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published
  10. * by the Free Software Foundiation. either version 2 of the License,
  11. * or (at your option) any later version
  12. */
  13. #define pr_fmt(fmt) "s5p-tv (hdmi_drv): " fmt
  14. #ifdef CONFIG_VIDEO_SAMSUNG_S5P_HDMI_DEBUG
  15. #define DEBUG
  16. #endif
  17. #include <linux/kernel.h>
  18. #include <linux/slab.h>
  19. #include <linux/io.h>
  20. #include <linux/i2c.h>
  21. #include <linux/platform_device.h>
  22. #include <media/v4l2-subdev.h>
  23. #include <linux/module.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/delay.h>
  27. #include <linux/bug.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/clk.h>
  30. #include <linux/regulator/consumer.h>
  31. #include <linux/v4l2-dv-timings.h>
  32. #include <media/s5p_hdmi.h>
  33. #include <media/v4l2-common.h>
  34. #include <media/v4l2-dev.h>
  35. #include <media/v4l2-device.h>
  36. #include <media/v4l2-dv-timings.h>
  37. #include "regs-hdmi.h"
  38. MODULE_AUTHOR("Tomasz Stanislawski, <t.stanislaws@samsung.com>");
  39. MODULE_DESCRIPTION("Samsung HDMI");
  40. MODULE_LICENSE("GPL");
  41. struct hdmi_pulse {
  42. u32 beg;
  43. u32 end;
  44. };
  45. struct hdmi_timings {
  46. struct hdmi_pulse hact;
  47. u32 hsyn_pol; /* 0 - high, 1 - low */
  48. struct hdmi_pulse hsyn;
  49. u32 interlaced;
  50. struct hdmi_pulse vact[2];
  51. u32 vsyn_pol; /* 0 - high, 1 - low */
  52. u32 vsyn_off;
  53. struct hdmi_pulse vsyn[2];
  54. };
  55. struct hdmi_resources {
  56. struct clk *hdmi;
  57. struct clk *sclk_hdmi;
  58. struct clk *sclk_pixel;
  59. struct clk *sclk_hdmiphy;
  60. struct clk *hdmiphy;
  61. struct regulator_bulk_data *regul_bulk;
  62. int regul_count;
  63. };
  64. struct hdmi_device {
  65. /** base address of HDMI registers */
  66. void __iomem *regs;
  67. /** HDMI interrupt */
  68. unsigned int irq;
  69. /** pointer to device parent */
  70. struct device *dev;
  71. /** subdev generated by HDMI device */
  72. struct v4l2_subdev sd;
  73. /** V4L2 device structure */
  74. struct v4l2_device v4l2_dev;
  75. /** subdev of HDMIPHY interface */
  76. struct v4l2_subdev *phy_sd;
  77. /** subdev of MHL interface */
  78. struct v4l2_subdev *mhl_sd;
  79. /** configuration of current graphic mode */
  80. const struct hdmi_timings *cur_conf;
  81. /** flag indicating that timings are dirty */
  82. int cur_conf_dirty;
  83. /** current timings */
  84. struct v4l2_dv_timings cur_timings;
  85. /** other resources */
  86. struct hdmi_resources res;
  87. };
  88. static const struct platform_device_id hdmi_driver_types[] = {
  89. {
  90. .name = "s5pv210-hdmi",
  91. }, {
  92. .name = "exynos4-hdmi",
  93. }, {
  94. /* end node */
  95. }
  96. };
  97. static const struct v4l2_subdev_ops hdmi_sd_ops;
  98. static struct hdmi_device *sd_to_hdmi_dev(struct v4l2_subdev *sd)
  99. {
  100. return container_of(sd, struct hdmi_device, sd);
  101. }
  102. static inline
  103. void hdmi_write(struct hdmi_device *hdev, u32 reg_id, u32 value)
  104. {
  105. writel(value, hdev->regs + reg_id);
  106. }
  107. static inline
  108. void hdmi_write_mask(struct hdmi_device *hdev, u32 reg_id, u32 value, u32 mask)
  109. {
  110. u32 old = readl(hdev->regs + reg_id);
  111. value = (value & mask) | (old & ~mask);
  112. writel(value, hdev->regs + reg_id);
  113. }
  114. static inline
  115. void hdmi_writeb(struct hdmi_device *hdev, u32 reg_id, u8 value)
  116. {
  117. writeb(value, hdev->regs + reg_id);
  118. }
  119. static inline
  120. void hdmi_writebn(struct hdmi_device *hdev, u32 reg_id, int n, u32 value)
  121. {
  122. switch (n) {
  123. default:
  124. writeb(value >> 24, hdev->regs + reg_id + 12);
  125. case 3:
  126. writeb(value >> 16, hdev->regs + reg_id + 8);
  127. case 2:
  128. writeb(value >> 8, hdev->regs + reg_id + 4);
  129. case 1:
  130. writeb(value >> 0, hdev->regs + reg_id + 0);
  131. }
  132. }
  133. static inline u32 hdmi_read(struct hdmi_device *hdev, u32 reg_id)
  134. {
  135. return readl(hdev->regs + reg_id);
  136. }
  137. static irqreturn_t hdmi_irq_handler(int irq, void *dev_data)
  138. {
  139. struct hdmi_device *hdev = dev_data;
  140. u32 intc_flag;
  141. (void)irq;
  142. intc_flag = hdmi_read(hdev, HDMI_INTC_FLAG);
  143. /* clearing flags for HPD plug/unplug */
  144. if (intc_flag & HDMI_INTC_FLAG_HPD_UNPLUG) {
  145. pr_info("unplugged\n");
  146. hdmi_write_mask(hdev, HDMI_INTC_FLAG, ~0,
  147. HDMI_INTC_FLAG_HPD_UNPLUG);
  148. }
  149. if (intc_flag & HDMI_INTC_FLAG_HPD_PLUG) {
  150. pr_info("plugged\n");
  151. hdmi_write_mask(hdev, HDMI_INTC_FLAG, ~0,
  152. HDMI_INTC_FLAG_HPD_PLUG);
  153. }
  154. return IRQ_HANDLED;
  155. }
  156. static void hdmi_reg_init(struct hdmi_device *hdev)
  157. {
  158. /* enable HPD interrupts */
  159. hdmi_write_mask(hdev, HDMI_INTC_CON, ~0, HDMI_INTC_EN_GLOBAL |
  160. HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG);
  161. /* choose DVI mode */
  162. hdmi_write_mask(hdev, HDMI_MODE_SEL,
  163. HDMI_MODE_DVI_EN, HDMI_MODE_MASK);
  164. hdmi_write_mask(hdev, HDMI_CON_2, ~0,
  165. HDMI_DVI_PERAMBLE_EN | HDMI_DVI_BAND_EN);
  166. /* disable bluescreen */
  167. hdmi_write_mask(hdev, HDMI_CON_0, 0, HDMI_BLUE_SCR_EN);
  168. /* choose bluescreen (fecal) color */
  169. hdmi_writeb(hdev, HDMI_BLUE_SCREEN_0, 0x12);
  170. hdmi_writeb(hdev, HDMI_BLUE_SCREEN_1, 0x34);
  171. hdmi_writeb(hdev, HDMI_BLUE_SCREEN_2, 0x56);
  172. }
  173. static void hdmi_timing_apply(struct hdmi_device *hdev,
  174. const struct hdmi_timings *t)
  175. {
  176. /* setting core registers */
  177. hdmi_writebn(hdev, HDMI_H_BLANK_0, 2, t->hact.beg);
  178. hdmi_writebn(hdev, HDMI_H_SYNC_GEN_0, 3,
  179. (t->hsyn_pol << 20) | (t->hsyn.end << 10) | t->hsyn.beg);
  180. hdmi_writeb(hdev, HDMI_VSYNC_POL, t->vsyn_pol);
  181. hdmi_writebn(hdev, HDMI_V_BLANK_0, 3,
  182. (t->vact[0].beg << 11) | t->vact[0].end);
  183. hdmi_writebn(hdev, HDMI_V_SYNC_GEN_1_0, 3,
  184. (t->vsyn[0].beg << 12) | t->vsyn[0].end);
  185. if (t->interlaced) {
  186. u32 vsyn_trans = t->hsyn.beg + t->vsyn_off;
  187. hdmi_writeb(hdev, HDMI_INT_PRO_MODE, 1);
  188. hdmi_writebn(hdev, HDMI_H_V_LINE_0, 3,
  189. (t->hact.end << 12) | t->vact[1].end);
  190. hdmi_writebn(hdev, HDMI_V_BLANK_F_0, 3,
  191. (t->vact[1].end << 11) | t->vact[1].beg);
  192. hdmi_writebn(hdev, HDMI_V_SYNC_GEN_2_0, 3,
  193. (t->vsyn[1].beg << 12) | t->vsyn[1].end);
  194. hdmi_writebn(hdev, HDMI_V_SYNC_GEN_3_0, 3,
  195. (vsyn_trans << 12) | vsyn_trans);
  196. } else {
  197. hdmi_writeb(hdev, HDMI_INT_PRO_MODE, 0);
  198. hdmi_writebn(hdev, HDMI_H_V_LINE_0, 3,
  199. (t->hact.end << 12) | t->vact[0].end);
  200. }
  201. /* Timing generator registers */
  202. hdmi_writebn(hdev, HDMI_TG_H_FSZ_L, 2, t->hact.end);
  203. hdmi_writebn(hdev, HDMI_TG_HACT_ST_L, 2, t->hact.beg);
  204. hdmi_writebn(hdev, HDMI_TG_HACT_SZ_L, 2, t->hact.end - t->hact.beg);
  205. hdmi_writebn(hdev, HDMI_TG_VSYNC_L, 2, t->vsyn[0].beg);
  206. hdmi_writebn(hdev, HDMI_TG_VACT_ST_L, 2, t->vact[0].beg);
  207. hdmi_writebn(hdev, HDMI_TG_VACT_SZ_L, 2,
  208. t->vact[0].end - t->vact[0].beg);
  209. hdmi_writebn(hdev, HDMI_TG_VSYNC_TOP_HDMI_L, 2, t->vsyn[0].beg);
  210. hdmi_writebn(hdev, HDMI_TG_FIELD_TOP_HDMI_L, 2, t->vsyn[0].beg);
  211. if (t->interlaced) {
  212. hdmi_write_mask(hdev, HDMI_TG_CMD, ~0, HDMI_TG_FIELD_EN);
  213. hdmi_writebn(hdev, HDMI_TG_V_FSZ_L, 2, t->vact[1].end);
  214. hdmi_writebn(hdev, HDMI_TG_VSYNC2_L, 2, t->vsyn[1].beg);
  215. hdmi_writebn(hdev, HDMI_TG_FIELD_CHG_L, 2, t->vact[0].end);
  216. hdmi_writebn(hdev, HDMI_TG_VACT_ST2_L, 2, t->vact[1].beg);
  217. hdmi_writebn(hdev, HDMI_TG_VSYNC_BOT_HDMI_L, 2, t->vsyn[1].beg);
  218. hdmi_writebn(hdev, HDMI_TG_FIELD_BOT_HDMI_L, 2, t->vsyn[1].beg);
  219. } else {
  220. hdmi_write_mask(hdev, HDMI_TG_CMD, 0, HDMI_TG_FIELD_EN);
  221. hdmi_writebn(hdev, HDMI_TG_V_FSZ_L, 2, t->vact[0].end);
  222. }
  223. }
  224. static int hdmi_conf_apply(struct hdmi_device *hdmi_dev)
  225. {
  226. struct device *dev = hdmi_dev->dev;
  227. const struct hdmi_timings *conf = hdmi_dev->cur_conf;
  228. int ret;
  229. dev_dbg(dev, "%s\n", __func__);
  230. /* skip if conf is already synchronized with HW */
  231. if (!hdmi_dev->cur_conf_dirty)
  232. return 0;
  233. /* reset hdmiphy */
  234. hdmi_write_mask(hdmi_dev, HDMI_PHY_RSTOUT, ~0, HDMI_PHY_SW_RSTOUT);
  235. mdelay(10);
  236. hdmi_write_mask(hdmi_dev, HDMI_PHY_RSTOUT, 0, HDMI_PHY_SW_RSTOUT);
  237. mdelay(10);
  238. /* configure timings */
  239. ret = v4l2_subdev_call(hdmi_dev->phy_sd, video, s_dv_timings,
  240. &hdmi_dev->cur_timings);
  241. if (ret) {
  242. dev_err(dev, "failed to set timings\n");
  243. return ret;
  244. }
  245. /* resetting HDMI core */
  246. hdmi_write_mask(hdmi_dev, HDMI_CORE_RSTOUT, 0, HDMI_CORE_SW_RSTOUT);
  247. mdelay(10);
  248. hdmi_write_mask(hdmi_dev, HDMI_CORE_RSTOUT, ~0, HDMI_CORE_SW_RSTOUT);
  249. mdelay(10);
  250. hdmi_reg_init(hdmi_dev);
  251. /* setting core registers */
  252. hdmi_timing_apply(hdmi_dev, conf);
  253. hdmi_dev->cur_conf_dirty = 0;
  254. return 0;
  255. }
  256. static void hdmi_dumpregs(struct hdmi_device *hdev, char *prefix)
  257. {
  258. #define DUMPREG(reg_id) \
  259. dev_dbg(hdev->dev, "%s:" #reg_id " = %08x\n", prefix, \
  260. readl(hdev->regs + reg_id))
  261. dev_dbg(hdev->dev, "%s: ---- CONTROL REGISTERS ----\n", prefix);
  262. DUMPREG(HDMI_INTC_FLAG);
  263. DUMPREG(HDMI_INTC_CON);
  264. DUMPREG(HDMI_HPD_STATUS);
  265. DUMPREG(HDMI_PHY_RSTOUT);
  266. DUMPREG(HDMI_PHY_VPLL);
  267. DUMPREG(HDMI_PHY_CMU);
  268. DUMPREG(HDMI_CORE_RSTOUT);
  269. dev_dbg(hdev->dev, "%s: ---- CORE REGISTERS ----\n", prefix);
  270. DUMPREG(HDMI_CON_0);
  271. DUMPREG(HDMI_CON_1);
  272. DUMPREG(HDMI_CON_2);
  273. DUMPREG(HDMI_SYS_STATUS);
  274. DUMPREG(HDMI_PHY_STATUS);
  275. DUMPREG(HDMI_STATUS_EN);
  276. DUMPREG(HDMI_HPD);
  277. DUMPREG(HDMI_MODE_SEL);
  278. DUMPREG(HDMI_HPD_GEN);
  279. DUMPREG(HDMI_DC_CONTROL);
  280. DUMPREG(HDMI_VIDEO_PATTERN_GEN);
  281. dev_dbg(hdev->dev, "%s: ---- CORE SYNC REGISTERS ----\n", prefix);
  282. DUMPREG(HDMI_H_BLANK_0);
  283. DUMPREG(HDMI_H_BLANK_1);
  284. DUMPREG(HDMI_V_BLANK_0);
  285. DUMPREG(HDMI_V_BLANK_1);
  286. DUMPREG(HDMI_V_BLANK_2);
  287. DUMPREG(HDMI_H_V_LINE_0);
  288. DUMPREG(HDMI_H_V_LINE_1);
  289. DUMPREG(HDMI_H_V_LINE_2);
  290. DUMPREG(HDMI_VSYNC_POL);
  291. DUMPREG(HDMI_INT_PRO_MODE);
  292. DUMPREG(HDMI_V_BLANK_F_0);
  293. DUMPREG(HDMI_V_BLANK_F_1);
  294. DUMPREG(HDMI_V_BLANK_F_2);
  295. DUMPREG(HDMI_H_SYNC_GEN_0);
  296. DUMPREG(HDMI_H_SYNC_GEN_1);
  297. DUMPREG(HDMI_H_SYNC_GEN_2);
  298. DUMPREG(HDMI_V_SYNC_GEN_1_0);
  299. DUMPREG(HDMI_V_SYNC_GEN_1_1);
  300. DUMPREG(HDMI_V_SYNC_GEN_1_2);
  301. DUMPREG(HDMI_V_SYNC_GEN_2_0);
  302. DUMPREG(HDMI_V_SYNC_GEN_2_1);
  303. DUMPREG(HDMI_V_SYNC_GEN_2_2);
  304. DUMPREG(HDMI_V_SYNC_GEN_3_0);
  305. DUMPREG(HDMI_V_SYNC_GEN_3_1);
  306. DUMPREG(HDMI_V_SYNC_GEN_3_2);
  307. dev_dbg(hdev->dev, "%s: ---- TG REGISTERS ----\n", prefix);
  308. DUMPREG(HDMI_TG_CMD);
  309. DUMPREG(HDMI_TG_H_FSZ_L);
  310. DUMPREG(HDMI_TG_H_FSZ_H);
  311. DUMPREG(HDMI_TG_HACT_ST_L);
  312. DUMPREG(HDMI_TG_HACT_ST_H);
  313. DUMPREG(HDMI_TG_HACT_SZ_L);
  314. DUMPREG(HDMI_TG_HACT_SZ_H);
  315. DUMPREG(HDMI_TG_V_FSZ_L);
  316. DUMPREG(HDMI_TG_V_FSZ_H);
  317. DUMPREG(HDMI_TG_VSYNC_L);
  318. DUMPREG(HDMI_TG_VSYNC_H);
  319. DUMPREG(HDMI_TG_VSYNC2_L);
  320. DUMPREG(HDMI_TG_VSYNC2_H);
  321. DUMPREG(HDMI_TG_VACT_ST_L);
  322. DUMPREG(HDMI_TG_VACT_ST_H);
  323. DUMPREG(HDMI_TG_VACT_SZ_L);
  324. DUMPREG(HDMI_TG_VACT_SZ_H);
  325. DUMPREG(HDMI_TG_FIELD_CHG_L);
  326. DUMPREG(HDMI_TG_FIELD_CHG_H);
  327. DUMPREG(HDMI_TG_VACT_ST2_L);
  328. DUMPREG(HDMI_TG_VACT_ST2_H);
  329. DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_L);
  330. DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_H);
  331. DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_L);
  332. DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_H);
  333. DUMPREG(HDMI_TG_FIELD_TOP_HDMI_L);
  334. DUMPREG(HDMI_TG_FIELD_TOP_HDMI_H);
  335. DUMPREG(HDMI_TG_FIELD_BOT_HDMI_L);
  336. DUMPREG(HDMI_TG_FIELD_BOT_HDMI_H);
  337. #undef DUMPREG
  338. }
  339. static const struct hdmi_timings hdmi_timings_480p = {
  340. .hact = { .beg = 138, .end = 858 },
  341. .hsyn_pol = 1,
  342. .hsyn = { .beg = 16, .end = 16 + 62 },
  343. .interlaced = 0,
  344. .vact[0] = { .beg = 42 + 3, .end = 522 + 3 },
  345. .vsyn_pol = 1,
  346. .vsyn[0] = { .beg = 6 + 3, .end = 12 + 3},
  347. };
  348. static const struct hdmi_timings hdmi_timings_576p50 = {
  349. .hact = { .beg = 144, .end = 864 },
  350. .hsyn_pol = 1,
  351. .hsyn = { .beg = 12, .end = 12 + 64 },
  352. .interlaced = 0,
  353. .vact[0] = { .beg = 44 + 5, .end = 620 + 5 },
  354. .vsyn_pol = 1,
  355. .vsyn[0] = { .beg = 0 + 5, .end = 5 + 5},
  356. };
  357. static const struct hdmi_timings hdmi_timings_720p60 = {
  358. .hact = { .beg = 370, .end = 1650 },
  359. .hsyn_pol = 0,
  360. .hsyn = { .beg = 110, .end = 110 + 40 },
  361. .interlaced = 0,
  362. .vact[0] = { .beg = 25 + 5, .end = 745 + 5 },
  363. .vsyn_pol = 0,
  364. .vsyn[0] = { .beg = 0 + 5, .end = 5 + 5},
  365. };
  366. static const struct hdmi_timings hdmi_timings_720p50 = {
  367. .hact = { .beg = 700, .end = 1980 },
  368. .hsyn_pol = 0,
  369. .hsyn = { .beg = 440, .end = 440 + 40 },
  370. .interlaced = 0,
  371. .vact[0] = { .beg = 25 + 5, .end = 745 + 5 },
  372. .vsyn_pol = 0,
  373. .vsyn[0] = { .beg = 0 + 5, .end = 5 + 5},
  374. };
  375. static const struct hdmi_timings hdmi_timings_1080p24 = {
  376. .hact = { .beg = 830, .end = 2750 },
  377. .hsyn_pol = 0,
  378. .hsyn = { .beg = 638, .end = 638 + 44 },
  379. .interlaced = 0,
  380. .vact[0] = { .beg = 41 + 4, .end = 1121 + 4 },
  381. .vsyn_pol = 0,
  382. .vsyn[0] = { .beg = 0 + 4, .end = 5 + 4},
  383. };
  384. static const struct hdmi_timings hdmi_timings_1080p60 = {
  385. .hact = { .beg = 280, .end = 2200 },
  386. .hsyn_pol = 0,
  387. .hsyn = { .beg = 88, .end = 88 + 44 },
  388. .interlaced = 0,
  389. .vact[0] = { .beg = 41 + 4, .end = 1121 + 4 },
  390. .vsyn_pol = 0,
  391. .vsyn[0] = { .beg = 0 + 4, .end = 5 + 4},
  392. };
  393. static const struct hdmi_timings hdmi_timings_1080i60 = {
  394. .hact = { .beg = 280, .end = 2200 },
  395. .hsyn_pol = 0,
  396. .hsyn = { .beg = 88, .end = 88 + 44 },
  397. .interlaced = 1,
  398. .vact[0] = { .beg = 20 + 2, .end = 560 + 2 },
  399. .vact[1] = { .beg = 583 + 2, .end = 1123 + 2 },
  400. .vsyn_pol = 0,
  401. .vsyn_off = 1100,
  402. .vsyn[0] = { .beg = 0 + 2, .end = 5 + 2},
  403. .vsyn[1] = { .beg = 562 + 2, .end = 567 + 2},
  404. };
  405. static const struct hdmi_timings hdmi_timings_1080i50 = {
  406. .hact = { .beg = 720, .end = 2640 },
  407. .hsyn_pol = 0,
  408. .hsyn = { .beg = 528, .end = 528 + 44 },
  409. .interlaced = 1,
  410. .vact[0] = { .beg = 20 + 2, .end = 560 + 2 },
  411. .vact[1] = { .beg = 583 + 2, .end = 1123 + 2 },
  412. .vsyn_pol = 0,
  413. .vsyn_off = 1320,
  414. .vsyn[0] = { .beg = 0 + 2, .end = 5 + 2},
  415. .vsyn[1] = { .beg = 562 + 2, .end = 567 + 2},
  416. };
  417. static const struct hdmi_timings hdmi_timings_1080p50 = {
  418. .hact = { .beg = 720, .end = 2640 },
  419. .hsyn_pol = 0,
  420. .hsyn = { .beg = 528, .end = 528 + 44 },
  421. .interlaced = 0,
  422. .vact[0] = { .beg = 41 + 4, .end = 1121 + 4 },
  423. .vsyn_pol = 0,
  424. .vsyn[0] = { .beg = 0 + 4, .end = 5 + 4},
  425. };
  426. /* default hdmi_timings index of the timings configured on probe */
  427. #define HDMI_DEFAULT_TIMINGS_IDX (0)
  428. static const struct {
  429. bool reduced_fps;
  430. const struct v4l2_dv_timings dv_timings;
  431. const struct hdmi_timings *hdmi_timings;
  432. } hdmi_timings[] = {
  433. { false, V4L2_DV_BT_CEA_720X480P59_94, &hdmi_timings_480p },
  434. { false, V4L2_DV_BT_CEA_720X576P50, &hdmi_timings_576p50 },
  435. { false, V4L2_DV_BT_CEA_1280X720P50, &hdmi_timings_720p50 },
  436. { true, V4L2_DV_BT_CEA_1280X720P60, &hdmi_timings_720p60 },
  437. { false, V4L2_DV_BT_CEA_1920X1080P24, &hdmi_timings_1080p24 },
  438. { false, V4L2_DV_BT_CEA_1920X1080P30, &hdmi_timings_1080p60 },
  439. { false, V4L2_DV_BT_CEA_1920X1080P50, &hdmi_timings_1080p50 },
  440. { false, V4L2_DV_BT_CEA_1920X1080I50, &hdmi_timings_1080i50 },
  441. { false, V4L2_DV_BT_CEA_1920X1080I60, &hdmi_timings_1080i60 },
  442. { false, V4L2_DV_BT_CEA_1920X1080P60, &hdmi_timings_1080p60 },
  443. };
  444. static int hdmi_streamon(struct hdmi_device *hdev)
  445. {
  446. struct device *dev = hdev->dev;
  447. struct hdmi_resources *res = &hdev->res;
  448. int ret, tries;
  449. dev_dbg(dev, "%s\n", __func__);
  450. ret = hdmi_conf_apply(hdev);
  451. if (ret)
  452. return ret;
  453. ret = v4l2_subdev_call(hdev->phy_sd, video, s_stream, 1);
  454. if (ret)
  455. return ret;
  456. /* waiting for HDMIPHY's PLL to get to steady state */
  457. for (tries = 100; tries; --tries) {
  458. u32 val = hdmi_read(hdev, HDMI_PHY_STATUS);
  459. if (val & HDMI_PHY_STATUS_READY)
  460. break;
  461. mdelay(1);
  462. }
  463. /* steady state not achieved */
  464. if (tries == 0) {
  465. dev_err(dev, "hdmiphy's pll could not reach steady state.\n");
  466. v4l2_subdev_call(hdev->phy_sd, video, s_stream, 0);
  467. hdmi_dumpregs(hdev, "hdmiphy - s_stream");
  468. return -EIO;
  469. }
  470. /* starting MHL */
  471. ret = v4l2_subdev_call(hdev->mhl_sd, video, s_stream, 1);
  472. if (hdev->mhl_sd && ret) {
  473. v4l2_subdev_call(hdev->phy_sd, video, s_stream, 0);
  474. hdmi_dumpregs(hdev, "mhl - s_stream");
  475. return -EIO;
  476. }
  477. /* hdmiphy clock is used for HDMI in streaming mode */
  478. clk_disable(res->sclk_hdmi);
  479. clk_set_parent(res->sclk_hdmi, res->sclk_hdmiphy);
  480. clk_enable(res->sclk_hdmi);
  481. /* enable HDMI and timing generator */
  482. hdmi_write_mask(hdev, HDMI_CON_0, ~0, HDMI_EN);
  483. hdmi_write_mask(hdev, HDMI_TG_CMD, ~0, HDMI_TG_EN);
  484. hdmi_dumpregs(hdev, "streamon");
  485. return 0;
  486. }
  487. static int hdmi_streamoff(struct hdmi_device *hdev)
  488. {
  489. struct device *dev = hdev->dev;
  490. struct hdmi_resources *res = &hdev->res;
  491. dev_dbg(dev, "%s\n", __func__);
  492. hdmi_write_mask(hdev, HDMI_CON_0, 0, HDMI_EN);
  493. hdmi_write_mask(hdev, HDMI_TG_CMD, 0, HDMI_TG_EN);
  494. /* pixel(vpll) clock is used for HDMI in config mode */
  495. clk_disable(res->sclk_hdmi);
  496. clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
  497. clk_enable(res->sclk_hdmi);
  498. v4l2_subdev_call(hdev->mhl_sd, video, s_stream, 0);
  499. v4l2_subdev_call(hdev->phy_sd, video, s_stream, 0);
  500. hdmi_dumpregs(hdev, "streamoff");
  501. return 0;
  502. }
  503. static int hdmi_s_stream(struct v4l2_subdev *sd, int enable)
  504. {
  505. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  506. struct device *dev = hdev->dev;
  507. dev_dbg(dev, "%s(%d)\n", __func__, enable);
  508. if (enable)
  509. return hdmi_streamon(hdev);
  510. return hdmi_streamoff(hdev);
  511. }
  512. static int hdmi_resource_poweron(struct hdmi_resources *res)
  513. {
  514. int ret;
  515. /* turn HDMI power on */
  516. ret = regulator_bulk_enable(res->regul_count, res->regul_bulk);
  517. if (ret < 0)
  518. return ret;
  519. /* power-on hdmi physical interface */
  520. clk_enable(res->hdmiphy);
  521. /* use VPP as parent clock; HDMIPHY is not working yet */
  522. clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
  523. /* turn clocks on */
  524. clk_enable(res->sclk_hdmi);
  525. return 0;
  526. }
  527. static void hdmi_resource_poweroff(struct hdmi_resources *res)
  528. {
  529. /* turn clocks off */
  530. clk_disable(res->sclk_hdmi);
  531. /* power-off hdmiphy */
  532. clk_disable(res->hdmiphy);
  533. /* turn HDMI power off */
  534. regulator_bulk_disable(res->regul_count, res->regul_bulk);
  535. }
  536. static int hdmi_s_power(struct v4l2_subdev *sd, int on)
  537. {
  538. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  539. int ret;
  540. if (on)
  541. ret = pm_runtime_get_sync(hdev->dev);
  542. else
  543. ret = pm_runtime_put_sync(hdev->dev);
  544. /* only values < 0 indicate errors */
  545. return ret < 0 ? ret : 0;
  546. }
  547. static int hdmi_s_dv_timings(struct v4l2_subdev *sd,
  548. struct v4l2_dv_timings *timings)
  549. {
  550. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  551. struct device *dev = hdev->dev;
  552. int i;
  553. for (i = 0; i < ARRAY_SIZE(hdmi_timings); i++)
  554. if (v4l2_match_dv_timings(&hdmi_timings[i].dv_timings,
  555. timings, 0))
  556. break;
  557. if (i == ARRAY_SIZE(hdmi_timings)) {
  558. dev_err(dev, "timings not supported\n");
  559. return -EINVAL;
  560. }
  561. hdev->cur_conf = hdmi_timings[i].hdmi_timings;
  562. hdev->cur_conf_dirty = 1;
  563. hdev->cur_timings = *timings;
  564. if (!hdmi_timings[i].reduced_fps)
  565. hdev->cur_timings.bt.flags &= ~V4L2_DV_FL_CAN_REDUCE_FPS;
  566. return 0;
  567. }
  568. static int hdmi_g_dv_timings(struct v4l2_subdev *sd,
  569. struct v4l2_dv_timings *timings)
  570. {
  571. *timings = sd_to_hdmi_dev(sd)->cur_timings;
  572. return 0;
  573. }
  574. static int hdmi_get_fmt(struct v4l2_subdev *sd,
  575. struct v4l2_subdev_pad_config *cfg,
  576. struct v4l2_subdev_format *format)
  577. {
  578. struct v4l2_mbus_framefmt *fmt = &format->format;
  579. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  580. const struct hdmi_timings *t = hdev->cur_conf;
  581. dev_dbg(hdev->dev, "%s\n", __func__);
  582. if (!hdev->cur_conf)
  583. return -EINVAL;
  584. if (format->pad)
  585. return -EINVAL;
  586. memset(fmt, 0, sizeof(*fmt));
  587. fmt->width = t->hact.end - t->hact.beg;
  588. fmt->height = t->vact[0].end - t->vact[0].beg;
  589. fmt->code = MEDIA_BUS_FMT_FIXED; /* means RGB888 */
  590. fmt->colorspace = V4L2_COLORSPACE_SRGB;
  591. if (t->interlaced) {
  592. fmt->field = V4L2_FIELD_INTERLACED;
  593. fmt->height *= 2;
  594. } else {
  595. fmt->field = V4L2_FIELD_NONE;
  596. }
  597. return 0;
  598. }
  599. static int hdmi_enum_dv_timings(struct v4l2_subdev *sd,
  600. struct v4l2_enum_dv_timings *timings)
  601. {
  602. if (timings->pad != 0)
  603. return -EINVAL;
  604. if (timings->index >= ARRAY_SIZE(hdmi_timings))
  605. return -EINVAL;
  606. timings->timings = hdmi_timings[timings->index].dv_timings;
  607. if (!hdmi_timings[timings->index].reduced_fps)
  608. timings->timings.bt.flags &= ~V4L2_DV_FL_CAN_REDUCE_FPS;
  609. return 0;
  610. }
  611. static int hdmi_dv_timings_cap(struct v4l2_subdev *sd,
  612. struct v4l2_dv_timings_cap *cap)
  613. {
  614. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  615. if (cap->pad != 0)
  616. return -EINVAL;
  617. /* Let the phy fill in the pixelclock range */
  618. v4l2_subdev_call(hdev->phy_sd, pad, dv_timings_cap, cap);
  619. cap->type = V4L2_DV_BT_656_1120;
  620. cap->bt.min_width = 720;
  621. cap->bt.max_width = 1920;
  622. cap->bt.min_height = 480;
  623. cap->bt.max_height = 1080;
  624. cap->bt.standards = V4L2_DV_BT_STD_CEA861;
  625. cap->bt.capabilities = V4L2_DV_BT_CAP_INTERLACED |
  626. V4L2_DV_BT_CAP_PROGRESSIVE;
  627. return 0;
  628. }
  629. static const struct v4l2_subdev_core_ops hdmi_sd_core_ops = {
  630. .s_power = hdmi_s_power,
  631. };
  632. static const struct v4l2_subdev_video_ops hdmi_sd_video_ops = {
  633. .s_dv_timings = hdmi_s_dv_timings,
  634. .g_dv_timings = hdmi_g_dv_timings,
  635. .s_stream = hdmi_s_stream,
  636. };
  637. static const struct v4l2_subdev_pad_ops hdmi_sd_pad_ops = {
  638. .enum_dv_timings = hdmi_enum_dv_timings,
  639. .dv_timings_cap = hdmi_dv_timings_cap,
  640. .get_fmt = hdmi_get_fmt,
  641. };
  642. static const struct v4l2_subdev_ops hdmi_sd_ops = {
  643. .core = &hdmi_sd_core_ops,
  644. .video = &hdmi_sd_video_ops,
  645. .pad = &hdmi_sd_pad_ops,
  646. };
  647. static int hdmi_runtime_suspend(struct device *dev)
  648. {
  649. struct v4l2_subdev *sd = dev_get_drvdata(dev);
  650. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  651. dev_dbg(dev, "%s\n", __func__);
  652. v4l2_subdev_call(hdev->mhl_sd, core, s_power, 0);
  653. hdmi_resource_poweroff(&hdev->res);
  654. /* flag that device context is lost */
  655. hdev->cur_conf_dirty = 1;
  656. return 0;
  657. }
  658. static int hdmi_runtime_resume(struct device *dev)
  659. {
  660. struct v4l2_subdev *sd = dev_get_drvdata(dev);
  661. struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
  662. int ret;
  663. dev_dbg(dev, "%s\n", __func__);
  664. ret = hdmi_resource_poweron(&hdev->res);
  665. if (ret < 0)
  666. return ret;
  667. /* starting MHL */
  668. ret = v4l2_subdev_call(hdev->mhl_sd, core, s_power, 1);
  669. if (hdev->mhl_sd && ret)
  670. goto fail;
  671. dev_dbg(dev, "poweron succeed\n");
  672. return 0;
  673. fail:
  674. hdmi_resource_poweroff(&hdev->res);
  675. dev_err(dev, "poweron failed\n");
  676. return ret;
  677. }
  678. static const struct dev_pm_ops hdmi_pm_ops = {
  679. .runtime_suspend = hdmi_runtime_suspend,
  680. .runtime_resume = hdmi_runtime_resume,
  681. };
  682. static void hdmi_resource_clear_clocks(struct hdmi_resources *res)
  683. {
  684. res->hdmi = ERR_PTR(-EINVAL);
  685. res->sclk_hdmi = ERR_PTR(-EINVAL);
  686. res->sclk_pixel = ERR_PTR(-EINVAL);
  687. res->sclk_hdmiphy = ERR_PTR(-EINVAL);
  688. res->hdmiphy = ERR_PTR(-EINVAL);
  689. }
  690. static void hdmi_resources_cleanup(struct hdmi_device *hdev)
  691. {
  692. struct hdmi_resources *res = &hdev->res;
  693. dev_dbg(hdev->dev, "HDMI resource cleanup\n");
  694. /* put clocks, power */
  695. if (res->regul_count)
  696. regulator_bulk_free(res->regul_count, res->regul_bulk);
  697. /* kfree is NULL-safe */
  698. kfree(res->regul_bulk);
  699. if (!IS_ERR(res->hdmiphy))
  700. clk_put(res->hdmiphy);
  701. if (!IS_ERR(res->sclk_hdmiphy))
  702. clk_put(res->sclk_hdmiphy);
  703. if (!IS_ERR(res->sclk_pixel))
  704. clk_put(res->sclk_pixel);
  705. if (!IS_ERR(res->sclk_hdmi))
  706. clk_put(res->sclk_hdmi);
  707. if (!IS_ERR(res->hdmi))
  708. clk_put(res->hdmi);
  709. memset(res, 0, sizeof(*res));
  710. hdmi_resource_clear_clocks(res);
  711. }
  712. static int hdmi_resources_init(struct hdmi_device *hdev)
  713. {
  714. struct device *dev = hdev->dev;
  715. struct hdmi_resources *res = &hdev->res;
  716. static char *supply[] = {
  717. "hdmi-en",
  718. "vdd",
  719. "vdd_osc",
  720. "vdd_pll",
  721. };
  722. int i, ret;
  723. dev_dbg(dev, "HDMI resource init\n");
  724. memset(res, 0, sizeof(*res));
  725. hdmi_resource_clear_clocks(res);
  726. /* get clocks, power */
  727. res->hdmi = clk_get(dev, "hdmi");
  728. if (IS_ERR(res->hdmi)) {
  729. dev_err(dev, "failed to get clock 'hdmi'\n");
  730. goto fail;
  731. }
  732. res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
  733. if (IS_ERR(res->sclk_hdmi)) {
  734. dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
  735. goto fail;
  736. }
  737. res->sclk_pixel = clk_get(dev, "sclk_pixel");
  738. if (IS_ERR(res->sclk_pixel)) {
  739. dev_err(dev, "failed to get clock 'sclk_pixel'\n");
  740. goto fail;
  741. }
  742. res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy");
  743. if (IS_ERR(res->sclk_hdmiphy)) {
  744. dev_err(dev, "failed to get clock 'sclk_hdmiphy'\n");
  745. goto fail;
  746. }
  747. res->hdmiphy = clk_get(dev, "hdmiphy");
  748. if (IS_ERR(res->hdmiphy)) {
  749. dev_err(dev, "failed to get clock 'hdmiphy'\n");
  750. goto fail;
  751. }
  752. res->regul_bulk = kcalloc(ARRAY_SIZE(supply),
  753. sizeof(res->regul_bulk[0]), GFP_KERNEL);
  754. if (!res->regul_bulk) {
  755. dev_err(dev, "failed to get memory for regulators\n");
  756. goto fail;
  757. }
  758. for (i = 0; i < ARRAY_SIZE(supply); ++i) {
  759. res->regul_bulk[i].supply = supply[i];
  760. res->regul_bulk[i].consumer = NULL;
  761. }
  762. ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
  763. if (ret) {
  764. dev_err(dev, "failed to get regulators\n");
  765. goto fail;
  766. }
  767. res->regul_count = ARRAY_SIZE(supply);
  768. return 0;
  769. fail:
  770. dev_err(dev, "HDMI resource init - failed\n");
  771. hdmi_resources_cleanup(hdev);
  772. return -ENODEV;
  773. }
  774. static int hdmi_probe(struct platform_device *pdev)
  775. {
  776. struct device *dev = &pdev->dev;
  777. struct resource *res;
  778. struct i2c_adapter *adapter;
  779. struct v4l2_subdev *sd;
  780. struct hdmi_device *hdmi_dev = NULL;
  781. struct s5p_hdmi_platform_data *pdata = dev->platform_data;
  782. int ret;
  783. dev_dbg(dev, "probe start\n");
  784. if (!pdata) {
  785. dev_err(dev, "platform data is missing\n");
  786. ret = -ENODEV;
  787. goto fail;
  788. }
  789. hdmi_dev = devm_kzalloc(&pdev->dev, sizeof(*hdmi_dev), GFP_KERNEL);
  790. if (!hdmi_dev) {
  791. dev_err(dev, "out of memory\n");
  792. ret = -ENOMEM;
  793. goto fail;
  794. }
  795. hdmi_dev->dev = dev;
  796. ret = hdmi_resources_init(hdmi_dev);
  797. if (ret)
  798. goto fail;
  799. /* mapping HDMI registers */
  800. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  801. if (res == NULL) {
  802. dev_err(dev, "get memory resource failed.\n");
  803. ret = -ENXIO;
  804. goto fail_init;
  805. }
  806. hdmi_dev->regs = devm_ioremap(&pdev->dev, res->start,
  807. resource_size(res));
  808. if (hdmi_dev->regs == NULL) {
  809. dev_err(dev, "register mapping failed.\n");
  810. ret = -ENXIO;
  811. goto fail_init;
  812. }
  813. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  814. if (res == NULL) {
  815. dev_err(dev, "get interrupt resource failed.\n");
  816. ret = -ENXIO;
  817. goto fail_init;
  818. }
  819. ret = devm_request_irq(&pdev->dev, res->start, hdmi_irq_handler, 0,
  820. "hdmi", hdmi_dev);
  821. if (ret) {
  822. dev_err(dev, "request interrupt failed.\n");
  823. goto fail_init;
  824. }
  825. hdmi_dev->irq = res->start;
  826. /* setting v4l2 name to prevent WARN_ON in v4l2_device_register */
  827. strlcpy(hdmi_dev->v4l2_dev.name, dev_name(dev),
  828. sizeof(hdmi_dev->v4l2_dev.name));
  829. /* passing NULL owner prevents driver from erasing drvdata */
  830. ret = v4l2_device_register(NULL, &hdmi_dev->v4l2_dev);
  831. if (ret) {
  832. dev_err(dev, "could not register v4l2 device.\n");
  833. goto fail_init;
  834. }
  835. /* testing if hdmiphy info is present */
  836. if (!pdata->hdmiphy_info) {
  837. dev_err(dev, "hdmiphy info is missing in platform data\n");
  838. ret = -ENXIO;
  839. goto fail_vdev;
  840. }
  841. adapter = i2c_get_adapter(pdata->hdmiphy_bus);
  842. if (adapter == NULL) {
  843. dev_err(dev, "hdmiphy adapter request failed\n");
  844. ret = -ENXIO;
  845. goto fail_vdev;
  846. }
  847. hdmi_dev->phy_sd = v4l2_i2c_new_subdev_board(&hdmi_dev->v4l2_dev,
  848. adapter, pdata->hdmiphy_info, NULL);
  849. /* on failure or not adapter is no longer useful */
  850. i2c_put_adapter(adapter);
  851. if (hdmi_dev->phy_sd == NULL) {
  852. dev_err(dev, "missing subdev for hdmiphy\n");
  853. ret = -ENODEV;
  854. goto fail_vdev;
  855. }
  856. /* initialization of MHL interface if present */
  857. if (pdata->mhl_info) {
  858. adapter = i2c_get_adapter(pdata->mhl_bus);
  859. if (adapter == NULL) {
  860. dev_err(dev, "MHL adapter request failed\n");
  861. ret = -ENXIO;
  862. goto fail_vdev;
  863. }
  864. hdmi_dev->mhl_sd = v4l2_i2c_new_subdev_board(
  865. &hdmi_dev->v4l2_dev, adapter,
  866. pdata->mhl_info, NULL);
  867. /* on failure or not adapter is no longer useful */
  868. i2c_put_adapter(adapter);
  869. if (hdmi_dev->mhl_sd == NULL) {
  870. dev_err(dev, "missing subdev for MHL\n");
  871. ret = -ENODEV;
  872. goto fail_vdev;
  873. }
  874. }
  875. clk_enable(hdmi_dev->res.hdmi);
  876. pm_runtime_enable(dev);
  877. sd = &hdmi_dev->sd;
  878. v4l2_subdev_init(sd, &hdmi_sd_ops);
  879. sd->owner = THIS_MODULE;
  880. strlcpy(sd->name, "s5p-hdmi", sizeof(sd->name));
  881. hdmi_dev->cur_timings =
  882. hdmi_timings[HDMI_DEFAULT_TIMINGS_IDX].dv_timings;
  883. /* FIXME: missing fail timings is not supported */
  884. hdmi_dev->cur_conf =
  885. hdmi_timings[HDMI_DEFAULT_TIMINGS_IDX].hdmi_timings;
  886. hdmi_dev->cur_conf_dirty = 1;
  887. /* storing subdev for call that have only access to struct device */
  888. dev_set_drvdata(dev, sd);
  889. dev_info(dev, "probe successful\n");
  890. return 0;
  891. fail_vdev:
  892. v4l2_device_unregister(&hdmi_dev->v4l2_dev);
  893. fail_init:
  894. hdmi_resources_cleanup(hdmi_dev);
  895. fail:
  896. dev_err(dev, "probe failed\n");
  897. return ret;
  898. }
  899. static int hdmi_remove(struct platform_device *pdev)
  900. {
  901. struct device *dev = &pdev->dev;
  902. struct v4l2_subdev *sd = dev_get_drvdata(dev);
  903. struct hdmi_device *hdmi_dev = sd_to_hdmi_dev(sd);
  904. pm_runtime_disable(dev);
  905. clk_disable(hdmi_dev->res.hdmi);
  906. v4l2_device_unregister(&hdmi_dev->v4l2_dev);
  907. disable_irq(hdmi_dev->irq);
  908. hdmi_resources_cleanup(hdmi_dev);
  909. dev_info(dev, "remove successful\n");
  910. return 0;
  911. }
  912. static struct platform_driver hdmi_driver __refdata = {
  913. .probe = hdmi_probe,
  914. .remove = hdmi_remove,
  915. .id_table = hdmi_driver_types,
  916. .driver = {
  917. .name = "s5p-hdmi",
  918. .pm = &hdmi_pm_ops,
  919. }
  920. };
  921. module_platform_driver(hdmi_driver);