ipmi_si: Convert some types into unsigned
[linux-2.6-block.git] / drivers / char / ipmi / ipmi_si_sm.h
CommitLineData
243ac210 1/* SPDX-License-Identifier: GPL-2.0+ */
1da177e4
LT
2/*
3 * ipmi_si_sm.h
4 *
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.
9 *
10 * Author: MontaVista Software, Inc.
11 * Corey Minyard <minyard@mvista.com>
12 * source@mvista.com
13 *
14 * Copyright 2002 MontaVista Software Inc.
1da177e4
LT
15 */
16
910840f2
CM
17#include <linux/ipmi.h>
18
c305e3d3
CM
19/*
20 * This is defined by the state machines themselves, it is an opaque
21 * data type for them to use.
22 */
1da177e4
LT
23struct si_sm_data;
24
910840f2 25enum si_type {
95e300c0 26 SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT
910840f2
CM
27};
28
c305e3d3
CM
29/*
30 * The structure for doing I/O in the state machine. The state
31 * machine doesn't have the actual I/O routines, they are done through
32 * this interface.
33 */
34struct si_sm_io {
81d02b7f
CM
35 unsigned char (*inputb)(const struct si_sm_io *io, unsigned int offset);
36 void (*outputb)(const struct si_sm_io *io,
1da177e4
LT
37 unsigned int offset,
38 unsigned char b);
39
c305e3d3
CM
40 /*
41 * Generic info used by the actual handling routines, the
42 * state machine shouldn't touch these.
43 */
1b75d8ba 44 void __iomem *addr;
f25eb448
CM
45 unsigned int regspacing;
46 unsigned int regsize;
47 unsigned int regshift;
b0defcdb 48 int addr_type;
f25eb448 49 unsigned long addr_data;
910840f2
CM
50 enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
51 void (*addr_source_cleanup)(struct si_sm_io *io);
52 void *addr_source_data;
bb398a4c 53 union ipmi_smi_info_union addr_info;
910840f2 54
e1eeb7f8
CM
55 int (*io_setup)(struct si_sm_io *info);
56 void (*io_cleanup)(struct si_sm_io *info);
57 unsigned int io_size;
58
910840f2 59 int irq;
4f3e8199
CM
60 int (*irq_setup)(struct si_sm_io *io);
61 void *irq_handler_data;
62 void (*irq_cleanup)(struct si_sm_io *io);
63
910840f2
CM
64 u8 slave_addr;
65 enum si_type si_type;
66 struct device *dev;
1da177e4
LT
67};
68
69/* Results of SMI events. */
c305e3d3 70enum si_sm_result {
1da177e4
LT
71 SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
72 SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
c305e3d3 73 SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
1da177e4
LT
74 SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
75 SI_SM_IDLE, /* The SM is in idle state. */
76 SI_SM_HOSED, /* The hardware violated the state machine. */
c305e3d3
CM
77
78 /*
79 * The hardware is asserting attn and the state machine is
80 * idle.
81 */
82 SI_SM_ATTN
1da177e4
LT
83};
84
85/* Handlers for the SMI state machine. */
c305e3d3
CM
86struct si_sm_handlers {
87 /*
88 * Put the version number of the state machine here so the
89 * upper layer can print it.
90 */
1da177e4
LT
91 char *version;
92
c305e3d3
CM
93 /*
94 * Initialize the data and return the amount of I/O space to
95 * reserve for the space.
96 */
1da177e4
LT
97 unsigned int (*init_data)(struct si_sm_data *smi,
98 struct si_sm_io *io);
99
c305e3d3
CM
100 /*
101 * Start a new transaction in the state machine. This will
102 * return -2 if the state machine is not idle, -1 if the size
103 * is invalid (to large or too small), or 0 if the transaction
104 * is successfully completed.
105 */
1da177e4
LT
106 int (*start_transaction)(struct si_sm_data *smi,
107 unsigned char *data, unsigned int size);
108
c305e3d3
CM
109 /*
110 * Return the results after the transaction. This will return
111 * -1 if the buffer is too small, zero if no transaction is
112 * present, or the actual length of the result data.
113 */
1da177e4
LT
114 int (*get_result)(struct si_sm_data *smi,
115 unsigned char *data, unsigned int length);
116
c305e3d3
CM
117 /*
118 * Call this periodically (for a polled interface) or upon
119 * receiving an interrupt (for a interrupt-driven interface).
120 * If interrupt driven, you should probably poll this
121 * periodically when not in idle state. This should be called
122 * with the time that passed since the last call, if it is
123 * significant. Time is in microseconds.
124 */
1da177e4
LT
125 enum si_sm_result (*event)(struct si_sm_data *smi, long time);
126
c305e3d3
CM
127 /*
128 * Attempt to detect an SMI. Returns 0 on success or nonzero
129 * on failure.
130 */
1da177e4
LT
131 int (*detect)(struct si_sm_data *smi);
132
133 /* The interface is shutting down, so clean it up. */
134 void (*cleanup)(struct si_sm_data *smi);
135
136 /* Return the size of the SMI structure in bytes. */
137 int (*size)(void);
138};
139
140/* Current state machines that we can use. */
81d02b7f
CM
141extern const struct si_sm_handlers kcs_smi_handlers;
142extern const struct si_sm_handlers smic_smi_handlers;
143extern const struct si_sm_handlers bt_smi_handlers;
1da177e4 144