Path: blob/master/arch/sh/kernel/cpu/irq/intc-sh5.c
17544 views
/*1* arch/sh/kernel/cpu/irq/intc-sh5.c2*3* Interrupt Controller support for SH5 INTC.4*5* Copyright (C) 2000, 2001 Paolo Alberelli6* Copyright (C) 2003 Paul Mundt7*8* Per-interrupt selective. IRLM=0 (Fixed priority) is not9* supported being useless without a cascaded interrupt10* controller.11*12* This file is subject to the terms and conditions of the GNU General Public13* License. See the file "COPYING" in the main directory of this archive14* for more details.15*/16#include <linux/init.h>17#include <linux/interrupt.h>18#include <linux/irq.h>19#include <linux/io.h>20#include <linux/kernel.h>21#include <linux/bitops.h>22#include <cpu/irq.h>23#include <asm/page.h>2425/*26* Maybe the generic Peripheral block could move to a more27* generic include file. INTC Block will be defined here28* and only here to make INTC self-contained in a single29* file.30*/31#define INTC_BLOCK_OFFSET 0x010000003233/* Base */34#define INTC_BASE PHYS_PERIPHERAL_BLOCK + \35INTC_BLOCK_OFFSET3637/* Address */38#define INTC_ICR_SET (intc_virt + 0x0)39#define INTC_ICR_CLEAR (intc_virt + 0x8)40#define INTC_INTPRI_0 (intc_virt + 0x10)41#define INTC_INTSRC_0 (intc_virt + 0x50)42#define INTC_INTSRC_1 (intc_virt + 0x58)43#define INTC_INTREQ_0 (intc_virt + 0x60)44#define INTC_INTREQ_1 (intc_virt + 0x68)45#define INTC_INTENB_0 (intc_virt + 0x70)46#define INTC_INTENB_1 (intc_virt + 0x78)47#define INTC_INTDSB_0 (intc_virt + 0x80)48#define INTC_INTDSB_1 (intc_virt + 0x88)4950#define INTC_ICR_IRLM 0x151#define INTC_INTPRI_PREGS 8 /* 8 Priority Registers */52#define INTC_INTPRI_PPREG 8 /* 8 Priorities per Register */535455/*56* Mapper between the vector ordinal and the IRQ number57* passed to kernel/device drivers.58*/59int intc_evt_to_irq[(0xE20/0x20)+1] = {60-1, -1, -1, -1, -1, -1, -1, -1, /* 0x000 - 0x0E0 */61-1, -1, -1, -1, -1, -1, -1, -1, /* 0x100 - 0x1E0 */620, 0, 0, 0, 0, 1, 0, 0, /* 0x200 - 0x2E0 */632, 0, 0, 3, 0, 0, 0, -1, /* 0x300 - 0x3E0 */6432, 33, 34, 35, 36, 37, 38, -1, /* 0x400 - 0x4E0 */65-1, -1, -1, 63, -1, -1, -1, -1, /* 0x500 - 0x5E0 */66-1, -1, 18, 19, 20, 21, 22, -1, /* 0x600 - 0x6E0 */6739, 40, 41, 42, -1, -1, -1, -1, /* 0x700 - 0x7E0 */684, 5, 6, 7, -1, -1, -1, -1, /* 0x800 - 0x8E0 */69-1, -1, -1, -1, -1, -1, -1, -1, /* 0x900 - 0x9E0 */7012, 13, 14, 15, 16, 17, -1, -1, /* 0xA00 - 0xAE0 */71-1, -1, -1, -1, -1, -1, -1, -1, /* 0xB00 - 0xBE0 */72-1, -1, -1, -1, -1, -1, -1, -1, /* 0xC00 - 0xCE0 */73-1, -1, -1, -1, -1, -1, -1, -1, /* 0xD00 - 0xDE0 */74-1, -1 /* 0xE00 - 0xE20 */75};7677static unsigned long intc_virt;78static int irlm; /* IRL mode */7980static void enable_intc_irq(struct irq_data *data)81{82unsigned int irq = data->irq;83unsigned long reg;84unsigned long bitmask;8586if ((irq <= IRQ_IRL3) && (irlm == NO_PRIORITY))87printk("Trying to use straight IRL0-3 with an encoding platform.\n");8889if (irq < 32) {90reg = INTC_INTENB_0;91bitmask = 1 << irq;92} else {93reg = INTC_INTENB_1;94bitmask = 1 << (irq - 32);95}9697__raw_writel(bitmask, reg);98}99100static void disable_intc_irq(struct irq_data *data)101{102unsigned int irq = data->irq;103unsigned long reg;104unsigned long bitmask;105106if (irq < 32) {107reg = INTC_INTDSB_0;108bitmask = 1 << irq;109} else {110reg = INTC_INTDSB_1;111bitmask = 1 << (irq - 32);112}113114__raw_writel(bitmask, reg);115}116117static struct irq_chip intc_irq_type = {118.name = "INTC",119.irq_enable = enable_intc_irq,120.irq_disable = disable_intc_irq,121};122123void __init plat_irq_setup(void)124{125unsigned long long __dummy0, __dummy1=~0x00000000100000f0;126unsigned long reg;127int i;128129intc_virt = (unsigned long)ioremap_nocache(INTC_BASE, 1024);130if (!intc_virt) {131panic("Unable to remap INTC\n");132}133134135/* Set default: per-line enable/disable, priority driven ack/eoi */136for (i = 0; i < NR_INTC_IRQS; i++)137irq_set_chip_and_handler(i, &intc_irq_type, handle_level_irq);138139140/* Disable all interrupts and set all priorities to 0 to avoid trouble */141__raw_writel(-1, INTC_INTDSB_0);142__raw_writel(-1, INTC_INTDSB_1);143144for (reg = INTC_INTPRI_0, i = 0; i < INTC_INTPRI_PREGS; i++, reg += 8)145__raw_writel( NO_PRIORITY, reg);146147148#ifdef CONFIG_SH_CAYMAN149{150unsigned long data;151152/* Set IRLM */153/* If all the priorities are set to 'no priority', then154* assume we are using encoded mode.155*/156irlm = platform_int_priority[IRQ_IRL0] +157platform_int_priority[IRQ_IRL1] +158platform_int_priority[IRQ_IRL2] +159platform_int_priority[IRQ_IRL3];160if (irlm == NO_PRIORITY) {161/* IRLM = 0 */162reg = INTC_ICR_CLEAR;163i = IRQ_INTA;164printk("Trying to use encoded IRL0-3. IRLs unsupported.\n");165} else {166/* IRLM = 1 */167reg = INTC_ICR_SET;168i = IRQ_IRL0;169}170__raw_writel(INTC_ICR_IRLM, reg);171172/* Set interrupt priorities according to platform description */173for (data = 0, reg = INTC_INTPRI_0; i < NR_INTC_IRQS; i++) {174data |= platform_int_priority[i] <<175((i % INTC_INTPRI_PPREG) * 4);176if ((i % INTC_INTPRI_PPREG) == (INTC_INTPRI_PPREG - 1)) {177/* Upon the 7th, set Priority Register */178__raw_writel(data, reg);179data = 0;180reg += 8;181}182}183}184#endif185186/*187* And now let interrupts come in.188* sti() is not enough, we need to189* lower priority, too.190*/191__asm__ __volatile__("getcon " __SR ", %0\n\t"192"and %0, %1, %0\n\t"193"putcon %0, " __SR "\n\t"194: "=&r" (__dummy0)195: "r" (__dummy1));196}197198199