spi: cadence-quadspi: Add minimum operable clock rate warning to baudrate divisor calculation
Message ID | 20221128164147.158441-1-nathan.morrison@timesys.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5808356wrr; Mon, 28 Nov 2022 08:58:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xty2o5w3BEXpbpRbgqMEhn4xyd23C2T1I6auNYg3q9izI/EWY/+lL+ROtxEm20+QdxCrz X-Received: by 2002:a17:906:4bc4:b0:78d:6325:356 with SMTP id x4-20020a1709064bc400b0078d63250356mr44187477ejv.6.1669654697066; Mon, 28 Nov 2022 08:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669654697; cv=none; d=google.com; s=arc-20160816; b=sG54+GcSh5BnUNYKpYCVpsPbFk5sXwgQTszG/c5I40FISJ74n7Hle7K00fP+3AeHpO n7dRdtii6uIpMEl5zbE9WOPky6GlbZN8rD66Srq3tqlvXvyCOQyH4c14o/Unyk/wNd37 7NsjXvYbLOfI/wL54PRCAm1/wa8KCltrrt+hRRyCBT46bok/cpboLQKf3uXTsEM95Vqp 4aEQvJcG3CTpNZlxNVo9QrgVJ2d+4NVaaTpZbSlh7o8gmBev452lMAdV69Q5b33RQY36 +zTprhbYxJGtC2wqNEimelDyn0mLlYxGPIP8YC2IlvmSPZHThNpCT02lDjIFNVjX9xRB dkgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=XXSSzXQqwpqTp8kvMCywn3wDULboBrcJlaRyokBQ21k=; b=dsjOn42CZcvYrNzxQHOYrkzaklGJzdA5uadmZ+xgTSUX0u92HwqeQ4a+L2125zMS07 tQroWj4cmTbqoxcFTfTdG2HZ6JawYcBbRIHeaRMLX+0oVizEVIkIUnw6TZdne54jVoHj WmT6ylmoap0I0HJWlQvgUxFBITjS4VvdBbdfP1SFaKTbsKtQtd4KvrtG7dy6e/KonwC/ aaDjY7lISRl1cgK002XDVUcRP8JuRDdzoK7IqC4AoySGvL0ZeJKKJ5cX6xCbfsvMOBVx DeX3WAGJON3ptdph1Y5iwCWykhIOHSCIDYCRwApBvvvuInAuB63ao1F6XPsg4GOaY9a7 kLRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@timesys-com.20210112.gappssmtp.com header.s=20210112 header.b=fejHIyNf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr11-20020a1709073f8b00b007ad8140c60asi11641894ejc.492.2022.11.28.08.57.53; Mon, 28 Nov 2022 08:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@timesys-com.20210112.gappssmtp.com header.s=20210112 header.b=fejHIyNf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbiK1QoY (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Mon, 28 Nov 2022 11:44:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbiK1QoT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 28 Nov 2022 11:44:19 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27C41B1CC for <linux-kernel@vger.kernel.org>; Mon, 28 Nov 2022 08:44:14 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id h24so7039867qta.9 for <linux-kernel@vger.kernel.org>; Mon, 28 Nov 2022 08:44:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timesys-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XXSSzXQqwpqTp8kvMCywn3wDULboBrcJlaRyokBQ21k=; b=fejHIyNfaphEgkYKnCMhaL2S9tzT4NlOpJKoyQ/v4qpJLWqHeLSj8Q/Bt8hkvQgiNW kf190UpnS4b3+SMrlzWDpyElTt4EXZp6IxFfn6XkfhiwmSmG3dzw0+kBSjHu6elG+sBH 76tF+npGB5JvlV3CaGWJ+G39ZWHYT+hbM37sQOLlOzLG5Uxtt87VXn+BS9DH3YYNPH0P yCzDWDNfhT6rLYKJVvz8pc1exJUAbkb0fmDJO8CDCXipAI+F8UtVaA//tWLZw+FAY62w wsVbyuA4jzpTNb2zMM6z0KtyvzP/DPYa0lmYAzF3y+okU7yq3liWGN9ajF3L8AUB8EqB WoIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XXSSzXQqwpqTp8kvMCywn3wDULboBrcJlaRyokBQ21k=; b=z65M21gtWtlVeZNvO/Y1qZEUb+Lwi6d0MpjsQ01UPrQ6Gd1TGp3iT4MJgPzQL6otj7 62sJt5HJ13Z+8Q1Gunc+cJLKt+h/EXU0GsaZTn+EIPRTt1lxX6ddrxrico1t1WFNGKJK meRXKyUwvVFbxyiwLfqJw5fgKgpnnV6MqwXr5B8xLafz7xm2MaV8oUUmgzoOBSElrfwd 1KBKrTb8WUwCvTTxOkJ+Wv/qkp8aII2V8P0KPj1wc3HM9g/WDSmpNw7X1KP5GhTQu2lO 2v8iCF06oluFomSOJ5fYVSOfZNFYLw8VNnvnJExkUSWLvqxrz3/ate0yKG5c3qp+vuKu 2Kyw== X-Gm-Message-State: ANoB5plrRT8ctk/wyzlvlqvrHWdyqiBKKRy4d1nilKlGBma/NSWvFT8P gtW9u9owGmeSsuhkS2WV/DPsfw== X-Received: by 2002:ac8:604e:0:b0:3a2:9fcd:59c8 with SMTP id k14-20020ac8604e000000b003a29fcd59c8mr34598175qtm.273.1669653853577; Mon, 28 Nov 2022 08:44:13 -0800 (PST) Received: from nathan-ideapad.. (d-75-76-18-234.oh.cpe.breezeline.net. [75.76.18.234]) by smtp.gmail.com with ESMTPSA id bn31-20020a05620a2adf00b006b95b0a714esm8724614qkb.17.2022.11.28.08.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 08:44:13 -0800 (PST) From: Nathan Barrett-Morrison <nathan.morrison@timesys.com> Cc: nathan.morrison@timesys.com, greg.malysa@timesys.com, Mark Brown <broonie@kernel.org>, linux-spi@vger.kernel.org (open list:SPI SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] spi: cadence-quadspi: Add minimum operable clock rate warning to baudrate divisor calculation Date: Mon, 28 Nov 2022 11:41:47 -0500 Message-Id: <20221128164147.158441-1-nathan.morrison@timesys.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750759843721815379?= X-GMAIL-MSGID: =?utf-8?q?1750759843721815379?= |
Series |
spi: cadence-quadspi: Add minimum operable clock rate warning to baudrate divisor calculation
|
|
Commit Message
Nathan Barrett-Morrison
Nov. 28, 2022, 4:41 p.m. UTC
This Cadence QSPI IP has a 4-bit clock divisor field
for baud rate division. For example:
0b0000 = /2
0b0001 = /4
0b0010 = /6
...
0b1111 = /32
The maximum divisor is 32
(when div = CQSPI_REG_CONFIG_BAUD_MASK).
If we assume a reference clock of 500MHz and we set
our spi-max-frequency to something low, such as 10 MHz.
The calculated bit field for the divisor ends up being:
DIV_ROUND_UP(500000000/(2*10000000))-1 = 25
25 is 0b11001... which truncates to a divisor field of 0b1001 (or /20).
This is higher than our anticipated max-frequency of 10MHz
(500MHz/20 = 25 MHz). Instead, let's make sure we're always using
the maximum divisor (/32) in this case and give the user a warning about
the rate adjustment.
Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
---
drivers/spi/spi-cadence-quadspi.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
On Mon, 28 Nov 2022 11:41:47 -0500, Nathan Barrett-Morrison wrote: > This Cadence QSPI IP has a 4-bit clock divisor field > for baud rate division. For example: > > 0b0000 = /2 > 0b0001 = /4 > 0b0010 = /6 > ... > 0b1111 = /32 > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next Thanks! [1/1] spi: cadence-quadspi: Add minimum operable clock rate warning to baudrate divisor calculation commit: f8fc65e50ad71c139a12a96e64eeba5005e491d5 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 447230547945..21b60b354404 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1119,6 +1119,14 @@ static void cqspi_config_baudrate_div(struct cqspi_st *cqspi) /* Recalculate the baudrate divisor based on QSPI specification. */ div = DIV_ROUND_UP(ref_clk_hz, 2 * cqspi->sclk) - 1; + /* Maximum baud divisor */ + if (div > CQSPI_REG_CONFIG_BAUD_MASK) { + div = CQSPI_REG_CONFIG_BAUD_MASK; + dev_warn(&cqspi->pdev->dev, + "Unable to adjust clock <= %d hz. Reduced to %d hz\n", + cqspi->sclk, ref_clk_hz/((div+1)*2)); + } + reg = readl(reg_base + CQSPI_REG_CONFIG); reg &= ~(CQSPI_REG_CONFIG_BAUD_MASK << CQSPI_REG_CONFIG_BAUD_LSB); reg |= (div & CQSPI_REG_CONFIG_BAUD_MASK) << CQSPI_REG_CONFIG_BAUD_LSB;