Message ID | 1449192204-24877-1-git-send-email-festevam@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 9f6aa42bbbb23d2115704c5044da951a7e685cc5 |
Headers | show |
On Thu, Dec 3, 2015 at 11:23 PM, Fabio Estevam <festevam@gmail.com> wrote: > From: Fabio Estevam <fabio.estevam@freescale.com> > > Loopback mode can be activated by setting bit LBC (LoopBack > Control) of register ECSPI_TESTREG. > > Add support for it. > > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> > --- > drivers/spi/spi-imx.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c > index 0e5723a..e7e4f0c 100644 > --- a/drivers/spi/spi-imx.c > +++ b/drivers/spi/spi-imx.c > @@ -244,6 +244,9 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, > #define MX51_ECSPI_STAT 0x18 > #define MX51_ECSPI_STAT_RR (1 << 3) > > +#define MX51_ECSPI_TESTREG 0x20 > +#define MX51_ECSPI_TESTREG_LBC BIT(31) > + > /* MX51 eCSPI */ > static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi, > unsigned int *fres) > @@ -313,7 +316,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, > { > u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0, dma = 0; > u32 tx_wml_cfg, rx_wml_cfg, rxt_wml_cfg; > - u32 clk = config->speed_hz, delay; > + u32 clk = config->speed_hz, delay, reg; > > /* > * The hardware seems to have a race condition when changing modes. The > @@ -351,6 +354,13 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, > else > cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs); > > + reg = readl(spi_imx->base + MX51_ECSPI_TESTREG); > + if (config->mode & SPI_LOOP) > + reg |= MX51_ECSPI_TESTREG_LBC; > + else > + reg &= ~MX51_ECSPI_TESTREG_LBC; > + writel(reg, spi_imx->base + MX51_ECSPI_TESTREG); > + > writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); > writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); > > @@ -1141,7 +1151,8 @@ static int spi_imx_probe(struct platform_device *pdev) > spi_imx->bitbang.master->cleanup = spi_imx_cleanup; > spi_imx->bitbang.master->prepare_message = spi_imx_prepare_message; > spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message; > - spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; > + spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | > + SPI_LOOP; The SPI_LOOP should not be added to all spi versions, only for the mx51/mx53/mx6q type. Just realized that Anton sent the loopback support as part of his series, so please discard this one. -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Dec 05, 2015 at 03:32:31PM -0200, Fabio Estevam wrote: > The SPI_LOOP should not be added to all spi versions, only for the > mx51/mx53/mx6q type. > Just realized that Anton sent the loopback support as part of his > series, so please discard this one. I'd already applied this before you sent your mail, sorry.
On 2015-12-06 12:24, Mark Brown wrote: > On Sat, Dec 05, 2015 at 03:32:31PM -0200, Fabio Estevam wrote: > >> The SPI_LOOP should not be added to all spi versions, only for the >> mx51/mx53/mx6q type. > >> Just realized that Anton sent the loopback support as part of his >> series, so please discard this one. > > I'd already applied this before you sent your mail, sorry. > I'll rebase my changes on top of topic/imx. Is it OK? Regards, Anton -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, Dec 6, 2015 at 9:24 AM, Mark Brown <broonie@kernel.org> wrote: > On Sat, Dec 05, 2015 at 03:32:31PM -0200, Fabio Estevam wrote: > >> The SPI_LOOP should not be added to all spi versions, only for the >> mx51/mx53/mx6q type. > >> Just realized that Anton sent the loopback support as part of his >> series, so please discard this one. > > I'd already applied this before you sent your mail, sorry. No problekm, Mark. I think Anton can move the SPI_LOOP flag from the probe function to only mx51/mx53/mx6 config and all will be fine. Thanks -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2015-12-06 15:51, Fabio Estevam wrote: > On Sun, Dec 6, 2015 at 9:24 AM, Mark Brown <broonie@kernel.org> wrote: >> On Sat, Dec 05, 2015 at 03:32:31PM -0200, Fabio Estevam wrote: >> >>> The SPI_LOOP should not be added to all spi versions, only for the >>> mx51/mx53/mx6q type. >> >>> Just realized that Anton sent the loopback support as part of his >>> series, so please discard this one. >> >> I'd already applied this before you sent your mail, sorry. > > No problekm, Mark. I think Anton can move the SPI_LOOP flag from the > probe function to only mx51/mx53/mx6 config and all will be fine. > > Thanks > There is a small problem with this change. Loopback mode not enabled for first transaction in the system. This is happen because TEST reg written before controller taken out from the reset by writing to CTRL reg. The simple fix will be to move TEST reg read/write after write to CTRL reg. Regards, Anton -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Anton, On Sun, Dec 6, 2015 at 4:06 PM, Anton Bondarenko <anton.bondarenko.sama@gmail.com> wrote: > > There is a small problem with this change. Loopback mode not enabled for > first transaction in the system. This is happen because TEST reg written > before controller taken out from the reset by writing to CTRL reg. The > simple fix will be to move TEST reg read/write after write to CTRL reg. Could you please fix this as part of your series? Thanks -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, Dec 06, 2015 at 01:49:56PM +0100, Anton Bondarenko wrote: > On 2015-12-06 12:24, Mark Brown wrote: > >I'd already applied this before you sent your mail, sorry. > I'll rebase my changes on top of topic/imx. Is it OK? Yes, totally fine - please go ahead.
On 2015-12-07 20:16, Mark Brown wrote: > On Sun, Dec 06, 2015 at 01:49:56PM +0100, Anton Bondarenko wrote: >> On 2015-12-06 12:24, Mark Brown wrote: > >>> I'd already applied this before you sent your mail, sorry. > >> I'll rebase my changes on top of topic/imx. Is it OK? > > Yes, totally fine - please go ahead. > Fix for this commit provided in [PATCH v6 01/08]. -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 0e5723a..e7e4f0c 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -244,6 +244,9 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, #define MX51_ECSPI_STAT 0x18 #define MX51_ECSPI_STAT_RR (1 << 3) +#define MX51_ECSPI_TESTREG 0x20 +#define MX51_ECSPI_TESTREG_LBC BIT(31) + /* MX51 eCSPI */ static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi, unsigned int *fres) @@ -313,7 +316,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, { u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0, dma = 0; u32 tx_wml_cfg, rx_wml_cfg, rxt_wml_cfg; - u32 clk = config->speed_hz, delay; + u32 clk = config->speed_hz, delay, reg; /* * The hardware seems to have a race condition when changing modes. The @@ -351,6 +354,13 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, else cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs); + reg = readl(spi_imx->base + MX51_ECSPI_TESTREG); + if (config->mode & SPI_LOOP) + reg |= MX51_ECSPI_TESTREG_LBC; + else + reg &= ~MX51_ECSPI_TESTREG_LBC; + writel(reg, spi_imx->base + MX51_ECSPI_TESTREG); + writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); @@ -1141,7 +1151,8 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->bitbang.master->cleanup = spi_imx_cleanup; spi_imx->bitbang.master->prepare_message = spi_imx_prepare_message; spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message; - spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; + spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | + SPI_LOOP; init_completion(&spi_imx->xfer_done);