prom.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * PROM interface routines.
  4. */
  5. #include <linux/types.h>
  6. #include <linux/init.h>
  7. #include <linux/string.h>
  8. #include <linux/ctype.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mm.h>
  11. #include <linux/bootmem.h>
  12. #include <linux/ioport.h>
  13. #include <asm/bootinfo.h>
  14. #include <asm/lasat/lasat.h>
  15. #include <asm/cpu.h>
  16. #include <asm/setup.h>
  17. #include "at93c.h"
  18. #include <asm/lasat/eeprom.h>
  19. #include "prom.h"
  20. #define RESET_VECTOR 0xbfc00000
  21. #define PROM_JUMP_TABLE_ENTRY(n) (*((u32 *)(RESET_VECTOR + 0x20) + n))
  22. #define PROM_DISPLAY_ADDR PROM_JUMP_TABLE_ENTRY(0)
  23. #define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
  24. #define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
  25. static void null_prom_display(const char *string, int pos, int clear)
  26. {
  27. }
  28. static void null_prom_monitor(void)
  29. {
  30. }
  31. static void null_prom_putc(char c)
  32. {
  33. }
  34. /* these are functions provided by the bootloader */
  35. static void (*__prom_putc)(char c) = null_prom_putc;
  36. void prom_putchar(char c)
  37. {
  38. __prom_putc(c);
  39. }
  40. void (*prom_display)(const char *string, int pos, int clear) =
  41. null_prom_display;
  42. void (*prom_monitor)(void) = null_prom_monitor;
  43. unsigned int lasat_ndelay_divider;
  44. static void setup_prom_vectors(void)
  45. {
  46. u32 version = *(u32 *)(RESET_VECTOR + 0x90);
  47. if (version >= 307) {
  48. prom_display = (void *)PROM_DISPLAY_ADDR;
  49. __prom_putc = (void *)PROM_PUTC_ADDR;
  50. prom_monitor = (void *)PROM_MONITOR_ADDR;
  51. }
  52. printk(KERN_DEBUG "prom vectors set up\n");
  53. }
  54. static struct at93c_defs at93c_defs[N_MACHTYPES] = {
  55. {
  56. .reg = (void *)AT93C_REG_100,
  57. .rdata_reg = (void *)AT93C_RDATA_REG_100,
  58. .rdata_shift = AT93C_RDATA_SHIFT_100,
  59. .wdata_shift = AT93C_WDATA_SHIFT_100,
  60. .cs = AT93C_CS_M_100,
  61. .clk = AT93C_CLK_M_100
  62. }, {
  63. .reg = (void *)AT93C_REG_200,
  64. .rdata_reg = (void *)AT93C_RDATA_REG_200,
  65. .rdata_shift = AT93C_RDATA_SHIFT_200,
  66. .wdata_shift = AT93C_WDATA_SHIFT_200,
  67. .cs = AT93C_CS_M_200,
  68. .clk = AT93C_CLK_M_200
  69. },
  70. };
  71. void __init prom_init(void)
  72. {
  73. int argc = fw_arg0;
  74. char **argv = (char **) fw_arg1;
  75. setup_prom_vectors();
  76. if (IS_LASAT_200()) {
  77. printk(KERN_INFO "LASAT 200 board\n");
  78. lasat_ndelay_divider = LASAT_200_DIVIDER;
  79. at93c = &at93c_defs[1];
  80. } else {
  81. printk(KERN_INFO "LASAT 100 board\n");
  82. lasat_ndelay_divider = LASAT_100_DIVIDER;
  83. at93c = &at93c_defs[0];
  84. }
  85. lasat_init_board_info(); /* Read info from EEPROM */
  86. /* Get the command line */
  87. if (argc > 0) {
  88. strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1);
  89. arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0';
  90. }
  91. /* Set the I/O base address */
  92. set_io_port_base(KSEG1);
  93. /* Set memory regions */
  94. ioport_resource.start = 0;
  95. ioport_resource.end = 0xffffffff; /* Wrong, fixme. */
  96. add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
  97. }
  98. void __init prom_free_prom_memory(void)
  99. {
  100. }
  101. const char *get_system_type(void)
  102. {
  103. return lasat_board_info.li_bmstr;
  104. }