Skip to contentSkip to conversation

add TI DA8xx support: Add new directory for da8xx cpu functions

PATCH Superseded Nick Thompson 4 participants 5 messages Oct 23, 2009 – Oct 26, 2009 Arm/actions semi architecture

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 add TI DA8xx support: Add new directory for da8xx cpu functions

Add new directory for da8xx cpu functions.

Provides initial support for TI OMAP-L1x/DA8xx SoC devices. See http://www.ti.com

Provides:
Low level initialisation.
System clock API.
Timer control.
System reset.

---
Applies to u-boot-ti

 cpu/arm926ejs/da8xx/Makefile        |   53 ++++++++++++
 cpu/arm926ejs/da8xx/clock.c         |   65 +++++++++++++++
 cpu/arm926ejs/da8xx/lowlevel_init.S |   71 ++++++++++++++++
 cpu/arm926ejs/da8xx/reset.S         |   75 +++++++++++++++++
 cpu/arm926ejs/da8xx/timer.c         |  152 +++++++++++++++++++++++++++++++++++
 5 files changed, 416 insertions(+), 0 deletions(-)
cpu/arm926ejs/da8xx/Makefile new file +53 -0
new file mode 100644
index 0000000..76fb7b8
@@ -0,0 +1,53 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2007 Sergey Kubushyn <[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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS	= timer.o clock.o
+SOBJS	= reset.o
+
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+SOBJS	+= lowlevel_init.o
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm926ejs/da8xx/clock.c new file +65 -0

65 lines not on this page · raw message

cpu/arm926ejs/da8xx/lowlevel_init.S new file +71 -0

71 lines not on this page · raw message

cpu/arm926ejs/da8xx/reset.S new file +75 -0

75 lines not on this page · raw message

cpu/arm926ejs/da8xx/timer.c new file +152 -0

152 lines not on this page · raw message

#1 lore raw

PATCH v2 1/4 add TI DA8xx support: Add new directory for da8xx cpu functions

Quoted 10 lines · Nick Thompson

Add new directory for da8xx cpu functions.

Provides initial support for TI OMAP-L1x/DA8xx SoC devices. See http://www.ti.com

Provides:
Low level initialisation.
System clock API.
Timer control.
System reset.

It looks like this patch is duplicating much of what is already in arm926ejs/davinci. Unless there is a really good reason for a separate cpu dir, this patch should change to merge with davinci.

Quoted 121 lines

---
Applies to u-boot-ti

 cpu/arm926ejs/da8xx/Makefile        |   53 ++++++++++++
 cpu/arm926ejs/da8xx/clock.c         |   65 +++++++++++++++
 cpu/arm926ejs/da8xx/lowlevel_init.S |   71 ++++++++++++++++
 cpu/arm926ejs/da8xx/reset.S         |   75 +++++++++++++++++
 cpu/arm926ejs/da8xx/timer.c         |  152 +++++++++++++++++++++++++++++++++++
 5 files changed, 416 insertions(+), 0 deletions(-)
cpu/arm926ejs/da8xx/Makefile new file +53 -0
new file mode 100644
index 0000000..76fb7b8
@@ -0,0 +1,53 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2007 Sergey Kubushyn <[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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS	= timer.o clock.o
+SOBJS	= reset.o
+
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+SOBJS	+= lowlevel_init.o
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm926ejs/da8xx/clock.c new file +44 -0
new file mode 100644
index 0000000..e4606b8
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Nick Thompson, GE Fanuc Ltd. <[email protected]>
+ *
+ * Changed to use readl and writel instead of volatile pointers.
+ *
+ * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc.  <[email protected]>
+ *
+ * DA8xx clock module
+ *
+ * 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 <asm/arch/hardware.h>
+#include <asm/io.h>
+
+unsigned int sysdiv[9] = {
+	PLL0_DIV1, PLL0_DIV2, PLL0_DIV3, PLL0_DIV4,
+	PLL0_DIV5, PLL0_DIV6, PLL0_DIV7, PLL0_DIV8,
+	PLL0_DIV9
+};
+
+int clk_get(unsigned int id)
+{
+	int pre_div = (readl(PLL0_PREDIV) & 0xff) + 1;
+	int pllm = readl(PLL0_PLLM) + 1;
+	int post_div = (readl(PLL0_POSTDIV) & 0xff) + 1;
+	int pll_out = CONFIG_SYS_OSCIN_FREQ;
+
+	if (id == DAVINCI_AUXCLK_CLKID)
+		goto out;

cpu/arm926ejs/da8xx/clock.c line 54

Quoted 10 lines
cpu/arm926ejs/da8xx/clock.c new file +10 -0
+
+	/*
+	 * Lets keep this simple. Combining operations can result in
+	 * unexpected approximations
+	 */
+	pll_out /= pre_div;
+	pll_out *= pllm;
+
+	if (id == DAVINCI_PLLM_CLKID)
+		goto out;

This define happens in patch #2.
To be bisectable, the order of the patches need to change.

Quoted 94 lines
cpu/arm926ejs/da8xx/clock.c new file +11 -0
+
+	pll_out /= post_div;
+
+	if (id == DAVINCI_PLLC_CLKID)
+		goto out;
+
+	pll_out /= (readl(sysdiv[id - 1]) & 0xff) + 1;
+
+out:
+	return pll_out;
+}
cpu/arm926ejs/da8xx/lowlevel_init.S new file +71 -0
new file mode 100644
index 0000000..3bdc57c
@@ -0,0 +1,71 @@
+/*
+ * Low-level board setup code for TI DA8xx SoC based boards.
+ *
+ * Copyright (C) 2008 Texas Instruments, Inc <www.ti.com>
+ * Sekhar Nori <[email protected]>
+ *
+ * Based on TI DaVinci low level init code. Original copyrights follow:
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[email protected]>
+ *
+ * Partially based on TI sources, original copyrights follow:
+ *
+ * Board specific setup info
+ *
+ * (C) Copyright 2003
+ * Texas Instruments, <www.ti.com>
+ * Kshitij Gupta <[email protected]>
+ *
+ * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
+ *
+ * Modified for OMAP 5912 OSK board by Rishi Bhattacharya, Apr 2004
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * Modified for DV-EVM board by Rishi Bhattacharya, Apr 2005
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * Modified for DV-EVM board by Swaminathan S, Nov 2005
+ * 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 <config.h>
+#include <asm/arch/hardware.h>
+
+.globl	lowlevel_init
+lowlevel_init:
+
+	/*
+	 * Call board-specific lowlevel init.
+	 * That MUST be present and THAT returns
+	 * back to arch calling code with "mov pc, lr."
+	 */
+	b	dv_board_init
+	nop
+
+.ltorg
+
+INTC_GLB_EN_ADDR:
+.word	INTC_GLB_EN
+INTC_EN_CLR0_ADDR:
+	.word	INTC_EN_CLR0
+INTC_HINT_EN_ADDR:
+	.word	INTC_HINT_EN
+
cpu/arm926ejs/da8xx/reset.S new file +0 -0
new file mode 100644
index 0000000..302b5b4

cpu/arm926ejs/da8xx/reset.S line 1

Quoted 1 line
cpu/arm926ejs/da8xx/reset.S new file +1 -0
@@ -0,0 +1,75 @@
+/*

This is very similar to the davinci/reset.S
Why can these not be combined ?

Quoted 39 lines
cpu/arm926ejs/da8xx/reset.S new file +39 -0
+ * Processor reset using WDT for TI TMS320DM644x SoC.
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+.globl reset_cpu
+reset_cpu:
+	ldr	r0, WDT_TGCR
+	mov	r1, $0x08
+	str	r1, [r0]
+	ldr	r1, [r0]
+	orr	r1, r1, $0x03
+	str	r1, [r0]
+	mov	r1, $0
+	ldr	r0, WDT_TIM12
+	str	r1, [r0]
+	ldr	r0, WDT_TIM34
+	str	r1, [r0]
+	ldr	r0, WDT_PRD12
+	str	r1, [r0]
+	ldr	r0, WDT_PRD34
+	str	r1, [r0]
+	ldr	r0, WDT_TCR
+	ldr	r1, [r0]

cpu/arm926ejs/da8xx/reset.S line 50

Quoted 10 lines
cpu/arm926ejs/da8xx/reset.S new file +10 -0
+	orr	r1, r1, $0x40
+	str	r1, [r0]
+	ldr	r0, WDT_WDTCR
+	ldr	r1, [r0]
+	orr	r1, r1, $0x4000
+	str	r1, [r0]
+	ldr	r1, WDTCR_VAL1
+	str	r1, [r0]
+	ldr	r1, WDTCR_VAL2
+	str	r1, [r0]

Please comment on these register settings.
Looks like watchdog setup..
Use the defines in arch-davinci/hardware.h

Why does this have to be in assembly?
Could this be moved to timer.c ?

Quoted 31 lines
cpu/arm926ejs/da8xx/reset.S new file +25 -0
+	nop
+	nop
+	nop
+	nop
+reset_cpu_loop:
+	b	reset_cpu_loop
+
+WDT_TGCR:
+	.word	0x01c21c24
+WDT_TIM12:
+	.word	0x01c21c10
+WDT_TIM34:
+	.word	0x01c21c14
+WDT_PRD12:
+	.word	0x01c21c18
+WDT_PRD34:
+	.word	0x01c21c1c
+WDT_TCR:
+	.word	0x01c21c20
+WDT_WDTCR:
+	.word	0x01c21c28
+WDTCR_VAL1:
+	.word	0xa5c64000
+WDTCR_VAL2:
+	.word	0xda7e4000
cpu/arm926ejs/da8xx/timer.c new file +0 -0
new file mode 100644
index 0000000..6a6f603

cpu/arm926ejs/da8xx/timer.c line 1

Quoted 1 line
cpu/arm926ejs/da8xx/timer.c new file +1 -0
@@ -0,0 +1,152 @@
+/*

This is very similar to the davinci/timer.c code. Can the da8xx cpu files be merged into davinci instead of creating a new cpu/* ?

The code changes are an improvement to davinci version.

Quoted 155 lines
cpu/arm926ejs/da8xx/timer.c new file +151 -0
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <[email protected]>
+ *
+ * Coding style changes. Use writel and readl for hardware accesses.
+ *
+ * (C) Copyright 2003
+ * Texas Instruments <www.ti.com>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <[email protected]>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <[email protected]>
+ *
+ * (C) Copyright 2002-2004
+ * Gary Jennejohn, DENX Software Engineering, <[email protected]>
+ *
+ * (C) Copyright 2004
+ * Philippe Robin, ARM Ltd. <[email protected]>
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[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
+ */
+
+#include <common.h>
+#include <asm/io.h>
+
+typedef struct {
+	u_int32_t	pid12;
+	u_int32_t	emumgt;
+	u_int32_t	na1;
+	u_int32_t	na2;
+	u_int32_t	tim12;
+	u_int32_t	tim34;
+	u_int32_t	prd12;
+	u_int32_t	prd34;
+	u_int32_t	tcr;
+	u_int32_t	tgcr;
+	u_int32_t	wdtcr;
+} davinci_timer;
+
+static davinci_timer * const timer = (davinci_timer *)CONFIG_SYS_TIMERBASE;
+
+#define TIMER_LOAD_VAL	(CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
+#define TIM_CLK_DIV	16
+
+static ulong timestamp;
+static ulong lastinc;
+
+int timer_init(void)
+{
+	/* We are using timer34 in unchained 32-bit mode, full speed */
+	writel(0x0, &timer->tcr);
+	writel(0x0, &timer->tgcr);
+	writel(0x06 | ((TIM_CLK_DIV - 1) << 8), &timer->tgcr);
+	writel(0x0, &timer->tim34);
+	writel(TIMER_LOAD_VAL, &timer->prd34);
+	lastinc = 0;
+	timestamp = 0;
+	writel(2 << 22, &timer->tcr);
+
+	return(0);
+}
+
+void reset_timer(void)
+{
+	writel(0x0, &timer->tcr);
+	writel(0x0, &timer->tim34);
+	lastinc = 0;
+	timestamp = 0;
+	writel(2 << 22, &timer->tcr);
+}
+
+static ulong get_timer_raw(void)
+{
+	ulong now = readl(&timer->tim34);
+
+	if (now >= lastinc) {
+		/* normal mode */
+		timestamp += now - lastinc;
+	} else {
+		/* overflow ... */
+		timestamp += now + TIMER_LOAD_VAL - lastinc;
+	}
+	lastinc = now;
+	return timestamp;
+}
+
+ulong get_timer(ulong base)
+{
+	return((get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base);
+}
+
+void set_timer(ulong t)
+{
+	timestamp = t;
+}
+
+void udelay(unsigned long usec)
+{
+	ulong tmo;
+	ulong endtime;
+	signed long diff;
+
+	tmo = CONFIG_SYS_HZ_CLOCK / 1000;
+	tmo *= usec;
+	tmo /= (1000 * TIM_CLK_DIV);
+
+	endtime = get_timer_raw() + tmo;
+
+	do {
+		ulong now = get_timer_raw();
+		diff = endtime - now;
+	} while (diff >= 0);
+}
+
+/*
+ * This function is derived from PowerPC code (read timebase as long long).
+ * On ARM it just returns the timer value.
+ */
+unsigned long long get_ticks(void)
+{
+	return(get_timer(0));
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	return CONFIG_SYS_HZ;
+}

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

#2 lore raw

PATCH v2 1/4 add TI DA8xx support: Add new directory for da8xx cpu functions

Quoted 16 lines
Quoted 10 lines · Nick Thompson

Add new directory for da8xx cpu functions.

Provides initial support for TI OMAP-L1x/DA8xx SoC devices. See http://www.ti.com

Provides:
Low level initialisation.
System clock API.
Timer control.
System reset.

Quoted 4 lines

It looks like this patch is duplicating much of what is already in arm926ejs/davinci. Unless there is a really good reason for a separate cpu dir, this patch should change to merge with davinci.

Tom,

There was a similar discussion in the Linux-Davinci ML when DA8xx was being added. Finally as things stand currently, we re use most of the stuff from DaVinci for DA8xx, i.e DM355,Dm365,DM6467,DM6446 and DA8xx are all considered DaVinci SOC's

If we do the same thing in U-Boot, then the DA8xx patches submitted will need re organization.

Quoted 501 lines
Quoted 11 lines

---
Applies to u-boot-ti

 cpu/arm926ejs/da8xx/Makefile        |   53 ++++++++++++
 cpu/arm926ejs/da8xx/clock.c         |   65 +++++++++++++++
 cpu/arm926ejs/da8xx/lowlevel_init.S |   71 ++++++++++++++++
 cpu/arm926ejs/da8xx/reset.S         |   75 +++++++++++++++++
 cpu/arm926ejs/da8xx/timer.c         |  152

+++++++++++++++++++++++++++++++++++

Quoted 44 lines
 5 files changed, 416 insertions(+), 0 deletions(-)
cpu/arm926ejs/da8xx/Makefile new file +35 -0
new file mode 100644
index 0000000..76fb7b8
@@ -0,0 +1,53 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2007 Sergey Kubushyn <[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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB        = $(obj)lib$(SOC).a
+
+COBJS      = timer.o clock.o
+SOBJS      = reset.o
+
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+SOBJS      += lowlevel_init.o
+endif

cpu/arm926ejs/da8xx/Makefile line 45

Quoted 10 lines
cpu/arm926ejs/da8xx/Makefile new file +10 -0
+
+SRCS       := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS       := $(addprefix $(obj),$(COBJS) $(SOBJS))
+START      := $(addprefix $(obj),$(START))
+
+all:       $(obj).depend $(LIB)
+
+$(LIB):    $(OBJS)
+   $(AR) $(ARFLAGS) $@ $(OBJS)
+

+#########################################################################

cpu/arm926ejs/da8xx/Makefile line 52

Quoted 7 lines
cpu/arm926ejs/da8xx/Makefile new file +6 -0
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+

+#########################################################################

cpu/arm926ejs/da8xx/clock.c line 2

Quoted 8 lines
cpu/arm926ejs/da8xx/clock.c new file +2 -0
new file mode 100644
index 0000000..e4606b8
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Nick Thompson, GE Fanuc Ltd.

<[email protected]>

cpu/arm926ejs/da8xx/clock.c

Quoted 4 lines
cpu/arm926ejs/da8xx/clock.c new file +4 -0
+ *
+ * Changed to use readl and writel instead of volatile pointers.
+ *
+ * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc.

<[email protected]>

Quoted 7 lines
cpu/arm926ejs/da8xx/clock.c new file +7 -0
+ *
+ * DA8xx clock module
+ *
+ * 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.

cpu/arm926ejs/da8xx/clock.c

Quoted 10 lines
cpu/arm926ejs/da8xx/clock.c new file +10 -0
+ *
+ * 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.
+ * --------------------------------------------------------------------

--------

Quoted 21 lines
cpu/arm926ejs/da8xx/clock.c new file +21 -0
+ */
+
+#include <common.h>
+#include <asm/arch/hardware.h>
+#include <asm/io.h>
+
+unsigned int sysdiv[9] = {
+   PLL0_DIV1, PLL0_DIV2, PLL0_DIV3, PLL0_DIV4,
+   PLL0_DIV5, PLL0_DIV6, PLL0_DIV7, PLL0_DIV8,
+   PLL0_DIV9
+};
+
+int clk_get(unsigned int id)
+{
+   int pre_div = (readl(PLL0_PREDIV) & 0xff) + 1;
+   int pllm = readl(PLL0_PLLM) + 1;
+   int post_div = (readl(PLL0_POSTDIV) & 0xff) + 1;
+   int pll_out = CONFIG_SYS_OSCIN_FREQ;
+
+   if (id == DAVINCI_AUXCLK_CLKID)
+           goto out;

cpu/arm926ejs/da8xx/clock.c line 54

Quoted 10 lines
cpu/arm926ejs/da8xx/clock.c new file +10 -0
+
+   /*
+    * Lets keep this simple. Combining operations can result in
+    * unexpected approximations
+    */
+   pll_out /= pre_div;
+   pll_out *= pllm;
+
+   if (id == DAVINCI_PLLM_CLKID)
+           goto out;

This define happens in patch #2.
To be bisectable, the order of the patches need to change.

Review

Quoted 12 lines
cpu/arm926ejs/da8xx/clock.c new file +11 -0
+
+   pll_out /= post_div;
+
+   if (id == DAVINCI_PLLC_CLKID)
+           goto out;
+
+   pll_out /= (readl(sysdiv[id - 1]) & 0xff) + 1;
+
+out:
+   return pll_out;
+}
(quoted diff) +0 -0

b/cpu/arm926ejs/da8xx/lowlevel_init.S

Quoted 82 lines

new file mode 100644
index 0000000..3bdc57c

cpu/arm926ejs/da8xx/lowlevel_init.S new file +71 -0
@@ -0,0 +1,71 @@
+/*
+ * Low-level board setup code for TI DA8xx SoC based boards.
+ *
+ * Copyright (C) 2008 Texas Instruments, Inc <www.ti.com>
+ * Sekhar Nori <[email protected]>
+ *
+ * Based on TI DaVinci low level init code. Original copyrights follow:
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[email protected]>
+ *
+ * Partially based on TI sources, original copyrights follow:
+ *
+ * Board specific setup info
+ *
+ * (C) Copyright 2003
+ * Texas Instruments, <www.ti.com>
+ * Kshitij Gupta <[email protected]>
+ *
+ * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
+ *
+ * Modified for OMAP 5912 OSK board by Rishi Bhattacharya, Apr 2004
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * Modified for DV-EVM board by Rishi Bhattacharya, Apr 2005
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * Modified for DV-EVM board by Swaminathan S, Nov 2005
+ * 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 <config.h>
+#include <asm/arch/hardware.h>
+
+.globl     lowlevel_init
+lowlevel_init:
+
+   /*
+    * Call board-specific lowlevel init.
+    * That MUST be present and THAT returns
+    * back to arch calling code with "mov pc, lr."
+    */
+   b       dv_board_init
+   nop
+
+.ltorg
+
+INTC_GLB_EN_ADDR:
+.word      INTC_GLB_EN
+INTC_EN_CLR0_ADDR:
+   .word   INTC_EN_CLR0
+INTC_HINT_EN_ADDR:
+   .word   INTC_HINT_EN
+
cpu/arm926ejs/da8xx/reset.S new file +0 -0
new file mode 100644
index 0000000..302b5b4

cpu/arm926ejs/da8xx/reset.S line 1

Quoted 1 line
cpu/arm926ejs/da8xx/reset.S new file +1 -0
@@ -0,0 +1,75 @@
+/*

This is very similar to the davinci/reset.S
Why can these not be combined ?

Quoted 39 lines
cpu/arm926ejs/da8xx/reset.S new file +39 -0
+ * Processor reset using WDT for TI TMS320DM644x SoC.
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+.globl reset_cpu
+reset_cpu:
+   ldr     r0, WDT_TGCR
+   mov     r1, $0x08
+   str     r1, [r0]
+   ldr     r1, [r0]
+   orr     r1, r1, $0x03
+   str     r1, [r0]
+   mov     r1, $0
+   ldr     r0, WDT_TIM12
+   str     r1, [r0]
+   ldr     r0, WDT_TIM34
+   str     r1, [r0]
+   ldr     r0, WDT_PRD12
+   str     r1, [r0]
+   ldr     r0, WDT_PRD34
+   str     r1, [r0]
+   ldr     r0, WDT_TCR
+   ldr     r1, [r0]

cpu/arm926ejs/da8xx/reset.S line 50

Quoted 10 lines
cpu/arm926ejs/da8xx/reset.S new file +10 -0
+   orr     r1, r1, $0x40
+   str     r1, [r0]
+   ldr     r0, WDT_WDTCR
+   ldr     r1, [r0]
+   orr     r1, r1, $0x4000
+   str     r1, [r0]
+   ldr     r1, WDTCR_VAL1
+   str     r1, [r0]
+   ldr     r1, WDTCR_VAL2
+   str     r1, [r0]

Please comment on these register settings.
Looks like watchdog setup..
Use the defines in arch-davinci/hardware.h

Why does this have to be in assembly?
Could this be moved to timer.c ?

Quoted 31 lines
cpu/arm926ejs/da8xx/reset.S new file +25 -0
+   nop
+   nop
+   nop
+   nop
+reset_cpu_loop:
+   b       reset_cpu_loop
+
+WDT_TGCR:
+   .word   0x01c21c24
+WDT_TIM12:
+   .word   0x01c21c10
+WDT_TIM34:
+   .word   0x01c21c14
+WDT_PRD12:
+   .word   0x01c21c18
+WDT_PRD34:
+   .word   0x01c21c1c
+WDT_TCR:
+   .word   0x01c21c20
+WDT_WDTCR:
+   .word   0x01c21c28
+WDTCR_VAL1:
+   .word   0xa5c64000
+WDTCR_VAL2:
+   .word   0xda7e4000
cpu/arm926ejs/da8xx/timer.c new file +0 -0
new file mode 100644
index 0000000..6a6f603

cpu/arm926ejs/da8xx/timer.c line 1

Quoted 1 line
cpu/arm926ejs/da8xx/timer.c new file +1 -0
@@ -0,0 +1,152 @@
+/*

This is very similar to the davinci/timer.c code. Can the da8xx cpu files be merged into davinci instead of creating a new cpu/* ?

The code changes are an improvement to davinci version.

cpu/arm926ejs/da8xx/timer.c line 2

Quoted 1 line
cpu/arm926ejs/da8xx/timer.c new file +1 -0
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd.

<[email protected]>

Quoted 49 lines
cpu/arm926ejs/da8xx/timer.c new file +49 -0
+ *
+ * Coding style changes. Use writel and readl for hardware accesses.
+ *
+ * (C) Copyright 2003
+ * Texas Instruments <www.ti.com>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <[email protected]>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <[email protected]>
+ *
+ * (C) Copyright 2002-2004
+ * Gary Jennejohn, DENX Software Engineering, <[email protected]>
+ *
+ * (C) Copyright 2004
+ * Philippe Robin, ARM Ltd. <[email protected]>
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <[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
+ */
+
+#include <common.h>
+#include <asm/io.h>
+
+typedef struct {
+   u_int32_t       pid12;
+   u_int32_t       emumgt;
+   u_int32_t       na1;
+   u_int32_t       na2;

cpu/arm926ejs/da8xx/timer.c

Quoted 10 lines
cpu/arm926ejs/da8xx/timer.c new file +10 -0
+   u_int32_t       tim12;
+   u_int32_t       tim34;
+   u_int32_t       prd12;
+   u_int32_t       prd34;
+   u_int32_t       tcr;
+   u_int32_t       tgcr;
+   u_int32_t       wdtcr;
+} davinci_timer;
+
+static davinci_timer * const timer = (davinci_timer

*)CONFIG_SYS_TIMERBASE;

Quoted 66 lines
cpu/arm926ejs/da8xx/timer.c new file +66 -0
+
+#define TIMER_LOAD_VAL     (CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
+#define TIM_CLK_DIV        16
+
+static ulong timestamp;
+static ulong lastinc;
+
+int timer_init(void)
+{
+   /* We are using timer34 in unchained 32-bit mode, full speed */
+   writel(0x0, &timer->tcr);
+   writel(0x0, &timer->tgcr);
+   writel(0x06 | ((TIM_CLK_DIV - 1) << 8), &timer->tgcr);
+   writel(0x0, &timer->tim34);
+   writel(TIMER_LOAD_VAL, &timer->prd34);
+   lastinc = 0;
+   timestamp = 0;
+   writel(2 << 22, &timer->tcr);
+
+   return(0);
+}
+
+void reset_timer(void)
+{
+   writel(0x0, &timer->tcr);
+   writel(0x0, &timer->tim34);
+   lastinc = 0;
+   timestamp = 0;
+   writel(2 << 22, &timer->tcr);
+}
+
+static ulong get_timer_raw(void)
+{
+   ulong now = readl(&timer->tim34);
+
+   if (now >= lastinc) {
+           /* normal mode */
+           timestamp += now - lastinc;
+   } else {
+           /* overflow ... */
+           timestamp += now + TIMER_LOAD_VAL - lastinc;
+   }
+   lastinc = now;
+   return timestamp;
+}
+
+ulong get_timer(ulong base)
+{
+   return((get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base);
+}
+
+void set_timer(ulong t)
+{
+   timestamp = t;
+}
+
+void udelay(unsigned long usec)
+{
+   ulong tmo;
+   ulong endtime;
+   signed long diff;
+
+   tmo = CONFIG_SYS_HZ_CLOCK / 1000;
+   tmo *= usec;
+   tmo /= (1000 * TIM_CLK_DIV);
+

cpu/arm926ejs/da8xx/timer.c

Quoted 10 lines
cpu/arm926ejs/da8xx/timer.c new file +10 -0
+   endtime = get_timer_raw() + tmo;
+
+   do {
+           ulong now = get_timer_raw();
+           diff = endtime - now;
+   } while (diff >= 0);
+}
+
+/*
+ * This function is derived from PowerPC code (read timebase as long

long).

cpu/arm926ejs/da8xx/timer.c

Quoted 9 lines
cpu/arm926ejs/da8xx/timer.c new file +9 -0
+ * On ARM it just returns the timer value.
+ */
+unsigned long long get_ticks(void)
+{
+   return(get_timer(0));
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock

frequency).

Quoted 10 lines
cpu/arm926ejs/da8xx/timer.c new file +6 -0
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+   return CONFIG_SYS_HZ;
+}

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

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

#3 lore raw

PATCH v2 1/4 add TI DA8xx support: Add new directory for da8xx cpu functions

Quoted 17 lines · Sandeep
Quoted 13 lines
Quoted 10 lines · Nick Thompson

Add new directory for da8xx cpu functions.

Provides initial support for TI OMAP-L1x/DA8xx SoC devices. See http://www.ti.com

Provides:
Low level initialisation.
System clock API.
Timer control.
System reset.

Quoted 4 lines

It looks like this patch is duplicating much of what is already in arm926ejs/davinci. Unless there is a really good reason for a separate cpu dir, this patch should change to merge with davinci.

Quoted 5 lines

Tom,

There was a similar discussion in the Linux-Davinci ML when DA8xx was being added. Finally as things stand currently, we re use most of the stuff from DaVinci for DA8xx, i.e DM355,Dm365,DM6467,DM6446 and DA8xx are all considered DaVinci SOC's

If we do the same thing in U-Boot, then the DA8xx patches submitted will need re organization.

Yes, I agree.

The more code I reviewed side-by-side with the u-boot davinci, the more this seems moving da8xx into davinci is the way to go. The big change is to get the memory map in hardware.h

The cleanups that Nick did for the common code should be used.

Tom

#4 lore raw

PATCH v2 1/4 add TI DA8xx support: Add new directory for da8xx cpu functions

In reply to Paulraj

Dear Sandeep,

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

It looks like this patch is duplicating much of what is already in arm926ejs/davinci. Unless there is a really good reason for a separate cpu dir, this patch should change to merge with davinci.

Tom,

There was a similar discussion in the Linux-Davinci ML when DA8xx was being added. Finally as things stand currently, we re use most of the stuff from DaVinci for DA8xx, i.e DM355,Dm365,DM6467,DM6446 and DA8xx are all considered DaVinci SOC's

Avoiding code duplication is definitely a good thing.

Quoted 1 line

If we do the same thing in U-Boot, then the DA8xx patches submitted will need re organization.

Please do this, then. I don't want to see the code duplicated without really good reasons.

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
"There is no statute of limitations on stupidity."
- Randomly produced by a computer program called Markov3.