Linux Audio

Check our new training course

Loading...
v6.8
  1/*
  2 * This file is subject to the terms and conditions of the GNU General
  3 * Public License.  See the file "COPYING" in the main directory of this
  4 * archive for more details.
  5 *
  6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
  7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
  8 */
  9#include <linux/kernel.h>
 10#include <linux/init.h>
 11#include <linux/sched.h>
 12#include <linux/smp.h>
 13#include <linux/mm.h>
 14#include <linux/export.h>
 15#include <linux/cpumask.h>
 16#include <asm/bootinfo.h>
 17#include <asm/cpu.h>
 18#include <asm/io.h>
 19#include <asm/sgialib.h>
 20#include <asm/time.h>
 21#include <asm/sn/agent.h>
 22#include <asm/sn/types.h>
 
 
 
 23#include <asm/sn/klconfig.h>
 24#include <asm/sn/ioc3.h>
 25#include <asm/mipsregs.h>
 26#include <asm/sn/gda.h>
 
 27#include <asm/sn/intr.h>
 28#include <asm/current.h>
 29#include <asm/processor.h>
 30#include <asm/mmu_context.h>
 31#include <asm/thread_info.h>
 32#include <asm/sn/launch.h>
 
 
 33#include <asm/sn/mapped_kernel.h>
 34
 35#include "ip27-common.h"
 36
 37#define CPU_NONE		(cpuid_t)-1
 38
 39static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES);
 40nasid_t master_nasid = INVALID_NASID;
 41
 
 
 
 
 
 
 42struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
 43EXPORT_SYMBOL_GPL(sn_cpu_info);
 44
 45static void per_hub_init(nasid_t nasid)
 
 
 46{
 47	struct hub_data *hub = hub_data(nasid);
 
 48
 49	cpumask_set_cpu(smp_processor_id(), &hub->h_cpus);
 50
 51	if (test_and_set_bit(nasid, hub_init_mask))
 52		return;
 53	/*
 54	 * Set CRB timeout at 5ms, (< PI timeout of 10ms)
 55	 */
 56	REMOTE_HUB_S(nasid, IIO_ICTP, 0x800);
 57	REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
 58
 59	hub_rtc_init(nasid);
 60
 61	if (nasid) {
 62		/* copy exception handlers from first node to current node */
 63		memcpy((void *)NODE_OFFSET_TO_K0(nasid, 0),
 64		       (void *)CKSEG0, 0x200);
 65		__flush_cache_all();
 66		/* switch to node local exception handlers */
 67		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K);
 68	}
 69}
 70
 71void per_cpu_init(void)
 72{
 73	int cpu = smp_processor_id();
 74	nasid_t nasid = get_nasid();
 
 
 75
 76	clear_c0_status(ST0_IM);
 
 77
 78	per_hub_init(nasid);
 79
 80	pr_info("CPU %d clock is %dMHz.\n", cpu, sn_cpu_info[cpu].p_speed);
 81
 
 82	install_ipi();
 83
 84	/* Install our NMI handler if symmon hasn't installed one. */
 85	install_cpu_nmi_handler(cputoslice(cpu));
 86
 87	enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE);
 88	enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE);
 89}
 90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 91void __init plat_mem_setup(void)
 92{
 93	u64 p, e, n_mode;
 94	nasid_t nid;
 95
 96	register_smp_ops(&ip27_smp_ops);
 97
 98	ip27_reboot_setup();
 99
100	/*
101	 * hub_rtc init and cpu clock intr enabled for later calibrate_delay.
102	 */
103	nid = get_nasid();
104	printk("IP27: Running on node %d.\n", nid);
105
106	p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1;
107	e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1;
108	printk("Node %d has %s primary CPU%s.\n", nid,
109	       p ? "a" : "no",
110	       e ? ", CPU is running" : "");
111
112	p = LOCAL_HUB_L(PI_CPU_PRESENT_B) & 1;
113	e = LOCAL_HUB_L(PI_CPU_ENABLE_B) & 1;
114	printk("Node %d has %s secondary CPU%s.\n", nid,
115	       p ? "a" : "no",
116	       e ? ", CPU is running" : "");
117
118	/*
119	 * Try to catch kernel missconfigurations and give user an
120	 * indication what option to select.
121	 */
122	n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
123	printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
124#ifdef CONFIG_SGI_SN_N_MODE
125	if (!n_mode)
126		panic("Kernel compiled for M mode.");
127#else
128	if (n_mode)
129		panic("Kernel compiled for N mode.");
130#endif
131
132	ioport_resource.start = 0;
133	ioport_resource.end = ~0UL;
134	set_io_port_base(IO_BASE);
135}
136
137const char *get_system_type(void)
138{
139	return "SGI Origin";
140}
141
142void __init prom_init(void)
143{
144	prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);
145	prom_meminit();
146}
147
v5.4
  1/*
  2 * This file is subject to the terms and conditions of the GNU General
  3 * Public License.  See the file "COPYING" in the main directory of this
  4 * archive for more details.
  5 *
  6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
  7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
  8 */
  9#include <linux/kernel.h>
 10#include <linux/init.h>
 11#include <linux/sched.h>
 12#include <linux/smp.h>
 13#include <linux/mm.h>
 14#include <linux/export.h>
 15#include <linux/cpumask.h>
 
 16#include <asm/cpu.h>
 17#include <asm/io.h>
 18#include <asm/pgtable.h>
 19#include <asm/time.h>
 
 20#include <asm/sn/types.h>
 21#include <asm/sn/sn0/addrs.h>
 22#include <asm/sn/sn0/hubni.h>
 23#include <asm/sn/sn0/hubio.h>
 24#include <asm/sn/klconfig.h>
 25#include <asm/sn/ioc3.h>
 26#include <asm/mipsregs.h>
 27#include <asm/sn/gda.h>
 28#include <asm/sn/hub.h>
 29#include <asm/sn/intr.h>
 30#include <asm/current.h>
 31#include <asm/processor.h>
 32#include <asm/mmu_context.h>
 33#include <asm/thread_info.h>
 34#include <asm/sn/launch.h>
 35#include <asm/sn/sn_private.h>
 36#include <asm/sn/sn0/ip27.h>
 37#include <asm/sn/mapped_kernel.h>
 38
 
 
 39#define CPU_NONE		(cpuid_t)-1
 40
 41static DECLARE_BITMAP(hub_init_mask, MAX_COMPACT_NODES);
 42nasid_t master_nasid = INVALID_NASID;
 43
 44cnodeid_t	nasid_to_compact_node[MAX_NASIDS];
 45nasid_t		compact_to_nasid_node[MAX_COMPACT_NODES];
 46cnodeid_t	cpuid_to_compact_node[MAXCPUS];
 47
 48EXPORT_SYMBOL(nasid_to_compact_node);
 49
 50struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
 51EXPORT_SYMBOL_GPL(sn_cpu_info);
 52
 53extern void pcibr_setup(cnodeid_t);
 54
 55static void per_hub_init(cnodeid_t cnode)
 56{
 57	struct hub_data *hub = hub_data(cnode);
 58	nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode);
 59
 60	cpumask_set_cpu(smp_processor_id(), &hub->h_cpus);
 61
 62	if (test_and_set_bit(cnode, hub_init_mask))
 63		return;
 64	/*
 65	 * Set CRB timeout at 5ms, (< PI timeout of 10ms)
 66	 */
 67	REMOTE_HUB_S(nasid, IIO_ICTP, 0x800);
 68	REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
 69
 70	hub_rtc_init(cnode);
 71
 72	if (nasid) {
 73		/* copy exception handlers from first node to current node */
 74		memcpy((void *)NODE_OFFSET_TO_K0(nasid, 0),
 75		       (void *)CKSEG0, 0x200);
 76		__flush_cache_all();
 77		/* switch to node local exception handlers */
 78		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K);
 79	}
 80}
 81
 82void per_cpu_init(void)
 83{
 84	int cpu = smp_processor_id();
 85	int slice = LOCAL_HUB_L(PI_CPU_NUM);
 86	cnodeid_t cnode = get_compact_nodeid();
 87	struct hub_data *hub = hub_data(cnode);
 88
 89	if (test_and_set_bit(slice, &hub->slice_map))
 90		return;
 91
 92	clear_c0_status(ST0_IM);
 93
 94	per_hub_init(cnode);
 95
 96	cpu_time_init();
 97	install_ipi();
 98
 99	/* Install our NMI handler if symmon hasn't installed one. */
100	install_cpu_nmi_handler(cputoslice(cpu));
101
102	enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE);
103	enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE);
104}
105
106/*
107 * get_nasid() returns the physical node id number of the caller.
108 */
109nasid_t
110get_nasid(void)
111{
112	return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK)
113			 >> NSRI_NODEID_SHFT);
114}
115
116/*
117 * Map the physical node id to a virtual node id (virtual node ids are contiguous).
118 */
119cnodeid_t get_compact_nodeid(void)
120{
121	return NASID_TO_COMPACT_NODEID(get_nasid());
122}
123
124extern void ip27_reboot_setup(void);
125
126void __init plat_mem_setup(void)
127{
128	u64 p, e, n_mode;
129	nasid_t nid;
130
 
 
131	ip27_reboot_setup();
132
133	/*
134	 * hub_rtc init and cpu clock intr enabled for later calibrate_delay.
135	 */
136	nid = get_nasid();
137	printk("IP27: Running on node %d.\n", nid);
138
139	p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1;
140	e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1;
141	printk("Node %d has %s primary CPU%s.\n", nid,
142	       p ? "a" : "no",
143	       e ? ", CPU is running" : "");
144
145	p = LOCAL_HUB_L(PI_CPU_PRESENT_B) & 1;
146	e = LOCAL_HUB_L(PI_CPU_ENABLE_B) & 1;
147	printk("Node %d has %s secondary CPU%s.\n", nid,
148	       p ? "a" : "no",
149	       e ? ", CPU is running" : "");
150
151	/*
152	 * Try to catch kernel missconfigurations and give user an
153	 * indication what option to select.
154	 */
155	n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
156	printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
157#ifdef CONFIG_SGI_SN_N_MODE
158	if (!n_mode)
159		panic("Kernel compiled for M mode.");
160#else
161	if (n_mode)
162		panic("Kernel compiled for N mode.");
163#endif
164
165	ioport_resource.start = 0;
166	ioport_resource.end = ~0UL;
167	set_io_port_base(IO_BASE);
168}