* [PATCH] spi-imx: Add loopback mode support @ 2015-12-04 1:23 Fabio Estevam [not found] ` <1449192204-24877-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Fabio Estevam @ 2015-12-04 1:23 UTC (permalink / raw) To: broonie-DgEjT+Ai2ygdnm+yROfE0A Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> 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-KZfg59tc24xl57MIdRCFDg@public.gmane.org> --- 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; init_completion(&spi_imx->xfer_done); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <1449192204-24877-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <1449192204-24877-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-12-05 17:32 ` Fabio Estevam [not found] ` <CAOMZO5AejRorUv6TKH90t-VpsSGd6NiH9cCTJC5-QuMpiGPOPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Fabio Estevam @ 2015-12-05 17:32 UTC (permalink / raw) To: Mark Brown Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam, anton.bondarenko.sama-Re5JQEeQqe8AvxtiuMwx3w On Thu, Dec 3, 2015 at 11:23 PM, Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > > 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-KZfg59tc24xl57MIdRCFDg@public.gmane.org> > --- > 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <CAOMZO5AejRorUv6TKH90t-VpsSGd6NiH9cCTJC5-QuMpiGPOPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <CAOMZO5AejRorUv6TKH90t-VpsSGd6NiH9cCTJC5-QuMpiGPOPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-12-06 11:24 ` Mark Brown [not found] ` <20151206112407.GK5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Mark Brown @ 2015-12-06 11:24 UTC (permalink / raw) To: Fabio Estevam Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam, anton.bondarenko.sama-Re5JQEeQqe8AvxtiuMwx3w [-- Attachment #1: Type: text/plain, Size: 323 bytes --] 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. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20151206112407.GK5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <20151206112407.GK5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> @ 2015-12-06 12:49 ` Anton Bondarenko [not found] ` <56642EF4.1050804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-06 14:51 ` Fabio Estevam 1 sibling, 1 reply; 9+ messages in thread From: Anton Bondarenko @ 2015-12-06 12:49 UTC (permalink / raw) To: Mark Brown, Fabio Estevam Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <56642EF4.1050804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <56642EF4.1050804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-12-07 19:16 ` Mark Brown [not found] ` <20151207191625.GM5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Mark Brown @ 2015-12-07 19:16 UTC (permalink / raw) To: Anton Bondarenko Cc: Fabio Estevam, linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam [-- Attachment #1: Type: text/plain, Size: 265 bytes --] 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. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20151207191625.GM5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <20151207191625.GM5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> @ 2015-12-08 6:46 ` Anton Bondarenko 0 siblings, 0 replies; 9+ messages in thread From: Anton Bondarenko @ 2015-12-08 6:46 UTC (permalink / raw) To: Mark Brown Cc: Fabio Estevam, linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <20151206112407.GK5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 2015-12-06 12:49 ` Anton Bondarenko @ 2015-12-06 14:51 ` Fabio Estevam [not found] ` <CAOMZO5BrOgOvupBXRcK=iLYmbViKMjQE6xYi6HwU71Twjt2O0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 1 sibling, 1 reply; 9+ messages in thread From: Fabio Estevam @ 2015-12-06 14:51 UTC (permalink / raw) To: Mark Brown Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam, Anton Bondarenko On Sun, Dec 6, 2015 at 9:24 AM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <CAOMZO5BrOgOvupBXRcK=iLYmbViKMjQE6xYi6HwU71Twjt2O0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <CAOMZO5BrOgOvupBXRcK=iLYmbViKMjQE6xYi6HwU71Twjt2O0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-12-06 18:06 ` Anton Bondarenko [not found] ` <56647929.4060202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Anton Bondarenko @ 2015-12-06 18:06 UTC (permalink / raw) To: Fabio Estevam, Mark Brown Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam On 2015-12-06 15:51, Fabio Estevam wrote: > On Sun, Dec 6, 2015 at 9:24 AM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <56647929.4060202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] spi-imx: Add loopback mode support [not found] ` <56647929.4060202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-12-06 19:34 ` Fabio Estevam 0 siblings, 0 replies; 9+ messages in thread From: Fabio Estevam @ 2015-12-06 19:34 UTC (permalink / raw) To: Anton Bondarenko Cc: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam Hi Anton, On Sun, Dec 6, 2015 at 4:06 PM, Anton Bondarenko <anton.bondarenko.sama-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-12-08 6:46 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-12-04 1:23 [PATCH] spi-imx: Add loopback mode support Fabio Estevam [not found] ` <1449192204-24877-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-05 17:32 ` Fabio Estevam [not found] ` <CAOMZO5AejRorUv6TKH90t-VpsSGd6NiH9cCTJC5-QuMpiGPOPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-12-06 11:24 ` Mark Brown [not found] ` <20151206112407.GK5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 2015-12-06 12:49 ` Anton Bondarenko [not found] ` <56642EF4.1050804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-07 19:16 ` Mark Brown [not found] ` <20151207191625.GM5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 2015-12-08 6:46 ` Anton Bondarenko 2015-12-06 14:51 ` Fabio Estevam [not found] ` <CAOMZO5BrOgOvupBXRcK=iLYmbViKMjQE6xYi6HwU71Twjt2O0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-12-06 18:06 ` Anton Bondarenko [not found] ` <56647929.4060202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-06 19:34 ` Fabio Estevam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).