Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * IBM ASM Service Processor Device Driver |
| 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Copyright (C) IBM Corporation, 2004 |
| 6 | * |
Al Viro | d36b691 | 2011-12-29 17:09:01 -0500 | [diff] [blame] | 7 | * Author: Max Asböck <amax@us.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include "ibmasm.h" |
| 11 | #include "lowlevel.h" |
| 12 | #include "i2o.h" |
| 13 | #include "dot_command.h" |
| 14 | #include "remote.h" |
| 15 | |
| 16 | static struct i2o_header header = I2O_HEADER_TEMPLATE; |
| 17 | |
| 18 | |
| 19 | int ibmasm_send_i2o_message(struct service_processor *sp) |
| 20 | { |
| 21 | u32 mfa; |
| 22 | unsigned int command_size; |
| 23 | struct i2o_message *message; |
| 24 | struct command *command = sp->current_command; |
| 25 | |
| 26 | mfa = get_mfa_inbound(sp->base_address); |
| 27 | if (!mfa) |
| 28 | return 1; |
| 29 | |
| 30 | command_size = get_dot_command_size(command->buffer); |
| 31 | header.message_size = outgoing_message_size(command_size); |
| 32 | |
| 33 | message = get_i2o_message(sp->base_address, mfa); |
| 34 | |
Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 35 | memcpy_toio(&message->header, &header, sizeof(struct i2o_header)); |
| 36 | memcpy_toio(&message->data, command->buffer, command_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | set_mfa_inbound(sp->base_address, mfa); |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 43 | irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | u32 mfa; |
| 46 | struct service_processor *sp = (struct service_processor *)dev_id; |
| 47 | void __iomem *base_address = sp->base_address; |
Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 48 | char tsbuf[32]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | if (!sp_interrupt_pending(base_address)) |
| 51 | return IRQ_NONE; |
| 52 | |
Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 53 | dbg("respond to interrupt at %s\n", get_timestamp(tsbuf)); |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | if (mouse_interrupt_pending(sp)) { |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 56 | ibmasm_handle_mouse_interrupt(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | clear_mouse_interrupt(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | mfa = get_mfa_outbound(base_address); |
| 61 | if (valid_mfa(mfa)) { |
| 62 | struct i2o_message *msg = get_i2o_message(base_address, mfa); |
| 63 | ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg)); |
Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 64 | } else |
| 65 | dbg("didn't get a valid MFA\n"); |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | set_mfa_outbound(base_address, mfa); |
Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 68 | dbg("finished interrupt at %s\n", get_timestamp(tsbuf)); |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | return IRQ_HANDLED; |
| 71 | } |