LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes
@ 2015-01-27 10:57 Bhuvanchandra DV
  2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

- Add second dspi instance.
- Enable MCP2515 CAN controller which is avaialble on
  Colibri evaluation board.

- Respin the stalled patches of dspi fixes.
  Previous discussion at:
  http://comments.gmane.org/gmane.linux.ports.arm.kernel/359542

Bhuvanchandra DV (4):
  ARM: vf610: add second DSPI instance
  ARM: vf-colibri: add SPI support and enable MCP2515 CAN
  spi: spi-fsl-dspi: Remove usage of devm_kalloc
  spi: spi-fsl-dspi: avoid preparing the clocks two times

Chao Fu (3):
  spi: spi-fsl-dspi: Remove spi-bitbang
  spi: spi-fsl-dspi: split the resuable code
  spi: spi-fsl-dspi: Add support for TCFQ transfer mode

 .../devicetree/bindings/spi/spi-fsl-dspi.txt       |   2 +
 arch/arm/boot/dts/vf-colibri-eval-v3.dtsi          |  31 ++
 arch/arm/boot/dts/vf-colibri.dtsi                  |  15 +
 arch/arm/boot/dts/vf500.dtsi                       |   4 +
 arch/arm/boot/dts/vfxxx.dtsi                       |  11 +
 drivers/spi/Kconfig                                |   1 -
 drivers/spi/spi-fsl-dspi.c                         | 314 +++++++++++++--------
 7 files changed, 254 insertions(+), 124 deletions(-)

-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/7] ARM: vf610: add second DSPI instance
  2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
@ 2015-01-27 10:57 ` Bhuvanchandra DV
  2015-01-28  9:08   ` Stefan Agner
  2015-02-26  8:02   ` Shawn Guo
  2015-01-27 10:57 ` [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN Bhuvanchandra DV
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 arch/arm/boot/dts/vf500.dtsi |  4 ++++
 arch/arm/boot/dts/vfxxx.dtsi | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/vf500.dtsi b/arch/arm/boot/dts/vf500.dtsi
index 1dbf8d2..f5f807c 100644
--- a/arch/arm/boot/dts/vf500.dtsi
+++ b/arch/arm/boot/dts/vf500.dtsi
@@ -66,6 +66,10 @@
 	interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
 };
 
+&dspi1 {
+	interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
+};
+
 &edma0 {
 	interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
 			<GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
index a29c7ce..789744b 100644
--- a/arch/arm/boot/dts/vfxxx.dtsi
+++ b/arch/arm/boot/dts/vfxxx.dtsi
@@ -139,6 +139,17 @@
 				status = "disabled";
 			};
 
+			dspi1: dspi1@4002d000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,vf610-dspi";
+				reg = <0x4002d000 0x1000>;
+				clocks = <&clks VF610_CLK_DSPI1>;
+				clock-names = "dspi";
+				spi-num-chipselects = <5>;
+				status = "disabled";
+			};
+
 			sai2: sai@40031000 {
 				compatible = "fsl,vf610-sai";
 				reg = <0x40031000 0x1000>;
-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN
  2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
  2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
@ 2015-01-27 10:57 ` Bhuvanchandra DV
  2015-01-28  9:55   ` Stefan Agner
  2015-01-27 10:57 ` [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Bhuvanchandra DV
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

MCP2515 CAN controller is available on Colibri Evaluation board.
Hence enable MCP2515 CAN.

Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 arch/arm/boot/dts/vf-colibri-eval-v3.dtsi | 31 +++++++++++++++++++++++++++++++
 arch/arm/boot/dts/vf-colibri.dtsi         | 15 +++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi b/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
index 36cafbf..69364b0 100644
--- a/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
+++ b/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
@@ -12,6 +12,12 @@
 		bootargs = "console=ttyLP0,115200";
 	};
 
+	clk16m: clk16m {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <16000000>;
+	};
+
 	regulators {
 		compatible = "simple-bus";
 		#address-cells = <1>;
@@ -47,6 +53,21 @@
 	status  = "okay";
 };
 
+&dspi1 {
+	status = "okay";
+
+	can2: mcp2515@0 {
+		compatible = "microchip,mcp2515";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_can_int>;
+		reg = <0>;
+		clocks = <&clk16m>;
+		spi-max-frequency = <10000000>;
+		interrupt-parent = <&gpio2>;
+		interrupts = <11 GPIO_ACTIVE_LOW>;
+	};
+};
+
 &esdhc1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_esdhc1>;
@@ -94,3 +115,13 @@
 &usbh1 {
 	vbus-supply = <&usbh_vbus_reg>;
 };
+
+&iomuxc {
+	vf610-colibri {
+		pinctrl_can_int: can_int {
+			fsl,pins = <
+				VF610_PAD_PTB21__GPIO_43	0x22ed
+			>;
+		};
+	};
+};
diff --git a/arch/arm/boot/dts/vf-colibri.dtsi b/arch/arm/boot/dts/vf-colibri.dtsi
index 5c2b732..fbef082 100644
--- a/arch/arm/boot/dts/vf-colibri.dtsi
+++ b/arch/arm/boot/dts/vf-colibri.dtsi
@@ -23,6 +23,12 @@
 	status = "okay";
 };
 
+&dspi1 {
+	bus-num = <1>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dspi1>;
+};
+
 &edma0 {
 	status = "okay";
 };
@@ -107,6 +113,15 @@
 			>;
 		};
 
+		pinctrl_dspi1: dspi1grp {
+			fsl,pins = <
+				VF610_PAD_PTD5__DSPI1_CS0		0x33e2
+				VF610_PAD_PTD6__DSPI1_SIN		0x33e1
+				VF610_PAD_PTD7__DSPI1_SOUT		0x33e2
+				VF610_PAD_PTD8__DSPI1_SCK		0x33e2
+			>;
+		};
+
 		pinctrl_esdhc1: esdhc1grp {
 			fsl,pins = <
 				VF610_PAD_PTA24__ESDHC1_CLK	0x31ef
-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc
  2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
  2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
  2015-01-27 10:57 ` [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN Bhuvanchandra DV
@ 2015-01-27 10:57 ` Bhuvanchandra DV
  2015-01-27 18:50   ` Aaron Brice
  2015-01-27 19:52   ` Mark Brown
  2015-01-27 10:57 ` [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times Bhuvanchandra DV
  2015-01-27 10:57 ` [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang Bhuvanchandra DV
  4 siblings, 2 replies; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

devm_* API was supposed to be used only in probe function call.
Memory is allocated at 'probe' and free automatically at 'remove'.
Usage of devm_* functions outside probe sometimes leads to memory leak.
Avoid using devm_kzalloc in dspi_setup_transfer and use kzalloc instead.
Also add the dspi_cleanup function to free the controller data upon
cleanup.

[    1.027945] fsl-dspi 4002d000.dspi1: registered master spi1
[    1.028664] spi spi1.0: setup mode 0, 8 bits/w, 50000000 Hz max --> 0
[    1.028877] ------------[ cut here ]------------
[    1.036953] WARNING: CPU: 0 PID: 1 at drivers/base/dd.c:286 driver_probe_device+0x1d8/0x244()
[    1.052136] Modules linked in:
[    1.058525] CPU: 0 PID: 1 Comm: swapper Not tainted 3.19.0-rc1-104479-g702bebc #202
[    1.072777] Backtrace:
[    1.078437] [<80011a04>] (dump_backtrace) from [<80011ce0>] (show_stack+0x18/0x1c)
[    1.092393]  r6:0000011e r5:00000009 r4:00000000 r3:00000000
[    1.101639] [<80011cc8>] (show_stack) from [<805a2d18>] (dump_stack+0x24/0x28)
[    1.115701] [<805a2cf4>] (dump_stack) from [<80021564>] (warn_slowpath_common+0x74/0x8c)
[    1.130905] [<800214f0>] (warn_slowpath_common) from [<80021620>] (warn_slowpath_null+0x24/0x2c)
[    1.147289]  r8:00000000 r7:807d5dd0 r6:802e2f54 r5:8ea1a200 r4:808444d4
[    1.158272] [<800215fc>] (warn_slowpath_null) from [<802e2ee8>] (driver_probe_device+0x1d8/0x244)
[    1.175532] [<802e2d10>] (driver_probe_device) from [<802e2f9c>] (__device_attach+0x48/0x4c)
[    1.192583]  r8:00000000 r7:8ea40000 r6:802e2f54 r5:8ea1a200 r4:807d5dd0 r3:8035a150
[    1.209718] [<802e2f54>] (__device_attach) from [<802e14ac>] (bus_for_each_drv+0x60/0x94)
[    1.227619]  r5:8ea1a200 r4:00000000
[    1.236097] [<802e144c>] (bus_for_each_drv) from [<802e2cd4>] (device_attach+0x7c/0x90)
[    1.253809]  r6:807d5cc0 r5:8ea1a234 r4:8ea1a200
[    1.263442] [<802e2c58>] (device_attach) from [<802e2338>] (bus_probe_device+0x8c/0xb0)
[    1.281269]  r6:807d5cc0 r5:8ea1a200 r4:8ea1a208 r3:8e881cc0
[    1.292124] [<802e22ac>] (bus_probe_device) from [<802e06c8>] (device_add+0x448/0x528)
[    1.309972]  r6:8ea1a200 r5:00000000 r4:8ea1a208 r3:00000001
[    1.320830] [<802e0280>] (device_add) from [<8035a8c8>] (spi_add_device+0x9c/0x15c)
[    1.338382]  r9:8e8ab210 r8:00000000 r7:8e8ab210 r6:00000000 r5:8ea40000 r4:8ea1a200
[    1.356236] [<8035a82c>] (spi_add_device) from [<8035c0a8>] (spi_register_master+0x4d8/0x73c)
[    1.374695]  r7:8ea1a368 r6:8ea1a200 r5:8fde7f7c r4:8ea40000
[    1.385537] [<8035bbd0>] (spi_register_master) from [<8035d930>] (spi_bitbang_start+0x9c/0x108)
[    1.404100]  r10:00008088 r9:8e816f80 r8:8fde7c50 r7:8e8ab210 r6:8e8ab200 r5:8ea40000
[    1.421967]  r4:8ea40000
[    1.429305] [<8035d894>] (spi_bitbang_start) from [<8035e334>] (dspi_probe+0x1d4/0x2bc)
[    1.446821]  r4:8ea40210 r3:80845a10
[    1.455241] [<8035e160>] (dspi_probe) from [<802e4854>] (platform_drv_probe+0x4c/0xac)
[    1.472666]  r10:00000000 r9:8ea1c2c0 r8:00000000 r7:807d5e20 r6:807d5e20 r5:fffffdfb
[    1.490365]  r4:8e8ab210
[    1.497638] [<802e4808>] (platform_drv_probe) from [<802e2e20>] (driver_probe_device+0x110/0x244)
[    1.516021]  r7:807d5e20 r6:00000000 r5:8e8ab210 r4:808444d4
[    1.526612] [<802e2d10>] (driver_probe_device) from [<802e3034>] (__driver_attach+0x94/0x98)
[    1.544556]  r8:807735e8 r7:00000000 r6:8e8ab244 r5:807d5e20 r4:8e8ab210 r3:00000000
[    1.562013] [<802e2fa0>] (__driver_attach) from [<802e13f4>] (bus_for_each_dev+0x68/0x9c)
[    1.579714]  r6:802e2fa0 r5:807d5e20 r4:00000000 r3:8e8ad03c
[    1.590310] [<802e138c>] (bus_for_each_dev) from [<802e2914>] (driver_attach+0x24/0x28)
[    1.607804]  r6:807ca840 r5:8ea25700 r4:807d5e20
[    1.617252] [<802e28f0>] (driver_attach) from [<802e25bc>] (bus_add_driver+0x150/0x1f8)
[    1.634584] [<802e246c>] (bus_add_driver) from [<802e3670>] (driver_register+0x80/0x100)
[    1.652292]  r7:8e842038 r6:8078e0f8 r5:807b3460 r4:807d5e20
[    1.662953] [<802e35f0>] (driver_register) from [<802e4798>] (__platform_driver_register+0x5c/0x64)
[    1.681772]  r5:807b3460 r4:807b3460
[    1.690234] [<802e473c>] (__platform_driver_register) from [<8078e114>] (fsl_dspi_driver_init+0x1c/0x20)
[    1.709306] [<8078e0f8>] (fsl_dspi_driver_init) from [<80008770>] (do_one_initcall+0x94/0x1d4)
[    1.727791] [<800086dc>] (do_one_initcall) from [<80773e38>] (kernel_init_freeable+0x130/0x1d0)
[    1.746412]  r10:8079eef0 r9:8079eee4 r8:807735e8 r7:807f1c80 r6:807f1c80 r5:00000006
[    1.764399]  r4:807a7bc8
[    1.771813] [<80773d08>] (kernel_init_freeable) from [<8059f864>] (kernel_init+0x10/0xf0)
[    1.789660]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:8059f854
[    1.807381]  r4:00000000
[    1.814668] [<8059f854>] (kernel_init) from [<8000e638>] (ret_from_fork+0x14/0x3c)
[    1.831772]  r4:00000000 r3:8e842000
[    1.840212] ---[ end trace f7f1c89f62e53de9 ]---

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 drivers/spi/spi-fsl-dspi.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 4cda994..9b80d54 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -342,8 +342,7 @@ static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	/* Only alloc on first setup */
 	chip = spi_get_ctldata(spi);
 	if (chip == NULL) {
-		chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
-				    GFP_KERNEL);
+		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
 		if (!chip)
 			return -ENOMEM;
 	}
@@ -382,6 +381,16 @@ static int dspi_setup(struct spi_device *spi)
 	return dspi_setup_transfer(spi, NULL);
 }
 
+static void dspi_cleanup(struct spi_device *spi)
+{
+	struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
+
+	dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n",
+			spi->master->bus_num, spi->chip_select);
+
+	kfree(chip);
+}
+
 static irqreturn_t dspi_interrupt(int irq, void *dev_id)
 {
 	struct fsl_dspi *dspi = (struct fsl_dspi *)dev_id;
@@ -467,6 +476,7 @@ static int dspi_probe(struct platform_device *pdev)
 	dspi->bitbang.master->setup = dspi_setup;
 	dspi->bitbang.master->dev.of_node = pdev->dev.of_node;
 
+	master->cleanup = dspi_cleanup;
 	master->mode_bits = SPI_CPOL | SPI_CPHA;
 	master->bits_per_word_mask = SPI_BPW_MASK(4) | SPI_BPW_MASK(8) |
 					SPI_BPW_MASK(16);
-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times
  2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
                   ` (2 preceding siblings ...)
  2015-01-27 10:57 ` [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Bhuvanchandra DV
@ 2015-01-27 10:57 ` Bhuvanchandra DV
  2015-01-27 13:01   ` Mark Brown
  2015-01-27 10:57 ` [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang Bhuvanchandra DV
  4 siblings, 1 reply; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

regmap_read/regmap_write will expect the peripheral clock
to be enabled before accessing the registers of the peripheral.
Since the peripheral clock is enabled separatly, avoid redundant clock
prepare (with devm_regmap_init_mmio_clk) and use devm_regmap_init_mmio instead.

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 drivers/spi/spi-fsl-dspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 9b80d54..5378148 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -502,7 +502,7 @@ static int dspi_probe(struct platform_device *pdev)
 		goto out_master_put;
 	}
 
-	dspi->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "dspi", base,
+	dspi->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 						&dspi_regmap_config);
 	if (IS_ERR(dspi->regmap)) {
 		dev_err(&pdev->dev, "failed to init regmap: %ld\n",
-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang
  2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
                   ` (3 preceding siblings ...)
  2015-01-27 10:57 ` [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times Bhuvanchandra DV
@ 2015-01-27 10:57 ` Bhuvanchandra DV
  2015-01-28 19:25   ` Mark Brown
  4 siblings, 1 reply; 13+ messages in thread
From: Bhuvanchandra DV @ 2015-01-27 10:57 UTC (permalink / raw)
  To: mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi, Bhuvanchandra DV

From: Chao Fu <B44548@freescale.com>

DSPI module need cs change information in
a spi transfer. According to cs change, DSPI
will give last data the right flag. Bitbang
provide cs change behind the last data in
a transfer. So DSPI can not deal the last
data in every transfer properly, so remove
the bitbang in the driver.

Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 drivers/spi/Kconfig        |   1 -
 drivers/spi/spi-fsl-dspi.c | 144 ++++++++++++++++++++++-----------------------
 2 files changed, 71 insertions(+), 74 deletions(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9982998..6316d6d 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -292,7 +292,6 @@ 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
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 5378148..b20dbb5 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -106,7 +106,7 @@ struct chip_data {
 };
 
 struct fsl_dspi {
-	struct spi_bitbang	bitbang;
+	struct spi_master	*master;
 	struct platform_device	*pdev;
 
 	struct regmap		*regmap;
@@ -114,6 +114,7 @@ struct fsl_dspi {
 	struct clk		*clk;
 
 	struct spi_transfer	*cur_transfer;
+	struct spi_message	*cur_msg;
 	struct chip_data	*cur_chip;
 	size_t			len;
 	void			*tx;
@@ -123,6 +124,7 @@ struct fsl_dspi {
 	char			dataflags;
 	u8			cs;
 	u16			void_write_data;
+	u32			cs_change;
 
 	wait_queue_head_t	waitq;
 	u32			waitflags;
@@ -225,6 +227,8 @@ static int dspi_transfer_write(struct fsl_dspi *dspi)
 		if (dspi->len == 0 || tx_count == DSPI_FIFO_SIZE - 1) {
 			/* last transfer in the transfer */
 			dspi_pushr |= SPI_PUSHR_EOQ;
+			if ((dspi->cs_change) && (!dspi->len))
+				dspi_pushr &= ~SPI_PUSHR_CONT;
 		} else if (tx_word && (dspi->len == 1))
 			dspi_pushr |= SPI_PUSHR_EOQ;
 
@@ -246,6 +250,7 @@ static int dspi_transfer_read(struct fsl_dspi *dspi)
 	int rx_count = 0;
 	int rx_word = is_double_byte_mode(dspi);
 	u16 d;
+
 	while ((dspi->rx < dspi->rx_end)
 			&& (rx_count < DSPI_FIFO_SIZE)) {
 		if (rx_word) {
@@ -276,64 +281,67 @@ static int dspi_transfer_read(struct fsl_dspi *dspi)
 	return rx_count;
 }
 
-static int dspi_txrx_transfer(struct spi_device *spi, struct spi_transfer *t)
+static int dspi_transfer_one_message(struct spi_master *master,
+		struct spi_message *message)
 {
-	struct fsl_dspi *dspi = spi_master_get_devdata(spi->master);
-	dspi->cur_transfer = t;
-	dspi->cur_chip = spi_get_ctldata(spi);
-	dspi->cs = spi->chip_select;
-	dspi->void_write_data = dspi->cur_chip->void_write_data;
-
-	dspi->dataflags = 0;
-	dspi->tx = (void *)t->tx_buf;
-	dspi->tx_end = dspi->tx + t->len;
-	dspi->rx = t->rx_buf;
-	dspi->rx_end = dspi->rx + t->len;
-	dspi->len = t->len;
-
-	if (!dspi->rx)
-		dspi->dataflags |= TRAN_STATE_RX_VOID;
-
-	if (!dspi->tx)
-		dspi->dataflags |= TRAN_STATE_TX_VOID;
-
-	regmap_write(dspi->regmap, SPI_MCR, dspi->cur_chip->mcr_val);
-	regmap_write(dspi->regmap, SPI_CTAR(dspi->cs), dspi->cur_chip->ctar_val);
-	regmap_write(dspi->regmap, SPI_RSER, SPI_RSER_EOQFE);
-
-	if (t->speed_hz)
+	struct fsl_dspi *dspi = spi_master_get_devdata(master);
+	struct spi_device *spi = message->spi;
+	struct spi_transfer *transfer;
+	int status = 0;
+	message->actual_length = 0;
+
+	list_for_each_entry(transfer, &message->transfers, transfer_list) {
+		dspi->cur_transfer = transfer;
+		dspi->cur_msg = message;
+		dspi->cur_chip = spi_get_ctldata(spi);
+		dspi->cs = spi->chip_select;
+		if (dspi->cur_transfer->transfer_list.next
+				== &dspi->cur_msg->transfers)
+			transfer->cs_change = 1;
+		dspi->cs_change = transfer->cs_change;
+		dspi->void_write_data = dspi->cur_chip->void_write_data;
+
+		dspi->dataflags = 0;
+		dspi->tx = (void *)transfer->tx_buf;
+		dspi->tx_end = dspi->tx + transfer->len;
+		dspi->rx = transfer->rx_buf;
+		dspi->rx_end = dspi->rx + transfer->len;
+		dspi->len = transfer->len;
+
+		if (!dspi->rx)
+			dspi->dataflags |= TRAN_STATE_RX_VOID;
+
+		if (!dspi->tx)
+			dspi->dataflags |= TRAN_STATE_TX_VOID;
+
+		regmap_write(dspi->regmap, SPI_MCR, dspi->cur_chip->mcr_val);
+		regmap_update_bits(dspi->regmap, SPI_MCR,
+				SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF,
+				SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
 		regmap_write(dspi->regmap, SPI_CTAR(dspi->cs),
 				dspi->cur_chip->ctar_val);
+		if (transfer->speed_hz)
+			regmap_write(dspi->regmap, SPI_CTAR(dspi->cs),
+					dspi->cur_chip->ctar_val);
 
-	dspi_transfer_write(dspi);
-
-	if (wait_event_interruptible(dspi->waitq, dspi->waitflags))
-		dev_err(&dspi->pdev->dev, "wait transfer complete fail!\n");
-	dspi->waitflags = 0;
-
-	return t->len - dspi->len;
-}
-
-static void dspi_chipselect(struct spi_device *spi, int value)
-{
-	struct fsl_dspi *dspi = spi_master_get_devdata(spi->master);
-	unsigned int pushr;
+		regmap_write(dspi->regmap, SPI_RSER, SPI_RSER_EOQFE);
+		message->actual_length += dspi_transfer_write(dspi);
 
-	regmap_read(dspi->regmap, SPI_PUSHR, &pushr);
+		if (wait_event_interruptible(dspi->waitq, dspi->waitflags))
+			dev_err(&dspi->pdev->dev, "wait transfer complete fail!\n");
+		dspi->waitflags = 0;
 
-	switch (value) {
-	case BITBANG_CS_ACTIVE:
-		pushr |= SPI_PUSHR_CONT;
-		break;
-	case BITBANG_CS_INACTIVE:
-		pushr &= ~SPI_PUSHR_CONT;
-		break;
+		if (transfer->delay_usecs)
+			udelay(transfer->delay_usecs);
 	}
 
-	regmap_write(dspi->regmap, SPI_PUSHR, pushr);
+	message->status = status;
+	spi_finalize_current_message(master);
+
+	return status;
 }
 
-static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
+static int dspi_setup(struct spi_device *spi)
 {
 	struct chip_data *chip;
 	struct fsl_dspi *dspi = spi_master_get_devdata(spi->master);
@@ -373,14 +381,6 @@ static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	return 0;
 }
 
-static int dspi_setup(struct spi_device *spi)
-{
-	if (!spi->max_speed_hz)
-		return -EINVAL;
-
-	return dspi_setup_transfer(spi, NULL);
-}
-
 static void dspi_cleanup(struct spi_device *spi)
 {
 	struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
@@ -395,22 +395,20 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
 {
 	struct fsl_dspi *dspi = (struct fsl_dspi *)dev_id;
 
-	regmap_write(dspi->regmap, SPI_SR, SPI_SR_EOQF);
+	struct spi_message *msg = dspi->cur_msg;
 
+	regmap_write(dspi->regmap, SPI_SR, SPI_SR_EOQF);
 	dspi_transfer_read(dspi);
 
 	if (!dspi->len) {
 		if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM)
 			regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs),
-				SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(16));
+			SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(16));
 
 		dspi->waitflags = 1;
 		wake_up_interruptible(&dspi->waitq);
-	} else {
-		dspi_transfer_write(dspi);
-
-		return IRQ_HANDLED;
-	}
+	} else
+		msg->actual_length += dspi_transfer_write(dspi);
 
 	return IRQ_HANDLED;
 }
@@ -469,12 +467,12 @@ static int dspi_probe(struct platform_device *pdev)
 
 	dspi = spi_master_get_devdata(master);
 	dspi->pdev = pdev;
-	dspi->bitbang.master = master;
-	dspi->bitbang.chipselect = dspi_chipselect;
-	dspi->bitbang.setup_transfer = dspi_setup_transfer;
-	dspi->bitbang.txrx_bufs = dspi_txrx_transfer;
-	dspi->bitbang.master->setup = dspi_setup;
-	dspi->bitbang.master->dev.of_node = pdev->dev.of_node;
+	dspi->master = master;
+
+	master->transfer = NULL;
+	master->setup = dspi_setup;
+	master->transfer_one_message = dspi_transfer_one_message;
+	master->dev.of_node = pdev->dev.of_node;
 
 	master->cleanup = dspi_cleanup;
 	master->mode_bits = SPI_CPOL | SPI_CPHA;
@@ -535,7 +533,7 @@ static int dspi_probe(struct platform_device *pdev)
 	init_waitqueue_head(&dspi->waitq);
 	platform_set_drvdata(pdev, master);
 
-	ret = spi_bitbang_start(&dspi->bitbang);
+	ret = spi_register_master(master);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Problem registering DSPI master\n");
 		goto out_clk_put;
@@ -557,9 +555,9 @@ static int dspi_remove(struct platform_device *pdev)
 	struct fsl_dspi *dspi = spi_master_get_devdata(master);
 
 	/* Disconnect from the SPI framework */
-	spi_bitbang_stop(&dspi->bitbang);
 	clk_disable_unprepare(dspi->clk);
-	spi_master_put(dspi->bitbang.master);
+	spi_unregister_master(dspi->master);
+	spi_master_put(dspi->master);
 
 	return 0;
 }
-- 
2.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times
  2015-01-27 10:57 ` [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times Bhuvanchandra DV
@ 2015-01-27 13:01   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-01-27 13:01 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, stefan, shawn.guo, robh+dt, pawel.moll,
	ijc+devicetree, galak, linux, B44548, Li.Xiubo, devicetree,
	linux-kernel, linux-arm-kernel, linux-spi

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

On Tue, Jan 27, 2015 at 04:27:21PM +0530, Bhuvanchandra DV wrote:
> regmap_read/regmap_write will expect the peripheral clock
> to be enabled before accessing the registers of the peripheral.
> Since the peripheral clock is enabled separatly, avoid redundant clock
> prepare (with devm_regmap_init_mmio_clk) and use devm_regmap_init_mmio instead.

What's the advantage of this?  The clock API is refcounted so there
should be no issue with this and it seems like it's opening us up to
bugs if there's a path where we interact with the registers without
enabling the clocks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc
  2015-01-27 10:57 ` [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Bhuvanchandra DV
@ 2015-01-27 18:50   ` Aaron Brice
  2015-01-27 19:52   ` Mark Brown
  1 sibling, 0 replies; 13+ messages in thread
From: Aaron Brice @ 2015-01-27 18:50 UTC (permalink / raw)
  To: Bhuvanchandra DV, mark.rutland
  Cc: stefan, shawn.guo, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi

On 01/27/2015 03:57 AM, Bhuvanchandra DV wrote:
> devm_* API was supposed to be used only in probe function call.
> Memory is allocated at 'probe' and free automatically at 'remove'.
> Usage of devm_* functions outside probe sometimes leads to memory leak.
> Avoid using devm_kzalloc in dspi_setup_transfer and use kzalloc instead.
> Also add the dspi_cleanup function to free the controller data upon
> cleanup.
>
> [    1.027945] fsl-dspi 4002d000.dspi1: registered master spi1
> [    1.028664] spi spi1.0: setup mode 0, 8 bits/w, 50000000 Hz max --> 0
> [    1.028877] ------------[ cut here ]------------
> [    1.036953] WARNING: CPU: 0 PID: 1 at drivers/base/dd.c:286 driver_probe_device+0x1d8/0x244()
> [    1.052136] Modules linked in:
> [    1.058525] CPU: 0 PID: 1 Comm: swapper Not tainted 3.19.0-rc1-104479-g702bebc #202
> [    1.072777] Backtrace:
> [    1.078437] [<80011a04>] (dump_backtrace) from [<80011ce0>] (show_stack+0x18/0x1c)
> [    1.092393]  r6:0000011e r5:00000009 r4:00000000 r3:00000000
> [    1.101639] [<80011cc8>] (show_stack) from [<805a2d18>] (dump_stack+0x24/0x28)
> [    1.115701] [<805a2cf4>] (dump_stack) from [<80021564>] (warn_slowpath_common+0x74/0x8c)
> [    1.130905] [<800214f0>] (warn_slowpath_common) from [<80021620>] (warn_slowpath_null+0x24/0x2c)
> [    1.147289]  r8:00000000 r7:807d5dd0 r6:802e2f54 r5:8ea1a200 r4:808444d4
> [    1.158272] [<800215fc>] (warn_slowpath_null) from [<802e2ee8>] (driver_probe_device+0x1d8/0x244)
> [    1.175532] [<802e2d10>] (driver_probe_device) from [<802e2f9c>] (__device_attach+0x48/0x4c)
> [    1.192583]  r8:00000000 r7:8ea40000 r6:802e2f54 r5:8ea1a200 r4:807d5dd0 r3:8035a150
> [    1.209718] [<802e2f54>] (__device_attach) from [<802e14ac>] (bus_for_each_drv+0x60/0x94)
> [    1.227619]  r5:8ea1a200 r4:00000000
> [    1.236097] [<802e144c>] (bus_for_each_drv) from [<802e2cd4>] (device_attach+0x7c/0x90)
> [    1.253809]  r6:807d5cc0 r5:8ea1a234 r4:8ea1a200
> [    1.263442] [<802e2c58>] (device_attach) from [<802e2338>] (bus_probe_device+0x8c/0xb0)
> [    1.281269]  r6:807d5cc0 r5:8ea1a200 r4:8ea1a208 r3:8e881cc0
> [    1.292124] [<802e22ac>] (bus_probe_device) from [<802e06c8>] (device_add+0x448/0x528)
> [    1.309972]  r6:8ea1a200 r5:00000000 r4:8ea1a208 r3:00000001
> [    1.320830] [<802e0280>] (device_add) from [<8035a8c8>] (spi_add_device+0x9c/0x15c)
> [    1.338382]  r9:8e8ab210 r8:00000000 r7:8e8ab210 r6:00000000 r5:8ea40000 r4:8ea1a200
> [    1.356236] [<8035a82c>] (spi_add_device) from [<8035c0a8>] (spi_register_master+0x4d8/0x73c)
> [    1.374695]  r7:8ea1a368 r6:8ea1a200 r5:8fde7f7c r4:8ea40000
> [    1.385537] [<8035bbd0>] (spi_register_master) from [<8035d930>] (spi_bitbang_start+0x9c/0x108)
> [    1.404100]  r10:00008088 r9:8e816f80 r8:8fde7c50 r7:8e8ab210 r6:8e8ab200 r5:8ea40000
> [    1.421967]  r4:8ea40000
> [    1.429305] [<8035d894>] (spi_bitbang_start) from [<8035e334>] (dspi_probe+0x1d4/0x2bc)
> [    1.446821]  r4:8ea40210 r3:80845a10
> [    1.455241] [<8035e160>] (dspi_probe) from [<802e4854>] (platform_drv_probe+0x4c/0xac)
> [    1.472666]  r10:00000000 r9:8ea1c2c0 r8:00000000 r7:807d5e20 r6:807d5e20 r5:fffffdfb
> [    1.490365]  r4:8e8ab210
> [    1.497638] [<802e4808>] (platform_drv_probe) from [<802e2e20>] (driver_probe_device+0x110/0x244)
> [    1.516021]  r7:807d5e20 r6:00000000 r5:8e8ab210 r4:808444d4
> [    1.526612] [<802e2d10>] (driver_probe_device) from [<802e3034>] (__driver_attach+0x94/0x98)
> [    1.544556]  r8:807735e8 r7:00000000 r6:8e8ab244 r5:807d5e20 r4:8e8ab210 r3:00000000
> [    1.562013] [<802e2fa0>] (__driver_attach) from [<802e13f4>] (bus_for_each_dev+0x68/0x9c)
> [    1.579714]  r6:802e2fa0 r5:807d5e20 r4:00000000 r3:8e8ad03c
> [    1.590310] [<802e138c>] (bus_for_each_dev) from [<802e2914>] (driver_attach+0x24/0x28)
> [    1.607804]  r6:807ca840 r5:8ea25700 r4:807d5e20
> [    1.617252] [<802e28f0>] (driver_attach) from [<802e25bc>] (bus_add_driver+0x150/0x1f8)
> [    1.634584] [<802e246c>] (bus_add_driver) from [<802e3670>] (driver_register+0x80/0x100)
> [    1.652292]  r7:8e842038 r6:8078e0f8 r5:807b3460 r4:807d5e20
> [    1.662953] [<802e35f0>] (driver_register) from [<802e4798>] (__platform_driver_register+0x5c/0x64)
> [    1.681772]  r5:807b3460 r4:807b3460
> [    1.690234] [<802e473c>] (__platform_driver_register) from [<8078e114>] (fsl_dspi_driver_init+0x1c/0x20)
> [    1.709306] [<8078e0f8>] (fsl_dspi_driver_init) from [<80008770>] (do_one_initcall+0x94/0x1d4)
> [    1.727791] [<800086dc>] (do_one_initcall) from [<80773e38>] (kernel_init_freeable+0x130/0x1d0)
> [    1.746412]  r10:8079eef0 r9:8079eee4 r8:807735e8 r7:807f1c80 r6:807f1c80 r5:00000006
> [    1.764399]  r4:807a7bc8
> [    1.771813] [<80773d08>] (kernel_init_freeable) from [<8059f864>] (kernel_init+0x10/0xf0)
> [    1.789660]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:8059f854
> [    1.807381]  r4:00000000
> [    1.814668] [<8059f854>] (kernel_init) from [<8000e638>] (ret_from_fork+0x14/0x3c)
> [    1.831772]  r4:00000000 r3:8e842000
> [    1.840212] ---[ end trace f7f1c89f62e53de9 ]---
>
> Acked-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
> ---
>   drivers/spi/spi-fsl-dspi.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
> index 4cda994..9b80d54 100644
> --- a/drivers/spi/spi-fsl-dspi.c
> +++ b/drivers/spi/spi-fsl-dspi.c
> @@ -342,8 +342,7 @@ static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
>   	/* Only alloc on first setup */
>   	chip = spi_get_ctldata(spi);
>   	if (chip == NULL) {
> -		chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
> -				    GFP_KERNEL);
> +		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
>   		if (!chip)
>   			return -ENOMEM;
>   	}
> @@ -382,6 +381,16 @@ static int dspi_setup(struct spi_device *spi)
>   	return dspi_setup_transfer(spi, NULL);
>   }
>   
> +static void dspi_cleanup(struct spi_device *spi)
> +{
> +	struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
> +
> +	dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n",
> +			spi->master->bus_num, spi->chip_select);
> +
> +	kfree(chip);
> +}
> +
Does dspi_cleanup need a spi_set_ctldata((struct spi_device *)spi, NULL) ?
>   static irqreturn_t dspi_interrupt(int irq, void *dev_id)
>   {
>   	struct fsl_dspi *dspi = (struct fsl_dspi *)dev_id;
> @@ -467,6 +476,7 @@ static int dspi_probe(struct platform_device *pdev)
>   	dspi->bitbang.master->setup = dspi_setup;
>   	dspi->bitbang.master->dev.of_node = pdev->dev.of_node;
>   
> +	master->cleanup = dspi_cleanup;
>   	master->mode_bits = SPI_CPOL | SPI_CPHA;
>   	master->bits_per_word_mask = SPI_BPW_MASK(4) | SPI_BPW_MASK(8) |
>   					SPI_BPW_MASK(16);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc
  2015-01-27 10:57 ` [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Bhuvanchandra DV
  2015-01-27 18:50   ` Aaron Brice
@ 2015-01-27 19:52   ` Mark Brown
  1 sibling, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-01-27 19:52 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, stefan, shawn.guo, robh+dt, pawel.moll,
	ijc+devicetree, galak, linux, B44548, Li.Xiubo, devicetree,
	linux-kernel, linux-arm-kernel, linux-spi

[-- Attachment #1: Type: text/plain, Size: 534 bytes --]

On Tue, Jan 27, 2015 at 04:27:20PM +0530, Bhuvanchandra DV wrote:
> devm_* API was supposed to be used only in probe function call.
> Memory is allocated at 'probe' and free automatically at 'remove'.

Applied, thanks.  Please don't dump entire backtraces into your commit
logs - they're far too big and not very helpful, they can obscure real
content in the message.  Explain in words what the problem is and if a
backtrace helps illustrate that edit it down to only relevant portions
rather than blindly including the entire thing.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/7] ARM: vf610: add second DSPI instance
  2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
@ 2015-01-28  9:08   ` Stefan Agner
  2015-02-26  8:02   ` Shawn Guo
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Agner @ 2015-01-28  9:08 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, shawn.guo, robh+dt, pawel.moll, ijc+devicetree,
	galak, linux, broonie, B44548, Li.Xiubo, devicetree,
	linux-kernel, linux-arm-kernel, linux-spi

On 2015-01-27 11:57, Bhuvanchandra DV wrote:
> Acked-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
> ---
>  arch/arm/boot/dts/vf500.dtsi |  4 ++++
>  arch/arm/boot/dts/vfxxx.dtsi | 11 +++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf500.dtsi b/arch/arm/boot/dts/vf500.dtsi
> index 1dbf8d2..f5f807c 100644
> --- a/arch/arm/boot/dts/vf500.dtsi
> +++ b/arch/arm/boot/dts/vf500.dtsi
> @@ -66,6 +66,10 @@
>  	interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
>  };
>  
> +&dspi1 {
> +	interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
> +};
> +
>  &edma0 {
>  	interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
>  			<GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
> diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
> index a29c7ce..789744b 100644
> --- a/arch/arm/boot/dts/vfxxx.dtsi
> +++ b/arch/arm/boot/dts/vfxxx.dtsi
> @@ -139,6 +139,17 @@
>  				status = "disabled";
>  			};
>  
> +			dspi1: dspi1@4002d000 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "fsl,vf610-dspi";
> +				reg = <0x4002d000 0x1000>;
> +				clocks = <&clks VF610_CLK_DSPI1>;
> +				clock-names = "dspi";
> +				spi-num-chipselects = <5>;
> +				status = "disabled";
> +			};
> +
>  			sai2: sai@40031000 {
>  				compatible = "fsl,vf610-sai";
>  				reg = <0x40031000 0x1000>;


Acked-by: Stefan Agner <stefan@agner.ch>

Shawn, this will conflict with the pending MSCM driver patchset. I
probably have to resend the MSCM patchset anyway, also, the fix would be
trivial anyway.

--
Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN
  2015-01-27 10:57 ` [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN Bhuvanchandra DV
@ 2015-01-28  9:55   ` Stefan Agner
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Agner @ 2015-01-28  9:55 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, shawn.guo, robh+dt, pawel.moll, ijc+devicetree,
	galak, linux, broonie, B44548, Li.Xiubo, devicetree,
	linux-kernel, linux-arm-kernel, linux-spi

On 2015-01-27 11:57, Bhuvanchandra DV wrote:
> MCP2515 CAN controller is available on Colibri Evaluation board.
> Hence enable MCP2515 CAN.
> 
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
> ---
>  arch/arm/boot/dts/vf-colibri-eval-v3.dtsi | 31 +++++++++++++++++++++++++++++++
>  arch/arm/boot/dts/vf-colibri.dtsi         | 15 +++++++++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
> b/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
> index 36cafbf..69364b0 100644
> --- a/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
> +++ b/arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
> @@ -12,6 +12,12 @@
>  		bootargs = "console=ttyLP0,115200";
>  	};
>  
> +	clk16m: clk16m {
> +		compatible = "fixed-clock";
> +		#clock-cells = <0>;
> +		clock-frequency = <16000000>;
> +	};
> +
>  	regulators {
>  		compatible = "simple-bus";
>  		#address-cells = <1>;
> @@ -47,6 +53,21 @@
>  	status  = "okay";
>  };
>  
> +&dspi1 {
> +	status = "okay";
> +
> +	can2: mcp2515@0 {


The device tree usage website states (devicetree.org): "nodes are named
according to what kind of device it represents"...

You can use the label to specify the type, e.g. I would suggest to use
something like:


	mcp2515can: can@0 {
...




> +		compatible = "microchip,mcp2515";
> +		pinctrl-names = "default";
> +		pinctrl-0 = <&pinctrl_can_int>;
> +		reg = <0>;
> +		clocks = <&clk16m>;
> +		spi-max-frequency = <10000000>;
> +		interrupt-parent = <&gpio2>;

The interrupt line of the MCP2515 is connected to SODIMM 73, which is
PORT1[11] on Vybrid. My recent renaming of the GPIO's has been merged
already:
https://lkml.org/lkml/2015/1/16/419

Hence, this should be updated to gpio1.


> +		interrupts = <11 GPIO_ACTIVE_LOW>;
> +	};
> +};
> +
>  &esdhc1 {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&pinctrl_esdhc1>;
> @@ -94,3 +115,13 @@
>  &usbh1 {
>  	vbus-supply = <&usbh_vbus_reg>;
>  };
> +
> +&iomuxc {
> +	vf610-colibri {
> +		pinctrl_can_int: can_int {
> +			fsl,pins = <
> +				VF610_PAD_PTB21__GPIO_43	0x22ed
> +			>;
> +		};
> +	};
> +};
> diff --git a/arch/arm/boot/dts/vf-colibri.dtsi
> b/arch/arm/boot/dts/vf-colibri.dtsi
> index 5c2b732..fbef082 100644
> --- a/arch/arm/boot/dts/vf-colibri.dtsi
> +++ b/arch/arm/boot/dts/vf-colibri.dtsi
> @@ -23,6 +23,12 @@
>  	status = "okay";
>  };
>  
> +&dspi1 {
> +	bus-num = <1>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_dspi1>;
> +};
> +
>  &edma0 {
>  	status = "okay";
>  };
> @@ -107,6 +113,15 @@
>  			>;
>  		};
>  
> +		pinctrl_dspi1: dspi1grp {
> +			fsl,pins = <
> +				VF610_PAD_PTD5__DSPI1_CS0		0x33e2
> +				VF610_PAD_PTD6__DSPI1_SIN		0x33e1
> +				VF610_PAD_PTD7__DSPI1_SOUT		0x33e2
> +				VF610_PAD_PTD8__DSPI1_SCK		0x33e2
> +			>;
> +		};
> +
>  		pinctrl_esdhc1: esdhc1grp {
>  			fsl,pins = <
>  				VF610_PAD_PTA24__ESDHC1_CLK	0x31ef


The rest looks good, thx.

--
Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang
  2015-01-27 10:57 ` [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang Bhuvanchandra DV
@ 2015-01-28 19:25   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-01-28 19:25 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, stefan, shawn.guo, robh+dt, pawel.moll,
	ijc+devicetree, galak, linux, B44548, Li.Xiubo, devicetree,
	linux-kernel, linux-arm-kernel, linux-spi

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]

On Tue, Jan 27, 2015 at 04:27:22PM +0530, Bhuvanchandra DV wrote:
> From: Chao Fu <B44548@freescale.com>
> 
> DSPI module need cs change information in
> a spi transfer. According to cs change, DSPI

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/7] ARM: vf610: add second DSPI instance
  2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
  2015-01-28  9:08   ` Stefan Agner
@ 2015-02-26  8:02   ` Shawn Guo
  1 sibling, 0 replies; 13+ messages in thread
From: Shawn Guo @ 2015-02-26  8:02 UTC (permalink / raw)
  To: Bhuvanchandra DV
  Cc: mark.rutland, stefan, robh+dt, pawel.moll, ijc+devicetree, galak,
	linux, broonie, B44548, Li.Xiubo, devicetree, linux-kernel,
	linux-arm-kernel, linux-spi

On Tue, Jan 27, 2015 at 04:27:18PM +0530, Bhuvanchandra DV wrote:
> Acked-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>

Applied, thanks.

> ---
>  arch/arm/boot/dts/vf500.dtsi |  4 ++++
>  arch/arm/boot/dts/vfxxx.dtsi | 11 +++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf500.dtsi b/arch/arm/boot/dts/vf500.dtsi
> index 1dbf8d2..f5f807c 100644
> --- a/arch/arm/boot/dts/vf500.dtsi
> +++ b/arch/arm/boot/dts/vf500.dtsi
> @@ -66,6 +66,10 @@
>  	interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
>  };
>  
> +&dspi1 {
> +	interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
> +};
> +
>  &edma0 {
>  	interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
>  			<GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
> diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
> index a29c7ce..789744b 100644
> --- a/arch/arm/boot/dts/vfxxx.dtsi
> +++ b/arch/arm/boot/dts/vfxxx.dtsi
> @@ -139,6 +139,17 @@
>  				status = "disabled";
>  			};
>  
> +			dspi1: dspi1@4002d000 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "fsl,vf610-dspi";
> +				reg = <0x4002d000 0x1000>;
> +				clocks = <&clks VF610_CLK_DSPI1>;
> +				clock-names = "dspi";
> +				spi-num-chipselects = <5>;
> +				status = "disabled";
> +			};
> +
>  			sai2: sai@40031000 {
>  				compatible = "fsl,vf610-sai";
>  				reg = <0x40031000 0x1000>;
> -- 
> 2.2.2
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-02-26  8:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 10:57 [PATCH 0/7] Add SPI support for Colibri modules and DSPI driver fixes Bhuvanchandra DV
2015-01-27 10:57 ` [PATCH 1/7] ARM: vf610: add second DSPI instance Bhuvanchandra DV
2015-01-28  9:08   ` Stefan Agner
2015-02-26  8:02   ` Shawn Guo
2015-01-27 10:57 ` [PATCH 2/7] ARM: vf-colibri: add SPI support and enable MCP2515 CAN Bhuvanchandra DV
2015-01-28  9:55   ` Stefan Agner
2015-01-27 10:57 ` [PATCH 3/7] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Bhuvanchandra DV
2015-01-27 18:50   ` Aaron Brice
2015-01-27 19:52   ` Mark Brown
2015-01-27 10:57 ` [PATCH 4/7] spi: spi-fsl-dspi: avoid preparing the clock two times Bhuvanchandra DV
2015-01-27 13:01   ` Mark Brown
2015-01-27 10:57 ` [PATCH 5/7] spi: spi-fsl-dspi: Remove spi-bitbang Bhuvanchandra DV
2015-01-28 19:25   ` 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).