From patchwork Tue Feb 9 12:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 379343 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp179450jah; Tue, 9 Feb 2021 04:37:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5gEgUTvOOVbLD25KBUfIr3x5kefOF/10XzxFcb7yb827mp+2q5Hy9ljD9A/Bm7e7HYE+w X-Received: by 2002:a17:903:4083:b029:e2:9654:de1c with SMTP id z3-20020a1709034083b02900e29654de1cmr21535762plc.43.1612874271634; Tue, 09 Feb 2021 04:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612874271; cv=none; d=google.com; s=arc-20160816; b=FxwQA3qcHEXA1M0gRH6deWYnfKEn4cCeH3aM0Eom34UHs8ktlaHAw1D1l9D9EFbQQZ v6EisXAbHpnGsuVsvNZDTPdJ5Y3gERO1xUvn47LCHJ/DVsZqtNLGIBUqAAcNASfr5Blb o/WM2qHoetDqXvZZSuim7BssTWVCkXBMerf9SOnwVhlqKd3vAHM2n/KC8xuAw5uapJ++ pT3UqkVUKfB3aFvR+ilDmV+XDBewZyIGABRNgQaeV9BdpxLVnZxpJdWq6PxQlG1hke6Z Ad1v/cEYr0lf2FZ/QbjPuq+CsLwOoS/AL8J7hcHWEBBBQfK17dZCP01/Vqj5+nA1i9Fv SbQg== 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=m31B/y3Ajhx2wdTyCRsrhwvMbAuP730A4SaTUp/7rqS6SrFfduGWrYYwZxC4w7i1LL sPLCxVZg2T8H9WHstDZwesxLYw1C+PZ4QrDyXA1FLiE/yFmXxZ8AiMTRNfiaJwFFvP9v 9xXHB9cBRY866kejGAFzTpFTjO9GG35MoChlL3kyeSqvGA9A+CNaiBxPrNK9OG/CvOKM iXwHYqRgQfntvUM1p5MPccYv0xkMjMhSqkTs0MvDj8hVr0z4xFj636lelGmaFg1GNAWF /4BOZjozRO+8cr+S5IZKW7Myo8JJUhMCOKWd5R3N6Tqin7Aa+p1vImbP2JfgUFYQmb0v R8GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=UA7qw6pC; 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 nl12si2557887pjb.44.2021.02.09.04.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 04:37:51 -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=UA7qw6pC; 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 2E04E6E051; Tue, 9 Feb 2021 12:37:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A7C36E051 for ; Tue, 9 Feb 2021 12:37:49 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id q20so11813270pfu.8 for ; Tue, 09 Feb 2021 04:37:49 -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=UA7qw6pCaOdf/yqq69etxef0untkhUFXSI+O9aCuyR/lOYzzPCRtWaHB6KbMDFaObh maH0YiX2IcjeEONLLi2m+Sk+3PTzs33BzrB2mJ0HcLcjRk2r9l8yFR3/KfrkL6EkdZzb i8Cave62QyllrlcUMYo1mEwijF+bfDhpgxDWkcnziTD6OcT6DxjwzJyWMEFdZWboC3uY cbIO+ZB5NSD6J70UHw1gRakG/afPMQiZ5Hd6tPMcqAv+xikSyDJDq/u4w5z8EMpDP8T2 Lg8Z3VO2gx3ssY95EEyC5FYR7D6991/PEqnpomJXo/ZUGeBHxea1UuMcYEtJj3Cc0wko 9Lgw== 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=rncD5jG05DWQGnIC0Uq0g1WaB54BlyAdSHXol11jbuggFjR/bPVZb9t5ZkGPYnl2qN Uu21HvtLOJd3+kNlGLaK6VsIhs6UmJm+GvFc71KhXyXnnAiSjgeeK5ipNSNWAp7ctG7c PKlF43HU0gUMrcTRiNyE5f/Xbyc10/zNpw4o0a5PggHFdDAyeOawPJojdmVi0M5ZlvJG R7HX76iEqYPaYYcC/kxg7sDX/iJFFXturXh4R+fj7NBgxJajelb5Sb+fzOW+8Ve76e0j OUqo1XQVV+2lRkoQW+FXGjOZwx+FqLvPIQMZAWCdEz6lJ8yibxiPv+LBWtXYu33WO5+W wjbA== X-Gm-Message-State: AOAM53078jfk0cftALHtqUQYmgv8otro9tQ89peh87XKp+t9grOQ76wz HVEekvTx5pr0thPbFGrtD0THHJbaKOqzvA== X-Received: by 2002:a63:c70c:: with SMTP id n12mr22157570pgg.347.1612874269194; Tue, 09 Feb 2021 04:37:49 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id i7sm22584395pfc.50.2021.02.09.04.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 04:37:48 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery , Jeremy Kerr Subject: [PATCH v3 1/2] drm/aspeed: Look up syscon by phandle Date: Tue, 9 Feb 2021 23:07:33 +1030 Message-Id: <20210209123734.130483-2-joel@jms.id.au> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209123734.130483-1-joel@jms.id.au> References: <20210209123734.130483-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 Reviewed-by: Andrew Jeffery 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 9 12:37:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 379344 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp179513jah; Tue, 9 Feb 2021 04:37:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu2sQj+/20i5X7dGkv2tm7weKoCazsaCezb8A8vZ4zLN3pyh1I7ifRVExb3jnSHzDTVLf7 X-Received: by 2002:a05:6a00:7c7:b029:1de:80cd:46b8 with SMTP id n7-20020a056a0007c7b02901de80cd46b8mr7666054pfu.63.1612874276588; Tue, 09 Feb 2021 04:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612874276; cv=none; d=google.com; s=arc-20160816; b=Cq/X54Bl2oPkslPMspif4CEj1l6ml3WgjpjBNevXion+iA8E25fs1FUxS7W0IA26e0 GUY9qHnxs5lmoFcRw3Qk5LW7Bi/6HjuDdw3mt8YuGhu0fM7BjNS1omJJAdo1MhO3bSF2 OhrbJFRBl8JTcI44YC2Mrvk9CaPr6hrc0oEj6l5+wkz2N1ZpIMe8NRUtcR6HgIGwcVyT vu4xE4Y+kajfq4/G/rWvxdvSwQVSKkBBXburzO1wtdF/mxLmXG589eBA8JCc1Fpos89p Jw6yMkW53mBoEO27c6tD9MTIl0zH/CJvdpD2cwaPPyIGjc/jkEq76LycHpLEbFfaZYlP O6Jw== 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=of3/9FoT31Rvq6k6Tily/5pAxGvqUjq2PgxhSf/5lMM=; b=ATPNNsJncGG3RyIb6QbSefGTenr4GWcIFD9pRZxAopRetrRfB+c90gknpu9f7YHTZe U4FkD2lxA4JENo9mUlQd0gcicUBtxT7PaTRTS3SRmKUJ0u2RAcmavdnYzBT5pPE1Jup1 jnIFWCt+hKH+RMF2DsGOCuOjzx/8I/bZIo+D1txJY2VoPPvQIwgIw1EaZSiUkoCTe/SU Oec7z7myeLp3hKjONyG+8cDeGzjPthmwVpMGRaUDbNVYFjmaBoZvDgsjJ5lWmyqEiOOU EZd+pTcvGvihYz6BiemmkG+ff7OjIEZ9qnYPdxNLEiPg2w/oZ7wmltrxraVUQ7GjnKrJ vYMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=qJmyr4yp; 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 c2si21579699plg.439.2021.02.09.04.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 04:37:56 -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=qJmyr4yp; 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 9A19C6E483; Tue, 9 Feb 2021 12:37:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id C5FD96E483 for ; Tue, 9 Feb 2021 12:37:53 +0000 (UTC) Received: by mail-pf1-x42a.google.com with SMTP id k13so5356005pfh.13 for ; Tue, 09 Feb 2021 04:37:53 -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=Zycq6RRVcVub8qCKjMDOvULYSyXziBOTcV1ME0xBHvk=; b=qJmyr4yp5zrPvgmZVaN4LjkrCfxfUxYuJOpaKzM74rCn9qdCwcQ/iQcvje/hRz1cI5 YmjP5fZYRdEzyp+6jy4aQKXUX01iefhZ5QgsDlw2mkHV5kkuBW5zUwxhF2twIgS10v/9 v8GXUHGBTLkOeREZdRiZ7mpgFk5p5AH7nrS5VUftjZGT/GGAk4nteW+rQR/ytgJFbtTW N4YqRvF1/sNabHHK9tiVUK82+3gnYcqj3EcjENmf7k7AzTnuj9V7ds4hTvZBwi8WSauR 1d0r/Ap0qDc8fb7DG4xG5PKVBAVE4+TZ1y4CTH9avB1krpUmGs1zJris6Ijc58a9E9WA TNtQ== 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=Zycq6RRVcVub8qCKjMDOvULYSyXziBOTcV1ME0xBHvk=; b=JYWh+SCf4O94oZ/OwGc4nNh3wSZaE8p9vGq4hzljk+O4zKs4Fcm4UxMF36pIfbbOBO QT/gGwXzyXpwFKYymz7MMWiKJ+ACr/hyBIWm9Of/tpxqgztcvXjFdArrPPYO5S99lJrC vEZjFo/xmzpTKoxGFFakN3WlZkcmrZldjnbVrCmjGlMTKmH6qpVpOCL/fOpyB61qE6p8 3gmbTS8G+Q//786wUr/K67QtCdVyauc8mLV3wks1/ullATNFWy9G02HW9enQFf7x0Msk zWTqoYkkaiIM85lNsQQUerzBiVdDVELZrfhG3uJONfIER4g24+Gf8q8H6s7U0m9MpVBo VWSA== X-Gm-Message-State: AOAM532z4FBVDQ/Jen6HNVo7qsZGaO9EaADxOcZUEk+OlYkLfTKIFf+o SqMXTw04ueUY9ebeY8ZY6hI= X-Received: by 2002:a62:1995:0:b029:1c0:c4d8:adcb with SMTP id 143-20020a6219950000b02901c0c4d8adcbmr22651384pfz.60.1612874273279; Tue, 09 Feb 2021 04:37:53 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id i7sm22584395pfc.50.2021.02.09.04.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 04:37:52 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery , Jeremy Kerr Subject: [PATCH v3 2/2] drm/aspeed: Use dt matching for default register values Date: Tue, 9 Feb 2021 23:07:34 +1030 Message-Id: <20210209123734.130483-3-joel@jms.id.au> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209123734.130483-1-joel@jms.id.au> References: <20210209123734.130483-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 --- v3: - Fix match table 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..6b3a01ba3e0d 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_match); + 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;