From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Michael van der Westhuizen
<michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Steffen Trumtrar
<s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Thor Thayer
<tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Subject: Re: [PATCH v2 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes
Date: Thu, 25 Jun 2015 17:41:45 +0300 [thread overview]
Message-ID: <1435243305.10393.103.camel@linux.intel.com> (raw)
In-Reply-To: <1435163696-14767-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
On Wed, 2015-06-24 at 18:34 +0200, Michael van der Westhuizen wrote:
> The commit dd11444327ce ("spi: dw-spi: Convert 16bit accesses to
> 32bit
> accesses") changed all 16bit accesses in the DW_apb_ssi driver to
> 32bit.
> This, unfortunately, breaks data register access on picoXcell, where
> the
> DW IP needs data register accesses to be word accesses (all other
> accesses appear to be OK).
>
> This change introduces a new master variable to allow interface
> drivers
> to specify that 16bit data transfer I/O is required. This change
> also
> introduces the ability to set this variable via device tree bindings
> in
> the MMIO interface driver.
>
> Before this change, on a picoXcell pc3x3:
> spi_master spi32766: interrupt_transfer: fifo overrun/underrun
> m25p80 spi32766.0: error -5 reading 9f
> m25p80: probe of spi32766.0 failed with error -5
>
> After this change:
> m25p80 spi32766.0: m25p40 (512 Kbytes)
Reviewed-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>
> Fixes: dd11444327ce ("spi: dw-spi: Convert 16bit accesses to 32bit
> accesses")
> Signed-off-by: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
> ---
>
> Changes in v2:
> - Incorporate review feedback from Andy Shevchenko
> - Rework the DT bindings to accept an I/O register width as a
> number of bytes rather than using a boolean spefifying the
> width preference to be 16 bits.
> - Add data register access wrapper functions and use them when
> reading and writing the data register.
>
> drivers/spi/spi-dw-mmio.c | 4 ++++
> drivers/spi/spi-dw.c | 4 ++--
> drivers/spi/spi-dw.h | 35 +++++++++++++++++++++++++++++++++++
> 3 files changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
> index eb03e12..e76bf72 100644
> --- a/drivers/spi/spi-dw-mmio.c
> +++ b/drivers/spi/spi-dw-mmio.c
> @@ -74,6 +74,10 @@ static int dw_spi_mmio_probe(struct
> platform_device *pdev)
>
> dws->max_freq = clk_get_rate(dwsmmio->clk);
>
> + if (pdev->dev.of_node)
> + of_property_read_u32(pdev->dev.of_node, "snps,reg-io
> -width",
> + &dws->reg_io_width);
> +
> num_cs = 4;
>
> if (pdev->dev.of_node)
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index 8d67d03..4fbfcdc 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -194,7 +194,7 @@ static void dw_writer(struct dw_spi *dws)
> else
> txw = *(u16 *)(dws->tx);
> }
> - dw_writel(dws, DW_SPI_DR, txw);
> + dw_write_io_reg(dws, DW_SPI_DR, txw);
> dws->tx += dws->n_bytes;
> }
> }
> @@ -205,7 +205,7 @@ static void dw_reader(struct dw_spi *dws)
> u16 rxw;
>
> while (max--) {
> - rxw = dw_readl(dws, DW_SPI_DR);
> + rxw = dw_read_io_reg(dws, DW_SPI_DR);
> /* Care rx only if the transfer's original "rx" is
> not null */
> if (dws->rx_end - dws->len) {
> if (dws->n_bytes == 1)
> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
> index 6c91391..b75ed32 100644
> --- a/drivers/spi/spi-dw.h
> +++ b/drivers/spi/spi-dw.h
> @@ -109,6 +109,7 @@ struct dw_spi {
> u32 fifo_len; /* depth of the FIFO
> buffer */
> u32 max_freq; /* max bus freq
> supported */
>
> + u32 reg_io_width; /* DR I/O width in
> bytes */
> u16 bus_num;
> u16 num_cs; /* supported
> slave numbers */
>
> @@ -145,11 +146,45 @@ static inline u32 dw_readl(struct dw_spi *dws,
> u32 offset)
> return __raw_readl(dws->regs + offset);
> }
>
> +static inline u16 dw_readw(struct dw_spi *dws, u32 offset)
> +{
> + return __raw_readw(dws->regs + offset);
> +}
> +
> static inline void dw_writel(struct dw_spi *dws, u32 offset, u32
> val)
> {
> __raw_writel(val, dws->regs + offset);
> }
>
> +static inline void dw_writew(struct dw_spi *dws, u32 offset, u16
> val)
> +{
> + __raw_writew(val, dws->regs + offset);
> +}
> +
> +static inline u32 dw_read_io_reg(struct dw_spi *dws, u32 offset)
> +{
> + switch (dws->reg_io_width) {
> + case 2:
> + return dw_readw(dws, offset);
> + case 4:
> + default:
> + return dw_readl(dws, offset);
> + }
> +}
> +
> +static inline void dw_write_io_reg(struct dw_spi *dws, u32 offset,
> u32 val)
> +{
> + switch (dws->reg_io_width) {
> + case 2:
> + dw_writew(dws, offset, val);
> + break;
> + case 4:
> + default:
> + dw_writel(dws, offset, val);
> + break;
> + }
> +}
> +
> static inline void spi_enable_chip(struct dw_spi *dws, int enable)
> {
> dw_writel(dws, DW_SPI_SSIENR, (enable ? 1 : 0));
--
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-06-25 14:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 8:43 [PATCH 0/2] spi: dw: Reintroduce optional 16 bit data register I/O Michael van der Westhuizen
[not found] ` <1434703435-25198-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-06-19 8:43 ` [PATCH 2/2] dt: snps,dw-apb-ssi: Describe 16 bit data register usage limitations Michael van der Westhuizen
2015-06-19 8:43 ` [PATCH 1/2] spi: dw: Allow interface drivers to limit data I/O to word sizes Michael van der Westhuizen
[not found] ` <1434703435-25198-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-06-24 11:57 ` Andy Shevchenko
2015-06-24 16:34 ` [PATCH v2 0/2] spi: dw: Reintroduce optional 16 bit data register I/O Michael van der Westhuizen
[not found] ` <1435163696-14767-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-06-24 16:34 ` [PATCH v2 1/2] dt: snps,dw-apb-ssi: Document new I/O data register width property Michael van der Westhuizen
2015-06-24 16:34 ` [PATCH v2 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes Michael van der Westhuizen
[not found] ` <1435163696-14767-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-06-25 14:41 ` Andy Shevchenko [this message]
2015-07-24 15:30 ` [PATCH v2 0/2] spi: dw: Reintroduce optional 16 bit data register I/O Andy Shevchenko
[not found] ` <1437751812.29746.74.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-24 15:37 ` Mark Brown
[not found] ` <20150724153704.GM11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-07-27 10:58 ` Andy Shevchenko
[not found] ` <1437994691.29746.80.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-27 11:19 ` Mark Brown
[not found] ` <20150727111944.GW11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-07-27 11:38 ` Michael van der Westhuizen
[not found] ` <CCC70BC0-E1D0-4C27-A44D-2D16ED9B3049-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-07-27 13:59 ` Mark Brown
[not found] ` <20150727135915.GY11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-08-18 10:29 ` Andy Shevchenko
2015-07-27 11:37 ` [RESEND PATCH " Michael van der Westhuizen
[not found] ` <1437997035-3046-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-07-27 11:37 ` [RESEND PATCH v2 1/2] dt: snps,dw-apb-ssi: Document new I/O data register width property Michael van der Westhuizen
[not found] ` <1437997035-3046-2-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-07-27 13:35 ` Rob Herring
2015-07-27 11:37 ` [RESEND PATCH v2 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes Michael van der Westhuizen
[not found] ` <1437997035-3046-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>
2015-08-18 10:36 ` Andy Shevchenko
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=1435243305.10393.103.camel@linux.intel.com \
--to=andriy.shevchenko-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org \
/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 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).