From: Mark Brown <broonie@kernel.org>
To: Piyush Malgujar <pmalgujar@marvell.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
jannadurai@marvell.com, cchavva@marvell.com,
Suneel Garapati <sgarapati@marvell.com>
Subject: Re: [PATCH 1/2] spi: octeontx2: Add support for octeontx2 spi controller
Date: Wed, 29 Mar 2023 12:43:52 +0100 [thread overview]
Message-ID: <ZCQkeKEpgANkE/GD@sirena.org.uk> (raw)
In-Reply-To: <20230327180753.2279-2-pmalgujar@marvell.com>
[-- Attachment #1: Type: text/plain, Size: 2096 bytes --]
On Mon, Mar 27, 2023 at 11:07:52AM -0700, Piyush Malgujar wrote:
> +static int tbi_clk_en = 1;
> +module_param(tbi_clk_en, uint, 0644);
> +MODULE_PARM_DESC(tbi_clk_en,
> + "Use Fixed Time Base 100MHz Reference Clock (0=Disable, 1=Enable [default])");
> +
> +static int cfg_mode_delay = 30;
> +module_param(cfg_mode_delay, uint, 0644);
> +MODULE_PARM_DESC(cfg_mode_delay,
> + "Delay in micro-seconds for mode change in MPI CFG register (30 [default])");
These don't look like they should be configurable at runtime,
either DT or (especially in the second case) just have the driver
do the right thing.
> +static void octeontx2_spi_wait_ready(struct octeontx2_spi *p)
> +{
> + union mpix_sts mpi_sts;
> + unsigned int loops = 0;
> +
> + mpi_sts.u64 = 0;
> + do {
> + if (loops++)
> + __delay(500);
> + mpi_sts.u64 = readq(p->register_base + OCTEONTX2_SPI_STS(p));
> + } while (mpi_sts.s.busy);
Might want a cpu_relax() in there.
> + p->cs_enax |= (0xFull << 12);
> + mpi_cfg.u64 |= p->cs_enax;
> +
> + if (mpi_cfg.u64 != p->last_cfg) {
> + p->last_cfg = mpi_cfg.u64;
> + writeq(mpi_cfg.u64, p->register_base + OCTEONTX2_SPI_CFG(p));
> + mpi_cfg.u64 = readq(p->register_base + OCTEONTX2_SPI_CFG(p));
> + udelay(cfg_mode_delay); /* allow CS change to settle */
> + }
It looks like the hardware has independent control of chip select
so should just implement a set_cs() operation. That seems to be
the only thing stopping the driver using transfer_one() instead
of transfer_one_message() so it should do that too and save more
code.
> + p->clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(p->clk)) {
> + p->clk = devm_clk_get(dev, "sclk");
> + p->sys_freq = 0;
> + } else {
> + ret = clk_prepare_enable(p->clk);
> + if (!ret)
> + p->sys_freq = clk_get_rate(p->clk);
> + }
We don't need to enable sclk or care about errors? That seems
buggy. The driver should just rely on the clock API here.
> + if (!p->sys_freq)
> + p->sys_freq = SYS_FREQ_DEFAULT;
> + if (tbi_clk_en)
> + p->sys_freq = TBI_FREQ;
We never seem to do anything to actually configure this in the
hardware.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-03-29 11:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 18:07 [PATCH 0/2] spi: octeontx2: Add spi driver for OcteonTX2 SOC Piyush Malgujar
2023-03-27 18:07 ` [PATCH 1/2] spi: octeontx2: Add support for octeontx2 spi controller Piyush Malgujar
2023-03-28 9:39 ` Andi Shyti
2023-03-29 11:43 ` Mark Brown [this message]
2023-03-27 18:07 ` [PATCH 2/2] spi: octeontx2: Add ACPI support Piyush Malgujar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCQkeKEpgANkE/GD@sirena.org.uk \
--to=broonie@kernel.org \
--cc=cchavva@marvell.com \
--cc=jannadurai@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=pmalgujar@marvell.com \
--cc=sgarapati@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®