Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / char / ipmi / ipmi_si_sm.h
blobc3cdbcab0f7755b3ffe40d0e598a974ba002f21c
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * ipmi_si_sm.h
5 * State machine interface for low-level IPMI system management
6 * interface state machines. This code is the interface between
7 * the ipmi_smi code (that handles the policy of a KCS, SMIC, or
8 * BT interface) and the actual low-level state machine.
10 * Author: MontaVista Software, Inc.
11 * Corey Minyard <minyard@mvista.com>
12 * source@mvista.com
14 * Copyright 2002 MontaVista Software Inc.
17 #ifndef __IPMI_SI_SM_H__
18 #define __IPMI_SI_SM_H__
20 #include "ipmi_si.h"
23 * This is defined by the state machines themselves, it is an opaque
24 * data type for them to use.
26 struct si_sm_data;
28 /* Results of SMI events. */
29 enum si_sm_result {
30 SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
31 SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
32 SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
33 SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
34 SI_SM_IDLE, /* The SM is in idle state. */
35 SI_SM_HOSED, /* The hardware violated the state machine. */
38 * The hardware is asserting attn and the state machine is
39 * idle.
41 SI_SM_ATTN
44 /* Handlers for the SMI state machine. */
45 struct si_sm_handlers {
47 * Put the version number of the state machine here so the
48 * upper layer can print it.
50 char *version;
53 * Initialize the data and return the amount of I/O space to
54 * reserve for the space.
56 unsigned int (*init_data)(struct si_sm_data *smi,
57 struct si_sm_io *io);
60 * Start a new transaction in the state machine. This will
61 * return -2 if the state machine is not idle, -1 if the size
62 * is invalid (to large or too small), or 0 if the transaction
63 * is successfully completed.
65 int (*start_transaction)(struct si_sm_data *smi,
66 unsigned char *data, unsigned int size);
69 * Return the results after the transaction. This will return
70 * -1 if the buffer is too small, zero if no transaction is
71 * present, or the actual length of the result data.
73 int (*get_result)(struct si_sm_data *smi,
74 unsigned char *data, unsigned int length);
77 * Call this periodically (for a polled interface) or upon
78 * receiving an interrupt (for a interrupt-driven interface).
79 * If interrupt driven, you should probably poll this
80 * periodically when not in idle state. This should be called
81 * with the time that passed since the last call, if it is
82 * significant. Time is in microseconds.
84 enum si_sm_result (*event)(struct si_sm_data *smi, long time);
87 * Attempt to detect an SMI. Returns 0 on success or nonzero
88 * on failure.
90 int (*detect)(struct si_sm_data *smi);
92 /* The interface is shutting down, so clean it up. */
93 void (*cleanup)(struct si_sm_data *smi);
95 /* Return the size of the SMI structure in bytes. */
96 int (*size)(void);
99 /* Current state machines that we can use. */
100 extern const struct si_sm_handlers kcs_smi_handlers;
101 extern const struct si_sm_handlers smic_smi_handlers;
102 extern const struct si_sm_handlers bt_smi_handlers;
104 #endif /* __IPMI_SI_SM_H__ */