From: Vladimir Zapolskiy Date: Sun, 27 Nov 2016 22:15:31 +0000 (+0200) Subject: sh: add common dram_init() function for all boards X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=cdbb0cf8ecf30d5dbbfa500e8939a32ef45896c5;p=u-boot.git sh: add common dram_init() function for all boards Generic board support assumes a different method of specifying DRAM size on board, also it can be shared among all boards, notably only sh7763rdp board has a custom legacy dram_init(), however the difference is only in printing some additional information, this feature can be removed. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Simon Glass --- diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index c5cf89f493..7be20b1bdd 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ # - +obj-y += board.o obj-$(CONFIG_CMD_BOOTM) += bootm.o ifeq ($(CONFIG_CPU_SH2),y) obj-y += time_sh2.o diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c new file mode 100644 index 0000000000..7cb594e31a --- /dev/null +++ b/arch/sh/lib/board.c @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2016 Vladimir Zapolskiy + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +DECLARE_GLOBAL_DATA_PTR; + +int dram_init(void) +{ + gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); + + return 0; +} diff --git a/board/alphaproject/ap_sh4a_4a/ap_sh4a_4a.c b/board/alphaproject/ap_sh4a_4a/ap_sh4a_4a.c index e65befc3ba..31418a1f96 100644 --- a/board/alphaproject/ap_sh4a_4a/ap_sh4a_4a.c +++ b/board/alphaproject/ap_sh4a_4a/ap_sh4a_4a.c @@ -11,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define MODEMR (0xFFCC0020) #define MODEMR_MASK (0x6) #define MODEMR_533MHZ (0x2) @@ -172,12 +170,3 @@ int board_late_init(void) return 0; } - -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - - return 0; -} diff --git a/board/espt/espt.c b/board/espt/espt.c index ee6e538c37..9ab71fe171 100644 --- a/board/espt/espt.c +++ b/board/espt/espt.c @@ -11,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: ESPT-GIGA\n"); @@ -24,14 +22,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/mpr2/mpr2.c b/board/mpr2/mpr2.c index 7449e036e4..3788a390b8 100644 --- a/board/mpr2/mpr2.c +++ b/board/mpr2/mpr2.c @@ -11,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: MPR2\n"); @@ -138,11 +136,3 @@ int board_init(void) return 0; } - -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("SDRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} diff --git a/board/ms7720se/ms7720se.c b/board/ms7720se/ms7720se.c index 534a422043..48edcc62fd 100644 --- a/board/ms7720se/ms7720se.c +++ b/board/ms7720se/ms7720se.c @@ -17,8 +17,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define LED_BASE 0xB0800000 int checkboard(void) @@ -32,14 +30,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { outw(value & 0xFF, LED_BASE); diff --git a/board/ms7722se/ms7722se.c b/board/ms7722se/ms7722se.c index ee1e99c117..869b415ba9 100644 --- a/board/ms7722se/ms7722se.c +++ b/board/ms7722se/ms7722se.c @@ -15,8 +15,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define LED_BASE 0xB0800000 int checkboard(void) @@ -33,14 +31,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { writew(value & 0xFF, LED_BASE); diff --git a/board/ms7750se/ms7750se.c b/board/ms7750se/ms7750se.c index a7f9346b2d..d252faa91f 100644 --- a/board/ms7750se/ms7750se.c +++ b/board/ms7750se/ms7750se.c @@ -8,8 +8,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: SH7750/SH7750S/SH7750R Solution Engine\n"); @@ -21,14 +19,6 @@ int board_init(void) return 0; } -int dram_init (void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - int board_late_init(void) { return 0; diff --git a/board/renesas/MigoR/migo_r.c b/board/renesas/MigoR/migo_r.c index fa2bf78cf1..6409a73de1 100644 --- a/board/renesas/MigoR/migo_r.c +++ b/board/renesas/MigoR/migo_r.c @@ -15,8 +15,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas MigoR\n"); @@ -28,14 +26,6 @@ int board_init(void) return 0; } -int dram_init (void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state (unsigned short value) { } diff --git a/board/renesas/ap325rxa/ap325rxa.c b/board/renesas/ap325rxa/ap325rxa.c index 518ad7b6a1..218d479c6b 100644 --- a/board/renesas/ap325rxa/ap325rxa.c +++ b/board/renesas/ap325rxa/ap325rxa.c @@ -10,8 +10,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - /* PRI control register */ #define PRPRICR5 0xFF800048 /* LMB */ #define PRPRICR5_D 0x2a @@ -130,14 +128,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/renesas/ecovec/ecovec.c b/board/renesas/ecovec/ecovec.c index d862d997e5..28b557a5b0 100644 --- a/board/renesas/ecovec/ecovec.c +++ b/board/renesas/ecovec/ecovec.c @@ -22,16 +22,6 @@ int checkboard(void) return 0; } -int dram_init(void) -{ - DECLARE_GLOBAL_DATA_PTR; - - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - static void debug_led(u8 led) { /* PDGR[0-4] is debug LED */ diff --git a/board/renesas/r0p7734/r0p7734.c b/board/renesas/r0p7734/r0p7734.c index 2e31ba6731..360e0a1a6f 100644 --- a/board/renesas/r0p7734/r0p7734.c +++ b/board/renesas/r0p7734/r0p7734.c @@ -11,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define MODEMR (0xFFCC0020) #define MODEMR_MASK (0x6) #define MODEMR_533MHZ (0x2) @@ -61,15 +59,6 @@ int board_late_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - - return 0; -} - #ifdef CONFIG_SMC911X int board_eth_init(bd_t *bis) { diff --git a/board/renesas/r2dplus/r2dplus.c b/board/renesas/r2dplus/r2dplus.c index 249c35f3a2..d6fb4da82b 100644 --- a/board/renesas/r2dplus/r2dplus.c +++ b/board/renesas/r2dplus/r2dplus.c @@ -12,8 +12,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas Solutions R2D Plus\n"); @@ -25,14 +23,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - int board_late_init(void) { return 0; diff --git a/board/renesas/r7780mp/r7780mp.c b/board/renesas/r7780mp/r7780mp.c index 783352d476..de259f502b 100644 --- a/board/renesas/r7780mp/r7780mp.c +++ b/board/renesas/r7780mp/r7780mp.c @@ -13,8 +13,6 @@ #include #include "r7780mp.h" -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { #if defined(CONFIG_R7780MP) @@ -33,14 +31,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { diff --git a/board/renesas/rsk7203/rsk7203.c b/board/renesas/rsk7203/rsk7203.c index 8800371b00..72c562d3e5 100644 --- a/board/renesas/rsk7203/rsk7203.c +++ b/board/renesas/rsk7203/rsk7203.c @@ -13,8 +13,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas Technology RSK7203\n"); @@ -26,14 +24,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/renesas/rsk7264/rsk7264.c b/board/renesas/rsk7264/rsk7264.c index d938b3a7b6..4ebb27b463 100644 --- a/board/renesas/rsk7264/rsk7264.c +++ b/board/renesas/rsk7264/rsk7264.c @@ -14,8 +14,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas Technology RSK7264\n"); @@ -27,14 +25,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/renesas/rsk7269/rsk7269.c b/board/renesas/rsk7269/rsk7269.c index ae32b6a6d5..0066f9f6d0 100644 --- a/board/renesas/rsk7269/rsk7269.c +++ b/board/renesas/rsk7269/rsk7269.c @@ -15,8 +15,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas RSK7269\n"); @@ -28,14 +26,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/renesas/sh7752evb/sh7752evb.c b/board/renesas/sh7752evb/sh7752evb.c index 3aad532367..525d979724 100644 --- a/board/renesas/sh7752evb/sh7752evb.c +++ b/board/renesas/sh7752evb/sh7752evb.c @@ -159,17 +159,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - DECLARE_GLOBAL_DATA_PTR; - - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - - return 0; -} - int board_mmc_init(bd_t *bis) { struct gpio_regs *gpio = GPIO_BASE; diff --git a/board/renesas/sh7753evb/sh7753evb.c b/board/renesas/sh7753evb/sh7753evb.c index 52a1906c7f..3d1eedaa5f 100644 --- a/board/renesas/sh7753evb/sh7753evb.c +++ b/board/renesas/sh7753evb/sh7753evb.c @@ -175,17 +175,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - DECLARE_GLOBAL_DATA_PTR; - - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - - return 0; -} - int board_mmc_init(bd_t *bis) { struct gpio_regs *gpio = GPIO_BASE; diff --git a/board/renesas/sh7757lcr/sh7757lcr.c b/board/renesas/sh7757lcr/sh7757lcr.c index ddcf275f6e..0a04a9d39d 100644 --- a/board/renesas/sh7757lcr/sh7757lcr.c +++ b/board/renesas/sh7757lcr/sh7757lcr.c @@ -224,31 +224,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - DECLARE_GLOBAL_DATA_PTR; - - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - printf(" Physical address\n"); - printf(" 0x%08x - 0x%08x : Accessible Space as ECC Area\n", - SH7757LCR_SDRAM_PHYS_TOP, - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_SDRAM_SIZE - 1); - printf(" 0x%08x - 0x%08x : No Access Area\n", - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_SDRAM_SIZE, - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_SDRAM_SIZE * 2 - 1); - printf(" 0x%08x - 0x%08x : Non-ECC Area for DVC/AVC\n", - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_SDRAM_ECC_SETTING * 2, - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_SDRAM_ECC_SETTING * 2 + - SH7757LCR_SDRAM_DVC_SIZE - 1); - printf(" 0x%08x - 0x%08x : Non-ECC Area for G200eR2\n", - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_GRA_OFFSET, - SH7757LCR_SDRAM_PHYS_TOP + SH7757LCR_GRA_OFFSET + 0x00ffffff); - - return 0; -} - int board_mmc_init(bd_t *bis) { return mmcif_mmc_init(); diff --git a/board/renesas/sh7763rdp/sh7763rdp.c b/board/renesas/sh7763rdp/sh7763rdp.c index 9658a5e440..d83e2f83b2 100644 --- a/board/renesas/sh7763rdp/sh7763rdp.c +++ b/board/renesas/sh7763rdp/sh7763rdp.c @@ -12,8 +12,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - #define CPU_CMDREG 0xB1000006 #define PDCR 0xffef0006 #define PECR 0xffef0008 @@ -51,14 +49,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - void led_set_state(unsigned short value) { } diff --git a/board/renesas/sh7785lcr/sh7785lcr.c b/board/renesas/sh7785lcr/sh7785lcr.c index 622e602613..a1a0301971 100644 --- a/board/renesas/sh7785lcr/sh7785lcr.c +++ b/board/renesas/sh7785lcr/sh7785lcr.c @@ -10,8 +10,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - int checkboard(void) { puts("BOARD: Renesas Technology Corp. R0P7785LC0011RL\n"); @@ -23,14 +21,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - static struct pci_controller hose; void pci_init_board(void) { diff --git a/board/shmin/shmin.c b/board/shmin/shmin.c index 74d1e39734..42bd1261b2 100644 --- a/board/shmin/shmin.c +++ b/board/shmin/shmin.c @@ -33,16 +33,6 @@ int board_init(void) return 0; } -int dram_init(void) -{ - DECLARE_GLOBAL_DATA_PTR; - - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; - printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024)); - return 0; -} - int board_eth_init(bd_t *bis) { return ne2k_register();