/* SPDX-License-Identifier: GPL-2.0+ */1/*2* ipmi_si_sm.h3*4* State machine interface for low-level IPMI system management5* interface state machines. This code is the interface between6* the ipmi_smi code (that handles the policy of a KCS, SMIC, or7* BT interface) and the actual low-level state machine.8*9* Author: MontaVista Software, Inc.10* Corey Minyard <[email protected]>11* [email protected]12*13* Copyright 2002 MontaVista Software Inc.14*/1516#ifndef __IPMI_SI_SM_H__17#define __IPMI_SI_SM_H__1819#include "ipmi_si.h"2021/*22* This is defined by the state machines themselves, it is an opaque23* data type for them to use.24*/25struct si_sm_data;2627/* Results of SMI events. */28enum si_sm_result {29SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */30SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */31SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */32SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */33SI_SM_IDLE, /* The SM is in idle state. */34SI_SM_HOSED, /* The hardware violated the state machine. */3536/*37* The hardware is asserting attn and the state machine is38* idle.39*/40SI_SM_ATTN41};4243/* Handlers for the SMI state machine. */44struct si_sm_handlers {45/*46* Put the version number of the state machine here so the47* upper layer can print it.48*/49char *version;5051/*52* Initialize the data and return the amount of I/O space to53* reserve for the space.54*/55unsigned int (*init_data)(struct si_sm_data *smi,56struct si_sm_io *io);5758/*59* Start a new transaction in the state machine. This will60* return -2 if the state machine is not idle, -1 if the size61* is invalid (to large or too small), or 0 if the transaction62* is successfully completed.63*/64int (*start_transaction)(struct si_sm_data *smi,65unsigned char *data, unsigned int size);6667/*68* Return the results after the transaction. This will return69* -1 if the buffer is too small, zero if no transaction is70* present, or the actual length of the result data.71*/72int (*get_result)(struct si_sm_data *smi,73unsigned char *data, unsigned int length);7475/*76* Call this periodically (for a polled interface) or upon77* receiving an interrupt (for a interrupt-driven interface).78* If interrupt driven, you should probably poll this79* periodically when not in idle state. This should be called80* with the time that passed since the last call, if it is81* significant. Time is in microseconds.82*/83enum si_sm_result (*event)(struct si_sm_data *smi, long time);8485/*86* Attempt to detect an SMI. Returns 0 on success or nonzero87* on failure.88*/89int (*detect)(struct si_sm_data *smi);9091/* The interface is shutting down, so clean it up. */92void (*cleanup)(struct si_sm_data *smi);9394/* Return the size of the SMI structure in bytes. */95int (*size)(void);96};9798/* Current state machines that we can use. */99extern const struct si_sm_handlers kcs_smi_handlers;100extern const struct si_sm_handlers smic_smi_handlers;101extern const struct si_sm_handlers bt_smi_handlers;102103#endif /* __IPMI_SI_SM_H__ */104105106