All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] spi: mxs: Allow other chip selects to work
Date: Mon, 23 Apr 2012 23:27:24 +0200	[thread overview]
Message-ID: <201204232327.24794.marex@denx.de> (raw)
In-Reply-To: <1335205850-26575-2-git-send-email-fabio.estevam@freescale.com>

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>

Acked-by: Marek Vasut <marex@denx.de>
> ---
> Changes since v1:
> - Check vor valid cs inside spi_cs_is_valid() (patch 1/2)
> 
>  drivers/spi/mxs_spi.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
> index e7237e7..7859536 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;
> @@ -65,6 +67,8 @@ 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 (!spi_cs_is_valid(bus, cs)) {
>  		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
> @@ -82,7 +86,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
> unsigned int cs, mxs_slave->max_khz = max_hz / 1000;
>  	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;
>  }

Best regards,
Marek Vasut

  reply	other threads:[~2012-04-23 21:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 18:30 [U-Boot] [PATCH v2 1/2] spi: mxs: Introduce spi_cs_is_valid() Fabio Estevam
2012-04-23 18:30 ` [U-Boot] [PATCH v2 2/2] spi: mxs: Allow other chip selects to work Fabio Estevam
2012-04-23 21:27   ` Marek Vasut [this message]
2012-05-09  9:53   ` Stefano Babic
2012-04-23 21:27 ` [U-Boot] [PATCH v2 1/2] spi: mxs: Introduce spi_cs_is_valid() Marek Vasut
2012-04-23 21:51 ` Mike Frysinger
2012-05-09  9:53 ` Stefano Babic

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=201204232327.24794.marex@denx.de \
    --to=marex@denx.de \
    --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.