From patchwork Tue Feb 23 20:46:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 1443637 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DlWPz4Yrgz9sVw for ; Wed, 24 Feb 2021 07:49:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4BA7C82ACD; Tue, 23 Feb 2021 21:48:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=siol.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 1AFBD82AA0; Tue, 23 Feb 2021 21:47:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.siol.net (mailoutvs12.siol.net [185.57.226.203]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DBEDF82AA2 for ; Tue, 23 Feb 2021 21:47:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siol.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jernej.skrabec@siol.net Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id 6E474524558; Tue, 23 Feb 2021 21:47:20 +0100 (CET) Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gjbQxQZNgTqS; Tue, 23 Feb 2021 21:47:20 +0100 (CET) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 2410B5244B9; Tue, 23 Feb 2021 21:47:20 +0100 (CET) Received: from kista.localdomain (cpe-86-58-17-133.cable.triera.net [86.58.17.133]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id E7E1B52455A; Tue, 23 Feb 2021 21:47:17 +0100 (CET) From: Jernej Skrabec To: jagan@amarulasolutions.com, andre.przywara@arm.com, agust@denx.de Cc: u-boot@lists.denx.de, linux-sunxi@googlegroups.com Subject: [PATCH 15/19] video: sunxi: de2: switch to DT probing Date: Tue, 23 Feb 2021 21:46:27 +0100 Message-Id: <20210223204631.1609597-16-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210223204631.1609597-1-jernej.skrabec@siol.net> References: <20210223204631.1609597-1-jernej.skrabec@siol.net> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Currently DE2 driver is probed via driver info. Switch probing to device tree compatible string method. Display is now searched via driver name which has same limitation as previous method. This can be improved only when all drivers in chain are probed via device tree compatible strings. Signed-off-by: Jernej Skrabec --- drivers/video/sunxi/sunxi_de2.c | 88 +++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c index e02d359cd259..81576e45e9ef 100644 --- a/drivers/video/sunxi/sunxi_de2.c +++ b/drivers/video/sunxi/sunxi_de2.c @@ -31,6 +31,11 @@ enum { LCD_MAX_LOG2_BPP = VIDEO_BPP32, }; +struct sunxi_de2_data { + int id; + const char *disp_drv_name; +}; + static void sunxi_de2_composer_init(void) { struct sunxi_ccm_reg * const ccm = @@ -228,51 +233,34 @@ static int sunxi_de2_init(struct udevice *dev, ulong fbbase, static int sunxi_de2_probe(struct udevice *dev) { + const struct sunxi_de2_data *data = + (const struct sunxi_de2_data *)dev_get_driver_data(dev); struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct udevice *disp; - int ret; + int ret, index = 0; /* Before relocation we don't need to do anything */ if (!(gd->flags & GD_FLG_RELOC)) return 0; - ret = uclass_get_device_by_driver(UCLASS_DISPLAY, - DM_DRIVER_GET(sunxi_lcd), &disp); - if (!ret) { - int mux; + while (!(ret = uclass_get_device(UCLASS_DISPLAY, index++, &disp))) { + if (strcmp(disp->driver->name, data->disp_drv_name)) + continue; - mux = 0; + ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, + data->id, false); + if (ret) + return ret; - ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, mux, - false); - if (!ret) { - video_set_flush_dcache(dev, 1); - return 0; - } - } - - debug("%s: lcd display not found (ret=%d)\n", __func__, ret); - - ret = uclass_get_device_by_driver(UCLASS_DISPLAY, - DM_DRIVER_GET(sunxi_dw_hdmi), &disp); - if (!ret) { - int mux; - if (IS_ENABLED(CONFIG_MACH_SUNXI_H3_H5)) - mux = 0; - else - mux = 1; + video_set_flush_dcache(dev, 1); - ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, mux, - false); - if (!ret) { - video_set_flush_dcache(dev, 1); - return 0; - } + return 0; } - debug("%s: hdmi display not found (ret=%d)\n", __func__, ret); + debug("%s: %s not found (ret=%d)\n", __func__, + data->disp_drv_name, ret); - return -ENODEV; + return ret; } static int sunxi_de2_bind(struct udevice *dev) @@ -285,22 +273,50 @@ static int sunxi_de2_bind(struct udevice *dev) return 0; } +const struct sunxi_de2_data h3_mixer_0 = { + .id = 0, + .disp_drv_name = "sunxi_dw_hdmi", +}; + +const struct sunxi_de2_data a64_mixer_0 = { + .id = 0, + .disp_drv_name = "sunxi_lcd", +}; + +const struct sunxi_de2_data a64_mixer_1 = { + .id = 1, + .disp_drv_name = "sunxi_dw_hdmi", +}; + +static const struct udevice_id sunxi_de2_ids[] = { + { + .compatible = "allwinner,sun8i-h3-de2-mixer-0", + .data = (ulong)&h3_mixer_0, + }, + { + .compatible = "allwinner,sun50i-a64-de2-mixer-0", + .data = (ulong)&a64_mixer_0, + }, + { + .compatible = "allwinner,sun50i-a64-de2-mixer-1", + .data = (ulong)&a64_mixer_1, + }, + { } +}; + static const struct video_ops sunxi_de2_ops = { }; U_BOOT_DRIVER(sunxi_de2) = { .name = "sunxi_de2", .id = UCLASS_VIDEO, + .of_match = sunxi_de2_ids, .ops = &sunxi_de2_ops, .bind = sunxi_de2_bind, .probe = sunxi_de2_probe, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRVINFO(sunxi_de2) = { - .name = "sunxi_de2" -}; - /* * Simplefb support. */