From patchwork Thu Oct 5 03:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 13409725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7A13E936F8 for ; Thu, 5 Oct 2023 03:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jd+NgW+0yM6INSTa3sVflaM/UC7+QCgv5lIUSMgBKaI=; b=4s5mgaZA/LFjtb fnUNfnPV7nnogR9M2vNsd2ddA+brlkWvUyNBhBSdY9xaSmpTxZeIPixbXalBGDjOpoQ6nkwbRQb/x fNonbL1i6QnG++gQferlXAnqJhXuIzMEMBxPVqq3Zz/hIdq4aN+4KLwrQRHdecccxSbx6CK114fo/ hXTDIal7COch8pBkugOnvPxhM6WwVE61B3CgFjKLepQI5g+JLHWjWqTiQXoqLfXJkA/LbeGGezzbe QLHRfUSyJkSzdwfYGNfy2tI3FBh48sk7qyZ91OjFz+dRdxaKiXydQJoEQjdhS1nXxTH+hx4nmiImk Y/cIiXH1iCuIu/G6DWzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoEja-001Hkf-2e; Thu, 05 Oct 2023 03:09:06 +0000 Received: from thorn.bewilderbeest.net ([71.19.156.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoEjY-001Hjx-03 for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 03:09:05 +0000 Received: from hatter.bewilderbeest.net (unknown [IPv6:2602:61:7e5d:5300::2]) (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) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 5DDAE224; Wed, 4 Oct 2023 20:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1696475343; bh=jhW/GPSan/u14E5ed+1vqJkRblZ4OlBm+NkX/QKFAVY=; h=From:To:Cc:Subject:Date:From; b=cN/CuYrP1UDn3bJhJ7G8Di0ztdAFDtjbcP3bpeecFQ01bwwnxIertZ5eLxUFNqXwM EYBalbsSMgxxMG9pzSsl6yFMqFmgE78XfOVuOXBnROZCnmGLevKW5pVOuw1ZNIOcc5 Jci94/J1+ZzoQ3UXA0Vr5K5D4v++GqR6G8ZB2fYc= From: Zev Weiss To: Andrew Jeffery , Linus Walleij , Joel Stanley , linux-aspeed@lists.ozlabs.org Cc: Zev Weiss , openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] pinctrl: aspeed: Allow changing SPI mode from hardware strap defaults Date: Wed, 4 Oct 2023 20:08:50 -0700 Message-ID: <20231005030849.11352-2-zev@bewilderbeest.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_200904_061394_28A634DD X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some platforms unfortunately have their SPI mode selection bits strapped incorrectly (such as being configured for passthrough mode when master mode is in fact the only useful configuration for it) and thus require correction in software. Add the SPI mode bits to the GPIO passthrough bits as the exceptions to the read-only rule for the hardware strap register so that the pinctrl subsystem can be used for such corrections. Signed-off-by: Zev Weiss Reviewed-by: Andrew Jeffery --- Changes since v1 [1]: - Refined to an additional per-bit exception instead of allowing arbitrary strap register alterations [Andrew] [1] https://lore.kernel.org/lkml/20231004071605.21323-2-zev@bewilderbeest.net/ drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c | 19 ++++++++++++------- drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c index bfed0e274643..774f8d05142f 100644 --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c @@ -2563,15 +2563,20 @@ static int aspeed_g4_sig_expr_set(struct aspeed_pinmux_data *ctx, * deconfigured and is the reason we re-evaluate after writing * all descriptor bits. * - * Port D and port E GPIO loopback modes are the only exception - * as those are commonly used with front-panel buttons to allow - * normal operation of the host when the BMC is powered off or - * fails to boot. Once the BMC has booted, the loopback mode - * must be disabled for the BMC to control host power-on and - * reset. + * We make two exceptions to the read-only rule: + * + * - The passthrough mode of GPIO ports D and E are commonly + * used with front-panel buttons to allow normal operation + * of the host if the BMC is powered off or fails to boot. + * Once the BMC has booted, the loopback mode must be + * disabled for the BMC to control host power-on and reset. + * + * - The operating mode of the SPI1 interface is simply + * strapped incorrectly on some systems and requires a + * software fixup, which we allow to be done via pinctrl. */ if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP1 && - !(desc->mask & (BIT(21) | BIT(22)))) + !(desc->mask & (BIT(22) | BIT(21) | BIT(13) | BIT(12)))) continue; if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP2) diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c index 4c0d26606b6c..5bb8fd0d1e41 100644 --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c @@ -2742,15 +2742,20 @@ static int aspeed_g5_sig_expr_set(struct aspeed_pinmux_data *ctx, * deconfigured and is the reason we re-evaluate after writing * all descriptor bits. * - * Port D and port E GPIO loopback modes are the only exception - * as those are commonly used with front-panel buttons to allow - * normal operation of the host when the BMC is powered off or - * fails to boot. Once the BMC has booted, the loopback mode - * must be disabled for the BMC to control host power-on and - * reset. + * We make two exceptions to the read-only rule: + * + * - The passthrough mode of GPIO ports D and E are commonly + * used with front-panel buttons to allow normal operation + * of the host if the BMC is powered off or fails to boot. + * Once the BMC has booted, the loopback mode must be + * disabled for the BMC to control host power-on and reset. + * + * - The operating mode of the SPI1 interface is simply + * strapped incorrectly on some systems and requires a + * software fixup, which we allow to be done via pinctrl. */ if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP1 && - !(desc->mask & (BIT(21) | BIT(22)))) + !(desc->mask & (BIT(22) | BIT(21) | BIT(13) | BIT(12)))) continue; if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP2)