From patchwork Wed Jun 12 15:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13695240 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 A36D9C27C53 for ; Wed, 12 Jun 2024 15:49: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=bPd30CSv0LijxN7s3vWkKyIWkH3yTosBJMpzpCFG4Dc=; b=HfZejzCiU5NjXn FDiM5pvP3GC63/jKnVTr4PxM0YrccUYwL7ai+q2rj3Yy03hCR7nsu8dhpPphKsBHJPT/KLMeOHrAM nBKOBTn+/vph3qhhjqnF5UQ4s3UMIWXn4oosKawIEW6fI6G/8+FweTDc9lIp5iVRr+hY4KHBuiEZ8 LYDYz6EXaosFSlu+KNQ1N2dG/EaEhMDZm3ZuwXLmbFuAQ9EbJqQnmbrR64ld2DCJJAnIIo/4Vqv0J EG8Hgxdcq2Ukdl4FS2vpitLv0N+sKhQZqE1L0uipv/l8ARIpEXeyMoFKw2x3c3hvILtnMGmXtzA0S Gx29NWYfMSGo7rqbnBzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDZ-0000000DEVb-1ZwB; Wed, 12 Jun 2024 15:48:57 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDX-0000000DEV6-1OeG for linux-riscv@lists.infradead.org; Wed, 12 Jun 2024 15:48:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9A679614DD; Wed, 12 Jun 2024 15:48:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9393DC4AF1A; Wed, 12 Jun 2024 15:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718207334; bh=P1vOj2Rn7zuoaBh6AcqrcUTEi1rovxUtpHsy8CmdHr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RM5rd5EJCfJaPHSF6RHPKysoR8lv3CkSLd4g2Berb4nT2sHLtIYnFt6NS60oRpl9g oELj9VAHV47yQv/PW5bqKN4G8Pzc0J1OY+DCv21YxQEmcmfzvEUyCFc6XGpr3gaL8v m42aKyyJ1o1WH/8kPZXWMVyo3tMASfqukyObPz/hrVo29vqFl0+HXgLAaFlXJvcA2h 5/zX4wXMTZOpYBUz+HtYelymZidotMFyoqz6B3QVwizDw5s+ubMk2Io9m2dkQ83SVE Jpi6Eyt0tUJpbyJ0XNr/yRaFoytL9m/duTvKpg9sooyAurw9t6/PBbTepntmShB9Rn 7x12qvQbD/Rxw== From: Conor Dooley To: linux-mmc@vger.kernel.org Cc: conor@kernel.org, Conor Dooley , Ulf Hansson , cyril.jean@microchip.com, Mark Brown , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-spi@vger.kernel.org Subject: [RFC v1 1/3] mmc: mmc_spi: allow for spi controllers incapable of getting as low as 400k Date: Wed, 12 Jun 2024 16:48:31 +0100 Message-ID: <20240612-dense-resample-563f07c30185@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612-brigade-shell-1f626e7e592f@spud> References: <20240612-brigade-shell-1f626e7e592f@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1284; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=tXCkjnYnQevs4Hom30XLCG5d2XL7igKpnQRl5B2TRkw=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGmZh32YQ6LF1YxuVN44oVfcacC3NEQq8fP2UjmeHOsvU xz69Sd3lLIwiHEwyIopsiTe7muRWv/HZYdzz1uYOaxMIEMYuDgFYCIsPIwMn456V+r3ir64lrdo KmPhpIDV4u8mNB94t0Rwf1q/maEiD8NfmZ3axzc5JC2xrbjnZyYflvhFedPN8EPp4tfsC9ds3DW BGQA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_084855_467659_752CF676 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley Some controllers may not be able to reach a bus clock as low as 400 KHz due to a lack of sufficient divisors. In these cases, the SD card slot becomes non-functional as Linux continuously attempts to set the bus clock to 400 KHz. If the controller is incapable of getting that low, set its minimum frequency instead. While this may eliminate some SD cards, it allows those capable of operating at the controller's minimum frequency to be used. Signed-off-by: Conor Dooley --- drivers/mmc/host/mmc_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 09d7a6a0dc1a..c9caa1ece7ef 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1208,7 +1208,10 @@ static int mmc_spi_probe(struct spi_device *spi) * that's the only reason not to use a few MHz for f_min (until * the upper layer reads the target frequency from the CSD). */ - mmc->f_min = 400000; + if (spi->controller->min_speed_hz > 400000) + dev_warn(&spi->dev,"Controller unable to reduce bus clock to 400 KHz\n"); + + mmc->f_min = max(spi->controller->min_speed_hz, 400000); mmc->f_max = spi->max_speed_hz; host = mmc_priv(mmc); From patchwork Wed Jun 12 15:48:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13695241 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 C51A8C27C7B for ; Wed, 12 Jun 2024 15:49:03 +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=WDnHwtIDTZdDmKJ4frADPK4z4F5ChW8RL27Z6mpyui4=; b=NX48U6qBRH+wXB Yi1kJ0Fryo/1LItKcLCVUCaGVgxaiF5+07S3gXwpct6J1Cukgv7e5MxWVOlptjAsySX7j4/RLV1Eo SHYTmjuMIJvoBXCoMN1L+iwFcbvGIgcaDyG1vM6Y7JILf5vCusEEtS03eCMqX0265M+v8BjbYg3K+ rMsOkIDolUgSfdqfHFTJbjGQJtDs7xO0P0udFAGTrk5vrbvLYeKaWVNi5+6w681GfInePVTlnC0Vv bSXaEULiw7nt4q3TPZFB+5GFZkeekD9gYQXu0kgcVSWITh5EvRORGbNXwUjt+D3+BX55rDxk+ugqu RaFvkkss+ZRgDZtjewsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDc-0000000DEXq-0h3o; Wed, 12 Jun 2024 15:49:00 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDa-0000000DEVj-0Z5e for linux-riscv@lists.infradead.org; Wed, 12 Jun 2024 15:48:59 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6A347614D7; Wed, 12 Jun 2024 15:48:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64BC6C116B1; Wed, 12 Jun 2024 15:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718207337; bh=Q80LEcSfWLwrGQtxBO719jXJBFBRKXkIm/AvzbhGOt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4LeZg6ZmpiDECtGr1npo3EJ+dB9xzOEoODDtCwMNjkwRHgnNKJ9dW1Zq8cV2R2yB ZHOexrEkJ9NTn37oh6yuvbPoAsUchxEDVLcvRIqkxR9TgjZj6Twty3W4K7yl3SZGbY 3EsZGEGxYhw4D/891sogIQ//LftabpA3PpL89wi0NyCBQWRvB2OE8llEFxCgvDXL9P S8av/vlaJo5lnBGWYF+v+DwyaLW196usIsp4lU6iUHYSqCSVCHpxACuKnSJ3hmbA/C k/VhFW6jmcpB+nq5N1N1DBojnS71/JGcsGIy+ocmPwCvqZOpKo1Dy7TuYImrLU3oxK 7IqxuNrAm7PyA== From: Conor Dooley To: linux-mmc@vger.kernel.org Cc: conor@kernel.org, Conor Dooley , Ulf Hansson , cyril.jean@microchip.com, Mark Brown , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-spi@vger.kernel.org Subject: [RFC v1 2/3] spi: microchip-core-qspi: Add regular transfers Date: Wed, 12 Jun 2024 16:48:32 +0100 Message-ID: <20240612-uphold-dinner-a47b4c44be18@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612-brigade-shell-1f626e7e592f@spud> References: <20240612-brigade-shell-1f626e7e592f@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8823; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=uI9WGvVZLyn7qdrTfj6zoMBWM0en+Fn3mbBJbuvgJdI=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGmZh329aqKFtOr3zPFcd03R+MeXtvUMzO1yyU9eaYouW OHIx2zSUcrCIMbBICumyJJ4u69Fav0flx3OPW9h5rAygQxh4OIUgImofmf4w7tuWuKHDeU1M5Sz tyv+vPU09swr+8By+45rWcLzfuyuKGH4XzrHrtKSI6pL76zc4xxjzqD/CUXb7rx9aLCdQajyf/k JNgA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_084858_359857_086661D8 X-CRM114-Status: GOOD ( 26.81 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Cyril Jean The driver for CoreQSPI only supports memory operations at present, so add support for regular transfers so that the SD card slot and ADC on the BeagleV Fire can be used. Signed-off-by: Cyril Jean Co-developed-by: Conor Dooley Signed-off-by: Conor Dooley --- drivers/spi/spi-microchip-core-qspi.c | 223 +++++++++++++++++++++++++- 1 file changed, 221 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-microchip-core-qspi.c b/drivers/spi/spi-microchip-core-qspi.c index 09f16471c537..1b23a38c155c 100644 --- a/drivers/spi/spi-microchip-core-qspi.c +++ b/drivers/spi/spi-microchip-core-qspi.c @@ -222,6 +222,86 @@ static inline void mchp_coreqspi_write_op(struct mchp_coreqspi *qspi, bool word) } } +static inline void mchp_coreqspi_write_read_op(struct mchp_coreqspi *qspi) +{ + u32 control, data; + + qspi->rx_len = qspi->tx_len; + + control = readl_relaxed(qspi->regs + REG_CONTROL); + control |= CONTROL_FLAGSX4; + writel_relaxed(control, qspi->regs + REG_CONTROL); + + while (qspi->tx_len >= 4) { + while (readl_relaxed(qspi->regs + REG_STATUS) & STATUS_TXFIFOFULL) + ; + + data = *(u32 *)qspi->txbuf; + qspi->txbuf += 4; + qspi->tx_len -= 4; + writel_relaxed(data, qspi->regs + REG_X4_TX_DATA); + + /* + * The rx FIFO is twice the size of the tx FIFO, so there is + * no requirement to block transmission if receive data is not + * ready, and it is fine to let the tx FIFO completely fill + * without reading anything from the rx FIFO. Once the tx FIFO + * has been filled and becomes non-full due to a transmission + * occurring there will always be something to receive. + * IOW, this is safe as TX_FIFO_SIZE + 4 < 2 * TX_FIFO_SIZE + */ + if (qspi->rx_len >= 4) { + if (readl_relaxed(qspi->regs + REG_STATUS) & STATUS_RXAVAILABLE) { + data = readl_relaxed(qspi->regs + REG_X4_RX_DATA); + *(u32 *)qspi->rxbuf = data; + qspi->rxbuf += 4; + qspi->rx_len -= 4; + } + } + } + + /* + * Since transmission is not being blocked by clearing the rx FIFO, + * loop here until all received data "leaked" by the loop above has + * been dealt with. + */ + while (qspi->rx_len >= 4) { + while (readl_relaxed(qspi->regs + REG_STATUS) & STATUS_RXFIFOEMPTY) + ; + data = readl_relaxed(qspi->regs + REG_X4_RX_DATA); + *(u32 *)qspi->rxbuf = data; + qspi->rxbuf += 4; + qspi->rx_len -= 4; + } + + /* + * Since rx_len and tx_len must be < 4 bytes at this point, there's no + * concern about overflowing the rx or tx FIFOs any longer. It's + * therefore safe to loop over the remainder of the transmit data before + * handling the remaining receive data. + */ + if (!qspi->tx_len) + return; + + control &= ~CONTROL_FLAGSX4; + writel_relaxed(control, qspi->regs + REG_CONTROL); + + while (qspi->tx_len--) { + while (readl_relaxed(qspi->regs + REG_STATUS) & STATUS_TXFIFOFULL) + ; + data = *qspi->txbuf++; + writel_relaxed(data, qspi->regs + REG_TX_DATA); + } + + while (qspi->rx_len--) { + while (readl_relaxed(qspi->regs + REG_STATUS) & STATUS_RXFIFOEMPTY) + ; + data = readl_relaxed(qspi->regs + REG_RX_DATA); + *qspi->rxbuf++ = (data & 0xFF); + } +} + + static void mchp_coreqspi_enable_ints(struct mchp_coreqspi *qspi) { u32 mask = IEN_TXDONE | @@ -366,7 +446,7 @@ static inline void mchp_coreqspi_config_op(struct mchp_coreqspi *qspi, const str writel_relaxed(frames, qspi->regs + REG_FRAMES); } -static int mchp_qspi_wait_for_ready(struct spi_mem *mem) +static int mchp_coreqspi_wait_for_ready(struct spi_mem *mem) { struct mchp_coreqspi *qspi = spi_controller_get_devdata (mem->spi->controller); @@ -395,7 +475,7 @@ static int mchp_coreqspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *o int err, i; mutex_lock(&qspi->op_lock); - err = mchp_qspi_wait_for_ready(mem); + err = mchp_coreqspi_wait_for_ready(mem); if (err) goto error; @@ -498,6 +578,142 @@ static const struct spi_controller_mem_ops mchp_coreqspi_mem_ops = { .exec_op = mchp_coreqspi_exec_op, }; + +static void mchp_coreqspi_activate_cs(struct spi_device *spi) +{ + if (spi_get_csgpiod(spi, 0)) + gpiod_set_value(spi_get_csgpiod(spi, 0), 1); +} + +static void mchp_coreqspi_deactivate_cs(struct spi_device *spi) +{ + if (spi_get_csgpiod(spi, 0)) + gpiod_set_value(spi_get_csgpiod(spi, 0), 0); +} + +static int mchp_coreqspi_transfer_one_message(struct spi_controller *ctlr, + struct spi_message *m) +{ + struct mchp_coreqspi *qspi = spi_controller_get_devdata(ctlr); + struct spi_transfer *t = NULL; + u32 control, frames, status; + u32 total_bytes = 0, cmd_bytes = 0, idle_cycles = 0; + int ret; + bool quad = false, dual = false; + bool cs_change = true; + + mutex_lock(&qspi->op_lock); + ret = readl_poll_timeout(qspi->regs + REG_STATUS, status, + (status & STATUS_READY), 0, + TIMEOUT_MS); + if (ret) { + mutex_unlock(&qspi->op_lock); + dev_err(&ctlr->dev, + "Timeout waiting on QSPI ready.\n"); + return -ETIMEDOUT; + } + + ret = mchp_coreqspi_setup_clock(qspi, m->spi); + if (ret) + goto error; + + control = readl_relaxed(qspi->regs + REG_CONTROL); + control &= ~(CONTROL_MODE12_MASK | CONTROL_MODE0); + writel_relaxed(control, qspi->regs + REG_CONTROL); + + reinit_completion(&qspi->data_completion); + + /* Check the total bytes and command bytes */ + list_for_each_entry(t, &m->transfers, transfer_list) { + total_bytes += t->len; + if ((!cmd_bytes) && !(t->tx_buf && t->rx_buf)) + cmd_bytes = t->len; + if (!t->rx_buf) + cmd_bytes = total_bytes; + if (t->tx_nbits == SPI_NBITS_QUAD || t->rx_nbits == SPI_NBITS_QUAD) + quad = true; + else if (t->tx_nbits == SPI_NBITS_DUAL || t->rx_nbits == SPI_NBITS_DUAL) + dual = true; + } + + control = readl_relaxed(qspi->regs + REG_CONTROL); + if (quad) { + control |= (CONTROL_MODE0 | CONTROL_MODE12_EX_RW); + } else if (dual) { + control &= ~CONTROL_MODE0; + control |= CONTROL_MODE12_FULL; + } else { + control &= ~(CONTROL_MODE12_MASK | CONTROL_MODE0); + } + + writel_relaxed(control, qspi->regs + REG_CONTROL); + frames = total_bytes & BYTESUPPER_MASK; + writel_relaxed(frames, qspi->regs + REG_FRAMESUP); + frames = total_bytes & BYTESLOWER_MASK; + frames |= cmd_bytes << FRAMES_CMDBYTES_SHIFT; + frames |= idle_cycles << FRAMES_IDLE_SHIFT; + control = readl_relaxed(qspi->regs + REG_CONTROL); + if (control & CONTROL_MODE12_MASK) + frames |= (1 << FRAMES_SHIFT); + + frames |= FRAMES_FLAGWORD; + writel_relaxed(frames, qspi->regs + REG_FRAMES); + + //TODO: questionable robustness if both cs_change and cs_off toggle + list_for_each_entry(t, &m->transfers, transfer_list) { + //cs_change being set means we need to re-enable + if (cs_change && !t->cs_off) + mchp_coreqspi_activate_cs(m->spi); + else if (cs_change) //cs_off set but we changed it after last xfer so it may be on + mchp_coreqspi_deactivate_cs(m->spi); + + if ((t->tx_buf) && (t->rx_buf)){ + qspi->txbuf = (u8 *)t->tx_buf; + qspi->rxbuf = (u8 *)t->rx_buf; + qspi->tx_len = t->len; + mchp_coreqspi_write_read_op(qspi); + } else if (t->tx_buf) { + qspi->txbuf = (u8 *)t->tx_buf; + qspi->tx_len = t->len; + mchp_coreqspi_write_op(qspi, true); + } else { + qspi->rxbuf = (u8 *)t->rx_buf; + qspi->rx_len = t->len; + mchp_coreqspi_read_op(qspi); + } + + spi_transfer_delay_exec(t); + + cs_change = t->cs_change; + if (cs_change) { + if (list_is_last(&t->transfer_list, &m->transfers)) { + break; //special meaning, see below + } + + // cs_change is set, so disable between xfers + if (!t->cs_off) + mchp_coreqspi_deactivate_cs(m->spi); + else + mchp_coreqspi_activate_cs(m->spi); + + spi_transfer_cs_change_delay_exec(m, t); + } + } + + udelay(750); + + m->actual_length = total_bytes; + +error: + if (ret != 0 || !cs_change) //special case of cs_change for last xfer, set means dont touch line state + mchp_coreqspi_deactivate_cs(m->spi); + + m->status = ret; + spi_finalize_current_message(ctlr); + mutex_unlock(&qspi->op_lock); + return ret; +} + static int mchp_coreqspi_probe(struct platform_device *pdev) { struct spi_controller *ctlr; @@ -544,6 +760,9 @@ static int mchp_coreqspi_probe(struct platform_device *pdev) ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_DUAL | SPI_TX_QUAD; ctlr->dev.of_node = np; + ctlr->transfer_one_message = mchp_coreqspi_transfer_one_message; + ctlr->num_chipselect = 2; + ctlr->use_gpio_descriptors = true; ret = devm_spi_register_controller(&pdev->dev, ctlr); if (ret) From patchwork Wed Jun 12 15:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13695242 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 05972C27C77 for ; Wed, 12 Jun 2024 15:49:08 +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=v8eAcZMo/2IA9d26beQPCeI6wH82qMiIFLI9+PigSwU=; b=nhjDrKNk2tJYKs gEjHzQB1y8LRzrUfrmJPJKmQ5c++O2nQyMssyUiXNOzNpbaBygKzqWDUE9x0xf6je59Y/f69/1cl9 1dB+Wu8VH/JCq2+Gx6axVTMkabqRaGdtFxL806W57Qln8T9VSHD8TbGbK5P3+Rul/2GWj92vMqmTa jpqvUk1lomnqpDy1gEj8b1kxzrPyUXsfkbGpkUI17Aqz7io+MHcwu5fRWGLmISO66cbLyfLT4ysne XV8vDdbn5cwVPLUN6DgoaP/Zo0ZzD0yA7KxDwaj+RBCnCTmaHPh424G0SIJyg5UwELhC9W9ypytjD Nqpb8uqkqtyA2cUanKEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDg-0000000DEaE-2yR6; Wed, 12 Jun 2024 15:49:04 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHQDd-0000000DEYJ-3qp6 for linux-riscv@lists.infradead.org; Wed, 12 Jun 2024 15:49:03 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1B589614DD; Wed, 12 Jun 2024 15:49:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E301C4AF1A; Wed, 12 Jun 2024 15:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718207340; bh=LaagHmLtHa02PqrnfSRNf9Efh1AA8FhF1xWGgB7qiDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aqL4E593HE6FBLtOmyFIOKrIMD5dhcFtcEOaqwRwBYlr1rbWEEnLlf+zTxQsPG65G ofyRr1EkMcr5oB38/1mB9k1dAFO6+hhLIxiySP3+gG+tYPX3W/WIyyArM7LmBzlOJp pe1n/JtogylSDtRVl/c7V6jIga7KJVIUZBt9kS24wUBdwNH6zXXHl/nfUM1HFOWgrX d3H5OPazlmfW+yiIBbwmMvz56hzvj6qAdlk3D/7/XynHvKCVwzO2CP0NEGapX1NXBb LsdvXZFG0HfeubchgL3r6NlvS3hCh4tN0Gse4UlNlG9JN/2hkm0yU3rztyxNQxyPA4 vUhU6xhQSehLw== From: Conor Dooley To: linux-mmc@vger.kernel.org Cc: conor@kernel.org, Conor Dooley , Ulf Hansson , cyril.jean@microchip.com, Mark Brown , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-spi@vger.kernel.org Subject: [RFC v1 3/3] spi: microchip-core-qspi: set min_speed_hz during probe Date: Wed, 12 Jun 2024 16:48:33 +0100 Message-ID: <20240612-attach-distaste-5c32099c1a76@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612-brigade-shell-1f626e7e592f@spud> References: <20240612-brigade-shell-1f626e7e592f@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=943; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=AySwqgGoZBkSC9iafcJMybZD7Uy/tn7eS25Dxx5hvrk=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGmZh32tHs8R7f/0n1feU7W14kqKbsjk9CkTQhyVVnyZs uC+/BGhjlIWBjEOBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAEykSJiR4RuXXZvMB8HqXcFv C+00E083mzUE73ea47Wi9hRP4PzyHIa/4pvd6hnvGbExncp1ZFykb6bmnc/84fHZZYnrQ1Mbi+Y xAgA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_084902_033861_B11CDB96 X-CRM114-Status: UNSURE ( 7.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley The controller's minimum possible bus clock is 1/30 the rate of the input clock. Naively set the minimum bus clock speed the controller is capable of during probe, assuming that the rate will never reduce further. Signed-off-by: Conor Dooley --- drivers/spi/spi-microchip-core-qspi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-microchip-core-qspi.c b/drivers/spi/spi-microchip-core-qspi.c index 1b23a38c155c..a549911b2f66 100644 --- a/drivers/spi/spi-microchip-core-qspi.c +++ b/drivers/spi/spi-microchip-core-qspi.c @@ -763,6 +763,7 @@ static int mchp_coreqspi_probe(struct platform_device *pdev) ctlr->transfer_one_message = mchp_coreqspi_transfer_one_message; ctlr->num_chipselect = 2; ctlr->use_gpio_descriptors = true; + ctlr->min_speed_hz = clk_get_rate(qspi->clk) / 30; ret = devm_spi_register_controller(&pdev->dev, ctlr); if (ret)