From patchwork Thu Apr 7 12:45:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 90169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A1E94B6F44 for ; Thu, 7 Apr 2011 22:39:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 334E0280C2; Thu, 7 Apr 2011 14:39:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KOFD61I+rDVw; Thu, 7 Apr 2011 14:39:46 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8B20728091; Thu, 7 Apr 2011 14:39:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 317E928086 for ; Thu, 7 Apr 2011 14:39:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z3uhdMWPaPyC for ; Thu, 7 Apr 2011 14:39:29 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from clanlab.dyndns.org (unknown [140.119.175.157]) by theia.denx.de (Postfix) with ESMTPS id 08C4528084 for ; Thu, 7 Apr 2011 14:39:26 +0200 (CEST) Received: by clanlab.dyndns.org (Postfix, from userid 1000) id E04B138B46A6; Thu, 7 Apr 2011 20:45:38 +0800 (CST) From: Macpaul Lin To: u-boot@lists.denx.de, ratbert@faraday-tech.com, wd@denx.de Date: Thu, 7 Apr 2011 20:45:28 +0800 Message-Id: <1302180333-25372-5-git-send-email-macpaul@andestech.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1302180333-25372-1-git-send-email-macpaul@andestech.com> References: <1302180333-25372-1-git-send-email-macpaul@andestech.com> Cc: Macpaul Lin Subject: [U-Boot] [PATCH v7 05/10] nds32/ag101: lowlevel_init.S of ag101 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de lowlevel_init.S is a peripheral initial procedure of ag101. It configures onboard dram, clock, and power settings. It also prepars the dram environment before moving u-boot from rom and flash into dram. This version of lowlevel_init.S also replace hardcode value by MARCO defines from the GPL version andesboot for better code quality. Signed-off-by: Macpaul Lin --- ChangeLog from v1-v4: - Code clean up and formatting style. ChangeLog from v5-v6 - Change hard code value into MARCO definitions. - ftsmc010 - Fix FTSMC020_TPR_AT2 from 1 to 3 (0xff3ff) - ftsdmc021 - Fix hardcoded address of CR1, CR2, TR1, TR2, BANK0 registers. - Fix the default configuration value of FTSDMC and FTSMC controller. - Remove some ftpmu010 and flash probe code to C functions. arch/nds32/cpu/n1213/ag101/lowlevel_init.S | 160 ++++++++++++++++++++++++++++ 1 files changed, 160 insertions(+), 0 deletions(-) create mode 100644 arch/nds32/cpu/n1213/ag101/lowlevel_init.S diff --git a/arch/nds32/cpu/n1213/ag101/lowlevel_init.S b/arch/nds32/cpu/n1213/ag101/lowlevel_init.S new file mode 100644 index 0000000..96969ba --- /dev/null +++ b/arch/nds32/cpu/n1213/ag101/lowlevel_init.S @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2011 Andes Technology Corporation + * Shawn Lin, Andes Technology Corporation + * Macpaul Lin, Andes Technology Corporation + * + * 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 + */ + +.text + +#include +#include + +#ifndef CONFIG_SKIP_LOWLEVEL_INIT +.globl lowlevel_init +lowlevel_init: + move $r10, $lp + jal mem_init + jal remap + + ret $r10 + +mem_init: + move $r11, $lp + + /* + * mem_init: + * There are 2 bank connected to FTSMC020 on AG101 + * BANK0: FLASH/ROM (SW5, J16), BANK1: OnBoard SDRAM. + * we need to set onboard SDRAM before remap and relocation. + */ + li $r0, (CONFIG_FTSMC020_BASE+FTSMC020_BANK0_CR) + li $r1, (FTSMC020_BANK1_CONFIG) ! 0x10000052 + swi $r1, [$r0] + li $r1, (FTSMC020_BANK1_TIMING) ! 0x00151151 + swi $r1, [$r0+FTSMC020_BANK0_TPR] + + /* + * config AHB Controller + */ + li $r0, (CONFIG_FTAHBC020S_BASE + FTAHBC020S_SLAVE_BSR_6) + li $r1, (CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6) + swi $r1, [$r0] + + /* + * config PMU + */ + li $r0, (CONFIG_FTPMU010_BASE + FTPMU010_PDLLCR0) + lwi $r1, [$r0] + ! ftpmu010_dlldis_disable, must do it in lowleve_init + li $r2, FTPMU010_PDLLCR0_DLLDIS ! 0x00010000 + or $r1, $r1, $r2 + swi $r1, [$r0] + + /* + * config SDRAM controller + */ + li $r0, (CONFIG_FTSDMC021_BASE) + li $r1, (CONFIG_SYS_FTSDMC021_TP1) ! 0x00011312 + swi $r1, [$r0] + li $r1, (CONFIG_SYS_FTSDMC021_TP2) ! 0x00480180 + swi $r1, [$r0+FTSDMC021_OFFSET_TP2] + li $r1, (CONFIG_SYS_FTSDMC021_CR1) ! 0x00002326 + swi $r1, [$r0+FTSDMC021_OFFSET_CR1] + li $r1, (FTSDMC021_CR2_IPREC) ! 0x00000010 + swi $r1, [$r0+FTSDMC021_OFFSET_CR2] +1: + lwi $r1, [$r0+FTSDMC021_OFFSET_CR2] + andi $r1, $r1, (CONFIG_SYS_FTSDMC021_CR2) ! 0x1C + bnez $r1, 1b + + li $r1, (FTSDMC021_CR2_ISMR) ! 0x00000004 + swi $r1, [$r0+FTSDMC021_OFFSET_CR2] +2: + lwi $r1, [$r0+FTSDMC021_OFFSET_CR2] + bnez $r1, 2b + + li $r1, (FTSDMC021_CR2_IREF) ! 0x00000008 + swi $r1, [$r0+FTSDMC021_OFFSET_CR2] +3: + lwi $r1, [$r0+FTSDMC021_OFFSET_CR2] + bnez $r1, 3b + + move $lp, $r11 + ret + +remap: + move $r11, $lp +#ifdef __NDS32_N1213_43U1H__ /* AG101 */ + bal 2f +relo_base: + move $r0, $lp +#else +relo_base: + mfusr $r0, $pc +#endif + + /* + * relocation, copy ROM code to SDRAM (current at 0x10000000) + */ + li $r4, CONFIG_SYS_RELO_ADDR ! 0x10000000 + li $r5, 0x0 + la $r1, relo_base + sub $r2, $r0, $r1 + sethi $r6, hi20(andesboot_end) + ori $r6, $r6, lo12(andesboot_end) + add $r6, $r6, $r2 +1: + lwi $r7, [$r5] + swi $r7, [$r4] + addi $r5, $r5, #4 + addi $r4, $r4, #4 + blt $r5, $r6, 1b + + /* + * Remapping + */ + li $r0, (CONFIG_FTSDMC021_BASE + FTSDMC021_OFFSET_TP1) + li $r1, (CONFIG_SYS_FTSDMC021_BANK0_BSR) ! 0x00001100 + swi $r1, [$r0+FTSDMC021_OFFSET_BANK0_BSR] + li $r1, 0x0 + swi $r1, [$r0+FTSDMC021_OFFSET_BANK1_BSR] + swi $r1, [$r0+FTSDMC021_OFFSET_BANK2_BSR] + swi $r1, [$r0+FTSDMC021_OFFSET_BANK3_BSR] + li $r1, (FTSDMC021_BANK_ENABLE) ! 0x00001000 + swi $r1, [$r0+FTSDMC021_OFFSET_BANK0_BSR] + + li $r0, (CONFIG_FTAHBC020S_BASE + FTAHBC020S_CR) + lwi $r1, [$r0] + ori $r1, $r1, FTAHBC020S_CR_REMAP ! 0x1 + swi $r1, [$r0] + + li $r0, (CONFIG_FTSMC020_BASE) + + move $lp, $r11 +2: + ret + +.globl show_led +show_led: + li $r8, (CONFIG_DEBUG_LED) + swi $r7, [$r8] + ret +#endif