Skip to contentSkip to conversation

Prepare for TI816X : reuse existing code from TI814X

PATCH Superseded TENART Antoine 3 participants 8 messages Apr 12, 2013 – Apr 15, 2013 1 message not in the archive

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/3 Prepare for TI816X : reuse existing code from TI814X

Rename some CONFIG_TI814X to a more generic CONFIG_81XX

---
 Makefile                                |    2 +-
 arch/arm/cpu/armv7/Makefile             |    2 +-
 arch/arm/cpu/armv7/omap-common/Makefile |    2 +-
 arch/arm/include/asm/arch-am33xx/cpu.h  |    2 +-
 arch/arm/include/asm/arch-am33xx/omap.h |    2 +-
 drivers/serial/ns16550.c                |    4 ++--
 spl/Makefile                            |    2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)
Makefile +1 -1
index 7273fa4..811e7b6 100644
@@ -330,7 +330,7 @@ LIBS-y += api/libapi.o
 LIBS-y += post/libpost.o
 LIBS-y += test/libtest.o
 
-ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI814X),)
+ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI81XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
 endif
 
arch/arm/cpu/armv7/Makefile +1 -1
index c961247..9bb2837 100644
@@ -32,7 +32,7 @@ COBJS	+= cache_v7.o
 COBJS	+= cpu.o
 COBJS	+= syslib.o
 
-ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_TI814X),)
+ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_TI81XX),)
 SOBJS	+= lowlevel_init.o
 endif
 
arch/arm/cpu/armv7/omap-common/Makefile +1 -1
index 55e82ba..8da8f91 100644
@@ -36,7 +36,7 @@ COBJS	+= emif-common.o
 COBJS	+= vc.o
 endif
 
-ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI814X),)
+ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI81XX),)
 COBJS	+= boot-common.o
 SOBJS	+= lowlevel_init.o
 endif
arch/arm/include/asm/arch-am33xx/cpu.h +1 -1
index 3d3a7c8..13c0667 100644
@@ -54,7 +54,7 @@
 /* Reset control */
 #ifdef CONFIG_AM33XX
 #define PRM_RSTCTRL			(PRCM_BASE + 0x0F00)
-#elif defined(CONFIG_TI814X)
+#elif defined(CONFIG_TI81XX)
 #define PRM_RSTCTRL			(PRCM_BASE + 0x00A0)
 #endif
 #define PRM_RSTST			(PRM_RSTCTRL + 8)
arch/arm/include/asm/arch-am33xx/omap.h +1 -1
index d28f9a8..1a1cc18 100644
@@ -31,7 +31,7 @@
 #ifdef CONFIG_AM33XX
 #define NON_SECURE_SRAM_START	0x40304000
 #define NON_SECURE_SRAM_END	0x4030E000
-#elif defined(CONFIG_TI814X)
+#elif defined(CONFIG_TI81XX)
 #define NON_SECURE_SRAM_START	0x40300000
 #define NON_SECURE_SRAM_END	0x40320000
 #endif
drivers/serial/ns16550.c +2 -2
index 02bc85b..c949423 100644
@@ -43,7 +43,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 
 	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
 #if (defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)) || \
-			defined(CONFIG_AM33XX) || defined(CONFIG_TI814X)
+			defined(CONFIG_AM33XX) || defined(CONFIG_TI81XX)
 	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
 #endif
 	serial_out(UART_LCR_BKSE | UART_LCRVAL, (ulong)&com_port->lcr);
@@ -58,7 +58,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 	serial_out(UART_LCRVAL, &com_port->lcr);
 #if (defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)) || \
 	defined(CONFIG_AM33XX) || defined(CONFIG_SOC_DA8XX) || \
-	defined(CONFIG_TI814X)
+	defined(CONFIG_TI81XX)
 
 #if defined(CONFIG_APTIX)
 	/* /13 mode so Aptix 6MHz can hit 115200 */
spl/Makefile +1 -1
index c398a5f..8692f30 100644
@@ -82,7 +82,7 @@ LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
 
-ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI814X),)
+ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI81XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
 endif
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 2/3 Add TI816X support

In reply to a message not in the archive
---
 arch/arm/include/asm/arch-am33xx/clock.h           |    4 +
 arch/arm/include/asm/arch-am33xx/clocks_ti816x.h   |  136 ++++++++
 arch/arm/include/asm/arch-am33xx/cpu.h             |    4 +
 arch/arm/include/asm/arch-am33xx/cpu_ti816x.h      |  194 +++++++++++
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |    4 +
 arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h |  248 +++++++++++++
 arch/arm/include/asm/arch-am33xx/hardware.h        |    7 +-
 arch/arm/include/asm/arch-am33xx/hardware_am33xx.h |    5 +
 arch/arm/include/asm/arch-am33xx/hardware_ti814x.h |    5 +
 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h |   56 +++
 arch/arm/include/asm/arch-am33xx/mmc_host_def.h    |    2 +
 arch/arm/include/asm/arch-am33xx/mux.h             |    2 +
 arch/arm/include/asm/arch-am33xx/mux_ti816x.h      |  363 ++++++++++++++++++++
 13 files changed, 1025 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-am33xx/clocks_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/cpu_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/mux_ti816x.h
arch/arm/include/asm/arch-am33xx/clock.h +4 -0
index ecb5901..123cc61 100644
@@ -19,6 +19,10 @@
 #ifndef _CLOCKS_H_
 #define _CLOCKS_H_
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/clocks_ti816x.h>
+#else
 #include <asm/arch/clocks_am33xx.h>
+#endif
 
 #endif
arch/arm/include/asm/arch-am33xx/clocks_ti816x.h new file +136 -0

136 lines not on this page · raw message

arch/arm/include/asm/arch-am33xx/cpu.h +4 -0
index 13c0667..34b3aa9 100644
@@ -25,6 +25,10 @@
 
 #include <asm/arch/hardware.h>
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/cpu_ti816x.h>
+#endif
+
 #define BIT(x)				(1 << x)
 #define CL_BIT(x)			(0 << x)
 
arch/arm/include/asm/arch-am33xx/cpu_ti816x.h new file +194 -0

194 lines not on this page · raw message

arch/arm/include/asm/arch-am33xx/ddr_defs.h +4 -0
index 15ca4c1..b959ba8 100644
@@ -22,6 +22,10 @@
 #include <asm/arch/hardware.h>
 #include <asm/emif.h>
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/ddr_defs_ti816x.h>
+#endif
+
 /* AM335X EMIF Register values */
 #define VTP_CTRL_READY		(0x1 << 5)
 #define VTP_CTRL_ENABLE		(0x1 << 6)
arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h new file +248 -0

248 lines not on this page · raw message

arch/arm/include/asm/arch-am33xx/hardware.h +2 -5
index 5a27f9c..7f3b555 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/omap.h>
 #ifdef CONFIG_AM33XX
 #include <asm/arch/hardware_am33xx.h>
+#elif defined(CONFIG_TI816X)
+#include <asm/arch/hardware_ti816x.h>
 #elif defined(CONFIG_TI814X)
 #include <asm/arch/hardware_ti814x.h>
 #endif
@@ -67,15 +69,10 @@
 /* DDR Base address */
 #define DDR_CTRL_ADDR			0x44E10E04
 #define DDR_CONTROL_BASE_ADDR		0x44E11404
-#define DDR_PHY_CMD_ADDR2		0x47C0C800
-#define DDR_PHY_DATA_ADDR2		0x47C0C8C8
 
 /* UART */
 #define DEFAULT_UART_BASE		UART0_BASE
 
-#define DDRPHY_0_CONFIG_BASE		(CTRL_BASE + 0x1400)
-#define DDRPHY_CONFIG_BASE		DDRPHY_0_CONFIG_BASE
-
 /* GPMC Base address */
 #define GPMC_BASE			0x50000000
 
arch/arm/include/asm/arch-am33xx/hardware_am33xx.h +5 -0
index fa02f19..553c3bd 100644
@@ -43,8 +43,13 @@
 /* DDR Base address */
 #define DDR_PHY_CMD_ADDR		0x44E12000
 #define DDR_PHY_DATA_ADDR		0x44E120C8
+#define DDR_PHY_CMD_ADDR2		0x47C0C800
+#define DDR_PHY_DATA_ADDR2		0x47C0C8C8
 #define DDR_DATA_REGS_NR		2
 
+#define DDRPHY_0_CONFIG_BASE		(CTRL_BASE + 0x1400)
+#define DDRPHY_CONFIG_BASE		DDRPHY_0_CONFIG_BASE
+
 /* CPSW Config space */
 #define CPSW_MDIO_BASE			0x4A101000
 
arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +5 -0
index a950ac3..c075274 100644
@@ -42,8 +42,13 @@
 /* DDR Base address */
 #define DDR_PHY_CMD_ADDR		0x47C0C400
 #define DDR_PHY_DATA_ADDR		0x47C0C4C8
+#define DDR_PHY_CMD_ADDR2		0x47C0C800
+#define DDR_PHY_DATA_ADDR2		0x47C0C8C8
 #define DDR_DATA_REGS_NR		4
 
+#define DDRPHY_0_CONFIG_BASE		(CTRL_BASE + 0x1400)
+#define DDRPHY_CONFIG_BASE		DDRPHY_0_CONFIG_BASE
+
 /* CPSW Config space */
 #define CPSW_MDIO_BASE			0x4A100800
 
arch/arm/include/asm/arch-am33xx/hardware_ti816x.h new file +56 -0

56 lines not on this page · raw message

arch/arm/include/asm/arch-am33xx/mmc_host_def.h +2 -0
index e0a3b8b..09d7a77 100644
@@ -155,6 +155,8 @@ typedef struct hsmmc {
 /* Clock Configurations and Macros */
 #ifdef CONFIG_AM33XX
 #define MMC_CLOCK_REFERENCE	96 /* MHz */
+#elif defined(CONFIG_TI816X)
+#define MMC_CLOCK_REFERENCE	48 /* MHz */
 #elif defined(CONFIG_TI814X)
 #define MMC_CLOCK_REFERENCE	192 /* MHz */
 #endif
arch/arm/include/asm/arch-am33xx/mux.h +2 -0
index 1c6b65f..4caa4d8 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/mux_am33xx.h>
 #elif defined(CONFIG_TI814X)
 #include <asm/arch/mux_ti814x.h>
+#elif defined(CONFIG_TI816X)
+#include <asm/arch/mux_ti816x.h>
 #endif
 
 struct module_pin_mux {
arch/arm/include/asm/arch-am33xx/mux_ti816x.h new file +363 -0

363 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v3 2/3 Add TI816X support

On Fri, Apr 12, 2013 at 7:10 AM, TENART Antoine <[email protected]

Quoted 73 lines

wrote:

---
 arch/arm/include/asm/arch-am33xx/clock.h           |    4 +
 arch/arm/include/asm/arch-am33xx/clocks_ti816x.h   |  136 ++++++++
 arch/arm/include/asm/arch-am33xx/cpu.h             |    4 +
 arch/arm/include/asm/arch-am33xx/cpu_ti816x.h      |  194 +++++++++++
 arch/arm/include/asm/arch-am33xx/ddr_defs.h        |    4 +
 arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h |  248 +++++++++++++
 arch/arm/include/asm/arch-am33xx/hardware.h        |    7 +-
 arch/arm/include/asm/arch-am33xx/hardware_am33xx.h |    5 +
 arch/arm/include/asm/arch-am33xx/hardware_ti814x.h |    5 +
 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h |   56 +++
 arch/arm/include/asm/arch-am33xx/mmc_host_def.h    |    2 +
 arch/arm/include/asm/arch-am33xx/mux.h             |    2 +
 arch/arm/include/asm/arch-am33xx/mux_ti816x.h      |  363
++++++++++++++++++++
 13 files changed, 1025 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-am33xx/clocks_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/cpu_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/hardware_ti816x.h
 create mode 100644 arch/arm/include/asm/arch-am33xx/mux_ti816x.h
arch/arm/include/asm/arch-am33xx/clock.h +4 -0
index ecb5901..123cc61 100644
@@ -19,6 +19,10 @@
 #ifndef _CLOCKS_H_
 #define _CLOCKS_H_
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/clocks_ti816x.h>
+#else
 #include <asm/arch/clocks_am33xx.h>
+#endif
 
 #endif
arch/arm/include/asm/arch-am33xx/clocks_ti816x.h new file +24 -0
new file mode 100644
index 0000000..403db33
@@ -0,0 +1,136 @@
+/*
+ * clocks_ti816x.h
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * Based on TI-PSP-04.00.02.14 :
+ *
+ * (C) Copyright 2006-2008
+ * Texas Instruments, <www.ti.com>
+ * Richard Woodruff <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software

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

Quoted 10 lines
arch/arm/include/asm/arch-am33xx/clocks_ti816x.h new file +10 -0
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef _CLOCKS_TI816X_H_
+#define _CLOCKS_TI816X_H_
+
+/*
+ * Values supported 400,531,675,796
+ *
+ * On TI8168 rev C, use 400 or 531 MHz !

Why? Is it specific to the EVM or is it general for all rev. C parts. A pointer to an errata would be good

arch/arm/include/asm/arch-am33xx/clocks_ti816x.h line 36

Quoted 3 lines
arch/arm/include/asm/arch-am33xx/clocks_ti816x.h new file +2 -0
+ */
+#define DDR_PLL_400

DDR PLL setup is related to the type of memory used on a particular board. Seems like it should be set in the board config

Quoted 376 lines
arch/arm/include/asm/arch-am33xx/clocks_ti816x.h new file +100 -0
+
+/* Main PLL */
+#define MAIN_N                 64
+#define MAIN_P                 0x1
+#define MAIN_INTFREQ1          0x8
+#define MAIN_FRACFREQ1         0x800000
+#define MAIN_MDIV1             0x2
+#define MAIN_INTFREQ2          0xE
+#define MAIN_FRACFREQ2         0x0
+#define MAIN_MDIV2             0x1
+#define MAIN_INTFREQ3          0x8
+#define MAIN_FRACFREQ3         0xAAAAB0
+#define MAIN_MDIV3             0x3
+#define MAIN_INTFREQ4          0x9
+#define MAIN_FRACFREQ4         0x55554F
+#define MAIN_MDIV4             0x3
+#define MAIN_INTFREQ5          0x9
+#define MAIN_FRACFREQ5         0x374BC6
+#define MAIN_MDIV5             0xC
+#define MAIN_MDIV6             0x48
+#define MAIN_MDIV7             0x4
+
+/* DDR PLL */
+/* For 400 MHz */
+#if defined(DDR_PLL_400)
+#define DDR_N                  59
+#define DDR_P                  0x1
+#define DDR_MDIV1              0x4
+#define DDR_INTFREQ2           0x8
+#define DDR_FRACFREQ2          0xD99999
+#define DDR_MDIV2              0x1E
+#define DDR_INTFREQ3           0x8
+#define DDR_FRACFREQ3          0x0
+#define DDR_MDIV3              0x4
+#define DDR_INTFREQ4           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ4          0x0
+#define DDR_MDIV4              0x4
+#define DDR_INTFREQ5           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ5          0x0
+#define DDR_MDIV5              0x4
+#endif
+
+/* For 531 MHz */
+#if defined(DDR_PLL_531)
+#define DDR_N                  59
+#define DDR_P                  0x1
+#define DDR_MDIV1              0x3
+#define DDR_INTFREQ2           0x8
+#define DDR_FRACFREQ2          0xD99999
+#define DDR_MDIV2              0x1E
+#define DDR_INTFREQ3           0x8
+#define DDR_FRACFREQ3          0x0
+#define DDR_MDIV3              0x4
+#define DDR_INTFREQ4           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ4          0x0
+#define DDR_MDIV4              0x4
+#define DDR_INTFREQ5           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ5          0x0
+#define DDR_MDIV5              0x4
+#endif
+
+/* For 675 MHz */
+#if defined(DDR_PLL_675)
+#define DDR_N                  50
+#define DDR_P                  0x1
+#define DDR_MDIV1              0x2
+#define DDR_INTFREQ2           0x9
+#define DDR_FRACFREQ2          0x0
+#define DDR_MDIV2              0x19
+#define DDR_INTFREQ3           0x13
+#define DDR_FRACFREQ3          0x800000
+#define DDR_MDIV3              0x2
+#define DDR_INTFREQ4           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ4          0x0
+#define DDR_MDIV4              0x4
+#define DDR_INTFREQ5           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ5          0x0
+#define DDR_MDIV5              0x4
+#endif
+
+/* For 796 MHz */
+#if defined(DDR_PLL_796)
+#define DDR_N                  59
+#define DDR_P                  0x1
+#define DDR_MDIV1              0x2
+#define DDR_INTFREQ2           0x8
+#define DDR_FRACFREQ2          0xD99999
+#define DDR_MDIV2              0x1E
+#define DDR_INTFREQ3           0x8
+#define DDR_FRACFREQ3          0x0
+#define DDR_MDIV3              0x4
+#define DDR_INTFREQ4           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ4          0x0
+#define DDR_MDIV4              0x4
+#define DDR_INTFREQ5           0xE /* Expansion DDR clk */
+#define DDR_FRACFREQ5          0x0
+#define DDR_MDIV5              0x4
+#endif
+
+#endif /* endif _CLOCKS_TI816X_H_ */
arch/arm/include/asm/arch-am33xx/cpu.h +4 -0
index 13c0667..34b3aa9 100644
@@ -25,6 +25,10 @@
 
 #include <asm/arch/hardware.h>
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/cpu_ti816x.h>
+#endif
+
 #define BIT(x)                         (1 << x)
 #define CL_BIT(x)                      (0 << x)
 
arch/arm/include/asm/arch-am33xx/cpu_ti816x.h new file +194 -0
new file mode 100644
index 0000000..515dba4
@@ -0,0 +1,194 @@
+/*
+ * cpu_ti816x.h
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * Based on TI-PSP-04.00.02.14 :
+ *
+ * (C) Copyright 2006
+ * Texas Instruments, <www.ti.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#ifndef _TI816X_CPU_H
+#define _TI816X_CPU_H
+
+#include <asm/arch/hardware.h>
+
+/* Control */
+#define CONTROL_STATUS         (CTRL_BASE + 0x40)
+
+/* PLL related registers */
+#define MAINPLL_CTRL           (CTRL_BASE + 0x0400)
+#define MAINPLL_PWD            (CTRL_BASE + 0x0404)
+#define MAINPLL_FREQ1          (CTRL_BASE + 0x0408)
+#define MAINPLL_DIV1           (CTRL_BASE + 0x040C)
+#define MAINPLL_FREQ2          (CTRL_BASE + 0x0410)
+#define MAINPLL_DIV2           (CTRL_BASE + 0x0414)
+#define MAINPLL_FREQ3          (CTRL_BASE + 0x0418)
+#define MAINPLL_DIV3           (CTRL_BASE + 0x041C)
+#define MAINPLL_FREQ4          (CTRL_BASE + 0x0420)
+#define MAINPLL_DIV4           (CTRL_BASE + 0x0424)
+#define MAINPLL_FREQ5          (CTRL_BASE + 0x0428)
+#define MAINPLL_DIV5           (CTRL_BASE + 0x042C)
+#define MAINPLL_DIV6           (CTRL_BASE + 0x0434)
+#define MAINPLL_DIV7           (CTRL_BASE + 0x043C)
+
+#define DDRPLL_CTRL            (CTRL_BASE + 0x0440)
+#define DDRPLL_PWD             (CTRL_BASE + 0x0444)
+#define DDRPLL_DIV1            (CTRL_BASE + 0x044C)
+#define DDRPLL_FREQ2           (CTRL_BASE + 0x0450)
+#define DDRPLL_DIV2            (CTRL_BASE + 0x0454)
+#define DDRPLL_FREQ3           (CTRL_BASE + 0x0458)
+#define DDRPLL_DIV3            (CTRL_BASE + 0x045C)
+#define DDRPLL_FREQ4           (CTRL_BASE + 0x0460)
+#define DDRPLL_DIV4            (CTRL_BASE + 0x0464)
+#define DDRPLL_FREQ5           (CTRL_BASE + 0x0468)
+#define DDRPLL_DIV5            (CTRL_BASE + 0x046C)
+
+#define DDR_RCD                        (CTRL_BASE + 0x070C)
+
+/* PRCM */
+#define CM_DPLL_OFFSET         (PRCM_BASE + 0x0300)
+
+#ifdef CONFIG_TI816X
+#define CM_TIMER1_CLKSEL       (CM_DPLL_OFFSET + 0x90)
+
+/* Timers */
+#define CM_ALWON_TIMER_0_CLKCTRL       (PRCM_BASE + 0x156C)
+#define CM_ALWON_TIMER_1_CLKCTRL       (PRCM_BASE + 0x1570)
+#define CM_ALWON_TIMER_2_CLKCTRL       (PRCM_BASE + 0x1574)
+#define CM_ALWON_TIMER_3_CLKCTRL       (PRCM_BASE + 0x1578)
+#define CM_ALWON_TIMER_4_CLKCTRL       (PRCM_BASE + 0x157C)
+#define CM_ALWON_TIMER_5_CLKCTRL       (PRCM_BASE + 0x1580)
+#define CM_ALWON_TIMER_6_CLKCTRL       (PRCM_BASE + 0x1584)
+#define CM_ALWON_TIMER_7_CLKCTRL       (PRCM_BASE + 0x1588)
+#endif
+
+#define CM_ALWON_WDTIMER_CLKCTRL       (PRCM_BASE + 0x158C)
+#define CM_ALWON_SPI_CLKCTRL           (PRCM_BASE + 0x1590)
+#define CM_ALWON_CONTROL_CLKCTRL       (PRCM_BASE + 0x15C4)
+
+#define CM_ALWON_L3_SLOW_CLKSTCTRL     (PRCM_BASE + 0x1400)
+
+#ifdef CONFIG_TI816X
+#define CM_ALWON_CUST_EFUSE_CLKCTRL    (PRCM_BASE + 0x1628)
+#endif
+
+#define CM_ALWON_GPIO_0_CLKCTRL                (PRCM_BASE + 0x155c)
+#define CM_ALWON_GPIO_0_OPTFCLKEN_DBCLK (PRCM_BASE + 0x155c)
+
+#define CM_ALWON_GPIO_1_CLKCTRL                (PRCM_BASE + 0x1560)
+/* Ethernet */
+#define CM_ETHERNET_CLKSTCTRL          (PRCM_BASE + 0x1404)
+#define CM_ALWON_ETHERNET_0_CLKCTRL    (PRCM_BASE + 0x15D4)
+#define CM_ALWON_ETHERNET_1_CLKCTRL    (PRCM_BASE + 0x15D8)
+
+/* UARTs */
+#define CM_ALWON_UART_0_CLKCTRL                (PRCM_BASE + 0x1550)
+#define CM_ALWON_UART_1_CLKCTRL                (PRCM_BASE + 0x1554)
+#define CM_ALWON_UART_2_CLKCTRL                (PRCM_BASE + 0x1558)
+
+/* I2C */
+/* Note: In ti814x I2C0 and I2C2 have common clk control */
+#define CM_ALWON_I2C_0_CLKCTRL         (PRCM_BASE + 0x1564)
+
+/* HSMMC */
+#ifdef CONFIG_TI816X
+#define CM_ALWON_HSMMC_CLKCTRL         (PRCM_BASE + 0x15B0)
+#endif
+
+/*DMM & EMIF4 MMR Declaration*/
+
+/* 0x420 = 0x460 - the lisa registers offset from the DMM region */
+#define DMM_PAT_BASE_ADDR              (DMM_BASE + 0x420)
+
+#define EMIF4_0_SDRAM_ZQCR             (EMIF4_0_CFG_BASE + 0xC8)
+#define EMIF4_0_SDRAM_CONFIG           (EMIF4_0_CFG_BASE + 0x08)
+#define EMIF4_0_SDRAM_CONFIG2          (EMIF4_0_CFG_BASE + 0x0C)
+#define EMIF4_0_SDRAM_REF_CTRL         (EMIF4_0_CFG_BASE + 0x10)
+#define EMIF4_0_SDRAM_REF_CTRL_SHADOW  (EMIF4_0_CFG_BASE + 0x14)
+#define EMIF4_0_SDRAM_TIM_1            (EMIF4_0_CFG_BASE + 0x18)
+#define EMIF4_0_SDRAM_TIM_1_SHADOW     (EMIF4_0_CFG_BASE + 0x1C)
+#define EMIF4_0_SDRAM_TIM_2            (EMIF4_0_CFG_BASE + 0x20)
+#define EMIF4_0_SDRAM_TIM_2_SHADOW     (EMIF4_0_CFG_BASE + 0x24)
+#define EMIF4_0_SDRAM_TIM_3            (EMIF4_0_CFG_BASE + 0x28)
+#define EMIF4_0_SDRAM_TIM_3_SHADOW     (EMIF4_0_CFG_BASE + 0x2C)
+#define EMIF4_0_DDR_PHY_CTRL_1         (EMIF4_0_CFG_BASE + 0xE4)
+#define EMIF4_0_DDR_PHY_CTRL_1_SHADOW  (EMIF4_0_CFG_BASE + 0xE8)
+#define EMIF4_0_IODFT_TLGC             (EMIF4_0_CFG_BASE + 0x60)
+
+#define EMIF4_1_SDRAM_ZQCR             (EMIF4_1_CFG_BASE + 0xC8)
+#define EMIF4_1_SDRAM_CONFIG           (EMIF4_1_CFG_BASE + 0x08)
+#define EMIF4_1_SDRAM_CONFIG2          (EMIF4_1_CFG_BASE + 0x0C)
+#define EMIF4_1_SDRAM_REF_CTRL         (EMIF4_1_CFG_BASE + 0x10)
+#define EMIF4_1_SDRAM_REF_CTRL_SHADOW  (EMIF4_1_CFG_BASE + 0x14)
+#define EMIF4_1_SDRAM_TIM_1            (EMIF4_1_CFG_BASE + 0x18)
+#define EMIF4_1_SDRAM_TIM_1_SHADOW     (EMIF4_1_CFG_BASE + 0x1C)
+#define EMIF4_1_SDRAM_TIM_2            (EMIF4_1_CFG_BASE + 0x20)
+#define EMIF4_1_SDRAM_TIM_2_SHADOW     (EMIF4_1_CFG_BASE + 0x24)
+#define EMIF4_1_SDRAM_TIM_3            (EMIF4_1_CFG_BASE + 0x28)
+#define EMIF4_1_SDRAM_TIM_3_SHADOW     (EMIF4_1_CFG_BASE + 0x2C)
+#define EMIF4_1_DDR_PHY_CTRL_1         (EMIF4_1_CFG_BASE + 0xE4)
+#define EMIF4_1_DDR_PHY_CTRL_1_SHADOW  (EMIF4_1_CFG_BASE + 0xE8)
+#define EMIF4_1_IODFT_TLGC             (EMIF4_1_CFG_BASE + 0x60)
+
+/*EMIF4 PRCM Defintion*/
+#define CM_DEFAULT_L3_FAST_CLKSTCTRL   (PRCM_BASE + 0x0508)
+#define CM_DEFAULT_EMIF_0_CLKCTRL      (PRCM_BASE + 0x0520)
+#define CM_DEFAULT_EMIF_1_CLKCTRL      (PRCM_BASE + 0x0524)
+#define CM_DEFAULT_DMM_CLKCTRL         (PRCM_BASE + 0x0528)
+#define CM_DEFAULT_FW_CLKCTRL          (PRCM_BASE + 0x052C)
+
+/* GPMC related */
+#define GPMC_CONFIG_CS0                (0x60)
+#define GPMC_CONFIG_CS0_BAS    (GPMC_BASE + GPMC_CONFIG_CS0)
+#define GPMC_CONFIG1           (0x00)
+#define GPMC_CONFIG2           (0x04)
+#define GPMC_CONFIG3           (0x08)
+#define GPMC_CONFIG4           (0x0C)
+#define GPMC_CONFIG5           (0x10)
+#define GPMC_CONFIG6           (0x14)
+#define GPMC_CONFIG7           (0x18)
+
+/* WDT related */
+#define WDT_WDSC               (WDT_BASE + 0x010)
+#define WDT_WDST               (WDT_BASE + 0x014)
+#define WDT_WISR               (WDT_BASE + 0x018)
+#define WDT_WIER               (WDT_BASE + 0x01C)
+#define WDT_WWER               (WDT_BASE + 0x020)
+#define WDT_WCLR               (WDT_BASE + 0x024)
+#define WDT_WCRR               (WDT_BASE + 0x028)
+#define WDT_WLDR               (WDT_BASE + 0x02C)
+#define WDT_WTGR               (WDT_BASE + 0x030)
+#define WDT_WWPS               (WDT_BASE + 0x034)
+#define WDT_WDLY               (WDT_BASE + 0x044)
+#define WDT_WSPR               (WDT_BASE + 0x048)
+#define WDT_WIRQEOI            (WDT_BASE + 0x050)
+#define WDT_WIRQSTATRAW                (WDT_BASE + 0x054)
+#define WDT_WIRQSTAT           (WDT_BASE + 0x058)
+#define WDT_WIRQENSET          (WDT_BASE + 0x05C)
+#define WDT_WIRQENCLR          (WDT_BASE + 0x060)
+
+#define WDT_UNFREEZE           (CTRL_BASE + 0x100)
+
+#endif /* _TI816X_CPU_H */
arch/arm/include/asm/arch-am33xx/ddr_defs.h +4 -0
index 15ca4c1..b959ba8 100644
@@ -22,6 +22,10 @@
 #include <asm/arch/hardware.h>
 #include <asm/emif.h>
 
+#if defined(CONFIG_TI816X)
+#include <asm/arch/ddr_defs_ti816x.h>
+#endif
+
 /* AM335X EMIF Register values */
 #define VTP_CTRL_READY         (0x1 << 5)
 #define VTP_CTRL_ENABLE                (0x1 << 6)
arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h new file +36 -0
new file mode 100644
index 0000000..4c0fe9d
@@ -0,0 +1,248 @@
+/*
+ * ddr_defs_ti816x.h
+ *
+ * ddr specific header for TI816X
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * Based on TI-PSP-04.00.02.14 :
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DDR_DEFS_TI816X_H
+#define _DDR_DEFS_TI816X_H
+
+#include <asm/arch/hardware.h>
+
+#ifdef CONFIG_TI816X_EVM_DDR3
+
+#define CONFIG_TI816X_DDR3_796         /* Values supported
Quoted 2 lines

400,531,675,796 */

Almost everything in this file should be defined on a per board basis, not in a generic header file. Also should combine defines with the PLL setup above so there is no possibility of mismatch between the two

Quoted 187 lines
arch/arm/include/asm/arch-am33xx/hardware.h +2 -5
index 5a27f9c..7f3b555 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/omap.h>
 #ifdef CONFIG_AM33XX
 #include <asm/arch/hardware_am33xx.h>
+#elif defined(CONFIG_TI816X)
+#include <asm/arch/hardware_ti816x.h>
 #elif defined(CONFIG_TI814X)
 #include <asm/arch/hardware_ti814x.h>
 #endif
@@ -67,15 +69,10 @@
 /* DDR Base address */
 #define DDR_CTRL_ADDR                  0x44E10E04
 #define DDR_CONTROL_BASE_ADDR          0x44E11404
-#define DDR_PHY_CMD_ADDR2              0x47C0C800
-#define DDR_PHY_DATA_ADDR2             0x47C0C8C8
 
 /* UART */
 #define DEFAULT_UART_BASE              UART0_BASE
 
-#define DDRPHY_0_CONFIG_BASE           (CTRL_BASE + 0x1400)
-#define DDRPHY_CONFIG_BASE             DDRPHY_0_CONFIG_BASE
-
 /* GPMC Base address */
 #define GPMC_BASE                      0x50000000
 
arch/arm/include/asm/arch-am33xx/hardware_am33xx.h +5 -0
index fa02f19..553c3bd 100644
@@ -43,8 +43,13 @@
 /* DDR Base address */
 #define DDR_PHY_CMD_ADDR               0x44E12000
 #define DDR_PHY_DATA_ADDR              0x44E120C8
+#define DDR_PHY_CMD_ADDR2              0x47C0C800
+#define DDR_PHY_DATA_ADDR2             0x47C0C8C8
 #define DDR_DATA_REGS_NR               2
 
+#define DDRPHY_0_CONFIG_BASE           (CTRL_BASE + 0x1400)
+#define DDRPHY_CONFIG_BASE             DDRPHY_0_CONFIG_BASE
+
 /* CPSW Config space */
 #define CPSW_MDIO_BASE                 0x4A101000
 
arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +5 -0
index a950ac3..c075274 100644
@@ -42,8 +42,13 @@
 /* DDR Base address */
 #define DDR_PHY_CMD_ADDR               0x47C0C400
 #define DDR_PHY_DATA_ADDR              0x47C0C4C8
+#define DDR_PHY_CMD_ADDR2              0x47C0C800
+#define DDR_PHY_DATA_ADDR2             0x47C0C8C8
 #define DDR_DATA_REGS_NR               4
 
+#define DDRPHY_0_CONFIG_BASE           (CTRL_BASE + 0x1400)
+#define DDRPHY_CONFIG_BASE             DDRPHY_0_CONFIG_BASE
+
 /* CPSW Config space */
 #define CPSW_MDIO_BASE                 0x4A100800
 
arch/arm/include/asm/arch-am33xx/hardware_ti816x.h new file +56 -0
new file mode 100644
index 0000000..60daf55
@@ -0,0 +1,56 @@
+/*
+ * hardware_ti816x.h
+ *
+ * TI816x hardware specific header
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ * Based on TI-PSP-04.00.02.14
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __AM33XX_HARDWARE_TI816X_H
+#define __AM33XX_HARDWARE_TI816X_H
+
+/* Watchdog Timer */
+#define WDT_BASE               0x480C2000
+
+/* Control Module Base Address */
+#define CTRL_BASE              0x48140000
+
+/* PRCM Base Address */
+#define PRCM_BASE              0x48180000
+
+/* VTP Base address */
+#define VTP0_CTRL_ADDR         0x48198358
+
+/* DDR Base address */
+#define DDR_PHY_CMD_ADDR       0x48198000
+#define DDR_PHY_DATA_ADDR      0x481980C8
+#define DDR_PHY_CMD_ADDR2      0x4819A000
+#define DDR_PHY_DATA_ADDR2     0x4819A0C8
+#define DDR_DATA_REGS_NR       4
+
+/* UART */
+#define UART0_BASE             0x48020000
+#define UART1_BASE             0x48022000
+#define UART2_BASE             0x48024000
+
+#define DDRPHY_0_CONFIG_BASE   0x48198000
+#define DDRPHY_1_CONFIG_BASE   0x4819a000
+#define DDRPHY_CONFIG_BASE     ((emif == 0) ? \
+       DDRPHY_0_CONFIG_BASE : DDRPHY_1_CONFIG_BASE)
+
+/* RTC base address */
+#define RTC_BASE               0x480C0000
+
+#endif /* __AM33XX_HARDWARE_TI816X_H */
arch/arm/include/asm/arch-am33xx/mmc_host_def.h +2 -0
index e0a3b8b..09d7a77 100644
@@ -155,6 +155,8 @@ typedef struct hsmmc {
 /* Clock Configurations and Macros */
 #ifdef CONFIG_AM33XX
 #define MMC_CLOCK_REFERENCE    96 /* MHz */
+#elif defined(CONFIG_TI816X)
+#define MMC_CLOCK_REFERENCE    48 /* MHz */
 #elif defined(CONFIG_TI814X)
 #define MMC_CLOCK_REFERENCE    192 /* MHz */
 #endif
arch/arm/include/asm/arch-am33xx/mux.h +2 -0
index 1c6b65f..4caa4d8 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/mux_am33xx.h>
 #elif defined(CONFIG_TI814X)
 #include <asm/arch/mux_ti814x.h>
+#elif defined(CONFIG_TI816X)
+#include <asm/arch/mux_ti816x.h>
 #endif
 
 struct module_pin_mux {
arch/arm/include/asm/arch-am33xx/mux_ti816x.h new file +20 -0
new file mode 100644
index 0000000..0fcd49e
@@ -0,0 +1,363 @@
+/*
+ * mux_ti816x.h
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _MUX_TI816X_H_
+#define _MUX_TI816X_H_
+
+#include <common.h>

arch/arm/include/asm/arch-am33xx/mux_ti816x.h line 30

Quoted 10 lines
arch/arm/include/asm/arch-am33xx/mux_ti816x.h new file +10 -0
+#include <asm/io.h>
+
+#define MUX_CFG(value, offset)  \
+       __raw_writel(value, (CTRL_BASE + offset));
+
+#define PULLDOWN_EN (0x0 << 4) /* Pull Down Selection */
+#define PULLUP_EN   (0x1 << 4) /* Pull Up Selection */
+#define PULLUDEN    (0x0 << 3) /* Pull up enabled */
+#define PULLUDDIS   (0x1 << 3) /* Pull up disabled */
+#define MODE(val)              val /* used for Readability */

shouldn't this have parenthesis to protect the parameter like so #define MODE(val) (val)

+

Quoted 339 lines
arch/arm/include/asm/arch-am33xx/mux_ti816x.h new file +332 -1
+
+/*
+ * PAD CONTROL OFFSETS
+ * Field names corresponds to the pad signal name
+ */
+struct pad_signals {
+       int pincntl1;
+       int pincntl2;
+       int pincntl3;
+       int pincntl4;
+       int pincntl5;
+       int pincntl6;
+       int pincntl7;
+       int pincntl8;
+       int pincntl9;
+       int pincntl10;
+       int pincntl11;
+       int pincntl12;
+       int pincntl13;
+       int pincntl14;
+       int pincntl15;
+       int pincntl16;
+       int pincntl17;
+       int pincntl18;
+       int pincntl19;
+       int pincntl20;
+       int pincntl21;
+       int pincntl22;
+       int pincntl23;
+       int pincntl24;
+       int pincntl25;
+       int pincntl26;
+       int pincntl27;
+       int pincntl28;
+       int pincntl29;
+       int pincntl30;
+       int pincntl31;
+       int pincntl32;
+       int pincntl33;
+       int pincntl34;
+       int pincntl35;
+       int pincntl36;
+       int pincntl37;
+       int pincntl38;
+       int pincntl39;
+       int pincntl40;
+       int pincntl41;
+       int pincntl42;
+       int pincntl43;
+       int pincntl44;
+       int pincntl45;
+       int pincntl46;
+       int pincntl47;
+       int pincntl48;
+       int pincntl49;
+       int pincntl50;
+       int pincntl51;
+       int pincntl52;
+       int pincntl53;
+       int pincntl54;
+       int pincntl55;
+       int pincntl56;
+       int pincntl57;
+       int pincntl58;
+       int pincntl59;
+       int pincntl60;
+       int pincntl61;
+       int pincntl62;
+       int pincntl63;
+       int pincntl64;
+       int pincntl65;
+       int pincntl66;
+       int pincntl67;
+       int pincntl68;
+       int pincntl69;
+       int pincntl70;
+       int pincntl71;
+       int pincntl72;
+       int pincntl73;
+       int pincntl74;
+       int pincntl75;
+       int pincntl76;
+       int pincntl77;
+       int pincntl78;
+       int pincntl79;
+       int pincntl80;
+       int pincntl81;
+       int pincntl82;
+       int pincntl83;
+       int pincntl84;
+       int pincntl85;
+       int pincntl86;
+       int pincntl87;
+       int pincntl88;
+       int pincntl89;
+       int pincntl90;
+       int pincntl91;
+       int pincntl92;
+       int pincntl93;
+       int pincntl94;
+       int pincntl95;
+       int pincntl96;
+       int pincntl97;
+       int pincntl98;
+       int pincntl99;
+       int pincntl100;
+       int pincntl101;
+       int pincntl102;
+       int pincntl103;
+       int pincntl104;
+       int pincntl105;
+       int pincntl106;
+       int pincntl107;
+       int pincntl108;
+       int pincntl109;
+       int pincntl110;
+       int pincntl111;
+       int pincntl112;
+       int pincntl113;
+       int pincntl114;
+       int pincntl115;
+       int pincntl116;
+       int pincntl117;
+       int pincntl118;
+       int pincntl119;
+       int pincntl120;
+       int pincntl121;
+       int pincntl122;
+       int pincntl123;
+       int pincntl124;
+       int pincntl125;
+       int pincntl126;
+       int pincntl127;
+       int pincntl128;
+       int pincntl129;
+       int pincntl130;
+       int pincntl131;
+       int pincntl132;
+       int pincntl133;
+       int pincntl134;
+       int pincntl135;
+       int pincntl136;
+       int pincntl137;
+       int pincntl138;
+       int pincntl139;
+       int pincntl140;
+       int pincntl141;
+       int pincntl142;
+       int pincntl143;
+       int pincntl144;
+       int pincntl145;
+       int pincntl146;
+       int pincntl147;
+       int pincntl148;
+       int pincntl149;
+       int pincntl150;
+       int pincntl151;
+       int pincntl152;
+       int pincntl153;
+       int pincntl154;
+       int pincntl155;
+       int pincntl156;
+       int pincntl157;
+       int pincntl158;
+       int pincntl159;
+       int pincntl160;
+       int pincntl161;
+       int pincntl162;
+       int pincntl163;
+       int pincntl164;
+       int pincntl165;
+       int pincntl166;
+       int pincntl167;
+       int pincntl168;
+       int pincntl169;
+       int pincntl170;
+       int pincntl171;
+       int pincntl172;
+       int pincntl173;
+       int pincntl174;
+       int pincntl175;
+       int pincntl176;
+       int pincntl177;
+       int pincntl178;
+       int pincntl179;
+       int pincntl180;
+       int pincntl181;
+       int pincntl182;
+       int pincntl183;
+       int pincntl184;
+       int pincntl185;
+       int pincntl186;
+       int pincntl187;
+       int pincntl188;
+       int pincntl189;
+       int pincntl190;
+       int pincntl191;
+       int pincntl192;
+       int pincntl193;
+       int pincntl194;
+       int pincntl195;
+       int pincntl196;
+       int pincntl197;
+       int pincntl198;
+       int pincntl199;
+       int pincntl200;
+       int pincntl201;
+       int pincntl202;
+       int pincntl203;
+       int pincntl204;
+       int pincntl205;
+       int pincntl206;
+       int pincntl207;
+       int pincntl208;
+       int pincntl209;
+       int pincntl210;
+       int pincntl211;
+       int pincntl212;
+       int pincntl213;
+       int pincntl214;
+       int pincntl215;
+       int pincntl216;
+       int pincntl217;
+       int pincntl218;
+       int pincntl219;
+       int pincntl220;
+       int pincntl221;
+       int pincntl222;
+       int pincntl223;
+       int pincntl224;
+       int pincntl225;
+       int pincntl226;
+       int pincntl227;
+       int pincntl228;
+       int pincntl229;
+       int pincntl230;
+       int pincntl231;
+       int pincntl232;
+       int pincntl233;
+       int pincntl234;
+       int pincntl235;
+       int pincntl236;
+       int pincntl237;
+       int pincntl238;
+       int pincntl239;
+       int pincntl240;
+       int pincntl241;
+       int pincntl242;
+       int pincntl243;
+       int pincntl244;
+       int pincntl245;
+       int pincntl246;
+       int pincntl247;
+       int pincntl248;
+       int pincntl249;
+       int pincntl250;
+       int pincntl251;
+       int pincntl252;
+       int pincntl253;
+       int pincntl254;
+       int pincntl255;
+       int pincntl256;
+       int pincntl257;
+       int pincntl258;
+       int pincntl259;
+       int pincntl260;
+       int pincntl261;
+       int pincntl262;
+       int pincntl263;
+       int pincntl264;
+       int pincntl265;
+       int pincntl266;
+       int pincntl267;
+       int pincntl268;
+       int pincntl269;
+       int pincntl270;
+       int pincntl271;
+       int pincntl272;
+       int pincntl273;
+       int pincntl274;
+       int pincntl275;
+       int pincntl276;
+       int pincntl277;
+       int pincntl278;
+       int pincntl279;
+       int pincntl280;
+       int pincntl281;
+       int pincntl282;
+       int pincntl283;
+       int pincntl284;
+       int pincntl285;
+       int pincntl286;
+       int pincntl287;
+       int pincntl288;
+       int pincntl289;
+       int pincntl290;
+       int pincntl291;
+       int pincntl292;
+       int pincntl293;
+       int pincntl294;
+       int pincntl295;
+       int pincntl296;
+       int pincntl297;
+       int pincntl298;
+       int pincntl299;
+       int pincntl300;
+       int pincntl301;
+       int pincntl302;
+       int pincntl303;
+       int pincntl304;
+       int pincntl305;
+       int pincntl306;
+       int pincntl307;
+       int pincntl308;
+       int pincntl309;
+       int pincntl310;
+       int pincntl311;
+       int pincntl312;
+       int pincntl313;
+       int pincntl314;
+       int pincntl315;
+       int pincntl316;
+       int pincntl317;
+       int pincntl318;
+       int pincntl319;
+       int pincntl320;
+       int pincntl321;
+       int pincntl322;
+       int pincntl323;
+};
+
+#endif /* endif _MUX_TI816X_H_ */
--

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

#4 lore raw

PATCH v3 2/3 Add TI816X support

Quoted 8 lines

+/*
+ * Values supported 400,531,675,796
+ *
+ * On TI8168 rev C, use 400 or 531 MHz !

Why? Is it specific to the EVM or is it general for all rev. C parts.
A pointer to an errata would be good

I don't know if there is an errata, but I couldn't get U-Boot working with DDR_PLL_675 or DDR_PLL_796 on my rev C. This is only base on my experience.

Quoted 6 lines

+ */
+#define DDR_PLL_400

DDR PLL setup is related to the type of memory used on a particular board. Seems like it should be set in the board config

I think so too.

Quoted 2 lines
    --- /dev/null
    +++ b/arch/arm/include/asm/arch-am33xx/ddr_defs_ti816x.h

[snip]

Quoted 4 lines

Almost everything in this file should be defined on a per board basis, not in a generic header file. Also should combine defines with the PLL setup above so there is no possibility of mismatch between the two

Right, it would make sense to move it to board/ti/ti816x.

Quoted 9 lines
    +#define PULLDOWN_EN (0x0 << 4) /* Pull Down Selection */
    +#define PULLUP_EN   (0x1 << 4) /* Pull Up Selection */
    +#define PULLUDEN    (0x0 << 3) /* Pull up enabled */
    +#define PULLUDDIS   (0x1 << 3) /* Pull up disabled */
    +#define MODE(val)              val /* used for Readability */

shouldn't this have parenthesis to protect the parameter like so #define MODE(val) (val)

Indeed.

Signature · 1 line
Antoine
#5 lore raw

PATCH v3 3/3 Add TI816X evm board support

In reply to a message not in the archive
---
 MAINTAINERS                            |    4 +
 arch/arm/include/asm/arch-am33xx/spl.h |    9 +
 board/ti/ti816x/Makefile               |   48 ++
 board/ti/ti816x/evm.c                  |  866 ++++++++++++++++++++++++++++++++
 boards.cfg                             |    1 +
 include/configs/ti816x_evm.h           |  177 +++++++
 6 files changed, 1105 insertions(+)
 create mode 100644 board/ti/ti816x/Makefile
 create mode 100644 board/ti/ti816x/evm.c
 create mode 100644 include/configs/ti816x_evm.h
MAINTAINERS +4 -0
index 6b2202c..3aaac7f 100644
@@ -922,6 +922,10 @@ Lucas Stach <[email protected]>
 
 	colibri_t20_iris	Tegra20 (ARM7 & A9 Dual Core)
 
+Antoine Tenart <[email protected]>
+
+	TI816X		ARM ARMV7 (TI816x Soc)
+
 Nick Thompson <[email protected]>
 
 	da830evm	ARM926EJS (DA830/OMAP-L137)
arch/arm/include/asm/arch-am33xx/spl.h +9 -0
index 9b5fe9e..d0c1ec9 100644
@@ -23,6 +23,14 @@
 #ifndef	_ASM_ARCH_SPL_H_
 #define	_ASM_SPL_H_
 
+#if defined(CONFIG_TI816X)
+#define BOOT_DEVICE_XIP		2
+#define BOOT_DEVICE_NAND	3
+#define BOOT_DEVICE_MMC1	6
+#define BOOT_DEVICE_MMC2	5
+#define BOOT_DEVICE_UART	0x43
+#define BOOT_DEVICE_MMC2_2	0xFF
+#else
 #define BOOT_DEVICE_XIP       	2
 #define BOOT_DEVICE_NAND	5
 #ifdef CONFIG_AM33XX
@@ -37,3 +45,4 @@
 #define BOOT_DEVICE_CPGMAC	70
 #define BOOT_DEVICE_MMC2_2      0xFF
 #endif
+#endif
board/ti/ti816x/Makefile new file +48 -0

48 lines not on this page · raw message

board/ti/ti816x/evm.c new file +866 -0

866 lines not on this page · raw message

boards.cfg +1 -0
index c98495a..aab56b9 100644
@@ -239,6 +239,7 @@ am335x_evm_uart3             arm         armv7       am335x              ti
 am335x_evm_uart4             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL5,CONS_INDEX=5
 am335x_evm_uart5             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL6,CONS_INDEX=6
 ti814x_evm                   arm         armv7       ti814x              ti             am33xx
+ti816x_evm                   arm         armv7       ti816x              ti             am33xx
 pcm051                       arm         armv7       pcm051              phytec         am33xx      pcm051
 highbank                     arm         armv7       highbank            -              highbank
 mx51_efikamx                 arm         armv7       mx51_efikamx        genesi         mx5		mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKAMX,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_mx.cfg
include/configs/ti816x_evm.h new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#6 lore raw

PATCH v3 3/3 Add TI816X evm board support

On Fri, Apr 12, 2013 at 7:10 AM, TENART Antoine <[email protected]

Quoted 199 lines

wrote:

---
 MAINTAINERS                            |    4 +
 arch/arm/include/asm/arch-am33xx/spl.h |    9 +
 board/ti/ti816x/Makefile               |   48 ++
 board/ti/ti816x/evm.c                  |  866
++++++++++++++++++++++++++++++++
 boards.cfg                             |    1 +
 include/configs/ti816x_evm.h           |  177 +++++++
 6 files changed, 1105 insertions(+)
 create mode 100644 board/ti/ti816x/Makefile
 create mode 100644 board/ti/ti816x/evm.c
 create mode 100644 include/configs/ti816x_evm.h
MAINTAINERS +4 -0
index 6b2202c..3aaac7f 100644
@@ -922,6 +922,10 @@ Lucas Stach <[email protected]>
 
        colibri_t20_iris        Tegra20 (ARM7 & A9 Dual Core)
 
+Antoine Tenart <[email protected]>
+
+       TI816X          ARM ARMV7 (TI816x Soc)
+
 Nick Thompson <[email protected]>
 
        da830evm        ARM926EJS (DA830/OMAP-L137)
arch/arm/include/asm/arch-am33xx/spl.h +9 -0
index 9b5fe9e..d0c1ec9 100644
@@ -23,6 +23,14 @@
 #ifndef        _ASM_ARCH_SPL_H_
 #define        _ASM_SPL_H_
 
+#if defined(CONFIG_TI816X)
+#define BOOT_DEVICE_XIP                2
+#define BOOT_DEVICE_NAND       3
+#define BOOT_DEVICE_MMC1       6
+#define BOOT_DEVICE_MMC2       5
+#define BOOT_DEVICE_UART       0x43
+#define BOOT_DEVICE_MMC2_2     0xFF
+#else
 #define BOOT_DEVICE_XIP        2
 #define BOOT_DEVICE_NAND       5
 #ifdef CONFIG_AM33XX
@@ -37,3 +45,4 @@
 #define BOOT_DEVICE_CPGMAC     70
 #define BOOT_DEVICE_MMC2_2      0xFF
 #endif
+#endif
board/ti/ti816x/Makefile new file +48 -0
new file mode 100644
index 0000000..59128ee
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+# Antoine Tenart, <[email protected]>
+#
+# Based on TI-PSP-04.00.02.14 :
+#
+# Copyright (C) 2009, Texas Instruments, Incorporated
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation version 2.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    = $(obj)lib$(BOARD).o
+
+COBJS  := evm.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):        $(obj).depend $(OBJS)
+       $(call cmd_link_o_target, $(OBJS))
+
+clean:
+       rm -f $(OBJS)
+
+distclean:     clean
+       rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
+
board/ti/ti816x/evm.c new file +82 -0
new file mode 100644
index 0000000..bb9d604
@@ -0,0 +1,866 @@
+/*
+ * evm.c
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * Based on TI-PSP-04.00.02.14 :
+ *
+ * Copyright (C) 2009, Texas Instruments, Incorporated
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <spl.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/ddr_defs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/arch/mmc_host_def.h>
+#include <asm/arch/mem.h>
+#include <asm/arch/mux.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_TI816X_DDR3_SW_LEVELING
+static void ddr3_sw_levelling(int emif);
+#endif
+
+int board_init(void)
+{
+       gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
+       return 0;
+}
+
+#if defined(CONFIG_SPL_BUILD)
+
+static struct module_pin_mux mmc_pin_mux[] = {
+       { OFFSET(pincntl157), PULLDOWN_EN | PULLUDDIS | MODE(0x0) },
+       { OFFSET(pincntl158), PULLDOWN_EN | PULLUDEN | MODE(0x0) },
+       { OFFSET(pincntl159), PULLUP_EN | PULLUDDIS | MODE(0x0) },
+       { OFFSET(pincntl160), PULLUP_EN | PULLUDDIS | MODE(0x0) },
+       { OFFSET(pincntl161), PULLUP_EN | PULLUDDIS | MODE(0x0) },
+       { OFFSET(pincntl162), PULLUP_EN | PULLUDDIS | MODE(0x0) },
+       { OFFSET(pincntl163), PULLUP_EN | PULLUDDIS | MODE(0x0) },
+       { -1 },
+};
+
+const struct dmm_lisa_map_regs evm_lisa_map_regs = {
+       .dmm_lisa_map_0 = 0x00000000,
+       .dmm_lisa_map_1 = 0x00000000,
+       .dmm_lisa_map_2 = 0x80640300,
+       .dmm_lisa_map_3 = 0xC0640320,
+};
+
+/*
+ * Routine: delay
+ * Description: spinning delay to use before udelay works
+ */
+static inline void delay(unsigned long loops)
+{
+       __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
+                       "bne 1b" : "=r" (loops) : "0"(loops));
+}
+
+/* assume delay is aprox at least 1us */
+void ddr_delay(int d)
+{
+       int i;

board/ti/ti816x/evm.c line 92

Quoted 10 lines
board/ti/ti816x/evm.c new file +10 -0
+
+       /*
+        * read a control module register.
+        * this is a bit more delay and cannot be optimized by the compiler
+        * assuming one read takes 200 cycles and A8 is runing 1 GHz
+        * somewhat conservative setting
+        */
+       for (i = 0; i < 50*d; i++)
+               readl(CONTROL_STATUS);
+}

these seem more SOC specific than board specific. Would likely be replicated per board, I'd suggest to move out of board specific file.

board/ti/ti816x/evm.c line 98

Quoted 7 lines
board/ti/ti816x/evm.c new file +6 -0
+
+#ifdef CONFIG_TI816X_EVM_DDR3
+/*
+ * Init DDR3 on TI816X EVM
+ */
+static void ddr_init_settings(int emif)

this function is generic to the SOC, move out of board specific file and call with appropriate values or defines

Quoted 48 lines
board/ti/ti816x/evm.c new file +47 -0
+{
+       /*
+        * DLL Lockdiff DLL_Lockdiff determines effectively is the
+        * threshold internal to the DLL to indicate that the DLL has
+        * lost lock.  When this happens the PHY currently issues an
+        * internal reset.  The reset value for this is 0x4, which is
+        * insufficient.  Set this to 15 (maximum possible - to
+        * prevent this reset.  If the reset happens it would cause
+        * the data to be corrupted.
+        */
+       if (0 == get_cpu_rev()) {
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x028);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x05C);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x090);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x138);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x1DC);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x280);
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x324);
+       }
+
+       /*
+        * setup use_rank_delays to 1.  This is only necessary when
+        * multiple ranks are in use.  Though the EVM does not have
+        * multiple ranks, this is a good value to set.
+        */
+       writel(1, DDRPHY_CONFIG_BASE + 0x134);
+       writel(1, DDRPHY_CONFIG_BASE + 0x1d8);
+       writel(1, DDRPHY_CONFIG_BASE + 0x27c);
+       writel(1, DDRPHY_CONFIG_BASE + 0x320);
+
+       /* see ddr_defs.h for invert clock setting and details */
+       /* invert_clk_out cmd0 */
+       writel(INVERT_CLOCK, DDRPHY_CONFIG_BASE + 0x02C);
+       /* invert_clk_out cmd0 */
+       writel(INVERT_CLOCK, DDRPHY_CONFIG_BASE + 0x060);
+       /* invert_clk_out cmd0 */
+       writel(INVERT_CLOCK, DDRPHY_CONFIG_BASE + 0x094);
+
+       /* with inv clkout: 0x100. no inv clkout: 0x80.  See ddr_defs.h */
+       /* cmd0 slave ratio */
+       writel(CMD_SLAVE_RATIO, DDRPHY_CONFIG_BASE + 0x01C);
+       /* cmd1 slave ratio */
+       writel(CMD_SLAVE_RATIO, DDRPHY_CONFIG_BASE + 0x050);
+       /* cmd2 slave ratio */
+       writel(CMD_SLAVE_RATIO, DDRPHY_CONFIG_BASE + 0x084);
+
+       /* for ddr3 this needs to be set to 1 */

board/ti/ti816x/evm.c line 155

Quoted 10 lines
board/ti/ti816x/evm.c new file +10 -0
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x0F8); /* init mode */
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x104);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x19C);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x1A8);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x240);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x24C);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x2E4);
+       writel(0x1, DDRPHY_CONFIG_BASE + 0x2F0);
+
+       /****  setup the initial levelinihg ratios ****/

typo

Quoted 84 lines
board/ti/ti816x/evm.c new file +84 -0
+       /*
+        * These are derived from board delays and may be different for
+        * different boards see ddr_defs.h
+        * We are setting the values here for both the ranks, though only
+        * one is in use
+        */
+
+       /* data0 writelvl init ratio */
+       writel((WR_DQS_RATIO_3 << 10) | WR_DQS_RATIO_3,
+                               DDRPHY_CONFIG_BASE + 0x0F0);
+       writel(0x00000, DDRPHY_CONFIG_BASE + 0x0F4);
+       /* data1 writelvl init ratio */
+       writel((WR_DQS_RATIO_2 << 10) | WR_DQS_RATIO_2,
+                               DDRPHY_CONFIG_BASE + 0x194);
+       writel(0x00000, DDRPHY_CONFIG_BASE + 0x198);
+       /* data2 writelvl init ratio */
+       writel((WR_DQS_RATIO_1 << 10) | WR_DQS_RATIO_1,
+                               DDRPHY_CONFIG_BASE + 0x238);
+       writel(0x00000, DDRPHY_CONFIG_BASE + 0x23c);
+       /* data3 writelvl init ratio */
+       writel((WR_DQS_RATIO_0 << 10) | WR_DQS_RATIO_0,
+                               DDRPHY_CONFIG_BASE + 0x2dc);
+       writel(0x00000, DDRPHY_CONFIG_BASE + 0x2e0);
+
+
+       /* data0 gatelvl init ratio */
+       writel((RD_GATE_RATIO_3 << 10) | RD_GATE_RATIO_3,
+                               DDRPHY_CONFIG_BASE + 0x0FC);
+       writel(0x0, DDRPHY_CONFIG_BASE + 0x100);
+       /* data1 gatelvl init ratio */
+       writel((RD_GATE_RATIO_2 << 10) | RD_GATE_RATIO_2,
+                               DDRPHY_CONFIG_BASE + 0x1A0);
+       writel(0x0, DDRPHY_CONFIG_BASE + 0x1A4);
+       /* data2 gatelvl init ratio */
+       writel((RD_GATE_RATIO_1 << 10) | RD_GATE_RATIO_1,
+                               DDRPHY_CONFIG_BASE + 0x244);
+       writel(0x0, DDRPHY_CONFIG_BASE + 0x248);
+       /* data3 gatelvl init ratio */
+       writel((RD_GATE_RATIO_0 << 10) | RD_GATE_RATIO_0,
+                               DDRPHY_CONFIG_BASE + 0x2E8);
+       writel(0x0, DDRPHY_CONFIG_BASE + 0x2EC);
+
+       /* cmd0 io config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x00C);
+       /* cmd0 io clk config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x010);
+       /* cmd1 io config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x040);
+       /* cmd1 io clk config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x044);
+       /* cmd2 io config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x074);
+       /* cmd2 io clk config - output impedance of pad */
+       writel(0x5, DDRPHY_CONFIG_BASE + 0x078);
+       /* data0 io config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x0A8);
+       /* data0 io clk config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x0AC);
+       /* data1 io config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x14C);
+       /* data1 io clk config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x150);
+       /* data2 io config - output impedance of pa */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x1F0);
+       /* data2 io clk config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x1F4);
+       /* data3 io config - output impedance of pa */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x294);
+       /* data3 io clk config - output impedance of pad */
+       writel(0x4, DDRPHY_CONFIG_BASE + 0x298);
+
+       if (get_cpu_rev() == 0) {
+               /* fifo_we_out0  - output impedance of pad */
+               writel(0x5, DDRPHY_CONFIG_BASE + 0x338);
+               /* fifo_we_out1 - output impedance of pad */
+               writel(0x5, DDRPHY_CONFIG_BASE + 0x340);
+               /* fifo_we_in2 - output impedance of pad */
+               writel(0x5, DDRPHY_CONFIG_BASE + 0x348);
+               /* fifo_we_in3 - output impedance of pad */
+               writel(0x5, DDRPHY_CONFIG_BASE + 0x350);
+       }
+}
+
+static void emif4p_init(u32 TIM1, u32 TIM2, u32 TIM3, u32 SDREF, u32
Quoted 3 lines

SDCFG,
+ u32 RL)

again function generic to SOC, move out of board file, applies for a lot of what follows, but I'll stop repeating it :-)

Quoted 32 lines
board/ti/ti816x/evm.c new file +31 -0
+{
+       if (USE_EMIF0) {
+               /* Program EMIF0 CFG Registers */
+               writel(TIM1, EMIF4_0_SDRAM_TIM_1);
+               writel(TIM1, EMIF4_0_SDRAM_TIM_1_SHADOW);
+               writel(TIM2, EMIF4_0_SDRAM_TIM_2);
+               writel(TIM2, EMIF4_0_SDRAM_TIM_2_SHADOW);
+               writel(TIM3, EMIF4_0_SDRAM_TIM_3);
+               writel(TIM3, EMIF4_0_SDRAM_TIM_3_SHADOW);
+               writel(SDCFG, EMIF4_0_SDRAM_CONFIG);
+               writel(RL, EMIF4_0_DDR_PHY_CTRL_1);
+               writel(RL, EMIF4_0_DDR_PHY_CTRL_1_SHADOW);
+               /* initially a large refresh period */
+               writel(0x0000613B, EMIF4_0_SDRAM_REF_CTRL);
+               /* trigger initialization */
+               writel(0x1000613B, EMIF4_0_SDRAM_REF_CTRL);
+               writel((0x10000000|EMIF_SDREF), EMIF4_0_SDRAM_REF_CTRL);
+       }
+
+       if (USE_EMIF1) {
+               /* Program EMIF1 CFG Registers */
+               writel(TIM1, EMIF4_1_SDRAM_TIM_1);
+               writel(TIM1, EMIF4_1_SDRAM_TIM_1_SHADOW);
+               writel(TIM2, EMIF4_1_SDRAM_TIM_2);
+               writel(TIM2, EMIF4_1_SDRAM_TIM_2_SHADOW);
+               writel(TIM3, EMIF4_1_SDRAM_TIM_3);
+               writel(TIM3, EMIF4_1_SDRAM_TIM_3_SHADOW);
+               writel(SDCFG, EMIF4_1_SDRAM_CONFIG);
+               writel(RL, EMIF4_1_DDR_PHY_CTRL_1);
+               writel(RL, EMIF4_1_DDR_PHY_CTRL_1_SHADOW);
+               /* initially a large refresh period */

board/ti/ti816x/evm.c line 281

Quoted 10 lines
board/ti/ti816x/evm.c new file +10 -0
+               writel(0x0000613B, EMIF4_1_SDRAM_REF_CTRL);
+               /* trigger initialization */
+               writel(0x1000613B, EMIF4_1_SDRAM_REF_CTRL);
+               writel((0x10000000|EMIF_SDREF), EMIF4_1_SDRAM_REF_CTRL);
+       }
+
+       delay(1000);
+#ifdef CONFIG_TI816X_DDR3_SW_LEVELING
+       ddr3_sw_levelling(0);
+       ddr3_sw_levelling(1);

call levelling code on both interfaces if only one EMIF is being used?
make conditional on USE_EMIF1

board/ti/ti816x/evm.c line 288

Quoted 8 lines
board/ti/ti816x/evm.c new file +7 -0
+#endif
+}
+
+/* needed by config_dmm() */
+void enable_dmm_clocks(void) {};
+
+static void config_ti816x_sdram_ddr(void)

again SOC specific code to move out of board file

Quoted 547 lines
board/ti/ti816x/evm.c new file +4 -0
+{
+       /* Enable the EMIF Firewall clocks */
+       writel(0x2, CM_DEFAULT_FW_CLKCTRL);
+       /* Enable the Power Domain Transition of L3 Fast Domain Peripheral

*/

board/ti/ti816x/evm.c new file +34 -0
+       writel(0x2, CM_DEFAULT_L3_FAST_CLKSTCTRL);
+       /* Enable EMIF0 Clock */
+       writel(0x2, CM_DEFAULT_EMIF_0_CLKCTRL);
+       /* Enable EMIF1 Clock */
+       writel(0x2, CM_DEFAULT_EMIF_1_CLKCTRL);
+       /* Poll for L3_FAST_GCLK  & DDR_GCLK  are active */
+       while ((readl(CM_DEFAULT_L3_FAST_CLKSTCTRL) & 0x300) != 0x300)
+               ;
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_EMIF_0_CLKCTRL)) != 0x2)
+               ;
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_EMIF_1_CLKCTRL)) != 0x2)
+               ;
+
+       if (USE_EMIF0)
+               ddr_init_settings(0);
+
+       if (USE_EMIF1)
+               ddr_init_settings(1);
+
+       /* Enable EMIF1 Clock */
+       writel(0x2, CM_DEFAULT_DMM_CLKCTRL);
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_DMM_CLKCTRL)) != 0x2)
+               ;
+
+       /* Program the DMM to for interleaved configuration */
+       config_dmm(&evm_lisa_map_regs);
+
+       /* Enable Tiled Access */
+       writel(0x80000000, DMM_PAT_BASE_ADDR);
+
+       emif4p_init(EMIF_TIM1, EMIF_TIM2, EMIF_TIM3, EMIF_SDREF &

0xFFFFFFF,

board/ti/ti816x/evm.c new file +143 -0
+                       EMIF_SDCFG, EMIF_PHYCFG);
+}
+
+#ifdef CONFIG_TI816X_DDR3_SW_LEVELING
+static void ddr3_sw_levelling(int emif)
+{
+       writel(0x6, (DDRPHY_CONFIG_BASE + 0x358));
+
+       writel(DQS_GATE_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x108));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x10C));
+       writel(DQS_GATE_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x1AC));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x1B0));
+       writel(DQS_GATE_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x250));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x254));
+       writel(DQS_GATE_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x2F4));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x2F8));
+
+       writel(WR_DQS_RATIO_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x0DC));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x0E0));
+       writel(WR_DQS_RATIO_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x180));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x184));
+       writel(WR_DQS_RATIO_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x224));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x228));
+       writel(WR_DQS_RATIO_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x2C8));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x2CC));
+
+       writel(WR_DATA_RATIO_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x120));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x124));
+       writel(WR_DATA_RATIO_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x1C4));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x1C8));
+       writel(WR_DATA_RATIO_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x268));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x26C));
+       writel(WR_DATA_RATIO_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x30C));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x310));
+
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x0C8));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x0CC));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x16C));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x170));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x210));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x214));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x2B4));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x2B8));
+}
+#endif /* CONFIG_TI816X_DDR3_SW_LEVELING */
+
+#endif /* CONFIG_TI816X_EVM_DDR3 */
+
+#ifdef CONFIG_TI816X_EVM_DDR2
+static void ddr_init_settings(int emif)
+{
+       /* DLL Lockdiff */
+       if (get_cpu_rev() == 0) {
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x028));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x05C));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x090));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x138));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x1DC));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x280));
+               writel(0xF, (DDRPHY_CONFIG_BASE + 0x324));
+       }
+
+       if (get_cpu_rev() == 1)
+               writel(0x6, (DDRPHY_CONFIG_BASE + 0x358));
+
+       /* setup rank delays */
+       writel(0x1, (DDRPHY_CONFIG_BASE + 0x134));
+       writel(0x1, (DDRPHY_CONFIG_BASE + 0x1D8));
+       writel(0x1, (DDRPHY_CONFIG_BASE + 0x27C));
+       writel(0x1, (DDRPHY_CONFIG_BASE + 0x320));
+
+       /* invert_clk_out cmd0 */
+       writel(INVERT_CLK_OUT, (DDRPHY_CONFIG_BASE + 0x02C));
+       writel(INVERT_CLK_OUT, (DDRPHY_CONFIG_BASE + 0x060));
+       writel(INVERT_CLK_OUT, (DDRPHY_CONFIG_BASE + 0x094));
+
+       /* cmd0 slave ratio */
+       writel(CMD_SLAVE_RATIO, (DDRPHY_CONFIG_BASE + 0x01C));
+       writel(CMD_SLAVE_RATIO, (DDRPHY_CONFIG_BASE + 0x050));
+       writel(CMD_SLAVE_RATIO, (DDRPHY_CONFIG_BASE + 0x084));
+
+       writel(DQS_GATE_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x108));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x10C));
+       writel(DQS_GATE_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x1AC));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x1B0));
+       writel(DQS_GATE_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x250));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x254));
+       writel(DQS_GATE_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x2F4));
+       writel(0x00000000, (DDRPHY_CONFIG_BASE + 0x2F8));
+
+       writel(WR_DQS_RATIO_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x0DC));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x0E0));
+       writel(WR_DQS_RATIO_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x180));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x184));
+       writel(WR_DQS_RATIO_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x224));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x228));
+       writel(WR_DQS_RATIO_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x2C8));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x2CC));
+
+       writel(WR_DATA_RATIO_BYTE_LANE0, (DDRPHY_CONFIG_BASE + 0x120));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x124));
+       writel(WR_DATA_RATIO_BYTE_LANE1, (DDRPHY_CONFIG_BASE + 0x1C4));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x1C8));
+       writel(WR_DATA_RATIO_BYTE_LANE2, (DDRPHY_CONFIG_BASE + 0x268));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x26C));
+       writel(WR_DATA_RATIO_BYTE_LANE3, (DDRPHY_CONFIG_BASE + 0x30C));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x310));
+
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x0C8));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x0CC));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x16C));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x170));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x210));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x214));
+       writel(RD_DQS_RATIO, (DDRPHY_CONFIG_BASE + 0x2B4));
+       writel(0x0, (DDRPHY_CONFIG_BASE + 0x2B8));
+
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x00C));
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x010));
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x040));
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x044));
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x074));
+       writel(0x5, (DDRPHY_CONFIG_BASE + 0x078));
+
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x0A8));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x0AC));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x14C));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x150));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x1F0));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x1F4));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x294));
+       writel(0x4, (DDRPHY_CONFIG_BASE + 0x298));
+
+       if (get_cpu_rev() == 0) {
+               writel(0x5, (DDRPHY_CONFIG_BASE + 0x338));
+               writel(0x5, (DDRPHY_CONFIG_BASE + 0x340));
+               writel(0x5, (DDRPHY_CONFIG_BASE + 0x348));
+               writel(0x5, (DDRPHY_CONFIG_BASE + 0x350));
+       }
+
+}
+
+static void emif4p_init(u32 TIM1, u32 TIM2, u32 TIM3, u32 SDREF, u32

SDCFG,

board/ti/ti816x/evm.c new file +47 -0
+               u32 RL)
+{
+       /* Program EMIF0 CFG Registers */
+       writel(TIM1, EMIF4_0_SDRAM_TIM_1);
+       writel(TIM1, EMIF4_0_SDRAM_TIM_1_SHADOW);
+       writel(TIM2, EMIF4_0_SDRAM_TIM_2);
+       writel(TIM2, EMIF4_0_SDRAM_TIM_2_SHADOW);
+       writel(TIM3, EMIF4_0_SDRAM_TIM_3);
+       writel(TIM3, EMIF4_0_SDRAM_TIM_3_SHADOW);
+       writel(SDCFG, EMIF4_0_SDRAM_CONFIG);
+       writel(RL, EMIF4_0_DDR_PHY_CTRL_1);
+       writel(RL, EMIF4_0_DDR_PHY_CTRL_1_SHADOW);
+
+       if (CONFIG_TI816X_TWO_EMIF) {
+               writel(TIM1, EMIF4_1_SDRAM_TIM_1);
+               writel(TIM1, EMIF4_1_SDRAM_TIM_1_SHADOW);
+               writel(TIM2, EMIF4_1_SDRAM_TIM_2);
+               writel(TIM2, EMIF4_1_SDRAM_TIM_2_SHADOW);
+               writel(TIM3, EMIF4_1_SDRAM_TIM_3);
+               writel(TIM3, EMIF4_1_SDRAM_TIM_3_SHADOW);
+               writel(SDCFG, EMIF4_1_SDRAM_CONFIG);
+               writel(RL, EMIF4_1_DDR_PHY_CTRL_1);
+               writel(RL, EMIF4_1_DDR_PHY_CTRL_1_SHADOW);
+       }
+
+       /* setup a small control period */
+       writel(0x0000613B, EMIF4_0_SDRAM_REF_CTRL);
+       writel(0x1000613B, EMIF4_0_SDRAM_REF_CTRL);
+       writel((0x10000000|SDREF), EMIF4_0_SDRAM_REF_CTRL);
+
+       if (CONFIG_TI816X_TWO_EMIF) {
+               /* setup a small control period */
+               writel(0x0000613B, EMIF4_1_SDRAM_REF_CTRL);
+               writel(0x1000613B, EMIF4_1_SDRAM_REF_CTRL);
+               writel((0x10000000|SDREF), EMIF4_1_SDRAM_REF_CTRL);
+
+       }
+
+
+}
+
+/* needed by config_dmm() */
+void enable_dmm_clocks(void) {};
+
+static void config_ti816x_sdram_ddr(void)
+{
+       /* Enable the Power Domain Transition of L3 Fast Domain Peripheral

*/

board/ti/ti816x/evm.c new file +33 -0
+       writel(0x2, CM_DEFAULT_L3_FAST_CLKSTCTRL);
+       /* Enable EMIF0 Clock */
+       writel(0x2, CM_DEFAULT_EMIF_0_CLKCTRL);
+       /* Enable EMIF1 Clock */
+       writel(0x2, CM_DEFAULT_EMIF_1_CLKCTRL);
+       /* Poll for L3_FAST_GCLK  & DDR_GCLK  are active */
+       while ((readl(CM_DEFAULT_L3_FAST_CLKSTCTRL) & 0x300) != 0x300)
+               ;
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_EMIF_0_CLKCTRL)) != 0x2)
+               ;
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_EMIF_1_CLKCTRL)) != 0x2)
+               ;
+
+       ddr_init_settings(0);
+
+       if (CONFIG_TI816X_TWO_EMIF)
+               ddr_init_settings(1);
+
+       /* Enable EMIF1 Clock */
+       writel(0x2, CM_DEFAULT_DMM_CLKCTRL);
+       /* Poll for Module is functional */
+       while ((readl(CM_DEFAULT_DMM_CLKCTRL)) != 0x2)
+               ;
+
+       /* Program the DMM for interleave setting */
+       config_dmm(&evm_lisa_map_regs);
+
+       /* Enable Tiled Access */
+       writel(0x80000000, DMM_PAT_BASE_ADDR);
+
+       emif4p_init(EMIF_TIM1, EMIF_TIM2, EMIF_TIM3, EMIF_SDREF &

0xFFFFFFF,

board/ti/ti816x/evm.c new file +17 -0
+                       EMIF_SDCFG, EMIF_PHYCFG);
+
+}
+#endif
+
+/*
+ * TI816X specific functions
+ */
+static void main_pll_init_ti816x(u32 sil_index, u32 clk_index)
+{
+       u32 main_pll_ctrl = 0;
+
+       /*
+        * Sequence to be followed:
+        * 1. Put the PLL in bypass mode by setting BIT2 in its ctrl reg
+        * 2. Write the values of N,P in the CTRL reg
+        * 3. Program the freq values, divider values for the required

output

board/ti/ti816x/evm.c new file +2 -0
+        *    in the Control module reg
+        * 4. Note: Loading the freq value requires a particular bit to be

set

board/ti/ti816x/evm.c new file +3 -0
+        *    in the freq reg.
+        * 4. Program the CM divider value in the CM module reg
+        * 5. Enable the PLL by setting the appropriate bit in the CTRL

reg of

board/ti/ti816x/evm.c new file +4 -0
+        *    the PLL
+        */
+
+       /* If the registers have been set by the ROM code dont do anything

*/

board/ti/ti816x/evm.c new file +61 -0
+
+       main_pll_ctrl = readl(MAINPLL_CTRL);
+       main_pll_ctrl &= 0xFFFFFFFB;
+       main_pll_ctrl |= 4;
+       writel(main_pll_ctrl, MAINPLL_CTRL);
+
+       main_pll_ctrl = readl(MAINPLL_CTRL);
+       main_pll_ctrl &= 0xFFFFFFF7;
+       main_pll_ctrl |= 8;
+       writel(main_pll_ctrl, MAINPLL_CTRL);
+
+       main_pll_ctrl = readl(MAINPLL_CTRL);
+       main_pll_ctrl &= 0xFF;
+       main_pll_ctrl |= (MAIN_N<<16 | MAIN_P<<8);
+       writel(main_pll_ctrl, MAINPLL_CTRL);
+
+       writel(0x0, MAINPLL_PWD);
+
+       writel((1<<31 | 1<<28 | (MAIN_INTFREQ1<<24) | MAIN_FRACFREQ1),
+                       MAINPLL_FREQ1);
+       writel(((1<<8) | MAIN_MDIV1), MAINPLL_DIV1);
+
+       writel((1<<31 | 1<<28 | (MAIN_INTFREQ2<<24) | MAIN_FRACFREQ2),
+                       MAINPLL_FREQ2);
+       writel(((1<<8) | MAIN_MDIV2), MAINPLL_DIV2);
+
+       writel((1<<31 | 1<<28 | (MAIN_INTFREQ3<<24) | MAIN_FRACFREQ3),
+                       MAINPLL_FREQ3);
+       writel(((1<<8) | MAIN_MDIV3), MAINPLL_DIV3);
+
+       writel((1<<31 | 1<<28 | (MAIN_INTFREQ4<<24) | MAIN_FRACFREQ4),
+                       MAINPLL_FREQ4);
+       writel(((1<<8) | MAIN_MDIV4), MAINPLL_DIV4);
+
+       writel((1<<31 | 1<<28 | (MAIN_INTFREQ5<<24) | MAIN_FRACFREQ5),
+                       MAINPLL_FREQ5);
+       writel(((1<<8) | MAIN_MDIV5), MAINPLL_DIV5);
+
+       writel((1<<8 | MAIN_MDIV6), MAINPLL_DIV6);
+
+       writel((1<<8 | MAIN_MDIV7), MAINPLL_DIV7);
+
+       while ((readl(MAINPLL_CTRL) & 0x80) != 0x80)
+               ;
+
+       main_pll_ctrl = readl(MAINPLL_CTRL);
+       main_pll_ctrl &= 0xFFFFFFFB;
+
+       writel(main_pll_ctrl, MAINPLL_CTRL);
+
+}
+
+static void ddr_pll_init_ti816x(u32 sil_index, u32 clk_index)
+{
+       u32 ddr_pll_ctrl = 0;
+
+       /*
+        * Sequence to be followed:
+        * 1. Put the PLL in bypass mode by setting BIT2 in its ctrl reg
+        * 2. Write the values of N,P in the CTRL reg
+        * 3. Program the freq values, divider values for the required

output

board/ti/ti816x/evm.c new file +2 -0
+        *    in the Control module reg
+        * 4. Note: Loading the freq value requires a particular bit to be

set

board/ti/ti816x/evm.c new file +3 -0
+        *    in the freq reg.
+        * 5. Program the CM divider value in the CM module reg
+        * 6. Enable the PLL by setting the appropriate bit in the CTRL

reg of

board/ti/ti816x/evm.c new file +4 -0
+        * the PLL
+        */
+
+       /* If the registers have been set by the ROM code dont do anything

*/

board/ti/ti816x/evm.c new file +75 -0
+
+       ddr_pll_ctrl = readl(DDRPLL_CTRL);
+       ddr_pll_ctrl &= 0xFFFFFFFB;
+       writel(ddr_pll_ctrl, DDRPLL_CTRL);
+
+       ddr_pll_ctrl = readl(DDRPLL_CTRL);
+       ddr_pll_ctrl &= 0xFFFFFFF7;
+       ddr_pll_ctrl |= 8;
+       writel(ddr_pll_ctrl, DDRPLL_CTRL);
+
+       ddr_pll_ctrl = readl(DDRPLL_CTRL);
+       ddr_pll_ctrl &= 0xFF;
+       ddr_pll_ctrl |= (DDR_N<<16 | DDR_P<<8);
+       writel(ddr_pll_ctrl, DDRPLL_CTRL);
+
+       /* 10usec delay */
+       ddr_delay(10);
+
+       writel(0x0, DDRPLL_PWD);
+
+       writel(((0<<8) | DDR_MDIV1), DDRPLL_DIV1);
+       ddr_delay(1);
+       writel(((1<<8) | DDR_MDIV1), DDRPLL_DIV1);
+
+       writel((1<<31 | 1<<28 | (DDR_INTFREQ2<<24) | DDR_FRACFREQ2),
+                       DDRPLL_FREQ2);
+       writel(((1<<8) | DDR_MDIV2), DDRPLL_DIV2);
+
+       writel(((0<<8) | DDR_MDIV3), DDRPLL_DIV3);
+       ddr_delay(1);
+       writel(((1<<8) | DDR_MDIV3), DDRPLL_DIV3);
+       ddr_delay(1);
+       writel((0<<31 | 1<<28 | (DDR_INTFREQ3<<24) | DDR_FRACFREQ3),
+                       DDRPLL_FREQ3);
+       ddr_delay(1);
+       writel((1<<31 | 1<<28 | (DDR_INTFREQ3<<24) | DDR_FRACFREQ3),
+                       DDRPLL_FREQ3);
+
+       ddr_delay(5);
+
+       /* Wait for PLL to lock */
+       while ((readl(DDRPLL_CTRL) & 0x80) != 0x80)
+               ;
+
+       ddr_pll_ctrl = readl(DDRPLL_CTRL);
+       ddr_pll_ctrl &= 0xFFFFFFFB;
+       ddr_pll_ctrl |= 4;
+       writel(ddr_pll_ctrl, DDRPLL_CTRL);
+
+       writel(0x1, DDR_RCD);
+
+}
+
+/*****************************************************************
+ * Routine: peripheral_enable
+ * Description: Enable the clks & power for perifs (TIMER1, UART0,...)
+ *
+ ******************************************************************/
+static void peripheral_enable(void)
+{
+       /* DMTimers */
+       writel(0x2, CM_ALWON_L3_SLOW_CLKSTCTRL);
+
+       /*
+        * Note on Timers:
+        * There are 8 timers(0-7) out of which timer 0 is a secure timer.
+        * Timer 0 mux should not be changed
+        * For other timers, there are 3 inputs TCLKIN, 32KHz (external clk
+        * or SYSCLK18?) and CLKIN(27MHz)
+        * We select CLKIN and use that
+        */
+
+       /*
+        * First we need to enable the modules and setup the clk path
+        * Then the timers need to be configured by writing to their

registers

board/ti/ti816x/evm.c new file +76 -0
+        * To access the timer registers we need the module to be
+        * enabled which is what we do in the first step
+        */
+
+       /* TIMER 1 */
+       writel(0x2, CM_ALWON_TIMER_1_CLKCTRL);
+
+       /* Selects CLKIN (27MHz) */
+       writel(0x2, CM_TIMER1_CLKSEL);
+
+       while (((readl(CM_ALWON_L3_SLOW_CLKSTCTRL)
+                       & (0x80000<<1)) >> (19+1)) != 1)
+               ;
+
+       while (((readl(CM_ALWON_TIMER_1_CLKCTRL) & 0x30000)>>16) != 0)
+               ;
+
+
+       writel(0x2, (DM_TIMER1_BASE + 0x54));
+       while (readl(DM_TIMER1_BASE + 0x10) & 1)
+               ;
+
+       writel(0x1, (DM_TIMER1_BASE + 0x38));
+
+       /* UARTs */
+       /* Note: The clock has been set to correct rate before this step */
+       writel(0x2, CM_ALWON_UART_0_CLKCTRL);
+       while (readl(CM_ALWON_UART_0_CLKCTRL) != 0x2)
+               ;
+
+       writel(0x2, CM_ALWON_UART_1_CLKCTRL);
+       while (readl(CM_ALWON_UART_1_CLKCTRL) != 0x2)
+               ;
+
+       writel(0x2, CM_ALWON_UART_2_CLKCTRL);
+       while (readl(CM_ALWON_UART_2_CLKCTRL) != 0x2)
+               ;
+
+       while ((readl(CM_ALWON_L3_SLOW_CLKSTCTRL) & 0x2100) != 0x2100)
+               ;
+
+       /* eFuse */
+       writel(0x2, CM_ALWON_CUST_EFUSE_CLKCTRL);
+       while (readl(CM_ALWON_CUST_EFUSE_CLKCTRL) != 0x2)
+               ;
+
+       /* GPIO0 */
+       writel(0x2, CM_ALWON_GPIO_0_CLKCTRL);
+       while (readl(CM_ALWON_GPIO_0_CLKCTRL) != 0x2)
+               ;
+
+       writel((BIT(8)), CM_ALWON_GPIO_0_OPTFCLKEN_DBCLK);
+
+       /* SPI */
+       writel(0x2, CM_ALWON_SPI_CLKCTRL);
+       while (readl(CM_ALWON_SPI_CLKCTRL) != 0x2)
+               ;
+
+       /* I2C0 */
+       writel(0x2, CM_ALWON_I2C_0_CLKCTRL);
+       while (readl(CM_ALWON_I2C_0_CLKCTRL) != 0x2)
+               ;
+
+       /* Ethernet */
+       writel(0x2, CM_ETHERNET_CLKSTCTRL);
+       writel(0x2, CM_ALWON_ETHERNET_0_CLKCTRL);
+       writel(0x2, CM_ALWON_ETHERNET_1_CLKCTRL);
+
+       /* HSMMC */
+       writel(0x2, CM_ALWON_HSMMC_CLKCTRL);
+       while (readl(CM_ALWON_HSMMC_CLKCTRL) != 0x2)
+               ;
+
+       /* WDT */
+       /*
+        * For WDT to be functional, it needs to be first stopped by

writing
+ * the pattern 0xAAAA followed by 0x5555 in the WDT start/stop
register.

board/ti/ti816x/evm.c new file +19 -0
+        * After that a write-once register in Control module needs to
+        * be configured
+        * to unfreeze the timer.
+        * Note: It is important to stop the watchdog before unfreezing it
+        */
+       writel(0xAAAA, WDT_WSPR);
+       while (readl(WDT_WWPS) != 0x0)
+               ;
+       writel(0x5555, WDT_WSPR);
+       while (readl(WDT_WWPS) != 0x0)
+               ;
+
+       /* Unfreeze WDT */
+       writel(0x2, WDT_UNFREEZE);
+}
+
 
+/******************************************************************************
+ * prcm_init() - inits clocks for PRCM as defined in clocks.h
+

*****************************************************************************/

board/ti/ti816x/evm.c line 822

Quoted 6 lines
board/ti/ti816x/evm.c new file +6 -0
+void prcm_init(void)
+{
+       /* For future */
+       u32 clk_index = 0, sil_index = 0;
+
+       writel(0x2, 0x48200010);

define a register name please

board/ti/ti816x/evm.c line 827

Quoted 6 lines
board/ti/ti816x/evm.c new file +5 -0
+       /* Enable the control module */
+       writel(0x2, CM_ALWON_CONTROL_CLKCTRL);
+
+       /* Fix ROM code bug */
+       writel(0x0, 0x48180324);

what bug? define a register name

Quoted 84 lines
board/ti/ti816x/evm.c new file +39 -0
+
+       main_pll_init_ti816x(clk_index, sil_index);
+       ddr_pll_init_ti816x(clk_index, sil_index);
+
+       /*
+        * With clk freqs setup to desired values,
+        * enable the required peripherals
+        */
+       peripheral_enable();
+}
+#endif /* CONFIG_SPL_BUILD */
+
+/**********************************************************
+ * Routine: s_init
+ * Description: Does early system init of muxing and clocks.
+ * - Called at time when only stack is available.
+ **********************************************************/
+void s_init(void)
+{
+#ifdef CONFIG_SPL_BUILD
+       /* Setup the PLLs and the clocks for the peripherals */
+       prcm_init();
+       configure_module_pin_mux(mmc_pin_mux);
+
+       gd = &gdata;
+
+       preloader_console_init();
+
+       config_ti816x_sdram_ddr();      /* Do DDR settings */
+#endif
+}
+
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
+int board_mmc_init(bd_t *bis)
+{
+       omap_mmc_init(0, 0, 0);
+       return 0;
+}
+#endif
boards.cfg +0 -0
index c98495a..aab56b9 100644
@@ -239,6 +239,7 @@ am335x_evm_uart3             arm         armv7

am335x ti
am335x_evm_uart4 arm armv7 am335x
ti am33xx am335x_evm:SERIAL5,CONS_INDEX=5
am335x_evm_uart5 arm armv7 am335x
ti am33xx am335x_evm:SERIAL6,CONS_INDEX=6
ti814x_evm arm armv7 ti814x
ti am33xx

boards.cfg +1 -0
+ti816x_evm                   arm         armv7       ti816x
 ti             am33xx
 pcm051                       arm         armv7       pcm051
 phytec         am33xx      pcm051
 highbank                     arm         armv7       highbank
 -              highbank
 mx51_efikamx                 arm         armv7       mx51_efikamx
 genesi         mx5
 mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKAMX,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_mx.cfg
include/configs/ti816x_evm.h new file +8 -0
new file mode 100644
index 0000000..8d10b1c
@@ -0,0 +1,177 @@
+/*
+ * ti816x_evm.h
+ *
+ * Copyright (C) 2013, Adeneo Embedded <www.adeneo-embedded.com>
+ * Antoine Tenart, <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for

details.
+ */

include/configs/ti816x_evm.h new file +7 -0
+
+#ifndef __CONFIG_TI816X_EVM_H
+#define __CONFIG_TI816X_EVM_H
+
+#define CONFIG_TI81XX
+#define CONFIG_TI816X
+#define CONFIG_SYS_NO_FLASH

include/configs/ti816x_evm.h line 26

Quoted 10 lines
include/configs/ti816x_evm.h new file +10 -0
+
+#include <asm/arch/cpu.h>
+#include <asm/arch/hardware.h>
+
+#define CONFIG_ENV_SIZE                        0x2000
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (32 * 1024))
+#define CONFIG_SYS_LONGHELP            /* undef save memory */
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT              "u-boot/ti816x# "
+#define CONFIG_MACH_TYPE               MACH_TYPE_TI8168EVM

+

Quoted 164 lines
include/configs/ti816x_evm.h new file +6 -0
+#define CONFIG_OF_LIBFDT
+#define CONFIG_CMDLINE_TAG             /* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG              /* required for ramdisk support */
+
+#include <config_cmd_default.h>                /* u-boot default commands

*/

include/configs/ti816x_evm.h new file +5 -0
+
+#define CONFIG_VERSION_VARIABLE
+#define CONFIG_DISPLAY_CPUINFO
+
+#define CONFIG_BOOTDELAY               3 /* set negative for no autoboot

*/

include/configs/ti816x_evm.h new file +9 -0
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       "verify=yes\0"
+
+#define CONFIG_BOOTCOMMAND                     \
+       "mmc rescan 0;"                         \
+       "fatload mmc 0 0x81000000 uImage;"      \
+       "bootm 0x81000000"
+
+#define CONFIG_BOOTARGS        "console=ttyO2,115200n8 noinitrd

earlyprintk"

include/configs/ti816x_evm.h new file +10 -0
+
+/* Clock Defines */
+#define V_OSCK          24000000    /* Clock output from T2 */
+#define V_SCLK          (V_OSCK >> 1)
+
+#define CONFIG_SYS_MAXARGS     32
+#define CONFIG_SYS_CBSIZE      512 /* console I/O buffer size */
+#define CONFIG_SYS_PBSIZE      (CONFIG_SYS_CBSIZE \
+               + sizeof(CONFIG_SYS_PROMPT) + 16) /* print buffer size */
+#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE /* boot arg buffer size

*/

include/configs/ti816x_evm.h new file +11 -0
+
+/*
+ * Memtest works on 8 MB in DRAM after skipping 32MB
+ * from start addr of ram disk
+ */
+#define CONFIG_SYS_MEMTEST_START       (PHYS_DRAM_1 + (64*1024*1024))
+#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_MEMTEST_START \
+               + (8*1024*1024))
+
+#undef  CONFIG_SYS_CLKS_IN_HZ
+#define CONFIG_SYS_LOAD_ADDR           0x81000000 /* Default load address

*/

include/configs/ti816x_evm.h new file +23 -0
+#define CONFIG_SYS_HZ                  1000       /* 1ms clock */
+
+#define CONFIG_CMD_ASKEN
+#define CONFIG_CMD_ECHO
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_OMAP_HSMMC
+#define CONFIG_CMD_MMC
+#define CONFIG_DOS_PARTITION
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_EXT2
+
+#define CONFIG_FS_FAT
+
+/* Only one of the following two options (DDR3/DDR2) should be enabled */
+/*
+#define CONFIG_TI816X_EVM_DDR2
+#define CONFIG_TI816X_TWO_EMIF 1
+*/
+#define CONFIG_TI816X_EVM_DDR3
+
+
+#define CONFIG_NR_DRAM_BANKS   2               /* we have 2 banks of DRAM

*/

include/configs/ti816x_evm.h new file +53 -0
+#define PHYS_DRAM_1            0x80000000      /* DRAM Bank #1 */
+#define PHYS_DRAM_1_SIZE        0x40000000     /* 1 GB */
+#define PHYS_DRAM_2            0xC0000000      /* DRAM Bank #2 */
+#define PHYS_DRAM_2_SIZE       0x40000000      /* 1 GB */
+
+#define CONFIG_MAX_RAM_BANK_SIZE       (2048 << 20)    /* 2048MB */
+#define CONFIG_SYS_SDRAM_BASE          PHYS_DRAM_1
+#define CONFIG_SYS_INIT_SP_ADDR                (NON_SECURE_SRAM_END - \
+               GENERATED_GBL_DATA_SIZE)
+
+/**
+ * Platform/Board specific defs
+ */
+#define CONFIG_SYS_CLK_FREQ     27000000
+#define CONFIG_SYS_TIMERBASE    0x4802E000
+#define CONFIG_SYS_PTV          2   /* Divisor: 2^(PTV+1) => 8 */
+
+#undef CONFIG_NAND_OMAP_GPMC
+
+/*
+ * NS16550 Configuration
+ */
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE (-4)
+#define CONFIG_SYS_NS16550_CLK      (48000000)
+#define CONFIG_SYS_NS16550_COM1     0x48024000  /* Base EVM has UART2 */
+
+#define CONFIG_BAUDRATE     115200
+
+/* allow overwriting serial config and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+
+#define CONFIG_SERIAL1
+#define CONFIG_SERIAL2
+#define CONFIG_SERIAL3
+#define CONFIG_CONS_INDEX      1
+#define CONFIG_SYS_CONSOLE_INFO_QUIET
+
+#define CONFIG_ENV_IS_NOWHERE
+
+/* SPL */
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_TEXT_BASE    0x40300000
+#define CONFIG_SPL_MAX_SIZE     ((128 - 18) * 1024)
+#define CONFIG_SPL_STACK        CONFIG_SYS_INIT_SP_ADDR
+
+#define CONFIG_SPL_BSS_START_ADDR   0x80000000
+#define CONFIG_SPL_BSS_MAX_SIZE     0x80000     /* 512 KB */
+
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000

*/

include/configs/ti816x_evm.h new file +33 -1
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS      0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION    1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME        "u-boot.img"
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SPL_FAT_SUPPORT
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_GPIO_SUPPORT
+#define CONFIG_SPL_YMODEM_SUPPORT
+#define CONFIG_SYS_SPI_U_BOOT_OFFS  0x20000
+#define CONFIG_SYS_SPI_U_BOOT_SIZE  0x40000
+#define CONFIG_SPL_LDSCRIPT     "$(CPUDIR)/omap-common/u-boot-spl.lds"
+
+#define CONFIG_SPL_BOARD_INIT
+
+#define CONFIG_SYS_TEXT_BASE        0x80800000
+#define CONFIG_SYS_SPL_MALLOC_START 0x80208000
+#define CONFIG_SYS_SPL_MALLOC_SIZE  0x100000
+
+/* Since SPL did pll and ddr initialization for us,
+ * we don't need to do it twice.
+ */
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+
+/* Unsupported features */
+#undef CONFIG_USE_IRQ
+
+#endif
--

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

#7 lore raw

PATCH v3 3/3 Add TI816X evm board support

[snip]

Quoted 2 lines

these seem more SOC specific than board specific. Would likely be replicated per board, I'd suggest to move out of board specific file.

[snip]

Quoted 2 lines

this function is generic to the SOC, move out of board specific file and call with appropriate values or defines

-plus the other ones-

Well there is a SOC specific way to initialize DDR, config_ddr(?).

That was a question I had before sending the first version : whether to send a working version early without using this or to send a version later. Seems that you prefer the second option :).

Quoted 4 lines

+ /**** setup the initial levelinihg ratios ****/

typo

Right.

Quoted 7 lines

+#ifdef CONFIG_TI816X_DDR3_SW_LEVELING
+ ddr3_sw_levelling(0);
+ ddr3_sw_levelling(1);

call levelling code on both interfaces if only one EMIF is being used?
make conditional on USE_EMIF1

I'll do that.

Quoted 12 lines
    +/******************************************************************************
    + * prcm_init() - inits clocks for PRCM as defined in clocks.h
    +
    *****************************************************************************/
    +void prcm_init(void)
    +{
    +       /* For future */
    +       u32 clk_index = 0, sil_index = 0;
    +
    +       writel(0x2, 0x48200010);
Quoted 1 line

define a register name please

I'll do that.

Quoted 8 lines

+ /* Enable the control module */
+ writel(0x2, CM_ALWON_CONTROL_CLKCTRL);
+
+ /* Fix ROM code bug */
+ writel(0x0, 0x48180324);

what bug? define a register name

This is imported from implementation in the TI-PSP-04.00.02.14 vendor tree. I'll find the register name.

Signature · 1 line
Antoine
#8 lore raw

PATCH v3 3/3 Add TI816X evm board support

In reply to Andrew Dyer
Quoted 4 lines · Andrew Dyer

On Fri, Apr 12, 2013 at 7:10 AM, TENART Antoine <[email protected]

Quoted 3 lines

wrote:

[snip]

Quoted 2 lines

board/ti/ti816x/evm.c line 110

Quoted 2 lines
board/ti/ti816x/evm.c new file +2 -0
+       if (0 == get_cpu_rev()) {
+               writel(0xF, DDRPHY_CONFIG_BASE + 0x028);

Here, and in lots of similar places, we're writing to magic locations when we have a struct defined somewhere that describes them. These IP blocks are used elsewhere between am335x and omap4/5, so please look around and update. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130415/ef721fa9/attachment.pgp>