ARM: OMAP3: Add ARM Cortex A8 common directory
PATCH v5 3/13 ARM: OMAP3: Add ARM Cortex A8 common directory
From: Dirk Behme <[email protected]>
Add ARM Cortex A8 common directory
--- cpu/arm_cortexa8/Makefile | 47 ++++ cpu/arm_cortexa8/config.mk | 36 +++ cpu/arm_cortexa8/cpu.c | 238 ++++++++++++++++++++ cpu/arm_cortexa8/start.S | 516 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 837 insertions(+)
cpu/arm_cortexa8/cpu.c new file +238 -0
@@ -0,0 +1,238 @@ +/* +* (C) Copyright 2008 Texas Insturments +* +* (C) Copyright 2002 +* Sysgo Real-Time Solutions, GmbH <www.elinos.com> +* Marius Groeger <[email protected]> +* +* (C) Copyright 2002 +* Gary Jennejohn, DENX Software Engineering, <[email protected]> +* +* 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 +*/ + +/* +* CPU specific code +*/ + +#include <common.h> +#include <command.h> +#include <asm/arch/sys_proto.h> + +#ifdef CONFIG_USE_IRQ +DECLARE_GLOBAL_DATA_PTR ; +#endif + +#ifndef CONFIG_L2_OFF +void l2cache_disable (void ); +#endif + +static void cache_flush (void ); + +/* read co-processor 15, register #1 (control register) */ +static unsigned long read_p15_c1 (void ) +{ +unsigned long value; + + __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 0\ +@ read control reg\n" :"=r" (value) + ::"memory" ); +return value; +} + +/* write to co-processor 15, register #1 (control register) */ +static void write_p15_c1 (unsigned long value) +{ + __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 0\ +@ write it back\n" ::"r" (value) + :"memory" ); + +read_p15_c1 (); +} + +static void cp_delay (void ) +{ +volatile int i; + +/* Many OMAP regs need at least 2 nops */ +for (i =0 ; i <100 ; i++) ; +} + +/* See also ARM Ref. Man. */ +#define C1_MMU (1<<0)/* mmu off/on */ +#define C1_ALIGN (1<<1)/* alignment faults off/on */ +#define C1_DC (1<<2)/* dcache off/on */ +#define C1_WB (1<<3)/* merging write buffer on/off */ +#define C1_BIG_ENDIAN (1<<7)/* big endian off/on */ +#define C1_SYS_PROT (1<<8)/* system protection */ +#define C1_ROM_PROT (1<<9)/* ROM protection */ +#define C1_IC (1<<12)/* icache off/on */ +#define C1_HIGH_VECTORS (1<<13)/* location of vectors: low/high addresses */ +#define RESERVED_1 (0xf << 3)/* must be 111b for R/W */ + +int cpu_init (void ) +{ +/* +* setup up stacks if necessary +*/ +#ifdef CONFIG_USE_IRQ +IRQ_STACK_START = + _armboot_start -CONFIG_SYS_MALLOC_LEN -CONFIG_SYS_GBL_DATA_SIZE -4 ; +FIQ_STACK_START =IRQ_STACK_START -CONFIG_STACKSIZE_IRQ ; +#endif +return 0 ; +} + +int cleanup_before_linux (void ) +{ +unsigned int i; + +/* +* this function is called just before we call linux +* it prepares the processor for linux +* +* we turn off caches etc ... +*/ +disable_interrupts (); + +/* turn off I/D-cache */ +icache_disable (); +dcache_disable (); + +/* invalidate I-cache */ +cache_flush (); + +#ifndef CONFIG_L2_OFF +/* turn off L2 cache */ +l2cache_disable (); +/* invalidate L2 cache also */ +v7_flush_dcache_all (get_device_type ()); +#endif + i =0 ; +/* mem barrier to sync up things */ + asm("mcr p15, 0, %0, c7, c10, 4" : :"r" (i)); + +#ifndef CONFIG_L2_OFF +l2cache_enable (); +#endif + +return 0 ; +} + +int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) +{ +disable_interrupts (); +reset_cpu (0 ); + +/* NOTREACHED */ +return 0 ; +} + +void icache_enable (void ) +{ +ulong reg; + + reg =read_p15_c1 ();/* get control reg. */ +cp_delay (); +write_p15_c1 (reg |C1_IC ); +} + +void icache_disable (void ) +{ +ulong reg; + + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_IC ); +} + +void dcache_disable (void ) +{ +ulong reg; + + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_DC ); +} + +void l2cache_enable () +{ +unsigned long i; +volatile unsigned int j; + +/* ES2 onwards we can disable/enable L2 ourselves */ +if (get_cpu_rev () ==CPU_3430_ES2 ) { + __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1" :"=r" (i)); + __asm__ __volatile__("orr %0, %0, #0x2" :"=r" (i)); + __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1" :"=r" (i)); + }else { +/* Save r0, r12 and restore them after usage */ + __asm__ __volatile__("mov %0, r12" :"=r" (j)); + __asm__ __volatile__("mov %0, r0" :"=r" (i)); + +/* GP Device ROM code API usage here */ +/* r12 = AUXCR Write function and r0 value */ + __asm__ __volatile__("mov r12, #0x3" ); + __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1" ); + __asm__ __volatile__("orr r0, r0, #0x2" ); +/* SMI instruction to call ROM Code API */ + __asm__ __volatile__(".word 0xE1600070" ); + __asm__ __volatile__("mov r0, %0" :"=r" (i)); + __asm__ __volatile__("mov r12, %0" :"=r" (j)); + } + +} + +void l2cache_disable () +{ +unsigned long i; +volatile unsigned int j; + +/* ES2 onwards we can disable/enable L2 ourselves */ +if (get_cpu_rev () ==CPU_3430_ES2 ) { + __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1" :"=r" (i)); + __asm__ __volatile__("bic %0, %0, #0x2" :"=r" (i)); + __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1" :"=r" (i)); + }else { +/* Save r0, r12 and restore them after usage */ + __asm__ __volatile__("mov %0, r12" :"=r" (j)); + __asm__ __volatile__("mov %0, r0" :"=r" (i)); + +/* GP Device ROM code API usage here */ +/* r12 = AUXCR Write function and r0 value */ + __asm__ __volatile__("mov r12, #0x3" ); + __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1" ); + __asm__ __volatile__("bic r0, r0, #0x2" ); +/* SMI instruction to call ROM Code API */ + __asm__ __volatile__(".word 0xE1600070" ); + __asm__ __volatile__("mov r0, %0" :"=r" (i)); + __asm__ __volatile__("mov r12, %0" :"=r" (j)); + } +} + +int icache_status (void ) +{ +return (read_p15_c1 () &C1_IC ) !=0 ; +} + +static void cache_flush (void ) +{ + asm ("mcr p15, 0, %0, c7, c5, 0" : :"r" (0 )); +} +
cpu/arm_cortexa8/Makefile new file +47 -0
48 lines not on this page · raw message
cpu/arm_cortexa8/config.mk new file +36 -0
@@ -0,0 +1,36 @@ +# +# (C) Copyright 2002 +# Gary Jennejohn, DENX Software Engineering, <[email protected]> +# +# 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 +# +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 \ + -msoft-float + +# Make ARMv5 to allow more compilers to work, even though its v7a. +PLATFORM_CPPFLAGS += -march=armv5 +# ========================================================================= +# +# Supply options according to compiler version +# +# ========================================================================= +PLATFORM_CPPFLAGS +=$(call cc-option) +PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,) +PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\ + $(call cc-option,-malignment-traps,))
cpu/arm_cortexa8/start.S new file +516 -0
516 lines not on this page · raw message
PATCH v5 3/13 ARM: OMAP3: Add ARM Cortex A8 common directory
Dear dirk.behme at googlemail.com,
Quoted 7 lines · In message <[email protected]> you wrote:
--===============1314021165==
From: Dirk Behme <[email protected]>
Add ARM Cortex A8 common directory
Signed-off-by Dirk Behme <[email protected]>
...
cpu/arm_cortexa8/cpu.c line 74
Quoted 6 lines
cpu/arm_cortexa8/cpu.c new file +6
-0+static void cp_delay (void ) +{ +volatile int i; + +/* Many OMAP regs need at least 2 nops */ +for (i =0 ; i <100 ; i++) ;
There is not much reason for the compiler not to optimize this code away.
Quoted 7 lines
cpu/arm_cortexa8/cpu.c new file +7
-0+void icache_disable (void ) +{ +ulong reg; + + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_IC );
cpu/arm_cortexa8/cpu.c line 172
Quoted 10 lines
cpu/arm_cortexa8/cpu.c new file +10
-0+} + +void dcache_disable (void ) +{ +ulong reg; + + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_DC ); +}
Would it make sense to flush caches before disbling?
...
cpu/arm_cortexa8/start.S line 397
Quoted 1 line
cpu/arm_cortexa8/start.S new file +1
-0+ /* someone ought to write a more effiction fiq_save_user_regs */
effiction ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When some people discover the truth, they just can't understand why everybody isn't eager to hear it.
PATCH v5 3/13 ARM: OMAP3: Add ARM Cortex A8 common directory
Quoted 39 lines · Wolfgang Denk
Dear dirk.behme at googlemail.com,
Quoted 7 lines · In message <[email protected]> you wrote:
--===============1314021165==
From: Dirk Behme <[email protected]>
Add ARM Cortex A8 common directory
Signed-off-by Dirk Behme <[email protected]>...
cpu/arm_cortexa8/cpu.c line 74
Quoted 6 lines
cpu/arm_cortexa8/cpu.c new file +6
-0+static void cp_delay (void ) +{ +volatile int i; + +/* Many OMAP regs need at least 2 nops */ +for (i =0 ; i <100 ; i++) ;There is not much reason for the compiler not to optimize this code away.
Quoted 12 lines
cpu/arm_cortexa8/cpu.c new file +12
-0+void icache_disable (void ) +{ +ulong reg; + + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_IC ); +} + +void dcache_disable (void ) +{ +ulong reg;
Quoted 8 lines
cpu/arm_cortexa8/cpu.c line 172
Quoted 5 lines
cpu/arm_cortexa8/cpu.c new file +5
-0+ + reg =read_p15_c1 (); +cp_delay (); +write_p15_c1 (reg & ~C1_DC ); +}Would it make sense to flush caches before disbling?
Basically yes. But regarding the logic used in existing code, e.g.
cpu/arm1176/cpu.c (cleanup_before_linux())
I'm not sure about this. The logic seems to be to provide single functions for each cache operation and then call the functions in the correct order.
Quoted 10 lines
cpu/arm_cortexa8/start.S line 397
Quoted 1 line
cpu/arm_cortexa8/start.S new file +1
-0+ /* someone ought to write a more effiction fiq_save_user_regs */effiction ?
Best regards,
Wolfgang Denk
PATCH v5 4/13 ARM: OMAP3: Add lowlevel init and sys_info common files
Subject: [PATCH 04/13 v5] ARM: OMAP3: Add lowlevel init and sys_info common files
From: Dirk Behme <[email protected]>
Add assembly lowlevel init and sys_info common files
---
Changes in version v3:
- Add detection and support for 128MB/256MB RAM by Mans Rullgard
Changes in version v2:
- Move common ARM Cortex A8 code to cpu/arm_cortexa8/ and OMAP3 SoC specific common code to cpu/arm_cortexa8/omap3 as proposed by Wolfgang.
cpu/arm_cortexa8/omap3/Makefile | 46 ++++ cpu/arm_cortexa8/omap3/config.mk | 36 +++ cpu/arm_cortexa8/omap3/lowlevel_init.S | 359 +++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/sys_info.c | 334 ++++++++++++++++++++++++++++++ 4 files changed, 775 insertions(+)
cpu/arm_cortexa8/omap3/Makefile new file +46 -0
@@ -0,0 +1,46 @@ +# +# (C) Copyright 2000-2003 +# 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$(SOC).a + +SOBJS := lowlevel_init.o +COBJS := sys_info.o + +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) + +all: $(obj).depend $(LIB) + +$(LIB): $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
cpu/arm_cortexa8/omap3/config.mk new file +36 -0
@@ -0,0 +1,36 @@ +# +# (C) Copyright 2002 +# Gary Jennejohn, DENX Software Engineering, <[email protected]> +# +# 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 +# +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 \ + -msoft-float + +# Make ARMv5 to allow more compilers to work, even though its v7a. +PLATFORM_CPPFLAGS += -march=armv5 +# ========================================================================= +# +# Supply options according to compiler version +# +# ========================================================================= +PLATFORM_CPPFLAGS +=$(call cc-option) +PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,) +PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\ + $(call cc-option,-malignment-traps,))
cpu/arm_cortexa8/omap3/lowlevel_init.S new file +359 -0
359 lines not on this page · raw message
cpu/arm_cortexa8/omap3/sys_info.c new file +334 -0
334 lines not on this page · raw message
PATCH v5 4/13 ARM: OMAP3: Add lowlevel init and sys_info common files
Quoted 32 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +32
-0+/**************************************************** +* get_cpu_type() - low level get cpu type +* - no C globals yet. +****************************************************/ +u32 get_cpu_type (void ) +{ +/* fixme, need to get register defines for OMAP3 */ +return CPU_3430 ; +} + +/****************************************** +* get_cpu_rev(void) - extract version info +******************************************/ +u32 get_cpu_rev (void ) +{ +u32 cpuid =0 ; +/* On ES1.0 the IDCODE register is not exposed on L4 +* so using CPU ID to differentiate +* between ES2.0 and ES1.0. +*/ + __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0" :"=r" (cpuid)); +if ((cpuid &0xf ) ==0x0 ) +return CPU_3430_ES1 ; +else +return CPU_3430_ES2 ; + +} + +/**************************************************** +* is_mem_sdr() - return 1 if mem type in use is SDR +****************************************************/ +u32 is_mem_sdr (void )
cpu/arm_cortexa8/omap3/sys_info.c line 91
Quoted 10 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +10
-0+{ +volatile u32 *burst = (volatile u32 *) (SDRC_MR_0 +SDRC_CS0_OSET ); +if (*burst ==SDP_SDRC_MR_0_SDR ) +return 1 ; +return 0 ; +} + +/*********************************************************** +* get_mem_type() - identify type of mDDR part used. +***********************************************************/
is it not better to implement it as weak and overwrite it in board file
Quoted 118 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +118
-0+u32 get_mem_type (void ) +{ +#if defined(CONFIG_OMAP3_BEAGLE ) || defined(CONFIG_OVERO ) +return DDR_STACKED ; +#else +return DDR_DISCRETE ; +#endif +} + +/*********************************************************************** +* get_cs0_size() - get size of chip select 0/1 +************************************************************************/ +u32 get_sdr_cs_size (u32 offset) +{ +u32 size; + +/* get ram size field */ + size =readl (SDRC_MCFG_0 + offset) >>8 ; + size &=0x3FF ;/* remove unwanted bits */ + size *=SZ_2M ;/* find size in MB */ +return size; +} + +/*********************************************************************** +* get_sdr_cs_offset() - get offset of cs from cs0 start +************************************************************************/ +u32 get_sdr_cs_offset (u32 cs) +{ +u32 offset; + +if (!cs) +return 0 ; + + offset =readl (SDRC_CS_CFG ); + offset = (offset &15 ) <<27 | (offset &0x30 ) >>17 ; + +return offset; +} + +/*********************************************************************** +* get_board_type() - get board type based on current production stats. +* - NOTE-1-: 2 I2C EEPROMs will someday be populated with proper info. +* when they are available we can get info from there. This should +* be correct of all known boards up until today. +* - NOTE-2- EEPROMs are populated but they are updated very slowly. To +* avoid waiting on them we will use ES version of the chip to get info. +* A later version of the FPGA migth solve their speed issue. +************************************************************************/ +u32 get_board_type (void ) +{ +if (get_cpu_rev () ==CPU_3430_ES2 ) +return sysinfo.board_type_v2; +else +return sysinfo.board_type_v1; +} + +/****************************************************************** +* get_sysboot_value() - get init word settings +******************************************************************/ +inline u32 get_sysboot_value (void ) +{ +return 0x0000003F &readl (CONTROL_STATUS ); +} + +/*************************************************************************** +* get_gpmc0_base() - Return current address hardware will be +* fetching from. The below effectively gives what is correct, its a bit +* mis-leading compared to the TRM. For the most general case the mask +* needs to be also taken into account this does work in practice. +* - for u-boot we currently map: +* -- 0 to nothing, +* -- 4 to flash +* -- 8 to enent +* -- c to wifi +****************************************************************************/ +u32 get_gpmc0_base (void ) +{ +u32 b; + + b =readl (gpmc_base +OFFS (GPMC_CONFIG7 )); + b &=0x1F ;/* keep base [5:0] */ + b = b <<24 ;/* ret 0x0b000000 */ +return b; +} + +/******************************************************************* +* get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand) +*******************************************************************/ +u32 get_gpmc0_width (void ) +{ +return WIDTH_16BIT ; +} + +/************************************************************************* +* get_board_rev() - setup to pass kernel board revision information +* returns:(bit[0-3] sub version, higher bit[7-4] is higher version) +*************************************************************************/ +u32 get_board_rev (void ) +{ +return 0x20 ; +} + +/********************************************************************* +* display_board_info() - print banner with board info. +*********************************************************************/ +void display_board_info (u32 btype) +{ +char *bootmode[] = { +"NOR" , +"ONENAND" , +"NAND" , +"P2a" , +"NOR" , +"NOR" , +"P2a" , +"P2b" , + }; +u32 brev =get_board_rev ();
cpu/arm_cortexa8/omap3/sys_info.c line 217
Quoted 10 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +8
-0+char db_ver[] ="0.0" ;/* board type */ +char mem_sdr[] ="mSDR" ;/* memory type */ +char mem_ddr[] ="LPDDR" ; +char t_tst[] ="TST" ;/* security level */ +char t_emu[] ="EMU" ; +char t_hs[] ="HS" ; +char t_gp[] ="GP" ; +char unk[] ="?" ;
is it not better to have it as macro?
Quoted 36 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +36
-0+#ifdef CONFIG_LED_INFO +char led_string[CONFIG_LED_LEN ] = {0 }; +#endif +char p_l3[] ="165" ; +char p_cpu[] ="2" ; + +char *db_s, *mem_s, *sec_s; +u32 cpu, rev, sec; + + rev =get_cpu_rev (); + cpu =get_cpu_type (); + sec =get_device_type (); + +if (is_mem_sdr ()) + mem_s = mem_sdr; +else + mem_s = mem_ddr; + + db_s = db_ver; + db_s[0 ] += (brev >>4 ) &0xF ; + db_s[2 ] += brev &0xF ; + +switch (sec) { +case TST_DEVICE : + sec_s = t_tst; +break ; +case EMU_DEVICE : + sec_s = t_emu; +break ; +case HS_DEVICE : + sec_s = t_hs; +break ; +case GP_DEVICE : + sec_s = t_gp; +break ; +default :
cpu/arm_cortexa8/omap3/sys_info.c line 263
Quoted 10 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +10
-0+ sec_s = unk; + } + +printf ("OMAP%s-%s rev %d, CPU-OPP%s L3-%sMHz\n" , sysinfo.cpu_string, + sec_s, rev, p_cpu, p_l3); +printf ("%s + %s/%s\n" , sysinfo.board_string, + mem_s, bootmode[get_gpmc0_type ()]); + +} +
Best Regards,
J.
PATCH v5 4/13 ARM: OMAP3: Add lowlevel init and sys_info common files
Dear Jean-Christophe,
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 16 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +16
-0+/********************************************************************* +* display_board_info() - print banner with board info. +*********************************************************************/ +void display_board_info (u32 btype) +{ +char *bootmode[] = { +"NOR" , +"ONENAND" , +"NAND" , +"P2a" , +"NOR" , +"NOR" , +"P2a" , +"P2b" , + }; +u32 brev =get_board_rev ();
Quoted 10 lines
cpu/arm_cortexa8/omap3/sys_info.c line 217
Quoted 8 lines
cpu/arm_cortexa8/omap3/sys_info.c new file +8
-0+char db_ver[] ="0.0" ;/* board type */ +char mem_sdr[] ="mSDR" ;/* memory type */ +char mem_ddr[] ="LPDDR" ; +char t_tst[] ="TST" ;/* security level */ +char t_emu[] ="EMU" ; +char t_hs[] ="HS" ; +char t_gp[] ="GP" ; +char unk[] ="?" ;is it not better to have it as macro?
Would be quite nice if you could send an example to get an better understanding how you like to have this macro look like.
Many thanks and best regards
Dirk
PATCH v5 5/13 ARM: OMAP3: Add board, clock and interrupts common files
Subject: [PATCH 05/13 v5] ARM: OMAP3: Add board, clock and interrupts common files
From: Dirk Behme <[email protected]>
Add board, clock, cpu and interrupts common files
---
Changes in version v5:
- Add Readme, further clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD
Changes in version v3:
- Add detection and support for 128MB/256MB RAM by Mans Rullgard
Changes in version v2:
- Move common ARM Cortex A8 code to cpu/arm_cortexa8/ and OMAP3 SoC specific common code to cpu/arm_cortexa8/omap3 as proposed by Wolfgang.
cpu/arm_cortexa8/omap3/Makefile | 2 cpu/arm_cortexa8/omap3/board.c | 326 +++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/clock.c | 328 ++++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/interrupts.c | 303 +++++++++++++++++++++++++++++++++ 4 files changed, 958 insertions(+), 1 deletion(-)
cpu/arm_cortexa8/omap3/Makefile +1 -1
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).a SOBJS := lowlevel_init.o -COBJS := sys_info.o +COBJS := sys_info.o board.o clock.o interrupts.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS))
cpu/arm_cortexa8/omap3/board.c new file +326 -0
326 lines not on this page · raw message
cpu/arm_cortexa8/omap3/clock.c new file +328 -0
328 lines not on this page · raw message
cpu/arm_cortexa8/omap3/interrupts.c new file +303 -0
303 lines not on this page · raw message
PATCH v5 5/13 ARM: OMAP3: Add board, clock and interrupts common files
Dear dirk.behme at googlemail.com,
Quoted 7 lines · In message <[email protected]> you wrote:
Subject: [PATCH 05/13 v5] ARM: OMAP3: Add board, clock and interrupts common files
From: Dirk Behme <[email protected]>
Add board, clock, cpu and interrupts common files
Signed-off-by Dirk Behme <[email protected]>
...
cpu/arm_cortexa8/omap3/board.c line 154
Quoted 3 lines
cpu/arm_cortexa8/omap3/board.c new file +3
-0+ +/* if GP device unlock device SRAM for general use */ +/* secure code breaks for Secure/Emulation device - HS/E/T */
Multiline comment style?
cpu/arm_cortexa8/omap3/board.c line 162
Quoted 4 lines
cpu/arm_cortexa8/omap3/board.c new file +4
-0+/* If device is EMU and boot is XIP external booting +* Unlock firewalls and disable L2 and put chip +* out of secure world +*/
Ditto.
And so on.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The perversity of nature is nowhere better demonstrated by the fact that, when exposed to the same atmosphere, bread becomes hard while crackers become soft.
PATCH v5 5/13 ARM: OMAP3: Add board, clock and interrupts common files
In reply to dirk.behme at googlemail.comQuoted 6 lines · dirk.behme at googlemail.com
Subject: [PATCH 05/13 v5] ARM: OMAP3: Add board, clock and interrupts common files
From: Dirk Behme <[email protected]>
Add board, clock, cpu and interrupts common files
Quoted 7 lines
Signed-off-by Dirk Behme <[email protected]>---
Changes in version v5:
- Add Readme, further clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD
Where is it?
Quoted 7 lines
Changes in version v3:
- Add detection and support for 128MB/256MB RAM by Mans Rullgard
Changes in version v2:
Quoted 7 lines
- Move common ARM Cortex A8 code to cpu/arm_cortexa8/ and OMAP3 SoC specific common code to cpu/arm_cortexa8/omap3 as proposed by Wolfgang.
cpu/arm_cortexa8/omap3/Makefile | 2 cpu/arm_cortexa8/omap3/board.c | 326 +++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/clock.c | 328 ++++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/interrupts.c | 303 +++++++++++++++++++++++++++++++++ 4 files changed, 958 insertions(+), 1 deletion(-)
Best Regards,
J.
PATCH v5 5/13 ARM: OMAP3: Add board, clock and interrupts common files
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · dirk.behme at googlemail.com
Subject: [PATCH 05/13 v5] ARM: OMAP3: Add board, clock and interrupts common files
From: Dirk Behme <[email protected]>
Add board, clock, cpu and interrupts common files
Signed-off-by Dirk Behme <[email protected]>
Quoted 7 lines
Quoted 5 lines
---
Changes in version v5:
- Add Readme, further clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD
Where is it?
Quoted 17 lines
Quoted 6 lines
Changes in version v3:
- Add detection and support for 128MB/256MB RAM by Mans Rullgard
Changes in version v2:
Quoted 7 lines
- Move common ARM Cortex A8 code to cpu/arm_cortexa8/ and OMAP3 SoC specific common code to cpu/arm_cortexa8/omap3 as proposed by Wolfgang.
cpu/arm_cortexa8/omap3/Makefile | 2 cpu/arm_cortexa8/omap3/board.c | 326 +++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/clock.c | 328 ++++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/interrupts.c | 303 +++++++++++++++++++++++++++++++++ 4 files changed, 958 insertions(+), 1 deletion(-)Best Regards,
J.
PATCH v5 6/13 ARM: OMAP3: Add memory and syslib common files
Subject: [PATCH 06/13 v5] ARM: OMAP3: Add memory and syslib common files
From: Dirk Behme <[email protected]>
Add memory and syslib common files.
---
Changes in version v3:
- Add detection and support for 128MB/256MB RAM by Mans Rullgard
Changes in version v2:
- Move common ARM Cortex A8 code to cpu/arm_cortexa8/ and OMAP3 SoC specific common code to cpu/arm_cortexa8/omap3 as proposed by Wolfgang.
cpu/arm_cortexa8/omap3/Makefile | 2 cpu/arm_cortexa8/omap3/mem.c | 306 ++++++++++++++++++++++++++++++++++++++++ cpu/arm_cortexa8/omap3/syslib.c | 72 +++++++++ examples/Makefile | 6 4 files changed, 383 insertions(+), 3 deletions(-)
cpu/arm_cortexa8/omap3/mem.c new file +306 -0
@@ -0,0 +1,306 @@ +/* +* (C) Copyright 2008 +* Texas Instruments, <www.ti.com> +* +* Author : +* Manikandan Pillai <[email protected]> +* +* Initial Code from: +* Richard Woodruff <[email protected]> +* Syed Mohammed Khasim <[email protected]> +* +* 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/io.h> +#include <asm/arch/bits.h> +#include <asm/arch/mem.h> +#include <asm/arch/sys_proto.h> +#include <command.h> + +/* Only One NAND allowed on board at a time. +* The GPMC CS Base for the same +*/ +unsigned int boot_flash_base; +unsigned int boot_flash_off; +unsigned int boot_flash_sec; +unsigned int boot_flash_type; +volatile unsigned int boot_flash_env_addr; + +/* help common/env_flash.c */ +#ifdef ENV_IS_VARIABLE + +uchar (*boot_env_get_char_spec) (int index); +int (*boot_env_init) (void ); +int (*boot_saveenv) (void ); +void (*boot_env_relocate_spec) (void ); + +/* 16 bit NAND */ +uchar env_get_char_spec (int index); +int env_init (void ); +int saveenv (void ); +void env_relocate_spec (void ); +extern char *env_name_spec; + +#if defined(CONFIG_CMD_NAND ) +u8 is_nand; +#endif + +#if defined(CONFIG_CMD_ONENAND ) +u8 is_onenand; +#endif + +#endif /* ENV_IS_VARIABLE */ + +#if defined(CONFIG_CMD_NAND ) +static u32 gpmc_m_nand[GPMC_MAX_REG ] = { +M_NAND_GPMC_CONFIG1 , +M_NAND_GPMC_CONFIG2 , +M_NAND_GPMC_CONFIG3 , +M_NAND_GPMC_CONFIG4 , +M_NAND_GPMC_CONFIG5 , +M_NAND_GPMC_CONFIG6 ,0 +}; + +u32 *nand_cs_base; + +#if defined(CONFIG_ENV_IS_IN_NAND ) +#define GPMC_CS 0 +#else +#define GPMC_CS 1 +#endif + +#endif + +#if defined(CONFIG_CMD_ONENAND ) +static u32 gpmc_onenand[GPMC_MAX_REG ] = { +ONENAND_GPMC_CONFIG1 , +ONENAND_GPMC_CONFIG2 , +ONENAND_GPMC_CONFIG3 , +ONENAND_GPMC_CONFIG4 , +ONENAND_GPMC_CONFIG5 , +ONENAND_GPMC_CONFIG6 ,0 +}; + +u32 *onenand_cs_base; + +#if defined(CONFIG_ENV_IS_IN_ONENAND ) +#define GPMC_CS 0 +#else +#define GPMC_CS 1 +#endif + +#endif + +/************************************************************************** +* make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow +* command line mem=xyz use all memory with out discontinuous support +* compiled in. Could do it at the ATAG, but there really is two banks... +* Called as part of 2nd phase DDR init. +**************************************************************************/ +void make_cs1_contiguous (void ) +{ +u32 size, a_add_low, a_add_high; + + size =get_sdr_cs_size (SDRC_CS0_OSET ); + size /=SZ_32M ;/* find size to offset CS1 */ + a_add_high = (size &3 ) <<8 ;/* set up low field */ + a_add_low = (size &0x3C ) >>2 ;/* set up high field */ +writel ((a_add_high | a_add_low),SDRC_CS_CFG ); + +} + +/******************************************************** +* mem_ok() - test used to see if timings are correct +* for a part. Helps in guessing which part +* we are currently using. +*******************************************************/ +u32 mem_ok (u32 cs) +{ +u32 val1, val2, addr; +u32 pattern =0x12345678 ; + + addr =OMAP34XX_SDRC_CS0 +get_sdr_cs_offset (cs); + +writel (0x0 , addr +0x400 );/* clear pos A */ +writel (pattern, addr);/* pattern to pos B */ +writel (0x0 , addr +4 );/* remove pattern off the bus */ + val1 =readl (addr +0x400 );/* get pos A value */ + val2 =readl (addr);/* get val2 */ + +if ((val1 !=0 ) || (val2 != pattern))/* see if pos A val changed */ +return 0 ; +else +return 1 ; +} + +/******************************************************** +* sdrc_init() - init the sdrc chip selects CS0 and CS1 +* - early init routines, called from flash or +* SRAM. +*******************************************************/ +void sdrc_init (void ) +{ +/* only init up first bank here */ +do_sdrc_init (SDRC_CS0_OSET ,EARLY_INIT ); +} + +/************************************************************************* +* do_sdrc_init(): initialize the SDRAM for use. +* -code sets up SDRAM basic SDRC timings for CS0 +* -optimal settings can be placed here, or redone after i2c +* inspection of board info +* +* - code called ones in C-Stack only context for CS0 and a possible 2nd +* time depending on memory configuration from stack+global context +**************************************************************************/ + +void do_sdrc_init (u32 offset,u32 early) +{ +u32 actim_offs = offset?0x28 :0 ; + +if (early) { +/* reset sdrc controller */ +writel (SOFTRESET ,SDRC_SYSCONFIG ); +wait_on_value (BIT0 ,BIT0 ,SDRC_STATUS ,12000000 ); +writel (0 ,SDRC_SYSCONFIG ); + +/* setup sdrc to ball mux */ +writel (SDP_SDRC_SHARING ,SDRC_SHARING ); + +/* Disble Power Down of CKE cuz of 1 CKE on combo part */ +writel (0x00000081 ,SDRC_POWER ); + +writel (0x0000A ,SDRC_DLLA_CTRL ); +sdelay (0x20000 ); + } + +writel (0x02584099 ,SDRC_MCFG_0 + offset); +writel (0x4e201 ,SDRC_RFR_CTRL + offset); +writel (0xaa9db4c6 ,SDRC_ACTIM_CTRLA_0 + actim_offs); +writel (0x11517 ,SDRC_ACTIM_CTRLB_0 + actim_offs); + +writel (CMD_NOP ,SDRC_MANUAL_0 + offset); +writel (CMD_PRECHARGE ,SDRC_MANUAL_0 + offset); +writel (CMD_AUTOREFRESH ,SDRC_MANUAL_0 + offset); +writel (CMD_AUTOREFRESH ,SDRC_MANUAL_0 + offset); + +/* CAS latency 3, Write Burst = Read Burst, Serial Mode, +Burst length = 4 */ +writel (0x00000032 ,SDRC_MR_0 + offset); + +if (!mem_ok (offset)) +writel (0 ,SDRC_MCFG_0 + offset); +} + +void enable_gpmc_config (u32 *gpmc_config,u32 *gpmc_cs_base,u32 base, +u32 size) +{ +writel (0 , gpmc_cs_base +OFFS (GPMC_CONFIG7 )); +sdelay (1000 ); +/* Delay for settling */ +writel (gpmc_config[0 ], gpmc_cs_base +OFFS (GPMC_CONFIG1 )); +writel (gpmc_config[1 ], gpmc_cs_base +OFFS (GPMC_CONFIG2 )); +writel (gpmc_config[2 ], gpmc_cs_base +OFFS (GPMC_CONFIG3 )); +writel (gpmc_config[3 ], gpmc_cs_base +OFFS (GPMC_CONFIG4 )); +writel (gpmc_config[4 ], gpmc_cs_base +OFFS (GPMC_CONFIG5 )); +writel (gpmc_config[5 ], gpmc_cs_base +OFFS (GPMC_CONFIG6 )); +/* Enable the config */ +writel ((((size &0xF ) <<8 ) | ((base >>24 ) &0x3F ) | + (1 <<6 )), gpmc_cs_base +OFFS (GPMC_CONFIG7 )); +sdelay (2000 ); +} + +/***************************************************** +* gpmc_init(): init gpmc bus +* Init GPMC for x16, MuxMode (SDRAM in x32). +* This code can only be executed from SRAM or SDRAM. +*****************************************************/ +void gpmc_init (void ) +{ +/* putting a blanket check on GPMC based on ZeBu for now */ +u32 mux =0 , mwidth; +u32 *gpmc_config =NULL ; +u32 *gpmc_base = (u32 *)GPMC_BASE ; +u32 base =0 ; +u32 size =0 ; +u32 f_off =CONFIG_SYS_MONITOR_LEN ; +u32 f_sec =0 ; +u32 config =0 ; + + mux =BIT9 ; + mwidth =get_gpmc0_width (); + +/* global settings */ +writel (0 , gpmc_base +OFFS (GPMC_IRQENABLE ));/* isr's sources masked */ +writel (0 , gpmc_base +OFFS (GPMC_TIMEOUT_CONTROL ));/* timeout disable */ + + config =readl (gpmc_base +OFFS (GPMC_CONFIG )); + config &= (~0xf00 ); +writel (config, gpmc_base +OFFS (GPMC_CONFIG )); + +/* Disable the GPMC0 config set by ROM code +* It conflicts with our MPDB (both@0x08000000) +*/ +writel (0 ,GPMC_CONFIG_CS0 +GPMC_CONFIG7 ); +sdelay (1000 ); + +#if defined(CONFIG_CMD_NAND )/* CS 0 */ + gpmc_config = gpmc_m_nand; + nand_cs_base = (u32 *)(GPMC_CONFIG_CS0_BASE + + (GPMC_CS *GPMC_CONFIG_WIDTH )); + base =PISMO1_NAND_BASE ; + size =PISMO1_NAND_SIZE ; +enable_gpmc_config (gpmc_config, nand_cs_base, base, size); + is_nand =1 ; +#if defined(CONFIG_ENV_IS_IN_NAND ) + f_off =SMNAND_ENV_OFFSET ; + f_sec =SZ_128K ; +/* env setup */ + boot_flash_base = base; + boot_flash_off = f_off; + boot_flash_sec = f_sec; + boot_flash_env_addr = f_off; +#endif +#endif + +#if defined(CONFIG_CMD_ONENAND ) + gpmc_config = gpmc_onenand; + onenand_cs_base = (u32 *)(GPMC_CONFIG_CS0 + + (GPMC_CS *GPMC_CONFIG_WIDTH )); + base =PISMO1_ONEN_BASE ; + size =PISMO1_ONEN_SIZE ; +enable_gpmc_config (gpmc_config, onenand_cs_base, base, size); + is_onenand =1 ; +#if defined(CONFIG_ENV_IS_IN_ONENAND ) + f_off =ONENAND_ENV_OFFSET ; + f_sec =SZ_128K ; +/* env setup */ + boot_flash_base = base; + boot_flash_off = f_off; + boot_flash_sec = f_sec; + boot_flash_env_addr = f_off; +#endif +#endif + +#ifdef ENV_IS_VARIABLE + boot_env_get_char_spec = env_get_char_spec; + boot_env_init = env_init; + boot_saveenv = saveenv; + boot_env_relocate_spec = env_relocate_spec; +#endif +}
cpu/arm_cortexa8/omap3/syslib.c new file +72 -0
72 lines not on this page · raw message
cpu/arm_cortexa8/omap3/Makefile +1 -1
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).a SOBJS := lowlevel_init.o -COBJS := sys_info.o board.o clock.o interrupts.o +COBJS := sys_info.o board.o clock.o interrupts.o mem.o syslib.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS))
examples/Makefile +4 -2
@@ -30,10 +30,12 @@ LOAD_ADDR = 0x40000 endif ifeq ($(ARCH),arm) +LOAD_ADDR = 0xc100000 ifeq ($(BOARD),omap2420h4) LOAD_ADDR = 0x80300000 -else -LOAD_ADDR = 0xc100000 +endif +ifeq ($(CPU),omap3) +LOAD_ADDR = 0x80300000 endif endif
PATCH v5 6/13 ARM: OMAP3: Add memory and syslib common files
Quoted 6 lines
examples/Makefile +0
-0@@ -30,10 +30,12 @@ LOAD_ADDR = 0x40000 endif ifeq ($(ARCH),arm)
examples/Makefile LOAD_ADDR = 0x40000 · line 40
Quoted 10 lines
examples/Makefile +4
-2+LOAD_ADDR = 0xc100000 ifeq ($(BOARD),omap2420h4) LOAD_ADDR = 0x80300000 -else -LOAD_ADDR = 0xc100000 +endif +ifeq ($(CPU),omap3) +LOAD_ADDR = 0x80300000 endif endif
Maybe we need to change it to allow arch/cpu to define itself and avoid ifeq/endif
Best Regards,
J.
PATCH v5 6/13 ARM: OMAP3: Add memory and syslib common files
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 5 lines
examples/Makefile +0
-0@@ -30,10 +30,12 @@ LOAD_ADDR = 0x40000 endif
Quoted 14 lines
examples/Makefile LOAD_ADDR = 0x40000 · line 40
Quoted 11 lines
examples/Makefile +4
-2ifeq ($(ARCH),arm) +LOAD_ADDR = 0xc100000 ifeq ($(BOARD),omap2420h4) LOAD_ADDR = 0x80300000 -else -LOAD_ADDR = 0xc100000 +endif +ifeq ($(CPU),omap3) +LOAD_ADDR = 0x80300000 endif endifMaybe we need to change it to allow
arch/cputo define itself and avoid ifeq/endif
In any case I think above should rather be written as
ifeq ($(BOARD),omap2420h4) LOAD_ADDR = 0x80300000 else ifeq ($(CPU),omap3) LOAD_ADDR = 0x80300000 else LOAD_ADDR = 0xc100000 endif
instead.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The main thing is the play itself. I swear that greed for money has nothing to do with it, although heaven knows I am sorely in need of money. - Feodor Dostoyevsky