SPI bus not probed

Michal Suchánek msuchanek at suse.de
Mon Sep 28 10:23:04 CEST 2020


On Sun, Sep 27, 2020 at 10:35:30PM +0200, Michal Suchánek wrote:
> Hello,
> 
> When I enable SPI support I do not get a SPI bus.
> 
> Config:
> --- a/configs/orangepi_zero_defconfig
> +++ b/configs/orangepi_zero_defconfig
> @@ -11,3 +11,21 @@ CONFIG_CONSOLE_MUX=y
>  CONFIG_SUN8I_EMAC=y
>  CONFIG_USB_EHCI_HCD=y
>  CONFIG_USB_OHCI_HCD=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SPI_FLASH=y
> +CONFIG_CMD_SPI=y
> +CONFIG_CMD_SF_TEST=y
> +CONFIG_SPI_FLASH_SFDP_SUPPORT=y
> +CONFIG_SPI_FLASH_ATMEL=y
> +CONFIG_SPI_FLASH_EON=y
> +CONFIG_SPI_FLASH_GIGADEVICE=y
> +CONFIG_SPI_FLASH_ISSI=y
> +CONFIG_SPI_FLASH_MACRONIX=y
> +CONFIG_SPI_FLASH_SPANSION=y
> +CONFIG_SPI_FLASH_STMICRO=y
> +CONFIG_SPI_FLASH_SST=y
> +CONFIG_SPI_FLASH_WINBOND=y
> +CONFIG_SPI_FLASH_XMC=y
> +CONFIG_SPI_FLASH_DATAFLASH=y
> 
> DT (which lists the flash types so did not really have to enable them all)
> --- a/arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts
> +++ b/arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts
> @@ -163,10 +163,11 @@
>  };
>  
>  &spi0 {
> -       /* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
> -       status = "disabled";
> +       /* Enable SPI NOR by default: it optional on Orange Pi Zero boards */
> +       status = "okay";
>  
>         flash at 0 {
> +            status = "okay";
>                 #address-cells = <1>;
>                 #size-cells = <1>;
>                 compatible = "mxicy,mx25l1606e", "winbond,w25q128";
> 
> The guide on debugging says to add dm_dump_all
> --- a/drivers/spi/spi-uclass.c
> +++ b/drivers/spi/spi-uclass.c
> @@ -328,6 +328,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
>         bool created = false;
>         int ret;
>  
> +        dm_dump_all();
>  #if CONFIG_IS_ENABLED(OF_PLATDATA)
>         ret = uclass_first_device_err(UCLASS_SPI, &bus);
>  #else
> 
> which prints
> 
>  Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>  root          0  [ + ]   root_driver           root_driver
>  simple_bus    0  [ + ]   simple_bus            |-- soc
>  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc at 1c0f000
>  blk           0  [   ]   mmc_blk               |   |   `-- mmc at 1c0f000.blk
>  mmc           1  [ + ]   sunxi_mmc             |   |-- mmc at 1c10000
>  blk           1  [   ]   mmc_blk               |   |   `-- mmc at 1c10000.blk
>  phy           0  [   ]   sun4i_usb_phy         |   |-- phy at 1c19400
>  usb           0  [   ]   ehci_generic          |   |-- usb at 1c1a000
>  usb           1  [   ]   ohci_generic          |   |-- usb at 1c1a400
>  usb           2  [   ]   ehci_generic          |   |-- usb at 1c1b000
>  usb           3  [   ]   ohci_generic          |   |-- usb at 1c1b400
>  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock at 1c20000
>  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>  gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl at 1c20800
>  gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
>  gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
>  gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
>  gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
>  gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
>  gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
>  gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
>  gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
>  gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
>  eth           0  [ + ]   eth_sun8i_emac        |   |-- ethernet at 1c30000
>  spi           0  [   ]   sun4i_spi             |   |-- spi at 1c68000
>  serial        0  [ + ]   ns16550_serial        |   |-- serial at 1c28000
>  gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl at 1f02c00
>  gpio         11  [ + ]   gpio_sunxi            |       `-- PL
>  clk           1  [ + ]   fixed_rate_clock      |-- osc24M_clk
>  clk           2  [   ]   fixed_rate_clock      `-- osc32k_clk
> Invalid bus 0 (err=-19)
> 
> -19 means ENODEV according to my /usr/include/asm-generic/errno-base.h
> 
> Debug prints added to sunxi driver are never printed:
> 
> --- a/drivers/spi/spi-sunxi.c
> +++ b/drivers/spi/spi-sunxi.c
> @@ -305,6 +305,7 @@ static int sun4i_spi_claim_bus(struct udevice *dev)
>  {
>         struct sun4i_spi_priv *priv = dev_get_priv(dev->parent);
>         int ret;
> +       printf("sun4i_spi_claim_bus\n");
>  
>         ret = sun4i_spi_set_clock(dev->parent, true);
>         if (ret)
> @@ -487,6 +488,8 @@ static int sun4i_spi_probe(struct udevice *bus)
>         struct sun4i_spi_priv *priv = dev_get_priv(bus);
>         int ret;
>  
> +       printf("sun4i_spi_probe\n");
> +
>         ret = clk_get_by_name(bus, "ahb", &priv->clk_ahb);
>         if (ret) {
>                 dev_err(dev, "failed to get ahb clock\n");
> 
> AFAICT the device tree compatible matches the one in the driver.
> 
> How do I make u-boot run the driver?
Further discussion on IRC shows that for now it is necessary to add

--- a/arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts
+++ b/arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts
@@ -59,6 +59,8 @@
                /* ethernet0 is the H3 emac, defined in sun8i-h3.dtsi */
                ethernet0 = &emac;
                ethernet1 = &xr819;
+               spi0 = &spi0;
+               spi1 = &spi1;
        };
 
        chosen {



More information about the U-Boot mailing list