^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) #ifndef __DOT_COMMAND_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __DOT_COMMAND_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * dot commands are the protocol used to communicate with the service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * processor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * They consist of header, a command of variable length and data of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * variable length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* dot command types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define sp_write 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define sp_write_next 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define sp_read 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define sp_read_next 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define sp_command_response 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define sp_event 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define sp_heartbeat 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #pragma pack(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct dot_command_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u8 command_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u16 data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #pragma pack()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static inline size_t get_dot_command_size(void *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct dot_command_header *cmd = (struct dot_command_header *)buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return sizeof(struct dot_command_header) + cmd->command_size + cmd->data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static inline unsigned int get_dot_command_timeout(void *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct dot_command_header *header = (struct dot_command_header *)buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned char *cmd = buffer + sizeof(struct dot_command_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* dot commands 6.3.1, 7.1 and 8.x need a longer timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (header->command_size == 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if ((cmd[0] == 6) && (cmd[1] == 3) && (cmd[2] == 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return IBMASM_CMD_TIMEOUT_EXTRA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) } else if (header->command_size == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if ((cmd[0] == 7) && (cmd[1] == 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return IBMASM_CMD_TIMEOUT_EXTRA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (cmd[0] == 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return IBMASM_CMD_TIMEOUT_EXTRA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return IBMASM_CMD_TIMEOUT_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #endif /* __DOT_COMMAND_H__ */