Skip to contentSkip to conversation

Add basic NVIDIA Tegra2 SoC support

PATCH Superseded Tom Warren 4 participants 15 messages Jan 14, 2011 – Jan 19, 2011

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Tom Warren

author
#0 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

This series of patches adds preliminary/baseline support for NVIDIA's Tegra2 SoC. Basic CPU (AVP), RAM and UART init are covered so that the system (Harmony or Seaboard) can boot to the U-Boot serial cmd prompt.

Further support (for Cortex-A9 CPU(s), USB, SD/MMC, etc.) to follow.

V2: Make changes based on feedback from Peter Tyser and Sandeep Paulraj.

Tom Warren (4):
arm: Tegra2: Add basic NVIDIA Tegra2 SoC support
serial: Add Tegra2 serial port support
arm: Tegra2: Add support for NVIDIA Harmony board
arm: Tegra2: Add support for NVIDIA Seaboard board

 MAINTAINERS                                  |    5 +
 arch/arm/cpu/armv7/tegra2/Makefile           |   48 ++++++
 arch/arm/cpu/armv7/tegra2/board.c            |   91 ++++++++++
 arch/arm/cpu/armv7/tegra2/config.mk          |   28 +++
 arch/arm/cpu/armv7/tegra2/lowlevel_init.S    |   66 +++++++
 arch/arm/cpu/armv7/tegra2/sys_info.c         |   35 ++++
 arch/arm/cpu/armv7/tegra2/timer.c            |  122 +++++++++++++
 arch/arm/include/asm/arch-tegra2/clk_rst.h   |  155 +++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pinmux.h    |   52 ++++++
 arch/arm/include/asm/arch-tegra2/pmc.h       |  125 ++++++++++++++
 arch/arm/include/asm/arch-tegra2/sys_proto.h |   33 ++++
 arch/arm/include/asm/arch-tegra2/tegra2.h    |   49 ++++++
 arch/arm/include/asm/arch-tegra2/uart.h      |   45 +++++
 board/nvidia/common/board.c                  |  234 ++++++++++++++++++++++++++
 board/nvidia/common/board.h                  |   57 +++++++
 board/nvidia/harmony/Makefile                |   50 ++++++
 board/nvidia/seaboard/Makefile               |   50 ++++++
 boards.cfg                                   |    2 +
 common/serial.c                              |    3 +-
 include/configs/harmony.h                    |   48 ++++++
 include/configs/seaboard.h                   |   43 +++++
 include/configs/tegra2-common.h              |  160 ++++++++++++++++++
 include/serial.h                             |    3 +-
 23 files changed, 1502 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/Makefile
 create mode 100644 arch/arm/cpu/armv7/tegra2/board.c
 create mode 100644 arch/arm/cpu/armv7/tegra2/config.mk
 create mode 100644 arch/arm/cpu/armv7/tegra2/lowlevel_init.S
 create mode 100644 arch/arm/cpu/armv7/tegra2/sys_info.c
 create mode 100644 arch/arm/cpu/armv7/tegra2/timer.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/clk_rst.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/pinmux.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/pmc.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/sys_proto.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/tegra2.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/uart.h
 create mode 100644 board/nvidia/common/board.c
 create mode 100644 board/nvidia/common/board.h
 create mode 100644 board/nvidia/harmony/Makefile
 create mode 100644 board/nvidia/seaboard/Makefile
 create mode 100644 include/configs/harmony.h
 create mode 100644 include/configs/seaboard.h
 create mode 100644 include/configs/tegra2-common.h
Signature · 1 line
1.7.3.5
author
#1 lore raw

PATCH v2 1/4 arm: Tegra2: Add basic NVIDIA Tegra2 SoC support

Add basic support for NVIDIA Tegra2 SoC chipset

---
 arch/arm/cpu/armv7/tegra2/Makefile           |   48 ++++++
 arch/arm/cpu/armv7/tegra2/board.c            |   91 ++++++++++
 arch/arm/cpu/armv7/tegra2/config.mk          |   28 +++
 arch/arm/cpu/armv7/tegra2/lowlevel_init.S    |   66 +++++++
 arch/arm/cpu/armv7/tegra2/sys_info.c         |   35 ++++
 arch/arm/cpu/armv7/tegra2/timer.c            |  122 +++++++++++++
 arch/arm/include/asm/arch-tegra2/clk_rst.h   |  155 +++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pinmux.h    |   52 ++++++
 arch/arm/include/asm/arch-tegra2/pmc.h       |  125 ++++++++++++++
 arch/arm/include/asm/arch-tegra2/sys_proto.h |   33 ++++
 arch/arm/include/asm/arch-tegra2/tegra2.h    |   49 ++++++
 arch/arm/include/asm/arch-tegra2/uart.h      |   45 +++++
 board/nvidia/common/board.c                  |  234 ++++++++++++++++++++++++++
 board/nvidia/common/board.h                  |   57 +++++++
 14 files changed, 1140 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/Makefile
 create mode 100644 arch/arm/cpu/armv7/tegra2/board.c
 create mode 100644 arch/arm/cpu/armv7/tegra2/config.mk
 create mode 100644 arch/arm/cpu/armv7/tegra2/lowlevel_init.S
 create mode 100644 arch/arm/cpu/armv7/tegra2/sys_info.c
 create mode 100644 arch/arm/cpu/armv7/tegra2/timer.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/clk_rst.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/pinmux.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/pmc.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/sys_proto.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/tegra2.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/uart.h
 create mode 100644 board/nvidia/common/board.c
 create mode 100644 board/nvidia/common/board.h
arch/arm/cpu/armv7/tegra2/Makefile new file +48 -0
new file mode 100644
index 0000000..75fba0b
@@ -0,0 +1,48 @@
+#
+# (C) Copyright 2010,2011 Nvidia Corporation.
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd 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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	=  $(obj)lib$(SOC).o
+
+SOBJS	:= lowlevel_init.o
+COBJS	:= sys_info.o board.o timer.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+
+all:	 $(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/armv7/tegra2/board.c new file +91 -0

91 lines not on this page · raw message

arch/arm/cpu/armv7/tegra2/config.mk new file +28 -0
new file mode 100644
index 0000000..96c0795
@@ -0,0 +1,28 @@
+#
+# (C) Copyright 2010,2011
+# NVIDIA Corporation <www.nvidia.com>
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[email protected]>
+#
+# 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
+#
+
+# Use ARMv4 for Tegra2 - initial code runs on the AVP, which is an ARM7TDI.
+PLATFORM_CPPFLAGS += -march=armv4
arch/arm/cpu/armv7/tegra2/lowlevel_init.S new file +66 -0

66 lines not on this page · raw message

arch/arm/cpu/armv7/tegra2/sys_info.c new file +35 -0
new file mode 100644
index 0000000..6d11dc1
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright 2010,2011
+ * NVIDIA Corporation <www.nvidia.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
+ */
+
+#include <common.h>
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+/* Print CPU information */
+int print_cpuinfo(void)
+{
+	puts("TEGRA2\n");
+
+	/* TBD: Add printf of major/minor rev info, stepping, etc. */
+	return 0;
+}
+#endif	/* CONFIG_DISPLAY_CPUINFO */
arch/arm/cpu/armv7/tegra2/timer.c new file +122 -0

122 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/clk_rst.h new file +155 -0

155 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/pinmux.h new file +52 -0

52 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/pmc.h new file +125 -0

125 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/sys_proto.h new file +33 -0
new file mode 100644
index 0000000..70e63a8
@@ -0,0 +1,33 @@
+/*
+ * (C) Copyright 2010,2011
+ * NVIDIA Corporation <www.nvidia.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 _SYS_PROTO_H_
+#define _SYS_PROTO_H_
+
+typedef struct {
+	char *board_string;
+} tegra2_sysinfo;
+
+void invalidate_dcache(void);
+
+#endif
arch/arm/include/asm/arch-tegra2/tegra2.h new file +49 -0

49 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/uart.h new file +45 -0

45 lines not on this page · raw message

board/nvidia/common/board.c new file +234 -0

234 lines not on this page · raw message

board/nvidia/common/board.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
1.7.3.5
author
#2 lore raw

PATCH v2 2/4 serial: Add Tegra2 serial port support

In reply to Tom Warren

Enable support for serial output on Tegra2 builds

---
 common/serial.c  |    3 ++-
 include/serial.h |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
common/serial.c +2 -1
index 051ae4e..8ebf9a5 100644
@@ -41,7 +41,8 @@ struct serial_device *__default_serial_console (void)
 #elif defined(CONFIG_4xx) \
    || defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) \
    || defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) \
-   || defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520)
+   || defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) \
+   || defined(CONFIG_TEGRA2)
 #if defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL)
 #if (CONFIG_CONS_INDEX==1)
 	return &eserial1_device;
include/serial.h +2 -1
index 15ab73c..f21d961 100644
@@ -27,7 +27,8 @@ extern struct serial_device * default_serial_console (void);
     defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) || \
     defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \
     defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \
-    defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520)
+    defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \
+    defined(CONFIG_TEGRA2)
 extern struct serial_device serial0_device;
 extern struct serial_device serial1_device;
 #if defined(CONFIG_SYS_NS16550_SERIAL)
Signature · 1 line
1.7.3.5
author
#3 lore raw

PATCH v2 3/4 arm: Tegra2: Add support for NVIDIA Harmony board

In reply to Tom Warren

Basic support for the NVIDIA Harmony board. U-Boot will load and respond to serial console commands with this patch. Further peripheral support (USB, SD/MMC, NAND, etc.) to follow.

---
 MAINTAINERS                     |    4 +
 board/nvidia/harmony/Makefile   |   50 ++++++++++++
 boards.cfg                      |    1 +
 include/configs/harmony.h       |   48 ++++++++++++
 include/configs/tegra2-common.h |  160 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 263 insertions(+), 0 deletions(-)
 create mode 100644 board/nvidia/harmony/Makefile
 create mode 100644 include/configs/harmony.h
 create mode 100644 include/configs/tegra2-common.h
MAINTAINERS +4 -0
index ba83f71..b5cff19 100644
@@ -841,6 +841,10 @@ Prafulla Wadaskar <[email protected]>
 	rd6281a		ARM926EJS (Kirkwood SoC)
 	sheevaplug	ARM926EJS (Kirkwood SoC)
 
+Tom Warren <[email protected]>
+
+	harmony		Tegra2 (ARM7 & A9 Dual Core)
+
 Matthias Weisser <[email protected]>
 
 	jadecpu		ARM926EJS (MB86R01 SoC)
board/nvidia/harmony/Makefile new file +50 -0

50 lines not on this page · raw message

boards.cfg +1 -0
index 94b8745..ee7c4b7 100644
@@ -122,6 +122,7 @@ omap4_panda                  arm         armv7       panda               ti
 omap4_sdp4430                arm         armv7       sdp4430             ti             omap4
 s5p_goni                     arm         armv7       goni                samsung        s5pc1xx
 smdkc100                     arm         armv7       smdkc100            samsung        s5pc1xx
+harmony                      arm         armv7       harmony             nvidia         tegra2
 actux1                       arm         ixp
 actux2                       arm         ixp
 actux3                       arm         ixp
include/configs/harmony.h new file +48 -0

48 lines not on this page · raw message

include/configs/tegra2-common.h new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
1.7.3.5
author
#4 lore raw

PATCH v2 4/4 arm: Tegra2: Add support for NVIDIA Seaboard board

In reply to Tom Warren

Basic support for the NVIDIA Seaboard board. U-Boot will load and respond to serial console commands with this patch. Further peripheral support (USB, SD/MMC, SPI, etc.) to follow.

---
 MAINTAINERS                    |    1 +
 board/nvidia/seaboard/Makefile |   50 ++++++++++++++++++++++++++++++++++++++++
 boards.cfg                     |    1 +
 include/configs/seaboard.h     |   43 ++++++++++++++++++++++++++++++++++
 4 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 board/nvidia/seaboard/Makefile
 create mode 100644 include/configs/seaboard.h
MAINTAINERS +1 -0
index b5cff19..f4795d3 100644
@@ -844,6 +844,7 @@ Prafulla Wadaskar <[email protected]>
 Tom Warren <[email protected]>
 
 	harmony		Tegra2 (ARM7 & A9 Dual Core)
+	seaboard	Tegra2 (ARM7 & A9 Dual Core)
 
 Matthias Weisser <[email protected]>
 
board/nvidia/seaboard/Makefile new file +50 -0

50 lines not on this page · raw message

boards.cfg +1 -0
index ee7c4b7..3c4c249 100644
@@ -123,6 +123,7 @@ omap4_sdp4430                arm         armv7       sdp4430             ti
 s5p_goni                     arm         armv7       goni                samsung        s5pc1xx
 smdkc100                     arm         armv7       smdkc100            samsung        s5pc1xx
 harmony                      arm         armv7       harmony             nvidia         tegra2
+seaboard                     arm         armv7       seaboard            nvidia         tegra2
 actux1                       arm         ixp
 actux2                       arm         ixp
 actux3                       arm         ixp
include/configs/seaboard.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#5 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

In reply to Tom Warren

Hi Tom,

Quoted 7 lines · Tom Warren

This series of patches adds preliminary/baseline support for NVIDIA's Tegra2 SoC. Basic CPU (AVP), RAM and UART init are covered so that the system (Harmony or Seaboard) can boot to the U-Boot serial cmd prompt.

Further support (for Cortex-A9 CPU(s), USB, SD/MMC, etc.) to follow.

V2: Make changes based on feedback from Peter Tyser and Sandeep Paulraj.

If you didn't use all the feedback to the original patches, you should state explicitly what you changed here, or respond to the original comment email as to why they weren't made. For example, I see you didn't make the suggested change to use IO access functions, or allow compiling out of support for UARTA and UARTD. That should be made clear somewhere (and the logic of why the changes weren't made) so that those reviewing the patches know what changed between v1 and v2 and why. As is its unclear why the v1 comments weren't implemented, so they also apply to this series.

Best,
Peter

author
#6 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Quoted 11 lines · Peter Tyser

Hi Tom,

Quoted 7 lines · Tom Warren

This series of patches adds preliminary/baseline support for NVIDIA's Tegra2 SoC. ?Basic CPU (AVP), RAM and UART init are covered so that the system (Harmony or Seaboard) can boot to the U-Boot serial cmd prompt.

Further support (for Cortex-A9 CPU(s), USB, SD/MMC, etc.) to follow.

V2: Make changes based on feedback from Peter Tyser and Sandeep Paulraj.

Quoted 10 lines

If you didn't use all the feedback to the original patches, you should state explicitly what you changed here, or respond to the original comment email as to why they weren't made. ?For example, I see you didn't make the suggested change to use IO access functions, or allow compiling out of support for UARTA and UARTD. ?That should be made clear somewhere (and the logic of why the changes weren't made) so that those reviewing the patches know what changed between v1 and v2 and why. ?As is its unclear why the v1 comments weren't implemented, so they also apply to this series.

Peter,

Sorry, since this is my first patch series to U-Boot upstream, I'm still learning the proper etiquette.
Let me respond here rather than in the patch comments since there are only 2 unchanged areas WRT comments.

1) IO access functions - I pre-reviewed my patch series with Wolfgang (to hopefully catch any blatant errors and smooth
the process) and he indicated that C structs and I/O accessor funcs or macros were preferred to my base+offset original code. Since the ARM is 32-bit, and all of our registers are I/O mapped, it made sense just to cast the necessary HW mem-mapped
regs as volatile structs and access the members directly. Works well, is easy to read & understand, etc. Let me know (with examples, if possible) how I can make it better.

2) Compiling out support for UARTA or UARTD - didn't seem necessary - size isn't an issue at this point with Tegra2 U-Boot,
and some boards (Harmony, for example) are populated w/hardware for both UARTA and UARTD, and can have both on at
U-Boot runtime (perhaps for debug out to UARTA whilst normal console I/O goes to UARTD), so I chose to leave the init code
for both intact. Plus I've never liked code with too many unnecessary ifdef's - makes it less readable, IMO.

I was going to respond to your review w/a direct, inline reply, but I thought it better to get the V2 patch out there before the weekend (we're off for MLK, as well). I'm under some pressure to get a baseline Tegra2 patchset in before the merge window
closes. I'll be sure to respond to each issue directly on the list in the future, though.

Thanks for the thorough review,

Tom

Quoted 4 lines

Best,
Peter

#7 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Quoted 22 lines · Tom Warren
Quoted 11 lines · Peter Tyser

Hi Tom,

Quoted 7 lines · Tom Warren

This series of patches adds preliminary/baseline support for NVIDIA's Tegra2 SoC. Basic CPU (AVP), RAM and UART init are covered so that the system (Harmony or Seaboard) can boot to the U-Boot serial cmd prompt.

Further support (for Cortex-A9 CPU(s), USB, SD/MMC, etc.) to follow.

V2: Make changes based on feedback from Peter Tyser and Sandeep Paulraj.

Quoted 10 lines

If you didn't use all the feedback to the original patches, you should state explicitly what you changed here, or respond to the original comment email as to why they weren't made. For example, I see you didn't make the suggested change to use IO access functions, or allow compiling out of support for UARTA and UARTD. That should be made clear somewhere (and the logic of why the changes weren't made) so that those reviewing the patches know what changed between v1 and v2 and why. As is its unclear why the v1 comments weren't implemented, so they also apply to this series.

Quoted 6 lines

Peter,

Sorry, since this is my first patch series to U-Boot upstream, I'm still learning the proper etiquette.
Let me respond here rather than in the patch comments since there are only 2 unchanged areas WRT comments.

No worries. I'm glad to see you're pushing your changes upstream.

Quoted 9 lines

1) IO access functions - I pre-reviewed my patch series with Wolfgang (to hopefully catch any blatant errors and smooth
the process) and he indicated that C structs and I/O accessor funcs or macros were preferred to my base+offset original code. Since the ARM is 32-bit, and all of our registers are I/O mapped, it made sense just to cast the necessary HW mem-mapped
regs as volatile structs and access the members directly. Works well, is easy to read & understand, etc. Let me know (with examples, if possible) how I can make it better.

Both Linux and U-Boot recommend using IO access functions instead pointer accesses, at least in PPC-land, and even for memory mapped registers. I'm not too familiar with ARM, but assume they have the same recommendation. If pointers are used, some CPUs may optimize the access order, thus causing problems. Using IO accessors also ensures that the code is portable. Even if the Tegra doesn't re-order accesses, a driver you write for use in a Tegra could be used on other CPUs that do.

eg:
http://www.mail-archive.com/u-boot at lists.denx.de/msg18435.html
http://lists.denx.de/pipermail/u-boot/2007-December/027595.html

It looks like other ARM processors use IO accessors too, eg the recent armada CPU:
arch/arm/cpu/arm926ejs/armada100/*
A grep of writel in arch/arm shows a number of references. Similarly in the Linux code in arch/arm.

ARM maintainers, feel free to chime in if you have comments.

Quoted 8 lines

2) Compiling out support for UARTA or UARTD - didn't seem necessary - size isn't an issue at this point with Tegra2 U-Boot,
and some boards (Harmony, for example) are populated w/hardware for both UARTA and UARTD, and can have both on at
U-Boot runtime (perhaps for debug out to UARTA whilst normal console I/O goes to UARTD), so I chose to leave the init code
for both intact. Plus I've never liked code with too many unnecessary ifdef's - makes it less readable, IMO.

Yeah, this is grey - I see both sides of the coin. U-Boot generally strives to be as small as possible. You may use a large flash on your eval boards and not care about space, but other system designers may place as small of flash as possible to save cost. It looked like UART_A-UART_E were also going to be supported at some time, which is quite a chunk of code. You also already are defining which serial ports are available at compile time via CONFIG_TEGRA2_ENABLE_UARTA and CONFIG_TEGRA2_ENABLE_UARTD.

Anyway, I don't really care much which way you go, just wanted to make sure you were making a conscious decision to not add the ifdefs.

Quoted 6 lines

I was going to respond to your review w/a direct, inline reply, but I thought it better to get the V2 patch out there before the weekend (we're off for MLK, as well). I'm under some pressure to get a baseline Tegra2 patchset in before the merge window
closes. I'll be sure to respond to each issue directly on the list in the future, though.

As long as you initially submit your patches during the merge window they will generally be merged, even if there are multiple revisions and discussion that lasts past the end of official merge window. So this stuff should get in.

Best,
Peter

author
#8 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Quoted 54 lines · Peter Tyser
Quoted 22 lines · Tom Warren
Quoted 11 lines · Peter Tyser

Hi Tom,

Quoted 7 lines · Tom Warren

This series of patches adds preliminary/baseline support for NVIDIA's Tegra2 SoC. ?Basic CPU (AVP), RAM and UART init are covered so that the system (Harmony or Seaboard) can boot to the U-Boot serial cmd prompt.

Further support (for Cortex-A9 CPU(s), USB, SD/MMC, etc.) to follow.

V2: Make changes based on feedback from Peter Tyser and Sandeep Paulraj.

Quoted 10 lines

If you didn't use all the feedback to the original patches, you should state explicitly what you changed here, or respond to the original comment email as to why they weren't made. ?For example, I see you didn't make the suggested change to use IO access functions, or allow compiling out of support for UARTA and UARTD. ?That should be made clear somewhere (and the logic of why the changes weren't made) so that those reviewing the patches know what changed between v1 and v2 and why. ?As is its unclear why the v1 comments weren't implemented, so they also apply to this series.

Quoted 6 lines

Peter,

Sorry, since this is my first patch series to U-Boot upstream, I'm still learning the proper etiquette.
Let me respond here rather than in the patch comments since there are only 2 unchanged areas WRT comments.

No worries. ?I'm glad to see you're pushing your changes upstream.

Quoted 9 lines

1) IO access functions - I pre-reviewed my patch series with Wolfgang (to hopefully catch any blatant errors and smooth
the process) and he indicated that C structs and I/O accessor funcs or macros were preferred to my base+offset original code. Since the ARM is 32-bit, and all of our registers are I/O mapped, it made sense just to cast the necessary HW mem-mapped
regs as volatile structs and access the members directly. Works well, is easy to read & understand, etc. Let me know (with examples, if possible) how I can make it better.

Both Linux and U-Boot recommend using IO access functions instead pointer accesses, at least in PPC-land, and even for memory mapped registers. ?I'm not too familiar with ARM, but assume they have the same recommendation. ?If pointers are used, some CPUs may optimize the access order, thus causing problems. ?Using IO accessors also ensures that the code is portable. ?Even if the Tegra doesn't re-order accesses, a driver you write for use in a Tegra could be used on other CPUs that do.

eg:
http://www.mail-archive.com/u-boot at lists.denx.de/msg18435.html
http://lists.denx.de/pipermail/u-boot/2007-December/027595.html

Quoted 6 lines

It looks like other ARM processors use IO accessors too, eg the recent armada CPU:
arch/arm/cpu/arm926ejs/armada100/*
A grep of writel in arch/arm shows a number of references. ?Similarly in the Linux code in arch/arm.

So instead of, say uart->lcr = 0, you'd prefer writel(0, uart->lcr), where writel = __arch_putl(v, a) = (*(volatile unsigned int *)(a) = (v))?

Is that different enough from 'uart->lcr = 0' to warrant the change? Does it add some HW barriers or forced read-before-write that the 'volatile' struct doesn't?

I've done a ton of embedded work, but all in x86 asm (and C) on PCs, so pardon my ignorance & questions.

Quoted 20 lines

ARM maintainers, feel free to chime in if you have comments.

Quoted 8 lines

2) Compiling out support for UARTA or UARTD - didn't seem necessary - size isn't an issue at this point with Tegra2 U-Boot,
and some boards (Harmony, for example) are populated w/hardware for both UARTA and UARTD, and can have both on at
U-Boot runtime (perhaps for debug out to UARTA whilst normal console I/O goes to UARTD), so I chose to leave the init code
for both intact. Plus I've never liked code with too many unnecessary ifdef's - makes it less readable, IMO.

Yeah, this is grey - I see both sides of the coin. ?U-Boot generally strives to be as small as possible. ?You may use a large flash on your eval boards and not care about space, but other system designers may place as small of flash as possible to save cost. ?It looked like UART_A-UART_E were also going to be supported at some time, which is quite a chunk of code. ?You also already are defining which serial ports are available at compile time via CONFIG_TEGRA2_ENABLE_UARTA and CONFIG_TEGRA2_ENABLE_UARTD.

Quoted 2 lines

Anyway, I don't really care much which way you go, just wanted to make sure you were making a conscious decision to not add the ifdefs.

As conscious I get before noon. ;)

Quoted 8 lines
Quoted 7 lines

I was going to respond to your review w/a direct, inline reply, but I thought it better to get the V2 patch out there before the weekend (we're off for MLK, as well). I'm under some pressure to get a baseline Tegra2 patchset in before the merge window
closes. ?I'll be sure to respond to each issue directly on the list in the future, though.

Quoted 5 lines

As long as you initially submit your patches during the merge window they will generally be merged, even if there are multiple revisions and discussion that lasts past the end of official merge window. ?So this stuff should get in.

Good to know. Thanks.

Quoted 4 lines

Best,
Peter

#9 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Hello,

Le 14/01/2011 23:39, Tom Warren a ?crit :

Quoted 6 lines

So instead of, say uart->lcr = 0, you'd prefer writel(0, uart->lcr), where writel = __arch_putl(v, a) = (*(volatile unsigned int *)(a) = (v))?
Is that different enough from 'uart->lcr = 0' to warrant the change? Does it add some HW barriers or forced read-before-write that the 'volatile' struct doesn't?

writel() and readl() do not introduce "read-before-write", that is, they do not perform any more than what their names imply, but yes they do introduce barriers, or more precisely, they force the compiler to do so.

Amicalement,

Signature · 1 line
Albert.
#10 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Quoted 11 lines · Albert ARIBAUD

Hello,

Le 14/01/2011 23:39, Tom Warren a ?crit :

Quoted 6 lines

So instead of, say uart->lcr = 0, you'd prefer writel(0, uart->lcr), where writel = __arch_putl(v, a) = (*(volatile unsigned int *)(a) = (v))?
Is that different enough from 'uart->lcr = 0' to warrant the change? Does it add some HW barriers or forced read-before-write that the 'volatile' struct doesn't?

Quoted 3 lines

writel() and readl() do not introduce "read-before-write", that is, they do not perform any more than what their names imply, but yes they do introduce barriers, or more precisely, they force the compiler to do so.

Agreed, I should have dug deeper. On PPC we use out_be32() or similar to access memory mapped registers, which does have an explicit barrier. I'm not familiar with ARM so don't know what the proper access functions are, but it looks like the defacto standard writel()/readl().

I'd personally use writel()/readl() in this patch. Functionally it may be the same as your volatile accesses, but its the generally recommended practice. It looks like most of the Tegra support in the Linux kernel also uses writel()/readl() for what its worth. Ultimately its up to the ARM U-Boot maintainer to decide if they require the access functions or not - I'm just giving my opinions from PPC experience.

Regards,
Peter

#11 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

Dear Peter Tyser,

Quoted 5 lines · In message <1295047406.29642.6729.camel@petert> you wrote:

Agreed, I should have dug deeper. On PPC we use out_be32() or similar to access memory mapped registers, which does have an explicit barrier. I'm not familiar with ARM so don't know what the proper access functions are, but it looks like the defacto standard writel()/readl().

I have a patch waiting o be applied that adds proper memory barriers for ARM, too. They are necessary.

Quoted 6 lines

I'd personally use writel()/readl() in this patch. Functionally it may be the same as your volatile accesses, but its the generally recommended practice. It looks like most of the Tegra support in the Linux kernel also uses writel()/readl() for what its worth. Ultimately its up to the ARM U-Boot maintainer to decide if they require the access functions or not - I'm just giving my opinions from PPC experience.

It's not only recommended, it is mandatory.

I/O accesors _MUST_ be used.

Best regards,

Wolfgang Denk

Signature · 6 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
The most difficult thing in the world is to know how to  do  a  thing
and to watch someone else doing it wrong, without commenting.
                                                        -- T.H. White
#13 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

In reply to Tom Warren

Dear Tom Warren,

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

1) IO access functions - I pre-reviewed my patch series with Wolfgang (to hopefully catch any blatant errors and smooth
the process) and he indicated that C structs and I/O accessor funcs or macros were preferred to my base+offset original code.

I don't think I said "preferred".

I apologize if I really should have been unclear. Fact is, the use of I/O accessors is mandatory for any new code going in.

Quoted 5 lines

Since the ARM is 32-bit, and all of our registers are I/O mapped, it made sense just to cast the necessary HW mem-mapped
regs as volatile structs and access the members directly. Works well, is easy to read & understand, etc. Let me know (with examples, if possible) how I can make it better.

It does NOT make sense. Please read the linux/Documentation/volatile-considered-harmful.txt document, and see recent dicussion in the "ARM: Avoid compiler optimization for usages of readb, writeb and friends." thread about what happens when you use just volatile pointers.

Quoted 2 lines

2) Compiling out support for UARTA or UARTD - didn't seem necessary - size isn't an issue at this point with Tegra2 U-Boot,

Maybe you don't care, but we do.

Please see http://www.denx.de/wiki/U-Boot/DesignPrinciples, item 5

Quoted 6 lines

I was going to respond to your review w/a direct, inline reply, but I thought it better to get the V2 patch out there before the weekend (we're off for MLK, as well). I'm under some pressure to get a baseline Tegra2 patchset in before the merge window
closes. I'll be sure to respond to each issue directly on the list in the future, though.

Please also make sure to maintain a changelog of in each of your patches (see second bullet in
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions).

Best regards,

Wolfgang Denk

Signature · 7 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
IMPORTANT NOTICE TO PURCHASERS: The Entire Physical Universe,  Inclu-
ding  This Product, May One Day Collapse Back into an Infinitesimally
Small Space. Should  Another  Universe  Subsequently  Re-emerge,  the
Existence of This Product in That Universe Cannot Be Guaranteed.
#12 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

In reply to Tom Warren

Dear Tom Warren,

Quoted 4 lines · In message <[email protected]> you…

So instead of, say uart->lcr = 0, you'd prefer writel(0, uart->lcr), where writel = __arch_putl(v, a) = (*(volatile unsigned int *)(a) = (v))?

Please see the thread "ARM: Avoid compiler optimization for usages of readb, writeb and friends."

Quoted 1 line

Is that different enough from 'uart->lcr = 0' to warrant the change?

Yes, it is - in recent (i. e. fixed) code.

Quoted 2 lines

Does it add some HW barriers or forced read-before-write that the 'volatile' struct doesn't?

Yes, it does. See above.

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
Conquest is easy. Control is not.
	-- Kirk, "Mirror, Mirror", stardate unknown
author
#14 lore raw

v2 cover Add basic NVIDIA Tegra2 SoC support

In reply to Wolfgang Denk

Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Tom Warren,

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

1) IO access functions - I pre-reviewed my patch series with Wolfgang (to hopefully catch any blatant errors and smooth
the process) and he indicated that C structs and I/O accessor funcs or macros were preferred to my base+offset original code.

Quoted 5 lines

I don't think I said "preferred".

I apologize if I really should have been unclear. Fact is, the use of I/O accessors is mandatory for any new code going in.

Sorry, I misunderstood what really constituted I/O accessors. Fixed in V3 (coming soon).

Quoted 12 lines
Quoted 5 lines

Since the ARM is 32-bit, and all of our registers are I/O mapped, it made sense just to cast the necessary HW mem-mapped
regs as volatile structs and access the members directly. Works well, is easy to read & understand, etc. Let me know (with examples, if possible) how I can make it better.

It does NOT make sense. Please read the linux/Documentation/volatile-considered-harmful.txt document, and see recent dicussion in the "ARM: Avoid compiler optimization for usages of readb, writeb and friends." thread about what happens when you use just volatile pointers.

Quoted 7 lines
Quoted 2 lines

2) Compiling out support for UARTA or UARTD - didn't seem necessary - size isn't an issue at this point with Tegra2 U-Boot,

Maybe you don't care, but we do.

Please see http://www.denx.de/wiki/U-Boot/DesignPrinciples, item 5

Done in V3 patch.

Quoted 11 lines
Quoted 6 lines

I was going to respond to your review w/a direct, inline reply, but I thought it better to get the V2 patch out there before the weekend (we're off for MLK, as well). I'm under some pressure to get a baseline Tegra2 patchset in before the merge window
closes. ?I'll be sure to respond to each issue directly on the list in the future, though.

Please also make sure to maintain a changelog of in each of your patches (see second bullet in
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions).

OK. I added a V2/V3 changelog to each patch. Hope I got it right. New patchset incoming.

Quoted 6 lines

Best regards,

Wolfgang Denk

Thanks for your patience,

Tom

Quoted 10 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 IMPORTANT NOTICE TO PURCHASERS: The Entire Physical Universe, ?Inclu- ding ?This Product, May One Day Collapse Back into an Infinitesimally Small Space. Should ?Another ?Universe ?Subsequently ?Re-emerge, ?the Existence of This Product in That Universe Cannot Be Guaranteed.