[U-Boot] [PATCH v3] Add support for MINI2440 (s3c2440). Documentation about the product can be found on: http://www.friendlyarm.net/products/mini2440

Ilya Averyanov averyanovin+uboot at gmail.com
Fri Apr 20 09:19:35 CEST 2012


2012/4/20 Marek Vasut <marex at denx.de>

> Dear Gabriel Huau,
>
> > On Thu, Apr 19, 2012 at 10:45:21PM +0200, Marek Vasut wrote:
> > > Dear Gabriel Huau,
> > >
> > > > On Thu, Apr 19, 2012 at 10:08:47PM +0200, Marek Vasut wrote:
> > > > > Dear Gabriel Huau,
> > > > >
> > > > > > ---
> > > > > >
> > > > > > Changes for v2:
> > > > > >       - Coding style cleanup
> > > > > >       - Remove unnecessary files modification
> > > > > >       - Remove unnecessary board configuration set
> > > > > >
> > > > > > Changes for v3:
> > > > > >       - Coding style cleanup
> > > > > >       - Move some macro definition from lowlevel_init.S
> > > > > >       to a new header
> > > > > >       - Remove some "magic bloat" with I/O board initialization
> > > > > >       - Add a pll_delay and replace loop by it
> > > > > >       - Somme cleanup in the configuration file
> > > > > >       - Cancel modifications on an SoC specific header
> > > > > >       - Add my name to copyright
> > > > > >
> > > > > > ---
> > > > > >
> > > > > >  board/friendlyarm/mini2440/Makefile        |   45 ++++++
> > > > > >  board/friendlyarm/mini2440/lowlevel_init.S |   76 ++++++++++
> > > > > >  board/friendlyarm/mini2440/mini2440.c      |  139
> > > > > >  ++++++++++++++++++ board/friendlyarm/mini2440/mini2440.h      |
> > > > > >  104 ++++++++++++++ boards.cfg                                 |
> > > > > >   1 +
> > > > > >  include/configs/mini2440.h                 |  215
> > > > > >
> > > > > > ++++++++++++++++++++++++++++ 6 files changed, 580 insertions(+)
> > > > > >
> > > > > >  create mode 100644 board/friendlyarm/mini2440/Makefile
> > > > > >  create mode 100644 board/friendlyarm/mini2440/lowlevel_init.S
> > > > > >  create mode 100644 board/friendlyarm/mini2440/mini2440.c
> > > > > >  create mode 100644 board/friendlyarm/mini2440/mini2440.h
> > > > > >  create mode 100644 include/configs/mini2440.h
> > > > > >
> > > > > > diff --git a/board/friendlyarm/mini2440/Makefile
> > > > > > b/board/friendlyarm/mini2440/Makefile new file mode 100644
> > > > > > index 0000000..e8d68cb
> > > > > > --- /dev/null
> > > > > > +++ b/board/friendlyarm/mini2440/Makefile
> > > > > > @@ -0,0 +1,45 @@
> > > > > > +#
> > > > > > +# (C) Copyright 2012
> > > > > > +# 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$(BOARD).o
> > > > > > +
> > > > > > +COBJS        := mini2440.o
> > > > > > +SOBJS        := lowlevel_init.o
> > > > > > +
> > > > > > +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
> > > > > > +OBJS := $(addprefix $(obj),$(COBJS))
> > > > > > +SOBJS        := $(addprefix $(obj),$(SOBJS))
> > > > > > +
> > > > > > +$(LIB):      $(obj).depend $(OBJS) $(SOBJS)
> > > > > > +     $(call cmd_link_o_target, $(OBJS) $(SOBJS))
> > > > > > +
> > > > > >
> +##################################################################
> > > > > > #### ### +
> > > > > > +# defines $(obj).depend target
> > > > > > +include $(SRCTREE)/rules.mk
> > > > > > +
> > > > > > +sinclude $(obj).depend
> > > > > > +
> > > > > >
> +##################################################################
> > > > > > #### ### diff --git a/board/friendlyarm/mini2440/lowlevel_init.S
> > > > > > b/board/friendlyarm/mini2440/lowlevel_init.S new file mode 100644
> > > > > > index 0000000..f69a08c
> > > > > > --- /dev/null
> > > > > > +++ b/board/friendlyarm/mini2440/lowlevel_init.S
> > > > > > @@ -0,0 +1,76 @@
> > > > > > +/*
> > > > > > + * Memory Setup stuff - taken from blob memsetup.S
> > > > > > + *
> > > > > > + * Copyright (C) 1999 2000 2001 Erik Mouw
> > > > > > (J.A.K.Mouw at its.tudelft.nl) and + *                     Jan-Derk
> > > > > > Bakker
> > > > > > (J.D.Bakker at its.tudelft.nl) + *
> > > > > > + * Modified for the Samsung SMDK2410 by
> > > > > > + * (C) Copyright 2002
> > > > > > + * David Mueller, ELSOFT AG, <d.mueller at elsoft.ch>
> > > > > > + *
> > > > > > + * (C) Copyright 2012
> > > > > > + * Gabriel Huau <contact at huau-gabriel.fr>
> > > > > > + *
> > > > > > + * 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 <version.h>
> > > > > > +#include "mini2440.h"
> > > > > > +
> > > > > > +_TEXT_BASE:
> > > > > > +     .word   CONFIG_SYS_TEXT_BASE
> > > > > > +
> > > > > > +.globl lowlevel_init
> > > > > > +lowlevel_init:
> > > > > > +     /* memory control configuration */
> > > > > > +     /* make r0 relative the current location so that it */
> > > > > > +     /* reads SMRDATA out of FLASH rather than memory ! */
> > > > > > +     ldr     r0, =SMRDATA
> > > > > > +     ldr     r1, _TEXT_BASE
> > > > > > +     sub     r0, r0, r1
> > > > > > +     ldr     r1, =BWSCON     /* Bus Width Status Controller */
> > > > > > +     add     r2, r0, #13*4
> > > > > > +0:
> > > > > > +     ldr     r3, [r0], #4
> > > > > > +     str     r3, [r1], #4
> > > > > > +     cmp     r2, r0
> > > > > > +     bne     0b
> > > > > > +
> > > > > > +     /* everything is fine now */
> > > > > > +     mov     pc, lr
> > > > > > +
> > > > > > +     .ltorg
> > > > > > +/* the literal pools origin */
> > > > > > +
> > > > > > +SMRDATA:
> > > > > > +    .word
> > > > > >
> (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B
> > > > > > 5_BW SCO N<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28)) +    .word
> > > > > >
> ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+
> > > > > > (B0_ Tac p<<2)+(B0_PMC)) +    .word
> > > > > >
> ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+
> > > > > > (B1_ Tac p<<2)+(B1_PMC)) +    .word
> > > > > >
> ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+
> > > > > > (B2_ Tac p<<2)+(B2_PMC)) +    .word
> > > > > >
> ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+
> > > > > > (B3_ Tac p<<2)+(B3_PMC)) +    .word
> > > > > >
> ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+
> > > > > > (B4_ Tac p<<2)+(B4_PMC)) +    .word
> > > > > >
> ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+
> > > > > > (B5_ Tac p<<2)+(B5_PMC)) +
> > > > > > +    .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))
> > > > > > +    .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))
> > > > > > +    .word
> > > > > > ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
> +
> > > > > > .word 0x32
> > > > > > +    .word 0x30
> > > > > > +    .word 0x30
> > > > >
> > > > > What this undocumented stuff?
> > > >
> > > > SoC specific, I pasted it from smdk2410, it's for initialize the
> DRAM.
> > >
> > > Can't you init DRAM in some more fitting place? Also document this?
> >
> > I don't know, this part is a bit difficult for me, but I'm going to try
> > to document it with the help of the SoC documentation.
> >
> > For the place, should I move it to mini2440.c in arch_cpu_init() or
> > board_early_init_f() ? I don't really know the difference.
>
> dram_init() maybe ?
>
You propose to initialize the SDRAM controller in dram_init ()?

>
> >
> > > > > > diff --git a/board/friendlyarm/mini2440/mini2440.c
> > > > > > b/board/friendlyarm/mini2440/mini2440.c new file mode 100644
> > > > > > index 0000000..9ba8d39
> > > > > > --- /dev/null
> > > > > > +++ b/board/friendlyarm/mini2440/mini2440.c
> > > > > > @@ -0,0 +1,139 @@
> > > > > > +/*
> > > > > > + * (C) Copyright 2002
> > > > > > + * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
> > > > > > + * Marius Groeger <mgroeger at sysgo.de>
> > > > > > + *
> > > > > > + * (C) Copyright 2002
> > > > > > + * David Mueller, ELSOFT AG, <d.mueller at elsoft.ch>
> > > > > > + *
> > > > > > + * (C) Copyright 2009
> > > > > > + * Michel Pollet <buserror at gmail.com>
> > > > > > + *
> > > > > > + * (C) Copyright 2012
> > > > > > + * Gabriel Huau <contact at huau-gabriel.fr>
> > > > > > + *
> > > > > > + * 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/arch/s3c2440.h>
> > > > > > +#include <asm/io.h>
> > > > > > +#include <video_fb.h>
> > > > > > +#include "mini2440.h"
> > > > > > +
> > > > > > +#ifdef CONFIG_DRIVER_DM9000
> > > > > > +#include <netdev.h>
> > > > > > +#endif
> > > > > > +
> > > > > > +DECLARE_GLOBAL_DATA_PTR;
> > > > > > +
> > > > > > +static inline void pll_delay(unsigned long loops)
> > > > > > +{
> > > > > > +     __asm__ volatile ("1:\n"
> > > > > > +       "subs %0, %1, #1\n"
> > > > > > +       "bne 1b" : "=r" (loops) : "0" (loops));
> > > > > > +}
> > > > > > +
> > > > > > +int arch_cpu_init(void)
> > > > > > +{
> > > > > > +     struct s3c24x0_clock_power * const clk_power =
> > > > > > +
> s3c24x0_get_base_clock_power();
> > > > > > +
> > > > > > +     /* to reduce PLL lock time, adjust the LOCKTIME register */
> > > > > > +     clk_power->locktime = 0xFFFFFF;
> > > > > > +     clk_power->clkdivn = CLKDIVN_VAL;
> > > > > > +
> > > > > > +     /* configure UPLL */
> > > > > > +     clk_power->upllcon = ((U_M_MDIV << 12) + (U_M_PDIV << 4) +
> > > > > > U_M_SDIV); +  /* some delay between MPLL and UPLL */
> > > > > > +     pll_delay(100000);
> > > > > > +
> > > > > > +     /* configure MPLL */
> > > > > > +     clk_power->mpllcon = ((M_MDIV << 12) + (M_PDIV << 4) +
> M_SDIV);
> > > > > > +
> > > > > > +     /* some delay between MPLL and UPLL */
> > > > > > +     pll_delay(500000);
> > > > >
> > > > > You use udelay() below, do you need pll_delay() at all?
> > > >
> > > > Yes, because initialisation of PLL is done before timer_init(), so we
> > > > can't use udelay().
> > >
> > > Maybe fix the timer driver?
> >
> > As PLL initialization is SoC specific, should I move it to
> > arch/arch/cpu/arm920t/s3c24x0/timer.c in timer_init() ?
>
> Yes
>
> > With this modification, I will have to patch all board based
> > on s3c24x0, because they are all using this "hack". Should this
> > modification be part of another patch ? (for me, yes ...)
>
> Yes
>
> ...
> _______________________________________________
> 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