Lines Matching full:can

2  * sun4i_can.c - CAN bus controller driver for Allwinner SUN4I&SUN7I based SoCs
51 #include <linux/can.h>
52 #include <linux/can/dev.h>
53 #include <linux/can/error.h>
68 #define SUN4I_REG_MSEL_ADDR 0x0000 /* CAN Mode Select */
69 #define SUN4I_REG_CMD_ADDR 0x0004 /* CAN Command */
70 #define SUN4I_REG_STA_ADDR 0x0008 /* CAN Status */
71 #define SUN4I_REG_INT_ADDR 0x000c /* CAN Interrupt Flag */
72 #define SUN4I_REG_INTEN_ADDR 0x0010 /* CAN Interrupt Enable */
73 #define SUN4I_REG_BTIME_ADDR 0x0014 /* CAN Bus Timing 0 */
74 #define SUN4I_REG_TEWL_ADDR 0x0018 /* CAN Tx Error Warning Limit */
75 #define SUN4I_REG_ERRC_ADDR 0x001c /* CAN Error Counter */
76 #define SUN4I_REG_RMCNT_ADDR 0x0020 /* CAN Receive Message Counter */
77 #define SUN4I_REG_RBUFSA_ADDR 0x0024 /* CAN Receive Buffer Start Address */
78 #define SUN4I_REG_BUF0_ADDR 0x0040 /* CAN Tx/Rx Buffer 0 */
79 #define SUN4I_REG_BUF1_ADDR 0x0044 /* CAN Tx/Rx Buffer 1 */
80 #define SUN4I_REG_BUF2_ADDR 0x0048 /* CAN Tx/Rx Buffer 2 */
81 #define SUN4I_REG_BUF3_ADDR 0x004c /* CAN Tx/Rx Buffer 3 */
82 #define SUN4I_REG_BUF4_ADDR 0x0050 /* CAN Tx/Rx Buffer 4 */
83 #define SUN4I_REG_BUF5_ADDR 0x0054 /* CAN Tx/Rx Buffer 5 */
84 #define SUN4I_REG_BUF6_ADDR 0x0058 /* CAN Tx/Rx Buffer 6 */
85 #define SUN4I_REG_BUF7_ADDR 0x005c /* CAN Tx/Rx Buffer 7 */
86 #define SUN4I_REG_BUF8_ADDR 0x0060 /* CAN Tx/Rx Buffer 8 */
87 #define SUN4I_REG_BUF9_ADDR 0x0064 /* CAN Tx/Rx Buffer 9 */
88 #define SUN4I_REG_BUF10_ADDR 0x0068 /* CAN Tx/Rx Buffer 10 */
89 #define SUN4I_REG_BUF11_ADDR 0x006c /* CAN Tx/Rx Buffer 11 */
90 #define SUN4I_REG_BUF12_ADDR 0x0070 /* CAN Tx/Rx Buffer 12 */
91 #define SUN4I_REG_ACPC_ADDR 0x0040 /* CAN Acceptance Code 0 */
92 #define SUN4I_REG_ACPM_ADDR 0x0044 /* CAN Acceptance Mask 0 */
93 #define SUN4I_REG_ACPC_ADDR_D1 0x0028 /* CAN Acceptance Code 0 on the D1 */
94 #define SUN4I_REG_ACPM_ADDR_D1 0x002C /* CAN Acceptance Mask 0 on the D1 */
95 #define SUN4I_REG_RBUF_RBACK_START_ADDR 0x0180 /* CAN transmit buffer start */
96 #define SUN4I_REG_RBUF_RBACK_END_ADDR 0x01b0 /* CAN transmit buffer end */
217 struct can_priv can; member
292 struct can_bittiming *bt = &priv->can.bittiming; in sun4ican_set_bittiming()
299 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in sun4ican_set_bittiming()
352 if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) in sun4i_can_start()
360 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) in sun4i_can_start()
362 else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) in sun4i_can_start()
377 priv->can.state = CAN_STATE_ERROR_ACTIVE; in sun4i_can_start()
387 priv->can.state = CAN_STATE_STOPPED; in sun4i_can_stop()
409 netdev_err(dev, "starting CAN controller failed!\n"); in sun4ican_set_mode()
422 /* transmit a CAN message
425 * [ can_id ] [flags] [len] [can data (up to 8 bytes]
468 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) in sun4ican_start_xmit()
487 /* create zero'ed CAN frame buffer */ in sun4i_can_rx()
531 enum can_state state = priv->can.state; in sun4i_can_err()
553 /* reset the CAN IP by entering reset mode in sun4i_can_err()
581 priv->can.can_stats.bus_error++; in sun4i_can_err()
621 priv->can.can_stats.arbitration_lost++; in sun4i_can_err()
628 if (state != priv->can.state) { in sun4i_can_err()
635 priv->can.state = state; in sun4i_can_err()
684 netdev_err(dev, "can't allocate buffer - clearing pending interrupts\n"); in sun4i_can_interrupt()
716 netdev_err(dev, "could not deassert CAN reset\n"); in sun4ican_open()
720 /* turn on clocking for CAN peripheral block */ in sun4ican_open()
723 netdev_err(dev, "could not enable CAN peripheral clock\n"); in sun4ican_open()
729 netdev_err(dev, "could not start CAN peripheral\n"); in sun4ican_open()
790 .compatible = "allwinner,sun4i-a10-can",
793 .compatible = "allwinner,sun7i-a20-can",
796 .compatible = "allwinner,sun8i-r40-can",
799 .compatible = "allwinner,sun20i-d1-can",
865 "could not allocate memory for CAN device\n"); in sun4ican_probe()
876 priv->can.clock.freq = clk_get_rate(clk); in sun4ican_probe()
877 priv->can.bittiming_const = &sun4ican_bittiming_const; in sun4ican_probe()
878 priv->can.do_set_mode = sun4ican_set_mode; in sun4ican_probe()
879 priv->can.do_get_berr_counter = sun4ican_get_berr_counter; in sun4ican_probe()
880 priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING | in sun4ican_probe()
925 MODULE_DESCRIPTION("CAN driver for Allwinner SoCs (A10/A20/D1)");