wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * James F. Dougherty, Broadcom Corporation, jfd@broadcom.com |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 25 | #include <watchdog.h> |
| 26 | #include <command.h> |
| 27 | #include <malloc.h> |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 28 | #include <stdio_dev.h> |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 29 | #include <net.h> |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 30 | #include <timestamp.h> |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 31 | #include <dtt.h> |
| 32 | #include <mpc824x.h> |
| 33 | #include <asm/processor.h> |
| 34 | #include <linux/mtd/doc2000.h> |
| 35 | |
| 36 | #include "bmw.h" |
| 37 | #include "m48t59y.h" |
| 38 | #include <pci.h> |
| 39 | |
| 40 | |
| 41 | int checkboard(void) |
| 42 | { |
| 43 | ulong busfreq = get_bus_freq(0); |
| 44 | char buf[32]; |
| 45 | |
| 46 | puts ("Board: BMW MPC8245/KAHLUA2 - CHRP (MAP B)\n"); |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 47 | printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 48 | /* printf("MPLD: Revision %d\n", SYS_REVID_GET()); */ |
| 49 | printf("Local Bus at %s MHz\n", strmhz(buf, busfreq)); |
| 50 | return 0; |
| 51 | } |
| 52 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 53 | phys_size_t initdram(int board_type) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 54 | { |
| 55 | return 64*1024*1024; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | void |
| 60 | get_tod(void) |
| 61 | { |
| 62 | int year, month, day, hour, minute, second; |
| 63 | |
| 64 | m48_tod_get(&year, |
| 65 | &month, |
| 66 | &day, |
| 67 | &hour, |
| 68 | &minute, |
| 69 | &second); |
| 70 | |
| 71 | printf(" Current date/time: %d/%d/%d %d:%d:%d \n", |
| 72 | month, day, year, hour, minute, second); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * EPIC, PCI, and I/O devices. |
| 78 | * Initialize Mousse Platform, probe for PCI devices, |
| 79 | * Query configuration parameters if not set. |
| 80 | */ |
| 81 | int misc_init_f (void) |
| 82 | { |
| 83 | #if 0 |
| 84 | m48_tod_init(); /* Init SGS M48T59Y TOD/NVRAM */ |
| 85 | printf("RTC: M48T589 TOD/NVRAM (%d) bytes\n", |
| 86 | TOD_NVRAM_SIZE); |
| 87 | get_tod(); |
| 88 | #endif |
| 89 | |
| 90 | sys_led_msg("BOOT"); |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 95 | /* |
| 96 | * Initialize PCI Devices, report devices found. |
| 97 | */ |
| 98 | struct pci_controller hose; |
| 99 | |
stroese | ad10dd9 | 2003-02-14 11:21:23 +0000 | [diff] [blame] | 100 | void pci_init_board (void) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 101 | { |
| 102 | pci_mpc824x_init(&hose); |
| 103 | /* pci_dev_init(0); */ |
| 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Write characters to LCD display. |
| 108 | * Note that the bytes for the first character is the last address. |
| 109 | */ |
| 110 | void |
| 111 | sys_led_msg(char* msg) |
| 112 | { |
| 113 | LED_REG(0) = msg[3]; |
| 114 | LED_REG(1) = msg[2]; |
| 115 | LED_REG(2) = msg[1]; |
| 116 | LED_REG(3) = msg[0]; |
| 117 | } |
| 118 | |
Wolfgang Denk | 7640f41 | 2009-07-19 19:37:24 +0200 | [diff] [blame] | 119 | #ifdef CONFIG_CMD_DOC |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 120 | /* |
| 121 | * Map onboard TSOP-16MB DOC FLASH chip. |
| 122 | */ |
| 123 | void doc_init (void) |
| 124 | { |
| 125 | doc_probe(DOC_BASE_ADDR); |
| 126 | } |
Wolfgang Denk | 7640f41 | 2009-07-19 19:37:24 +0200 | [diff] [blame] | 127 | #endif |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 128 | |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 129 | #define NV_ADDR ((volatile unsigned char *) CONFIG_ENV_ADDR) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 130 | |
| 131 | /* Read from NVRAM */ |
| 132 | void* |
| 133 | nvram_read(void *dest, const long src, size_t count) |
| 134 | { |
| 135 | int i; |
| 136 | volatile unsigned char* d = (unsigned char*)dest; |
| 137 | volatile unsigned char* s = (unsigned char*)src; |
| 138 | |
| 139 | for( i = 0; i < count;i++) |
| 140 | d[i] = s[i]; |
| 141 | |
| 142 | return dest; |
| 143 | } |
| 144 | |
| 145 | /* Write to NVRAM */ |
| 146 | void |
| 147 | nvram_write(long dest, const void *src, size_t count) |
| 148 | { |
| 149 | int i; |
| 150 | volatile unsigned char* d = (unsigned char*)dest; |
| 151 | volatile unsigned char* s = (unsigned char*)src; |
| 152 | |
| 153 | SYS_TOD_UNPROTECT(); |
| 154 | |
| 155 | for( i = 0; i < count;i++) |
| 156 | d[i] = s[i]; |
| 157 | |
| 158 | SYS_TOD_PROTECT(); |
| 159 | } |