• Home
  • Raw
  • Download

Lines Matching refs:card

32 typedef void (*creg_cmd_cb)(struct rsxx_cardinfo *card,
61 static int copy_to_creg_data(struct rsxx_cardinfo *card, in copy_to_creg_data() argument
69 if (unlikely(card->eeh_state)) in copy_to_creg_data()
78 iowrite32be(data[i], card->regmap + CREG_DATA(i)); in copy_to_creg_data()
80 iowrite32(data[i], card->regmap + CREG_DATA(i)); in copy_to_creg_data()
87 static int copy_from_creg_data(struct rsxx_cardinfo *card, in copy_from_creg_data() argument
95 if (unlikely(card->eeh_state)) in copy_from_creg_data()
104 data[i] = ioread32be(card->regmap + CREG_DATA(i)); in copy_from_creg_data()
106 data[i] = ioread32(card->regmap + CREG_DATA(i)); in copy_from_creg_data()
112 static void creg_issue_cmd(struct rsxx_cardinfo *card, struct creg_cmd *cmd) in creg_issue_cmd() argument
116 if (unlikely(card->eeh_state)) in creg_issue_cmd()
119 iowrite32(cmd->addr, card->regmap + CREG_ADD); in creg_issue_cmd()
120 iowrite32(cmd->cnt8, card->regmap + CREG_CNT); in creg_issue_cmd()
124 st = copy_to_creg_data(card, cmd->cnt8, in creg_issue_cmd()
131 if (unlikely(card->eeh_state)) in creg_issue_cmd()
135 iowrite32(cmd->op, card->regmap + CREG_CMD); in creg_issue_cmd()
138 static void creg_kick_queue(struct rsxx_cardinfo *card) in creg_kick_queue() argument
140 if (card->creg_ctrl.active || list_empty(&card->creg_ctrl.queue)) in creg_kick_queue()
143 card->creg_ctrl.active = 1; in creg_kick_queue()
144 card->creg_ctrl.active_cmd = list_first_entry(&card->creg_ctrl.queue, in creg_kick_queue()
146 list_del(&card->creg_ctrl.active_cmd->list); in creg_kick_queue()
147 card->creg_ctrl.q_depth--; in creg_kick_queue()
155 mod_timer(&card->creg_ctrl.cmd_timer, in creg_kick_queue()
158 creg_issue_cmd(card, card->creg_ctrl.active_cmd); in creg_kick_queue()
161 static int creg_queue_cmd(struct rsxx_cardinfo *card, in creg_queue_cmd() argument
173 if (unlikely(card->halt)) in creg_queue_cmd()
176 if (card->creg_ctrl.reset) in creg_queue_cmd()
197 spin_lock_bh(&card->creg_ctrl.lock); in creg_queue_cmd()
198 list_add_tail(&cmd->list, &card->creg_ctrl.queue); in creg_queue_cmd()
199 card->creg_ctrl.q_depth++; in creg_queue_cmd()
200 creg_kick_queue(card); in creg_queue_cmd()
201 spin_unlock_bh(&card->creg_ctrl.lock); in creg_queue_cmd()
208 struct rsxx_cardinfo *card = (struct rsxx_cardinfo *) data; in creg_cmd_timed_out() local
211 spin_lock(&card->creg_ctrl.lock); in creg_cmd_timed_out()
212 cmd = card->creg_ctrl.active_cmd; in creg_cmd_timed_out()
213 card->creg_ctrl.active_cmd = NULL; in creg_cmd_timed_out()
214 spin_unlock(&card->creg_ctrl.lock); in creg_cmd_timed_out()
217 card->creg_ctrl.creg_stats.creg_timeout++; in creg_cmd_timed_out()
218 dev_warn(CARD_TO_DEV(card), in creg_cmd_timed_out()
224 cmd->cb(card, cmd, -ETIMEDOUT); in creg_cmd_timed_out()
229 spin_lock(&card->creg_ctrl.lock); in creg_cmd_timed_out()
230 card->creg_ctrl.active = 0; in creg_cmd_timed_out()
231 creg_kick_queue(card); in creg_cmd_timed_out()
232 spin_unlock(&card->creg_ctrl.lock); in creg_cmd_timed_out()
238 struct rsxx_cardinfo *card; in creg_cmd_done() local
242 card = container_of(work, struct rsxx_cardinfo, in creg_cmd_done()
249 if (del_timer_sync(&card->creg_ctrl.cmd_timer) == 0) in creg_cmd_done()
250 card->creg_ctrl.creg_stats.failed_cancel_timer++; in creg_cmd_done()
252 spin_lock_bh(&card->creg_ctrl.lock); in creg_cmd_done()
253 cmd = card->creg_ctrl.active_cmd; in creg_cmd_done()
254 card->creg_ctrl.active_cmd = NULL; in creg_cmd_done()
255 spin_unlock_bh(&card->creg_ctrl.lock); in creg_cmd_done()
258 dev_err(CARD_TO_DEV(card), in creg_cmd_done()
263 card->creg_ctrl.creg_stats.stat = ioread32(card->regmap + CREG_STAT); in creg_cmd_done()
264 cmd->status = card->creg_ctrl.creg_stats.stat; in creg_cmd_done()
266 dev_err(CARD_TO_DEV(card), in creg_cmd_done()
280 unsigned int cnt8 = ioread32(card->regmap + CREG_CNT); in creg_cmd_done()
284 dev_err(CARD_TO_DEV(card), in creg_cmd_done()
290 dev_err(CARD_TO_DEV(card), in creg_cmd_done()
296 st = copy_from_creg_data(card, cnt8, cmd->buf, cmd->stream); in creg_cmd_done()
301 cmd->cb(card, cmd, st); in creg_cmd_done()
305 spin_lock_bh(&card->creg_ctrl.lock); in creg_cmd_done()
306 card->creg_ctrl.active = 0; in creg_cmd_done()
307 creg_kick_queue(card); in creg_cmd_done()
308 spin_unlock_bh(&card->creg_ctrl.lock); in creg_cmd_done()
311 static void creg_reset(struct rsxx_cardinfo *card) in creg_reset() argument
321 if (!mutex_trylock(&card->creg_ctrl.reset_lock)) in creg_reset()
324 card->creg_ctrl.reset = 1; in creg_reset()
325 spin_lock_irqsave(&card->irq_lock, flags); in creg_reset()
326 rsxx_disable_ier_and_isr(card, CR_INTR_CREG | CR_INTR_EVENT); in creg_reset()
327 spin_unlock_irqrestore(&card->irq_lock, flags); in creg_reset()
329 dev_warn(CARD_TO_DEV(card), in creg_reset()
333 spin_lock_bh(&card->creg_ctrl.lock); in creg_reset()
334 list_for_each_entry_safe(cmd, tmp, &card->creg_ctrl.queue, list) { in creg_reset()
336 card->creg_ctrl.q_depth--; in creg_reset()
338 cmd->cb(card, cmd, -ECANCELED); in creg_reset()
342 cmd = card->creg_ctrl.active_cmd; in creg_reset()
343 card->creg_ctrl.active_cmd = NULL; in creg_reset()
345 if (timer_pending(&card->creg_ctrl.cmd_timer)) in creg_reset()
346 del_timer_sync(&card->creg_ctrl.cmd_timer); in creg_reset()
349 cmd->cb(card, cmd, -ECANCELED); in creg_reset()
352 card->creg_ctrl.active = 0; in creg_reset()
354 spin_unlock_bh(&card->creg_ctrl.lock); in creg_reset()
356 card->creg_ctrl.reset = 0; in creg_reset()
357 spin_lock_irqsave(&card->irq_lock, flags); in creg_reset()
358 rsxx_enable_ier_and_isr(card, CR_INTR_CREG | CR_INTR_EVENT); in creg_reset()
359 spin_unlock_irqrestore(&card->irq_lock, flags); in creg_reset()
361 mutex_unlock(&card->creg_ctrl.reset_lock); in creg_reset()
371 static void creg_cmd_done_cb(struct rsxx_cardinfo *card, in creg_cmd_done_cb() argument
385 static int __issue_creg_rw(struct rsxx_cardinfo *card, in __issue_creg_rw() argument
402 st = creg_queue_cmd(card, op, addr, cnt8, buf, stream, creg_cmd_done_cb, in __issue_creg_rw()
413 card->creg_ctrl.q_depth + 20000); in __issue_creg_rw()
425 dev_crit(CARD_TO_DEV(card), in __issue_creg_rw()
427 creg_reset(card); in __issue_creg_rw()
441 ioread32(card->regmap + SCRATCH); in __issue_creg_rw()
443 dev_warn(CARD_TO_DEV(card), in __issue_creg_rw()
452 static int issue_creg_rw(struct rsxx_cardinfo *card, in issue_creg_rw() argument
469 st = __issue_creg_rw(card, op, addr, xfer, in issue_creg_rw()
483 int rsxx_creg_write(struct rsxx_cardinfo *card, in rsxx_creg_write() argument
489 return issue_creg_rw(card, addr, size8, data, byte_stream, 0); in rsxx_creg_write()
492 int rsxx_creg_read(struct rsxx_cardinfo *card, in rsxx_creg_read() argument
498 return issue_creg_rw(card, addr, size8, data, byte_stream, 1); in rsxx_creg_read()
501 int rsxx_get_card_state(struct rsxx_cardinfo *card, unsigned int *state) in rsxx_get_card_state() argument
503 return rsxx_creg_read(card, CREG_ADD_CARD_STATE, in rsxx_get_card_state()
507 int rsxx_get_card_size8(struct rsxx_cardinfo *card, u64 *size8) in rsxx_get_card_size8() argument
512 st = rsxx_creg_read(card, CREG_ADD_CARD_SIZE, in rsxx_get_card_size8()
521 int rsxx_get_num_targets(struct rsxx_cardinfo *card, in rsxx_get_num_targets() argument
524 return rsxx_creg_read(card, CREG_ADD_NUM_TARGETS, in rsxx_get_num_targets()
528 int rsxx_get_card_capabilities(struct rsxx_cardinfo *card, in rsxx_get_card_capabilities() argument
531 return rsxx_creg_read(card, CREG_ADD_CAPABILITIES, in rsxx_get_card_capabilities()
535 int rsxx_issue_card_cmd(struct rsxx_cardinfo *card, u32 cmd) in rsxx_issue_card_cmd() argument
537 return rsxx_creg_write(card, CREG_ADD_CARD_CMD, in rsxx_issue_card_cmd()
543 static void hw_log_msg(struct rsxx_cardinfo *card, const char *str, int len) in hw_log_msg() argument
559 dev_emerg(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
562 dev_alert(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
565 dev_crit(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
568 dev_err(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
571 dev_warn(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
574 dev_notice(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
577 dev_info(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
580 dev_dbg(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
583 dev_info(CARD_TO_DEV(card), "HW: %.*s", len, str); in hw_log_msg()
609 static void read_hw_log_done(struct rsxx_cardinfo *card, in read_hw_log_done() argument
627 log_str = &card->log.buf[card->log.buf_len]; in read_hw_log_done()
628 cnt = min(cmd->cnt8 - off, LOG_BUF_SIZE8 - card->log.buf_len); in read_hw_log_done()
632 card->log.buf_len += len; in read_hw_log_done()
639 (card->log.buf_len == LOG_BUF_SIZE8)) { in read_hw_log_done()
640 if (card->log.buf_len != 1) /* Don't log blank lines. */ in read_hw_log_done()
641 hw_log_msg(card, card->log.buf, in read_hw_log_done()
642 card->log.buf_len); in read_hw_log_done()
643 card->log.buf_len = 0; in read_hw_log_done()
649 rsxx_read_hw_log(card); in read_hw_log_done()
652 int rsxx_read_hw_log(struct rsxx_cardinfo *card) in rsxx_read_hw_log() argument
656 st = creg_queue_cmd(card, CREG_OP_READ, CREG_ADD_LOG, in rsxx_read_hw_log()
657 sizeof(card->log.tmp), card->log.tmp, in rsxx_read_hw_log()
660 dev_err(CARD_TO_DEV(card), in rsxx_read_hw_log()
667 static int issue_reg_cmd(struct rsxx_cardinfo *card, in issue_reg_cmd() argument
673 return __issue_creg_rw(card, op, cmd->addr, cmd->cnt, cmd->data, in issue_reg_cmd()
677 int rsxx_reg_access(struct rsxx_cardinfo *card, in rsxx_reg_access() argument
691 st = issue_reg_cmd(card, &cmd, read); in rsxx_reg_access()
708 void rsxx_eeh_save_issued_creg(struct rsxx_cardinfo *card) in rsxx_eeh_save_issued_creg() argument
712 cmd = card->creg_ctrl.active_cmd; in rsxx_eeh_save_issued_creg()
713 card->creg_ctrl.active_cmd = NULL; in rsxx_eeh_save_issued_creg()
716 del_timer_sync(&card->creg_ctrl.cmd_timer); in rsxx_eeh_save_issued_creg()
718 spin_lock_bh(&card->creg_ctrl.lock); in rsxx_eeh_save_issued_creg()
719 list_add(&cmd->list, &card->creg_ctrl.queue); in rsxx_eeh_save_issued_creg()
720 card->creg_ctrl.q_depth++; in rsxx_eeh_save_issued_creg()
721 card->creg_ctrl.active = 0; in rsxx_eeh_save_issued_creg()
722 spin_unlock_bh(&card->creg_ctrl.lock); in rsxx_eeh_save_issued_creg()
726 void rsxx_kick_creg_queue(struct rsxx_cardinfo *card) in rsxx_kick_creg_queue() argument
728 spin_lock_bh(&card->creg_ctrl.lock); in rsxx_kick_creg_queue()
729 if (!list_empty(&card->creg_ctrl.queue)) in rsxx_kick_creg_queue()
730 creg_kick_queue(card); in rsxx_kick_creg_queue()
731 spin_unlock_bh(&card->creg_ctrl.lock); in rsxx_kick_creg_queue()
735 int rsxx_creg_setup(struct rsxx_cardinfo *card) in rsxx_creg_setup() argument
737 card->creg_ctrl.active_cmd = NULL; in rsxx_creg_setup()
739 card->creg_ctrl.creg_wq = in rsxx_creg_setup()
741 if (!card->creg_ctrl.creg_wq) in rsxx_creg_setup()
744 INIT_WORK(&card->creg_ctrl.done_work, creg_cmd_done); in rsxx_creg_setup()
745 mutex_init(&card->creg_ctrl.reset_lock); in rsxx_creg_setup()
746 INIT_LIST_HEAD(&card->creg_ctrl.queue); in rsxx_creg_setup()
747 spin_lock_init(&card->creg_ctrl.lock); in rsxx_creg_setup()
748 setup_timer(&card->creg_ctrl.cmd_timer, creg_cmd_timed_out, in rsxx_creg_setup()
749 (unsigned long) card); in rsxx_creg_setup()
754 void rsxx_creg_destroy(struct rsxx_cardinfo *card) in rsxx_creg_destroy() argument
761 spin_lock_bh(&card->creg_ctrl.lock); in rsxx_creg_destroy()
762 list_for_each_entry_safe(cmd, tmp, &card->creg_ctrl.queue, list) { in rsxx_creg_destroy()
765 cmd->cb(card, cmd, -ECANCELED); in rsxx_creg_destroy()
771 dev_info(CARD_TO_DEV(card), in rsxx_creg_destroy()
774 cmd = card->creg_ctrl.active_cmd; in rsxx_creg_destroy()
775 card->creg_ctrl.active_cmd = NULL; in rsxx_creg_destroy()
777 if (timer_pending(&card->creg_ctrl.cmd_timer)) in rsxx_creg_destroy()
778 del_timer_sync(&card->creg_ctrl.cmd_timer); in rsxx_creg_destroy()
781 cmd->cb(card, cmd, -ECANCELED); in rsxx_creg_destroy()
782 dev_info(CARD_TO_DEV(card), in rsxx_creg_destroy()
786 spin_unlock_bh(&card->creg_ctrl.lock); in rsxx_creg_destroy()
788 cancel_work_sync(&card->creg_ctrl.done_work); in rsxx_creg_destroy()