ARM: tegra: allow disabling HDMI through DT
Alexandre Courbot [Tue, 12 Mar 2013 06:42:40 +0000 (15:42 +0900)]
HDMI output can be disabled by setting the "host1x/hdmi" node's status
to disabled. Also factorizes the common HDMI initialization code to one
place.

Bug 1239870
Bug 1332618

Change-Id: I34f8d3cfdcc205b640b4294e8cfc38449484d6ba
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-on: http://git-master/r/208311
Reviewed-on: http://git-master/r/263200
(cherry picked from commit c0b71f030335bf33c0aaa227c139f4ce056950bb)
(cherry picked from commit fcaff7edf54611d085b2f21f9674fd1e58bc4f46)
Reviewed-on: http://git-master/r/263764
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jong Kim <jongk@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Allen Martin <amartin@nvidia.com>
Tested-by: Jong Kim <jongk@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

arch/arm/mach-tegra/board-ardbeg-panel.c
arch/arm/mach-tegra/board-dalmore-panel.c
arch/arm/mach-tegra/board-macallan-panel.c
arch/arm/mach-tegra/board-panel.c
arch/arm/mach-tegra/board-panel.h
arch/arm/mach-tegra/board-pismo-panel.c
arch/arm/mach-tegra/board-pluto-panel.c
arch/arm/mach-tegra/board-roth-panel.c

index 0a578c4..4b1452c 100644 (file)
@@ -578,12 +578,6 @@ int __init ardbeg_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       res = platform_get_resource_byname(&ardbeg_disp2_device,
-                                        IORESOURCE_MEM, "fbmem");
-
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        ardbeg_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&ardbeg_disp1_device);
        if (err) {
@@ -591,12 +585,9 @@ int __init ardbeg_panel_init(void)
                return err;
        }
 
-       ardbeg_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&ardbeg_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&ardbeg_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;
index 377627c..cf980d7 100644 (file)
@@ -543,12 +543,6 @@ int __init dalmore_panel_init(void)
                __tegra_clear_framebuffer(&dalmore_nvmap_device,
                                          tegra_fb_start, tegra_fb_size);
 
-       res = platform_get_resource_byname(&dalmore_disp2_device,
-                                        IORESOURCE_MEM, "fbmem");
-
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        dalmore_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&dalmore_disp1_device);
        if (err) {
@@ -556,12 +550,9 @@ int __init dalmore_panel_init(void)
                return err;
        }
 
-       dalmore_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&dalmore_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&dalmore_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;
index 9a85620..702178e 100644 (file)
@@ -472,11 +472,6 @@ int __init macallan_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       res = platform_get_resource_byname(&macallan_disp2_device,
-               IORESOURCE_MEM, "fbmem");
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        macallan_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&macallan_disp1_device);
        if (err) {
@@ -484,12 +479,9 @@ int __init macallan_panel_init(void)
                return err;
        }
 
-       macallan_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&macallan_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&macallan_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;
index 64c9cb3..0997116 100644 (file)
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
 #include <linux/export.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
 
 #include <mach/dc.h>
 
 #include "board-panel.h"
+#include "board.h"
 #include "iomap.h"
 
 atomic_t sd_brightness = ATOMIC_INIT(255);
@@ -159,3 +162,45 @@ fail:
        of_node_put(node);
        return err;
 }
+
+#ifdef CONFIG_TEGRA_DC
+/**
+ * tegra_init_hdmi - initialize and add HDMI device if not disabled by DT
+ */
+int tegra_init_hdmi(struct platform_device *pdev,
+                    struct platform_device *phost1x)
+{
+       struct resource __maybe_unused *res;
+       bool enabled = true;
+       int err;
+#ifdef CONFIG_OF
+       struct device_node *hdmi_node = NULL;
+
+       hdmi_node = of_find_node_by_path("/host1x/hdmi");
+       /* disable HDMI if explicitly set that way in the device tree */
+       enabled = !hdmi_node || of_device_is_available(hdmi_node);
+#endif
+
+       if (enabled) {
+               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+                                                  "fbmem");
+               res->start = tegra_fb2_start;
+               res->end = tegra_fb2_start + tegra_fb2_size - 1;
+
+               pdev->dev.parent = &phost1x->dev;
+               err = platform_device_register(pdev);
+               if (err) {
+                       dev_err(&pdev->dev, "device registration failed\n");
+                       return err;
+               }
+       }
+
+       return 0;
+}
+#else
+int tegra_init_hdmi(struct platform_device *pdev,
+                    struct platform_device *phost1x)
+{
+       return 0;
+}
+#endif
index d217fd4..4bf9338 100644 (file)
@@ -68,4 +68,7 @@ int tegra_panel_gpio_get_dt(const char *comp_str,
                                struct tegra_panel_of *panel);
 
 int tegra_panel_reset(struct tegra_panel_of *panel, unsigned int delay_ms);
+
+int tegra_init_hdmi(struct platform_device *pdev,
+                    struct platform_device *phost1x);
 #endif /* __MACH_TEGRA_BOARD_PANEL_H */
index d22e12d..5db0b14 100644 (file)
@@ -457,12 +457,6 @@ int __init pismo_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       res = platform_get_resource_byname(&pismo_disp2_device,
-                                        IORESOURCE_MEM, "fbmem");
-
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        pismo_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&pismo_disp1_device);
        if (err) {
@@ -470,12 +464,9 @@ int __init pismo_panel_init(void)
                return err;
        }
 
-       pismo_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&pismo_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&pismo_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;
index f202d47..83fa4e5 100644 (file)
@@ -471,12 +471,6 @@ int __init pluto_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       res = platform_get_resource_byname(&pluto_disp2_device,
-                                        IORESOURCE_MEM, "fbmem");
-
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        pluto_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&pluto_disp1_device);
        if (err) {
@@ -484,12 +478,9 @@ int __init pluto_panel_init(void)
                return err;
        }
 
-       pluto_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&pluto_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&pluto_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;
index db3c12c..3c702c2 100644 (file)
@@ -36,6 +36,7 @@
 #include <asm/mach-types.h>
 
 #include "board.h"
+#include "board-panel.h"
 #include "devices.h"
 #include "gpio-names.h"
 #include "iomap.h"
@@ -69,8 +70,6 @@ struct platform_device * __init roth_host1x_init(void)
 /* HDMI Hotplug detection pin */
 #define roth_hdmi_hpd  TEGRA_GPIO_PN7
 
-static atomic_t sd_brightness = ATOMIC_INIT(255);
-
 static bool reg_requested;
 static bool gpio_requested;
 
@@ -987,11 +986,6 @@ int __init roth_panel_init(int board_id)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       res = platform_get_resource_byname(&roth_disp2_device,
-                                        IORESOURCE_MEM, "fbmem");
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        /*
         * only roth supports initialized mode.
         */
@@ -1005,12 +999,9 @@ int __init roth_panel_init(int board_id)
                return err;
        }
 
-       roth_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&roth_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&roth_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #if IS_EXTERNAL_PWM
        err = platform_add_devices(roth_bl_device,