ARM: tegra11: 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

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Change-Id: I4202b5832c77e265dae2c3bcb7d92c509cffd606
Reviewed-on: http://git-master/r/208311
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-dalmore-panel.c
arch/arm/mach-tegra/board-macallan-panel.c
arch/arm/mach-tegra/board-panel.c [new file with mode: 0644]
arch/arm/mach-tegra/board-panel.h
arch/arm/mach-tegra/board-pluto-panel.c
arch/arm/mach-tegra/board-roth-panel.c
arch/arm/mach-tegra/board-tegratab-panel.c

index 9703dc3..5ed6263 100644 (file)
@@ -109,7 +109,7 @@ obj-$(CONFIG_ARCH_TEGRA_11x_SOC)        += tegra3_actmon.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += tegra2_emc.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += tegra3_emc.o
 obj-$(CONFIG_ARCH_TEGRA_11x_SOC)        += tegra11_emc.o
-obj-y                                  += tegra_emc.o
+obj-y                                   += tegra_emc.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += pinmux-tegra20-tables.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += pinmux-tegra30-tables.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += board-dt-tegra30.o
@@ -158,6 +158,7 @@ obj-$(CONFIG_TEGRA_DYNAMIC_PWRDET)      += powerdetect.o
 obj-$(CONFIG_ARCH_TEGRA_HAS_CL_DVFS)    += tegra_cl_dvfs.o
 
 obj-y                                   += board-common.o
+obj-y                                   += board-panel.o
 obj-$(CONFIG_TEGRA_WAKEUP_MONITOR)      += tegra_wakeup_monitor.o
 obj-$(CONFIG_TEGRA_PCI)                 += pcie.o
 
@@ -284,7 +285,7 @@ obj-${CONFIG_MACH_DALMORE}              += board-dalmore-sdhci.o
 obj-${CONFIG_MACH_DALMORE}              += board-dalmore-panel.o
 obj-${CONFIG_MACH_DALMORE}              += board-roth-panel.o
 obj-${CONFIG_MACH_DALMORE}              += board-dalmore-kbc.o
-obj-${CONFIG_MACH_DALMORE}             += board-dalmore-sensors.o
+obj-${CONFIG_MACH_DALMORE}              += board-dalmore-sensors.o
 obj-${CONFIG_MACH_DALMORE}              += panel-a-1080p-11-6.o
 obj-${CONFIG_MACH_DALMORE}              += panel-p-wuxga-10-1.o
 obj-${CONFIG_MACH_DALMORE}              += panel-s-wqxga-10-1.o
index 1542699..4f16bcf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-dalmore-panel.c
  *
- * Copyright (c) 2011-2013, NVIDIA Corporation.
+ * Copyright (c) 2011-2013, NVIDIA Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -482,22 +482,6 @@ int __init dalmore_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       /*
-        * If the bootloader fb2 is valid, copy it to the fb2, or else
-        * clear fb2 to avoid garbage on dispaly2.
-        */
-       if (tegra_bootloader_fb2_size)
-               tegra_move_framebuffer(tegra_fb2_start,
-                       tegra_bootloader_fb2_start,
-                       min(tegra_fb2_size, tegra_bootloader_fb2_size));
-       else
-               tegra_clear_framebuffer(tegra_fb2_start, tegra_fb2_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) {
@@ -505,12 +489,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 1aa046c..3fed204 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-macallan-panel.c
  *
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2011-2013, NVIDIA Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -470,11 +470,6 @@ int __init macallan_panel_init(void)
        else
                tegra_clear_framebuffer(tegra_fb2_start, tegra_fb2_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) {
@@ -482,12 +477,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;
diff --git a/arch/arm/mach-tegra/board-panel.c b/arch/arm/mach-tegra/board-panel.c
new file mode 100644 (file)
index 0000000..66f580a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * arch/arm/mach-tegra/board-panel.c
+ *
+ * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/of.h>
+
+#include "board.h"
+
+#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) {
+               /*
+                * If the bootloader fb2 is valid, copy it to the fb2, or else
+                * clear fb2 to avoid garbage on dispaly2.
+                */
+               if (tegra_bootloader_fb2_size)
+                       tegra_move_framebuffer(tegra_fb2_start,
+                               tegra_bootloader_fb2_start,
+                               min(tegra_fb2_size, tegra_bootloader_fb2_size));
+               else
+                       tegra_clear_framebuffer(tegra_fb2_start,
+                                               tegra_fb2_size);
+
+               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 9e253ea..3069b74 100644 (file)
@@ -51,3 +51,5 @@ extern struct tegra_panel dsi_a_1080p_11_6;
 extern struct tegra_panel dsi_s_wqxga_10_1;
 extern struct tegra_panel dsi_lgd_wxga_7_0;
 
+int tegra_init_hdmi(struct platform_device *pdev,
+                    struct platform_device *phost1x);
index 9016501..44133a5 100644 (file)
@@ -454,22 +454,6 @@ int __init pluto_panel_init(void)
                tegra_fb_start, tegra_bootloader_fb_start,
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
-       /*
-        * If the bootloader fb2 is valid, copy it to the fb2, or else
-        * clear fb2 to avoid garbage on dispaly2.
-        */
-       if (tegra_bootloader_fb2_size)
-               tegra_move_framebuffer(tegra_fb2_start,
-                       tegra_bootloader_fb2_start,
-                       min(tegra_fb2_size, tegra_bootloader_fb2_size));
-       else
-               tegra_clear_framebuffer(tegra_fb2_start, tegra_fb2_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) {
@@ -477,12 +461,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 bc5881b..e2334bf 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/mach-types.h>
 
 #include "board.h"
+#include "board-panel.h"
 #include "devices.h"
 #include "gpio-names.h"
 #include "tegra11_host1x_devices.h"
@@ -66,8 +67,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;
 
@@ -763,22 +762,6 @@ int __init roth_panel_init(int board_id)
                        min(tegra_fb_size, tegra_bootloader_fb_size));
 
        /*
-        * If the bootloader fb2 is valid, copy it to the fb2, or else
-        * clear fb2 to avoid garbage on dispaly2.
-        */
-       if (tegra_bootloader_fb2_size)
-               tegra_move_framebuffer(tegra_fb2_start,
-                       tegra_bootloader_fb2_start,
-                       min(tegra_fb2_size, tegra_bootloader_fb2_size));
-       else
-               tegra_clear_framebuffer(tegra_fb2_start, tegra_fb2_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.
         */
        if (!board_id)
@@ -791,12 +774,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,
index 865280a..307457b 100644 (file)
@@ -482,11 +482,6 @@ int __init tegratab_panel_init(void)
        else
                tegra_clear_framebuffer(tegra_fb2_start, tegra_fb2_size);
 
-       res = platform_get_resource_byname(&tegratab_disp2_device,
-               IORESOURCE_MEM, "fbmem");
-       res->start = tegra_fb2_start;
-       res->end = tegra_fb2_start + tegra_fb2_size - 1;
-
        tegratab_disp1_device.dev.parent = &phost1x->dev;
        err = platform_device_register(&tegratab_disp1_device);
        if (err) {
@@ -494,12 +489,9 @@ int __init tegratab_panel_init(void)
                return err;
        }
 
-       tegratab_disp2_device.dev.parent = &phost1x->dev;
-       err = platform_device_register(&tegratab_disp2_device);
-       if (err) {
-               pr_err("disp2 device registration failed\n");
+       err = tegra_init_hdmi(&tegratab_disp2_device, phost1x);
+       if (err)
                return err;
-       }
 
 #ifdef CONFIG_TEGRA_NVAVP
        nvavp_device.dev.parent = &phost1x->dev;