[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] spi and spidev usage



Hi Carsten,

No luck yet on detecting the SPI interfaces.  I've tried every /dev/spi-# entry using spi-test and all of them report:

can't open device: No such device or address
Abort

Do you have any suggestions?  I have two SPI devices, one set to the 3 header pins and another to a DAC.  I'm using the Spartan 3E Starter Kit.

Thanks for the help.

Matt

 

On Mon, Mar 2, 2009 at 23:54, Matt Staniszewski <matt.staniszewski@xxxxxxxxx> wrote:
Hi Carsten,

Thanks for the patch!  After manually patching a few of the files (I'm guessing the SVN version that I use is slightly different) I was able to get /dev/spi-0 through 7 on my board!

I wasn't able to try the SPI tests outlined in the documentation, but I did have a question.  Can I use the XSPI_IOCTL functions instead of the SPI ones?  Just wondering.

I'll try and test out the SPI functions tomorrow.

Matt



On Mon, Mar 2, 2009 at 03:13, Bartsch Carsten <cbartsch@xxxxxxxxxx> wrote:
Because I was asked for in another thread I post here my changes to get
spidev working. I hope I got all things together. It's not all as
intended by the programmers (e.g. not using udev), corrections are
welcome.

Add the following files from xilinx kernel git repository:
petalinux-mmu-v0.10/software/linux-2.6.x-petalogix/drivers/spi/xilinx_sp
i.c
petalinux-mmu-v0.10/software/linux-2.6.x-petalogix/drivers/spi/spidev.c
petalinux-mmu-v0.10/software/linux-2.6.x-petalogix/include/linux/spi/spi
dev.h

Apply the modifications in the attached patch.

Then you should have access to /dev/spi-0 to -7. The test application in
the linuxtree/Documentation/spi/spidev_test.c should work.
For instance on by board I can read the SPI-flash-ID with:
static void read_flash_id(int fd)
{
       int ret;
       uint8_t tx[] = {
               0x9f,    // code to read id from flash
               0, 0, 0  // space for answer with manufacturer, type and
size (8 bit each)
       };
       uint8_t rx[ARRAY_SIZE(tx)] = {0, };
       struct spi_ioc_transfer tr = {
               .tx_buf = (unsigned long)tx,
               .rx_buf = (unsigned long)rx,
               .len = ARRAY_SIZE(tx),
               .delay_usecs = delay,
               .speed_hz = speed,
               .bits_per_word = bits,
       };

       ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
       if (ret == 1)
               pabort("can't send spi message");

       printf("SPI-Flash Manuf %.2X  Type %.2X  Size %.2X ", rx[1],
rx[2], rx[3]);
       puts("");
}