Lines Matching full:can
13 #include <linux/can/dev.h>
21 MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
47 /* Kvaser KCAN CAN controller registers */
178 /* Controller got CAN FD capability */
190 /* CAN FD non-ISO */
196 /* Classic CAN mode */
253 struct can_priv can; member
269 struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS]; member
484 static void kvaser_pciefd_request_status(struct kvaser_pciefd_can *can) in kvaser_pciefd_request_status() argument
489 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_request_status()
490 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_request_status()
493 static void kvaser_pciefd_enable_err_gen(struct kvaser_pciefd_can *can) in kvaser_pciefd_enable_err_gen() argument
498 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_enable_err_gen()
499 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_enable_err_gen()
502 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_enable_err_gen()
504 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_enable_err_gen()
507 static void kvaser_pciefd_disable_err_gen(struct kvaser_pciefd_can *can) in kvaser_pciefd_disable_err_gen() argument
512 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_disable_err_gen()
513 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_disable_err_gen()
515 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_disable_err_gen()
516 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_disable_err_gen()
519 static int kvaser_pciefd_set_tx_irq(struct kvaser_pciefd_can *can) in kvaser_pciefd_set_tx_irq() argument
529 iowrite32(msk, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_set_tx_irq()
534 static void kvaser_pciefd_setup_controller(struct kvaser_pciefd_can *can) in kvaser_pciefd_setup_controller() argument
539 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_setup_controller()
541 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_setup_controller()
542 if (can->can.ctrlmode & CAN_CTRLMODE_FD) { in kvaser_pciefd_setup_controller()
544 if (can->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) in kvaser_pciefd_setup_controller()
553 if (can->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) in kvaser_pciefd_setup_controller()
561 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_setup_controller()
563 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_setup_controller()
566 static void kvaser_pciefd_start_controller_flush(struct kvaser_pciefd_can *can) in kvaser_pciefd_start_controller_flush() argument
571 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_start_controller_flush()
572 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_start_controller_flush()
574 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_start_controller_flush()
576 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_start_controller_flush()
582 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_start_controller_flush()
583 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_start_controller_flush()
588 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_start_controller_flush()
590 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_start_controller_flush()
593 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_start_controller_flush()
596 static int kvaser_pciefd_bus_on(struct kvaser_pciefd_can *can) in kvaser_pciefd_bus_on() argument
601 del_timer(&can->bec_poll_timer); in kvaser_pciefd_bus_on()
603 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_bus_on()
604 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_bus_on()
606 if (!wait_for_completion_timeout(&can->flush_comp, in kvaser_pciefd_bus_on()
608 netdev_err(can->can.dev, "Timeout during bus on flush\n"); in kvaser_pciefd_bus_on()
612 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_bus_on()
613 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
614 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_bus_on()
617 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
619 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_bus_on()
621 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_bus_on()
622 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_bus_on()
624 if (!wait_for_completion_timeout(&can->start_comp, in kvaser_pciefd_bus_on()
626 netdev_err(can->can.dev, "Timeout during bus on reset\n"); in kvaser_pciefd_bus_on()
630 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_bus_on()
631 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_bus_on()
633 kvaser_pciefd_set_tx_irq(can); in kvaser_pciefd_bus_on()
634 kvaser_pciefd_setup_controller(can); in kvaser_pciefd_bus_on()
636 can->can.state = CAN_STATE_ERROR_ACTIVE; in kvaser_pciefd_bus_on()
637 netif_wake_queue(can->can.dev); in kvaser_pciefd_bus_on()
638 can->bec.txerr = 0; in kvaser_pciefd_bus_on()
639 can->bec.rxerr = 0; in kvaser_pciefd_bus_on()
640 can->err_rep_cnt = 0; in kvaser_pciefd_bus_on()
645 static void kvaser_pciefd_pwm_stop(struct kvaser_pciefd_can *can) in kvaser_pciefd_pwm_stop() argument
651 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_pwm_stop()
652 pwm_ctrl = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_stop()
657 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_stop()
658 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_pwm_stop()
661 static void kvaser_pciefd_pwm_start(struct kvaser_pciefd_can *can) in kvaser_pciefd_pwm_start() argument
667 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_pwm_start()
668 spin_lock_irqsave(&can->lock, irq); in kvaser_pciefd_pwm_start()
671 top = can->kv_pcie->bus_freq / (2 * 500000) - 1; in kvaser_pciefd_pwm_start()
675 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_start()
681 iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); in kvaser_pciefd_pwm_start()
682 spin_unlock_irqrestore(&can->lock, irq); in kvaser_pciefd_pwm_start()
688 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_open() local
694 err = kvaser_pciefd_bus_on(can); in kvaser_pciefd_open()
705 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_stop() local
709 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_stop()
710 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_stop()
712 if (!wait_for_completion_timeout(&can->flush_comp, in kvaser_pciefd_stop()
714 netdev_err(can->can.dev, "Timeout during stop\n"); in kvaser_pciefd_stop()
717 iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_stop()
718 del_timer(&can->bec_poll_timer); in kvaser_pciefd_stop()
726 struct kvaser_pciefd_can *can, in kvaser_pciefd_prepare_tx_packet() argument
731 int seq = can->echo_idx; in kvaser_pciefd_prepare_tx_packet()
735 if (can->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) in kvaser_pciefd_prepare_tx_packet()
767 struct kvaser_pciefd_can *can = netdev_priv(netdev); in kvaser_pciefd_start_xmit() local
776 nwords = kvaser_pciefd_prepare_tx_packet(&packet, can, skb); in kvaser_pciefd_start_xmit()
778 spin_lock_irqsave(&can->echo_lock, irq_flags); in kvaser_pciefd_start_xmit()
781 can_put_echo_skb(skb, netdev, can->echo_idx); in kvaser_pciefd_start_xmit()
784 can->echo_idx = (can->echo_idx + 1) % can->can.echo_skb_max; in kvaser_pciefd_start_xmit()
788 can->reg_base + KVASER_PCIEFD_KCAN_FIFO_REG); in kvaser_pciefd_start_xmit()
790 can->reg_base + KVASER_PCIEFD_KCAN_FIFO_REG); in kvaser_pciefd_start_xmit()
796 iowrite32_rep(can->reg_base + in kvaser_pciefd_start_xmit()
800 __raw_writel(data_last, can->reg_base + in kvaser_pciefd_start_xmit()
804 __raw_writel(0, can->reg_base + in kvaser_pciefd_start_xmit()
808 count = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NPACKETS_REG); in kvaser_pciefd_start_xmit()
813 can->can.echo_skb[can->echo_idx]) in kvaser_pciefd_start_xmit()
816 spin_unlock_irqrestore(&can->echo_lock, irq_flags); in kvaser_pciefd_start_xmit()
821 static int kvaser_pciefd_set_bittiming(struct kvaser_pciefd_can *can, bool data) in kvaser_pciefd_set_bittiming() argument
829 bt = &can->can.data_bittiming; in kvaser_pciefd_set_bittiming()
831 bt = &can->can.bittiming; in kvaser_pciefd_set_bittiming()
840 spin_lock_irqsave(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
841 mode = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
845 can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
847 /* Can only set bittiming if in reset mode */ in kvaser_pciefd_set_bittiming()
848 ret = readl_poll_timeout(can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG, in kvaser_pciefd_set_bittiming()
853 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
858 iowrite32(btrn, can->reg_base + KVASER_PCIEFD_KCAN_BTRD_REG); in kvaser_pciefd_set_bittiming()
860 iowrite32(btrn, can->reg_base + KVASER_PCIEFD_KCAN_BTRN_REG); in kvaser_pciefd_set_bittiming()
863 iowrite32(mode, can->reg_base + KVASER_PCIEFD_KCAN_MODE_REG); in kvaser_pciefd_set_bittiming()
865 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_set_bittiming()
881 struct kvaser_pciefd_can *can = netdev_priv(ndev); in kvaser_pciefd_set_mode() local
886 if (!can->can.restart_ms) in kvaser_pciefd_set_mode()
887 ret = kvaser_pciefd_bus_on(can); in kvaser_pciefd_set_mode()
899 struct kvaser_pciefd_can *can = netdev_priv(ndev); in kvaser_pciefd_get_berr_counter() local
901 bec->rxerr = can->bec.rxerr; in kvaser_pciefd_get_berr_counter()
902 bec->txerr = can->bec.txerr; in kvaser_pciefd_get_berr_counter()
908 struct kvaser_pciefd_can *can = from_timer(can, data, bec_poll_timer); in kvaser_pciefd_bec_poll_timer() local
910 kvaser_pciefd_enable_err_gen(can); in kvaser_pciefd_bec_poll_timer()
911 kvaser_pciefd_request_status(can); in kvaser_pciefd_bec_poll_timer()
912 can->err_rep_cnt = 0; in kvaser_pciefd_bec_poll_timer()
928 struct kvaser_pciefd_can *can; in kvaser_pciefd_setup_can_ctrls() local
936 can = netdev_priv(netdev); in kvaser_pciefd_setup_can_ctrls()
938 can->reg_base = pcie->reg_base + KVASER_PCIEFD_KCAN0_BASE + in kvaser_pciefd_setup_can_ctrls()
941 can->kv_pcie = pcie; in kvaser_pciefd_setup_can_ctrls()
942 can->cmd_seq = 0; in kvaser_pciefd_setup_can_ctrls()
943 can->err_rep_cnt = 0; in kvaser_pciefd_setup_can_ctrls()
944 can->bec.txerr = 0; in kvaser_pciefd_setup_can_ctrls()
945 can->bec.rxerr = 0; in kvaser_pciefd_setup_can_ctrls()
947 init_completion(&can->start_comp); in kvaser_pciefd_setup_can_ctrls()
948 init_completion(&can->flush_comp); in kvaser_pciefd_setup_can_ctrls()
949 timer_setup(&can->bec_poll_timer, kvaser_pciefd_bec_poll_timer, in kvaser_pciefd_setup_can_ctrls()
952 tx_npackets = ioread32(can->reg_base + in kvaser_pciefd_setup_can_ctrls()
963 can->can.clock.freq = pcie->freq; in kvaser_pciefd_setup_can_ctrls()
964 can->can.echo_skb_max = KVASER_PCIEFD_CAN_TX_MAX_COUNT; in kvaser_pciefd_setup_can_ctrls()
965 can->echo_idx = 0; in kvaser_pciefd_setup_can_ctrls()
966 spin_lock_init(&can->echo_lock); in kvaser_pciefd_setup_can_ctrls()
967 spin_lock_init(&can->lock); in kvaser_pciefd_setup_can_ctrls()
968 can->can.bittiming_const = &kvaser_pciefd_bittiming_const; in kvaser_pciefd_setup_can_ctrls()
969 can->can.data_bittiming_const = &kvaser_pciefd_bittiming_const; in kvaser_pciefd_setup_can_ctrls()
971 can->can.do_set_bittiming = kvaser_pciefd_set_nominal_bittiming; in kvaser_pciefd_setup_can_ctrls()
972 can->can.do_set_data_bittiming = in kvaser_pciefd_setup_can_ctrls()
975 can->can.do_set_mode = kvaser_pciefd_set_mode; in kvaser_pciefd_setup_can_ctrls()
976 can->can.do_get_berr_counter = kvaser_pciefd_get_berr_counter; in kvaser_pciefd_setup_can_ctrls()
978 can->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY | in kvaser_pciefd_setup_can_ctrls()
982 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_setup_can_ctrls()
985 "CAN FD not supported as expected %d\n", i); in kvaser_pciefd_setup_can_ctrls()
992 can->can.ctrlmode_supported |= CAN_CTRLMODE_ONE_SHOT; in kvaser_pciefd_setup_can_ctrls()
998 iowrite32(-1, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_setup_can_ctrls()
1001 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_setup_can_ctrls()
1003 pcie->can[i] = can; in kvaser_pciefd_setup_can_ctrls()
1004 kvaser_pciefd_pwm_start(can); in kvaser_pciefd_setup_can_ctrls()
1015 int err = register_candev(pcie->can[i]->can.dev); in kvaser_pciefd_reg_candev()
1022 unregister_candev(pcie->can[j]->can.dev); in kvaser_pciefd_reg_candev()
1152 priv = &pcie->can[ch_id]->can; in kvaser_pciefd_handle_data_packet()
1198 static void kvaser_pciefd_change_state(struct kvaser_pciefd_can *can, in kvaser_pciefd_change_state() argument
1204 can_change_state(can->can.dev, cf, tx_state, rx_state); in kvaser_pciefd_change_state()
1207 struct net_device *ndev = can->can.dev; in kvaser_pciefd_change_state()
1210 spin_lock_irqsave(&can->lock, irq_flags); in kvaser_pciefd_change_state()
1211 netif_stop_queue(can->can.dev); in kvaser_pciefd_change_state()
1212 spin_unlock_irqrestore(&can->lock, irq_flags); in kvaser_pciefd_change_state()
1214 /* Prevent CAN controller from auto recover from bus off */ in kvaser_pciefd_change_state()
1215 if (!can->can.restart_ms) { in kvaser_pciefd_change_state()
1216 kvaser_pciefd_start_controller_flush(can); in kvaser_pciefd_change_state()
1248 static int kvaser_pciefd_rx_error_frame(struct kvaser_pciefd_can *can, in kvaser_pciefd_rx_error_frame() argument
1253 struct net_device *ndev = can->can.dev; in kvaser_pciefd_rx_error_frame()
1259 old_state = can->can.state; in kvaser_pciefd_rx_error_frame()
1270 kvaser_pciefd_change_state(can, cf, new_state, tx_state, in kvaser_pciefd_rx_error_frame()
1275 can->can.restart_ms) { in kvaser_pciefd_rx_error_frame()
1276 can->can.can_stats.restarts++; in kvaser_pciefd_rx_error_frame()
1282 can->err_rep_cnt++; in kvaser_pciefd_rx_error_frame()
1283 can->can.can_stats.bus_error++; in kvaser_pciefd_rx_error_frame()
1286 can->bec.txerr = bec.txerr; in kvaser_pciefd_rx_error_frame()
1287 can->bec.rxerr = bec.rxerr; in kvaser_pciefd_rx_error_frame()
1297 can->kv_pcie->freq_to_ticks_div)); in kvaser_pciefd_rx_error_frame()
1313 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_error_packet() local
1319 can = pcie->can[ch_id]; in kvaser_pciefd_handle_error_packet()
1321 kvaser_pciefd_rx_error_frame(can, p); in kvaser_pciefd_handle_error_packet()
1322 if (can->err_rep_cnt >= KVASER_PCIEFD_MAX_ERR_REP) in kvaser_pciefd_handle_error_packet()
1324 kvaser_pciefd_disable_err_gen(can); in kvaser_pciefd_handle_error_packet()
1326 mod_timer(&can->bec_poll_timer, KVASER_PCIEFD_BEC_POLL_FREQ); in kvaser_pciefd_handle_error_packet()
1330 static int kvaser_pciefd_handle_status_resp(struct kvaser_pciefd_can *can, in kvaser_pciefd_handle_status_resp() argument
1336 old_state = can->can.state; in kvaser_pciefd_handle_status_resp()
1345 struct net_device *ndev = can->can.dev; in kvaser_pciefd_handle_status_resp()
1358 kvaser_pciefd_change_state(can, cf, new_state, tx_state, in kvaser_pciefd_handle_status_resp()
1363 can->can.restart_ms) { in kvaser_pciefd_handle_status_resp()
1364 can->can.can_stats.restarts++; in kvaser_pciefd_handle_status_resp()
1371 can->kv_pcie->freq_to_ticks_div)); in kvaser_pciefd_handle_status_resp()
1378 can->bec.txerr = bec.txerr; in kvaser_pciefd_handle_status_resp()
1379 can->bec.rxerr = bec.rxerr; in kvaser_pciefd_handle_status_resp()
1382 mod_timer(&can->bec_poll_timer, KVASER_PCIEFD_BEC_POLL_FREQ); in kvaser_pciefd_handle_status_resp()
1390 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_status_packet() local
1398 can = pcie->can[ch_id]; in kvaser_pciefd_handle_status_packet()
1400 status = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_STAT_REG); in kvaser_pciefd_handle_status_packet()
1412 can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_handle_status_packet()
1414 cmd |= ++can->cmd_seq << KVASER_PCIEFD_KCAN_CMD_SEQ_SHIFT; in kvaser_pciefd_handle_status_packet()
1415 iowrite32(cmd, can->reg_base + KVASER_PCIEFD_KCAN_CMD_REG); in kvaser_pciefd_handle_status_packet()
1418 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_handle_status_packet()
1424 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_status_packet()
1429 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_handle_status_packet()
1433 kvaser_pciefd_handle_status_resp(can, p); in kvaser_pciefd_handle_status_packet()
1434 if (can->can.state != CAN_STATE_BUS_OFF && in kvaser_pciefd_handle_status_packet()
1435 can->can.state != CAN_STATE_ERROR_ACTIVE) { in kvaser_pciefd_handle_status_packet()
1436 mod_timer(&can->bec_poll_timer, in kvaser_pciefd_handle_status_packet()
1442 if (!completion_done(&can->start_comp)) in kvaser_pciefd_handle_status_packet()
1443 complete(&can->start_comp); in kvaser_pciefd_handle_status_packet()
1452 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_eack_packet() local
1458 can = pcie->can[ch_id]; in kvaser_pciefd_handle_eack_packet()
1462 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_eack_packet()
1467 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_handle_eack_packet()
1470 int dlc = can_get_echo_skb(can->can.dev, echo_idx); in kvaser_pciefd_handle_eack_packet()
1471 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_eack_packet()
1476 if (netif_queue_stopped(can->can.dev)) in kvaser_pciefd_handle_eack_packet()
1477 netif_wake_queue(can->can.dev); in kvaser_pciefd_handle_eack_packet()
1483 static void kvaser_pciefd_handle_nack_packet(struct kvaser_pciefd_can *can, in kvaser_pciefd_handle_nack_packet() argument
1487 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_nack_packet()
1490 skb = alloc_can_err_skb(can->can.dev, &cf); in kvaser_pciefd_handle_nack_packet()
1496 can->can.can_stats.arbitration_lost++; in kvaser_pciefd_handle_nack_packet()
1508 netdev_warn(can->can.dev, "No memory left for err_skb\n"); in kvaser_pciefd_handle_nack_packet()
1515 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_ack_packet() local
1522 can = pcie->can[ch_id]; in kvaser_pciefd_handle_ack_packet()
1528 kvaser_pciefd_handle_nack_packet(can, p); in kvaser_pciefd_handle_ack_packet()
1533 netdev_dbg(can->can.dev, "Packet was flushed\n"); in kvaser_pciefd_handle_ack_packet()
1536 int dlc = can_get_echo_skb(can->can.dev, echo_idx); in kvaser_pciefd_handle_ack_packet()
1537 u8 count = ioread32(can->reg_base + in kvaser_pciefd_handle_ack_packet()
1541 netif_queue_stopped(can->can.dev)) in kvaser_pciefd_handle_ack_packet()
1542 netif_wake_queue(can->can.dev); in kvaser_pciefd_handle_ack_packet()
1545 struct net_device_stats *stats = &can->can.dev->stats; in kvaser_pciefd_handle_ack_packet()
1558 struct kvaser_pciefd_can *can; in kvaser_pciefd_handle_eflush_packet() local
1564 can = pcie->can[ch_id]; in kvaser_pciefd_handle_eflush_packet()
1566 if (!completion_done(&can->flush_comp)) in kvaser_pciefd_handle_eflush_packet()
1567 complete(&can->flush_comp); in kvaser_pciefd_handle_eflush_packet()
1700 static int kvaser_pciefd_transmit_irq(struct kvaser_pciefd_can *can) in kvaser_pciefd_transmit_irq() argument
1702 u32 irq = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_transmit_irq()
1705 netdev_err(can->can.dev, "Tx FIFO overflow\n"); in kvaser_pciefd_transmit_irq()
1708 u8 count = ioread32(can->reg_base + in kvaser_pciefd_transmit_irq()
1713 can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG); in kvaser_pciefd_transmit_irq()
1717 netdev_err(can->can.dev, in kvaser_pciefd_transmit_irq()
1721 netdev_err(can->can.dev, "CAN FD frame in CAN mode\n"); in kvaser_pciefd_transmit_irq()
1724 netdev_err(can->can.dev, "Rx FIFO overflow\n"); in kvaser_pciefd_transmit_irq()
1726 iowrite32(irq, can->reg_base + KVASER_PCIEFD_KCAN_IRQ_REG); in kvaser_pciefd_transmit_irq()
1745 if (!pcie->can[i]) { in kvaser_pciefd_irq_handler()
1753 kvaser_pciefd_transmit_irq(pcie->can[i]); in kvaser_pciefd_irq_handler()
1763 struct kvaser_pciefd_can *can; in kvaser_pciefd_teardown_can_ctrls() local
1766 can = pcie->can[i]; in kvaser_pciefd_teardown_can_ctrls()
1767 if (can) { in kvaser_pciefd_teardown_can_ctrls()
1769 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_teardown_can_ctrls()
1770 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_teardown_can_ctrls()
1771 free_candev(can->can.dev); in kvaser_pciefd_teardown_can_ctrls()
1870 struct kvaser_pciefd_can *can; in kvaser_pciefd_remove_all_ctrls() local
1874 can = pcie->can[i]; in kvaser_pciefd_remove_all_ctrls()
1875 if (can) { in kvaser_pciefd_remove_all_ctrls()
1877 can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); in kvaser_pciefd_remove_all_ctrls()
1878 unregister_candev(can->can.dev); in kvaser_pciefd_remove_all_ctrls()
1879 del_timer(&can->bec_poll_timer); in kvaser_pciefd_remove_all_ctrls()
1880 kvaser_pciefd_pwm_stop(can); in kvaser_pciefd_remove_all_ctrls()
1881 free_candev(can->can.dev); in kvaser_pciefd_remove_all_ctrls()