| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 | * linux/arch/sh/boards/renesas/systemh/irq.c | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * | 
|  | 4 | * Copyright (C) 2000  Kazumoto Kojima | 
|  | 5 | * | 
|  | 6 | * Hitachi SystemH Support. | 
|  | 7 | * | 
|  | 8 | * Modified for 7751 SystemH by | 
|  | 9 | * Jonathan Short. | 
|  | 10 | */ | 
|  | 11 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/init.h> | 
|  | 13 | #include <linux/irq.h> | 
| Adrian Bunk | 0e25f71 | 2008-08-05 18:17:00 +0200 | [diff] [blame] | 14 | #include <linux/interrupt.h> | 
| Matt Fleming | bd0a22d | 2008-12-14 12:02:25 +0000 | [diff] [blame] | 15 | #include <linux/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 |  | 
| Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 17 | #include <mach/systemh7751.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/smc37c93x.h> | 
|  | 19 |  | 
|  | 20 | /* address of external interrupt mask register | 
|  | 21 | * address must be set prior to use these (maybe in init_XXX_irq()) | 
|  | 22 | * XXX : is it better to use .config than specifying it in code? */ | 
|  | 23 | static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004; | 
|  | 24 | static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000; | 
|  | 25 |  | 
|  | 26 | /* forward declaration */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | static void enable_systemh_irq(unsigned int irq); | 
|  | 28 | static void disable_systemh_irq(unsigned int irq); | 
|  | 29 | static void mask_and_ack_systemh(unsigned int); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 |  | 
| Matt Fleming | bd0a22d | 2008-12-14 12:02:25 +0000 | [diff] [blame] | 31 | static struct irq_chip systemh_irq_type = { | 
|  | 32 | .name = " SystemH Register", | 
|  | 33 | .unmask = enable_systemh_irq, | 
|  | 34 | .mask = disable_systemh_irq, | 
| Thomas Gleixner | 08d0fd0 | 2005-09-10 00:26:42 -0700 | [diff] [blame] | 35 | .ack = mask_and_ack_systemh, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | }; | 
|  | 37 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | static void disable_systemh_irq(unsigned int irq) | 
|  | 39 | { | 
|  | 40 | if (systemh_irq_mask_register) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | unsigned long val, mask = 0x01 << 1; | 
|  | 42 |  | 
|  | 43 | /* Clear the "irq"th bit in the mask and set it in the request */ | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 44 | val = __raw_readl((unsigned long)systemh_irq_mask_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | val &= ~mask; | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 46 | __raw_writel(val, (unsigned long)systemh_irq_mask_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 |  | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 48 | val = __raw_readl((unsigned long)systemh_irq_request_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | val |= mask; | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 50 | __raw_writel(val, (unsigned long)systemh_irq_request_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | static void enable_systemh_irq(unsigned int irq) | 
|  | 55 | { | 
|  | 56 | if (systemh_irq_mask_register) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | unsigned long val, mask = 0x01 << 1; | 
|  | 58 |  | 
|  | 59 | /* Set "irq"th bit in the mask register */ | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 60 | val = __raw_readl((unsigned long)systemh_irq_mask_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | val |= mask; | 
| Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 62 | __raw_writel(val, (unsigned long)systemh_irq_mask_register); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | } | 
|  | 64 | } | 
|  | 65 |  | 
|  | 66 | static void mask_and_ack_systemh(unsigned int irq) | 
|  | 67 | { | 
|  | 68 | disable_systemh_irq(irq); | 
|  | 69 | } | 
|  | 70 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | void make_systemh_irq(unsigned int irq) | 
|  | 72 | { | 
|  | 73 | disable_irq_nosync(irq); | 
| Matt Fleming | bd0a22d | 2008-12-14 12:02:25 +0000 | [diff] [blame] | 74 | set_irq_chip_and_handler(irq, &systemh_irq_type, handle_level_irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | disable_systemh_irq(irq); | 
|  | 76 | } |