All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Pietrek <mpietrek@fsforth.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Patch for NAND Booting on SMDK2410
Date: Wed, 14 Jan 2004 09:20:37 +0100	[thread overview]
Message-ID: <200401140920.37883.mpietrek@fsforth.de> (raw)
In-Reply-To: <002501c3d6cb$022c7900$c922a8c0@Invocon.com>

Hi,

> I've taken a look at your patch and board/smdk2410/nandboot.S appears to
> be missing.  Was it your intention to add this file, have I missed
> something from earlier on in the list, or will I need to create this
> myself?

Oops, sorry. As this file didn't exist originally, my "cvs diff -c -D" must 
have skipped this file. Here it is.

Bye,
-- 
Markus Pietrek
FS Forth-Systeme GmbH
Phone: +49 (7667) 908 145,  FAX +49 (7667) 908 221

-------------- next part --------------
/***********************************************************************
 *
 *  Copyright (C) 2003 by FS Forth-Systeme GmbH.
 *  All rights reserved.
 *	
 *  @Author: Markus Pietrek
 *  @Descr: Supports only 512 bytes media with no bad-block management
 *  @References: [1] S3C2410X User's Manual Rev. 1
 *	         [2] Toshiba's NAND Flash Applications Design Guide Rev. 1.0
 * 	         [3] vivi/arch/s3c2420/head.S, Rev. 1.18 (initialization)
 *
 * 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>

#ifdef CONFIG_BOOT_NAND	
.globl _nandboot

/***********************************************************************
 * @Function: _nandboot (unsigned int unStartBlock,
 *			  unsigned int* punDest, unsigned int unLength)
 * @Return: always, no error handling
 * @Descr: copies blocks from NAND to RAM (punDest) until unLength data has been
 *	   read. unStartBlock
 ***********************************************************************/

#define rNF_BASE	(0x4e000000)
#define	oNF_CONF	(0x00)
#define	oNF_CMD		(0x04)
#define oNF_ADDR	(0x08)
#define oNF_DATA	(0x0c)
#define oNF_STAT	(0x10)
#define oNF_ECC		(0x14)

#define vNF_CONF_RESET  (0xf830) /* NAND Controller enable, enable chip,
	                            TWRPH0 = 3 */ 			
_nandboot:
	ldr	r6, =0x200              @ page size
	
	mov	r3, #rNF_BASE           @ reset NAND Controller
	ldr	r4, =vNF_CONF_RESET
	str	r4, [r3, #oNF_CONF]
	
	ldr	r4, [r3, #oNF_CONF]
	bic	r4, r4, #0x800	        @ enable chip	
	str	r4, [r3, #oNF_CONF]
	
	mov	r4, #0xff		@ send reset to NAND
	strb	r4, [r3, #oNF_CMD]

	mov	r4, #0			@ wait 
1:	add	r4, r4, #0x1
	cmp	r4, #0xa
	blt	1b
	
2:	ldr	r4, [r3, #oNF_STAT]	@ wait ready
	tst	r4, #0x1
	beq	2b
	
	ldr	r4, [r3, #oNF_CONF]
	orr	r4, r4, #0x800		@ disable chip
	str	r4, [r3, #oNF_CONF]

_nandboot_read_page:	
	@ read one page
	ldr	r4, [r3, #oNF_CONF]
	bic	r4, r4, #0x800		@ enable chip
	str	r4, [r3, #oNF_CONF]

	mov	r4, #0			@ wait 
4:
	add	r4, r4, #0x1
	cmp	r4, #0xa
	blt	4b

	mov	r4, #0x0		@ READ0
	strb	r4, [r3, #oNF_CMD]

	mov	r4, r0		        @ ADDR
	strb	r4, [r3, #oNF_ADDR]
  	mov	r4, r4, lsr #9
	strb	r4, [r3, #oNF_ADDR]
  	mov	r4, r4, lsr #9
	strb	r4, [r3, #oNF_ADDR]
  	mov	r4, r4, lsr #9
	strb	r4, [r3, #oNF_ADDR]

5:
	ldr	r4, [r3, #oNF_STAT]     @ wait idle
	tst	r4, #0x1
	beq	5b

	@ copy at max 512 bytes
	@ r2 is number of bytes overall left after this copy
	@ r5 is number in page left
	cmp	r2, r6
	subge	r2, r2, r6
	movge	r5, r6
	movlt	r5, r2
	movlt	r2, #0

_nandboot_page_copy_to_mem:
	@ copy page to memory
	cmp	r5, #0
	beq	7f
	sub	r5, r5, #1

	ldrb	r4, [r3, #oNF_DATA]
	strb	r4, [r1], #1
	b	_nandboot_page_copy_to_mem
				
7:	
	ldr	r4, [r3, #oNF_CONF]
	orr	r4, r4, #0x800		@ disable chip
	str	r4, [r3, #oNF_CONF]

	cmp	r2, #0
	addne	r0, r0, r6          @ select next page
	bne	_nandboot_read_page

	@ finished, all bytes read
	mov	r4, #0
	str	r4, [r3, #oNF_CONF]     @ disable NAND Controller

	mov	pc, lr	
#endif /* CONFIG_BOOT_NAND */

  reply	other threads:[~2004-01-14  8:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-09 14:18 [U-Boot-Users] Patch for NAND Booting on SMDK2410 Markus Pietrek
2004-01-09 16:09 ` Matt Matoushek
2004-01-14  8:20   ` Markus Pietrek [this message]
2004-01-14 14:09     ` Matt Matoushek
2004-01-15  8:48       ` Markus Pietrek
2004-02-08 20:16 ` Wolfgang Denk

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=200401140920.37883.mpietrek@fsforth.de \
    --to=mpietrek@fsforth.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.