Dual / Quad output using SPIDEV?

Started by Chris, February 01, 2015, 04:44:09 am

Previous topic - Next topic

Chris

February 01, 2015, 04:44:09 am Last Edit: February 01, 2015, 07:45:58 am by Chris
Heya!
I succeeded in outputting serial data using SPIDEV without any problems. But I still have no idea how to output data in dual / quad mode. I ran the spidev_test program with the -2 / -4 options, but the output was exactly the same and spidev_test said:
~>./spidev_test -2
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)

spi mode: 0x0 => no dual mode

DMESG says
spidev spi1.0: setup: ignoring unsupported mode bits 100
100 = dual mode

The kernel (3.18) pin definition inside imx23.dtsi is
spi2_pins_a: spi2@0 {
reg = <0>;
fsl,pinmux-ids = <
MX23_PAD_GPMI_WRN__SSP2_SCK
MX23_PAD_GPMI_RDY1__SSP2_CMD
MX23_PAD_GPMI_D00__SSP2_DATA0
MX23_PAD_GPMI_D03__SSP2_DATA3
>;
fsl,drive-strength = <MXS_DRIVE_8mA>;
fsl,voltage = <MXS_VOLTAGE_HIGH>;
fsl,pull-up = <MXS_PULL_ENABLE>;
};


Data is beautifully outputted on pin CMD, clock on SCK, DATA3 seems to be CS, DATA0 does nothing.

What's wrong with dual / quad mode? I compiled the 3.18 kernel with the dtsi above, is there something missing, maybe further pinmux-ids?

Any idea??

swahren

Quote from: Chris on February 01, 2015, 04:44:09 am
DMESG says
spidev spi1.0: setup: ignoring unsupported mode bits 100
100 = dual mode


Looking at the reference manual the i.MX23 should support Winbond mode (dual and quad). But this message looks like the spi-mxs driver doesn't support dual und quad mode yet.

In the Freescale Community somebody has the same problem, but there is no solution:

https://community.freescale.com/thread/310574

Quote from: Chris on February 01, 2015, 04:44:09 am
The kernel (3.18) pin definition inside imx23.dtsi is
spi2_pins_a: spi2@0 {
reg = <0>;
fsl,pinmux-ids = <
MX23_PAD_GPMI_WRN__SSP2_SCK
MX23_PAD_GPMI_RDY1__SSP2_CMD
MX23_PAD_GPMI_D00__SSP2_DATA0
MX23_PAD_GPMI_D03__SSP2_DATA3
>;
fsl,drive-strength = <MXS_DRIVE_8mA>;
fsl,voltage = <MXS_VOLTAGE_HIGH>;
fsl,pull-up = <MXS_PULL_ENABLE>;
};


Data is beautifully outputted on pin CMD, clock on SCK, DATA3 seems to be CS, DATA0 does nothing.

What's wrong with dual / quad mode? I compiled the 3.18 kernel with the dtsi above, is there something missing, maybe further pinmux-ids?

Any idea??


DATA0 should be MISO.

The definition spi2_pins_a is made for Motorola SPI mode. In your case you need to copy the pin definition for dual or quad mode, add the missing pins SSP_DATA1 and SSP_DATA2 and use the new muxing in your board file. But finally you will still need the support in spi-mxs.

Chris

OK, I patched the spi-mxs driver, it supports now dual and quad transfers, no error messages, DMESG is clean.
I also added several data lines to imx23.dtsi. But all that changed nothing: SPIDEV still outputs on one line, all further defined data lines are dead.

I browsed through the source code of spi, spi-mxs and spidev, but found even not 1 line of code that assigns any data line to the imx233 processor. Where in the kernel exactly does this happen? I also found in the imx233 architecture manual from Freescale no information about the line assignment, you can enable Winbond spi mode and enable dual / quad mode in the ssp processor registers, but can't tell the imx233 on which lines to output that data. How does the processor get this information?

swahren

Quote from: Chris on February 02, 2015, 08:37:53 pm
OK, I patched the spi-mxs driver, it supports now dual and quad transfers, no error messages, DMESG is clean.
I also added several data lines to imx23.dtsi. But all that changed nothing: SPIDEV still outputs on one line, all further defined data lines are dead.


Is it possible for to post your changes including the dts file of your platform?

Quote from: Chris on February 02, 2015, 08:37:53 pm
I browsed through the source code of spi, spi-mxs and spidev, but found even not 1 line of code that assigns any data line to the imx233 processor. Where in the kernel exactly does this happen? I also found in the imx233 architecture manual from Freescale no information about the line assignment, you can enable Winbond spi mode and enable dual / quad mode in the ssp processor registers, but can't tell the imx233 on which lines to output that data. How does the processor get this information?


The output lines for spi are hardwired in the processor. The pinmuxing in the dtsi file only describe which pins are involded and try to avoid collisions in case another driver wants to use the same pins.

In case of quad spi you could use mmc0_4bit_pins_a.

Btw if you want more freedom about your spi pins you could use the spi-gpio driver.

Chris

February 03, 2015, 12:48:53 am #4 Last Edit: February 03, 2015, 01:22:42 am by Chris
QuoteIs it possible for to post your changes including the dts file of your platform?

spi-mxs.c line 99: Replace the writel(...) with
writel(BM_SSP_CTRL0_LOCK_CS |
    ((dev->mode & SPI_TX_DUAL || dev->mode & SPI_RX_DUAL) ? 1 << BP_SSP_CTRL0_BUS_WIDTH : 0) |
    ((dev->mode & SPI_TX_QUAD || dev->mode & SPI_RX_QUAD) ? 2 << BP_SSP_CTRL0_BUS_WIDTH : 0),
    ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);


spi-mxs.c line 499: Replace the master->mode_bits = ... with
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_DUAL | SPI_RX_DUAL | SPI_TX_QUAD | SPI_RX_QUAD;

imx23-olinuxino.dts (excerpt)
ssp1: ssp@80034000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx23-spi";
pinctrl-names = "default";
pinctrl-0 = <&spi2_pins_a>;
clock-frequency = <1000000>;
status = "okay";

spidev: spidev@0 {
compatible = "spidev";
spi-max-frequency = <1000000>;
reg = <0>;
};
};


imx23.dtsi (excerpt)
spi2_pins_a: spi2@0 {
reg = <0>;
fsl,pinmux-ids = <
MX23_PAD_GPMI_WRN__SSP2_SCK
MX23_PAD_GPMI_RDY1__SSP2_CMD
MX23_PAD_GPMI_D00__SSP2_DATA0
MX23_PAD_GPMI_D01__SSP2_DATA1
MX23_PAD_GPMI_D02__SSP2_DATA2
MX23_PAD_GPMI_D03__SSP2_DATA3
MX23_PAD_GPMI_D04__SSP2_DATA4
MX23_PAD_GPMI_D05__SSP2_DATA5
>;
fsl,drive-strength = <MXS_DRIVE_8mA>;
fsl,voltage = <MXS_VOLTAGE_HIGH>;
fsl,pull-up = <MXS_PULL_ENABLE>;
};

I also tested w/o DATA4 / DATA5 etc...

QuoteIn case of quad spi you could use mmc0_4bit_pins_a.

That was no good idea, these pins belong to SSP0 - the sd card - which caused a lot of trouble. :o

QuoteBtw if you want more freedom about your spi pins you could use the spi-gpio driver.

Does it provide hardware SPI or just bitbang?

swahren

Quote from: Chris on February 03, 2015, 12:48:53 am
QuoteIn case of quad spi you could use mmc0_4bit_pins_a.

That was no good idea, these pins belong to SSP0 - the sd card - which caused a lot of trouble. :o


Sorry, i didn't really think about that. I looked again in the reference manual and found on page 1023 that the MX23 only support dual / quad SPI read but no write.

Quote from: Chris on February 03, 2015, 12:48:53 am
QuoteBtw if you want more freedom about your spi pins you could use the spi-gpio driver.

Does it provide hardware SPI or just bitbang?


Just bitbang