pal4_setup.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * arch/ppc/platforms/pal4_setup.c
  3.  *
  4.  * Board setup routines for the SBS PalomarIV.
  5.  *
  6.  * Author: Dan Cox
  7.  *
  8.  * Copyright 2002 MontaVista Software Inc.
  9.  *
  10.  * This program is free software; you can redistribute  it and/or modify it
  11.  * under  the terms of  the GNU General Public License as published by the
  12.  * Free Software Foundation;  either version 2 of the  License, or (at your
  13.  * option) any later version.
  14.  */
  15. #include <linux/config.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/types.h>
  19. #include <linux/errno.h>
  20. #include <linux/reboot.h>
  21. #include <linux/time.h>
  22. #include <linux/irq.h>
  23. #include <linux/kdev_t.h>
  24. #include <linux/blk.h>
  25. #include <linux/console.h>
  26. #include <linux/seq_file.h>
  27. #include <asm/todc.h>
  28. #include <asm/bootinfo.h>
  29. #include "cpc700.h"
  30. #include "pal4.h"
  31. extern void pal4_find_bridges(void);
  32. unsigned int cpc700_irq_assigns[][2] = {
  33.         {1, 1},    /* IRQ 0: ECC correctable error */
  34.         {1, 1},    /* IRQ 1: PCI write to memory range */
  35.         {0, 1},    /* IRQ 2: PCI write to command register */
  36.         {0, 1},    /* IRQ 3: UART 0 */
  37.         {0, 1},    /* IRQ 4: UART 1 */
  38.         {0, 1},    /* IRQ 5: ICC 0 */
  39.         {0, 1},    /* IRQ 6: ICC 1 */
  40.         {0, 1},    /* IRQ 7: GPT compare 0 */
  41.         {0, 1},    /* IRQ 8: GPT compare 1 */
  42.         {0, 1},    /* IRQ 9: GPT compare 2 */
  43.         {0, 1},    /* IRQ 10: GPT compare 3 */
  44.         {0, 1},    /* IRQ 11: GPT compare 4 */
  45.         {0, 1},    /* IRQ 12: GPT capture 0 */
  46.         {0, 1},    /* IRQ 13: GPT capture 1 */
  47.         {0, 1},    /* IRQ 14: GPT capture 2 */
  48.         {0, 1},    /* IRQ 15: GPT capture 3 */
  49.         {0, 1},    /* IRQ 16: GPT capture 4 */
  50.         {0, 0},    /* IRQ 17: reserved */
  51.         {0, 0},    /* IRQ 18: reserved */
  52.         {0, 0},    /* IRQ 19: reserved */
  53.         {0, 0},    /* IRQ 20: reserved */
  54.         {0, 1},    /* IRQ 21: Ethernet */
  55.         {0, 0},    /* IRQ 22: reserved */
  56.         {0, 0},    /* IRQ 23: reserved */
  57.         {0, 0},    /* IRQ 24: resreved */
  58.         {0, 0},    /* IRQ 25: reserved */
  59.         {0, 0},    /* IRQ 26: reserved */
  60.         {0, 0},    /* IRQ 27: reserved */
  61.         {0, 0},    /* IRQ 28: reserved */
  62.         {0, 0},    /* IRQ 29: reserved */
  63.         {0, 0},    /* IRQ 30: reserved */
  64.         {0, 0},    /* IRQ 31: reserved */
  65. };
  66. static int
  67. pal4_show_cpuinfo(struct seq_file *m)
  68. {
  69.         seq_printf(m, "boardtt: SBS Palomar IVn");
  70.         return 0;
  71. }
  72. static void
  73. pal4_restart(char *cmd)
  74. {
  75.         __cli();
  76.         __asm__ __volatile__("lis  3,0xfff0n 
  77.                               ori  3,3,0x100n 
  78.                               mtspr 26,3n 
  79.                               li   3,0n 
  80.                               mtspr 27,3n 
  81.                               rfi");
  82.         for(;;);
  83. }
  84. static void
  85. pal4_power_off(void)
  86. {
  87. __cli();
  88. for(;;);
  89. }
  90. static void
  91. pal4_halt(void)
  92. {
  93. pal4_power_off();
  94. }
  95. static unsigned long __init
  96. pal4_find_end_of_memory(void)
  97. {
  98. int i;
  99. unsigned long len, amt, batu, batl;
  100.         __asm__ __volatile__("lis  %0,0xf000n 
  101.                               ori  %1,%0,0x002an 
  102.                               ori  %0,%0,0x1ffen 
  103.                               mtspr 0x21e,%0n 
  104.                               mtspr 0x21f,%1n 
  105.                               isyncn 
  106.                               sync" : "=r" (batu), "=r" (batl));
  107. for(len = 0, i = CPC700_MB1EA; i <= CPC700_MB4EA; i+=4) {
  108. amt = cpc700_read_memreg(i);
  109. if (amt == 0)
  110. break;
  111. len = amt;
  112. }
  113. return len;
  114. }
  115. TODC_ALLOC();
  116. static void __init
  117. pal4_setup_arch(void)
  118. {
  119. unsigned long l2;
  120. TODC_INIT(TODC_TYPE_MK48T37, 0, 0, 
  121.   ioremap(PAL4_NVRAM, PAL4_NVRAM_SIZE), 8);
  122. pal4_find_bridges();
  123. #ifdef CONFIG_BLK_DEV_INITRD
  124. if (initrd_start)
  125. ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
  126. else
  127. #endif
  128. ROOT_DEV = to_kdev_t(0x00ff);
  129. /* The L2 gets disabled in the bootloader, but all the proper
  130.    bits should be present from the fw, so just re-enable it */
  131. l2 = _get_L2CR();
  132. if (!(l2 & L2CR_L2E)) {
  133. /* presume that it was initially set if the size is
  134.    still present. */
  135. if (l2 ^ L2CR_L2SIZ_MASK)
  136. _set_L2CR(l2 | L2CR_L2E);
  137. else
  138. printk("L2 not set by firmware; left disabled.n");
  139. }
  140. }
  141. static void __init
  142. pal4_map_io(void)
  143. {
  144. io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
  145. }
  146. void __init
  147. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  148.       unsigned long r6, unsigned long r7)
  149. {
  150. parse_bootinfo(find_bootinfo());
  151. isa_io_base = 0 /*PAL4_ISA_IO_BASE*/;
  152. pci_dram_offset = 0 /*PAL4_PCI_SYS_MEM_BASE*/;
  153. ppc_md.setup_arch = pal4_setup_arch;
  154. ppc_md.show_cpuinfo = pal4_show_cpuinfo;
  155. ppc_md.find_end_of_memory = pal4_find_end_of_memory;
  156. ppc_md.setup_io_mappings = pal4_map_io;
  157. ppc_md.init_IRQ = cpc700_init_IRQ;
  158. ppc_md.get_irq = cpc700_get_irq;
  159. ppc_md.restart = pal4_restart;
  160. ppc_md.halt = pal4_halt;
  161. ppc_md.power_off = pal4_power_off;
  162. ppc_md.time_init = todc_time_init;
  163. ppc_md.set_rtc_time = todc_set_rtc_time;
  164. ppc_md.get_rtc_time = todc_get_rtc_time;
  165. ppc_md.calibrate_decr = todc_calibrate_decr;
  166. ppc_md.nvram_read_val = todc_direct_read_val;
  167. ppc_md.nvram_write_val = todc_direct_write_val;
  168. }