nds32: Enable two banks of SDRAM on Andes board
PATCH 1/4 nds32: Enable two banks of SDRAM on Andes board
The original adp-ag101/adp-ag101p initialize only one bank(64MB) by default at boot time, but it is not enough for some application, so increasing to two banks(128M).
--- arch/nds32/cpu/n1213/ag101/lowlevel_init.S | 6 +++++- board/AndesTech/adp-ag101/adp-ag101.c | 10 +++++++++- board/AndesTech/adp-ag101p/adp-ag101p.c | 10 +++++++++- include/configs/adp-ag101.h | 10 +++++++++- include/configs/adp-ag101p.h | 9 ++++++++- 5 files changed, 40 insertions(+), 5 deletions(-)
arch/nds32/cpu/n1213/ag101/lowlevel_init.S +5 -1
@@ -38,6 +38,7 @@ #define SDMC_CR1_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR1) #define SDMC_CR2_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR2) #define SDMC_B0_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK0_BSR) +#define SDMC_B1_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK1_BSR) #define SDMC_TP1_D CONFIG_SYS_FTSDMC021_TP1 #define SDMC_TP2_D CONFIG_SYS_FTSDMC021_TP2
@@ -45,6 +46,7 @@ #define SDMC_CR2_D CONFIG_SYS_FTSDMC021_CR2 #define SDMC_B0_BSR_D CONFIG_SYS_FTSDMC021_BANK0_BSR +#define SDMC_B1_BSR_D CONFIG_SYS_FTSDMC021_BANK1_BSR /* * parameters for the static memory controller
@@ -167,12 +169,12 @@ relo_base: */ led 0x1a write32 SDMC_B0_BSR_A, SDMC_B0_BSR_D ! 0x00001100 + write32 SDMC_B1_BSR_A, SDMC_B1_BSR_D ! 0x00001140 /* clear empty BSR registers */ led 0x1b li $r4, CONFIG_FTSDMC021_BASE li $r5, 0x0 - swi $r5, [$r4 + FTSDMC021_BANK1_BSR] swi $r5, [$r4 + FTSDMC021_BANK2_BSR] swi $r5, [$r4 + FTSDMC021_BANK3_BSR]
@@ -223,6 +225,8 @@ relo_base: * - after remap: flash/rom 0x80000000, sdram: 0x00000000 */ led 0x1c + write32 SDMC_B0_BSR_A, 0x00001000 + write32 SDMC_B1_BSR_A, 0x00001040 setbf15 AHBC_CR_A, FTAHBC020S_CR_REMAP ! 0x1 #endif /* #ifdef CONFIG_MEM_REMAP */
board/AndesTech/adp-ag101/adp-ag101.c +9 -1
@@ -50,7 +50,7 @@ int board_init(void)int dram_init (void ) {unsigned long sdram_base =PHYS_SDRAM_0 ; -unsigned long expected_size =PHYS_SDRAM_0_SIZE ; +unsigned long expected_size =PHYS_SDRAM_0_SIZE +PHYS_SDRAM_1_SIZE ;unsigned long actual_size; actual_size =get_ram_size ((void *)sdram_base, expected_size);
@@ -65,6 +65,14 @@ int dram_init(void)return 0 ; } +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =PHYS_SDRAM_0 ; + gd->bd->bi_dram[0 ].size =PHYS_SDRAM_0_SIZE ; + gd->bd->bi_dram[1 ].start =PHYS_SDRAM_1 ; + gd->bd->bi_dram[1 ].size =PHYS_SDRAM_1_SIZE ; +} +int board_eth_init (bd_t *bd) {return ftmac100_initialize (bd);
board/AndesTech/adp-ag101p/adp-ag101p.c +9 -1
@@ -50,7 +50,7 @@ int board_init(void)int dram_init (void ) {unsigned long sdram_base =PHYS_SDRAM_0 ; -unsigned long expected_size =PHYS_SDRAM_0_SIZE ; +unsigned long expected_size =PHYS_SDRAM_0_SIZE +PHYS_SDRAM_1_SIZE ;unsigned long actual_size; actual_size =get_ram_size ((void *)sdram_base, expected_size);
@@ -65,6 +65,14 @@ int dram_init(void)return 0 ; } +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =PHYS_SDRAM_0 ; + gd->bd->bi_dram[0 ].size =PHYS_SDRAM_0_SIZE ; + gd->bd->bi_dram[1 ].start =PHYS_SDRAM_1 ; + gd->bd->bi_dram[1 ].size =PHYS_SDRAM_1_SIZE ; +} +int board_eth_init (bd_t *bd) {return ftmac100_initialize (bd);
include/configs/adp-ag101.h +9 -1
@@ -235,6 +235,11 @@#define CONFIG_SYS_FTSDMC021_BANK0_BSR (FTSDMC021_BANK_ENABLE | \ CONFIG_SYS_FTSDMC021_BANK0_BASE) +#define CONFIG_SYS_FTSDMC021_BANK1_BASE \ + (CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE + (PHYS_SDRAM_0_SIZE >> 20)) +#define CONFIG_SYS_FTSDMC021_BANK1_BSR (FTSDMC021_BANK_ENABLE | \ + CONFIG_SYS_FTSDMC021_BANK1_BASE) +#endif /*
@@ -248,9 +253,12 @@#else /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_MEM_REMAP */ #define PHYS_SDRAM_0 0x10000000/* SDRAM Bank #1 */ #endif +#define PHYS_SDRAM_1 \ + (PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE)/* SDRAM Bank #2 */ -#define CONFIG_NR_DRAM_BANKS 1/* we have 1 bank of DRAM */ +#define CONFIG_NR_DRAM_BANKS 2/* we have 2 bank of DRAM */ #define PHYS_SDRAM_0_SIZE 0x04000000/* 64 MB */ +#define PHYS_SDRAM_1_SIZE 0x04000000/* 64 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_0
include/configs/adp-ag101p.h +8 -1
@@ -236,6 +236,10 @@#define CONFIG_SYS_FTSDMC021_BANK0_BSR (FTSDMC021_BANK_ENABLE | \ CONFIG_SYS_FTSDMC021_BANK0_BASE) +#define CONFIG_SYS_FTSDMC021_BANK1_BASE \ + (CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE + (PHYS_SDRAM_0_SIZE >> 20)) +#define CONFIG_SYS_FTSDMC021_BANK1_BSR (FTSDMC021_BANK_ENABLE | \ + CONFIG_SYS_FTSDMC021_BANK1_BASE)#endif /*
@@ -249,9 +253,12 @@#else /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_MEM_REMAP */ #define PHYS_SDRAM_0 0x10000000/* SDRAM Bank #1 */ #endif +#define PHYS_SDRAM_1 \ + (PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE)/* SDRAM Bank #2 */ -#define CONFIG_NR_DRAM_BANKS 1/* we have 1 bank of DRAM */ +#define CONFIG_NR_DRAM_BANKS 2/* we have 2 bank of DRAM */ #define PHYS_SDRAM_0_SIZE 0x04000000/* 64 MB */ +#define PHYS_SDRAM_1_SIZE 0x04000000/* 64 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_0
Signature · 1 line
1.7.9.5
PATCH 2/4 nds32: Add bitwise operation macros for drivers
Add clrbits_* setbits_* clrsetbits_* for peripheral drivers
--- arch/nds32/include/asm/io.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/nds32/include/asm/io.h +38 -0
@@ -6,6 +6,7 @@* Copyright (C) 2011 Andes Technology Corporation * Shawn Lin, Andes Technology Corporation <[email protected]> * Macpaul Lin, Andes Technology Corporation <[email protected]> +* Ken Kuo, Andes Technology Corporation <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -165,6 +166,14 @@ static inline unsigned int readl(unsigned int *addr)#define __raw_base_readw (base, off) __arch_base_getw(base, off)#define __raw_base_readl (base, off) __arch_base_getl(base, off) +/* +* Clear and set bits in one shot. These macros can be used to clear and +* set multiple bits in a register using a single call. These macros can +* also be used to set a multiple-bit bit pattern using a mask, by +* specifying the mask in the 'clear' parameter and the new bit pattern +* in the 'set' parameter. +*/ +#define out_arch (type, endian, a, v) __raw_write##type(cpu_to_##endian(v), a)#define in_arch (type, endian, a) endian##_to_cpu(__raw_read##type(a))
@@ -183,6 +192,35 @@ static inline unsigned int readl(unsigned int *addr)#define out_8 (a, v) __raw_writeb(v, a)#define in_8 (a) __raw_readb(a) +#define clrbits (type, addr, clear) \ + out_##type((addr), in_##type(addr) & ~(clear)) + +#define setbits (type, addr, set) \ + out_##type((addr), in_##type(addr) | (set)) + +#define clrsetbits (type, addr, clear, set) \ + out_##type((addr), (in_##type(addr) & ~(clear)) | (set)) + +#define clrbits_be32 (addr, clear) clrbits(be32, addr, clear) +#define setbits_be32 (addr, set) setbits(be32, addr, set) +#define clrsetbits_be32 (addr, clear, set) clrsetbits(be32, addr, clear, set) + +#define clrbits_le32 (addr, clear) clrbits(le32, addr, clear) +#define setbits_le32 (addr, set) setbits(le32, addr, set) +#define clrsetbits_le32 (addr, clear, set) clrsetbits(le32, addr, clear, set) + +#define clrbits_be16 (addr, clear) clrbits(be16, addr, clear) +#define setbits_be16 (addr, set) setbits(be16, addr, set) +#define clrsetbits_be16 (addr, clear, set) clrsetbits(be16, addr, clear, set) + +#define clrbits_le16 (addr, clear) clrbits(le16, addr, clear) +#define setbits_le16 (addr, set) setbits(le16, addr, set) +#define clrsetbits_le16 (addr, clear, set) clrsetbits(le16, addr, clear, set) + +#define clrbits_8 (addr, clear) clrbits(8, addr, clear) +#define setbits_8 (addr, set) setbits(8, addr, set) +#define clrsetbits_8 (addr, clear, set) clrsetbits(8, addr, clear, set) +/* * Now, pick up the machine-defined IO definitions * #include <asm/arch/io.h>
Signature · 1 line
1.7.9.5
PATCH 2/4 nds32: Add bitwise operation macros for drivers
Hi Kuan-Yu,
2013/6/8 Kuan-Yu Kuo <[email protected]>:
Quoted 8 lines
Add clrbits_* setbits_* clrsetbits_* for peripheral drivers
Signed-off-by Kuan-Yu Kuo <[email protected]>Cc Macpaul Lin <[email protected]>--- arch/nds32/include/asm/io.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Applied to u-boot-nds32/master
Thanks for your help!
Signature · 2 lines
Best regards, Macpaul Lin
PATCH 2/4 nds32: Add bitwise operation macros for drivers
Hi Kuan-Yu,
2013/7/24 Macpaul Lin <[email protected]>:
Quoted 12 lines
Hi Kuan-Yu,
2013/6/8 Kuan-Yu Kuo <[email protected]>:
Quoted 8 lines
Add clrbits_* setbits_* clrsetbits_* for peripheral drivers
Signed-off-by Kuan-Yu Kuo <[email protected]>Cc Macpaul Lin <[email protected]>--- arch/nds32/include/asm/io.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Quoted 3 lines
Applied to u-boot-nds32/master
Thanks for your help!
Sorry for correcting this reply!
This patch you've sent was identical to commit "bea2868f5e5f994db3f6cf23a6111cfd6ac79fc3"
Gabor Juhos, "nds32: introduce macros for bit manipulation"
Since Gabor sent this patch earlier, so I take his patch. Thanks for both of your work!
Signature · 2 lines
Best regards, Macpaul Lin
PATCH 3/4 nds32: Enable SDIO and EXT2 command support for Andes board
In reply to Kuan-Yu Kuo--- include/configs/adp-ag101.h | 2 ++ include/configs/adp-ag101p.h | 2 ++ 2 files changed, 4 insertions(+)
include/configs/adp-ag101.h +2 -0
@@ -116,7 +116,9 @@#define CONFIG_DOS_PARTITION #define CONFIG_FTSDC010 #define CONFIG_FTSDC010_NUMBER 1 +#define CONFIG_FTSDC010_SDIO #define CONFIG_CMD_FAT +#define CONFIG_CMD_EXT2 /* * Command line configuration.
include/configs/adp-ag101p.h +2 -0
@@ -116,7 +116,9 @@#define CONFIG_DOS_PARTITION #define CONFIG_FTSDC010 #define CONFIG_FTSDC010_NUMBER 1 +#define CONFIG_FTSDC010_SDIO #define CONFIG_CMD_FAT +#define CONFIG_CMD_EXT2 /* * Command line configuration.
Signature · 1 line
1.7.9.5
PATCH 3/4 nds32: Enable SDIO and EXT2 command support for Andes board
Hi Kuan-Yu,
2013/6/8 Kuan-Yu Kuo <[email protected]>:
Quoted 2 lines
Signed-off-by Kuan-Yu Kuo <[email protected]>Cc Macpaul Lin <[email protected]>
Applied to u-boot-nds32/master
Thanks for your help!
Signature · 2 lines
Best regards, Macpaul Lin
PATCH 4/4 nds32: Enable the function of passing parameters to Linux
In reply to Kuan-Yu KuoAdd a header file, setup.h, which copy from Linux source code, this file contain structures are used to pass initialisation parameters to Linux. Enable this function on adp-ag101/adp-ag101p target
--- arch/nds32/include/asm/setup.h | 192 ++++++++++++++++++++++++++++++++++++++++ include/common.h | 1 + include/configs/adp-ag101.h | 7 ++ include/configs/adp-ag101p.h | 7 ++ 4 files changed, 207 insertions(+) create mode 100644 arch/nds32/include/asm/setup.h
arch/nds32/include/asm/setup.h new file +192 -0
@@ -0,0 +1,192 @@ +/* +* linux/arch/nds32/include/asm/setup.h +* +* Copyright (C) 1997-1999 Russell King +* Copyright (C) 2008 Andes Technology Corporation +* Copyright (C) 2013 Ken Kuo (ken_kuo at andestech.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Structure passed to kernel to tell it about the +* hardware it's running on. See Documentation/arm/Setup +* for more info. +*/ +#ifndef __ASMNDS32_SETUP_H +#define __ASMNDS32_SETUP_H + +#define COMMAND_LINE_SIZE 256 + +/* The list ends with an ATAG_NONE node. */ +#define ATAG_NONE 0x00000000 + +struct tag_header { +u32 size; +u32 tag; +}; + +/* The list must start with an ATAG_CORE node */ +#define ATAG_CORE 0x54410001 + +struct tag_core { +u32 flags;/* bit 0 = read-only */ +u32 pagesize; +u32 rootdev; +}; + +/* it is allowed to have multiple ATAG_MEM nodes */ +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { +u32 size; +u32 start;/* physical start address */ +}; + +/* VGA text type displays */ +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { +u8 x; +u8 y; +u16 video_page; +u8 video_mode; +u8 video_cols; +u16 video_ega_bx; +u8 video_lines; +u8 video_isvga; +u16 video_points; +}; + +/* describes how the ramdisk will be used in kernel */ +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { +u32 flags;/* bit 0 = load, bit 1 = prompt */ +u32 size;/* decompressed ramdisk size in _kilo_ bytes */ +u32 start;/* starting block of floppy-based RAM disk image */ +}; + +/* +* this one accidentally used virtual addresses - as such, +* it's deprecated. +* describes where the compressed ramdisk image lives (virtual address) +*/ +#define ATAG_INITRD 0x54410005 + +/* describes where the compressed ramdisk image lives (physical address) */ +#define ATAG_INITRD2 0x54420005 + +struct tag_initrd { +u32 start;/* physical start address */ +u32 size;/* size of compressed ramdisk image in bytes */ +}; + +/* board serial number. "64 bits should be enough for everybody" */ +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { +u32 low; +u32 high; +}; + +/* board revision */ +#define ATAG_REVISION 0x54410007 + +struct tag_revision { +u32 rev; +}; + +/* initial values for vesafb-type framebuffers. see struct screen_info +* in include/linux/tty.h +*/ +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { +u16 lfb_width; +u16 lfb_height; +u16 lfb_depth; +u16 lfb_linelength; +u32 lfb_base; +u32 lfb_size; +u8 red_size; +u8 red_pos; +u8 green_size; +u8 green_pos; +u8 blue_size; +u8 blue_pos; +u8 rsvd_size; +u8 rsvd_pos; +}; + +/* command line: \0 terminated string */ +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { +char cmdline[COMMAND_LINE_SIZE ]; +}; + +struct tag { +struct tag_header hdr; +union { +struct tag_core core; +struct tag_mem32 mem; +struct tag_videotext videotext; +struct tag_ramdisk ramdisk; +struct tag_initrd initrd; +struct tag_serialnr serialnr; +struct tag_revision revision; +struct tag_videolfb videolfb; +struct tag_cmdline cmdline; + } u; +}; + +struct tagtable { +u32 tag; +int (*parse)(const struct tag *); +}; + +#define tag_member_present (tag, member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next (t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_size (type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#define for_each_tag (t, base) \ + for (t = base; t->hdr.size; t = tag_next(t)) + +#ifdef __KERNEL__ + +#define __tag __used __attribute__((__section__(".taglist"))) +#define __tagtable (tag, fn) \ +static struct tagtable __tagtable_##fn __tag = { tag, fn } + +/* +* Memory map description +*/ +#define NR_BANKS 8 + +struct meminfo { +int nr_banks; +struct { +unsigned long start; +unsigned long size; +int node; + } bank[NR_BANKS ]; +}; + +/* +* Early command line parameters. +*/ +struct early_params { +const char *arg; +void (*fn)(char **p); +}; + +#define __early_param (name, fn) \ +static struct early_params __early_##fn __used \ +__attribute__((__section__("__early_param"))) = { name, fn } + +#endif +#endif
include/common.h +1 -0
@@ -421,6 +421,7 @@ static inline int setenv_addr(const char *varname, const void *addr)#endif #ifdef CONFIG_NDS32 # include <asm/mach-types.h> +# include <asm/setup.h> # include <asm/u-boot-nds32.h> #endif /* CONFIG_NDS32 */ #ifdef CONFIG_MIPS
include/configs/adp-ag101.h +7 -0
@@ -35,6 +35,13 @@#define CONFIG_SKIP_LOWLEVEL_INIT +/* +* Definitions related to passing arguments to kernel. +*/ +#define CONFIG_CMDLINE_TAG /* send commandline to Kernel */ +#define CONFIG_SETUP_MEMORY_TAGS /* send memory definition to kernel */ +#define CONFIG_INITRD_TAG /* send initrd params */ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_MEM_REMAP #endif
include/configs/adp-ag101p.h +7 -0
@@ -35,6 +35,13 @@#define CONFIG_SKIP_LOWLEVEL_INIT +/* +* Definitions related to passing arguments to kernel. +*/ +#define CONFIG_CMDLINE_TAG /* send commandline to Kernel */ +#define CONFIG_SETUP_MEMORY_TAGS /* send memory definition to kernel */ +#define CONFIG_INITRD_TAG /* send initrd params */ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_MEM_REMAP #endif
Signature · 1 line
1.7.9.5
PATCH 4/4 nds32: Enable the function of passing parameters to Linux
Hi Kuan-Yu,
2013/6/8 Kuan-Yu Kuo <[email protected]>:
Quoted 6 lines
Add a header file,
setup.h, which copy from Linux source code, this file contain structures are used to pass initialisation parameters to Linux. Enable this function on adp-ag101/adp-ag101p targetSigned-off-by Kuan-Yu Kuo <[email protected]>Cc Macpaul Lin <[email protected]>
Applied to u-boot-nds32/master
Thanks for your help!
Signature · 2 lines
Best regards, Macpaul Lin
PATCH 1/4 nds32: Enable two banks of SDRAM on Andes board
In reply to Kuan-Yu KuoHi Kuan-YU
2013/6/8 Kuan-Yu Kuo <[email protected]>:
Quoted 6 lines
The original adp-ag101/adp-ag101p initialize only one bank(64MB) by default at boot time, but it is not enough for some application, so increasing to two banks(128M).
Signed-off-by Kuan-Yu Kuo <[email protected]>Cc Macpaul Lin <[email protected]>
Applied to u-boot-nds32/master
Thanks for your help!
Signature · 2 lines
Best regards, Macpaul Lin