Lines Matching refs:can
257 struct can_priv can; member
273 struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS]; member
488 static void kvaser_pciefd_request_status(struct kvaser_pciefd_can *can) in kvaser_pciefd_request_status() argument
493 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_request_status()
494 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_request_status()
497 static void kvaser_pciefd_enable_err_gen(struct kvaser_pciefd_can *can) in kvaser_pciefd_enable_err_gen() argument
502 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_enable_err_gen()
503 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_enable_err_gen()
506 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_enable_err_gen()
508 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_enable_err_gen()
511 static void kvaser_pciefd_disable_err_gen(struct kvaser_pciefd_can *can) in kvaser_pciefd_disable_err_gen() argument
516 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_disable_err_gen()
517 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_disable_err_gen()
519 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_disable_err_gen()
520 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_disable_err_gen()
523 static int kvaser_pciefd_set_tx_irq(struct kvaser_pciefd_can *can) in kvaser_pciefd_set_tx_irq() argument
533 iowrite32(msk, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_set_tx_irq()
538 static void kvaser_pciefd_setup_controller(struct kvaser_pciefd_can *can) in kvaser_pciefd_setup_controller() argument
543 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_setup_controller()
545 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_setup_controller()
546 if (can->can.ctrlmode & CAN_CTRLMODE_FD) { in kvaser_pciefd_setup_controller()
548 if (can->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) in kvaser_pciefd_setup_controller()
557 if (can->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) in kvaser_pciefd_setup_controller()
565 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_setup_controller()
567 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_setup_controller()
570 static void kvaser_pciefd_start_controller_flush(struct kvaser_pciefd_can *can) in kvaser_pciefd_start_controller_flush() argument
575 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_start_controller_flush()
576 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_start_controller_flush()
578 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_start_controller_flush()
580 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_start_controller_flush()
586 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_start_controller_flush()
587 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_start_controller_flush()
592 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_start_controller_flush()
594 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_start_controller_flush()
597 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_start_controller_flush()
600 static int kvaser_pciefd_bus_on(struct kvaser_pciefd_can *can) in kvaser_pciefd_bus_on() argument
605 del_timer(&can->bec_poll_timer); in kvaser_pciefd_bus_on()
607 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_bus_on()
608 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_bus_on()
610 if (!wait_for_completion_timeout(&can->flush_comp, in kvaser_pciefd_bus_on()
612 netdev_err(can->can.dev, "Timeout during bus on flush\n"); in kvaser_pciefd_bus_on()
616 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_bus_on()
617 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
618 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_bus_on()
621 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
623 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_bus_on()
625 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_bus_on()
626 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_bus_on()
628 if (!wait_for_completion_timeout(&can->start_comp, in kvaser_pciefd_bus_on()
630 netdev_err(can->can.dev, "Timeout during bus on reset\n"); in kvaser_pciefd_bus_on()
634 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
635 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_bus_on()
637 kvaser_pciefd_set_tx_irq(can); in kvaser_pciefd_bus_on()
638 kvaser_pciefd_setup_controller(can); in kvaser_pciefd_bus_on()
640 can->can.state = CAN_STATE_ERROR_ACTIVE; in kvaser_pciefd_bus_on()
641 netif_wake_queue(can->can.dev); in kvaser_pciefd_bus_on()
642 can->bec.txerr = 0; in kvaser_pciefd_bus_on()
643 can->bec.rxerr = 0; in kvaser_pciefd_bus_on()
644 can->err_rep_cnt = 0; in kvaser_pciefd_bus_on()
649 static void kvaser_pciefd_pwm_stop(struct kvaser_pciefd_can *can) in kvaser_pciefd_pwm_stop() argument
655 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_pwm_stop()
656 pwm_ctrl = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_stop()
661 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_stop()
662 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_pwm_stop()
665 static void kvaser_pciefd_pwm_start(struct kvaser_pciefd_can *can) in kvaser_pciefd_pwm_start() argument
671 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_pwm_start()
672 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_pwm_start()
675 top = can->kv_pcie->bus_freq / (2 * 500000) - 1; in kvaser_pciefd_pwm_start()
679 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_start()
685 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_start()
686 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_pwm_start()
692 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_open() local
698 err = kvaser_pciefd_bus_on(can); in kvaser_pciefd_open()
709 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_stop() local
713 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_stop()
714 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_stop()
716 if (!wait_for_completion_timeout(&can->flush_comp, in kvaser_pciefd_stop()
718 netdev_err(can->can.dev, "Timeout during stop\n"); in kvaser_pciefd_stop()
721 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_stop()
722 del_timer(&can->bec_poll_timer); in kvaser_pciefd_stop()
730 struct kvaser_pciefd_can *can, in kvaser_pciefd_prepare_tx_packet() argument
735 int seq = can->echo_idx; in kvaser_pciefd_prepare_tx_packet()
739 if (can->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) in kvaser_pciefd_prepare_tx_packet()
771 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_start_xmit() local
780 nwords = kvaser_pciefd_prepare_tx_packet(&packet, can, skb); in kvaser_pciefd_start_xmit()
782 spin_lock_irqsave(&can->echo_lock, irq_flags); in kvaser_pciefd_start_xmit()
785 can_put_echo_skb(skb, netdev, can->echo_idx, 0); in kvaser_pciefd_start_xmit()
788 can->echo_idx = (can->echo_idx + 1) % can->can.echo_skb_max; in kvaser_pciefd_start_xmit()
792 can->reg_base + KVASER_PCIEFD_KCAN_FIFO_REG); in kvaser_pciefd_start_xmit()
794 can->reg_base + KVASER_PCIEFD_KCAN_FIFO_REG); in kvaser_pciefd_start_xmit()
800 iowrite32_rep(can->reg_base + in kvaser_pciefd_start_xmit()
804 __raw_writel(data_last, can->reg_base + in kvaser_pciefd_start_xmit()
808 __raw_writel(0, can->reg_base + in kvaser_pciefd_start_xmit()
812 count = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NPACKETS_REG); in kvaser_pciefd_start_xmit()
817 can->can.echo_skb[can->echo_idx]) in kvaser_pciefd_start_xmit()
820 spin_unlock_irqrestore(&can->echo_lock, irq_flags); in kvaser_pciefd_start_xmit()
825 static int kvaser_pciefd_set_bittiming(struct kvaser_pciefd_can *can, bool data) in kvaser_pciefd_set_bittiming() argument
833 bt = &can->can.data_bittiming; in kvaser_pciefd_set_bittiming()
835 bt = &can->can.bittiming; in kvaser_pciefd_set_bittiming()
844 spin_lock_irqsave(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
845 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
849 can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
852 ret = readl_poll_timeout(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG, in kvaser_pciefd_set_bittiming()
857 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
862 iowrite32(btrn, can->reg_base + KVASER_PCIEFD_KCAN_BTRD_REG); in kvaser_pciefd_set_bittiming()
864 iowrite32(btrn, can->reg_base + KVASER_PCIEFD_KCAN_BTRN_REG); in kvaser_pciefd_set_bittiming()
867 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
869 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
885 struct kvaser_pciefd_can *can = netdev_priv(ndev); in kvaser_pciefd_set_mode() local
890 if (!can->can.restart_ms) in kvaser_pciefd_set_mode()
891 ret = kvaser_pciefd_bus_on(can); in kvaser_pciefd_set_mode()
903 struct kvaser_pciefd_can *can = netdev_priv(ndev); in kvaser_pciefd_get_berr_counter() local
905 bec->rxerr = can->bec.rxerr; in kvaser_pciefd_get_berr_counter()
906 bec->txerr = can->bec.txerr; in kvaser_pciefd_get_berr_counter()
912 struct kvaser_pciefd_can *can = from_timer(can, data, bec_poll_timer); in kvaser_pciefd_bec_poll_timer() local
914 kvaser_pciefd_enable_err_gen(can); in kvaser_pciefd_bec_poll_timer()
915 kvaser_pciefd_request_status(can); in kvaser_pciefd_bec_poll_timer()
916 can->err_rep_cnt = 0; in kvaser_pciefd_bec_poll_timer()
932 struct kvaser_pciefd_can *can; in kvaser_pciefd_setup_can_ctrls() local
940 can = netdev_priv(netdev); in kvaser_pciefd_setup_can_ctrls()
942 can->reg_base = pcie->reg_base + KVASER_PCIEFD_KCAN0_BASE + in kvaser_pciefd_setup_can_ctrls()
945 can->kv_pcie = pcie; in kvaser_pciefd_setup_can_ctrls()
946 can->cmd_seq = 0; in kvaser_pciefd_setup_can_ctrls()
947 can->err_rep_cnt = 0; in kvaser_pciefd_setup_can_ctrls()
948 can->bec.txerr = 0; in kvaser_pciefd_setup_can_ctrls()
949 can->bec.rxerr = 0; in kvaser_pciefd_setup_can_ctrls()
951 init_completion(&can->start_comp); in kvaser_pciefd_setup_can_ctrls()
952 init_completion(&can->flush_comp); in kvaser_pciefd_setup_can_ctrls()
953 timer_setup(&can->bec_poll_timer, kvaser_pciefd_bec_poll_timer, in kvaser_pciefd_setup_can_ctrls()
957 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_BUS_LOAD_REG); in kvaser_pciefd_setup_can_ctrls()
959 tx_npackets = ioread32(can->reg_base + in kvaser_pciefd_setup_can_ctrls()
970 can->can.clock.freq = pcie->freq; in kvaser_pciefd_setup_can_ctrls()
971 can->can.echo_skb_max = KVASER_PCIEFD_CAN_TX_MAX_COUNT; in kvaser_pciefd_setup_can_ctrls()
972 can->echo_idx = 0; in kvaser_pciefd_setup_can_ctrls()
973 spin_lock_init(&can->echo_lock); in kvaser_pciefd_setup_can_ctrls()
974 spin_lock_init(&can->lock); in kvaser_pciefd_setup_can_ctrls()
975 can->can.bittiming_const = &kvaser_pciefd_bittiming_const; in kvaser_pciefd_setup_can_ctrls()
976 can->can.data_bittiming_const = &kvaser_pciefd_bittiming_const; in kvaser_pciefd_setup_can_ctrls()
978 can->can.do_set_bittiming = kvaser_pciefd_set_nominal_bittiming; in kvaser_pciefd_setup_can_ctrls()
979 can->can.do_set_data_bittiming = in kvaser_pciefd_setup_can_ctrls()
982 can->can.do_set_mode = kvaser_pciefd_set_mode; in kvaser_pciefd_setup_can_ctrls()
983 can->can.do_get_berr_counter = kvaser_pciefd_get_berr_counter; in kvaser_pciefd_setup_can_ctrls()
985 can->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY | in kvaser_pciefd_setup_can_ctrls()
989 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_setup_can_ctrls()
999 can->can.ctrlmode_supported |= CAN_CTRLMODE_ONE_SHOT; in kvaser_pciefd_setup_can_ctrls()
1005 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_setup_can_ctrls()
1008 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_setup_can_ctrls()
1010 pcie->can[i] = can; in kvaser_pciefd_setup_can_ctrls()
1011 kvaser_pciefd_pwm_start(can); in kvaser_pciefd_setup_can_ctrls()
1022 int err = register_candev(pcie->can[i]->can.dev); in kvaser_pciefd_reg_candev()
1029 unregister_candev(pcie->can[j]->can.dev); in kvaser_pciefd_reg_candev()
1159 priv = &pcie->can[ch_id]->can; in kvaser_pciefd_handle_data_packet()
1205 static void kvaser_pciefd_change_state(struct kvaser_pciefd_can *can, in kvaser_pciefd_change_state() argument
1211 can_change_state(can->can.dev, cf, tx_state, rx_state); in kvaser_pciefd_change_state()
1214 struct net_device *ndev = can->can.dev; in kvaser_pciefd_change_state()
1217 spin_lock_irqsave(&can->lock, irq_flags); in kvaser_pciefd_change_state()
1218 netif_stop_queue(can->can.dev); in kvaser_pciefd_change_state()
1219 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_change_state()
1222 if (!can->can.restart_ms) { in kvaser_pciefd_change_state()
1223 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_change_state()
1255 static int kvaser_pciefd_rx_error_frame(struct kvaser_pciefd_can *can, in kvaser_pciefd_rx_error_frame() argument
1260 struct net_device *ndev = can->can.dev; in kvaser_pciefd_rx_error_frame()
1266 old_state = can->can.state; in kvaser_pciefd_rx_error_frame()
1277 kvaser_pciefd_change_state(can, cf, new_state, tx_state, in kvaser_pciefd_rx_error_frame()
1282 can->can.restart_ms) { in kvaser_pciefd_rx_error_frame()
1283 can->can.can_stats.restarts++; in kvaser_pciefd_rx_error_frame()
1289 can->err_rep_cnt++; in kvaser_pciefd_rx_error_frame()
1290 can->can.can_stats.bus_error++; in kvaser_pciefd_rx_error_frame()
1296 can->bec.txerr = bec.txerr; in kvaser_pciefd_rx_error_frame()
1297 can->bec.rxerr = bec.rxerr; in kvaser_pciefd_rx_error_frame()
1307 can->kv_pcie->freq_to_ticks_div)); in kvaser_pciefd_rx_error_frame()
1323 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_error_packet() local
1329 can = pcie->can[ch_id]; in kvaser_pciefd_handle_error_packet()
1331 kvaser_pciefd_rx_error_frame(can, p); in kvaser_pciefd_handle_error_packet()
1332 if (can->err_rep_cnt >= KVASER_PCIEFD_MAX_ERR_REP) in kvaser_pciefd_handle_error_packet()
1334 kvaser_pciefd_disable_err_gen(can); in kvaser_pciefd_handle_error_packet()
1336 mod_timer(&can->bec_poll_timer, KVASER_PCIEFD_BEC_POLL_FREQ); in kvaser_pciefd_handle_error_packet()
1340 static int kvaser_pciefd_handle_status_resp(struct kvaser_pciefd_can *can, in kvaser_pciefd_handle_status_resp() argument
1346 old_state = can->can.state; in kvaser_pciefd_handle_status_resp()
1355 struct net_device *ndev = can->can.dev; in kvaser_pciefd_handle_status_resp()
1368 kvaser_pciefd_change_state(can, cf, new_state, tx_state, in kvaser_pciefd_handle_status_resp()
1373 can->can.restart_ms) { in kvaser_pciefd_handle_status_resp()
1374 can->can.can_stats.restarts++; in kvaser_pciefd_handle_status_resp()
1381 can->kv_pcie->freq_to_ticks_div)); in kvaser_pciefd_handle_status_resp()
1388 can->bec.txerr = bec.txerr; in kvaser_pciefd_handle_status_resp()
1389 can->bec.rxerr = bec.rxerr; in kvaser_pciefd_handle_status_resp()
1392 mod_timer(&can->bec_poll_timer, KVASER_PCIEFD_BEC_POLL_FREQ); in kvaser_pciefd_handle_status_resp()
1400 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_status_packet() local
1408 can = pcie->can[ch_id]; in kvaser_pciefd_handle_status_packet()
1410 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_handle_status_packet()
1422 can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_handle_status_packet()
1424 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_handle_status_packet()
1425 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_handle_status_packet()
1428 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_handle_status_packet()
1434 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_status_packet()
1439 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_handle_status_packet()
1443 kvaser_pciefd_handle_status_resp(can, p); in kvaser_pciefd_handle_status_packet()
1444 if (can->can.state != CAN_STATE_BUS_OFF && in kvaser_pciefd_handle_status_packet()
1445 can->can.state != CAN_STATE_ERROR_ACTIVE) { in kvaser_pciefd_handle_status_packet()
1446 mod_timer(&can->bec_poll_timer, in kvaser_pciefd_handle_status_packet()
1452 if (!completion_done(&can->start_comp)) in kvaser_pciefd_handle_status_packet()
1453 complete(&can->start_comp); in kvaser_pciefd_handle_status_packet()
1462 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_eack_packet() local
1468 can = pcie->can[ch_id]; in kvaser_pciefd_handle_eack_packet()
1472 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_eack_packet()
1477 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_handle_eack_packet()
1480 int dlc = can_get_echo_skb(can->can.dev, echo_idx, NULL); in kvaser_pciefd_handle_eack_packet()
1481 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_eack_packet()
1486 if (netif_queue_stopped(can->can.dev)) in kvaser_pciefd_handle_eack_packet()
1487 netif_wake_queue(can->can.dev); in kvaser_pciefd_handle_eack_packet()
1493 static void kvaser_pciefd_handle_nack_packet(struct kvaser_pciefd_can *can, in kvaser_pciefd_handle_nack_packet() argument
1497 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_nack_packet()
1500 skb = alloc_can_err_skb(can->can.dev, &cf); in kvaser_pciefd_handle_nack_packet()
1506 can->can.can_stats.arbitration_lost++; in kvaser_pciefd_handle_nack_packet()
1518 netdev_warn(can->can.dev, "No memory left for err_skb\n"); in kvaser_pciefd_handle_nack_packet()
1525 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_ack_packet() local
1532 can = pcie->can[ch_id]; in kvaser_pciefd_handle_ack_packet()
1538 kvaser_pciefd_handle_nack_packet(can, p); in kvaser_pciefd_handle_ack_packet()
1543 netdev_dbg(can->can.dev, "Packet was flushed\n"); in kvaser_pciefd_handle_ack_packet()
1546 int dlc = can_get_echo_skb(can->can.dev, echo_idx, NULL); in kvaser_pciefd_handle_ack_packet()
1547 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_ack_packet()
1551 netif_queue_stopped(can->can.dev)) in kvaser_pciefd_handle_ack_packet()
1552 netif_wake_queue(can->can.dev); in kvaser_pciefd_handle_ack_packet()
1555 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_ack_packet()
1568 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_eflush_packet() local
1574 can = pcie->can[ch_id]; in kvaser_pciefd_handle_eflush_packet()
1576 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_handle_eflush_packet()
1577 complete(&can->flush_comp); in kvaser_pciefd_handle_eflush_packet()
1710 static int kvaser_pciefd_transmit_irq(struct kvaser_pciefd_can *can) in kvaser_pciefd_transmit_irq() argument
1712 u32 irq = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_transmit_irq()
1715 netdev_err(can->can.dev, "Tx FIFO overflow\n"); in kvaser_pciefd_transmit_irq()
1718 u8 count = ioread32(can->reg_base + in kvaser_pciefd_transmit_irq()
1723 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_transmit_irq()
1727 netdev_err(can->can.dev, in kvaser_pciefd_transmit_irq()
1731 netdev_err(can->can.dev, "CAN FD frame in CAN mode\n"); in kvaser_pciefd_transmit_irq()
1734 netdev_err(can->can.dev, "Rx FIFO overflow\n"); in kvaser_pciefd_transmit_irq()
1736 iowrite32(irq, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_transmit_irq()
1755 if (!pcie->can[i]) { in kvaser_pciefd_irq_handler()
1763 kvaser_pciefd_transmit_irq(pcie->can[i]); in kvaser_pciefd_irq_handler()
1773 struct kvaser_pciefd_can *can; in kvaser_pciefd_teardown_can_ctrls() local
1776 can = pcie->can[i]; in kvaser_pciefd_teardown_can_ctrls()
1777 if (can) { in kvaser_pciefd_teardown_can_ctrls()
1779 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_teardown_can_ctrls()
1780 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_teardown_can_ctrls()
1781 free_candev(can->can.dev); in kvaser_pciefd_teardown_can_ctrls()
1880 struct kvaser_pciefd_can *can; in kvaser_pciefd_remove_all_ctrls() local
1884 can = pcie->can[i]; in kvaser_pciefd_remove_all_ctrls()
1885 if (can) { in kvaser_pciefd_remove_all_ctrls()
1887 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_remove_all_ctrls()
1888 unregister_candev(can->can.dev); in kvaser_pciefd_remove_all_ctrls()
1889 del_timer(&can->bec_poll_timer); in kvaser_pciefd_remove_all_ctrls()
1890 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_remove_all_ctrls()
1891 free_candev(can->can.dev); in kvaser_pciefd_remove_all_ctrls()