Lines Matching +full:clkout +full:- +full:disable
1 // SPDX-License-Identifier: GPL-2.0-only
43 * 2. Support of silent (listen-only) mode.
46 * Details are available from Bosch's "CC770_Product_Info_2007-01.pdf",
58 * "msgobj15_eff". If not equal 0, it will receive 29-bit EFF frames,
63 MODULE_PARM_DESC(msgobj15_eff, "Extended 29-bit frames for message object 15 "
64 "(default: 11-bit standard frames)");
102 return MSGOBJ_LAST + 2 - intid; in intid2obj()
112 for (o = 0; o < ARRAY_SIZE(priv->obj_flags); o++) { in enable_all_objs()
113 obj_flags = priv->obj_flags[o]; in enable_all_objs()
121 if (priv->control_normal_mode & CTRL_EAF) { in enable_all_objs()
173 for (o = 0; o < ARRAY_SIZE(priv->obj_flags); o++) { in disable_all_objs()
176 if (priv->obj_flags[o] & CC770_OBJ_FLAG_RX) { in disable_all_objs()
177 if (o > 0 && priv->control_normal_mode & CTRL_EAF) in disable_all_objs()
202 /* Enable configuration and puts chip in bus-off, disable interrupts */ in set_reset_mode()
205 priv->can.state = CAN_STATE_STOPPED; in set_reset_mode()
213 /* Disable all used message objects */ in set_reset_mode()
224 /* Clear status register and pre-set last error code */ in set_normal_mode()
231 * Clear bus-off, interrupts only for errors, in set_normal_mode()
234 cc770_write_reg(priv, control, priv->control_normal_mode); in set_normal_mode()
236 priv->can.state = CAN_STATE_ERROR_ACTIVE; in set_normal_mode()
243 /* Enable configuration and put chip in bus-off, disable interrupts */ in chipset_init()
246 /* Set CLKOUT divider and slew rates */ in chipset_init()
247 cc770_write_reg(priv, clkout, priv->clkout); in chipset_init()
249 /* Configure CPU interface / CLKOUT enable */ in chipset_init()
250 cc770_write_reg(priv, cpu_interface, priv->cpu_interface); in chipset_init()
253 cc770_write_reg(priv, bus_config, priv->bus_config); in chipset_init()
293 /* Enable configuration, put chip in bus-off, disable ints */ in cc770_probe_chip()
295 /* Configure cpu interface / CLKOUT disable */ in cc770_probe_chip()
296 cc770_write_reg(priv, cpu_interface, priv->cpu_interface); in cc770_probe_chip()
304 priv->reg_base); in cc770_probe_chip()
305 return -ENODEV; in cc770_probe_chip()
316 priv->reg_base); in cc770_probe_chip()
317 return -ENODEV; in cc770_probe_chip()
322 priv->control_normal_mode |= CTRL_EAF; in cc770_probe_chip()
332 if (priv->can.state != CAN_STATE_STOPPED) in cc770_start()
348 return -EOPNOTSUPP; in cc770_set_mode()
357 struct can_bittiming *bt = &priv->can.bittiming; in cc770_set_bittiming()
360 btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); in cc770_set_bittiming()
361 btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) | in cc770_set_bittiming()
362 (((bt->phase_seg2 - 1) & 0x7) << 4); in cc770_set_bittiming()
363 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in cc770_set_bittiming()
379 bec->txerr = cc770_read_reg(priv, tx_error_counter); in cc770_get_berr_counter()
380 bec->rxerr = cc770_read_reg(priv, rx_error_counter); in cc770_get_berr_counter()
388 struct can_frame *cf = (struct can_frame *)priv->tx_skb->data; in cc770_tx()
393 dlc = cf->can_dlc; in cc770_tx()
394 id = cf->can_id; in cc770_tx()
395 rtr = cf->can_id & CAN_RTR_FLAG ? 0 : MSGCFG_DIR; in cc770_tx()
418 cc770_write_reg(priv, msgobj[mo].data[i], cf->data[i]); in cc770_tx()
442 priv->tx_skb = skb; in cc770_start_xmit()
451 struct net_device_stats *stats = &dev->stats; in cc770_rx()
470 cf->can_id = CAN_RTR_FLAG; in cc770_rx()
472 cf->can_id |= CAN_EFF_FLAG; in cc770_rx()
473 cf->can_dlc = 0; in cc770_rx()
488 cf->can_id = id; in cc770_rx()
489 cf->can_dlc = get_can_dlc((config & 0xf0) >> 4); in cc770_rx()
490 for (i = 0; i < cf->can_dlc; i++) in cc770_rx()
491 cf->data[i] = cc770_read_reg(priv, msgobj[mo].data[i]); in cc770_rx()
494 stats->rx_packets++; in cc770_rx()
495 stats->rx_bytes += cf->can_dlc; in cc770_rx()
502 struct net_device_stats *stats = &dev->stats; in cc770_err()
511 return -ENOMEM; in cc770_err()
514 if (priv->control_normal_mode & CTRL_EAF) { in cc770_err()
515 cf->data[6] = cc770_read_reg(priv, tx_error_counter); in cc770_err()
516 cf->data[7] = cc770_read_reg(priv, rx_error_counter); in cc770_err()
520 /* Disable interrupts */ in cc770_err()
522 cf->can_id |= CAN_ERR_BUSOFF; in cc770_err()
523 priv->can.state = CAN_STATE_BUS_OFF; in cc770_err()
524 priv->can.can_stats.bus_off++; in cc770_err()
527 cf->can_id |= CAN_ERR_CRTL; in cc770_err()
529 if (cf->data[7] > 127) { in cc770_err()
530 cf->data[1] = CAN_ERR_CRTL_RX_PASSIVE | in cc770_err()
532 priv->can.state = CAN_STATE_ERROR_PASSIVE; in cc770_err()
533 priv->can.can_stats.error_passive++; in cc770_err()
535 cf->data[1] = CAN_ERR_CRTL_RX_WARNING | in cc770_err()
537 priv->can.state = CAN_STATE_ERROR_WARNING; in cc770_err()
538 priv->can.can_stats.error_warning++; in cc770_err()
542 cf->can_id |= CAN_ERR_PROT; in cc770_err()
543 cf->data[2] = CAN_ERR_PROT_ACTIVE; in cc770_err()
544 priv->can.state = CAN_STATE_ERROR_ACTIVE; in cc770_err()
550 cf->can_id |= CAN_ERR_ACK; in cc770_err()
552 cf->can_id |= CAN_ERR_PROT; in cc770_err()
555 cf->data[2] |= CAN_ERR_PROT_STUFF; in cc770_err()
558 cf->data[2] |= CAN_ERR_PROT_FORM; in cc770_err()
561 cf->data[2] |= CAN_ERR_PROT_BIT1; in cc770_err()
564 cf->data[2] |= CAN_ERR_PROT_BIT0; in cc770_err()
567 cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; in cc770_err()
574 stats->rx_packets++; in cc770_err()
575 stats->rx_bytes += cf->can_dlc; in cc770_err()
602 struct net_device_stats *stats = &dev->stats; in cc770_rx_interrupt()
607 while (n--) { in cc770_rx_interrupt()
612 if (priv->control_normal_mode & CTRL_EAF) { in cc770_rx_interrupt()
622 stats->rx_over_errors++; in cc770_rx_interrupt()
623 stats->rx_errors++; in cc770_rx_interrupt()
647 while (n--) { in cc770_rtr_interrupt()
667 struct net_device_stats *stats = &dev->stats; in cc770_tx_interrupt()
679 if (unlikely(!priv->tx_skb)) { in cc770_tx_interrupt()
685 stats->rx_over_errors++; in cc770_tx_interrupt()
686 stats->rx_errors++; in cc770_tx_interrupt()
701 cf = (struct can_frame *)priv->tx_skb->data; in cc770_tx_interrupt()
702 stats->tx_bytes += cf->can_dlc; in cc770_tx_interrupt()
703 stats->tx_packets++; in cc770_tx_interrupt()
705 can_put_echo_skb(priv->tx_skb, dev, 0); in cc770_tx_interrupt()
707 priv->tx_skb = NULL; in cc770_tx_interrupt()
720 if (priv->can.state == CAN_STATE_STOPPED) in cc770_interrupt()
723 if (priv->pre_irq) in cc770_interrupt()
724 priv->pre_irq(priv); in cc770_interrupt()
734 /* Exit in case of bus-off */ in cc770_interrupt()
746 if (priv->obj_flags[o] & CC770_OBJ_FLAG_RTR) in cc770_interrupt()
748 else if (priv->obj_flags[o] & CC770_OBJ_FLAG_RX) in cc770_interrupt()
755 if (priv->post_irq) in cc770_interrupt()
756 priv->post_irq(priv); in cc770_interrupt()
777 err = request_irq(dev->irq, &cc770_interrupt, priv->irq_flags, in cc770_open()
778 dev->name, dev); in cc770_open()
781 return -EAGAIN; in cc770_open()
797 free_irq(dev->irq, dev); in cc770_close()
815 priv->dev = dev; in alloc_cc770dev()
816 priv->can.bittiming_const = &cc770_bittiming_const; in alloc_cc770dev()
817 priv->can.do_set_bittiming = cc770_set_bittiming; in alloc_cc770dev()
818 priv->can.do_set_mode = cc770_set_mode; in alloc_cc770dev()
819 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; in alloc_cc770dev()
820 priv->tx_skb = NULL; in alloc_cc770dev()
822 memcpy(priv->obj_flags, cc770_obj_flags, sizeof(cc770_obj_flags)); in alloc_cc770dev()
825 priv->priv = (void *)priv + sizeof(struct cc770_priv); in alloc_cc770dev()
853 dev->netdev_ops = &cc770_netdev_ops; in register_cc770dev()
855 dev->flags |= IFF_ECHO; /* we support local echo */ in register_cc770dev()
858 if (!i82527_compat && priv->control_normal_mode & CTRL_EAF) { in register_cc770dev()
859 priv->can.do_get_berr_counter = cc770_get_berr_counter; in register_cc770dev()
860 priv->control_normal_mode = CTRL_IE | CTRL_EAF | CTRL_EIE; in register_cc770dev()
863 priv->control_normal_mode = CTRL_IE | CTRL_EIE; in register_cc770dev()