[U-Boot] [PATCH v2 1/4] add TI DA8xx support: Add new directory for da8xx cpu functions

Paulraj, Sandeep s-paulraj at ti.com
Sun Oct 25 00:48:27 CEST 2009



>
> Nick Thompson wrote:
> > 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.
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.

>
> >
> > Signed-off-by: Nick Thompson <nick.thompson at gefanuc.com>
> > ---
> > 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(-)
> >
> > diff --git a/cpu/arm926ejs/da8xx/Makefile b/cpu/arm926ejs/da8xx/Makefile
> > new file mode 100644
> > index 0000000..76fb7b8
> > --- /dev/null
> > +++ b/cpu/arm926ejs/da8xx/Makefile
> > @@ -0,0 +1,53 @@
> > +#
> > +# (C) Copyright 2000-2006
> > +# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> > +#
> > +# Copyright (C) 2007 Sergey Kubushyn <ksi at koi8.net>
> > +#
> > +# 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
> > +
> >
> +#########################################################################
> > diff --git a/cpu/arm926ejs/da8xx/clock.c b/cpu/arm926ejs/da8xx/clock.c
> > new file mode 100644
> > index 0000000..e4606b8
> > --- /dev/null
> > +++ b/cpu/arm926ejs/da8xx/clock.c
> > @@ -0,0 +1,65 @@
> > +/*
> > + * Copyright (C) 2008 Nick Thompson, GE Fanuc Ltd.
> <nick.thompson at gefanuc.com>
> > + *
> > + * Changed to use readl and writel instead of volatile pointers.
> > + *
> > + * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc.
> <nsekhar at ti.com>
> > + *
> > + * 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;
> > +
> > +   /*
> > +    * 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.
>
> > +
> > +   pll_out /= post_div;
> > +
> > +   if (id == DAVINCI_PLLC_CLKID)
> > +           goto out;
> > +
> > +   pll_out /= (readl(sysdiv[id - 1]) & 0xff) + 1;
> > +
> > +out:
> > +   return pll_out;
> > +}
> > diff --git a/cpu/arm926ejs/da8xx/lowlevel_init.S
> b/cpu/arm926ejs/da8xx/lowlevel_init.S
> > new file mode 100644
> > index 0000000..3bdc57c
> > --- /dev/null
> > +++ b/cpu/arm926ejs/da8xx/lowlevel_init.S
> > @@ -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 <nsekhar at ti.com>
> > + *
> > + * Based on TI DaVinci low level init code. Original copyrights follow:
> > + *
> > + * Copyright (C) 2007 Sergey Kubushyn <ksi at koi8.net>
> > + *
> > + * Partially based on TI sources, original copyrights follow:
> > + *
> > + * Board specific setup info
> > + *
> > + * (C) Copyright 2003
> > + * Texas Instruments, <www.ti.com>
> > + * Kshitij Gupta <Kshitij at ti.com>
> > + *
> > + * 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
> > +
> > diff --git a/cpu/arm926ejs/da8xx/reset.S b/cpu/arm926ejs/da8xx/reset.S
> > new file mode 100644
> > index 0000000..302b5b4
> > --- /dev/null
> > +++ b/cpu/arm926ejs/da8xx/reset.S
> > @@ -0,0 +1,75 @@
> > +/*
>
> This is very similar to the davinci/reset.S
> Why can these not be combined ?
>
> > + * Processor reset using WDT for TI TMS320DM644x SoC.
> > + *
> > + * Copyright (C) 2007 Sergey Kubushyn <ksi at koi8.net>
> > + *
> > + * 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]
> > +   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 ?
>
> > +   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
> > diff --git a/cpu/arm926ejs/da8xx/timer.c b/cpu/arm926ejs/da8xx/timer.c
> > new file mode 100644
> > index 0000000..6a6f603
> > --- /dev/null
> > +++ b/cpu/arm926ejs/da8xx/timer.c
> > @@ -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.
>
> > + * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd.
> <nick.thompson at gefanuc.com>
> > + *
> > + * 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 <mgroeger at sysgo.de>
> > + *
> > + * (C) Copyright 2002
> > + * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
> > + * Alex Zuepke <azu at sysgo.de>
> > + *
> > + * (C) Copyright 2002-2004
> > + * Gary Jennejohn, DENX Software Engineering, <gj at denx.de>
> > + *
> > + * (C) Copyright 2004
> > + * Philippe Robin, ARM Ltd. <philippe.robin at arm.com>
> > + *
> > + * Copyright (C) 2007 Sergey Kubushyn <ksi at koi8.net>
> > + *
> > + * 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
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



More information about the U-Boot mailing list