Skip to contentSkip to conversation

cgtqmx6eval: Add SPI NOR flash support

PATCH Superseded Otavio Salvador 4 participants 14 messages Oct 30, 2015 – Nov 3, 2015

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

---

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 35 insertions(+)
board/congatec/cgtqmx6eval/cgtqmx6eval.c +23 -0
index cf5607b..18e408b 100644
@@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_DSE_40ohm | PAD_CTL_HYS |			\
 	PAD_CTL_ODE | PAD_CTL_SRE_FAST)
 
+#define SPI_PAD_CTRL (PAD_CTL_HYS |				\
+	PAD_CTL_SPEED_MED |		\
+	PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
 #define MX6Q_QMX6_PFUZE_MUX		IMX_GPIO_NR(6, 9)
 
 
@@ -152,6 +156,13 @@ static iomux_v3_cfg_t enet_pads_ar8035[] = {
 	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+	MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 struct i2c_pads_info i2c_pad_info1 = {
 	.scl = {
@@ -381,6 +392,12 @@ static void setup_iomux_uart(void)
 	imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+void setup_spinor(void)
+{
+	imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+	gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
 	{USDHC2_BASE_ADDR},
@@ -646,6 +663,7 @@ int board_early_init_f(void)
 {
 	setup_iomux_uart();
 	setup_display();
+	setup_spinor();
 
 	return 0;
 }
@@ -671,6 +689,11 @@ int checkboard(void)
 	return 0;
 }
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+	return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
 	/* 4 bit bus width */
include/configs/cgtqmx6eval.h +12 -0
index e0aa4b0..9aa66c7 100644
@@ -29,6 +29,16 @@
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
 
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI
+#define CONFIG_SF_DEFAULT_BUS		0
+#define CONFIG_SF_DEFAULT_SPEED		20000000
+#define CONFIG_SF_DEFAULT_MODE		(SPI_MODE_0)
+
 /* Miscellaneous commands */
 #define CONFIG_CMD_BMODE
 
@@ -200,8 +210,10 @@
 		"else " \
 			"bootz; " \
 		"fi;\0" \
+	"spilock=sf probe && sf protect lock 0x3f0000 0x10000;"\
 
 #define CONFIG_BOOTCOMMAND \
+	"run spilock;"	    \
 	"mmc dev ${mmcdev};" \
 	"if mmc rescan; then " \
 		"if run loadbootscript; then " \
Signature · 1 line
2.6.2
#1 lore raw

PATCH v5 2/6 cgtqmx6eval: Use SPI NOR to store the environment

Congatec boards boot from SPI NOR, so it makes more sense to use SPI NOR to store the environment variables.

---

Changes in v5: None
Changes in v4: None

 include/configs/cgtqmx6eval.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
include/configs/cgtqmx6eval.h +14 -4
index 9aa66c7..79183c4 100644
@@ -245,11 +245,21 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* Environment organization */
-#define CONFIG_ENV_SIZE			(8 * 1024)
-
-#define CONFIG_ENV_IS_IN_MMC
-
+#if defined (CONFIG_ENV_IS_IN_MMC)
 #define CONFIG_ENV_OFFSET		(6 * 64 * 1024)
 #define CONFIG_SYS_MMC_ENV_DEV		0
+#endif
+
+#define CONFIG_ENV_SIZE			(8 * 1024)
+
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#if defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+#define CONFIG_ENV_OFFSET		(768 * 1024)
+#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
+#endif
 
 #endif			       /* __CONFIG_CGTQMX6EVAL_H */
Signature · 1 line
2.6.2
#2 lore raw

PATCH v5 2/6 cgtqmx6eval: Use SPI NOR to store the environment

Quoted 22 lines · Otavio Salvador

Congatec boards boot from SPI NOR, so it makes more sense to use SPI NOR to store the environment variables.

---

Changes in v5: None
Changes in v4: None

 include/configs/cgtqmx6eval.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
include/configs/cgtqmx6eval.h +0 -2
index 9aa66c7..79183c4 100644
@@ -245,11 +245,21 @@
        (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* Environment organization */
-#define CONFIG_ENV_SIZE                        (8 * 1024)
-

include/configs/cgtqmx6eval.h line 255

Quoted 10 lines
include/configs/cgtqmx6eval.h +6 -2
-#define CONFIG_ENV_IS_IN_MMC
-
+#if defined (CONFIG_ENV_IS_IN_MMC)
 #define CONFIG_ENV_OFFSET              (6 * 64 * 1024)
 #define CONFIG_SYS_MMC_ENV_DEV         0
+#endif
+
+#define CONFIG_ENV_SIZE                        (8 * 1024)
+
+#define CONFIG_ENV_IS_IN_SPI_FLASH

You make default flash env as spi-flash as this board boot from spi-nor always is it?

Quoted 11 lines
include/configs/cgtqmx6eval.h +8 -1
+#if defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+#define CONFIG_ENV_OFFSET              (768 * 1024)
+#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
+#endif
 
 #endif                        /* __CONFIG_CGTQMX6EVAL_H */
--
Quoted 2 lines

2.6.2

thanks!

Signature · 1 line
Jagan | openedev.
#3 lore raw

PATCH v5 2/6 cgtqmx6eval: Use SPI NOR to store the environment

Quoted 5 lines · Jagan Teki
Quoted 4 lines · Otavio Salvador

Congatec boards boot from SPI NOR, so it makes more sense to use SPI NOR to store the environment variables.

...

Quoted 4 lines
Quoted 1 line

+#define CONFIG_ENV_IS_IN_SPI_FLASH

You make default flash env as spi-flash as this board boot from spi-nor always is it?

Yes; this is the supported setting by Congatec.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#4 lore raw

PATCH v5 2/6 cgtqmx6eval: Use SPI NOR to store the environment

Quoted 6 lines · Otavio Salvador
Quoted 5 lines · Jagan Teki
Quoted 4 lines · Otavio Salvador

Congatec boards boot from SPI NOR, so it makes more sense to use SPI NOR to store the environment variables.

thanks!

Signature · 1 line
Jagan | openedev.
#5 lore raw

PATCH v5 3/6 cgtqmx6eval: Add fastboot support

In reply to Otavio Salvador

Tested basic fastboot commands, such as:

On the U-boot prompt:

=> fastboot 0

On the host PC:

$ fastboot getvar bootloader-version -i 0x0525
bootloader-version: U-Boot 2015.10-rc2-09654-g8f41d27
finished. total time: 0.000s
$ fastboot reboot -i 0x0525 --> board reboots fine.

---

Changes in v5: None
Changes in v4: None

 include/configs/cgtqmx6eval.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/configs/cgtqmx6eval.h +6 -0
index 79183c4..ee48fa6 100644
@@ -89,6 +89,12 @@
 #define CONFIG_G_DNL_PRODUCT_NUM	0xa4a5
 #define CONFIG_G_DNL_MANUFACTURER	"Congatec"
 
+#define CONFIG_USB_FUNCTION_FASTBOOT
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_FASTBOOT_BUF_ADDR   CONFIG_SYS_LOAD_ADDR
+#define CONFIG_FASTBOOT_BUF_SIZE   0x07000000
+
 /* Framebuffer */
 #define CONFIG_VIDEO
 #define CONFIG_VIDEO_IPUV3
Signature · 1 line
2.6.2
#6 lore raw

PATCH v5 4/6 cgtqmx6eval: Add SPL support

In reply to Otavio Salvador

Congatec has several MX6 boards based on quad, dual, dual-lite and solo.

Add SPL support so that all the variants can be supported

---

Changes in v5:
- Add missing CONFIG_BOARD_LATE_INIT
- Fix checkpatch error
- Use erase/write as update seems to not work

Changes in v4:
- Rework README (Marek)
- Rework code to compare part-# (Marek)

 arch/arm/cpu/armv7/mx6/Kconfig                     |   3 +
 board/congatec/cgtqmx6eval/README                  |  78 ++-
 board/congatec/cgtqmx6eval/cgtqmx6eval.c           | 578 +++++++++++++++++----
 board/congatec/cgtqmx6eval/imximage.cfg            | 143 -----
 ...gtqmx6qeval_defconfig => cgtqmx6eval_defconfig} |   5 +-
 include/configs/cgtqmx6eval.h                      |  22 +-
 6 files changed, 568 insertions(+), 261 deletions(-)
 delete mode 100644 board/congatec/cgtqmx6eval/imximage.cfg
 rename configs/{cgtqmx6qeval_defconfig => cgtqmx6eval_defconfig} (57%)
arch/arm/cpu/armv7/mx6/Kconfig +3 -0
index 0b02e9e..9ee509e 100644
@@ -44,6 +44,9 @@ config TARGET_ARISTAINETOS2B
 
 config TARGET_CGTQMX6EVAL
 	bool "cgtqmx6eval"
+	select SUPPORT_SPL
+	select DM
+	select DM_THERMAL
 
 config TARGET_CM_FX6
 	bool "CM-FX6"
board/congatec/cgtqmx6eval/README +60 -18

88 lines not on this page · raw message

board/congatec/cgtqmx6eval/cgtqmx6eval.c +481 -97

699 lines not on this page · raw message

board/congatec/cgtqmx6eval/imximage.cfg deleted +0 -143

143 lines not on this page · raw message

configs/cgtqmx6eval_defconfig renamed from configs/cgtqmx6qeval_defconfig +3 -2
similarity index 57%
rename from configs/cgtqmx6qeval_defconfig
rename to configs/cgtqmx6eval_defconfig
index fdbcc22..2765aa2 100644
@@ -1,10 +1,11 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_CGTQMX6EVAL=y
-CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/congatec/cgtqmx6eval/imximage.cfg,MX6Q"
-CONFIG_SYS_PROMPT="CGT-QMX6-Quad U-Boot > "
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,SPL,MX6QDL"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_SYS_PROMPT="CGT-QMX6 U-Boot > "
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
include/configs/cgtqmx6eval.h +21 -1
index ee48fa6..79fc0f6 100644
@@ -17,10 +17,21 @@
 
 #define CONFIG_MACH_TYPE	4122
 
+#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
+
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(10 * 1024 * 1024)
 
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT
 #define CONFIG_MISC_INIT_R
 
 #define CONFIG_MXC_UART
@@ -144,10 +155,11 @@
 #define CONFIG_MMCROOT		"/dev/mmcblk0p2"
 #define CONFIG_SYS_MMC_ENV_DEV		0
 
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"fdtfile=imx6q-qmx6.dtb\0" \
+	"fdtfile=undefined\0" \
 	"fdt_addr_r=0x18000000\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
@@ -192,6 +204,13 @@
 		"else " \
 			"bootz; " \
 		"fi;\0" \
+	"findfdt="\
+		"if test $board_rev = MX6Q ; then " \
+			"setenv fdtfile imx6q-qmx6.dtb; fi; " \
+		"if test $board_rev = MX6DL ; then " \
+			"setenv fdtfile imx6dl-qmx6.dtb; fi; " \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine dtb to use; fi; \0" \
 	"netargs=setenv bootargs console=${console},${baudrate} " \
 		"root=/dev/nfs " \
 		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
@@ -220,6 +239,7 @@
 
 #define CONFIG_BOOTCOMMAND \
 	"run spilock;"	    \
+	"run findfdt; "	\
 	"mmc dev ${mmcdev};" \
 	"if mmc rescan; then " \
 		"if run loadbootscript; then " \
Signature · 1 line
2.6.2
#7 lore raw

PATCH v5 5/6 iomux-v3: Take MX6D in consideration for imx_iomux_v3_setup_pad()

In reply to Otavio Salvador

We should also take MX6D option in consideration when defining imx_iomux_v3_setup_pad().

---

Changes in v5: None
Changes in v4: None

 arch/arm/include/asm/imx-common/iomux-v3.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/imx-common/iomux-v3.h +1 -1
index 1a80a96..2e49968 100644
@@ -236,7 +236,7 @@ void imx_iomux_gpio_get_function(unsigned int gpio,
 #if defined(CONFIG_MX6QDL)
 #define IOMUX_PADS(x) (MX6Q_##x), (MX6DL_##x)
 #define SETUP_IOMUX_PAD(def)					\
-if (is_cpu_type(MXC_CPU_MX6Q)) {				\
+if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) {				\
 	imx_iomux_v3_setup_pad(MX6Q_##def);			\
 } else {							\
 	imx_iomux_v3_setup_pad(MX6DL_##def);			\
Signature · 1 line
2.6.2
#8 lore raw

PATCH v5 6/6 cgtqmx6eval: Add DFU support

In reply to Otavio Salvador

Add MMC and SPI DFU support.

---

Changes in v5: None
Changes in v4: None

 include/configs/cgtqmx6eval.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/configs/cgtqmx6eval.h +10 -0
index 79fc0f6..487c011 100644
@@ -100,6 +100,12 @@
 #define CONFIG_G_DNL_PRODUCT_NUM	0xa4a5
 #define CONFIG_G_DNL_MANUFACTURER	"Congatec"
 
+/* USB Device Firmware Update support */
+#define CONFIG_CMD_DFU
+#define CONFIG_USB_FUNCTION_DFU
+#define CONFIG_DFU_MMC
+#define CONFIG_DFU_SF
+
 #define CONFIG_USB_FUNCTION_FASTBOOT
 #define CONFIG_CMD_FASTBOOT
 #define CONFIG_ANDROID_BOOT_IMAGE
@@ -164,6 +170,10 @@
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
 	"console=" CONFIG_CONSOLE_DEV "\0" \
+	"dfuspi=dfu 0 sf 0:0:10000000:0\0" \
+	"dfu_alt_info_spl=spl raw 0x400\0" \
+	"dfu_alt_info_img=u-boot raw 0x10000\0" \
+	"dfu_alt_info=spl raw 0x400\0" \
 	"bootm_size=0x10000000\0" \
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=1\0" \
Signature · 1 line
2.6.2
#9 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

In reply to Otavio Salvador
Quoted 82 lines · Otavio Salvador

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

---

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 35 insertions(+)
board/congatec/cgtqmx6eval/cgtqmx6eval.c +23 -0
index cf5607b..18e408b 100644
@@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
        PAD_CTL_DSE_40ohm | PAD_CTL_HYS |                       \
        PAD_CTL_ODE | PAD_CTL_SRE_FAST)
 
+#define SPI_PAD_CTRL (PAD_CTL_HYS |                            \
+       PAD_CTL_SPEED_MED |             \
+       PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
 #define MX6Q_QMX6_PFUZE_MUX            IMX_GPIO_NR(6, 9)
 
 
@@ -152,6 +156,13 @@ static iomux_v3_cfg_t enet_pads_ar8035[] = {
        MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+       MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 struct i2c_pads_info i2c_pad_info1 = {
        .scl = {
@@ -381,6 +392,12 @@ static void setup_iomux_uart(void)
        imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+void setup_spinor(void)
+{
+       imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+       gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
        {USDHC2_BASE_ADDR},
@@ -646,6 +663,7 @@ int board_early_init_f(void)
 {
        setup_iomux_uart();
        setup_display();
+       setup_spinor();
 
        return 0;
 }
@@ -671,6 +689,11 @@ int checkboard(void)
        return 0;
 }
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
        /* 4 bit bus width */
include/configs/cgtqmx6eval.h +0 -0
index e0aa4b0..9aa66c7 100644

include/configs/cgtqmx6eval.h line 37

Quoted 9 lines
include/configs/cgtqmx6eval.h +6 -0
@@ -29,6 +29,16 @@
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
 
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI

Please try to move this to driver model, all these "spinor setup" stuff will go easily on probe call. Ping me anytime for any help.

thanks!

Signature · 1 line
Jagan | openedev.
#10 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

Quoted 7 lines · Jagan Teki
Quoted 6 lines · Otavio Salvador

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

...

Quoted 9 lines

include/configs/cgtqmx6eval.h line 37

Quoted 6 lines
include/configs/cgtqmx6eval.h +6 -0
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI

Please try to move this to driver model, all these "spinor setup" stuff will go easily on probe call. Ping me anytime for any help.

I can work on this but I want to merge this working version before doing any changes.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#11 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

Quoted 19 lines · Otavio Salvador
Quoted 7 lines · Jagan Teki
Quoted 6 lines · Otavio Salvador

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

...

Quoted 9 lines

include/configs/cgtqmx6eval.h line 37

Quoted 6 lines
include/configs/cgtqmx6eval.h +6 -0
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI

Please try to move this to driver model, all these "spinor setup" stuff will go easily on probe call. Ping me anytime for any help.

Quoted 2 lines

I can work on this but I want to merge this working version before doing any changes.

Thanks, I really see this to happen many of board init stuff have to migrate.

thanks!

Signature · 1 line
Jagan | openedev.
#12 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

In reply to Jagan Teki
Quoted 86 lines · Jagan Teki
Quoted 85 lines · Otavio Salvador

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

---

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 35 insertions(+)
board/congatec/cgtqmx6eval/cgtqmx6eval.c +23 -0
index cf5607b..18e408b 100644
@@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
        PAD_CTL_DSE_40ohm | PAD_CTL_HYS |                       \
        PAD_CTL_ODE | PAD_CTL_SRE_FAST)
 
+#define SPI_PAD_CTRL (PAD_CTL_HYS |                            \
+       PAD_CTL_SPEED_MED |             \
+       PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
 #define MX6Q_QMX6_PFUZE_MUX            IMX_GPIO_NR(6, 9)
 
 
@@ -152,6 +156,13 @@ static iomux_v3_cfg_t enet_pads_ar8035[] = {
        MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+       MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 struct i2c_pads_info i2c_pad_info1 = {
        .scl = {
@@ -381,6 +392,12 @@ static void setup_iomux_uart(void)
        imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+void setup_spinor(void)
+{
+       imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+       gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
        {USDHC2_BASE_ADDR},
@@ -646,6 +663,7 @@ int board_early_init_f(void)
 {
        setup_iomux_uart();
        setup_display();
+       setup_spinor();
 
        return 0;
 }
@@ -671,6 +689,11 @@ int checkboard(void)
        return 0;
 }
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
        /* 4 bit bus width */
include/configs/cgtqmx6eval.h +0 -0
index e0aa4b0..9aa66c7 100644
@@ -29,6 +29,16 @@
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
 
Quoted 9 lines

include/configs/cgtqmx6eval.h line 37

Quoted 6 lines
include/configs/cgtqmx6eval.h +6 -0
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI

Please try to move this to driver model, all these "spinor setup" stuff will go easily on probe call. Ping me anytime for any help.

I really prefer iterative development and improvement when possible. If follow-up on improvements doesn't happen we can always remove code for lack of maintenance.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151103/04a2ebab/attachment.sig>
#13 lore raw

PATCH v5 1/6 cgtqmx6eval: Add SPI NOR flash support

In reply to Otavio Salvador
Quoted 45 lines · Otavio Salvador

Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

---

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 35 insertions(+)
board/congatec/cgtqmx6eval/cgtqmx6eval.c +11 -0
index cf5607b..18e408b 100644
@@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
        PAD_CTL_DSE_40ohm | PAD_CTL_HYS |                       \
        PAD_CTL_ODE | PAD_CTL_SRE_FAST)
 
+#define SPI_PAD_CTRL (PAD_CTL_HYS |                            \
+       PAD_CTL_SPEED_MED |             \
+       PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
 #define MX6Q_QMX6_PFUZE_MUX            IMX_GPIO_NR(6, 9)
 
 
@@ -152,6 +156,13 @@ static iomux_v3_cfg_t enet_pads_ar8035[] = {
        MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+       MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
+       MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 struct i2c_pads_info i2c_pad_info1 = {
        .scl = {

board/congatec/cgtqmx6eval/cgtqmx6eval.c static void setup_iomux_uart(void) · line 400

Quoted 9 lines
board/congatec/cgtqmx6eval/cgtqmx6eval.c +6 -0
@@ -381,6 +392,12 @@ static void setup_iomux_uart(void)
        imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+void setup_spinor(void)
+{
+       imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+       gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+

As this init stuff is related to MXC better to move this with CONFIG_MXC_SPI defined.

Quoted 62 lines
board/congatec/cgtqmx6eval/cgtqmx6eval.c +6 -0
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
        {USDHC2_BASE_ADDR},
@@ -646,6 +663,7 @@ int board_early_init_f(void)
 {
        setup_iomux_uart();
        setup_display();
+       setup_spinor();
 
        return 0;
 }
@@ -671,6 +689,11 @@ int checkboard(void)
        return 0;
 }
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
        /* 4 bit bus width */
include/configs/cgtqmx6eval.h +12 -1
index e0aa4b0..9aa66c7 100644
@@ -29,6 +29,16 @@
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
 
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI
+#define CONFIG_SF_DEFAULT_BUS          0
+#define CONFIG_SF_DEFAULT_SPEED                20000000
+#define CONFIG_SF_DEFAULT_MODE         (SPI_MODE_0)
+
 /* Miscellaneous commands */
 #define CONFIG_CMD_BMODE
 
@@ -200,8 +210,10 @@
                "else " \
                        "bootz; " \
                "fi;\0" \
+       "spilock=sf probe && sf protect lock 0x3f0000 0x10000;"\
 
 #define CONFIG_BOOTCOMMAND \
+       "run spilock;"      \
        "mmc dev ${mmcdev};" \
        "if mmc rescan; then " \
                "if run loadbootscript; then " \
--

2.6.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 1 line
Jagan | openedev.