hdmi5.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*
  2. * HDMI driver for OMAP5
  3. *
  4. * Copyright (C) 2014 Texas Instruments Incorporated
  5. *
  6. * Authors:
  7. * Yong Zhi
  8. * Mythri pk
  9. * Archit Taneja <archit@ti.com>
  10. * Tomi Valkeinen <tomi.valkeinen@ti.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License version 2 as published by
  14. * the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but WITHOUT
  17. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  18. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  19. * more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along with
  22. * this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. #define DSS_SUBSYS_NAME "HDMI"
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/err.h>
  28. #include <linux/io.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/mutex.h>
  31. #include <linux/delay.h>
  32. #include <linux/string.h>
  33. #include <linux/platform_device.h>
  34. #include <linux/pm_runtime.h>
  35. #include <linux/clk.h>
  36. #include <linux/gpio.h>
  37. #include <linux/regulator/consumer.h>
  38. #include <video/omapdss.h>
  39. #include "hdmi5_core.h"
  40. #include "dss.h"
  41. #include "dss_features.h"
  42. static struct {
  43. struct mutex lock;
  44. struct platform_device *pdev;
  45. struct hdmi_wp_data wp;
  46. struct hdmi_pll_data pll;
  47. struct hdmi_phy_data phy;
  48. struct hdmi_core_data core;
  49. struct hdmi_config cfg;
  50. struct clk *sys_clk;
  51. struct regulator *vdda_reg;
  52. bool core_enabled;
  53. struct omap_dss_device output;
  54. } hdmi;
  55. static int hdmi_runtime_get(void)
  56. {
  57. int r;
  58. DSSDBG("hdmi_runtime_get\n");
  59. r = pm_runtime_get_sync(&hdmi.pdev->dev);
  60. WARN_ON(r < 0);
  61. if (r < 0)
  62. return r;
  63. return 0;
  64. }
  65. static void hdmi_runtime_put(void)
  66. {
  67. int r;
  68. DSSDBG("hdmi_runtime_put\n");
  69. r = pm_runtime_put_sync(&hdmi.pdev->dev);
  70. WARN_ON(r < 0 && r != -ENOSYS);
  71. }
  72. static irqreturn_t hdmi_irq_handler(int irq, void *data)
  73. {
  74. struct hdmi_wp_data *wp = data;
  75. u32 irqstatus;
  76. irqstatus = hdmi_wp_get_irqstatus(wp);
  77. hdmi_wp_set_irqstatus(wp, irqstatus);
  78. if ((irqstatus & HDMI_IRQ_LINK_CONNECT) &&
  79. irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
  80. u32 v;
  81. /*
  82. * If we get both connect and disconnect interrupts at the same
  83. * time, turn off the PHY, clear interrupts, and restart, which
  84. * raises connect interrupt if a cable is connected, or nothing
  85. * if cable is not connected.
  86. */
  87. hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF);
  88. /*
  89. * We always get bogus CONNECT & DISCONNECT interrupts when
  90. * setting the PHY to LDOON. To ignore those, we force the RXDET
  91. * line to 0 until the PHY power state has been changed.
  92. */
  93. v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
  94. v = FLD_MOD(v, 1, 15, 15); /* FORCE_RXDET_HIGH */
  95. v = FLD_MOD(v, 0, 14, 7); /* RXDET_LINE */
  96. hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
  97. hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
  98. HDMI_IRQ_LINK_DISCONNECT);
  99. hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
  100. REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
  101. } else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
  102. hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
  103. } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
  104. hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
  105. }
  106. return IRQ_HANDLED;
  107. }
  108. static int hdmi_init_regulator(void)
  109. {
  110. int r;
  111. struct regulator *reg;
  112. if (hdmi.vdda_reg != NULL)
  113. return 0;
  114. reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
  115. if (IS_ERR(reg)) {
  116. DSSERR("can't get VDDA regulator\n");
  117. return PTR_ERR(reg);
  118. }
  119. if (regulator_can_change_voltage(reg)) {
  120. r = regulator_set_voltage(reg, 1800000, 1800000);
  121. if (r) {
  122. devm_regulator_put(reg);
  123. DSSWARN("can't set the regulator voltage\n");
  124. return r;
  125. }
  126. }
  127. hdmi.vdda_reg = reg;
  128. return 0;
  129. }
  130. static int hdmi_power_on_core(struct omap_dss_device *dssdev)
  131. {
  132. int r;
  133. r = regulator_enable(hdmi.vdda_reg);
  134. if (r)
  135. return r;
  136. r = hdmi_runtime_get();
  137. if (r)
  138. goto err_runtime_get;
  139. /* Make selection of HDMI in DSS */
  140. dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
  141. hdmi.core_enabled = true;
  142. return 0;
  143. err_runtime_get:
  144. regulator_disable(hdmi.vdda_reg);
  145. return r;
  146. }
  147. static void hdmi_power_off_core(struct omap_dss_device *dssdev)
  148. {
  149. hdmi.core_enabled = false;
  150. hdmi_runtime_put();
  151. regulator_disable(hdmi.vdda_reg);
  152. }
  153. static int hdmi_power_on_full(struct omap_dss_device *dssdev)
  154. {
  155. int r;
  156. struct omap_video_timings *p;
  157. struct omap_overlay_manager *mgr = hdmi.output.manager;
  158. unsigned long phy;
  159. r = hdmi_power_on_core(dssdev);
  160. if (r)
  161. return r;
  162. p = &hdmi.cfg.timings;
  163. DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
  164. /* the functions below use kHz pixel clock. TODO: change to Hz */
  165. phy = p->pixelclock / 1000;
  166. hdmi_pll_compute(&hdmi.pll, clk_get_rate(hdmi.sys_clk), phy);
  167. /* disable and clear irqs */
  168. hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
  169. hdmi_wp_set_irqstatus(&hdmi.wp,
  170. hdmi_wp_get_irqstatus(&hdmi.wp));
  171. /* config the PLL and PHY hdmi_set_pll_pwrfirst */
  172. r = hdmi_pll_enable(&hdmi.pll, &hdmi.wp);
  173. if (r) {
  174. DSSDBG("Failed to lock PLL\n");
  175. goto err_pll_enable;
  176. }
  177. r = hdmi_phy_configure(&hdmi.phy, &hdmi.cfg);
  178. if (r) {
  179. DSSDBG("Failed to start PHY\n");
  180. goto err_phy_cfg;
  181. }
  182. r = hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_LDOON);
  183. if (r)
  184. goto err_phy_pwr;
  185. hdmi5_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
  186. /* bypass TV gamma table */
  187. dispc_enable_gamma_table(0);
  188. /* tv size */
  189. dss_mgr_set_timings(mgr, p);
  190. r = hdmi_wp_video_start(&hdmi.wp);
  191. if (r)
  192. goto err_vid_enable;
  193. r = dss_mgr_enable(mgr);
  194. if (r)
  195. goto err_mgr_enable;
  196. hdmi_wp_set_irqenable(&hdmi.wp,
  197. HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
  198. return 0;
  199. err_mgr_enable:
  200. hdmi_wp_video_stop(&hdmi.wp);
  201. err_vid_enable:
  202. hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
  203. err_phy_pwr:
  204. err_phy_cfg:
  205. hdmi_pll_disable(&hdmi.pll, &hdmi.wp);
  206. err_pll_enable:
  207. hdmi_power_off_core(dssdev);
  208. return -EIO;
  209. }
  210. static void hdmi_power_off_full(struct omap_dss_device *dssdev)
  211. {
  212. struct omap_overlay_manager *mgr = hdmi.output.manager;
  213. hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
  214. dss_mgr_disable(mgr);
  215. hdmi_wp_video_stop(&hdmi.wp);
  216. hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
  217. hdmi_pll_disable(&hdmi.pll, &hdmi.wp);
  218. hdmi_power_off_core(dssdev);
  219. }
  220. static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
  221. struct omap_video_timings *timings)
  222. {
  223. struct omap_dss_device *out = &hdmi.output;
  224. if (!dispc_mgr_timings_ok(out->dispc_channel, timings))
  225. return -EINVAL;
  226. return 0;
  227. }
  228. static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
  229. struct omap_video_timings *timings)
  230. {
  231. mutex_lock(&hdmi.lock);
  232. hdmi.cfg.timings = *timings;
  233. dispc_set_tv_pclk(timings->pixelclock);
  234. mutex_unlock(&hdmi.lock);
  235. }
  236. static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
  237. struct omap_video_timings *timings)
  238. {
  239. *timings = hdmi.cfg.timings;
  240. }
  241. static void hdmi_dump_regs(struct seq_file *s)
  242. {
  243. mutex_lock(&hdmi.lock);
  244. if (hdmi_runtime_get()) {
  245. mutex_unlock(&hdmi.lock);
  246. return;
  247. }
  248. hdmi_wp_dump(&hdmi.wp, s);
  249. hdmi_pll_dump(&hdmi.pll, s);
  250. hdmi_phy_dump(&hdmi.phy, s);
  251. hdmi5_core_dump(&hdmi.core, s);
  252. hdmi_runtime_put();
  253. mutex_unlock(&hdmi.lock);
  254. }
  255. static int read_edid(u8 *buf, int len)
  256. {
  257. int r;
  258. int idlemode;
  259. mutex_lock(&hdmi.lock);
  260. r = hdmi_runtime_get();
  261. BUG_ON(r);
  262. idlemode = REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
  263. /* No-idle mode */
  264. REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
  265. r = hdmi5_read_edid(&hdmi.core, buf, len);
  266. REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
  267. hdmi_runtime_put();
  268. mutex_unlock(&hdmi.lock);
  269. return r;
  270. }
  271. static int hdmi_display_enable(struct omap_dss_device *dssdev)
  272. {
  273. struct omap_dss_device *out = &hdmi.output;
  274. int r = 0;
  275. DSSDBG("ENTER hdmi_display_enable\n");
  276. mutex_lock(&hdmi.lock);
  277. if (out == NULL || out->manager == NULL) {
  278. DSSERR("failed to enable display: no output/manager\n");
  279. r = -ENODEV;
  280. goto err0;
  281. }
  282. r = hdmi_power_on_full(dssdev);
  283. if (r) {
  284. DSSERR("failed to power on device\n");
  285. goto err0;
  286. }
  287. mutex_unlock(&hdmi.lock);
  288. return 0;
  289. err0:
  290. mutex_unlock(&hdmi.lock);
  291. return r;
  292. }
  293. static void hdmi_display_disable(struct omap_dss_device *dssdev)
  294. {
  295. DSSDBG("Enter hdmi_display_disable\n");
  296. mutex_lock(&hdmi.lock);
  297. hdmi_power_off_full(dssdev);
  298. mutex_unlock(&hdmi.lock);
  299. }
  300. static int hdmi_core_enable(struct omap_dss_device *dssdev)
  301. {
  302. int r = 0;
  303. DSSDBG("ENTER omapdss_hdmi_core_enable\n");
  304. mutex_lock(&hdmi.lock);
  305. r = hdmi_power_on_core(dssdev);
  306. if (r) {
  307. DSSERR("failed to power on device\n");
  308. goto err0;
  309. }
  310. mutex_unlock(&hdmi.lock);
  311. return 0;
  312. err0:
  313. mutex_unlock(&hdmi.lock);
  314. return r;
  315. }
  316. static void hdmi_core_disable(struct omap_dss_device *dssdev)
  317. {
  318. DSSDBG("Enter omapdss_hdmi_core_disable\n");
  319. mutex_lock(&hdmi.lock);
  320. hdmi_power_off_core(dssdev);
  321. mutex_unlock(&hdmi.lock);
  322. }
  323. static int hdmi_get_clocks(struct platform_device *pdev)
  324. {
  325. struct clk *clk;
  326. clk = devm_clk_get(&pdev->dev, "sys_clk");
  327. if (IS_ERR(clk)) {
  328. DSSERR("can't get sys_clk\n");
  329. return PTR_ERR(clk);
  330. }
  331. hdmi.sys_clk = clk;
  332. return 0;
  333. }
  334. static int hdmi_connect(struct omap_dss_device *dssdev,
  335. struct omap_dss_device *dst)
  336. {
  337. struct omap_overlay_manager *mgr;
  338. int r;
  339. r = hdmi_init_regulator();
  340. if (r)
  341. return r;
  342. mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
  343. if (!mgr)
  344. return -ENODEV;
  345. r = dss_mgr_connect(mgr, dssdev);
  346. if (r)
  347. return r;
  348. r = omapdss_output_set_device(dssdev, dst);
  349. if (r) {
  350. DSSERR("failed to connect output to new device: %s\n",
  351. dst->name);
  352. dss_mgr_disconnect(mgr, dssdev);
  353. return r;
  354. }
  355. return 0;
  356. }
  357. static void hdmi_disconnect(struct omap_dss_device *dssdev,
  358. struct omap_dss_device *dst)
  359. {
  360. WARN_ON(dst != dssdev->dst);
  361. if (dst != dssdev->dst)
  362. return;
  363. omapdss_output_unset_device(dssdev);
  364. if (dssdev->manager)
  365. dss_mgr_disconnect(dssdev->manager, dssdev);
  366. }
  367. static int hdmi_read_edid(struct omap_dss_device *dssdev,
  368. u8 *edid, int len)
  369. {
  370. bool need_enable;
  371. int r;
  372. need_enable = hdmi.core_enabled == false;
  373. if (need_enable) {
  374. r = hdmi_core_enable(dssdev);
  375. if (r)
  376. return r;
  377. }
  378. r = read_edid(edid, len);
  379. if (need_enable)
  380. hdmi_core_disable(dssdev);
  381. return r;
  382. }
  383. #if defined(CONFIG_OMAP5_DSS_HDMI_AUDIO)
  384. static int hdmi_audio_enable(struct omap_dss_device *dssdev)
  385. {
  386. int r;
  387. mutex_lock(&hdmi.lock);
  388. if (!hdmi_mode_has_audio(hdmi.cfg.hdmi_dvi_mode)) {
  389. r = -EPERM;
  390. goto err;
  391. }
  392. r = hdmi_wp_audio_enable(&hdmi.wp, true);
  393. if (r)
  394. goto err;
  395. mutex_unlock(&hdmi.lock);
  396. return 0;
  397. err:
  398. mutex_unlock(&hdmi.lock);
  399. return r;
  400. }
  401. static void hdmi_audio_disable(struct omap_dss_device *dssdev)
  402. {
  403. hdmi_wp_audio_enable(&hdmi.wp, false);
  404. }
  405. static int hdmi_audio_start(struct omap_dss_device *dssdev)
  406. {
  407. return hdmi_wp_audio_core_req_enable(&hdmi.wp, true);
  408. }
  409. static void hdmi_audio_stop(struct omap_dss_device *dssdev)
  410. {
  411. hdmi_wp_audio_core_req_enable(&hdmi.wp, false);
  412. }
  413. static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
  414. {
  415. bool r;
  416. mutex_lock(&hdmi.lock);
  417. r = hdmi_mode_has_audio(hdmi.cfg.hdmi_dvi_mode);
  418. mutex_unlock(&hdmi.lock);
  419. return r;
  420. }
  421. static int hdmi_audio_config(struct omap_dss_device *dssdev,
  422. struct omap_dss_audio *audio)
  423. {
  424. int r;
  425. u32 pclk = hdmi.cfg.timings.pixelclock;
  426. mutex_lock(&hdmi.lock);
  427. if (!hdmi_mode_has_audio(hdmi.cfg.hdmi_dvi_mode)) {
  428. r = -EPERM;
  429. goto err;
  430. }
  431. r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, audio, pclk);
  432. if (r)
  433. goto err;
  434. mutex_unlock(&hdmi.lock);
  435. return 0;
  436. err:
  437. mutex_unlock(&hdmi.lock);
  438. return r;
  439. }
  440. #else
  441. static int hdmi_audio_enable(struct omap_dss_device *dssdev)
  442. {
  443. return -EPERM;
  444. }
  445. static void hdmi_audio_disable(struct omap_dss_device *dssdev)
  446. {
  447. }
  448. static int hdmi_audio_start(struct omap_dss_device *dssdev)
  449. {
  450. return -EPERM;
  451. }
  452. static void hdmi_audio_stop(struct omap_dss_device *dssdev)
  453. {
  454. }
  455. static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
  456. {
  457. return false;
  458. }
  459. static int hdmi_audio_config(struct omap_dss_device *dssdev,
  460. struct omap_dss_audio *audio)
  461. {
  462. return -EPERM;
  463. }
  464. #endif
  465. static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
  466. const struct hdmi_avi_infoframe *avi)
  467. {
  468. hdmi.cfg.infoframe = *avi;
  469. return 0;
  470. }
  471. static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
  472. bool hdmi_mode)
  473. {
  474. hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
  475. return 0;
  476. }
  477. static const struct omapdss_hdmi_ops hdmi_ops = {
  478. .connect = hdmi_connect,
  479. .disconnect = hdmi_disconnect,
  480. .enable = hdmi_display_enable,
  481. .disable = hdmi_display_disable,
  482. .check_timings = hdmi_display_check_timing,
  483. .set_timings = hdmi_display_set_timing,
  484. .get_timings = hdmi_display_get_timings,
  485. .read_edid = hdmi_read_edid,
  486. .set_infoframe = hdmi_set_infoframe,
  487. .set_hdmi_mode = hdmi_set_hdmi_mode,
  488. .audio_enable = hdmi_audio_enable,
  489. .audio_disable = hdmi_audio_disable,
  490. .audio_start = hdmi_audio_start,
  491. .audio_stop = hdmi_audio_stop,
  492. .audio_supported = hdmi_audio_supported,
  493. .audio_config = hdmi_audio_config,
  494. };
  495. static void hdmi_init_output(struct platform_device *pdev)
  496. {
  497. struct omap_dss_device *out = &hdmi.output;
  498. out->dev = &pdev->dev;
  499. out->id = OMAP_DSS_OUTPUT_HDMI;
  500. out->output_type = OMAP_DISPLAY_TYPE_HDMI;
  501. out->name = "hdmi.0";
  502. out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
  503. out->ops.hdmi = &hdmi_ops;
  504. out->owner = THIS_MODULE;
  505. omapdss_register_output(out);
  506. }
  507. static void __exit hdmi_uninit_output(struct platform_device *pdev)
  508. {
  509. struct omap_dss_device *out = &hdmi.output;
  510. omapdss_unregister_output(out);
  511. }
  512. static int hdmi_probe_of(struct platform_device *pdev)
  513. {
  514. struct device_node *node = pdev->dev.of_node;
  515. struct device_node *ep;
  516. int r;
  517. ep = omapdss_of_get_first_endpoint(node);
  518. if (!ep)
  519. return 0;
  520. r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
  521. if (r)
  522. goto err;
  523. of_node_put(ep);
  524. return 0;
  525. err:
  526. of_node_put(ep);
  527. return r;
  528. }
  529. /* HDMI HW IP initialisation */
  530. static int omapdss_hdmihw_probe(struct platform_device *pdev)
  531. {
  532. int r;
  533. int irq;
  534. hdmi.pdev = pdev;
  535. mutex_init(&hdmi.lock);
  536. if (pdev->dev.of_node) {
  537. r = hdmi_probe_of(pdev);
  538. if (r)
  539. return r;
  540. }
  541. r = hdmi_wp_init(pdev, &hdmi.wp);
  542. if (r)
  543. return r;
  544. r = hdmi_pll_init(pdev, &hdmi.pll);
  545. if (r)
  546. return r;
  547. r = hdmi_phy_init(pdev, &hdmi.phy);
  548. if (r)
  549. return r;
  550. r = hdmi5_core_init(pdev, &hdmi.core);
  551. if (r)
  552. return r;
  553. r = hdmi_get_clocks(pdev);
  554. if (r) {
  555. DSSERR("can't get clocks\n");
  556. return r;
  557. }
  558. irq = platform_get_irq(pdev, 0);
  559. if (irq < 0) {
  560. DSSERR("platform_get_irq failed\n");
  561. return -ENODEV;
  562. }
  563. r = devm_request_threaded_irq(&pdev->dev, irq,
  564. NULL, hdmi_irq_handler,
  565. IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp);
  566. if (r) {
  567. DSSERR("HDMI IRQ request failed\n");
  568. return r;
  569. }
  570. pm_runtime_enable(&pdev->dev);
  571. hdmi_init_output(pdev);
  572. dss_debugfs_create_file("hdmi", hdmi_dump_regs);
  573. return 0;
  574. }
  575. static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
  576. {
  577. hdmi_uninit_output(pdev);
  578. pm_runtime_disable(&pdev->dev);
  579. return 0;
  580. }
  581. static int hdmi_runtime_suspend(struct device *dev)
  582. {
  583. clk_disable_unprepare(hdmi.sys_clk);
  584. dispc_runtime_put();
  585. return 0;
  586. }
  587. static int hdmi_runtime_resume(struct device *dev)
  588. {
  589. int r;
  590. r = dispc_runtime_get();
  591. if (r < 0)
  592. return r;
  593. clk_prepare_enable(hdmi.sys_clk);
  594. return 0;
  595. }
  596. static const struct dev_pm_ops hdmi_pm_ops = {
  597. .runtime_suspend = hdmi_runtime_suspend,
  598. .runtime_resume = hdmi_runtime_resume,
  599. };
  600. static const struct of_device_id hdmi_of_match[] = {
  601. { .compatible = "ti,omap5-hdmi", },
  602. {},
  603. };
  604. static struct platform_driver omapdss_hdmihw_driver = {
  605. .probe = omapdss_hdmihw_probe,
  606. .remove = __exit_p(omapdss_hdmihw_remove),
  607. .driver = {
  608. .name = "omapdss_hdmi5",
  609. .owner = THIS_MODULE,
  610. .pm = &hdmi_pm_ops,
  611. .of_match_table = hdmi_of_match,
  612. .suppress_bind_attrs = true,
  613. },
  614. };
  615. int __init hdmi5_init_platform_driver(void)
  616. {
  617. return platform_driver_register(&omapdss_hdmihw_driver);
  618. }
  619. void __exit hdmi5_uninit_platform_driver(void)
  620. {
  621. platform_driver_unregister(&omapdss_hdmihw_driver);
  622. }