adir_setup.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * arch/ppc/platforms/adir_setup.c
  3. *
  4. * Board setup routines for SBS Adirondack
  5. *
  6. * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
  7. * based on the K2 version by Matt Porter <mporter@mvista.com>
  8. */
  9. #include <linux/config.h>
  10. #include <linux/stddef.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/errno.h>
  14. #include <linux/reboot.h>
  15. #include <linux/pci.h>
  16. #include <linux/kdev_t.h>
  17. #include <linux/types.h>
  18. #include <linux/major.h>
  19. #include <linux/initrd.h>
  20. #include <linux/console.h>
  21. #include <linux/delay.h>
  22. #include <linux/ide.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <asm/system.h>
  26. #include <asm/pgtable.h>
  27. #include <asm/page.h>
  28. #include <asm/dma.h>
  29. #include <asm/io.h>
  30. #include <asm/machdep.h>
  31. #include <asm/time.h>
  32. #include <asm/todc.h>
  33. #include <asm/bootinfo.h>
  34. #include "adir.h"
  35. extern void adir_init_IRQ(void);
  36. extern int adir_get_irq(struct pt_regs *);
  37. extern void adir_find_bridges(void);
  38. extern unsigned long loops_per_jiffy;
  39. static unsigned int cpu_750cx[16] = {
  40. 5, 15, 14, 0, 4, 13, 0, 9, 6, 11, 8, 10, 16, 12, 7, 0
  41. };
  42. static int
  43. adir_get_bus_speed(void)
  44. {
  45. if (!(*((u_char *) ADIR_CLOCK_REG) & ADIR_CLOCK_REG_SEL133))
  46. return 100000000;
  47. else
  48. return 133333333;
  49. }
  50. static int
  51. adir_get_cpu_speed(void)
  52. {
  53. unsigned long hid1;
  54. int cpu_speed;
  55. hid1 = mfspr(SPRN_HID1) >> 28;
  56. hid1 = cpu_750cx[hid1];
  57. cpu_speed = adir_get_bus_speed()*hid1/2;
  58. return cpu_speed;
  59. }
  60. static void __init
  61. adir_calibrate_decr(void)
  62. {
  63. int freq, divisor = 4;
  64. /* determine processor bus speed */
  65. freq = adir_get_bus_speed();
  66. tb_ticks_per_jiffy = freq / HZ / divisor;
  67. tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
  68. }
  69. static int
  70. adir_show_cpuinfo(struct seq_file *m)
  71. {
  72. seq_printf(m, "vendor\t\t: SBS\n");
  73. seq_printf(m, "machine\t\t: Adirondack\n");
  74. seq_printf(m, "cpu speed\t: %dMhz\n", adir_get_cpu_speed()/1000000);
  75. seq_printf(m, "bus speed\t: %dMhz\n", adir_get_bus_speed()/1000000);
  76. seq_printf(m, "memory type\t: SDRAM\n");
  77. return 0;
  78. }
  79. extern char cmd_line[];
  80. TODC_ALLOC();
  81. static void __init
  82. adir_setup_arch(void)
  83. {
  84. unsigned int cpu;
  85. /* Setup TODC access */
  86. TODC_INIT(TODC_TYPE_MC146818, ADIR_NVRAM_RTC_ADDR, 0,
  87. ADIR_NVRAM_RTC_DATA, 8);
  88. /* init to some ~sane value until calibrate_delay() runs */
  89. loops_per_jiffy = 50000000/HZ;
  90. /* Setup PCI host bridges */
  91. adir_find_bridges();
  92. #ifdef CONFIG_BLK_DEV_INITRD
  93. if (initrd_start)
  94. ROOT_DEV = Root_RAM0;
  95. else
  96. #endif
  97. #ifdef CONFIG_ROOT_NFS
  98. ROOT_DEV = Root_NFS;
  99. #else
  100. ROOT_DEV = Root_SDA1;
  101. #endif
  102. /* Identify the system */
  103. printk("System Identification: SBS Adirondack - PowerPC 750CXe @ %d Mhz\n", adir_get_cpu_speed()/1000000);
  104. printk("SBS Adirondack port (C) 2001 SBS Technologies, Inc.\n");
  105. /* Identify the CPU manufacturer */
  106. cpu = mfspr(SPRN_PVR);
  107. printk("CPU manufacturer: IBM [rev=%04x]\n", (cpu & 0xffff));
  108. }
  109. static void
  110. adir_restart(char *cmd)
  111. {
  112. local_irq_disable();
  113. /* SRR0 has system reset vector, SRR1 has default MSR value */
  114. /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
  115. __asm__ __volatile__
  116. ("lis 3,0xfff0\n\t"
  117. "ori 3,3,0x0100\n\t"
  118. "mtspr 26,3\n\t"
  119. "li 3,0\n\t"
  120. "mtspr 27,3\n\t"
  121. "rfi\n\t");
  122. for(;;);
  123. }
  124. static void
  125. adir_power_off(void)
  126. {
  127. for(;;);
  128. }
  129. static void
  130. adir_halt(void)
  131. {
  132. adir_restart(NULL);
  133. }
  134. static unsigned long __init
  135. adir_find_end_of_memory(void)
  136. {
  137. return boot_mem_size;
  138. }
  139. static void __init
  140. adir_map_io(void)
  141. {
  142. io_block_mapping(ADIR_PCI32_VIRT_IO_BASE, ADIR_PCI32_IO_BASE,
  143. ADIR_PCI32_VIRT_IO_SIZE, _PAGE_IO);
  144. io_block_mapping(ADIR_PCI64_VIRT_IO_BASE, ADIR_PCI64_IO_BASE,
  145. ADIR_PCI64_VIRT_IO_SIZE, _PAGE_IO);
  146. }
  147. void __init
  148. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  149. unsigned long r6, unsigned long r7)
  150. {
  151. /*
  152. * On the Adirondack we use bi_recs and pass the pointer to them in R3.
  153. */
  154. parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
  155. /* Remember, isa_io_base is virtual but isa_mem_base is physical! */
  156. isa_io_base = ADIR_PCI32_VIRT_IO_BASE;
  157. isa_mem_base = ADIR_PCI32_MEM_BASE;
  158. pci_dram_offset = ADIR_PCI_SYS_MEM_BASE;
  159. ppc_md.setup_arch = adir_setup_arch;
  160. ppc_md.show_cpuinfo = adir_show_cpuinfo;
  161. ppc_md.irq_canonicalize = NULL;
  162. ppc_md.init_IRQ = adir_init_IRQ;
  163. ppc_md.get_irq = adir_get_irq;
  164. ppc_md.init = NULL;
  165. ppc_md.find_end_of_memory = adir_find_end_of_memory;
  166. ppc_md.setup_io_mappings = adir_map_io;
  167. ppc_md.restart = adir_restart;
  168. ppc_md.power_off = adir_power_off;
  169. ppc_md.halt = adir_halt;
  170. ppc_md.time_init = todc_time_init;
  171. ppc_md.set_rtc_time = todc_set_rtc_time;
  172. ppc_md.get_rtc_time = todc_get_rtc_time;
  173. ppc_md.nvram_read_val = todc_mc146818_read_val;
  174. ppc_md.nvram_write_val = todc_mc146818_write_val;
  175. ppc_md.calibrate_decr = adir_calibrate_decr;
  176. }