From patchwork Wed Jun 22 09:42:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 12890414 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 46B4FC433EF for ; Wed, 22 Jun 2022 09:44:02 +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: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=F1NeRRqkRQkTkRwz+Vw2O0WHXtF3rw3MPxvTRP1vzns=; b=O3WWh6d54D/15E sobmjepfoZ6t3mtNMxfkhkWDIFD6+jj81TjB/R8UKqDnpqaFIjs3NzQFlv86Dig0FJzZLa7+QZibp iLMAkmHLb5OBZ98VW2NlQwHpCT5VcRtddG995PJBIJEr+kDRymqh3bP0ndXgyZKtyqIQtwUpvg2fz tSfOnsja8zYv+CckI8jt1t2msFYXadN3d1v1BAghP6pOqmWiaJa9acqwAGL4i5CAeZo/gNJypadCT 4rgSUePZWok/pLcM3xJ7eydhYsLuWJtL4Zr/lQ17kPwip33qoSyajHVSpKc2VI36Z8lFnEV4VorXY XsLurCy3s3sBERjHFX6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3wt8-009g6p-KT; Wed, 22 Jun 2022 09:43:06 +0000 Received: from mail.ozlabs.org ([2404:9400:2221:ea00::3] helo=gandalf.ozlabs.org) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3wsx-009g2h-DO for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 09:42:57 +0000 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4LSdj60YbKz4xZh; Wed, 22 Jun 2022 19:42:50 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (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 mail.ozlabs.org (Postfix) with ESMTPSA id 4LSdj25Vydz4xZb; Wed, 22 Jun 2022 19:42:46 +1000 (AEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: linux-spi@vger.kernel.org Cc: Mark Brown , Pratyush Yadav , linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Date: Wed, 22 Jun 2022 11:42:32 +0200 Message-Id: <20220622094233.3681843-2-clg@kaod.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220622094233.3681843-1-clg@kaod.org> References: <20220622094233.3681843-1-clg@kaod.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220622_024255_671420_A4EA7283 X-CRM114-Status: GOOD ( 10.66 ) 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 It helps to analyze the default setting of the control register. Signed-off-by: Cédric Le Goater Reviewed-by: Paul Menzel --- drivers/spi/spi-aspeed-smc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index 496f3e1e9079..ac64be289e59 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) u32 ctl_val; int ret = 0; + dev_dbg(aspi->dev, + "CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n", + chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write", + desc->info.offset, desc->info.offset + desc->info.length, + op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, + op->dummy.buswidth, op->data.buswidth, + op->addr.nbytes, op->dummy.nbytes); + chip->clk_freq = desc->mem->spi->max_speed_hz; /* Only for reads */ From patchwork Wed Jun 22 09:42:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 12890415 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 86E68C433EF for ; Wed, 22 Jun 2022 09:44:04 +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: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=L6KG98wNJM7bBfHOFNd9e0PqIItFX+zBhdsDZEUvwiE=; b=Kt9WV598tLgxuV dmvl+IOC6J7DCi04PTaefWmzqDtpbL3+I2DEl/KIwljETiJ/7kj/kXXA+B9h+/d1SytIIlYFmnQOK eZlACLTlWz0UHaWzvW8shAZRrcfB558gy9HCoG1vryvpYuW1du0Lpp3YLeGimIc2sb1l2DMRUuOev 08cj6LWma/rZygx0WhT/xWjIm2ATXUWfBqMlGdJ1Yyi6YnC8D+5v0Bspz3J+bIbpPudM7X/+JTK3G 7180WWcb8Q8IuWlepgWS+59pCNzxajEdjygMAsaLjXP75+xpIovtmeUxgu/SKAjelL/GBIyPfWhxr tcan3D78POeQUvTk028Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3wtH-009g9d-Ls; Wed, 22 Jun 2022 09:43:15 +0000 Received: from gandalf.ozlabs.org ([150.107.74.76]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3wsz-009g3W-II for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 09:42:58 +0000 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4LSdjB4S8Bz4xZj; Wed, 22 Jun 2022 19:42:54 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (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 mail.ozlabs.org (Postfix) with ESMTPSA id 4LSdj64JWlz4xZb; Wed, 22 Jun 2022 19:42:50 +1000 (AEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: linux-spi@vger.kernel.org Cc: Mark Brown , Pratyush Yadav , linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ian Woloschin , Ian Woloschin Subject: [PATCH v2 2/2] spi: aspeed: Fix division by zero Date: Wed, 22 Jun 2022 11:42:33 +0200 Message-Id: <20220622094233.3681843-3-clg@kaod.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220622094233.3681843-1-clg@kaod.org> References: <20220622094233.3681843-1-clg@kaod.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220622_024257_777311_82E511BA X-CRM114-Status: GOOD ( 11.76 ) 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 When using the normal read operation for data transfers, the dummy bus width is zero. In that case, they are no dummy bytes to transfer and setting the dummy field in the controller register becomes useless. Issue was found on a custom "Bifrost" board based on the AST2500 SoC and using a MX25L51245GMI-08G SPI Flash. Reported-by: Ian Woloschin Reviewed-by: Pratyush Yadav Tested-by: Ian Woloschin Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping") Signed-off-by: Cédric Le Goater --- drivers/spi/spi-aspeed-smc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index ac64be289e59..3e891bf22470 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -582,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK; ctl_val |= aspeed_spi_get_io_mode(op) | op->cmd.opcode << CTRL_COMMAND_SHIFT | - CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) | CTRL_IO_MODE_READ; + if (op->dummy.nbytes) + ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth); + /* Tune 4BYTE address mode */ if (op->addr.nbytes) { u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);