hdmi4.c 15 KB

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