18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ipmi_si_sm.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * State machine interface for low-level IPMI system management 68c2ecf20Sopenharmony_ci * interface state machines. This code is the interface between 78c2ecf20Sopenharmony_ci * the ipmi_smi code (that handles the policy of a KCS, SMIC, or 88c2ecf20Sopenharmony_ci * BT interface) and the actual low-level state machine. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc. 118c2ecf20Sopenharmony_ci * Corey Minyard <minyard@mvista.com> 128c2ecf20Sopenharmony_ci * source@mvista.com 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Copyright 2002 MontaVista Software Inc. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifndef __IPMI_SI_SM_H__ 188c2ecf20Sopenharmony_ci#define __IPMI_SI_SM_H__ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include "ipmi_si.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * This is defined by the state machines themselves, it is an opaque 248c2ecf20Sopenharmony_ci * data type for them to use. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cistruct si_sm_data; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Results of SMI events. */ 298c2ecf20Sopenharmony_cienum si_sm_result { 308c2ecf20Sopenharmony_ci SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */ 318c2ecf20Sopenharmony_ci SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */ 328c2ecf20Sopenharmony_ci SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */ 338c2ecf20Sopenharmony_ci SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */ 348c2ecf20Sopenharmony_ci SI_SM_IDLE, /* The SM is in idle state. */ 358c2ecf20Sopenharmony_ci SI_SM_HOSED, /* The hardware violated the state machine. */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci /* 388c2ecf20Sopenharmony_ci * The hardware is asserting attn and the state machine is 398c2ecf20Sopenharmony_ci * idle. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci SI_SM_ATTN 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Handlers for the SMI state machine. */ 458c2ecf20Sopenharmony_cistruct si_sm_handlers { 468c2ecf20Sopenharmony_ci /* 478c2ecf20Sopenharmony_ci * Put the version number of the state machine here so the 488c2ecf20Sopenharmony_ci * upper layer can print it. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci char *version; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci /* 538c2ecf20Sopenharmony_ci * Initialize the data and return the amount of I/O space to 548c2ecf20Sopenharmony_ci * reserve for the space. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci unsigned int (*init_data)(struct si_sm_data *smi, 578c2ecf20Sopenharmony_ci struct si_sm_io *io); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* 608c2ecf20Sopenharmony_ci * Start a new transaction in the state machine. This will 618c2ecf20Sopenharmony_ci * return -2 if the state machine is not idle, -1 if the size 628c2ecf20Sopenharmony_ci * is invalid (to large or too small), or 0 if the transaction 638c2ecf20Sopenharmony_ci * is successfully completed. 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci int (*start_transaction)(struct si_sm_data *smi, 668c2ecf20Sopenharmony_ci unsigned char *data, unsigned int size); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci /* 698c2ecf20Sopenharmony_ci * Return the results after the transaction. This will return 708c2ecf20Sopenharmony_ci * -1 if the buffer is too small, zero if no transaction is 718c2ecf20Sopenharmony_ci * present, or the actual length of the result data. 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci int (*get_result)(struct si_sm_data *smi, 748c2ecf20Sopenharmony_ci unsigned char *data, unsigned int length); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci /* 778c2ecf20Sopenharmony_ci * Call this periodically (for a polled interface) or upon 788c2ecf20Sopenharmony_ci * receiving an interrupt (for a interrupt-driven interface). 798c2ecf20Sopenharmony_ci * If interrupt driven, you should probably poll this 808c2ecf20Sopenharmony_ci * periodically when not in idle state. This should be called 818c2ecf20Sopenharmony_ci * with the time that passed since the last call, if it is 828c2ecf20Sopenharmony_ci * significant. Time is in microseconds. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci enum si_sm_result (*event)(struct si_sm_data *smi, long time); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* 878c2ecf20Sopenharmony_ci * Attempt to detect an SMI. Returns 0 on success or nonzero 888c2ecf20Sopenharmony_ci * on failure. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci int (*detect)(struct si_sm_data *smi); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* The interface is shutting down, so clean it up. */ 938c2ecf20Sopenharmony_ci void (*cleanup)(struct si_sm_data *smi); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* Return the size of the SMI structure in bytes. */ 968c2ecf20Sopenharmony_ci int (*size)(void); 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* Current state machines that we can use. */ 1008c2ecf20Sopenharmony_ciextern const struct si_sm_handlers kcs_smi_handlers; 1018c2ecf20Sopenharmony_ciextern const struct si_sm_handlers smic_smi_handlers; 1028c2ecf20Sopenharmony_ciextern const struct si_sm_handlers bt_smi_handlers; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#endif /* __IPMI_SI_SM_H__ */ 105