/*1* ipmi_si_sm.h2*3* State machine interface for low-level IPMI system management4* interface state machines. This code is the interface between5* the ipmi_smi code (that handles the policy of a KCS, SMIC, or6* BT interface) and the actual low-level state machine.7*8* Author: MontaVista Software, Inc.9* Corey Minyard <[email protected]>10* [email protected]11*12* Copyright 2002 MontaVista Software Inc.13*14* This program is free software; you can redistribute it and/or modify it15* under the terms of the GNU General Public License as published by the16* Free Software Foundation; either version 2 of the License, or (at your17* option) any later version.18*19*20* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED21* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF22* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.23* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,24* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,25* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS26* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND27* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR28* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE29* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*31* You should have received a copy of the GNU General Public License along32* with this program; if not, write to the Free Software Foundation, Inc.,33* 675 Mass Ave, Cambridge, MA 02139, USA.34*/3536/*37* This is defined by the state machines themselves, it is an opaque38* data type for them to use.39*/40struct si_sm_data;4142/*43* The structure for doing I/O in the state machine. The state44* machine doesn't have the actual I/O routines, they are done through45* this interface.46*/47struct si_sm_io {48unsigned char (*inputb)(struct si_sm_io *io, unsigned int offset);49void (*outputb)(struct si_sm_io *io,50unsigned int offset,51unsigned char b);5253/*54* Generic info used by the actual handling routines, the55* state machine shouldn't touch these.56*/57void __iomem *addr;58int regspacing;59int regsize;60int regshift;61int addr_type;62long addr_data;63};6465/* Results of SMI events. */66enum si_sm_result {67SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */68SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */69SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */70SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */71SI_SM_IDLE, /* The SM is in idle state. */72SI_SM_HOSED, /* The hardware violated the state machine. */7374/*75* The hardware is asserting attn and the state machine is76* idle.77*/78SI_SM_ATTN79};8081/* Handlers for the SMI state machine. */82struct si_sm_handlers {83/*84* Put the version number of the state machine here so the85* upper layer can print it.86*/87char *version;8889/*90* Initialize the data and return the amount of I/O space to91* reserve for the space.92*/93unsigned int (*init_data)(struct si_sm_data *smi,94struct si_sm_io *io);9596/*97* Start a new transaction in the state machine. This will98* return -2 if the state machine is not idle, -1 if the size99* is invalid (to large or too small), or 0 if the transaction100* is successfully completed.101*/102int (*start_transaction)(struct si_sm_data *smi,103unsigned char *data, unsigned int size);104105/*106* Return the results after the transaction. This will return107* -1 if the buffer is too small, zero if no transaction is108* present, or the actual length of the result data.109*/110int (*get_result)(struct si_sm_data *smi,111unsigned char *data, unsigned int length);112113/*114* Call this periodically (for a polled interface) or upon115* receiving an interrupt (for a interrupt-driven interface).116* If interrupt driven, you should probably poll this117* periodically when not in idle state. This should be called118* with the time that passed since the last call, if it is119* significant. Time is in microseconds.120*/121enum si_sm_result (*event)(struct si_sm_data *smi, long time);122123/*124* Attempt to detect an SMI. Returns 0 on success or nonzero125* on failure.126*/127int (*detect)(struct si_sm_data *smi);128129/* The interface is shutting down, so clean it up. */130void (*cleanup)(struct si_sm_data *smi);131132/* Return the size of the SMI structure in bytes. */133int (*size)(void);134};135136/* Current state machines that we can use. */137extern struct si_sm_handlers kcs_smi_handlers;138extern struct si_sm_handlers smic_smi_handlers;139extern struct si_sm_handlers bt_smi_handlers;140141142143