Skip to contentSkip to conversation

ARM: cfa10036: Switch SPI to gpio bitbanging

PATCH Superseded Maxime Ripard 3 participants 7 messages Dec 27, 2012 – Feb 5, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ARM: cfa10036: Switch SPI to gpio bitbanging

Hi Shawn,

Here is a patchset that moves the spi bus we use to bitbanging. This is needed because the DAC found on this bus is actually using a 12 bits wordlength, while the imx28 spi controler can only handle 4, 8 or 16 bits per words.

Thanks,
Maxime

Maxime Ripard (2):
spi: spi-gpio: Add checks for the dt properties
ARM: dts: cfa10049: Change the SPI3 bus to spi-gpio

 arch/arm/boot/dts/imx28-cfa10049.dts |   78 ++++++++++++++++++----------------
 drivers/spi/spi-gpio.c               |   23 ++++++++--
 2 files changed, 62 insertions(+), 39 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 spi: spi-gpio: Add checks for the dt properties

The bindings assumed that the gpios properties were always there, which made the NO_TX and NO_RX mode not usable from device tree. Add extra checks to make sure that the driver can work if either MOSI or MISO is not used.

---
 drivers/spi/spi-gpio.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/spi/spi-gpio.c +20 -3
index c7cf0b7..9ddef55 100644
@@ -365,9 +365,26 @@ static int spi_gpio_probe_dt(struct platform_device *pdev)
 	if (!pdata)
 		return -ENOMEM;
 
-	pdata->sck = of_get_named_gpio(np, "gpio-sck", 0);
-	pdata->miso = of_get_named_gpio(np, "gpio-miso", 0);
-	pdata->mosi = of_get_named_gpio(np, "gpio-mosi", 0);
+	ret = of_get_named_gpio(np, "gpio-sck", 0);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "gpio-sck property not found\n");
+		goto error_free;
+	}
+	pdata->sck = ret;
+
+	ret = of_get_named_gpio(np, "gpio-miso", 0);
+	if (ret < 0) {
+		dev_info(&pdev->dev, "gpio-miso property not found, switching to no-rx mode\n");
+		pdata->miso = SPI_GPIO_NO_MISO;
+	} else
+		pdata->miso = ret;
+
+	ret = of_get_named_gpio(np, "gpio-mosi", 0);
+	if (ret < 0) {
+		dev_info(&pdev->dev, "gpio-mosi property not found, switching to no-tx mode\n");
+		pdata->mosi = SPI_GPIO_NO_MOSI;
+	} else
+		pdata->mosi = ret;
 
 	ret = of_property_read_u32(np, "num-chipselects", &tmp);
 	if (ret < 0) {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/2 spi: spi-gpio: Add checks for the dt properties

Hi Grant,

Quoted 4 lines · Maxime Ripard

The bindings assumed that the gpios properties were always there, which made the NO_TX and NO_RX mode not usable from device tree. Add extra checks to make sure that the driver can work if either MOSI or MISO is not used.

Can you give me your Acked-by on this, or do you have any comments on this?

Thanks,
Maxime

Signature · 4 lines
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/2 spi: spi-gpio: Add checks for the dt properties

Quoted 7 lines · Maxime Ripard
Quoted 4 lines · Maxime Ripard

The bindings assumed that the gpios properties were always there, which made the NO_TX and NO_RX mode not usable from device tree. Add extra checks to make sure that the driver can work if either MOSI or MISO is not used.

Can you give me your Acked-by on this, or do you have any comments on this?

Ping?

Signature · 4 lines
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/2 spi: spi-gpio: Add checks for the dt properties

Quoted 10 lines · Maxime Ripard
Quoted 7 lines · Maxime Ripard
Quoted 4 lines · Maxime Ripard

The bindings assumed that the gpios properties were always there, which made the NO_TX and NO_RX mode not usable from device tree. Add extra checks to make sure that the driver can work if either MOSI or MISO is not used.

Can you give me your Acked-by on this, or do you have any comments on this?

Ping?

Mark has applied it and it is now in my tree.

g.

#5 lore raw

PATCH 2/2 ARM: dts: cfa10049: Change the SPI3 bus to spi-gpio

In reply to Maxime Ripard

The DAC found on the last chip select requires a word length of 12 bits, which is not supported by the SSP controller of the iMX28. Use bitbanging for that bus to support such a length.

---
 arch/arm/boot/dts/imx28-cfa10049.dts |   78 ++++++++++++++++++----------------
 1 file changed, 42 insertions(+), 36 deletions(-)
arch/arm/boot/dts/imx28-cfa10049.dts +42 -36
index 7890acc..dd91244 100644
@@ -52,48 +52,17 @@
 				spi3_pins_cfa10049: spi3-cfa10049 at 0 {
 					reg = <0>;
 					fsl,pinmux-ids = <
-						0x0181 /* MX28_PAD_GPMI_RDN__SSP3_SCK */
-						0x01c1 /* MX28_PAD_GPMI_RESETN__SSP3_CMD */
-						0x0111 /* MX28_PAD_GPMI_CE1N__SSP3_D3 */
-						0x01a2 /* MX28_PAD_GPMI_ALE__SSP3_D4 */
-						0x01b2 /* MX28_PAD_GPMI_CLE__SSP3_D5 */
+						0x0183 /* MX28_PAD_GPMI_RDN__GPIO_0_24 */
+						0x01c3 /* MX28_PAD_GPMI_RESETN__GPIO_0_28 */
+						0x0113 /* MX28_PAD_GPMI_CE1N__GPIO_0_17 */
+						0x01a3 /* MX28_PAD_GPMI_ALE__GPIO_0_26 */
+						0x01b3 /* MX28_PAD_GPMI_CLE__GPIO_0_27 */
 					>;
 					fsl,drive-strength = <1>;
 					fsl,voltage = <1>;
 					fsl,pull-up = <1>;
 				};
 			};
-
-			ssp3: ssp at 80016000 {
-				compatible = "fsl,imx28-spi";
-				pinctrl-names = "default";
-				pinctrl-0 = <&spi3_pins_cfa10049>;
-				status = "okay";
-
-				gpio5: gpio5 at 0 {
-					compatible = "fairchild,74hc595";
-					gpio-controller;
-					#gpio-cells = <2>;
-					reg = <0>;
-					registers-number = <2>;
-					spi-max-frequency = <100000>;
-				};
-
-				gpio6: gpio6 at 1 {
-					compatible = "fairchild,74hc595";
-					gpio-controller;
-					#gpio-cells = <2>;
-					reg = <1>;
-					registers-number = <4>;
-					spi-max-frequency = <100000>;
-				};
-
-				dac0: dh2228 at 2 {
-					compatible = "rohm,dh2228fv";
-					reg = <2>;
-					spi-max-frequency = <100000>;
-				};
-			};
 		};
 
 		apbx at 80040000 {
@@ -177,4 +146,41 @@
 			status = "okay";
 		};
 	};
+
+	spi3 {
+		compatible = "spi-gpio";
+		pinctrl-names = "default";
+		pinctrl-0 = <&spi3_pins_cfa10049>;
+		status = "okay";
+		gpio-sck = <&gpio0 24 0>;
+		gpio-mosi = <&gpio0 28 0>;
+		cs-gpios = <&gpio0 17 0 &gpio0 26 0 &gpio0 27 0>;
+		num-chipselects = <3>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		gpio5: gpio5 at 0 {
+			compatible = "fairchild,74hc595";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0>;
+			registers-number = <2>;
+			spi-max-frequency = <100000>;
+		};
+
+		gpio6: gpio6 at 1 {
+			compatible = "fairchild,74hc595";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <1>;
+			registers-number = <4>;
+			spi-max-frequency = <100000>;
+		};
+
+		dac0: dh2228 at 2 {
+			compatible = "rohm,dh2228fv";
+			reg = <2>;
+			spi-max-frequency = <100000>;
+		};
+	};
 };
Signature · 1 line
1.7.9.5
#6 lore raw

cover ARM: cfa10036: Switch SPI to gpio bitbanging

In reply to Maxime Ripard
Quoted 6 lines · Maxime Ripard

Hi Shawn,

Here is a patchset that moves the spi bus we use to bitbanging. This is needed because the DAC found on this bus is actually using a 12 bits wordlength, while the imx28 spi controler can only handle 4, 8 or 16 bits per words.

Will try to apply the second patch after the first one gets applied on spi tree.

Shawn

Quoted 11 lines

Maxime Ripard (2):
spi: spi-gpio: Add checks for the dt properties
ARM: dts: cfa10049: Change the SPI3 bus to spi-gpio

 arch/arm/boot/dts/imx28-cfa10049.dts |   78 ++++++++++++++++++----------------
 drivers/spi/spi-gpio.c               |   23 ++++++++--
 2 files changed, 62 insertions(+), 39 deletions(-)
Signature · 1 line
1.7.9.5