Hi all,
I have a OrangePi R1 and want to enable SPI in U-Boot to talk to connected leds. The leds are connected to SPI0 on the pins: 19 (MOSI), 4 (5v) and 6 (GND) . I enabled the CONFIG_SUN4I_SPI flag to enable the sunxi SPI driver. I also added the following lines to `arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts` to enable both SPI0 and SPI1.
&spi0 {
status = "okay";
flash@0 {
compatible = "mxicy,mx25l12805d", "jedec,spi-nor";
};
};
&spi1 {
status = "okay";
};
To control the leds I added a call to the following function inside the `board_init()` function inside: `/board/sunxi/board.c`.
static int set_leds()
{
int bus = 0;
int cs = 1;
int mode = 0;
struct spi_slave *slave;
int ret = 0;
printf("set_leds");
char name[30], *str;
struct udevice *dev;
snprintf(name, sizeof(name), "generic_%d:%d", bus, cs);
str = strdup(name);
if (!str) return -ENOMEM;
ret = spi_get_bus_and_cs(bus, cs, 38095, mode, "spi_generic_drv",str, &dev, &slave);
if (ret) return ret;
ret = spi_claim_bus(slave);
if (ret) goto done;
uchar dout[2];
uchar din[2];
int bitlen = 16;
ret = spi_xfer(slave, bitlen, dout, din, SPI_XFER_BEGIN | SPI_XFER_END);
done:
spi_release_bus(slave);
spi_free_slave(slave);
}
(please note that I am not transferring the actual data needed by the leds in this sample code)
When I flash the bootloader the leds wont respond (but I see the message printed in the console). I don''t have an oscilloscope so I am not able to see if the `spi_xfer` function actual sends the data. So my question is does this code look okey? Or is there something I am missing?