imx: ventana: update LVDS support
authorTim Harvey <tharvey@gateworks.com>
Wed, 29 Sep 2021 22:04:21 +0000 (15:04 -0700)
committerStefano Babic <sbabic@denx.de>
Thu, 7 Oct 2021 14:53:50 +0000 (16:53 +0200)
Enable LVDS display detection and panel-specific configuration

Make I2C based LVDS detection and configuration model specific:
- not all boards support LVDS connectors; fail detection that do not
  support LVDS to avoid misdetecting an I2C device as a display
- GPIO configuration is panel specific; use panel name where needed

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
board/gateworks/gw_ventana/gw_ventana.c

index 1646806..1c82bd5 100644 (file)
@@ -158,25 +158,54 @@ static void enable_hdmi(struct display_info_t const *dev)
        imx_enable_hdmi_phy();
 }
 
-static int detect_i2c(struct display_info_t const *dev)
+static int detect_lvds(struct display_info_t const *dev)
 {
+       /* only the following boards support LVDS connectors */
+       switch (board_type) {
+       case GW52xx:
+       case GW53xx:
+       case GW54xx:
+       case GW560x:
+       case GW5905:
+       case GW5909:
+               break;
+       default:
+               return 0;
+       }
+
        return i2c_set_bus_num(dev->bus) == 0 &&
                i2c_probe(dev->addr) == 0;
 }
 
 static void enable_lvds(struct display_info_t const *dev)
 {
-       struct iomuxc *iomux = (struct iomuxc *)
-                               IOMUXC_BASE_ADDR;
+       struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
 
        /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */
        u32 reg = readl(&iomux->gpr[2]);
        reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT;
        writel(reg, &iomux->gpr[2]);
 
-       /* Enable Backlight */
-       gpio_request(IMX_GPIO_NR(1, 10), "bklt_gpio");
-       gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
+       /* Configure GPIO */
+       switch (board_type) {
+       case GW52xx:
+       case GW53xx:
+       case GW54xx:
+               if (!strncmp(dev->mode.name, "Hannstar", 8)) {
+                       SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
+                       gpio_request(IMX_GPIO_NR(1, 10), "cabc");
+                       gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
+               } else if (!strncmp(dev->mode.name, "DLC", 3)) {
+                       SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
+                       gpio_request(IMX_GPIO_NR(1, 10), "touch_rst#");
+                       gpio_direction_output(IMX_GPIO_NR(1, 10), 1);
+               }
+               break;
+       default:
+               break;
+       }
+
+       /* Configure backlight */
        gpio_request(IMX_GPIO_NR(1, 18), "bklt_en");
        SETUP_IOMUX_PAD(PAD_SD1_CMD__GPIO1_IO18 | DIO_PAD_CFG);
        gpio_direction_output(IMX_GPIO_NR(1, 18), 1);
@@ -208,7 +237,7 @@ struct display_info_t const displays[] = {{
        .bus    = 2,
        .addr   = 0x4,
        .pixfmt = IPU_PIX_FMT_LVDS666,
-       .detect = detect_i2c,
+       .detect = detect_lvds,
        .enable = enable_lvds,
        .mode   = {
                .name           = "Hannstar-XGA",
@@ -228,7 +257,7 @@ struct display_info_t const displays[] = {{
        /* DLC700JMG-T-4 */
        .bus    = 2,
        .addr   = 0x38,
-       .detect = NULL,
+       .detect = detect_lvds,
        .enable = enable_lvds,
        .pixfmt = IPU_PIX_FMT_LVDS666,
        .mode   = {
@@ -247,9 +276,9 @@ struct display_info_t const displays[] = {{
                .vmode          = FB_VMODE_NONINTERLACED
 } }, {
        /* DLC0700XDP21LF-C-1 */
-       .bus    = 0,
-       .addr   = 0,
-       .detect = NULL,
+       .bus    = 2,
+       .addr   = 0x38,
+       .detect = detect_lvds,
        .enable = enable_lvds,
        .pixfmt = IPU_PIX_FMT_LVDS666,
        .mode   = {
@@ -270,7 +299,7 @@ struct display_info_t const displays[] = {{
        /* DLC800FIG-T-3 */
        .bus    = 2,
        .addr   = 0x14,
-       .detect = NULL,
+       .detect = detect_lvds,
        .enable = enable_lvds,
        .pixfmt = IPU_PIX_FMT_LVDS666,
        .mode   = {
@@ -290,7 +319,7 @@ struct display_info_t const displays[] = {{
 } }, {
        .bus    = 2,
        .addr   = 0x5d,
-       .detect = detect_i2c,
+       .detect = detect_lvds,
        .enable = enable_lvds,
        .pixfmt = IPU_PIX_FMT_LVDS666,
        .mode   = {
@@ -358,10 +387,6 @@ static void setup_display(void)
            | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
               <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
        writel(reg, &iomux->gpr[3]);
-
-       /* LVDS Backlight GPIO on LVDS connector - output low */
-       SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
-       gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
 }
 #endif /* CONFIG_VIDEO_IPUV3 */