Lines Matching refs:mod

291 static inline void ican3_set_page(struct ican3_dev *mod, unsigned int page)  in ican3_set_page()  argument
294 iowrite8(page, &mod->dpmctrl->window_address); in ican3_set_page()
308 static int ican3_old_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_old_recv_msg() argument
314 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_recv_msg()
315 peer = ioread8(mod->dpm + MSYNC_PEER); in ican3_old_recv_msg()
316 locl = ioread8(mod->dpm + MSYNC_LOCL); in ican3_old_recv_msg()
320 netdev_dbg(mod->ndev, "no mbox for reading\n"); in ican3_old_recv_msg()
332 ican3_set_page(mod, mbox_page); in ican3_old_recv_msg()
333 memcpy_fromio(msg, mod->dpm, sizeof(*msg)); in ican3_old_recv_msg()
341 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_recv_msg()
342 iowrite8(locl, mod->dpm + MSYNC_LOCL); in ican3_old_recv_msg()
353 static int ican3_old_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_old_send_msg() argument
359 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_send_msg()
360 peer = ioread8(mod->dpm + MSYNC_PEER); in ican3_old_send_msg()
361 locl = ioread8(mod->dpm + MSYNC_LOCL); in ican3_old_send_msg()
365 netdev_err(mod->ndev, "no mbox for writing\n"); in ican3_old_send_msg()
374 ican3_set_page(mod, mbox_page); in ican3_old_send_msg()
375 memcpy_toio(mod->dpm, msg, sizeof(*msg)); in ican3_old_send_msg()
381 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_old_send_msg()
382 iowrite8(locl, mod->dpm + MSYNC_LOCL); in ican3_old_send_msg()
390 static void ican3_init_new_host_interface(struct ican3_dev *mod) in ican3_init_new_host_interface() argument
397 spin_lock_irqsave(&mod->lock, flags); in ican3_init_new_host_interface()
400 mod->rx_num = 0; in ican3_init_new_host_interface()
401 mod->rx_int = 0; in ican3_init_new_host_interface()
404 ican3_set_page(mod, QUEUE_TOHOST); in ican3_init_new_host_interface()
405 dst = mod->dpm; in ican3_init_new_host_interface()
410 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
418 mod->free_page++; in ican3_init_new_host_interface()
422 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_init_new_host_interface()
423 dst = mod->dpm; in ican3_init_new_host_interface()
426 mod->tx_num = 0; in ican3_init_new_host_interface()
431 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
439 mod->free_page++; in ican3_init_new_host_interface()
443 ican3_set_page(mod, QUEUE_FROMHOST_HIGH); in ican3_init_new_host_interface()
444 dst = mod->dpm; in ican3_init_new_host_interface()
448 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
450 mod->free_page++; in ican3_init_new_host_interface()
453 ican3_set_page(mod, QUEUE_FROMHOST_LOW); in ican3_init_new_host_interface()
454 dst = mod->dpm; in ican3_init_new_host_interface()
458 desc.pointer = mod->free_page; in ican3_init_new_host_interface()
460 mod->free_page++; in ican3_init_new_host_interface()
462 spin_unlock_irqrestore(&mod->lock, flags); in ican3_init_new_host_interface()
469 static void ican3_init_fast_host_interface(struct ican3_dev *mod) in ican3_init_fast_host_interface() argument
477 spin_lock_irqsave(&mod->lock, flags); in ican3_init_fast_host_interface()
480 mod->fastrx_start = mod->free_page; in ican3_init_fast_host_interface()
481 mod->fastrx_num = 0; in ican3_init_fast_host_interface()
497 ican3_set_page(mod, mod->free_page); in ican3_init_fast_host_interface()
500 dst = mod->dpm + addr; in ican3_init_fast_host_interface()
507 mod->free_page++; in ican3_init_fast_host_interface()
513 mod->free_page++; in ican3_init_fast_host_interface()
516 mod->fasttx_start = mod->free_page; in ican3_init_fast_host_interface()
517 mod->fasttx_num = 0; in ican3_init_fast_host_interface()
533 ican3_set_page(mod, mod->free_page); in ican3_init_fast_host_interface()
536 dst = mod->dpm + addr; in ican3_init_fast_host_interface()
543 mod->free_page++; in ican3_init_fast_host_interface()
547 spin_unlock_irqrestore(&mod->lock, flags); in ican3_init_fast_host_interface()
557 static int ican3_new_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_new_send_msg() argument
560 void __iomem *desc_addr = mod->dpm + (mod->tx_num * sizeof(desc)); in ican3_new_send_msg()
563 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_new_send_msg()
567 netdev_dbg(mod->ndev, "%s: no free buffers\n", __func__); in ican3_new_send_msg()
572 ican3_set_page(mod, desc.pointer); in ican3_new_send_msg()
573 memcpy_toio(mod->dpm, msg, sizeof(*msg)); in ican3_new_send_msg()
576 ican3_set_page(mod, QUEUE_FROMHOST_MID); in ican3_new_send_msg()
581 mod->tx_num = (desc.control & DESC_WRAP) ? 0 : (mod->tx_num + 1); in ican3_new_send_msg()
588 static int ican3_new_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_new_recv_msg() argument
591 void __iomem *desc_addr = mod->dpm + (mod->rx_num * sizeof(desc)); in ican3_new_recv_msg()
594 ican3_set_page(mod, QUEUE_TOHOST); in ican3_new_recv_msg()
598 netdev_dbg(mod->ndev, "%s: no buffers to recv\n", __func__); in ican3_new_recv_msg()
603 ican3_set_page(mod, desc.pointer); in ican3_new_recv_msg()
604 memcpy_fromio(msg, mod->dpm, sizeof(*msg)); in ican3_new_recv_msg()
607 ican3_set_page(mod, QUEUE_TOHOST); in ican3_new_recv_msg()
612 mod->rx_num = (desc.control & DESC_WRAP) ? 0 : (mod->rx_num + 1); in ican3_new_recv_msg()
620 static int ican3_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_send_msg() argument
625 spin_lock_irqsave(&mod->lock, flags); in ican3_send_msg()
627 if (mod->iftype == 0) in ican3_send_msg()
628 ret = ican3_old_send_msg(mod, msg); in ican3_send_msg()
630 ret = ican3_new_send_msg(mod, msg); in ican3_send_msg()
632 spin_unlock_irqrestore(&mod->lock, flags); in ican3_send_msg()
636 static int ican3_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_recv_msg() argument
641 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_msg()
643 if (mod->iftype == 0) in ican3_recv_msg()
644 ret = ican3_old_recv_msg(mod, msg); in ican3_recv_msg()
646 ret = ican3_new_recv_msg(mod, msg); in ican3_recv_msg()
648 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_msg()
656 static int ican3_msg_connect(struct ican3_dev *mod) in ican3_msg_connect() argument
664 return ican3_send_msg(mod, &msg); in ican3_msg_connect()
667 static int ican3_msg_disconnect(struct ican3_dev *mod) in ican3_msg_disconnect() argument
675 return ican3_send_msg(mod, &msg); in ican3_msg_disconnect()
678 static int ican3_msg_newhostif(struct ican3_dev *mod) in ican3_msg_newhostif() argument
688 WARN_ON(mod->iftype != 0); in ican3_msg_newhostif()
690 ret = ican3_send_msg(mod, &msg); in ican3_msg_newhostif()
695 mod->iftype = 1; in ican3_msg_newhostif()
699 static int ican3_msg_fasthostif(struct ican3_dev *mod) in ican3_msg_fasthostif() argument
709 addr = DPM_PAGE_ADDR(mod->fastrx_start); in ican3_msg_fasthostif()
716 addr = DPM_PAGE_ADDR(mod->fasttx_start); in ican3_msg_fasthostif()
723 WARN_ON(mod->iftype != 1); in ican3_msg_fasthostif()
725 return ican3_send_msg(mod, &msg); in ican3_msg_fasthostif()
732 static int ican3_set_id_filter(struct ican3_dev *mod, bool accept) in ican3_set_id_filter() argument
749 ret = ican3_send_msg(mod, &msg); in ican3_set_id_filter()
770 return ican3_send_msg(mod, &msg); in ican3_set_id_filter()
776 static int ican3_set_bus_state(struct ican3_dev *mod, bool on) in ican3_set_bus_state() argument
778 struct can_bittiming *bt = &mod->can.bittiming; in ican3_set_bus_state()
789 if (mod->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in ican3_set_bus_state()
792 if (mod->fwtype == ICAN3_FWTYPE_ICANOS) { in ican3_set_bus_state()
803 res = ican3_send_msg(mod, &msg); in ican3_set_bus_state()
813 return ican3_send_msg(mod, &msg); in ican3_set_bus_state()
815 } else if (mod->fwtype == ICAN3_FWTYPE_CAL_CANOPEN) { in ican3_set_bus_state()
830 res = ican3_send_msg(mod, &msg); in ican3_set_bus_state()
848 return ican3_send_msg(mod, &msg); in ican3_set_bus_state()
855 static int ican3_set_termination(struct ican3_dev *mod, bool on) in ican3_set_termination() argument
865 return ican3_send_msg(mod, &msg); in ican3_set_termination()
868 static int ican3_send_inquiry(struct ican3_dev *mod, u8 subspec) in ican3_send_inquiry() argument
878 return ican3_send_msg(mod, &msg); in ican3_send_inquiry()
881 static int ican3_set_buserror(struct ican3_dev *mod, u8 quota) in ican3_set_buserror() argument
885 if (mod->fwtype == ICAN3_FWTYPE_ICANOS) { in ican3_set_buserror()
891 } else if (mod->fwtype == ICAN3_FWTYPE_CAL_CANOPEN) { in ican3_set_buserror()
902 return ican3_send_msg(mod, &msg); in ican3_set_buserror()
909 static void ican3_to_can_frame(struct ican3_dev *mod, in ican3_to_can_frame() argument
941 static void can_frame_to_ican3(struct ican3_dev *mod, in can_frame_to_ican3() argument
954 if (mod->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) in can_frame_to_ican3()
985 static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_idvers() argument
987 netdev_dbg(mod->ndev, "IDVERS response: %s\n", msg->data); in ican3_handle_idvers()
990 static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_msglost() argument
992 struct net_device *dev = mod->ndev; in ican3_handle_msglost()
1003 netdev_err(mod->ndev, "lost %d control messages\n", msg->data[0]); in ican3_handle_msglost()
1032 static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_cevtind() argument
1034 struct net_device *dev = mod->ndev; in ican3_handle_cevtind()
1036 enum can_state state = mod->can.state; in ican3_handle_cevtind()
1043 netdev_err(mod->ndev, "unable to handle errors on non-SJA1000\n"); in ican3_handle_cevtind()
1049 netdev_err(mod->ndev, "error message too short\n"); in ican3_handle_cevtind()
1071 netdev_dbg(mod->ndev, "bus error interrupt\n"); in ican3_handle_cevtind()
1075 kfree_skb(skb_dequeue(&mod->echoq)); in ican3_handle_cevtind()
1085 ret = ican3_set_buserror(mod, 1); in ican3_handle_cevtind()
1087 netdev_err(mod->ndev, "unable to re-enable bus-error\n"); in ican3_handle_cevtind()
1092 if (!(mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) in ican3_handle_cevtind()
1102 netdev_dbg(mod->ndev, "data overrun interrupt\n"); in ican3_handle_cevtind()
1111 netdev_dbg(mod->ndev, "error warning + passive interrupt\n"); in ican3_handle_cevtind()
1115 mod->can.can_stats.bus_off++; in ican3_handle_cevtind()
1129 mod->can.can_stats.bus_error++; in ican3_handle_cevtind()
1154 if (state != mod->can.state && (state == CAN_STATE_ERROR_WARNING || in ican3_handle_cevtind()
1158 mod->can.can_stats.error_warning++; in ican3_handle_cevtind()
1163 mod->can.can_stats.error_passive++; in ican3_handle_cevtind()
1173 mod->can.state = state; in ican3_handle_cevtind()
1178 static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_inquiry() argument
1183 mod->bec.rxerr = msg->data[5]; in ican3_handle_inquiry()
1184 mod->bec.txerr = msg->data[6]; in ican3_handle_inquiry()
1185 complete(&mod->buserror_comp); in ican3_handle_inquiry()
1188 mod->termination_enabled = msg->data[6] & HWCONF_TERMINATE_ON; in ican3_handle_inquiry()
1189 complete(&mod->termination_comp); in ican3_handle_inquiry()
1192 netdev_err(mod->ndev, "received an unknown inquiry response\n"); in ican3_handle_inquiry()
1198 static void ican3_handle_nmtsind(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_nmtsind() argument
1212 ican3_handle_cevtind(mod, msg); in ican3_handle_nmtsind()
1219 netdev_warn(mod->ndev, "unknown NMTS event indication %x\n", in ican3_handle_nmtsind()
1226 netdev_warn(mod->ndev, "unhandled NMTS indication %x\n", in ican3_handle_nmtsind()
1232 static void ican3_handle_unknown_message(struct ican3_dev *mod, in ican3_handle_unknown_message() argument
1235 netdev_warn(mod->ndev, "received unknown message: spec 0x%.2x length %d\n", in ican3_handle_unknown_message()
1242 static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg) in ican3_handle_message() argument
1244 netdev_dbg(mod->ndev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__, in ican3_handle_message()
1245 mod->num, msg->spec, le16_to_cpu(msg->len)); in ican3_handle_message()
1249 ican3_handle_idvers(mod, msg); in ican3_handle_message()
1253 ican3_handle_msglost(mod, msg); in ican3_handle_message()
1256 ican3_handle_cevtind(mod, msg); in ican3_handle_message()
1259 ican3_handle_inquiry(mod, msg); in ican3_handle_message()
1262 ican3_handle_nmtsind(mod, msg); in ican3_handle_message()
1265 ican3_handle_unknown_message(mod, msg); in ican3_handle_message()
1274 static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb) in ican3_put_echo_skb() argument
1281 skb_queue_tail(&mod->echoq, skb); in ican3_put_echo_skb()
1284 static unsigned int ican3_get_echo_skb(struct ican3_dev *mod) in ican3_get_echo_skb() argument
1286 struct sk_buff *skb = skb_dequeue(&mod->echoq); in ican3_get_echo_skb()
1292 netdev_err(mod->ndev, "BUG: echo skb not occupied\n"); in ican3_get_echo_skb()
1308 skb->dev = mod->ndev; in ican3_get_echo_skb()
1322 static bool ican3_echo_skb_matches(struct ican3_dev *mod, struct sk_buff *skb) in ican3_echo_skb_matches() argument
1325 struct sk_buff *echo_skb = skb_peek(&mod->echoq); in ican3_echo_skb_matches()
1346 static bool ican3_txok(struct ican3_dev *mod) in ican3_txok() argument
1352 if (skb_queue_len(&mod->echoq) >= ICAN3_TX_BUFFERS) in ican3_txok()
1356 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); in ican3_txok()
1357 desc = mod->dpm + ((mod->fasttx_num % 16) * sizeof(*desc)); in ican3_txok()
1372 static int ican3_recv_skb(struct ican3_dev *mod) in ican3_recv_skb() argument
1374 struct net_device *ndev = mod->ndev; in ican3_recv_skb()
1382 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_skb()
1385 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); in ican3_recv_skb()
1386 desc_addr = mod->dpm + ((mod->fastrx_num % 16) * sizeof(desc)); in ican3_recv_skb()
1389 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_skb()
1403 ican3_to_can_frame(mod, &desc, cf); in ican3_recv_skb()
1415 if (ican3_echo_skb_matches(mod, skb)) { in ican3_recv_skb()
1417 stats->tx_bytes += ican3_get_echo_skb(mod); in ican3_recv_skb()
1431 spin_lock_irqsave(&mod->lock, flags); in ican3_recv_skb()
1433 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); in ican3_recv_skb()
1437 mod->fastrx_num = (desc.control & DESC_WRAP) ? 0 in ican3_recv_skb()
1438 : (mod->fastrx_num + 1); in ican3_recv_skb()
1441 spin_unlock_irqrestore(&mod->lock, flags); in ican3_recv_skb()
1447 struct ican3_dev *mod = container_of(napi, struct ican3_dev, napi); in ican3_napi() local
1455 ret = ican3_recv_msg(mod, &msg); in ican3_napi()
1459 ican3_handle_message(mod, &msg); in ican3_napi()
1464 ret = ican3_recv_skb(mod); in ican3_napi()
1476 spin_lock_irqsave(&mod->lock, flags); in ican3_napi()
1479 if (netif_queue_stopped(mod->ndev) && ican3_txok(mod)) in ican3_napi()
1480 netif_wake_queue(mod->ndev); in ican3_napi()
1482 spin_unlock_irqrestore(&mod->lock, flags); in ican3_napi()
1485 iowrite8(1 << mod->num, &mod->ctrl->int_enable); in ican3_napi()
1491 struct ican3_dev *mod = dev_id; in ican3_irq() local
1498 stat = ioread8(&mod->ctrl->int_disable) & (1 << mod->num); in ican3_irq()
1499 if (stat == (1 << mod->num)) in ican3_irq()
1503 ioread8(&mod->dpmctrl->interrupt); in ican3_irq()
1506 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_irq()
1507 napi_schedule(&mod->napi); in ican3_irq()
1520 static int ican3_reset_module(struct ican3_dev *mod) in ican3_reset_module() argument
1526 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_reset_module()
1529 mod->free_page = DPM_FREE_START; in ican3_reset_module()
1531 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_reset_module()
1532 runold = ioread8(mod->dpm + TARGET_RUNNING); in ican3_reset_module()
1535 iowrite8(0x00, &mod->dpmctrl->hwreset); in ican3_reset_module()
1540 ican3_set_page(mod, QUEUE_OLD_CONTROL); in ican3_reset_module()
1541 runnew = ioread8(mod->dpm + TARGET_RUNNING); in ican3_reset_module()
1548 netdev_err(mod->ndev, "failed to reset CAN module\n"); in ican3_reset_module()
1552 static void ican3_shutdown_module(struct ican3_dev *mod) in ican3_shutdown_module() argument
1554 ican3_msg_disconnect(mod); in ican3_shutdown_module()
1555 ican3_reset_module(mod); in ican3_shutdown_module()
1561 static int ican3_startup_module(struct ican3_dev *mod) in ican3_startup_module() argument
1565 ret = ican3_reset_module(mod); in ican3_startup_module()
1567 netdev_err(mod->ndev, "unable to reset module\n"); in ican3_startup_module()
1572 memcpy_fromio(mod->fwinfo, mod->dpm + FIRMWARE_STAMP, sizeof(mod->fwinfo) - 1); in ican3_startup_module()
1573 if (strncmp(mod->fwinfo, "JANZ-ICAN3", 10)) { in ican3_startup_module()
1574 netdev_err(mod->ndev, "ICAN3 not detected (found %s)\n", mod->fwinfo); in ican3_startup_module()
1577 if (strstr(mod->fwinfo, "CAL/CANopen")) in ican3_startup_module()
1578 mod->fwtype = ICAN3_FWTYPE_CAL_CANOPEN; in ican3_startup_module()
1580 mod->fwtype = ICAN3_FWTYPE_ICANOS; in ican3_startup_module()
1583 iowrite8(1 << mod->num, &mod->ctrl->int_enable); in ican3_startup_module()
1585 ret = ican3_msg_connect(mod); in ican3_startup_module()
1587 netdev_err(mod->ndev, "unable to connect to module\n"); in ican3_startup_module()
1591 ican3_init_new_host_interface(mod); in ican3_startup_module()
1592 ret = ican3_msg_newhostif(mod); in ican3_startup_module()
1594 netdev_err(mod->ndev, "unable to switch to new-style interface\n"); in ican3_startup_module()
1599 ret = ican3_set_termination(mod, true); in ican3_startup_module()
1601 netdev_err(mod->ndev, "unable to enable termination\n"); in ican3_startup_module()
1606 ret = ican3_set_buserror(mod, 1); in ican3_startup_module()
1608 netdev_err(mod->ndev, "unable to set bus-error\n"); in ican3_startup_module()
1612 ican3_init_fast_host_interface(mod); in ican3_startup_module()
1613 ret = ican3_msg_fasthostif(mod); in ican3_startup_module()
1615 netdev_err(mod->ndev, "unable to switch to fast host interface\n"); in ican3_startup_module()
1619 ret = ican3_set_id_filter(mod, true); in ican3_startup_module()
1621 netdev_err(mod->ndev, "unable to set acceptance filter\n"); in ican3_startup_module()
1634 struct ican3_dev *mod = netdev_priv(ndev); in ican3_open() local
1640 netdev_err(mod->ndev, "unable to start CAN layer\n"); in ican3_open()
1645 ret = ican3_set_bus_state(mod, true); in ican3_open()
1647 netdev_err(mod->ndev, "unable to set bus-on\n"); in ican3_open()
1653 mod->can.state = CAN_STATE_ERROR_ACTIVE; in ican3_open()
1661 struct ican3_dev *mod = netdev_priv(ndev); in ican3_stop() local
1666 mod->can.state = CAN_STATE_STOPPED; in ican3_stop()
1669 ret = ican3_set_bus_state(mod, false); in ican3_stop()
1671 netdev_err(mod->ndev, "unable to set bus-off\n"); in ican3_stop()
1676 skb_queue_purge(&mod->echoq); in ican3_stop()
1685 struct ican3_dev *mod = netdev_priv(ndev); in ican3_xmit() local
1694 spin_lock_irqsave(&mod->lock, flags); in ican3_xmit()
1697 if (!ican3_txok(mod)) { in ican3_xmit()
1698 netdev_err(mod->ndev, "BUG: no free descriptors\n"); in ican3_xmit()
1699 spin_unlock_irqrestore(&mod->lock, flags); in ican3_xmit()
1704 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); in ican3_xmit()
1705 desc_addr = mod->dpm + ((mod->fasttx_num % 16) * sizeof(desc)); in ican3_xmit()
1710 can_frame_to_ican3(mod, cf, &desc); in ican3_xmit()
1718 ican3_put_echo_skb(mod, skb); in ican3_xmit()
1729 iowrite8(0x01, &mod->dpmctrl->interrupt); in ican3_xmit()
1735 mod->fasttx_num = (desc.control & DESC_WRAP) ? 0 in ican3_xmit()
1736 : (mod->fasttx_num + 1); in ican3_xmit()
1739 if (!ican3_txok(mod)) in ican3_xmit()
1742 spin_unlock_irqrestore(&mod->lock, flags); in ican3_xmit()
1772 struct ican3_dev *mod = netdev_priv(ndev); in ican3_set_mode() local
1779 ret = ican3_set_bus_state(mod, true); in ican3_set_mode()
1786 mod->can.state = CAN_STATE_ERROR_ACTIVE; in ican3_set_mode()
1797 struct ican3_dev *mod = netdev_priv(ndev); in ican3_get_berr_counter() local
1800 ret = ican3_send_inquiry(mod, INQUIRY_STATUS); in ican3_get_berr_counter()
1804 if (!wait_for_completion_timeout(&mod->buserror_comp, HZ)) { in ican3_get_berr_counter()
1805 netdev_info(mod->ndev, "%s timed out\n", __func__); in ican3_get_berr_counter()
1809 bec->rxerr = mod->bec.rxerr; in ican3_get_berr_counter()
1810 bec->txerr = mod->bec.txerr; in ican3_get_berr_counter()
1822 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in termination_show() local
1825 ret = ican3_send_inquiry(mod, INQUIRY_TERMINATION); in termination_show()
1829 if (!wait_for_completion_timeout(&mod->termination_comp, HZ)) { in termination_show()
1830 netdev_info(mod->ndev, "%s timed out\n", __func__); in termination_show()
1834 return sysfs_emit(buf, "%u\n", mod->termination_enabled); in termination_show()
1841 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in termination_store() local
1848 ret = ican3_set_termination(mod, enable); in termination_store()
1859 struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); in fwinfo_show() local
1861 return scnprintf(buf, PAGE_SIZE, "%s\n", mod->fwinfo); in fwinfo_show()
1885 struct ican3_dev *mod; in ican3_probe() local
1900 ndev = alloc_candev(sizeof(*mod), 0); in ican3_probe()
1908 mod = netdev_priv(ndev); in ican3_probe()
1909 mod->ndev = ndev; in ican3_probe()
1910 mod->num = pdata->modno; in ican3_probe()
1911 netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS); in ican3_probe()
1912 skb_queue_head_init(&mod->echoq); in ican3_probe()
1913 spin_lock_init(&mod->lock); in ican3_probe()
1914 init_completion(&mod->termination_comp); in ican3_probe()
1915 init_completion(&mod->buserror_comp); in ican3_probe()
1921 mod->free_page = DPM_FREE_START; in ican3_probe()
1927 mod->can.clock.freq = ICAN3_CAN_CLOCK; in ican3_probe()
1928 mod->can.bittiming_const = &ican3_bittiming_const; in ican3_probe()
1929 mod->can.do_set_mode = ican3_set_mode; in ican3_probe()
1930 mod->can.do_get_berr_counter = ican3_get_berr_counter; in ican3_probe()
1931 mod->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES in ican3_probe()
1936 mod->irq = platform_get_irq(pdev, 0); in ican3_probe()
1937 if (mod->irq < 0) { in ican3_probe()
1942 ndev->irq = mod->irq; in ican3_probe()
1952 mod->dpm = ioremap(res->start, resource_size(res)); in ican3_probe()
1953 if (!mod->dpm) { in ican3_probe()
1959 mod->dpmctrl = mod->dpm + DPM_PAGE_SIZE; in ican3_probe()
1969 mod->ctrl = ioremap(res->start, resource_size(res)); in ican3_probe()
1970 if (!mod->ctrl) { in ican3_probe()
1977 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_probe()
1978 ret = request_irq(mod->irq, ican3_irq, IRQF_SHARED, DRV_NAME, mod); in ican3_probe()
1985 napi_enable(&mod->napi); in ican3_probe()
1986 ret = ican3_startup_module(mod); in ican3_probe()
1999 netdev_info(mod->ndev, "module %d: registered CAN device\n", pdata->modno); in ican3_probe()
2003 napi_disable(&mod->napi); in ican3_probe()
2004 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_probe()
2005 free_irq(mod->irq, mod); in ican3_probe()
2007 iounmap(mod->ctrl); in ican3_probe()
2009 iounmap(mod->dpm); in ican3_probe()
2019 struct ican3_dev *mod = netdev_priv(ndev); in ican3_remove() local
2023 napi_disable(&mod->napi); in ican3_remove()
2024 iowrite8(1 << mod->num, &mod->ctrl->int_disable); in ican3_remove()
2025 free_irq(mod->irq, mod); in ican3_remove()
2028 ican3_shutdown_module(mod); in ican3_remove()
2031 iounmap(mod->ctrl); in ican3_remove()
2032 iounmap(mod->dpm); in ican3_remove()