📄 hermes.c
字号:
/* * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@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 <common.h>#include <commproc.h>#include <mpc8xx.h>#ifdef CONFIG_SHOW_BOOT_PROGRESS# include <status_led.h># define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)#else# define SHOW_BOOT_PROGRESS(arg)#endif/* ------------------------------------------------------------------------- */static long int dram_size (long int, long int *, long int);static ulong board_init (void);static void send_smi_frame (volatile scc_t * sp, volatile cbd_t * bd, uchar * msg);/* ------------------------------------------------------------------------- */#define _NOT_USED_ 0xFFFFFFFFconst uint sdram_table[] = { /* * Single Read. (Offset 0 in UPMA RAM) */ 0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00, 0x1ff77c47, /* last */ /* * SDRAM Initialization (offset 5 in UPMA RAM) * * This is no UPM entry point. The following definition uses * the remaining space to establish an initialization * sequence, which is executed by a RUN command. * */ 0x1fe77c35, 0xffaffc34, 0x1fa57c35, /* last */ /* * Burst Read. (Offset 8 in UPMA RAM) */ 0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00, 0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47, /* last */ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, /* * Single Write. (Offset 18 in UPMA RAM) */ 0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47, /* last */ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, /* * Burst Write. (Offset 20 in UPMA RAM) */ 0x1f07fc04, 0xeeaebc00, 0x10ad4c00, 0xf0afcc00, 0xf0afcc00, 0xe1bb8c06, 0x1ff77c47, /* last */ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, /* * Refresh (Offset 30 in UPMA RAM) */ 0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc84, 0xfffffc07, /* last */ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, /* * Exception. (Offset 3c in UPMA RAM) */ 0x7ffffc07, /* last */ _NOT_USED_, _NOT_USED_, _NOT_USED_,};/* ------------------------------------------------------------------------- *//* * Check Board Identity: * * Test ID string (HERMES...) * * Return code for board revision and network speed */int checkboard (void){ DECLARE_GLOBAL_DATA_PTR; unsigned char *s = getenv ("serial#"); unsigned char *e; puts ("Board: "); if (!s || strncmp (s, "HERMES", 6)) { puts ("### No HW ID - assuming HERMES-PRO"); } else { for (e = s; *e; ++e) { if (*e == ' ') break; } for (; s < e; ++s) { putc (*s); } } gd->board_type = board_init (); printf (" Rev. %ld.x\n", (gd->board_type >> 16)); return (0);}/* ------------------------------------------------------------------------- */long int initdram (int board_type){ volatile immap_t *immap = (immap_t *) CFG_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; long int size, size8, size9; upmconfig (UPMA, (uint *) sdram_table, sizeof (sdram_table) / sizeof (uint)); /* * Preliminary prescaler for refresh */ memctl->memc_mptpr = 0x0400; memctl->memc_mar = 0x00000088; /* * Map controller banks 1 to the SDRAM banks at preliminary address */ memctl->memc_or1 = CFG_OR1_PRELIM; memctl->memc_br1 = CFG_BR1_PRELIM; /* HERMES-PRO boards have only one bank SDRAM */ udelay (200); /* perform SDRAM initializsation sequence */ memctl->memc_mamr = 0xD0802114; memctl->memc_mcr = 0x80002105; udelay (1); memctl->memc_mamr = 0xD0802118; memctl->memc_mcr = 0x80002130; udelay (1); memctl->memc_mamr = 0xD0802114; memctl->memc_mcr = 0x80002106; udelay (1000); /* * Check Bank 0 Memory Size for re-configuration * * try 8 column mode */ size8 = dram_size (CFG_MAMR_8COL, (ulong *) SDRAM_BASE_PRELIM, SDRAM_MAX_SIZE); udelay (1000); /* * try 9 column mode */ size9 = dram_size (CFG_MAMR_9COL, (ulong *) SDRAM_BASE_PRELIM, SDRAM_MAX_SIZE); if (size8 < size9) { /* leave configuration at 9 columns */ size = size9;/* debug ("SDRAM Bank 0 in 9 column mode: %ld MB\n", size >> 20); */ } else { /* back to 8 columns */ size = size8; memctl->memc_mamr = CFG_MAMR_8COL; udelay (500);/* debug ("SDRAM Bank 0 in 8 column mode: %ld MB\n", size >> 20); */ } udelay (1000); memctl->memc_or1 = ((-size) & 0xFFFF0000) | SDRAM_TIMING; memctl->memc_br1 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V; udelay (10000); return (size);}/* ------------------------------------------------------------------------- *//* * Check memory range for valid RAM. A simple memory test determines * the actually available RAM size between addresses `base' and * `base + maxsize'. Some (not all) hardware errors are detected: * - short between address lines * - short between data lines */static long int dram_size (long int mamr_value, long int *base, long int maxsize){ volatile immap_t *immap = (immap_t *) CFG_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; volatile long int *addr; ulong cnt, val; ulong save[32]; /* to make test non-destructive */ unsigned char i = 0; memctl->memc_mamr = mamr_value; for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) { addr = base + cnt; /* pointer arith! */ save[i++] = *addr; *addr = ~cnt; } /* write 0 to base address */ addr = base; save[i] = *addr; *addr = 0; /* check at base address */ if ((val = *addr) != 0) { *addr = save[i]; return (0); } for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) { addr = base + cnt; /* pointer arith! */ val = *addr; *addr = save[--i]; if (val != (~cnt)) { return (cnt * sizeof (long)); } } return (maxsize);}/* ------------------------------------------------------------------------- */#define PB_LED_3 0x00020000 /* Status LED's */#define PB_LED_2 0x00010000#define PB_LED_1 0x00008000#define PB_LED_0 0x00004000#define PB_LED_ALL (PB_LED_0 | PB_LED_1 | PB_LED_2 | PB_LED_3)#define PC_REP_SPD1 0x00000800#define PC_REP_SPD0 0x00000400#define PB_RESET_2081 0x00000020 /* Reset PEB2081 */#define PB_MAI_4 0x00000010 /* Configuration */#define PB_MAI_3 0x00000008#define PB_MAI_2 0x00000004#define PB_MAI_1 0x00000002#define PB_MAI_0 0x00000001#define PB_MAI_ALL (PB_MAI_0 | PB_MAI_1 | PB_MAI_2 | PB_MAI_3 | PB_MAI_4)#define PC_REP_MGRPRS 0x0200#define PC_REP_SPD 0x0040 /* Select 100 Mbps */#define PC_REP_RES 0x0004#define PC_BIT14 0x0002 /* ??? */#define PC_BIT15 0x0001 /* ??? ENDSL ?? *//* ------------------------------------------------------------------------- */static ulong board_init (void){ volatile immap_t *immr = (immap_t *) CFG_IMMR; ulong reg, revision, speed = 100; int ethspeed; char *s; if ((s = getenv ("ethspeed")) != NULL) { if (strcmp (s, "100") == 0) { ethspeed = 100; } else if (strcmp (s, "10") == 0) { ethspeed = 10; } else { ethspeed = 0; } } else { ethspeed = 0; } /* Configure Port B Output Pins => 0x0003cc3F */ reg = PB_LED_ALL | PC_REP_SPD1 | PC_REP_SPD0 | PB_RESET_2081 | PB_MAI_ALL; immr->im_cpm.cp_pbpar &= ~reg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -