All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <monstr@monstr.eu>
To: Rob Herring <robherring2@gmail.com>
Cc: Harini Katakam <harinik@xilinx.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>, Rob Landley <rob@landley.net>,
	Mark Brown <broonie@kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>
Subject: Re: [PATCH] SPI: Add driver for Cadence SPI controller
Date: Mon, 17 Mar 2014 14:22:54 +0100	[thread overview]
Message-ID: <5326F72E.7010401@monstr.eu> (raw)
In-Reply-To: <CAL_JsqKacetGytGUJir7ky3qOgCy-3ny1pT_Bx4eCYV2wMgcTg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5732 bytes --]

Hi Rob,

On 03/17/2014 01:47 PM, Rob Herring wrote:
> On Mon, Mar 17, 2014 at 7:05 AM, Harini Katakam <harinik@xilinx.com> wrote:
>> Add driver for Cadence SPI controller. This is used in Xilinx Zynq.
>>
>> Signed-off-by: Harini Katakam <harinik@xilinx.com>
>> ---
>>  .../devicetree/bindings/spi/spi-cadence.txt        |   25 +
> 
> We prefer binding docs in separate patch.

I have heard several times that also for binding review you need driver
to look if this binding make sense that's why Harini sent this together.
It means 2 emails instead of one.
But if you wish to have this in two files no problem to split it
but then I believe both should be copied to DT mailing list.


>>  drivers/spi/Kconfig                                |    7 +
>>  drivers/spi/Makefile                               |    1 +
>>  drivers/spi/spi-cadence.c                          |  804 ++++++++++++++++++++
>>  4 files changed, 837 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/spi/spi-cadence.txt
>>  create mode 100644 drivers/spi/spi-cadence.c
>>
>> diff --git a/Documentation/devicetree/bindings/spi/spi-cadence.txt b/Documentation/devicetree/bindings/spi/spi-cadence.txt
>> new file mode 100644
>> index 0000000..d25bc2d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/spi/spi-cadence.txt
>> @@ -0,0 +1,25 @@
>> +Cadence SPI controller Device Tree Bindings
>> +-------------------------------------------
>> +
>> +Required properties:
>> +- compatible           : Should be "cdns,spi-r1p6".
> 
> One problem with using IP vendor info in the compatible string is an
> IP block typically has a variety of configuration options so the
> actual implementations may be very different. I would recommend adding
> a Xilinx compatible string as well even if you don't use it now.

It means xlnx,zynq-spi-r1p6 should be fine.

> 
>> +- reg                  : Physical base address and size of SPI registers map.
>> +- interrupts           : Property with a value describing the interrupt
>> +                         number.
>> +- interrupt-parent     : Must be core interrupt controller
>> +- clock-names          : List of input clock names - "ref_clk", "pclk"
>> +                         (See clock bindings for details).
>> +- clocks               : Clock phandles (see clock bindings for details).
>> +- num-chip-select      : Number of chip selects used.
> 
> See Documentation/devicetree/bindings/spi/spi-bus.txt. Use "num-cs" here.
> 
>> +
>> +Example:
>> +
>> +       spi@e0007000 {
>> +               clock-names = "ref_clk", "pclk";
>> +               clocks = <&clkc 26>, <&clkc 35>;
>> +               compatible = "cdns,spi-r1p6";
> 
> Nit. We usually put compatible first in the node.

Our device-tree generator sorts them that's why it is just like this
but not a problem to fix just in documentation.


>> +               interrupt-parent = <&intc>;
>> +               interrupts = <0 49 4>;
>> +               num-chip-select = /bits/ 16 <4>;

I was expecting you will comment this a little bit. :-)
Because all just reading this num-cs as 32bit and then
assigning this value to master->num_chipselect which is 16bit.

<snip>

>> +/* Macros for the SPI controller read/write */
>> +#define cdns_spi_read(addr)    readl_relaxed(addr)
>> +#define cdns_spi_write(addr, val)      writel_relaxed((val), (addr))
> 
> Just use readl/writel directly.

There shouldn't be any problem to use these helper macros
and even I think this is better than using readl/writel directly
because you are more flexible if you want to change it to different
IO.

<snip>

>> +/**
>> + * cdns_spi_probe - Probe method for the SPI driver
>> + * @pdev:      Pointer to the platform_device structure
>> + *
>> + * This function initializes the driver data structures and the hardware.
>> + *
>> + * Return:     0 on success and error value on error
>> + */
>> +static int cdns_spi_probe(struct platform_device *pdev)
>> +{
>> +       int ret = 0, irq;
>> +       struct spi_master *master;
>> +       struct cdns_spi *xspi;
>> +       struct resource *res;
>> +
>> +       master = spi_alloc_master(&pdev->dev, sizeof(*xspi));
>> +       if (master == NULL)
>> +               return -ENOMEM;
>> +
>> +       xspi = spi_master_get_devdata(master);
>> +       master->dev.of_node = pdev->dev.of_node;
>> +       platform_set_drvdata(pdev, master);
>> +
>> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +       xspi->regs = devm_ioremap_resource(&pdev->dev, res);
>> +       if (IS_ERR(xspi->regs)) {
>> +               ret = PTR_ERR(xspi->regs);
>> +               goto remove_master;
>> +       }
>> +
>> +       irq = platform_get_irq(pdev, 0);
>> +       if (irq < 0) {
> 
> I believe this returns NO_IRQ which could be 0.
> 
> s/</<=/

Are you sure regarding this?
NO_IRQ on ARM is -1.
And IRC irq = 0 should be just valid number.

But if you are right then others drivers have to fixed too.


>> +       return 0;
>> +}
>> +
>> +static SIMPLE_DEV_PM_OPS(cdns_spi_dev_pm_ops, cdns_spi_suspend,
>> +                        cdns_spi_resume);
>> +
>> +/* Work with hotplug and coldplug */
>> +MODULE_ALIAS("platform:" CDNS_SPI_NAME);
> 
> Not sure, but I don't think this should be needed.

I don't know too.

Thanks for review,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  parent reply	other threads:[~2014-03-17 13:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 12:05 [PATCH] SPI: Add driver for Cadence SPI controller Harini Katakam
2014-03-17 12:47 ` Rob Herring
     [not found]   ` <CAL_JsqKacetGytGUJir7ky3qOgCy-3ny1pT_Bx4eCYV2wMgcTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-17 13:14     ` Mark Brown
2014-03-17 13:14       ` Mark Brown
2014-03-17 13:22   ` Michal Simek [this message]
2014-03-17 13:30     ` Geert Uytterhoeven
2014-03-17 13:54     ` Harini Katakam
     [not found]     ` <5326F72E.7010401-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2014-03-17 19:00       ` Rob Herring
2014-03-17 19:00         ` Rob Herring
2014-03-20 11:23         ` Michal Simek
2014-03-17 14:01   ` Harini Katakam
     [not found] ` <1395057936-8643-1-git-send-email-harinik-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2014-03-17 17:30   ` Mark Brown
2014-03-17 17:30     ` Mark Brown
2014-03-17 17:59     ` Josh Cartwright
2014-03-17 18:14       ` Mark Brown
2014-03-18  5:22         ` Harini Katakam
     [not found]           ` <554ccbca-f92e-454c-90c0-b8a4ddddf3fd-p/+QeVIcf1BZbvUCbuG1mrjjLBE8jN/0@public.gmane.org>
2014-03-18 11:06             ` Mark Brown
2014-03-18 11:06               ` Mark Brown
2014-03-18  5:16     ` Harini Katakam
2014-03-18 11:04       ` Mark Brown
     [not found]         ` <20140318110401.GH11706-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-03-18 12:13           ` Harini Katakam
2014-03-18 12:13             ` Harini Katakam
2014-03-18 12:33             ` Mark Brown
2014-03-18 14:45               ` Harini Katakam
2014-03-18 15:59                 ` 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=5326F72E.7010401@monstr.eu \
    --to=monstr@monstr.eu \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=harinik@xilinx.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=rob@landley.net \
    --cc=robh+dt@kernel.org \
    --cc=robherring2@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 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.