[U-Boot] [RFC v2 10/15] efi_loader: gop: convert efi_gop_obj to DM

AKASHI Takahiro takahiro.akashi at linaro.org
Fri Feb 8 08:15:37 UTC 2019


Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 drivers/video/video-uclass.c |  9 +++++++++
 lib/efi_loader/efi_gop.c     | 28 ++++++++++++++++++++++------
 lib/efi_loader/efi_setup.c   |  3 ++-
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index f307cf243bdc..2abb647d4428 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -276,6 +276,15 @@ static int video_post_probe(struct udevice *dev)
 		return ret;
 	}
 
+#ifdef CONFIG_EFI_LOADER
+	extern efi_gop_register(void);
+	ret = efi_gop_register()
+	if (ret) {
+		debug("%s: Cannot register efi gop\n", __func__);
+		return ret;
+	}
+#endif
+
 	return 0;
 };
 
diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index d62ce4591272..b2ab583a44c3 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -14,20 +14,19 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static const efi_guid_t efi_gop_guid = EFI_GOP_GUID;
+const efi_guid_t efi_gop_guid = EFI_GOP_GUID;
 
+/* FIXME: move this to somewhere else, like struct video_priv? */
 /**
  * struct efi_gop_obj - graphical output protocol object
  *
- * @header:	EFI object header
  * @ops:	graphical output protocol interface
  * @info:	graphical output mode information
  * @mode:	graphical output mode
  * @bpix:	bits per pixel
  * @fb:		frame buffer
  */
-struct efi_gop_obj {
-	struct efi_object header;
+static struct efi_gop_obj {
 	struct efi_gop ops;
 	struct efi_gop_mode_info info;
 	struct efi_gop_mode mode;
@@ -446,10 +445,14 @@ efi_status_t efi_gop_register(void)
 	}
 
 	/* Hook up to the device list */
-	efi_add_handle(&gopobj->header);
+	ret = efi_add_handle(vdev);
+	if (ret != EFI_SUCCESS) {
+		printf("ERROR: Failure adding GOP handle\n");
+		return ret;
+	}
 
 	/* Fill in object data */
-	ret = efi_add_protocol(&gopobj->header, &efi_gop_guid,
+	ret = efi_add_protocol(vdev, &efi_gop_guid,
 			       &gopobj->ops);
 	if (ret != EFI_SUCCESS) {
 		printf("ERROR: Failure adding GOP protocol\n");
@@ -489,3 +492,16 @@ efi_status_t efi_gop_register(void)
 
 	return EFI_SUCCESS;
 }
+
+static int efi_gop_probe(struct udevice *dev)
+{
+	device_set_name(dev, "GOP");
+
+	return 0;
+}
+
+U_BOOT_DRIVER(efi_gop) = {
+	.name = "efi_gop",
+	.id = UCLASS_EFI_PROTOCOL,
+	.probe = efi_gop_probe,
+};
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index ea65dec6c066..59f3a617aca3 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -55,7 +55,8 @@ static efi_status_t efi_system_init(void)
 	if (ret != EFI_SUCCESS)
 		goto out;
 #endif
-#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
+#if defined(CONFIG_LCD)
+	/* for !DM_VIDEO */
 	ret = efi_gop_register();
 	if (ret != EFI_SUCCESS)
 		goto out;
-- 
2.19.1



More information about the U-Boot mailing list