linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Richardson <jonathar@broadcom.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Dmitry Torokhov <dtor@google.com>,
	Anatol Pomazau <anatol@google.com>,
	Scott Branden <sbranden@broadcom.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-spi <linux-spi@vger.kernel.org>,
	bcm-kernel-feedback-list <bcm-kernel-feedback-list@broadcom.com>,
	devicetree <devicetree@vger.kernel.org>
Subject: Re: [PATCH 3/4] spi: bcm-mspi: Make BCMA optional to support non-BCMA chips
Date: Mon, 6 Apr 2015 12:09:26 -0700	[thread overview]
Message-ID: <5522D9E6.3080008@broadcom.com> (raw)
In-Reply-To: <CACna6ry9qxzY9xaaqR8K6XgSEun31c=d1XrWH_vk7Fq7fJTxoA@mail.gmail.com>

On 15-04-06 03:36 AM, Rafał Miłecki wrote:
> On 3 April 2015 at 19:52, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 03/04/15 06:38, Andy Shevchenko wrote:
>>> On Thu, Apr 2, 2015 at 10:23 PM, Jonathan Richardson
>>> <jonathar@broadcom.com> wrote:
>>>> The Broadcom MSPI controller is used on various chips. The driver only
>>>> supported BCM53xx chips with BCMA (an AMBA bus variant). The driver is
>>>> refactored to make BCMA optional and provides a new config for non BCMA
>>>> systems.
>>>
>>>>  struct bcm_mspi {
>>>> +       #ifdef CONFIG_SPI_BCMA_MSPI
>>>>         struct bcma_device *core;
>>>> -       struct spi_master *master;
>>>> +       #endif
>>>>
>>>> +       void __iomem *base;
>>>> +       struct spi_master *master;
>>>>         size_t read_offset;
>>>
>>>> +       void (*mspi_write)(struct bcm_mspi *mspi, u16 offset, u32 value);
>>>> +       u32 (*mspi_read)(struct bcm_mspi *mspi, u16 offset);
>>>> +};
>>>
>>> To avoid ugly ifdefs I think better to split driver to core part and
>>> the actual driver part, at the end you will have something like
>>> mspi-core.c mspi-53xx.c mspi-whatever.c. Check for example spi-dw*.c
>>
>> Actually, I am really curious whether we need the special BCMA I/O
>> accessors in the first place, cannot we just access the MSPI core on
>> BCM53xx chips using regular MMIO? That would probably solve the
>> "problem" entirely. Rafal, did you try this before?
> 
> It's a matter of choice between:
> 1) Using one design for all bcma users
> 2) Using one design for all bcm-mspi users
> I believe no matter which one you choose, you'll break another one.
> 
> If you take a look at drivers/bcma/host_soc.c, you'll see we've there
> core->io_addr. I guess you could use it as the base in bcm-mspi. That
> of course will make you a bit less compatible with other bcma drivers
> (skipping bcma R/W layer).

That would require compiling in BCMA for a driver/chip that doesn't use
BCMA but then I could do DT parsing in init only anyway. I don't think
that's really an option so I'm going to leave as is unless there is
further opinion on it.

> 
> 
>> As for splitting the driver into a "library" driver which is mostly
>> independent from the bus and a bus-specific wrapper, I think BCMA is
>> really the only special case here, which is why I suggested earlier to
>> Jonathan that we might just prefer ifdefing things out instead of
>> creating a separate layer just for BCMA.
> 
> I think you may be right, this #if for bcma shouldn't be that bad and
> it shouldn't grow in the future.
> Still, I'd like to get this patch split nicely to review independent changes.
> 

Making BCMA optional was made possible by using DT. I'm not sure I could
split it into two commits. I would have to add a hard coded SPI device
for non-BMCA as well. I thought the driver was a bit odd in that this
was hard coded. Normally this should be in a separate driver. How would
you use it if you wanted to use m25p80 for example?



  reply	other threads:[~2015-04-06 19:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 19:23 [PATCH 0/4] Add MSPI support for Cygnus Jonathan Richardson
2015-04-02 19:23 ` [PATCH 1/4] ARM: dts: Add binding for Broadcom MSPI driver Jonathan Richardson
2015-04-04 19:17   ` Florian Fainelli
2015-04-06 18:45     ` Jonathan Richardson
2015-04-02 19:23 ` [PATCH 2/4] spi: bcm53xx: Refactor to make driver nonspecific to 53xx SoCs Jonathan Richardson
2015-04-03 13:35   ` Andy Shevchenko
2015-04-06 10:18     ` Rafał Miłecki
2015-04-06 18:58       ` Jonathan Richardson
2015-04-06 18:30     ` Jonathan Richardson
2015-04-07  8:03       ` Andy Shevchenko
2015-04-02 19:23 ` [PATCH 3/4] spi: bcm-mspi: Make BCMA optional to support non-BCMA chips Jonathan Richardson
2015-04-03 13:38   ` Andy Shevchenko
2015-04-03 17:52     ` Florian Fainelli
2015-04-06 10:36       ` Rafał Miłecki
2015-04-06 19:09         ` Jonathan Richardson [this message]
2015-04-06 18:39       ` Jonathan Richardson
2015-04-06 10:26     ` Rafał Miłecki
2015-04-06 10:26   ` Rafał Miłecki
2015-04-02 19:23 ` [PATCH 4/4] spi: bcm-mspi: Add support to set serial baud clock rate Jonathan Richardson
2015-04-04 19:12   ` Florian Fainelli
2015-04-06  9:46     ` Mark Brown
2015-04-06 18:54       ` Jonathan Richardson

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=5522D9E6.3080008@broadcom.com \
    --to=jonathar@broadcom.com \
    --cc=anatol@google.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dtor@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=zajec5@gmail.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;
as well as URLs for NNTP newsgroup(s).