Hi.
i am using SABRE Platform for smart Devices with I.MX6Q
i've already set spidev4.0 for ECSPI5 like a following code .
but i could not see the signal for SS0,CLK ..etc . Here is my code , what am i doing wrong ?
1. i added in board-mx6q_sabresd.c
MX6Q_PAD_SD2_CLK__ECSPI5_SCLK,
MX6Q_PAD_SD2_CMD__ECSPI5_MOSI,
MX6Q_PAD_SD2_DAT0__ECSPI5_MISO,
MX6Q_PAD_SD2_DAT1__ECSPI5_SS0,
2. i modified iomux-mx6q.h
MUX_PAD_CTRL( NO_PAD_CTRL) -> MUX_PAD_CTRL(MX6Q_ECSPI_PAD_CTRL) for all PAD above
3, finally , i changed board-mx6q_sabread.c as a following code
#define SABRESD_ECSPI5_CS0 IMX_GPIO_NR(1, 14)
static int mx6q_sabresd_spi5_cs0[] = {
SABRESD_ECSPI5_CS0,
};
static const struct spi_imx_master mx6q_sabresd_spi5_data0 __initconst = {
.chipselect = mx6q_sabresd_spi5_cs0,
.num_chipselect = ARRAY_SIZE(mx6q_sabresd_spi5_cs0),
};
static struct spi_board_info imx6_sabresd_spi_nor_device[] __initdata = {
#if 1
{
.modalias = "spidev",
.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 4,
.chip_select = 0,
.mode = SPI_MODE_0,
.platform_data = NULL,
},
#endif
};"
imx6q_add_ecspi(4, &mx6q_sabresd_spi5_data0);
spi_device_init();
4. after i rebuild kernel , i can see /dev/spidev4.0 and it was operated succesfully With IOCTL as a spidev_test.c
i added following code in jni for android
static void transfer(int fd)
{
int ret;
uint8_t tx[] = {
0xa5, 0xa5,
};
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 = 0,
.speed_hz = 6000000,
.bits_per_word = 8,
};
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
if (ret < 1)
pabort("can't send spi message");
for (ret = 0; ret < ARRAY_SIZE(tx); ret++) {
if (!(ret % 6))
puts("");
printf("%.2X ", rx[ret]);
}
puts("");
}
mode = SPI_MODE_0;
bits = 8;
speed = 6000000;
fd = open("dev/spidev4.0", O_RDWR);
ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
transfer(fd);
and i can see return value "2" of ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr) sucessfully
but i could not see the signal for SSO , CLK, etc with Scope
SS0 -> SD2_DAT1 ( PIN NO #08)
CLK -> SD2_CLK (PIN NO #05)
.etc
please help me.
thank you in advance
Hi,
Let me see if I understand correctly. You were able to make it work using spidev_test.c with the above modifications but it does not work using jni correct?
I wonder if you are able to dump the value of the registers including the IOMUX values. That will help to identify the problem.
Best Regards,
Alejandro