]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/bmw/bmw.c
* Code cleanup:
[karo-tx-uboot.git] / board / bmw / bmw.c
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>
25 #include <common.h>
26 #include <watchdog.h>
27 #include <command.h>
28 #include <malloc.h>
29 #include <devices.h>
30 #include <syscall.h>
31 #include <net.h>
32 #include <version.h>
33 #include <dtt.h>
34 #include <mpc824x.h>
35 #include <asm/processor.h>
36 #include <linux/mtd/doc2000.h>
37
38 #include "bmw.h"
39 #include "m48t59y.h"
40 #include <pci.h>
41
42
43 int checkboard(void)
44 {
45     ulong busfreq  = get_bus_freq(0);
46     char  buf[32];
47
48     puts ("Board: BMW MPC8245/KAHLUA2 - CHRP (MAP B)\n");
49     printf("Built: %s at %s\n", __DATE__ , __TIME__ );
50     /* printf("MPLD:  Revision %d\n", SYS_REVID_GET()); */
51     printf("Local Bus at %s MHz\n", strmhz(buf, busfreq));
52     return 0;
53 }
54
55 long int initdram(int board_type)
56 {
57     return 64*1024*1024;
58 }
59
60
61 void
62 get_tod(void)
63 {
64     int year, month, day, hour, minute, second;
65
66     m48_tod_get(&year,
67                 &month,
68                 &day,
69                 &hour,
70                 &minute,
71                 &second);
72
73     printf("  Current date/time: %d/%d/%d %d:%d:%d \n",
74            month, day, year, hour, minute, second);
75
76 }
77
78 /*
79  * EPIC, PCI, and I/O devices.
80  * Initialize Mousse Platform, probe for PCI devices,
81  * Query configuration parameters if not set.
82  */
83 int misc_init_f (void)
84 {
85 #if 0
86     m48_tod_init(); /* Init SGS M48T59Y TOD/NVRAM */
87     printf("RTC:   M48T589 TOD/NVRAM (%d) bytes\n",
88            TOD_NVRAM_SIZE);
89     get_tod();
90 #endif
91
92     sys_led_msg("BOOT");
93     return 0;
94 }
95
96
97 /*
98  * Initialize PCI Devices, report devices found.
99  */
100 struct pci_controller hose;
101
102 void pci_init_board (void)
103 {
104     pci_mpc824x_init(&hose);
105     /* pci_dev_init(0); */
106 }
107
108 /*
109  * Write characters to LCD display.
110  * Note that the bytes for the first character is the last address.
111  */
112 void
113 sys_led_msg(char* msg)
114 {
115     LED_REG(0) = msg[3];
116     LED_REG(1) = msg[2];
117     LED_REG(2) = msg[1];
118     LED_REG(3) = msg[0];
119 }
120
121 /*
122  * Map onboard TSOP-16MB DOC FLASH chip.
123  */
124 void doc_init (void)
125 {
126     doc_probe(DOC_BASE_ADDR);
127 }
128
129 #define NV_ADDR ((volatile unsigned char *) CFG_ENV_ADDR)
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 }