Lines Matching +full:clkout +full:- +full:fmt

1 // SPDX-License-Identifier: GPL-2.0-only
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt argument
44 * 2. Support of silent (listen-only) mode.
47 * Details are available from Bosch's "CC770_Product_Info_2007-01.pdf",
59 * "msgobj15_eff". If not equal 0, it will receive 29-bit EFF frames,
64 MODULE_PARM_DESC(msgobj15_eff, "Extended 29-bit frames for message object 15 "
65 "(default: 11-bit standard frames)");
103 return MSGOBJ_LAST + 2 - intid; in intid2obj()
113 for (o = 0; o < ARRAY_SIZE(priv->obj_flags); o++) { in enable_all_objs()
114 obj_flags = priv->obj_flags[o]; in enable_all_objs()
122 if (priv->control_normal_mode & CTRL_EAF) { in enable_all_objs()
174 for (o = 0; o < ARRAY_SIZE(priv->obj_flags); o++) { in disable_all_objs()
177 if (priv->obj_flags[o] & CC770_OBJ_FLAG_RX) { in disable_all_objs()
178 if (o > 0 && priv->control_normal_mode & CTRL_EAF) in disable_all_objs()
203 /* Enable configuration and puts chip in bus-off, disable interrupts */ in set_reset_mode()
206 priv->can.state = CAN_STATE_STOPPED; in set_reset_mode()
225 /* Clear status register and pre-set last error code */ in set_normal_mode()
232 * Clear bus-off, interrupts only for errors, in set_normal_mode()
235 cc770_write_reg(priv, control, priv->control_normal_mode); in set_normal_mode()
237 priv->can.state = CAN_STATE_ERROR_ACTIVE; in set_normal_mode()
244 /* Enable configuration and put chip in bus-off, disable interrupts */ in chipset_init()
247 /* Set CLKOUT divider and slew rates */ in chipset_init()
248 cc770_write_reg(priv, clkout, priv->clkout); in chipset_init()
250 /* Configure CPU interface / CLKOUT enable */ in chipset_init()
251 cc770_write_reg(priv, cpu_interface, priv->cpu_interface); in chipset_init()
254 cc770_write_reg(priv, bus_config, priv->bus_config); in chipset_init()
294 /* Enable configuration, put chip in bus-off, disable ints */ in cc770_probe_chip()
296 /* Configure cpu interface / CLKOUT disable */ in cc770_probe_chip()
297 cc770_write_reg(priv, cpu_interface, priv->cpu_interface); in cc770_probe_chip()
305 priv->reg_base); in cc770_probe_chip()
306 return -ENODEV; in cc770_probe_chip()
317 priv->reg_base); in cc770_probe_chip()
318 return -ENODEV; in cc770_probe_chip()
323 priv->control_normal_mode |= CTRL_EAF; in cc770_probe_chip()
333 if (priv->can.state != CAN_STATE_STOPPED) in cc770_start()
349 return -EOPNOTSUPP; in cc770_set_mode()
358 struct can_bittiming *bt = &priv->can.bittiming; in cc770_set_bittiming()
361 btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); in cc770_set_bittiming()
362 btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) | in cc770_set_bittiming()
363 (((bt->phase_seg2 - 1) & 0x7) << 4); in cc770_set_bittiming()
364 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in cc770_set_bittiming()
380 bec->txerr = cc770_read_reg(priv, tx_error_counter); in cc770_get_berr_counter()
381 bec->rxerr = cc770_read_reg(priv, rx_error_counter); in cc770_get_berr_counter()
389 struct can_frame *cf = (struct can_frame *)priv->tx_skb->data; in cc770_tx()
394 dlc = cf->len; in cc770_tx()
395 id = cf->can_id; in cc770_tx()
396 rtr = cf->can_id & CAN_RTR_FLAG ? 0 : MSGCFG_DIR; in cc770_tx()
419 cc770_write_reg(priv, msgobj[mo].data[i], cf->data[i]); in cc770_tx()
443 priv->tx_skb = skb; in cc770_start_xmit()
452 struct net_device_stats *stats = &dev->stats; in cc770_rx()
471 cf->can_id = CAN_RTR_FLAG; in cc770_rx()
473 cf->can_id |= CAN_EFF_FLAG; in cc770_rx()
474 cf->len = 0; in cc770_rx()
489 cf->can_id = id; in cc770_rx()
490 cf->len = can_cc_dlc2len((config & 0xf0) >> 4); in cc770_rx()
491 for (i = 0; i < cf->len; i++) in cc770_rx()
492 cf->data[i] = cc770_read_reg(priv, msgobj[mo].data[i]); in cc770_rx()
494 stats->rx_bytes += cf->len; in cc770_rx()
496 stats->rx_packets++; in cc770_rx()
512 return -ENOMEM; in cc770_err()
515 if (priv->control_normal_mode & CTRL_EAF) { in cc770_err()
516 cf->can_id |= CAN_ERR_CNT; in cc770_err()
517 cf->data[6] = cc770_read_reg(priv, tx_error_counter); in cc770_err()
518 cf->data[7] = cc770_read_reg(priv, rx_error_counter); in cc770_err()
524 cf->can_id |= CAN_ERR_BUSOFF; in cc770_err()
525 priv->can.state = CAN_STATE_BUS_OFF; in cc770_err()
526 priv->can.can_stats.bus_off++; in cc770_err()
529 cf->can_id |= CAN_ERR_CRTL; in cc770_err()
531 if (cf->data[7] > 127) { in cc770_err()
532 cf->data[1] = CAN_ERR_CRTL_RX_PASSIVE | in cc770_err()
534 priv->can.state = CAN_STATE_ERROR_PASSIVE; in cc770_err()
535 priv->can.can_stats.error_passive++; in cc770_err()
537 cf->data[1] = CAN_ERR_CRTL_RX_WARNING | in cc770_err()
539 priv->can.state = CAN_STATE_ERROR_WARNING; in cc770_err()
540 priv->can.can_stats.error_warning++; in cc770_err()
544 cf->can_id |= CAN_ERR_PROT; in cc770_err()
545 cf->data[2] = CAN_ERR_PROT_ACTIVE; in cc770_err()
546 priv->can.state = CAN_STATE_ERROR_ACTIVE; in cc770_err()
552 cf->can_id |= CAN_ERR_ACK; in cc770_err()
554 cf->can_id |= CAN_ERR_PROT; in cc770_err()
557 cf->data[2] |= CAN_ERR_PROT_STUFF; in cc770_err()
560 cf->data[2] |= CAN_ERR_PROT_FORM; in cc770_err()
563 cf->data[2] |= CAN_ERR_PROT_BIT1; in cc770_err()
566 cf->data[2] |= CAN_ERR_PROT_BIT0; in cc770_err()
569 cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 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()
678 if (unlikely(!priv->tx_skb)) { in cc770_tx_interrupt()
684 stats->rx_over_errors++; in cc770_tx_interrupt()
685 stats->rx_errors++; in cc770_tx_interrupt()
700 can_put_echo_skb(priv->tx_skb, dev, 0, 0); in cc770_tx_interrupt()
701 stats->tx_bytes += can_get_echo_skb(dev, 0, NULL); in cc770_tx_interrupt()
702 stats->tx_packets++; in cc770_tx_interrupt()
703 priv->tx_skb = NULL; in cc770_tx_interrupt()
716 if (priv->can.state == CAN_STATE_STOPPED) in cc770_interrupt()
719 if (priv->pre_irq) in cc770_interrupt()
720 priv->pre_irq(priv); in cc770_interrupt()
730 /* Exit in case of bus-off */ in cc770_interrupt()
742 if (priv->obj_flags[o] & CC770_OBJ_FLAG_RTR) in cc770_interrupt()
744 else if (priv->obj_flags[o] & CC770_OBJ_FLAG_RX) in cc770_interrupt()
751 if (priv->post_irq) in cc770_interrupt()
752 priv->post_irq(priv); in cc770_interrupt()
773 err = request_irq(dev->irq, &cc770_interrupt, priv->irq_flags, in cc770_open()
774 dev->name, dev); in cc770_open()
777 return -EAGAIN; in cc770_open()
793 free_irq(dev->irq, dev); in cc770_close()
811 priv->dev = dev; in alloc_cc770dev()
812 priv->can.bittiming_const = &cc770_bittiming_const; in alloc_cc770dev()
813 priv->can.do_set_bittiming = cc770_set_bittiming; in alloc_cc770dev()
814 priv->can.do_set_mode = cc770_set_mode; in alloc_cc770dev()
815 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; in alloc_cc770dev()
816 priv->tx_skb = NULL; in alloc_cc770dev()
818 memcpy(priv->obj_flags, cc770_obj_flags, sizeof(cc770_obj_flags)); in alloc_cc770dev()
821 priv->priv = (void *)priv + sizeof(struct cc770_priv); in alloc_cc770dev()
853 dev->netdev_ops = &cc770_netdev_ops; in register_cc770dev()
854 dev->ethtool_ops = &cc770_ethtool_ops; in register_cc770dev()
856 dev->flags |= IFF_ECHO; /* we support local echo */ in register_cc770dev()
859 if (!i82527_compat && priv->control_normal_mode & CTRL_EAF) { in register_cc770dev()
860 priv->can.do_get_berr_counter = cc770_get_berr_counter; in register_cc770dev()
861 priv->control_normal_mode = CTRL_IE | CTRL_EAF | CTRL_EIE; in register_cc770dev()
864 priv->control_normal_mode = CTRL_IE | CTRL_EIE; in register_cc770dev()