setup.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * arch/mips/emma2rh/markeins/setup.c
  3. * This file is setup for EMMA2RH Mark-eins.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2004-2006
  6. *
  7. * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c.
  8. *
  9. * Copyright 2001 MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/init.h>
  26. #include <linux/kernel.h>
  27. #include <linux/types.h>
  28. #include <asm/time.h>
  29. #include <asm/reboot.h>
  30. #include <asm/emma/emma2rh.h>
  31. #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
  32. extern void markeins_led(const char *);
  33. static int bus_frequency = 0;
  34. static void markeins_machine_restart(char *command)
  35. {
  36. static void (*back_to_prom) (void) = (void (*)(void))0xbfc00000;
  37. printk("cannot EMMA2RH Mark-eins restart.\n");
  38. markeins_led("restart.");
  39. back_to_prom();
  40. }
  41. static void markeins_machine_halt(void)
  42. {
  43. printk("EMMA2RH Mark-eins halted.\n");
  44. markeins_led("halted.");
  45. while (1) ;
  46. }
  47. static void markeins_machine_power_off(void)
  48. {
  49. printk("EMMA2RH Mark-eins halted. Please turn off the power.\n");
  50. markeins_led("poweroff.");
  51. while (1) ;
  52. }
  53. static unsigned long __initdata emma2rh_clock[4] = {
  54. 166500000, 187312500, 199800000, 210600000
  55. };
  56. static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
  57. {
  58. u32 reg;
  59. /* detect from boot strap */
  60. reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
  61. reg = (reg >> 4) & 0x3;
  62. return emma2rh_clock[reg];
  63. }
  64. void __init plat_time_init(void)
  65. {
  66. u32 reg;
  67. if (bus_frequency == 0)
  68. bus_frequency = detect_bus_frequency(0);
  69. reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
  70. if ((reg & 0x3) == 0)
  71. reg = (reg >> 6) & 0x3;
  72. else {
  73. reg = emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL);
  74. reg = (reg >> 4) & 0x3;
  75. }
  76. mips_hpt_frequency = (bus_frequency * (4 + reg)) / 4 / 2;
  77. }
  78. static void markeins_board_init(void);
  79. extern void markeins_irq_setup(void);
  80. static void inline __init markeins_sio_setup(void)
  81. {
  82. }
  83. void __init plat_mem_setup(void)
  84. {
  85. /* initialize board - we don't trust the loader */
  86. markeins_board_init();
  87. set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE));
  88. _machine_restart = markeins_machine_restart;
  89. _machine_halt = markeins_machine_halt;
  90. pm_power_off = markeins_machine_power_off;
  91. /* setup resource limits */
  92. ioport_resource.start = EMMA2RH_PCI_IO_BASE;
  93. ioport_resource.end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1;
  94. iomem_resource.start = EMMA2RH_IO_BASE;
  95. iomem_resource.end = EMMA2RH_ROM_BASE - 1;
  96. /* Reboot on panic */
  97. panic_timeout = 180;
  98. markeins_sio_setup();
  99. }
  100. static void __init markeins_board_init(void)
  101. {
  102. u32 val;
  103. val = emma2rh_in32(EMMA2RH_PBRD_INT_EN); /* open serial interrupts. */
  104. emma2rh_out32(EMMA2RH_PBRD_INT_EN, val | 0xaa);
  105. val = emma2rh_in32(EMMA2RH_PBRD_CLKSEL); /* set serial clocks. */
  106. emma2rh_out32(EMMA2RH_PBRD_CLKSEL, val | 0x5); /* 18MHz */
  107. emma2rh_out32(EMMA2RH_PCI_CONTROL, 0);
  108. markeins_led("MVL E2RH");
  109. }