DM: SPI: Convert display5 to use SPI with DM/DTS (but no in SPL)
authorLukasz Majewski <lukma@denx.de>
Tue, 3 Sep 2019 14:38:43 +0000 (16:38 +0200)
committerStefano Babic <sbabic@denx.de>
Tue, 8 Oct 2019 14:35:59 +0000 (16:35 +0200)
The DM/DTS support for SPI is disabled on purpose for SPL, as it is not
supported as of time of this conversion.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
arch/arm/mach-imx/mx6/Kconfig
board/liebherr/display5/common.c
board/liebherr/display5/common.h
board/liebherr/display5/display5.c
configs/display5_defconfig
include/configs/display5.h

index 032fd56562b9b9168bea93dad08d72f73705c7bd..7e5a667e81e48c00d59a3c637f84b01b4a966d89 100644 (file)
@@ -200,6 +200,7 @@ config TARGET_DISPLAY5
        select DM_ETH
        select DM_I2C
        select DM_MMC
+       select DM_SPI
        select DM_GPIO
        select DM_SERIAL
        select SUPPORT_SPL
index 754c442427f82e6c16882be91425e181865cb2ec..d2d174beaa0d5ff357af8e8a7b4f8807a66797ff 100644 (file)
@@ -45,18 +45,6 @@ void displ5_set_iomux_misc_spl(void)
 }
 
 #ifdef CONFIG_MXC_SPI
-iomux_v3_cfg_t const ecspi_pads[] = {
-       /* SPI3 */
-       MX6_PAD_DISP0_DAT2__ECSPI3_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
-       MX6_PAD_DISP0_DAT1__ECSPI3_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
-       MX6_PAD_DISP0_DAT0__ECSPI3_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
-       MX6_PAD_DISP0_DAT3__ECSPI3_SS0  | MUX_PAD_CTRL(NO_PAD_CTRL),
-       MX6_PAD_DISP0_DAT4__ECSPI3_SS1  | MUX_PAD_CTRL(NO_PAD_CTRL),
-       MX6_PAD_DISP0_DAT5__ECSPI3_SS2  | MUX_PAD_CTRL(NO_PAD_CTRL),
-       MX6_PAD_DISP0_DAT6__ECSPI3_SS3  | MUX_PAD_CTRL(NO_PAD_CTRL),
-       MX6_PAD_DISP0_DAT7__ECSPI3_RDY  | MUX_PAD_CTRL(NO_PAD_CTRL),
-};
-
 iomux_v3_cfg_t const ecspi2_pads[] = {
        /* SPI2, NOR Flash nWP, CS0 */
        MX6_PAD_CSI0_DAT10__ECSPI2_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
@@ -79,14 +67,8 @@ void displ5_set_iomux_ecspi_spl(void)
        SETUP_IOMUX_PADS(ecspi2_pads);
 }
 
-void displ5_set_iomux_ecspi(void)
-{
-       SETUP_IOMUX_PADS(ecspi_pads);
-}
-
 #else
 void displ5_set_iomux_ecspi_spl(void) {}
-void displ5_set_iomux_ecspi(void) {}
 #endif
 
 #ifdef CONFIG_FSL_ESDHC_IMX
index 231cefc960099e50714db2736a305a46b1732899..2bbd934e7a7060f4b421365cfa9ca2e9b63e9732 100644 (file)
@@ -34,7 +34,6 @@
 void displ5_set_iomux_uart_spl(void);
 void displ5_set_iomux_uart(void);
 void displ5_set_iomux_ecspi_spl(void);
-void displ5_set_iomux_ecspi(void);
 void displ5_set_iomux_usdhc_spl(void);
 void displ5_set_iomux_misc_spl(void);
 
index e008ea9a3fb8017ecf93d1242d09cbd1ebee8f63..541e3e94a5eb1fb8291504d8d111e20c62fd9e8b 100644 (file)
@@ -19,7 +19,6 @@
 #include <malloc.h>
 #include <asm/mach-imx/iomux-v3.h>
 #include <asm/mach-imx/boot_mode.h>
-#include <asm/mach-imx/spi.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <i2c.h>
 #include <dm/platform_data/serial_mxc.h>
 #include <dm/platdata.h>
 
-#ifndef CONFIG_MXC_SPI
-#error "CONFIG_SPI must be set for this board"
-#error "Please check your config file"
-#endif
-
 #include "common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -140,21 +134,6 @@ iomux_v3_cfg_t const misc_pads[] = {
        MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
-static void displ5_setup_ecspi(void)
-{
-       int ret;
-
-       displ5_set_iomux_ecspi();
-
-       ret = gpio_request(IMX_GPIO_NR(5, 29), "spi2_cs0");
-       if (!ret)
-               gpio_direction_output(IMX_GPIO_NR(5, 29), 1);
-
-       ret = gpio_request(IMX_GPIO_NR(7, 0), "spi2_#wp");
-       if (!ret)
-               gpio_direction_output(IMX_GPIO_NR(7, 0), 1);
-}
-
 /*
  * Do not overwrite the console
  * Always use serial for U-Boot console
@@ -188,7 +167,7 @@ int board_phy_config(struct phy_device *phydev)
 
 int board_init(void)
 {
-       struct gpio_desc phy_int_gbe;
+       struct gpio_desc phy_int_gbe, spi2_wp;
        int ret;
 
        debug("board init\n");
@@ -197,9 +176,6 @@ int board_init(void)
 
        /* Setup iomux for non console UARTS */
        displ5_set_iomux_uart();
-
-       displ5_setup_ecspi();
-
        /* Setup misc (application specific) stuff */
        SETUP_IOMUX_PADS(misc_pads);
 
@@ -229,6 +205,17 @@ int board_init(void)
        iomuxc_set_rgmii_io_voltage(DDR_SEL_1P5V_IO);
        enable_fec_anatop_clock(0, ENET_125MHZ);
 
+       /* Setup #WP for SPI-NOR memory */
+       ret = dm_gpio_lookup_name("GPIO7_0", &spi2_wp);
+       if (ret) {
+               printf("Cannot get GPIO7_0\n");
+       } else {
+               ret = dm_gpio_request(&spi2_wp, "spi2_#wp");
+               if (!ret)
+                       dm_gpio_set_dir_flags(&spi2_wp, GPIOD_IS_OUT |
+                                             GPIOD_IS_OUT_ACTIVE);
+       }
+
        return 0;
 }
 
index b1267b169389ae122274d283ab81d567be44c924..875ccce1c8cf47bafbc2e8cdcb378888d2acfd85 100644 (file)
@@ -85,12 +85,15 @@ CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SF_DEFAULT_BUS=1
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=50000000
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MARVELL=y
 CONFIG_FEC_MXC=y
index 6f19e55c706961eaefe6d83bf4e53714a97be982..bbcb5da7bbde1932aa72862e74e84573bd00fae1 100644 (file)
  * 0x1540000 - 0x1640000 : SPI.factory  (1MiB)
  */
 
-#ifndef CONFIG_SPL_BUILD
-#define CONFIG_SPI_FLASH_MTD
+/* SPI Flash Configs */
+#if defined(CONFIG_SPL_BUILD)
+#undef CONFIG_DM_SPI
+#undef CONFIG_DM_SPI_FLASH
+#undef CONFIG_SPI_FLASH_MTD
 #endif
 
 /* Below values are "dummy" - only to avoid build break */