From nobody Sat Feb 7 15:30:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648803421444530.2681106753697; Fri, 1 Apr 2022 01:57:01 -0700 (PDT) Received: from localhost ([::1]:36366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naD5Y-0002LU-4m for importer@patchew.org; Fri, 01 Apr 2022 04:57:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naCpK-0000Dm-Mw; Fri, 01 Apr 2022 04:40:22 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:24706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naCpI-0001SA-Fy; Fri, 01 Apr 2022 04:40:14 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 2318Rrwv030513; Fri, 1 Apr 2022 16:27:53 +0800 (GMT-8) (envelope-from jamin_lin@aspeedtech.com) Received: from localhost.localdomain (192.168.70.87) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 1 Apr 2022 16:38:55 +0800 From: Jamin Lin To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Andrew Jeffery , Joel Stanley , Alistair Francis , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , "Beraldo Leal" , "open list:ASPEED BMCs" , "open list:All patches CC here" Subject: [PATCH v5 6/9] aspeed/scu: Add AST1030 support Date: Fri, 1 Apr 2022 16:38:47 +0800 Message-ID: <20220401083850.15266-7-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220401083850.15266-1-jamin_lin@aspeedtech.com> References: <20220401083850.15266-1-jamin_lin@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.70.87] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 2318Rrwv030513 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=211.20.114.71; envelope-from=jamin_lin@aspeedtech.com; helo=twspam01.aspeedtech.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jamin_lin@aspeedtech.com, troy_lee@aspeedtech.com, steven_lee@aspeedtech.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1648803423074100001 From: Steven Lee Per ast1030_v07.pdf, AST1030 SOC doesn't have SCU300, the pclk divider selection is defined in SCU310[11:8]. Add a get_apb_freq function and a class init handler for ast1030. Signed-off-by: Troy Lee Signed-off-by: Jamin Lin Signed-off-by: Steven Lee Reviewed-by: C=C3=A9dric Le Goater --- hw/misc/aspeed_scu.c | 63 ++++++++++++++++++++++++++++++++++++ include/hw/misc/aspeed_scu.h | 25 ++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c index 150567f98a..19b03471fc 100644 --- a/hw/misc/aspeed_scu.c +++ b/hw/misc/aspeed_scu.c @@ -235,6 +235,15 @@ static uint32_t aspeed_2600_scu_get_apb_freq(AspeedSCU= State *s) / asc->apb_divider; } =20 +static uint32_t aspeed_1030_scu_get_apb_freq(AspeedSCUState *s) +{ + AspeedSCUClass *asc =3D ASPEED_SCU_GET_CLASS(s); + uint32_t hpll =3D asc->calc_hpll(s, s->regs[AST2600_HPLL_PARAM]); + + return hpll / (SCU_AST1030_CLK_GET_PCLK_DIV(s->regs[AST2600_CLK_SEL4])= + 1) + / asc->apb_divider; +} + static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size) { AspeedSCUState *s =3D ASPEED_SCU(opaque); @@ -482,6 +491,8 @@ static uint32_t aspeed_silicon_revs[] =3D { AST2600_A1_SILICON_REV, AST2600_A2_SILICON_REV, AST2600_A3_SILICON_REV, + AST1030_A0_SILICON_REV, + AST1030_A1_SILICON_REV, }; =20 bool is_supported_silicon_rev(uint32_t silicon_rev) @@ -770,12 +781,64 @@ static const TypeInfo aspeed_2600_scu_info =3D { .class_init =3D aspeed_2600_scu_class_init, }; =20 +static const uint32_t ast1030_a1_resets[ASPEED_AST2600_SCU_NR_REGS] =3D { + [AST2600_SYS_RST_CTRL] =3D 0xFFC3FED8, + [AST2600_SYS_RST_CTRL2] =3D 0x09FFFFFC, + [AST2600_CLK_STOP_CTRL] =3D 0xFFFF7F8A, + [AST2600_CLK_STOP_CTRL2] =3D 0xFFF0FFF0, + [AST2600_DEBUG_CTRL2] =3D 0x00000000, + [AST2600_HPLL_PARAM] =3D 0x10004077, + [AST2600_HPLL_EXT] =3D 0x00000031, + [AST2600_CLK_SEL4] =3D 0x43F90900, + [AST2600_CLK_SEL5] =3D 0x40000000, + [AST2600_CHIP_ID0] =3D 0xDEADBEEF, + [AST2600_CHIP_ID1] =3D 0x0BADCAFE, +}; + +static void aspeed_ast1030_scu_reset(DeviceState *dev) +{ + AspeedSCUState *s =3D ASPEED_SCU(dev); + AspeedSCUClass *asc =3D ASPEED_SCU_GET_CLASS(dev); + + memcpy(s->regs, asc->resets, asc->nr_regs * 4); + + s->regs[AST2600_SILICON_REV] =3D AST1030_A1_SILICON_REV; + s->regs[AST2600_SILICON_REV2] =3D s->silicon_rev; + s->regs[AST2600_HW_STRAP1] =3D s->hw_strap1; + s->regs[AST2600_HW_STRAP2] =3D s->hw_strap2; + s->regs[PROT_KEY] =3D s->hw_prot_key; +} + +static void aspeed_1030_scu_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + AspeedSCUClass *asc =3D ASPEED_SCU_CLASS(klass); + + dc->desc =3D "ASPEED 1030 System Control Unit"; + dc->reset =3D aspeed_ast1030_scu_reset; + asc->resets =3D ast1030_a1_resets; + asc->calc_hpll =3D aspeed_2600_scu_calc_hpll; + asc->get_apb =3D aspeed_1030_scu_get_apb_freq; + asc->apb_divider =3D 2; + asc->nr_regs =3D ASPEED_AST2600_SCU_NR_REGS; + asc->clkin_25Mhz =3D true; + asc->ops =3D &aspeed_ast2600_scu_ops; +} + +static const TypeInfo aspeed_1030_scu_info =3D { + .name =3D TYPE_ASPEED_1030_SCU, + .parent =3D TYPE_ASPEED_SCU, + .instance_size =3D sizeof(AspeedSCUState), + .class_init =3D aspeed_1030_scu_class_init, +}; + static void aspeed_scu_register_types(void) { type_register_static(&aspeed_scu_info); type_register_static(&aspeed_2400_scu_info); type_register_static(&aspeed_2500_scu_info); type_register_static(&aspeed_2600_scu_info); + type_register_static(&aspeed_1030_scu_info); } =20 type_init(aspeed_scu_register_types); diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h index fdc721846c..d71aa66e40 100644 --- a/include/hw/misc/aspeed_scu.h +++ b/include/hw/misc/aspeed_scu.h @@ -19,6 +19,7 @@ OBJECT_DECLARE_TYPE(AspeedSCUState, AspeedSCUClass, ASPEE= D_SCU) #define TYPE_ASPEED_2400_SCU TYPE_ASPEED_SCU "-ast2400" #define TYPE_ASPEED_2500_SCU TYPE_ASPEED_SCU "-ast2500" #define TYPE_ASPEED_2600_SCU TYPE_ASPEED_SCU "-ast2600" +#define TYPE_ASPEED_1030_SCU TYPE_ASPEED_SCU "-ast1030" =20 #define ASPEED_SCU_NR_REGS (0x1A8 >> 2) #define ASPEED_AST2600_SCU_NR_REGS (0xE20 >> 2) @@ -45,6 +46,8 @@ struct AspeedSCUState { #define AST2600_A1_SILICON_REV 0x05010303U #define AST2600_A2_SILICON_REV 0x05020303U #define AST2600_A3_SILICON_REV 0x05030303U +#define AST1030_A0_SILICON_REV 0x80000000U +#define AST1030_A1_SILICON_REV 0x80010000U =20 #define ASPEED_IS_AST2500(si_rev) ((((si_rev) >> 24) & 0xff) =3D=3D 0x= 04) =20 @@ -335,4 +338,26 @@ uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s); #define SCU_AST2600_H_PLL_BYPASS_EN (0x1 << 24) #define SCU_AST2600_H_PLL_OFF (0x1 << 23) =20 +/* + * SCU310 Clock Selection Register Set 4 (for Aspeed AST1030 SOC) + * + * 31 I3C Clock Source selection + * 30:28 I3C clock divider selection + * 26:24 MAC AHB clock divider selection + * 22:20 RGMII 125MHz clock divider ration + * 19:16 RGMII 50MHz clock divider ration + * 15 LHCLK clock generation/output enable control + * 14:12 LHCLK divider selection + * 11:8 APB Bus PCLK divider selection + * 7 Select PECI clock source + * 6 Select UART debug port clock source + * 5 Select UART6 clock source + * 4 Select UART5 clock source + * 3 Select UART4 clock source + * 2 Select UART3 clock source + * 1 Select UART2 clock source + * 0 Select UART1 clock source + */ +#define SCU_AST1030_CLK_GET_PCLK_DIV(x) (((x) >> 8) & 0= xf) + #endif /* ASPEED_SCU_H */ --=20 2.17.1