public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Using spi_alloc_slave() from SPL
@ 2015-08-06 13:25 Fabio Estevam
  2015-08-06 13:33 ` Marek Vasut
  2015-08-06 13:38 ` Stefano Babic
  0 siblings, 2 replies; 16+ messages in thread
From: Fabio Estevam @ 2015-08-06 13:25 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-11-10 14:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 13:25 [U-Boot] Using spi_alloc_slave() from SPL Fabio Estevam
2015-08-06 13:33 ` Marek Vasut
2015-08-06 13:38 ` Stefano Babic
2015-08-06 14:14   ` Fabio Estevam
2015-08-06 14:28     ` Marek Vasut
2015-08-06 16:44       ` Fabio Estevam
2015-08-06 17:03       ` Stefano Babic
2015-08-06 18:24         ` Fabio Estevam
2015-08-06 19:29           ` Fabio Estevam
2015-08-06 19:31           ` Simon Glass
2015-08-06 22:13             ` Fabio Estevam
2015-08-13 12:37               ` Nikolay Dimitrov
2015-11-10  0:05                 ` Fabio Estevam
2015-11-10 14:41                   ` Fabio Estevam
2015-11-09 23:28               ` Fabio Estevam
2015-08-06 22:22         ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox