excite_prom.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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/config.h>
  21. #include <linux/init.h>
  22. #include <linux/sched.h>
  23. #include <linux/mm.h>
  24. #include <linux/delay.h>
  25. #include <linux/smp.h>
  26. #include <linux/module.h>
  27. #include <asm/io.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/processor.h>
  30. #include <asm/reboot.h>
  31. #include <asm/system.h>
  32. #include <asm/bootinfo.h>
  33. #include <asm/string.h>
  34. #include <excite.h>
  35. /* This struct is used by Redboot to pass arguments to the kernel */
  36. typedef struct
  37. {
  38. char *name;
  39. char *val;
  40. } t_env_var;
  41. struct parmblock {
  42. t_env_var memsize;
  43. t_env_var modetty0;
  44. t_env_var ethaddr;
  45. t_env_var env_end;
  46. char *argv[2];
  47. char text[0];
  48. };
  49. static unsigned int prom_argc;
  50. static const char ** prom_argv;
  51. static const t_env_var * prom_env;
  52. static void prom_halt(void) __attribute__((noreturn));
  53. static void prom_exit(void) __attribute__((noreturn));
  54. const char *get_system_type(void)
  55. {
  56. return "Basler eXcite";
  57. }
  58. /*
  59. * Halt the system
  60. */
  61. static void prom_halt(void)
  62. {
  63. printk(KERN_NOTICE "\n** System halted.\n");
  64. while (1)
  65. asm volatile (
  66. "\t.set\tmips3\n"
  67. "\twait\n"
  68. "\t.set\tmips0\n"
  69. );
  70. }
  71. /*
  72. * Reset the CPU and re-enter Redboot
  73. */
  74. static void prom_exit(void)
  75. {
  76. unsigned int i;
  77. volatile unsigned char * const flg =
  78. (volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_DPR);
  79. /* Clear the watchdog reset flag, set the reboot flag */
  80. *flg &= ~0x01;
  81. *flg |= 0x80;
  82. for (i = 0; i < 10; i++) {
  83. *(volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_SYSCTL) = 0x02;
  84. iob();
  85. mdelay(1000);
  86. }
  87. printk(KERN_NOTICE "Reset failed\n");
  88. prom_halt();
  89. }
  90. static const char __init *prom_getenv(char *name)
  91. {
  92. const t_env_var * p;
  93. for (p = prom_env; p->name != NULL; p++)
  94. if(strcmp(name, p->name) == 0)
  95. break;
  96. return p->val;
  97. }
  98. /*
  99. * Init routine which accepts the variables from Redboot
  100. */
  101. void __init prom_init(void)
  102. {
  103. const struct parmblock * const pb = (struct parmblock *) fw_arg2;
  104. prom_argc = fw_arg0;
  105. prom_argv = (const char **) fw_arg1;
  106. prom_env = &pb->memsize;
  107. /* Callbacks for halt, restart */
  108. _machine_restart = (void (*)(char *)) prom_exit;
  109. _machine_halt = prom_halt;
  110. #ifdef CONFIG_32BIT
  111. /* copy command line */
  112. strcpy(arcs_cmdline, prom_argv[1]);
  113. memsize = simple_strtol(prom_getenv("memsize"), NULL, 16);
  114. strcpy(modetty, prom_getenv("modetty0"));
  115. #endif /* CONFIG_32BIT */
  116. #ifdef CONFIG_64BIT
  117. # error 64 bit support not implemented
  118. #endif /* CONFIG_64BIT */
  119. mips_machgroup = MACH_GROUP_TITAN;
  120. mips_machtype = MACH_TITAN_EXCITE;
  121. }
  122. /* This is called from free_initmem(), so we need to provide it */
  123. void __init prom_free_prom_memory(void)
  124. {
  125. /* Nothing to do */
  126. }