lcd: add auto test for panel color bar
authorEvoke Zhang <evoke.zhang@amlogic.com>
Thu, 19 Apr 2018 08:10:34 +0000 (16:10 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Tue, 21 Aug 2018 11:28:56 +0000 (04:28 -0700)
PD#169249: lcd: add auto test for panel color bar
also add gp0_pll clktree for clk_path 1 used

Change-Id: I78d1e42e68bfb8f294247053fdae4bb09fc3077a
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
arch/arm64/boot/dts/amlogic/mesong12a_skt-panel.dtsi
arch/arm64/boot/dts/amlogic/mesong12b_skt-panel.dtsi
drivers/amlogic/media/vout/lcd/lcd_clk_config.c
drivers/amlogic/media/vout/lcd/lcd_vout.c
include/linux/amlogic/media/vout/lcd/lcd_vout.h

index ecaca4a..8a5b9a5 100644 (file)
                        &clkc CLKID_MIPI_DSI_PHY
                        &clkc CLKID_DSI_MEAS_COMP
                        &clkc CLKID_VCLK2_ENCL
-                       &clkc CLKID_VCLK2_VENCL>;
+                       &clkc CLKID_VCLK2_VENCL
+                       &clkc CLKID_GP0_PLL>;
                clock-names = "dsi_host_gate",
                        "dsi_phy_gate",
                        "dsi_meas",
                        "encl_top_gate",
-                       "encl_int_gate";
+                       "encl_int_gate",
+                       "gp0_pll";
                reg = <0x0 0xffd07000 0x0 0x400    /* dsi_host */
                        0x0 0xff644000 0x0 0x200>; /* dsi_phy */
                interrupts = <0 3 1>;
index 277cdfd..8caa15d 100644 (file)
                        &clkc CLKID_MIPI_DSI_PHY
                        &clkc CLKID_DSI_MEAS_COMP
                        &clkc CLKID_VCLK2_ENCL
-                       &clkc CLKID_VCLK2_VENCL>;
+                       &clkc CLKID_VCLK2_VENCL
+                       &clkc CLKID_GP0_PLL>;
                clock-names = "dsi_host_gate",
                        "dsi_phy_gate",
                        "dsi_meas",
                        "encl_top_gate",
-                       "encl_int_gate";
+                       "encl_int_gate",
+                       "gp0_pll";
                reg = <0x0 0xffd07000 0x0 0x400    /* dsi_host */
                        0x0 0xff644000 0x0 0x200>; /* dsi_phy */
                interrupts = <0 3 1>;
index 1b2a57a..eccb4cf 100644 (file)
@@ -2427,6 +2427,13 @@ void lcd_clk_gate_switch(int status)
                        break;
                case LCD_CHIP_G12A:
                case LCD_CHIP_G12B:
+                       if (lcd_drv->lcd_clk_path) {
+                               if (IS_ERR(lcd_drv->gp0_pll))
+                                       LCDERR("%s: gp0_pll\n", __func__);
+                               else
+                                       clk_prepare_enable(lcd_drv->gp0_pll);
+                       }
+
                        if (IS_ERR(lcd_drv->dsi_host_gate))
                                LCDERR("%s: dsi_host_gate\n", __func__);
                        else
@@ -2521,6 +2528,13 @@ void lcd_clk_gate_switch(int status)
                        else
                                clk_disable_unprepare(
                                        lcd_drv->encl_top_gate);
+
+                       if (lcd_drv->lcd_clk_path) {
+                               if (IS_ERR(lcd_drv->gp0_pll))
+                                       LCDERR("%s: gp0_pll\n", __func__);
+                               else
+                                       clk_disable_unprepare(lcd_drv->gp0_pll);
+                       }
                        break;
                default:
                        if (IS_ERR(lcd_drv->encl_int_gate))
@@ -2598,6 +2612,10 @@ static void lcd_clktree_probe(void)
                        lcd_drv->dev, "encl_int_gate");
                if (IS_ERR(lcd_drv->encl_int_gate))
                        LCDERR("%s: clk encl_int_gate\n", __func__);
+
+               lcd_drv->gp0_pll = devm_clk_get(lcd_drv->dev, "gp0_pll");
+               if (IS_ERR(lcd_drv->gp0_pll))
+                       LCDERR("%s: clk gp0_pll\n", __func__);
                break;
        default:
                lcd_drv->encl_top_gate = devm_clk_get(lcd_drv->dev,
@@ -2634,6 +2652,8 @@ static void lcd_clktree_remove(void)
                        devm_clk_put(lcd_drv->dev, lcd_drv->dsi_phy_gate);
                if (!IS_ERR(lcd_drv->dsi_host_gate))
                        devm_clk_put(lcd_drv->dev, lcd_drv->dsi_host_gate);
+               if (!IS_ERR(lcd_drv->gp0_pll))
+                       devm_clk_put(lcd_drv->dev, lcd_drv->gp0_pll);
                break;
        case LCD_CHIP_G12A:
        case LCD_CHIP_G12B:
index 9cc196b..f2db70b 100644 (file)
@@ -936,6 +936,16 @@ static int lcd_config_probe(struct platform_device *pdev)
                LCDPR("detect lcd_clk_path: %d\n", lcd_driver->lcd_clk_path);
        }
 
+       ret = of_property_read_u32(lcd_driver->dev->of_node, "auto_test", &val);
+       if (ret) {
+               if (lcd_debug_print_flag)
+                       LCDPR("failed to get auto_test\n");
+               lcd_driver->lcd_auto_test = 0;
+       } else {
+               lcd_driver->lcd_auto_test = (unsigned char)val;
+               LCDPR("detect lcd_auto_test: %d\n", lcd_driver->lcd_auto_test);
+       }
+
        lcd_driver->lcd_info = &lcd_vinfo;
        lcd_driver->lcd_config = &lcd_config_dft;
        lcd_driver->lcd_test_state = 0;
@@ -1084,6 +1094,28 @@ static const struct of_device_id lcd_dt_match_table[] = {
 };
 #endif
 
+static struct delayed_work lcd_test_delayed_work;
+static void lcd_auto_test_delayed(struct work_struct *work)
+{
+       LCDPR("%s\n", __func__);
+       mutex_lock(&lcd_driver->power_mutex);
+       aml_lcd_notifier_call_chain(LCD_EVENT_POWER_ON, NULL);
+       mutex_unlock(&lcd_driver->power_mutex);
+}
+
+static void lcd_auto_test(unsigned char flag)
+{
+       lcd_driver->lcd_test_flag = flag;
+       if (lcd_driver->workqueue) {
+               queue_delayed_work(lcd_driver->workqueue,
+                       &lcd_test_delayed_work,
+                       msecs_to_jiffies(20000));
+       } else {
+               schedule_delayed_work(&lcd_test_delayed_work,
+                       msecs_to_jiffies(20000));
+       }
+}
+
 static int lcd_probe(struct platform_device *pdev)
 {
        const struct of_device_id *match;
@@ -1120,6 +1152,7 @@ static int lcd_probe(struct platform_device *pdev)
        /* init workqueue */
        INIT_DELAYED_WORK(&lcd_driver->lcd_probe_delayed_work,
                lcd_config_probe_delayed);
+       INIT_DELAYED_WORK(&lcd_test_delayed_work, lcd_auto_test_delayed);
        lcd_driver->workqueue = create_singlethread_workqueue("lcd_work_queue");
        if (lcd_driver->workqueue == NULL)
                LCDERR("can't create lcd workqueue\n");
@@ -1131,6 +1164,10 @@ static int lcd_probe(struct platform_device *pdev)
        lcd_vsync_irq_init();
 
        LCDPR("%s %s\n", __func__, (ret ? "failed" : "ok"));
+
+       if (lcd_driver->lcd_auto_test)
+               lcd_auto_test(lcd_driver->lcd_auto_test);
+
        return 0;
 }
 
index ccf8a91..a8e8565 100644 (file)
@@ -418,6 +418,7 @@ struct aml_lcd_drv_s {
        unsigned char lcd_clk_path; /* 0=hpll, 1=gp0_pll */
        unsigned char lcd_config_load;
        unsigned char lcd_resume_type; /* 0=directly, 1=workqueue */
+       unsigned char lcd_auto_test;
        unsigned char lcd_test_state;
        unsigned char lcd_test_flag;
        unsigned char lcd_mute_state;
@@ -432,6 +433,7 @@ struct aml_lcd_drv_s {
        struct clk *dsi_meas;
        struct clk *mipi_enable_gate;
        struct clk *mipi_bandgap_gate;
+       struct clk *gp0_pll;
 
        struct device *dev;
        struct lcd_config_s *lcd_config;