| .. | .. |
|---|
| 19 | 19 | #include <linux/platform_device.h> |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | #include <asm/time.h> |
|---|
| 22 | | -#include <asm/pgtable.h> |
|---|
| 23 | 22 | #include <asm/sgialib.h> |
|---|
| 24 | | -#include <asm/sn/ioc3.h> |
|---|
| 25 | 23 | #include <asm/sn/klconfig.h> |
|---|
| 26 | 24 | #include <asm/sn/arch.h> |
|---|
| 27 | 25 | #include <asm/sn/addrs.h> |
|---|
| 28 | | -#include <asm/sn/sn_private.h> |
|---|
| 29 | | -#include <asm/sn/sn0/ip27.h> |
|---|
| 30 | | -#include <asm/sn/sn0/hub.h> |
|---|
| 26 | +#include <asm/sn/agent.h> |
|---|
| 31 | 27 | |
|---|
| 32 | | -#define TICK_SIZE (tick_nsec / 1000) |
|---|
| 33 | | - |
|---|
| 34 | | -/* Includes for ioc3_init(). */ |
|---|
| 35 | | -#include <asm/sn/types.h> |
|---|
| 36 | | -#include <asm/sn/sn0/addrs.h> |
|---|
| 37 | | -#include <asm/sn/sn0/hubni.h> |
|---|
| 38 | | -#include <asm/sn/sn0/hubio.h> |
|---|
| 39 | | -#include <asm/pci/bridge.h> |
|---|
| 40 | | - |
|---|
| 41 | | -static void enable_rt_irq(struct irq_data *d) |
|---|
| 42 | | -{ |
|---|
| 43 | | -} |
|---|
| 44 | | - |
|---|
| 45 | | -static void disable_rt_irq(struct irq_data *d) |
|---|
| 46 | | -{ |
|---|
| 47 | | -} |
|---|
| 48 | | - |
|---|
| 49 | | -static struct irq_chip rt_irq_type = { |
|---|
| 50 | | - .name = "SN HUB RT timer", |
|---|
| 51 | | - .irq_mask = disable_rt_irq, |
|---|
| 52 | | - .irq_unmask = enable_rt_irq, |
|---|
| 53 | | -}; |
|---|
| 28 | +#include "ip27-common.h" |
|---|
| 54 | 29 | |
|---|
| 55 | 30 | static int rt_next_event(unsigned long delta, struct clock_event_device *evt) |
|---|
| 56 | 31 | { |
|---|
| .. | .. |
|---|
| 64 | 39 | |
|---|
| 65 | 40 | return LOCAL_HUB_L(PI_RT_COUNT) >= cnt ? -ETIME : 0; |
|---|
| 66 | 41 | } |
|---|
| 67 | | - |
|---|
| 68 | | -unsigned int rt_timer_irq; |
|---|
| 69 | 42 | |
|---|
| 70 | 43 | static DEFINE_PER_CPU(struct clock_event_device, hub_rt_clockevent); |
|---|
| 71 | 44 | static DEFINE_PER_CPU(char [11], hub_rt_name); |
|---|
| .. | .. |
|---|
| 87 | 60 | |
|---|
| 88 | 61 | struct irqaction hub_rt_irqaction = { |
|---|
| 89 | 62 | .handler = hub_rt_counter_handler, |
|---|
| 63 | + .percpu_dev_id = &hub_rt_clockevent, |
|---|
| 90 | 64 | .flags = IRQF_PERCPU | IRQF_TIMER, |
|---|
| 91 | 65 | .name = "hub-rt", |
|---|
| 92 | 66 | }; |
|---|
| .. | .. |
|---|
| 107 | 81 | unsigned int cpu = smp_processor_id(); |
|---|
| 108 | 82 | struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu); |
|---|
| 109 | 83 | unsigned char *name = per_cpu(hub_rt_name, cpu); |
|---|
| 110 | | - int irq = rt_timer_irq; |
|---|
| 111 | 84 | |
|---|
| 112 | 85 | sprintf(name, "hub-rt %d", cpu); |
|---|
| 113 | 86 | cd->name = name; |
|---|
| .. | .. |
|---|
| 118 | 91 | cd->min_delta_ns = clockevent_delta2ns(0x300, cd); |
|---|
| 119 | 92 | cd->min_delta_ticks = 0x300; |
|---|
| 120 | 93 | cd->rating = 200; |
|---|
| 121 | | - cd->irq = irq; |
|---|
| 94 | + cd->irq = IP27_RT_TIMER_IRQ; |
|---|
| 122 | 95 | cd->cpumask = cpumask_of(cpu); |
|---|
| 123 | 96 | cd->set_next_event = rt_next_event; |
|---|
| 124 | 97 | clockevents_register_device(cd); |
|---|
| 98 | + |
|---|
| 99 | + enable_percpu_irq(IP27_RT_TIMER_IRQ, IRQ_TYPE_NONE); |
|---|
| 125 | 100 | } |
|---|
| 126 | 101 | |
|---|
| 127 | 102 | static void __init hub_rt_clock_event_global_init(void) |
|---|
| 128 | 103 | { |
|---|
| 129 | | - int irq; |
|---|
| 130 | | - |
|---|
| 131 | | - do { |
|---|
| 132 | | - smp_wmb(); |
|---|
| 133 | | - irq = rt_timer_irq; |
|---|
| 134 | | - if (irq) |
|---|
| 135 | | - break; |
|---|
| 136 | | - |
|---|
| 137 | | - irq = allocate_irqno(); |
|---|
| 138 | | - if (irq < 0) |
|---|
| 139 | | - panic("Allocation of irq number for timer failed"); |
|---|
| 140 | | - } while (xchg(&rt_timer_irq, irq)); |
|---|
| 141 | | - |
|---|
| 142 | | - irq_set_chip_and_handler(irq, &rt_irq_type, handle_percpu_irq); |
|---|
| 143 | | - setup_irq(irq, &hub_rt_irqaction); |
|---|
| 104 | + irq_set_handler(IP27_RT_TIMER_IRQ, handle_percpu_devid_irq); |
|---|
| 105 | + irq_set_percpu_devid(IP27_RT_TIMER_IRQ); |
|---|
| 106 | + setup_percpu_irq(IP27_RT_TIMER_IRQ, &hub_rt_irqaction); |
|---|
| 144 | 107 | } |
|---|
| 145 | 108 | |
|---|
| 146 | 109 | static u64 hub_rt_read(struct clocksource *cs) |
|---|
| .. | .. |
|---|
| 177 | 140 | hub_rt_clock_event_init(); |
|---|
| 178 | 141 | } |
|---|
| 179 | 142 | |
|---|
| 180 | | -void cpu_time_init(void) |
|---|
| 181 | | -{ |
|---|
| 182 | | - lboard_t *board; |
|---|
| 183 | | - klcpu_t *cpu; |
|---|
| 184 | | - int cpuid; |
|---|
| 185 | | - |
|---|
| 186 | | - /* Don't use ARCS. ARCS is fragile. Klconfig is simple and sane. */ |
|---|
| 187 | | - board = find_lboard(KL_CONFIG_INFO(get_nasid()), KLTYPE_IP27); |
|---|
| 188 | | - if (!board) |
|---|
| 189 | | - panic("Can't find board info for myself."); |
|---|
| 190 | | - |
|---|
| 191 | | - cpuid = LOCAL_HUB_L(PI_CPU_NUM) ? IP27_CPU0_INDEX : IP27_CPU1_INDEX; |
|---|
| 192 | | - cpu = (klcpu_t *) KLCF_COMP(board, cpuid); |
|---|
| 193 | | - if (!cpu) |
|---|
| 194 | | - panic("No information about myself?"); |
|---|
| 195 | | - |
|---|
| 196 | | - printk("CPU %d clock is %dMHz.\n", smp_processor_id(), cpu->cpu_speed); |
|---|
| 197 | | - |
|---|
| 198 | | - set_c0_status(SRB_TIMOCLK); |
|---|
| 199 | | -} |
|---|
| 200 | | - |
|---|
| 201 | | -void hub_rtc_init(cnodeid_t cnode) |
|---|
| 143 | +void hub_rtc_init(nasid_t nasid) |
|---|
| 202 | 144 | { |
|---|
| 203 | 145 | |
|---|
| 204 | 146 | /* |
|---|
| .. | .. |
|---|
| 206 | 148 | * If this is not the current node then it is a cpuless |
|---|
| 207 | 149 | * node and timeouts will not happen there. |
|---|
| 208 | 150 | */ |
|---|
| 209 | | - if (get_compact_nodeid() == cnode) { |
|---|
| 151 | + if (get_nasid() == nasid) { |
|---|
| 210 | 152 | LOCAL_HUB_S(PI_RT_EN_A, 1); |
|---|
| 211 | 153 | LOCAL_HUB_S(PI_RT_EN_B, 1); |
|---|
| 212 | 154 | LOCAL_HUB_S(PI_PROF_EN_A, 0); |
|---|
| .. | .. |
|---|
| 216 | 158 | LOCAL_HUB_S(PI_RT_PEND_B, 0); |
|---|
| 217 | 159 | } |
|---|
| 218 | 160 | } |
|---|
| 219 | | - |
|---|
| 220 | | -static int __init sgi_ip27_rtc_devinit(void) |
|---|
| 221 | | -{ |
|---|
| 222 | | - struct resource res; |
|---|
| 223 | | - |
|---|
| 224 | | - memset(&res, 0, sizeof(res)); |
|---|
| 225 | | - res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + |
|---|
| 226 | | - IOC3_BYTEBUS_DEV0); |
|---|
| 227 | | - res.end = res.start + 32767; |
|---|
| 228 | | - res.flags = IORESOURCE_MEM; |
|---|
| 229 | | - |
|---|
| 230 | | - return IS_ERR(platform_device_register_simple("rtc-m48t35", -1, |
|---|
| 231 | | - &res, 1)); |
|---|
| 232 | | -} |
|---|
| 233 | | - |
|---|
| 234 | | -/* |
|---|
| 235 | | - * kludge make this a device_initcall after ioc3 resource conflicts |
|---|
| 236 | | - * are resolved |
|---|
| 237 | | - */ |
|---|
| 238 | | -late_initcall(sgi_ip27_rtc_devinit); |
|---|