Skip to contentSkip to conversation

ARM: AM43xx: Update support for AM4372 SoC

PATCH Superseded Lokesh Vutla 3 participants 48 messages Nov 21, 2013 – Dec 4, 2013 Arm (32-bit)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ARM: AM43xx: Update support for AM4372 SoC

This Patch series updates support for AM4372 EPOS and GP EVM boards. AM4372 is a low cost Cortex-A9 based application processor targeted at existing ARM9/ARM11 base of customers that need more processing capabilities. Currently there are two boards with AM4372 SoC: EPOS and GP EVM. Except for few differences like oscillator clock and SDRAM both EPOS and GP EVM boards are similar.
EPOS EVM:

	OSC clk	: 25MHz
	DDR	: LPDDR2 @ 266MHz (MT42L256M32D2LG-25 WT:A)
GP EVM:
	OSC clk	: 24MHz
	DDR	: DDR3 @ 400MHz(MT41K512M8RH)

This patch series is applied on top of Mainline U-Boot Tree and two patches mentioned below:
git://git.denx.de/u-boot.git master
http://patchwork.ozlabs.org/patch/288175/

Testing:
-> Boot tested on AM4372 EPOS and GP EVMs, Beaglebone Black. -> verified MAKEALL -s am33xx.
-> Ran checkpatch on all patches.

Changes Since V1:
As per Vaibhav's and Tom's Comments:
-> Updated the mux data not to use DSPULLUDEN.
-> Reused the emif4d file for configuring emif4d5 registers. -> Updated the code with comments.
-> Rebased on top of Current U-Boot mainline.

Lokesh Vutla (12):
ARM: AM43xx: Update the base addresses of modules
ARM: AM43xx: Adapt to ti_armv7_common.h config file
ARM: AM43xx: Add L2 Support
ARM: AM43xx: Add extra ENV settings
ARM: AM43xx: Select clk source for Timer2
ARM: AM43xx: Update Current Booting devices list
ARM: AM43xx: mux: Update mux data
ARM: AM43xx: clocks: Update DPLL details for EPOS EVM
ARM: AM43xx: clocks: Add DPLL data for GP EVM
ARM: AM43xx: EPOS_EVM: Add support for LPDDR2
ARM: AM43xx: GP_EVM: Add support for DDR3
ARM: AM43xx: Add Maintainer

Sekhar Nori (2):
ARM: AM43XX: board: add support for reading onboard EEPROM
ARM: AM43XX: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

 arch/arm/cpu/armv7/am33xx/clock.c                  |   12 +-
 arch/arm/cpu/armv7/am33xx/clock_am33xx.c           |   15 ++
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c           |   12 +-
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  149 ++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +-
 arch/arm/cpu/armv7/omap-common/emif-common.c       |   14 -
 arch/arm/include/asm/arch-am33xx/clock.h           |    7 +-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |   22 +-
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   41 ++-
 arch/arm/include/asm/arch-am33xx/hardware.h        |    7 -
 arch/arm/include/asm/arch-am33xx/hardware_am33xx.h |    2 +
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    3 +
 arch/arm/include/asm/arch-am33xx/hardware_ti814x.h |    2 +
 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h |    2 +
 arch/arm/include/asm/arch-am33xx/mux_am43xx.h      |   45 ++++
 arch/arm/include/asm/arch-am33xx/omap.h            |    2 +
 arch/arm/include/asm/arch-am33xx/spl.h             |   12 +-
 arch/arm/include/asm/emif.h                        |   26 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 ++-
 board/ti/am43xx/board.c                            |  271 +++++++++++++++++++-
 board/ti/am43xx/board.h                            |   33 +++
 board/ti/am43xx/mux.c                              |   35 ++-
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 boards.cfg                                         |    2 +-
 include/configs/am43xx_evm.h                       |  204 +++++++--------
 32 files changed, 874 insertions(+), 180 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/14 ARM: AM43xx: Update the base addresses of modules

PRCM, timer base addresses and offsets are different from AM33xx. Updating the same.

---
 arch/arm/include/asm/arch-am33xx/cpu.h             |   17 +++++++++++------
 arch/arm/include/asm/arch-am33xx/hardware.h        |    7 -------
 arch/arm/include/asm/arch-am33xx/hardware_am33xx.h |    2 ++
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    2 ++
 arch/arm/include/asm/arch-am33xx/hardware_ti814x.h |    2 ++
 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h |    2 ++
 6 files changed, 19 insertions(+), 13 deletions(-)
arch/arm/include/asm/arch-am33xx/cpu.h +11 -6
index 05752ce..19b8469 100644
@@ -237,6 +237,14 @@ struct cm_perpll {
 	unsigned int cpswclkstctrl;	/* offset 0x144 */
 	unsigned int lcdcclkstctrl;	/* offset 0x148 */
 };
+
+/* Encapsulating Display pll registers */
+struct cm_dpll {
+	unsigned int resv1[2];
+	unsigned int clktimer2clk;	/* offset 0x08 */
+	unsigned int resv2[10];
+	unsigned int clklcdcpixelclk;	/* offset 0x34 */
+};
 #else
 /* Encapsulating core pll registers */
 struct cm_wkuppll {
@@ -392,15 +400,12 @@ struct cm_perpll {
 	unsigned int resv40[7];
 	unsigned int cpgmac0clkctrl;	/* offset 0xB20 */
 };
-#endif /* CONFIG_AM43XX */
 
-/* Encapsulating Display pll registers */
 struct cm_dpll {
-	unsigned int resv1[2];
-	unsigned int clktimer2clk;	/* offset 0x08 */
-	unsigned int resv2[10];
-	unsigned int clklcdcpixelclk;	/* offset 0x34 */
+	unsigned int resv1;
+	unsigned int clktimer2clk;	/* offset 0x04 */
 };
+#endif /* CONFIG_AM43XX */
 
 /* Control Module RTC registers */
 struct cm_rtc {
arch/arm/include/asm/arch-am33xx/hardware.h +0 -7
index ee5fce0..dd950e5 100644
@@ -48,13 +48,6 @@
 #define EMIF4_0_CFG_BASE		0x4C000000
 #define EMIF4_1_CFG_BASE		0x4D000000
 
-/* PLL related registers */
-#define CM_DPLL				0x44E00500
-#define CM_DEVICE			0x44E00700
-#define CM_RTC				0x44E00800
-#define CM_CEFUSE			0x44E00A00
-#define PRM_DEVICE			0x44E00F00
-
 /* DDR Base address */
 #define DDR_CTRL_ADDR			0x44E10E04
 #define DDR_CONTROL_BASE_ADDR		0x44E11404
arch/arm/include/asm/arch-am33xx/hardware_am33xx.h +2 -0
index e4231c8..c67a080 100644
@@ -30,6 +30,8 @@
 #define PRCM_BASE			0x44E00000
 #define CM_PER				0x44E00000
 #define CM_WKUP				0x44E00400
+#define CM_DPLL				0x44E00500
+#define CM_RTC				0x44E00800
 
 #define PRM_RSTCTRL			(PRCM_BASE + 0x0F00)
 #define PRM_RSTST			(PRM_RSTCTRL + 8)
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +2 -0
index 3b665e6..64f9c99 100644
@@ -30,6 +30,8 @@
 #define PRCM_BASE			0x44DF0000
 #define	CM_WKUP				0x44DF2800
 #define	CM_PER				0x44DF8800
+#define CM_DPLL				0x44DF4200
+#define CM_RTC				0x44df8500
 
 #define PRM_RSTCTRL			(PRCM_BASE + 0x4000)
 #define PRM_RSTST			(PRM_RSTCTRL + 4)
arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +2 -0
index 4509a23..9080b6f 100644
@@ -27,6 +27,8 @@
 #define PRCM_BASE			0x48180000
 #define CM_PER				0x44E00000
 #define CM_WKUP				0x44E00400
+#define CM_DPLL				0x44E00500
+#define CM_RTC				0x44E00800
 
 #define PRM_RSTCTRL			(PRCM_BASE + 0x00A0)
 #define PRM_RSTST			(PRM_RSTCTRL + 8)
arch/arm/include/asm/arch-am33xx/hardware_ti816x.h +2 -0
index 3c68064..0f6a016 100644
@@ -34,6 +34,8 @@
 
 /* PRCM Base Address */
 #define PRCM_BASE		0x48180000
+#define CM_DPLL				0x44E00500
+#define CM_RTC				0x44E00800
 
 #define PRM_RSTCTRL		(PRCM_BASE + 0x00A0)
 #define PRM_RSTST		(PRM_RSTCTRL + 8)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 1/14 ARM: AM43xx: Update the base addresses of modules

Hi Lokesh,

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

arch/arm/include/asm/arch-am33xx/hardware_am43xx.h line 34

Quoted 3 lines
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +2 -0
+#define CM_DPLL                                0x44DF4200
+#define CM_RTC                         0x44df8500

nit: CM_RTC address should be in caps for the sake of consistency

arch/arm/include/asm/arch-am33xx/hardware_ti814x.h line 32

Quoted 13 lines

#define PRM_RSTCTRL (PRCM_BASE + 0x4000)
#define PRM_RSTST (PRM_RSTCTRL + 4)

arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +2 -0
index 4509a23..9080b6f 100644
@@ -27,6 +27,8 @@
 #define PRCM_BASE                      0x48180000
 #define CM_PER                         0x44E00000
 #define CM_WKUP                                0x44E00400
+#define CM_DPLL                                0x44E00500
+#define CM_RTC                         0x44E00800
 

Looking at these address i strongly suspect the CM_XXX ones are wrong for the TI81xx
family. Does this really match with the TRM?

Regards,
Vaibhav

#3 lore raw

PATCH v2 1/14 ARM: AM43xx: Update the base addresses of modules

Quoted 9 lines · Vaibhav Bedia

Hi Lokesh,

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

arch/arm/include/asm/arch-am33xx/hardware_am43xx.h line 34

Quoted 3 lines
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +2 -0
+#define CM_DPLL                                0x44DF4200
+#define CM_RTC                         0x44df8500

nit: CM_RTC address should be in caps for the sake of consistency

OK ll change it.

Quoted 10 lines
Quoted 10 lines

#define PRM_RSTCTRL (PRCM_BASE + 0x4000)
#define PRM_RSTST (PRM_RSTCTRL + 4)

arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +0 -0
index 4509a23..9080b6f 100644
@@ -27,6 +27,8 @@
 #define PRCM_BASE                      0x48180000
 #define CM_PER                         0x44E00000
Quoted 8 lines

arch/arm/include/asm/arch-am33xx/hardware_ti814x.h line 32

Quoted 4 lines
arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +2 -0
 #define CM_WKUP                                0x44E00400
+#define CM_DPLL                                0x44E00500
+#define CM_RTC                         0x44E00800
 

Looking at these address i strongly suspect the CM_XXX ones are wrong for the TI81xx
family. Does this really match with the TRM?

Yes, you are correct. TI814x code doesn't use these defines at all. Ill drop these.

Thanks
Lokesh

Quoted 4 lines

Regards,
Vaibhav

#4 lore raw

PATCH v2 2/14 ARM: AM43xx: Adapt to ti_armv7_common.h config file

In reply to Lokesh Vutla

Use ti_armv7_common.h config file to inclde the common configs.

---
 board/ti/am43xx/board.c      |    2 +-
 include/configs/am43xx_evm.h |  129 +++++++++---------------------------------
 2 files changed, 28 insertions(+), 103 deletions(-)
board/ti/am43xx/board.c +1 -1
index 51b2576..dcd8cbb 100644
@@ -44,7 +44,7 @@ void sdram_init(void)
 
 int board_init(void)
 {
-	gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
+	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
 	return 0;
 }
include/configs/am43xx_evm.h +27 -102

154 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v2 3/14 ARM: AM43xx: Add L2 Support

In reply to Lokesh Vutla

AM4372 uses PL310 L2 Cache. Enable the configs for the same.

---
 include/configs/am43xx_evm.h |    5 +++++
 1 file changed, 5 insertions(+)
include/configs/am43xx_evm.h +5 -0
index 4815357..b0269a7 100644
@@ -30,6 +30,11 @@
 #define CONFIG_SPL_MAX_SIZE		(0x4030C000 - CONFIG_SPL_TEXT_BASE)
 #define CONFIG_SPL_YMODEM_SUPPORT
 
+/* Enabling L2 Cache */
+#define CONFIG_SYS_L2_PL310
+#define CONFIG_SYS_PL310_BASE	0x48242000
+#define CONFIG_SYS_CACHELINE_SIZE	32
+
 /*
  * Since SPL did pll and ddr initialization for us,
  * we don't need to do it twice.
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v2 4/14 ARM: AM43xx: Add extra ENV settings

In reply to Lokesh Vutla

Add Extra env settings.
This is derived from am335x Extra ENV settings.

---
 include/configs/am43xx_evm.h |   63 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
include/configs/am43xx_evm.h +63 -0
index b0269a7..6693321 100644
@@ -72,4 +72,67 @@
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_AM437X_USB2PHY2_HOST
 
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x80200000\0" \
+	"fdtaddr=0x80F80000\0" \
+	"fdt_high=0xffffffff\0" \
+	"rdaddr=0x81000000\0" \
+	"fdtfile=undefined\0" \
+	"bootpart=0:2\0" \
+	"bootdir=/boot\0" \
+	"bootfile=zImage\0" \
+	"console=ttyO0,115200n8\0" \
+	"optargs=\0" \
+	"mmcdev=0\0" \
+	"mmcroot=/dev/mmcblk0p2 rw\0" \
+	"mmcrootfstype=ext4 rootwait\0" \
+	"ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=${rdaddr},64M\0" \
+	"ramrootfstype=ext2\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+		"${optargs} " \
+		"root=${mmcroot} " \
+		"rootfstype=${mmcrootfstype}\0" \
+	"bootenv=uEnv.txt\0" \
+	"loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
+	"importbootenv=echo Importing environment from mmc ...; " \
+		"env import -t $loadaddr $filesize\0" \
+	"ramargs=setenv bootargs console=${console} " \
+		"${optargs} " \
+		"root=${ramroot} " \
+		"rootfstype=${ramrootfstype}\0" \
+	"loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
+	"loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
+	"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
+	"mmcboot=mmc dev ${mmcdev}; " \
+		"if mmc rescan; then " \
+			"echo SD/MMC found on device ${mmcdev};" \
+			"if run loadbootenv; then " \
+				"echo Loaded environment from ${bootenv};" \
+				"run importbootenv;" \
+			"fi;" \
+			"if test -n $uenvcmd; then " \
+				"echo Running uenvcmd ...;" \
+				"run uenvcmd;" \
+			"fi;" \
+			"if run loadimage; then " \
+				"run loadfdt; " \
+				"echo Booting from mmc${mmcdev} ...; " \
+				"run mmcargs; " \
+				"bootz ${loadaddr} - ${fdtaddr}; " \
+			"fi;" \
+		"fi;\0" \
+	"findfdt="\
+		"if test $board_name = AM43EPOS; then " \
+			"setenv fdtfile am43x-epos-evm.dtb; fi; " \
+		"if test $board_name = AM43__GP; then " \
+			"setenv fdtfile am437x-gp-evm.dtb; fi; " \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree; fi; \0"
+
+#define CONFIG_BOOTCOMMAND \
+	"run findfdt; " \
+	"run mmcboot;"
+
+#endif
 #endif	/* __CONFIG_AM43XX_EVM_H */
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v2 5/14 ARM: AM43XX: board: add support for reading onboard EEPROM

In reply to Lokesh Vutla

From: Sekhar Nori <[email protected]>

Add support for reading onboard EEPROM to enable
board detection.

---
 arch/arm/include/asm/arch-am33xx/omap.h |    2 ++
 board/ti/am43xx/board.c                 |   46 +++++++++++++++++++++++++++++++
 board/ti/am43xx/board.h                 |   32 +++++++++++++++++++++
 include/configs/am43xx_evm.h            |    7 +++++
 4 files changed, 87 insertions(+)
arch/arm/include/asm/arch-am33xx/omap.h +2 -0
index 2250721..10f05c9 100644
@@ -27,5 +27,7 @@
 #define NON_SECURE_SRAM_START	0x402F0400
 #define NON_SECURE_SRAM_END	0x40340000
 #define SRAM_SCRATCH_SPACE_ADDR	0x4033C000
+#define AM4372_BOARD_NAME_START	SRAM_SCRATCH_SPACE_ADDR
+#define AM4372_BOARD_NAME_END	SRAM_SCRATCH_SPACE_ADDR + 0xC
 #endif
 #endif
board/ti/am43xx/board.c +46 -0

58 lines not on this page · raw message

board/ti/am43xx/board.h +32 -0
index 8ca098b..9268895 100644
@@ -12,6 +12,38 @@
 #ifndef _BOARD_H_
 #define _BOARD_H_
 
+#include <asm/arch/omap.h>
+
+static char *const am43xx_board_name = (char *)AM4372_BOARD_NAME_START;
+
+/*
+ * TI AM437x EVMs define a system EEPROM that defines certain sub-fields.
+ * We use these fields to in turn see what board we are on, and what
+ * that might require us to set or not set.
+ */
+#define HDR_NO_OF_MAC_ADDR	3
+#define HDR_ETH_ALEN		6
+#define HDR_NAME_LEN		8
+
+struct am43xx_board_id {
+	unsigned int  magic;
+	char name[HDR_NAME_LEN];
+	char version[4];
+	char serial[12];
+	char config[32];
+	char mac_addr[HDR_NO_OF_MAC_ADDR][HDR_ETH_ALEN];
+};
+
+static inline int board_is_eposevm(void)
+{
+	return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
+}
+
+static inline int board_is_gpevm(void)
+{
+	return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN);
+}
+
 void enable_uart0_pin_mux(void);
 void enable_board_pin_mux(void);
 #endif
include/configs/am43xx_evm.h +7 -0
index 6693321..7810c59 100644
@@ -25,6 +25,13 @@
 #define CONFIG_SYS_NS16550_REG_SIZE	(-4)
 #define CONFIG_SYS_NS16550_CLK		48000000
 
+/* I2C Configuration */
+#define CONFIG_CMD_EEPROM
+#define CONFIG_ENV_EEPROM_IS_ON_I2C
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
+#define CONFIG_SYS_I2C_MULTI_EEPROMS
+
 /* SPL defines. */
 #define CONFIG_SPL_TEXT_BASE		0x40300350
 #define CONFIG_SPL_MAX_SIZE		(0x4030C000 - CONFIG_SPL_TEXT_BASE)
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v2 5/14 ARM: AM43XX: board: add support for reading onboard EEPROM

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

arch/arm/include/asm/arch-am33xx/omap.h line 31

Quoted 5 lines

#define NON_SECURE_SRAM_START 0x402F0400
#define NON_SECURE_SRAM_END 0x40340000
#define SRAM_SCRATCH_SPACE_ADDR 0x4033C000

arch/arm/include/asm/arch-am33xx/omap.h +2 -0
+#define AM4372_BOARD_NAME_START        SRAM_SCRATCH_SPACE_ADDR
+#define AM4372_BOARD_NAME_END  SRAM_SCRATCH_SPACE_ADDR + 0xC

Why do you need to keep the struct address hardcoded like this?

[...]

board/ti/am43xx/board.h line 46

Quoted 10 lines
board/ti/am43xx/board.h +10 -0
+static inline int board_is_eposevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
+}
+
+static inline int board_is_gpevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN);
+}
+

Looks like you got the EEPROM content updated ;)

Regards,
Vaibhav

#9 lore raw

PATCH v2 5/14 ARM: AM43XX: board: add support for reading onboard EEPROM

Quoted 9 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

arch/arm/include/asm/arch-am33xx/omap.h line 31

Quoted 5 lines

#define NON_SECURE_SRAM_START 0x402F0400
#define NON_SECURE_SRAM_END 0x40340000
#define SRAM_SCRATCH_SPACE_ADDR 0x4033C000

arch/arm/include/asm/arch-am33xx/omap.h +2 -0
+#define AM4372_BOARD_NAME_START        SRAM_SCRATCH_SPACE_ADDR
+#define AM4372_BOARD_NAME_END  SRAM_SCRATCH_SPACE_ADDR + 0xC

Why do you need to keep the struct address hardcoded like this?

FYI, this is not struct address. This is the place where where I am storing board name. This helps in detecting the board.
It ll be good to understand the code properly and comment.

Quoted 14 lines

[...]

board/ti/am43xx/board.h line 46

Quoted 10 lines
board/ti/am43xx/board.h +10 -0
+static inline int board_is_eposevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
+}
+
+static inline int board_is_gpevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN);
+}
+

Looks like you got the EEPROM content updated ;)

There is nothing updated. This is what I have used previously. Please recollect your comments properly.

Thanks and regards,
Lokesh

Quoted 4 lines

Regards,
Vaibhav

#10 lore raw

PATCH v2 5/14 ARM: AM43XX: board: add support for reading onboard EEPROM

Quoted 10 lines · Lokesh Vutla
Quoted 9 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

arch/arm/include/asm/arch-am33xx/omap.h line 31

Quoted 5 lines

#define NON_SECURE_SRAM_START 0x402F0400
#define NON_SECURE_SRAM_END 0x40340000
#define SRAM_SCRATCH_SPACE_ADDR 0x4033C000

arch/arm/include/asm/arch-am33xx/omap.h +2 -0
+#define AM4372_BOARD_NAME_START        SRAM_SCRATCH_SPACE_ADDR
+#define AM4372_BOARD_NAME_END  SRAM_SCRATCH_SPACE_ADDR + 0xC

Why do you need to keep the struct address hardcoded like this?

Quoted 3 lines

FYI, this is not struct address. This is the place where where I am storing board name. This helps in detecting the board.
It ll be good to understand the code properly and comment.

My bad. Should have looked closer.

Quoted 14 lines
Quoted 14 lines

[...]

board/ti/am43xx/board.h line 46

Quoted 10 lines
board/ti/am43xx/board.h +10 -0
+static inline int board_is_eposevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
+}
+
+static inline int board_is_gpevm(void)
+{
+       return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN);
+}
+

Looks like you got the EEPROM content updated ;)

Quoted 3 lines

There is nothing updated. This is what I have used previously. Please recollect your comments properly.

Well it would help if you added in a more detailed changelog for the different variants of the patches highlighting what's changed and if some comment is being ignored the reason for the same.

Regards,
Vaibhav

#11 lore raw

PATCH v2 6/14 ARM: AM43XX: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

In reply to Lokesh Vutla

From: Sekhar Nori <[email protected]>

CONFIG_ENV_VARS_UBOOT_CONFIG, CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG and CONFIG_BOARD_LATE_INIT is already set. Adding support to detect the board. These variables are used by findfdt.

---
 board/ti/am43xx/board.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
board/ti/am43xx/board.c +16 -0
index 4fc1a40..723d0ca 100644
@@ -98,6 +98,22 @@ int board_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+	char safe_string[HDR_NAME_LEN + 1];
+	struct am43xx_board_id header;
+
+	if (read_eeprom(&header) < 0)
+		puts("Could not get board ID.\n");
+
+	/* Now set variables based on the header. */
+	strncpy(safe_string, (char *)header.name, sizeof(header.name));
+	safe_string[sizeof(header.name)] = 0;
+	setenv("board_name", safe_string);
+
+	strncpy(safe_string, (char *)header.version, sizeof(header.version));
+	safe_string[sizeof(header.version)] = 0;
+	setenv("board_rev", safe_string);
+#endif
 	return 0;
 }
 #endif
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v2 6/14 ARM: AM43XX: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

board/ti/am43xx/board.c int board_init(void) · line 106

Quoted 6 lines
board/ti/am43xx/board.c +6 -0
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       char safe_string[HDR_NAME_LEN + 1];
+       struct am43xx_board_id header;
+
+       if (read_eeprom(&header) < 0)
+               puts("Could not get board ID.\n");

Hmm... didn't the previous patch read the EEPROM?

#13 lore raw

PATCH v2 6/14 ARM: AM43XX: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

Quoted 10 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

board/ti/am43xx/board.c int board_init(void) · line 106

Quoted 6 lines
board/ti/am43xx/board.c +6 -0
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       char safe_string[HDR_NAME_LEN + 1];
+       struct am43xx_board_id header;
+
+       if (read_eeprom(&header) < 0)
+               puts("Could not get board ID.\n");

Hmm... didn't the previous patch read the EEPROM?

This is as per suggested by Tom. If I populate a common structure it ll bread NOR boot. I hope you understand what happens in NOR boot.

Thanks
Lokesh

Quoted 1 line
#14 lore raw

PATCH v2 6/14 ARM: AM43XX: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

Quoted 11 lines · Lokesh Vutla
Quoted 10 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

board/ti/am43xx/board.c int board_init(void) · line 106

Quoted 6 lines
board/ti/am43xx/board.c +6 -0
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       char safe_string[HDR_NAME_LEN + 1];
+       struct am43xx_board_id header;
+
+       if (read_eeprom(&header) < 0)
+               puts("Could not get board ID.\n");

Hmm... didn't the previous patch read the EEPROM?

Quoted 3 lines

This is as per suggested by Tom. If I populate a common structure it ll bread NOR boot. I hope you understand what happens in NOR boot.

Care to explain how this particular snippet relates to NOR boot?

#15 lore raw

PATCH v2 7/14 ARM: AM43xx: Select clk source for Timer2

In reply to Lokesh Vutla

Selecting the Master osc clk as Timer2 clock source.

---
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +4 -0
index c4890f2..22963b7 100644
@@ -18,6 +18,7 @@
 
 struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
 struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
+struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL;
 
 const struct dpll_regs dpll_mpu_regs = {
 	.cm_clkmode_dpll	= CM_WKUP + 0x560,
@@ -107,4 +108,7 @@ void enable_basic_clocks(void)
 	};
 
 	do_enable_clocks(clk_domains, clk_modules_explicit_en, 1);
+
+	/* Select the Master osc clk as Timer2 clock source */
+	writel(0x1, &cmdpll->clktimer2clk);
 }
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH v2 7/14 ARM: AM43xx: Select clk source for Timer2

Quoted 20 lines · Lokesh Vutla

Selecting the Master osc clk as Timer2 clock source.

---
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -0
index c4890f2..22963b7 100644
@@ -18,6 +18,7 @@
 
 struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
 struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
+struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL;
 
 const struct dpll_regs dpll_mpu_regs = {
        .cm_clkmode_dpll        = CM_WKUP + 0x560,

arch/arm/cpu/armv7/am33xx/clock_am43xx.c void enable_basic_clocks(void) · line 113

Quoted 6 lines
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +3 -0
@@ -107,4 +108,7 @@ void enable_basic_clocks(void)
        };
 
        do_enable_clocks(clk_domains, clk_modules_explicit_en, 1);
+
+       /* Select the Master osc clk as Timer2 clock source */
+       writel(0x1, &cmdpll->clktimer2clk);

I really don't see a point of copying whatever AM335x does. You should have a good reason for not using the other timers :P

#17 lore raw

PATCH v2 7/14 ARM: AM43xx: Select clk source for Timer2

Quoted 23 lines · Vaibhav Bedia
Quoted 22 lines · Lokesh Vutla

Selecting the Master osc clk as Timer2 clock source.

---
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -0
index c4890f2..22963b7 100644
@@ -18,6 +18,7 @@
 
 struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
 struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
+struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL;
 
 const struct dpll_regs dpll_mpu_regs = {
        .cm_clkmode_dpll        = CM_WKUP + 0x560,
@@ -107,4 +108,7 @@ void enable_basic_clocks(void)
        };
 
Quoted 7 lines

arch/arm/cpu/armv7/am33xx/clock_am43xx.c void enable_basic_clocks(void) · line 113

Quoted 4 lines
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +3 -0
        do_enable_clocks(clk_domains, clk_modules_explicit_en, 1);
+
+       /* Select the Master osc clk as Timer2 clock source */
+       writel(0x1, &cmdpll->clktimer2clk);

I really don't see a point of copying whatever AM335x does. You should have a good reason for not using the other timers :P

Again nothing is copied here, I am reusing the code what ever is present. I don't have any restrictions to choose any timer here. All OMAPs and AM uses timer 2 and I used it. I have already told you why I can't use timer1.

First please give me a *valid reason* why I should not use timer2, then Ill think of using other timer. As per my understanding there is nothing wrong to reuse what ever is present.
Please be specific when you are commenting.

Thanks
Lokesh

Quoted 1 line
#18 lore raw

PATCH v2 7/14 ARM: AM43xx: Select clk source for Timer2

Quoted 31 lines · Lokesh Vutla
Quoted 23 lines · Vaibhav Bedia
Quoted 22 lines · Lokesh Vutla

Selecting the Master osc clk as Timer2 clock source.

---
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -0
index c4890f2..22963b7 100644
@@ -18,6 +18,7 @@
 
 struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
 struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
+struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL;
 
 const struct dpll_regs dpll_mpu_regs = {
        .cm_clkmode_dpll        = CM_WKUP + 0x560,
@@ -107,4 +108,7 @@ void enable_basic_clocks(void)
        };
 
Quoted 7 lines

arch/arm/cpu/armv7/am33xx/clock_am43xx.c void enable_basic_clocks(void) · line 113

Quoted 4 lines
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +3 -0
        do_enable_clocks(clk_domains, clk_modules_explicit_en, 1);
+
+       /* Select the Master osc clk as Timer2 clock source */
+       writel(0x1, &cmdpll->clktimer2clk);

I really don't see a point of copying whatever AM335x does. You should have a good reason for not using the other timers :P

Quoted 4 lines

Again nothing is copied here, I am reusing the code what ever is present. I don't have any restrictions to choose any timer here. All OMAPs and AM uses timer 2 and I used it. I have already told you why I can't use timer1.

If by that you are referring to your reasoning that there's a base address that's already
there and hence let's reuse it, then yes you did.

Quoted 4 lines

First please give me a *valid reason* why I should not use timer2, then Ill think of using other timer. As per my understanding there is nothing wrong to reuse what ever is present.
Please be specific when you are commenting.

And the reuse without rethink is exactly how over a period of time we end up with choices in s/w that no one can recollect.... have it your way :)

Regards,
Vaibhav

#19 lore raw

PATCH v2 8/14 ARM: AM43xx: Update Current Booting devices list

In reply to Lokesh Vutla

Current Booting devices list is different from that of AM33xx. Updating the same.

---
 arch/arm/include/asm/arch-am33xx/spl.h |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-am33xx/spl.h +9 -3
index 95de9aa..82116a9 100644
@@ -13,11 +13,17 @@
 #define BOOT_DEVICE_MMC1	6
 #define BOOT_DEVICE_MMC2	5
 #define BOOT_DEVICE_UART	0x43
-#define BOOT_DEVICE_MMC2_2	0xFF
+#elif defined(CONFIG_AM43XX)
+#define BOOT_DEVICE_NOR		1
+#define BOOT_DEVICE_NAND	5
+#define BOOT_DEVICE_MMC1	7
+#define BOOT_DEVICE_MMC2	8
+#define BOOT_DEVICE_SPI		10
+#define BOOT_DEVICE_UART	65
 #else
 #define BOOT_DEVICE_XIP       	2
 #define BOOT_DEVICE_NAND	5
-#if defined(CONFIG_AM33XX) || defined(CONFIG_AM43XX)
+#if defined(CONFIG_AM33XX)
 #define BOOT_DEVICE_MMC1	8
 #define BOOT_DEVICE_MMC2	9	/* eMMC or daughter card */
 #elif defined(CONFIG_TI814X)
@@ -28,8 +34,8 @@
 #define BOOT_DEVICE_UART	65
 #define BOOT_DEVICE_USBETH	68
 #define BOOT_DEVICE_CPGMAC	70
-#define BOOT_DEVICE_MMC2_2      0xFF
 #endif
+#define BOOT_DEVICE_MMC2_2      0xFF
 
 #if defined(CONFIG_AM33XX) || defined(CONFIG_AM43XX)
 #define MMC_BOOT_DEVICES_START	BOOT_DEVICE_MMC1
Signature · 1 line
1.7.9.5
#20 lore raw

PATCH v2 9/14 ARM: AM43xx: mux: Update mux data

In reply to Lokesh Vutla

Updating the mux data for UART, adding data for i2c0 and mmc. And also updating pad_signals structure.

---
 arch/arm/include/asm/arch-am33xx/mux_am43xx.h |   45 +++++++++++++++++++++++++
 board/ti/am43xx/mux.c                         |   22 ++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +45 -0
index 0206912..98fc2b5 100644
@@ -137,6 +137,51 @@ struct pad_signals {
 	int mcasp0_fsr;
 	int mcasp0_axr1;
 	int mcasp0_ahclkx;
+	int xdma_event_intr0;
+	int xdma_event_intr1;
+	int nresetin_out;
+	int porz;
+	int nnmi;
+	int osc0_in;
+	int osc0_out;
+	int rsvd1;
+	int tms;
+	int tdi;
+	int tdo;
+	int tck;
+	int ntrst;
+	int emu0;
+	int emu1;
+	int osc1_in;
+	int osc1_out;
+	int pmic_power_en;
+	int rtc_porz;
+	int rsvd2;
+	int ext_wakeup;
+	int enz_kaldo_1p8v;
+	int usb0_dm;
+	int usb0_dp;
+	int usb0_ce;
+	int usb0_id;
+	int usb0_vbus;
+	int usb0_drvvbus;
+	int usb1_dm;
+	int usb1_dp;
+	int usb1_ce;
+	int usb1_id;
+	int usb1_vbus;
+	int usb1_drvvbus;
+	int ddr_resetn;
+	int ddr_csn0;
+	int ddr_cke;
+	int ddr_ck;
+	int ddr_nck;
+	int ddr_casn;
+	int ddr_rasn;
+	int ddr_wen;
+	int ddr_ba0;
+	int ddr_ba1;
+	int ddr_ba2;
 };
 
 #endif /* _MUX_AM43XX_H_ */
board/ti/am43xx/mux.c +20 -2
index 700e9a7..46bad01 100644
@@ -12,8 +12,24 @@
 #include "board.h"
 
 static struct module_pin_mux uart0_pin_mux[] = {
-	{OFFSET(uart0_rxd), (MODE(0) | RXACTIVE)},	/* UART0_RXD */
-	{OFFSET(uart0_txd), (MODE(0))},			/* UART0_TXD */
+	{OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
+	{OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
+	{-1},
+};
+
+static struct module_pin_mux mmc0_pin_mux[] = {
+	{OFFSET(mmc0_clk), (MODE(0) | PULLUDDIS | RXACTIVE)},  /* MMC0_CLK */
+	{OFFSET(mmc0_cmd), (MODE(0) | PULLUP_EN | RXACTIVE)},  /* MMC0_CMD */
+	{OFFSET(mmc0_dat0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT0 */
+	{OFFSET(mmc0_dat1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT1 */
+	{OFFSET(mmc0_dat2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT2 */
+	{OFFSET(mmc0_dat3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT3 */
+	{-1},
+};
+
+static struct module_pin_mux i2c0_pin_mux[] = {
+	{OFFSET(i2c0_sda), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
+	{OFFSET(i2c0_scl), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
 	{-1},
 };
 
@@ -24,4 +40,6 @@ void enable_uart0_pin_mux(void)
 
 void enable_board_pin_mux(void)
 {
+	configure_module_pin_mux(mmc0_pin_mux);
+	configure_module_pin_mux(i2c0_pin_mux);
 }
Signature · 1 line
1.7.9.5
#21 lore raw

PATCH v2 9/14 ARM: AM43xx: mux: Update mux data

Quoted 53 lines · Lokesh Vutla

Updating the mux data for UART, adding data for i2c0 and mmc. And also updating pad_signals structure.

---
 arch/arm/include/asm/arch-am33xx/mux_am43xx.h |   45 +++++++++++++++++++++++++
 board/ti/am43xx/mux.c                         |   22 ++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +36 -0
index 0206912..98fc2b5 100644
@@ -137,6 +137,51 @@ struct pad_signals {
        int mcasp0_fsr;
        int mcasp0_axr1;
        int mcasp0_ahclkx;
+       int xdma_event_intr0;
+       int xdma_event_intr1;
+       int nresetin_out;
+       int porz;
+       int nnmi;
+       int osc0_in;
+       int osc0_out;
+       int rsvd1;
+       int tms;
+       int tdi;
+       int tdo;
+       int tck;
+       int ntrst;
+       int emu0;
+       int emu1;
+       int osc1_in;
+       int osc1_out;
+       int pmic_power_en;
+       int rtc_porz;
+       int rsvd2;
+       int ext_wakeup;
+       int enz_kaldo_1p8v;
+       int usb0_dm;
+       int usb0_dp;
+       int usb0_ce;
+       int usb0_id;
+       int usb0_vbus;
+       int usb0_drvvbus;
+       int usb1_dm;
+       int usb1_dp;
+       int usb1_ce;
+       int usb1_id;
+       int usb1_vbus;
+       int usb1_drvvbus;
+       int ddr_resetn;
+       int ddr_csn0;

arch/arm/include/asm/arch-am33xx/mux_am43xx.h struct pad_signals { · line 185

Quoted 10 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +9 -0
+       int ddr_cke;
+       int ddr_ck;
+       int ddr_nck;
+       int ddr_casn;
+       int ddr_rasn;
+       int ddr_wen;
+       int ddr_ba0;
+       int ddr_ba1;
+       int ddr_ba2;
 };

IIRC not all the pads over here have any IO control. Some are analog pins and some like JTAG, PORz really shouldn't be meddled with if the h/w does expose some configuration. Please revisit this change.

Quoted 7 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +0 -0
 #endif /* _MUX_AM43XX_H_ */
board/ti/am43xx/mux.c +0 -0
index 700e9a7..46bad01 100644

board/ti/am43xx/mux.c line 17

Quoted 8 lines
board/ti/am43xx/mux.c +3 -2
@@ -12,8 +12,24 @@
 #include "board.h"
 
 static struct module_pin_mux uart0_pin_mux[] = {
-       {OFFSET(uart0_rxd), (MODE(0) | RXACTIVE)},      /* UART0_RXD */
-       {OFFSET(uart0_txd), (MODE(0))},                 /* UART0_TXD */
+       {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
+       {OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
+       {-1},

SLEWCTRL is typically not changed. You might want to double check this portion with the h/w folks.

Regards,
Vaibhav

#22 lore raw

PATCH v2 9/14 ARM: AM43xx: mux: Update mux data

Quoted 60 lines · Vaibhav Bedia
Quoted 59 lines · Lokesh Vutla

Updating the mux data for UART, adding data for i2c0 and mmc. And also updating pad_signals structure.

---
 arch/arm/include/asm/arch-am33xx/mux_am43xx.h |   45 +++++++++++++++++++++++++
 board/ti/am43xx/mux.c                         |   22 ++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +42 -0
index 0206912..98fc2b5 100644
@@ -137,6 +137,51 @@ struct pad_signals {
        int mcasp0_fsr;
        int mcasp0_axr1;
        int mcasp0_ahclkx;
+       int xdma_event_intr0;
+       int xdma_event_intr1;
+       int nresetin_out;
+       int porz;
+       int nnmi;
+       int osc0_in;
+       int osc0_out;
+       int rsvd1;
+       int tms;
+       int tdi;
+       int tdo;
+       int tck;
+       int ntrst;
+       int emu0;
+       int emu1;
+       int osc1_in;
+       int osc1_out;
+       int pmic_power_en;
+       int rtc_porz;
+       int rsvd2;
+       int ext_wakeup;
+       int enz_kaldo_1p8v;
+       int usb0_dm;
+       int usb0_dp;
+       int usb0_ce;
+       int usb0_id;
+       int usb0_vbus;
+       int usb0_drvvbus;
+       int usb1_dm;
+       int usb1_dp;
+       int usb1_ce;
+       int usb1_id;
+       int usb1_vbus;
+       int usb1_drvvbus;
+       int ddr_resetn;
+       int ddr_csn0;
+       int ddr_cke;
+       int ddr_ck;
+       int ddr_nck;
+       int ddr_casn;
+       int ddr_rasn;
+       int ddr_wen;
Quoted 8 lines

arch/arm/include/asm/arch-am33xx/mux_am43xx.h struct pad_signals { · line 185

Quoted 4 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +3 -0
+       int ddr_ba0;
+       int ddr_ba1;
+       int ddr_ba2;
 };

IIRC not all the pads over here have any IO control. Some are analog pins and some like JTAG, PORz really shouldn't be meddled with if the h/w does expose some configuration. Please revisit this change.

Nothing to be revisited here. I have to use ddr_ba2 for VTT, so I have populated the structure till this point.
I don't see any error to update a structure so that I can use the desired pins. I am not using the pins what ever you have mentioned. I purposefully populated those because I don't want make them as reserved.

Quoted 10 lines
Quoted 10 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +0 -0
 #endif /* _MUX_AM43XX_H_ */
board/ti/am43xx/mux.c +0 -0
index 700e9a7..46bad01 100644
@@ -12,8 +12,24 @@
 #include "board.h"
 
Quoted 9 lines

board/ti/am43xx/mux.c line 17

Quoted 6 lines
board/ti/am43xx/mux.c +3 -2
 static struct module_pin_mux uart0_pin_mux[] = {
-       {OFFSET(uart0_rxd), (MODE(0) | RXACTIVE)},      /* UART0_RXD */
-       {OFFSET(uart0_txd), (MODE(0))},                 /* UART0_TXD */
+       {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
+       {OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
+       {-1},

SLEWCTRL is typically not changed. You might want to double check this portion with the h/w folks.

I have checked with h/w folks, they said nothing wrong here.

Thanks
Lokesh

Quoted 4 lines

Regards,
Vaibhav

#23 lore raw

PATCH v2 9/14 ARM: AM43xx: mux: Update mux data

Quoted 69 lines · Lokesh Vutla
Quoted 60 lines · Vaibhav Bedia
Quoted 59 lines · Lokesh Vutla

Updating the mux data for UART, adding data for i2c0 and mmc. And also updating pad_signals structure.

---
 arch/arm/include/asm/arch-am33xx/mux_am43xx.h |   45 +++++++++++++++++++++++++
 board/ti/am43xx/mux.c                         |   22 ++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +42 -0
index 0206912..98fc2b5 100644
@@ -137,6 +137,51 @@ struct pad_signals {
        int mcasp0_fsr;
        int mcasp0_axr1;
        int mcasp0_ahclkx;
+       int xdma_event_intr0;
+       int xdma_event_intr1;
+       int nresetin_out;
+       int porz;
+       int nnmi;
+       int osc0_in;
+       int osc0_out;
+       int rsvd1;
+       int tms;
+       int tdi;
+       int tdo;
+       int tck;
+       int ntrst;
+       int emu0;
+       int emu1;
+       int osc1_in;
+       int osc1_out;
+       int pmic_power_en;
+       int rtc_porz;
+       int rsvd2;
+       int ext_wakeup;
+       int enz_kaldo_1p8v;
+       int usb0_dm;
+       int usb0_dp;
+       int usb0_ce;
+       int usb0_id;
+       int usb0_vbus;
+       int usb0_drvvbus;
+       int usb1_dm;
+       int usb1_dp;
+       int usb1_ce;
+       int usb1_id;
+       int usb1_vbus;
+       int usb1_drvvbus;
+       int ddr_resetn;
+       int ddr_csn0;
+       int ddr_cke;
+       int ddr_ck;
+       int ddr_nck;
+       int ddr_casn;
+       int ddr_rasn;
+       int ddr_wen;
Quoted 8 lines

arch/arm/include/asm/arch-am33xx/mux_am43xx.h struct pad_signals { · line 185

Quoted 4 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +3 -0
+       int ddr_ba0;
+       int ddr_ba1;
+       int ddr_ba2;
 };

IIRC not all the pads over here have any IO control. Some are analog pins and some like JTAG, PORz really shouldn't be meddled with if the h/w does expose some configuration. Please revisit this change.

Quoted 5 lines

Nothing to be revisited here. I have to use ddr_ba2 for VTT, so I have populated the structure till this point.
I don't see any error to update a structure so that I can use the desired pins. I am not using the pins what ever you have mentioned. I purposefully populated those because I don't want make them as reserved.

I think i gave a good enough technical reason why that's not a good thing to do. If you really don't see the shortcomings of that i have nothing more to add here.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
arch/arm/include/asm/arch-am33xx/mux_am43xx.h +0 -0
 #endif /* _MUX_AM43XX_H_ */
board/ti/am43xx/mux.c +0 -0
index 700e9a7..46bad01 100644
@@ -12,8 +12,24 @@
 #include "board.h"
 
Quoted 9 lines

board/ti/am43xx/mux.c line 17

Quoted 6 lines
board/ti/am43xx/mux.c +3 -2
 static struct module_pin_mux uart0_pin_mux[] = {
-       {OFFSET(uart0_rxd), (MODE(0) | RXACTIVE)},      /* UART0_RXD */
-       {OFFSET(uart0_txd), (MODE(0))},                 /* UART0_TXD */
+       {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
+       {OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
+       {-1},

SLEWCTRL is typically not changed. You might want to double check this portion with the h/w folks.

Quoted 2 lines

I have checked with h/w folks, they said nothing wrong here.

Fine with me.

Regards,
Vaibhav

#24 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

In reply to Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

---
 arch/arm/cpu/armv7/am33xx/clock.c        |   12 +++++++---
 arch/arm/cpu/armv7/am33xx/clock_am33xx.c |   15 ++++++++++++
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    8 +------
 arch/arm/include/asm/arch-am33xx/clock.h |    7 +++---
 board/ti/am43xx/board.c                  |   38 +++++++++++++++++++++++++++---
 board/ti/am43xx/board.h                  |    1 +
 board/ti/am43xx/mux.c                    |    5 ++++
 7 files changed, 69 insertions(+), 17 deletions(-)
arch/arm/cpu/armv7/am33xx/clock.c +9 -3
index 8e5f3c6..0672798 100644
@@ -101,9 +101,15 @@ void do_setup_dpll(const struct dpll_regs *dpll_regs,
 static void setup_dplls(void)
 {
 	const struct dpll_params *params;
-	do_setup_dpll(&dpll_core_regs, &dpll_core);
-	do_setup_dpll(&dpll_mpu_regs, &dpll_mpu);
-	do_setup_dpll(&dpll_per_regs, &dpll_per);
+
+	params = get_dpll_core_params();
+	do_setup_dpll(&dpll_core_regs, params);
+
+	params = get_dpll_mpu_params();
+	do_setup_dpll(&dpll_mpu_regs, params);
+
+	params = get_dpll_per_params();
+	do_setup_dpll(&dpll_per_regs, params);
 	writel(0x300, &cmwkup->clkdcoldodpllper);
 
 	params = get_dpll_ddr_params();
arch/arm/cpu/armv7/am33xx/clock_am33xx.c +15 -0
index fabe259..92142c8 100644
@@ -62,6 +62,21 @@ const struct dpll_params dpll_core = {
 const struct dpll_params dpll_per = {
 		960, OSC-1, 5, -1, -1, -1, -1};
 
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+	return &dpll_mpu;
+}
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+	return &dpll_core;
+}
+
+const struct dpll_params *get_dpll_per_params(void)
+{
+	return &dpll_per;
+}
+
 void setup_clocks_for_console(void)
 {
 	clrsetbits_le32(&cmwkup->wkclkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -7
index 22963b7..97c00b4 100644
@@ -48,15 +48,9 @@ const struct dpll_regs dpll_ddr_regs = {
 	.cm_idlest_dpll		= CM_WKUP + 0x5A4,
 	.cm_clksel_dpll		= CM_WKUP + 0x5AC,
 	.cm_div_m2_dpll		= CM_WKUP + 0x5B0,
+	.cm_div_m4_dpll		= CM_WKUP + 0x5B8,
 };
 
-const struct dpll_params dpll_mpu = {
-		-1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_core = {
-		-1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_per = {
-		-1, -1, -1, -1, -1, -1, -1};
-
 void setup_clocks_for_console(void)
 {
 	/* Do not add any spl_debug prints in this function */
arch/arm/include/asm/arch-am33xx/clock.h +3 -4
index 519249e..7637457 100644
@@ -98,13 +98,12 @@ extern const struct dpll_regs dpll_mpu_regs;
 extern const struct dpll_regs dpll_core_regs;
 extern const struct dpll_regs dpll_per_regs;
 extern const struct dpll_regs dpll_ddr_regs;
-extern const struct dpll_params dpll_mpu;
-extern const struct dpll_params dpll_core;
-extern const struct dpll_params dpll_per;
-extern const struct dpll_params dpll_ddr;
 
 extern struct cm_wkuppll *const cmwkup;
 
+const struct dpll_params *get_dpll_mpu_params(void);
+const struct dpll_params *get_dpll_core_params(void);
+const struct dpll_params *get_dpll_per_params(void);
 const struct dpll_params *get_dpll_ddr_params(void);
 void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *);
 void prcm_init(void);
board/ti/am43xx/board.c +35 -3
index 723d0ca..2d1b8f9 100644
@@ -65,12 +65,44 @@ static int read_eeprom(struct am43xx_board_id *header)
 
 #ifdef CONFIG_SPL_BUILD
 
-const struct dpll_params dpll_ddr = {
-		-1, -1, -1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_ddr = {
+		266, 24, 1, -1, 1, -1, -1};
+const struct dpll_params epos_evm_dpll_mpu = {
+		600, 24, 1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_core = {
+		1000, 24, -1, -1, 10, 8, 4};
+const struct dpll_params epos_evm_dpll_per = {
+		960, 24, 5, -1, -1, -1, -1};
 
 const struct dpll_params *get_dpll_ddr_params(void)
 {
-	return &dpll_ddr;
+	if (board_is_eposevm())
+		return &epos_evm_dpll_ddr;
+}
+
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+	if (board_is_eposevm())
+		return &epos_evm_dpll_mpu;
+}
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+	struct am43xx_board_id header;
+
+	enable_i2c0_pin_mux();
+	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
+	if (read_eeprom(&header) < 0)
+		puts("Could not get board ID.\n");
+
+	if (board_is_eposevm())
+		return &epos_evm_dpll_core;
+}
+
+const struct dpll_params *get_dpll_per_params(void)
+{
+	if (board_is_eposevm())
+		return &epos_evm_dpll_per;
 }
 
 void set_uart_mux_conf(void)
board/ti/am43xx/board.h +1 -0
index 9268895..beee770 100644
@@ -46,4 +46,5 @@ static inline int board_is_gpevm(void)
 
 void enable_uart0_pin_mux(void);
 void enable_board_pin_mux(void);
+void enable_i2c0_pin_mux(void);
 #endif
board/ti/am43xx/mux.c +5 -0
index 46bad01..a2d72dd 100644
@@ -43,3 +43,8 @@ void enable_board_pin_mux(void)
 	configure_module_pin_mux(mmc0_pin_mux);
 	configure_module_pin_mux(i2c0_pin_mux);
 }
+
+void enable_i2c0_pin_mux(void)
+{
+	configure_module_pin_mux(i2c0_pin_mux);
+}
Signature · 1 line
1.7.9.5
#25 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

Quoted 133 lines
---
 arch/arm/cpu/armv7/am33xx/clock.c        |   12 +++++++---
 arch/arm/cpu/armv7/am33xx/clock_am33xx.c |   15 ++++++++++++
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    8 +------
 arch/arm/include/asm/arch-am33xx/clock.h |    7 +++---
 board/ti/am43xx/board.c                  |   38 +++++++++++++++++++++++++++---
 board/ti/am43xx/board.h                  |    1 +
 board/ti/am43xx/mux.c                    |    5 ++++
 7 files changed, 69 insertions(+), 17 deletions(-)
arch/arm/cpu/armv7/am33xx/clock.c +9 -3
index 8e5f3c6..0672798 100644
@@ -101,9 +101,15 @@ void do_setup_dpll(const struct dpll_regs *dpll_regs,
 static void setup_dplls(void)
 {
        const struct dpll_params *params;
-       do_setup_dpll(&dpll_core_regs, &dpll_core);
-       do_setup_dpll(&dpll_mpu_regs, &dpll_mpu);
-       do_setup_dpll(&dpll_per_regs, &dpll_per);
+
+       params = get_dpll_core_params();
+       do_setup_dpll(&dpll_core_regs, params);
+
+       params = get_dpll_mpu_params();
+       do_setup_dpll(&dpll_mpu_regs, params);
+
+       params = get_dpll_per_params();
+       do_setup_dpll(&dpll_per_regs, params);
        writel(0x300, &cmwkup->clkdcoldodpllper);
 
        params = get_dpll_ddr_params();
arch/arm/cpu/armv7/am33xx/clock_am33xx.c +15 -0
index fabe259..92142c8 100644
@@ -62,6 +62,21 @@ const struct dpll_params dpll_core = {
 const struct dpll_params dpll_per = {
                960, OSC-1, 5, -1, -1, -1, -1};
 
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+       return &dpll_mpu;
+}
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+       return &dpll_core;
+}
+
+const struct dpll_params *get_dpll_per_params(void)
+{
+       return &dpll_per;
+}
+
 void setup_clocks_for_console(void)
 {
        clrsetbits_le32(&cmwkup->wkclkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -7
index 22963b7..97c00b4 100644
@@ -48,15 +48,9 @@ const struct dpll_regs dpll_ddr_regs = {
        .cm_idlest_dpll         = CM_WKUP + 0x5A4,
        .cm_clksel_dpll         = CM_WKUP + 0x5AC,
        .cm_div_m2_dpll         = CM_WKUP + 0x5B0,
+       .cm_div_m4_dpll         = CM_WKUP + 0x5B8,
 };
 
-const struct dpll_params dpll_mpu = {
-               -1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_core = {
-               -1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_per = {
-               -1, -1, -1, -1, -1, -1, -1};
-
 void setup_clocks_for_console(void)
 {
        /* Do not add any spl_debug prints in this function */
arch/arm/include/asm/arch-am33xx/clock.h +3 -4
index 519249e..7637457 100644
@@ -98,13 +98,12 @@ extern const struct dpll_regs dpll_mpu_regs;
 extern const struct dpll_regs dpll_core_regs;
 extern const struct dpll_regs dpll_per_regs;
 extern const struct dpll_regs dpll_ddr_regs;
-extern const struct dpll_params dpll_mpu;
-extern const struct dpll_params dpll_core;
-extern const struct dpll_params dpll_per;
-extern const struct dpll_params dpll_ddr;
 
 extern struct cm_wkuppll *const cmwkup;
 
+const struct dpll_params *get_dpll_mpu_params(void);
+const struct dpll_params *get_dpll_core_params(void);
+const struct dpll_params *get_dpll_per_params(void);
 const struct dpll_params *get_dpll_ddr_params(void);
 void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *);
 void prcm_init(void);
board/ti/am43xx/board.c +17 -3
index 723d0ca..2d1b8f9 100644
@@ -65,12 +65,44 @@ static int read_eeprom(struct am43xx_board_id *header)
 
 #ifdef CONFIG_SPL_BUILD
 
-const struct dpll_params dpll_ddr = {
-               -1, -1, -1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_ddr = {
+               266, 24, 1, -1, 1, -1, -1};
+const struct dpll_params epos_evm_dpll_mpu = {
+               600, 24, 1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_core = {
+               1000, 24, -1, -1, 10, 8, 4};
+const struct dpll_params epos_evm_dpll_per = {
+               960, 24, 5, -1, -1, -1, -1};
 
 const struct dpll_params *get_dpll_ddr_params(void)
 {
-       return &dpll_ddr;
+       if (board_is_eposevm())
+               return &epos_evm_dpll_ddr;
+}
+
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+       if (board_is_eposevm())
+               return &epos_evm_dpll_mpu;
+}

board/ti/am43xx/board.c static int read_eeprom(struct am43xx_board_id *header) · line 97

Quoted 10 lines
board/ti/am43xx/board.c +10 -0
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+       struct am43xx_board_id header;
+
+       enable_i2c0_pin_mux();
+       i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
+       if (read_eeprom(&header) < 0)
+               puts("Could not get board ID.\n");
+

Reading the EEPROM again? Why don't you just read it once and update some common structure?

Regards,
Vaibhav

#26 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 9 lines · Vaibhav Bedia
Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

Quoted 4 lines

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

We already had a discussion on this during V1 of this series.
Sekhar and Tom replied to you comments. What is the point in asking the same question again?

Since you are very concerned here. Why are you feeling it so complicated when new variants come?
We can always differentiate the new variant from the old ones and can pass dpll structure accordingly. It is just a matter a one if condition. It ll be better to look at the current code and see how cleanly it is done.

Thanks
Lokesh

Quoted 151 lines
Quoted 134 lines
---
 arch/arm/cpu/armv7/am33xx/clock.c        |   12 +++++++---
 arch/arm/cpu/armv7/am33xx/clock_am33xx.c |   15 ++++++++++++
 arch/arm/cpu/armv7/am33xx/clock_am43xx.c |    8 +------
 arch/arm/include/asm/arch-am33xx/clock.h |    7 +++---
 board/ti/am43xx/board.c                  |   38 +++++++++++++++++++++++++++---
 board/ti/am43xx/board.h                  |    1 +
 board/ti/am43xx/mux.c                    |    5 ++++
 7 files changed, 69 insertions(+), 17 deletions(-)
arch/arm/cpu/armv7/am33xx/clock.c +9 -3
index 8e5f3c6..0672798 100644
@@ -101,9 +101,15 @@ void do_setup_dpll(const struct dpll_regs *dpll_regs,
 static void setup_dplls(void)
 {
        const struct dpll_params *params;
-       do_setup_dpll(&dpll_core_regs, &dpll_core);
-       do_setup_dpll(&dpll_mpu_regs, &dpll_mpu);
-       do_setup_dpll(&dpll_per_regs, &dpll_per);
+
+       params = get_dpll_core_params();
+       do_setup_dpll(&dpll_core_regs, params);
+
+       params = get_dpll_mpu_params();
+       do_setup_dpll(&dpll_mpu_regs, params);
+
+       params = get_dpll_per_params();
+       do_setup_dpll(&dpll_per_regs, params);
        writel(0x300, &cmwkup->clkdcoldodpllper);
 
        params = get_dpll_ddr_params();
arch/arm/cpu/armv7/am33xx/clock_am33xx.c +15 -0
index fabe259..92142c8 100644
@@ -62,6 +62,21 @@ const struct dpll_params dpll_core = {
 const struct dpll_params dpll_per = {
                960, OSC-1, 5, -1, -1, -1, -1};
 
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+       return &dpll_mpu;
+}
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+       return &dpll_core;
+}
+
+const struct dpll_params *get_dpll_per_params(void)
+{
+       return &dpll_per;
+}
+
 void setup_clocks_for_console(void)
 {
        clrsetbits_le32(&cmwkup->wkclkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +1 -7
index 22963b7..97c00b4 100644
@@ -48,15 +48,9 @@ const struct dpll_regs dpll_ddr_regs = {
        .cm_idlest_dpll         = CM_WKUP + 0x5A4,
        .cm_clksel_dpll         = CM_WKUP + 0x5AC,
        .cm_div_m2_dpll         = CM_WKUP + 0x5B0,
+       .cm_div_m4_dpll         = CM_WKUP + 0x5B8,
 };
 
-const struct dpll_params dpll_mpu = {
-               -1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_core = {
-               -1, -1, -1, -1, -1, -1, -1};
-const struct dpll_params dpll_per = {
-               -1, -1, -1, -1, -1, -1, -1};
-
 void setup_clocks_for_console(void)
 {
        /* Do not add any spl_debug prints in this function */
arch/arm/include/asm/arch-am33xx/clock.h +3 -4
index 519249e..7637457 100644
@@ -98,13 +98,12 @@ extern const struct dpll_regs dpll_mpu_regs;
 extern const struct dpll_regs dpll_core_regs;
 extern const struct dpll_regs dpll_per_regs;
 extern const struct dpll_regs dpll_ddr_regs;
-extern const struct dpll_params dpll_mpu;
-extern const struct dpll_params dpll_core;
-extern const struct dpll_params dpll_per;
-extern const struct dpll_params dpll_ddr;
 
 extern struct cm_wkuppll *const cmwkup;
 
+const struct dpll_params *get_dpll_mpu_params(void);
+const struct dpll_params *get_dpll_core_params(void);
+const struct dpll_params *get_dpll_per_params(void);
 const struct dpll_params *get_dpll_ddr_params(void);
 void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *);
 void prcm_init(void);
board/ti/am43xx/board.c +17 -3
index 723d0ca..2d1b8f9 100644
@@ -65,12 +65,44 @@ static int read_eeprom(struct am43xx_board_id *header)
 
 #ifdef CONFIG_SPL_BUILD
 
-const struct dpll_params dpll_ddr = {
-               -1, -1, -1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_ddr = {
+               266, 24, 1, -1, 1, -1, -1};
+const struct dpll_params epos_evm_dpll_mpu = {
+               600, 24, 1, -1, -1, -1, -1};
+const struct dpll_params epos_evm_dpll_core = {
+               1000, 24, -1, -1, 10, 8, 4};
+const struct dpll_params epos_evm_dpll_per = {
+               960, 24, 5, -1, -1, -1, -1};
 
 const struct dpll_params *get_dpll_ddr_params(void)
 {
-       return &dpll_ddr;
+       if (board_is_eposevm())
+               return &epos_evm_dpll_ddr;
+}
+
+const struct dpll_params *get_dpll_mpu_params(void)
+{
+       if (board_is_eposevm())
+               return &epos_evm_dpll_mpu;
+}

board/ti/am43xx/board.c static int read_eeprom(struct am43xx_board_id *header) · line 97

Quoted 10 lines
board/ti/am43xx/board.c +10 -0
+
+const struct dpll_params *get_dpll_core_params(void)
+{
+       struct am43xx_board_id header;
+
+       enable_i2c0_pin_mux();
+       i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
+       if (read_eeprom(&header) < 0)
+               puts("Could not get board ID.\n");
+

Reading the EEPROM again? Why don't you just read it once and update some common structure?

Regards,
Vaibhav

#27 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 10 lines · Lokesh Vutla
Quoted 9 lines · Vaibhav Bedia
Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

Quoted 7 lines
Quoted 4 lines

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

We already had a discussion on this during V1 of this series.
Sekhar and Tom replied to you comments. What is the point in asking the same question again?

Because i don't recall any conclusion being reached on that thread? Because the objective of a patch review is to come up with a solution which learns from the past
and doesn't try to brush the past issues under the carpet under the assumption that
the shiny new device will never have bugs?

Quoted 4 lines

Since you are very concerned here. Why are you feeling it so complicated when new variants come?
We can always differentiate the new variant from the old ones and can pass dpll structure accordingly. It is just a matter a one if condition. It ll be better to look at the current code and see how cleanly it is done.

As the OPP decoder table in the AM335x datasheet will tell you it's not that simple.
Frankly, i could care less about this change...

#28 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 19 lines · Vaibhav Bedia
Quoted 10 lines · Lokesh Vutla
Quoted 9 lines · Vaibhav Bedia
Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

Quoted 7 lines
Quoted 4 lines

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

We already had a discussion on this during V1 of this series.
Sekhar and Tom replied to you comments. What is the point in asking the same question again?

Quoted 6 lines

Because i don't recall any conclusion being reached on that thread? Because the objective of a patch review is to come up with a solution which learns from the past
and doesn't try to brush the past issues under the carpet under the assumption that
the shiny new device will never have bugs?

Yes I agree with you point.
But I have replied to this thread saying that
"Currently these values are not blown in eFuse. Both EPOS and GP evms support OPP NOM. So there is no harm in booting at OPP NOM here."
You haven't come back on that.

Quoted 8 lines
Quoted 5 lines

Since you are very concerned here. Why are you feeling it so complicated when new variants come?
We can always differentiate the new variant from the old ones and can pass dpll structure accordingly. It is just a matter a one if condition. It ll be better to look at the current code and see how cleanly it is done.

As the OPP decoder table in the AM335x datasheet will tell you it's not that simple.

I guess your previous comment was about the code complexity when a new variant of the board comes. Coming to OPP tables:
Frankly, I don't know what happened during AM33xx times. I am just trying to make things simpler and cleaner. Do you mean here, we need to support all OPPs in U-Boot?
Are you expecting complete OPP table to get from e-fuse values for AM43xx?

As per my understanding from working on OMAP, U-Boot supports only OPP_NOM( or the safe OPP to boot).

Please correct me if I am wrong.

Thanks and regards,
Lokesh

Quoted 2 lines

Frankly, i could care less about this change...

#29 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 26 lines · Lokesh Vutla
Quoted 19 lines · Vaibhav Bedia
Quoted 10 lines · Lokesh Vutla
Quoted 9 lines · Vaibhav Bedia
Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

Quoted 7 lines
Quoted 4 lines

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

We already had a discussion on this during V1 of this series.
Sekhar and Tom replied to you comments. What is the point in asking the same question again?

Quoted 6 lines

Because i don't recall any conclusion being reached on that thread? Because the objective of a patch review is to come up with a solution which learns from the past
and doesn't try to brush the past issues under the carpet under the assumption that
the shiny new device will never have bugs?

Quoted 6 lines

Yes I agree with you point.
But I have replied to this thread saying that
"Currently these values are not blown in eFuse. Both EPOS and GP evms support OPP NOM. So there is no harm in booting at OPP NOM here."
You haven't come back on that.

Sorry i somehow missed replying to that.

So here's the thing. Right now you are told that all the devices support OPP NOM and hence as the U-Boot maintainer for AM437x you go ahead and use that information. However, few days down the line you'll have different speed grades coming out of the fab and some of them are going to have a max OPP that's lower than what OPP_NOM means. After a few devices blow up and some mails go around the world your code gets blamed and you hastily come up with a patch which tries to address the slower devices. The future you then realizes that you need some mechanism the differentiate the old devices without the eFuse information and the new which do. You might discover that there's some board rev check or something like that can be used. But that's only if you are lucky. I hope you see where this is going.

So what can you do?
A. Go ahead with OPP NOM and be prepared to debug boot failures on random boards only to discover that the devices are not meant to operate at OPP_NOM.

B. Find the lowest common denominator for the supported OPPs and use that in here. This might end up making some folks unhappy but then you need to make a choice between fast and reliable and i would personally go for the latter. If folks really care about boot times someone needs to start putting the right information in the eFuses at the right time.

Quoted 14 lines
Quoted 8 lines
Quoted 5 lines

Since you are very concerned here. Why are you feeling it so complicated when new variants come?
We can always differentiate the new variant from the old ones and can pass dpll structure accordingly. It is just a matter a one if condition. It ll be better to look at the current code and see how cleanly it is done.

As the OPP decoder table in the AM335x datasheet will tell you it's not that simple.

I guess your previous comment was about the code complexity when a new variant of the board comes. Coming to OPP tables:
Frankly, I don't know what happened during AM33xx times. I am just trying to make things simpler and cleaner. Do you mean here, we need to support all OPPs in U-Boot?
Are you expecting complete OPP table to get from e-fuse values for AM43xx?

Quoted 4 lines

As per my understanding from working on OMAP, U-Boot supports only OPP_NOM( or the safe OPP to boot).

Please correct me if I am wrong.

I hope the verbiage above helps you get an idea of why i am insisting on a change here.

I am not asking U-Boot to have the complete OPP table. That's for the kernel
+ device-tree to handle. If there's no eFuse data in the devices, hard luck. We do the only thing we can for reliable boots and that's to use an OPP which is reliable all the time.

If you still think OPP_NOM is the right choice please go ahead and use it.

Regards,
Vaibhav

#30 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 36 lines · Vaibhav Bedia
Quoted 26 lines · Lokesh Vutla
Quoted 19 lines · Vaibhav Bedia
Quoted 10 lines · Lokesh Vutla
Quoted 9 lines · Vaibhav Bedia
Quoted 7 lines · Lokesh Vutla

Updating the Multiplier and Dividers values for all DPLLs for EPOS EVM. Following are the DPLL locking frequencies at OPP NOM:
MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 266MHz

Quoted 7 lines
Quoted 4 lines

As mentioned earlier, this hardcoded frequency approach is really not scalable when you have
more device variants coming in. Just look at the AM335x changes on how this gets complicated.

We already had a discussion on this during V1 of this series.
Sekhar and Tom replied to you comments. What is the point in asking the same question again?

Quoted 6 lines

Because i don't recall any conclusion being reached on that thread? Because the objective of a patch review is to come up with a solution which learns from the past
and doesn't try to brush the past issues under the carpet under the assumption that
the shiny new device will never have bugs?

Quoted 6 lines

Yes I agree with you point.
But I have replied to this thread saying that
"Currently these values are not blown in eFuse. Both EPOS and GP evms support OPP NOM. So there is no harm in booting at OPP NOM here."
You haven't come back on that.

Sorry i somehow missed replying to that.

Quoted 12 lines

So here's the thing. Right now you are told that all the devices support OPP NOM and hence as the U-Boot maintainer for AM437x you go ahead and use that information. However, few days down the line you'll have different speed grades coming out of the fab and some of them are going to have a max OPP that's lower than what OPP_NOM means. After a few devices blow up and some mails go around the world your code gets blamed and you hastily come up with a patch which tries to address the slower devices. The future you then realizes that you need some mechanism the differentiate the old devices without the eFuse information and the new which do. You might discover that there's some board rev check or something like that can be used. But that's only if you are lucky. I hope you see where this is going.

Thanks for the clear explanation. Now I get the point.

Quoted 31 lines

So what can you do?
A. Go ahead with OPP NOM and be prepared to debug boot failures on random boards only to discover that the devices are not meant to operate at OPP_NOM.

B. Find the lowest common denominator for the supported OPPs and use that in here. This might end up making some folks unhappy but then you need to make a choice between fast and reliable and i would personally go for the latter. If folks really care about boot times someone needs to start putting the right information in the eFuses at the right time.

Quoted 14 lines
Quoted 8 lines
Quoted 5 lines

Since you are very concerned here. Why are you feeling it so complicated when new variants come?
We can always differentiate the new variant from the old ones and can pass dpll structure accordingly. It is just a matter a one if condition. It ll be better to look at the current code and see how cleanly it is done.

As the OPP decoder table in the AM335x datasheet will tell you it's not that simple.

I guess your previous comment was about the code complexity when a new variant of the board comes. Coming to OPP tables:
Frankly, I don't know what happened during AM33xx times. I am just trying to make things simpler and cleaner. Do you mean here, we need to support all OPPs in U-Boot?
Are you expecting complete OPP table to get from e-fuse values for AM43xx?

Quoted 4 lines

As per my understanding from working on OMAP, U-Boot supports only OPP_NOM( or the safe OPP to boot).

Please correct me if I am wrong.

Quoted 7 lines

I hope the verbiage above helps you get an idea of why i am insisting on a change here.

I am not asking U-Boot to have the complete OPP table. That's for the kernel
+ device-tree to handle. If there's no eFuse data in the devices, hard luck. We do the only thing we can for reliable boots and that's to use an OPP which is reliable all the time.

I agree with you, we need to have EEPROM to have the safe OPP. Unfortunately we don't have this information.
I am sure people will not accept to boot at lowest OPP.

I read more about it and got inputs from Sekhar. I came to know that there is a DEV_ATTRIBUTE register which tells about the safest OPP to boot with. Looks like this should be sufficient to get the values. Ill add this code and update the patch.

Thanks and regards,
Lokesh

Quoted 6 lines

If you still think OPP_NOM is the right choice please go ahead and use it.

Regards,
Vaibhav

#31 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

On Sun, Dec 1, 2013 at 10:53 PM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 3 lines

I read more about it and got inputs from Sekhar. I came to know that there is a DEV_ATTRIBUTE register which tells about the safest OPP to boot with. Looks like this should be sufficient to get the values. Ill add this code and update the patch.

Hmm i don't know how that field gets populated. Unless it's coming from the eFuse i really doubt
it would serve the purpose.

#32 lore raw

PATCH v2 10/14 ARM: AM43xx: clocks: Update DPLL details for EPOS EVM

Quoted 9 lines · Vaibhav Bedia

On Sun, Dec 1, 2013 at 10:53 PM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 3 lines

I read more about it and got inputs from Sekhar. I came to know that there is a DEV_ATTRIBUTE register which tells about the safest OPP to boot with. Looks like this should be sufficient to get the values. Ill add this code and update the patch.

Hmm i don't know how that field gets populated. Unless it's coming from the eFuse i really doubt
it would serve the purpose.

Yes, that register is a reflection of efuse settings.

Thanks,
Sekhar

#33 lore raw

PATCH v2 11/14 ARM: AM43xx: clocks: Add DPLL data for GP EVM

In reply to Lokesh Vutla

Adding DPLLs Multiplier and DIvider values for GP EVM Following are the DPLL locking frequencies at OPP NOM MPU locks at 600MHz
Core locks at 1000MHz
Per locks at 960MHz
DDR locks at 400MHz

---
 board/ti/am43xx/board.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
board/ti/am43xx/board.c +17 -0
index 2d1b8f9..366bec3 100644
@@ -74,16 +74,29 @@ const struct dpll_params epos_evm_dpll_core = {
 const struct dpll_params epos_evm_dpll_per = {
 		960, 24, 5, -1, -1, -1, -1};
 
+const struct dpll_params gp_evm_dpll_ddr = {
+		400, 23, 1, -1, 1, -1, -1};
+const struct dpll_params gp_evm_dpll_mpu = {
+		600, 23, 1, -1, -1, -1, -1};
+const struct dpll_params gp_evm_dpll_core = {
+		1000, 23, -1, -1, 10, 8, 4};
+const struct dpll_params gp_evm_dpll_per = {
+		960, 23, 5, -1, -1, -1, -1};
+
 const struct dpll_params *get_dpll_ddr_params(void)
 {
 	if (board_is_eposevm())
 		return &epos_evm_dpll_ddr;
+	else
+		return &gp_evm_dpll_ddr;
 }
 
 const struct dpll_params *get_dpll_mpu_params(void)
 {
 	if (board_is_eposevm())
 		return &epos_evm_dpll_mpu;
+	else
+		return &gp_evm_dpll_mpu;
 }
 
 const struct dpll_params *get_dpll_core_params(void)
@@ -97,12 +110,16 @@ const struct dpll_params *get_dpll_core_params(void)
 
 	if (board_is_eposevm())
 		return &epos_evm_dpll_core;
+	else
+		return &gp_evm_dpll_core;
 }
 
 const struct dpll_params *get_dpll_per_params(void)
 {
 	if (board_is_eposevm())
 		return &epos_evm_dpll_per;
+	else
+		return &gp_evm_dpll_per;
 }
 
 void set_uart_mux_conf(void)
Signature · 1 line
1.7.9.5
#34 lore raw

PATCH v2 12/14 ARM: AM43xx: EPOS_EVM: Add support for LPDDR2

In reply to Lokesh Vutla

AM4372 EPOS EVM has 1GB LPDDR2(Part no: MT42L256M32D2LG-25 WT:A) Adding LPDDR2 init sequence and register details for the same. Below is the brief description of LPDDR2 init sequence:
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register -> Wait till initialization is complete and the configure MR registers.

---
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  147 +++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +++-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |    5 +
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   33 ++++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    1 +
 arch/arm/include/asm/emif.h                        |   12 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 +++++-
 board/ti/am43xx/board.c                            |   66 +++++++++
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 16 files changed, 373 insertions(+), 27 deletions(-)
arch/arm/cpu/armv7/am33xx/ddr.c +141 -6
index fa697c7..fbee51d 100644
@@ -36,6 +36,74 @@ static struct ddr_data_regs *ddr_data_reg[2] = {
 static struct ddr_cmdtctrl *ioctrl_reg = {
 			(struct ddr_cmdtctrl *)DDR_CONTROL_BASE_ADDR};
 
+static inline u32 get_mr(int nr, u32 cs, u32 mr_addr)
+{
+	u32 mr;
+
+	mr_addr |= cs << EMIF_REG_CS_SHIFT;
+	writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+
+	mr = readl(&emif_reg[nr]->emif_lpddr2_mode_reg_data);
+	debug("get_mr: EMIF1 cs %d mr %08x val 0x%x\n", cs, mr_addr, mr);
+	if (((mr & 0x0000ff00) >>  8) == (mr & 0xff) &&
+	    ((mr & 0x00ff0000) >> 16) == (mr & 0xff) &&
+	    ((mr & 0xff000000) >> 24) == (mr & 0xff))
+		return mr & 0xff;
+	else
+		return mr;
+}
+
+static inline void set_mr(int nr, u32 cs, u32 mr_addr, u32 mr_val)
+{
+	mr_addr |= cs << EMIF_REG_CS_SHIFT;
+	writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+	writel(mr_val, &emif_reg[nr]->emif_lpddr2_mode_reg_data);
+}
+
+static void configure_mr(int nr, u32 cs)
+{
+	u32 mr_addr;
+
+	while (get_mr(nr, cs, LPDDR2_MR0) & LPDDR2_MR0_DAI_MASK)
+		;
+	set_mr(nr, cs, LPDDR2_MR10, 0x56);
+
+	set_mr(nr, cs, LPDDR2_MR1, 0x43);
+	set_mr(nr, cs, LPDDR2_MR2, 0x2);
+
+	mr_addr = LPDDR2_MR2 | EMIF_REG_REFRESH_EN_MASK;
+	set_mr(nr, cs, mr_addr, 0x2);
+}
+
+/*
+ * Configure EMIF4D5 registers and MR registers
+ */
+void config_sdram_emif4d5(const struct emif_regs *regs, int nr)
+{
+	writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl);
+	writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl_shdw);
+	writel(0x1, &emif_reg[nr]->emif_iodft_tlgc);
+	writel(regs->zq_config, &emif_reg[nr]->emif_zq_config);
+
+	writel(regs->temp_alert_config, &emif_reg[nr]->emif_temp_alert_config);
+	writel(regs->emif_rd_wr_lvl_rmp_win,
+	       &emif_reg[nr]->emif_rd_wr_lvl_rmp_win);
+	writel(regs->emif_rd_wr_lvl_rmp_ctl,
+	       &emif_reg[nr]->emif_rd_wr_lvl_rmp_ctl);
+	writel(regs->emif_rd_wr_lvl_ctl, &emif_reg[nr]->emif_rd_wr_lvl_ctl);
+	writel(regs->emif_rd_wr_exec_thresh,
+	       &emif_reg[nr]->emif_rd_wr_exec_thresh);
+
+	clrbits_le32(&emif_reg[nr]->emif_sdram_ref_ctrl,
+		     EMIF_REG_INITREF_DIS_MASK);
+
+	writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config);
+	writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl);
+
+	configure_mr(nr, 0);
+	configure_mr(nr, 1);
+}
+
 /**
  * Configure SDRAM
  */
@@ -72,15 +140,67 @@ void set_sdram_timings(const struct emif_regs *regs, int nr)
 	writel(regs->sdram_tim3, &emif_reg[nr]->emif_sdram_tim_3_shdw);
 }
 
+void __weak emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size)
+{
+}
+
+/*
+ * Configure EXT PHY registers
+ */
+static void ext_phy_settings(const struct emif_regs *regs, int nr)
+{
+	u32 *ext_phy_ctrl_base = 0;
+	u32 *emif_ext_phy_ctrl_base = 0;
+	const u32 *ext_phy_ctrl_const_regs;
+	u32 i = 0;
+	u32 size;
+
+	ext_phy_ctrl_base = (u32 *)&(regs->emif_ddr_ext_phy_ctrl_1);
+	emif_ext_phy_ctrl_base =
+			(u32 *)&(emif_reg[nr]->emif_ddr_ext_phy_ctrl_1);
+
+	/* Configure external phy control timing registers */
+	for (i = 0; i < EMIF_EXT_PHY_CTRL_TIMING_REG; i++) {
+		writel(*ext_phy_ctrl_base, emif_ext_phy_ctrl_base++);
+		/* Update shadow registers */
+		writel(*ext_phy_ctrl_base++, emif_ext_phy_ctrl_base++);
+	}
+
+	/*
+	 * external phy 6-24 registers do not change with
+	 * ddr frequency
+	 */
+	emif_get_ext_phy_ctrl_const_regs(&ext_phy_ctrl_const_regs, &size);
+
+	if (!size)
+		return;
+
+	for (i = 0; i < size; i++) {
+		writel(ext_phy_ctrl_const_regs[i], emif_ext_phy_ctrl_base++);
+		/* Update shadow registers */
+		writel(ext_phy_ctrl_const_regs[i], emif_ext_phy_ctrl_base++);
+	}
+}
+
 /**
  * Configure DDR PHY
  */
 void config_ddr_phy(const struct emif_regs *regs, int nr)
 {
+	/*
+	 * disable initialization and refreshes for now until we
+	 * finish programming EMIF regs.
+	 */
+	setbits_le32(&emif_reg[nr]->emif_sdram_ref_ctrl,
+		     EMIF_REG_INITREF_DIS_MASK);
+
 	writel(regs->emif_ddr_phy_ctlr_1,
 		&emif_reg[nr]->emif_ddr_phy_ctrl_1);
 	writel(regs->emif_ddr_phy_ctlr_1,
 		&emif_reg[nr]->emif_ddr_phy_ctrl_1_shdw);
+
+	if (get_emif_rev((u32)emif_reg[nr]) == EMIF_4D5)
+		ext_phy_settings(regs, nr);
 }
 
 /**
@@ -88,6 +208,9 @@ void config_ddr_phy(const struct emif_regs *regs, int nr)
  */
 void config_cmd_ctrl(const struct cmd_control *cmd, int nr)
 {
+	if (!cmd)
+		return;
+
 	writel(cmd->cmd0csratio, &ddr_cmd_reg[nr]->cm0csratio);
 	writel(cmd->cmd0dldiff, &ddr_cmd_reg[nr]->cm0dldiff);
 	writel(cmd->cmd0iclkout, &ddr_cmd_reg[nr]->cm0iclkout);
@@ -108,6 +231,9 @@ void config_ddr_data(const struct ddr_data *data, int nr)
 {
 	int i;
 
+	if (!data)
+		return;
+
 	for (i = 0; i < DDR_DATA_REGS_NR; i++) {
 		writel(data->datardsratio0,
 			&(ddr_data_reg[nr]+i)->dt0rdsratio0);
@@ -128,11 +254,20 @@ void config_ddr_data(const struct ddr_data *data, int nr)
 	}
 }
 
-void config_io_ctrl(unsigned long val)
+void config_io_ctrl(const struct ctrl_ioregs *ioregs)
 {
-	writel(val, &ioctrl_reg->cm0ioctl);
-	writel(val, &ioctrl_reg->cm1ioctl);
-	writel(val, &ioctrl_reg->cm2ioctl);
-	writel(val, &ioctrl_reg->dt0ioctl);
-	writel(val, &ioctrl_reg->dt1ioctl);
+	if (!ioregs)
+		return;
+
+	writel(ioregs->cm0ioctl, &ioctrl_reg->cm0ioctl);
+	writel(ioregs->cm1ioctl, &ioctrl_reg->cm1ioctl);
+	writel(ioregs->cm2ioctl, &ioctrl_reg->cm2ioctl);
+	writel(ioregs->dt0ioctl, &ioctrl_reg->dt0ioctl);
+	writel(ioregs->dt1ioctl, &ioctrl_reg->dt1ioctl);
+#ifdef CONFIG_AM43XX
+	writel(ioregs->dt2ioctrl, &ioctrl_reg->dt2ioctrl);
+	writel(ioregs->dt3ioctrl, &ioctrl_reg->dt3ioctrl);
+	writel(ioregs->emif_sdram_config_ext,
+	       &ioctrl_reg->emif_sdram_config_ext);
+#endif
 }
arch/arm/cpu/armv7/am33xx/emif4.c +22 -3
index 59ad25c..d28fceb 100644
@@ -48,6 +48,11 @@ static struct vtp_reg *vtpreg[2] = {
 #ifdef CONFIG_AM33XX
 static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
 #endif
+#ifdef CONFIG_AM43XX
+static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
+static struct cm_device_inst *cm_device =
+				(struct cm_device_inst *)CM_DEVICE_INST;
+#endif
 
 #ifdef CONFIG_TI81XX
 void config_dmm(const struct dmm_lisa_map_regs *regs)
@@ -87,7 +92,7 @@ void __weak ddr_pll_config(unsigned int ddrpll_m)
 {
 }
 
-void config_ddr(unsigned int pll, unsigned int ioctrl,
+void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
 		const struct ddr_data *data, const struct cmd_control *ctrl,
 		const struct emif_regs *regs, int nr)
 {
@@ -99,7 +104,18 @@ void config_ddr(unsigned int pll, unsigned int ioctrl,
 
 	config_ddr_data(data, nr);
 #ifdef CONFIG_AM33XX
-	config_io_ctrl(ioctrl);
+	config_io_ctrl(ioregs);
+
+	/* Set CKE to be controlled by EMIF/DDR PHY */
+	writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
+#endif
+#ifdef CONFIG_AM43XX
+	writel(readl(&cm_device->cm_dll_ctrl) & ~0x1, &cm_device->cm_dll_ctrl);
+	while ((readl(&cm_device->cm_dll_ctrl) && CM_DLL_READYST) == 0)
+		;
+	writel(0x0, &ddrctrl->ddrioctrl);
+
+	config_io_ctrl(ioregs);
 
 	/* Set CKE to be controlled by EMIF/DDR PHY */
 	writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
@@ -108,6 +124,9 @@ void config_ddr(unsigned int pll, unsigned int ioctrl,
 	/* Program EMIF instance */
 	config_ddr_phy(regs, nr);
 	set_sdram_timings(regs, nr);
-	config_sdram(regs, nr);
+	if (get_emif_rev(EMIF1_BASE) == EMIF_4D5)
+		config_sdram_emif4d5(regs, nr);
+	else
+		config_sdram(regs, nr);
 }
 #endif
arch/arm/include/asm/arch-am33xx/clocks_am33xx.h +3 -0
index 02ed595..4c9352a 100644
@@ -28,6 +28,9 @@
 #define UART_CLK_RUNNING_MASK	0x1
 #define UART_SMART_IDLE_EN	(0x1 << 0x3)
 
+#define CM_DLL_CTRL_NO_OVERRIDE	0x0
+#define CM_DLL_READYST		0x4
+
 extern void enable_dmm_clocks(void);
 extern const struct dpll_params dpll_core_opp100;
 extern struct dpll_params dpll_mpu_opp100;
arch/arm/include/asm/arch-am33xx/cpu.h +5 -0
index 19b8469..18d0458 100644
@@ -401,6 +401,11 @@ struct cm_perpll {
 	unsigned int cpgmac0clkctrl;	/* offset 0xB20 */
 };
 
+struct cm_device_inst {
+	unsigned int cm_clkout1_ctrl;
+	unsigned int cm_dll_ctrl;
+};
+
 struct cm_dpll {
 	unsigned int resv1;
 	unsigned int clktimer2clk;	/* offset 0x04 */
arch/arm/include/asm/arch-am33xx/ddr_defs.h +31 -2
index fe48b5f..c98ab7f 100644
@@ -19,7 +19,11 @@
 #define VTP_CTRL_ENABLE		(0x1 << 6)
 #define VTP_CTRL_START_EN	(0x1)
 #define PHY_DLL_LOCK_DIFF	0x0
+#ifdef CONFIG_AM43XX
+#define DDR_CKE_CTRL_NORMAL	0x3
+#else
 #define DDR_CKE_CTRL_NORMAL	0x1
+#endif
 #define PHY_EN_DYN_PWRDN	(0x1 << 20)
 
 /* Micron MT47H128M16RT-25E */
@@ -126,6 +130,14 @@
 #define K4B2G1646EBIH9_PHY_WR_DATA		0x76
 #define K4B2G1646EBIH9_IOCTRL_VALUE		0x18B
 
+#define  LPDDR2_ADDRCTRL_IOCTRL_VALUE   0x294
+#define  LPDDR2_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  LPDDR2_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  LPDDR2_DATA0_IOCTRL_VALUE   0x20000294
+#define  LPDDR2_DATA1_IOCTRL_VALUE   0x20000294
+#define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
+#define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
+
 /**
  * Configure DMM
  */
@@ -135,6 +147,7 @@ void config_dmm(const struct dmm_lisa_map_regs *regs);
  * Configure SDRAM
  */
 void config_sdram(const struct emif_regs *regs, int nr);
+void config_sdram_emif4d5(const struct emif_regs *regs, int nr);
 
 /**
  * Set SDRAM timings
@@ -291,12 +304,27 @@ struct ddr_cmdtctrl {
 	unsigned int resv2[12];
 	unsigned int dt0ioctl;
 	unsigned int dt1ioctl;
+	unsigned int dt2ioctrl;
+	unsigned int dt3ioctrl;
+	unsigned int resv3[4];
+	unsigned int emif_sdram_config_ext;
+};
+
+struct ctrl_ioregs {
+	unsigned int cm0ioctl;
+	unsigned int cm1ioctl;
+	unsigned int cm2ioctl;
+	unsigned int dt0ioctl;
+	unsigned int dt1ioctl;
+	unsigned int dt2ioctrl;
+	unsigned int dt3ioctrl;
+	unsigned int emif_sdram_config_ext;
 };
 
 /**
  * Configure DDR io control registers
  */
-void config_io_ctrl(unsigned long val);
+void config_io_ctrl(const struct ctrl_ioregs *ioregs);
 
 struct ddr_ctrl {
 	unsigned int ddrioctrl;
@@ -304,8 +332,9 @@ struct ddr_ctrl {
 	unsigned int ddrckectrl;
 };
 
-void config_ddr(unsigned int pll, unsigned int ioctrl,
+void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
 		const struct ddr_data *data, const struct cmd_control *ctrl,
 		const struct emif_regs *regs, int nr);
+void emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size);
 
 #endif  /* _DDR_DEFS_H */
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +1 -0
index 64f9c99..efb7b0d 100644
@@ -62,5 +62,6 @@
 #define PRM_PER_USBPHYOCP2SCP0_CLKCTRL (CM_PER + 0x5b8)
 #define PRM_PER_USBPHYOCP2SCP1_CLKCTRL (CM_PER + 0x5c0)
 #define USBPHYOCPSCP_MODULE_EN	(1 << 2)
+#define CM_DEVICE_INST			0x44df4100
 
 #endif /* __AM43XX_HARDWARE_AM43XX_H */
arch/arm/include/asm/emif.h +12 -0
index 1b94a99..ce6b229 100644
@@ -14,11 +14,15 @@
 #define _EMIF_H_
 #include <asm/types.h>
 #include <common.h>
+#include <asm/io.h>
 
 /* Base address */
 #define EMIF1_BASE				0x4c000000
 #define EMIF2_BASE				0x4d000000
 
+#define EMIF_4D					0x4
+#define EMIF_4D5				0x5
+
 /* Registers shifts, masks and values */
 
 /* EMIF_MOD_ID_REV */
@@ -1139,6 +1143,14 @@ struct lpddr2_mr_regs {
 	s8 mr16;
 };
 
+static inline u32 get_emif_rev(u32 base)
+{
+	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
+
+	return (readl(&emif->emif_mod_id_rev) & EMIF_REG_MAJOR_REVISION_MASK)
+		>> EMIF_REG_MAJOR_REVISION_SHIFT;
+}
+
 /* assert macros */
 #if defined(DEBUG)
 #define emif_assert(c)	({ if (!(c)) for (;;); })
board/isee/igep0033/board.c +9 -1
index 0b8356d..2a1b75f 100644
@@ -81,9 +81,17 @@ void set_mux_conf_regs(void)
 	enable_board_pin_mux();
 }
 
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= K4B2G1646EBIH9_IOCTRL_VALUE,
+	.cm1ioctl		= K4B2G1646EBIH9_IOCTRL_VALUE,
+	.cm2ioctl		= K4B2G1646EBIH9_IOCTRL_VALUE,
+	.dt0ioctl		= K4B2G1646EBIH9_IOCTRL_VALUE,
+	.dt1ioctl		= K4B2G1646EBIH9_IOCTRL_VALUE,
+};
+
 void sdram_init(void)
 {
-	config_ddr(400, K4B2G1646EBIH9_IOCTRL_VALUE, &ddr3_data,
+	config_ddr(400, &ioregs, &ddr3_data,
 		   &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
 }
 #endif
board/phytec/pcm051/board.c +10 -2
index 034886a..f8e1951 100644
@@ -96,10 +96,18 @@ void set_mux_conf_regs(void)
 	enable_board_pin_mux();
 }
 
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= MT41J256M8HX15E_IOCTRL_VALUE,
+	.cm1ioctl		= MT41J256M8HX15E_IOCTRL_VALUE,
+	.cm2ioctl		= MT41J256M8HX15E_IOCTRL_VALUE,
+	.dt0ioctl		= MT41J256M8HX15E_IOCTRL_VALUE,
+	.dt1ioctl		= MT41J256M8HX15E_IOCTRL_VALUE,
+};
+
 void sdram_init(void)
 {
-	config_ddr(DDR_CLK_MHZ, MT41J256M8HX15E_IOCTRL_VALUE, &ddr3_data,
-			&ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
+	config_ddr(DDR_CLK_MHZ, &ioregs, &ddr3_data, &ddr3_cmd_ctrl_data,
+		   &ddr3_emif_reg_data, 0);
 }
 #endif
 
board/siemens/dxr2/board.c +9 -1
index af9d84f..df26340 100644
@@ -147,6 +147,14 @@ struct cmd_control dxr2_ddr3_cmd_ctrl_data = {
 	.cmd1dldiff = 0,
 	.cmd2dldiff = 0,
 };
+
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= DXR2_IOCTRL_VAL,
+	.cm1ioctl		= DXR2_IOCTRL_VAL,
+	.cm2ioctl		= DXR2_IOCTRL_VAL,
+	.dt0ioctl		= DXR2_IOCTRL_VAL,
+	.dt1ioctl		= DXR2_IOCTRL_VAL,
+};
 	/* pass values from eeprom */
 	dxr2_ddr3_emif_reg_data.sdram_tim1 = settings.ddr3.sdram_tim1;
 	dxr2_ddr3_emif_reg_data.sdram_tim2 = settings.ddr3.sdram_tim2;
@@ -168,7 +176,7 @@ struct cmd_control dxr2_ddr3_cmd_ctrl_data = {
 	dxr2_ddr3_cmd_ctrl_data.cmd2csratio = settings.ddr3.ddr3_sratio;
 	dxr2_ddr3_cmd_ctrl_data.cmd2iclkout = settings.ddr3.iclkout;
 
-	config_ddr(DDR_PLL_FREQ, DXR2_IOCTRL_VAL, &dxr2_ddr3_data,
+	config_ddr(DDR_PLL_FREQ, &ioregs, &dxr2_ddr3_data,
 		   &dxr2_ddr3_cmd_ctrl_data, &dxr2_ddr3_emif_reg_data, 0);
 }
 
board/siemens/pxm2/board.c +9 -1
index 2c1841f..16aec28 100644
@@ -74,7 +74,15 @@ struct cmd_control pxm2_ddr3_cmd_ctrl_data = {
 	.cmd2iclkout = 0,
 };
 
-	config_ddr(DDR_PLL_FREQ, DXR2_IOCTRL_VAL, &pxm2_ddr3_data,
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= DXR2_IOCTRL_VAL,
+	.cm1ioctl		= DXR2_IOCTRL_VAL,
+	.cm2ioctl		= DXR2_IOCTRL_VAL,
+	.dt0ioctl		= DXR2_IOCTRL_VAL,
+	.dt1ioctl		= DXR2_IOCTRL_VAL,
+};
+
+	config_ddr(DDR_PLL_FREQ, &ioregs, &pxm2_ddr3_data,
 		   &pxm2_ddr3_cmd_ctrl_data, &pxm2_ddr3_emif_reg_data, 0);
 }
 
board/siemens/rut/board.c +9 -1
index 5de8fc6..317350b 100644
@@ -79,7 +79,15 @@ struct cmd_control rut_ddr3_cmd_ctrl_data = {
 	.cmd2iclkout = 1,
 };
 
-	config_ddr(DDR_PLL_FREQ, RUT_IOCTRL_VAL, &rut_ddr3_data,
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= RUT_IOCTRL_VAL,
+	.cm1ioctl		= RUT_IOCTRL_VAL,
+	.cm2ioctl		= RUT_IOCTRL_VAL,
+	.dt0ioctl		= RUT_IOCTRL_VAL,
+	.dt1ioctl		= RUT_IOCTRL_VAL,
+};
+
+	config_ddr(DDR_PLL_FREQ, &ioregs, &rut_ddr3_data,
 		   &rut_ddr3_cmd_ctrl_data, &rut_ddr3_emif_reg_data, 0);
 }
 
board/ti/am335x/board.c +36 -4
index 8edd21b..aff2dba 100644
@@ -443,6 +443,38 @@ void set_mux_conf_regs(void)
 	enable_board_pin_mux(&header);
 }
 
+const struct ctrl_ioregs ioregs_evmsk = {
+	.cm0ioctl		= MT41J128MJT125_IOCTRL_VALUE,
+	.cm1ioctl		= MT41J128MJT125_IOCTRL_VALUE,
+	.cm2ioctl		= MT41J128MJT125_IOCTRL_VALUE,
+	.dt0ioctl		= MT41J128MJT125_IOCTRL_VALUE,
+	.dt1ioctl		= MT41J128MJT125_IOCTRL_VALUE,
+};
+
+const struct ctrl_ioregs ioregs_bonelt = {
+	.cm0ioctl		= MT41K256M16HA125E_IOCTRL_VALUE,
+	.cm1ioctl		= MT41K256M16HA125E_IOCTRL_VALUE,
+	.cm2ioctl		= MT41K256M16HA125E_IOCTRL_VALUE,
+	.dt0ioctl		= MT41K256M16HA125E_IOCTRL_VALUE,
+	.dt1ioctl		= MT41K256M16HA125E_IOCTRL_VALUE,
+};
+
+const struct ctrl_ioregs ioregs_evm15 = {
+	.cm0ioctl		= MT41J512M8RH125_IOCTRL_VALUE,
+	.cm1ioctl		= MT41J512M8RH125_IOCTRL_VALUE,
+	.cm2ioctl		= MT41J512M8RH125_IOCTRL_VALUE,
+	.dt0ioctl		= MT41J512M8RH125_IOCTRL_VALUE,
+	.dt1ioctl		= MT41J512M8RH125_IOCTRL_VALUE,
+};
+
+const struct ctrl_ioregs ioregs = {
+	.cm0ioctl		= MT47H128M16RT25E_IOCTRL_VALUE,
+	.cm1ioctl		= MT47H128M16RT25E_IOCTRL_VALUE,
+	.cm2ioctl		= MT47H128M16RT25E_IOCTRL_VALUE,
+	.dt0ioctl		= MT47H128M16RT25E_IOCTRL_VALUE,
+	.dt1ioctl		= MT47H128M16RT25E_IOCTRL_VALUE,
+};
+
 void sdram_init(void)
 {
 	__maybe_unused struct am335x_baseboard_id header;
@@ -460,18 +492,18 @@ void sdram_init(void)
 	}
 
 	if (board_is_evm_sk(&header))
-		config_ddr(303, MT41J128MJT125_IOCTRL_VALUE, &ddr3_data,
+		config_ddr(303, &ioregs_evmsk, &ddr3_data,
 			   &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
 	else if (board_is_bone_lt(&header))
-		config_ddr(400, MT41K256M16HA125E_IOCTRL_VALUE,
+		config_ddr(400, &ioregs_bonelt,
 			   &ddr3_beagleblack_data,
 			   &ddr3_beagleblack_cmd_ctrl_data,
 			   &ddr3_beagleblack_emif_reg_data, 0);
 	else if (board_is_evm_15_or_later(&header))
-		config_ddr(303, MT41J512M8RH125_IOCTRL_VALUE, &ddr3_evm_data,
+		config_ddr(303, &ioregs_evm15, &ddr3_evm_data,
 			   &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);
 	else
-		config_ddr(266, MT47H128M16RT25E_IOCTRL_VALUE, &ddr2_data,
+		config_ddr(266, &ioregs, &ddr2_data,
 			   &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0);
 }
 #endif
board/ti/am43xx/board.c +66 -0

84 lines not on this page · raw message

board/ti/ti814x/evm.c +2 -2
index e406326..56ec4b2 100644
@@ -100,9 +100,9 @@ void sdram_init(void)
 {
 	config_dmm(&evm_lisa_map_regs);
 
-	config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
+	config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data,
 		   &evm_ddr2_emif0_regs, 0);
-	config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
+	config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data,
 		   &evm_ddr2_emif1_regs, 1);
 }
 #endif
board/ti/ti816x/evm.c +8 -4
index 74d35e9..9e7d503 100644
@@ -206,13 +206,15 @@ void sdram_init(void)
 	if (CONFIG_TI816X_USE_EMIF0) {
 		ddr2_emif0_regs.emif_ddr_phy_ctlr_1 =
 			(get_cpu_rev() == 0x1 ? 0x0000010B : 0x0000030B);
-		config_ddr(0, 0, &ddr2_data, &ddr2_ctrl, &ddr2_emif0_regs, 0);
+		config_ddr(0, NULL, &ddr2_data, &ddr2_ctrl, &ddr2_emif0_regs,
+			   0);
 	}
 
 	if (CONFIG_TI816X_USE_EMIF1) {
 		ddr2_emif1_regs.emif_ddr_phy_ctlr_1 =
 			(get_cpu_rev() == 0x1 ? 0x0000010B : 0x0000030B);
-		config_ddr(1, 0, &ddr2_data, &ddr2_ctrl, &ddr2_emif1_regs, 1);
+		config_ddr(1, NULL, &ddr2_data, &ddr2_ctrl, &ddr2_emif1_regs,
+			   1);
 	}
 #endif
 
@@ -220,10 +222,12 @@ void sdram_init(void)
 	ddr3_data.datadldiff0 = (get_cpu_rev() == 0x1 ? 0x0 : 0xF);
 
 	if (CONFIG_TI816X_USE_EMIF0)
-		config_ddr(0, 0, &ddr3_data, &ddr3_ctrl, &ddr3_emif0_regs, 0);
+		config_ddr(0, NULL, &ddr3_data, &ddr3_ctrl, &ddr3_emif0_regs,
+			   0);
 
 	if (CONFIG_TI816X_USE_EMIF1)
-		config_ddr(1, 0, &ddr3_data, &ddr3_ctrl, &ddr3_emif1_regs, 1);
+		config_ddr(1, NULL, &ddr3_data, &ddr3_ctrl, &ddr3_emif1_regs,
+			   1);
 #endif
 }
 #endif /* CONFIG_SPL_BUILD */
Signature · 1 line
1.7.9.5
#35 lore raw

PATCH v2 12/14 ARM: AM43xx: EPOS_EVM: Add support for LPDDR2

Quoted 11 lines · Lokesh Vutla

AM4372 EPOS EVM has 1GB LPDDR2(Part no: MT42L256M32D2LG-25 WT:A) Adding LPDDR2 init sequence and register details for the same. Below is the brief description of LPDDR2 init sequence:
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register -> Wait till initialization is complete and the configure MR registers.

This patch does too many things, some of which affects AM335x and needs to be split up. I lost track of what you were doing as i scrolled down :\

Quoted 86 lines
---
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  147 +++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +++-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |    5 +
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   33 ++++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    1 +
 arch/arm/include/asm/emif.h                        |   12 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 +++++-
 board/ti/am43xx/board.c                            |   66 +++++++++
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 16 files changed, 373 insertions(+), 27 deletions(-)
arch/arm/cpu/armv7/am33xx/ddr.c +58 -0
index fa697c7..fbee51d 100644
@@ -36,6 +36,74 @@ static struct ddr_data_regs *ddr_data_reg[2] = {
 static struct ddr_cmdtctrl *ioctrl_reg = {
                        (struct ddr_cmdtctrl *)DDR_CONTROL_BASE_ADDR};
 
+static inline u32 get_mr(int nr, u32 cs, u32 mr_addr)
+{
+       u32 mr;
+
+       mr_addr |= cs << EMIF_REG_CS_SHIFT;
+       writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+
+       mr = readl(&emif_reg[nr]->emif_lpddr2_mode_reg_data);
+       debug("get_mr: EMIF1 cs %d mr %08x val 0x%x\n", cs, mr_addr, mr);
+       if (((mr & 0x0000ff00) >>  8) == (mr & 0xff) &&
+           ((mr & 0x00ff0000) >> 16) == (mr & 0xff) &&
+           ((mr & 0xff000000) >> 24) == (mr & 0xff))
+               return mr & 0xff;
+       else
+               return mr;
+}
+
+static inline void set_mr(int nr, u32 cs, u32 mr_addr, u32 mr_val)
+{
+       mr_addr |= cs << EMIF_REG_CS_SHIFT;
+       writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+       writel(mr_val, &emif_reg[nr]->emif_lpddr2_mode_reg_data);
+}
+
+static void configure_mr(int nr, u32 cs)
+{
+       u32 mr_addr;
+
+       while (get_mr(nr, cs, LPDDR2_MR0) & LPDDR2_MR0_DAI_MASK)
+               ;
+       set_mr(nr, cs, LPDDR2_MR10, 0x56);
+
+       set_mr(nr, cs, LPDDR2_MR1, 0x43);
+       set_mr(nr, cs, LPDDR2_MR2, 0x2);
+
+       mr_addr = LPDDR2_MR2 | EMIF_REG_REFRESH_EN_MASK;
+       set_mr(nr, cs, mr_addr, 0x2);
+}
+
+/*
+ * Configure EMIF4D5 registers and MR registers
+ */
+void config_sdram_emif4d5(const struct emif_regs *regs, int nr)
+{
+       writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl);
+       writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl_shdw);
+       writel(0x1, &emif_reg[nr]->emif_iodft_tlgc);
+       writel(regs->zq_config, &emif_reg[nr]->emif_zq_config);
+
+       writel(regs->temp_alert_config, &emif_reg[nr]->emif_temp_alert_config);
+       writel(regs->emif_rd_wr_lvl_rmp_win,
+              &emif_reg[nr]->emif_rd_wr_lvl_rmp_win);
+       writel(regs->emif_rd_wr_lvl_rmp_ctl,
+              &emif_reg[nr]->emif_rd_wr_lvl_rmp_ctl);
+       writel(regs->emif_rd_wr_lvl_ctl, &emif_reg[nr]->emif_rd_wr_lvl_ctl);
+       writel(regs->emif_rd_wr_exec_thresh,
+              &emif_reg[nr]->emif_rd_wr_exec_thresh);
+

arch/arm/cpu/armv7/am33xx/ddr.c static struct ddr_data_regs *ddr_data_reg[2] = { · line 106

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/ddr.c +10 -0
+       clrbits_le32(&emif_reg[nr]->emif_sdram_ref_ctrl,
+                    EMIF_REG_INITREF_DIS_MASK);
+
+       writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config);
+       writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl);
+
+       configure_mr(nr, 0);
+       configure_mr(nr, 1);
+}
+

Why can't this portion be shared with the other OMAPs? It looks to be following a recommended sequence and i can't see why that would vary.

It's just too hard to review so many changes in a single patch so i'll stop here, sorry.

#36 lore raw

PATCH v2 12/14 ARM: AM43xx: EPOS_EVM: Add support for LPDDR2

Quoted 13 lines · Vaibhav Bedia
Quoted 11 lines · Lokesh Vutla

AM4372 EPOS EVM has 1GB LPDDR2(Part no: MT42L256M32D2LG-25 WT:A) Adding LPDDR2 init sequence and register details for the same. Below is the brief description of LPDDR2 init sequence:
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register -> Wait till initialization is complete and the configure MR registers.

Quoted 2 lines

This patch does too many things, some of which affects AM335x and needs to be split up. I lost track of what you were doing as i scrolled down :\

It does only two things. Update IO settings and emif configuration. I wanted to keep these things in a single patch so that if some functionality breaks down I can burn down to this patch.

Quoted 92 lines
Quoted 92 lines
---
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  147 +++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +++-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |    5 +
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   33 ++++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    1 +
 arch/arm/include/asm/emif.h                        |   12 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 +++++-
 board/ti/am43xx/board.c                            |   66 +++++++++
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 16 files changed, 373 insertions(+), 27 deletions(-)
arch/arm/cpu/armv7/am33xx/ddr.c +63 -0
index fa697c7..fbee51d 100644
@@ -36,6 +36,74 @@ static struct ddr_data_regs *ddr_data_reg[2] = {
 static struct ddr_cmdtctrl *ioctrl_reg = {
                        (struct ddr_cmdtctrl *)DDR_CONTROL_BASE_ADDR};
 
+static inline u32 get_mr(int nr, u32 cs, u32 mr_addr)
+{
+       u32 mr;
+
+       mr_addr |= cs << EMIF_REG_CS_SHIFT;
+       writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+
+       mr = readl(&emif_reg[nr]->emif_lpddr2_mode_reg_data);
+       debug("get_mr: EMIF1 cs %d mr %08x val 0x%x\n", cs, mr_addr, mr);
+       if (((mr & 0x0000ff00) >>  8) == (mr & 0xff) &&
+           ((mr & 0x00ff0000) >> 16) == (mr & 0xff) &&
+           ((mr & 0xff000000) >> 24) == (mr & 0xff))
+               return mr & 0xff;
+       else
+               return mr;
+}
+
+static inline void set_mr(int nr, u32 cs, u32 mr_addr, u32 mr_val)
+{
+       mr_addr |= cs << EMIF_REG_CS_SHIFT;
+       writel(mr_addr, &emif_reg[nr]->emif_lpddr2_mode_reg_cfg);
+       writel(mr_val, &emif_reg[nr]->emif_lpddr2_mode_reg_data);
+}
+
+static void configure_mr(int nr, u32 cs)
+{
+       u32 mr_addr;
+
+       while (get_mr(nr, cs, LPDDR2_MR0) & LPDDR2_MR0_DAI_MASK)
+               ;
+       set_mr(nr, cs, LPDDR2_MR10, 0x56);
+
+       set_mr(nr, cs, LPDDR2_MR1, 0x43);
+       set_mr(nr, cs, LPDDR2_MR2, 0x2);
+
+       mr_addr = LPDDR2_MR2 | EMIF_REG_REFRESH_EN_MASK;
+       set_mr(nr, cs, mr_addr, 0x2);
+}
+
+/*
+ * Configure EMIF4D5 registers and MR registers
+ */
+void config_sdram_emif4d5(const struct emif_regs *regs, int nr)
+{
+       writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl);
+       writel(0x0, &emif_reg[nr]->emif_pwr_mgmt_ctrl_shdw);
+       writel(0x1, &emif_reg[nr]->emif_iodft_tlgc);
+       writel(regs->zq_config, &emif_reg[nr]->emif_zq_config);
+
+       writel(regs->temp_alert_config, &emif_reg[nr]->emif_temp_alert_config);
+       writel(regs->emif_rd_wr_lvl_rmp_win,
+              &emif_reg[nr]->emif_rd_wr_lvl_rmp_win);
+       writel(regs->emif_rd_wr_lvl_rmp_ctl,
+              &emif_reg[nr]->emif_rd_wr_lvl_rmp_ctl);
+       writel(regs->emif_rd_wr_lvl_ctl, &emif_reg[nr]->emif_rd_wr_lvl_ctl);
+       writel(regs->emif_rd_wr_exec_thresh,
+              &emif_reg[nr]->emif_rd_wr_exec_thresh);
+
+       clrbits_le32(&emif_reg[nr]->emif_sdram_ref_ctrl,
+                    EMIF_REG_INITREF_DIS_MASK);
+
+       writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config);
+       writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl);
Quoted 8 lines

arch/arm/cpu/armv7/am33xx/ddr.c static struct ddr_data_regs *ddr_data_reg[2] = { · line 106

Quoted 5 lines
arch/arm/cpu/armv7/am33xx/ddr.c +5 -0
+
+       configure_mr(nr, 0);
+       configure_mr(nr, 1);
+}
+

Why can't this portion be shared with the other OMAPs? It looks to be following a recommended sequence and i can't see why that would vary.

Yes, my ultimate goal is to have a single emif file, but with the current position of emif file for OMAP's I can't reuse.
This is in my To do list. I have already discussed this with Tom

Thanks
Lokesh

Quoted 4 lines

It's just too hard to review so many changes in a single patch so i'll stop here, sorry.

#37 lore raw

PATCH v2 12/14 ARM: AM43xx: EPOS_EVM: Add support for LPDDR2

Quoted 14 lines · Lokesh Vutla
Quoted 13 lines · Vaibhav Bedia
Quoted 11 lines · Lokesh Vutla

AM4372 EPOS EVM has 1GB LPDDR2(Part no: MT42L256M32D2LG-25 WT:A) Adding LPDDR2 init sequence and register details for the same. Below is the brief description of LPDDR2 init sequence:
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register -> Wait till initialization is complete and the configure MR registers.

Quoted 5 lines
Quoted 2 lines

This patch does too many things, some of which affects AM335x and needs to be split up. I lost track of what you were doing as i scrolled down :\

It does only two things. Update IO settings and emif configuration. I wanted to keep these things in a single patch so that if some functionality breaks down I can burn down to this patch.

That doesn't mean that you mix up everything in one humungous patch and try to force your way through.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  147 +++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +++-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |    5 +
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   33 ++++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    1 +
 arch/arm/include/asm/emif.h                        |   12 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 +++++-
 board/ti/am43xx/board.c                            |   66 +++++++++
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 16 files changed, 373 insertions(+), 27 deletions(-)

As the diffstat above shows, this patch affects a critical portion of AM335x, TI81xx and and at the same time adds in support for a new SoC. If that's not mixing up things i honestly don't know what is.

And if you have some discussions off-list you should at least attempt to capture the summary of what was agreed to do taken up as TODO for the benefit of others. If there's a agreed upon patch to improving the code that helps is overlooking some short term compromises.

#38 lore raw

PATCH v2 12/14 ARM: AM43xx: EPOS_EVM: Add support for LPDDR2

Quoted 15 lines · Vaibhav Bedia
Quoted 14 lines · Lokesh Vutla
Quoted 13 lines · Vaibhav Bedia
Quoted 11 lines · Lokesh Vutla

AM4372 EPOS EVM has 1GB LPDDR2(Part no: MT42L256M32D2LG-25 WT:A) Adding LPDDR2 init sequence and register details for the same. Below is the brief description of LPDDR2 init sequence:
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register -> Wait till initialization is complete and the configure MR registers.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

This patch does too many things, some of which affects AM335x and needs to be split up. I lost track of what you were doing as i scrolled down :\

It does only two things. Update IO settings and emif configuration. I wanted to keep these things in a single patch so that if some functionality breaks down I can burn down to this patch.

That doesn't mean that you mix up everything in one humungous patch and try to force your way through.

OK, Ill separate out EMIF configuration and io settings and repost.

Thanks
Lokesh

Quoted 31 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
---
 arch/arm/cpu/armv7/am33xx/ddr.c                    |  147 +++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/emif4.c                  |   25 +++-
 arch/arm/include/asm/arch-am33xx/clocks_am33xx.h   |    3 +
 arch/arm/include/asm/arch-am33xx/cpu.h             |    5 +
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |   33 ++++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |    1 +
 arch/arm/include/asm/emif.h                        |   12 ++
 board/isee/igep0033/board.c                        |   10 +-
 board/phytec/pcm051/board.c                        |   12 +-
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
 board/siemens/dxr2/board.c                         |   10 +-
 board/siemens/pxm2/board.c                         |   10 +-
 board/siemens/rut/board.c                          |   10 +-
 board/ti/am335x/board.c                            |   40 +++++-
 board/ti/am43xx/board.c                            |   66 +++++++++
 board/ti/ti814x/evm.c                              |    4 +-
 board/ti/ti816x/evm.c                              |   12 +-
 16 files changed, 373 insertions(+), 27 deletions(-)

As the diffstat above shows, this patch affects a critical portion of AM335x, TI81xx and and at the same time adds in support for a new SoC. If that's not mixing up things i honestly don't know what is.

And if you have some discussions off-list you should at least attempt to capture the summary of what was agreed to do taken up as TODO for the benefit of others. If there's a agreed upon patch to improving the code that helps is overlooking some short term compromises.

#39 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

In reply to Lokesh Vutla

GP EVM has 1GB DDR3 attached(Part no: MT41K512M8RH).
Adding details for the same.
Below is the brief description of DDR3 init sequence(SW leveling):
-> Enable VTT regulator
-> Configure VTP
-> Configure DDR IO settings
-> Disable initialization and refreshes until EMIF registers are programmed. -> Program Timing registers
-> Program leveling registers
-> Program PHY control and Temp alert and ZQ config registers. -> Enable initialization and refreshes and configure SDRAM CONFIG register

---
 arch/arm/cpu/armv7/am33xx/ddr.c              |    6 +-
 arch/arm/cpu/armv7/omap-common/emif-common.c |   14 ----
 arch/arm/include/asm/arch-am33xx/ddr_defs.h  |    8 +++
 arch/arm/include/asm/emif.h                  |   14 ++++
 board/ti/am43xx/board.c                      |   92 +++++++++++++++++++++++++-
 board/ti/am43xx/mux.c                        |    8 +++
 6 files changed, 123 insertions(+), 19 deletions(-)
arch/arm/cpu/armv7/am33xx/ddr.c +4 -2
index fbee51d..389fdfc 100644
@@ -100,8 +100,10 @@ void config_sdram_emif4d5(const struct emif_regs *regs, int nr)
 	writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config);
 	writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl);
 
-	configure_mr(nr, 0);
-	configure_mr(nr, 1);
+	if (emif_sdram_type() == EMIF_SDRAM_TYPE_LPDDR2) {
+		configure_mr(nr, 0);
+		configure_mr(nr, 1);
+	}
 }
 
 /**
arch/arm/cpu/armv7/omap-common/emif-common.c +0 -14
index b0e1caa..d8a15be 100644
@@ -50,20 +50,6 @@ inline u32 emif_num(u32 base)
 		return 0;
 }
 
-/*
- * Get SDRAM type connected to EMIF.
- * Assuming similar SDRAM parts are connected to both EMIF's
- * which is typically the case. So it is sufficient to get
- * SDRAM type from EMIF1.
- */
-u32 emif_sdram_type()
-{
-	struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
-
-	return (readl(&emif->emif_sdram_config) &
-		EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
-}
-
 static inline u32 get_mr(u32 base, u32 cs, u32 mr_addr)
 {
 	u32 mr;
arch/arm/include/asm/arch-am33xx/ddr_defs.h +8 -0
index c98ab7f..646e50f 100644
@@ -138,6 +138,14 @@
 #define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
 #define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
 
+#define  DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_IOCTRL_VALUE   0x84
+#define  DDR3_DATA0_IOCTRL_VALUE   0x84
+#define  DDR3_DATA1_IOCTRL_VALUE   0x84
+#define  DDR3_DATA2_IOCTRL_VALUE   0x84
+#define  DDR3_DATA3_IOCTRL_VALUE   0x84
+
 /**
  * Configure DMM
  */
arch/arm/include/asm/emif.h +14 -0
index ce6b229..b4a8c9f 100644
@@ -1151,6 +1151,20 @@ static inline u32 get_emif_rev(u32 base)
 		>> EMIF_REG_MAJOR_REVISION_SHIFT;
 }
 
+/*
+ * Get SDRAM type connected to EMIF.
+ * Assuming similar SDRAM parts are connected to both EMIF's
+ * which is typically the case. So it is sufficient to get
+ * SDRAM type from EMIF1.
+ */
+static inline u32 emif_sdram_type(void)
+{
+	struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
+
+	return (readl(&emif->emif_sdram_config) &
+		EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
+}
+
 /* assert macros */
 #if defined(DEBUG)
 #define emif_assert(c)	({ if (!(c)) for (;;); })
board/ti/am43xx/board.c +89 -3

114 lines not on this page · raw message

board/ti/am43xx/mux.c +8 -0
index a2d72dd..810b194 100644
@@ -33,6 +33,11 @@ static struct module_pin_mux i2c0_pin_mux[] = {
 	{-1},
 };
 
+static struct module_pin_mux gpio0_22_pin_mux[] = {
+	{OFFSET(ddr_ba2), (MODE(9) | PULLUP_EN)},	/* GPIO0_22 */
+	{-1},
+};
+
 void enable_uart0_pin_mux(void)
 {
 	configure_module_pin_mux(uart0_pin_mux);
@@ -42,6 +47,9 @@ void enable_board_pin_mux(void)
 {
 	configure_module_pin_mux(mmc0_pin_mux);
 	configure_module_pin_mux(i2c0_pin_mux);
+
+	if (board_is_gpevm())
+		configure_module_pin_mux(gpio0_22_pin_mux);
 }
 
 void enable_i2c0_pin_mux(void)
Signature · 1 line
1.7.9.5
#40 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 48 lines
arch/arm/cpu/armv7/omap-common/emif-common.c +0 -14
-/*
- * Get SDRAM type connected to EMIF.
- * Assuming similar SDRAM parts are connected to both EMIF's
- * which is typically the case. So it is sufficient to get
- * SDRAM type from EMIF1.
- */
-u32 emif_sdram_type()
-{
-       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
-
-       return (readl(&emif->emif_sdram_config) &
-               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
-}
-
 static inline u32 get_mr(u32 base, u32 cs, u32 mr_addr)
 {
        u32 mr;
arch/arm/include/asm/arch-am33xx/ddr_defs.h +8 -0
index c98ab7f..646e50f 100644
@@ -138,6 +138,14 @@
 #define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
 #define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
 
+#define  DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_IOCTRL_VALUE   0x84
+#define  DDR3_DATA0_IOCTRL_VALUE   0x84
+#define  DDR3_DATA1_IOCTRL_VALUE   0x84
+#define  DDR3_DATA2_IOCTRL_VALUE   0x84
+#define  DDR3_DATA3_IOCTRL_VALUE   0x84
+
 /**
  * Configure DMM
  */
arch/arm/include/asm/emif.h +4 -0
index ce6b229..b4a8c9f 100644
@@ -1151,6 +1151,20 @@ static inline u32 get_emif_rev(u32 base)
                >> EMIF_REG_MAJOR_REVISION_SHIFT;
 }
 
+/*
+ * Get SDRAM type connected to EMIF.
+ * Assuming similar SDRAM parts are connected to both EMIF's
+ * which is typically the case. So it is sufficient to get

arch/arm/include/asm/emif.h static inline u32 get_emif_rev(u32 base) · line 1167

Quoted 10 lines
arch/arm/include/asm/emif.h +10 -0
+ * SDRAM type from EMIF1.
+ */
+static inline u32 emif_sdram_type(void)
+{
+       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
+
+       return (readl(&emif->emif_sdram_config) &
+               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
+}
+

This change don't make any sense to me. How are the EMIF register bits any indication
of what memory time is used especially for DDR2/3?

[...]

Quoted 5 lines
arch/arm/include/asm/emif.h +4 -0
+static void enable_vtt_regulator(void)
+{
+       u32 temp;
+

arch/arm/include/asm/emif.h static inline u32 get_emif_rev(u32 base)

Quoted 10 lines
arch/arm/include/asm/emif.h +10 -0
+       /* enable module */
+       writel(0x0, AM33XX_GPIO0_BASE + OMAP_GPIO_CTRL);
+
+       /*enable output for GPIO0_22*/
+       writel((1 << 22), AM33XX_GPIO0_BASE + OMAP_GPIO_SETDATAOUT);
+       temp = readl(AM33XX_GPIO0_BASE + OMAP_GPIO_OE);
+       temp = temp & ~(1 << 22);
+       writel(temp, AM33XX_GPIO0_BASE + OMAP_GPIO_OE);
+}
+

No magic nos. please. I think you have a #def the pin used for VTT regulator in the config file - makes it simpler for others who design their own board.

Regards,
Vaibhav

#41 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

Quoted 57 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 54 lines
arch/arm/cpu/armv7/omap-common/emif-common.c +0 -14
-/*
- * Get SDRAM type connected to EMIF.
- * Assuming similar SDRAM parts are connected to both EMIF's
- * which is typically the case. So it is sufficient to get
- * SDRAM type from EMIF1.
- */
-u32 emif_sdram_type()
-{
-       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
-
-       return (readl(&emif->emif_sdram_config) &
-               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
-}
-
 static inline u32 get_mr(u32 base, u32 cs, u32 mr_addr)
 {
        u32 mr;
arch/arm/include/asm/arch-am33xx/ddr_defs.h +8 -0
index c98ab7f..646e50f 100644
@@ -138,6 +138,14 @@
 #define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
 #define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
 
+#define  DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_IOCTRL_VALUE   0x84
+#define  DDR3_DATA0_IOCTRL_VALUE   0x84
+#define  DDR3_DATA1_IOCTRL_VALUE   0x84
+#define  DDR3_DATA2_IOCTRL_VALUE   0x84
+#define  DDR3_DATA3_IOCTRL_VALUE   0x84
+
 /**
  * Configure DMM
  */
arch/arm/include/asm/emif.h +10 -0
index ce6b229..b4a8c9f 100644
@@ -1151,6 +1151,20 @@ static inline u32 get_emif_rev(u32 base)
                >> EMIF_REG_MAJOR_REVISION_SHIFT;
 }
 
+/*
+ * Get SDRAM type connected to EMIF.
+ * Assuming similar SDRAM parts are connected to both EMIF's
+ * which is typically the case. So it is sufficient to get
+ * SDRAM type from EMIF1.
+ */
+static inline u32 emif_sdram_type(void)
+{
+       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
+
Quoted 8 lines

arch/arm/include/asm/emif.h static inline u32 get_emif_rev(u32 base) · line 1167

Quoted 4 lines
arch/arm/include/asm/emif.h +4 -0
+       return (readl(&emif->emif_sdram_config) &
+               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
+}
+

This change don't make any sense to me. How are the EMIF register bits any indication
of what memory time is used especially for DDR2/3?

What is not making sense here ?
If you go and read EMIF spec, it is clearly written that on coming out of reset HW sequence starts according to the value populated in SDRAM config register. As far as I am concerned this is the best way to differentiate between Memories.

Can you tell me a better way to differentiate between memories in emif file ? Definitely I should not use board_is_foo() functions.

Thanks
Lokesh

Quoted 24 lines

[...]

Quoted 5 lines
arch/arm/include/asm/emif.h +4 -0
+static void enable_vtt_regulator(void)
+{
+       u32 temp;
+

arch/arm/include/asm/emif.h

Quoted 10 lines
arch/arm/include/asm/emif.h +10 -0
+       /* enable module */
+       writel(0x0, AM33XX_GPIO0_BASE + OMAP_GPIO_CTRL);
+
+       /*enable output for GPIO0_22*/
+       writel((1 << 22), AM33XX_GPIO0_BASE + OMAP_GPIO_SETDATAOUT);
+       temp = readl(AM33XX_GPIO0_BASE + OMAP_GPIO_OE);
+       temp = temp & ~(1 << 22);
+       writel(temp, AM33XX_GPIO0_BASE + OMAP_GPIO_OE);
+}
+

No magic nos. please. I think you have a #def the pin used for VTT regulator in the config file - makes it simpler for others who design their own board.

Regards,
Vaibhav

#42 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

Quoted 66 lines · Lokesh Vutla
Quoted 57 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 54 lines
arch/arm/cpu/armv7/omap-common/emif-common.c +0 -14
-/*
- * Get SDRAM type connected to EMIF.
- * Assuming similar SDRAM parts are connected to both EMIF's
- * which is typically the case. So it is sufficient to get
- * SDRAM type from EMIF1.
- */
-u32 emif_sdram_type()
-{
-       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
-
-       return (readl(&emif->emif_sdram_config) &
-               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
-}
-
 static inline u32 get_mr(u32 base, u32 cs, u32 mr_addr)
 {
        u32 mr;
arch/arm/include/asm/arch-am33xx/ddr_defs.h +8 -0
index c98ab7f..646e50f 100644
@@ -138,6 +138,14 @@
 #define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
 #define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
 
+#define  DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_IOCTRL_VALUE   0x84
+#define  DDR3_DATA0_IOCTRL_VALUE   0x84
+#define  DDR3_DATA1_IOCTRL_VALUE   0x84
+#define  DDR3_DATA2_IOCTRL_VALUE   0x84
+#define  DDR3_DATA3_IOCTRL_VALUE   0x84
+
 /**
  * Configure DMM
  */
arch/arm/include/asm/emif.h +10 -0
index ce6b229..b4a8c9f 100644
@@ -1151,6 +1151,20 @@ static inline u32 get_emif_rev(u32 base)
                >> EMIF_REG_MAJOR_REVISION_SHIFT;
 }
 
+/*
+ * Get SDRAM type connected to EMIF.
+ * Assuming similar SDRAM parts are connected to both EMIF's
+ * which is typically the case. So it is sufficient to get
+ * SDRAM type from EMIF1.
+ */
+static inline u32 emif_sdram_type(void)
+{
+       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
+
Quoted 8 lines

arch/arm/include/asm/emif.h static inline u32 get_emif_rev(u32 base) · line 1167

Quoted 4 lines
arch/arm/include/asm/emif.h +4 -0
+       return (readl(&emif->emif_sdram_config) &
+               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
+}
+

This change don't make any sense to me. How are the EMIF register bits any indication
of what memory time is used especially for DDR2/3?

Quoted 5 lines

What is not making sense here ?
If you go and read EMIF spec, it is clearly written that on coming out of reset HW sequence starts according to the value populated in SDRAM config register. As far as I am concerned this is the best way to differentiate between Memories.

Take a moment to think about where that register value comes from. Does it somehow automagically get reconfigured when the chip is put in a board with LPDDR2 vs DDR2 vs DDR3? While you are at it also look at the JEDEC specs to figure out is there's some way to probe the DDR2/3 memory types.

Quoted 3 lines

Can you tell me a better way to differentiate between memories in emif file ? Definitely I should not use board_is_foo() functions.

AFAIK there is none and hence this way of trying to get the memory type is broken.

Moreover, my understanding was that one of the prime functions of the EEPROM board data was to enable differentiation between the memory types.

#43 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

Quoted 73 lines · Vaibhav Bedia
Quoted 66 lines · Lokesh Vutla
Quoted 57 lines · Vaibhav Bedia

On Thu, Nov 21, 2013 at 1:18 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 54 lines
arch/arm/cpu/armv7/omap-common/emif-common.c +0 -14
-/*
- * Get SDRAM type connected to EMIF.
- * Assuming similar SDRAM parts are connected to both EMIF's
- * which is typically the case. So it is sufficient to get
- * SDRAM type from EMIF1.
- */
-u32 emif_sdram_type()
-{
-       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
-
-       return (readl(&emif->emif_sdram_config) &
-               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
-}
-
 static inline u32 get_mr(u32 base, u32 cs, u32 mr_addr)
 {
        u32 mr;
arch/arm/include/asm/arch-am33xx/ddr_defs.h +8 -0
index c98ab7f..646e50f 100644
@@ -138,6 +138,14 @@
 #define  LPDDR2_DATA2_IOCTRL_VALUE   0x20000294
 #define  LPDDR2_DATA3_IOCTRL_VALUE   0x20000294
 
+#define  DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000
+#define  DDR3_ADDRCTRL_IOCTRL_VALUE   0x84
+#define  DDR3_DATA0_IOCTRL_VALUE   0x84
+#define  DDR3_DATA1_IOCTRL_VALUE   0x84
+#define  DDR3_DATA2_IOCTRL_VALUE   0x84
+#define  DDR3_DATA3_IOCTRL_VALUE   0x84
+
 /**
  * Configure DMM
  */
arch/arm/include/asm/emif.h +10 -0
index ce6b229..b4a8c9f 100644
@@ -1151,6 +1151,20 @@ static inline u32 get_emif_rev(u32 base)
                >> EMIF_REG_MAJOR_REVISION_SHIFT;
 }
 
+/*
+ * Get SDRAM type connected to EMIF.
+ * Assuming similar SDRAM parts are connected to both EMIF's
+ * which is typically the case. So it is sufficient to get
+ * SDRAM type from EMIF1.
+ */
+static inline u32 emif_sdram_type(void)
+{
+       struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
+
Quoted 8 lines

arch/arm/include/asm/emif.h static inline u32 get_emif_rev(u32 base) · line 1167

Quoted 4 lines
arch/arm/include/asm/emif.h +4 -0
+       return (readl(&emif->emif_sdram_config) &
+               EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
+}
+

This change don't make any sense to me. How are the EMIF register bits any indication
of what memory time is used especially for DDR2/3?

Quoted 5 lines

What is not making sense here ?
If you go and read EMIF spec, it is clearly written that on coming out of reset HW sequence starts according to the value populated in SDRAM config register. As far as I am concerned this is the best way to differentiate between Memories.

Quoted 4 lines

Take a moment to think about where that register value comes from. Does it somehow automagically get reconfigured when the chip is put in a board with LPDDR2 vs DDR2 vs DDR3? While you are at it also look at the JEDEC specs to figure out is there's some way to probe the DDR2/3 memory types.

Ideally the default value should be exported from e-fuse values. EMIF does some HW sequence according to the value exported here. This filed tells what type of memory it is.

I understand the point what if efuse is not blown. I am using this only after we write into sdarm_config register. This can confirm that we get a correct value.
If this is not sufficient we can hardcode the register during startup only ?
One more thing is we can get from MR registers of DDR.
But for DDR3 we cannot access MR registers. That is why I didn't go with this approach.

Currently EEPROM doesn't have any details about DDR. Please let me know if this approach is not good enough.

Thanks and regards,
Lokesh

Quoted 11 lines
Quoted 4 lines

Can you tell me a better way to differentiate between memories in emif file ? Definitely I should not use board_is_foo() functions.

AFAIK there is none and hence this way of trying to get the memory type is broken.

Moreover, my understanding was that one of the prime functions of the EEPROM board data was to enable differentiation between the memory types.

#44 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

On Wed, Nov 27, 2013 at 4:34 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 4 lines

Ideally the default value should be exported from e-fuse values. EMIF does some HW sequence according to the value exported here. This filed tells what type of memory it is.

No, eFuse is not the right place for this information. If you were to do that you would be restricting what memory type is supported on a particular device that gets shipped and that's not a scalable model.

Quoted 3 lines

I understand the point what if efuse is not blown. I am using this only after we write into sdarm_config register. This can confirm that we get a correct value.
If this is not sufficient we can hardcode the register during startup only ?

I don't see any value in writing some value in the EMIF register at one place and then using that here. If you already know what register values to program you already know the memory type.

Another place where the memory type information is needed is when the device enters low power state and the EMIF contents are lost. Rather than having to invent one more way of detecting the memory type in resume from low power state you could work out a persistent storage area (RTC scratchpad maybe? assuming the RTC is powered up) and use that in all the places. Requires some thought about the whole sequence but definitely doable IMHO.

Quoted 3 lines

One more thing is we can get from MR registers of DDR.
But for DDR3 we cannot access MR registers. That is why I didn't go with this approach.

So now you know why things just worked on OMAP3 (and OMAP4?) and not on TI81xx, AM335x and AM437x :)

Quoted 3 lines

Currently EEPROM doesn't have any details about DDR. Please let me know if this approach is not good enough.

Since there's no speced way of detecting the memory type you should push for the right information to be made available via the EEPROM and write generic code.
But hey that's for you to decide :)

Regards,
Vaibhav

#45 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

Quoted 10 lines · Vaibhav Bedia

On Wed, Nov 27, 2013 at 4:34 AM, Lokesh Vutla <[email protected]> wrote:
[...]

Quoted 4 lines

Ideally the default value should be exported from e-fuse values. EMIF does some HW sequence according to the value exported here. This filed tells what type of memory it is.

No, eFuse is not the right place for this information. If you were to do that you would be restricting what memory type is supported on a particular device that gets shipped and that's not a scalable model.

At least this was the case for OMAPs. So it worked well..:)

Quoted 8 lines
Quoted 4 lines

I understand the point what if efuse is not blown. I am using this only after we write into sdarm_config register. This can confirm that we get a correct value.
If this is not sufficient we can hardcode the register during startup only ?

I don't see any value in writing some value in the EMIF register at one place and then using that here. If you already know what register values to program you already know the memory type.

Yes, according to the board we are passing the registers that means we know the memory type. The same information I am getting from registers.

Quoted 7 lines

Another place where the memory type information is needed is when the device enters low power state and the EMIF contents are lost. Rather than having to invent one more way of detecting the memory type in resume from low power state you could work out a persistent storage area (RTC scratchpad maybe? assuming the RTC is powered up) and use that in all the places. Requires some thought about the whole sequence but definitely doable IMHO.

We should not rely on RTC here. I don't think U-Boot should worry about low power state. You mean to say about passing this information to kernel?
In the current kernel also memory type is derived according to the SDRAM CONFIG register only. So I thought this would be good enough.

Thanks and regards,
Lokesh

Quoted 20 lines
Quoted 4 lines

One more thing is we can get from MR registers of DDR.
But for DDR3 we cannot access MR registers. That is why I didn't go with this approach.

So now you know why things just worked on OMAP3 (and OMAP4?) and not on TI81xx, AM335x and AM437x :)

Quoted 3 lines

Currently EEPROM doesn't have any details about DDR. Please let me know if this approach is not good enough.

Since there's no speced way of detecting the memory type you should push for the right information to be made available via the EEPROM and write generic code.
But hey that's for you to decide :)

Regards,
Vaibhav

#46 lore raw

PATCH v2 13/14 ARM: AM43xx: GP_EVM: Add support for DDR3

On Sun, Dec 1, 2013 at 11:21 PM, Lokesh Vutla <[email protected]> wrote:
][...]

Quoted 2 lines

We should not rely on RTC here. I don't think U-Boot should worry about low power state. You mean to say about passing this information to kernel?

No. I am not asking you to pass this to the kernel.

Quoted 3 lines

In the current kernel also memory type is derived according to the SDRAM CONFIG register only. So I thought this would be good enough.

The only problem with this being that register is also lost when you go lower than DeepSleep
and would require you to figure out how to get the memory type.

Your call though. I guess i am just trying to over-engineer things ;)

#47 lore raw

PATCH v2 14/14 ARM: AM43xx: Add Maintainer

In reply to Lokesh Vutla

Adding Maintainer for AM43xx.

---
 boards.cfg |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boards.cfg +1 -1
index e742746..7cd19f7 100644
@@ -263,7 +263,7 @@ Active  arm         armv7          am33xx      ti              am335x
 Active  arm         armv7          am33xx      ti              am335x              am335x_evm_uart4                     am335x_evm:SERIAL5,CONS_INDEX=1,NAND                                                                                              Tom Rini <[email protected]>
 Active  arm         armv7          am33xx      ti              am335x              am335x_evm_uart5                     am335x_evm:SERIAL6,CONS_INDEX=1,NAND                                                                                              Tom Rini <[email protected]>
 Active  arm         armv7          am33xx      ti              am335x              am335x_evm_usbspl                    am335x_evm:SERIAL1,CONS_INDEX=1,NAND,SPL_USBETH_SUPPORT                                                                           Tom Rini <[email protected]>
-Active  arm         armv7          am33xx      ti              am43xx              am43xx_evm                           am43xx_evm:SERIAL1,CONS_INDEX=1                                                                                                   -
+Active  arm         armv7          am33xx      ti              am43xx              am43xx_evm                           am43xx_evm:SERIAL1,CONS_INDEX=1                                                                                                   Lokesh Vutla <[email protected]>
 Active  arm         armv7          am33xx      ti              ti814x              ti814x_evm                           -                                                                                                                                 Matt Porter <[email protected]>
 Active  arm         armv7          am33xx      ti              ti816x              ti816x_evm                           -                                                                                                                                 -
 Active  arm         armv7          at91        atmel           sama5d3xek          sama5d3xek_mmc                       sama5d3xek:SAMA5D3,SYS_USE_MMC                                                                                                    Bo Shen <[email protected]>
Signature · 1 line
1.7.9.5