Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1594813pxm; Thu, 3 Mar 2022 22:51:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDPUVyUIoNKW7WoxXrW31zIyJTlg9NPen5PY2up+eNp1ZZnArlW0Usu8p3qiyaWqU/Nqm9 X-Received: by 2002:a17:907:1b0e:b0:6da:81ae:a798 with SMTP id mp14-20020a1709071b0e00b006da81aea798mr7198685ejc.699.1646376708004; Thu, 03 Mar 2022 22:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646376707; cv=none; d=google.com; s=arc-20160816; b=Po1CVxDBsQOdN7xQ6cQYWoNqz5xcDbZr9Irn74HiZJtCxqeJnojqDMv5/ca9wDb6Op gV/GnO4G192dZyY0+aBQzMIG6TJKdxT1XawBQJcA8b/zhAFXi06KsIqYiDJSu0bCTlJa H6M+eGCO8q8AaaNWaWFU1c2oWJwNtVRZueD9jwMggPGGYlVgrNUxYLcBRik5CNkZBQQG jvMcJplD7Vy1SNyVdNRDG9ty0YlApujn8xAuqxf5dPI+QDtlcWHH2CbW7qRXd83UgrCU uzJLkY5Sq6xuDtlr4HkZCAsp5mKXUrIu5ERdYfpAryocULZQ7qBO42yfQ5M1NNu31UIG 3Qvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ZxRQQNrNxwmB1ezJkatHXC2Dtd8ty6b9CQaMVzLTcHA=; b=AnAWk62xsJn/haCPZMAlC1O9loVXIhQld51uFrg/sAEtDHR5NymMuqL2zCzBTndM6Z WI6OJOPGYdjG3ZpbnIFYeOYkl3v2aApVOlCkEzggi4T3a3/T8DfWgSxmaq7YgSSVCejg UVzHVSeYHPq9n68EllpLbUXZfBWF0O/8Qge3v45g3EgcSm82CnGCWp28L92lvVhLHDol jx06T/m5AUQ1B4MufpWVD8C+nvalFwuiM67StqX57cfXA2FC7qidbyW9ZNZDPoToe0w7 nT+FrlsMf4CZ/4moKWDkhpfPi3uKDnEu8/IGcbAapVGJOB4uwP4vBhho5EYW4m8JAn6C AQfg== ARC-Authentication-Results: i=1; mx.google.com; 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 g1-20020a056402424100b00413adb1bbabsi2643132edb.91.2022.03.03.22.51.25; Thu, 03 Mar 2022 22:51:47 -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; 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 S236327AbiCDGdr (ORCPT + 99 others); Fri, 4 Mar 2022 01:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232484AbiCDGdm (ORCPT ); Fri, 4 Mar 2022 01:33:42 -0500 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965F82A277 for ; Thu, 3 Mar 2022 22:32:52 -0800 (PST) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 2246MIZl041905; Fri, 4 Mar 2022 14:22:18 +0800 (GMT-8) (envelope-from tommy_huang@aspeedtech.com) Received: from tommy0527-VirtualBox.aspeedtech.com (192.168.2.141) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Mar 2022 14:31:44 +0800 From: Tommy Haung To: , , , , , , , , , CC: Subject: [PATCH v1 1/2] drm/aspeed: Add gfx flags and clock selection for AST2600 Date: Fri, 4 Mar 2022 14:31:36 +0800 Message-ID: <20220304063137.12970-2-tommy_huang@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220304063137.12970-1-tommy_huang@aspeedtech.com> References: <20220304063137.12970-1-tommy_huang@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.2.141] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 2246MIZl041905 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Add clock selection code for AST2600. At AST2600 user could select more than one dispaly timing. Add gfx flags for future usage. Signed-off-by: Tommy Haung --- drivers/gpu/drm/aspeed/aspeed_gfx.h | 11 +++++++++++ drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h index 4e6a442c3886..eb4c267cde5e 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h @@ -16,6 +16,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 +107,13 @@ 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 CLK_MASK BIT(0) +#define CLK_G6 BIT(0) + +#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..a24fab22eac4 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. */ diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index d10246b1d1c2..af56ffdccc65 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 = CLK_G6, }; static const struct of_device_id aspeed_gfx_match[] = { -- 2.17.1