AnsweredAssumed Answered

U Boot how to make SPI Flash configuration

Question asked by berkay ercan on Nov 6, 2019
Latest reply on Nov 11, 2019 by berkay ercan

Hi guys,

 

I'm working on i.MX6UL custom board. Trying to configure SPI Flash (Model = Winbond W25Q128JV),
Here's the changes that I've made and the parts that I've added;

## arch/arm/dts/imx6ul-14x14-evk.dts;

 

+spi4 {
+        compatible = "spi-gpio";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_spi4>;
+        pinctrl-assert-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
+        num-chipselects = <1>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        status = "okay";
+            flash: m25p80@0 {
+                #address-cells = <1>;
+                #size-cells = <1>;
+                compatible = "spansion,m25p80";
+                reg = <0>;
+                spi-max-frequency = <133000000>;
+    };

 

## board/freescale/imx6ul_14x14_evk.c;

 

+#define SPI_PAD_CTRL (PAD_CTL_HYS |                \
+    PAD_CTL_SPEED_MED |        \
+    PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)

-----------------------------------------------------------------------------------------------------------------------------

+#ifdef CONFIG_SPINOR
+/* pin conflicts with eim nor */
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+    MX6_PAD_ENET2_TX_EN__ECSPI4_MOSI| MUX_PAD_CTRL(SPI_PAD_CTRL),
+    MX6_PAD_ENET2_TX_DATA1__ECSPI4_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+    MX6_PAD_ENET2_TX_CLK__ECSPI4_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),

 

+  /* CS Pin */
+  MX6_PAD_JTAG_MOD__GPIO1_IO10  | MUX_PAD_CTRL(NO_PAD_CTRL),
+};

 

+static void setup_spinor(void)
+{
+ imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+  gpio_request(IMX_GPIO_NR(1, 10), "escpi cs");
+   gpio_direction_output(IMX_GPIO_NR(1, 0), 0);
+}

 

+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+   return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(1, 10)) : -1;
+}
+#endif

-----------------------------------------------------------------------------------------------------------------------------

+#ifdef CONFIG_SPINOR
+   setup_spinor();
+#endif

-----------------------------------------------------------------------------------------------------------------------------

##configs/mx6ul_14x14_evk_defconfig

+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPINOR=y
+CONFIG_WINBOND=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_CMD_SPI=y

-----------------------------------------------------------------------------------------------------------------------------

##drivers/mtd/spi/spi_flash_ids.c

#ifdef CONFIG_SPI_FLASH_WINBOND        /* WINBOND */

   + {"w25q128jv",       INFO(0xef7018, 0x0,    64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },

-----------------------------------------------------------------------------------------------------------------------------

##include/configs/mx6ul_14x14_evk.h

 

+#ifdef CONFIG_SPINOR
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_WINBOND
+#define CONFIG_SF_DEFAULT_BUS 4
+#define CONFIG_SF_DEFAULT_CS 0
+#define CONFIG_SF_DEFAULT_SPEED 133000000
+#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
+#endif

 

But I can't even open the SPI bus. Here's the terminal output when I try to 'sf probe'

=>sf probe

Invalid bus 0 (err=-19)

Failed to initialize SPI flash at 0:0 (error -19)

 

=>sf probe 4:0

Invalid bus 4 (err=-19)

Failed to initialize SPI flash at 4:0(error -19)

 

.

.

.

 

I dont know what I'm missing , I could use some help.

Thank you.

Outcomes