SPI not working

gabonator
Hello,

I compiled the linux 2.6.35.7 with these settings enabled in
mini210_linux_defconfig:

CONFIG_S3C64XX_DEV_SPI=y
CONFIG_SPI=y

during the compilation it was asking me several times whether I do or don't
want to enable some SPI peripheral drivers. I tried to answer yes for the
core SPI drivers and no for the special SPI peripheral drivers. I flashed
new zImage to the tiny210 board through SD card.

Inside the /dev folder two new files appeared: spidev0.0 and spidev1.0
When I call this command: "echo test > spidev0.0" or "echo test >
spidev1.0" it replies with some error:

[root@FriendlyARM /dev]# echo test > spidev9.0
[ 2701.292651] spidev spi0.0: I/O Error: rx-0 tx-1 res:rx-p tx-f len-5
[root@FriendlyARM /dev]# echo test > spidev1.0
[ 2710.053429] spidev spi1.0: I/O Error: rx-0 tx-1 res:rx-p tx-f len-5

I also placed 220ohm between SCON pin 13 & 14 to form a loopback. My board
is SDK1. When reading from the SPI ports I get following error:

[root@FriendlyARM /dev]# cat spidev0.0
[ 2803.005565] spidev spi0.0: I/O Error: rx-1 tx-0 res:rx-f tx-p len-4096
[ 2803.005643] s3c64xx-spi s3c64xx-spi.0: DmaAbrtRx-4096
cat: read error: Input/output error
[root@FriendlyARM /dev]# cat spidev1.0
[ 2806.646181] spidev spi1.0: I/O Error: rx-1 tx-0 res:rx-f tx-p len-4096
[ 2806.646258] s3c64xx-spi s3c64xx-spi.1: DmaAbrtRx-4096
cat: read error: Input/output error

Any idea what am I doing wrong?

davef
Can you run ( a cross-compiled version) of the utility called spi-test "the
SPI testing utility (using spidev driver)"?

I only have some experience running SPI on the mini2440, so it may not
apply to the mini210.  If you want to have two spidevs then you have to do
some hacking around in the mach-s3c2440.c file.

During compilation how do you get the opportunity to answer yes or no to
anything?  

Just guessing but I wonder if you only had one spidev would you still have
this problem.

gabonator
Thank you very much!!! I found the source codes of spi-test utiliy (not the
armel binary, but I compiled it without any problem) and this utility sends
some buffer to the SPI and then shows the reply. With the loopback resistor
it showed exactly the same buffer as defined in source code and without it
showed only 0xFFs. Therefore I think that it is working well.

In the mach-xxx.c file are all the necessary structures declared, I only
needed to enable it by setting the precompiler macro
"CONFIG_S3C64XX_DEV_SPI"

Executing the build script with CONFIG_SPI enabled (in
mini210_linux_defconfig) looks like this:

=============
[builder@builder linux-2.6.35.7]$ ./build
scripts/kconfig/conf -s arch/arm/Kconfig
.config:1260:warning: override: reassigning to symbol SPI
*
* Restart config...
*
*
* Self-contained MTD device drivers
*
Support for AT45xxx DataFlash (MTD_DATAFLASH) [N/m/y/?] (NEW) m
  Verify DataFlash page writes (MTD_DATAFLASH_WRITE_VERIFY) [N/y/?] (NEW) N
  DataFlash OTP support (Security Register) (MTD_DATAFLASH_OTP) [N/y/?]
(NEW) N
Support most SPI Flash chips (AT26DF, M25P, W25X, ...) (MTD_M25P80)
[N/m/y/?] (NEW) N
Support SST25L (non JEDEC) SPI Flash chips (MTD_SST25L) [N/m/y/?] (NEW) N
Uncached system RAM (MTD_SLRAM) [N/m/y/?] n
Physical system RAM (MTD_PHRAM) [N/m/y/?] n
Test driver using RAM (MTD_MTDRAM) [N/m/y/?] n
MTD using block device (MTD_BLOCK2MTD) [N/m/y/?] n
==============

davef
> In the mach-xxx.c file are all the necessary structures declared, I only
> needed to enable it by setting the precompiler macro
> "CONFIG_S3C64XX_DEV_SPI"

For the mini2440 even spidev is not in any kernel.  The kernel needs
patching for SPI. Looks like things work differently for the mini210, or
you wouldn't get spi-test to work.

I have never been asked for options during compilation, so I can't help
with that issue.

Good luck!

davef
> For the mini2440 even spidev is not in any kernel. 

Correction: any mainline kernel