All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] Add support for MINI2440 (s3c2440). Documentation about the product can be found on: http://www.friendlyarm.net/products/mini2440
Date: Fri, 20 Apr 2012 00:22:43 +0200	[thread overview]
Message-ID: <201204200022.43671.marex@denx.de> (raw)
In-Reply-To: <20120419210936.GA7679@debian>

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@elsoft.ch>
> > > > > + *
> > > > > + * (C) Copyright 2012
> > > > > + * Gabriel Huau <contact@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 ?

> 
> > > > > 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@sysgo.de>
> > > > > + *
> > > > > + * (C) Copyright 2002
> > > > > + * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
> > > > > + *
> > > > > + * (C) Copyright 2009
> > > > > + * Michel Pollet <buserror@gmail.com>
> > > > > + *
> > > > > + * (C) Copyright 2012
> > > > > + * Gabriel Huau <contact@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

...

  reply	other threads:[~2012-04-19 22:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 17:46 [U-Boot] Add support for Mini2440 Gabriel Huau
2012-04-17 20:09 ` [U-Boot] [PATCH V2] " Gabriel Huau
     [not found]   ` <1334694802-4881-1-git-send-email-contact@huau-gabriel.fr>
2012-04-17 20:45     ` [U-Boot] [PATCH v2] Add support for MINI2440 (s3c2440). Documentation about the product can be found on: http://www.friendlyarm.net/products/mini2440 Marek Vasut
2012-04-19 19:25 ` [U-Boot] [PATCH v3] " Gabriel Huau
2012-04-19 20:08   ` Marek Vasut
2012-04-19 20:16     ` Gabriel Huau
2012-04-19 20:45       ` Marek Vasut
2012-04-19 21:33         ` Gabriel Huau
2012-04-19 22:22           ` Marek Vasut [this message]
2012-04-20  7:19             ` Ilya Averyanov
2012-04-20  9:11               ` Marek Vasut
2012-04-20 13:35                 ` Ilya Averyanov
2012-04-20 14:08                   ` Marek Vasut
2012-04-20 14:30                     ` Ilya Averyanov
2012-04-20 14:35                       ` Ilya Averyanov
2012-04-20 16:17                         ` Marek Vasut
2012-04-20 17:17                           ` Ilya Averyanov
2012-04-20 19:11                             ` Marek Vasut
2012-04-23 20:36                             ` Wolfgang Denk
2012-04-20 19:18                           ` Vasily Khoruzhick
2012-04-20 20:03                             ` Marek Vasut
2012-04-20 22:51                               ` Ilya Averyanov
2012-04-20 23:07                                 ` Marek Vasut
2012-04-21  7:35                                   ` Vasily Khoruzhick
2012-04-23 20:43                                     ` Wolfgang Denk
2012-04-20 23:30                                 ` [U-Boot] [PATCH v3] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-21  4:09                                   ` Ilya Averyanov
2012-04-21  9:00                                   ` Vasily Khoruzhick
2012-04-21  7:42                                 ` [U-Boot] [PATCH v3] Add support for MINI2440 (s3c2440). Documentation about the product can be found on: http://www.friendlyarm.net/products/mini2440 Vasily Khoruzhick
2012-04-21 10:39                                   ` Marek Vasut
2012-04-21 12:33                                   ` Ilya Averyanov
2012-04-21 13:19                                     ` Marek Vasut
2012-04-23 13:40                                       ` Ilya Averyanov
2012-04-23 14:07                                         ` Marek Vasut
2012-04-23 14:27                                           ` Ilya Averyanov
2012-04-23 15:25                                             ` Marek Vasut
2012-04-23 20:39                             ` Wolfgang Denk
2012-04-20 16:16                       ` Marek Vasut
2012-04-19 21:37         ` Ilya Averyanov
2012-04-19 22:23           ` Marek Vasut
2012-04-19 22:30             ` Graeme Russ
2012-04-19 22:22   ` Graeme Russ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201204200022.43671.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.