From patchwork Wed Jun 23 03:38:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=PhXe2lce; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=mn9t7UPI; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pt44w2pz9sTD for ; Wed, 23 Jun 2021 13:39:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pt52cgfz309F for ; Wed, 23 Jun 2021 13:39:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=PhXe2lce; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=mn9t7UPI; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=PhXe2lce; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=mn9t7UPI; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psX1HQNz300Q for ; Wed, 23 Jun 2021 13:39:12 +1000 (AEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 85BF3EC4; Tue, 22 Jun 2021 23:39:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 22 Jun 2021 23:39:09 -0400 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-transfer-encoding; s=fm3; bh=33OG8YRSBH++5 +rmz3V+7Uv8nnEDRcFBvejaPQOoXUI=; b=PhXe2lcekBCYFaKXUvALzT42OPMFr G/Y+ot5hAtkYCkGJHsqo+Je4qks+6bqZetkcPLkct8XX6Qar5KX6dtNmytBEt6KP Q94HTjCaGhodlU7H7emBDMVg/jUaAiIxyoMCKJSmsj3gVpj7H8g9gnWbCpBlq7rA mQQ/GKXg8L8Bu74KGdhEu3wJo6AeOCTuPy2ilQ0r8V159LriGWKWV1ceQ1QtMenL r63/ra1TYP45ZZOaolFOYPz/w1kWYI52Xj9q+mBTh6H+3KyxMw5w7e2TJNIawS4X hhx7+avAx0pc5V9Ac8gQXdjnJUgRNv80H6QIvX+D6iQZUbhxUQMMrrfaw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=33OG8YRSBH++5+rmz3V+7Uv8nnEDRcFBvejaPQOoXUI=; b=mn9t7UPI A7pjlMw7utJddNSwt4GteuTzjs5y73bfSb0mQT57cpl2VXboIPnnGAqk5JZY4oRC UR3PrRnD7yrN3zDPtFxsppjCtaOivWwNvVK3NKkZsgR3pmvpSipzjjfnwDr6uEl7 IeoDH92u47ZS9IlTEvRZw5ywgHVtWInOIhrBurMusACLM4Fr2dA8N8dbfxY+C9LF RycqbA6VRfroma85LVdQ8LkBxdJL9C0D+1PMfgOuR30cL8nHB/Yhbmjk/thmls9g RL/NCOvIL22STjsz0ID700RmOC/bQwDK6p/3/dyr+Z4+v3fzwRzdPYCgyRQ/tyDu SkOURi7+ilwe+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:07 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 1/7] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int Date: Wed, 23 Jun 2021 13:08:48 +0930 Message-Id: <20210623033854.587464-2-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" From: Colin Ian King The comparisons of the unsigned int hw_type to less than zero always false because it is unsigned. Fix this by using an int for the assignment and less than zero check. Addresses-Coverity: ("Unsigned compared against 0") Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration") Signed-off-by: Colin Ian King Message-Id: <20210616162913.15259-1-colin.king@canonical.com> Signed-off-by: Corey Minyard --- drivers/char/ipmi/kcs_bmc_aspeed.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c index 9753ed0a5be6..b555286016b1 100644 --- a/drivers/char/ipmi/kcs_bmc_aspeed.c +++ b/drivers/char/ipmi/kcs_bmc_aspeed.c @@ -301,13 +301,15 @@ static inline int aspeed_kcs_map_serirq_type(u32 dt_type) static int aspeed_kcs_config_upstream_irq(struct aspeed_kcs_bmc *priv, u32 id, u32 dt_type) { unsigned int mask, val, hw_type; + int ret; if (id > 15) return -EINVAL; - hw_type = aspeed_kcs_map_serirq_type(dt_type); - if (hw_type < 0) - return hw_type; + ret = aspeed_kcs_map_serirq_type(dt_type); + if (ret < 0) + return ret; + hw_type = ret; priv->upstream_irq.mode = aspeed_kcs_irq_serirq; priv->upstream_irq.id = id; From patchwork Wed Jun 23 03:38:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=h6Cr2bOR; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=KWXEobmK; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8ptc0h9Yz9sTD for ; Wed, 23 Jun 2021 13:40:08 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8ptc5b1Wz303h for ; Wed, 23 Jun 2021 13:40:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=h6Cr2bOR; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=KWXEobmK; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=h6Cr2bOR; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=KWXEobmK; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psZ5TlCz307j for ; Wed, 23 Jun 2021 13:39:14 +1000 (AEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 20077D25; Tue, 22 Jun 2021 23:39:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 22 Jun 2021 23:39:12 -0400 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-transfer-encoding; s=fm3; bh=vH6omC5hc28Li cPoZ2XrJnVd+EV5JxqMlltQbj9TwDs=; b=h6Cr2bORgWmTzsr/6rAWsD2gpFHqX K1byVYe4Z8MYhe9nF2XqtqhD9Cnj4//7Y86RL0ZrA+KbDeAFlGUQVRxVbC9VoFCj qCDGwu5+scK8G0jbuPyPyMp2vus2/JDpxznH0FIXF8nXhIBo1lEFVoDBf1EM4AbY faxAP0Qg2rpDBfAX60iDoJ+D2GQOQAOuBSoMmBr50LIH8sGxZggXYp9jeJxF6hqd +N+l1Z/iIET/MCa72ppUvSbOF9svmuSt+DQR/W/c2gyjrlqMAmp/konHaSjXm/n2 Q5DFMaFFSIqDigK+IrAThmhjyZjEcKwUl4Uuu85OIpsCW/Jrz3E2tlzOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=vH6omC5hc28LicPoZ2XrJnVd+EV5JxqMlltQbj9TwDs=; b=KWXEobmK P1rZ98zx4s7aUXnzSEpg5ZrlQAZWapTLdVEANLQqUyRNe5B0SgxLS6U9wz9UdS/c oJOalRF7IU8UONbcTEh4HTGBEqs0uQlrOssFrBWlrtBzVKK/7Xmi5/mrr6SMdrD1 Z/gEx/UIvcpP5ZVjbTYt0OsmT1KLkcVUB2HlZi07tM0u/uX3+w6U/Dpp4hIS0yEg frbNLHW1ITFCXjvgaPsVqz/rOG1uSCp/NhpBHq0Zft15CGYBsXPl7ese/FIfpBdM /gH6aVfgWCdKAPBCdffLVye2SFZPAnbk26mFzpgQ6LpF0XKtXUrn2C34ciM9MZ5W hn5wl2MyNBMmvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepuefhtefhudeufeehffeffeetieeufe duleevgfekteefteekleetffehjeeukeehnecuffhomhgrihhnpehgihhthhhusgdrtgho mhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvfiesrghjrdhiugdrrghu X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:10 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 2/7] ipmi: kcs_bmc: Add a "raw" character device interface Date: Wed, 23 Jun 2021 13:08:49 +0930 Message-Id: <20210623033854.587464-3-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The existing IPMI chardev encodes IPMI behaviours as the name suggests. However, KCS devices are useful beyond IPMI (or keyboards), as they provide a means to generate IRQs and exchange arbitrary data between a BMC and its host system. Implement a "raw" KCS character device that exposes the IDR, ODR and STR registers to userspace via read() and write() implemented on a character device: +--------+--------+---------+ | Offset | read() | write() | +--------+--------+---------+ | 0 | IDR | ODR | +--------+--------+---------+ | 1 | STR | STR | +--------+--------+---------+ This interface allows userspace to implement arbitrary (though somewhat inefficient) protocols for exchanging information between a BMC and host firmware. Conceptually the KCS interface can be used as an out-of-band mechanism for interrupt-signaled control messages while bulk data transfers occur over more appropriate interfaces between the BMC and the host (which may lack their own interrupt mechanism, e.g. LPC FW cycles). poll() is provided, which will wait for IBF or OBE conditions for data reads and writes respectively. Reads of STR on its own never blocks, though accessing both offsets in the one system call may block if the data registers are not ready. Signed-off-by: Andrew Jeffery --- Documentation/ABI/testing/dev-raw-kcs | 25 ++ drivers/char/ipmi/Kconfig | 17 + drivers/char/ipmi/Makefile | 1 + drivers/char/ipmi/kcs_bmc_cdev_raw.c | 447 ++++++++++++++++++++++++++ 4 files changed, 490 insertions(+) create mode 100644 Documentation/ABI/testing/dev-raw-kcs create mode 100644 drivers/char/ipmi/kcs_bmc_cdev_raw.c diff --git a/Documentation/ABI/testing/dev-raw-kcs b/Documentation/ABI/testing/dev-raw-kcs new file mode 100644 index 000000000000..06e7e2071562 --- /dev/null +++ b/Documentation/ABI/testing/dev-raw-kcs @@ -0,0 +1,25 @@ +What: /dev/raw-kcs* +Date: 2021-02-15 +KernelVersion: 5.13 +Contact: openbmc@lists.ozlabs.org +Contact: openipmi-developer@lists.sourceforge.net +Contact: Andrew Jeffery +Description: ``/dev/raw-kcs*`` exposes to userspace the data and + status registers of Keyboard-Controller-Style (KCS) IPMI + interfaces via read() and write() syscalls. Direct + exposure of the data and status registers enables + inefficient but arbitrary protocols to be implemented + over the device. A typical approach is to use KCS + devices for out-of-band signalling for bulk data + transfers over other interfaces between a Baseboard + Management Controller and its host. + + +--------+--------+---------+ + | Offset | read() | write() | + +--------+--------+---------+ + | 0 | IDR | ODR | + +--------+--------+---------+ + | 1 | STR | STR | + +--------+--------+---------+ + +Users: libmctp: https://github.com/openbmc/libmctp diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig index 249b31197eea..19f1efc0bc3d 100644 --- a/drivers/char/ipmi/Kconfig +++ b/drivers/char/ipmi/Kconfig @@ -151,6 +151,23 @@ config IPMI_KCS_BMC_SERIO This support is also available as a module. The module will be called kcs_bmc_serio. +config IPMI_KCS_BMC_CDEV_RAW + depends on IPMI_KCS_BMC + tristate "Raw character device interface for BMC KCS devices" + help + Provides a BMC-side character device directly exposing the + data and status registers of a KCS device to userspace. While + KCS devices are commonly used to implement IPMI message + passing, they provide a general interface for exchange of + interrupts, data and status information between the BMC and + its host. + + Say YES if you wish to use the KCS devices to implement + protocols that are not IPMI. + + This support is also available as a module. The module will be + called kcs_bmc_cdev_raw. + config ASPEED_BT_IPMI_BMC depends on ARCH_ASPEED || COMPILE_TEST depends on REGMAP && REGMAP_MMIO && MFD_SYSCON diff --git a/drivers/char/ipmi/Makefile b/drivers/char/ipmi/Makefile index 84f47d18007f..3390985b4802 100644 --- a/drivers/char/ipmi/Makefile +++ b/drivers/char/ipmi/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o obj-$(CONFIG_IPMI_KCS_BMC) += kcs_bmc.o obj-$(CONFIG_IPMI_KCS_BMC_SERIO) += kcs_bmc_serio.o obj-$(CONFIG_IPMI_KCS_BMC_CDEV_IPMI) += kcs_bmc_cdev_ipmi.o +obj-$(CONFIG_IPMI_KCS_BMC_CDEV_RAW) += kcs_bmc_cdev_raw.o obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += bt-bmc.o obj-$(CONFIG_ASPEED_KCS_IPMI_BMC) += kcs_bmc_aspeed.o obj-$(CONFIG_NPCM7XX_KCS_IPMI_BMC) += kcs_bmc_npcm7xx.o diff --git a/drivers/char/ipmi/kcs_bmc_cdev_raw.c b/drivers/char/ipmi/kcs_bmc_cdev_raw.c new file mode 100644 index 000000000000..6865628476e1 --- /dev/null +++ b/drivers/char/ipmi/kcs_bmc_cdev_raw.c @@ -0,0 +1,447 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (c) 2021 IBM Corp. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kcs_bmc_client.h" + +#define DEVICE_NAME "raw-kcs" + +struct kcs_bmc_raw { + struct list_head entry; + + struct kcs_bmc_client client; + + wait_queue_head_t queue; + u8 events; + bool writable; + bool readable; + u8 idr; + + struct miscdevice miscdev; +}; + +static inline struct kcs_bmc_raw *client_to_kcs_bmc_raw(struct kcs_bmc_client *client) +{ + return container_of(client, struct kcs_bmc_raw, client); +} + +/* Call under priv->queue.lock */ +static void kcs_bmc_raw_update_event_mask(struct kcs_bmc_raw *priv, u8 mask, u8 state) +{ + kcs_bmc_update_event_mask(priv->client.dev, mask, state); + priv->events &= ~mask; + priv->events |= state & mask; +} + +static irqreturn_t kcs_bmc_raw_event(struct kcs_bmc_client *client) +{ + struct kcs_bmc_raw *priv; + struct device *dev; + u8 status, handled; + + priv = client_to_kcs_bmc_raw(client); + dev = priv->miscdev.this_device; + + spin_lock(&priv->queue.lock); + + status = kcs_bmc_read_status(client->dev); + handled = 0; + + if ((priv->events & KCS_BMC_EVENT_TYPE_IBF) && (status & KCS_BMC_STR_IBF)) { + if (priv->readable) + dev_err(dev, "Unexpected IBF IRQ, dropping data"); + + dev_dbg(dev, "Disabling IDR events for back-pressure\n"); + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_IBF, 0); + priv->idr = kcs_bmc_read_data(client->dev); + priv->readable = true; + + dev_dbg(dev, "IDR read, waking waiters\n"); + wake_up_locked(&priv->queue); + + handled |= KCS_BMC_EVENT_TYPE_IBF; + } + + if ((priv->events & KCS_BMC_EVENT_TYPE_OBE) && !(status & KCS_BMC_STR_OBF)) { + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_OBE, 0); + priv->writable = true; + + dev_dbg(dev, "ODR writable, waking waiters\n"); + wake_up_locked(&priv->queue); + + handled |= KCS_BMC_EVENT_TYPE_OBE; + } + + spin_unlock(&priv->queue.lock); + + return handled ? IRQ_HANDLED : IRQ_NONE; +} + +static const struct kcs_bmc_client_ops kcs_bmc_raw_client_ops = { + .event = kcs_bmc_raw_event, +}; + +static inline struct kcs_bmc_raw *file_to_kcs_bmc_raw(struct file *filp) +{ + return container_of(filp->private_data, struct kcs_bmc_raw, miscdev); +} + +static int kcs_bmc_raw_open(struct inode *inode, struct file *filp) +{ + struct kcs_bmc_raw *priv = file_to_kcs_bmc_raw(filp); + int rc; + + priv->events = KCS_BMC_EVENT_TYPE_IBF; + rc = kcs_bmc_enable_device(priv->client.dev, &priv->client); + if (rc) + priv->events = 0; + + return rc; +} + +static bool kcs_bmc_raw_prepare_obe(struct kcs_bmc_raw *priv) +{ + bool writable; + + /* Enable the OBE event so we can catch the host clearing OBF */ + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_OBE, KCS_BMC_EVENT_TYPE_OBE); + + /* Now that we'll catch an OBE event, check if it's already occurred */ + writable = !(kcs_bmc_read_status(priv->client.dev) & KCS_BMC_STR_OBF); + + /* If OBF is clear we've missed the OBE event, so disable it */ + if (writable) + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_OBE, 0); + + return writable; +} + +static __poll_t kcs_bmc_raw_poll(struct file *filp, poll_table *wait) +{ + struct kcs_bmc_raw *priv; + __poll_t events = 0; + + priv = file_to_kcs_bmc_raw(filp); + + poll_wait(filp, &priv->queue, wait); + + spin_lock_irq(&priv->queue.lock); + if (kcs_bmc_raw_prepare_obe(priv)) + events |= (EPOLLOUT | EPOLLWRNORM); + + if (priv->readable || (kcs_bmc_read_status(priv->client.dev) & KCS_BMC_STR_IBF)) + events |= (EPOLLIN | EPOLLRDNORM); + spin_unlock_irq(&priv->queue.lock); + + return events; +} + +static ssize_t kcs_bmc_raw_read(struct file *filp, char __user *buf, + size_t count, loff_t *ppos) +{ + struct kcs_bmc_device *kcs_bmc; + struct kcs_bmc_raw *priv; + bool read_idr, read_str; + struct device *dev; + u8 idr, str; + ssize_t rc; + + priv = file_to_kcs_bmc_raw(filp); + kcs_bmc = priv->client.dev; + dev = priv->miscdev.this_device; + + if (!count) + return 0; + + if (count > 2 || *ppos > 1) + return -EINVAL; + + if (*ppos + count > 2) + return -EINVAL; + + read_idr = (*ppos == 0); + read_str = (*ppos == 1) || (count == 2); + + spin_lock_irq(&priv->queue.lock); + if (read_idr) { + dev_dbg(dev, "Waiting for IBF\n"); + str = kcs_bmc_read_status(kcs_bmc); + if ((filp->f_flags & O_NONBLOCK) && (str & KCS_BMC_STR_IBF)) { + rc = -EWOULDBLOCK; + goto out; + } + + rc = wait_event_interruptible_locked(priv->queue, + priv->readable || (str & KCS_BMC_STR_IBF)); + if (rc < 0) + goto out; + + if (signal_pending(current)) { + dev_dbg(dev, "Interrupted waiting for IBF\n"); + rc = -EINTR; + goto out; + } + + /* + * Re-enable events prior to possible read of IDR (which clears + * IBF) to ensure we receive interrupts for subsequent writes + * to IDR. Writes to IDR by the host should not occur while IBF + * is set. + */ + dev_dbg(dev, "Woken by IBF, enabling IRQ\n"); + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_IBF, + KCS_BMC_EVENT_TYPE_IBF); + + /* Read data out of IDR into internal storage if necessary */ + if (!priv->readable) { + WARN(!(str & KCS_BMC_STR_IBF), "Unknown reason for wakeup!"); + + priv->idr = kcs_bmc_read_data(kcs_bmc); + } + + /* Copy data from internal storage to userspace */ + idr = priv->idr; + + /* We're done consuming the internally stored value */ + priv->readable = false; + } + + if (read_str) { + str = kcs_bmc_read_status(kcs_bmc); + if (*ppos == 0 || priv->readable) + /* + * If we got this far with `*ppos == 0` then we've read + * data out of IDR, so set IBF when reporting back to + * userspace so userspace knows the IDR value is valid. + */ + str |= KCS_BMC_STR_IBF; + + dev_dbg(dev, "Read status 0x%x\n", str); + + } + + rc = count; +out: + spin_unlock_irq(&priv->queue.lock); + + if (rc < 0) + return rc; + + /* Now copy the data in to the userspace buffer */ + + if (read_idr) + if (copy_to_user(buf++, &idr, sizeof(idr))) + return -EFAULT; + + if (read_str) + if (copy_to_user(buf, &str, sizeof(str))) + return -EFAULT; + + return count; +} + +static ssize_t kcs_bmc_raw_write(struct file *filp, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct kcs_bmc_device *kcs_bmc; + bool write_odr, write_str; + struct kcs_bmc_raw *priv; + struct device *dev; + ssize_t result; + u8 data[2]; + u8 str; + + priv = file_to_kcs_bmc_raw(filp); + kcs_bmc = priv->client.dev; + dev = priv->miscdev.this_device; + + if (!count) + return count; + + if (count > 2) + return -EINVAL; + + if (*ppos >= 2) + return -EINVAL; + + if (*ppos + count > 2) + return -EINVAL; + + if (copy_from_user(data, buf, count)) + return -EFAULT; + + write_odr = (*ppos == 0); + write_str = (*ppos == 1) || (count == 2); + + spin_lock_irq(&priv->queue.lock); + + /* Always write status before data, we generate the SerIRQ by writing ODR */ + if (write_str) { + /* The index of STR in the userspace buffer depends on whether ODR is written */ + str = data[*ppos == 0]; + if (!(str & KCS_BMC_STR_OBF)) + dev_warn(dev, "Clearing OBF with status write: 0x%x\n", str); + dev_dbg(dev, "Writing status 0x%x\n", str); + kcs_bmc_write_status(kcs_bmc, str); + } + + if (write_odr) { + /* If we're writing ODR it's always the first byte in the buffer */ + u8 odr = data[0]; + + str = kcs_bmc_read_status(kcs_bmc); + if (str & KCS_BMC_STR_OBF) { + if (filp->f_flags & O_NONBLOCK) { + result = -EWOULDBLOCK; + goto out; + } + + priv->writable = kcs_bmc_raw_prepare_obe(priv); + + /* Now either OBF is already clear, or we'll get an OBE event to wake us */ + dev_dbg(dev, "Waiting for OBF to clear\n"); + wait_event_interruptible_locked(priv->queue, priv->writable); + + if (signal_pending(current)) { + kcs_bmc_raw_update_event_mask(priv, KCS_BMC_EVENT_TYPE_OBE, 0); + result = -EINTR; + goto out; + } + + WARN_ON(kcs_bmc_read_status(kcs_bmc) & KCS_BMC_STR_OBF); + } + + dev_dbg(dev, "Writing 0x%x to ODR\n", odr); + kcs_bmc_write_data(kcs_bmc, odr); + } + + result = count; +out: + spin_unlock_irq(&priv->queue.lock); + + return result; +} + +static int kcs_bmc_raw_release(struct inode *inode, struct file *filp) +{ + struct kcs_bmc_raw *priv = file_to_kcs_bmc_raw(filp); + + kcs_bmc_disable_device(priv->client.dev, &priv->client); + priv->events = 0; + + return 0; +} + +static const struct file_operations kcs_bmc_raw_fops = { + .owner = THIS_MODULE, + .open = kcs_bmc_raw_open, + .llseek = no_seek_end_llseek, + .read = kcs_bmc_raw_read, + .write = kcs_bmc_raw_write, + .poll = kcs_bmc_raw_poll, + .release = kcs_bmc_raw_release, +}; + +static DEFINE_SPINLOCK(kcs_bmc_raw_instances_lock); +static LIST_HEAD(kcs_bmc_raw_instances); + +static int kcs_bmc_raw_add_device(struct kcs_bmc_device *kcs_bmc) +{ + struct kcs_bmc_raw *priv; + int rc; + + priv = devm_kzalloc(kcs_bmc->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->client.dev = kcs_bmc; + priv->client.ops = &kcs_bmc_raw_client_ops; + + init_waitqueue_head(&priv->queue); + priv->writable = false; + priv->readable = false; + + priv->miscdev.minor = MISC_DYNAMIC_MINOR; + priv->miscdev.name = devm_kasprintf(kcs_bmc->dev, GFP_KERNEL, "%s%u", DEVICE_NAME, + kcs_bmc->channel); + if (!priv->miscdev.name) + return -EINVAL; + + priv->miscdev.fops = &kcs_bmc_raw_fops; + + /* Disable interrupts until userspace opens the the chardev */ + kcs_bmc_raw_update_event_mask(priv, (KCS_BMC_EVENT_TYPE_IBF | KCS_BMC_EVENT_TYPE_OBE), 0); + + rc = misc_register(&priv->miscdev); + if (rc) { + dev_err(kcs_bmc->dev, "Unable to register device\n"); + return rc; + } + + spin_lock_irq(&kcs_bmc_raw_instances_lock); + list_add(&priv->entry, &kcs_bmc_raw_instances); + spin_unlock_irq(&kcs_bmc_raw_instances_lock); + + dev_info(kcs_bmc->dev, "Initialised raw client for channel %d", kcs_bmc->channel); + + return 0; +} + +static int kcs_bmc_raw_remove_device(struct kcs_bmc_device *kcs_bmc) +{ + struct kcs_bmc_raw *priv = NULL, *pos; + + spin_lock_irq(&kcs_bmc_raw_instances_lock); + list_for_each_entry(pos, &kcs_bmc_raw_instances, entry) { + if (pos->client.dev == kcs_bmc) { + priv = pos; + list_del(&pos->entry); + break; + } + } + spin_unlock_irq(&kcs_bmc_raw_instances_lock); + + if (!priv) + return -ENODEV; + + misc_deregister(&priv->miscdev); + kcs_bmc_disable_device(kcs_bmc, &priv->client); + devm_kfree(priv->client.dev->dev, priv); + + return 0; +} + +static const struct kcs_bmc_driver_ops kcs_bmc_raw_driver_ops = { + .add_device = kcs_bmc_raw_add_device, + .remove_device = kcs_bmc_raw_remove_device, +}; + +static struct kcs_bmc_driver kcs_bmc_raw_driver = { + .ops = &kcs_bmc_raw_driver_ops, +}; + +static int kcs_bmc_raw_init(void) +{ + kcs_bmc_register_driver(&kcs_bmc_raw_driver); + + return 0; +} +module_init(kcs_bmc_raw_init); + +static void kcs_bmc_raw_exit(void) +{ + kcs_bmc_unregister_driver(&kcs_bmc_raw_driver); +} +module_exit(kcs_bmc_raw_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Andrew Jeffery "); +MODULE_DESCRIPTION("Character device for raw access to a KCS device"); From patchwork Wed Jun 23 03:38:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=GVcyu69q; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=PudS5yAq; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pvP2fncz9sTD for ; Wed, 23 Jun 2021 13:40:49 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pvQ0sFLz30Dl for ; Wed, 23 Jun 2021 13:40:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=GVcyu69q; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=PudS5yAq; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=GVcyu69q; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=PudS5yAq; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psd2dXcz3098 for ; Wed, 23 Jun 2021 13:39:17 +1000 (AEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id BAEAFEC8; Tue, 22 Jun 2021 23:39:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 22 Jun 2021 23:39:14 -0400 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-transfer-encoding; s=fm3; bh=3/zXr0MFCoTlv 4MVeFTVcgwaIENgH4z2YG9XCFzoO4w=; b=GVcyu69qOvno4ZoxEgZpEflu1CkuH KH3ZPiejjAcXbLEHGqVEgir7Q8N3IOy038cG0SS0u/fKI9DhD3rVLalcUwNpJANe UB0fSaMbvO6j4fQ1LV4OO5D7Yd3hCrjTqgWx9Si+wd3hcUD38gI29EdGjJ2g26oA wPZKwgDn+iQgz5Vguj7WCrMWbLg56rU2hpe37x39xejaStljv4OZPQmBfX8CJGUr Aft+Zp46aqfB6id5yz30F2Akwq2pcI2ohn0TE3J3rUzG9tasSu8donkSGFwiQUK2 UxwKRrt0oRAq3bxR1C4WMiSU4RFDEHYqhf6F4qcsMGb4rXcphrx9r5J8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=3/zXr0MFCoTlv4MVeFTVcgwaIENgH4z2YG9XCFzoO4w=; b=PudS5yAq IDnw4WyRbRwqOTACL0cCUC0x6lrHoth5ko5/zqPr35VOyMpqwBh4dRNfGBk0OsJz +9HgpXyYDeU2ZRNcMZeSnnCVhCqRZGJGbNtNbNn3TnzBpnHZcQ8WcHyHJeG6NmVp FZdi3SE4LYxHrImnge5oC1OfN5C175w8I265j7XwGrurCIQx5ATrY375Yr7HeAMV Y5yr3SVyXjUQmJOyckfpI32PIs1H9FIxHVpTksdVjTGUA8tDYjC200aDh9m6Z70e lheDfIhdKaERBPphTyM8hPVhujbCtvC66oSuflnFeB2LkbH9R+2r27QKRqKAH+b7 Y4dWyYswBEavqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:12 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 3/7] ARM: configs: Enable IPMI KCS raw chardev Date: Wed, 23 Jun 2021 13:08:50 +0930 Message-Id: <20210623033854.587464-4-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The raw KCS chardev is used by libmctp's vendor-defined LPC binding. Signed-off-by: Andrew Jeffery --- arch/arm/configs/aspeed_g5_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/aspeed_g5_defconfig b/arch/arm/configs/aspeed_g5_defconfig index cefbec257bd8..045d383ce5ce 100644 --- a/arch/arm/configs/aspeed_g5_defconfig +++ b/arch/arm/configs/aspeed_g5_defconfig @@ -180,6 +180,7 @@ CONFIG_SERIAL_8250_DW=y CONFIG_SERIAL_OF_PLATFORM=y CONFIG_ASPEED_KCS_IPMI_BMC=y CONFIG_IPMI_KCS_BMC_SERIO=y +CONFIG_IPMI_KCS_BMC_CDEV_RAW=y CONFIG_ASPEED_BT_IPMI_BMC=y CONFIG_HW_RANDOM=y CONFIG_HW_RANDOM_TIMERIOMEM=y From patchwork Wed Jun 23 03:38:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=JNLS301s; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OQ1/VLVE; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pvq6htyz9sTD for ; Wed, 23 Jun 2021 13:41:11 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pvr4bXZz302f for ; Wed, 23 Jun 2021 13:41:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=JNLS301s; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OQ1/VLVE; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=JNLS301s; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OQ1/VLVE; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psg6gSfz307m for ; Wed, 23 Jun 2021 13:39:19 +1000 (AEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 51C9AEC4; Tue, 22 Jun 2021 23:39:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 22 Jun 2021 23:39:17 -0400 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-transfer-encoding; s=fm3; bh=nywLGSt2lhgne 7YWWpdBw4RgY5fP4s/yT7U9JbKKIxI=; b=JNLS301sLTLVzNxfmW8oiFLiTTYdh D4n+FtZIsburH1B0NYyDLfLlKSS7kmdFmJ3dkI9hV5aWGyGnAe3PNCBLbjN1RB1b J76OBaon1Kt7yvQGnGQTjwIIhkeL3j3OCCH1WFLKEDd/SSGcwtIX0nh1DABdW9B9 Nh8NWf69dh949wuXUwRU+1iSB2f2ljT1TT/1JS7JLLowu9MqbJdY6mbnB2LqrSnK 2F6AqBd+xba/ooWezY8c7x7TalaRRTa4+3OqjUdI/23B04YE66BKLNYFYJhv1V6g FJR+tLziH2EdfpkX5kXVZvmacrkEaK0IfHFcHyASqAbNyK1S++Ur8DlDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=nywLGSt2lhgne7YWWpdBw4RgY5fP4s/yT7U9JbKKIxI=; b=OQ1/VLVE 2lIs2LGhxRWLunNDOODYSv+7loTVJERvEy/32Gx9c++b1HJ+OLtET/BD4sviN9dc JIlcgXhMaVLQwepVO5qrvLXjYp91DAAm7vi1saCDNbYjTPvjPsnmthVADHlW/p8X obCU787lquJRpIF3Eo/iv7a9HgzWOO5hk7LPqd2gCntqkyQJHP8qInVJ/TX7ZYNd bzVpBVB556V1YazdLkTPte6BM0PcOU6rBtG05sjdjJERcFJBBH6QnrJqpRjCfsIM auYsShgV52I2ZFfoVCGHUr+G55IK76GHQmbdZKAt9FaXXbiK5TtLIu0IZ6G2vlYQ kRp7/4U/Bi8uyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:15 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 4/7] ARM: dts: p10bmc: Drop the openbmc, mctp-lpc node Date: Wed, 23 Jun 2021 13:08:51 +0930 Message-Id: <20210623033854.587464-5-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The MCTP LPC driver was loaded by hacking up the compatible in the devicetree node for KCS 4. With the introduction of the raw KCS driver this hack is no-longer required. Use the regular compatible string for KCS 4 and configure the appropriate SerIRQ. Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts | 11 ++++++----- arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts index 1c9e4ff5388b..d899c9620286 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts @@ -4049,11 +4049,6 @@ &lpc_ctrl { memory-region = <&flash_memory>; }; -&kcs4 { - compatible = "openbmc,mctp-lpc"; - status = "okay"; -}; - &mac2 { status = "okay"; pinctrl-names = "default"; @@ -4092,3 +4087,9 @@ &xdma { status = "okay"; memory-region = <&vga_memory>; }; + +&kcs4 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts index 73e94be5424b..9ea3864651d6 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts @@ -1717,11 +1717,6 @@ &lpc_ctrl { memory-region = <&flash_memory>; }; -&kcs4 { - compatible = "openbmc,mctp-lpc"; - status = "okay"; -}; - &mac2 { status = "okay"; pinctrl-names = "default"; @@ -1784,3 +1779,9 @@ &xdma { status = "okay"; memory-region = <&vga_memory>; }; + +&kcs4 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; From patchwork Wed Jun 23 03:38:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=ABaQcKrQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=kFXZq86r; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pwJ5dhbz9sTD for ; Wed, 23 Jun 2021 13:41:36 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pwK3tXsz307q for ; Wed, 23 Jun 2021 13:41:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=ABaQcKrQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=kFXZq86r; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=ABaQcKrQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=kFXZq86r; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psk37k4z300C for ; Wed, 23 Jun 2021 13:39:22 +1000 (AEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C3EE5D25; Tue, 22 Jun 2021 23:39:19 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 22 Jun 2021 23:39:19 -0400 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-transfer-encoding; s=fm3; bh=jJD+Ts+qjQRxG hZXKEDERkD/VObf17d+0UDi5qsv8ns=; b=ABaQcKrQl2yetwVO8NnH3n6w1zKne fp57zpsVAGhEHNtIhmPzhl2MZm8foie32W2DPg4NVQxAJmfkxaOkY9IYNhpZ64YN AFMFwywwvfd9x89daVBetH0UW4ex+BwEA4E7LRIqR/abz49+z8vCttLlE5sc6h27 KPEu2XOuvJoCg/5QAN2xWvhIICV1EpnEVmkhVKT4/RSqP/fpBjcfo6p6tEslOciM 4MVs0L36yLQzPF3hfKu8W00SGE08j9+WwGVm3TTQ3WarCsaenwEwkXArtjifDLI1 zpvvK54lYEEFkReTuyS4nUCtVixMMvBhqmRSDkZGotvMEZ4/u0/NBthJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=jJD+Ts+qjQRxGhZXKEDERkD/VObf17d+0UDi5qsv8ns=; b=kFXZq86r LM0fUZP6PZkorRBlzdWui18YL9ZjOvPWX2EpQ6VyfpF0azwxM0QKex1H1BgMa5S7 d6G2qCIots2IZ42/tDKs4WyyBwXB18KH0ypJMkMnJwIBETSUkPcAbDp32OoCTmkW LvhnyJEQ96AW4Jp2rlbEn/nq14LstyVtSahSVUK3UAXUWflNW34+IOwgU3aVAZ5H fAF2UqisoXKoE2Y9cx5kA/S/J9WlYl0crD+n5zslsnWk0bU3gN3p/XLXhNXgVFPE MMV2gMIgfzgSRTwMEaPkMjqNRmfoW7Im7leQ4ckOfn4fvVoot3/k4ePbozWucVRQ DJyTGJ/XE8O/+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhephefgffekgfegieeguedtgeegfeeugf efjeeggfejueefgeeufeektdeltdefteefnecuffhomhgrihhnpehgihhthhhusgdrtgho mhdpkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:17 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 5/7] misc: Remove obsolete mctp-lpc chardev Date: Wed, 23 Jun 2021 13:08:52 +0930 Message-Id: <20210623033854.587464-6-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The mctp-lpc chardev is replaced (temporarily) by the raw KCS chardev. The raw chardev is required for IBM's purposes until Jeremy's socket-based MCTP patches are merged[1][2]. [1] https://github.com/openbmc/docs/blob/master/designs/mctp/mctp-kernel.md [2] https://lore.kernel.org/openbmc/f4f5fa66542401e8d5e78c1fb30153195d384b62.camel@codeconstruct.com.au/ Signed-off-by: Andrew Jeffery --- arch/arm/configs/aspeed_g5_defconfig | 1 - drivers/misc/Kconfig | 7 - drivers/misc/Makefile | 1 - drivers/misc/mctp-lpc.c | 443 --------------------------- 4 files changed, 452 deletions(-) delete mode 100644 drivers/misc/mctp-lpc.c diff --git a/arch/arm/configs/aspeed_g5_defconfig b/arch/arm/configs/aspeed_g5_defconfig index 045d383ce5ce..550884fee892 100644 --- a/arch/arm/configs/aspeed_g5_defconfig +++ b/arch/arm/configs/aspeed_g5_defconfig @@ -111,7 +111,6 @@ CONFIG_MTD_UBI_FASTMAP=y CONFIG_MTD_UBI_BLOCK=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_NBD=y -CONFIG_MCTP_LPC=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_AT25=y CONFIG_MD=y diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index c1322e9bee8a..54cfb599cd3e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -444,13 +444,6 @@ config XILINX_SDFEC If unsure, say N. -config MCTP_LPC - tristate "MCTP LPC binding implementation for ASPEED BMCs" - depends on REGMAP - help - Implements the MCTP LPC binding via KCS LPC IO cycles for control and - LPC FWH cycles for data - config MISC_RTSX tristate default MISC_RTSX_PCI || MISC_RTSX_USB diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index bcc79a1d7a72..39e5ba5d0985 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -60,4 +60,3 @@ obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-$(CONFIG_NPCM7XX_LPC_BPC) += npcm7xx-lpc-bpc.o obj-$(CONFIG_NPCM7XX_PCI_MBOX) += npcm7xx-pci-mbox.o obj-$(CONFIG_NPCM7XX_JTAG_MASTER) += npcm7xx-jtag-master.o -obj-$(CONFIG_MCTP_LPC) += mctp-lpc.o diff --git a/drivers/misc/mctp-lpc.c b/drivers/misc/mctp-lpc.c deleted file mode 100644 index 0228f6bbf1a7..000000000000 --- a/drivers/misc/mctp-lpc.c +++ /dev/null @@ -1,443 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (c) 2019, IBM Corp. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LPC_HICRB 0x100 -#define LPC_HICRB_IBFIF4 BIT(1) -#define LPC_HICRB_LPC4E BIT(0) -#define LPC_HICRC 0x104 -#define LPC_KCS4_IRQSEL_MASK GENMASK(7, 4) -#define LPC_KCS4_IRQSEL_SHIFT 4 -#define LPC_KCS4_IRQTYPE_MASK GENMASK(3, 2) -#define LPC_KCS4_IRQTYPE_SHIFT 2 -#define LPC_KCS4_IRQTYPE_LOW 0b00 -#define LPC_KCS4_IRQTYPE_HIGH 0b01 -#define LPC_KCS4_IRQTYPE_RSVD 0b10 -#define LPC_KCS4_IRQTYPE_RISING 0b11 -#define LPC_KCS4_OBF4_AUTO_CLR BIT(1) -#define LPC_KCS4_IRQ_HOST BIT(0) -#define LPC_LADR4 0x110 -#define LPC_IDR4 0x114 -#define LPC_ODR4 0x118 -#define LPC_STR4 0x11C -#define STR4_IBF (1 << 1) -#define STR4_OBF (1 << 0) - -#define HOST_ODR 0xca2 -#define HOST_STR 0xca3 -#define HOST_SERIRQ_ID 11 -#define HOST_SERIRQ_TYPE LPC_KCS4_IRQTYPE_LOW - -#define RX_BUF_SIZE 1024 - -struct mctp_lpc { - struct miscdevice miscdev; - struct regmap *map; - - wait_queue_head_t rx; - bool pending; - u8 idr; -}; - -static irqreturn_t mctp_lpc_irq(int irq, void *data) -{ - struct mctp_lpc *priv = data; - unsigned long flags; - unsigned int hicrb; - struct device *dev; - unsigned int str; - irqreturn_t ret; - - dev = priv->miscdev.this_device; - - spin_lock_irqsave(&priv->rx.lock, flags); - - regmap_read(priv->map, LPC_STR4, &str); - regmap_read(priv->map, LPC_HICRB, &hicrb); - - if ((str & STR4_IBF) && (hicrb & LPC_HICRB_IBFIF4)) { - unsigned int val; - - if (priv->pending) - dev_err(dev, "Storm brewing!"); - - /* Mask the IRQ / Enter polling mode */ - dev_dbg(dev, "Received IRQ %d, disabling to provide back-pressure\n", - irq); - regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_IBFIF4, 0); - - /* - * Extract the IDR4 value to ack the IRQ. Reading IDR clears - * IBF and allows the host to write another value, however as - * we have disabled IRQs the back-pressure is still applied - * until userspace starts servicing the interface. - */ - regmap_read(priv->map, LPC_IDR4, &val); - priv->idr = val & 0xff; - priv->pending = true; - - dev_dbg(dev, "Set pending, waking waiters\n"); - wake_up_locked(&priv->rx); - ret = IRQ_HANDLED; - } else { - dev_dbg(dev, "LPC IRQ triggered, but not for us (str=0x%x, hicrb=0x%x)\n", - str, hicrb); - ret = IRQ_NONE; - } - - spin_unlock_irqrestore(&priv->rx.lock, flags); - - return ret; -} - -static inline struct mctp_lpc *to_mctp_lpc(struct file *filp) -{ - return container_of(filp->private_data, struct mctp_lpc, miscdev); -} - -static ssize_t mctp_lpc_read(struct file *filp, char __user *buf, - size_t count, loff_t *ppos) -{ - struct mctp_lpc *priv; - struct device *dev; - size_t remaining; - ssize_t rc; - - priv = to_mctp_lpc(filp); - dev = priv->miscdev.this_device; - - if (!count) - return 0; - - if (count > 2 || *ppos > 1) - return -EINVAL; - - remaining = count; - - spin_lock_irq(&priv->rx.lock); - if (*ppos == 0) { - unsigned int val; - u8 str; - - /* YOLO blocking, non-block not supported */ - dev_dbg(dev, "Waiting for IBF\n"); - regmap_read(priv->map, LPC_STR4, &val); - str = val & 0xff; - rc = wait_event_interruptible_locked(priv->rx, (priv->pending || str & STR4_IBF)); - if (rc < 0) - goto out; - - if (signal_pending(current)) { - dev_dbg(dev, "Interrupted waiting for IBF\n"); - rc = -EINTR; - goto out; - } - - /* - * Re-enable IRQs prior to possible read of IDR (which clears - * IBF) to ensure we receive interrupts for subsequent writes - * to IDR. Writes to IDR by the host should not occur while IBF - * is set. - */ - dev_dbg(dev, "Woken by IBF, enabling IRQ\n"); - regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_IBFIF4, - LPC_HICRB_IBFIF4); - - /* Read data out of IDR into internal storage if necessary */ - if (!priv->pending) { - WARN(!(str & STR4_IBF), "Unknown reason for wakeup!"); - - /* Extract the IDR4 value to ack the IRQ */ - regmap_read(priv->map, LPC_IDR4, &val); - priv->idr = val & 0xff; - } - - /* Copy data from internal storage to userspace */ - if (copy_to_user(buf, &priv->idr, sizeof(priv->idr))) { - rc = -EFAULT; - goto out; - } - - /* We're done consuming the internally stored value */ - priv->pending = false; - - remaining--; - buf++; - } - - if (remaining) { - /* Either: - * - * 1. (count == 1 && *ppos == 1) - * 2. (count == 2 && *ppos == 0) - */ - unsigned int val; - u8 str; - - regmap_read(priv->map, LPC_STR4, &val); - str = val & 0xff; - if (*ppos == 0 || priv->pending) - /* - * If we got this far with `*ppos == 0` then we've read - * data out of IDR, so set IBF when reporting back to - * userspace so userspace knows the IDR value is valid. - */ - str |= STR4_IBF; - - dev_dbg(dev, "Read status 0x%x\n", str); - if (copy_to_user(buf, &str, sizeof(str))) { - rc = -EFAULT; - goto out; - } - - remaining--; - } - - WARN_ON(remaining); - - rc = count; - -out: - spin_unlock_irq(&priv->rx.lock); - - return rc; -} - -static ssize_t mctp_lpc_write(struct file *filp, const char __user *buf, - size_t count, loff_t *ppos) -{ - uint8_t _data[2], *data = &_data[0]; - struct mctp_lpc *priv; - struct device *dev; - size_t remaining; - unsigned int str; - - priv = to_mctp_lpc(filp); - dev = priv->miscdev.this_device; - - if (!count) - return count; - - if (count > 2) - return -EINVAL; - - if (*ppos >= 2) - return -EINVAL; - - if (*ppos + count > 2) - return -EINVAL; - - if (copy_from_user(data, buf, count)) - return -EFAULT; - - remaining = count; - - if (*ppos == 0) { - /* Wait until OBF is clear - we don't get an IRQ */ - dev_dbg(dev, "Waiting for OBF to clear\n"); - for (;;) { - if (signal_pending(current)) - return -EINTR; - - regmap_read(priv->map, LPC_STR4, &str); - if (!(str & STR4_OBF)) - break; - - msleep(1); - } - - dev_dbg(dev, "Writing 0x%x to ODR\n", *data); - regmap_write(priv->map, LPC_ODR4, *data); - remaining--; - data++; - } - - if (remaining) { - if (!(*data & STR4_OBF)) - dev_err(dev, "Clearing OBF with status write: 0x%x\n", - *data); - dev_dbg(dev, "Writing status 0x%x\n", *data); - regmap_write(priv->map, LPC_STR4, *data); - remaining--; - } - - WARN_ON(remaining); - - regmap_read(priv->map, LPC_STR4, &str); - dev_dbg(dev, "Triggering SerIRQ (current str=0x%x)\n", str); - - /* - * Trigger Host IRQ on ODR write. Do this after any STR write in case - * we need to write ODR to indicate an STR update (which we do). - */ - if (*ppos == 0) - regmap_update_bits(priv->map, LPC_HICRC, LPC_KCS4_IRQ_HOST, - LPC_KCS4_IRQ_HOST); - - return count; -} - -static __poll_t mctp_lpc_poll(struct file *filp, poll_table *wait) -{ - struct mctp_lpc *priv; - struct device *dev; - unsigned int val; - bool ibf; - - priv = to_mctp_lpc(filp); - dev = priv->miscdev.this_device; - - regmap_read(priv->map, LPC_STR4, &val); - - spin_lock_irq(&priv->rx.lock); - - ibf = priv->pending || val & STR4_IBF; - - if (!ibf) { - dev_dbg(dev, "Polling on IBF\n"); - - spin_unlock_irq(&priv->rx.lock); - - poll_wait(filp, &priv->rx, wait); - if (signal_pending(current)) { - dev_dbg(dev, "Polling IBF was interrupted\n"); - goto out; - } - - spin_lock_irq(&priv->rx.lock); - - regmap_read(priv->map, LPC_STR4, &val); - - ibf = priv->pending || val & STR4_IBF; - } - - spin_unlock_irq(&priv->rx.lock); - -out: - dev_dbg(dev, "Polled IBF state: %s\n", ibf ? "set" : "clear"); - - return ibf ? EPOLLIN : 0; -} - -static const struct file_operations mctp_lpc_fops = { - .owner = THIS_MODULE, - .llseek = no_seek_end_llseek, - .read = mctp_lpc_read, - .write = mctp_lpc_write, - .poll = mctp_lpc_poll, -}; - -static int mctp_lpc_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - unsigned int mask, val; - struct mctp_lpc *priv; - int irq; - int rc; - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->map = syscon_node_to_regmap(dev->parent->of_node); - if (IS_ERR(priv->map)) { - dev_err(dev, "Couldn't get regmap\n"); - return -ENODEV; - } - - /* - * Set the LPC address. Simultaneously, test our MMIO regmap works. All - * subsequent accesses are assumed to work - */ - rc = regmap_write(priv->map, LPC_LADR4, ((HOST_STR) << 16) | HOST_ODR); - if (rc < 0) - return rc; - - /* Set up the SerIRQ */ - mask = LPC_KCS4_IRQSEL_MASK - | LPC_KCS4_IRQTYPE_MASK - | LPC_KCS4_OBF4_AUTO_CLR; - val = (HOST_SERIRQ_ID << LPC_KCS4_IRQSEL_SHIFT) - | (HOST_SERIRQ_TYPE << LPC_KCS4_IRQTYPE_SHIFT); - val &= ~LPC_KCS4_OBF4_AUTO_CLR; /* Unnecessary, just documentation */ - regmap_update_bits(priv->map, LPC_HICRC, mask, val); - - /* Trigger waiters from IRQ */ - init_waitqueue_head(&priv->rx); - - dev_set_drvdata(dev, priv); - - /* Set up the miscdevice */ - priv->miscdev.minor = MISC_DYNAMIC_MINOR; - priv->miscdev.name = "mctp0"; - priv->miscdev.fops = &mctp_lpc_fops; - - /* Configure the IRQ handler */ - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - rc = devm_request_irq(dev, irq, mctp_lpc_irq, IRQF_SHARED, - dev_name(dev), priv); - if (rc < 0) - return rc; - - /* Register the device */ - rc = misc_register(&priv->miscdev); - if (rc) { - dev_err(dev, "Unable to register device\n"); - return rc; - } - - /* Enable the channel */ - regmap_update_bits(priv->map, LPC_HICRB, - LPC_HICRB_IBFIF4 | LPC_HICRB_LPC4E, - LPC_HICRB_IBFIF4 | LPC_HICRB_LPC4E); - - return 0; -} - -static int mctp_lpc_remove(struct platform_device *pdev) -{ - struct mctp_lpc *ctx = dev_get_drvdata(&pdev->dev); - - misc_deregister(&ctx->miscdev); - - return 0; -} - -static const struct of_device_id mctp_lpc_match[] = { - { .compatible = "openbmc,mctp-lpc" }, - { } -}; -MODULE_DEVICE_TABLE(of, mctp_lpc_match); - -static struct platform_driver mctp_lpc = { - .driver = { - .name = "mctp-lpc", - .of_match_table = mctp_lpc_match, - }, - .probe = mctp_lpc_probe, - .remove = mctp_lpc_remove, -}; -module_platform_driver(mctp_lpc); - -MODULE_LICENSE("GPL v2+"); -MODULE_AUTHOR("Andrew Jeffery "); -MODULE_DESCRIPTION("OpenBMC MCTP LPC binding on ASPEED KCS"); From patchwork Wed Jun 23 03:38:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=WdvZomH7; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OqmEHBdt; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pwm0M5nz9sTD for ; Wed, 23 Jun 2021 13:42:00 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pwm5Mc9z3bxw for ; Wed, 23 Jun 2021 13:42:00 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=WdvZomH7; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OqmEHBdt; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=WdvZomH7; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=OqmEHBdt; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psn0RB3z30CX for ; Wed, 23 Jun 2021 13:39:25 +1000 (AEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 6D1C6F5F; Tue, 22 Jun 2021 23:39:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 22 Jun 2021 23:39:22 -0400 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-transfer-encoding; s=fm3; bh=D2rV8itMeaMiS JE6lTJuFr6bSVoMV6928n7JfRv1hqo=; b=WdvZomH7HrsyROSYBAnfatxkM3jJq 31G7H5aED+H4R5HTJzUgdBsd0LK3Sd35kxr4R1s2BUv640j2ZhYz5Mzy91rWsmxC luckaAv5ZHAQkYje6ARiuHCtykzLMkse1x9C92y2gb2/ZHAifYwA/IdOcQynoYzs FXwISvKH5v+C5XOuq0zAHVHWo+deB0eosUIOPx/4L9XEcaygMICgKe7nZ56QLCEX XCf7b8nl4WKh8nk6Oln6kSVLAhKFDsRSeJqZXu6qWV7mPQXwWccW30G+XutyvRm6 6SZcUU2AXt9h1Y3sCULva8xSRa/BjHaU3XRAsl1w3hzPj/8nLFrIYAS8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=D2rV8itMeaMiSJE6lTJuFr6bSVoMV6928n7JfRv1hqo=; b=OqmEHBdt ZOWnZ79O4ndlWF7npS4TLsYZD+qPvhRvi/dZzpODyPBPNWXpu7NctJ5JD7I0aI2O fUbYTnGia4sqGCrEbh5a7A8BvjoRu0frUePMTuX1ZqlrOzIuK+Fipd1by+0AK/gv 6MoKr+zbHmUz82qdA2y94Eisek4EXtQweiFTxiep3yd7Ng/7UFrA5z34hiogOc2s WU7oLKIdBmWfuXfiNV7bt2vzRP5zREXzNFFzBH/cnC7Qa/Tq7pnXb8oPLsS0muCq sEtF0VDsHhJKhggw/rhYskXNPbRP/F+yh/s2jcN+1iIIMKbNCCIhSZlJuzBvbQBa qCsBQEZcsuLKeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecuvehluhhsthgvrhfuihiivgepvdenucfr rghrrghmpehmrghilhhfrhhomheprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:20 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 6/7] ARM: dts: p10bmc: Switch to KCS 3 for MCTP binding Date: Wed, 23 Jun 2021 13:08:53 +0930 Message-Id: <20210623033854.587464-7-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The reset state of the status bits on KCS 4 is inappropriate for the MCTP LPC binding. Switch to KCS 3 which has a different reset behaviour. Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts | 2 +- arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts index d899c9620286..738785390fa3 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts @@ -4088,7 +4088,7 @@ &xdma { memory-region = <&vga_memory>; }; -&kcs4 { +&kcs3 { status = "okay"; aspeed,lpc-io-reg = <0xca2>; aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts index 9ea3864651d6..9d57f9f6a1c3 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts @@ -1780,7 +1780,7 @@ &xdma { memory-region = <&vga_memory>; }; -&kcs4 { +&kcs3 { status = "okay"; aspeed,lpc-io-reg = <0xca2>; aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; From patchwork Wed Jun 23 03:38:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1495921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=OGo6SqSQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=RzBod8Eo; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8pxV5kpsz9sTD for ; Wed, 23 Jun 2021 13:42:38 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G8pxW3bX8z3bwQ for ; Wed, 23 Jun 2021 13:42:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=OGo6SqSQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=RzBod8Eo; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=OGo6SqSQ; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=RzBod8Eo; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G8psr2KcSz309H for ; Wed, 23 Jun 2021 13:39:28 +1000 (AEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id AB1B6D25; Tue, 22 Jun 2021 23:39:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 22 Jun 2021 23:39:25 -0400 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-transfer-encoding; s=fm3; bh=sDPqIrp/dmfrZ 0TQZoGzAIfFS0OKhVxV0OkEb/0/4Jk=; b=OGo6SqSQhWjY0zWFBYH8/IdDJagJ6 lRWtTfMOKyuccACG1Ov8rcstmVU8lnA6IsHhYh31pjN9Sl3Wz5YWe8v9Vj94TrFx eC5sH4Al4W7U2jH1rj4/f6ej1QHkMgsJI7dpwRR5PH7MmH74uw1fyySZMr8DcJba Uvj2woo9lIsYX/JMl1AGErwpSrwOXjMoDZiAF7KAn8wW3BpCEOKW9gwZiaz7gNoy DO121IKzQVflR6w4Zr7M2vap0Wf8Yqr+46LuAhVnjK5U6uqI/5jkmDz7mz5fx+nX hOw4H24LJFWmuiSkT7fw1jDswOm4g2Js1iEg3kTQFi5rSJnDnx/cxrNaA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=sDPqIrp/dmfrZ0TQZoGzAIfFS0OKhVxV0OkEb/0/4Jk=; b=RzBod8Eo jFzkzYKWMhotIlLYTcmUpACKYuXklnl63ZSTEUrD4MUqCdJq3RDR6N7c/UQD5rcF ckAlc2mEQ7bgTXfp5woEqGxbCT7V12KBb0cmlz7M6BqornZwCHE7JGuP671A6ZrS Z/hivWXOwqYFgBnd1AhWHNmmSY1DBfik6BApw4gXcFjDqaDvcvNromRVsvqZsdiA TQv2asWN9q74WDuH6Tf4lcWlCUE74x3Wa18Vu8Ld4yGtOFQdCEv/VZlQQXVALBn6 z4fwNDS13c76IPQtgCPNVw+pq8P2yTdg0GeERTU5nzd/HKESwZoZ/pul8wXqxu6N V8xT0tTOV8k2Qg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegvddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepuefhtefhudeufeehffeffeetieeufe duleevgfekteefteekleetffehjeeukeehnecuffhomhgrihhnpehgihhthhhusgdrtgho mhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvfiesrghjrdhiugdrrghu X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 23:39:23 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.10 v2 7/7] ARM: dts: p10bmc: Enable KCS channel 2 Date: Wed, 23 Jun 2021 13:08:54 +0930 Message-Id: <20210623033854.587464-8-andrew@aj.id.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623033854.587464-1-andrew@aj.id.au> References: <20210623033854.587464-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Rainier uses KCS channel 2 as the source for the debug-trigger application outlined at [1] and implemented at [2]. [1] https://github.com/openbmc/docs/blob/master/designs/bmc-service-failure-debug-and-recovery.md [2] https://github.com/openbmc/debug-trigger Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts | 5 +++++ arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts index 738785390fa3..43d998e39f65 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-everest.dts @@ -4088,6 +4088,11 @@ &xdma { memory-region = <&vga_memory>; }; +&kcs2 { + status = "okay"; + aspeed,lpc-io-reg = <0xca8 0xcac>; +}; + &kcs3 { status = "okay"; aspeed,lpc-io-reg = <0xca2>; diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts index 9d57f9f6a1c3..5e071b548cb1 100644 --- a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts +++ b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts @@ -1780,6 +1780,11 @@ &xdma { memory-region = <&vga_memory>; }; +&kcs2 { + status = "okay"; + aspeed,lpc-io-reg = <0xca8 0xcac>; +}; + &kcs3 { status = "okay"; aspeed,lpc-io-reg = <0xca2>;