Skip to contentSkip to conversation

cgtqmx6eval: Add SPI NOR flash support

PATCH New Otavio Salvador 4 participants 19 messages Nov 19, 2015 – Dec 4, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v6 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 v6:
- use ifdef CONFIG_MXC_SPI (Jagan)

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 29 +++++++++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 41 insertions(+)
board/congatec/cgtqmx6eval/cgtqmx6eval.c +29 -0
index cf5607b..0458229 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,14 @@ static void setup_iomux_uart(void)
 	imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+#ifdef CONFIG_MXC_SPI
+static void setup_spi(void)
+{
+	imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+	gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+#endif
+
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
 	{USDHC2_BASE_ADDR},
@@ -647,6 +666,9 @@ int board_early_init_f(void)
 	setup_iomux_uart();
 	setup_display();
 
+#ifdef CONFIG_MXC_SPI
+	setup_spi();
+#endif
 	return 0;
 }
 
@@ -671,6 +693,13 @@ int checkboard(void)
 	return 0;
 }
 
+#ifdef CONFIG_MXC_SPI
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+	return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+#endif
+
 #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 v6 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 v6: None
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
#4 lore raw

PATCH v6 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 v6: None
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
reviewer
#5 lore raw

PATCH v6 3/6 cgtqmx6eval: Add fastboot support

Quoted 8 lines · Otavio Salvador

Tested basic fastboot commands, such as:

On the U-boot prompt:

=> fastboot 0

On the host PC:

Quoted 7 lines
$ 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.
#6 lore raw

PATCH v6 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 v6: None
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 273e209..8489182 100644
@@ -46,6 +46,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
#8 lore raw

PATCH v6 4/6 cgtqmx6eval: Add SPL support

In reply to Otavio Salvador

Hi Otavio,

Quoted 7 lines · 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

---

Whole series applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
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
=====================================================================
#9 lore raw

PATCH v6 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 v6: None
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
#11 lore raw

PATCH v6 6/6 cgtqmx6eval: Add DFU support

In reply to Otavio Salvador

Add MMC and SPI DFU support.

---

Changes in v6: None
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
#16 lore raw

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

Quoted 7 lines · Fabio Estevam

Hi Jagan,

Quoted 1 line · Jagan Teki

Applied to u-boot-spi/master

Not sure why you applied this into u-boot-spi.

Because these two are SPI/SPI-NOR related - not so big deal as these were first two patches from the series.

Quoted 4 lines

This is i.MX board related code and has already been applied into Stefano's tree:
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=commitdiff;h=71bcdafe73255d6ef974e55f3d31cf27127871b5;hp=fef438d76c08ba11f35b1257892bb3093d8e4caf

thanks!
--
Jagan.

#17 lore raw

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

Quoted 12 lines · Jagan Teki
Quoted 7 lines · Fabio Estevam

Hi Jagan,

Quoted 1 line · Jagan Teki

Applied to u-boot-spi/master

Not sure why you applied this into u-boot-spi.

Because these two are SPI/SPI-NOR related - not so big deal as these were first two patches from the series.

They are related to i.MX boards, that the reason they flow into i.MX tree. Or in different way if discussed in the ML.

They are part of a series (6 patches) related to the cgtqmx6eval board only (one of them is related to iomux-v3). I applied the whole series. I guess Tom can have problems by pulling both trees. Maybe not, I send my PR to check it.

Quoted 5 lines
Quoted 5 lines

This is i.MX board related code and has already been applied into Stefano's tree:
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=commitdiff;h=71bcdafe73255d6ef974e55f3d31cf27127871b5;hp=fef438d76c08ba11f35b1257892bb3093d8e4caf

Best regards,
Stefano

Signature · 5 lines
=====================================================================
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
=====================================================================
#18 lore raw

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

Quoted 14 lines · Stefano Babic
Quoted 12 lines · Jagan Teki
Quoted 7 lines · Fabio Estevam

Hi Jagan,

Quoted 1 line · Jagan Teki

Applied to u-boot-spi/master

Not sure why you applied this into u-boot-spi.

Because these two are SPI/SPI-NOR related - not so big deal as these were first two patches from the series.

Quoted 7 lines

They are related to i.MX boards, that the reason they flow into i.MX tree. Or in different way if discussed in the ML.

They are part of a series (6 patches) related to the cgtqmx6eval board only (one of them is related to iomux-v3). I applied the whole series. I guess Tom can have problems by pulling both trees. Maybe not, I send my PR to check it.

Ohh.. You applied it on your tree already? then I couldn't find on ML about "Applied to" text probably I mayn't be in that chain.

OK, then proceed with it I will re-base mine.

thanks!

Signature · 1 line
Jagan