* [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work
@ 2012-04-23 12:43 Fabio Estevam
2012-04-23 13:12 ` Marek Vasut
2012-04-23 17:43 ` Mike Frysinger
0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2012-04-23 12:43 UTC (permalink / raw)
To: u-boot
MXS SSP controller may have up to three chip selects per port: SS0, SS1 and SS2.
Currently only SS0 is supported in the mxs_spi driver.
Allow all the three chip select to work by selecting the desired one
in bits 20 and 21 of the HW_SSP_CTRL0 register.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/spi/mxs_spi.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
index 4e6f14e..c0bfd25 100644
--- a/drivers/spi/mxs_spi.c
+++ b/drivers/spi/mxs_spi.c
@@ -34,6 +34,8 @@
#define MXS_SPI_MAX_TIMEOUT 1000000
#define MXS_SPI_PORT_OFFSET 0x2000
+#define MXS_SSP_CHIPSELECT_MASK 0x00300000
+#define MXS_SSP_CHIPSELECT_SHIFT 20
struct mxs_spi_slave {
struct spi_slave slave;
@@ -56,12 +58,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
{
struct mxs_spi_slave *mxs_slave;
uint32_t addr;
+ struct mx28_ssp_regs *ssp_regs;
+ int reg;
if (bus > 3) {
printf("MXS SPI: Max bus number is 3\n");
return NULL;
}
+ if (cs > 2) {
+ printf("MXS SPI: Invalid chip select number: %d\n", cs);
+ return NULL;
+ }
+
mxs_slave = malloc(sizeof(struct mxs_spi_slave));
if (!mxs_slave)
return NULL;
@@ -74,6 +83,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
mxs_slave->mode = mode;
mxs_slave->regs = (struct mx28_ssp_regs *)addr;
+ ssp_regs = mxs_slave->regs;
+
+ reg = readl(&ssp_regs->hw_ssp_ctrl0);
+ reg &= ~(MXS_SSP_CHIPSELECT_MASK);
+ reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
+
+ writel(reg, &ssp_regs->hw_ssp_ctrl0);
+
return &mxs_slave->slave;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work
2012-04-23 12:43 [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work Fabio Estevam
@ 2012-04-23 13:12 ` Marek Vasut
2012-04-23 17:43 ` Mike Frysinger
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2012-04-23 13:12 UTC (permalink / raw)
To: u-boot
Dear Fabio Estevam,
> MXS SSP controller may have up to three chip selects per port: SS0, SS1 and
> SS2.
>
> Currently only SS0 is supported in the mxs_spi driver.
>
> Allow all the three chip select to work by selecting the desired one
> in bits 20 and 21 of the HW_SSP_CTRL0 register.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> drivers/spi/mxs_spi.c | 17 +++++++++++++++++
> 1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
> index 4e6f14e..c0bfd25 100644
> --- a/drivers/spi/mxs_spi.c
> +++ b/drivers/spi/mxs_spi.c
> @@ -34,6 +34,8 @@
>
> #define MXS_SPI_MAX_TIMEOUT 1000000
> #define MXS_SPI_PORT_OFFSET 0x2000
> +#define MXS_SSP_CHIPSELECT_MASK 0x00300000
> +#define MXS_SSP_CHIPSELECT_SHIFT 20
>
> struct mxs_spi_slave {
> struct spi_slave slave;
> @@ -56,12 +58,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
> unsigned int cs, {
> struct mxs_spi_slave *mxs_slave;
> uint32_t addr;
> + struct mx28_ssp_regs *ssp_regs;
> + int reg;
>
> if (bus > 3) {
> printf("MXS SPI: Max bus number is 3\n");
> return NULL;
> }
>
> + if (cs > 2) {
> + printf("MXS SPI: Invalid chip select number: %d\n", cs);
> + return NULL;
> + }
> +
> mxs_slave = malloc(sizeof(struct mxs_spi_slave));
> if (!mxs_slave)
> return NULL;
> @@ -74,6 +83,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
> unsigned int cs, mxs_slave->mode = mode;
> mxs_slave->regs = (struct mx28_ssp_regs *)addr;
>
> + ssp_regs = mxs_slave->regs;
> +
> + reg = readl(&ssp_regs->hw_ssp_ctrl0);
> + reg &= ~(MXS_SSP_CHIPSELECT_MASK);
> + reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
> +
> + writel(reg, &ssp_regs->hw_ssp_ctrl0);
> +
> return &mxs_slave->slave;
> }
Acked-by: Marek Vasut <marex@denx.de>
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work
2012-04-23 12:43 [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work Fabio Estevam
2012-04-23 13:12 ` Marek Vasut
@ 2012-04-23 17:43 ` Mike Frysinger
1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2012-04-23 17:43 UTC (permalink / raw)
To: u-boot
On Monday 23 April 2012 08:43:12 Fabio Estevam wrote:
> --- a/drivers/spi/mxs_spi.c
> +++ b/drivers/spi/mxs_spi.c
> @@ -56,12 +58,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
>
> if (bus > 3) {
> printf("MXS SPI: Max bus number is 3\n");
> return NULL;
> }
>
> + if (cs > 2) {
> + printf("MXS SPI: Invalid chip select number: %d\n", cs);
> + return NULL;
> + }
this stuff really belongs in spi_cs_is_valid(), sans the printf's.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120423/10aed766/attachment.pgp>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-23 17:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-23 12:43 [U-Boot] [PATCH] spi: mxs: Allow other chip selects to work Fabio Estevam
2012-04-23 13:12 ` Marek Vasut
2012-04-23 17:43 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox