Why can't I access the SPI pins via GPIO? How to use SPI?

Started by M-Reimer, September 02, 2013, 07:24:57 pm

Previous topic - Next topic

M-Reimer

Hello,

for some reason it is impossible to "export" the SPI pins to be used as GPIO pins. Why?

Does someone have information on how to work with the SPI interface? Did someone ever do this with the kernel API for the SPI port? I still can't get a CS signal where it should be.

Fadil Berisha

Quote from: M-Reimer on September 02, 2013, 07:24:57 pm
Hello,

for some reason it is impossible to "export" the SPI pins to be used as GPIO pins. Why?

Does someone have information on how to work with the SPI interface? Did someone ever do this with the kernel API for the SPI port? I still can't get a CS signal where it should be.

using kernel 3.x and imx23 hardware resources for SPI, examples are here  https://www.olimex.com/forum/index.php?topic=232.0
Is that what you are looking for? Maybe you are looking for GPIO bit banding?

M-Reimer

What I'm searching for is a /dev/spidev interface, just as it is available on other platforms like the Raspberry Pi. I tried to enable it, but with my /dev/spidev I don't get anything on the CS pin.

Evgeny Boger

You should add something like

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


to ssp1 entry of your imx23-olinuxino.dts file.
If you want to use CS#1 or CS#2 you should enable them as SPI chipselects at spi2_pins_a entry in imx23.dtsi.

AFAIK, some olinuxino boards have weird "CS_UEXT_GPIO" pin which is either hardware SPI chipselect or GPIO, depending on jumper setting. Make sure you are using the pin labeled "P12/LCD_D11" for CS#0.


M-Reimer

Quote from: Evgeny Boger on September 03, 2013, 06:30:48 pm
You should add something like

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



I tried this with "reg = <1>". Is it really possible that this makes the difference? What is this "reg" field meant for?

Quote
If you want to use CS#1 or CS#2 you should enable them as SPI chipselects at spi2_pins_a entry in imx23.dtsi.


I just want to use *any* pin for CS. So far no pin seems to do anything, I can use for CS, while sending to SPI.

Evgeny Boger

September 06, 2013, 04:08:12 am #6 Last Edit: September 06, 2013, 04:10:20 am by Evgeny Boger
"reg = <0>" is for chipselect 0.
As I said, other chipselects are disabled (configured as GPIO) by default.

By the way, it's worth to take a look at DT documentation ( https://www.kernel.org/doc/Documentation/devicetree/bindings/spi/spi-bus.txt )