setup.c 3.3 KB

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