/* * Carsten Langgaard, carstenl@mips.com * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved. * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * Routines for generic manipulation of the interrupts found on the MIPS * Sead board. */ #include #include #include #include #include #include #include #include #include #if defined(CONFIG_VLYNQ_SUPPORT) #include #endif /*--- #if defined(CONFIG_VLYNQ_SUPPORT) ---*/ #include #include #include #if defined(CONFIG_AVM_SIMPLE_PROFILING) #include #include #endif /*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ extern asmlinkage void mipsIRQ(void); static void __init ohio_init_irq(void); /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ asmlinkage void ohio_hw0_irqdispatch(struct pt_regs *regs) { /* TODO */ #if defined(CONFIG_AVM_SIMPLE_PROFILING) /*--- struct pt_regs lregs; ---*/ /*--- regs.cp0_epc = read_c0_epc(); ---*/ void DO_IRQ(unsigned int i, struct pt_regs *_regs) { struct irq_desc *desc = irq_desc + i; avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, (unsigned int)desc, i); do_IRQ(i, _regs); avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, (unsigned int)desc, i); } #else /*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ #define DO_IRQ(i, r) do_IRQ(i, r) #endif /*--- #else ---*/ /*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ struct _irq_hw *IRQ = (struct _irq_hw *)OHIO_IRQ_CTRL_BASE; unsigned int priority_index_reg = IRQ->priority_index_reg; unsigned int irq = (priority_index_reg >> 16) & 0x3F; extern void r4k_wait_end(void); r4k_wait_end(); irq += MIPS_EXCEPTION_OFFSET; /*--- printk("[ohio_hw0_irqdispatch] irq=%u chan_nr=%u\n", irq, chan_nr); ---*/ if(irq == MIPS_EXCEPTION_OFFSET) { unsigned int _irq; for(_irq = 0 ; _irq < 32 ; _irq++) { if(IRQ->exception_clear_status_reg & (1 << _irq)) break; } if(_irq != 32) DO_IRQ(_irq, regs); } #if defined(CONFIG_VLYNQ_SUPPORT) else if(irq == OHIOINT_VLYNQ0) { unsigned int vlynq_irq = vlynq_get_irq(0) + OHIO_INT_START_VIRTUAL; if(vlynq_irq != (unsigned int)-1) DO_IRQ(vlynq_irq, regs); } #endif /*--- #if defined(CONFIG_VLYNQ_SUPPORT) ---*/ kstat_this_cpu.irqs[MIPS_EXCEPTION_OFFSET - 2]++; DO_IRQ(irq, regs); #if defined(CONFIG_AVM_SIMPLE_PROFILING) avm_simple_profiling(regs, irq); #endif /*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ asmlinkage void ohio_hw1_irqdispatch(struct pt_regs *regs) /* TODO */ { /*--- do_IRQ(OHIOINT_UART1, regs); ---*/ /*--- struct irq_desc *desc; ---*/ /*--- int cpu = smp_processor_id(); ---*/ struct _irq_hw *IRQ = (struct _irq_hw *)OHIO_IRQ_CTRL_BASE; unsigned int priority_index_reg = IRQ->priority_index_reg; unsigned int irq = (priority_index_reg >> 16) & 0x3F; unsigned int chan_nr = priority_index_reg & 0x3F; printk("[ohio_hw1_irqdispatch] irq=%u chan_nr=%u\n", irq, chan_nr); } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ static struct _ohio_nsec_timer { unsigned long long offset; unsigned int last; unsigned long clock_faktor; } nT = { 0ULL, 0U, 0UL }; /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ unsigned long long ohio_nsec_timer(void) { unsigned int count; if(nT.clock_faktor == 0) { /*--- wie viele n-sec pro clock ---*/ nT.clock_faktor = (unsigned long)(1000000000 / (ohio_get_clock(avm_clock_id_cpu) / 2)); } local_irq_disable(); count = read_c0_count() * nT.clock_faktor; if(count < nT.last) nT.offset += 0xFFFFFFFF * nT.clock_faktor; nT.last = count; local_irq_enable(); return (unsigned long long)count + nT.offset; } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ void ohio_timer_interrupt(void) { unsigned int count; count = read_c0_count(); if(count < nT.last) { nT.offset += ((unsigned long long)1 << 32); nT.offset = count; } return; } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ extern void mips_cpu_irq_init(int irq_base); void __init arch_init_irq(void) /* TODO */ { ohio_init_irq(); /* * Mask out all interrupt */ clear_c0_status(0x0000ff00); /* Now safe to set the exception vector. */ set_except_vector(0, mipsIRQ); mips_cpu_irq_init(0); } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ irqreturn_t dummy_timer_irq(int irq, void *context, struct pt_regs *regs) { panic("dummy_timer_irq must not be called\n"); return 0; } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ irqreturn_t dummy_system_irq_2(int irq, void *context, struct pt_regs *regs) { panic("dummy_system_irq_2 must not be called\n"); return 0; } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ static int __init ohio_install_dummy_irq_functions(void) { request_irq(MIPS_EXCEPTION_OFFSET - 7, dummy_timer_irq, 0, "system timer", NULL); request_irq(MIPS_EXCEPTION_OFFSET - 2, dummy_system_irq_2, 0, "OHIO primary", NULL); return 0; } late_initcall(ohio_install_dummy_irq_functions); /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ static void __init ohio_init_irq(void) { struct _irq_hw *IRQ = (struct _irq_hw *)OHIO_IRQ_CTRL_BASE; unsigned int irq; IRQ->enable_clear_reg[0] = 0xFFFFFFFF; IRQ->enable_clear_reg[1] = 0xFFFFFFFF; IRQ->status_clear_reg[0] = 0xFFFFFFFF; IRQ->status_clear_reg[1] = 0xFFFFFFFF; /*--- IRQ->enable_set_reg[0] = ---*/ /*--- IRQ->enable_set_reg[1] = ---*/ /*--- IRQ->polarity_reg[0] = ---*/ /*--- IRQ->polarity_reg[1] = ---*/ /*--- IRQ->type_reg[0] = ---*/ /*--- IRQ->type_reg[1] = ---*/ /*--- IRQ->exception_set_status_reg = ---*/ IRQ->exception_enable_clear_reg = 0xFFFFFFFF; IRQ->exception_clear_status_reg = 0xFFFFFFFF; /*--- IRQ->exception_enable_set_reg = ---*/ /*--- IRQ->pacing_prescale_reg = ---*/ /*--- IRQ->pacing_map_reg = ---*/ /*--- IRQ->pacing_max_reg = ---*/ IRQ->polarity_reg[0] = 0; IRQ->polarity_reg[1] = 0; IRQ->type_reg[0] = 0 | (1 << 7) | (1 << 8) | (1 << 22) | (1 << 23) | (1 << 24) | (1 << 28) | (1 << 29) ; IRQ->type_reg[1] = 0x00000000; for(irq = 0 ; irq < sizeof(IRQ->channel_number_reg) / sizeof(IRQ->channel_number_reg[0]) ; irq++) { IRQ->channel_number_reg[irq] = irq; } /*--- printk("[ohio_init_irq] ebase = 0x%x\n", read_c0_ebase()); ---*/ } /*------------------------------------------------------------------------------------------*\ \*------------------------------------------------------------------------------------------*/ int ohio_sleep_mode(unsigned deep_sleep) { /*--- unsigned int save_mapping[4]; ---*/ unsigned int i, ii; unsigned int save_irq_enable[2]; struct _irq_hw *IRQ = (struct _irq_hw *)OHIO_IRQ_CTRL_BASE; struct _hw_clock *CLOCK = (struct _hw_clock *)OHIO_CLOCK_BASE; struct EMIF_register_memory_map *EMIF = (struct EMIF_register_memory_map *)OHIO_EMIF_BASE; printk("suspend ...\n"); local_irq_disable(); save_irq_enable[0] = IRQ->enable_set_reg[0]; save_irq_enable[1] = IRQ->enable_set_reg[1]; IRQ->enable_clear_reg[0] = 0 | (1 << 1) | /*--- AHCI ---*/ (1 << 7) | /*--- serial ---*/ (1 << 15) | /*--- SAR ---*/ (1 << 19) | /*--- CPMAC ---*/ /*--- (1 << 21) | ---*/ /*--- VLYNQ ---*/ /*--- (1 << 23) | ---*/ /*--- DSL ---*/ 0; printk("going to %ssleep ...\n", deep_sleep ? "deep " : ""); printk("raw interrupt status 0x%x%08x\n", IRQ->enable_clear_reg[1], IRQ->enable_clear_reg[0]); printk("save interrupt enable 0x%x%08x\n", save_irq_enable[1], save_irq_enable[0]); printk("interrupt enable 0x%x%08x\n", IRQ->enable_set_reg[1], IRQ->enable_set_reg[0]); /*--- printk("wakeup register %08x\n", CLOCK->WKCR.Register); ---*/ printk("PDCR register %08x\n", CLOCK->PDCR.Register); i = read_c0_count(); /*--- clear_c0_status(0x100 << 0); ---*/ EMIF->SDRAMBankCR.Bits.sr = 1; CLOCK->PDCR.Bits.glbpd = deep_sleep ? 3 : 2; /* standby */ EMIF->SDRAMBankCR.Bits.sr = 0; /*--- clear_c0_cause(0x100 << 0); ---*/ /*--- set_c0_status(0x100 << 0); ---*/ ii = read_c0_count(); printk("raw interrupt status 0x%x%08x\n", IRQ->enable_clear_reg[1], IRQ->enable_clear_reg[0]); IRQ->enable_set_reg[1] = save_irq_enable[1]; IRQ->enable_set_reg[0] = save_irq_enable[0]; local_irq_enable(); printk("resumed !\n"); return 0; } EXPORT_SYMBOL (ohio_sleep_mode); EXPORT_SYMBOL (ohio_nsec_timer);