* [PATCH v3 0/2] spi: dw: Reintroduce optional 16 bit data register I/O @ 2015-08-18 20:21 Michael van der Westhuizen [not found] ` <1439929313-4948-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Michael van der Westhuizen @ 2015-08-18 20:21 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Steffen Trumtrar, Thor Thayer, Andy Shevchenko, Mark Brown, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Michael van der Westhuizen The commit dd11444327ce ("spi: dw-spi: Convert 16bit accesses to 32bit accesses") globally changed all register access in the dw_apb_ssi driver to 32 bit access, which breaks data register (FIFO) access on picoXcell platforms. This series introduces a variable to the core spi-dw driver to indicate to the core that either 16 or 32 bit data register access is appropriate, with the code defaulting to the current 32 bit behaviour. The dw-spi-mmio driver is updated to support optionally setting this variable from the device tree and the binding documentation is updated. Prior to applying this change the following error presents on a picoXcell pc3x3 platform: spi_master spi32766: interrupt_transfer: fifo overrun/underrun m25p80 spi32766.0: error -5 reading 9f m25p80: probe of spi32766.0 failed with error -5 With this series applied: m25p80 spi32766.0: m25p40 (512 Kbytes) Changes in v3: - Rename the DT property as requested by Rob Herring. Changes in v2: - Incorporate review feedback from Andy Shevchenko, reworking the bindings to reflect common practice and adjusting the driver to suit. - Add a wrapper inline function for accessing the data register using the configured with. Michael van der Westhuizen (2): dt: snps,dw-apb-ssi: Document new I/O data register width property spi: dw: Allow interface drivers to limit data I/O to word sizes drivers/spi/spi-dw-mmio.c | 3 +++ drivers/spi/spi-dw.c | 4 ++-- drivers/spi/spi-dw.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) -- 2.1.4 -- 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] 6+ messages in thread
[parent not found: <1439929313-4948-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>]
* [PATCH v3 1/2] dt: snps,dw-apb-ssi: Document new I/O data register width property [not found] ` <1439929313-4948-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> @ 2015-08-18 20:21 ` Michael van der Westhuizen [not found] ` <1439929313-4948-2-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-18 20:21 ` [PATCH v3 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes Michael van der Westhuizen 1 sibling, 1 reply; 6+ messages in thread From: Michael van der Westhuizen @ 2015-08-18 20:21 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Steffen Trumtrar, Thor Thayer, Andy Shevchenko, Mark Brown, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Michael van der Westhuizen This change documents a new property for the snps,dw-apb-ssi device, allowing an implementer to specify either four byte or two bytes access to the SPI controller data register. This supports a change that unbreaks this driver on picoXcell platforms. Signed-off-by: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> --- Changes in v3: - Rename the DT property as requested by Rob Herring. Changes in v2: - Incorporate review feedback from Andy Shevchenko, reworking the bindings to reflect common practice. Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt index bd99193..204b311 100644 --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt @@ -10,6 +10,8 @@ Required properties: Optional properties: - cs-gpios : Specifies the gpio pis to be used for chipselects. - num-cs : The number of chipselects. If omitted, this will default to 4. +- reg-io-width : The I/O register width (in bytes) implemented by this + device. Supported values are 2 or 4 (the default). Child nodes as per the generic SPI binding. -- 2.1.4 -- 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] 6+ messages in thread
[parent not found: <1439929313-4948-2-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>]
* Applied "dt: snps,dw-apb-ssi: Document new I/O data register width property" to the spi tree [not found] ` <1439929313-4948-2-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> @ 2015-08-21 17:26 ` Mark Brown 0 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2015-08-21 17:26 UTC (permalink / raw) To: Michael van der Westhuizen, Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA The patch dt: snps,dw-apb-ssi: Document new I/O data register width property has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 4b226fbde68b8bfb66452067523a677b8e6492fa Mon Sep 17 00:00:00 2001 From: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> Date: Tue, 18 Aug 2015 22:21:52 +0200 Subject: [PATCH] dt: snps,dw-apb-ssi: Document new I/O data register width property This change documents a new property for the snps,dw-apb-ssi device, allowing an implementer to specify either four byte or two bytes access to the SPI controller data register. This supports a change that unbreaks this driver on picoXcell platforms. Signed-off-by: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt index bd99193..204b311 100644 --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt @@ -10,6 +10,8 @@ Required properties: Optional properties: - cs-gpios : Specifies the gpio pis to be used for chipselects. - num-cs : The number of chipselects. If omitted, this will default to 4. +- reg-io-width : The I/O register width (in bytes) implemented by this + device. Supported values are 2 or 4 (the default). Child nodes as per the generic SPI binding. -- 2.5.0 -- 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] 6+ messages in thread
* [PATCH v3 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes [not found] ` <1439929313-4948-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-18 20:21 ` [PATCH v3 1/2] dt: snps,dw-apb-ssi: Document new I/O data register width property Michael van der Westhuizen @ 2015-08-18 20:21 ` Michael van der Westhuizen [not found] ` <1439929313-4948-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 1 sibling, 1 reply; 6+ messages in thread From: Michael van der Westhuizen @ 2015-08-18 20:21 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Steffen Trumtrar, Thor Thayer, Andy Shevchenko, Mark Brown, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Michael van der Westhuizen 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. Both the core and the MMIO interface driver default to the current 32bit behaviour. 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) 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 v3: - Rename the DT property as requested by Rob Herring. 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 | 3 +++ drivers/spi/spi-dw.c | 4 ++-- drivers/spi/spi-dw.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index eb03e12..7edede6 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -74,6 +74,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->max_freq = clk_get_rate(dwsmmio->clk); + of_property_read_u32(pdev->dev.of_node, "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)); -- 2.1.4 -- 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] 6+ messages in thread
[parent not found: <1439929313-4948-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org>]
* Re: [PATCH v3 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes [not found] ` <1439929313-4948-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> @ 2015-08-19 8:51 ` Andy Shevchenko 2015-08-21 17:26 ` Applied "spi: dw: Allow interface drivers to limit data I/O to word sizes" to the spi tree Mark Brown 1 sibling, 0 replies; 6+ messages in thread From: Andy Shevchenko @ 2015-08-19 8:51 UTC (permalink / raw) To: Michael van der Westhuizen, linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Steffen Trumtrar, Thor Thayer, Mark Brown, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala On Tue, 2015-08-18 at 22:21 +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. Both the core and the MMIO interface > driver > default to the current 32bit behaviour. > > 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 v3: > - Rename the DT property as requested by Rob Herring. > > 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 | 3 +++ > drivers/spi/spi-dw.c | 4 ++-- > drivers/spi/spi-dw.h | 35 +++++++++++++++++++++++++++++++++++ > 3 files changed, 40 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c > index eb03e12..7edede6 100644 > --- a/drivers/spi/spi-dw-mmio.c > +++ b/drivers/spi/spi-dw-mmio.c > @@ -74,6 +74,9 @@ static int dw_spi_mmio_probe(struct platform_device > *pdev) > > dws->max_freq = clk_get_rate(dwsmmio->clk); > > + of_property_read_u32(pdev->dev.of_node, "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 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] 6+ messages in thread
* Applied "spi: dw: Allow interface drivers to limit data I/O to word sizes" to the spi tree [not found] ` <1439929313-4948-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-19 8:51 ` Andy Shevchenko @ 2015-08-21 17:26 ` Mark Brown 1 sibling, 0 replies; 6+ messages in thread From: Mark Brown @ 2015-08-21 17:26 UTC (permalink / raw) To: Michael van der Westhuizen, Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA The patch spi: dw: Allow interface drivers to limit data I/O to word sizes has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From c4fe57f76269dbb2af135071513f260ca40229a3 Mon Sep 17 00:00:00 2001 From: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> Date: Tue, 18 Aug 2015 22:21:53 +0200 Subject: [PATCH] spi: dw: Allow interface drivers to limit data I/O to word sizes 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. Both the core and the MMIO interface driver default to the current 32bit behaviour. 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) Fixes: dd11444327ce ("spi: dw-spi: Convert 16bit accesses to 32bit accesses") Signed-off-by: Michael van der Westhuizen <michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- drivers/spi/spi-dw-mmio.c | 3 +++ drivers/spi/spi-dw.c | 4 ++-- drivers/spi/spi-dw.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index eb03e12..7edede6 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -74,6 +74,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->max_freq = clk_get_rate(dwsmmio->clk); + of_property_read_u32(pdev->dev.of_node, "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)); -- 2.5.0 -- 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] 6+ messages in thread
end of thread, other threads:[~2015-08-21 17:26 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-08-18 20:21 [PATCH v3 0/2] spi: dw: Reintroduce optional 16 bit data register I/O Michael van der Westhuizen [not found] ` <1439929313-4948-1-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-18 20:21 ` [PATCH v3 1/2] dt: snps,dw-apb-ssi: Document new I/O data register width property Michael van der Westhuizen [not found] ` <1439929313-4948-2-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-21 17:26 ` Applied "dt: snps,dw-apb-ssi: Document new I/O data register width property" to the spi tree Mark Brown 2015-08-18 20:21 ` [PATCH v3 2/2] spi: dw: Allow interface drivers to limit data I/O to word sizes Michael van der Westhuizen [not found] ` <1439929313-4948-3-git-send-email-michael-XrNoQAPr3WXM9gW82pYGhQ@public.gmane.org> 2015-08-19 8:51 ` Andy Shevchenko 2015-08-21 17:26 ` Applied "spi: dw: Allow interface drivers to limit data I/O to word sizes" to the spi tree Mark Brown
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).