dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Rob Clark <robdclark-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	aarch64-laptops-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	Julien Thierry <julien.thierry-5wv7dgnIgG8@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Ard Biesheuvel
	<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Will Deacon <will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Steve Capper <steve.capper-5wv7dgnIgG8@public.gmane.org>,
	Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>,
	Leif Lindholm
	<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH 2/4] efi/libstub: detect panel-id
Date: Sun, 30 Jun 2019 13:36:06 -0700	[thread overview]
Message-ID: <20190630203614.5290-3-robdclark@gmail.com> (raw)
In-Reply-To: <20190630203614.5290-1-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Rob Clark <robdclark@chromium.org>

On snapdragon aarch64 laptops, a 'UEFIDisplayInfo' variable is provided
to communicate some information about the display.  Crutially it has the
panel-id, so the appropriate panel driver can be selected.  Read this
out and stash in /chosen/panel-id so that display driver can use it to
pick the appropriate panel.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 drivers/firmware/efi/libstub/arm-stub.c | 49 +++++++++++++++++++++++++
 drivers/firmware/efi/libstub/efistub.h  |  2 +
 drivers/firmware/efi/libstub/fdt.c      |  9 +++++
 3 files changed, 60 insertions(+)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 04e6ecd72cd9..999813252e0d 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -69,6 +69,53 @@ static struct screen_info *setup_graphics(efi_system_table_t *sys_table_arg)
 	return si;
 }
 
+/*
+ * We (at least currently) don't care about most of the fields, just
+ * panel_id:
+ */
+struct mdp_disp_info {
+	u32 version_info;
+	u32 pad0[9];
+	u32 panel_id;
+	u32 pad1[17];
+};
+
+#define MDP_DISP_INFO_VERSION_MAGIC 0xaa
+
+static void get_panel_id(efi_system_table_t *sys_table_arg,
+			 unsigned long fdt_addr)
+{
+	efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
+	efi_status_t status;
+	struct mdp_disp_info *disp_info;
+	unsigned long size = 0;
+
+	status = efi_call_runtime(get_variable, L"UEFIDisplayInfo",
+				  &gop_proto, NULL, &size, NULL);
+	if (status == EFI_NOT_FOUND)
+		return;
+
+	status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size,
+				(void **)&disp_info);
+	if (status != EFI_SUCCESS)
+		return;
+
+	status = efi_call_runtime(get_variable, L"UEFIDisplayInfo",
+				  &gop_proto, NULL, &size, disp_info);
+	if (status != EFI_SUCCESS)
+		goto cleanup;
+
+	if ((disp_info->version_info >> 16) != MDP_DISP_INFO_VERSION_MAGIC)
+		goto cleanup;
+
+	efi_printk(sys_table_arg, "found a panel-id!\n");
+
+	set_chosen_panel_id(fdt_addr, disp_info->panel_id);
+
+cleanup:
+	efi_call_early(free_pool, disp_info);
+}
+
 void install_memreserve_table(efi_system_table_t *sys_table_arg)
 {
 	struct linux_efi_memreserve *rsv;
@@ -229,6 +276,8 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table,
 	if (!fdt_addr)
 		pr_efi(sys_table, "Generating empty DTB\n");
 
+	get_panel_id(sys_table, fdt_addr);
+
 	status = handle_cmdline_files(sys_table, image, cmdline_ptr, "initrd=",
 				      efi_get_max_initrd_addr(dram_base,
 							      *image_addr),
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 1b1dfcaa6fb9..8832cb9a7a40 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -39,6 +39,8 @@ void efi_char16_printk(efi_system_table_t *, efi_char16_t *);
 
 unsigned long get_dram_base(efi_system_table_t *sys_table_arg);
 
+void set_chosen_panel_id(unsigned long fdt_addr, unsigned panel_id);
+
 efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
 					    void *handle,
 					    unsigned long *new_fdt_addr,
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 5440ba17a1c5..cb6ea160a40a 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -200,6 +200,15 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
 	return EFI_SUCCESS;
 }
 
+void set_chosen_panel_id(unsigned long fdt_addr, unsigned panel_id)
+{
+	void *fdt = (void *)fdt_addr;
+	int node = fdt_subnode_offset(fdt, 0, "chosen");
+	u32 fdt_val32 = cpu_to_fdt32(panel_id);
+
+	fdt_setprop_var(fdt, node, "panel-id", fdt_val32);
+}
+
 #ifndef EFI_FDT_ALIGN
 # define EFI_FDT_ALIGN EFI_PAGE_SIZE
 #endif
-- 
2.20.1

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2019-06-30 20:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30 20:36 [PATCH 0/4] drm+dt+efi: support devices with multiple possible panels Rob Clark
2019-06-30 20:36 ` [PATCH 3/4] drm: add helper to lookup panel-id Rob Clark
     [not found] ` <20190630203614.5290-1-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-30 20:36   ` [PATCH 1/4] dt-bindings: chosen: document panel-id binding Rob Clark
2019-07-01 14:03     ` Rob Herring
     [not found]       ` <CAL_JsqKMULJJ9CERRBpqd7Y2dtovEJ6jcDKy6J4yR6rAdjibUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-01 14:28         ` Jeffrey Hugo
2019-07-01 14:41       ` Rob Clark
2019-11-30 18:37       ` Rob Clark
     [not found]         ` <CAF6AEGsAgUsKJjLQkRDdjZtSvX267Cz_m_P7_m6VeJ2u=Ozc1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-30 18:39           ` Rob Clark
2019-11-30 18:39             ` Rob Clark
2019-06-30 20:36   ` Rob Clark [this message]
     [not found]     ` <20190630203614.5290-3-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-07-02 20:26       ` [PATCH 2/4] efi/libstub: detect panel-id Ard Biesheuvel
     [not found]         ` <CAKv+Gu_8BOt+f8RTspHo+se-=igZba1zL0+jWLV2HuuUXCKYpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-02 20:35           ` Ard Biesheuvel
     [not found]             ` <CAKv+Gu-KhPJxxJA3+J813OPcnoAD4nHq6MhiRTJSd_5y1dPNnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-02 21:01               ` Rob Clark
     [not found]                 ` <CAF6AEGv+uAXVV6Q78n=jP0YRDjYn9OS=Xec9MU0+_7EBirxF5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-02 21:53                   ` Ard Biesheuvel
     [not found]                     ` <CAKv+Gu9pH9=AnNee7B-z0sP3rGJ-0Qnpziyx445M30KWC=Vq+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-02 22:36                       ` Rob Clark
2019-07-02 21:59                   ` Leif Lindholm
     [not found]                     ` <20190702215953.wdqges66hx3ge4jr-t77nlHhSwNqAroYi2ySoxKxOck334EZe@public.gmane.org>
2019-07-02 22:48                       ` Rob Clark
2019-07-03 16:33                         ` Leif Lindholm
2019-07-03 17:41                           ` Rob Clark
2019-07-03 17:54                             ` Ard Biesheuvel
2019-06-30 20:36   ` [PATCH 4/4] drm/bridge: ti-sn65dsi86: use helper to lookup panel-id Rob Clark
     [not found]     ` <20190630203614.5290-5-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-30 21:17       ` Laurent Pinchart
2019-06-30 21:50         ` Rob Clark
2019-06-30 21:57           ` Laurent Pinchart
     [not found]             ` <20190630215742.GK7043-N3hz7ZxfLydczECFQUw77jytWr6r+dGw0E9HWUfgJXw@public.gmane.org>
2019-06-30 22:04               ` Rob Clark
2019-06-30 20:47   ` [PATCH 0/4] drm+dt+efi: support devices with multiple possible panels Laurent Pinchart
2019-06-30 21:05     ` Rob Clark
2019-06-30 21:15       ` Laurent Pinchart
     [not found]         ` <20190630211520.GI7043-N3hz7ZxfLydczECFQUw77jytWr6r+dGw0E9HWUfgJXw@public.gmane.org>
2019-06-30 21:35           ` Rob Clark
2019-07-02 12:50   ` Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190630203614.5290-3-robdclark@gmail.com \
    --to=robdclark-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=aarch64-laptops-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
    --cc=agraf-l3A5Bk7waGM@public.gmane.org \
    --cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=julien.thierry-5wv7dgnIgG8@public.gmane.org \
    --cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org \
    --cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robdclark-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=steve.capper-5wv7dgnIgG8@public.gmane.org \
    --cc=will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox