excite_prom.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2004, 2005 by Thomas Koeller (thomas.koeller@baslerweb.com)
  3. * Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
  4. * Manish Lachwani.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/sched.h>
  22. #include <linux/mm.h>
  23. #include <linux/delay.h>
  24. #include <linux/smp.h>
  25. #include <linux/module.h>
  26. #include <asm/io.h>
  27. #include <asm/pgtable.h>
  28. #include <asm/processor.h>
  29. #include <asm/reboot.h>
  30. #include <asm/system.h>
  31. #include <asm/bootinfo.h>
  32. #include <asm/string.h>
  33. #include <excite.h>
  34. /* This struct is used by Redboot to pass arguments to the kernel */
  35. typedef struct
  36. {
  37. char *name;
  38. char *val;
  39. } t_env_var;
  40. struct parmblock {
  41. t_env_var memsize;
  42. t_env_var modetty0;
  43. t_env_var ethaddr;
  44. t_env_var env_end;
  45. char *argv[2];
  46. char text[0];
  47. };
  48. static unsigned int prom_argc;
  49. static const char ** prom_argv;
  50. static const t_env_var * prom_env;
  51. static void prom_halt(void) __attribute__((noreturn));
  52. static void prom_exit(void) __attribute__((noreturn));
  53. const char *get_system_type(void)
  54. {
  55. return "Basler eXcite";
  56. }
  57. /*
  58. * Halt the system
  59. */
  60. static void prom_halt(void)
  61. {
  62. printk(KERN_NOTICE "\n** System halted.\n");
  63. while (1)
  64. asm volatile (
  65. "\t.set\tmips3\n"
  66. "\twait\n"
  67. "\t.set\tmips0\n"
  68. );
  69. }
  70. /*
  71. * Reset the CPU and re-enter Redboot
  72. */
  73. static void prom_exit(void)
  74. {
  75. unsigned int i;
  76. volatile unsigned char * const flg =
  77. (volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_DPR);
  78. /* Clear the watchdog reset flag, set the reboot flag */
  79. *flg &= ~0x01;
  80. *flg |= 0x80;
  81. for (i = 0; i < 10; i++) {
  82. *(volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_SYSCTL) = 0x02;
  83. iob();
  84. mdelay(1000);
  85. }
  86. printk(KERN_NOTICE "Reset failed\n");
  87. prom_halt();
  88. }
  89. static const char __init *prom_getenv(char *name)
  90. {
  91. const t_env_var * p;
  92. for (p = prom_env; p->name != NULL; p++)
  93. if(strcmp(name, p->name) == 0)
  94. break;
  95. return p->val;
  96. }
  97. /*
  98. * Init routine which accepts the variables from Redboot
  99. */
  100. void __init prom_init(void)
  101. {
  102. const struct parmblock * const pb = (struct parmblock *) fw_arg2;
  103. prom_argc = fw_arg0;
  104. prom_argv = (const char **) fw_arg1;
  105. prom_env = &pb->memsize;
  106. /* Callbacks for halt, restart */
  107. _machine_restart = (void (*)(char *)) prom_exit;
  108. _machine_halt = prom_halt;
  109. #ifdef CONFIG_32BIT
  110. /* copy command line */
  111. strcpy(arcs_cmdline, prom_argv[1]);
  112. memsize = simple_strtol(prom_getenv("memsize"), NULL, 16);
  113. strcpy(modetty, prom_getenv("modetty0"));
  114. #endif /* CONFIG_32BIT */
  115. #ifdef CONFIG_64BIT
  116. # error 64 bit support not implemented
  117. #endif /* CONFIG_64BIT */
  118. }
  119. /* This is called from free_initmem(), so we need to provide it */
  120. void __init prom_free_prom_memory(void)
  121. {
  122. /* Nothing to do */
  123. }