| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * IBM ASM Service Processor Device Driver | 
 | 3 |  * | 
 | 4 |  * This program is free software; you can redistribute it and/or modify | 
 | 5 |  * it under the terms of the GNU General Public License as published by | 
 | 6 |  * the Free Software Foundation; either version 2 of the License, or | 
 | 7 |  * (at your option) any later version. | 
 | 8 |  * | 
 | 9 |  * This program is distributed in the hope that it will be useful, | 
 | 10 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 11 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 12 |  * GNU General Public License for more details. | 
 | 13 |  * | 
 | 14 |  * You should have received a copy of the GNU General Public License | 
 | 15 |  * along with this program; if not, write to the Free Software | 
 | 16 |  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
 | 17 |  * | 
 | 18 |  * Copyright (C) IBM Corporation, 2004 | 
 | 19 |  * | 
| Dmitry Torokhov | 3110dc7 | 2007-07-17 04:03:58 -0700 | [diff] [blame] | 20 |  * Author: Max Asböck <amax@us.ibm.com> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 |  * | 
 | 22 |  */ | 
 | 23 |  | 
 | 24 | #include "ibmasm.h" | 
 | 25 | #include "lowlevel.h" | 
 | 26 | #include "i2o.h" | 
 | 27 | #include "dot_command.h" | 
 | 28 | #include "remote.h" | 
 | 29 |  | 
 | 30 | static struct i2o_header header = I2O_HEADER_TEMPLATE; | 
 | 31 |  | 
 | 32 |  | 
 | 33 | int ibmasm_send_i2o_message(struct service_processor *sp) | 
 | 34 | { | 
 | 35 | 	u32 mfa; | 
 | 36 | 	unsigned int command_size; | 
 | 37 | 	struct i2o_message *message; | 
 | 38 | 	struct command *command = sp->current_command; | 
 | 39 |  | 
 | 40 | 	mfa = get_mfa_inbound(sp->base_address); | 
 | 41 | 	if (!mfa) | 
 | 42 | 		return 1; | 
 | 43 |  | 
 | 44 | 	command_size = get_dot_command_size(command->buffer); | 
 | 45 | 	header.message_size = outgoing_message_size(command_size); | 
 | 46 |  | 
 | 47 | 	message = get_i2o_message(sp->base_address, mfa); | 
 | 48 |  | 
| Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 49 | 	memcpy_toio(&message->header, &header, sizeof(struct i2o_header)); | 
 | 50 | 	memcpy_toio(&message->data, command->buffer, command_size); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
 | 52 | 	set_mfa_inbound(sp->base_address, mfa); | 
 | 53 |  | 
 | 54 | 	return 0; | 
 | 55 | } | 
 | 56 |  | 
| David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 57 | irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { | 
 | 59 | 	u32	mfa; | 
 | 60 | 	struct service_processor *sp = (struct service_processor *)dev_id; | 
 | 61 | 	void __iomem *base_address = sp->base_address; | 
| Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 62 | 	char tsbuf[32]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 |  | 
 | 64 | 	if (!sp_interrupt_pending(base_address)) | 
 | 65 | 		return IRQ_NONE; | 
 | 66 |  | 
| Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 67 | 	dbg("respond to interrupt at %s\n", get_timestamp(tsbuf)); | 
 | 68 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | 	if (mouse_interrupt_pending(sp)) { | 
| David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 70 | 		ibmasm_handle_mouse_interrupt(sp); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | 		clear_mouse_interrupt(sp); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | 	} | 
 | 73 |  | 
 | 74 | 	mfa = get_mfa_outbound(base_address); | 
 | 75 | 	if (valid_mfa(mfa)) { | 
 | 76 | 		struct i2o_message *msg = get_i2o_message(base_address, mfa); | 
 | 77 | 		ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg)); | 
| Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 78 | 	} else | 
 | 79 | 		dbg("didn't get a valid MFA\n"); | 
 | 80 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | 	set_mfa_outbound(base_address, mfa); | 
| Max Asbock | 278d72a | 2005-06-21 17:16:34 -0700 | [diff] [blame] | 82 | 	dbg("finished interrupt at   %s\n", get_timestamp(tsbuf)); | 
 | 83 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | 	return IRQ_HANDLED; | 
 | 85 | } |