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>
69 #define SUN4I_REG_MSEL_ADDR 0x0000 /* CAN Mode Select */
70 #define SUN4I_REG_CMD_ADDR 0x0004 /* CAN Command */
71 #define SUN4I_REG_STA_ADDR 0x0008 /* CAN Status */
72 #define SUN4I_REG_INT_ADDR 0x000c /* CAN Interrupt Flag */
73 #define SUN4I_REG_INTEN_ADDR 0x0010 /* CAN Interrupt Enable */
74 #define SUN4I_REG_BTIME_ADDR 0x0014 /* CAN Bus Timing 0 */
75 #define SUN4I_REG_TEWL_ADDR 0x0018 /* CAN Tx Error Warning Limit */
76 #define SUN4I_REG_ERRC_ADDR 0x001c /* CAN Error Counter */
77 #define SUN4I_REG_RMCNT_ADDR 0x0020 /* CAN Receive Message Counter */
78 #define SUN4I_REG_RBUFSA_ADDR 0x0024 /* CAN Receive Buffer Start Address */
79 #define SUN4I_REG_BUF0_ADDR 0x0040 /* CAN Tx/Rx Buffer 0 */
80 #define SUN4I_REG_BUF1_ADDR 0x0044 /* CAN Tx/Rx Buffer 1 */
81 #define SUN4I_REG_BUF2_ADDR 0x0048 /* CAN Tx/Rx Buffer 2 */
82 #define SUN4I_REG_BUF3_ADDR 0x004c /* CAN Tx/Rx Buffer 3 */
83 #define SUN4I_REG_BUF4_ADDR 0x0050 /* CAN Tx/Rx Buffer 4 */
84 #define SUN4I_REG_BUF5_ADDR 0x0054 /* CAN Tx/Rx Buffer 5 */
85 #define SUN4I_REG_BUF6_ADDR 0x0058 /* CAN Tx/Rx Buffer 6 */
86 #define SUN4I_REG_BUF7_ADDR 0x005c /* CAN Tx/Rx Buffer 7 */
87 #define SUN4I_REG_BUF8_ADDR 0x0060 /* CAN Tx/Rx Buffer 8 */
88 #define SUN4I_REG_BUF9_ADDR 0x0064 /* CAN Tx/Rx Buffer 9 */
89 #define SUN4I_REG_BUF10_ADDR 0x0068 /* CAN Tx/Rx Buffer 10 */
90 #define SUN4I_REG_BUF11_ADDR 0x006c /* CAN Tx/Rx Buffer 11 */
91 #define SUN4I_REG_BUF12_ADDR 0x0070 /* CAN Tx/Rx Buffer 12 */
92 #define SUN4I_REG_ACPC_ADDR 0x0040 /* CAN Acceptance Code 0 */
93 #define SUN4I_REG_ACPM_ADDR 0x0044 /* CAN Acceptance Mask 0 */
94 #define SUN4I_REG_RBUF_RBACK_START_ADDR 0x0180 /* CAN transmit buffer start */
95 #define SUN4I_REG_RBUF_RBACK_END_ADDR 0x01b0 /* CAN transmit buffer end */
214 struct can_priv can; member
288 struct can_bittiming *bt = &priv->can.bittiming; in sun4ican_set_bittiming()
295 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) in sun4ican_set_bittiming()
348 if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) in sun4i_can_start()
356 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) in sun4i_can_start()
358 else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) in sun4i_can_start()
373 priv->can.state = CAN_STATE_ERROR_ACTIVE; in sun4i_can_start()
383 priv->can.state = CAN_STATE_STOPPED; in sun4i_can_stop()
405 netdev_err(dev, "starting CAN controller failed!\n"); in sun4ican_set_mode()
418 /* transmit a CAN message
421 * [ can_id ] [flags] [len] [can data (up to 8 bytes]
464 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) in sun4ican_start_xmit()
483 /* create zero'ed CAN frame buffer */ in sun4i_can_rx()
527 enum can_state state = priv->can.state; in sun4i_can_err()
549 /* reset the CAN IP by entering reset mode in sun4i_can_err()
577 priv->can.can_stats.bus_error++; in sun4i_can_err()
617 priv->can.can_stats.arbitration_lost++; in sun4i_can_err()
624 if (state != priv->can.state) { in sun4i_can_err()
631 priv->can.state = state; in sun4i_can_err()
680 netdev_err(dev, "can't allocate buffer - clearing pending interrupts\n"); in sun4i_can_interrupt()
712 netdev_err(dev, "could not deassert CAN reset\n"); in sun4ican_open()
716 /* turn on clocking for CAN peripheral block */ in sun4ican_open()
719 netdev_err(dev, "could not enable CAN peripheral clock\n"); in sun4ican_open()
725 netdev_err(dev, "could not start CAN peripheral\n"); in sun4ican_open()
779 .compatible = "allwinner,sun4i-a10-can",
782 .compatible = "allwinner,sun7i-a20-can",
785 .compatible = "allwinner,sun8i-r40-can",
853 "could not allocate memory for CAN device\n"); in sun4ican_probe()
864 priv->can.clock.freq = clk_get_rate(clk); in sun4ican_probe()
865 priv->can.bittiming_const = &sun4ican_bittiming_const; in sun4ican_probe()
866 priv->can.do_set_mode = sun4ican_set_mode; in sun4ican_probe()
867 priv->can.do_get_berr_counter = sun4ican_get_berr_counter; in sun4ican_probe()
868 priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING | in sun4ican_probe()
912 MODULE_DESCRIPTION("CAN driver for Allwinner SoCs (A10/A20)");