Commit c305e3d3 authored by Corey Minyard's avatar Corey Minyard Committed by Linus Torvalds

IPMI: Style fixes in the system interface code

Lots of style fixes for the IPMI system interface driver.  No functional
changes.  Basically fixes everything reported by checkpatch and fixes the
comment style.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
Cc: Rocky Craig <rocky.craig@hp.com>
Cc: Hannes Schulz <schulz@schwaar.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c70d7499
This diff is collapsed.
...@@ -60,37 +60,58 @@ MODULE_PARM_DESC(kcs_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); ...@@ -60,37 +60,58 @@ MODULE_PARM_DESC(kcs_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
/* The states the KCS driver may be in. */ /* The states the KCS driver may be in. */
enum kcs_states { enum kcs_states {
KCS_IDLE, /* The KCS interface is currently /* The KCS interface is currently doing nothing. */
doing nothing. */ KCS_IDLE,
KCS_START_OP, /* We are starting an operation. The
data is in the output buffer, but /*
nothing has been done to the * We are starting an operation. The data is in the output
interface yet. This was added to * buffer, but nothing has been done to the interface yet. This
the state machine in the spec to * was added to the state machine in the spec to wait for the
wait for the initial IBF. */ * initial IBF.
KCS_WAIT_WRITE_START, /* We have written a write cmd to the */
interface. */ KCS_START_OP,
KCS_WAIT_WRITE, /* We are writing bytes to the
interface. */ /* We have written a write cmd to the interface. */
KCS_WAIT_WRITE_END, /* We have written the write end cmd KCS_WAIT_WRITE_START,
to the interface, and still need to
write the last byte. */ /* We are writing bytes to the interface. */
KCS_WAIT_READ, /* We are waiting to read data from KCS_WAIT_WRITE,
the interface. */
KCS_ERROR0, /* State to transition to the error /*
handler, this was added to the * We have written the write end cmd to the interface, and
state machine in the spec to be * still need to write the last byte.
sure IBF was there. */ */
KCS_ERROR1, /* First stage error handler, wait for KCS_WAIT_WRITE_END,
the interface to respond. */
KCS_ERROR2, /* The abort cmd has been written, /* We are waiting to read data from the interface. */
wait for the interface to KCS_WAIT_READ,
respond. */
KCS_ERROR3, /* We wrote some data to the /*
interface, wait for it to switch to * State to transition to the error handler, this was added to
read mode. */ * the state machine in the spec to be sure IBF was there.
KCS_HOSED /* The hardware failed to follow the */
state machine. */ KCS_ERROR0,
/*
* First stage error handler, wait for the interface to
* respond.
*/
KCS_ERROR1,
/*
* The abort cmd has been written, wait for the interface to
* respond.
*/
KCS_ERROR2,
/*
* We wrote some data to the interface, wait for it to switch
* to read mode.
*/
KCS_ERROR3,
/* The hardware failed to follow the state machine. */
KCS_HOSED
}; };
#define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH #define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH
...@@ -102,8 +123,7 @@ enum kcs_states { ...@@ -102,8 +123,7 @@ enum kcs_states {
#define MAX_ERROR_RETRIES 10 #define MAX_ERROR_RETRIES 10
#define ERROR0_OBF_WAIT_JIFFIES (2*HZ) #define ERROR0_OBF_WAIT_JIFFIES (2*HZ)
struct si_sm_data struct si_sm_data {
{
enum kcs_states state; enum kcs_states state;
struct si_sm_io *io; struct si_sm_io *io;
unsigned char write_data[MAX_KCS_WRITE_SIZE]; unsigned char write_data[MAX_KCS_WRITE_SIZE];
...@@ -187,7 +207,8 @@ static inline void start_error_recovery(struct si_sm_data *kcs, char *reason) ...@@ -187,7 +207,8 @@ static inline void start_error_recovery(struct si_sm_data *kcs, char *reason)
(kcs->error_retries)++; (kcs->error_retries)++;
if (kcs->error_retries > MAX_ERROR_RETRIES) { if (kcs->error_retries > MAX_ERROR_RETRIES) {
if (kcs_debug & KCS_DEBUG_ENABLE) if (kcs_debug & KCS_DEBUG_ENABLE)
printk(KERN_DEBUG "ipmi_kcs_sm: kcs hosed: %s\n", reason); printk(KERN_DEBUG "ipmi_kcs_sm: kcs hosed: %s\n",
reason);
kcs->state = KCS_HOSED; kcs->state = KCS_HOSED;
} else { } else {
kcs->error0_timeout = jiffies + ERROR0_OBF_WAIT_JIFFIES; kcs->error0_timeout = jiffies + ERROR0_OBF_WAIT_JIFFIES;
...@@ -271,10 +292,9 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data, ...@@ -271,10 +292,9 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
if (kcs_debug & KCS_DEBUG_MSG) { if (kcs_debug & KCS_DEBUG_MSG) {
printk(KERN_DEBUG "start_kcs_transaction -"); printk(KERN_DEBUG "start_kcs_transaction -");
for (i = 0; i < size; i ++) { for (i = 0; i < size; i++)
printk(" %02x", (unsigned char) (data [i])); printk(" %02x", (unsigned char) (data [i]));
} printk("\n");
printk ("\n");
} }
kcs->error_retries = 0; kcs->error_retries = 0;
memcpy(kcs->write_data, data, size); memcpy(kcs->write_data, data, size);
...@@ -305,9 +325,11 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data, ...@@ -305,9 +325,11 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data,
kcs->read_pos = 3; kcs->read_pos = 3;
} }
if (kcs->truncated) { if (kcs->truncated) {
/* Report a truncated error. We might overwrite /*
another error, but that's too bad, the user needs * Report a truncated error. We might overwrite
to know it was truncated. */ * another error, but that's too bad, the user needs
* to know it was truncated.
*/
data[2] = IPMI_ERR_MSG_TRUNCATED; data[2] = IPMI_ERR_MSG_TRUNCATED;
kcs->truncated = 0; kcs->truncated = 0;
} }
...@@ -315,9 +337,11 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data, ...@@ -315,9 +337,11 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data,
return kcs->read_pos; return kcs->read_pos;
} }
/* This implements the state machine defined in the IPMI manual, see /*
that for details on how this works. Divide that flowchart into * This implements the state machine defined in the IPMI manual, see
sections delimited by "Wait for IBF" and this will become clear. */ * that for details on how this works. Divide that flowchart into
* sections delimited by "Wait for IBF" and this will become clear.
*/
static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
{ {
unsigned char status; unsigned char status;
...@@ -392,7 +416,8 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) ...@@ -392,7 +416,8 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
case KCS_WAIT_WRITE_END: case KCS_WAIT_WRITE_END:
if (state != KCS_WRITE_STATE) { if (state != KCS_WRITE_STATE) {
start_error_recovery(kcs, start_error_recovery(kcs,
"Not in write state for write end"); "Not in write state"
" for write end");
break; break;
} }
clear_obf(kcs, status); clear_obf(kcs, status);
...@@ -413,13 +438,15 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) ...@@ -413,13 +438,15 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
read_next_byte(kcs); read_next_byte(kcs);
} else { } else {
/* We don't implement this exactly like the state /*
machine in the spec. Some broken hardware * We don't implement this exactly like the state
does not write the final dummy byte to the * machine in the spec. Some broken hardware
read register. Thus obf will never go high * does not write the final dummy byte to the
here. We just go straight to idle, and we * read register. Thus obf will never go high
handle clearing out obf in idle state if it * here. We just go straight to idle, and we
happens to come in. */ * handle clearing out obf in idle state if it
* happens to come in.
*/
clear_obf(kcs, status); clear_obf(kcs, status);
kcs->orig_write_count = 0; kcs->orig_write_count = 0;
kcs->state = KCS_IDLE; kcs->state = KCS_IDLE;
...@@ -430,7 +457,8 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) ...@@ -430,7 +457,8 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
case KCS_ERROR0: case KCS_ERROR0:
clear_obf(kcs, status); clear_obf(kcs, status);
status = read_status(kcs); status = read_status(kcs);
if (GET_STATUS_OBF(status)) /* controller isn't responding */ if (GET_STATUS_OBF(status))
/* controller isn't responding */
if (time_before(jiffies, kcs->error0_timeout)) if (time_before(jiffies, kcs->error0_timeout))
return SI_SM_CALL_WITH_TICK_DELAY; return SI_SM_CALL_WITH_TICK_DELAY;
write_cmd(kcs, KCS_GET_STATUS_ABORT); write_cmd(kcs, KCS_GET_STATUS_ABORT);
...@@ -495,10 +523,12 @@ static int kcs_size(void) ...@@ -495,10 +523,12 @@ static int kcs_size(void)
static int kcs_detect(struct si_sm_data *kcs) static int kcs_detect(struct si_sm_data *kcs)
{ {
/* It's impossible for the KCS status register to be all 1's, /*
(assuming a properly functioning, self-initialized BMC) * It's impossible for the KCS status register to be all 1's,
but that's what you get from reading a bogus address, so we * (assuming a properly functioning, self-initialized BMC)
test that first. */ * but that's what you get from reading a bogus address, so we
* test that first.
*/
if (read_status(kcs) == 0xff) if (read_status(kcs) == 0xff)
return 1; return 1;
...@@ -509,8 +539,7 @@ static void kcs_cleanup(struct si_sm_data *kcs) ...@@ -509,8 +539,7 @@ static void kcs_cleanup(struct si_sm_data *kcs)
{ {
} }
struct si_sm_handlers kcs_smi_handlers = struct si_sm_handlers kcs_smi_handlers = {
{
.init_data = init_kcs_data, .init_data = init_kcs_data,
.start_transaction = start_kcs_transaction, .start_transaction = start_kcs_transaction,
.get_result = get_kcs_result, .get_result = get_kcs_result,
......
This diff is collapsed.
...@@ -34,22 +34,27 @@ ...@@ -34,22 +34,27 @@
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* This is defined by the state machines themselves, it is an opaque /*
data type for them to use. */ * This is defined by the state machines themselves, it is an opaque
* data type for them to use.
*/
struct si_sm_data; struct si_sm_data;
/* The structure for doing I/O in the state machine. The state /*
machine doesn't have the actual I/O routines, they are done through * The structure for doing I/O in the state machine. The state
this interface. */ * machine doesn't have the actual I/O routines, they are done through
struct si_sm_io * this interface.
{ */
struct si_sm_io {
unsigned char (*inputb)(struct si_sm_io *io, unsigned int offset); unsigned char (*inputb)(struct si_sm_io *io, unsigned int offset);
void (*outputb)(struct si_sm_io *io, void (*outputb)(struct si_sm_io *io,
unsigned int offset, unsigned int offset,
unsigned char b); unsigned char b);
/* Generic info used by the actual handling routines, the /*
state machine shouldn't touch these. */ * Generic info used by the actual handling routines, the
* state machine shouldn't touch these.
*/
void __iomem *addr; void __iomem *addr;
int regspacing; int regspacing;
int regsize; int regsize;
...@@ -59,53 +64,67 @@ struct si_sm_io ...@@ -59,53 +64,67 @@ struct si_sm_io
}; };
/* Results of SMI events. */ /* Results of SMI events. */
enum si_sm_result enum si_sm_result {
{
SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */ SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */ SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
SI_SM_CALL_WITH_TICK_DELAY, /* Delay at least 1 tick before calling again. */ SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */ SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
SI_SM_IDLE, /* The SM is in idle state. */ SI_SM_IDLE, /* The SM is in idle state. */
SI_SM_HOSED, /* The hardware violated the state machine. */ SI_SM_HOSED, /* The hardware violated the state machine. */
SI_SM_ATTN /* The hardware is asserting attn and the
state machine is idle. */ /*
* The hardware is asserting attn and the state machine is
* idle.
*/
SI_SM_ATTN
}; };
/* Handlers for the SMI state machine. */ /* Handlers for the SMI state machine. */
struct si_sm_handlers struct si_sm_handlers {
{ /*
/* Put the version number of the state machine here so the * Put the version number of the state machine here so the
upper layer can print it. */ * upper layer can print it.
*/
char *version; char *version;
/* Initialize the data and return the amount of I/O space to /*
reserve for the space. */ * Initialize the data and return the amount of I/O space to
* reserve for the space.
*/
unsigned int (*init_data)(struct si_sm_data *smi, unsigned int (*init_data)(struct si_sm_data *smi,
struct si_sm_io *io); struct si_sm_io *io);
/* Start a new transaction in the state machine. This will /*
return -2 if the state machine is not idle, -1 if the size * Start a new transaction in the state machine. This will
is invalid (to large or too small), or 0 if the transaction * return -2 if the state machine is not idle, -1 if the size
is successfully completed. */ * is invalid (to large or too small), or 0 if the transaction
* is successfully completed.
*/
int (*start_transaction)(struct si_sm_data *smi, int (*start_transaction)(struct si_sm_data *smi,
unsigned char *data, unsigned int size); unsigned char *data, unsigned int size);
/* Return the results after the transaction. This will return /*
-1 if the buffer is too small, zero if no transaction is * Return the results after the transaction. This will return
present, or the actual length of the result data. */ * -1 if the buffer is too small, zero if no transaction is
* present, or the actual length of the result data.
*/
int (*get_result)(struct si_sm_data *smi, int (*get_result)(struct si_sm_data *smi,
unsigned char *data, unsigned int length); unsigned char *data, unsigned int length);
/* Call this periodically (for a polled interface) or upon /*
receiving an interrupt (for a interrupt-driven interface). * Call this periodically (for a polled interface) or upon
If interrupt driven, you should probably poll this * receiving an interrupt (for a interrupt-driven interface).
periodically when not in idle state. This should be called * If interrupt driven, you should probably poll this
with the time that passed since the last call, if it is * periodically when not in idle state. This should be called
significant. Time is in microseconds. */ * with the time that passed since the last call, if it is
* significant. Time is in microseconds.
*/
enum si_sm_result (*event)(struct si_sm_data *smi, long time); enum si_sm_result (*event)(struct si_sm_data *smi, long time);
/* Attempt to detect an SMI. Returns 0 on success or nonzero /*
on failure. */ * Attempt to detect an SMI. Returns 0 on success or nonzero
* on failure.
*/
int (*detect)(struct si_sm_data *smi); int (*detect)(struct si_sm_data *smi);
/* The interface is shutting down, so clean it up. */ /* The interface is shutting down, so clean it up. */
......
...@@ -85,6 +85,7 @@ enum smic_states { ...@@ -85,6 +85,7 @@ enum smic_states {
/* SMIC Flags Register Bits */ /* SMIC Flags Register Bits */
#define SMIC_RX_DATA_READY 0x80 #define SMIC_RX_DATA_READY 0x80
#define SMIC_TX_DATA_READY 0x40 #define SMIC_TX_DATA_READY 0x40
/* /*
* SMIC_SMI and SMIC_EVM_DATA_AVAIL are only used by * SMIC_SMI and SMIC_EVM_DATA_AVAIL are only used by
* a few systems, and then only by Systems Management * a few systems, and then only by Systems Management
...@@ -104,8 +105,7 @@ enum smic_states { ...@@ -104,8 +105,7 @@ enum smic_states {
#define EC_ILLEGAL_COMMAND 0x04 #define EC_ILLEGAL_COMMAND 0x04
#define EC_BUFFER_FULL 0x05 #define EC_BUFFER_FULL 0x05
struct si_sm_data struct si_sm_data {
{
enum smic_states state; enum smic_states state;
struct si_sm_io *io; struct si_sm_io *io;
unsigned char write_data[MAX_SMIC_WRITE_SIZE]; unsigned char write_data[MAX_SMIC_WRITE_SIZE];
...@@ -119,7 +119,7 @@ struct si_sm_data ...@@ -119,7 +119,7 @@ struct si_sm_data
long smic_timeout; long smic_timeout;
}; };
static unsigned int init_smic_data (struct si_sm_data *smic, static unsigned int init_smic_data(struct si_sm_data *smic,
struct si_sm_io *io) struct si_sm_io *io)
{ {
smic->state = SMIC_IDLE; smic->state = SMIC_IDLE;
...@@ -150,11 +150,10 @@ static int start_smic_transaction(struct si_sm_data *smic, ...@@ -150,11 +150,10 @@ static int start_smic_transaction(struct si_sm_data *smic,
return IPMI_NOT_IN_MY_STATE_ERR; return IPMI_NOT_IN_MY_STATE_ERR;
if (smic_debug & SMIC_DEBUG_MSG) { if (smic_debug & SMIC_DEBUG_MSG) {
printk(KERN_INFO "start_smic_transaction -"); printk(KERN_DEBUG "start_smic_transaction -");
for (i = 0; i < size; i ++) { for (i = 0; i < size; i++)
printk (" %02x", (unsigned char) (data [i])); printk(" %02x", (unsigned char) data[i]);
} printk("\n");
printk ("\n");
} }
smic->error_retries = 0; smic->error_retries = 0;
memcpy(smic->write_data, data, size); memcpy(smic->write_data, data, size);
...@@ -173,11 +172,10 @@ static int smic_get_result(struct si_sm_data *smic, ...@@ -173,11 +172,10 @@ static int smic_get_result(struct si_sm_data *smic,
int i; int i;
if (smic_debug & SMIC_DEBUG_MSG) { if (smic_debug & SMIC_DEBUG_MSG) {
printk (KERN_INFO "smic_get result -"); printk(KERN_DEBUG "smic_get result -");
for (i = 0; i < smic->read_pos; i ++) { for (i = 0; i < smic->read_pos; i++)
printk (" %02x", (smic->read_data [i])); printk(" %02x", smic->read_data[i]);
} printk("\n");
printk ("\n");
} }
if (length < smic->read_pos) { if (length < smic->read_pos) {
smic->read_pos = length; smic->read_pos = length;
...@@ -223,7 +221,7 @@ static inline void write_smic_control(struct si_sm_data *smic, ...@@ -223,7 +221,7 @@ static inline void write_smic_control(struct si_sm_data *smic,
smic->io->outputb(smic->io, 1, control); smic->io->outputb(smic->io, 1, control);
} }
static inline void write_si_sm_data (struct si_sm_data *smic, static inline void write_si_sm_data(struct si_sm_data *smic,
unsigned char data) unsigned char data)
{ {
smic->io->outputb(smic->io, 0, data); smic->io->outputb(smic->io, 0, data);
...@@ -233,10 +231,9 @@ static inline void start_error_recovery(struct si_sm_data *smic, char *reason) ...@@ -233,10 +231,9 @@ static inline void start_error_recovery(struct si_sm_data *smic, char *reason)
{ {
(smic->error_retries)++; (smic->error_retries)++;
if (smic->error_retries > SMIC_MAX_ERROR_RETRIES) { if (smic->error_retries > SMIC_MAX_ERROR_RETRIES) {
if (smic_debug & SMIC_DEBUG_ENABLE) { if (smic_debug & SMIC_DEBUG_ENABLE)
printk(KERN_WARNING printk(KERN_WARNING
"ipmi_smic_drv: smic hosed: %s\n", reason); "ipmi_smic_drv: smic hosed: %s\n", reason);
}
smic->state = SMIC_HOSED; smic->state = SMIC_HOSED;
} else { } else {
smic->write_count = smic->orig_write_count; smic->write_count = smic->orig_write_count;
...@@ -254,14 +251,14 @@ static inline void write_next_byte(struct si_sm_data *smic) ...@@ -254,14 +251,14 @@ static inline void write_next_byte(struct si_sm_data *smic)
(smic->write_count)--; (smic->write_count)--;
} }
static inline void read_next_byte (struct si_sm_data *smic) static inline void read_next_byte(struct si_sm_data *smic)
{ {
if (smic->read_pos >= MAX_SMIC_READ_SIZE) { if (smic->read_pos >= MAX_SMIC_READ_SIZE) {
read_smic_data (smic); read_smic_data(smic);
smic->truncated = 1; smic->truncated = 1;
} else { } else {
smic->read_data[smic->read_pos] = read_smic_data(smic); smic->read_data[smic->read_pos] = read_smic_data(smic);
(smic->read_pos)++; smic->read_pos++;
} }
} }
...@@ -336,7 +333,7 @@ static inline void read_next_byte (struct si_sm_data *smic) ...@@ -336,7 +333,7 @@ static inline void read_next_byte (struct si_sm_data *smic)
SMIC_SC_SMS_RD_END 0xC6 SMIC_SC_SMS_RD_END 0xC6
*/ */
static enum si_sm_result smic_event (struct si_sm_data *smic, long time) static enum si_sm_result smic_event(struct si_sm_data *smic, long time)
{ {
unsigned char status; unsigned char status;
unsigned char flags; unsigned char flags;
...@@ -347,13 +344,15 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -347,13 +344,15 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
return SI_SM_HOSED; return SI_SM_HOSED;
} }
if (smic->state != SMIC_IDLE) { if (smic->state != SMIC_IDLE) {
if (smic_debug & SMIC_DEBUG_STATES) { if (smic_debug & SMIC_DEBUG_STATES)
printk(KERN_INFO printk(KERN_DEBUG
"smic_event - smic->smic_timeout = %ld," "smic_event - smic->smic_timeout = %ld,"
" time = %ld\n", " time = %ld\n",
smic->smic_timeout, time); smic->smic_timeout, time);
} /*
/* FIXME: smic_event is sometimes called with time > SMIC_RETRY_TIMEOUT */ * FIXME: smic_event is sometimes called with time >
* SMIC_RETRY_TIMEOUT
*/
if (time < SMIC_RETRY_TIMEOUT) { if (time < SMIC_RETRY_TIMEOUT) {
smic->smic_timeout -= time; smic->smic_timeout -= time;
if (smic->smic_timeout < 0) { if (smic->smic_timeout < 0) {
...@@ -366,9 +365,9 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -366,9 +365,9 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
if (flags & SMIC_FLAG_BSY) if (flags & SMIC_FLAG_BSY)
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
status = read_smic_status (smic); status = read_smic_status(smic);
if (smic_debug & SMIC_DEBUG_STATES) if (smic_debug & SMIC_DEBUG_STATES)
printk(KERN_INFO printk(KERN_DEBUG
"smic_event - state = %d, flags = 0x%02x," "smic_event - state = %d, flags = 0x%02x,"
" status = 0x%02x\n", " status = 0x%02x\n",
smic->state, flags, status); smic->state, flags, status);
...@@ -377,9 +376,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -377,9 +376,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
case SMIC_IDLE: case SMIC_IDLE:
/* in IDLE we check for available messages */ /* in IDLE we check for available messages */
if (flags & SMIC_SMS_DATA_AVAIL) if (flags & SMIC_SMS_DATA_AVAIL)
{
return SI_SM_ATTN; return SI_SM_ATTN;
}
return SI_SM_IDLE; return SI_SM_IDLE;
case SMIC_START_OP: case SMIC_START_OP:
...@@ -411,8 +408,10 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -411,8 +408,10 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
"status != SMIC_SC_SMS_WR_START"); "status != SMIC_SC_SMS_WR_START");
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
} }
/* we must not issue WR_(NEXT|END) unless /*
TX_DATA_READY is set */ * we must not issue WR_(NEXT|END) unless
* TX_DATA_READY is set
* */
if (flags & SMIC_TX_DATA_READY) { if (flags & SMIC_TX_DATA_READY) {
if (smic->write_count == 1) { if (smic->write_count == 1) {
/* last byte */ /* last byte */
...@@ -424,10 +423,8 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -424,10 +423,8 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
} }
write_next_byte(smic); write_next_byte(smic);
write_smic_flags(smic, flags | SMIC_FLAG_BSY); write_smic_flags(smic, flags | SMIC_FLAG_BSY);
} } else
else {
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
}
break; break;
case SMIC_WRITE_NEXT: case SMIC_WRITE_NEXT:
...@@ -442,22 +439,19 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -442,22 +439,19 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
if (smic->write_count == 1) { if (smic->write_count == 1) {
write_smic_control(smic, SMIC_CC_SMS_WR_END); write_smic_control(smic, SMIC_CC_SMS_WR_END);
smic->state = SMIC_WRITE_END; smic->state = SMIC_WRITE_END;
} } else {
else {
write_smic_control(smic, SMIC_CC_SMS_WR_NEXT); write_smic_control(smic, SMIC_CC_SMS_WR_NEXT);
smic->state = SMIC_WRITE_NEXT; smic->state = SMIC_WRITE_NEXT;
} }
write_next_byte(smic); write_next_byte(smic);
write_smic_flags(smic, flags | SMIC_FLAG_BSY); write_smic_flags(smic, flags | SMIC_FLAG_BSY);
} } else
else {
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
}
break; break;
case SMIC_WRITE_END: case SMIC_WRITE_END:
if (status != SMIC_SC_SMS_WR_END) { if (status != SMIC_SC_SMS_WR_END) {
start_error_recovery (smic, start_error_recovery(smic,
"state = SMIC_WRITE_END, " "state = SMIC_WRITE_END, "
"status != SMIC_SC_SMS_WR_END"); "status != SMIC_SC_SMS_WR_END");
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
...@@ -465,29 +459,28 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -465,29 +459,28 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
/* data register holds an error code */ /* data register holds an error code */
data = read_smic_data(smic); data = read_smic_data(smic);
if (data != 0) { if (data != 0) {
if (smic_debug & SMIC_DEBUG_ENABLE) { if (smic_debug & SMIC_DEBUG_ENABLE)
printk(KERN_INFO printk(KERN_DEBUG
"SMIC_WRITE_END: data = %02x\n", data); "SMIC_WRITE_END: data = %02x\n", data);
}
start_error_recovery(smic, start_error_recovery(smic,
"state = SMIC_WRITE_END, " "state = SMIC_WRITE_END, "
"data != SUCCESS"); "data != SUCCESS");
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
} else { } else
smic->state = SMIC_WRITE2READ; smic->state = SMIC_WRITE2READ;
}
break; break;
case SMIC_WRITE2READ: case SMIC_WRITE2READ:
/* we must wait for RX_DATA_READY to be set before we /*
can continue */ * we must wait for RX_DATA_READY to be set before we
* can continue
*/
if (flags & SMIC_RX_DATA_READY) { if (flags & SMIC_RX_DATA_READY) {
write_smic_control(smic, SMIC_CC_SMS_RD_START); write_smic_control(smic, SMIC_CC_SMS_RD_START);
write_smic_flags(smic, flags | SMIC_FLAG_BSY); write_smic_flags(smic, flags | SMIC_FLAG_BSY);
smic->state = SMIC_READ_START; smic->state = SMIC_READ_START;
} else { } else
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
}
break; break;
case SMIC_READ_START: case SMIC_READ_START:
...@@ -502,15 +495,16 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -502,15 +495,16 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
write_smic_control(smic, SMIC_CC_SMS_RD_NEXT); write_smic_control(smic, SMIC_CC_SMS_RD_NEXT);
write_smic_flags(smic, flags | SMIC_FLAG_BSY); write_smic_flags(smic, flags | SMIC_FLAG_BSY);
smic->state = SMIC_READ_NEXT; smic->state = SMIC_READ_NEXT;
} else { } else
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
}
break; break;
case SMIC_READ_NEXT: case SMIC_READ_NEXT:
switch (status) { switch (status) {
/* smic tells us that this is the last byte to be read /*
--> clean up */ * smic tells us that this is the last byte to be read
* --> clean up
*/
case SMIC_SC_SMS_RD_END: case SMIC_SC_SMS_RD_END:
read_next_byte(smic); read_next_byte(smic);
write_smic_control(smic, SMIC_CC_SMS_RD_END); write_smic_control(smic, SMIC_CC_SMS_RD_END);
...@@ -523,9 +517,8 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -523,9 +517,8 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
write_smic_control(smic, SMIC_CC_SMS_RD_NEXT); write_smic_control(smic, SMIC_CC_SMS_RD_NEXT);
write_smic_flags(smic, flags | SMIC_FLAG_BSY); write_smic_flags(smic, flags | SMIC_FLAG_BSY);
smic->state = SMIC_READ_NEXT; smic->state = SMIC_READ_NEXT;
} else { } else
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
}
break; break;
default: default:
start_error_recovery( start_error_recovery(
...@@ -546,10 +539,9 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -546,10 +539,9 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
data = read_smic_data(smic); data = read_smic_data(smic);
/* data register holds an error code */ /* data register holds an error code */
if (data != 0) { if (data != 0) {
if (smic_debug & SMIC_DEBUG_ENABLE) { if (smic_debug & SMIC_DEBUG_ENABLE)
printk(KERN_INFO printk(KERN_DEBUG
"SMIC_READ_END: data = %02x\n", data); "SMIC_READ_END: data = %02x\n", data);
}
start_error_recovery(smic, start_error_recovery(smic,
"state = SMIC_READ_END, " "state = SMIC_READ_END, "
"data != SUCCESS"); "data != SUCCESS");
...@@ -565,7 +557,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -565,7 +557,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
default: default:
if (smic_debug & SMIC_DEBUG_ENABLE) { if (smic_debug & SMIC_DEBUG_ENABLE) {
printk(KERN_WARNING "smic->state = %d\n", smic->state); printk(KERN_DEBUG "smic->state = %d\n", smic->state);
start_error_recovery(smic, "state = UNKNOWN"); start_error_recovery(smic, "state = UNKNOWN");
return SI_SM_CALL_WITH_DELAY; return SI_SM_CALL_WITH_DELAY;
} }
...@@ -576,10 +568,12 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time) ...@@ -576,10 +568,12 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
static int smic_detect(struct si_sm_data *smic) static int smic_detect(struct si_sm_data *smic)
{ {
/* It's impossible for the SMIC fnags register to be all 1's, /*
(assuming a properly functioning, self-initialized BMC) * It's impossible for the SMIC fnags register to be all 1's,
but that's what you get from reading a bogus address, so we * (assuming a properly functioning, self-initialized BMC)
test that first. */ * but that's what you get from reading a bogus address, so we
* test that first.
*/
if (read_smic_flags(smic) == 0xff) if (read_smic_flags(smic) == 0xff)
return 1; return 1;
...@@ -595,8 +589,7 @@ static int smic_size(void) ...@@ -595,8 +589,7 @@ static int smic_size(void)
return sizeof(struct si_sm_data); return sizeof(struct si_sm_data);
} }
struct si_sm_handlers smic_smi_handlers = struct si_sm_handlers smic_smi_handlers = {
{
.init_data = init_smic_data, .init_data = init_smic_data,
.start_transaction = start_smic_transaction, .start_transaction = start_smic_transaction,
.get_result = smic_get_result, .get_result = smic_get_result,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment