Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2586085pxm; Mon, 28 Feb 2022 01:59:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJynrGS3QG+rkkvHIK5HY7J8qN4Q9lTJJ9vkJzLCi3/L5f5EtybkvGTtdYPKqrKTk3fChis/ X-Received: by 2002:a17:907:9910:b0:6d5:acd6:8d02 with SMTP id ka16-20020a170907991000b006d5acd68d02mr14327220ejc.173.1646042397973; Mon, 28 Feb 2022 01:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646042397; cv=none; d=google.com; s=arc-20160816; b=nqbK5nSN6iuo2amRLMcWIF3Xf53feF+hsxWzeK/woVa3R8uAGe6pikWAOxMFOuXyFr biE9N+2kBCPeHDGPt4Re3Yk6aJQXWLrmM2wBSh1mGYKYNAEx8k7XAdpPgy9uFsnXl6Iq 71RWwknq/muF6hC2vk7EFKMKgPq+3e9ZFFGQVsdb5wQAi4NyYY8F+l1sXbdNN3QnfMvJ SeE6dogoxceBhfGgUbnmxgvU6C3m1dx/O52QV3FxXCLGF/OBWKMEGUW7NEMVoiRdTZUj 9VtXwcf9AE6USMxIBT9t1DRz9LPmMmJsmm2XkIAJjhmZmLX9qLDEIRNXTHGdw5COJGy5 9AGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2ChCJy+0OwFHzxUqMKUpKVLhG2Ciw026npYT/0GQ0Yk=; b=lEXXl2do7hpLL6leOz+/6pT+Sl7T5M28dr+N+xgGGXHPWh9SGxTDbwvz55FRaWx/8M 46WuPraUVgUFK+JGMPZ/jFKmZnfEWU2z2jkkEW2tSnuPVMMJ2DbfzvotzGLjc8g5DxJn gfy7V9Vc/raaCJEHIvrcTLXtytj1OdTj8ugXtS0D227lBkV6yu96BwYlXKb9+stlyIM4 yxiUesF1wIE5jmJPGvxnguqQnIc7eQ119UFvy4gmluWWMyZkIfpODxI4le0/muI/ZxR1 IITEmlpz4YRVFVuoHahKYVxX1hLN0xDLCzwVXUgQTD6IMpqM+U63p///djt4UHakEAk1 iqcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=hTAs+3Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j25-20020aa7de99000000b0041086c885b9si5986733edv.392.2022.02.28.01.59.34; Mon, 28 Feb 2022 01:59:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=hTAs+3Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234432AbiB1Jve (ORCPT + 99 others); Mon, 28 Feb 2022 04:51:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbiB1Jvd (ORCPT ); Mon, 28 Feb 2022 04:51:33 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F8716A068; Mon, 28 Feb 2022 01:50:55 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id d84so9860870qke.8; Mon, 28 Feb 2022 01:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2ChCJy+0OwFHzxUqMKUpKVLhG2Ciw026npYT/0GQ0Yk=; b=hTAs+3Xrr+6O7Mn2pIyT3WlaYT4dcHLyCkL6jprx+rcKO4WDXKPAoVsxvKUYypPwwB IXO8ZfW2Xi8IyJ3LlYi+wST6t6yGyjM/N3uxgvUNyUP+3PH+Mn91ZWhX00qzZ0MdJSac 3Mqm6l9D+Bv6SwWPNpZqKI+pJ2BfbDqmjpr6Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ChCJy+0OwFHzxUqMKUpKVLhG2Ciw026npYT/0GQ0Yk=; b=N8V6D+GbaIPnLL2eEVTtMI8j+PsAyvfA218CBuT1PcpN/Y17KnRBXDveyuS6rAek90 b8slvHIIU3DRsIObC9Crq60CIryJ+LksndjbcbGRKh82iHyYug6w22h0mUebmukt2CVH ept4jHXIXm1E+Anm1U/maOEj87GfbkVvQPoq6JNBDTr80KGs7P0WvCdOWVevTxdEsr13 PDuj+n8ZMif9346w4ScH7VETyqGZSd2WyfnlLJHqBYUW1XL+5SPcNLMjjW4wETPGqUHW zwfZz78cpU2MKKswzOT84pvGARERNUSv7xii18RDdGHH5dK8dZQUT1mh5Xb0WVk51MCe rX/g== X-Gm-Message-State: AOAM532zPDOqdQnRJOHonVo7dlRm3tb6bEUK/vOlpkrvPDCom7b46N9t 0Sp4S2WfsDVPbBR6EuB00Ixmi2GwF8mRUAnbZSc= X-Received: by 2002:a37:f903:0:b0:648:ca74:b7dc with SMTP id l3-20020a37f903000000b00648ca74b7dcmr10479323qkj.666.1646041854321; Mon, 28 Feb 2022 01:50:54 -0800 (PST) MIME-Version: 1.0 References: <20211208013337.13806-1-tommy_huang@aspeedtech.com> <20211208013337.13806-6-tommy_huang@aspeedtech.com> In-Reply-To: <20211208013337.13806-6-tommy_huang@aspeedtech.com> From: Joel Stanley Date: Mon, 28 Feb 2022 09:50:42 +0000 Message-ID: Subject: Re: [PATCH v5 5/7] drm/aspeed: Add reset and clock for AST2600 To: Tommy Haung Cc: David Airlie , Daniel Vetter , Rob Herring , Andrew Jeffery , linux-aspeed , "open list:DRM DRIVERS" , devicetree , Linux ARM , Linux Kernel Mailing List , BMC-SW Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Dec 2021 at 01:34, Tommy Haung wrote: > > From: tommy-huang > > Add more reset and clock select code for AST2600. > The gfx_flags parameter was added for chip caps idenified. Can you tell me a bit more about the two reset lines: What is the CRT reset line controlling? What does the engine reset line control? Can we use devm_reset_control_array_get() to get whichever are specified in the device tree, so we don't need to have different logic for the 2600 and earlier chips? > > Signed-off-by: tommy-huang > --- > drivers/gpu/drm/aspeed/aspeed_gfx.h | 16 +++++++- > drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 16 ++++++++ > drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 50 ++++++++++++++++++++++-- > 3 files changed, 77 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h > index 4e6a442c3886..2c733225d3c7 100644 > --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h > @@ -8,7 +8,8 @@ struct aspeed_gfx { > struct drm_device drm; > void __iomem *base; > struct clk *clk; > - struct reset_control *rst; > + struct reset_control *rst_crt; > + struct reset_control *rst_engine; > struct regmap *scu; > > u32 dac_reg; > @@ -16,6 +17,7 @@ struct aspeed_gfx { > u32 vga_scratch_reg; > u32 throd_val; > u32 scan_line_max; > + u32 flags; > > struct drm_simple_display_pipe pipe; > struct drm_connector connector; > @@ -106,3 +108,15 @@ int aspeed_gfx_create_output(struct drm_device *drm); > /* CRT_THROD */ > #define CRT_THROD_LOW(x) (x) > #define CRT_THROD_HIGH(x) ((x) << 8) > + > +/* SCU control */ > +#define SCU_G6_CLK_COURCE 0x300 > + > +/* GFX FLAGS */ > +#define RESET_MASK BIT(0) > +#define RESET_G6 BIT(0) > +#define CLK_MASK BIT(4) > +#define CLK_G6 BIT(4) > + > +#define G6_CLK_MASK (BIT(8) | BIT(9) | BIT(10)) > +#define G6_USB_40_CLK BIT(9) > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c > index 827e62c1daba..e0975ecda92d 100644 > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c > @@ -77,6 +77,18 @@ static void aspeed_gfx_disable_controller(struct aspeed_gfx *priv) > regmap_update_bits(priv->scu, priv->dac_reg, BIT(16), 0); > } > > +static void aspeed_gfx_set_clk(struct aspeed_gfx *priv) > +{ > + switch (priv->flags & CLK_MASK) { > + case CLK_G6: > + regmap_update_bits(priv->scu, SCU_G6_CLK_COURCE, G6_CLK_MASK, 0x0); > + regmap_update_bits(priv->scu, SCU_G6_CLK_COURCE, G6_CLK_MASK, G6_USB_40_CLK); > + break; > + default: > + break; > + } > +} > + > static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) > { > struct drm_display_mode *m = &priv->pipe.crtc.state->adjusted_mode; > @@ -87,6 +99,8 @@ static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) > if (err) > return; > > + aspeed_gfx_set_clk(priv); > + > #if 0 > /* TODO: we have only been able to test with the 40MHz USB clock. The > * clock is fixed, so we cannot adjust it here. */ > @@ -193,6 +207,7 @@ static void aspeed_gfx_pipe_update(struct drm_simple_display_pipe *pipe, > static int aspeed_gfx_enable_vblank(struct drm_simple_display_pipe *pipe) > { > struct aspeed_gfx *priv = drm_pipe_to_aspeed_gfx(pipe); > + > u32 reg = readl(priv->base + CRT_CTRL1); > > /* Clear pending VBLANK IRQ */ > @@ -207,6 +222,7 @@ static int aspeed_gfx_enable_vblank(struct drm_simple_display_pipe *pipe) > static void aspeed_gfx_disable_vblank(struct drm_simple_display_pipe *pipe) > { > struct aspeed_gfx *priv = drm_pipe_to_aspeed_gfx(pipe); > + > u32 reg = readl(priv->base + CRT_CTRL1); > > reg &= ~CRT_CTRL_VERTICAL_INTR_EN; > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c > index d10246b1d1c2..59a0de92650f 100644 > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c > @@ -64,6 +64,7 @@ struct aspeed_gfx_config { > 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 */ > + u32 gfx_flags; /* Flags for gfx chip caps */ > }; > > static const struct aspeed_gfx_config ast2400_config = { > @@ -72,6 +73,7 @@ static const struct aspeed_gfx_config ast2400_config = { > .vga_scratch_reg = 0x50, > .throd_val = CRT_THROD_LOW(0x1e) | CRT_THROD_HIGH(0x12), > .scan_line_max = 64, > + .gfx_flags = 0, > }; > > static const struct aspeed_gfx_config ast2500_config = { > @@ -80,6 +82,7 @@ static const struct aspeed_gfx_config ast2500_config = { > .vga_scratch_reg = 0x50, > .throd_val = CRT_THROD_LOW(0x24) | CRT_THROD_HIGH(0x3c), > .scan_line_max = 128, > + .gfx_flags = 0, > }; > > static const struct aspeed_gfx_config ast2600_config = { > @@ -88,6 +91,7 @@ static const struct aspeed_gfx_config ast2600_config = { > .vga_scratch_reg = 0x50, > .throd_val = CRT_THROD_LOW(0x50) | CRT_THROD_HIGH(0x70), > .scan_line_max = 128, > + .gfx_flags = RESET_G6 | CLK_G6, > }; > > static const struct of_device_id aspeed_gfx_match[] = { > @@ -138,6 +142,44 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data) > return IRQ_NONE; > } > > +static int aspeed_gfx_reset(struct drm_device *drm) > +{ > + struct platform_device *pdev = to_platform_device(drm->dev); > + struct aspeed_gfx *priv = to_aspeed_gfx(drm); > + > + switch (priv->flags & RESET_MASK) { > + case RESET_G6: > + priv->rst_crt = devm_reset_control_get(&pdev->dev, "crt"); > + if (IS_ERR(priv->rst_crt)) { > + dev_err(&pdev->dev, > + "missing or invalid crt reset controller device tree entry"); > + return PTR_ERR(priv->rst_crt); > + } > + reset_control_deassert(priv->rst_crt); > + > + priv->rst_engine = devm_reset_control_get(&pdev->dev, "engine"); > + if (IS_ERR(priv->rst_engine)) { > + dev_err(&pdev->dev, > + "missing or invalid engine reset controller device tree entry"); > + return PTR_ERR(priv->rst_engine); > + } > + reset_control_deassert(priv->rst_engine); > + break; > + > + default: > + priv->rst_crt = devm_reset_control_get_exclusive(&pdev->dev, NULL); > + if (IS_ERR(priv->rst_crt)) { > + dev_err(&pdev->dev, > + "missing or invalid reset controller device tree entry"); > + return PTR_ERR(priv->rst_crt); > + } > + reset_control_deassert(priv->rst_crt); > + break; > + } > + > + return 0; > +} > + > static int aspeed_gfx_load(struct drm_device *drm) > { > struct platform_device *pdev = to_platform_device(drm->dev); > @@ -163,6 +205,7 @@ static int aspeed_gfx_load(struct drm_device *drm) > priv->vga_scratch_reg = config->vga_scratch_reg; > priv->throd_val = config->throd_val; > priv->scan_line_max = config->scan_line_max; > + priv->flags = config->gfx_flags; > > priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon"); > if (IS_ERR(priv->scu)) { > @@ -186,13 +229,12 @@ static int aspeed_gfx_load(struct drm_device *drm) > return ret; > } > > - priv->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); > - if (IS_ERR(priv->rst)) { > + ret = aspeed_gfx_reset(drm); > + if (ret) { > dev_err(&pdev->dev, > "missing or invalid reset controller device tree entry"); > - return PTR_ERR(priv->rst); > + return ret; > } > - reset_control_deassert(priv->rst); > > priv->clk = devm_clk_get(drm->dev, NULL); > if (IS_ERR(priv->clk)) { > -- > 2.17.1 >