sead3-init.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/io.h>
  10. #include <asm/bootinfo.h>
  11. #include <asm/cacheflush.h>
  12. #include <asm/traps.h>
  13. #include <asm/mips-boards/generic.h>
  14. #include <asm/mips-boards/prom.h>
  15. extern void prom_init_early_console(char port);
  16. extern char except_vec_nmi;
  17. extern char except_vec_ejtag_debug;
  18. int prom_argc;
  19. int *_prom_argv, *_prom_envp;
  20. #define prom_envp(index) ((char *)(long)_prom_envp[(index)])
  21. char *prom_getenv(char *envname)
  22. {
  23. /*
  24. * Return a pointer to the given environment variable.
  25. * In 64-bit mode: we're using 64-bit pointers, but all pointers
  26. * in the PROM structures are only 32-bit, so we need some
  27. * workarounds, if we are running in 64-bit mode.
  28. */
  29. int i, index = 0;
  30. i = strlen(envname);
  31. while (prom_envp(index)) {
  32. if (strncmp(envname, prom_envp(index), i) == 0)
  33. return prom_envp(index+1);
  34. index += 2;
  35. }
  36. return NULL;
  37. }
  38. static void __init mips_nmi_setup(void)
  39. {
  40. void *base;
  41. base = cpu_has_veic ?
  42. (void *)(CAC_BASE + 0xa80) :
  43. (void *)(CAC_BASE + 0x380);
  44. memcpy(base, &except_vec_nmi, 0x80);
  45. flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
  46. }
  47. static void __init mips_ejtag_setup(void)
  48. {
  49. void *base;
  50. base = cpu_has_veic ?
  51. (void *)(CAC_BASE + 0xa00) :
  52. (void *)(CAC_BASE + 0x300);
  53. memcpy(base, &except_vec_ejtag_debug, 0x80);
  54. flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
  55. }
  56. void __init prom_init(void)
  57. {
  58. prom_argc = fw_arg0;
  59. _prom_argv = (int *) fw_arg1;
  60. _prom_envp = (int *) fw_arg2;
  61. board_nmi_handler_setup = mips_nmi_setup;
  62. board_ejtag_handler_setup = mips_ejtag_setup;
  63. prom_init_cmdline();
  64. #ifdef CONFIG_EARLY_PRINTK
  65. if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL)
  66. prom_init_early_console(0);
  67. else if ((strstr(prom_getcmdline(), "console=ttyS1")) != NULL)
  68. prom_init_early_console(1);
  69. #endif
  70. #ifdef CONFIG_SERIAL_8250_CONSOLE
  71. if ((strstr(prom_getcmdline(), "console=")) == NULL)
  72. strcat(prom_getcmdline(), " console=ttyS0,38400n8r");
  73. #endif
  74. }
  75. void prom_free_prom_memory(void)
  76. {
  77. }