From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/9] i.MX31: support GPIO as a chip-select in the mxc_spi driver
Date: Wed, 4 Feb 2009 23:25:01 +0100 [thread overview]
Message-ID: <20090204222501.GD3924@game.jcrosoft.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0902041539490.6279@axis700.grange>
On 17:59 Wed 04 Feb , Guennadi Liakhovetski wrote:
> Some SPI devices have special requirements on chip-select handling.
> With this patch we can use a GPIO as a chip-select and strictly follow
> the SPI_XFER_BEGIN and SPI_XFER_END flags.
>
> Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
> ---
>
> Jean-Christophe: one more for you to ack.
>
> drivers/spi/mxc_spi.c | 35 +++++++++++++++++++++++++++++------
> 1 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
> index 9267341..eacd36c 100644
> --- a/drivers/spi/mxc_spi.c
> +++ b/drivers/spi/mxc_spi.c
> @@ -32,6 +32,8 @@
>
> #else
>
> +#include <asm/arch/mx31.h>
> +
> #define MXC_CSPIRXDATA 0x00
> #define MXC_CSPITXDATA 0x04
> #define MXC_CSPICTRL 0x08
> @@ -68,6 +70,7 @@ struct mxc_spi_slave {
> struct spi_slave slave;
> unsigned long base;
> u32 ctrl_reg;
> + int gpio;
> };
>
> static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave)
> @@ -91,6 +94,9 @@ static u32 spi_xchg_single(struct spi_slave *slave, u32 data,
> struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
> unsigned int cfg_reg = reg_read(mxcs->base + MXC_CSPICTRL);
>
> + if (mxcs->gpio > 0 && (flags & SPI_XFER_BEGIN))
> + mx31_gpio_set(mxcs->gpio, !!(mxcs->ctrl_reg & MXC_CSPICTRL_SSPOL));
> +
> reg_write(mxcs->base + MXC_CSPITXDATA, data);
>
> cfg_reg |= MXC_CSPICTRL_XCH;
> @@ -100,6 +106,9 @@ static u32 spi_xchg_single(struct spi_slave *slave, u32 data,
> while (reg_read(mxcs->base + MXC_CSPICTRL) & MXC_CSPICTRL_XCH)
> ;
>
> + if (mxcs->gpio > 0 && (flags & SPI_XFER_END))
> + mx31_gpio_set(mxcs->gpio, !(mxcs->ctrl_reg & MXC_CSPICTRL_SSPOL));
> +
> return reg_read(mxcs->base + MXC_CSPIRXDATA);
> }
>
> @@ -175,10 +184,28 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
> unsigned int ctrl_reg;
> struct mxc_spi_slave *mxcs;
>
> - if (bus >= sizeof(spi_bases) / sizeof(spi_bases[0]) ||
> - cs > 3)
> + if (bus >= sizeof(spi_bases) / sizeof(spi_bases[0]))
> + return NULL;
> +
> + mxcs = malloc(sizeof(struct mxc_spi_slave));
> + if (!mxcs)
> return NULL;
>
> + /*
> + * Some SPI devices require active chip-select over multiple
> + * transactions, we achieve this using a GPIO. Still, the SPI
> + * controller has to be configured to use one of its own chipselects.
> + * To use this feature you have to call spi_setup_slave() with
> + * cs = internal_cs | (gpio << 8), and you have to use some unused
> + * on this SPI controller cs between 0 and 3.
> + */
> + if (cs > 3) {
> + mxcs->gpio = cs >> 8;
> + cs &= 3;
> + mx31_gpio_direction(mxcs->gpio, MX31_GPIO_DIRECTION_OUT);
> + } else
> + mxcs->gpio = -1;
> +
why not add a callback for the chipselect instead
as example if you have to use a gpio extender it will simplest to implent
instead of hack the SPI driver
Best Regars,
J.
next prev parent reply other threads:[~2009-02-04 22:25 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-04 16:59 [U-Boot] [PATCH 0/9] ARM: Support for splashimage om i.MX31-based phycore "eet" variant Guennadi Liakhovetski
2009-02-04 16:59 ` [U-Boot] [PATCH 1/9] i.MX31: fix SPI driver for shorter than 32 bit transfers Guennadi Liakhovetski
2009-02-04 21:30 ` Wolfgang Denk
2009-02-04 21:42 ` Scott Wood
2009-02-04 22:00 ` Wolfgang Denk
2009-02-05 6:13 ` [U-Boot] MPC8548_eTSEC to Marvell 88E1145 E0 version Phy Initialization Ajeesh Kumar
2009-02-04 22:39 ` [U-Boot] [PATCH 1/9] i.MX31: fix SPI driver for shorter than 32 bit transfers Jean-Christophe PLAGNIOL-VILLARD
2009-02-05 1:31 ` Mike Frysinger
2009-02-05 8:28 ` Guennadi Liakhovetski
2009-02-05 15:34 ` Mike Frysinger
2009-02-04 16:59 ` [U-Boot] [PATCH 2/9] i.MX31: add a simple gpio driver Guennadi Liakhovetski
2009-02-04 18:54 ` Magnus Lilja
2009-02-04 19:54 ` Anatolij Gustschin
2009-02-04 20:41 ` Guennadi Liakhovetski
2009-02-04 22:44 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 16:59 ` [U-Boot] [PATCH 3/9] i.MX31: support GPIO as a chip-select in the mxc_spi driver Guennadi Liakhovetski
2009-02-04 20:28 ` Anatolij Gustschin
2009-02-04 20:40 ` Guennadi Liakhovetski
2009-02-04 21:34 ` Wolfgang Denk
2009-02-04 22:25 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2009-02-05 10:03 ` Guennadi Liakhovetski
2009-02-04 16:59 ` [U-Boot] [PATCH 4/9] A driver for the S6E63D6 SPI display controller from Samsung Guennadi Liakhovetski
2009-02-04 18:54 ` Magnus Lilja
2009-02-04 21:39 ` Wolfgang Denk
2009-02-04 21:38 ` Wolfgang Denk
2009-02-04 22:24 ` Guennadi Liakhovetski
2009-02-04 22:20 ` Anatolij Gustschin
2009-02-05 10:19 ` Guennadi Liakhovetski
2009-02-04 22:33 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-05 10:33 ` Guennadi Liakhovetski
2009-02-05 12:29 ` Wolfgang Denk
2009-02-04 16:59 ` [U-Boot] [PATCH 5/9] ARM: remove unused variable Guennadi Liakhovetski
2009-02-04 21:33 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 22:20 ` Guennadi Liakhovetski
2009-02-04 22:30 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 17:00 ` [U-Boot] [PATCH 6/9] Add 16bpp BMP support Guennadi Liakhovetski
2009-02-04 22:01 ` Wolfgang Denk
2009-02-04 22:07 ` Guennadi Liakhovetski
2009-02-04 22:36 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 22:46 ` Anatolij Gustschin
2009-02-04 23:02 ` Anatolij Gustschin
2009-02-04 17:00 ` [U-Boot] [PATCH 7/9] LCD: support 8bpp BMPs on 16bpp displays Guennadi Liakhovetski
2009-02-04 22:45 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 17:00 ` [U-Boot] [PATCH 8/9] video: add a i.MX31 framebuffer driver only for bitmaps so far Guennadi Liakhovetski
2009-02-04 18:54 ` Magnus Lilja
2009-02-04 19:39 ` Guennadi Liakhovetski
2009-02-04 20:22 ` Magnus Lilja
2009-02-04 21:20 ` Wolfgang Denk
2009-02-04 17:00 ` [U-Boot] [PATCH 9/9] ARM: add an "eet" variant of the imx31_phycore board Guennadi Liakhovetski
2009-02-04 21:30 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 22:17 ` Guennadi Liakhovetski
2009-02-04 22:18 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-04 22:22 ` Wolfgang Denk
2009-02-05 10:51 ` Guennadi Liakhovetski
2009-02-05 12:31 ` [U-Boot] [PATCH 0/9 v2] ARM: Support for splashimage om i.MX31-based phycore "eet" variant Guennadi Liakhovetski
2009-02-05 12:31 ` [U-Boot] [PATCH 1/9 v2] i.MX31: fix SPI driver for shorter than 32 bit transfers Guennadi Liakhovetski
2009-02-05 12:32 ` [U-Boot] [PATCH 2/9 v2] i.MX31: add a simple gpio driver Guennadi Liakhovetski
2009-02-05 14:50 ` Anatolij Gustschin
2009-02-05 15:24 ` Guennadi Liakhovetski
2009-02-05 16:07 ` Anatolij Gustschin
2009-02-05 12:32 ` [U-Boot] [PATCH 3/9 v2] i.MX31: support GPIO as a chip-select in the mxc_spi driver Guennadi Liakhovetski
2009-02-05 16:32 ` Anatolij Gustschin
2009-02-05 16:44 ` Guennadi Liakhovetski
2009-02-05 17:22 ` Anatolij Gustschin
2009-02-05 12:32 ` [U-Boot] [PATCH 4/9 v2] A driver for the S6E63D6 SPI display controller from Samsung Guennadi Liakhovetski
2009-02-05 16:42 ` Anatolij Gustschin
2009-02-05 16:46 ` Guennadi Liakhovetski
2009-02-06 0:19 ` Anatolij Gustschin
2009-02-05 12:32 ` [U-Boot] [PATCH 5/9 v2] ARM: remove unused variable Guennadi Liakhovetski
2009-02-05 12:32 ` [U-Boot] [PATCH 6/9 v2] Add 16bpp BMP support Guennadi Liakhovetski
2009-02-05 12:32 ` [U-Boot] [PATCH 7/9 v2] LCD: support 8bpp BMPs on 16bpp displays Guennadi Liakhovetski
2009-02-05 12:32 ` [U-Boot] [PATCH 8/9 v2] video: add a i.MX31 framebuffer driver Guennadi Liakhovetski
2009-02-06 0:27 ` Anatolij Gustschin
2009-02-05 12:32 ` [U-Boot] [PATCH 9/9 v2] ARM: add an "eet" variant of the imx31_phycore board Guennadi Liakhovetski
2009-02-06 0:52 ` Anatolij Gustschin
2009-02-06 9:37 ` [U-Boot] [PATCH 0/9 v3] ARM: Support for splashimage om i.MX31-based phycore "eet" variant Guennadi Liakhovetski
2009-02-06 9:37 ` [U-Boot] [PATCH 1/9 v3] i.MX31: fix SPI driver for shorter than 32 bit transfers Guennadi Liakhovetski
2009-02-06 21:28 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-06 9:37 ` [U-Boot] [PATCH 2/9 v3] i.MX31: add a simple gpio driver Guennadi Liakhovetski
2009-02-06 21:27 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-23 10:58 ` Anatolij Gustschin
2009-02-24 3:07 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-24 4:59 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-06 9:37 ` [U-Boot] [PATCH 3/9 v3] i.MX31: support GPIO as a chip-select in the mxc_spi driver Guennadi Liakhovetski
2009-02-06 21:25 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-06 9:37 ` [U-Boot] [PATCH 4/9 v3] A driver for the S6E63D6 SPI display controller from Samsung Guennadi Liakhovetski
2009-02-06 15:38 ` Anatolij Gustschin
2009-02-21 21:34 ` Wolfgang Denk
2009-02-23 13:13 ` Anatolij Gustschin
2009-02-23 21:39 ` Wolfgang Denk
2009-02-06 9:37 ` [U-Boot] [PATCH 5/9 v3] ARM: remove unused variable Guennadi Liakhovetski
2009-02-06 21:14 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-06 9:37 ` [U-Boot] [PATCH 6/9 v3] Add 16bpp BMP support Guennadi Liakhovetski
2009-02-06 15:42 ` Anatolij Gustschin
2009-02-06 9:37 ` [U-Boot] [PATCH 7/9 v3] LCD: support 8bpp BMPs on 16bpp displays Guennadi Liakhovetski
2009-02-06 16:14 ` Anatolij Gustschin
2009-02-06 16:23 ` Guennadi Liakhovetski
2009-02-06 9:37 ` [U-Boot] [PATCH 8/9 v3] video: add an i.MX31 framebuffer driver Guennadi Liakhovetski
2009-02-06 16:16 ` Anatolij Gustschin
2009-02-06 9:38 ` [U-Boot] [PATCH 9/9 v3] ARM: add an "eet" variant of the imx31_phycore board Guennadi Liakhovetski
2009-02-06 21:13 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-23 12:20 ` Anatolij Gustschin
2009-02-23 12:34 ` [U-Boot] [PATCH 9/9 v4] " Guennadi Liakhovetski
2009-02-24 5:00 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-24 13:51 ` Anatolij Gustschin
2009-02-06 17:25 ` [U-Boot] [PATCH 0/9 v3] ARM: Support for splashimage om i.MX31-based phycore "eet" variant Anatolij Gustschin
2009-02-06 17:34 ` Guennadi Liakhovetski
2009-02-06 22:05 ` Jean-Christophe PLAGNIOL-VILLARD
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=20090204222501.GD3924@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--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.