Skip to contentSkip to conversation

spi:fsl-dspi:convert to use regmap and big-endian supports

PATCH New Chao Fu 3 participants 5 messages Feb 12, 2014 – Feb 16, 2014

Subsystems (3)
lore
Share & tools
lore

Chao Fu

author
#0 lore raw

PATCH v4 1/2 spi:fsl-dspi:convert to use regmap and big-endian supports

From: Chao Fu <[email protected]>

Freescale DSPI module will have two endianess in different platform, but ARM is little endian. So when DSPI in big endian, core in little endian, readl and writel can not adjust R/W register in this condition. This patch will remove general readl/writel, and import regmap mechanism. Data endian will be transfered in regmap APIs.

Documents: dspi add bool "big-endian" in dts node if DSPI module work in big endian.

---
Change in v4:
Add Kconfig select REGMAP_MMIO.
Change in v3:
Remove readl and wrirel, and import regmap mechanism to R/W module registers.

Change in v2:
Make dspi_readx dspi_writex as inline functions. Modify the issue of indentation in function is_double_byte_mode. Add description about big endian in bindings document.

 .../devicetree/bindings/spi/spi-fsl-dspi.txt       |  2 +
 drivers/spi/Kconfig                                |  1 +
 drivers/spi/spi-fsl-dspi.c                         | 80 ++++++++++++++--------
 3 files changed, 56 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +2 -0
index a1fb303..5376de4 100644
@@ -10,6 +10,7 @@ Required properties:
 - pinctrl-names: must contain a "default" entry.
 - spi-num-chipselects : the number of the chipselect signals.
 - bus-num : the slave chip chipselect signal number.
+- big-endian : if DSPI modudle is big endian, the bool will be set in node.
 Example:
 
 dspi0 at 4002c000 {
@@ -24,6 +25,7 @@ dspi0 at 4002c000 {
 	bus-num = <0>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_dspi0_1>;
+	big-endian;
 	status = "okay";
 
 	sflash: at26df081a at 0 {
drivers/spi/Kconfig +1 -0
index ecd8f06..6554bd0 100644
@@ -270,6 +270,7 @@ config SPI_FSL_SPI
 config SPI_FSL_DSPI
 	tristate "Freescale DSPI controller"
 	select SPI_BITBANG
+	select REGMAP_MMIO
 	depends on SOC_VF610 || COMPILE_TEST
 	help
 	  This enables support for the Freescale DSPI controller in master
drivers/spi/spi-fsl-dspi.c +53 -27

179 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#1 lore raw

PATCH v4 2/2 spi:dspi:Remove some coding sytle not in standard

From: Chao Fu <[email protected]>

Remove some coding sytle not in standard in former code.

---
Change in v4:
None.
Change in v3:
None.
Change in v2:
New.

 drivers/spi/spi-fsl-dspi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-fsl-dspi.c +4 -4
index fb16575..42ede0d 100644
@@ -111,9 +111,9 @@ struct fsl_dspi {
 
 	struct regmap		*regmap;
 	int			irq;
-	struct clk 		*clk;
+	struct clk		*clk;
 
-	struct spi_transfer 	*cur_transfer;
+	struct spi_transfer	*cur_transfer;
 	struct chip_data	*cur_chip;
 	size_t			len;
 	void			*tx;
@@ -124,8 +124,8 @@ struct fsl_dspi {
 	u8			cs;
 	u16			void_write_data;
 
-	wait_queue_head_t 	waitq;
-	u32 			waitflags;
+	wait_queue_head_t	waitq;
+	u32			waitflags;
 };
 
 static inline int is_double_byte_mode(struct fsl_dspi *dspi)
Signature · 1 line
1.8.4
#2 lore raw

PATCH v4 1/2 spi:fsl-dspi:convert to use regmap and big-endian supports

In reply to Chao Fu

drivers/spi/spi-fsl-dspi.c static const struct dev_pm_ops dspi_pm = { · line 450

Quoted 13 lines
drivers/spi/spi-fsl-dspi.c +7 -0
@@ -435,12 +441,20 @@ static const struct dev_pm_ops dspi_pm = {
 	SET_SYSTEM_SLEEP_PM_OPS(dspi_suspend, dspi_resume)
 };
 
+static struct regmap_config dspi_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.max_register = 0x88,
+};
+

If needed, you should add the callbacks like:
.readable_reg,
.writeable_reg,
.volatile_reg,

Otherwise, it looks fine to me, for both patches:

maintainer
#3 lore raw

PATCH v4 1/2 spi:fsl-dspi:convert to use regmap and big-endian supports

Quoted 4 lines · Li.Xiubo at freescale.com

If needed, you should add the callbacks like:
.readable_reg,
.writeable_reg,
.volatile_reg,

They're not 100% needed unless you have a cache in which case
volatile_reg() becomes important but it's definitely good practice to
add them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140216/6dc4a770/attachment-0001.sig>

maintainer
#4 lore raw

PATCH v4 1/2 spi:fsl-dspi:convert to use regmap and big-endian supports

In reply to Chao Fu
Quoted 7 lines · Chao Fu

From: Chao Fu <[email protected]>

Freescale DSPI module will have two endianess in different platform, but ARM is little endian. So when DSPI in big endian, core in little endian, readl and writel can not adjust R/W register in this condition. This patch will remove general readl/writel, and import regmap mechanism. Data endian will be transfered in regmap APIs.

Applied both, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140216/f022e2e9/attachment.sig>