prom.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * PROM interface routines.
  3. */
  4. #include <linux/types.h>
  5. #include <linux/init.h>
  6. #include <linux/string.h>
  7. #include <linux/ctype.h>
  8. #include <linux/kernel.h>
  9. #include <linux/mm.h>
  10. #include <linux/bootmem.h>
  11. #include <linux/ioport.h>
  12. #include <asm/bootinfo.h>
  13. #include <asm/lasat/lasat.h>
  14. #include <asm/cpu.h>
  15. #include "at93c.h"
  16. #include <asm/lasat/eeprom.h>
  17. #include "prom.h"
  18. #define RESET_VECTOR 0xbfc00000
  19. #define PROM_JUMP_TABLE_ENTRY(n) (*((u32 *)(RESET_VECTOR + 0x20) + n))
  20. #define PROM_DISPLAY_ADDR PROM_JUMP_TABLE_ENTRY(0)
  21. #define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
  22. #define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
  23. static void null_prom_printf(const char * fmt, ...)
  24. {
  25. }
  26. static void null_prom_display(const char *string, int pos, int clear)
  27. {
  28. }
  29. static void null_prom_monitor(void)
  30. {
  31. }
  32. static void null_prom_putc(char c)
  33. {
  34. }
  35. /* these are functions provided by the bootloader */
  36. static void (* prom_putc)(char c) = null_prom_putc;
  37. void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
  38. void (* prom_display)(const char *string, int pos, int clear) =
  39. null_prom_display;
  40. void (* prom_monitor)(void) = null_prom_monitor;
  41. unsigned int lasat_ndelay_divider;
  42. #define PROM_PRINTFBUF_SIZE 256
  43. static char prom_printfbuf[PROM_PRINTFBUF_SIZE];
  44. static void real_prom_printf(const char * fmt, ...)
  45. {
  46. va_list ap;
  47. int len;
  48. char *c = prom_printfbuf;
  49. int i;
  50. va_start(ap, fmt);
  51. len = vsnprintf(prom_printfbuf, PROM_PRINTFBUF_SIZE, fmt, ap);
  52. va_end(ap);
  53. /* output overflowed the buffer */
  54. if (len < 0 || len > PROM_PRINTFBUF_SIZE)
  55. len = PROM_PRINTFBUF_SIZE;
  56. for (i=0; i < len; i++) {
  57. if (*c == '\n')
  58. prom_putc('\r');
  59. prom_putc(*c++);
  60. }
  61. }
  62. static void setup_prom_vectors(void)
  63. {
  64. u32 version = *(u32 *)(RESET_VECTOR + 0x90);
  65. if (version >= 307) {
  66. prom_display = (void *)PROM_DISPLAY_ADDR;
  67. prom_putc = (void *)PROM_PUTC_ADDR;
  68. prom_printf = real_prom_printf;
  69. prom_monitor = (void *)PROM_MONITOR_ADDR;
  70. }
  71. prom_printf("prom vectors set up\n");
  72. }
  73. static struct at93c_defs at93c_defs[N_MACHTYPES] = {
  74. {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100,
  75. AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100},
  76. {(void *)AT93C_REG_200, (void *)AT93C_RDATA_REG_200, AT93C_RDATA_SHIFT_200,
  77. AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200},
  78. };
  79. void __init prom_init(void)
  80. {
  81. int argc = fw_arg0;
  82. char **argv = (char **) fw_arg1;
  83. setup_prom_vectors();
  84. if (current_cpu_data.cputype == CPU_R5000) {
  85. prom_printf("LASAT 200 board\n");
  86. mips_machtype = MACH_LASAT_200;
  87. lasat_ndelay_divider = LASAT_200_DIVIDER;
  88. } else {
  89. prom_printf("LASAT 100 board\n");
  90. mips_machtype = MACH_LASAT_100;
  91. lasat_ndelay_divider = LASAT_100_DIVIDER;
  92. }
  93. at93c = &at93c_defs[mips_machtype];
  94. lasat_init_board_info(); /* Read info from EEPROM */
  95. mips_machgroup = MACH_GROUP_LASAT;
  96. /* Get the command line */
  97. if (argc > 0) {
  98. strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
  99. arcs_cmdline[CL_SIZE-1] = '\0';
  100. }
  101. /* Set the I/O base address */
  102. set_io_port_base(KSEG1);
  103. /* Set memory regions */
  104. ioport_resource.start = 0;
  105. ioport_resource.end = 0xffffffff; /* Wrong, fixme. */
  106. add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
  107. }
  108. unsigned long __init prom_free_prom_memory(void)
  109. {
  110. return 0;
  111. }
  112. const char *get_system_type(void)
  113. {
  114. return lasat_board_info.li_bmstr;
  115. }