From patchwork Mon Jan 11 04:46:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12009717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBF7C433E0 for ; Mon, 11 Jan 2021 04:49:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FC2A20782 for ; Mon, 11 Jan 2021 04:49:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FC2A20782 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=a7ExBEWXLvhvoQDcOfVEoexoHII0V7MUGeXtP5cLs6c=; b=ByEnExZF4J0e1SJS123jDGhjk qVF/jXcZyY8lEmTAUe2ELHN1vMQZtaboWWwQhsOn+6tdskqSwmfXQZ/mHU9j7kEzA4MCQ47Bb+G5a iJ3ZSaRhdVsFqaHFOnMNHcYXsFG3DOQmt5LwFyf0k13Rv2Lqu9duoNNtRTDnXZvjkzkyf9Z3L3s9b PobnOd3QSCW0u9h+N60KQpe5H5aEgg64z1gJOaj3tBfahvF4L4nssaP2mdYmhRUsfKlBm9hqtaXUF /ZglFyx5JNElFsGnVii1V2BNz6wbKPVBJS4tETIyi1GkFY2/iUlZrevseHHu6rXm+dbkxGsnRccRh VMyHsixGA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyp6f-0005u1-3I; Mon, 11 Jan 2021 04:47:05 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyp6Y-0005re-8I for linux-arm-kernel@lists.infradead.org; Mon, 11 Jan 2021 04:46:59 +0000 Received: by mail-pl1-x635.google.com with SMTP id y8so8855904plp.8 for ; Sun, 10 Jan 2021 20:46:57 -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=MTf0t/g0yj3eP5J//Lhcit/5I+gGR9P17fx+loKYd/M=; b=dw5F35awsAORBgdcbHHhKYguLZM0wNpcAaLrWiMxPHQ4tVm1cEZ3v74VLibe/czHdO pwQ99HhRgX0FOyRYJqxbtB/L1y1De2JhaK4naHS4s5akLQbPjXTSfN1i0DUgeb5Kqx7H FzQcDvVn71rvwYON67M6KQ/mqbMTWBdV7dOXg+Wxllpp9qpOs7sln5VPaFRhvyPZlQtD M++05rDMjs2LTTBELMhAsq6J7QkN3V8myu3QrIDmNvd9d5wTfuLCPPoElPo/izspnJk/ jcY5XjteZxRrgdhmGmnTmQPqsPlEsXcSqoED50FZPgqVdlBcI7d/DQE1zXgl8+rA2HOO yNvQ== 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=MTf0t/g0yj3eP5J//Lhcit/5I+gGR9P17fx+loKYd/M=; b=LV2ONqH0UtvFpZnC4QCLnVPcw6r3JOVGTWOncviP/JuHjmAv7BD4p8nNLpMdUsbLpr J8QyOc4K8SB3mmAp2wJThpV2t1du0EbtH8NBbf1L0r23bR5nCvxFmsq0f4QbbAtOz0Rx 8Fs/9Am41RhuEft4lhq7n5PPC0NZ3DJ4/ume8GzKHTT/iFxQZ2NIOecumWAnE8lRETvX B4keCFb+Wf4g8vg30KwRrniTGNWNthPX+sQiEK/L9kkD2qW+E+oYBp3u8BMWV9KrafGJ n3naANcHzrNj0ABnYj/LrwmFxyEA53ZGnJUhNo98okTF2X+FCouJEjvtmLsbKOTGoM+G Fxdw== X-Gm-Message-State: AOAM533YNeF4NEeLxtVztQqUSzmbAhQjU6hNx4yUN23/GN2r6Z6Xc9z2 QGI5VKZ7aRLYgxLcXLHD0iR+5aKOl/1jiA== X-Google-Smtp-Source: ABdhPJxBCkl3x3enJELsSBqm0G69v1s8CkiXkSccBZx3mbk8e2hUMZjKOIW2OVFq2LoTLGhJe3UxIQ== X-Received: by 2002:a17:90a:2e84:: with SMTP id r4mr15948077pjd.147.1610340415961; Sun, 10 Jan 2021 20:46:55 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id z6sm17442303pfj.22.2021.01.10.20.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jan 2021 20:46:54 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery Subject: [PATCH 1/2] drm/aspeed: Look up syscon by phandle Date: Mon, 11 Jan 2021 15:16:37 +1030 Message-Id: <20210111044638.290909-2-joel@jms.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210111044638.290909-1-joel@jms.id.au> References: <20210111044638.290909-1-joel@jms.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210110_234658_387169_1E90FC0E X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This scales better to multiple families of SoC. The lookup by compatible can be removed in a future change. Signed-off-by: Joel Stanley --- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index 457ec04950f7..8ada7e944147 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,aspeed-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 Mon Jan 11 04:46:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12009721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63E18C433DB for ; Mon, 11 Jan 2021 04:49:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24B3F20782 for ; Mon, 11 Jan 2021 04:49:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24B3F20782 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=js3cF19sBEoz+5zM+cXBjpi6xFaHrUnkL/De3P2NWyQ=; b=Fm8Q9T/HJfMek+KYpe+oZb++D ApCeorID/FmTCid8ZQSmR8BX0PcQLMVlSjRGMs1Zpda+HekwK6hK/Zi4HhJJwJVDptN0vHCclRBYp t4Zbb8p3DzCJZCtQ1aM5IhWC1ycwYVPlZZLMvmhMtcVNjhebXCLWUPkOZEkAb6RxxkyL3W4VUpWmN 3dI13XAR23UAtA6gYNUSS6kej4q6fvjZUiqhNHfeiRCaeOVwVTvSgE/AbZTcLgtOEWdza+fBdpBly lz1zty3QybP+bJrvMnbB4mxpzEVaOMF6HcH1whehCdsTnbsHYRubukF4/EQcLU/DMspX1l/Ov9XlA coLR42hDg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyp6j-0005wV-Kb; Mon, 11 Jan 2021 04:47:09 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyp6c-0005t4-0G for linux-arm-kernel@lists.infradead.org; Mon, 11 Jan 2021 04:47:04 +0000 Received: by mail-pj1-x102a.google.com with SMTP id b5so9765685pjk.2 for ; Sun, 10 Jan 2021 20:47:01 -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=XD7tvFGN3IxIWU+2iTGhYLlRWQFvJrJsXmN7RwoxZJo=; b=NIb79AR6TanCl5pjG6v3ruDYPijk9ktw82udfuL7TCHXgm+b3dtOuJs7DDBQxHWWeg f/dorYAEUvDlzVdHliWPXL1QeOHgdtjmolGReF0IwS10uLqdyDJzK4ik63ysEzU8TINW rptJrcuuEoLtIhY8z8HvmI8J6d0QbNQHDP+lg5pHHXzTeIgq5KQYU8/EZ0ZPBD/W6To8 sCRa/90AEqWqRlfQPIJSMUZWPBJifR+8m2Qf9AtP7YNqAMlOKCytmcHdX6hgB1x6ij4k X/jJUFgvBi2TDh6Q2xpgLS3naigoNi+yjQQj7JgFKny3pdF0DLENtH/wwXlLndp5U23W D+Cw== 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=XD7tvFGN3IxIWU+2iTGhYLlRWQFvJrJsXmN7RwoxZJo=; b=CEyQBRiK3OwGVfx+GxAnfAtSeGvYlYhmSrSJ0j0lx2tKBuoii6NX6OOgKj4uM6yo0m 78kBNskodE6vPuEFTl8cwGNgE1sodaRIXTj8+gxTBwvW77y1UKkc605zCvO3+T049Lbw aTxS8i53T3tHIUrc/2ad2wZA6WbCw23mL9XMUGe7PfNaMVx+0QmSc0izdfAF6Ex26oX6 Mf3nesmJh/PaoIZb4kwRhC2CqyjPdJm3T7QGprueGunIXho7Z0vA26f16v1KpJ74ipCu B2Eh5awFkFgsSMOtold293aHRujVN0bGK41TyzMIAVhvQSHkRS2kaQdVCq+6v0UQVXpO Fc8g== X-Gm-Message-State: AOAM530iR2iwRjciQV8x7yiBPkiN2yqdbW+bLcBfONTeynFY3avpAsfs DG0MifbJWSqygbHVVd7CLU3h85ePTpu4Bg== X-Google-Smtp-Source: ABdhPJxDS6uKzsKL5VW0vWuGgi1aUkg43+d3HPZfBGPyAvAVW+yCN8kldY7VfvcMaw3AEg5sKzpYjw== X-Received: by 2002:a17:902:fe91:b029:da:6bf3:7ba0 with SMTP id x17-20020a170902fe91b02900da6bf37ba0mr14956309plm.2.1610340419884; Sun, 10 Jan 2021 20:46:59 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id z6sm17442303pfj.22.2021.01.10.20.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jan 2021 20:46:59 -0800 (PST) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery Subject: [PATCH 2/2] drm/aspeed: Use dt matching for default register values Date: Mon, 11 Jan 2021 15:16:38 +1030 Message-Id: <20210111044638.290909-3-joel@jms.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210111044638.290909-1-joel@jms.id.au> References: <20210111044638.290909-1-joel@jms.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210110_234702_171052_3B3C061F X-CRM114-Status: GOOD ( 22.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are minor differences in the values for the threshold value and the scan line size between families of ASPEED SoC. Additionally the SCU register for the output control differs 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. Signed-off-by: Joel Stanley Reviewed-by: Jeremy Kerr --- drivers/gpu/drm/aspeed/aspeed_gfx.h | 7 ++-- drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 10 +++-- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 48 +++++++++++++++++++----- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h index f1e7e56abc02..c81d214688f2 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h @@ -11,6 +11,10 @@ struct aspeed_gfx { struct reset_control *rst; struct regmap *scu; + u32 dac_reg; + u32 throd_val; + u32 scan_line_max; + struct drm_simple_display_pipe pipe; struct drm_connector connector; }; @@ -100,6 +104,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..4e8126edacbd 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c @@ -60,7 +60,8 @@ static void aspeed_gfx_enable_controller(struct aspeed_gfx *priv) 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)); + 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 +75,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 +128,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 +137,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 8ada7e944147..de0f0bf82c6b 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,31 @@ * which is available under NDA from ASPEED. */ +struct aspeed_gfx_config { + u32 dac_reg; /* DAC 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, + .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, + .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 +123,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 +138,15 @@ 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->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,aspeed-scu"); @@ -206,11 +241,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 @@ -228,7 +258,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 +271,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;