Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: M-Reimer on September 02, 2013, 07:24:57 pm

Title: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: 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.
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: Fadil Berisha on September 02, 2013, 07:38:10 pm
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?
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: M-Reimer on September 03, 2013, 04:59:52 pm
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.
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: 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>;
};


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.
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: jeroends on September 04, 2013, 08:55:17 am
hello,
a simple search on the forum:
https://www.olimex.com/forum/index.php?topic=873.0 (https://www.olimex.com/forum/index.php?topic=873.0)
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: M-Reimer on September 04, 2013, 09:48:17 am
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.
Title: Re: Why can't I access the SPI pins via GPIO? How to use SPI?
Post by: Evgeny Boger on September 06, 2013, 04:08:12 am
"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 )