From patchwork Mon Mar 8 15:37:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12122773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C42BC433E0 for ; Mon, 8 Mar 2021 15:39:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C20C865208 for ; Mon, 8 Mar 2021 15:39:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C20C865208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=3WvemEpqLVfO6K27YfXEca/ijPAJEqXyVQSoF3q5jNA=; b=cT/OX9IT2TKVXzVBZ9Gp7dXV8d kMLNq+gVcbqMV0Vv+AGM7tKWNhoEzKBZOI6nofjTvSCc8xkAi7Zhx/UXQS1Y3SaRAen7Bzw1kKyyp ZFNvSfksyV8+7YpsUT10YLPdcQr6iWUkSttrAtawnhVpIpkPAtFsMwSVz6xUmbRtg35Ck1aTbf74V fuKHzxox/qTEfv/dUFoVl2aDo08bZevW5si6aymZEJmq86thNS6WCh4kfP241dZMDvc58UTSw0Do2 H3GxawpmzgN7aw30aN9OZ8XlGqjjktXUTMyyyXHaMBEnfz4VTRWXLRoOUeOiMj2K/5n2Ne4T+xNGs O+/Bsdww==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHww-000erE-1d; Mon, 08 Mar 2021 15:37:38 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHwr-000enw-Pd for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EEC2C65208; Mon, 8 Mar 2021 15:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217850; bh=uxCp6IN5xTdKQhaP3mh22hDmJsBIoNGm5ZELPunoPH8=; h=From:To:Cc:Subject:Date:From; b=ema9w1jQkA2YIY4TsGwK7r16RdZUYOeE24bUjXU/vASrKw5Yh4Zn6e35G3miA6XdC MmiFDsH8RiyRV82zUZu2TuFyERphOLKJTYWFvvBrpKq9XKcmKvYi8Kj4OmIhwmCjXs s9ZP41L447I5fZgwEQv5zxb4c1Q9wg6yCDuRFPrYFrCW+iF7o9ShxGwt5BCHImhohm miZw2sx+zdyf2rCQSqRlvyGbQ5+QL12YplFfJ5H/0FGG/FX/BH8apDNBEtHaHKiAtz /VpCRkOWczDABvnIMEtm4U7+GxjExjFGJcBT/L9qL916WDuHYUEQ9PU7lzJ7QCDsjT A1PVHfHDwvjyA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= Subject: [PATCH mvebu + mvebu/dt64 1/4] firmware: turris-mox-rwtm: fix reply status decoding function Date: Mon, 8 Mar 2021 16:37:00 +0100 Message-Id: <20210308153703.23097-1-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153734_158960_9FC2399C X-CRM114-Status: GOOD ( 11.07 ) 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 The status decoding function mox_get_status() currently contains a dead code path: if the error status is not MBOX_STS_SUCCESS, it always returns -EIO, so the comparison to MBOX_STS_FAIL is never executed and we don't get the actual error code sent by the firmware. Fix this. Signed-off-by: Marek Behún Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") --- drivers/firmware/turris-mox-rwtm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 50bb2a6d6ccf..54b98642ee1b 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -147,11 +147,14 @@ MOX_ATTR_RO(pubkey, "%s\n", pubkey); static int mox_get_status(enum mbox_cmd cmd, u32 retval) { - if (MBOX_STS_CMD(retval) != cmd || - MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + if (MBOX_STS_CMD(retval) != cmd) return -EIO; else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL) return -(int)MBOX_STS_VALUE(retval); + else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD) + return -ENOSYS; + else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + return -EIO; else return MBOX_STS_VALUE(retval); } From patchwork Mon Mar 8 15:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12122777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE9B0C433DB for ; Mon, 8 Mar 2021 15:39:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56D1365208 for ; Mon, 8 Mar 2021 15:39:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56D1365208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=P9SUpkTlDgVU0GpmQdEYtx/m2u9Qnyy789gCbqae288=; b=cifaNFMqdapnMmvIe0jq4YCqf Y7juR5EcWqc+808tpyFWszSvTG7bhmyK7nsx6U1AJmwOiZjExaoyxp979+VsfLBUrPq3qe6bGfyr2 HYEbo0CNP+lP6jemRJMbcbc7f+gJem97TvEsyX6THm/tpNk9oM50wuAlFs5pvdzkmUQxQDri4Vy7I e4sZeSqAo+0y2PDrmtnjmEIqg7DAYamumudvj2cpqZWjCqUaKMyBMGlhq0jzcH8HG5cm6mJf9ulLS Keb05Vh7ZwWSTyzLmmnLNG9/SwG3eiBvYgfFwqHtRmaHU4dckcUp8PwNdKJEJkrkeNLnqDk2XHruN MyyRXUEpw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHxB-000eyw-Le; Mon, 08 Mar 2021 15:37:53 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHwt-000eoR-6V for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:37 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35D6365226; Mon, 8 Mar 2021 15:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217852; bh=DWXhdU4fbTmQ8ZdSnOtkGfJ+kEZcEYeSsHL/SKnku70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiAKEHl7Dw1yPnv0c1FshwfQubOmKCjzW7+BwVd6ue7UcG5L8U5x5/pRsupJYSTt9 BC3tNdgnaRmfEiRGkxMyVlRBTcxqbAFuE9A9Vt9KVrjBDB4MLMHosgBeV5wE0PSmmv Od5puCgYCGy1XKhrVCtCYCVefj54v20F948XiAPye3uX25ZSPwquY3ptNch6Uf0eo/ ya3IeQ9m/Ia7SD6doV8sm1tkSNKUTxFg9wsygIEy5iMyVebbOTWrOtIIhxdV1ebPMs UDEUNn/uLdk79yNa6lskfTGhQlKKVD+EWjUSnBGhZ/75yeZet3UFxe53fLrY+TjXp2 +s2n68411JNyw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= Subject: [PATCH mvebu + mvebu/dt64 2/4] firmware: turris-mox-rwtm: report failures better Date: Mon, 8 Mar 2021 16:37:01 +0100 Message-Id: <20210308153703.23097-2-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210308153703.23097-1-kabel@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153735_440600_E677A7F1 X-CRM114-Status: GOOD ( 13.44 ) 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 Report a notice level message if a command is not supported by the rWTM firmware. This should not be an error, merely a notice, because the firmware can be used on non-CZ.NIC boards that do not have manufacturing information burned. Signed-off-by: Marek Behún Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") --- drivers/firmware/turris-mox-rwtm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 54b98642ee1b..0f9e40a28fb0 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -204,11 +204,14 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval); - if (ret < 0 && ret != -ENODATA) { - return ret; - } else if (ret == -ENODATA) { + if (ret == -ENODATA) { dev_warn(rwtm->dev, "Board does not have manufacturing information burned!\n"); + } else if (ret == -ENOSYS) { + dev_notice(rwtm->dev, + "Firmware does not support the BOARD_INFO command\n"); + } else if (ret < 0) { + return ret; } else { rwtm->serial_number = reply->status[1]; rwtm->serial_number <<= 32; @@ -237,10 +240,13 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval); - if (ret < 0 && ret != -ENODATA) { - return ret; - } else if (ret == -ENODATA) { + if (ret == -ENODATA) { dev_warn(rwtm->dev, "Board has no public key burned!\n"); + } else if (ret == -ENOSYS) { + dev_notice(rwtm->dev, + "Firmware does not support the ECDSA_PUB_KEY command\n"); + } else if (ret < 0) { + return ret; } else { u32 *s = reply->status; From patchwork Mon Mar 8 15:37:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12122775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74FCC433E6 for ; Mon, 8 Mar 2021 15:39:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AD216521D for ; Mon, 8 Mar 2021 15:39:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AD216521D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=TvEDBVrv1BAg4qVauES6UCfh8N7iRXKBQKPYu//dV9w=; b=Bo8PUQFBJLrJbfeuhNNBEPIj1 5bKxVp1liMMPWO6dL07JHJUvNd+Hc5fqEIgFl8zYN/1eFtMylCz1zItwEBY+oh8YWuxCsi0fLPQr2 nM8ANSms0az7I4MUAVeOGveI1qcuzR1nGTZyJbqmSVk3mxnX4EiFnC+SB4jCHUjX3zx65KV5T3U6j ReQSjPpDEee3A7j5aPXiqG+rrw51eyQ9hOD32xbiBa21H9UVLIJ2x0uiLkAa3Sr+aNFhLQdRXv6Y/ cvtc+svfXCpliSRr8DLTVc1W4GhqzZJAPIcQ8hOFxQE/q7LLNbEapMh+FDxBkhEgT20arxfsqpPOG q9bxGWjrw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHx4-000ev6-Vi; Mon, 08 Mar 2021 15:37:47 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHws-000eot-FU for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:36 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F7B465227; Mon, 8 Mar 2021 15:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217853; bh=UvlwAXuTf/WSevmLoNHuimORXWgQj45bWzZau2BFOgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cae6qEZm+8a0oMdRbuWEC64bFMfIIHlmiV3AZp80R23VDI72HhNPHSOuL68m72O5u MTC5aucROijigr4aUZfMh9lBWtLhCU8khMnUlKNP6oIf+2eRlYNzUwumsx/Oqe/wxg ZVFBCiNnaTwMaWe3hT4xYHeQ/DWMBJnp0eYBoFsJHsNlmHFk/6uvqIFYWNa/7YTUze 116wBZkc/P1zwCyx+hctJVGiWRH3iV96Bp+ZG3p7v0+4N9siggO2oAN7K2f3nmwc8s 1u8Uwa5aD/dEg44tcqBZE6xOipAkjzjhunCbL8HZH2UvCWv0Utv8ZBvsu/TDpbUngh a0wmJjfy4o8nA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= Subject: [PATCH mvebu + mvebu/dt64 3/4] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Date: Mon, 8 Mar 2021 16:37:02 +0100 Message-Id: <20210308153703.23097-3-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210308153703.23097-1-kabel@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153735_314107_C82B4975 X-CRM114-Status: GOOD ( 14.37 ) 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 From: Pali Rohár When Marvell's rWTM firmware, which does not support the GET_RANDOM command, is used, kernel prints an error message hwrng: no data available every 10 seconds. Fail probing of this driver if the rWTM firmware does not support the GET_RANDOM command. This makes it possible to put this driver's compatible into generic armada-37xx device tree, to be available for other Armada 3720 devices besides Turris MOX. If they use the rWTM firmware from CZ.NIC, they will have HWRNG available, and if not, the driver won't be complaining. Signed-off-by: Pali Rohár Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Signed-off-by: Marek Behún --- drivers/firmware/turris-mox-rwtm.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 0f9e40a28fb0..2b56dd05961f 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -260,6 +260,27 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return 0; } +static int check_get_random_support(struct mox_rwtm *rwtm) +{ + struct armada_37xx_rwtm_tx_msg msg; + int ret; + + msg.command = MBOX_CMD_GET_RANDOM; + msg.args[0] = 1; + msg.args[1] = rwtm->buf_phys; + msg.args[2] = 4; + + ret = mbox_send_message(rwtm->mbox, &msg); + if (ret < 0) + return ret; + + ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); + if (ret < 0) + return ret; + + return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval); +} + static int mox_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait) { struct mox_rwtm *rwtm = (struct mox_rwtm *) rng->priv; @@ -497,6 +518,13 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev) if (ret < 0) dev_warn(dev, "Cannot read board information: %i\n", ret); + ret = check_get_random_support(rwtm); + if (ret < 0) { + dev_notice(dev, + "Firmware does not support the GET_RANDOM command\n"); + goto free_channel; + } + rwtm->hwrng.name = DRIVER_NAME "_hwrng"; rwtm->hwrng.read = mox_hwrng_read; rwtm->hwrng.priv = (unsigned long) rwtm; From patchwork Mon Mar 8 15:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12122779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D18C433DB for ; Mon, 8 Mar 2021 15:39:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A1D36521D for ; Mon, 8 Mar 2021 15:39:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A1D36521D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=0wQoLWAMU2ObWpk2IcZkzzbrs70CK0NMugduwGBRJzk=; b=OWIu/9+9A3axC5zU/8WKzBZg+ WejgLySdspPz2ZmlbEAELRlhI+F4SLGC/lYkPeZK1jEaeqtsGk245Savy36JlUeEk6vCcLdb38WGL j9rhnylMcFB64aZ7EGMVAZJe5ul6vmU/FQ/FA6XEet55/LCQdUXaiNPyYS6v127v+U6ynsbHFMCjx mY+HDvTt6g4AK7ETREVo3SoMYaT+QvaGk3m86zXA6v/CWWLeVFfxCUiZS0qRR0JU+vQXD30n1/vub Q5+7QF2BCnObvle0AhUvknj1KKpaKk8Xv/8lZAeTCheZRbrOU1+xQGNeoX6C6I62l4t2CAT+zd9gy vvdVOjyfg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHxL-000f3e-HG; Mon, 08 Mar 2021 15:38:03 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHwt-000epb-RM for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:37 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8CC36522D; Mon, 8 Mar 2021 15:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217854; bh=A46gTqxo7AwHyKvIEVnYzBRWhGG50dROOHU9I3dE1aU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BL48PRgFuU+5ddLyYRtlzjamdQFCv1UufBC/vewp6sa3deQpBDwcBeHJSrHzw1T8y eGL3y5mteIm5imB4cp38x8iKRA+Usr08YFv3HlC1DnsLrfshrkOBjYlh64KNTt2tNy SQEFNVTiyiE/V59tz6Lh4z9iH8tgbQXRTT2n8I3td/01cr528Ae9P1eD1f03OAdbce H4mH2H9B9ySHyscNj+g5GoEJQ4Aphf+dhYv+Lo9A3wxqEgedgjSl66Cn0nJ35EYO72 F/5m4Zg59gqpOtMV3qvspsX7p2dg2i/NhGhJi8t/73vWDV69QcEBK14llyttEh/kgP hHW5Sok1U8P0A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= , stable@vger.kernel.org Subject: [PATCH mvebu + mvebu/dt64 4/4] arm64: dts: marvell: armada-37xx: move firmware node to generic dtsi file Date: Mon, 8 Mar 2021 16:37:03 +0100 Message-Id: <20210308153703.23097-4-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210308153703.23097-1-kabel@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153736_111858_446D6788 X-CRM114-Status: GOOD ( 13.67 ) 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 From: Pali Rohár Move the turris-mox-rwtm firmware node from Turris MOX' device tree into the generic armada-37xx.dtsi file. The Turris MOX rWTM firmware can be used on any Armada 37xx device, giving them access to the rWTM hardware random number generator, which is otherwise unavailable. This change allows Linux to load the turris-mox-rwtm.ko module on these boards. Tested on ESPRESSObin v5 with both default Marvell WTMI firmware and CZ.NIC's firmware. With default WTMI firmware the turris-mox-rwtm fails to probe, while with CZ.NIC's firmware it registers the HW random number generator. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Cc: # 5.4+: 46d2f6d0c99f ("arm64: dts: armada-3720-turris-mox: add firmware node") --- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 8 -------- arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts index d239ab70ed99..8447f303a294 100644 --- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts @@ -107,14 +107,6 @@ sfp: sfp { /* enabled by U-Boot if SFP module is present */ status = "disabled"; }; - - firmware { - turris-mox-rwtm { - compatible = "cznic,turris-mox-rwtm"; - mboxes = <&rwtm 0>; - status = "okay"; - }; - }; }; &i2c0 { diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi index 7a2df148c6a3..31126f1ffe5b 100644 --- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi +++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi @@ -503,4 +503,12 @@ pcie_intc: interrupt-controller { }; }; }; + + firmware { + turris-mox-rwtm { + compatible = "cznic,turris-mox-rwtm"; + mboxes = <&rwtm 0>; + status = "okay"; + }; + }; };