Hi, I am trying to use spi_flash_probe() inside SPL on a custom mx6 board.
The idea is to read some parameters from the SPI NOR flash and configure the DDR accordingly. This is similar to what gw_ventana_spl.c does, but it reads from i2c eeprom instead of SPI NOR. Here are the changes just to illustrate the problem: --- a/board/freescale/mx6sabresd/mx6sabresd.c +++ b/board/freescale/mx6sabresd/mx6sabresd.c @@ -692,6 +692,19 @@ int checkboard(void) #ifdef CONFIG_SPL_BUILD #include <spl.h> #include <libfdt.h> +#include <spi_flash.h> +#include <spi.h> + +static int read_spi_flash(void) +{ + struct spi_flash *spi; + char buf[2]; + + spi = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); + return spi_flash_read(spi, 0, 2, buf); +} const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = { .dram_sdclk_0 = 0x00020030, @@ -837,6 +850,8 @@ void board_init_f(ulong dummy) /* UART clocks enabled and gd valid - init serial console */ preloader_console_init(); + read_spi_flash(); + /* DDR initialization */ spl_dram_init(); diff --git a/include/configs/mx6sabresd.h b/include/configs/mx6sabresd.h index 41162ca..f5dfaf7 100644 --- a/include/configs/mx6sabresd.h +++ b/include/configs/mx6sabresd.h @@ -12,6 +12,10 @@ #ifdef CONFIG_SPL #define CONFIG_SPL_LIBCOMMON_SUPPORT #define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SPL_SPI_SUPPORT +#define CONFIG_SPL_SPI_FLASH_SUPPORT +#define CONFIG_SYS_SPI_U_BOOT_OFFS (64 * 1024) +#define CONFIG_SPL_SPI_LOAD #include "imx6_spl.h" #endif @@ -35,6 +39,12 @@ #define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC3 */ #endif +#define CONFIG_ENV_SECT_SIZE (64 * 1024) +#define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS +#define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS +#define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE +#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED + #define CONFIG_CMD_PCI #ifdef CONFIG_CMD_PCI #define CONFIG_PCI -- 1.9.1 The when I run it: U-Boot SPL 2015.07-08202-g6dcdca1-dirty (Aug 06 2015 - 10:18:33) mxc_spi: SPI Slave not allocated ! spi_flash_probe() ---> spi_setup_slave() ----> spi_alloc_slave() which fails on mxc_spi.c As read_spi_flash() is called prior to the DDR initialization, spi_alloc_slave() fails. Is there a way to avoid calling spi_alloc_slave() in the SPL case? Any ideas on how to fix this? Thanks, Fabio Estevam _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot