From: Sam Ravnborg <sam@ravnborg.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 06/11] spi: atmel_spi: Add DT support
Date: Wed, 15 Mar 2017 21:54:22 +0100 [thread overview]
Message-ID: <20170315205422.GB3531@ravnborg.org> (raw)
In-Reply-To: <20170314155222.11657-7-andrew.smirnov@gmail.com>
On Tue, Mar 14, 2017 at 08:52:17AM -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> drivers/spi/atmel_spi.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
> index ef57867..55032be 100644
> --- a/drivers/spi/atmel_spi.c
> +++ b/drivers/spi/atmel_spi.c
> @@ -29,6 +29,7 @@
> #include <clock.h>
> #include <xfuncs.h>
> #include <gpio.h>
> +#include <of_gpio.h>
> #include <io.h>
> #include <spi/spi.h>
> #include <mach/io.h>
> @@ -400,10 +401,11 @@ static int atmel_spi_probe(struct device_d *dev)
> int ret = 0;
> int i;
> struct spi_master *master;
> + struct device_node *node = dev->device_node;
> struct atmel_spi *as;
> struct at91_spi_platform_data *pdata = dev->platform_data;
>
> - if (!pdata) {
> + if (!IS_ENABLED(CONFIG_OFDEVICE) && !pdata) {
> dev_err(dev, "missing platform data\n");
> return -EINVAL;
> }
> @@ -414,6 +416,23 @@ static int atmel_spi_probe(struct device_d *dev)
> master->dev = dev;
> master->bus_num = dev->id;
>
> + if (pdata) {
> + master->num_chipselect = pdata->num_chipselect;
> + as->cs_pins = pdata->chipselect;
> + } else {
> + master->num_chipselect = of_gpio_named_count(node, "cs-gpios");
> + as->cs_pins = xzalloc(sizeof(u32) * master->num_chipselect);
> +
> + for (i = 0; i < master->num_chipselect; i++) {
> + as->cs_pins[i] = of_get_named_gpio(node, "cs-gpios", i);
> +
> + if (!gpio_is_valid(as->cs_pins[i]))
> + break;
> + }
> +
> + master->num_chipselect = i;
> + }
> +
> as->clk = clk_get(dev, "spi_clk");
> if (IS_ERR(as->clk)) {
> dev_err(dev, "no spi_clk\n");
> @@ -423,8 +442,6 @@ static int atmel_spi_probe(struct device_d *dev)
>
> master->setup = atmel_spi_setup;
> master->transfer = atmel_spi_transfer;
> - master->num_chipselect = pdata->num_chipselect;
> - as->cs_pins = pdata->chipselect;
> iores = dev_request_mem_resource(dev, 0);
> if (IS_ERR(iores))
> return PTR_ERR(iores);
> @@ -465,8 +482,14 @@ out_free:
> return ret;
> }
>
> +static __maybe_unused const struct of_device_id atmel_spi_dt_ids[] = {
const?
Sam
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-03-15 20:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 15:52 [PATCH 00/11] AT91, at91sam9x5ek updates (part II/III) Andrey Smirnov
2017-03-14 15:52 ` [PATCH 01/11] clocksource: at91: Add DT compatibility table Andrey Smirnov
2017-03-15 20:33 ` Sam Ravnborg
2017-03-14 15:52 ` [PATCH 02/11] serial: atmel: " Andrey Smirnov
2017-03-14 15:52 ` [PATCH 03/11] clk: at91: Port at91 DT clock code Andrey Smirnov
2017-03-14 15:52 ` [PATCH 04/11] mci: Allow parsing for explicit DT node Andrey Smirnov
2017-03-14 15:52 ` [PATCH 05/11] mci: atmel_mci: Add DT support Andrey Smirnov
2017-03-14 15:52 ` [PATCH 06/11] spi: atmel_spi: " Andrey Smirnov
2017-03-15 20:54 ` Sam Ravnborg [this message]
2017-03-14 15:52 ` [PATCH 07/11] w1-gpio: " Andrey Smirnov
2017-03-14 15:52 ` [PATCH 08/11] usb: ohci-at91: " Andrey Smirnov
2017-03-14 15:52 ` [PATCH 09/11] usb/host: Allow USB_OHCI_AT91 even if USB_OHCI is disabled Andrey Smirnov
2017-03-14 15:52 ` [PATCH 10/11] usb: echi-atmel: Add DT support Andrey Smirnov
2017-03-14 15:52 ` [PATCH 11/11] net: macb: " Andrey Smirnov
2017-03-15 21:03 ` [PATCH 00/11] AT91, at91sam9x5ek updates (part II/III) Sam Ravnborg
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=20170315205422.GB3531@ravnborg.org \
--to=sam@ravnborg.org \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/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