Lines Matching defs:smic
122 static unsigned int init_smic_data (struct si_sm_data *smic,
125 smic->state = SMIC_IDLE;
126 smic->io = io;
127 smic->write_pos = 0;
128 smic->write_count = 0;
129 smic->orig_write_count = 0;
130 smic->read_pos = 0;
131 smic->error_retries = 0;
132 smic->truncated = 0;
133 smic->smic_timeout = SMIC_RETRY_TIMEOUT;
139 static int start_smic_transaction(struct si_sm_data *smic,
149 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
159 smic->error_retries = 0;
160 memcpy(smic->write_data, data, size);
161 smic->write_count = size;
162 smic->orig_write_count = size;
163 smic->write_pos = 0;
164 smic->read_pos = 0;
165 smic->state = SMIC_START_OP;
166 smic->smic_timeout = SMIC_RETRY_TIMEOUT;
170 static int smic_get_result(struct si_sm_data *smic,
177 for (i = 0; i < smic->read_pos; i ++) {
178 printk (" %02x", (smic->read_data [i]));
182 if (length < smic->read_pos) {
183 smic->read_pos = length;
184 smic->truncated = 1;
186 memcpy(data, smic->read_data, smic->read_pos);
188 if ((length >= 3) && (smic->read_pos < 3)) {
190 smic->read_pos = 3;
192 if (smic->truncated) {
194 smic->truncated = 0;
196 return smic->read_pos;
199 static inline unsigned char read_smic_flags(struct si_sm_data *smic)
201 return smic->io->inputb(smic->io, 2);
204 static inline unsigned char read_smic_status(struct si_sm_data *smic)
206 return smic->io->inputb(smic->io, 1);
209 static inline unsigned char read_smic_data(struct si_sm_data *smic)
211 return smic->io->inputb(smic->io, 0);
214 static inline void write_smic_flags(struct si_sm_data *smic,
217 smic->io->outputb(smic->io, 2, flags);
220 static inline void write_smic_control(struct si_sm_data *smic,
223 smic->io->outputb(smic->io, 1, control);
226 static inline void write_si_sm_data (struct si_sm_data *smic,
229 smic->io->outputb(smic->io, 0, data);
232 static inline void start_error_recovery(struct si_sm_data *smic, char *reason)
234 (smic->error_retries)++;
235 if (smic->error_retries > SMIC_MAX_ERROR_RETRIES) {
238 "ipmi_smic_drv: smic hosed: %s\n", reason);
240 smic->state = SMIC_HOSED;
242 smic->write_count = smic->orig_write_count;
243 smic->write_pos = 0;
244 smic->read_pos = 0;
245 smic->state = SMIC_START_OP;
246 smic->smic_timeout = SMIC_RETRY_TIMEOUT;
250 static inline void write_next_byte(struct si_sm_data *smic)
252 write_si_sm_data(smic, smic->write_data[smic->write_pos]);
253 (smic->write_pos)++;
254 (smic->write_count)--;
257 static inline void read_next_byte (struct si_sm_data *smic)
259 if (smic->read_pos >= MAX_SMIC_READ_SIZE) {
260 read_smic_data (smic);
261 smic->truncated = 1;
263 smic->read_data[smic->read_pos] = read_smic_data(smic);
264 (smic->read_pos)++;
339 static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
345 if (smic->state == SMIC_HOSED) {
346 init_smic_data(smic, smic->io);
349 if (smic->state != SMIC_IDLE) {
352 "smic_event - smic->smic_timeout = %ld,"
354 smic->smic_timeout, time);
357 smic->smic_timeout -= time;
358 if (smic->smic_timeout < 0) {
359 start_error_recovery(smic, "smic timed out.");
364 flags = read_smic_flags(smic);
368 status = read_smic_status (smic);
373 smic->state, flags, status);
375 switch (smic->state) {
385 /* sanity check whether smic is really idle */
386 write_smic_control(smic, SMIC_CC_SMS_GET_STATUS);
387 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
388 smic->state = SMIC_OP_OK;
394 start_error_recovery(smic,
399 /* OK so far; smic is idle let us start ... */
400 write_smic_control(smic, SMIC_CC_SMS_WR_START);
401 write_next_byte(smic);
402 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
403 smic->state = SMIC_WRITE_START;
408 start_error_recovery(smic,
416 if (smic->write_count == 1) {
418 write_smic_control(smic, SMIC_CC_SMS_WR_END);
419 smic->state = SMIC_WRITE_END;
421 write_smic_control(smic, SMIC_CC_SMS_WR_NEXT);
422 smic->state = SMIC_WRITE_NEXT;
424 write_next_byte(smic);
425 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
434 start_error_recovery(smic,
441 if (smic->write_count == 1) {
442 write_smic_control(smic, SMIC_CC_SMS_WR_END);
443 smic->state = SMIC_WRITE_END;
446 write_smic_control(smic, SMIC_CC_SMS_WR_NEXT);
447 smic->state = SMIC_WRITE_NEXT;
449 write_next_byte(smic);
450 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
459 start_error_recovery (smic,
465 data = read_smic_data(smic);
471 start_error_recovery(smic,
476 smic->state = SMIC_WRITE2READ;
484 write_smic_control(smic, SMIC_CC_SMS_RD_START);
485 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
486 smic->state = SMIC_READ_START;
494 start_error_recovery(smic,
500 read_next_byte(smic);
501 write_smic_control(smic, SMIC_CC_SMS_RD_NEXT);
502 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
503 smic->state = SMIC_READ_NEXT;
511 /* smic tells us that this is the last byte to be read
514 read_next_byte(smic);
515 write_smic_control(smic, SMIC_CC_SMS_RD_END);
516 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
517 smic->state = SMIC_READ_END;
521 read_next_byte(smic);
522 write_smic_control(smic, SMIC_CC_SMS_RD_NEXT);
523 write_smic_flags(smic, flags | SMIC_FLAG_BSY);
524 smic->state = SMIC_READ_NEXT;
531 smic,
540 start_error_recovery(smic,
545 data = read_smic_data(smic);
552 start_error_recovery(smic,
557 smic->state = SMIC_IDLE;
562 init_smic_data(smic, smic->io);
567 printk(KERN_WARNING "smic->state = %d\n", smic->state);
568 start_error_recovery(smic, "state = UNKNOWN");
572 smic->smic_timeout = SMIC_RETRY_TIMEOUT;
576 static int smic_detect(struct si_sm_data *smic)
582 if (read_smic_flags(smic) == 0xff)