wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 ELTEC Elektronik AG |
| 3 | * Frank Gottschling <fgottschling@eltec.de> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <mpc106.h> |
| 11 | #include <video_fb.h> |
Ben Warren | 10efa02 | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 12 | #include <netdev.h> |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 13 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 16 | /* ------------------------------------------------------------------------- */ |
| 17 | |
| 18 | int checkboard (void) |
| 19 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 20 | puts ("Board: ELTEC PowerPC\n"); |
| 21 | return (0); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | /* ------------------------------------------------------------------------- */ |
| 25 | |
| 26 | int checkflash (void) |
| 27 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 28 | /* TODO */ |
| 29 | printf ("Test not implemented !\n"); |
| 30 | return (0); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | /* ------------------------------------------------------------------------- */ |
| 34 | |
| 35 | static unsigned int mpc106_read_cfg_dword (unsigned int reg) |
| 36 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 37 | unsigned int reg_addr = MPC106_REG | (reg & 0xFFFFFFFC); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 38 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 39 | out32r (MPC106_REG_ADDR, reg_addr); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 40 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 41 | return (in32r (MPC106_REG_DATA | (reg & 0x3))); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /* ------------------------------------------------------------------------- */ |
| 45 | |
| 46 | long int dram_size (int board_type) |
| 47 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | /* |
| 49 | * No actual initialisation to do - done when setting up |
| 50 | * PICRs MCCRs ME/SARs etc in asm_init.S. |
| 51 | */ |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 52 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 53 | register unsigned long i, msar1, mear1, memSize; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 54 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | #if defined(CONFIG_SYS_MEMTEST) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 56 | register unsigned long reg; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 57 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 58 | printf ("Testing DRAM\n"); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 59 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 60 | /* write each mem addr with it's address */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 61 | for (reg = CONFIG_SYS_MEMTEST_START; reg < CONFIG_SYS_MEMTEST_END; reg += 4) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 62 | *reg = reg; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 63 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | for (reg = CONFIG_SYS_MEMTEST_START; reg < CONFIG_SYS_MEMTEST_END; reg += 4) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 65 | if (*reg != reg) |
| 66 | return -1; |
| 67 | } |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 68 | #endif |
| 69 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 70 | /* |
| 71 | * Since MPC107 memory controller chip has already been set to |
| 72 | * control all memory, just read and interpret its memory boundery register. |
| 73 | */ |
| 74 | memSize = 0; |
| 75 | msar1 = mpc106_read_cfg_dword (MPC106_MSAR1); |
| 76 | mear1 = mpc106_read_cfg_dword (MPC106_MEAR1); |
| 77 | i = mpc106_read_cfg_dword (MPC106_MBER) & 0xf; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 78 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 79 | do { |
| 80 | if (i & 0x01) /* is bank enabled ? */ |
| 81 | memSize += (mear1 & 0xff) - (msar1 & 0xff) + 1; |
| 82 | msar1 >>= 8; |
| 83 | mear1 >>= 8; |
| 84 | i >>= 1; |
| 85 | } while (i); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 86 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 87 | return (memSize * 0x100000); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 88 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 89 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 90 | /* ------------------------------------------------------------------------- */ |
| 91 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 92 | phys_size_t initdram (int board_type) |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 93 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 94 | return dram_size (board_type); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | /* ------------------------------------------------------------------------- */ |
| 98 | |
| 99 | /* |
| 100 | * The BAB 911 can be reset by writing bit 0 of the Processor Initialization |
| 101 | * Register PI in the MPC 107 (at offset 0x41090 of the Embedded Utilities |
| 102 | * Memory Block). |
| 103 | */ |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 104 | int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 105 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 106 | out8 (MPC107_EUMB_PI, 1); |
| 107 | return (0); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /* ------------------------------------------------------------------------- */ |
| 111 | |
| 112 | #if defined(CONFIG_WATCHDOG) |
| 113 | |
| 114 | /* |
| 115 | * Since the 7xx CPUs don't have an internal watchdog, this function is |
| 116 | * board specific. |
| 117 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 118 | void watchdog_reset (void) |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 119 | { |
| 120 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 121 | #endif /* CONFIG_WATCHDOG */ |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 122 | |
| 123 | /* ------------------------------------------------------------------------- */ |
| 124 | |
| 125 | void after_reloc (ulong dest_addr) |
| 126 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 127 | /* |
| 128 | * Jump to the main U-Boot board init code |
| 129 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 130 | board_init_r ((gd_t *)gd, dest_addr); |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | /* ------------------------------------------------------------------------- */ |
| 134 | |
| 135 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 136 | extern GraphicDevice smi; |
| 137 | |
| 138 | void video_get_info_str (int line_number, char *info) |
| 139 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 140 | /* init video info strings for graphic console */ |
| 141 | switch (line_number) { |
| 142 | case 1: |
| 143 | sprintf (info, " MPC7xx V%d.%d at %d / %d MHz", |
| 144 | (get_pvr () >> 8) & 0xFF, get_pvr () & 0xFF, 400, 100); |
| 145 | return; |
| 146 | case 2: |
| 147 | sprintf (info, " ELTEC ELPPC with %ld MB DRAM and %ld MB FLASH", |
| 148 | dram_size (0) / 0x100000, flash_init () / 0x100000); |
| 149 | return; |
| 150 | case 3: |
| 151 | sprintf (info, " %s", smi.modeIdent); |
| 152 | return; |
| 153 | } |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 154 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 155 | /* no more info lines */ |
| 156 | *info = 0; |
| 157 | return; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 158 | } |
| 159 | #endif |
Ben Warren | 10efa02 | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 160 | |
| 161 | int board_eth_init(bd_t *bis) |
| 162 | { |
| 163 | return pci_eth_init(bis); |
| 164 | } |