From f7a91ee41448a4ec9a7206ec4725176be964e8ad Mon Sep 17 00:00:00 2001 From: Hang Cheng Date: Wed, 8 Aug 2018 21:25:27 +0800 Subject: [PATCH] hdmirx: add power ctrl in early suspend PD#171879: hdmirx: add power ctrl in early suspend add rxsense pulse(20ms) to fix mtk box sda low issue. 50ms delay is needed between rxsense pulse and rxsense high, accroding to experiment and LG TV Change-Id: Ifceeec415f9c69abce7aced1f3011020848043d0 Signed-off-by: Hang Cheng --- .../amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c | 116 +++++++++++++-------- .../amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h | 2 +- 2 files changed, 74 insertions(+), 44 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c index 6096998..9b745c8 100644 --- a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c +++ b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c @@ -46,6 +46,9 @@ #include /*#include */ #include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include +#endif /* Local include */ #include "hdmi_rx_drv.h" @@ -137,6 +140,9 @@ int suspend_pddq_sel = 1; static int hpd_low_cec_off = 1; int disable_port_num; int disable_port_en; +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +static bool early_suspend_flag; +#endif struct reg_map reg_maps[MAP_ADDR_MODULE_NUM]; @@ -1520,17 +1526,67 @@ static int hdmirx_switch_pinmux(struct device *dev) } return ret; } -#ifdef CONFIG_HAS_EARLYSUSPEND + +static void rx_phy_suspend(void) +{ + /* set HPD low when cec off. */ + if (!hdmi_cec_en) + rx_set_port_hpd(ALL_PORTS, 0); + if (suspend_pddq_sel == 0) + rx_pr("don't set phy pddq down\n"); + else { + /* there's no SDA low issue on MTK box when CEC off */ + if (hdmi_cec_en != 0) { + if (suspend_pddq_sel == 2) { + /* set rxsense pulse */ + hdmirx_phy_pddq(1); + mdelay(10); + hdmirx_phy_pddq(0); + mdelay(10); + } + } + /* phy powerdown */ + hdmirx_phy_pddq(1); + } +} + +static void rx_phy_resume(void) +{ + if (hdmi_cec_en != 0) { + if (suspend_pddq_sel == 1) { + /* set rxsense pulse, if delay time between + * rxsense pulse and phy_int shottern than + * 50ms, SDA may be pulled low 800ms on MTK box + */ + hdmirx_phy_pddq(0); + msleep(20); + hdmirx_phy_pddq(1); + msleep(50); + } + } + hdmirx_phy_init(); + pre_port = 0xff; + rx.boot_flag = true; +} + +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void hdmirx_early_suspend(struct early_suspend *h) { + if (early_suspend_flag) + return; + + early_suspend_flag = true; + rx_phy_suspend(); rx_pr("hdmirx_early_suspend ok\n"); } static void hdmirx_late_resume(struct early_suspend *h) { - /* after early suspend & late resuem, also need to */ - /* do hpd reset when open port for hdcp compliance */ - pre_port = 0xff; + if (!early_suspend_flag) + return; + + early_suspend_flag = false; + rx_phy_resume(); rx_pr("hdmirx_late_resume ok\n"); }; @@ -1833,7 +1889,7 @@ static int hdmirx_probe(struct platform_device *pdev) } hdmirx_hw_probe(); hdmirx_switch_pinmux(&(pdev->dev)); -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND register_early_suspend(&hdmirx_early_suspend_handler); #endif mutex_init(&hdevp->rx_lock); @@ -1896,7 +1952,7 @@ static int hdmirx_remove(struct platform_device *pdev) cancel_delayed_work_sync(&esm_dwork); destroy_workqueue(esm_wq); -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND unregister_early_suspend(&hdmirx_early_suspend_handler); #endif mutex_destroy(&hdevp->rx_lock); @@ -1947,31 +2003,15 @@ static int hdmirx_suspend(struct platform_device *pdev, pm_message_t state) struct hdmirx_dev_s *hdevp; hdevp = platform_get_drvdata(pdev); - rx_pr("[hdmirx]: hdmirx_suspend\n"); del_timer_sync(&hdevp->timer); - /* set HPD low when cec off. */ - if (!hdmi_cec_en) - rx_set_port_hpd(ALL_PORTS, 0); - - if (suspend_pddq_sel == 0) - rx_pr("don't set phy pddq down\n"); - else { - /* there's no SDA low issue on MTK box when CEC off */ - if (hdmi_cec_en != 0) { - if (suspend_pddq_sel == 2) { - /* set rxsense pulse */ - mdelay(10); - hdmirx_phy_pddq(1); - mdelay(10); - hdmirx_phy_pddq(0); - } - } - /* phy powerdown */ - hdmirx_phy_pddq(1); - } +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND + /* if early suspend not called, need to pw down phy here */ + if (!early_suspend_flag) +#endif + rx_phy_suspend(); if (hdcp22_on) hdcp22_suspend(); - rx_pr("[hdmirx]: suspend success\n"); + rx_pr("hdmirx: suspend success\n"); return 0; } @@ -1980,25 +2020,15 @@ static int hdmirx_resume(struct platform_device *pdev) struct hdmirx_dev_s *hdevp; hdevp = platform_get_drvdata(pdev); - if (hdmi_cec_en != 0) { - if (suspend_pddq_sel == 1) { - /* set rxsense pulse, if delay time between - * rxsense pulse and phy_int shottern than - * 50ms, SDA may be pulled low 800ms on MTK box - */ - hdmirx_phy_pddq(0); - mdelay(10); - hdmirx_phy_pddq(1); - mdelay(50); - } - } - rx.boot_flag = true; - hdmirx_phy_init(); add_timer(&hdevp->timer); +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND + /* if early suspend not called, need to pw up phy here */ + if (!early_suspend_flag) +#endif + rx_phy_resume(); if (hdcp22_on) hdcp22_resume(); rx_pr("hdmirx: resume\n"); - pre_port = 0xff; return 0; } #endif diff --git a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h index 93db9db..061e7bf 100644 --- a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h +++ b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h @@ -41,7 +41,7 @@ * * */ -#define RX_VER1 "ver.2018/07/19" +#define RX_VER1 "ver.2018/08/22" /* * * -- 2.7.4