Skip to contentSkip to conversation

ram: add SDRAM driver for i.MXRT SoCs

PATCH New Giulio Benetti 1 participant 5 messages Dec 4, 2019

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

PATCH 16/20 ram: add SDRAM driver for i.MXRT SoCs

Add SDRAM driver for i.MXRT SoCs.

---
 drivers/ram/Kconfig                      |   8 +
 drivers/ram/Makefile                     |   2 +
 drivers/ram/imxrt_sdram.c                | 439 +++++++++++++++++++++++
 include/dt-bindings/memory/imxrt-sdram.h | 100 ++++++
 4 files changed, 549 insertions(+)
 create mode 100644 drivers/ram/imxrt_sdram.c
 create mode 100644 include/dt-bindings/memory/imxrt-sdram.h
drivers/ram/Kconfig +8 -0
index b454ceb599..56fea7c94c 100644
@@ -65,5 +65,13 @@ config K3_J721E_DDRSS
 	  Enabling this config adds support for the DDR memory controller
 	  on J721E family of SoCs.
 
+config IMXRT_SDRAM
+	bool "Enable i.MXRT SDRAM support"
+	depends on RAM
+	help
+	  i.MXRT family devices support smart external memory controller(SEMC)
+	  to support external memories like sdram, psram & nand.
+	  This driver is for the sdram memory interface with the SEMC.
+
 source "drivers/ram/rockchip/Kconfig"
 source "drivers/ram/stm32mp1/Kconfig"
drivers/ram/Makefile +2 -0
index 4b77969b39..5c897410c6 100644
@@ -15,3 +15,5 @@ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_K3_AM654_DDRSS) += k3-am654-ddrss.o
 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
 obj-$(CONFIG_K3_J721E_DDRSS) += k3-j721e/
+
+obj-$(CONFIG_IMXRT_SDRAM) += imxrt_sdram.o
drivers/ram/imxrt_sdram.c new file +439 -0

439 lines not on this page · raw message

include/dt-bindings/memory/imxrt-sdram.h new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH 17/20 mmc: fsl_esdhc: make if(CONFIG_IS_ENABLED(CLK)) an #if statement

Not all architectures(i.e. i.MXRT) support mxc_get_clock() and use DM_CLK instead. So building could result in failure due to missing mxc_get_clock().

Make if(CONFIG_IS_ENABLED(CLK)) an #if statement.

---
 drivers/mmc/fsl_esdhc_imx.c | 38 ++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/mmc/fsl_esdhc_imx.c +19 -19
index f1afab742d..afdca9cd07 100644
@@ -1514,27 +1514,27 @@ static int fsl_esdhc_probe(struct udevice *dev)
 
 	init_clk_usdhc(dev->seq);
 
-	if (CONFIG_IS_ENABLED(CLK)) {
-		/* Assigned clock already set clock */
-		ret = clk_get_by_name(dev, "per", &priv->per_clk);
-		if (ret) {
-			printf("Failed to get per_clk\n");
-			return ret;
-		}
-		ret = clk_enable(&priv->per_clk);
-		if (ret) {
-			printf("Failed to enable per_clk\n");
-			return ret;
-		}
+#if CONFIG_IS_ENABLED(CLK)
+	/* Assigned clock already set clock */
+	ret = clk_get_by_name(dev, "per", &priv->per_clk);
+	if (ret) {
+		printf("Failed to get per_clk\n");
+		return ret;
+	}
+	ret = clk_enable(&priv->per_clk);
+	if (ret) {
+		printf("Failed to enable per_clk\n");
+		return ret;
+	}
 
-		priv->sdhc_clk = clk_get_rate(&priv->per_clk);
-	} else {
-		priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
-		if (priv->sdhc_clk <= 0) {
-			dev_err(dev, "Unable to get clk for %s\n", dev->name);
-			return -EINVAL;
-		}
+	priv->sdhc_clk = clk_get_rate(&priv->per_clk);
+#else
+	priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
+	if (priv->sdhc_clk <= 0) {
+		dev_err(dev, "Unable to get clk for %s\n", dev->name);
+		return -EINVAL;
 	}
+#endif
 
 	ret = fsl_esdhc_init(priv, plat);
 	if (ret) {
Signature · 1 line
2.20.1
#2 lore raw

PATCH 18/20 mmc: fsl_esdhc: add compatible for fsl, imxrt-usdhc

In reply to Giulio Benetti

Add compatible "fsl,imxrt-usdhc" to make mmc working on i.MXRT platforms with CONFIG_DM_MMC=y.

---
 drivers/mmc/Kconfig         | 2 +-
 drivers/mmc/fsl_esdhc_imx.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/Kconfig +1 -1
index 85fd1906bd..9974b995a2 100644
@@ -732,7 +732,7 @@ config FSL_ESDHC_IMX
 
 config FSL_USDHC
 	bool "Freescale/NXP i.MX uSDHC controller support"
-	depends on MX6 || MX7 ||ARCH_MX7ULP || IMX8 || IMX8M || TARGET_S32V234EVB
+	depends on MX6 || MX7 ||ARCH_MX7ULP || IMX8 || IMX8M || TARGET_S32V234EVB || ARCH_IMXRT
 	select FSL_ESDHC_IMX
 	help
 	  This enables the Ultra Secured Digital Host Controller enhancements
drivers/mmc/fsl_esdhc_imx.c +2 -1
index afdca9cd07..318c1a1913 100644
@@ -78,7 +78,7 @@ struct fsl_esdhc {
 	uint    vendorspec;
 	uint    mmcboot;
 	uint    vendorspec2;
-	uint    tuning_ctrl;	/* on i.MX6/7/8 */
+	uint    tuning_ctrl;	/* on i.MX6/7/8/RT */
 	char	reserved5[44];
 	uint    hostver;	/* Host controller version register */
 	char    reserved6[4];	/* reserved */
@@ -1651,6 +1651,7 @@ static const struct udevice_id fsl_esdhc_ids[] = {
 	{ .compatible = "fsl,imx8mm-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
 	{ .compatible = "fsl,imx8mn-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
 	{ .compatible = "fsl,imx8mq-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
+	{ .compatible = "fsl,imxrt-usdhc", },
 	{ .compatible = "fsl,esdhc", },
 	{ /* sentinel */ }
 };
Signature · 1 line
2.20.1
#3 lore raw

PATCH 19/20 imx: Add basic support for the NXP IMXRT10xx SoC family

In reply to Giulio Benetti

Add i.IMXRT family basic support.

---
 arch/arm/Kconfig                            | 10 ++++++
 arch/arm/Makefile                           |  4 +--
 arch/arm/include/asm/arch-imxrt/clock.h     | 10 ++++++
 arch/arm/include/asm/arch-imxrt/gpio.h      | 19 +++++++++++
 arch/arm/include/asm/arch-imxrt/imx-regs.h  | 20 ++++++++++++
 arch/arm/include/asm/arch-imxrt/imxrt.h     | 11 +++++++
 arch/arm/include/asm/arch-imxrt/sys_proto.h | 11 +++++++
 arch/arm/mach-imx/Makefile                  |  3 +-
 arch/arm/mach-imx/imxrt/Kconfig             | 21 +++++++++++++
 arch/arm/mach-imx/imxrt/Makefile            |  7 +++++
 arch/arm/mach-imx/imxrt/soc.c               | 35 +++++++++++++++++++++
 11 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-imxrt/clock.h
 create mode 100644 arch/arm/include/asm/arch-imxrt/gpio.h
 create mode 100644 arch/arm/include/asm/arch-imxrt/imx-regs.h
 create mode 100644 arch/arm/include/asm/arch-imxrt/imxrt.h
 create mode 100644 arch/arm/include/asm/arch-imxrt/sys_proto.h
 create mode 100644 arch/arm/mach-imx/imxrt/Kconfig
 create mode 100644 arch/arm/mach-imx/imxrt/Makefile
 create mode 100644 arch/arm/mach-imx/imxrt/soc.c
arch/arm/Kconfig +10 -0
index f96841c777..24c6a6dbbf 100644
@@ -797,6 +797,14 @@ config ARCH_IMX8M
 	select SUPPORT_SPL
 	imply CMD_DM
 
+config ARCH_IMXRT
+	bool "NXP i.MXRT platform"
+	select CPU_V7M
+	select DM
+	select DM_SERIAL
+	select SUPPORT_SPL
+	imply CMD_DM
+
 config ARCH_MX23
 	bool "NXP i.MX23 family"
 	select CPU_ARM926EJS
@@ -1720,6 +1728,8 @@ source "arch/arm/mach-imx/imx8/Kconfig"
 
 source "arch/arm/mach-imx/imx8m/Kconfig"
 
+source "arch/arm/mach-imx/imxrt/Kconfig"
+
 source "arch/arm/mach-imx/mxs/Kconfig"
 
 source "arch/arm/mach-omap2/Kconfig"
arch/arm/Makefile +2 -2
index 60af7e3199..22e2815cc1 100644
@@ -104,11 +104,11 @@ libs-y += arch/arm/cpu/
 libs-y += arch/arm/lib/
 
 ifeq ($(CONFIG_SPL_BUILD),y)
-ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC), mx25 mx5 mx6 mx7 mx35 imx8m imx8))
+ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC), mx25 mx5 mx6 mx7 mx35 imx8m imx8 imxrt))
 libs-y += arch/arm/mach-imx/
 endif
 else
-ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs imx8m imx8 vf610))
+ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs imx8m imx8 imxrt vf610))
 libs-y += arch/arm/mach-imx/
 endif
 endif
arch/arm/include/asm/arch-imxrt/clock.h new file +10 -0
new file mode 100644
index 0000000000..7409028b9a
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#ifndef __ASM_ARCH_CLOCK_H
+#define __ASM_ARCH_CLOCK_H
+
+#endif /* __ASM_ARCH_CLOCK_H */
arch/arm/include/asm/arch-imxrt/gpio.h new file +19 -0
new file mode 100644
index 0000000000..da31a7438a
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#ifndef __ASM_ARCH_GPIO_H__
+#define __ASM_ARCH_GPIO_H__
+
+#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
+/* GPIO registers */
+struct gpio_regs {
+	u32 gpio_dr;	/* data */
+	u32 gpio_dir;	/* direction */
+	u32 gpio_psr;	/* pad satus */
+};
+#endif
+
+#endif /* __ASM_ARCH_GPIO_H__ */
arch/arm/include/asm/arch-imxrt/imx-regs.h new file +20 -0
new file mode 100644
index 0000000000..d21450cfc6
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright(C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#ifndef __ASM_ARCH_IMX_REGS_H__
+#define __ASM_ARCH_IMX_REGS_H__
+
+#define ARCH_MXC
+
+#define ANATOP_BASE_ADDR	0x400d8000
+
+#define MXS_LCDIF_BASE		0x402b8000
+
+#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
+#include <asm/mach-imx/regs-lcdif.h>
+#endif
+
+#endif /* __ASM_ARCH_IMX_REGS_H__ */
arch/arm/include/asm/arch-imxrt/imxrt.h new file +11 -0
new file mode 100644
index 0000000000..1cb2c57d31
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#ifndef _ASM_ARCH_IMXRT_H
+#define _ASM_ARCH_IMXRT_H
+
+#endif /* _ASM_ARCH_IMXRT_H */
+
arch/arm/include/asm/arch-imxrt/sys_proto.h new file +11 -0
new file mode 100644
index 0000000000..eb878e672e
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2017 NXP
+ */
+
+#ifndef _ASM_ARCH_SYS_PROTO_H
+#define _ASM_ARCH_SYS_PROTO_H
+
+#include <asm/mach-imx/sys_proto.h>
+
+#endif /* _ASM_ARCH_SYS_PROTO_H */
arch/arm/mach-imx/Makefile +2 -1
index e14713c5c4..a70d51b5cf 100644
@@ -27,7 +27,7 @@ endif
 obj-$(CONFIG_GPT_TIMER) += timer.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 endif
-ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m imx8))
+ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m imx8 imxrt))
 obj-y	+= misc.o
 obj-$(CONFIG_SPL_BUILD)	+= spl.o
 endif
@@ -226,5 +226,6 @@ obj-$(CONFIG_MX7) += mx7/
 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
 obj-$(CONFIG_IMX8M) += imx8m/
 obj-$(CONFIG_ARCH_IMX8) += imx8/
+obj-$(CONFIG_ARCH_IMXRT) += imxrt/
 
 obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_imx_romapi.o
arch/arm/mach-imx/imxrt/Kconfig new file +21 -0
new file mode 100644
index 0000000000..22f130e79a
@@ -0,0 +1,21 @@
+if ARCH_IMXRT
+
+config IMXRT1050
+	bool
+
+config SYS_SOC
+	default "imxrt"
+
+choice
+	prompt "NXP i.MXRT board select"
+	optional
+
+config TARGET_IMXRT1050_EVK
+	bool "Support imxrt1050 EVK board"
+	select IMXRT1050
+
+endchoice
+
+source "board/freescale/imxrt1050-evk/Kconfig"
+
+endif
arch/arm/mach-imx/imxrt/Makefile new file +7 -0
new file mode 100644
index 0000000000..9621a8335a
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2019
+# Author(s): Giulio Benetti <[email protected]>
+#
+
+obj-y	:= soc.o
arch/arm/mach-imx/imxrt/soc.c new file +35 -0
new file mode 100644
index 0000000000..e1eea23035
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/armv7_mpu.h>
+
+int arch_cpu_init(void)
+{
+	int i;
+
+	struct mpu_region_config imxrt1050_region_config[] = {
+		{ 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
+		  STRONG_ORDER, REGION_4GB },
+		{ PHYS_SDRAM, REGION_1, XN_DIS, PRIV_RW_USR_RW,
+		  O_I_WB_RD_WR_ALLOC, (ffs(PHYS_SDRAM_SIZE) - 2) },
+		{ DMAMEM_BASE,
+		  REGION_2, XN_DIS, PRIV_RW_USR_RW,
+		  STRONG_ORDER, (ffs(DMAMEM_SZ_ALL) - 2) },
+	};
+
+	/*
+	 * Configure the memory protection unit (MPU) to allow full access to
+	 * the whole 4GB address space.
+	 */
+	disable_mpu();
+	for (i = 0; i < ARRAY_SIZE(imxrt1050_region_config); i++)
+		mpu_config(&imxrt1050_region_config[i]);
+	enable_mpu();
+
+	return 0;
+}
Signature · 1 line
2.20.1
#4 lore raw

PATCH 20/20 imx: imxrt1050-evk: Add support for the NXP i.MXRT1050-EVK

In reply to Giulio Benetti

This commit adds board support for i.MXRT1050-EVK from NXP. This board is an evaluation kit provided by NXP for i.MXRT105x processor family.

More information about this board can be found here:
https://www.nxp.com/design/development-boards/i.mx-evaluation-and-development-boards/i.mx-rt1050-evaluation-kit:MIMXRT1050-EVK

The initial supported/tested devices include:
- Debug serial
- SD

---
 arch/arm/dts/Makefile                         |   2 +
 arch/arm/dts/imxrt1050-evk.dts                | 209 ++++++++++++++++++
 board/freescale/imxrt1050-evk/Kconfig         |  22 ++
 board/freescale/imxrt1050-evk/MAINTAINERS     |   6 +
 board/freescale/imxrt1050-evk/Makefile        |   6 +
 board/freescale/imxrt1050-evk/README          |  31 +++
 board/freescale/imxrt1050-evk/imximage.cfg    |  36 +++
 board/freescale/imxrt1050-evk/imxrt1050-evk.c |  81 +++++++
 configs/imxrt1050-evk_defconfig               |  74 +++++++
 include/configs/imxrt1050-evk.h               |  59 +++++
 10 files changed, 526 insertions(+)
 create mode 100644 arch/arm/dts/imxrt1050-evk.dts
 create mode 100644 board/freescale/imxrt1050-evk/Kconfig
 create mode 100644 board/freescale/imxrt1050-evk/MAINTAINERS
 create mode 100644 board/freescale/imxrt1050-evk/Makefile
 create mode 100644 board/freescale/imxrt1050-evk/README
 create mode 100644 board/freescale/imxrt1050-evk/imximage.cfg
 create mode 100644 board/freescale/imxrt1050-evk/imxrt1050-evk.c
 create mode 100644 configs/imxrt1050-evk_defconfig
 create mode 100644 include/configs/imxrt1050-evk.h
arch/arm/dts/Makefile +2 -0
index 3dc9c4d41c..1cba8809f2 100644
@@ -672,6 +672,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
 	imx8mn-ddr4-evk.dtb \
 	imx8mq-evk.dtb
 
+dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb
+
 dtb-$(CONFIG_RCAR_GEN2) += \
 	r8a7790-lager-u-boot.dtb \
 	r8a7790-stout-u-boot.dtb \
arch/arm/dts/imxrt1050-evk.dts new file +209 -0

209 lines not on this page · raw message

board/freescale/imxrt1050-evk/Kconfig new file +22 -0
new file mode 100644
index 0000000000..79e6e4524a
@@ -0,0 +1,22 @@
+if TARGET_IMXRT1050_EVK
+
+config SYS_BOARD
+	string
+	default "imxrt1050-evk"
+
+config SYS_VENDOR
+	string
+	default "freescale"
+
+config SYS_SOC
+	string
+	default "imxrt1050"
+
+config SYS_CONFIG_NAME
+	string
+	default "imxrt1050-evk"
+
+config IMX_CONFIG
+	default "board/freescale/imxrt1050-evk/imximage.cfg"
+
+endif
board/freescale/imxrt1050-evk/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..a872855452
@@ -0,0 +1,6 @@
+IMXRT1050 EVALUATION KIT
+M:	Giulio Benetti <[email protected]>
+S:	Maintained
+F:	board/freescale/imxrt1050-evk
+F:	include/configs/imxrt1050-evk.h
+F:	configs/imxrt1050-evk_defconfig
board/freescale/imxrt1050-evk/Makefile new file +6 -0
new file mode 100644
index 0000000000..0e984d1d7a
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2019
+# Author(s): Giulio Benetti <[email protected]>
+
+obj-y	:= imxrt1050-evk.o
board/freescale/imxrt1050-evk/README new file +31 -0
new file mode 100644
index 0000000000..f7e2894025
@@ -0,0 +1,31 @@
+How to use U-Boot on NXP i.MXRT1050 EVK
+-----------------------------------------------
+
+- Build U-Boot for i.MXRT1050 EVK:
+
+$ make mrproper
+$ make imxrt1050-evk_defconfig
+$ make
+
+This will generate the SPL image called SPL and the u-boot.img.
+
+- Flash the SPL image into the micro SD card:
+
+sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+
+- Flash the u-boot.img image into the micro SD card:
+
+sudo dd if=u-boot.img of=/dev/sdb bs=1k seek=128; sync
+
+- Jumper settings:
+
+SW7: 1 0 1 0
+
+where 0 means bottom position and 1 means top position (from the
+switch label numbers reference).
+
+- Connect the USB cable between the EVK and the PC for the console.
+(The USB console connector is the one close the ethernet connector)
+
+- Insert the micro SD card in the board, power it up and U-Boot messages should
+come up.
board/freescale/imxrt1050-evk/imximage.cfg new file +36 -0
new file mode 100644
index 0000000000..cf1665be61
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019
+ * Author(s): Giulio Benetti <[email protected]>
+ */
+
+#define __ASSEMBLY__
+#include <config.h>
+
+/* image version */
+
+IMAGE_VERSION 2
+
+/*
+ * Boot Device : one of
+ * spi/sd/nand/onenand, qspi/nor
+ */
+
+BOOT_FROM	sd
+
+/*
+ * Device Configuration Data (DCD)
+ *
+ * Each entry must have the format:
+ * Addr-type           Address        Value
+ *
+ * where:
+ *	Addr-type register length (1,2 or 4 bytes)
+ *	Address	  absolute address of the register
+ *	value	  value to be stored in the register
+ */
+
+/* Set all FlexRAM as OCRAM(01b) */
+DATA 4 0x400AC044 0x55555555
+/* Use FLEXRAM_BANK_CFG to config FlexRAM */
+SET_BIT 4 0x400AC040 0x4
board/freescale/imxrt1050-evk/imxrt1050-evk.c new file +81 -0

81 lines not on this page · raw message

configs/imxrt1050-evk_defconfig new file +74 -0

74 lines not on this page · raw message

include/configs/imxrt1050-evk.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.20.1