From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Using spi_alloc_slave() from SPL
Date: Thu, 06 Aug 2015 15:38:48 +0200 [thread overview]
Message-ID: <55C36368.1070701@denx.de> (raw)
In-Reply-To: <CAOMZO5ChvMsYsFK4wq_RNE5wFFv+HS7VQ6vZhdajvCVdgrDXKg@mail.gmail.com>
Hi Fabio,
On 06/08/2015 15:25, Fabio Estevam wrote:
> 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
>
> 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
Right - if I remember well, spi_alloc requires a full functional malloc,
and then fails.
>
> 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?
There is the possibility to set a malloc area inside SPL:
CONFIG_SYS_SPL_MALLOC_START
CONFIG_SYS_SPL_MALLOC_SIZE
you do not need a lot of space, and you can try to put it inside the IRAM.
This should guarantee that spi_alloc_slave() works.
Best regards,
Stefano
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
next prev parent reply other threads:[~2015-08-06 13:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55C36368.1070701@denx.de \
--to=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.