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("");
}