1 | /* $NetBSD: can_link.h,v 1.2 2017/05/27 21:02:56 bouyer Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (c) 2017 The NetBSD Foundation, Inc. |
5 | * All rights reserved. |
6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Manuel Bouyer |
9 | * |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions |
12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. |
18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
31 | |
32 | #ifndef _NETCAN_CAN_LINK_H |
33 | #define _NETCAN_CAN_LINK_H |
34 | |
35 | /* |
36 | * CAN bus link-layer related commands, from the SIOCSDRVSPEC |
37 | */ |
38 | |
39 | /* get timing capabilities from HW */ |
40 | struct can_link_timecaps { |
41 | uint32_t cltc_prop_min; /* prop seg, in tq */ |
42 | uint32_t cltc_prop_max; |
43 | uint32_t cltc_ps1_min; /* phase1 seg, in tq */ |
44 | uint32_t cltc_ps1_max; |
45 | uint32_t cltc_ps2_min; /* phase 2 seg, in tq */ |
46 | uint32_t cltc_ps2_max; |
47 | uint32_t cltc_sjw_max; /* Synchronisation Jump Width */ |
48 | uint32_t cltc_brp_min; /* bit-rate prescaler */ |
49 | uint32_t cltc_brp_max; |
50 | uint32_t cltc_brp_inc; |
51 | uint32_t cltc_clock_freq; /* prescaler input clock, in hz */ |
52 | uint32_t cltc_linkmode_caps; /* link mode, see below */ |
53 | }; |
54 | #define CANGLINKTIMECAP 0 /* get struct can_link_timecaps */ |
55 | |
56 | /* get/set timing parameters */ |
57 | struct can_link_timings { |
58 | uint32_t clt_brp; /* prescaler value */ |
59 | uint32_t clt_prop; /* Propagation segment in tq */ |
60 | uint32_t clt_ps1; /* Phase segment 1 in tq */ |
61 | uint32_t clt_ps2; /* Phase segment 2 in tq */ |
62 | uint32_t clt_sjw; /* Synchronisation jump width in tq */ |
63 | }; |
64 | #define CANGLINKTIMINGS 1 /* get struct can_link_timings */ |
65 | #define CANSLINKTIMINGS 2 /* set struct can_link_timings */ |
66 | |
67 | /* link-level modes */ |
68 | #define CAN_LINKMODE_LOOPBACK 0x01 /* Loopback mode */ |
69 | #define CAN_LINKMODE_LISTENONLY 0x02 /* Listen-only mode */ |
70 | #define CAN_LINKMODE_3SAMPLES 0x04 /* Triple sampling mode */ |
71 | #define CAN_LINKMODE_PRESUME_ACK 0x08 /* Ignore missing CAN ACKs */ |
72 | #define CAN_IFFBITS \ |
73 | "\020\1LOOPBACK\2LISTENONLY\3TRIPLESAMPLE\4PRESUMEACK" |
74 | |
75 | #define CANGLINKMODE 3 /* (uint32_t) get bits */ |
76 | #define CANSLINKMODE 4 /* (uint32_t) set bits */ |
77 | #define CANCLINKMODE 5 /* (uint32_t) clear bits */ |
78 | |
79 | #endif /* _NETCAN_CAN_LINK_H */ |
80 | |
81 | |