From: "Jan Lübbe" <jlu@pengutronix.de>
To: "Teresa Gámez" <t.gamez@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCHv2 2/3] omap3_spi: Add CS check for AM33xx
Date: Tue, 18 Jun 2013 15:19:50 +0200 [thread overview]
Message-ID: <1371561590.4168.67.camel@coredoba.hi.pengutronix.de> (raw)
In-Reply-To: <1371561347-3530-2-git-send-email-t.gamez@phytec.de>
On Tue, 2013-06-18 at 15:15 +0200, Teresa Gámez wrote:
> AM33xx has only 2 McSPI busses and 2 CS for each bus.
> Added comment and the check.
>
> Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
> ---
> drivers/spi/omap3_spi.c | 20 +++++++++++++++++---
> 1 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
> index e6581df..1eb0e6a 100644
> --- a/drivers/spi/omap3_spi.c
> +++ b/drivers/spi/omap3_spi.c
> @@ -326,11 +326,17 @@ static int omap3_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
> static int omap3_spi_setup(struct spi_device *spi)
> {
> struct spi_master *master = spi->master;
> + int is_not_valid;
>
> - if (((master->bus_num == 1) && (spi->chip_select > 3)) ||
> + if (IS_ENABLED(CONFIG_ARCH_OMAP3))
> + is_not_valid = ((master->bus_num == 1) && (spi->chip_select > 3)) ||
> ((master->bus_num == 2) && (spi->chip_select > 1)) ||
> ((master->bus_num == 3) && (spi->chip_select > 1)) ||
> - ((master->bus_num == 4) && (spi->chip_select > 0))) {
> + ((master->bus_num == 4) && (spi->chip_select > 0));
> + else
> + is_not_valid = (spi->chip_select > 1);
> +
> + if (is_not_valid) {
> printf("SPI error: unsupported chip select %i \
> on bus %i\n", spi->chip_select, master->bus_num);
> return -EINVAL;
> @@ -368,12 +374,20 @@ static int omap3_spi_probe(struct device_d *dev)
> * McSPI3 has 2 CS (bus 3, cs 0 - 1)
> * McSPI4 has 1 CS (bus 4, cs 0)
> *
> + * AM335x McSPI has 2 busses with 2 chip selects:
> + * McSPI0 has 2 CS (bus 0, cs 0 - 1)
> + * McSPI1 has 2 CS (bus 1, cs 0 - 1)
> + *
> * The board code has to make sure that it does not use
> * invalid buses or chip selects.
> */
>
> master->bus_num = dev->id;
> - master->num_chipselect = 4;
> +
> + if (IS_ENABLED(CONFIG_ARCH_OMAP3))
> + master->num_chipselect = 4;
> + else
> + master->num_chipselect = 2;
> master->setup = omap3_spi_setup;
> master->transfer = omap3_spi_transfer;
By now, I think we should just drop the CS/bus checks in the driver. We
don't need to protect against wrong device setup from the board file of
later from DT.
Regards,
Jan
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-06-18 13:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 13:15 [PATCHv2 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
2013-06-18 13:15 ` [PATCHv2 2/3] omap3_spi: Add CS check for AM33xx Teresa Gámez
2013-06-18 13:19 ` Jan Lübbe [this message]
2013-06-18 13:15 ` [PATCHv2 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
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=1371561590.4168.67.camel@coredoba.hi.pengutronix.de \
--to=jlu@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=t.gamez@phytec.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox