From nobody Mon May 20 18:24:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1614649830; cv=none; d=zohomail.com; s=zohoarc; b=LEMs3Dj09EGPxtYI/5a8JW2acdxq/VHuJ2CpPQytkCeM7Aju74pAnztXc+fJPirxpeBBHos3PTI5E5KZN6pw9xHp5q6H7U7idz5HsIA1KxCLJJ1nsdf0OSdSv6Jws1M4/rsTT+g0k3lAQZzRO0tHghuDT89LRbyX7Dxxkq6uXuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614649830; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kpPFFjA24ZGThZS1GYY5Tvg8kQFh1t9IdgiwXayB5Vw=; b=G13P1K/EKn9gWVCdFkGNuRouPv0kvi4WLRuq/qrCymmbZyEkGbuGxD49VQsvWb2CeqpU3DflHzurWnHc3QArpGbVRdQcrVPIbuUdTmvCre1L+9i0g/jXRf6C2+YSeBrW0cpvTIFKUTVkN79uQBDOqvXR12AKStv511C9NeWVY3E= ARC-Authentication-Results: i=1; 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 1614649830355477.021254892776; Mon, 1 Mar 2021 17:50:30 -0800 (PST) Received: from localhost ([::1]:39922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGuBB-00075D-C9 for importer@patchew.org; Mon, 01 Mar 2021 20:50:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4i-0002Br-RT; Mon, 01 Mar 2021 20:43:48 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:32909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4X-00021h-0m; Mon, 01 Mar 2021 20:43:48 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 27CE55C00C6; Mon, 1 Mar 2021 20:43:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 01 Mar 2021 20:43:33 -0500 Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id EEF8D240065; Mon, 1 Mar 2021 20:43:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= kpPFFjA24ZGThZS1GYY5Tvg8kQFh1t9IdgiwXayB5Vw=; b=eILslYBrMcjxjVhx AavR0EWix2lDWYbdEpXCg5ji2HhQGNTf9sBzwOJZSHnzgex79FgovP6b6m8Hr/6f 1Z8QtQkXvxuLkWCruPCl3nS/Bf2ptW5sl1qNujcEexG/ymzQGscCVyfrHUuIbtLE QOhUS8JXKEicDIBUzD+vjmEcq6+qm2FiCbFNUDoM7rI9G2KjhzrhI0LUI5SlD2Y/ IgVtfZaTAigiELHwkiB5rsPbGkdaQugozw3MIFj2sAvzrLlt63yzuAv1sJb0Ionm NM5tes/CJI/UR7ZWPAzdd2z9lr9d0Aqa0UWvzU/m7QUV6oFk1tP8unE9vgqDhxA9 pglt1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=kpPFFjA24ZGThZS1GYY5Tvg8kQFh1t9IdgiwXayB5 Vw=; b=iNq8nTS7uHcnd8gAP4QzorXgUeNboGnx4AQ3eaGLkrWqNtwK/RCB8IHc6 WT8IgLVtb3ZxDPW5PvIYH7ApyXltgOa9ghiHE+LGerOWw2CopVOe395mPY65yTcI XLsEg2uvk4iJqri8L/IZm1uPPlviwfQrEn5vjRjBsqm8FH7GBgn0zMX4KDX749jr I2uQf5NT1oCjYIM92WJfcgQsXDiiLBTpXzJPxVZHBWvhvYR7YL+3/yG8qTaTe3fB CfisQ5I5ZIL0vcJK7ePQHd4mdGZ4a7X+YsU8z/xsqY8uOVfMKsFZeGeIJ8hr2oQI vfeOM3RjpG8vd2oKD/vS6f4MF82xQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesthekre dtredtjeenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnheptefhvdethedtgffgvefftedvkeelvd fhvddtjeeukeevvdekjefgtdeifeelgfegnecukfhppedugedrvddrledurdefjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfi esrghjrdhiugdrrghu X-ME-Proxy: From: Andrew Jeffery To: qemu-arm@nongnu.org Subject: [PATCH v3 1/5] hw/arm: ast2600: Force a multiple of 32 of IRQs for the GIC Date: Tue, 2 Mar 2021 12:13:13 +1030 Message-Id: <20210302014317.915120-2-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302014317.915120-1-andrew@aj.id.au> References: <20210302014317.915120-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=andrew@aj.id.au; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ryan_chen@aspeedtech.com, minyard@acm.org, qemu-devel@nongnu.org, f4bug@amsat.org, clg@kaod.org, joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This appears to be a requirement of the GIC model. The AST2600 allocates 197 GIC IRQs, which we will adjust shortly. Signed-off-by: Andrew Jeffery Reviewed-by: C=C3=A9dric Le Goater --- hw/arm/aspeed_ast2600.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index bf31ca351feb..bc0eeb058b24 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -65,7 +65,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] =3D { =20 #define ASPEED_A7MPCORE_ADDR 0x40460000 =20 -#define ASPEED_SOC_AST2600_MAX_IRQ 128 +#define AST2600_MAX_IRQ 128 =20 /* Shared Peripheral Interrupt values below are offset by -32 from datashe= et */ static const int aspeed_soc_ast2600_irqmap[] =3D { @@ -267,7 +267,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", sc->num_cpus, &error_abort); object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", - ASPEED_SOC_AST2600_MAX_IRQ + GIC_INTERNAL, + ROUND_UP(AST2600_MAX_IRQ + GIC_INTERNAL, 32), &error_abort); =20 sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); --=20 2.27.0 From nobody Mon May 20 18:24:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1614649658; cv=none; d=zohomail.com; s=zohoarc; b=Jj4f5Q5jE2wP7n7/USfscagwOhWt+Mg+3kUphjKmAnQKK0bnd02Gvvhvj6tu3PDWqn4DBHX7/BZA/UewNlmq7KXzEGLDXrIRG+roqkHSYK1a+MFxQNyn127Wwj8zQEYT9N3NXKMOcQIHl4sxlRDNviy3C28O3/UKjbSn7mJ4UuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614649658; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AjcWu99zYWM3MFP7FCVoSIVRy3dP2O7AvMfoVzpMjzk=; b=Y8G7yICMweO2C6I6AEc4lqKqVG21Cu26Ifj1WZ+eljdisxZfbXiE2TvIPEIH+gupK8nVxVArTxwIVOPHi+DC76Fa0lQrIQaBXXgIF17t8kJmgOUl3dcy8rY6BQGJsyfm/lscoSTvmnDTWOBeBS7yF2FF8SMJ3QDsv8HXYuH2YUw= ARC-Authentication-Results: i=1; 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 1614649658783586.2743239843838; Mon, 1 Mar 2021 17:47:38 -0800 (PST) Received: from localhost ([::1]:34294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGu8P-0004UH-NE for importer@patchew.org; Mon, 01 Mar 2021 20:47:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4p-0002F5-4z; Mon, 01 Mar 2021 20:43:55 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:36211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4Y-000222-SY; Mon, 01 Mar 2021 20:43:53 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D61C55C0088; Mon, 1 Mar 2021 20:43:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 01 Mar 2021 20:43:37 -0500 Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id 9C91B240065; Mon, 1 Mar 2021 20:43:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= AjcWu99zYWM3MFP7FCVoSIVRy3dP2O7AvMfoVzpMjzk=; b=uyJd9ph0vto5JLC5 Xl736evEsi+0lP/DxHCPdfATYlIKl6rsaclUXZmzJzTqG4BBr+wPu3v7dlzkOJpr JWdDxI29yyDREmubySnrxKbKEJ/Sih3e+LR688d3/HfIhoVN8nvIOZ4pl/HzaQN4 iZGi+2FRb4YYXfOn4Q6RNkVZESO4KY+G0Ii7FfwSP2hTzz7jvv8TgbDt8FZWFNT+ rQMj4OSeVBwVQU2V07aUEV1mSlB9imS4aXs5hlweseL1M4CWphbaWqbFADoE0pgE 8QyJzwui/bdmEeOnEN+WMmky7rbUn9x8rFXx5ArSyxIidUYvOhS5M43uUZY8WZLH edfuiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=AjcWu99zYWM3MFP7FCVoSIVRy3dP2O7AvMfoVzpMj zk=; b=riEPRWoWwvw6Z20BWxy1au+NH9k0tvjAK4b3Oifd/4TBXgVkzHSZ5eUdI dImnUalqXVgN13maSoC3eQN9A41rcuf2LdraTn3H/e78ud3M01K2EiO41I2CUlVT V5vC/G8xVglebgFyg7GR90XhIAXZXY0WKN9tZoxu+N1l7ebzpmxYOAfZdjMH3zS6 IJTiMT90/MGIiquUOuQesrH5lHWjqOS9hVDOGS3DYNKjdb5vttU/uMqjuYgHvlIe j0n2iOwSyisBridH4OQB+Ul2M+RfWdbnI/PHL5PamxoYGBAlO9CO7w/IHvUHDxxZ UMV2GhmXJPWfdLP9pqa6zF2QUqOag== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesthekre dtredtjeenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnheptefhvdethedtgffgvefftedvkeelvd fhvddtjeeukeevvdekjefgtdeifeelgfegnecukfhppedugedrvddrledurdefjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfi esrghjrdhiugdrrghu X-ME-Proxy: From: Andrew Jeffery To: qemu-arm@nongnu.org Subject: [PATCH v3 2/5] hw/arm: ast2600: Set AST2600_MAX_IRQ to value from datasheet Date: Tue, 2 Mar 2021 12:13:14 +1030 Message-Id: <20210302014317.915120-3-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302014317.915120-1-andrew@aj.id.au> References: <20210302014317.915120-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=andrew@aj.id.au; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ryan_chen@aspeedtech.com, minyard@acm.org, qemu-devel@nongnu.org, f4bug@amsat.org, clg@kaod.org, joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The datasheet says we have 197 IRQs allocated, and we need more than 128 to describe IRQs from LPC devices. Raise the value now to allow modelling of the LPC devices. Signed-off-by: Andrew Jeffery Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/arm/aspeed_ast2600.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index bc0eeb058b24..22fcb5b0edbe 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -65,7 +65,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] =3D { =20 #define ASPEED_A7MPCORE_ADDR 0x40460000 =20 -#define AST2600_MAX_IRQ 128 +#define AST2600_MAX_IRQ 197 =20 /* Shared Peripheral Interrupt values below are offset by -32 from datashe= et */ static const int aspeed_soc_ast2600_irqmap[] =3D { --=20 2.27.0 From nobody Mon May 20 18:24:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1614649682; cv=none; d=zohomail.com; s=zohoarc; b=ATN6jZGsd+TnODEaQHSQta4vQc7ILtRDMNkEB5lPrNSrQrCIkFStH02h47zHhcFQLvN9dwD/+pKIVCnTTTkuYgtLI8In9k7VY9p4973lh1cNOPimUEdvCp6QEvfFbohuilDVR+KWlY+SmHq951gwyQcX3HNtpz/FnqtYiR3Ksyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614649682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qwz5vS0eVntfRCjzEGyKDEX/ntnbNpeqXmp68NIOYNQ=; b=NZ9Y2zUrq8wkQ6K0RbLkZcm64mEi4p0hSF5d8n42tTLu1ypupP7pAqAD2pOFq2q+Q6YnYiy2YTd3U6RKbkbRDAgXokDqMgRqLixmw2oKiAD+9ksyh3611os6fHnd3S/PjBg9qfs23OPKF7xywk5DzBPD9WkfSl142Av/E6Qp7go= ARC-Authentication-Results: i=1; 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 161464968275985.8867703079286; Mon, 1 Mar 2021 17:48:02 -0800 (PST) Received: from localhost ([::1]:35084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGu8n-0004o7-MZ for importer@patchew.org; Mon, 01 Mar 2021 20:48:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4q-0002HI-2u; Mon, 01 Mar 2021 20:43:56 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:48637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4b-00022J-Je; Mon, 01 Mar 2021 20:43:55 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6211A5C009C; Mon, 1 Mar 2021 20:43:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 01 Mar 2021 20:43:40 -0500 Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id 38758240057; Mon, 1 Mar 2021 20:43:36 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= Qwz5vS0eVntfRCjzEGyKDEX/ntnbNpeqXmp68NIOYNQ=; b=DeZaEm05Yae/NDeB hg9BUm78tGufR3clBIPFqxHTulmYdPmm2Ky4pcOJ66tUi5XU46RsiRTcchawHsVx uU17XN4eKAKUnwLiMnrWTBhcMSKuilYVFp3Fqw/V+VrCENugxUdxcGlzL49Ue2b/ mAEx8B3DZkwe2ZhBiHBNkdgPbGf5cq2z3ufzY+5NQxHwJTeqaNvGT4YKEWm515Cp lwEGLXJca3poKUOua4ygvp1KoSFijW7Mzp86CixnnpYFMxCMVSDxzrr0i6xGTion jQYCEHaXSNfVAul588Vl7JPxsUiNEUjpNzJOKCECSXeVAZ7uDkUW3uOW3utcrFrm ZFKU3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Qwz5vS0eVntfRCjzEGyKDEX/ntnbNpeqXmp68NIOY NQ=; b=k15XHDtBZBI8v0Yb8UeU970Nz7Uo6xebKsWKS2gmRG/bcB8KgRh6QpFGd k28J2UFo0+YSTcplsxS+uqN4dLWxqvwdqYjxPytzxYwi/r/cLE02zWW3JBhm3OnU wvcjCvKpbp6BMvknvQiLCiHWDnk8RhX6Lv2Vxg+5/u2Tf5EL6RU7YOE4avlBGu2+ uLBWuXbIegoOWyXVHjpRxj+cRxekzlZqItsdtkFdr2hcMIScwG5mIwrlfGz8n8Uc hP4glVYtliKeAnpdhS5OggeibEQxqFMsbnAF5MAoa/XQqNjB8DNE/fh1cQPLCu0J fOcCSkMwJgtdrAn11d4nc/2WnOU+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesthekre dtredtjeenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnheptefhvdethedtgffgvefftedvkeelvd fhvddtjeeukeevvdekjefgtdeifeelgfegnecukfhppedugedrvddrledurdefjeenucev lhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfi esrghjrdhiugdrrghu X-ME-Proxy: From: Andrew Jeffery To: qemu-arm@nongnu.org Subject: [PATCH v3 3/5] hw/arm: ast2600: Correct the iBT interrupt ID Date: Tue, 2 Mar 2021 12:13:15 +1030 Message-Id: <20210302014317.915120-4-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302014317.915120-1-andrew@aj.id.au> References: <20210302014317.915120-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=andrew@aj.id.au; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ryan_chen@aspeedtech.com, minyard@acm.org, qemu-devel@nongnu.org, f4bug@amsat.org, clg@kaod.org, joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The AST2600 allocates distinct GIC IRQs for the LPC subdevices such as the iBT device. Previously on the AST2400 and AST2500 the LPC subdevices shared a single LPC IRQ. Signed-off-by: Andrew Jeffery Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/arm/aspeed_ast2600.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index 22fcb5b0edbe..2125a96ef317 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -98,7 +98,7 @@ static const int aspeed_soc_ast2600_irqmap[] =3D { [ASPEED_DEV_WDT] =3D 24, [ASPEED_DEV_PWM] =3D 44, [ASPEED_DEV_LPC] =3D 35, - [ASPEED_DEV_IBT] =3D 35, /* LPC */ + [ASPEED_DEV_IBT] =3D 143, [ASPEED_DEV_I2C] =3D 110, /* 110 -> 125 */ [ASPEED_DEV_ETH1] =3D 2, [ASPEED_DEV_ETH2] =3D 3, --=20 2.27.0 From nobody Mon May 20 18:24:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1614649880; cv=none; d=zohomail.com; s=zohoarc; b=YcUzH6ApJfkTYjw4g0QlmUy39HQEi9ik7ip4inb+zcx3/ews4u92KH0JxFYQrfWdwaJ1R3HoUIXrmyR2Lg/ExG82zol1SJoi421/2p/mznAeekuoSNcEL4uK+rUS+G6ad1yMezH4sorPsjC8bG2IWWigJCAIMFeAHLI5Cmz1JuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614649880; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GvVLz9Ew2z/x3kAzwBKi2Krr2lhTc1EirivJxoMp6Yc=; b=E6fcZ2lNYJGbBJh3Lbxrs+fYBmoFjJ1MAZ06EvogGI1VH7ck0qYs/Fk9T4u6NwbvHMSFRarbGo6U1qBR6FOwt30iJ0QDgpIebrxM1R3Xo65DQXBEGixFkqnY71eJBN8tNTitt2Y/MrlK2HJ1tAKH6zNKkXlXzFxNMHF/cL68Eos= ARC-Authentication-Results: i=1; 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 1614649880454877.438651221515; Mon, 1 Mar 2021 17:51:20 -0800 (PST) Received: from localhost ([::1]:41292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGuBz-0007k1-CJ for importer@patchew.org; Mon, 01 Mar 2021 20:51:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4s-0002Lt-9C; Mon, 01 Mar 2021 20:43:58 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:45095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4e-00023x-UV; Mon, 01 Mar 2021 20:43:58 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 279045C00F8; Mon, 1 Mar 2021 20:43:44 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 01 Mar 2021 20:43:44 -0500 Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id DFF3224005A; Mon, 1 Mar 2021 20:43:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= GvVLz9Ew2z/x3kAzwBKi2Krr2lhTc1EirivJxoMp6Yc=; b=ixVZcrRL+h5thZq/ k661zsX6KZ8Ljj00Ma+cNJwlT9+mJ61hJA5Q0G7T7KtjMBn+Mfk45LPuoTKd15Rz 3AHVsV0h/0S8rgP5ZyWovfNFEC9XtuY0n29Tve11ah1K90QGh3HE0K7h+KmMgx/2 rwzwYJRD+Ke4bFwSqpeykRG5kLmfMnsowQEsBfAlNeiwDAjZBYSD2uY1JyjMnKZJ 7qHhcVF/HdLmc4nlJdu19QmS1p0PKrdRlwLmx72fYTpM84f9A/3Gbm7yDMXWqm9o 8XVtlWW4JYZzZnHV4RcbcdidAPtKRj+cjUW8EB79NozD5+X8WClgMvIQQs1TcBed eOtLIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=GvVLz9Ew2z/x3kAzwBKi2Krr2lhTc1EirivJxoMp6 Yc=; b=MNe3oSOCd4lqH6xxCRJtcg4o9L22c695ykyo9FlqB9/Fyqf9MvWs1PUDg hgy+H142XrFXBtpt3XKFE8A/5oqqMt9AmuaqOfSLGjr7NpqMUU3J0Vc3s5tdKhFd 7GuNe1NJenzJmxO9HFc4ltRczKNn/DAGkkHR/UiIDK79u9SL09lm91pp0+5iVs0L DDoFvVjvhpTZM5S7N3/rbOUNlqEKlLDr2hRz8ARlQ4PqY4tkPKECCggylTRdcQ3r adqxKTOpjXOcoIMG2is/asYbtcHeydnq5iCV40Qg6CvH1mStecsB4f+dRJcgiWvO qsuSBg9Qr66S6l08I/gOPtCk1KRPg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesthekre dtredtjeenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnheptefhvdethedtgffgvefftedvkeelvd fhvddtjeeukeevvdekjefgtdeifeelgfegnecukfhppedugedrvddrledurdefjeenucev lhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfi esrghjrdhiugdrrghu X-ME-Proxy: From: Andrew Jeffery To: qemu-arm@nongnu.org Subject: [PATCH v3 4/5] hw/misc: Add a basic Aspeed LPC controller model Date: Tue, 2 Mar 2021 12:13:16 +1030 Message-Id: <20210302014317.915120-5-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302014317.915120-1-andrew@aj.id.au> References: <20210302014317.915120-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=andrew@aj.id.au; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ryan_chen@aspeedtech.com, minyard@acm.org, qemu-devel@nongnu.org, f4bug@amsat.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: C=C3=A9dric Le Goater This is a very minimal framework to access registers which are used to configure the AHB memory mapping of the flash chips on the LPC HC Firmware address space. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Andrew Jeffery --- docs/system/arm/aspeed.rst | 2 +- hw/arm/aspeed_ast2600.c | 10 +++ hw/arm/aspeed_soc.c | 10 +++ hw/misc/aspeed_lpc.c | 131 +++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 7 +- include/hw/arm/aspeed_soc.h | 2 + include/hw/misc/aspeed_lpc.h | 32 +++++++++ 7 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 hw/misc/aspeed_lpc.c create mode 100644 include/hw/misc/aspeed_lpc.h diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst index 690bada7842b..2f6fa8938d02 100644 --- a/docs/system/arm/aspeed.rst +++ b/docs/system/arm/aspeed.rst @@ -48,6 +48,7 @@ Supported devices * UART * Ethernet controllers * Front LEDs (PCA9552 on I2C bus) + * LPC Peripheral Controller (a subset of subdevices are supported) =20 =20 Missing devices @@ -56,7 +57,6 @@ Missing devices * Coprocessor support * ADC (out of tree implementation) * PWM and Fan Controller - * LPC Bus Controller * Slave GPIO Controller * Super I/O Controller * Hash/Crypto Engine diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index 2125a96ef317..5a7b8ba81c92 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -211,6 +211,8 @@ static void aspeed_soc_ast2600_init(Object *obj) =20 object_initialize_child(obj, "emmc-controller.sdhci", &s->emmc.slots[0= ], TYPE_SYSBUS_SDHCI); + + object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC); } =20 /* @@ -469,6 +471,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *de= v, Error **errp) sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_DEV_EMM= C]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_EMMC)); + + /* LPC */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, + aspeed_soc_get_irq(s, ASPEED_DEV_LPC)); } =20 static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 7eefd54ac07a..4f098da437ac 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -211,6 +211,8 @@ static void aspeed_soc_init(Object *obj) object_initialize_child(obj, "sdhci[*]", &s->sdhci.slots[i], TYPE_SYSBUS_SDHCI); } + + object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC); } =20 static void aspeed_soc_realize(DeviceState *dev, Error **errp) @@ -393,6 +395,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error= **errp) sc->memmap[ASPEED_DEV_SDHCI]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); + + /* LPC */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, + aspeed_soc_get_irq(s, ASPEED_DEV_LPC)); } static Property aspeed_soc_properties[] =3D { DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, diff --git a/hw/misc/aspeed_lpc.c b/hw/misc/aspeed_lpc.c new file mode 100644 index 000000000000..e668e985ff04 --- /dev/null +++ b/hw/misc/aspeed_lpc.c @@ -0,0 +1,131 @@ +/* + * ASPEED LPC Controller + * + * Copyright (C) 2017-2018 IBM Corp. + * + * This code is licensed under the GPL version 2 or later. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/error-report.h" +#include "hw/misc/aspeed_lpc.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" + +#define TO_REG(offset) ((offset) >> 2) + +#define HICR0 TO_REG(0x00) +#define HICR1 TO_REG(0x04) +#define HICR2 TO_REG(0x08) +#define HICR3 TO_REG(0x0C) +#define HICR4 TO_REG(0x10) +#define HICR5 TO_REG(0x80) +#define HICR6 TO_REG(0x84) +#define HICR7 TO_REG(0x88) +#define HICR8 TO_REG(0x8C) + +static uint64_t aspeed_lpc_read(void *opaque, hwaddr offset, unsigned size) +{ + AspeedLPCState *s =3D ASPEED_LPC(opaque); + int reg =3D TO_REG(offset); + + if (reg >=3D ARRAY_SIZE(s->regs)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Out-of-bounds read at offset 0x%" HWADDR_PRIx "= \n", + __func__, offset); + return 0; + } + + return s->regs[reg]; +} + +static void aspeed_lpc_write(void *opaque, hwaddr offset, uint64_t data, + unsigned int size) +{ + AspeedLPCState *s =3D ASPEED_LPC(opaque); + int reg =3D TO_REG(offset); + + if (reg >=3D ARRAY_SIZE(s->regs)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx = "\n", + __func__, offset); + return; + } + + s->regs[reg] =3D data; +} + +static const MemoryRegionOps aspeed_lpc_ops =3D { + .read =3D aspeed_lpc_read, + .write =3D aspeed_lpc_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, +}; + +static void aspeed_lpc_reset(DeviceState *dev) +{ + struct AspeedLPCState *s =3D ASPEED_LPC(dev); + + memset(s->regs, 0, sizeof(s->regs)); + + s->regs[HICR7] =3D s->hicr7; +} + +static void aspeed_lpc_realize(DeviceState *dev, Error **errp) +{ + AspeedLPCState *s =3D ASPEED_LPC(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + + sysbus_init_irq(sbd, &s->irq); + + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_lpc_ops, s, + TYPE_ASPEED_LPC, 0x1000); + + sysbus_init_mmio(sbd, &s->iomem); +} + +static const VMStateDescription vmstate_aspeed_lpc =3D { + .name =3D TYPE_ASPEED_LPC, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, AspeedLPCState, ASPEED_LPC_NR_REGS), + VMSTATE_END_OF_LIST(), + } +}; + +static Property aspeed_lpc_properties[] =3D { + DEFINE_PROP_UINT32("hicr7", AspeedLPCState, hicr7, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void aspeed_lpc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D aspeed_lpc_realize; + dc->reset =3D aspeed_lpc_reset; + dc->desc =3D "Aspeed LPC Controller", + dc->vmsd =3D &vmstate_aspeed_lpc; + device_class_set_props(dc, aspeed_lpc_properties); +} + +static const TypeInfo aspeed_lpc_info =3D { + .name =3D TYPE_ASPEED_LPC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(AspeedLPCState), + .class_init =3D aspeed_lpc_class_init, +}; + +static void aspeed_lpc_register_types(void) +{ + type_register_static(&aspeed_lpc_info); +} + +type_init(aspeed_lpc_register_types); diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 629283957fcc..e3263383cd59 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -102,7 +102,12 @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: fil= es('armsse-mhu.c')) softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) -softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', '= aspeed_sdmc.c', 'aspeed_xdma.c')) +softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( + 'aspeed_lpc.c', + 'aspeed_scu.c', + 'aspeed_sdmc.c', + 'aspeed_xdma.c')) + softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_rng.c')) =20 diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 11cfe6e3585b..42c64bd28ba2 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -28,6 +28,7 @@ #include "hw/sd/aspeed_sdhci.h" #include "hw/usb/hcd-ehci.h" #include "qom/object.h" +#include "hw/misc/aspeed_lpc.h" =20 #define ASPEED_SPIS_NUM 2 #define ASPEED_EHCIS_NUM 2 @@ -61,6 +62,7 @@ struct AspeedSoCState { AspeedGPIOState gpio_1_8v; AspeedSDHCIState sdhci; AspeedSDHCIState emmc; + AspeedLPCState lpc; }; =20 #define TYPE_ASPEED_SOC "aspeed-soc" diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h new file mode 100644 index 000000000000..0fbb7f68bed2 --- /dev/null +++ b/include/hw/misc/aspeed_lpc.h @@ -0,0 +1,32 @@ +/* + * ASPEED LPC Controller + * + * Copyright (C) 2017-2018 IBM Corp. + * + * This code is licensed under the GPL version 2 or later. See + * the COPYING file in the top-level directory. + */ + +#ifndef ASPEED_LPC_H +#define ASPEED_LPC_H + +#include "hw/sysbus.h" + +#define TYPE_ASPEED_LPC "aspeed.lpc" +#define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LP= C) + +#define ASPEED_LPC_NR_REGS (0x260 >> 2) + +typedef struct AspeedLPCState { + /* */ + SysBusDevice parent; + + /*< public >*/ + MemoryRegion iomem; + qemu_irq irq; + + uint32_t regs[ASPEED_LPC_NR_REGS]; + uint32_t hicr7; +} AspeedLPCState; + +#endif /* _ASPEED_LPC_H_ */ --=20 2.27.0 From nobody Mon May 20 18:24:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1614649964; cv=none; d=zohomail.com; s=zohoarc; b=lDb8eJxjV3aZfYUiBlJTIRXWQFKvjqAPIG19qytIjYnuUWsjOlIXDq0QEWXczmtrPlfwCXKgwfbOvvEMGmFXI5noyrvqwOaYhZMBQeh8UQU68UZz58TNkUggKA7wHBM8+xPgShUZ1MBfJTagEZUlblxNZiaoCiDgLtTlrDkXklc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614649964; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FVcvz7TWnB3xIDYYAgP5J/nTND+a76bP79lTBcshBIo=; b=BHdehXSMCIaEJPjIf0jch/5jyBF7t5Yj0HgqAPKLaCGC94vt3aAC63xWXTUQx125kYLbIT/hKDuEr2acma9OpHzXyQAvlvzjaYPk+2rifoyEa3qxz8+7nqYnk2TMKmKi0Cd6RTUO70JN8lTb3S/CsfH8YAGtJ4+mKc0IpTUtjjA= ARC-Authentication-Results: i=1; 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 1614649964911768.8126986049257; Mon, 1 Mar 2021 17:52:44 -0800 (PST) Received: from localhost ([::1]:43944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGuDL-0000Wa-G1 for importer@patchew.org; Mon, 01 Mar 2021 20:52:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4s-0002Na-T4; Mon, 01 Mar 2021 20:43:58 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:60779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGu4i-00024a-T8; Mon, 01 Mar 2021 20:43:58 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 2D6285C00D5; Mon, 1 Mar 2021 20:43:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 01 Mar 2021 20:43:48 -0500 Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id A3EFC24005A; Mon, 1 Mar 2021 20:43:44 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= FVcvz7TWnB3xIDYYAgP5J/nTND+a76bP79lTBcshBIo=; b=O8kLm/PMSLsOcH0M KC6rOGj/jIJZCARqmhKE/Qdcu8ppfGDbI0OpSk65+aF8LrzHnLzDKMYNqk+b8QaE 0Liap+5ZK5zN8cyz8TTi2Hx44EndnojKq4eFAMVsY+3s85ulIQMMqmEpa2TigRoJ gsxebJOVyYelFhkFLGogLdWnrjB0MwELbWqaaPX97yVjOJ1boA+f7/uvIVeQEIBD tKKBa4Zq+IlYLGaVYdo2mXRpOdWzTTRjK2EIFY+GOIqN9yKeILse90T7YWmsyuxH u8xGN18jjB5p+QB7bCvLkp5A3TXDe7EPnPb0+yzPpPVI0qAIDDTlbvzmK4TqGKIv wwjihw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=FVcvz7TWnB3xIDYYAgP5J/nTND+a76bP79lTBcshB Io=; b=wNQkoy5s8GPu7ySE2pJMs+gsuBOf3cHf0IbCB+uw8Bwl13cWjEPiFCSe2 kX562OjiAsdxTZ8HvsKBPkWTzavMODYa5Izmgp1J2Z7xdRgKb8nk/HiYs3ZnwWGw 9348xkO166uhBNhpzUK7+H5ltJtonjBInGiEynwjIVnSfhCELSEbxa6W20+XG3cr e+RfwnYRFDVwugsBJ7FYZfOBT3GbZjd38DgOT4omzwbvQ88OHggo0ZjyUCNnzQU7 AW/YgqtirlHwskAus4dyuR+k4046MlNsnq1K11y6lzYJLe0J5RnVEAwgNg4S8SFh jxZlI+7l7u5AOwxeoTHkj5o6Y43Xw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesthekre dtredtjeenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnheptefhvdethedtgffgvefftedvkeelvd fhvddtjeeukeevvdekjefgtdeifeelgfegnecukfhppedugedrvddrledurdefjeenucev lhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfi esrghjrdhiugdrrghu X-ME-Proxy: From: Andrew Jeffery To: qemu-arm@nongnu.org Subject: [PATCH v3 5/5] hw/misc: Model KCS devices in the Aspeed LPC controller Date: Tue, 2 Mar 2021 12:13:17 +1030 Message-Id: <20210302014317.915120-6-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210302014317.915120-1-andrew@aj.id.au> References: <20210302014317.915120-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=andrew@aj.id.au; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ryan_chen@aspeedtech.com, minyard@acm.org, qemu-devel@nongnu.org, f4bug@amsat.org, clg@kaod.org, joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Keyboard-Controller-Style devices for IPMI purposes are exposed via LPC IO cycles from the BMC to the host. Expose support on the BMC side by implementing the usual MMIO behaviours, and expose the ability to inspect the KCS registers in "host" style by accessing QOM properties associated with each register. The model caters to the IRQ style of both the AST2600 and the earlier SoCs (AST2400 and AST2500). The AST2600 allocates an IRQ for each LPC sub-device, while there is a single IRQ shared across all subdevices on the AST2400 and AST2500. Signed-off-by: Andrew Jeffery Reviewed-by: C=C3=A9dric Le Goater --- hw/arm/aspeed_ast2600.c | 28 ++- hw/arm/aspeed_soc.c | 24 ++- hw/misc/aspeed_lpc.c | 359 ++++++++++++++++++++++++++++++++++- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_lpc.h | 17 +- 5 files changed, 424 insertions(+), 5 deletions(-) diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index 5a7b8ba81c92..4f83097e4a26 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -104,7 +104,7 @@ static const int aspeed_soc_ast2600_irqmap[] =3D { [ASPEED_DEV_ETH2] =3D 3, [ASPEED_DEV_ETH3] =3D 32, [ASPEED_DEV_ETH4] =3D 33, - + [ASPEED_DEV_KCS] =3D 138, /* 138 -> 142 */ }; =20 static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl) @@ -477,8 +477,34 @@ static void aspeed_soc_ast2600_realize(DeviceState *de= v, Error **errp) return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]= ); + + /* Connect the LPC IRQ to the GIC. It is otherwise unused. */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_LPC)); + + /* + * On the AST2600 LPC subdevice IRQs are connected straight to the GIC. + * + * LPC subdevice IRQ sources are offset from 1 because the LPC model c= aters + * to the AST2400 and AST2500. SoCs before the AST2600 have one LPC IRQ + * shared across the subdevices, and the shared IRQ output to the VIC = is at + * offset 0. + */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1, + qdev_get_gpio_in(DEVICE(&s->a7mpcore), + sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kc= s_1)); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2, + qdev_get_gpio_in(DEVICE(&s->a7mpcore), + sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kc= s_2)); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3, + qdev_get_gpio_in(DEVICE(&s->a7mpcore), + sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kc= s_3)); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4, + qdev_get_gpio_in(DEVICE(&s->a7mpcore), + sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kc= s_4)); } =20 static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 4f098da437ac..057d053c8478 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -112,7 +112,6 @@ static const int aspeed_soc_ast2400_irqmap[] =3D { [ASPEED_DEV_WDT] =3D 27, [ASPEED_DEV_PWM] =3D 28, [ASPEED_DEV_LPC] =3D 8, - [ASPEED_DEV_IBT] =3D 8, /* LPC */ [ASPEED_DEV_I2C] =3D 12, [ASPEED_DEV_ETH1] =3D 2, [ASPEED_DEV_ETH2] =3D 3, @@ -401,8 +400,31 @@ static void aspeed_soc_realize(DeviceState *dev, Error= **errp) return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]= ); + + /* Connect the LPC IRQ to the VIC */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_LPC)); + + /* + * On the AST2400 and AST2500 the one LPC IRQ is shared between all of= the + * subdevices. Connect the LPC subdevice IRQs to the LPC controller IR= Q (by + * contrast, on the AST2600, the subdevice IRQs are connected straight= to + * the GIC). + * + * LPC subdevice IRQ sources are offset from 1 because the shared IRQ = output + * to the VIC is at offset 0. + */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1, + qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_1)= ); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2, + qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_2)= ); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3, + qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_3)= ); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4, + qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_4)= ); } static Property aspeed_soc_properties[] =3D { DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, diff --git a/hw/misc/aspeed_lpc.c b/hw/misc/aspeed_lpc.c index e668e985ff04..2dddb27c35d0 100644 --- a/hw/misc/aspeed_lpc.c +++ b/hw/misc/aspeed_lpc.c @@ -12,20 +12,301 @@ #include "qemu/error-report.h" #include "hw/misc/aspeed_lpc.h" #include "qapi/error.h" +#include "qapi/visitor.h" +#include "hw/irq.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" =20 #define TO_REG(offset) ((offset) >> 2) =20 #define HICR0 TO_REG(0x00) +#define HICR0_LPC3E BIT(7) +#define HICR0_LPC2E BIT(6) +#define HICR0_LPC1E BIT(5) #define HICR1 TO_REG(0x04) #define HICR2 TO_REG(0x08) +#define HICR2_IBFIE3 BIT(3) +#define HICR2_IBFIE2 BIT(2) +#define HICR2_IBFIE1 BIT(1) #define HICR3 TO_REG(0x0C) #define HICR4 TO_REG(0x10) +#define HICR4_KCSENBL BIT(2) +#define IDR1 TO_REG(0x24) +#define IDR2 TO_REG(0x28) +#define IDR3 TO_REG(0x2C) +#define ODR1 TO_REG(0x30) +#define ODR2 TO_REG(0x34) +#define ODR3 TO_REG(0x38) +#define STR1 TO_REG(0x3C) +#define STR_OBF BIT(0) +#define STR_IBF BIT(1) +#define STR_CMD_DATA BIT(3) +#define STR2 TO_REG(0x40) +#define STR3 TO_REG(0x44) #define HICR5 TO_REG(0x80) #define HICR6 TO_REG(0x84) #define HICR7 TO_REG(0x88) #define HICR8 TO_REG(0x8C) +#define HICRB TO_REG(0x100) +#define HICRB_IBFIE4 BIT(1) +#define HICRB_LPC4E BIT(0) +#define IDR4 TO_REG(0x114) +#define ODR4 TO_REG(0x118) +#define STR4 TO_REG(0x11C) + +enum aspeed_kcs_channel_id { + kcs_channel_1 =3D 0, + kcs_channel_2, + kcs_channel_3, + kcs_channel_4, +}; + +static const enum aspeed_lpc_subdevice aspeed_kcs_subdevice_map[] =3D { + [kcs_channel_1] =3D aspeed_lpc_kcs_1, + [kcs_channel_2] =3D aspeed_lpc_kcs_2, + [kcs_channel_3] =3D aspeed_lpc_kcs_3, + [kcs_channel_4] =3D aspeed_lpc_kcs_4, +}; + +struct aspeed_kcs_channel { + enum aspeed_kcs_channel_id id; + + int idr; + int odr; + int str; +}; + +static const struct aspeed_kcs_channel aspeed_kcs_channel_map[] =3D { + [kcs_channel_1] =3D { + .id =3D kcs_channel_1, + .idr =3D IDR1, + .odr =3D ODR1, + .str =3D STR1 + }, + + [kcs_channel_2] =3D { + .id =3D kcs_channel_2, + .idr =3D IDR2, + .odr =3D ODR2, + .str =3D STR2 + }, + + [kcs_channel_3] =3D { + .id =3D kcs_channel_3, + .idr =3D IDR3, + .odr =3D ODR3, + .str =3D STR3 + }, + + [kcs_channel_4] =3D { + .id =3D kcs_channel_4, + .idr =3D IDR4, + .odr =3D ODR4, + .str =3D STR4 + }, +}; + +struct aspeed_kcs_register_data { + const char *name; + int reg; + const struct aspeed_kcs_channel *chan; +}; + +static const struct aspeed_kcs_register_data aspeed_kcs_registers[] =3D { + { + .name =3D "idr1", + .reg =3D IDR1, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_1], + }, + { + .name =3D "odr1", + .reg =3D ODR1, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_1], + }, + { + .name =3D "str1", + .reg =3D STR1, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_1], + }, + { + .name =3D "idr2", + .reg =3D IDR2, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_2], + }, + { + .name =3D "odr2", + .reg =3D ODR2, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_2], + }, + { + .name =3D "str2", + .reg =3D STR2, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_2], + }, + { + .name =3D "idr3", + .reg =3D IDR3, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_3], + }, + { + .name =3D "odr3", + .reg =3D ODR3, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_3], + }, + { + .name =3D "str3", + .reg =3D STR3, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_3], + }, + { + .name =3D "idr4", + .reg =3D IDR4, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_4], + }, + { + .name =3D "odr4", + .reg =3D ODR4, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_4], + }, + { + .name =3D "str4", + .reg =3D STR4, + .chan =3D &aspeed_kcs_channel_map[kcs_channel_4], + }, + { }, +}; + +static const struct aspeed_kcs_register_data * +aspeed_kcs_get_register_data_by_name(const char *name) +{ + const struct aspeed_kcs_register_data *pos =3D aspeed_kcs_registers; + + while (pos->name) { + if (!strcmp(pos->name, name)) { + return pos; + } + pos++; + } + + return NULL; +} + +static const struct aspeed_kcs_channel * +aspeed_kcs_get_channel_by_register(int reg) +{ + const struct aspeed_kcs_register_data *pos =3D aspeed_kcs_registers; + + while (pos->name) { + if (pos->reg =3D=3D reg) { + return pos->chan; + } + pos++; + } + + return NULL; +} + +static void aspeed_kcs_get_register_property(Object *obj, + Visitor *v, + const char *name, + void *opaque, + Error **errp) +{ + const struct aspeed_kcs_register_data *data; + AspeedLPCState *s =3D ASPEED_LPC(obj); + uint32_t val; + + data =3D aspeed_kcs_get_register_data_by_name(name); + if (!data) { + return; + } + + if (!strncmp("odr", name, 3)) { + s->regs[data->chan->str] &=3D ~STR_OBF; + } + + val =3D s->regs[data->reg]; + + visit_type_uint32(v, name, &val, errp); +} + +static bool aspeed_kcs_channel_enabled(AspeedLPCState *s, + const struct aspeed_kcs_channel *ch= annel) +{ + switch (channel->id) { + case kcs_channel_1: return s->regs[HICR0] & HICR0_LPC1E; + case kcs_channel_2: return s->regs[HICR0] & HICR0_LPC2E; + case kcs_channel_3: + return (s->regs[HICR0] & HICR0_LPC3E) && + (s->regs[HICR4] & HICR4_KCSENBL); + case kcs_channel_4: return s->regs[HICRB] & HICRB_LPC4E; + default: return false; + } +} + +static bool +aspeed_kcs_channel_ibf_irq_enabled(AspeedLPCState *s, + const struct aspeed_kcs_channel *channe= l) +{ + if (!aspeed_kcs_channel_enabled(s, channel)) { + return false; + } + + switch (channel->id) { + case kcs_channel_1: return s->regs[HICR2] & HICR2_IBFIE1; + case kcs_channel_2: return s->regs[HICR2] & HICR2_IBFIE2; + case kcs_channel_3: return s->regs[HICR2] & HICR2_IBFIE3; + case kcs_channel_4: return s->regs[HICRB] & HICRB_IBFIE4; + default: return false; + } +} + +static void aspeed_kcs_set_register_property(Object *obj, + Visitor *v, + const char *name, + void *opaque, + Error **errp) +{ + const struct aspeed_kcs_register_data *data; + AspeedLPCState *s =3D ASPEED_LPC(obj); + uint32_t val; + + data =3D aspeed_kcs_get_register_data_by_name(name); + if (!data) { + return; + } + + if (!visit_type_uint32(v, name, &val, errp)) { + return; + } + + if (strncmp("str", name, 3)) { + s->regs[data->reg] =3D val; + } + + if (!strncmp("idr", name, 3)) { + s->regs[data->chan->str] |=3D STR_IBF; + if (aspeed_kcs_channel_ibf_irq_enabled(s, data->chan)) { + enum aspeed_lpc_subdevice subdev; + + subdev =3D aspeed_kcs_subdevice_map[data->chan->id]; + qemu_irq_raise(s->subdevice_irqs[subdev]); + } + } +} + +static void aspeed_lpc_set_irq(void *opaque, int irq, int level) +{ + AspeedLPCState *s =3D (AspeedLPCState *)opaque; + + if (level) { + s->subdevice_irqs_pending |=3D BIT(irq); + } else { + s->subdevice_irqs_pending &=3D ~BIT(irq); + } + + qemu_set_irq(s->irq, !!s->subdevice_irqs_pending); +} =20 static uint64_t aspeed_lpc_read(void *opaque, hwaddr offset, unsigned size) { @@ -39,6 +320,29 @@ static uint64_t aspeed_lpc_read(void *opaque, hwaddr of= fset, unsigned size) return 0; } =20 + switch (reg) { + case IDR1: + case IDR2: + case IDR3: + case IDR4: + { + const struct aspeed_kcs_channel *channel; + + channel =3D aspeed_kcs_get_channel_by_register(reg); + if (s->regs[channel->str] & STR_IBF) { + enum aspeed_lpc_subdevice subdev; + + subdev =3D aspeed_kcs_subdevice_map[channel->id]; + qemu_irq_lower(s->subdevice_irqs[subdev]); + } + + s->regs[channel->str] &=3D ~STR_IBF; + break; + } + default: + break; + } + return s->regs[reg]; } =20 @@ -55,6 +359,18 @@ static void aspeed_lpc_write(void *opaque, hwaddr offse= t, uint64_t data, return; } =20 + + switch (reg) { + case ODR1: + case ODR2: + case ODR3: + case ODR4: + s->regs[aspeed_kcs_get_channel_by_register(reg)->str] |=3D STR_OBF; + break; + default: + break; + } + s->regs[reg] =3D data; } =20 @@ -72,6 +388,8 @@ static void aspeed_lpc_reset(DeviceState *dev) { struct AspeedLPCState *s =3D ASPEED_LPC(dev); =20 + s->subdevice_irqs_pending =3D 0; + memset(s->regs, 0, sizeof(s->regs)); =20 s->regs[HICR7] =3D s->hicr7; @@ -83,19 +401,55 @@ static void aspeed_lpc_realize(DeviceState *dev, Error= **errp) SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); =20 sysbus_init_irq(sbd, &s->irq); + sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_1]); + sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_2]); + sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_3]); + sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_4]); + sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_ibt]); =20 memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_lpc_ops, s, TYPE_ASPEED_LPC, 0x1000); =20 sysbus_init_mmio(sbd, &s->iomem); + + qdev_init_gpio_in(dev, aspeed_lpc_set_irq, ASPEED_LPC_NR_SUBDEVS); +} + +static void aspeed_lpc_init(Object *obj) +{ + object_property_add(obj, "idr1", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "odr1", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "str1", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "idr2", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "odr2", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "str2", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "idr3", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "odr3", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "str3", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "idr4", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "odr4", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); + object_property_add(obj, "str4", "uint32", aspeed_kcs_get_register_pro= perty, + aspeed_kcs_set_register_property, NULL, NULL); } =20 static const VMStateDescription vmstate_aspeed_lpc =3D { .name =3D TYPE_ASPEED_LPC, - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_UINT32_ARRAY(regs, AspeedLPCState, ASPEED_LPC_NR_REGS), + VMSTATE_UINT32(subdevice_irqs_pending, AspeedLPCState), VMSTATE_END_OF_LIST(), } }; @@ -121,6 +475,7 @@ static const TypeInfo aspeed_lpc_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(AspeedLPCState), .class_init =3D aspeed_lpc_class_init, + .instance_init =3D aspeed_lpc_init, }; =20 static void aspeed_lpc_register_types(void) diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 42c64bd28ba2..9359d6da336d 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -132,6 +132,7 @@ enum { ASPEED_DEV_SDRAM, ASPEED_DEV_XDMA, ASPEED_DEV_EMMC, + ASPEED_DEV_KCS, }; =20 #endif /* ASPEED_SOC_H */ diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h index 0fbb7f68bed2..df418cfcd36c 100644 --- a/include/hw/misc/aspeed_lpc.h +++ b/include/hw/misc/aspeed_lpc.h @@ -12,10 +12,22 @@ =20 #include "hw/sysbus.h" =20 +#include + #define TYPE_ASPEED_LPC "aspeed.lpc" #define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LP= C) =20 -#define ASPEED_LPC_NR_REGS (0x260 >> 2) +#define ASPEED_LPC_NR_REGS (0x260 >> 2) + +enum aspeed_lpc_subdevice { + aspeed_lpc_kcs_1 =3D 0, + aspeed_lpc_kcs_2, + aspeed_lpc_kcs_3, + aspeed_lpc_kcs_4, + aspeed_lpc_ibt, +}; + +#define ASPEED_LPC_NR_SUBDEVS 5 =20 typedef struct AspeedLPCState { /* */ @@ -25,6 +37,9 @@ typedef struct AspeedLPCState { MemoryRegion iomem; qemu_irq irq; =20 + qemu_irq subdevice_irqs[ASPEED_LPC_NR_SUBDEVS]; + uint32_t subdevice_irqs_pending; + uint32_t regs[ASPEED_LPC_NR_REGS]; uint32_t hicr7; } AspeedLPCState; --=20 2.27.0