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