Hi all,
I am recently working on spi driver for ECSPI1 in Uboot. I have brought up the command interface by adding a macro "CONFIG_CMD_SPI" in my config file "imx6qdl-sabreauto.dtsi". I looped back MISO and MOSI for ECSPI1. When I issued the command like "sspi 0:0.0 8 8" , I am always receiving "00". I added following in my board config file:
#ifdef CONFIG_MXC_SPI
iomux_v3_cfg_t const ecspi1_pads[] = {
MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_EIM_EB2__GPIO2_IO30 | MUX_PAD_CTRL(NO_PAD_CTRL),
};
void setup_spi(void)
{
imx_iomux_v3_setup_multiple_pads(ecspi1_pads,
ARRAY_SIZE(ecspi1_pads));
gpio_direction_output(IMX_GPIO_NR(2, 30), 0);
}
#endif
and I called "setup_spi" in "board_early_init_f". What did I missed? Any help?
Thanks
yong
Hi yong
one can check signals with oscilloscope and seems this may be easily debugged using
some ecspi1 baremetal example like sdk:
Github SDK
https://github.com/backenklee/swp-report/tree/master/iMX6_Platform_SDK
What uboot version used in the case, please note that latest official uboot release is
imx_v2016.03, please try to test on it
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/?h=imx_v2016.03_4.1.15_2.0.0_ga
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
Thanks for your help! It was pin conflicts problem. I have checked MISO, MOSI, and SCLK. All these three signals are working fine but I am not observing the chip select signal toggling on my scope. I am using GPIO for my CS signal. I tired 2 GPIO for this signal. Neither of both shows any toggling.
In function int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags)
before transfer begins, spi_cs_activate(slave) is called. I assumed this function toggles the chip select signal.
void spi_cs_activate(struct spi_slave *slave)
{
struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
if (mxcs->gpio > 0)
gpio_set_value(mxcs->gpio, mxcs->ss_pol);
}
mxcs->gpio is initialized to -1 for gpio.
thanks
yong