Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Platform dependent support for HP simulator. |
| 4 | * |
| 5 | * Copyright (C) 1998-2001 Hewlett-Packard Co |
| 6 | * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com> |
| 7 | */ |
| 8 | |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/irq.h> |
| 13 | |
Jiri Slaby | 6efb6b7 | 2012-03-08 21:01:18 +0100 | [diff] [blame] | 14 | #include "hpsim_ssc.h" |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | static unsigned int |
Thomas Gleixner | 35d75b0 | 2011-02-04 20:12:06 +0100 | [diff] [blame] | 17 | hpsim_irq_startup(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static void |
Thomas Gleixner | 35d75b0 | 2011-02-04 20:12:06 +0100 | [diff] [blame] | 23 | hpsim_irq_noop(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { |
| 25 | } |
| 26 | |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 27 | static int |
Thomas Gleixner | 35d75b0 | 2011-02-04 20:12:06 +0100 | [diff] [blame] | 28 | hpsim_set_affinity_noop(struct irq_data *d, const struct cpumask *b, bool f) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 30 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Thomas Gleixner | fb824f4 | 2009-06-10 12:45:00 -0700 | [diff] [blame] | 33 | static struct irq_chip irq_type_hp_sim = { |
Thomas Gleixner | 35d75b0 | 2011-02-04 20:12:06 +0100 | [diff] [blame] | 34 | .name = "hpsim", |
| 35 | .irq_startup = hpsim_irq_startup, |
| 36 | .irq_shutdown = hpsim_irq_noop, |
| 37 | .irq_enable = hpsim_irq_noop, |
| 38 | .irq_disable = hpsim_irq_noop, |
| 39 | .irq_ack = hpsim_irq_noop, |
| 40 | .irq_set_affinity = hpsim_set_affinity_noop, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Jiri Slaby | 6efb6b7 | 2012-03-08 21:01:18 +0100 | [diff] [blame] | 43 | static void hpsim_irq_set_chip(int irq) |
| 44 | { |
| 45 | struct irq_chip *chip = irq_get_chip(irq); |
| 46 | |
| 47 | if (chip == &no_irq_chip) |
| 48 | irq_set_chip(irq, &irq_type_hp_sim); |
| 49 | } |
| 50 | |
| 51 | static void hpsim_connect_irq(int intr, int irq) |
| 52 | { |
| 53 | ia64_ssc(intr, irq, 0, 0, SSC_CONNECT_INTERRUPT); |
| 54 | } |
| 55 | |
| 56 | int hpsim_get_irq(int intr) |
| 57 | { |
| 58 | int irq = assign_irq_vector(AUTO_ASSIGN); |
| 59 | |
| 60 | if (irq >= 0) { |
| 61 | hpsim_irq_set_chip(irq); |
| 62 | irq_set_handler(irq, handle_simple_irq); |
| 63 | hpsim_connect_irq(intr, irq); |
| 64 | } |
| 65 | |
| 66 | return irq; |
| 67 | } |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | void __init |
| 70 | hpsim_irq_init (void) |
| 71 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | int i; |
| 73 | |
Jiri Slaby | 6efb6b7 | 2012-03-08 21:01:18 +0100 | [diff] [blame] | 74 | for_each_active_irq(i) |
| 75 | hpsim_irq_set_chip(i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |