From patchwork Tue Feb 2 05:45:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 374597 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1924712jah; Mon, 1 Feb 2021 21:46:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYlDR+eYtAYd2wgiF67tSJ4EWpqAdiXqbPrGDEVvwrjFmVfr6Jk8VGesG2HfTmKq2szr9Z X-Received: by 2002:a62:8f96:0:b029:1b7:75a9:a8b7 with SMTP id n144-20020a628f960000b02901b775a9a8b7mr20182695pfd.28.1612244776478; Mon, 01 Feb 2021 21:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612244776; cv=none; d=google.com; s=arc-20160816; b=jMYcf44Pzrp4tdYammWdT5oZoC+Qyo97lw85mDn/6IQQINv+kfUkQKNmthE+j8m4op gEU+PXJLEAgJD2AWAOcCB4J1ki5JYC+uj6bvW/BMvJkfXeMvn0MvI0iK9a0kSiULYYMF uMAD83+tbM+CkVjXnCkfeeka8rZCK7G6zg6Xqd36B/klP5L3L9zuTsA8bIccyQiy5CTI HgoYbEum2RY0YbI4GTT6CMt+nQyN2TYgYyyj8Dz61cjaXNb1sYC1IQ87wgXqtUzote5P Tvm5k+6WOL4qzwbZDzRt7VejX3xAQ5EBAsaxJfzXh0+u11XuhNOflEhF6/cq429rxVkX oxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=6NGDXevYRfKHYvmsrZIwX7aDvxzI/xtUbOvXKwJmd1s=; b=o+tTANcc5Sf47d9hQmJVG8Ory/KuQ3m3XWXC1ziL6LKGa5RvuQvef3WsXm0PM3SBIT pXha9xoMXCJIVcYtdCbzSBu6xtJWxiZWlGpkajwj4FQnXTT4hDCFLziXx5XG6c3p8q8N +Li4bXMn5Yww4bBrjhLOYiroSKSiEjClK50G71PUWosGc+CePm21m8X1l0pgYSsxkf6l oAew6CaDPf9LB8MQaj2TYqfhd3fJo6e50IWS8PTT+oIWj9QbZRWSI8Pt9zeDYmx2MMhm M4pWHy16qyTEIibyE5hNNghlnANt56zTWM0qS00/84sLDhjqf34W/dMamt93uw+7C5w/ KVyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=HpuuWare; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id j18si21437087pfe.133.2021.02.01.21.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 21:46:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=HpuuWare; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E12D86E8BF; Tue, 2 Feb 2021 05:46:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D13916E8C7 for ; Tue, 2 Feb 2021 05:46:13 +0000 (UTC) Received: by mail-pl1-x62c.google.com with SMTP id u15so11852897plf.1 for ; Mon, 01 Feb 2021 21:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HEWcLvUvYkWYLO51rzp4RR+x1aKBWP/abPyEZI4rYFM=; b=HpuuWareLWeEAeZr0X/SrjJLr0wnhOLwG79M8rRveb8GLZtjklgyYM5/AViq8HXOPV r93GdrYThzkoxsupajVRFYMXjF7miGvNdwJk0cbw0V6KJOl9cdm/IKavMiYT/2L1TKhE kKQO8V7Orn3mDF43Uv0qmSRcxfrSGGdzeRZf/d8U2aGxP6m8QgqHACDIQ0QtyYr92S/x pm2VyY1D+E4Rc+UPJX9HsvIvG1/bDLPxA2Wm2fiRO93ix6mS6Gm8evIniBFlWVk1CHUD Wsog2C71CyWnq6cr2IpeJ5JJ319LpKm/6EqO8ZeFM4lVXp1p3qpTFOOK4361R3LB3Ywj /vDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HEWcLvUvYkWYLO51rzp4RR+x1aKBWP/abPyEZI4rYFM=; b=CWYIkBXxdILo5Hmls7EPxOgYKJJqt0XhSfpcAeAmfsexrS57kxunLBYd60pZgdjR3C PgBEdJ82mF/9MamtDpxKg1+SSHLRTGtiipbf0kRciZLEeyYo9LP2t5/TFuFGeV6DQZCu wUvUMFK4f/fnRy5Q4dEX8OUKd3LQMiyPjOLWDk2AuPJAOxeZIKHhCq9/iE2uwEBzCAqX GTnXQ6/lKvQGOqravL6M2E3JpEnZEnsbnpaLI24DBAP6cvsio2I/Rt2Iw3S13y5hZchI Yc1jdibdOKCdVdyx907xw6a/y6fhs1cS8x/WZkiTkZB6k1qJaZrci1whBXIF1nRYxo72 7m5w== X-Gm-Message-State: AOAM532MOXCU8Bz5QJbgULh8e/8kE7hnoPLNqjjTNaru9Pv0YK9JmWk7 y2uwwXYOExgDwzSHsUg1J+k= X-Received: by 2002:a17:90a:6342:: with SMTP id v2mr2497324pjs.150.1612244773488; Mon, 01 Feb 2021 21:46:13 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id h23sm20707603pgh.64.2021.02.01.21.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 21:46:12 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery , Jeremy Kerr Subject: [PATCH v2 1/2] drm/aspeed: Look up syscon by phandle Date: Tue, 2 Feb 2021 16:15:57 +1030 Message-Id: <20210202054558.344451-2-joel@jms.id.au> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202054558.344451-1-joel@jms.id.au> References: <20210202054558.344451-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-aspeed@lists.ozlabs.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This scales better to multiple families of SoC. The lookup by compatible can be removed in a future change. The fallback path is for the ast2500 platform only. Other platforms will be added with the new style, so they won't need fallback paths. Signed-off-by: Joel Stanley --- v2: Fix fallback path to still find ast2500-scu. Thanks jk for the review --- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index 457ec04950f7..54a6bda03c0e 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c @@ -103,6 +103,7 @@ static int aspeed_gfx_load(struct drm_device *drm) { struct platform_device *pdev = to_platform_device(drm->dev); struct aspeed_gfx *priv = to_aspeed_gfx(drm); + struct device_node *np = pdev->dev.of_node; struct resource *res; int ret; @@ -111,10 +112,13 @@ static int aspeed_gfx_load(struct drm_device *drm) if (IS_ERR(priv->base)) return PTR_ERR(priv->base); - priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); + priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon"); if (IS_ERR(priv->scu)) { - dev_err(&pdev->dev, "failed to find SCU regmap\n"); - return PTR_ERR(priv->scu); + priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); + if (IS_ERR(priv->scu)) { + dev_err(&pdev->dev, "failed to find SCU regmap\n"); + return PTR_ERR(priv->scu); + } } ret = of_reserved_mem_device_init(drm->dev); From patchwork Tue Feb 2 05:45:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 374598 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1924745jah; Mon, 1 Feb 2021 21:46:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQpsuVaUlqIrX5sMwZjkqrxuXFDPk5W4x2QQvY3DR34G/2glOak7Cl9jS5c/VAcf0pmcKn X-Received: by 2002:a17:902:44d:b029:de:c063:85c9 with SMTP id 71-20020a170902044db02900dec06385c9mr21225885ple.35.1612244780949; Mon, 01 Feb 2021 21:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612244780; cv=none; d=google.com; s=arc-20160816; b=WuN6HvzxGcc17npOmUhce1cZWqHz1pNQvgHgZNJmfNO2OABFN+Eop8N7hBDs+ioJRe gGFpc6AcHw2wphGbiC212INgNr6Eop5dXWh+tEngfiF4y8EF0j7EFsqYR+IrDhgIZ8kR hLbIFX9Q4ELACHeAuXVnoOUgwWAZ+d4OKpm0WDORGoNk1jVord0dF3W7QdliCjB2QZjv HrqggG/5bjzZUkbv1+KA7oVEqI9r0KoTORn6s89qZhtoYmv+0v5BjjPebcDwr3WBTc1Z 3+5LAX0bnGZXrhp/nBqeqev3/emH+6+TnGv/Hq1UE4a0Q1n6cyxSr5iC4YvnlGoIYWCB c8Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=AxN2Fyl8+IpFKrIddD3/iWe9v8h+rGPrhmwJhz7jQtU=; b=e4jcHMOfZz/vPtzBLJIerJkAjywq1/DKQg/G1JkPLvm+x4IQV1HoJwtiyAg37ESREV Va56fguQERYFxoL9oCEQ3Vv1fxdJ3JdSpovrxR+BnJcztLGVzo/XKLRWfway+39eAgpg cfPcWMadDJn+YpSYcfURYQt1V1khgWqBEYI2sSCmnFLIfBwyn2OLi230gDElPfc+tEP6 C9XL0z8NfXPnaPxO3w7rDenLafhHWJ0BESzc1ryOv5M2S0aiHJ3qZ+0vs83UXdLqQNx3 G+1jG5Pe1akO8KPPhk4Z0ufbxSJIzExmmrRwyGxvux0M0S/pnkoGxRtCeqe7jQuJR/94 moSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ur5uyu81; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id 89si22251422pla.96.2021.02.01.21.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 21:46:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ur5uyu81; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E68F06E8C0; Tue, 2 Feb 2021 05:46:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4158F6E8C0 for ; Tue, 2 Feb 2021 05:46:18 +0000 (UTC) Received: by mail-pg1-x52b.google.com with SMTP id t25so14197211pga.2 for ; Mon, 01 Feb 2021 21:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tln3Bg0XWCxbufTPpfscM35i70HxngVJbE7UvBj98UE=; b=ur5uyu8125bKSk36BOgqcHzNRba+m4rmdURAunmA1IZgw8Ukl7SwGOgOY/um9zahIF U2fjcHxa/Bt7VIsk6JgIIJ/TZ6SszxDbMTjrGzgEQdw9/cNitmVV4L64z10vcV68FzZl UpG3NLARwg6/5a3KUXd4EyeB8O+hogCEvX/yn1wJiuW1FxbzPw0jxY5brGCWEnLFw7z2 eiH9COO2N0exjo0wFrvLPlJ8i+hQESRvRDMI2tjHB31idQ9emCrcNwGeTn0ZUGRZW+e6 BJUpNKgYQgyrRNwgeKx66tWx3uP0Mbq7wEsCUuN9JrcHqrG4Hi05g99cG9ymwChQ519E cbKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Tln3Bg0XWCxbufTPpfscM35i70HxngVJbE7UvBj98UE=; b=kTLC8i75EmA+tJVg+WIgie83bJVGpI4bQ8VbNV3MFKJxIvQ2iELh4NvEwi5oHP288i BzMT5IogyrRDU/M5fQa+u6kRpMVuhIp9TGT/bnH73jaoxgDW1+vFzEpAMObNhqME2Foi 4ZiVzRlILwLXUknZ6dHn7SN9soBxkfMlAupEgYUbWdoL+Rrf647BF2ntNB3PMpHgqyTG HBoOfoDnIwae3qNjOewQ4vm9kd0787dq/Jd9YVutM/saryzKrNWaY7ubnP0yeiWsJZVS jR/RHMDq5C9wJPntV0LP0pOdAPctnXxjtQqXV7pvx+Ovi8kgR3Uzn/cbKhytd1K8yiTX Nvpw== X-Gm-Message-State: AOAM530u7TrIgiwV1KhiDVJLraz5SLf57VIWiaHmfgmtYs9/+n1T7Pz+ DKEIBXO+IdEy9KMD/zI/8FBZmwy3sVw= X-Received: by 2002:a62:2ac3:0:b029:1bc:4287:c0b3 with SMTP id q186-20020a622ac30000b02901bc4287c0b3mr19188437pfq.26.1612244777839; Mon, 01 Feb 2021 21:46:17 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id h23sm20707603pgh.64.2021.02.01.21.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 21:46:16 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery , Jeremy Kerr Subject: [PATCH v2 2/2] drm/aspeed: Use dt matching for default register values Date: Tue, 2 Feb 2021 16:15:58 +1030 Message-Id: <20210202054558.344451-3-joel@jms.id.au> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202054558.344451-1-joel@jms.id.au> References: <20210202054558.344451-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-aspeed@lists.ozlabs.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There are minor differences in the values for the threshold value and the scan line size between families of ASPEED SoC. Additionally the SCU registers for the output control and scratch registers differ between families. This adds device tree matching to parameterise these values, allowing us to add support for the AST2400 now, and in the future the AST2600. Reviewed-by: Jeremy Kerr Signed-off-by: Joel Stanley --- v2: - Add jk's review - Clean up comments and unused define - Add VGA password register --- drivers/gpu/drm/aspeed/aspeed_gfx.h | 8 ++-- drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 11 ++--- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 57 ++++++++++++++++++------ 3 files changed, 55 insertions(+), 21 deletions(-) -- 2.30.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h index f1e7e56abc02..96501152bafa 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h @@ -11,6 +11,11 @@ struct aspeed_gfx { struct reset_control *rst; struct regmap *scu; + u32 dac_reg; + u32 vga_scratch_reg; + u32 throd_val; + u32 scan_line_max; + struct drm_simple_display_pipe pipe; struct drm_connector connector; }; @@ -100,6 +105,3 @@ int aspeed_gfx_create_output(struct drm_device *drm); /* CRT_THROD */ #define CRT_THROD_LOW(x) (x) #define CRT_THROD_HIGH(x) ((x) << 8) - -/* Default Threshold Seting */ -#define G5_CRT_THROD_VAL (CRT_THROD_LOW(0x24) | CRT_THROD_HIGH(0x3C)) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c index e54686c31a90..20c2197b270f 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c @@ -59,8 +59,8 @@ static void aspeed_gfx_enable_controller(struct aspeed_gfx *priv) u32 ctrl1 = readl(priv->base + CRT_CTRL1); u32 ctrl2 = readl(priv->base + CRT_CTRL2); - /* SCU2C: set DAC source for display output to Graphics CRT (GFX) */ - regmap_update_bits(priv->scu, 0x2c, BIT(16), BIT(16)); + /* Set DAC source for display output to Graphics CRT (GFX) */ + regmap_update_bits(priv->scu, priv->dac_reg, BIT(16), BIT(16)); writel(ctrl1 | CRT_CTRL_EN, priv->base + CRT_CTRL1); writel(ctrl2 | CRT_CTRL_DAC_EN, priv->base + CRT_CTRL2); @@ -74,7 +74,7 @@ static void aspeed_gfx_disable_controller(struct aspeed_gfx *priv) writel(ctrl1 & ~CRT_CTRL_EN, priv->base + CRT_CTRL1); writel(ctrl2 & ~CRT_CTRL_DAC_EN, priv->base + CRT_CTRL2); - regmap_update_bits(priv->scu, 0x2c, BIT(16), 0); + regmap_update_bits(priv->scu, priv->dac_reg, BIT(16), 0); } static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) @@ -127,7 +127,8 @@ static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) * Terminal Count: memory size of one scan line */ d_offset = m->hdisplay * bpp / 8; - t_count = (m->hdisplay * bpp + 127) / 128; + t_count = DIV_ROUND_UP(m->hdisplay * bpp, priv->scan_line_max); + writel(CRT_DISP_OFFSET(d_offset) | CRT_TERM_COUNT(t_count), priv->base + CRT_OFFSET); @@ -135,7 +136,7 @@ static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) * Threshold: FIFO thresholds of refill and stop (16 byte chunks * per line, rounded up) */ - writel(G5_CRT_THROD_VAL, priv->base + CRT_THROD); + writel(priv->throd_val, priv->base + CRT_THROD); } static void aspeed_gfx_pipe_enable(struct drm_simple_display_pipe *pipe, diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index 54a6bda03c0e..debf6c6e1958 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,34 @@ * which is available under NDA from ASPEED. */ +struct aspeed_gfx_config { + u32 dac_reg; /* DAC register in SCU */ + u32 vga_scratch_reg; /* VGA scratch register in SCU */ + u32 throd_val; /* Default Threshold Seting */ + u32 scan_line_max; /* Max memory size of one scan line */ +}; + +static const struct aspeed_gfx_config ast2400_config = { + .dac_reg = 0x2c, + .vga_scratch_reg = 0x50, + .throd_val = CRT_THROD_LOW(0x1e) | CRT_THROD_HIGH(0x12), + .scan_line_max = 64, +}; + +static const struct aspeed_gfx_config ast2500_config = { + .dac_reg = 0x2c, + .vga_scratch_reg = 0x50, + .throd_val = CRT_THROD_LOW(0x24) | CRT_THROD_HIGH(0x3c), + .scan_line_max = 128, +}; + +static const struct of_device_id aspeed_gfx_match[] = { + { .compatible = "aspeed,ast2400-gfx", .data = &ast2400_config }, + { .compatible = "aspeed,ast2500-gfx", .data = &ast2500_config }, + { }, +}; +MODULE_DEVICE_TABLE(of, aspeed_gfx_of_table); + static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = { .fb_create = drm_gem_fb_create, .atomic_check = drm_atomic_helper_check, @@ -97,13 +126,13 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data) return IRQ_NONE; } - - static int aspeed_gfx_load(struct drm_device *drm) { struct platform_device *pdev = to_platform_device(drm->dev); struct aspeed_gfx *priv = to_aspeed_gfx(drm); struct device_node *np = pdev->dev.of_node; + const struct aspeed_gfx_config *config; + const struct of_device_id *match; struct resource *res; int ret; @@ -112,6 +141,16 @@ static int aspeed_gfx_load(struct drm_device *drm) if (IS_ERR(priv->base)) return PTR_ERR(priv->base); + match = of_match_device(aspeed_gfx_match, &pdev->dev); + if (!match) + return -EINVAL; + config = match->data; + + priv->dac_reg = config->dac_reg; + priv->vga_scratch_reg = config->vga_scratch_reg; + priv->throd_val = config->throd_val; + priv->scan_line_max = config->scan_line_max; + priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon"); if (IS_ERR(priv->scu)) { priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); @@ -206,14 +245,6 @@ static const struct drm_driver aspeed_gfx_driver = { .minor = 0, }; -static const struct of_device_id aspeed_gfx_match[] = { - { .compatible = "aspeed,ast2500-gfx" }, - { } -}; - -#define ASPEED_SCU_VGA0 0x50 -#define ASPEED_SCU_MISC_CTRL 0x2c - static ssize_t dac_mux_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -228,7 +259,7 @@ static ssize_t dac_mux_store(struct device *dev, struct device_attribute *attr, if (val > 3) return -EINVAL; - rc = regmap_update_bits(priv->scu, ASPEED_SCU_MISC_CTRL, 0x30000, val << 16); + rc = regmap_update_bits(priv->scu, priv->dac_reg, 0x30000, val << 16); if (rc < 0) return 0; @@ -241,7 +272,7 @@ static ssize_t dac_mux_show(struct device *dev, struct device_attribute *attr, c u32 reg; int rc; - rc = regmap_read(priv->scu, ASPEED_SCU_MISC_CTRL, ®); + rc = regmap_read(priv->scu, priv->dac_reg, ®); if (rc) return rc; @@ -256,7 +287,7 @@ vga_pw_show(struct device *dev, struct device_attribute *attr, char *buf) u32 reg; int rc; - rc = regmap_read(priv->scu, ASPEED_SCU_VGA0, ®); + rc = regmap_read(priv->scu, priv->vga_scratch_reg, ®); if (rc) return rc;