Skip to contentSkip to conversation

Add basic NVIDIA Tegra2 SoC support

PATCH Superseded Tom Warren 4 participants 12 messages Jan 21, 2011

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Tom Warren

author
#0 lore raw

v4 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.

Changes for V2:
- Coding style cleanup
- Remove mach-types.h change; wait for ARM kernel sync-up
- Move serial driver changes to separate patch
- Use board/nvidia/ instead of /board/tegra
- Remove TRUE/FALSE defines
- Use standard NS16550 register/bit defines in UART init
- Change nv-common.h config file to tegra2-common.h

Changes for V3:
- Use I/O accessors for Tegra2 HW MMIO register access
- Allow conditional compile of UARTA/UARTD code to save space

Changes for V4:
- Use address of HW structs (&pmc, etc.) in readl/writel
- Remove empty lines, fix mixed case hex #s & comments in header(s)
- Move board/nvidia/common/board.c UART code & header to arch/arm/cpu/armv7/tegra2/
- Declare internal functions as static in UART code

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/board.h            |   58 +++++++
 arch/arm/cpu/armv7/tegra2/config.mk          |   28 ++++
 arch/arm/cpu/armv7/tegra2/lowlevel_init.S    |   65 ++++++++
 arch/arm/cpu/armv7/tegra2/sys_info.c         |   35 ++++
 arch/arm/cpu/armv7/tegra2/timer.c            |  122 +++++++++++++++
 arch/arm/cpu/armv7/tegra2/uart.c             |  216 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/clk_rst.h   |  154 ++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pinmux.h    |   51 ++++++
 arch/arm/include/asm/arch-tegra2/pmc.h       |  124 +++++++++++++++
 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      |   44 ++++++
 board/nvidia/common/board.c                  |   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                   |   44 ++++++
 include/configs/tegra2-common.h              |  160 +++++++++++++++++++
 include/serial.h                             |    3 +-
 24 files changed, 1538 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/board.h
 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/cpu/armv7/tegra2/uart.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/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 v4 1/4 arm: Tegra2: Add basic NVIDIA Tegra2 SoC support

---
Changes for V2:
- Coding style cleanup
- Move serial driver changes to separate patch
- Use board/nvidia instead of board/tegra
- Remove TRUE/FALSE defines
- Use standard NS16550 registers/bit defines in UART init

Changes for V3:
- Use I/O accessors for Tegra2 HW MMIO register access
- Allow conditional compile of UARTA/UARTD code to save space

Changes for V4:
- Use address of HW structs (&pmc, etc.) in readl/writel
- Remove empty lines, fix mixed case hex #s & comments in header(s)
- Move board/nvidia/common/board.c UART code & header to arch/arm/cpu/armv7/tegra2/
- Declare internal functions as static in UART code

 arch/arm/cpu/armv7/tegra2/Makefile           |   48 ++++++
 arch/arm/cpu/armv7/tegra2/board.c            |   91 +++++++++++
 arch/arm/cpu/armv7/tegra2/board.h            |   58 +++++++
 arch/arm/cpu/armv7/tegra2/config.mk          |   28 ++++
 arch/arm/cpu/armv7/tegra2/lowlevel_init.S    |   65 ++++++++
 arch/arm/cpu/armv7/tegra2/sys_info.c         |   35 ++++
 arch/arm/cpu/armv7/tegra2/timer.c            |  122 +++++++++++++++
 arch/arm/cpu/armv7/tegra2/uart.c             |  216 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/clk_rst.h   |  154 ++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pinmux.h    |   51 ++++++
 arch/arm/include/asm/arch-tegra2/pmc.h       |  124 +++++++++++++++
 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      |   44 ++++++
 board/nvidia/common/board.c                  |   57 +++++++
 15 files changed, 1175 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/board.h
 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/cpu/armv7/tegra2/uart.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
arch/arm/cpu/armv7/tegra2/Makefile new file +48 -0
new file mode 100644
index 0000000..f5b657b
@@ -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	:= board.o sys_info.o timer.o uart.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/board.h new file +58 -0

58 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 +65 -0

65 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/cpu/armv7/tegra2/uart.c new file +216 -0

216 lines not on this page · raw message

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

154 lines not on this page · raw message

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

51 lines not on this page · raw message

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

124 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 +44 -0

44 lines not on this page · raw message

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

57 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#2 lore raw

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

Dear Tom Warren,

arch/arm/cpu/armv7/tegra2/uart.c

Quoted 5 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/uart.c new file +0 -0
new file mode 100644
index 0000000..5e60bd8

How about move it to drivers/serial/ ?
And why don't you use serial multi interface?

Thanks
Minkyu Kang

Signature · 2 lines
from. prom.
www.promsoft.net
author
#3 lore raw

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

Minkyu,

Quoted 10 lines · Minkyu Kang

Dear Tom Warren,

arch/arm/cpu/armv7/tegra2/uart.c

Quoted 5 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/uart.c new file +0 -0
new file mode 100644
index 0000000..5e60bd8

How about move it to drivers/serial/ ?

There's Tegra-specific code in there (clocks, PLLs and pinmuxes).

Quoted 1 line

And why don't you use serial multi interface?

CONFIG_SERIAL_MULTI is enabled in the config files.

Quoted 3 lines

Thanks
Minkyu Kang

Thank you,

Tom

Quoted 4 lines

--
from. prom.
www.promsoft.net

#4 lore raw

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

Quoted 12 lines · Tom Warren

Minkyu,

Quoted 9 lines · Minkyu Kang

Dear Tom Warren,

arch/arm/cpu/armv7/tegra2/uart.c

Quoted 5 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/uart.c new file +0 -0
new file mode 100644
index 0000000..5e60bd8

How about move it to drivers/serial/ ?

Approve? you can use name in the drivers/serial. such as? serial_tegra2.c

Thanks
seedshope

Quoted 18 lines

There's Tegra-specific code in there (clocks, PLLs and pinmuxes).

Quoted 1 line

And why don't you use serial multi interface?

CONFIG_SERIAL_MULTI is enabled in the config files.

Quoted 2 lines

Thanks
Minkyu Kang

Thank you,

Tom

Quoted 4 lines

--
from. prom.
www.promsoft.net

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

#5 lore raw

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

In reply to Tom Warren
Quoted 128 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/board.h new file +10 -0
+
+enum {
+	UART_A = 1,
+	UART_B,
+	UART_C,
+	UART_D,
+	UART_E
+};
+
+#endif /* _BOARD_H_ */
arch/arm/cpu/armv7/tegra2/uart.c new file +110 -0
new file mode 100644
index 0000000..5e60bd8
@@ -0,0 +1,216 @@
+/*
+ *  (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>
+#include<ns16550.h>
+#include<asm/io.h>
+#include<asm/arch/tegra2.h>
+#include "board.h"
+
+/*
+ * Routine: uart_clock_init
+ * Description: init the PLL and clock for the UART in uart_num
+ */
+static void uart_clock_init(int uart_num)
+{
+	clk_rst_ctlr *const clkrst = (clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
+	static int pllp_init_done;
+	u32 reg;
+
+	if (!pllp_init_done) {
+		/* Override pllp setup for 216MHz operation. */
+		reg = (PLL_BYPASS | PLL_BASE_OVRRIDE | PLL_DIVP);
+		reg |= (((NVRM_PLLP_FIXED_FREQ_KHZ/500)<<  8) | PLL_DIVM);
+		writel(reg,&clkrst->crc_pllp_base);
+
+		reg |= PLL_ENABLE;
+		writel(reg,&clkrst->crc_pllp_base);
+
+		reg&= ~PLL_BYPASS;
+		writel(reg,&clkrst->crc_pllp_base);
+
+		pllp_init_done++;
+	}
+
+	/* Now do the UART reset/clock enable based on uart_num */
+#if CONFIG_TEGRA2_ENABLE_UARTA
+	if (uart_num == UART_A) {
+		/* Assert Reset to UART */
+		reg = readl(&clkrst->crc_rst_dev_l);
+		reg |= SWR_UARTA_RST;		/* SWR_UARTA_RST = 1 */
+		writel(reg,&clkrst->crc_rst_dev_l);
+
+		/* Enable clk to UART */
+		reg = readl(&clkrst->crc_clk_out_enb_l);
+		reg |= CLK_ENB_UARTA;		/* CLK_ENB_UARTA = 1 */
+		writel(reg,&clkrst->crc_clk_out_enb_l);
+
+		/* Enable pllp_out0 to UART */
+		reg = readl(&clkrst->crc_clk_src_uarta);
+		reg&= 0x3FFFFFFF;	/* UARTA_CLK_SRC = 00, PLLP_OUT0 */
+		writel(reg,&clkrst->crc_clk_src_uarta);
+
+		/* wait for 2us */
+		udelay(2);
+
+		/* De-assert reset to UART */
+		reg = readl(&clkrst->crc_rst_dev_l);
+		reg&= ~SWR_UARTA_RST;		/* SWR_UARTA_RST = 0 */
+		writel(reg,&clkrst->crc_rst_dev_l);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTA */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+	if (uart_num == UART_D) {
+		/* Assert Reset to UART */
+		reg = readl(&clkrst->crc_rst_dev_u);
+		reg |= SWR_UARTD_RST;		/* SWR_UARTD_RST = 1 */
+		writel(reg,&clkrst->crc_rst_dev_u);
+
+		/* Enable clk to UART */
+		reg = readl(&clkrst->crc_clk_out_enb_u);
+		reg |= CLK_ENB_UARTD;		/* CLK_ENB_UARTD = 1 */
+		writel(reg,&clkrst->crc_clk_out_enb_u);
+
+		/* Enable pllp_out0 to UART */
+		reg = readl(&clkrst->crc_clk_src_uartd);
+		reg&= 0x3FFFFFFF;	/* UARTD_CLK_SRC = 00, PLLP_OUT0 */
+		writel(reg,&clkrst->crc_clk_src_uartd);
+
+		/* wait for 2us */
+		udelay(2);
+
+		/* De-assert reset to UART */
+		reg = readl(&clkrst->crc_rst_dev_u);
+		reg&= ~SWR_UARTD_RST;		/* SWR_UARTD_RST = 0 */
+		writel(reg,&clkrst->crc_rst_dev_u);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+/*

arch/arm/cpu/armv7/tegra2/uart.c line 120

Quoted 10 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +10 -0
+ * Routine: pin_mux_uart
+ * Description: setup the pin muxes/tristate values for UART based on uart_num
+ */
+static void pin_mux_uart(int uart_num)
+{
+	pinmux_tri_ctlr *const pmt = (pinmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
+	u32 reg;
+
+#if CONFIG_TEGRA2_ENABLE_UARTA
+	if (uart_num  == UART_A) {

Why you need get the parameters uart_num, I think if you want to use CONFIG_TEGRA2_ENABLE_UARTA,
You only defined CONFIG_TEGRA2_ENABLE_UARTA in include/configs/seaboard.h or include/configs/tegra2-common.h.

Here, The code formats may be as following:

#ifdef CONFIG_SERIAL1
......
#elif defined(CONFIG_SERIAL2)
......
#else
......
#endif

Quoted 53 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +53 -0
+		reg = readl(&pmt->pmt_ctl_c);
+		reg&= 0xFFF0FFFF;	/* IRRX_/IRTX_SEL [19:16] = 00 UARTA */
+		writel(reg,&pmt->pmt_ctl_c);
+
+		reg = readl(&pmt->pmt_tri_a);
+		reg&= ~Z_IRRX;		/* Z_IRRX = normal (0) */
+		reg&= ~Z_IRTX;		/* Z_IRTX = normal (0) */
+		writel(reg,&pmt->pmt_tri_a);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTA */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+	if (uart_num == UART_D) {
+		reg = readl(&pmt->pmt_ctl_b);
+		reg&= 0xFFFFFFF3;	/* GMC_SEL [3:2] = 00, UARTD */
+		writel(reg,&pmt->pmt_ctl_b);
+
+		reg = readl(&pmt->pmt_tri_a);
+		reg&= ~Z_GMC;		/* Z_GMC = normal (0) */
+		writel(reg,&pmt->pmt_tri_a);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+static void setup_uart(uart_ctlr *u)
+{
+	u32 reg;
+
+	/* Prepare the divisor value */
+	reg = NVRM_PLLP_FIXED_FREQ_KHZ * 1000 / NV_DEFAULT_DEBUG_BAUD / 16;
+
+	/* Set up UART parameters */
+	writel(UART_LCR_DLAB,&u->uart_lcr);
+	writel(reg,&u->uart_thr_dlab_0);
+	writel(0,&u->uart_ier_dlab_0);
+	writel(0,&u->uart_lcr);			/* clear DLAB */
+	writel((UART_FCR_TRIGGER_3 | UART_FCR_FIFO_EN | \
+		UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_RCVR),&u->uart_iir_fcr);
+	writel(0,&u->uart_ier_dlab_0);
+	writel(UART_LCR_WLS_8,&u->uart_lcr);	/* 8N1 */
+	writel(UART_MCR_RTS,&u->uart_mcr);
+	writel(0,&u->uart_msr);
+	writel(0,&u->uart_spr);
+	writel(0,&u->uart_irda_csr);
+	writel(0,&u->uart_asr);
+	writel((UART_FCR_TRIGGER_3 | UART_FCR_FIFO_EN),&u->uart_iir_fcr);
+
+	/* Flush any old characters out of the RX FIFO */
+	reg = readl(&u->uart_lsr);
+
+	while (reg&  UART_LSR_DR) {
+		reg = readl(&u->uart_thr_dlab_0);
+		reg = readl(&u->uart_lsr);
+	}

arch/arm/cpu/armv7/tegra2/uart.c line 183

Quoted 10 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +10 -0
+}
+
+/*
+ * Routine: init_uart
+ * Description: init the UART clocks, muxes, and baudrate/parity/etc.
+ */
+static void init_uart(int uart_num)
+{
+#if CONFIG_TEGRA2_ENABLE_UARTA
+	if (uart_num == UART_A) {

above.

Thanks
seedshope

Quoted 34 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +33 -0
+		uart_ctlr *const uart = (uart_ctlr *)NV_PA_APB_UARTA_BASE;
+
+		uart_clock_init(UART_A);
+
+		/* Enable UARTA - uses config 0 */
+		pin_mux_uart(UART_A);
+
+		setup_uart(uart);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTD */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+	if (uart_num == UART_D) {
+		uart_ctlr *const uart = (uart_ctlr *)NV_PA_APB_UARTD_BASE;
+
+		uart_clock_init(UART_D);
+
+		/* Enable UARTD - uses config 0 */
+		pin_mux_uart(UART_D);
+
+		setup_uart(uart);
+	}
+#endif	/* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+void uart_init(void)
+{
+#if (CONFIG_TEGRA2_ENABLE_UARTA)
+	init_uart(UART_A);
+#endif
+#if (CONFIG_TEGRA2_ENABLE_UARTD)
+	init_uart(UART_D);
+#endif
+}
#6 lore raw

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

Quoted 149 lines · seedshope
Quoted 137 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/board.h new file +10 -0
+
+enum {
+    UART_A = 1,
+    UART_B,
+    UART_C,
+    UART_D,
+    UART_E
+};
+
+#endif /* _BOARD_H_ */
arch/arm/cpu/armv7/tegra2/uart.c new file +112 -0
new file mode 100644
index 0000000..5e60bd8
@@ -0,0 +1,216 @@
+/*
+ *  (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>
+#include<ns16550.h>
+#include<asm/io.h>
+#include<asm/arch/tegra2.h>
+#include "board.h"
+
+/*
+ * Routine: uart_clock_init
+ * Description: init the PLL and clock for the UART in uart_num
+ */
+static void uart_clock_init(int uart_num)
+{
+    clk_rst_ctlr *const clkrst = (clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
+    static int pllp_init_done;
+    u32 reg;
+
+    if (!pllp_init_done) {
+        /* Override pllp setup for 216MHz operation. */
+        reg = (PLL_BYPASS | PLL_BASE_OVRRIDE | PLL_DIVP);
+        reg |= (((NVRM_PLLP_FIXED_FREQ_KHZ/500)<<  8) | PLL_DIVM);
+        writel(reg,&clkrst->crc_pllp_base);
+
+        reg |= PLL_ENABLE;
+        writel(reg,&clkrst->crc_pllp_base);
+
+        reg&= ~PLL_BYPASS;
+        writel(reg,&clkrst->crc_pllp_base);
+
+        pllp_init_done++;
+    }
+
+    /* Now do the UART reset/clock enable based on uart_num */
+#if CONFIG_TEGRA2_ENABLE_UARTA
+    if (uart_num == UART_A) {
+        /* Assert Reset to UART */
+        reg = readl(&clkrst->crc_rst_dev_l);
+        reg |= SWR_UARTA_RST;        /* SWR_UARTA_RST = 1 */
+        writel(reg,&clkrst->crc_rst_dev_l);
+
+        /* Enable clk to UART */
+        reg = readl(&clkrst->crc_clk_out_enb_l);
+        reg |= CLK_ENB_UARTA;        /* CLK_ENB_UARTA = 1 */
+        writel(reg,&clkrst->crc_clk_out_enb_l);
+
+        /* Enable pllp_out0 to UART */
+        reg = readl(&clkrst->crc_clk_src_uarta);
+        reg&= 0x3FFFFFFF;    /* UARTA_CLK_SRC = 00, PLLP_OUT0 */
+        writel(reg,&clkrst->crc_clk_src_uarta);
+
+        /* wait for 2us */
+        udelay(2);
+
+        /* De-assert reset to UART */
+        reg = readl(&clkrst->crc_rst_dev_l);
+        reg&= ~SWR_UARTA_RST;        /* SWR_UARTA_RST = 0 */
+        writel(reg,&clkrst->crc_rst_dev_l);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTA */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+    if (uart_num == UART_D) {
+        /* Assert Reset to UART */
+        reg = readl(&clkrst->crc_rst_dev_u);
+        reg |= SWR_UARTD_RST;        /* SWR_UARTD_RST = 1 */
+        writel(reg,&clkrst->crc_rst_dev_u);
+
+        /* Enable clk to UART */
+        reg = readl(&clkrst->crc_clk_out_enb_u);
+        reg |= CLK_ENB_UARTD;        /* CLK_ENB_UARTD = 1 */
+        writel(reg,&clkrst->crc_clk_out_enb_u);
+
+        /* Enable pllp_out0 to UART */
+        reg = readl(&clkrst->crc_clk_src_uartd);
+        reg&= 0x3FFFFFFF;    /* UARTD_CLK_SRC = 00, PLLP_OUT0 */
+        writel(reg,&clkrst->crc_clk_src_uartd);
+
+        /* wait for 2us */
+        udelay(2);
+
+        /* De-assert reset to UART */
+        reg = readl(&clkrst->crc_rst_dev_u);
+        reg&= ~SWR_UARTD_RST;        /* SWR_UARTD_RST = 0 */
+        writel(reg,&clkrst->crc_rst_dev_u);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+/*
+ * Routine: pin_mux_uart
+ * Description: setup the pin muxes/tristate values for UART based 

on uart_num
+ */

arch/arm/cpu/armv7/tegra2/uart.c new file +3 -0
+static void pin_mux_uart(int uart_num)
+{
+    pinmux_tri_ctlr *const pmt = (pinmux_tri_ctlr 

*)NV_PA_APB_MISC_BASE;

arch/arm/cpu/armv7/tegra2/uart.c line 57

Quoted 4 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +4 -0
+    u32 reg;
+
+#if CONFIG_TEGRA2_ENABLE_UARTA
+    if (uart_num  == UART_A) {

Why you need get the parameters uart_num, I think if you want to use CONFIG_TEGRA2_ENABLE_UARTA,
You only defined CONFIG_TEGRA2_ENABLE_UARTA in include/configs/seaboard.h or include/configs/tegra2-common.h.

Here, The code formats may be as following:

Quoted 7 lines

#ifdef CONFIG_SERIAL1
......
#elif defined(CONFIG_SERIAL2)
......
#else
......
#endif

I am sorry, just see the tegra2-common.h file, UARTA is for keypad, UARTB for debug.
But I feel the line of "if (uart_num == UART_A) " is not necessary. Because CONFIG_TEGRA2_ENABLE_UARTA
have already represent UART_A.

You only use as following:

#ifdef CONFIG_TEGRA2_ENABLE_UARTA

#endif

Thanks,
seedshope

Quoted 103 lines
Quoted 54 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +53 -0
+        reg = readl(&pmt->pmt_ctl_c);
+        reg&= 0xFFF0FFFF;    /* IRRX_/IRTX_SEL [19:16] = 00 UARTA */
+        writel(reg,&pmt->pmt_ctl_c);
+
+        reg = readl(&pmt->pmt_tri_a);
+        reg&= ~Z_IRRX;        /* Z_IRRX = normal (0) */
+        reg&= ~Z_IRTX;        /* Z_IRTX = normal (0) */
+        writel(reg,&pmt->pmt_tri_a);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTA */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+    if (uart_num == UART_D) {
+        reg = readl(&pmt->pmt_ctl_b);
+        reg&= 0xFFFFFFF3;    /* GMC_SEL [3:2] = 00, UARTD */
+        writel(reg,&pmt->pmt_ctl_b);
+
+        reg = readl(&pmt->pmt_tri_a);
+        reg&= ~Z_GMC;        /* Z_GMC = normal (0) */
+        writel(reg,&pmt->pmt_tri_a);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+static void setup_uart(uart_ctlr *u)
+{
+    u32 reg;
+
+    /* Prepare the divisor value */
+    reg = NVRM_PLLP_FIXED_FREQ_KHZ * 1000 / NV_DEFAULT_DEBUG_BAUD / 16;
+
+    /* Set up UART parameters */
+    writel(UART_LCR_DLAB,&u->uart_lcr);
+    writel(reg,&u->uart_thr_dlab_0);
+    writel(0,&u->uart_ier_dlab_0);
+    writel(0,&u->uart_lcr);            /* clear DLAB */
+    writel((UART_FCR_TRIGGER_3 | UART_FCR_FIFO_EN | \
+        UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_RCVR),&u->uart_iir_fcr);
+    writel(0,&u->uart_ier_dlab_0);
+    writel(UART_LCR_WLS_8,&u->uart_lcr);    /* 8N1 */
+    writel(UART_MCR_RTS,&u->uart_mcr);
+    writel(0,&u->uart_msr);
+    writel(0,&u->uart_spr);
+    writel(0,&u->uart_irda_csr);
+    writel(0,&u->uart_asr);
+    writel((UART_FCR_TRIGGER_3 | UART_FCR_FIFO_EN),&u->uart_iir_fcr);
+
+    /* Flush any old characters out of the RX FIFO */
+    reg = readl(&u->uart_lsr);
+
+    while (reg&  UART_LSR_DR) {
+        reg = readl(&u->uart_thr_dlab_0);
+        reg = readl(&u->uart_lsr);
+    }

arch/arm/cpu/armv7/tegra2/uart.c line 183

Quoted 10 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +10 -0
+}
+
+/*
+ * Routine: init_uart
+ * Description: init the UART clocks, muxes, and baudrate/parity/etc.
+ */
+static void init_uart(int uart_num)
+{
+#if CONFIG_TEGRA2_ENABLE_UARTA
+    if (uart_num == UART_A) {

above.

Thanks
seedshope

Quoted 34 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +33 -0
+        uart_ctlr *const uart = (uart_ctlr *)NV_PA_APB_UARTA_BASE;
+
+        uart_clock_init(UART_A);
+
+        /* Enable UARTA - uses config 0 */
+        pin_mux_uart(UART_A);
+
+        setup_uart(uart);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTD */
+#if CONFIG_TEGRA2_ENABLE_UARTD
+    if (uart_num == UART_D) {
+        uart_ctlr *const uart = (uart_ctlr *)NV_PA_APB_UARTD_BASE;
+
+        uart_clock_init(UART_D);
+
+        /* Enable UARTD - uses config 0 */
+        pin_mux_uart(UART_D);
+
+        setup_uart(uart);
+    }
+#endif    /* CONFIG_TEGRA2_ENABLE_UARTD */
+}
+
+void uart_init(void)
+{
+#if (CONFIG_TEGRA2_ENABLE_UARTA)
+    init_uart(UART_A);
+#endif
+#if (CONFIG_TEGRA2_ENABLE_UARTD)
+    init_uart(UART_D);
+#endif
+}
author
#7 lore raw

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

In reply to seedshope

seedshope, (?)

Quoted 13 lines · seedshope
Quoted 12 lines · Tom Warren
arch/arm/cpu/armv7/tegra2/board.h new file +10 -0
+
+enum {
+ ? ? ? UART_A = 1,
+ ? ? ? UART_B,
+ ? ? ? UART_C,
+ ? ? ? UART_D,
+ ? ? ? UART_E
+};
+
+#endif /* _BOARD_H_ */

<snip>

Quoted 9 lines

arch/arm/cpu/armv7/tegra2/uart.c

Quoted 3 lines
arch/arm/cpu/armv7/tegra2/uart.c new file +3 -0
+
+#if CONFIG_TEGRA2_ENABLE_UARTA
+ ? ? ? if (uart_num ?== UART_A) {

Why ?you need get the parameters uart_num, I think if you want to use CONFIG_TEGRA2_ENABLE_UARTA,
You ?only defined CONFIG_TEGRA2_ENABLE_UARTA in include/configs/seaboard.h or include/configs/tegra2-common.h.

OK, makes sense. I'll move uart.c/board.h to drivers/serial as serial_tegra2.[ch] and remove
all mention of UART_[A-E] and uart_num. Thanks.

Quoted 10 lines

Here, The code formats may be as following:

#ifdef CONFIG_SERIAL1
......
#elif defined(CONFIG_SERIAL2)
......
#else
......
#endif

Some configs / builds can have both UARTs active, so each #ifdef/#endif pair is needed.

Quoted 2 lines

Thanks
seedshope

Thanks for the feedback

Tom

author
#8 lore raw

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

In reply to Tom Warren

---
Changes for V2:
- Move serial driver to separate patch

 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
#9 lore raw

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

In reply to Tom Warren

---
Changes for V2:
- Use board/nvidia/ instead of /board/tegra
- Change nv-common.h config file to tegra2-common.h

 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
#10 lore raw

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

In reply to Tom Warren

---
Changes for V2:
- Remove mach-types.h change; wait for ARM kernel sync-up
- Use board/nvidia instead of board/tegra

 MAINTAINERS                    |    1 +
 board/nvidia/seaboard/Makefile |   50 ++++++++++++++++++++++++++++++++++++++++
 boards.cfg                     |    1 +
 include/configs/seaboard.h     |   44 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 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 +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#11 lore raw

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

Le 21/01/2011 01:42, Tom Warren a ?crit :

Quoted 5 lines

---
Changes for V2:
- Remove mach-types.h change; wait for ARM kernel sync-up
- Use board/nvidia instead of board/tegra

Doesn't this mean that the patch cannot compile on current u-boot, and won't until mach-types.h is updated?

Amicalement,

Signature · 1 line
Albert.