Merge tag 'for-linus-20190706' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / char / ipmi / ipmi_si_sm.h
blob499db820fadb3a0aea90afaa85d34b1d328f4fcb
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 #include <linux/ipmi.h>
20 * This is defined by the state machines themselves, it is an opaque
21 * data type for them to use.
23 struct si_sm_data;
25 enum si_type {
26 SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT
29 enum ipmi_addr_space {
30 IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
34 * The structure for doing I/O in the state machine. The state
35 * machine doesn't have the actual I/O routines, they are done through
36 * this interface.
38 struct si_sm_io {
39 unsigned char (*inputb)(const struct si_sm_io *io, unsigned int offset);
40 void (*outputb)(const struct si_sm_io *io,
41 unsigned int offset,
42 unsigned char b);
45 * Generic info used by the actual handling routines, the
46 * state machine shouldn't touch these.
48 void __iomem *addr;
49 unsigned int regspacing;
50 unsigned int regsize;
51 unsigned int regshift;
52 enum ipmi_addr_space addr_space;
53 unsigned long addr_data;
54 enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
55 void (*addr_source_cleanup)(struct si_sm_io *io);
56 void *addr_source_data;
57 union ipmi_smi_info_union addr_info;
59 int (*io_setup)(struct si_sm_io *info);
60 void (*io_cleanup)(struct si_sm_io *info);
61 unsigned int io_size;
63 int irq;
64 int (*irq_setup)(struct si_sm_io *io);
65 void *irq_handler_data;
66 void (*irq_cleanup)(struct si_sm_io *io);
68 u8 slave_addr;
69 enum si_type si_type;
70 struct device *dev;
73 /* Results of SMI events. */
74 enum si_sm_result {
75 SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
76 SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
77 SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
78 SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
79 SI_SM_IDLE, /* The SM is in idle state. */
80 SI_SM_HOSED, /* The hardware violated the state machine. */
83 * The hardware is asserting attn and the state machine is
84 * idle.
86 SI_SM_ATTN
89 /* Handlers for the SMI state machine. */
90 struct si_sm_handlers {
92 * Put the version number of the state machine here so the
93 * upper layer can print it.
95 char *version;
98 * Initialize the data and return the amount of I/O space to
99 * reserve for the space.
101 unsigned int (*init_data)(struct si_sm_data *smi,
102 struct si_sm_io *io);
105 * Start a new transaction in the state machine. This will
106 * return -2 if the state machine is not idle, -1 if the size
107 * is invalid (to large or too small), or 0 if the transaction
108 * is successfully completed.
110 int (*start_transaction)(struct si_sm_data *smi,
111 unsigned char *data, unsigned int size);
114 * Return the results after the transaction. This will return
115 * -1 if the buffer is too small, zero if no transaction is
116 * present, or the actual length of the result data.
118 int (*get_result)(struct si_sm_data *smi,
119 unsigned char *data, unsigned int length);
122 * Call this periodically (for a polled interface) or upon
123 * receiving an interrupt (for a interrupt-driven interface).
124 * If interrupt driven, you should probably poll this
125 * periodically when not in idle state. This should be called
126 * with the time that passed since the last call, if it is
127 * significant. Time is in microseconds.
129 enum si_sm_result (*event)(struct si_sm_data *smi, long time);
132 * Attempt to detect an SMI. Returns 0 on success or nonzero
133 * on failure.
135 int (*detect)(struct si_sm_data *smi);
137 /* The interface is shutting down, so clean it up. */
138 void (*cleanup)(struct si_sm_data *smi);
140 /* Return the size of the SMI structure in bytes. */
141 int (*size)(void);
144 /* Current state machines that we can use. */
145 extern const struct si_sm_handlers kcs_smi_handlers;
146 extern const struct si_sm_handlers smic_smi_handlers;
147 extern const struct si_sm_handlers bt_smi_handlers;