Fixed tools/env utilities
[u-boot-openmoko/mini2440.git] / board / bmw / bmw.c
blob485e050b19a65319a5b272326b32ff64193a4ec5
1 /*
2 * (C) Copyright 2002
3 * James F. Dougherty, Broadcom Corporation, jfd@broadcom.com
5 * See file CREDITS for list of people who contributed to this
6 * project.
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.
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.
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
24 #include <common.h>
25 #include <common.h>
26 #include <watchdog.h>
27 #include <command.h>
28 #include <malloc.h>
29 #include <devices.h>
30 #include <net.h>
31 #include <version.h>
32 #include <dtt.h>
33 #include <mpc824x.h>
34 #include <asm/processor.h>
35 #include <linux/mtd/doc2000.h>
37 #include "bmw.h"
38 #include "m48t59y.h"
39 #include <pci.h>
42 int checkboard(void)
44 ulong busfreq = get_bus_freq(0);
45 char buf[32];
47 puts ("Board: BMW MPC8245/KAHLUA2 - CHRP (MAP B)\n");
48 printf("Built: %s at %s\n", __DATE__ , __TIME__ );
49 /* printf("MPLD: Revision %d\n", SYS_REVID_GET()); */
50 printf("Local Bus at %s MHz\n", strmhz(buf, busfreq));
51 return 0;
54 long int initdram(int board_type)
56 return 64*1024*1024;
60 void
61 get_tod(void)
63 int year, month, day, hour, minute, second;
65 m48_tod_get(&year,
66 &month,
67 &day,
68 &hour,
69 &minute,
70 &second);
72 printf(" Current date/time: %d/%d/%d %d:%d:%d \n",
73 month, day, year, hour, minute, second);
78 * EPIC, PCI, and I/O devices.
79 * Initialize Mousse Platform, probe for PCI devices,
80 * Query configuration parameters if not set.
82 int misc_init_f (void)
84 #if 0
85 m48_tod_init(); /* Init SGS M48T59Y TOD/NVRAM */
86 printf("RTC: M48T589 TOD/NVRAM (%d) bytes\n",
87 TOD_NVRAM_SIZE);
88 get_tod();
89 #endif
91 sys_led_msg("BOOT");
92 return 0;
97 * Initialize PCI Devices, report devices found.
99 struct pci_controller hose;
101 void pci_init_board (void)
103 pci_mpc824x_init(&hose);
104 /* pci_dev_init(0); */
108 * Write characters to LCD display.
109 * Note that the bytes for the first character is the last address.
111 void
112 sys_led_msg(char* msg)
114 LED_REG(0) = msg[3];
115 LED_REG(1) = msg[2];
116 LED_REG(2) = msg[1];
117 LED_REG(3) = msg[0];
121 * Map onboard TSOP-16MB DOC FLASH chip.
123 void doc_init (void)
125 doc_probe(DOC_BASE_ADDR);
128 #define NV_ADDR ((volatile unsigned char *) CFG_ENV_ADDR)
130 /* Read from NVRAM */
131 void*
132 nvram_read(void *dest, const long src, size_t count)
134 int i;
135 volatile unsigned char* d = (unsigned char*)dest;
136 volatile unsigned char* s = (unsigned char*)src;
138 for( i = 0; i < count;i++)
139 d[i] = s[i];
141 return dest;
144 /* Write to NVRAM */
145 void
146 nvram_write(long dest, const void *src, size_t count)
148 int i;
149 volatile unsigned char* d = (unsigned char*)dest;
150 volatile unsigned char* s = (unsigned char*)src;
152 SYS_TOD_UNPROTECT();
154 for( i = 0; i < count;i++)
155 d[i] = s[i];
157 SYS_TOD_PROTECT();