All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v2 06/10] drivers: spi: Add SPI controller driver for Octeon
Date: Thu, 30 Jul 2020 08:23:09 +0200	[thread overview]
Message-ID: <d44958d9-1050-63c0-5b3d-68d58d098918@denx.de> (raw)
In-Reply-To: <e3ebed29-534d-4741-bdc3-b26230021b03@denx.de>

Hi Daniel,

On 30.07.20 07:49, Stefan Roese wrote:
> Hi Daniel,
> 
> On 24.07.20 15:56, Daniel Schwierzeck wrote:
>> Am Donnerstag, den 23.07.2020, 12:17 +0200 schrieb Stefan Roese:
>>> From: Suneel Garapati <sgarapati@marvell.com>
>>>
>>> Adds support for SPI controllers found on Octeon II/III and Octeon TX
>>> TX2 SoC platforms.
>>>
>>> Signed-off-by: Aaron Williams <awilliams@marvell.com>
>>> Signed-off-by: Suneel Garapati <sgarapati@marvell.com>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
>>> Cc: Aaron Williams <awilliams@marvell.com>
>>> Cc: Chandrakala Chavva <cchavva@marvell.com>
>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
> 
> <snip>
> 
>>> +static const struct dm_spi_ops octeon_spi_ops = {
>>> +??? .claim_bus??? = octeon_spi_claim_bus,
>>> +??? .release_bus??? = octeon_spi_release_bus,
>>> +??? .set_speed??? = octeon_spi_set_speed,
>>> +??? .set_mode??? = octeon_spi_set_mode,
>>> +??? .xfer??????? = octeon_spi_xfer,
>>> +};
>>> +
>>> +static const struct dm_spi_ops octeontx2_spi_ops = {
>>> +??? .claim_bus??? = octeon_spi_claim_bus,
>>> +??? .release_bus??? = octeon_spi_release_bus,
>>> +??? .set_speed??? = octeon_spi_set_speed,
>>> +??? .set_mode??? = octeon_spi_set_mode,
>>> +??? .xfer??????? = octeontx2_spi_xfer,
>>> +??? .mem_ops??? = &octeontx2_spi_mem_ops,
>>> +};
>>> +
>>> +static int octeon_spi_probe(struct udevice *dev)
>>> +{
>>> +??? struct octeon_spi *priv = dev_get_priv(dev);
>>> +??? const struct octeon_spi_data *data;
>>> +??? int ret;
>>> +
>>> +??? data = (const struct octeon_spi_data *)dev_get_driver_data(dev);
>>> +??? if (data->probe == PROBE_PCI) {
>>> +??????? pci_dev_t bdf = dm_pci_get_bdf(dev);
>>> +
>>> +??????? debug("SPI PCI device: %x\n", bdf);
>>> +??????? priv->base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
>>> +??????????????????????? PCI_REGION_MEM);
>>> +??? } else {
>>> +??????? priv->base = dev_remap_addr(dev);
>>> +??? }
>>> +
>>> +??? priv->base += data->reg_offs;
>>> +
>>> +??? /* Octeon TX2 needs a different ops struct */
>>> +??? if (device_is_compatible(dev, "cavium,thunderx-spi")) {
>>> +??????? /*
>>> +???????? * "ops" is const and can't be written directly. So we need
>>> +???????? * to write the Octeon TX2 ops value using this trick
>>> +???????? */
>>> +??????? writeq((u64)&octeontx2_spi_ops, (void *)&dev->driver->ops);
>>> +??? }
>>
>> can't you simply add a xfer() function pointer to "struct
>> octeon_spi_data" and assign the according xfer function to it? Then
>> in octeon_spi_xfer() you can simply call that function pointer. With
>> this you only need one instance of "struct dm_spi_ops" and don't need
>> this ugly hack ;)
> 
> Unfortuantely its not that easy, as the Octeon TX2 ops struct also has
> a " mem_ops" member, which the driver does not support for the other
> Octeon models. I could clear this "mem_ops" member in the non Octeon
> TX2 case, which is a bit better than the 2nd ops struct. But its still
> not really elegent.
> 
> Or do you have some other idea on how to implement this in a "better
> way"?

BTW: If this SPI driver is the only patch in this series, that you feel
is not ready, then I suggest to drop this one from this patch series
and push the remaining ones to mainline (if they have no issues of
course).

Thanks,
Stefan

  reply	other threads:[~2020-07-30  6:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 10:17 [PATCH v2 00/10] mips: octeon: Misc Octeon drivers, DT and Kconfig / defconfig updates Stefan Roese
2020-07-23 10:17 ` [PATCH v2 01/10] gpio: octeon_gpio: Add GPIO controller driver for Octeon Stefan Roese
2020-07-23 10:17 ` [PATCH v2 02/10] mips: octeon: mrvl,cn73xx.dtsi: Add GPIO DT nodes Stefan Roese
2020-07-23 10:17 ` [PATCH v2 03/10] mips: octeon: dts: Add I2C " Stefan Roese
2020-07-23 10:17 ` [PATCH v2 04/10] clk: clk_octeon: Add simple MIPS Octeon clock driver Stefan Roese
2020-07-23 10:17 ` [PATCH v2 05/10] mips: octeon: dts: Add Octeon clock driver DT nodes Stefan Roese
2020-07-23 10:17 ` [PATCH v2 06/10] drivers: spi: Add SPI controller driver for Octeon Stefan Roese
2020-07-24 13:56   ` Daniel Schwierzeck
2020-07-24 14:27     ` Stefan Roese
2020-07-30  5:49     ` Stefan Roese
2020-07-30  6:23       ` Stefan Roese [this message]
2020-07-30 11:00         ` Daniel Schwierzeck
2020-07-30 11:42           ` Stefan Roese
2020-07-30  7:50     ` Jagan Teki
2020-07-30  7:53       ` Stefan Roese
2020-07-30  7:44   ` Jagan Teki
2020-07-30  8:06     ` Stefan Roese
2020-07-23 10:17 ` [PATCH v2 07/10] mips: octeon: mrvl,cn73xx.dtsi: Add SPI DT node Stefan Roese
2020-07-23 10:17 ` [PATCH v2 08/10] mips: octeon: mrvl, octeon-ebb7304.dts: Add SPI flash " Stefan Roese
2020-07-23 10:17 ` [PATCH v2 09/10] mips: octeon: Update Octeon Kconfig Stefan Roese
2020-07-23 10:17 ` [PATCH v2 10/10] mips: octeon: Update EBB7304 defconfig Stefan Roese
2020-07-30 11:56 [PATCH v2 00/10] mips: octeon: Misc Octeon drivers, DT and Kconfig / defconfig updates Stefan Roese
2020-07-30 11:56 ` [PATCH v2 06/10] drivers: spi: Add SPI controller driver for Octeon Stefan Roese
2020-08-03 19:09   ` Daniel Schwierzeck
2020-08-03 23:20   ` Suneel Garapati
2020-08-04 12:54     ` Stefan Roese

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=d44958d9-1050-63c0-5b3d-68d58d098918@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.