All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Add support for the digsy MTC board.
Date: Thu, 12 Feb 2009 10:49:57 +0100	[thread overview]
Message-ID: <200902121049.57501.sr@denx.de> (raw)
In-Reply-To: <1234430475528-git-send-email-gjb@semihalf.com>

On Thursday 12 February 2009, Grzegorz Bernacki wrote:
> This is the InterControl custom device based on the MPC5200B chip.
>
> Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>

Please find some comments below.

> diff --git a/board/digsy_mtc/digsy_mtc.c b/board/digsy_mtc/digsy_mtc.c
> new file mode 100644
> index 0000000..0cde8a8
> --- /dev/null
> +++ b/board/digsy_mtc/digsy_mtc.c
> @@ -0,0 +1,333 @@
> +/*
> + * (C) Copyright 2003
> + * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> + *
> + * (C) Copyright 2004
> + * Mark Jonas, Freescale Semiconductor, mark.jonas at motorola.com.
> + *
> + * (C) Copyright 2005-2009
> + * Modified for InterControl digsyMTC MPC5200 board by
> + * Frank Bodammer, GCD Hard- & Software GmbH,
> + *                 frank.bodammer at gcd-solutions.de
> + *
> + * (C) Copyright 2009
> + * Grzegorz Bernacki, Semihalf, gjb at semihalf.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 <mpc5xxx.h>
> +#include <pci.h>
> +#include <asm/processor.h>
> +#include <i2c.h>
> +#include "eeprom.h"
> +#include "is42s16800a-7t.h"
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +extern int usb_cpu_init(void);
> +
> +#ifndef CONFIG_SYS_RAMBOOT
> +static void sdram_start(int hi_addr)
> +{
> +	long hi_addr_bit = hi_addr ? 0x01000000 : 0;
> +	long control = SDRAM_CONTROL | hi_addr_bit;
> +
> +	/* unlock mode register */
> +	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000000);

Please use the out_be32()/in_be32() accessor functions for accessing SoC 
perepherals instead. They have the io-barriers included. You could git into 
trouble by "just" using out/in32(). This is a general comment meant for the 
complete patch.

> +
> +	/* precharge all banks */
> +	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000002);
> +
> +	/* auto refresh */
> +	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000004);
> +
> +	/* set mode register */
> +	out32(MPC5XXX_SDRAM_MODE, SDRAM_MODE);
> +
> +	/* normal operation */
> +	out32(MPC5XXX_SDRAM_CTRL, control);
> +}
> +#endif
> +
> +/*
> + * ATTENTION: Although partially referenced initdram does NOT make real
> use + *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if
> + *            CONFIG_SYS_SDRAM_BASE is something else than 0x00000000. +
> */
> +
> +phys_size_t initdram(int board_type)
> +{
> +	ulong dramsize = 0;
> +	ulong dramsize2 = 0;
> +	uint svr, pvr;
> +#ifndef CONFIG_SYS_RAMBOOT
> +	ulong test1, test2;
> +
> +	/* setup SDRAM chip selects */
> +	out32(MPC5XXX_SDRAM_CS0CFG, 0x0000001C);	/* 512MB at 0x0 */
> +	out32(MPC5XXX_SDRAM_CS1CFG, 0x80000000);	/* disabled */
> +
> +	/* setup config registers */
> +	out32(MPC5XXX_SDRAM_CONFIG1, SDRAM_CONFIG1);
> +	out32(MPC5XXX_SDRAM_CONFIG2, SDRAM_CONFIG2);
> +
> +	/* find RAM size using SDRAM CS0 only */
> +	sdram_start(0);
> +	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
> +	sdram_start(1);
> +	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
> +	if (test1 > test2) {
> +		sdram_start(0);
> +		dramsize = test1;
> +	} else {
> +		dramsize = test2;
> +	}
> +
> +	/* memory smaller than 1MB is impossible */
> +	if (dramsize < (1 << 20)) {
> +		dramsize = 0;
> +	}

Nitpicking: Remove the curly braces for single-line statements.

> +
> +	/* set SDRAM CS0 size according to the amount of RAM found */
> +	if (dramsize > 0) {
> +		out32(MPC5XXX_SDRAM_CS0CFG,
> +			(0x13 + __builtin_ffs(dramsize >> 20) - 1));
> +	} else {
> +		out32(MPC5XXX_SDRAM_CS0CFG, 0); /* disabled */
> +	}
> +
> +	/* let SDRAM CS1 start right after CS0 */
> +	out32(MPC5XXX_SDRAM_CS1CFG, dramsize + 0x0000001C); /* 512MB */
> +
> +	/* find RAM size using SDRAM CS1 only */
> +	test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
> +			0x08000000);
> +		dramsize2 = test1;
> +
> +	/* memory smaller than 1MB is impossible */
> +	if (dramsize2 < (1 << 20)) {
> +		dramsize2 = 0;
> +	}

Again. Not curly braces here.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

  reply	other threads:[~2009-02-12  9:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12  9:21 [U-Boot] [PATCH] Add support for the digsy MTC board Grzegorz Bernacki
2009-02-12  9:49 ` Stefan Roese [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-01-28 15:07 Grzegorz Bernacki
2009-01-28 21:05 ` Wolfgang Denk
2009-01-29  8:56   ` Grzegorz Bernacki
2009-01-29 10:52     ` Wolfgang Denk
2009-01-29 11:09       ` Grzegorz Bernacki
2009-01-29 12:51       ` Jerry Van Baren
2009-02-03 10:05   ` Grzegorz Bernacki

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=200902121049.57501.sr@denx.de \
    --to=sr@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.