| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/arch/m68k/sun3/config.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 1996,1997 Pekka Pietik{inen | 
|  | 5 | * | 
|  | 6 | * This file is subject to the terms and conditions of the GNU General Public | 
|  | 7 | * License.  See the file COPYING in the main directory of this archive | 
|  | 8 | * for more details. | 
|  | 9 | */ | 
|  | 10 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/types.h> | 
|  | 12 | #include <linux/kernel.h> | 
|  | 13 | #include <linux/mm.h> | 
|  | 14 | #include <linux/tty.h> | 
|  | 15 | #include <linux/console.h> | 
|  | 16 | #include <linux/init.h> | 
|  | 17 | #include <linux/bootmem.h> | 
|  | 18 |  | 
|  | 19 | #include <asm/oplib.h> | 
|  | 20 | #include <asm/setup.h> | 
|  | 21 | #include <asm/contregs.h> | 
|  | 22 | #include <asm/movs.h> | 
|  | 23 | #include <asm/pgtable.h> | 
| Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 24 | #include <asm/pgalloc.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/sun3-head.h> | 
|  | 26 | #include <asm/sun3mmu.h> | 
|  | 27 | #include <asm/rtc.h> | 
|  | 28 | #include <asm/machdep.h> | 
|  | 29 | #include <asm/intersil.h> | 
|  | 30 | #include <asm/irq.h> | 
|  | 31 | #include <asm/segment.h> | 
|  | 32 | #include <asm/sun3ints.h> | 
|  | 33 |  | 
|  | 34 | extern char _text, _end; | 
|  | 35 |  | 
|  | 36 | char sun3_reserved_pmeg[SUN3_PMEGS_NUM]; | 
|  | 37 |  | 
|  | 38 | extern unsigned long sun3_gettimeoffset(void); | 
| Adrian Bunk | 07b8125 | 2008-07-17 21:16:27 +0200 | [diff] [blame] | 39 | static void sun3_sched_init(irq_handler_t handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | extern void sun3_get_model (char* model); | 
|  | 41 | extern void idprom_init (void); | 
|  | 42 | extern int sun3_hwclk(int set, struct rtc_time *t); | 
|  | 43 |  | 
|  | 44 | volatile char* clock_va; | 
|  | 45 | extern volatile unsigned char* sun3_intreg; | 
|  | 46 | extern unsigned long availmem; | 
|  | 47 | unsigned long num_pages; | 
|  | 48 |  | 
|  | 49 | static int sun3_get_hardware_list(char *buffer) | 
|  | 50 | { | 
|  | 51 |  | 
|  | 52 | int len = 0; | 
|  | 53 |  | 
|  | 54 | len += sprintf(buffer + len, "PROM Revision:\t%s\n", | 
|  | 55 | romvec->pv_monid); | 
|  | 56 |  | 
|  | 57 | return len; | 
|  | 58 |  | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | void __init sun3_init(void) | 
|  | 62 | { | 
|  | 63 | unsigned char enable_register; | 
|  | 64 | int i; | 
|  | 65 |  | 
|  | 66 | m68k_machtype= MACH_SUN3; | 
|  | 67 | m68k_cputype = CPU_68020; | 
|  | 68 | m68k_fputype = FPU_68881; /* mc68881 actually */ | 
|  | 69 | m68k_mmutype = MMU_SUN3; | 
|  | 70 | clock_va    =          (char *) 0xfe06000;	/* dark  */ | 
|  | 71 | sun3_intreg = (unsigned char *) 0xfe0a000;	/* magic */ | 
|  | 72 | sun3_disable_interrupts(); | 
|  | 73 |  | 
|  | 74 | prom_init((void *)LINUX_OPPROM_BEGVM); | 
|  | 75 |  | 
|  | 76 | GET_CONTROL_BYTE(AC_SENABLE,enable_register); | 
|  | 77 | enable_register |= 0x50; /* Enable FPU */ | 
|  | 78 | SET_CONTROL_BYTE(AC_SENABLE,enable_register); | 
|  | 79 | GET_CONTROL_BYTE(AC_SENABLE,enable_register); | 
|  | 80 |  | 
|  | 81 | /* This code looks suspicious, because it doesn't subtract | 
|  | 82 | memory belonging to the kernel from the available space */ | 
|  | 83 |  | 
|  | 84 |  | 
|  | 85 | memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg)); | 
|  | 86 |  | 
|  | 87 | /* Reserve important PMEGS */ | 
|  | 88 | /* FIXME: These should be probed instead of hardcoded */ | 
|  | 89 |  | 
|  | 90 | for (i=0; i<8; i++)		/* Kernel PMEGs */ | 
|  | 91 | sun3_reserved_pmeg[i] = 1; | 
|  | 92 |  | 
|  | 93 | sun3_reserved_pmeg[247] = 1;	/* ROM mapping  */ | 
|  | 94 | sun3_reserved_pmeg[248] = 1;	/* AMD Ethernet */ | 
|  | 95 | sun3_reserved_pmeg[251] = 1;	/* VB area      */ | 
|  | 96 | sun3_reserved_pmeg[254] = 1;	/* main I/O     */ | 
|  | 97 |  | 
|  | 98 | sun3_reserved_pmeg[249] = 1; | 
|  | 99 | sun3_reserved_pmeg[252] = 1; | 
|  | 100 | sun3_reserved_pmeg[253] = 1; | 
|  | 101 | set_fs(KERNEL_DS); | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | /* Without this, Bad Things happen when something calls arch_reset. */ | 
|  | 105 | static void sun3_reboot (void) | 
|  | 106 | { | 
|  | 107 | prom_reboot ("vmlinux"); | 
|  | 108 | } | 
|  | 109 |  | 
|  | 110 | static void sun3_halt (void) | 
|  | 111 | { | 
|  | 112 | prom_halt (); | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | /* sun3 bootmem allocation */ | 
|  | 116 |  | 
| Adrian Bunk | 07b8125 | 2008-07-17 21:16:27 +0200 | [diff] [blame] | 117 | static void __init sun3_bootmem_alloc(unsigned long memory_start, | 
|  | 118 | unsigned long memory_end) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | { | 
|  | 120 | unsigned long start_page; | 
|  | 121 |  | 
|  | 122 | /* align start/end to page boundaries */ | 
|  | 123 | memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK); | 
|  | 124 | memory_end = memory_end & PAGE_MASK; | 
|  | 125 |  | 
|  | 126 | start_page = __pa(memory_start) >> PAGE_SHIFT; | 
|  | 127 | num_pages = __pa(memory_end) >> PAGE_SHIFT; | 
|  | 128 |  | 
|  | 129 | high_memory = (void *)memory_end; | 
|  | 130 | availmem = memory_start; | 
|  | 131 |  | 
| Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 132 | m68k_setup_node(0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages); | 
|  | 134 | availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK; | 
|  | 135 |  | 
|  | 136 | free_bootmem(__pa(availmem), memory_end - (availmem)); | 
|  | 137 | } | 
|  | 138 |  | 
|  | 139 |  | 
|  | 140 | void __init config_sun3(void) | 
|  | 141 | { | 
|  | 142 | unsigned long memory_start, memory_end; | 
|  | 143 |  | 
|  | 144 | printk("ARCH: SUN3\n"); | 
|  | 145 | idprom_init(); | 
|  | 146 |  | 
|  | 147 | /* Subtract kernel memory from available memory */ | 
|  | 148 |  | 
|  | 149 | mach_sched_init      =  sun3_sched_init; | 
|  | 150 | mach_init_IRQ        =  sun3_init_IRQ; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | mach_reset           =  sun3_reboot; | 
|  | 152 | mach_gettimeoffset   =  sun3_gettimeoffset; | 
|  | 153 | mach_get_model	     =  sun3_get_model; | 
|  | 154 | mach_hwclk           =  sun3_hwclk; | 
|  | 155 | mach_halt	     =  sun3_halt; | 
|  | 156 | mach_get_hardware_list = sun3_get_hardware_list; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 |  | 
|  | 158 | memory_start = ((((int)&_end) + 0x2000) & ~0x1fff); | 
|  | 159 | // PROM seems to want the last couple of physical pages. --m | 
|  | 160 | memory_end   = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE; | 
|  | 161 |  | 
|  | 162 | m68k_num_memory=1; | 
|  | 163 | m68k_memory[0].size=*(romvec->pv_sun3mem); | 
|  | 164 |  | 
|  | 165 | sun3_bootmem_alloc(memory_start, memory_end); | 
|  | 166 | } | 
|  | 167 |  | 
| Adrian Bunk | 07b8125 | 2008-07-17 21:16:27 +0200 | [diff] [blame] | 168 | static void __init sun3_sched_init(irq_handler_t timer_routine) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | { | 
|  | 170 | sun3_disable_interrupts(); | 
|  | 171 | intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE); | 
|  | 172 | intersil_clock->int_reg=INTERSIL_HZ_100_MASK; | 
|  | 173 | intersil_clear(); | 
|  | 174 | sun3_enable_irq(5); | 
|  | 175 | intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE); | 
|  | 176 | sun3_enable_interrupts(); | 
|  | 177 | intersil_clear(); | 
|  | 178 | } | 
|  | 179 |  |