1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* CAN bus driver for Bosch M_CAN controller
3 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
9 #include <linux/can/core.h>
10 #include <linux/can/led.h>
11 #include <linux/completion.h>
12 #include <linux/device.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/freezer.h>
15 #include <linux/slab.h>
16 #include <linux/uaccess.h>
17 #include <linux/clk.h>
18 #include <linux/delay.h>
19 #include <linux/interrupt.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/netdevice.h>
25 #include <linux/of_device.h>
26 #include <linux/pm_runtime.h>
27 #include <linux/iopoll.h>
28 #include <linux/can/dev.h>
29 #include <linux/pinctrl/consumer.h>
31 /* m_can lec values */
54 /* address offset and element number for each FIFO/Buffer in the Message RAM */
60 struct m_can_classdev;
62 /* Device specific call backs */
63 int (*clear_interrupts)(struct m_can_classdev *cdev);
64 u32 (*read_reg)(struct m_can_classdev *cdev, int reg);
65 int (*write_reg)(struct m_can_classdev *cdev, int reg, int val);
66 u32 (*read_fifo)(struct m_can_classdev *cdev, int addr_offset);
67 int (*write_fifo)(struct m_can_classdev *cdev, int addr_offset,
69 int (*init)(struct m_can_classdev *cdev);
72 struct m_can_classdev {
74 struct napi_struct napi;
75 struct net_device *net;
80 struct workqueue_struct *tx_wq;
81 struct work_struct tx_work;
82 struct sk_buff *tx_skb;
84 struct can_bittiming_const *bit_timing;
85 struct can_bittiming_const *data_timing;
87 struct m_can_ops *ops;
98 struct mram_cfg mcfg[MRAM_CFG_NUM];
101 struct m_can_classdev *m_can_class_allocate_dev(struct device *dev);
102 void m_can_class_free_dev(struct net_device *net);
103 int m_can_class_register(struct m_can_classdev *cdev);
104 void m_can_class_unregister(struct m_can_classdev *cdev);
105 int m_can_class_get_clocks(struct m_can_classdev *cdev);
106 void m_can_init_ram(struct m_can_classdev *priv);
107 void m_can_config_endisable(struct m_can_classdev *priv, bool enable);
109 int m_can_class_suspend(struct device *dev);
110 int m_can_class_resume(struct device *dev);
111 #endif /* _CAN_M_H_ */