2 * CBE Pervasive Monitor and Debug
4 * (C) Copyright IBM Corporation 2005
6 * Authors: Maximino Aguilar (maguilar@us.ibm.com)
7 * Michael N. Day (mnday@us.ibm.com)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/interrupt.h>
27 #include <linux/irq.h>
28 #include <linux/percpu.h>
29 #include <linux/types.h>
30 #include <linux/kallsyms.h>
33 #include <asm/machdep.h>
35 #include <asm/pgtable.h>
38 #include "pervasive.h"
41 static void cbe_power_save(void)
43 unsigned long ctrl, thread_switch_control;
46 * We need to hard disable interrupts, but we also need to mark them
47 * hard disabled in the PACA so that the local_irq_enable() done by
48 * our caller upon return propertly hard enables.
51 get_paca()->hard_enabled = 0;
53 ctrl = mfspr(SPRN_CTRLF);
55 /* Enable DEC and EE interrupt request */
56 thread_switch_control = mfspr(SPRN_TSC_CELL);
57 thread_switch_control |= TSC_CELL_EE_ENABLE | TSC_CELL_EE_BOOST;
59 switch (ctrl & CTRL_CT) {
61 thread_switch_control |= TSC_CELL_DEC_ENABLE_0;
64 thread_switch_control |= TSC_CELL_DEC_ENABLE_1;
67 printk(KERN_WARNING "%s: unknown configuration\n",
71 mtspr(SPRN_TSC_CELL, thread_switch_control);
74 * go into low thread priority, medium priority will be
75 * restored for us after wake-up.
80 * atomically disable thread execution and runlatch.
81 * External and Decrementer exceptions are still handled when the
82 * thread is disabled but now enter in cbe_system_reset_exception()
84 ctrl &= ~(CTRL_RUNLATCH | CTRL_TE);
85 mtspr(SPRN_CTRLT, ctrl);
88 static int cbe_system_reset_exception(struct pt_regs *regs)
90 switch (regs->msr & SRR1_WAKEMASK) {
95 timer_interrupt(regs);
100 case SRR1_WAKESYSERR:
101 cbe_system_error_exception(regs);
104 cbe_thermal_exception(regs);
106 #endif /* CONFIG_CBE_RAS */
108 /* do system reset */
111 /* everything handled */
115 void __init cbe_pervasive_init(void)
118 if (!cpu_has_feature(CPU_FTR_PAUSE_ZERO))
121 for_each_possible_cpu(cpu) {
122 struct cbe_pmd_regs __iomem *regs = cbe_get_cpu_pmd_regs(cpu);
126 /* Enable Pause(0) control bit */
127 out_be64(®s->pmcr, in_be64(®s->pmcr) |
128 CBE_PMD_PAUSE_ZERO_CONTROL);
131 ppc_md.power_save = cbe_power_save;
132 ppc_md.system_reset_exception = cbe_system_reset_exception;