Lines Matching refs:mod

292 static inline void ican3_set_page(struct ican3_dev *mod, unsigned int page)  in ican3_set_page()  argument
295 iowrite8(page, &mod->dpmctrl->window_address); in ican3_set_page()
309 static int ican3_old_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_old_recv_msg() argument
315 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_recv_msg()
316 peer = ioread8(mod->dpm + MSYNC_PEER); in ican3_old_recv_msg()
317 locl = ioread8(mod->dpm + MSYNC_LOCL); in ican3_old_recv_msg()
321 netdev_dbg(mod->ndev, "no mbox for reading\n"); in ican3_old_recv_msg()
333 ican3_set_page(mod, mbox_page); in ican3_old_recv_msg()
334 memcpy_fromio(msg, mod->dpm, sizeof(*msg)); in ican3_old_recv_msg()
342 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_recv_msg()
343 iowrite8(locl, mod->dpm + MSYNC_LOCL); in ican3_old_recv_msg()
354 static int ican3_old_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_old_send_msg() argument
360 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_send_msg()
361 peer = ioread8(mod->dpm + MSYNC_PEER); in ican3_old_send_msg()
362 locl = ioread8(mod->dpm + MSYNC_LOCL); in ican3_old_send_msg()
366 netdev_err(mod->ndev, "no mbox for writing\n"); in ican3_old_send_msg()
375 ican3_set_page(mod, mbox_page); in ican3_old_send_msg()
376 memcpy_toio(mod->dpm, msg, sizeof(*msg)); in ican3_old_send_msg()
382 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_send_msg()
383 iowrite8(locl, mod->dpm + MSYNC_LOCL); in ican3_old_send_msg()
391 static void ican3_init_new_host_interface(struct ican3_dev *mod) in ican3_init_new_host_interface() argument
398 spin_lock_irqsave(&mod->lock, flags); in ican3_init_new_host_interface()
401 mod->rx_num = 0; in ican3_init_new_host_interface()
402 mod->rx_int = 0; in ican3_init_new_host_interface()
405 ican3_set_page(mod, QUEUE_TOHOST); in ican3_init_new_host_interface()
406 dst = mod->dpm; in ican3_init_new_host_interface()
411 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
419 mod->free_page++; in ican3_init_new_host_interface()
423 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_init_new_host_interface()
424 dst = mod->dpm; in ican3_init_new_host_interface()
427 mod->tx_num = 0; in ican3_init_new_host_interface()
432 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
440 mod->free_page++; in ican3_init_new_host_interface()
444 ican3_set_page(mod, QUEUE_FROMHOST_HIGH); in ican3_init_new_host_interface()
445 dst = mod->dpm; in ican3_init_new_host_interface()
449 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
451 mod->free_page++; in ican3_init_new_host_interface()
454 ican3_set_page(mod, QUEUE_FROMHOST_LOW); in ican3_init_new_host_interface()
455 dst = mod->dpm; in ican3_init_new_host_interface()
459 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
461 mod->free_page++; in ican3_init_new_host_interface()
463 spin_unlock_irqrestore(&mod->lock, flags); in ican3_init_new_host_interface()
470 static void ican3_init_fast_host_interface(struct ican3_dev *mod) in ican3_init_fast_host_interface() argument
478 spin_lock_irqsave(&mod->lock, flags); in ican3_init_fast_host_interface()
481 mod->fastrx_start = mod->free_page; in ican3_init_fast_host_interface()
482 mod->fastrx_num = 0; in ican3_init_fast_host_interface()
498 ican3_set_page(mod, mod->free_page); in ican3_init_fast_host_interface()
501 dst = mod->dpm + addr; in ican3_init_fast_host_interface()
508 mod->free_page++; in ican3_init_fast_host_interface()
514 mod->free_page++; in ican3_init_fast_host_interface()
517 mod->fasttx_start = mod->free_page; in ican3_init_fast_host_interface()
518 mod->fasttx_num = 0; in ican3_init_fast_host_interface()
534 ican3_set_page(mod, mod->free_page); in ican3_init_fast_host_interface()
537 dst = mod->dpm + addr; in ican3_init_fast_host_interface()
544 mod->free_page++; in ican3_init_fast_host_interface()
548 spin_unlock_irqrestore(&mod->lock, flags); in ican3_init_fast_host_interface()
558 static int ican3_new_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_new_send_msg() argument
561 void __iomem *desc_addr = mod->dpm + (mod->tx_num * sizeof(desc)); in ican3_new_send_msg()
564 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_new_send_msg()
568 netdev_dbg(mod->ndev, "%s: no free buffers\n", __func__); in ican3_new_send_msg()
573 ican3_set_page(mod, desc.pointer); in ican3_new_send_msg()
574 memcpy_toio(mod->dpm, msg, sizeof(*msg)); in ican3_new_send_msg()
577 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_new_send_msg()
582 mod->tx_num = (desc.control & DESC_WRAP) ? 0 : (mod->tx_num + 1); in ican3_new_send_msg()
589 static int ican3_new_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_new_recv_msg() argument
592 void __iomem *desc_addr = mod->dpm + (mod->rx_num * sizeof(desc)); in ican3_new_recv_msg()
595 ican3_set_page(mod, QUEUE_TOHOST); in ican3_new_recv_msg()
599 netdev_dbg(mod->ndev, "%s: no buffers to recv\n", __func__); in ican3_new_recv_msg()
604 ican3_set_page(mod, desc.pointer); in ican3_new_recv_msg()
605 memcpy_fromio(msg, mod->dpm, sizeof(*msg)); in ican3_new_recv_msg()
608 ican3_set_page(mod, QUEUE_TOHOST); in ican3_new_recv_msg()
613 mod->rx_num = (desc.control & DESC_WRAP) ? 0 : (mod->rx_num + 1); in ican3_new_recv_msg()
621 static int ican3_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_send_msg() argument
626 spin_lock_irqsave(&mod->lock, flags); in ican3_send_msg()
628 if (mod->iftype == 0) in ican3_send_msg()
629 ret = ican3_old_send_msg(mod, msg); in ican3_send_msg()
631 ret = ican3_new_send_msg(mod, msg); in ican3_send_msg()
633 spin_unlock_irqrestore(&mod->lock, flags); in ican3_send_msg()
637 static int ican3_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_recv_msg() argument
642 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_msg()
644 if (mod->iftype == 0) in ican3_recv_msg()
645 ret = ican3_old_recv_msg(mod, msg); in ican3_recv_msg()
647 ret = ican3_new_recv_msg(mod, msg); in ican3_recv_msg()
649 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_msg()
657 static int ican3_msg_connect(struct ican3_dev *mod) in ican3_msg_connect() argument
665 return ican3_send_msg(mod, &msg); in ican3_msg_connect()
668 static int ican3_msg_disconnect(struct ican3_dev *mod) in ican3_msg_disconnect() argument
676 return ican3_send_msg(mod, &msg); in ican3_msg_disconnect()
679 static int ican3_msg_newhostif(struct ican3_dev *mod) in ican3_msg_newhostif() argument
689 WARN_ON(mod->iftype != 0); in ican3_msg_newhostif()
691 ret = ican3_send_msg(mod, &msg); in ican3_msg_newhostif()
696 mod->iftype = 1; in ican3_msg_newhostif()
700 static int ican3_msg_fasthostif(struct ican3_dev *mod) in ican3_msg_fasthostif() argument
710 addr = DPM_PAGE_ADDR(mod->fastrx_start); in ican3_msg_fasthostif()
717 addr = DPM_PAGE_ADDR(mod->fasttx_start); in ican3_msg_fasthostif()
724 WARN_ON(mod->iftype != 1); in ican3_msg_fasthostif()
726 return ican3_send_msg(mod, &msg); in ican3_msg_fasthostif()
733 static int ican3_set_id_filter(struct ican3_dev *mod, bool accept) in ican3_set_id_filter() argument
750 ret = ican3_send_msg(mod, &msg); in ican3_set_id_filter()
771 return ican3_send_msg(mod, &msg); in ican3_set_id_filter()
777 static int ican3_set_bus_state(struct ican3_dev *mod, bool on) in ican3_set_bus_state() argument
779 struct can_bittiming *bt = &mod->can.bittiming; in ican3_set_bus_state()
790 if (mod->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in ican3_set_bus_state()
793 if (mod->fwtype == ICAN3_FWTYPE_ICANOS) { in ican3_set_bus_state()
804 res = ican3_send_msg(mod, &msg); in ican3_set_bus_state()
814 return ican3_send_msg(mod, &msg); in ican3_set_bus_state()
816 } else if (mod->fwtype == ICAN3_FWTYPE_CAL_CANOPEN) { in ican3_set_bus_state()
831 res = ican3_send_msg(mod, &msg); in ican3_set_bus_state()
849 return ican3_send_msg(mod, &msg); in ican3_set_bus_state()
856 static int ican3_set_termination(struct ican3_dev *mod, bool on) in ican3_set_termination() argument
866 return ican3_send_msg(mod, &msg); in ican3_set_termination()
869 static int ican3_send_inquiry(struct ican3_dev *mod, u8 subspec) in ican3_send_inquiry() argument
879 return ican3_send_msg(mod, &msg); in ican3_send_inquiry()
882 static int ican3_set_buserror(struct ican3_dev *mod, u8 quota) in ican3_set_buserror() argument
886 if (mod->fwtype == ICAN3_FWTYPE_ICANOS) { in ican3_set_buserror()
892 } else if (mod->fwtype == ICAN3_FWTYPE_CAL_CANOPEN) { in ican3_set_buserror()
903 return ican3_send_msg(mod, &msg); in ican3_set_buserror()
910 static void ican3_to_can_frame(struct ican3_dev *mod, in ican3_to_can_frame() argument
942 static void can_frame_to_ican3(struct ican3_dev *mod, in can_frame_to_ican3() argument
955 if (mod->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) in can_frame_to_ican3()
986 static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_idvers() argument
988 netdev_dbg(mod->ndev, "IDVERS response: %s\n", msg->data); in ican3_handle_idvers()
991 static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_msglost() argument
993 struct net_device *dev = mod->ndev; in ican3_handle_msglost()
1004 netdev_err(mod->ndev, "lost %d control messages\n", msg->data[0]); in ican3_handle_msglost()
1033 static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_cevtind() argument
1035 struct net_device *dev = mod->ndev; in ican3_handle_cevtind()
1037 enum can_state state = mod->can.state; in ican3_handle_cevtind()
1044 netdev_err(mod->ndev, "unable to handle errors on non-SJA1000\n"); in ican3_handle_cevtind()
1050 netdev_err(mod->ndev, "error message too short\n"); in ican3_handle_cevtind()
1072 netdev_dbg(mod->ndev, "bus error interrupt\n"); in ican3_handle_cevtind()
1076 kfree_skb(skb_dequeue(&mod->echoq)); in ican3_handle_cevtind()
1086 ret = ican3_set_buserror(mod, 1); in ican3_handle_cevtind()
1088 netdev_err(mod->ndev, "unable to re-enable bus-error\n"); in ican3_handle_cevtind()
1093 if (!(mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) in ican3_handle_cevtind()
1103 netdev_dbg(mod->ndev, "data overrun interrupt\n"); in ican3_handle_cevtind()
1112 netdev_dbg(mod->ndev, "error warning + passive interrupt\n"); in ican3_handle_cevtind()
1116 mod->can.can_stats.bus_off++; in ican3_handle_cevtind()
1130 mod->can.can_stats.bus_error++; in ican3_handle_cevtind()
1155 if (state != mod->can.state && (state == CAN_STATE_ERROR_WARNING || in ican3_handle_cevtind()
1159 mod->can.can_stats.error_warning++; in ican3_handle_cevtind()
1164 mod->can.can_stats.error_passive++; in ican3_handle_cevtind()
1174 mod->can.state = state; in ican3_handle_cevtind()
1179 static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_inquiry() argument
1184 mod->bec.rxerr = msg->data[5]; in ican3_handle_inquiry()
1185 mod->bec.txerr = msg->data[6]; in ican3_handle_inquiry()
1186 complete(&mod->buserror_comp); in ican3_handle_inquiry()
1189 mod->termination_enabled = msg->data[6] & HWCONF_TERMINATE_ON; in ican3_handle_inquiry()
1190 complete(&mod->termination_comp); in ican3_handle_inquiry()
1193 netdev_err(mod->ndev, "received an unknown inquiry response\n"); in ican3_handle_inquiry()
1199 static void ican3_handle_nmtsind(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_nmtsind() argument
1213 ican3_handle_cevtind(mod, msg); in ican3_handle_nmtsind()
1220 netdev_warn(mod->ndev, "unknown NMTS event indication %x\n", in ican3_handle_nmtsind()
1227 netdev_warn(mod->ndev, "unhandled NMTS indication %x\n", in ican3_handle_nmtsind()
1233 static void ican3_handle_unknown_message(struct ican3_dev *mod, in ican3_handle_unknown_message() argument
1236 netdev_warn(mod->ndev, "received unknown message: spec 0x%.2x length %d\n", in ican3_handle_unknown_message()
1243 static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_message() argument
1245 netdev_dbg(mod->ndev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__, in ican3_handle_message()
1246 mod->num, msg->spec, le16_to_cpu(msg->len)); in ican3_handle_message()
1250 ican3_handle_idvers(mod, msg); in ican3_handle_message()
1254 ican3_handle_msglost(mod, msg); in ican3_handle_message()
1257 ican3_handle_cevtind(mod, msg); in ican3_handle_message()
1260 ican3_handle_inquiry(mod, msg); in ican3_handle_message()
1263 ican3_handle_nmtsind(mod, msg); in ican3_handle_message()
1266 ican3_handle_unknown_message(mod, msg); in ican3_handle_message()
1275 static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb) in ican3_put_echo_skb() argument
1284 skb_queue_tail(&mod->echoq, skb); in ican3_put_echo_skb()
1287 static unsigned int ican3_get_echo_skb(struct ican3_dev *mod) in ican3_get_echo_skb() argument
1289 struct sk_buff *skb = skb_dequeue(&mod->echoq); in ican3_get_echo_skb()
1295 netdev_err(mod->ndev, "BUG: echo skb not occupied\n"); in ican3_get_echo_skb()
1312 skb->dev = mod->ndev; in ican3_get_echo_skb()
1326 static bool ican3_echo_skb_matches(struct ican3_dev *mod, struct sk_buff *skb) in ican3_echo_skb_matches() argument
1329 struct sk_buff *echo_skb = skb_peek(&mod->echoq); in ican3_echo_skb_matches()
1350 static bool ican3_txok(struct ican3_dev *mod) in ican3_txok() argument
1356 if (skb_queue_len(&mod->echoq) >= ICAN3_TX_BUFFERS) in ican3_txok()
1360 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); in ican3_txok()
1361 desc = mod->dpm + ((mod->fasttx_num % 16) * sizeof(*desc)); in ican3_txok()
1376 static int ican3_recv_skb(struct ican3_dev *mod) in ican3_recv_skb() argument
1378 struct net_device *ndev = mod->ndev; in ican3_recv_skb()
1386 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_skb()
1389 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); in ican3_recv_skb()
1390 desc_addr = mod->dpm + ((mod->fastrx_num % 16) * sizeof(desc)); in ican3_recv_skb()
1393 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_skb()
1407 ican3_to_can_frame(mod, &desc, cf); in ican3_recv_skb()
1419 if (ican3_echo_skb_matches(mod, skb)) { in ican3_recv_skb()
1421 stats->tx_bytes += ican3_get_echo_skb(mod); in ican3_recv_skb()
1436 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_skb()
1438 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); in ican3_recv_skb()
1442 mod->fastrx_num = (desc.control & DESC_WRAP) ? 0 in ican3_recv_skb()
1443 : (mod->fastrx_num + 1); in ican3_recv_skb()
1446 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_skb()
1452 struct ican3_dev *mod = container_of(napi, struct ican3_dev, napi); in ican3_napi() local
1460 ret = ican3_recv_msg(mod, &msg); in ican3_napi()
1464 ican3_handle_message(mod, &msg); in ican3_napi()
1469 ret = ican3_recv_skb(mod); in ican3_napi()
1481 spin_lock_irqsave(&mod->lock, flags); in ican3_napi()
1484 if (netif_queue_stopped(mod->ndev) && ican3_txok(mod)) in ican3_napi()
1485 netif_wake_queue(mod->ndev); in ican3_napi()
1487 spin_unlock_irqrestore(&mod->lock, flags); in ican3_napi()
1490 iowrite8(1 << mod->num, &mod->ctrl->int_enable); in ican3_napi()
1496 struct ican3_dev *mod = dev_id; in ican3_irq() local
1503 stat = ioread8(&mod->ctrl->int_disable) & (1 << mod->num); in ican3_irq()
1504 if (stat == (1 << mod->num)) in ican3_irq()
1508 ioread8(&mod->dpmctrl->interrupt); in ican3_irq()
1511 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_irq()
1512 napi_schedule(&mod->napi); in ican3_irq()
1525 static int ican3_reset_module(struct ican3_dev *mod) in ican3_reset_module() argument
1531 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_reset_module()
1534 mod->free_page = DPM_FREE_START; in ican3_reset_module()
1536 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_reset_module()
1537 runold = ioread8(mod->dpm + TARGET_RUNNING); in ican3_reset_module()
1540 iowrite8(0x00, &mod->dpmctrl->hwreset); in ican3_reset_module()
1545 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_reset_module()
1546 runnew = ioread8(mod->dpm + TARGET_RUNNING); in ican3_reset_module()
1553 netdev_err(mod->ndev, "failed to reset CAN module\n"); in ican3_reset_module()
1557 static void ican3_shutdown_module(struct ican3_dev *mod) in ican3_shutdown_module() argument
1559 ican3_msg_disconnect(mod); in ican3_shutdown_module()
1560 ican3_reset_module(mod); in ican3_shutdown_module()
1566 static int ican3_startup_module(struct ican3_dev *mod) in ican3_startup_module() argument
1570 ret = ican3_reset_module(mod); in ican3_startup_module()
1572 netdev_err(mod->ndev, "unable to reset module\n"); in ican3_startup_module()
1577 memcpy_fromio(mod->fwinfo, mod->dpm + FIRMWARE_STAMP, sizeof(mod->fwinfo) - 1); in ican3_startup_module()
1578 if (strncmp(mod->fwinfo, "JANZ-ICAN3", 10)) { in ican3_startup_module()
1579 netdev_err(mod->ndev, "ICAN3 not detected (found %s)\n", mod->fwinfo); in ican3_startup_module()
1582 if (strstr(mod->fwinfo, "CAL/CANopen")) in ican3_startup_module()
1583 mod->fwtype = ICAN3_FWTYPE_CAL_CANOPEN; in ican3_startup_module()
1585 mod->fwtype = ICAN3_FWTYPE_ICANOS; in ican3_startup_module()
1588 iowrite8(1 << mod->num, &mod->ctrl->int_enable); in ican3_startup_module()
1590 ret = ican3_msg_connect(mod); in ican3_startup_module()
1592 netdev_err(mod->ndev, "unable to connect to module\n"); in ican3_startup_module()
1596 ican3_init_new_host_interface(mod); in ican3_startup_module()
1597 ret = ican3_msg_newhostif(mod); in ican3_startup_module()
1599 netdev_err(mod->ndev, "unable to switch to new-style interface\n"); in ican3_startup_module()
1604 ret = ican3_set_termination(mod, true); in ican3_startup_module()
1606 netdev_err(mod->ndev, "unable to enable termination\n"); in ican3_startup_module()
1611 ret = ican3_set_buserror(mod, 1); in ican3_startup_module()
1613 netdev_err(mod->ndev, "unable to set bus-error\n"); in ican3_startup_module()
1617 ican3_init_fast_host_interface(mod); in ican3_startup_module()
1618 ret = ican3_msg_fasthostif(mod); in ican3_startup_module()
1620 netdev_err(mod->ndev, "unable to switch to fast host interface\n"); in ican3_startup_module()
1624 ret = ican3_set_id_filter(mod, true); in ican3_startup_module()
1626 netdev_err(mod->ndev, "unable to set acceptance filter\n"); in ican3_startup_module()
1639 struct ican3_dev *mod = netdev_priv(ndev); in ican3_open() local
1645 netdev_err(mod->ndev, "unable to start CAN layer\n"); in ican3_open()
1650 ret = ican3_set_bus_state(mod, true); in ican3_open()
1652 netdev_err(mod->ndev, "unable to set bus-on\n"); in ican3_open()
1658 mod->can.state = CAN_STATE_ERROR_ACTIVE; in ican3_open()
1666 struct ican3_dev *mod = netdev_priv(ndev); in ican3_stop() local
1671 mod->can.state = CAN_STATE_STOPPED; in ican3_stop()
1674 ret = ican3_set_bus_state(mod, false); in ican3_stop()
1676 netdev_err(mod->ndev, "unable to set bus-off\n"); in ican3_stop()
1681 skb_queue_purge(&mod->echoq); in ican3_stop()
1690 struct ican3_dev *mod = netdev_priv(ndev); in ican3_xmit() local
1699 spin_lock_irqsave(&mod->lock, flags); in ican3_xmit()
1702 if (!ican3_txok(mod)) { in ican3_xmit()
1703 netdev_err(mod->ndev, "BUG: no free descriptors\n"); in ican3_xmit()
1704 spin_unlock_irqrestore(&mod->lock, flags); in ican3_xmit()
1709 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); in ican3_xmit()
1710 desc_addr = mod->dpm + ((mod->fasttx_num % 16) * sizeof(desc)); in ican3_xmit()
1715 can_frame_to_ican3(mod, cf, &desc); in ican3_xmit()
1723 ican3_put_echo_skb(mod, skb); in ican3_xmit()
1734 iowrite8(0x01, &mod->dpmctrl->interrupt); in ican3_xmit()
1740 mod->fasttx_num = (desc.control & DESC_WRAP) ? 0 in ican3_xmit()
1741 : (mod->fasttx_num + 1); in ican3_xmit()
1744 if (!ican3_txok(mod)) in ican3_xmit()
1747 spin_unlock_irqrestore(&mod->lock, flags); in ican3_xmit()
1781 struct ican3_dev *mod = netdev_priv(ndev); in ican3_set_mode() local
1788 ret = ican3_set_bus_state(mod, true); in ican3_set_mode()
1795 mod->can.state = CAN_STATE_ERROR_ACTIVE; in ican3_set_mode()
1806 struct ican3_dev *mod = netdev_priv(ndev); in ican3_get_berr_counter() local
1809 ret = ican3_send_inquiry(mod, INQUIRY_STATUS); in ican3_get_berr_counter()
1813 if (!wait_for_completion_timeout(&mod->buserror_comp, HZ)) { in ican3_get_berr_counter()
1814 netdev_info(mod->ndev, "%s timed out\n", __func__); in ican3_get_berr_counter()
1818 bec->rxerr = mod->bec.rxerr; in ican3_get_berr_counter()
1819 bec->txerr = mod->bec.txerr; in ican3_get_berr_counter()
1831 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in termination_show() local
1834 ret = ican3_send_inquiry(mod, INQUIRY_TERMINATION); in termination_show()
1838 if (!wait_for_completion_timeout(&mod->termination_comp, HZ)) { in termination_show()
1839 netdev_info(mod->ndev, "%s timed out\n", __func__); in termination_show()
1843 return sysfs_emit(buf, "%u\n", mod->termination_enabled); in termination_show()
1850 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in termination_store() local
1857 ret = ican3_set_termination(mod, enable); in termination_store()
1868 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in fwinfo_show() local
1870 return scnprintf(buf, PAGE_SIZE, "%s\n", mod->fwinfo); in fwinfo_show()
1894 struct ican3_dev *mod; in ican3_probe() local
1909 ndev = alloc_candev(sizeof(*mod), 0); in ican3_probe()
1917 mod = netdev_priv(ndev); in ican3_probe()
1918 mod->ndev = ndev; in ican3_probe()
1919 mod->num = pdata->modno; in ican3_probe()
1920 netif_napi_add_weight(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS); in ican3_probe()
1921 skb_queue_head_init(&mod->echoq); in ican3_probe()
1922 spin_lock_init(&mod->lock); in ican3_probe()
1923 init_completion(&mod->termination_comp); in ican3_probe()
1924 init_completion(&mod->buserror_comp); in ican3_probe()
1930 mod->free_page = DPM_FREE_START; in ican3_probe()
1937 mod->can.clock.freq = ICAN3_CAN_CLOCK; in ican3_probe()
1938 mod->can.bittiming_const = &ican3_bittiming_const; in ican3_probe()
1939 mod->can.do_set_mode = ican3_set_mode; in ican3_probe()
1940 mod->can.do_get_berr_counter = ican3_get_berr_counter; in ican3_probe()
1941 mod->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES in ican3_probe()
1946 mod->irq = platform_get_irq(pdev, 0); in ican3_probe()
1947 if (mod->irq < 0) { in ican3_probe()
1952 ndev->irq = mod->irq; in ican3_probe()
1962 mod->dpm = ioremap(res->start, resource_size(res)); in ican3_probe()
1963 if (!mod->dpm) { in ican3_probe()
1969 mod->dpmctrl = mod->dpm + DPM_PAGE_SIZE; in ican3_probe()
1979 mod->ctrl = ioremap(res->start, resource_size(res)); in ican3_probe()
1980 if (!mod->ctrl) { in ican3_probe()
1987 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_probe()
1988 ret = request_irq(mod->irq, ican3_irq, IRQF_SHARED, DRV_NAME, mod); in ican3_probe()
1995 napi_enable(&mod->napi); in ican3_probe()
1996 ret = ican3_startup_module(mod); in ican3_probe()
2009 netdev_info(mod->ndev, "module %d: registered CAN device\n", pdata->modno); in ican3_probe()
2013 napi_disable(&mod->napi); in ican3_probe()
2014 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_probe()
2015 free_irq(mod->irq, mod); in ican3_probe()
2017 iounmap(mod->ctrl); in ican3_probe()
2019 iounmap(mod->dpm); in ican3_probe()
2029 struct ican3_dev *mod = netdev_priv(ndev); in ican3_remove() local
2033 napi_disable(&mod->napi); in ican3_remove()
2034 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_remove()
2035 free_irq(mod->irq, mod); in ican3_remove()
2038 ican3_shutdown_module(mod); in ican3_remove()
2041 iounmap(mod->ctrl); in ican3_remove()
2042 iounmap(mod->dpm); in ican3_remove()