Lines Matching full:core

39 /*   Two bit wide command masks to mask or unmask a single core IRQ */
47 static void acc_resetmode_enter(struct acc_core *core) in acc_resetmode_enter() argument
49 acc_set_bits(core, ACC_CORE_OF_CTRL, in acc_resetmode_enter()
53 acc_resetmode_entered(core); in acc_resetmode_enter()
56 static void acc_resetmode_leave(struct acc_core *core) in acc_resetmode_leave() argument
58 acc_clear_bits(core, ACC_CORE_OF_CTRL, in acc_resetmode_leave()
62 acc_resetmode_entered(core); in acc_resetmode_leave()
65 static void acc_txq_put(struct acc_core *core, u32 acc_id, u32 acc_dlc, in acc_txq_put() argument
68 acc_write32_noswap(core, ACC_CORE_OF_TXFIFO_DATA_1, in acc_txq_put()
70 acc_write32_noswap(core, ACC_CORE_OF_TXFIFO_DATA_0, in acc_txq_put()
72 acc_write32(core, ACC_CORE_OF_TXFIFO_DLC, acc_dlc); in acc_txq_put()
74 acc_write32(core, ACC_CORE_OF_TXFIFO_ID, acc_id); in acc_txq_put()
77 static u8 acc_tx_fifo_next(struct acc_core *core, u8 tx_fifo_idx) in acc_tx_fifo_next() argument
80 if (tx_fifo_idx >= core->tx_fifo_size) in acc_tx_fifo_next()
166 struct acc_core *core = &cores[u]; in acc_init_bm_ptr() local
168 core->bmfifo.messages = mem + (u + 1U) * ACC_CORE_DMABUF_SIZE; in acc_init_bm_ptr()
169 core->bmfifo.irq_cnt = ov->bmfifo.irq_cnt + (u + 1U); in acc_init_bm_ptr()
176 struct acc_core *core = priv->core; in acc_open() local
185 acc_resetmode_enter(core); in acc_open()
205 acc_set_bits(core, ACC_CORE_OF_CTRL, ctrl); in acc_open()
207 acc_resetmode_leave(core); in acc_open()
211 tx_fifo_status = acc_read32(core, ACC_CORE_OF_TXFIFO_STATUS); in acc_open()
212 core->tx_fifo_head = tx_fifo_status & 0xff; in acc_open()
213 core->tx_fifo_tail = (tx_fifo_status >> 8) & 0xff; in acc_open()
222 struct acc_core *core = priv->core; in acc_close() local
224 acc_clear_bits(core, ACC_CORE_OF_CTRL, in acc_close()
233 acc_resetmode_enter(core); in acc_close()
237 acc_write32(core, ACC_CORE_OF_TX_ABORT_MASK, 0xffff); in acc_close()
240 acc_clear_bits(core, ACC_CORE_OF_CTRL, in acc_close()
250 struct acc_core *core = priv->core; in acc_start_xmit() local
252 u8 tx_fifo_head = core->tx_fifo_head; in acc_start_xmit()
260 /* Access core->tx_fifo_tail only once because it may be changed in acc_start_xmit()
263 fifo_usage = tx_fifo_head - core->tx_fifo_tail; in acc_start_xmit()
265 fifo_usage += core->tx_fifo_size; in acc_start_xmit()
267 if (fifo_usage >= core->tx_fifo_size - 1) { in acc_start_xmit()
268 netdev_err(core->netdev, in acc_start_xmit()
274 if (fifo_usage == core->tx_fifo_size - 2) in acc_start_xmit()
290 can_put_echo_skb(skb, netdev, core->tx_fifo_head, 0); in acc_start_xmit()
292 core->tx_fifo_head = acc_tx_fifo_next(core, tx_fifo_head); in acc_start_xmit()
294 acc_txq_put(core, acc_id, acc_dlc, cf->data); in acc_start_xmit()
303 u32 core_status = acc_read32(priv->core, ACC_CORE_OF_STATUS); in acc_get_berr_counter()
320 acc_read32(priv->core, ACC_CORE_OF_TXFIFO_STATUS); in acc_set_mode()
323 if (hw_fifo_head != priv->core->tx_fifo_head || in acc_set_mode()
324 hw_fifo_head != priv->core->tx_fifo_tail) { in acc_set_mode()
327 priv->core->tx_fifo_tail, in acc_set_mode()
328 priv->core->tx_fifo_head, in acc_set_mode()
332 acc_resetmode_leave(priv->core); in acc_set_mode()
379 acc_write32(priv->core, ACC_CORE_OF_BRP, brp); in acc_set_bittiming()
380 acc_write32(priv->core, ACC_CORE_OF_BTR, btr); in acc_set_bittiming()
396 acc_write32(priv->core, ACC_CORE_OF_BRP, brp); in acc_set_bittiming()
397 acc_write32(priv->core, ACC_CORE_OF_BTR, btr); in acc_set_bittiming()
405 static void handle_core_msg_rxtxdone(struct acc_core *core, in handle_core_msg_rxtxdone() argument
408 struct acc_net_priv *priv = netdev_priv(core->netdev); in handle_core_msg_rxtxdone()
409 struct net_device_stats *stats = &core->netdev->stats; in handle_core_msg_rxtxdone()
413 u8 tx_fifo_tail = core->tx_fifo_tail; in handle_core_msg_rxtxdone()
415 if (core->tx_fifo_head == tx_fifo_tail) { in handle_core_msg_rxtxdone()
416 netdev_warn(core->netdev, in handle_core_msg_rxtxdone()
429 stats->tx_bytes += can_get_echo_skb(core->netdev, tx_fifo_tail, in handle_core_msg_rxtxdone()
432 core->tx_fifo_tail = acc_tx_fifo_next(core, tx_fifo_tail); in handle_core_msg_rxtxdone()
434 netif_wake_queue(core->netdev); in handle_core_msg_rxtxdone()
439 skb = alloc_can_skb(core->netdev, &cf); in handle_core_msg_rxtxdone()
466 static void handle_core_msg_txabort(struct acc_core *core, in handle_core_msg_txabort() argument
469 struct net_device_stats *stats = &core->netdev->stats; in handle_core_msg_txabort()
470 u8 tx_fifo_tail = core->tx_fifo_tail; in handle_core_msg_txabort()
474 while (tx_fifo_tail != core->tx_fifo_head && (abort_mask)) { in handle_core_msg_txabort()
481 can_free_echo_skb(core->netdev, tx_fifo_tail, NULL); in handle_core_msg_txabort()
485 tx_fifo_tail = acc_tx_fifo_next(core, tx_fifo_tail); in handle_core_msg_txabort()
487 core->tx_fifo_tail = tx_fifo_tail; in handle_core_msg_txabort()
489 netdev_warn(core->netdev, "Unhandled aborted messages\n"); in handle_core_msg_txabort()
491 if (!acc_resetmode_entered(core)) in handle_core_msg_txabort()
492 netif_wake_queue(core->netdev); in handle_core_msg_txabort()
495 static void handle_core_msg_overrun(struct acc_core *core, in handle_core_msg_overrun() argument
498 struct acc_net_priv *priv = netdev_priv(core->netdev); in handle_core_msg_overrun()
499 struct net_device_stats *stats = &core->netdev->stats; in handle_core_msg_overrun()
512 skb = alloc_can_err_skb(core->netdev, &cf); in handle_core_msg_overrun()
524 static void handle_core_msg_buserr(struct acc_core *core, in handle_core_msg_buserr() argument
527 struct acc_net_priv *priv = netdev_priv(core->netdev); in handle_core_msg_buserr()
528 struct net_device_stats *stats = &core->netdev->stats; in handle_core_msg_buserr()
561 skb = alloc_can_err_skb(core->netdev, &cf); in handle_core_msg_buserr()
582 handle_core_msg_errstatechange(struct acc_core *core, in handle_core_msg_errstatechange() argument
585 struct acc_net_priv *priv = netdev_priv(core->netdev); in handle_core_msg_errstatechange()
603 netif_wake_queue(core->netdev); in handle_core_msg_errstatechange()
607 skb = alloc_can_err_skb(core->netdev, &cf); in handle_core_msg_errstatechange()
621 can_change_state(core->netdev, cf, tx_state, rx_state); in handle_core_msg_errstatechange()
635 acc_write32(core, ACC_CORE_OF_TX_ABORT_MASK, 0xffff); in handle_core_msg_errstatechange()
636 can_bus_off(core->netdev); in handle_core_msg_errstatechange()
640 static void handle_core_interrupt(struct acc_core *core) in handle_core_interrupt() argument
642 u32 msg_fifo_head = core->bmfifo.local_irq_cnt & 0xff; in handle_core_interrupt()
644 while (core->bmfifo.msg_fifo_tail != msg_fifo_head) { in handle_core_interrupt()
646 &core->bmfifo.messages[core->bmfifo.msg_fifo_tail]; in handle_core_interrupt()
650 handle_core_msg_rxtxdone(core, &msg->rxtxdone); in handle_core_interrupt()
654 handle_core_msg_txabort(core, &msg->txabort); in handle_core_interrupt()
658 handle_core_msg_overrun(core, &msg->overrun); in handle_core_interrupt()
662 handle_core_msg_buserr(core, &msg->buserr); in handle_core_interrupt()
667 handle_core_msg_errstatechange(core, in handle_core_interrupt()
676 core->bmfifo.msg_fifo_tail = in handle_core_interrupt()
677 (core->bmfifo.msg_fifo_tail + 1) & 0xff; in handle_core_interrupt()
685 * @cores: array of core structures
690 * It examines for all cores (the overview module core and the CAN cores)
696 * ACC_OV_OF_BM_IRQ_MASK. This register has for each core a two bit command
705 * For each CAN core with a pending IRQ handle_core_interrupt() handles all
707 * index) is written to the CAN core to acknowledge its handling.
733 struct acc_core *core = &cores[i]; in acc_card_interrupt() local
735 if (READ_ONCE(*core->bmfifo.irq_cnt) != core->bmfifo.local_irq_cnt) { in acc_card_interrupt()
737 core->bmfifo.local_irq_cnt = READ_ONCE(*core->bmfifo.irq_cnt); in acc_card_interrupt()
745 * call handle_{ov|core}_interrupt and then acknowledge the in acc_card_interrupt()
757 struct acc_core *core = &cores[i]; in acc_card_interrupt() local
760 handle_core_interrupt(core); in acc_card_interrupt()
761 acc_write32(core, ACC_OV_OF_BM_IRQ_COUNTER, in acc_card_interrupt()
762 core->bmfifo.local_irq_cnt); in acc_card_interrupt()