From: andy.shevchenko@gmail.com
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: broonie@kernel.org, lee@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
tglx@linutronix.de, maz@kernel.org, linus.walleij@linaro.org,
vkoul@kernel.org, lgirdwood@gmail.com,
yung-chuan.liao@linux.intel.com, sanyog.r.kale@intel.com,
pierre-louis.bossart@linux.intel.com,
alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/10] spi: cs42l43: Add SPI controller support
Date: Fri, 12 May 2023 22:03:08 +0300 [thread overview]
Message-ID: <ZF6NbHVD4ay2S83R@surfacebook> (raw)
In-Reply-To: <20230512122838.243002-10-ckeepax@opensource.cirrus.com>
Fri, May 12, 2023 at 01:28:37PM +0100, Charles Keepax kirjoitti:
> From: Lucas Tanure <tanureal@opensource.cirrus.com>
>
> The CS42L43 is an audio CODEC with integrated MIPI SoundWire interface
> (Version 1.2.1 compliant), I2C, SPI, and I2S/TDM interfaces designed
> for portable applications. It provides a high dynamic range, stereo
> DAC for headphone output, two integrated Class D amplifiers for
> loudspeakers, and two ADCs for wired headset microphone input or
> stereo line input. PDM inputs are provided for digital microphones.
>
> The SPI component incorporates a SPI controller interface for
> communication with other peripheral components.
...
> +#define CS42L43_SPI_ROOT_HZ 40000000
HZ_PER_MHZ?
...
> + const u8 *block = min_t(const u8 *, buf + CS42L43_FIFO_SIZE, end);
Wouldn't min() work?
...
> + for (; buf < block - (sizeof(u32) - 1); buf += sizeof(u32))
> + regmap_write(regmap, CS42L43_TX_DATA, *(const u32 *)buf);
This casting might be potentially wrong taking alignment into consideration.
Perhaps you need get_unaligned(). Also here the return value isn't checked,
while in the read it is.
...
> + const u8 *block = min_t(const u8 *, buf + CS42L43_FIFO_SIZE, end);
min() ?
...
> + for (; buf < block - (sizeof(u32) - 1); buf += sizeof(u32)) {
> + ret = regmap_read(regmap, CS42L43_RX_DATA, (u32 *)buf);
put_unaligned() ?
> + if (ret)
> + return ret;
> + }
...
> +static int cs42l43_prepare_transfer_hardware(struct spi_controller *ctlr)
> +{
> + struct cs42l43_spi *priv = spi_controller_get_devdata(ctlr);
> + int ret;
> +
> + ret = regmap_write(priv->regmap, CS42L43_BLOCK_EN2, CS42L43_SPI_MSTR_EN_MASK);
> + if (ret) {
> + dev_err(priv->dev, "Failed to enable SPI controller: %d\n", ret);
> + return ret;
> + }
> +
> + return 0;
return ret; ?
> +}
> +
> +static int cs42l43_unprepare_transfer_hardware(struct spi_controller *ctlr)
> +{
> + struct cs42l43_spi *priv = spi_controller_get_devdata(ctlr);
> + int ret;
> +
> + ret = regmap_write(priv->regmap, CS42L43_BLOCK_EN2, 0);
> + if (ret) {
> + dev_err(priv->dev, "Failed to disable SPI controller: %d\n", ret);
> + return ret;
> + }
> +
> + return 0;
Ditto.
> +}
...
> + if (is_of_node(dev_fwnode(cs42l43->dev))) {
> + priv->ctlr->dev.fwnode =
> + fwnode_get_named_child_node(dev_fwnode(cs42l43->dev), "spi");
> + priv->ctlr->dev.of_node = to_of_node(dev_fwnode(&priv->ctlr->dev));
> + } else {
> + priv->ctlr->dev.fwnode = dev_fwnode(priv->dev);
> + }
Can you use device_set_node() once you have an fwnode that needs to be passed?
...
> + priv->ctlr->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;
SPI_MODE_X_MASK
...
> +static struct platform_driver cs42l43_spi_driver = {
> + .driver = {
> + .name = "cs42l43-spi",
> + },
> +
Unneeded blank line.
> + .probe = cs42l43_spi_probe,
> + .remove = cs42l43_spi_remove,
> +};
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-05-12 19:04 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 12:28 [PATCH 00/10] Add cs42l43 PC focused SoundWire CODEC Charles Keepax
2023-05-12 12:28 ` [PATCH 01/10] soundwire: bus: Allow SoundWire peripherals to register IRQ handlers Charles Keepax
2023-05-12 13:45 ` Pierre-Louis Bossart
2023-05-12 16:02 ` Charles Keepax
2023-05-12 16:34 ` Pierre-Louis Bossart
2023-05-12 16:43 ` Charles Keepax
2023-05-12 12:28 ` [PATCH 02/10] ASoC: soc-component: Add notify control helper function Charles Keepax
2023-05-12 12:28 ` [PATCH 03/10] ASoC: ak4118: Update to use new component control notify helper Charles Keepax
2023-05-12 13:48 ` Pierre-Louis Bossart
2023-05-12 15:42 ` Charles Keepax
2023-05-12 12:28 ` [PATCH 04/10] ASoC: wm_adsp: Update to use new component control notify helepr Charles Keepax
2023-05-12 12:28 ` [PATCH 05/10] dt-bindings: mfd: cirrus,cs42l43: Add initial DT binding Charles Keepax
2023-05-12 15:23 ` Krzysztof Kozlowski
2023-05-12 16:15 ` Charles Keepax
2023-05-13 18:05 ` Krzysztof Kozlowski
2023-05-12 15:25 ` Krzysztof Kozlowski
2023-05-12 16:18 ` Charles Keepax
2023-05-13 18:08 ` Krzysztof Kozlowski
2023-05-15 10:02 ` Charles Keepax
2023-05-12 12:28 ` [PATCH 06/10] mfd: cs42l43: Add support for cs42l43 core driver Charles Keepax
2023-05-12 14:52 ` Pierre-Louis Bossart
2023-05-18 10:05 ` Charles Keepax
2023-05-12 15:16 ` Krzysztof Kozlowski
2023-05-18 10:24 ` Charles Keepax
2023-05-18 15:16 ` Pierre-Louis Bossart
2023-05-18 16:15 ` Richard Fitzgerald
2023-05-18 16:47 ` Pierre-Louis Bossart
2023-05-19 9:24 ` Charles Keepax
2023-05-12 12:28 ` [PATCH 07/10] irqchip/cs42l43: Add support for the cs42l43 IRQs Charles Keepax
2023-05-12 15:10 ` Marc Zyngier
2023-05-12 15:39 ` Charles Keepax
2023-05-12 16:07 ` Marc Zyngier
2023-05-12 16:42 ` Charles Keepax
2023-05-15 1:08 ` Mark Brown
2023-05-15 9:57 ` Charles Keepax
2023-05-16 10:07 ` Lee Jones
2023-05-15 11:25 ` Lee Jones
2023-05-16 8:51 ` Marc Zyngier
2023-05-16 10:09 ` Lee Jones
2023-05-16 10:23 ` Marc Zyngier
2023-05-16 10:41 ` Charles Keepax
2023-05-12 15:27 ` Krzysztof Kozlowski
2023-05-12 12:28 ` [PATCH 08/10] pinctrl: cs42l43: Add support for the cs42l43 Charles Keepax
2023-05-12 15:30 ` Krzysztof Kozlowski
2023-05-12 15:54 ` Charles Keepax
2023-05-13 18:00 ` Krzysztof Kozlowski
2023-05-12 19:19 ` andy.shevchenko
2023-05-15 10:13 ` Charles Keepax
2023-05-16 19:03 ` Andy Shevchenko
2023-05-17 10:13 ` Charles Keepax
2023-05-17 13:59 ` Andy Shevchenko
2023-05-17 14:11 ` Pierre-Louis Bossart
2023-05-17 14:30 ` Mark Brown
2023-05-12 12:28 ` [PATCH 09/10] spi: cs42l43: Add SPI controller support Charles Keepax
2023-05-12 19:03 ` andy.shevchenko [this message]
2023-05-12 12:28 ` [PATCH 10/10] ASoC: cs42l43: Add support for the cs42l43 Charles Keepax
2023-05-15 15:21 ` (subset) [PATCH 00/10] Add cs42l43 PC focused SoundWire CODEC Mark Brown
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=ZF6NbHVD4ay2S83R@surfacebook \
--to=andy.shevchenko@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=maz@kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=robh+dt@kernel.org \
--cc=sanyog.r.kale@intel.com \
--cc=tglx@linutronix.de \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.