linux-sunxi / u-boot-sunxi

Allwinner A1x native u-boot support
https://github.com/linux-sunxi/u-boot-sunxi/wiki
315 stars 333 forks source link

Configuration for specific board #16

Closed YuukiHogo closed 12 years ago

YuukiHogo commented 12 years ago

What correct way to configure uboot sun4i branch for a board with 4x256MiB banks? Is this correct? include/configs/sun4i.h:

#define CONFIG_NR_DRAM_BANKS            4
#define CONFIG_SDRAM_SIZE                       (256 << 20)
#define PHYS_SDRAM_1                            CONFIG_SYS_SDRAM_BASE                   /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE                       CONFIG_SDRAM_SIZE                       /* 0x10000000, 256 MB Bank #1 */
#define PHYS_SDRAM_2                            (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE)      /* SDRAM Bank #2 */
#define PHYS_SDRAM_2_SIZE                       CONFIG_SDRAM_SIZE                       /* 0x10000000, 256 MB Bank #2 */
#define PHYS_SDRAM_3                            (PHYS_SDRAM_2 + PHYS_SDRAM_2_SIZE)      /* SDRAM Bank #3 */
#define PHYS_SDRAM_3_SIZE                       CONFIG_SDRAM_SIZE                       /* 0x10000000, 256 MB Bank #3 */
#define PHYS_SDRAM_4                            (PHYS_SDRAM_3 + PHYS_SDRAM_3_SIZE)      /* SDRAM Bank #4 */
#define PHYS_SDRAM_4_SIZE                       CONFIG_SDRAM_SIZE                       /* 0x10000000, 256 MB Bank #4 */

board/allwinner/a10-evb/a10-evb.c:

void dram_init_banksize(void) {

        gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
        gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
        gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
        gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
        gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
        gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
        gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
        gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
}

int dram_init(void) {

        gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
                     + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
                     + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
                     + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
        return 0;
}
hno commented 12 years ago

tis 2012-09-18 klockan 08:52 -0700 skrev YuukiHogo:

What correct way to configure uboot for a board with 4x256MiB banks?

That's actually one bank of 4 chips.

There is two parts that need to fit together

a) The dram controller initialization, matching how the DRAM is wired on your board.

b) bd->bi_dram[] bank configuration.

The details of 'a' is in dram-sun?i.c.

The details of 'b' is in the board sources.

For 'b' you have three options

a) Ignore it, and use a kernel that builds it's own memory info by probing the DRAM controller (ugly, but easy)

b) Configure it as one large 1GB bank.

c) Configure is as one 512-64MB bank and one 512MB bank, for the memory layout expected by MALI.

Regards Henrik

YuukiHogo commented 12 years ago

Thanks. I configured it as 1x1GiB bank, but dunno how to check/configure wiring. It seems too deep for me.

Ugly kernel-dram-detect way is unstable - different boots show different dram configurations.

hno commented 12 years ago

Memory configuration have changed significantly, and is now easier to set up. Please see current sunxi branch where there is board/allwinner/ folders with per-board configuration.