bmw.c 3.3 KB

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