1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2015-2018, Intel Corporation.
9 #include <linux/miscdevice.h>
11 /* Different phases of the KCS BMC module.
13 * BMC should not be expecting nor sending any data.
14 * KCS_PHASE_WRITE_START:
15 * BMC is receiving a WRITE_START command from system software.
16 * KCS_PHASE_WRITE_DATA:
17 * BMC is receiving a data byte from system software.
18 * KCS_PHASE_WRITE_END_CMD:
19 * BMC is waiting a last data byte from system software.
20 * KCS_PHASE_WRITE_DONE:
21 * BMC has received the whole request from system software.
22 * KCS_PHASE_WAIT_READ:
23 * BMC is waiting the response from the upper IPMI service.
25 * BMC is transferring the response to system software.
26 * KCS_PHASE_ABORT_ERROR1:
27 * BMC is waiting error status request from system software.
28 * KCS_PHASE_ABORT_ERROR2:
29 * BMC is waiting for idle status afer error from system software.
31 * BMC has detected a protocol violation at the interface level.
36 KCS_PHASE_WRITE_START,
38 KCS_PHASE_WRITE_END_CMD,
44 KCS_PHASE_ABORT_ERROR1,
45 KCS_PHASE_ABORT_ERROR2,
49 /* IPMI 2.0 - Table 9-4, KCS Interface Status Codes */
52 KCS_ABORTED_BY_COMMAND = 0x01,
53 KCS_ILLEGAL_CONTROL_CODE = 0x02,
54 KCS_LENGTH_ERROR = 0x06,
55 KCS_UNSPECIFIED_ERROR = 0xFF
58 /* IPMI 2.0 - 9.5, KCS Interface Registers
59 * @idr: Input Data Register
60 * @odr: Output Data Register
61 * @str: Status Register
75 /* Setup by BMC KCS controller driver */
76 struct kcs_ioreg ioreg;
77 u8 (*io_inputb)(struct kcs_bmc *kcs_bmc, u32 reg);
78 void (*io_outputb)(struct kcs_bmc *kcs_bmc, u32 reg, u8 b);
80 enum kcs_phases phase;
81 enum kcs_errors error;
83 wait_queue_head_t queue;
95 struct miscdevice miscdev;
100 static inline void *kcs_bmc_priv(struct kcs_bmc *kcs_bmc)
102 return kcs_bmc->priv;
105 int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc);
106 struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv,
108 #endif /* __KCS_BMC_H__ */