• Home
  • Raw
  • Download

Lines Matching refs:bt

90 #define BT_STATE_CHANGE(X, Y) { bt->state = X; return Y; }
129 #define BT_STATUS bt->io->inputb(bt->io, 0)
130 #define BT_CONTROL(x) bt->io->outputb(bt->io, 0, x)
132 #define BMC2HOST bt->io->inputb(bt->io, 1)
133 #define HOST2BMC(x) bt->io->outputb(bt->io, 1, x)
135 #define BT_INTMASK_R bt->io->inputb(bt->io, 2)
136 #define BT_INTMASK_W(x) bt->io->outputb(bt->io, 2, x)
163 #define STATE2TXT state2txt(bt->state)
194 static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) in bt_init_data() argument
196 memset(bt, 0, sizeof(struct si_sm_data)); in bt_init_data()
197 if (bt->io != io) { in bt_init_data()
199 bt->io = io; in bt_init_data()
200 bt->seq = 0; in bt_init_data()
202 bt->state = BT_STATE_IDLE; /* start here */ in bt_init_data()
203 bt->complete = BT_STATE_IDLE; /* end here */ in bt_init_data()
204 bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * USEC_PER_SEC; in bt_init_data()
205 bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT; in bt_init_data()
212 static void force_result(struct si_sm_data *bt, unsigned char completion_code) in force_result() argument
214 bt->read_data[0] = 4; /* # following bytes */ in force_result()
215 bt->read_data[1] = bt->write_data[1] | 4; /* Odd NetFn/LUN */ in force_result()
216 bt->read_data[2] = bt->write_data[2]; /* seq (ignored) */ in force_result()
217 bt->read_data[3] = bt->write_data[3]; /* Command */ in force_result()
218 bt->read_data[4] = completion_code; in force_result()
219 bt->read_count = 5; in force_result()
224 static int bt_start_transaction(struct si_sm_data *bt, in bt_start_transaction() argument
235 if (bt->state == BT_STATE_LONG_BUSY) in bt_start_transaction()
238 if (bt->state != BT_STATE_IDLE) in bt_start_transaction()
248 bt->write_data[0] = size + 1; /* all data plus seq byte */ in bt_start_transaction()
249 bt->write_data[1] = *data; /* NetFn/LUN */ in bt_start_transaction()
250 bt->write_data[2] = bt->seq++; in bt_start_transaction()
251 memcpy(bt->write_data + 3, data + 1, size - 1); in bt_start_transaction()
252 bt->write_count = size + 2; in bt_start_transaction()
253 bt->error_retries = 0; in bt_start_transaction()
254 bt->nonzero_status = 0; in bt_start_transaction()
255 bt->truncated = 0; in bt_start_transaction()
256 bt->state = BT_STATE_XACTION_START; in bt_start_transaction()
257 bt->timeout = bt->BT_CAP_req2rsp; in bt_start_transaction()
258 force_result(bt, IPMI_ERR_UNSPECIFIED); in bt_start_transaction()
267 static int bt_get_result(struct si_sm_data *bt, in bt_get_result() argument
273 msg_len = bt->read_count - 2; /* account for length & seq */ in bt_get_result()
275 force_result(bt, IPMI_ERR_UNSPECIFIED); in bt_get_result()
278 data[0] = bt->read_data[1]; in bt_get_result()
279 data[1] = bt->read_data[3]; in bt_get_result()
280 if (length < msg_len || bt->truncated) { in bt_get_result()
284 memcpy(data + 2, bt->read_data + 4, msg_len - 2); in bt_get_result()
298 static void reset_flags(struct si_sm_data *bt) in reset_flags() argument
315 static void drain_BMC2HOST(struct si_sm_data *bt) in drain_BMC2HOST() argument
338 static inline void write_all_bytes(struct si_sm_data *bt) in write_all_bytes() argument
344 bt->write_count, bt->seq); in write_all_bytes()
345 for (i = 0; i < bt->write_count; i++) in write_all_bytes()
346 printk(" %02x", bt->write_data[i]); in write_all_bytes()
349 for (i = 0; i < bt->write_count; i++) in write_all_bytes()
350 HOST2BMC(bt->write_data[i]); in write_all_bytes()
353 static inline int read_all_bytes(struct si_sm_data *bt) in read_all_bytes() argument
362 bt->read_data[0] = BMC2HOST; in read_all_bytes()
363 bt->read_count = bt->read_data[0]; in read_all_bytes()
365 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) { in read_all_bytes()
368 bt->read_count); in read_all_bytes()
369 bt->truncated = 1; in read_all_bytes()
372 for (i = 1; i <= bt->read_count; i++) in read_all_bytes()
373 bt->read_data[i] = BMC2HOST; in read_all_bytes()
374 bt->read_count++; /* Account internally for length byte */ in read_all_bytes()
377 int max = bt->read_count; in read_all_bytes()
380 max, bt->read_data[2]); in read_all_bytes()
384 printk(KERN_CONT " %02x", bt->read_data[i]); in read_all_bytes()
385 printk(KERN_CONT "%s\n", bt->read_count == max ? "" : " ..."); in read_all_bytes()
389 if ((bt->read_data[3] == bt->write_data[3]) && in read_all_bytes()
390 (bt->read_data[2] == bt->write_data[2]) && in read_all_bytes()
391 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) in read_all_bytes()
397 bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3], in read_all_bytes()
398 bt->read_data[1], bt->read_data[2], bt->read_data[3]); in read_all_bytes()
404 static enum si_sm_result error_recovery(struct si_sm_data *bt, in error_recovery() argument
410 bt->timeout = bt->BT_CAP_req2rsp; in error_recovery()
428 (bt->error_retries)++; in error_recovery()
429 if (bt->error_retries < bt->BT_CAP_retries) { in error_recovery()
431 bt->BT_CAP_retries - bt->error_retries); in error_recovery()
432 bt->state = BT_STATE_RESTART; in error_recovery()
437 bt->BT_CAP_retries); in error_recovery()
438 if (!bt->nonzero_status) in error_recovery()
442 else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) { in error_recovery()
444 bt->state = BT_STATE_RESET1; in error_recovery()
453 bt->state = BT_STATE_IDLE; in error_recovery()
458 bt->state = BT_STATE_LONG_BUSY; in error_recovery()
464 force_result(bt, cCode); in error_recovery()
470 static enum si_sm_result bt_event(struct si_sm_data *bt, long time) in bt_event() argument
477 bt->nonzero_status |= status; in bt_event()
478 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) { in bt_event()
482 bt->timeout, in bt_event()
484 last_printed = bt->state; in bt_event()
494 if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) { in bt_event()
495 drain_BMC2HOST(bt); in bt_event()
499 if ((bt->state != BT_STATE_IDLE) && in bt_event()
500 (bt->state < BT_STATE_PRINTME)) { in bt_event()
502 bt->timeout -= time; in bt_event()
503 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) in bt_event()
504 return error_recovery(bt, in bt_event()
509 switch (bt->state) { in bt_event()
526 if (!bt->BT_CAP_outreqs) in bt_event()
529 bt->timeout = bt->BT_CAP_req2rsp; in bt_event()
544 write_all_bytes(bt); in bt_event()
586 i = read_all_bytes(bt); /* true == packet seq match */ in bt_event()
591 bt->state = bt->complete; in bt_event()
592 return bt->state == BT_STATE_IDLE ? /* where to next? */ in bt_event()
598 reset_flags(bt); /* next state is now IDLE */ in bt_event()
599 bt_init_data(bt, bt->io); in bt_event()
604 reset_flags(bt); in bt_event()
605 drain_BMC2HOST(bt); in bt_event()
616 bt->timeout = BT_RESET_DELAY * USEC_PER_SEC; in bt_event()
621 if (bt->timeout > 0) in bt_event()
623 drain_BMC2HOST(bt); in bt_event()
628 bt->read_count = 0; in bt_event()
629 bt->nonzero_status = 0; in bt_event()
630 bt->timeout = bt->BT_CAP_req2rsp; in bt_event()
639 bt->BT_CAP_outreqs = 1; in bt_event()
642 bt->state = BT_STATE_IDLE; in bt_event()
643 bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP)); in bt_event()
645 bt->complete = BT_STATE_CAPABILITIES_END; in bt_event()
650 i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP)); in bt_event()
651 bt_init_data(bt, bt->io); in bt_event()
653 bt->BT_CAP_outreqs = BT_CAP[3]; in bt_event()
654 bt->BT_CAP_req2rsp = BT_CAP[6] * USEC_PER_SEC; in bt_event()
655 bt->BT_CAP_retries = BT_CAP[7]; in bt_event()
658 if (!bt->BT_CAP_outreqs) in bt_event()
659 bt->BT_CAP_outreqs = 1; in bt_event()
661 bt->BT_CAP_req2rsp / USEC_PER_SEC, bt->BT_CAP_retries); in bt_event()
662 bt->timeout = bt->BT_CAP_req2rsp; in bt_event()
666 return error_recovery(bt, in bt_event()
673 static int bt_detect(struct si_sm_data *bt) in bt_detect() argument
684 reset_flags(bt); in bt_detect()
688 static void bt_cleanup(struct si_sm_data *bt) in bt_cleanup() argument