Linux Audio

Check our new training course

Loading...
v6.2
  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
 11#include <linux/types.h>
 12#include <linux/kernel.h>
 13#include <linux/mm.h>
 14#include <linux/seq_file.h>
 15#include <linux/tty.h>
 16#include <linux/console.h>
 17#include <linux/init.h>
 18#include <linux/memblock.h>
 19#include <linux/platform_device.h>
 20
 21#include <asm/oplib.h>
 22#include <asm/setup.h>
 23#include <asm/contregs.h>
 24#include <asm/movs.h>
 
 25#include <asm/pgalloc.h>
 26#include <asm/sun3-head.h>
 27#include <asm/sun3mmu.h>
 28#include <asm/machdep.h>
 29#include <asm/machines.h>
 30#include <asm/idprom.h>
 31#include <asm/intersil.h>
 32#include <asm/irq.h>
 33#include <asm/sections.h>
 
 34#include <asm/sun3ints.h>
 35
 36char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
 37
 38static void sun3_sched_init(void);
 
 39extern void sun3_get_model (char* model);
 40extern int sun3_hwclk(int set, struct rtc_time *t);
 41
 42volatile char* clock_va;
 43extern unsigned long availmem;
 44unsigned long num_pages;
 45
 46static void sun3_get_hardware_list(struct seq_file *m)
 47{
 48	seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid);
 49}
 50
 51void __init sun3_init(void)
 52{
 53	unsigned char enable_register;
 54	int i;
 55
 56	m68k_machtype= MACH_SUN3;
 57	m68k_cputype = CPU_68020;
 58	m68k_fputype = FPU_68881; /* mc68881 actually */
 59	m68k_mmutype = MMU_SUN3;
 60	clock_va    =          (char *) 0xfe06000;	/* dark  */
 61	sun3_intreg = (unsigned char *) 0xfe0a000;	/* magic */
 62	sun3_disable_interrupts();
 63
 64	prom_init((void *)LINUX_OPPROM_BEGVM);
 65
 66	GET_CONTROL_BYTE(AC_SENABLE,enable_register);
 67	enable_register |= 0x50; /* Enable FPU */
 68	SET_CONTROL_BYTE(AC_SENABLE,enable_register);
 69	GET_CONTROL_BYTE(AC_SENABLE,enable_register);
 70
 71	/* This code looks suspicious, because it doesn't subtract
 72           memory belonging to the kernel from the available space */
 73
 74
 75	memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
 76
 77	/* Reserve important PMEGS */
 78	/* FIXME: These should be probed instead of hardcoded */
 79
 80	for (i=0; i<8; i++)		/* Kernel PMEGs */
 81		sun3_reserved_pmeg[i] = 1;
 82
 83	sun3_reserved_pmeg[247] = 1;	/* ROM mapping  */
 84	sun3_reserved_pmeg[248] = 1;	/* AMD Ethernet */
 85	sun3_reserved_pmeg[251] = 1;	/* VB area      */
 86	sun3_reserved_pmeg[254] = 1;	/* main I/O     */
 87
 88	sun3_reserved_pmeg[249] = 1;
 89	sun3_reserved_pmeg[252] = 1;
 90	sun3_reserved_pmeg[253] = 1;
 91	set_fc(USER_DATA);
 92}
 93
 94/* Without this, Bad Things happen when something calls arch_reset. */
 95static void sun3_reboot (void)
 96{
 97	prom_reboot ("vmlinux");
 98}
 99
100static void sun3_halt (void)
101{
102	prom_halt ();
103}
104
105/* sun3 bootmem allocation */
106
107static void __init sun3_bootmem_alloc(unsigned long memory_start,
108				      unsigned long memory_end)
109{
110	unsigned long start_page;
111
112	/* align start/end to page boundaries */
113	memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
114	memory_end = memory_end & PAGE_MASK;
115
116	start_page = __pa(memory_start) >> PAGE_SHIFT;
117	max_pfn = num_pages = __pa(memory_end) >> PAGE_SHIFT;
118
119	high_memory = (void *)memory_end;
120	availmem = memory_start;
121
122	m68k_setup_node(0);
 
 
 
 
123}
124
125
126void __init config_sun3(void)
127{
128	unsigned long memory_start, memory_end;
129
130	pr_info("ARCH: SUN3\n");
131	idprom_init();
132
133	/* Subtract kernel memory from available memory */
134
135        mach_sched_init      =  sun3_sched_init;
136        mach_init_IRQ        =  sun3_init_IRQ;
137        mach_reset           =  sun3_reboot;
 
138	mach_get_model	     =  sun3_get_model;
139	mach_hwclk           =  sun3_hwclk;
140	mach_halt	     =  sun3_halt;
141	mach_get_hardware_list = sun3_get_hardware_list;
142
143	memory_start = ((((unsigned long)_end) + 0x2000) & ~0x1fff);
144// PROM seems to want the last couple of physical pages. --m
145	memory_end   = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
146
147	m68k_num_memory=1;
148        m68k_memory[0].size=*(romvec->pv_sun3mem);
149
150	sun3_bootmem_alloc(memory_start, memory_end);
151}
152
153static void __init sun3_sched_init(void)
154{
155	sun3_disable_interrupts();
156        intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
157        intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
158	intersil_clear();
159        sun3_enable_irq(5);
160        intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
161        sun3_enable_interrupts();
162        intersil_clear();
163}
164
165#if IS_ENABLED(CONFIG_SUN3_SCSI)
166
167static const struct resource sun3_scsi_vme_rsrc[] __initconst = {
168	{
169		.flags = IORESOURCE_IRQ,
170		.start = SUN3_VEC_VMESCSI0,
171		.end   = SUN3_VEC_VMESCSI0,
172	}, {
173		.flags = IORESOURCE_MEM,
174		.start = 0xff200000,
175		.end   = 0xff200021,
176	}, {
177		.flags = IORESOURCE_IRQ,
178		.start = SUN3_VEC_VMESCSI1,
179		.end   = SUN3_VEC_VMESCSI1,
180	}, {
181		.flags = IORESOURCE_MEM,
182		.start = 0xff204000,
183		.end   = 0xff204021,
184	},
185};
186
187/*
188 * Int: level 2 autovector
189 * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
190 */
191static const struct resource sun3_scsi_rsrc[] __initconst = {
192	{
193		.flags = IORESOURCE_IRQ,
194		.start = 2,
195		.end   = 2,
196	}, {
197		.flags = IORESOURCE_MEM,
198		.start = 0x00140000,
199		.end   = 0x0014001f,
200	},
201};
202
203int __init sun3_platform_init(void)
204{
205	switch (idprom->id_machtype) {
206	case SM_SUN3 | SM_3_160:
207	case SM_SUN3 | SM_3_260:
208		platform_device_register_simple("sun3_scsi_vme", -1,
209			sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc));
210		break;
211	case SM_SUN3 | SM_3_50:
212	case SM_SUN3 | SM_3_60:
213		platform_device_register_simple("sun3_scsi", -1,
214			sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc));
215		break;
216	}
217	return 0;
218}
219
220arch_initcall(sun3_platform_init);
221
222#endif
v4.17
  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
 11#include <linux/types.h>
 12#include <linux/kernel.h>
 13#include <linux/mm.h>
 14#include <linux/seq_file.h>
 15#include <linux/tty.h>
 16#include <linux/console.h>
 17#include <linux/init.h>
 18#include <linux/bootmem.h>
 19#include <linux/platform_device.h>
 20
 21#include <asm/oplib.h>
 22#include <asm/setup.h>
 23#include <asm/contregs.h>
 24#include <asm/movs.h>
 25#include <asm/pgtable.h>
 26#include <asm/pgalloc.h>
 27#include <asm/sun3-head.h>
 28#include <asm/sun3mmu.h>
 29#include <asm/machdep.h>
 30#include <asm/machines.h>
 31#include <asm/idprom.h>
 32#include <asm/intersil.h>
 33#include <asm/irq.h>
 34#include <asm/sections.h>
 35#include <asm/segment.h>
 36#include <asm/sun3ints.h>
 37
 38char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
 39
 40extern u32 sun3_gettimeoffset(void);
 41static void sun3_sched_init(irq_handler_t handler);
 42extern void sun3_get_model (char* model);
 43extern int sun3_hwclk(int set, struct rtc_time *t);
 44
 45volatile char* clock_va;
 46extern unsigned long availmem;
 47unsigned long num_pages;
 48
 49static void sun3_get_hardware_list(struct seq_file *m)
 50{
 51	seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid);
 52}
 53
 54void __init sun3_init(void)
 55{
 56	unsigned char enable_register;
 57	int i;
 58
 59	m68k_machtype= MACH_SUN3;
 60	m68k_cputype = CPU_68020;
 61	m68k_fputype = FPU_68881; /* mc68881 actually */
 62	m68k_mmutype = MMU_SUN3;
 63	clock_va    =          (char *) 0xfe06000;	/* dark  */
 64	sun3_intreg = (unsigned char *) 0xfe0a000;	/* magic */
 65	sun3_disable_interrupts();
 66
 67	prom_init((void *)LINUX_OPPROM_BEGVM);
 68
 69	GET_CONTROL_BYTE(AC_SENABLE,enable_register);
 70	enable_register |= 0x50; /* Enable FPU */
 71	SET_CONTROL_BYTE(AC_SENABLE,enable_register);
 72	GET_CONTROL_BYTE(AC_SENABLE,enable_register);
 73
 74	/* This code looks suspicious, because it doesn't subtract
 75           memory belonging to the kernel from the available space */
 76
 77
 78	memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
 79
 80	/* Reserve important PMEGS */
 81	/* FIXME: These should be probed instead of hardcoded */
 82
 83	for (i=0; i<8; i++)		/* Kernel PMEGs */
 84		sun3_reserved_pmeg[i] = 1;
 85
 86	sun3_reserved_pmeg[247] = 1;	/* ROM mapping  */
 87	sun3_reserved_pmeg[248] = 1;	/* AMD Ethernet */
 88	sun3_reserved_pmeg[251] = 1;	/* VB area      */
 89	sun3_reserved_pmeg[254] = 1;	/* main I/O     */
 90
 91	sun3_reserved_pmeg[249] = 1;
 92	sun3_reserved_pmeg[252] = 1;
 93	sun3_reserved_pmeg[253] = 1;
 94	set_fs(KERNEL_DS);
 95}
 96
 97/* Without this, Bad Things happen when something calls arch_reset. */
 98static void sun3_reboot (void)
 99{
100	prom_reboot ("vmlinux");
101}
102
103static void sun3_halt (void)
104{
105	prom_halt ();
106}
107
108/* sun3 bootmem allocation */
109
110static void __init sun3_bootmem_alloc(unsigned long memory_start,
111				      unsigned long memory_end)
112{
113	unsigned long start_page;
114
115	/* align start/end to page boundaries */
116	memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
117	memory_end = memory_end & PAGE_MASK;
118
119	start_page = __pa(memory_start) >> PAGE_SHIFT;
120	max_pfn = num_pages = __pa(memory_end) >> PAGE_SHIFT;
121
122	high_memory = (void *)memory_end;
123	availmem = memory_start;
124
125	m68k_setup_node(0);
126	availmem += init_bootmem(start_page, num_pages);
127	availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
128
129	free_bootmem(__pa(availmem), memory_end - (availmem));
130}
131
132
133void __init config_sun3(void)
134{
135	unsigned long memory_start, memory_end;
136
137	pr_info("ARCH: SUN3\n");
138	idprom_init();
139
140	/* Subtract kernel memory from available memory */
141
142        mach_sched_init      =  sun3_sched_init;
143        mach_init_IRQ        =  sun3_init_IRQ;
144        mach_reset           =  sun3_reboot;
145	arch_gettimeoffset   =  sun3_gettimeoffset;
146	mach_get_model	     =  sun3_get_model;
147	mach_hwclk           =  sun3_hwclk;
148	mach_halt	     =  sun3_halt;
149	mach_get_hardware_list = sun3_get_hardware_list;
150
151	memory_start = ((((unsigned long)_end) + 0x2000) & ~0x1fff);
152// PROM seems to want the last couple of physical pages. --m
153	memory_end   = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
154
155	m68k_num_memory=1;
156        m68k_memory[0].size=*(romvec->pv_sun3mem);
157
158	sun3_bootmem_alloc(memory_start, memory_end);
159}
160
161static void __init sun3_sched_init(irq_handler_t timer_routine)
162{
163	sun3_disable_interrupts();
164        intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
165        intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
166	intersil_clear();
167        sun3_enable_irq(5);
168        intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
169        sun3_enable_interrupts();
170        intersil_clear();
171}
172
173#if IS_ENABLED(CONFIG_SUN3_SCSI)
174
175static const struct resource sun3_scsi_vme_rsrc[] __initconst = {
176	{
177		.flags = IORESOURCE_IRQ,
178		.start = SUN3_VEC_VMESCSI0,
179		.end   = SUN3_VEC_VMESCSI0,
180	}, {
181		.flags = IORESOURCE_MEM,
182		.start = 0xff200000,
183		.end   = 0xff200021,
184	}, {
185		.flags = IORESOURCE_IRQ,
186		.start = SUN3_VEC_VMESCSI1,
187		.end   = SUN3_VEC_VMESCSI1,
188	}, {
189		.flags = IORESOURCE_MEM,
190		.start = 0xff204000,
191		.end   = 0xff204021,
192	},
193};
194
195/*
196 * Int: level 2 autovector
197 * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
198 */
199static const struct resource sun3_scsi_rsrc[] __initconst = {
200	{
201		.flags = IORESOURCE_IRQ,
202		.start = 2,
203		.end   = 2,
204	}, {
205		.flags = IORESOURCE_MEM,
206		.start = 0x00140000,
207		.end   = 0x0014001f,
208	},
209};
210
211int __init sun3_platform_init(void)
212{
213	switch (idprom->id_machtype) {
214	case SM_SUN3 | SM_3_160:
215	case SM_SUN3 | SM_3_260:
216		platform_device_register_simple("sun3_scsi_vme", -1,
217			sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc));
218		break;
219	case SM_SUN3 | SM_3_50:
220	case SM_SUN3 | SM_3_60:
221		platform_device_register_simple("sun3_scsi", -1,
222			sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc));
223		break;
224	}
225	return 0;
226}
227
228arch_initcall(sun3_platform_init);
229
230#endif