Xenomai 3.3.2
Loading...
Searching...
No Matches
rtcan_peak_canfd_user.h
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * CAN driver for PEAK System micro-CAN based adapters.
4 *
5 * Copyright (C) 2001-2021 PEAK System-Technik GmbH
6 * Copyright (C) 2019-2021 Stephane Grosjean <s.grosjean@peak-system.com>
7 */
8#ifndef PEAK_CANFD_USER_H
9#define PEAK_CANFD_USER_H
10
11#include <linux/can/dev/peak_canfd.h>
12
13#define CAN_MAX_DLC 8
14#define get_can_dlc(i) (min_t(__u8, (i), CAN_MAX_DLC))
15
16struct peak_berr_counter {
17 __u16 txerr;
18 __u16 rxerr;
19};
20
21/* data structure private to each uCAN interface */
22struct peak_canfd_priv {
23 struct rtcan_device *rdev; /* RTCAN device */
24 int index; /* channel index */
25
26 struct peak_berr_counter bec;
27
28 int cmd_len;
29 void *cmd_buffer;
30 int cmd_maxlen;
31
32 int (*pre_cmd)(struct peak_canfd_priv *priv);
33 int (*write_cmd)(struct peak_canfd_priv *priv);
34 int (*post_cmd)(struct peak_canfd_priv *priv);
35
36 int (*enable_tx_path)(struct peak_canfd_priv *priv);
37 void *(*alloc_tx_msg)(struct peak_canfd_priv *priv, u16 msg_size,
38 int *room_left);
39 int (*write_tx_msg)(struct peak_canfd_priv *priv,
40 struct pucan_tx_msg *msg);
41};
42
43struct rtcan_device *alloc_peak_canfd_dev(int sizeof_priv, int index);
44void rtcan_peak_pciefd_remove_proc(struct rtcan_device *rdev);
45int rtcan_peak_pciefd_create_proc(struct rtcan_device *rdev);
46
47int peak_canfd_handle_msg(struct peak_canfd_priv *priv,
48 struct pucan_rx_msg *msg);
49int peak_canfd_handle_msgs_list(struct peak_canfd_priv *priv,
50 struct pucan_rx_msg *rx_msg, int rx_count);
51#endif