Skip to contentSkip to conversation

arm, davinci: add support for dm368 based cam_enc_4xx board

PATCH Superseded Heiko Schocher 3 participants 24 messages Jul 16, 2011 – Oct 5, 2011

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover arm, davinci: add support for dm368 based cam_enc_4xx board

- DM368 SOC
- booting with nand_spl not with UBL from TI
- before loading u-boot from NAND into RAM, test
the RAM with the post memory test. If error
is found, switch all LEDs on and halt system.
- SPI Flash
Dataflash Typ: M25PE80
- Ethernet DM9161BI

following patches posted on this list are needed for this board support:

- get CONFIG_POST working for arm boards:
[PATCH] post, memorytest: fix if vstart is not = 0x0

	http://patchwork.ozlabs.org/patch/98127/
[PATCH v2] post, memorytest: add support for none powerpc archs
	http://patchwork.ozlabs.org/patch/98522/
[PATCH] post, memory test: add memory_post_test() to include file
	http://patchwork.ozlabs.org/patch/98126/
[PATCH 1/2] arm, lib/board.c: Coding Style cleanup
	http://patchwork.ozlabs.org/patch/98532/
	update:
	http://patchwork.ozlabs.org/patch/104755/
	http://patchwork.ozlabs.org/patch/104932/
[PATCH 2/2] arm, lib/board.c: use gd->ram_size instead of bd->bi_memsize
	http://patchwork.ozlabs.org/patch/98531/

Patches based on:
commit 68d4230c3ccce96a72c5b99e48399bf1796fe3c6

Author: Ramneek Mehresh <[email protected]>
Date:   Tue Jun 7 10:10:43 2011 +0000

powerpc/85xx: Add default usb mode and phy type to hwconfig

"MAKEALL arm" looks good, checkpatch says:
total: 0 errors, 0 warnings, 585 lines checked

20110715_ml/0001-mkimage-add-UBL-header-support-for-booting-davinci-c.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 12 lines checked

20110715_ml/0002-arm-arm926-fix-missing-symbols-in-NAND_SPL-mode.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 37 lines checked

20110715_ml/0003-nand-add-a-hw-specific-subcommand-to-the-nand-comman.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 485 lines checked

20110715_ml/0004-arm-davinci-add-header-files-for-dm365.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 505 lines checked

20110715_ml/0005-arm-davinci-add-lowlevel-function-for-dm365-soc.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 91 lines checked

20110715_ml/0006-arm926ejs-davinci-add-cpuinfo-for-dm365.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 15 lines checked

20110715_ml/0007-arm926ejs-davinci-add-missing-spi-defines-for-dm365.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 54 lines checked

20110715_ml/0008-spl-nand-add-4bit-HW-ecc-oob-first-nand_read_page-fu.patch has no obvious style problems and is ready for submission.
WARNING: Use #include <linux/io.h> instead of <asm/io.h>
#153: FILE: board/ait/cam_enc_4xx/cam_enc_4xx.c:26:
+#include <asm/io.h>

WARNING: Use #include <linux/errno.h> instead of <asm/errno.h> #491: FILE: board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c:27:
+#include <asm/errno.h>

WARNING: Use #include <linux/io.h> instead of <asm/io.h> #493: FILE: board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c:29:
+#include <asm/io.h>

total: 0 errors, 3 warnings, 1377 lines checked

20110715_ml/0009-arm-davinci-add-cam_enc_4xx-support.patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

@Sandeep Paulraj:
I try to find time to switch to the new spl framework
from Daniel Schwierzeck, so arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c could be moved to arch/arm/cpu/arm926ejs/davinci/spl.c
but I don;t know (at the moment), if this code is valid
for all davinci cpus ... maybe you can give a comment
on this?

Heiko Schocher (9):
mkimage: add UBL header support for booting davinci cpus arm, arm926: fix missing symbols in NAND_SPL mode
nand: add a hw specific subcommand to the nand command. arm, davinci: add header files for dm365
arm, davinci: add lowlevel function for dm365 soc arm926ejs, davinci: add cpuinfo for dm365 arm926ejs, davinci: add missing spi defines for dm365 spl, nand: add 4bit HW ecc oob first nand_read_page function arm, davinci: add cam_enc_4xx support

 .gitignore                                         |    1 +
 MAINTAINERS                                        |    1 +
 MAKEALL                                            |    1 +
 Makefile                                           |    5 +
 README                                             |    2 +
 arch/arm/cpu/arm926ejs/davinci/cpu.c               |   34 ++-
 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c    |  463 ++++++++++++++++++++
 arch/arm/cpu/arm926ejs/start.S                     |    6 +
 arch/arm/include/asm/arch-davinci/aintc_defs.h     |   50 +++
 arch/arm/include/asm/arch-davinci/ddr2_defs.h      |   92 ++++
 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h |   42 ++
 arch/arm/include/asm/arch-davinci/hardware.h       |   13 +
 arch/arm/include/asm/arch-davinci/pll_defs.h       |   84 ++++
 arch/arm/include/asm/arch-davinci/psc_defs.h       |  129 ++++++
 arch/arm/include/asm/arch-davinci/syscfg_defs.h    |   66 +++
 arch/arm/include/asm/arch-davinci/timer_defs.h     |   48 ++
 board/ait/cam_enc_4xx/Makefile                     |   52 +++
 board/ait/cam_enc_4xx/cam_enc_4xx.c                |  331 ++++++++++++++
 board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c       |  115 +++++
 board/ait/cam_enc_4xx/config.mk                    |   19 +
 board/ait/cam_enc_4xx/ublimage.cfg                 |   48 ++
 boards.cfg                                         |    1 +
 common/cmd_nand.c                                  |    8 +
 common/image.c                                     |    1 +
 doc/README.davinci.nand_spl                        |  141 ++++++
 doc/README.ublimage                                |  141 ++++++
 include/configs/cam_enc_4xx.h                      |  423 ++++++++++++++++++
 include/image.h                                    |    1 +
 include/nand.h                                     |    3 +
 nand_spl/board/ait/cam_enc_4xx/Makefile            |  152 +++++++
 nand_spl/board/ait/cam_enc_4xx/u-boot.lds          |   75 ++++
 nand_spl/nand_boot.c                               |   42 ++
 tools/Makefile                                     |    2 +
 tools/mkimage.c                                    |    2 +
 tools/mkimage.h                                    |    1 +
 tools/ublimage.c                                   |  275 ++++++++++++
 tools/ublimage.h                                   |  103 +++++
 37 files changed, 2969 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c
 create mode 100644 arch/arm/include/asm/arch-davinci/aintc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/ddr2_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h
 create mode 100644 arch/arm/include/asm/arch-davinci/pll_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/psc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/syscfg_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/timer_defs.h
 create mode 100644 board/ait/cam_enc_4xx/Makefile
 create mode 100644 board/ait/cam_enc_4xx/cam_enc_4xx.c
 create mode 100644 board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c
 create mode 100644 board/ait/cam_enc_4xx/config.mk
 create mode 100644 board/ait/cam_enc_4xx/ublimage.cfg
 create mode 100644 doc/README.davinci.nand_spl
 create mode 100644 doc/README.ublimage
 create mode 100644 include/configs/cam_enc_4xx.h
 create mode 100644 nand_spl/board/ait/cam_enc_4xx/Makefile
 create mode 100644 nand_spl/board/ait/cam_enc_4xx/u-boot.lds
 create mode 100644 tools/ublimage.c
 create mode 100644 tools/ublimage.h
Signature · 1 line
1.7.6
#1 lore raw

PATCH 1/9 mkimage: add UBL header support for booting davinci cpus

creating an u-boot.ubl file, which contains the UBL Header needed for booting from NAND with the RBL from TI. For more information read doc/README.ublimage.

---
 .gitignore          |    1 +
 Makefile            |    5 +
 common/image.c      |    1 +
 doc/README.ublimage |  141 ++++++++++++++++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    2 +
 tools/mkimage.c     |    2 +
 tools/mkimage.h     |    1 +
 tools/ublimage.c    |  275 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/ublimage.h    |  103 +++++++++++++++++++
 10 files changed, 532 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.ublimage
 create mode 100644 tools/ublimage.c
 create mode 100644 tools/ublimage.h
.gitignore +1 -0
index 34a2ca9..dbf545f 100644
@@ -33,6 +33,7 @@
 /u-boot.sha1
 /u-boot.dis
 /u-boot.lds
+/u-boot.ubl
 
 #
 # Generated files
Makefile +5 -0
index e56fa02..01f9391 100644
@@ -400,6 +400,10 @@ $(obj)u-boot.sha1:	$(obj)u-boot.bin
 $(obj)u-boot.dis:	$(obj)u-boot
 		$(OBJDUMP) -d $< > $@
 
+$(obj)u-boot.ubl:       $(obj)u-boot-nand.bin
+		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
+		-e $(CONFIG_SYS_TEXT_BASE) -d $< $@
+
 GEN_UBOOT = \
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
 		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
@@ -1099,6 +1103,7 @@ clobber:	clean
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
 	@rm -f $(obj)u-boot.kwb
 	@rm -f $(obj)u-boot.imx
+	@rm -f $(obj)u-boot.ubl
 	@rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}
 	@rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
 	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
common/image.c +1 -0
index e542a57..50b4f80 100644
@@ -141,6 +141,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
 	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
+	{	IH_TYPE_UBLIMAGE,   "ublimage",   "Davinci UBL image",},
 	{	-1,		    "",		  "",			},
 };
 
doc/README.ublimage new file +141 -0

141 lines not on this page · raw message

include/image.h +1 -0
index c31e862..3c528a4 100644
@@ -157,6 +157,7 @@
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
 #define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
 #define IH_TYPE_IMXIMAGE	10	/* Freescale IMXBoot Image	*/
+#define IH_TYPE_UBLIMAGE	11	/* Davinci UBL Image		*/
 
 /*
  * Compression Types
tools/Makefile +2 -0
index 97f83f8..a7f7af1 100644
@@ -92,6 +92,7 @@ NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
+NOPED_OBJ_FILES-y += ublimage.o
 
 # Don't build by default
 #ifeq ($(ARCH),ppc)
@@ -189,6 +190,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
 			$(obj)sha1.o \
+			$(obj)ublimage.o \
 			$(LIBFDT_OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
tools/mkimage.c +2 -0
index 60f7263..7215d0f 100644
@@ -158,6 +158,8 @@ main (int argc, char **argv)
 	init_fit_image_type ();
 	/* Init Default image generation/list support */
 	init_default_image_type ();
+	/* Init Davinci UBL support */
+	init_ubl_image_type();
 
 	params.cmdname = *argv;
 	params.addr = params.ep = 0;
tools/mkimage.h +1 -0
index 9033a7d..d109d40 100644
@@ -143,5 +143,6 @@ void init_kwb_image_type (void);
 void init_imx_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
+void init_ubl_image_type(void);
 
 #endif /* _MKIIMAGE_H_ */
tools/ublimage.c new file +275 -0

275 lines not on this page · raw message

tools/ublimage.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.7.6
#2 lore raw

PATCH 1/9 mkimage: add UBL header support for booting davinci cpus

Dear Heiko Schocher,

Quoted 5 lines · In message <[email protected]> you wrote:

creating an u-boot.ubl file, which contains the UBL Header needed for booting from NAND with the RBL from TI. For more information read doc/README.ublimage.

Quoted 15 lines
---
 .gitignore          |    1 +
 Makefile            |    5 +
 common/image.c      |    1 +
 doc/README.ublimage |  141 ++++++++++++++++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    2 +
 tools/mkimage.c     |    2 +
 tools/mkimage.h     |    1 +
 tools/ublimage.c    |  275 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/ublimage.h    |  103 +++++++++++++++++++
 10 files changed, 532 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.ublimage
 create mode 100644 tools/ublimage.c
 create mode 100644 tools/ublimage.h

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An Ada exception is when a routine gets in trouble and says
'Beam me up, Scotty'.
#3 lore raw

PATCH 2/9 arm, arm926: fix missing symbols in NAND_SPL mode

In reply to Heiko Schocher
---
 arch/arm/cpu/arm926ejs/start.S |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/start.S +6 -0
index 0940937..7b1a803 100644
@@ -137,6 +137,12 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+#ifdef CONFIG_NAND_U_BOOT
+.globl _end
+_end:
+	.word __bss_end__
+#endif
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
Signature · 1 line
1.7.6
#4 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

In reply to Heiko Schocher

Actually this is needed for coming up davinci dm368 cam_enc_4xx board support. There we need two different nand read/write functions, because the RBL uses different nand read/write functions than u-boot.

Another place where such a command is used is:
arch/arm/cpu/armv7/omap3/board.c: do_switch_ecc()

Maybe this should be fixed?

---
 README            |    2 ++
 common/cmd_nand.c |    8 ++++++++
 include/nand.h    |    3 +++
 3 files changed, 13 insertions(+), 0 deletions(-)
README +2 -0
index 1e2d4d3..647e10b 100644
@@ -705,6 +705,8 @@ The following options need to be configured:
 		CONFIG_CMD_MII		* MII utility commands
 		CONFIG_CMD_MTDPARTS	* MTD partition support
 		CONFIG_CMD_NAND		* NAND support
+		CONFIG_CMD_NAND_HWFUNC	  add to the nand commando a hw specific
+					  subcommand.
 		CONFIG_CMD_NET		  bootp, tftpboot, rarpboot
 		CONFIG_CMD_PCA953X	* PCA953x I2C gpio commands
 		CONFIG_CMD_PCA953X_INFO	* PCA953x I2C gpio info command
common/cmd_nand.c +8 -0
index 8c56802..416d2c7 100644
@@ -689,6 +689,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 		return 0;
 	}
 #endif
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	if (strcmp(cmd, "hwfunc") == 0)
+		return nand_hwfunc(argc - 2, argv + 2);
+#endif
 
 usage:
 	return cmd_usage(cmdtp);
@@ -739,6 +743,10 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	"\n"
+	"nand hwfunc " CONFIG_CMD_NAND_HWFUNC "\n"
+#endif
 );
 
 static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
include/nand.h +3 -0
index 8d94b5c..06b86f8 100644
@@ -138,6 +138,9 @@ void board_nand_select_device(struct nand_chip *nand, int chip);
 
 __attribute__((noreturn)) void nand_boot(void);
 
+#ifdef CONFIG_CMD_NAND_HWFUNC
+int nand_hwfunc(int argc, char * const argv[]);
+#endif
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_OOB
Signature · 1 line
1.7.6
#5 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Sorry for the delay, didn't see this the first time around -- just noticed it in patchwork.

common/cmd_nand.c U_BOOT_CMD( · line 749

Quoted 8 lines · Heiko Schocher
common/cmd_nand.c +4 -0
@@ -739,6 +743,10 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	"\n"
+	"nand hwfunc " CONFIG_CMD_NAND_HWFUNC "\n"
+#endif

Why not just define hardware-specific commands at whatever scope they makes sense (board code, controller driver, etc.), rather than add a generic hook here?

-Scott

#6 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Hello Scott,

Quoted 2 lines · Scott Wood

Sorry for the delay, didn't see this the first time around -- just noticed it in patchwork.

No problem. Thanks for the review!

Quoted 5 lines · Heiko Schocher
Quoted 4 lines
common/cmd_nand.c +0 -0
@@ -739,6 +743,10 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
Quoted 8 lines

common/cmd_nand.c U_BOOT_CMD( · line 749

Quoted 4 lines
common/cmd_nand.c +4 -0
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	"\n"
+	"nand hwfunc " CONFIG_CMD_NAND_HWFUNC "\n"
+#endif

Why not just define hardware-specific commands at whatever scope they makes sense (board code, controller driver, etc.), rather than add a generic hook here?

Hmm... because if I define a hw specific command for example at soc scope, it is not a nand subcommand ... and I like to have all nand commands (I use it for switching between different read/write functions) accessable under "nand ..." from the u-boot shell ... I don;t like to have all over the code randomised some nand commands ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#7 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Quoted 22 lines · On Wed, 3 Aug 2011 07:14:51 +0200 Heiko Schocher <[email protected]> wrote:

Hello Scott,

Quoted 2 lines · Scott Wood

Sorry for the delay, didn't see this the first time around -- just noticed it in patchwork.

No problem. Thanks for the review!

Quoted 5 lines · Heiko Schocher
Quoted 4 lines
common/cmd_nand.c +0 -0
@@ -739,6 +743,10 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
Quoted 8 lines

common/cmd_nand.c U_BOOT_CMD( · line 749

Quoted 4 lines
common/cmd_nand.c +4 -0
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	"\n"
+	"nand hwfunc " CONFIG_CMD_NAND_HWFUNC "\n"
+#endif

Why not just define hardware-specific commands at whatever scope they makes sense (board code, controller driver, etc.), rather than add a generic hook here?

Quoted 5 lines

Hmm... because if I define a hw specific command for example at soc scope, it is not a nand subcommand ... and I like to have all nand commands (I use it for switching between different read/write functions) accessable under "nand ..." from the u-boot shell ... I don;t like to have all over the code randomised some nand commands ...

What if there are multiple such commands? You'd end up with "nand hwfunc foo <args>", which is getting a bit unwieldy. Having only one might actually be worse: what does a plain "nand hwfunc" do?

What if there are multiple commands, but which belong in different places (e.g. one defined by the board, one defined by the controller driver)?

-Scott

#8 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Hello Scott,

Quoted 22 lines · Scott Wood
Quoted 19 lines · On Wed, 3 Aug 2011 07:14:51 +0200 Heiko Schocher <[email protected]> wrote:

Hello Scott,

Quoted 2 lines · Scott Wood

Sorry for the delay, didn't see this the first time around -- just noticed it in patchwork.

No problem. Thanks for the review!

Quoted 12 lines · Heiko Schocher

common/cmd_nand.c U_BOOT_CMD( · line 749

Quoted 8 lines
common/cmd_nand.c +4 -0
@@ -739,6 +743,10 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
+#ifdef CONFIG_CMD_NAND_HWFUNC
+	"\n"
+	"nand hwfunc " CONFIG_CMD_NAND_HWFUNC "\n"
+#endif

Why not just define hardware-specific commands at whatever scope they makes sense (board code, controller driver, etc.), rather than add a generic hook here?

Quoted 7 lines
Quoted 5 lines

Hmm... because if I define a hw specific command for example at soc scope, it is not a nand subcommand ... and I like to have all nand commands (I use it for switching between different read/write functions) accessable under "nand ..." from the u-boot shell ... I don;t like to have all over the code randomised some nand commands ...

What if there are multiple such commands? You'd end up with "nand hwfunc

Then we would have a (as hwfunc is a nand subcommand) hwfunc subcommand(s) ...

Quoted 1 line

foo <args>", which is getting a bit unwieldy. Having only one might

Why? (I don;t know, if we get really more then one hwfunc...), but if we define all over the code some (board, soc, arch,...) specific nand commands, we lose track ... and with the "nand hwfunc" we have one place where we have to look ...

Quoted 1 line

actually be worse: what does a plain "nand hwfunc" do?

A plain "nand hwfunc" should print the help message (if we have more subcommands under "nand hwfunc"), if we have only one, it returns as usual in uboot, actual state ... for example on the cam_enc_4xx board:

cam_enc_4xx> nand
nand - NAND sub-system

Usage:
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
read/write 'size' bytes starting at offset 'off'
to/from memory address 'addr', skipping bad blocks.
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
With '.spread', erase enough for given file size, otherwise, 'size' includes skipped bad blocks.
nand erase.part [clean] partition - erase entire mtd partition' nand erase.chip [clean] - erase entire chip'
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub off size | scrub.part partition | scrub.chip
really clean NAND erasing bad blocks (UNSAFE)
nand markbad off [...] - mark bad block(s) at offset (UNSAFE) nand biterr off - make a bit error at offset (UNSAFE)
nand hwfunc [rbl/uboot]
switch between rbl/uboot nand read/write functions

cam_enc_4xx> nand hwfunc
uboot
cam_enc_4xx>

Quoted 2 lines

What if there are multiple commands, but which belong in different places (e.g. one defined by the board, one defined by the controller driver)?

Maybe something like this?

nand hwfunc arch ...
nand hwfunc board ...
nand hwfunc ctrl ...
nand hwfunc soc ...
[...]

each hwfunc subcommand added through an define ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#9 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Quoted 5 lines · Heiko Schocher
Quoted 1 line · Scott Wood

What if there are multiple such commands? You'd end up with "nand hwfunc

Then we would have a (as hwfunc is a nand subcommand) hwfunc subcommand(s) ...

The question was rhetorical, as the next sentence indicates -- unless you had a different answer, of course.

Quoted 3 lines
Quoted 1 line

foo<args>", which is getting a bit unwieldy. Having only one might

Why?

The "hwfunc" doesn't really tell the user anything, it's an internal implementation detail of where in the code the command is implemented. It's verbosity without benefit.

Quoted 1 line

(I don;t know, if we get really more then one hwfunc...)

You later say a plain "nand hwfunc" would print a help message, so that plus one real command makes two...

Quoted 3 lines

, but if we define all over the code some (board, soc, arch,...) specific nand commands, we lose track ...
and with the "nand hwfunc" we have one place where we have to look ...

More like one thing to grep for, and you'll still need to limit the files grepped so you don't get irrelevant results from other boards or controllers. Why not just search those files for U_BOOT_CMD?

Quoted 5 lines
Quoted 1 line

actually be worse: what does a plain "nand hwfunc" do?

A plain "nand hwfunc" should print the help message (if we have more subcommands under "nand hwfunc"), if we have only one, it returns as usual in uboot, actual state ...

"actual state" of what? We haven't gotten to the point of actually defining a command yet.

Quoted 5 lines

nand hwfunc [rbl/uboot]
switch between rbl/uboot nand read/write functions

cam_enc_4xx> nand hwfunc
uboot

Again, I think "nand hwfunc" conveys little information about what it's actually going to do, versus something like:

=> nandrbl
off

At least "nand hwfunc type" or "nand hwfunc rbl" would be more informative, but I question the benefit that the verbosity buys us.

Why do you need alternative implementations of read/write functions, BTW?

Quoted 7 lines

cam_enc_4xx>

Quoted 2 lines

What if there are multiple commands, but which belong in different places (e.g. one defined by the board, one defined by the controller driver)?

Maybe something like this?

Quoted 7 lines

nand hwfunc arch ...
nand hwfunc board ...
nand hwfunc ctrl ...
nand hwfunc soc ...
[...]

each hwfunc subcommand added through an define ...

So now it's "nand hwfunc ctrl type rbl"? Just to avoid grepping for U_BOOT_CMD?

Or by "one place to look" are you talking about as a user in the help output? If you insist on the command appearing as a proper "nand" subcommand, how about dropping "hwfunc" and letting other pieces of code register on a chain of handlers? Anything that isn't recognized gets passed on to the next link in the chain.

-Scott

#10 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Dear Scott Wood,

Quoted 6 lines · In message <[email protected]> you wrote:

Again, I think "nand hwfunc" conveys little information about what it's actually going to do, versus something like:

=> nandrbl
off

I agree with Heiko that NAND related commands should be implemented as subcommands of the "nand" command.

Havong "nand <subcommand>" and "nandrbl" at the same time is not acceptable to me - that should be changed into "nand rbl".

Quoted 2 lines

At least "nand hwfunc type" or "nand hwfunc rbl" would be more informative, but I question the benefit that the verbosity buys us.

I agree that "hwfunc" is an unlucky name.

Quoted 2 lines

So now it's "nand hwfunc ctrl type rbl"? Just to avoid grepping for U_BOOT_CMD?

No. I would not like this either.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
War isn't a good life, but it's life.
	-- Kirk, "A Private Little War", stardate 4211.8
#11 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Quoted 19 lines · Wolfgang Denk

Dear Scott Wood,

Quoted 6 lines · In message<[email protected]> you wrote:

Again, I think "nand hwfunc" conveys little information about what it's actually going to do, versus something like:

=> nandrbl
off

I agree with Heiko that NAND related commands should be implemented as subcommands of the "nand" command.

Havong "nand<subcommand>" and "nandrbl" at the same time is not acceptable to me - that should be changed into "nand rbl".

Quoted 2 lines

At least "nand hwfunc type" or "nand hwfunc rbl" would be more informative, but I question the benefit that the verbosity buys us.

Quoted 6 lines

I agree that "hwfunc" is an unlucky name.

Quoted 2 lines

So now it's "nand hwfunc ctrl type rbl"? Just to avoid grepping for U_BOOT_CMD?

No. I would not like this either.

How about some way of board/controller/etc. code plugging in commands to "nand" without "hwfunc"? Could be a chained handler, or copying entries into a command table, or some way of generalizing the stuff in common/command.c to operate on multiple command lists. Though without some change to how linker scripts are managed, to be practical that last option would need to avoid introducing a new section per subtable (maybe just filter out others when iterating). Would be nice to get tab completion on subcommands.

-Scott

#12 lore raw

PATCH 3/9 nand: add a hw specific subcommand to the nand command.

Dear Scott Wood,

Quoted 5 lines · In message <[email protected]> you wrote:

How about some way of board/controller/etc. code plugging in commands to "nand" without "hwfunc"? Could be a chained handler, or copying entries into a command table, or some way of generalizing the stuff in common/command.c to operate on multiple command lists. Though without

I think a chained handler would be best.

Quoted 2 lines

some change to how linker scripts are managed, to be practical that last option would need to avoid introducing a new section per subtable (maybe

I didn't have time to actually think this to an end how to implement it etc. Proposals / patches welcome :-)

Quoted 2 lines

just filter out others when iterating). Would be nice to get tab completion on subcommands.

Indeed :-)

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every revolutionary idea - in science, politics, art, or  whatever  -
evokes three stages of reaction in a hearer:
  1. It is completely impossible - don't waste my time.
  2. It is possible, but it is not worth doing.
  3. I said it was a good idea all along.
#13 lore raw

PATCH 4/9 arm, davinci: add header files for dm365

In reply to Heiko Schocher
---
 arch/arm/include/asm/arch-davinci/aintc_defs.h  |   50 +++++++++
 arch/arm/include/asm/arch-davinci/ddr2_defs.h   |   92 ++++++++++++++++
 arch/arm/include/asm/arch-davinci/hardware.h    |   11 ++
 arch/arm/include/asm/arch-davinci/pll_defs.h    |   79 ++++++++++++++
 arch/arm/include/asm/arch-davinci/psc_defs.h    |  129 +++++++++++++++++++++++
 arch/arm/include/asm/arch-davinci/syscfg_defs.h |   66 ++++++++++++
 arch/arm/include/asm/arch-davinci/timer_defs.h  |   48 +++++++++
 7 files changed, 475 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-davinci/aintc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/ddr2_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/pll_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/psc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/syscfg_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/timer_defs.h
arch/arm/include/asm/arch-davinci/aintc_defs.h new file +50 -0
new file mode 100644
index 0000000..8f37053
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * 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 _DV_AINTC_DEFS_H_
+#define _DV_AINTC_DEFS_H_
+
+struct dv_aintc_regs {
+	unsigned int	fiq0;		/* 0x00 */
+	unsigned int	fiq1;		/* 0x04 */
+	unsigned int	irq0;		/* 0x08 */
+	unsigned int	irq1;		/* 0x0c */
+	unsigned int	fiqentry;	/* 0x10 */
+	unsigned int	irqentry;	/* 0x14 */
+	unsigned int	eint0;		/* 0x18 */
+	unsigned int	eint1;		/* 0x1c */
+	unsigned int	intctl;		/* 0x20 */
+	unsigned int	eabase;		/* 0x24 */
+	unsigned char	rsvd0[8];	/* 0x28 */
+	unsigned int	intpri0;	/* 0x30 */
+	unsigned int	intpri1;	/* 0x34 */
+	unsigned int	intpri2;	/* 0x38 */
+	unsigned int	intpri3;	/* 0x3c */
+	unsigned int	intpri4;	/* 0x40 */
+	unsigned int	intpri5;	/* 0x44 */
+	unsigned int	intpri6;	/* 0x48 */
+	unsigned int	intpri7;	/* 0x4c */
+};
+
+#define dv_aintc_regs ((struct dv_aintc_regs *)DAVINCI_ARM_INTC_BASE)
+
+#endif /* _DV_AINTC_DEFS_H_ */
arch/arm/include/asm/arch-davinci/ddr2_defs.h new file +92 -0

92 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/hardware.h +11 -0
index df3f549..f2c1060 100644
@@ -108,6 +108,7 @@ typedef volatile unsigned int *	dv_reg_p;
 #define DAVINCI_MMC_SD1_BASE			0x01d00000
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x01d10000
 #define DAVINCI_MMC_SD0_BASE			0x01d11000
+#define DAVINCI_DDR_EMIF_CTRL_BASE		0x20000000
 
 #elif defined(CONFIG_SOC_DM646X)
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x20008000
@@ -478,4 +479,14 @@ static inline int get_async3_src(void)
 
 #endif /* CONFIG_SOC_DA8XX */
 
+#if defined(CONFIG_SOC_DM365)
+#include <asm/arch/aintc_defs.h>
+#include <asm/arch/ddr2_defs.h>
+#include <asm/arch/emif_defs.h>
+#include <asm/arch/gpio_defs.h>
+#include <asm/arch/pll_defs.h>
+#include <asm/arch/psc_defs.h>
+#include <asm/arch/syscfg_defs.h>
+#include <asm/arch/timer_defs.h>
+#endif
 #endif /* __ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-davinci/pll_defs.h new file +79 -0

79 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/psc_defs.h new file +129 -0

129 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/syscfg_defs.h new file +66 -0

66 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/timer_defs.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.6
#14 lore raw

PATCH v2 6/10 arm, davinci: add header files for dm365

Cc Albert ARIBAUD <[email protected]>
Cc Sandeep Paulraj <[email protected]>

---
changes for v2:
- rebase to TOT
- add defines for timer 3 and 4
- delete "struct dv_timer_regs" as it is now "davinci_timer"

 arch/arm/include/asm/arch-davinci/aintc_defs.h  |   50 +++++++++
 arch/arm/include/asm/arch-davinci/hardware.h    |   13 +++
 arch/arm/include/asm/arch-davinci/pll_defs.h    |   79 ++++++++++++++
 arch/arm/include/asm/arch-davinci/psc_defs.h    |  129 +++++++++++++++++++++++
 arch/arm/include/asm/arch-davinci/syscfg_defs.h |   66 ++++++++++++
 5 files changed, 337 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-davinci/aintc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/pll_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/psc_defs.h
 create mode 100644 arch/arm/include/asm/arch-davinci/syscfg_defs.h
arch/arm/include/asm/arch-davinci/aintc_defs.h new file +50 -0
new file mode 100644
index 0000000..8f37053
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * 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 _DV_AINTC_DEFS_H_
+#define _DV_AINTC_DEFS_H_
+
+struct dv_aintc_regs {
+	unsigned int	fiq0;		/* 0x00 */
+	unsigned int	fiq1;		/* 0x04 */
+	unsigned int	irq0;		/* 0x08 */
+	unsigned int	irq1;		/* 0x0c */
+	unsigned int	fiqentry;	/* 0x10 */
+	unsigned int	irqentry;	/* 0x14 */
+	unsigned int	eint0;		/* 0x18 */
+	unsigned int	eint1;		/* 0x1c */
+	unsigned int	intctl;		/* 0x20 */
+	unsigned int	eabase;		/* 0x24 */
+	unsigned char	rsvd0[8];	/* 0x28 */
+	unsigned int	intpri0;	/* 0x30 */
+	unsigned int	intpri1;	/* 0x34 */
+	unsigned int	intpri2;	/* 0x38 */
+	unsigned int	intpri3;	/* 0x3c */
+	unsigned int	intpri4;	/* 0x40 */
+	unsigned int	intpri5;	/* 0x44 */
+	unsigned int	intpri6;	/* 0x48 */
+	unsigned int	intpri7;	/* 0x4c */
+};
+
+#define dv_aintc_regs ((struct dv_aintc_regs *)DAVINCI_ARM_INTC_BASE)
+
+#endif /* _DV_AINTC_DEFS_H_ */
arch/arm/include/asm/arch-davinci/hardware.h +13 -0
index b6a3209..e4be42a 100644
@@ -56,6 +56,7 @@ typedef volatile unsigned int *	dv_reg_p;
 #define DAVINCI_DMA_3PTC1_BASE			(0x01c10400)
 #define DAVINCI_UART0_BASE			(0x01c20000)
 #define DAVINCI_UART1_BASE			(0x01c20400)
+#define DAVINCI_TIMER3_BASE			(0x01c20800)
 #define DAVINCI_I2C_BASE			(0x01c21000)
 #define DAVINCI_TIMER0_BASE			(0x01c21400)
 #define DAVINCI_TIMER1_BASE			(0x01c21800)
@@ -63,6 +64,7 @@ typedef volatile unsigned int *	dv_reg_p;
 #define DAVINCI_PWM0_BASE			(0x01c22000)
 #define DAVINCI_PWM1_BASE			(0x01c22400)
 #define DAVINCI_PWM2_BASE			(0x01c22800)
+#define DAVINCI_TIMER4_BASE			(0x01c23800)
 #define DAVINCI_SYSTEM_MODULE_BASE		(0x01c40000)
 #define DAVINCI_PLL_CNTRL0_BASE			(0x01c40800)
 #define DAVINCI_PLL_CNTRL1_BASE			(0x01c40c00)
@@ -108,6 +110,7 @@ typedef volatile unsigned int *	dv_reg_p;
 #define DAVINCI_MMC_SD1_BASE			0x01d00000
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x01d10000
 #define DAVINCI_MMC_SD0_BASE			0x01d11000
+#define DAVINCI_DDR_EMIF_CTRL_BASE		0x20000000
 
 #elif defined(CONFIG_SOC_DM646X)
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x20008000
@@ -538,4 +541,14 @@ static inline int get_async3_src(void)
 
 #endif /* CONFIG_SOC_DA8XX */
 
+#if defined(CONFIG_SOC_DM365)
+#include <asm/arch/aintc_defs.h>
+#include <asm/arch/ddr2_defs.h>
+#include <asm/arch/emif_defs.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/pll_defs.h>
+#include <asm/arch/psc_defs.h>
+#include <asm/arch/syscfg_defs.h>
+#include <asm/arch/timer_defs.h>
+#endif
 #endif /* __ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-davinci/pll_defs.h new file +79 -0

79 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/psc_defs.h new file +129 -0

129 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/syscfg_defs.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
1.7.6.2
#15 lore raw

PATCH 5/9 arm, davinci: add lowlevel function for dm365 soc

In reply to Heiko Schocher

used for booting (for example) from NAND using nand_spl code.

---
 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c    |  463 ++++++++++++++++++++
 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h |   42 ++
 2 files changed, 505 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c
 create mode 100644 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h
arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c new file +463 -0
new file mode 100644
index 0000000..bd32f6b
@@ -0,0 +1,463 @@
+/*
+ * SoC-specific lowlevel code for tms320dm365 and similar chips
+ * Actually used for booting from NAND with nand_spl.
+ *
+ * Copyright (C) 2011
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <common.h>
+#include <nand.h>
+#include <ns16550.h>
+#include <post.h>
+#include <asm/arch/dm365_lowlevel.h>
+#include <asm/arch/hardware.h>
+
+void dm365_waitloop(unsigned long loopcnt)
+{
+	unsigned long	i;
+
+	for (i = 0; i < loopcnt; i++)
+		asm("   NOP");
+}
+
+int dm365_pll1_init(unsigned long pllmult, unsigned long prediv)
+{
+	unsigned int clksrc = 0x0;
+
+	/* Power up the PLL */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLPWRDN);
+
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_RES_9);
+	setbits_le32(&dv_pll0_regs->pllctl, clksrc << 8);
+
+	/*
+	 * Set PLLENSRC '0', PLL Enable(PLLEN) selection is controlled
+	 * through MMR
+	 */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLENSRC);
+
+	/* Set PLLEN=0 => PLL BYPASS MODE */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLEN);
+
+	dm365_waitloop(150);
+
+	 /* PLLRST=1(reset assert) */
+	setbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLRST);
+
+	dm365_waitloop(300);
+
+	/*Bring PLL out of Reset*/
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLRST);
+
+	/* Program the Multiper and Pre-Divider for PLL1 */
+	writel(pllmult, &dv_pll0_regs->pllm);
+	writel(prediv, &dv_pll0_regs->prediv);
+
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE |
+		PLLSECCTL_TINITZ, &dv_pll0_regs->secctl);
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE,
+		&dv_pll0_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE, &dv_pll0_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TINITZ, &dv_pll0_regs->secctl);
+
+	/* Program the PostDiv for PLL1 */
+	writel(0x8000, &dv_pll0_regs->postdiv);
+
+	/* Post divider setting for PLL1 */
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV1, &dv_pll0_regs->plldiv1);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV2, &dv_pll0_regs->plldiv2);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV3, &dv_pll0_regs->plldiv3);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV4, &dv_pll0_regs->plldiv4);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV5, &dv_pll0_regs->plldiv5);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV6, &dv_pll0_regs->plldiv6);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV7, &dv_pll0_regs->plldiv7);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV8, &dv_pll0_regs->plldiv8);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV9, &dv_pll0_regs->plldiv9);
+
+	dm365_waitloop(300);
+
+	/* Set the GOSET bit */
+	writel(PLLCMD_GOSET, &dv_pll0_regs->pllcmd); /* Go */
+
+	dm365_waitloop(300);
+
+	/* Wait for PLL to LOCK */
+	while (!((readl(&dv_sys_module_regs->pll0_config) & PLL0_LOCK)
+		== PLL0_LOCK))
+		;
+
+	/* Enable the PLL Bit of PLLCTL*/
+	setbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLEN);
+
+	return 0;
+}
+
+int dm365_pll2_init(unsigned long pllm, unsigned long prediv)
+{
+	unsigned int clksrc = 0x0;
+
+	/* Power up the PLL*/
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLPWRDN);
+
+	/*
+	 * Select the Clock Mode as Onchip Oscilator or External Clock on
+	 * MXI pin
+	 * VDB has input on MXI pin
+	 */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_RES_9);
+	setbits_le32(&dv_pll1_regs->pllctl, clksrc << 8);
+
+	/*
+	 * Set PLLENSRC '0', PLL Enable(PLLEN) selection is controlled
+	 * through MMR
+	 */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLENSRC);
+
+	/* Set PLLEN=0 => PLL BYPASS MODE */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLEN);
+
+	dm365_waitloop(50);
+
+	 /* PLLRST=1(reset assert) */
+	setbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLRST);
+
+	dm365_waitloop(300);
+
+	/* Bring PLL out of Reset */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLRST);
+
+	/* Program the Multiper and Pre-Divider for PLL2 */
+	writel(pllm, &dv_pll1_regs->pllm);
+	writel(prediv, &dv_pll1_regs->prediv);
+
+	writel(0x8000, &dv_pll1_regs->postdiv);
+
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE |
+		PLLSECCTL_TINITZ, &dv_pll1_regs->secctl);
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE,
+		&dv_pll1_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE, &dv_pll1_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TINITZ, &dv_pll1_regs->secctl);
+
+	/* Post divider setting for PLL2 */
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV1, &dv_pll1_regs->plldiv1);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV2, &dv_pll1_regs->plldiv2);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV3, &dv_pll1_regs->plldiv3);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV4, &dv_pll1_regs->plldiv4);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV5, &dv_pll1_regs->plldiv5);
+
+	/* GoCmd for PostDivider to take effect */
+	writel(PLLCMD_GOSET, &dv_pll1_regs->pllcmd);
+
+	dm365_waitloop(150);
+
+	/* Wait for PLL to LOCK */
+	while (!((readl(&dv_sys_module_regs->pll1_config) & PLL1_LOCK)
+		== PLL1_LOCK))
+		;
+
+	dm365_waitloop(4100);
+
+	/* Enable the PLL2 */
+	setbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLEN);
+
+	/* do this after PLL's have been set up */
+	writel(CONFIG_SYS_DM36x_PERI_CLK_CTRL,
+		&dv_sys_module_regs->peri_clkctl);
+
+	return 0;
+}
+
+void dm365_lpc_transition(unsigned char module, unsigned char domain,
+				unsigned char state)
+{
+	/* Wait for any outstanding transition to complete */
+	while ((readl(&dv_psc_regs->ptstat)) & (PSC_GOSTAT << domain))
+		;
+
+	/* If we are already in that state, just return */
+	if (((readl(&dv_psc_regs->mdstat[module])) & PSC_MD_STATE_MSK)
+		== state)
+		return;
+
+	/* Perform transition */
+	writel(((readl(&dv_psc_regs->mdctl[module])) & (~PSC_MD_STATE_MSK)) |
+		state, &dv_psc_regs->mdctl[module]);
+	setbits_le32(&dv_psc_regs->ptcmd, (PSC_CMD_GO << domain));
+
+	/* Wait for transition to complete */
+	while ((readl(&dv_psc_regs->ptstat)) & (PSC_GOSTAT << domain))
+		;
+
+	/* Wait and verify the state */
+	while (((readl(&dv_psc_regs->mdstat[module])) & PSC_MD_STATE_MSK)
+		!= state)
+		;
+}
+
+int dm365_ddr_setup(void)
+{
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+	clrbits_le32(&dv_sys_module_regs->vtpiocr,
+		VPTIO_IOPWRDN | VPTIO_CLRZ | VPTIO_LOCK | VPTIO_PWRDN);
+
+	/* Set bit CLRZ (bit 13) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_CLRZ);
+
+	/* Check VTP READY Status */
+	while (!(readl(&dv_sys_module_regs->vtpiocr) & VPTIO_RDY))
+		;
+
+	/* Set bit VTP_IOPWRDWN bit 14 for DDR input buffers) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_IOPWRDN);
+
+	/* Set bit LOCK(bit7) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_LOCK);
+
+	/*
+	 * Powerdown VTP as it is locked (bit 6)
+	 * Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
+	 */
+	setbits_le32(&dv_sys_module_regs->vtpiocr,
+		VPTIO_IOPWRDN | VPTIO_PWRDN);
+
+	/* Wait for calibration to complete */
+	dm365_waitloop(150);
+
+	/* Set the DDR2 to synreset, then enable it again */
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_SYNCRESET);
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+
+	writel(CONFIG_SYS_DM36x_DDR2_DDRPHYCR, &dv_ddr2_regs_ctrl->ddrphycr);
+
+	/* Program SDRAM Bank Config Register */
+	writel((CONFIG_SYS_DM36x_DDR2_SDBCR | DM36x_DDR_BOOTUNLOCK),
+		&dv_ddr2_regs_ctrl->sdbcr);
+	writel((CONFIG_SYS_DM36x_DDR2_SDBCR | DM36x_DDR_TIMUNLOCK),
+		&dv_ddr2_regs_ctrl->sdbcr);
+
+	/* Program SDRAM Timing Control Register1 */
+	writel(CONFIG_SYS_DM36x_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr);
+	/* Program SDRAM Timing Control Register2 */
+	writel(CONFIG_SYS_DM36x_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2);
+
+	writel(CONFIG_SYS_DM36x_DDR2_PBBPR, &dv_ddr2_regs_ctrl->pbbpr);
+
+	writel(CONFIG_SYS_DM36x_DDR2_SDBCR, &dv_ddr2_regs_ctrl->sdbcr);
+
+	/* Program SDRAM Refresh Control Register */
+	writel(CONFIG_SYS_DM36x_DDR2_SDRCR, &dv_ddr2_regs_ctrl->sdrcr);
+
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_SYNCRESET);
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+
+	return 0;
+}
+
+void dm365_vpss_sync_reset(void)
+{
+	unsigned int PdNum = 0;
+
+	/* VPSS_CLKMD 1:1 */
+	setbits_le32(&dv_sys_module_regs->vpss_clkctl,
+		VPSS_CLK_CTL_VPSS_CLKMD);
+
+	/* LPSC SyncReset DDR Clock Enable */
+	writel(((readl(&dv_psc_regs->mdctl[47]) & ~PSC_MD_STATE_MSK) |
+		PSC_SYNCRESET), &dv_psc_regs->mdctl[47]);
+
+	writel((1 << PdNum), &dv_psc_regs->ptcmd);
+
+	while (!(((readl(&dv_psc_regs->ptstat) >> PdNum) & PSC_GOSTAT) == 0))
+		;
+	while (!((readl(&dv_psc_regs->mdstat[47]) &  PSC_MD_STATE_MSK) ==
+		PSC_SYNCRESET))
+		;
+}
+
+void dm365_por_reset(void)
+{
+	if (readl(&dv_pll0_regs->rstype) & 3)
+		dm365_vpss_sync_reset();
+}
+
+void dm365_psc_init(void)
+{
+	unsigned char i = 0;
+	unsigned char lpsc_start;
+	unsigned char lpsc_end, lpscgroup, lpscmin, lpscmax;
+	unsigned int  PdNum = 0;
+
+	lpscmin = 0;
+	lpscmax = 2;
+
+	for (lpscgroup = lpscmin; lpscgroup <= lpscmax; lpscgroup++) {
+		if (lpscgroup == 0) {
+			lpsc_start = 0; /* Enabling LPSC 3 to 28 SCR first */
+			lpsc_end   = 28;
+		} else if (lpscgroup == 1) { /* Skip locked LPSCs [29-37] */
+			lpsc_start = 38;
+			lpsc_end   = 47;
+		} else {
+			lpsc_start = 50;
+			lpsc_end   = 51;
+		}
+
+		/* NEXT=0x3, Enable LPSC's */
+		for (i = lpsc_start; i <= lpsc_end; i++)
+			setbits_le32(&dv_psc_regs->mdctl[i], 0x3);
+
+		/*
+		 * Program goctl to start transition sequence for LPSCs
+		 * CSL_PSC_0_REGS->PTCMD = (1<<PdNum); Kick off Power
+		 * Domain 0 Modules
+		 */
+		writel((1 << PdNum), &dv_psc_regs->ptcmd);
+
+		/*
+		 * Wait for GOSTAT = NO TRANSITION from PSC for Powerdomain 0
+		 */
+		while (!(((readl(&dv_psc_regs->ptstat) >> PdNum) & PSC_GOSTAT)
+			== 0))
+			;
+
+		/* Wait for MODSTAT = ENABLE from LPSC's */
+		for (i = lpsc_start; i <= lpsc_end; i++)
+			while (!((readl(&dv_psc_regs->mdstat[i]) &
+				PSC_MD_STATE_MSK) == 0x3))
+				;
+	}
+}
+
+static void dm365_emif_init(void)
+{
+	writel(CONFIG_SYS_DM36x_AWCCR, &davinci_emif_regs->awccr);
+	writel(CONFIG_SYS_DM36x_AB1CR, &davinci_emif_regs->ab1cr);
+
+	setbits_le32(&davinci_emif_regs->nandfcr, 1);
+
+	writel(CONFIG_SYS_DM36x_AB1CR, &davinci_emif_regs->ab2cr);
+
+	return;
+}
+
+void dm365_pinmux_ctl(unsigned long offset, unsigned long mask,
+	unsigned long value)
+{
+	clrbits_le32(&dv_sys_module_regs->pinmux[offset], mask);
+	setbits_le32(&dv_sys_module_regs->pinmux[offset], (mask & value));
+}
+
+__attribute__((weak))
+void board_gpio_init(void)
+{
+	return;
+}
+
+void board_init_f(ulong bootflag)
+{
+	/*
+	 * copied from arch/arm/cpu/arm926ejs/start.S
+	 *
+	 * flush v4 I/D caches
+	 */
+	asm("mov	r0, #0");
+	asm("mcr	p15, 0, r0, c7, c7, 0");	/* flush v3/v4 cache */
+	asm("mcr	p15, 0, r0, c8, c7, 0");	/* flush v4 TLB */
+
+	/*
+	 * disable MMU stuff and caches
+	 */
+	asm("mrc	p15, 0, r0, c1, c0, 0");
+	/* clear bits 13, 9:8 (--V- --RS) */
+	asm("bic	r0, r0, #0x00002300");
+	/* clear bits 7, 2:0 (B--- -CAM) */
+	asm("bic	r0, r0, #0x00000087");
+	/* set bit 2 (A) Align */
+	asm("orr	r0, r0, #0x00000002");
+	/* set bit 12 (I) I-Cache */
+	asm("orr	r0, r0, #0x00001000");
+	asm("mcr	p15, 0, r0, c1, c0, 0");
+
+	/* Mask all interrupts */
+	writel(0x04, &dv_aintc_regs->intctl);
+	writel(0x0, &dv_aintc_regs->eabase);
+	writel(0x0, &dv_aintc_regs->eint0);
+	writel(0x0, &dv_aintc_regs->eint1);
+
+	/* Clear all interrupts */
+	writel(0xffffffff, &dv_aintc_regs->fiq0);
+	writel(0xffffffff, &dv_aintc_regs->fiq1);
+	writel(0xffffffff, &dv_aintc_regs->irq0);
+	writel(0xffffffff, &dv_aintc_regs->irq1);
+
+	/* System PSC setup - enable all */
+	dm365_psc_init();
+
+	/* Setup Pinmux */
+	dm365_pinmux_ctl(0, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX0);
+	dm365_pinmux_ctl(1, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX1);
+	dm365_pinmux_ctl(2, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX2);
+	dm365_pinmux_ctl(3, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX3);
+	dm365_pinmux_ctl(4, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX4);
+
+	/* PLL setup */
+	dm365_pll1_init(CONFIG_SYS_DM36x_PLL1_PLLM,
+		CONFIG_SYS_DM36x_PLL1_PREDIV);
+	dm365_pll2_init(CONFIG_SYS_DM36x_PLL2_PLLM,
+		CONFIG_SYS_DM36x_PLL2_PREDIV);
+
+	/* GPIO setup */
+	board_gpio_init();
+
+	NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1),
+			CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
+
+	/*
+	 * Fix Power and Emulation Management Register
+	 * see sprufh2.pdf page 38 Table 22
+	 */
+	writel(0x0000e003, (CONFIG_SYS_NS16550_COM1 + 0x30));
+	puts("ddr init\n");
+	dm365_ddr_setup();
+
+	puts("emif init\n");
+	dm365_emif_init();
+
+	puts("Nand boot...\n");
+
+#if defined(CONFIG_POST)
+	/*
+	 * Do memory tests, calls arch_memory_failure_handle()
+	 * if error detected.
+	 */
+	memory_post_test(0);
+#endif
+
+	nand_boot();
+}
arch/arm/include/asm/arch-davinci/dm365_lowlevel.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
1.7.6
#16 lore raw

PATCH 6/9 arm926ejs, davinci: add cpuinfo for dm365

In reply to Heiko Schocher
---
 arch/arm/cpu/arm926ejs/davinci/cpu.c         |   34 ++++++++++++++++++++++---
 arch/arm/include/asm/arch-davinci/pll_defs.h |    4 +++
 2 files changed, 34 insertions(+), 4 deletions(-)
arch/arm/cpu/arm926ejs/davinci/cpu.c +30 -4
index 8b57205..97275ce 100644
@@ -114,9 +114,11 @@ out:
 static unsigned pll_div(volatile void *pllbase, unsigned offset)
 {
 	u32	div;
+	unsigned ret;
 
-	div = REG(pllbase + offset);
-	return (div & BIT(15)) ? (1 + (div & 0x1f)) : 1;
+	div = (readl(pllbase + offset));
+	ret = (div & BIT(15)) ? (1 + (div & 0x1f)) : 1;
+	return ret;
 }
 
 static inline unsigned pll_prediv(volatile void *pllbase)
@@ -127,13 +129,15 @@ static inline unsigned pll_prediv(volatile void *pllbase)
 		return 8;
 	else
 		return pll_div(pllbase, PLLC_PREDIV);
+#elif defined(CONFIG_SOC_DM365)
+	return pll_div(pllbase, PLLC_PREDIV);
 #endif
 	return 1;
 }
 
 static inline unsigned pll_postdiv(volatile void *pllbase)
 {
-#ifdef CONFIG_SOC_DM355
+#if defined(CONFIG_SOC_DM355) || defined(CONFIG_SOC_DM365)
 	return pll_div(pllbase, PLLC_POSTDIV);
 #elif defined(CONFIG_SOC_DM6446)
 	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
@@ -152,9 +156,13 @@ static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
 #endif
 
 	/* the PLL might be bypassed */
-	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
+	if (readl(pllbase + PLLC_PLLCTL) & BIT(0)) {
 		base /= pll_prediv(pllbase);
+#if defined(CONFIG_SOC_DM365)
+		base *=  2 * (readl(pllbase + PLLC_PLLM) & 0x0ff);
+#else
 		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
+#endif
 		base /= pll_postdiv(pllbase);
 	}
 	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
@@ -165,8 +173,13 @@ int print_cpuinfo(void)
 	/* REVISIT fetch and display CPU ID and revision information
 	 * too ... that will matter as more revisions appear.
 	 */
+#if defined(CONFIG_SOC_DM365)
+	printf("Cores: ARM %d MHz",
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, ARM_PLLDIV));
+#else
 	printf("Cores: ARM %d MHz",
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+#endif
 
 #ifdef DSP_PLLDIV
 	printf(", DSP %d MHz",
@@ -175,8 +188,13 @@ int print_cpuinfo(void)
 
 	printf("\nDDR:   %d MHz\n",
 			/* DDR PHY uses an x2 input clock */
+#if defined(CONFIG_SOC_DM365)
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DDR_PLLDIV)
+				/ 2);
+#else
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
 				/ 2);
+#endif
 	return 0;
 }
 
@@ -186,6 +204,14 @@ unsigned int davinci_arm_clk_get()
 	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV) * 1000000;
 }
 #endif
+
+#if defined(CONFIG_SOC_DM365)
+unsigned int davinci_clk_get(unsigned int div)
+{
+	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, div) * 1000000;
+}
+#endif
+
 #endif
 
 /*
arch/arm/include/asm/arch-davinci/pll_defs.h +4 -0
index 5d37616..606ed0b 100644
@@ -76,4 +76,8 @@ struct dv_pll_regs {
 #define dv_pll0_regs ((struct dv_pll_regs *)DAVINCI_PLL_CNTRL0_BASE)
 #define dv_pll1_regs ((struct dv_pll_regs *)DAVINCI_PLL_CNTRL1_BASE)
 
+#define ARM_PLLDIV	(offsetof(struct dv_pll_regs, plldiv2))
+#define DDR_PLLDIV	(offsetof(struct dv_pll_regs, plldiv7))
+
+unsigned int davinci_clk_get(unsigned int div);
 #endif /* _DV_PLL_DEFS_H_ */
Signature · 1 line
1.7.6
#17 lore raw

PATCH v2 7/10 arm, davinci: add lowlevel function for dm365 soc

used for booting (for example) from NAND using spl code.

Cc Albert ARIBAUD <[email protected]>
Cc Sandeep Paulraj <[email protected]>

---
changes for v2:
- fix bug for dm365 if setup A2CR register
- rebase to TOT:
- rename DM36x_DDR_* to DV_DDR_*
- add support for new SPL framework

 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c    |  466 ++++++++++++++++++++
 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h |   43 ++
 2 files changed, 509 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c
 create mode 100644 arch/arm/include/asm/arch-davinci/dm365_lowlevel.h
arch/arm/cpu/arm926ejs/davinci/dm365_lowlevel.c new file +466 -0
new file mode 100644
index 0000000..d7c6a3e
@@ -0,0 +1,466 @@
+/*
+ * SoC-specific lowlevel code for tms320dm365 and similar chips
+ * Actually used for booting from NAND with nand_spl.
+ *
+ * Copyright (C) 2011
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <common.h>
+#include <nand.h>
+#include <ns16550.h>
+#include <post.h>
+#include <asm/arch/dm365_lowlevel.h>
+#include <asm/arch/hardware.h>
+
+void dm365_waitloop(unsigned long loopcnt)
+{
+	unsigned long	i;
+
+	for (i = 0; i < loopcnt; i++)
+		asm("   NOP");
+}
+
+int dm365_pll1_init(unsigned long pllmult, unsigned long prediv)
+{
+	unsigned int clksrc = 0x0;
+
+	/* Power up the PLL */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLPWRDN);
+
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_RES_9);
+	setbits_le32(&dv_pll0_regs->pllctl, clksrc << 8);
+
+	/*
+	 * Set PLLENSRC '0', PLL Enable(PLLEN) selection is controlled
+	 * through MMR
+	 */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLENSRC);
+
+	/* Set PLLEN=0 => PLL BYPASS MODE */
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLEN);
+
+	dm365_waitloop(150);
+
+	 /* PLLRST=1(reset assert) */
+	setbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLRST);
+
+	dm365_waitloop(300);
+
+	/*Bring PLL out of Reset*/
+	clrbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLRST);
+
+	/* Program the Multiper and Pre-Divider for PLL1 */
+	writel(pllmult, &dv_pll0_regs->pllm);
+	writel(prediv, &dv_pll0_regs->prediv);
+
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE |
+		PLLSECCTL_TINITZ, &dv_pll0_regs->secctl);
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE,
+		&dv_pll0_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE, &dv_pll0_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TINITZ, &dv_pll0_regs->secctl);
+
+	/* Program the PostDiv for PLL1 */
+	writel(0x8000, &dv_pll0_regs->postdiv);
+
+	/* Post divider setting for PLL1 */
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV1, &dv_pll0_regs->plldiv1);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV2, &dv_pll0_regs->plldiv2);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV3, &dv_pll0_regs->plldiv3);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV4, &dv_pll0_regs->plldiv4);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV5, &dv_pll0_regs->plldiv5);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV6, &dv_pll0_regs->plldiv6);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV7, &dv_pll0_regs->plldiv7);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV8, &dv_pll0_regs->plldiv8);
+	writel(CONFIG_SYS_DM36x_PLL1_PLLDIV9, &dv_pll0_regs->plldiv9);
+
+	dm365_waitloop(300);
+
+	/* Set the GOSET bit */
+	writel(PLLCMD_GOSET, &dv_pll0_regs->pllcmd); /* Go */
+
+	dm365_waitloop(300);
+
+	/* Wait for PLL to LOCK */
+	while (!((readl(&dv_sys_module_regs->pll0_config) & PLL0_LOCK)
+		== PLL0_LOCK))
+		;
+
+	/* Enable the PLL Bit of PLLCTL*/
+	setbits_le32(&dv_pll0_regs->pllctl, PLLCTL_PLLEN);
+
+	return 0;
+}
+
+int dm365_pll2_init(unsigned long pllm, unsigned long prediv)
+{
+	unsigned int clksrc = 0x0;
+
+	/* Power up the PLL*/
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLPWRDN);
+
+	/*
+	 * Select the Clock Mode as Onchip Oscilator or External Clock on
+	 * MXI pin
+	 * VDB has input on MXI pin
+	 */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_RES_9);
+	setbits_le32(&dv_pll1_regs->pllctl, clksrc << 8);
+
+	/*
+	 * Set PLLENSRC '0', PLL Enable(PLLEN) selection is controlled
+	 * through MMR
+	 */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLENSRC);
+
+	/* Set PLLEN=0 => PLL BYPASS MODE */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLEN);
+
+	dm365_waitloop(50);
+
+	 /* PLLRST=1(reset assert) */
+	setbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLRST);
+
+	dm365_waitloop(300);
+
+	/* Bring PLL out of Reset */
+	clrbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLRST);
+
+	/* Program the Multiper and Pre-Divider for PLL2 */
+	writel(pllm, &dv_pll1_regs->pllm);
+	writel(prediv, &dv_pll1_regs->prediv);
+
+	writel(0x8000, &dv_pll1_regs->postdiv);
+
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE |
+		PLLSECCTL_TINITZ, &dv_pll1_regs->secctl);
+	/* Assert TENABLE = 1, TENABLEDIV = 1, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TENABLEDIV | PLLSECCTL_TENABLE,
+		&dv_pll1_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 0 */
+	writel(PLLSECCTL_STOPMODE, &dv_pll1_regs->secctl);
+	/* Assert TENABLE = 0, TENABLEDIV = 0, TINITZ = 1 */
+	writel(PLLSECCTL_STOPMODE | PLLSECCTL_TINITZ, &dv_pll1_regs->secctl);
+
+	/* Post divider setting for PLL2 */
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV1, &dv_pll1_regs->plldiv1);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV2, &dv_pll1_regs->plldiv2);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV3, &dv_pll1_regs->plldiv3);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV4, &dv_pll1_regs->plldiv4);
+	writel(CONFIG_SYS_DM36x_PLL2_PLLDIV5, &dv_pll1_regs->plldiv5);
+
+	/* GoCmd for PostDivider to take effect */
+	writel(PLLCMD_GOSET, &dv_pll1_regs->pllcmd);
+
+	dm365_waitloop(150);
+
+	/* Wait for PLL to LOCK */
+	while (!((readl(&dv_sys_module_regs->pll1_config) & PLL1_LOCK)
+		== PLL1_LOCK))
+		;
+
+	dm365_waitloop(4100);
+
+	/* Enable the PLL2 */
+	setbits_le32(&dv_pll1_regs->pllctl, PLLCTL_PLLEN);
+
+	/* do this after PLL's have been set up */
+	writel(CONFIG_SYS_DM36x_PERI_CLK_CTRL,
+		&dv_sys_module_regs->peri_clkctl);
+
+	return 0;
+}
+
+void dm365_lpc_transition(unsigned char module, unsigned char domain,
+				unsigned char state)
+{
+	/* Wait for any outstanding transition to complete */
+	while ((readl(&dv_psc_regs->ptstat)) & (PSC_GOSTAT << domain))
+		;
+
+	/* If we are already in that state, just return */
+	if (((readl(&dv_psc_regs->mdstat[module])) & PSC_MD_STATE_MSK)
+		== state)
+		return;
+
+	/* Perform transition */
+	writel(((readl(&dv_psc_regs->mdctl[module])) & (~PSC_MD_STATE_MSK)) |
+		state, &dv_psc_regs->mdctl[module]);
+	setbits_le32(&dv_psc_regs->ptcmd, (PSC_CMD_GO << domain));
+
+	/* Wait for transition to complete */
+	while ((readl(&dv_psc_regs->ptstat)) & (PSC_GOSTAT << domain))
+		;
+
+	/* Wait and verify the state */
+	while (((readl(&dv_psc_regs->mdstat[module])) & PSC_MD_STATE_MSK)
+		!= state)
+		;
+}
+
+int dm365_ddr_setup(void)
+{
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+	clrbits_le32(&dv_sys_module_regs->vtpiocr,
+		VPTIO_IOPWRDN | VPTIO_CLRZ | VPTIO_LOCK | VPTIO_PWRDN);
+
+	/* Set bit CLRZ (bit 13) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_CLRZ);
+
+	/* Check VTP READY Status */
+	while (!(readl(&dv_sys_module_regs->vtpiocr) & VPTIO_RDY))
+		;
+
+	/* Set bit VTP_IOPWRDWN bit 14 for DDR input buffers) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_IOPWRDN);
+
+	/* Set bit LOCK(bit7) */
+	setbits_le32(&dv_sys_module_regs->vtpiocr, VPTIO_LOCK);
+
+	/*
+	 * Powerdown VTP as it is locked (bit 6)
+	 * Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
+	 */
+	setbits_le32(&dv_sys_module_regs->vtpiocr,
+		VPTIO_IOPWRDN | VPTIO_PWRDN);
+
+	/* Wait for calibration to complete */
+	dm365_waitloop(150);
+
+	/* Set the DDR2 to synreset, then enable it again */
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_SYNCRESET);
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+
+	writel(CONFIG_SYS_DM36x_DDR2_DDRPHYCR, &dv_ddr2_regs_ctrl->ddrphycr);
+
+	/* Program SDRAM Bank Config Register */
+	writel((CONFIG_SYS_DM36x_DDR2_SDBCR | DV_DDR_BOOTUNLOCK),
+		&dv_ddr2_regs_ctrl->sdbcr);
+	writel((CONFIG_SYS_DM36x_DDR2_SDBCR | DV_DDR_TIMUNLOCK),
+		&dv_ddr2_regs_ctrl->sdbcr);
+
+	/* Program SDRAM Timing Control Register1 */
+	writel(CONFIG_SYS_DM36x_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr);
+	/* Program SDRAM Timing Control Register2 */
+	writel(CONFIG_SYS_DM36x_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2);
+
+	writel(CONFIG_SYS_DM36x_DDR2_PBBPR, &dv_ddr2_regs_ctrl->pbbpr);
+
+	writel(CONFIG_SYS_DM36x_DDR2_SDBCR, &dv_ddr2_regs_ctrl->sdbcr);
+
+	/* Program SDRAM Refresh Control Register */
+	writel(CONFIG_SYS_DM36x_DDR2_SDRCR, &dv_ddr2_regs_ctrl->sdrcr);
+
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_SYNCRESET);
+	dm365_lpc_transition(LPSC_DDR2, 0, PSC_ENABLE);
+
+	return 0;
+}
+
+void dm365_vpss_sync_reset(void)
+{
+	unsigned int PdNum = 0;
+
+	/* VPSS_CLKMD 1:1 */
+	setbits_le32(&dv_sys_module_regs->vpss_clkctl,
+		VPSS_CLK_CTL_VPSS_CLKMD);
+
+	/* LPSC SyncReset DDR Clock Enable */
+	writel(((readl(&dv_psc_regs->mdctl[47]) & ~PSC_MD_STATE_MSK) |
+		PSC_SYNCRESET), &dv_psc_regs->mdctl[47]);
+
+	writel((1 << PdNum), &dv_psc_regs->ptcmd);
+
+	while (!(((readl(&dv_psc_regs->ptstat) >> PdNum) & PSC_GOSTAT) == 0))
+		;
+	while (!((readl(&dv_psc_regs->mdstat[47]) &  PSC_MD_STATE_MSK) ==
+		PSC_SYNCRESET))
+		;
+}
+
+void dm365_por_reset(void)
+{
+	if (readl(&dv_pll0_regs->rstype) & 3)
+		dm365_vpss_sync_reset();
+}
+
+void dm365_psc_init(void)
+{
+	unsigned char i = 0;
+	unsigned char lpsc_start;
+	unsigned char lpsc_end, lpscgroup, lpscmin, lpscmax;
+	unsigned int  PdNum = 0;
+
+	lpscmin = 0;
+	lpscmax = 2;
+
+	for (lpscgroup = lpscmin; lpscgroup <= lpscmax; lpscgroup++) {
+		if (lpscgroup == 0) {
+			lpsc_start = 0; /* Enabling LPSC 3 to 28 SCR first */
+			lpsc_end   = 28;
+		} else if (lpscgroup == 1) { /* Skip locked LPSCs [29-37] */
+			lpsc_start = 38;
+			lpsc_end   = 47;
+		} else {
+			lpsc_start = 50;
+			lpsc_end   = 51;
+		}
+
+		/* NEXT=0x3, Enable LPSC's */
+		for (i = lpsc_start; i <= lpsc_end; i++)
+			setbits_le32(&dv_psc_regs->mdctl[i], 0x3);
+
+		/*
+		 * Program goctl to start transition sequence for LPSCs
+		 * CSL_PSC_0_REGS->PTCMD = (1<<PdNum); Kick off Power
+		 * Domain 0 Modules
+		 */
+		writel((1 << PdNum), &dv_psc_regs->ptcmd);
+
+		/*
+		 * Wait for GOSTAT = NO TRANSITION from PSC for Powerdomain 0
+		 */
+		while (!(((readl(&dv_psc_regs->ptstat) >> PdNum) & PSC_GOSTAT)
+			== 0))
+			;
+
+		/* Wait for MODSTAT = ENABLE from LPSC's */
+		for (i = lpsc_start; i <= lpsc_end; i++)
+			while (!((readl(&dv_psc_regs->mdstat[i]) &
+				PSC_MD_STATE_MSK) == 0x3))
+				;
+	}
+}
+
+static void dm365_emif_init(void)
+{
+	writel(CONFIG_SYS_DM36x_AWCCR, &davinci_emif_regs->awccr);
+	writel(CONFIG_SYS_DM36x_AB1CR, &davinci_emif_regs->ab1cr);
+
+	setbits_le32(&davinci_emif_regs->nandfcr, 1);
+
+	writel(CONFIG_SYS_DM36x_AB2CR, &davinci_emif_regs->ab2cr);
+
+	return;
+}
+
+void dm365_pinmux_ctl(unsigned long offset, unsigned long mask,
+	unsigned long value)
+{
+	clrbits_le32(&dv_sys_module_regs->pinmux[offset], mask);
+	setbits_le32(&dv_sys_module_regs->pinmux[offset], (mask & value));
+}
+
+__attribute__((weak))
+void board_gpio_init(void)
+{
+	return;
+}
+
+#if defined(CONFIG_POST)
+int post_log(char *format, ...)
+{
+	return 0;
+}
+#endif
+
+void dm36x_lowlevel_init(ulong bootflag)
+{
+	/*
+	 * copied from arch/arm/cpu/arm926ejs/start.S
+	 *
+	 * flush v4 I/D caches
+	 */
+	asm("mov	r0, #0");
+	asm("mcr	p15, 0, r0, c7, c7, 0");	/* flush v3/v4 cache */
+	asm("mcr	p15, 0, r0, c8, c7, 0");	/* flush v4 TLB */
+
+	/*
+	 * disable MMU stuff and caches
+	 */
+	asm("mrc	p15, 0, r0, c1, c0, 0");
+	/* clear bits 13, 9:8 (--V- --RS) */
+	asm("bic	r0, r0, #0x00002300");
+	/* clear bits 7, 2:0 (B--- -CAM) */
+	asm("bic	r0, r0, #0x00000087");
+	/* set bit 2 (A) Align */
+	asm("orr	r0, r0, #0x00000002");
+	/* set bit 12 (I) I-Cache */
+	asm("orr	r0, r0, #0x00001000");
+	asm("mcr	p15, 0, r0, c1, c0, 0");
+
+	/* Mask all interrupts */
+	writel(0x04, &dv_aintc_regs->intctl);
+	writel(0x0, &dv_aintc_regs->eabase);
+	writel(0x0, &dv_aintc_regs->eint0);
+	writel(0x0, &dv_aintc_regs->eint1);
+
+	/* Clear all interrupts */
+	writel(0xffffffff, &dv_aintc_regs->fiq0);
+	writel(0xffffffff, &dv_aintc_regs->fiq1);
+	writel(0xffffffff, &dv_aintc_regs->irq0);
+	writel(0xffffffff, &dv_aintc_regs->irq1);
+
+	/* System PSC setup - enable all */
+	dm365_psc_init();
+
+	/* Setup Pinmux */
+	dm365_pinmux_ctl(0, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX0);
+	dm365_pinmux_ctl(1, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX1);
+	dm365_pinmux_ctl(2, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX2);
+	dm365_pinmux_ctl(3, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX3);
+	dm365_pinmux_ctl(4, 0xFFFFFFFF, CONFIG_SYS_DM36x_PINMUX4);
+
+	/* PLL setup */
+	dm365_pll1_init(CONFIG_SYS_DM36x_PLL1_PLLM,
+		CONFIG_SYS_DM36x_PLL1_PREDIV);
+	dm365_pll2_init(CONFIG_SYS_DM36x_PLL2_PLLM,
+		CONFIG_SYS_DM36x_PLL2_PREDIV);
+
+	/* GPIO setup */
+	board_gpio_init();
+
+	NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1),
+			CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
+
+	/*
+	 * Fix Power and Emulation Management Register
+	 * see sprufh2.pdf page 38 Table 22
+	 */
+	writel(0x0000e003, (CONFIG_SYS_NS16550_COM1 + 0x30));
+	puts("ddr init\n");
+	dm365_ddr_setup();
+
+	puts("emif init\n");
+	dm365_emif_init();
+
+#if defined(CONFIG_POST)
+	/*
+	 * Do memory tests, calls arch_memory_failure_handle()
+	 * if error detected.
+	 */
+	memory_post_test(0);
+#endif
+}
arch/arm/include/asm/arch-davinci/dm365_lowlevel.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.7.6.2
#18 lore raw

PATCH v2 8/10 arm926ejs, davinci: add cpuinfo for dm365

In reply to Heiko Schocher
Cc Albert ARIBAUD <[email protected]>
Cc Sandeep Paulraj <[email protected]>

---
Changes for v2:
- rebase to TOT

 arch/arm/cpu/arm926ejs/davinci/cpu.c         |   27 ++++++++++++++++++++++++-
 arch/arm/include/asm/arch-davinci/pll_defs.h |    4 +++
 2 files changed, 29 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/davinci/cpu.c +25 -2
index 02819f6..9ea9785 100644
@@ -146,13 +146,15 @@ static inline unsigned pll_prediv(volatile void *pllbase)
 		return 8;
 	else
 		return pll_div(pllbase, PLLC_PREDIV);
+#elif defined(CONFIG_SOC_DM365)
+	return pll_div(pllbase, PLLC_PREDIV);
 #endif
 	return 1;
 }
 
 static inline unsigned pll_postdiv(volatile void *pllbase)
 {
-#ifdef CONFIG_SOC_DM355
+#if defined(CONFIG_SOC_DM355) || defined(CONFIG_SOC_DM365)
 	return pll_div(pllbase, PLLC_POSTDIV);
 #elif defined(CONFIG_SOC_DM6446)
 	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
@@ -171,9 +173,13 @@ static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
 #endif
 
 	/* the PLL might be bypassed */
-	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
+	if (readl(pllbase + PLLC_PLLCTL) & BIT(0)) {
 		base /= pll_prediv(pllbase);
+#if defined(CONFIG_SOC_DM365)
+		base *=  2 * (readl(pllbase + PLLC_PLLM) & 0x0ff);
+#else
 		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
+#endif
 		base /= pll_postdiv(pllbase);
 	}
 	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
@@ -184,8 +190,13 @@ int print_cpuinfo(void)
 	/* REVISIT fetch and display CPU ID and revision information
 	 * too ... that will matter as more revisions appear.
 	 */
+#if defined(CONFIG_SOC_DM365)
+	printf("Cores: ARM %d MHz",
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, ARM_PLLDIV));
+#else
 	printf("Cores: ARM %d MHz",
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+#endif
 
 #ifdef DSP_PLLDIV
 	printf(", DSP %d MHz",
@@ -194,8 +205,13 @@ int print_cpuinfo(void)
 
 	printf("\nDDR:   %d MHz\n",
 			/* DDR PHY uses an x2 input clock */
+#if defined(CONFIG_SOC_DM365)
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DDR_PLLDIV)
+				/ 2);
+#else
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
 				/ 2);
+#endif
 	return 0;
 }
 
@@ -205,6 +221,13 @@ unsigned int davinci_arm_clk_get()
 	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV) * 1000000;
 }
 #endif
+
+#if defined(CONFIG_SOC_DM365)
+unsigned int davinci_clk_get(unsigned int div)
+{
+	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, div) * 1000000;
+}
+#endif
 #endif /* CONFIG_DISPLAY_CPUINFO */
 #endif /* !CONFIG_SOC_DA8XX */
 
arch/arm/include/asm/arch-davinci/pll_defs.h +4 -0
index 5d37616..606ed0b 100644
@@ -76,4 +76,8 @@ struct dv_pll_regs {
 #define dv_pll0_regs ((struct dv_pll_regs *)DAVINCI_PLL_CNTRL0_BASE)
 #define dv_pll1_regs ((struct dv_pll_regs *)DAVINCI_PLL_CNTRL1_BASE)
 
+#define ARM_PLLDIV	(offsetof(struct dv_pll_regs, plldiv2))
+#define DDR_PLLDIV	(offsetof(struct dv_pll_regs, plldiv7))
+
+unsigned int davinci_clk_get(unsigned int div);
 #endif /* _DV_PLL_DEFS_H_ */
Signature · 1 line
1.7.6.2
#19 lore raw

PATCH 7/9 arm926ejs, davinci: add missing spi defines for dm365

In reply to Heiko Schocher
---
 arch/arm/include/asm/arch-davinci/hardware.h |    2 ++
 arch/arm/include/asm/arch-davinci/pll_defs.h |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-davinci/hardware.h +2 -0
index f2c1060..11f16ff 100644
@@ -109,6 +109,8 @@ typedef volatile unsigned int *	dv_reg_p;
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x01d10000
 #define DAVINCI_MMC_SD0_BASE			0x01d11000
 #define DAVINCI_DDR_EMIF_CTRL_BASE		0x20000000
+#define DAVINCI_SPI0_BASE			0x01c66000
+#define DAVINCI_SPI1_BASE			0x01c66800
 
 #elif defined(CONFIG_SOC_DM646X)
 #define DAVINCI_ASYNC_EMIF_CNTRL_BASE		0x20008000
arch/arm/include/asm/arch-davinci/pll_defs.h +1 -0
index 606ed0b..5c30953 100644
@@ -78,6 +78,7 @@ struct dv_pll_regs {
 
 #define ARM_PLLDIV	(offsetof(struct dv_pll_regs, plldiv2))
 #define DDR_PLLDIV	(offsetof(struct dv_pll_regs, plldiv7))
+#define SPI_PLLDIV	(offsetof(struct dv_pll_regs, plldiv4))
 
 unsigned int davinci_clk_get(unsigned int div);
 #endif /* _DV_PLL_DEFS_H_ */
Signature · 1 line
1.7.6
#20 lore raw

PATCH 8/9 spl, nand: add 4bit HW ecc oob first nand_read_page function

In reply to Heiko Schocher
---
 nand_spl/nand_boot.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
nand_spl/nand_boot.c +42 -0
index 4683c7c..615ef25 100644
@@ -135,6 +135,47 @@ static int nand_is_bad_block(struct mtd_info *mtd, int block)
 	return 0;
 }
 
+#if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST)
+static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
+{
+	struct nand_chip *this = mtd->priv;
+	u_char *ecc_calc;
+	u_char *ecc_code;
+	u_char *oob_data;
+	int i;
+	int eccsize = CONFIG_SYS_NAND_ECCSIZE;
+	int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
+	int eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+	uint8_t *p = dst;
+	int stat;
+
+	/*
+	 * No malloc available for now, just use some temporary locations
+	 * in SDRAM
+	 */
+	ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
+	ecc_code = ecc_calc + 0x100;
+	oob_data = ecc_calc + 0x200;
+
+	nand_command(mtd, block, page, 0, NAND_CMD_READOOB);
+	this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
+	nand_command(mtd, block, page, 0, NAND_CMD_READ0);
+
+	/* Pick the ECC bytes out of the oob data */
+	for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
+		ecc_code[i] = oob_data[nand_ecc_pos[i]];
+
+
+	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+		this->ecc.hwctl(mtd, NAND_ECC_READ);
+		this->read_buf(mtd, p, eccsize);
+		this->ecc.calculate(mtd, p, &ecc_calc[i]);
+		stat = this->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
+	}
+
+	return 0;
+}
+#else
 static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 {
 	struct nand_chip *this = mtd->priv;
@@ -181,6 +222,7 @@ static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 
 	return 0;
 }
+#endif /* #if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST) */
 
 static int nand_load(struct mtd_info *mtd, unsigned int offs,
 		     unsigned int uboot_size, uchar *dst)
Signature · 1 line
1.7.6
#21 lore raw

PATCH 8/9 spl, nand: add 4bit HW ecc oob first nand_read_page function

Quoted 6 lines · Heiko Schocher

---
nand_spl/nand_boot.c | 42 ++++++++++++++++++++++++++++++++++++++++++

 1 files changed, 42 insertions(+), 0 deletions(-)

Applied to u-boot-nand-flash next

-Scott

#22 lore raw

PATCH 9/9 arm, davinci: add cam_enc_4xx support

In reply to Heiko Schocher

- DM368 SOC
- booting with nand_spl not with UBL from TI
- before loading u-boot from NAND into RAM, test
the RAM with the post memory test. If error
is found, switch all LEDs on and halt system.
- SPI Flash
Dataflash Typ: M25PE80
- Ethernet DM9161BI

---
 MAINTAINERS                                  |    1 +
 MAKEALL                                      |    1 +
 board/ait/cam_enc_4xx/Makefile               |   52 ++++
 board/ait/cam_enc_4xx/cam_enc_4xx.c          |  331 ++++++++++++++++++++
 board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c |  115 +++++++
 board/ait/cam_enc_4xx/config.mk              |   19 ++
 board/ait/cam_enc_4xx/ublimage.cfg           |   48 +++
 boards.cfg                                   |    1 +
 doc/README.davinci.nand_spl                  |  141 +++++++++
 include/configs/cam_enc_4xx.h                |  423 ++++++++++++++++++++++++++
 nand_spl/board/ait/cam_enc_4xx/Makefile      |  152 +++++++++
 nand_spl/board/ait/cam_enc_4xx/u-boot.lds    |   75 +++++
 12 files changed, 1359 insertions(+), 0 deletions(-)
 create mode 100644 board/ait/cam_enc_4xx/Makefile
 create mode 100644 board/ait/cam_enc_4xx/cam_enc_4xx.c
 create mode 100644 board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c
 create mode 100644 board/ait/cam_enc_4xx/config.mk
 create mode 100644 board/ait/cam_enc_4xx/ublimage.cfg
 create mode 100644 doc/README.davinci.nand_spl
 create mode 100644 include/configs/cam_enc_4xx.h
 create mode 100644 nand_spl/board/ait/cam_enc_4xx/Makefile
 create mode 100644 nand_spl/board/ait/cam_enc_4xx/u-boot.lds
MAINTAINERS +1 -0
index 143f31b..3ef515d 100644
@@ -428,6 +428,7 @@ Georg Schardt <[email protected]>
 
 Heiko Schocher <[email protected]>
 
+	cam_enc_4xx	davinci/ARM926EJS
 	charon		MPC5200
 	ids8247		MPC8247
 	jupiter		MPC5200
MAKEALL +1 -0
index 4adaeb8..70c8f84 100755
@@ -328,6 +328,7 @@ LIST_ARM9="			\
 	ap946es			\
 	ap966			\
 	aspenite		\
+	cam_enc_4xx		\
 	cp920t			\
 	cp922_XA10		\
 	cp926ejs		\
board/ait/cam_enc_4xx/Makefile new file +52 -0

52 lines not on this page · raw message

board/ait/cam_enc_4xx/cam_enc_4xx.c new file +331 -0

331 lines not on this page · raw message

board/ait/cam_enc_4xx/cam_enc_4xx_nand_spl.c new file +115 -0

115 lines not on this page · raw message

board/ait/cam_enc_4xx/config.mk new file +19 -0
new file mode 100644
index 0000000..1169325
@@ -0,0 +1,19 @@
+#
+# 	AIT cam_enc_4xx board
+#	cam_enc_4xx board has 1 bank of 256 MB DDR RAM
+#	Physical Address: 8000'0000 to 9000'0000
+#
+# Linux Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+#
+
+#Provide at least 16MB spacing between us and the Linux Kernel image
+ifdef CONFIG_NAND_SPL
+#TEXT_BASE + (6 * pagesize)
+PAD_TO	:= 12320
+CONFIG_SYS_TEXT_BASE = 0x0000020
+else
+UBL_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/ublimage.cfg
+CONFIG_SYS_TEXT_BASE = 0x81080000
+ALL += $(obj)u-boot.ubl
+endif
board/ait/cam_enc_4xx/ublimage.cfg new file +48 -0

48 lines not on this page · raw message

boards.cfg +1 -0
index 4522ea7..c376091 100644
@@ -103,6 +103,7 @@ pm9261                       arm         arm926ejs   -                   ronetix
 pm9263                       arm         arm926ejs   -                   ronetix        at91
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
 da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci
+cam_enc_4xx                  arm         arm926ejs   cam_enc_4xx         ait            davinci     cam_enc_4xx:NAND_U_BOOT
 hawkboard                    arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard_nand               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:NAND_U_BOOT
 hawkboard_uart               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:UART_U_BOOT
doc/README.davinci.nand_spl new file +141 -0

141 lines not on this page · raw message

include/configs/cam_enc_4xx.h new file +423 -0

423 lines not on this page · raw message

nand_spl/board/ait/cam_enc_4xx/Makefile new file +152 -0

152 lines not on this page · raw message

nand_spl/board/ait/cam_enc_4xx/u-boot.lds new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
1.7.6
#23 lore raw

PATCH v2 10/10 arm, davinci: add cam_enc_4xx support

- DM368 SOC
- booting with spl not with UBL from TI
- before loading u-boot from NAND into RAM, test
the RAM with the post memory test. If error
is found, switch all LEDs on and halt system.
- SPI Flash
Dataflash Typ: M25PE80
- Ethernet DM9161BI
- MMC
- USB

Cc Sandeep Paulraj <[email protected]>
Cc Albert ARIBAUD <[email protected]>

---
changes for v2:
- rebase to TOT
- adapted to new spl framework
- add USB support
- MDIO Clk only 1MHz
- LED: set LED in spl code, and clear them after 1 second
- add "bdinfo" command
- add nandrbl board specific command for switching between rbl and uboot ecc calculation algorithm

 MAINTAINERS                          |    1 +
 board/ait/cam_enc_4xx/Makefile       |   52 ++++
 board/ait/cam_enc_4xx/cam_enc_4xx.c  |  455 ++++++++++++++++++++++++++++++++++
 board/ait/cam_enc_4xx/config.mk      |   13 +
 board/ait/cam_enc_4xx/u-boot-spl.lds |   73 ++++++
 board/ait/cam_enc_4xx/ublimage.cfg   |   48 ++++
 boards.cfg                           |    1 +
 doc/README.davinci.nand_spl          |  141 +++++++++++
 include/configs/cam_enc_4xx.h        |  449 +++++++++++++++++++++++++++++++++
 9 files changed, 1233 insertions(+), 0 deletions(-)
 create mode 100644 board/ait/cam_enc_4xx/Makefile
 create mode 100644 board/ait/cam_enc_4xx/cam_enc_4xx.c
 create mode 100644 board/ait/cam_enc_4xx/config.mk
 create mode 100644 board/ait/cam_enc_4xx/u-boot-spl.lds
 create mode 100644 board/ait/cam_enc_4xx/ublimage.cfg
 create mode 100644 doc/README.davinci.nand_spl
 create mode 100644 include/configs/cam_enc_4xx.h
MAINTAINERS +1 -0
index 3ab38fa..980b2db 100644
@@ -417,6 +417,7 @@ Georg Schardt <[email protected]>
 
 Heiko Schocher <[email protected]>
 
+	cam_enc_4xx	davinci/ARM926EJS
 	charon		MPC5200
 	ids8247		MPC8247
 	jupiter		MPC5200
board/ait/cam_enc_4xx/Makefile new file +52 -0

52 lines not on this page · raw message

board/ait/cam_enc_4xx/cam_enc_4xx.c new file +455 -0

455 lines not on this page · raw message

board/ait/cam_enc_4xx/config.mk new file +13 -0
new file mode 100644
index 0000000..2801e9e
@@ -0,0 +1,13 @@
+#
+# 	AIT cam_enc_4xx board
+#	cam_enc_4xx board has 1 bank of 256 MB DDR RAM
+#	Physical Address: 8000'0000 to 9000'0000
+#
+# Linux Kernel is expected to be at 8000'8000, entry 8000'8000
+# (mem base + reserved)
+#
+
+#Provide at least 16MB spacing between us and the Linux Kernel image
+PAD_TO	:= 12320
+UBL_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/ublimage.cfg
+ALL += $(obj)u-boot.ubl
board/ait/cam_enc_4xx/u-boot-spl.lds new file +73 -0

73 lines not on this page · raw message

board/ait/cam_enc_4xx/ublimage.cfg new file +48 -0

48 lines not on this page · raw message

boards.cfg +1 -0
index 3254702..31b4b2c 100644
@@ -116,6 +116,7 @@ pm9263                       arm         arm926ejs   pm9263              ronetix
 pm9g45                       arm         arm926ejs   pm9g45              ronetix        at91        pm9g45:AT91SAM9G45
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
 da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci
+cam_enc_4xx                  arm         arm926ejs   cam_enc_4xx         ait            davinci     cam_enc_4xx
 hawkboard                    arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard_nand               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:NAND_U_BOOT
 hawkboard_uart               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:UART_U_BOOT
doc/README.davinci.nand_spl new file +141 -0

141 lines not on this page · raw message

include/configs/cam_enc_4xx.h new file +449 -0

449 lines not on this page · raw message

Signature · 1 line
1.7.6.2