1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IBM ASM Service Processor Device Driver
5 * Copyright (C) IBM Corporation, 2004
11 #include "dot_command.h"
14 * Dispatch an incoming message to the specific handler for the message.
15 * Called from interrupt context.
17 void ibmasm_receive_message(struct service_processor *sp, void *message, int message_size)
20 struct dot_command_header *header = (struct dot_command_header *)message;
22 if (message_size == 0)
25 size = get_dot_command_size(message);
29 if (size > message_size)
32 switch (header->type) {
34 ibmasm_receive_event(sp, message, size);
36 case sp_command_response:
37 ibmasm_receive_command_response(sp, message, size);
40 ibmasm_receive_heartbeat(sp, message, size);
43 dev_err(sp->dev, "Received unknown message from service processor\n");
48 #define INIT_BUFFER_SIZE 32
52 * send the 4.3.5.10 dot command (driver VPD) to the service processor
54 int ibmasm_send_driver_vpd(struct service_processor *sp)
56 struct command *command;
57 struct dot_command_header *header;
62 command = ibmasm_new_command(sp, INIT_BUFFER_SIZE);
66 header = (struct dot_command_header *)command->buffer;
67 header->type = sp_write;
68 header->command_size = 4;
69 header->data_size = 16;
73 vpd_command = command->buffer + sizeof(struct dot_command_header);
79 vpd_data = vpd_command + header->command_size;
81 strcat(vpd_data, IBMASM_DRIVER_VPD);
85 ibmasm_exec_command(sp, command);
86 ibmasm_wait_for_response(command, IBMASM_CMD_TIMEOUT_NORMAL);
88 if (command->status != IBMASM_CMD_COMPLETE)
96 struct os_state_command {
97 struct dot_command_header header;
98 unsigned char command[3];
103 * send the 4.3.6 dot command (os state) to the service processor
104 * During driver init this function is called with os state "up".
105 * This causes the service processor to start sending heartbeats the
107 * During driver exit the function is called with os state "down",
108 * causing the service processor to stop the heartbeats.
110 int ibmasm_send_os_state(struct service_processor *sp, int os_state)
113 struct os_state_command *os_state_cmd;
116 cmd = ibmasm_new_command(sp, sizeof(struct os_state_command));
120 os_state_cmd = (struct os_state_command *)cmd->buffer;
121 os_state_cmd->header.type = sp_write;
122 os_state_cmd->header.command_size = 3;
123 os_state_cmd->header.data_size = 1;
124 os_state_cmd->header.status = 0;
125 os_state_cmd->command[0] = 4;
126 os_state_cmd->command[1] = 3;
127 os_state_cmd->command[2] = 6;
128 os_state_cmd->data = os_state;
130 ibmasm_exec_command(sp, cmd);
131 ibmasm_wait_for_response(cmd, IBMASM_CMD_TIMEOUT_NORMAL);
133 if (cmd->status != IBMASM_CMD_COMPLETE)