Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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