1 /**************************************************************************/
2 /* File: constants.h - driver build time constant parameters */
4 /* LinCAN - (Not only) Linux CAN bus driver */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
7 /* Funded by OCERA and FRESCOR IST projects */
8 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl> */
10 /* LinCAN is free software; you can redistribute it and/or modify it */
11 /* under terms of the GNU General Public License as published by the */
12 /* Free Software Foundation; either version 2, or (at your option) any */
13 /* later version. LinCAN is distributed in the hope that it will be */
14 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
15 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* General Public License for more details. You should have received a */
17 /* copy of the GNU General Public License along with LinCAN; see file */
18 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
19 /* Cambridge, MA 02139, USA. */
21 /* To allow use of LinCAN in the compact embedded systems firmware */
22 /* and RT-executives (RTEMS for example), main authors agree with next */
23 /* special exception: */
25 /* Including LinCAN header files in a file, instantiating LinCAN generics */
26 /* or templates, or linking other files with LinCAN objects to produce */
27 /* an application image/executable, does not by itself cause the */
28 /* resulting application image/executable to be covered by */
29 /* the GNU General Public License. */
30 /* This exception does not however invalidate any other reasons */
31 /* why the executable file might be covered by the GNU Public License. */
32 /* Publication of enhanced or derived LinCAN files is required although. */
33 /**************************************************************************/
35 #ifndef __CONSTANTS_H__
36 #define __CONSTANTS_H__
38 /* Device name as it will appear in /proc/devices */
39 #define DEVICE_NAME "can"
41 /* Branch of the driver */
42 #define CAN_DRV_BRANCH (('L'<<24)|('I'<<16)|('N'<<8)|'C')
44 /* Version of the driver */
45 #define CAN_DRV_VER_MAJOR 0
46 #define CAN_DRV_VER_MINOR 3
47 #define CAN_DRV_VER_PATCH 4
48 #define CAN_DRV_VER ((CAN_DRV_VER_MAJOR<<16) | (CAN_DRV_VER_MINOR<<8) | CAN_DRV_VER_PATCH)
50 /* Default driver major number, see /usr/src/linux/Documentation/devices.txt */
53 /* Definition of the maximum number of concurrent supported hardware boards,
54 * chips per board, total number of chips, interrupts and message objects.
55 * Obviously there are no 32 different interrupts, but each chip can have its
56 * own interrupt so we have to check for it MAX_IRQ == MAX_TOT_CHIPS times.
58 #define MAX_HW_CARDS 8
59 #define MAX_HW_CHIPS 4
60 #define MAX_TOT_CHIPS (MAX_HW_CHIPS*MAX_HW_CARDS)
61 #define MAX_TOT_CHIPS_STR 32 /* must be explicit for MODULE_PARM */
63 #define MAX_MSGOBJS 32
64 #define MAX_TOT_MSGOBJS (MAX_TOT_CHIPS*MAX_MSGOBJS)
65 #define MAX_BUF_LENGTH 64
66 //#define MAX_BUF_LENGTH 4
69 /* These flags can be used for the msgobj_t structure flags data entry */
70 #define MSGOBJ_OPENED_b 0
71 #define MSGOBJ_TX_REQUEST_b 1
72 #define MSGOBJ_TX_LOCK_b 2
73 #define MSGOBJ_IRQ_REQUEST_b 3
74 #define MSGOBJ_WORKER_WAKE_b 4
75 #define MSGOBJ_FILTCH_REQUEST_b 5
76 #define MSGOBJ_RX_MODE_b 6
77 #define MSGOBJ_RX_MODE_EXT_b 7
78 #define MSGOBJ_TX_PENDING_b 8
80 #define MSGOBJ_OPENED (1<<MSGOBJ_OPENED_b)
81 #define MSGOBJ_TX_REQUEST (1<<MSGOBJ_TX_REQUEST_b)
82 #define MSGOBJ_TX_LOCK (1<<MSGOBJ_TX_LOCK_b)
83 #define MSGOBJ_IRQ_REQUEST (1<<MSGOBJ_IRQ_REQUEST_b)
84 #define MSGOBJ_WORKER_WAKE (1<<MSGOBJ_WORKER_WAKE_b)
85 #define MSGOBJ_FILTCH_REQUEST (1<<MSGOBJ_FILTCH_REQUEST_b)
86 #define MSGOBJ_RX_MODE (1<<MSGOBJ_RX_MODE_b)
87 #define MSGOBJ_RX_MODE_EXT (1<<MSGOBJ_RX_MODE_EXT_b)
88 #define MSGOBJ_TX_PENDING (1<<MSGOBJ_TX_PENDING_b)
90 #define can_msgobj_test_fl(obj,obj_fl) \
91 test_bit(MSGOBJ_##obj_fl##_b,&(obj)->obj_flags)
92 #define can_msgobj_set_fl(obj,obj_fl) \
93 set_bit(MSGOBJ_##obj_fl##_b,&(obj)->obj_flags)
94 #define can_msgobj_clear_fl(obj,obj_fl) \
95 clear_bit(MSGOBJ_##obj_fl##_b,&(obj)->obj_flags)
96 #define can_msgobj_test_and_set_fl(obj,obj_fl) \
97 test_and_set_bit(MSGOBJ_##obj_fl##_b,&(obj)->obj_flags)
98 #define can_msgobj_test_and_clear_fl(obj,obj_fl) \
99 test_and_clear_bit(MSGOBJ_##obj_fl##_b,&(obj)->obj_flags)
102 /* These flags can be used for the canchip_t structure flags data entry */
103 #define CHIP_ATTACHED (1<<0) /* chip is attached to HW, release_chip() has to be called */
104 #define CHIP_CONFIGURED (1<<1) /* chip is configured and prepared for communication */
105 #define CHIP_SEGMENTED (1<<2) /* segmented access, ex: i82527 with 16 byte window*/
106 #define CHIP_IRQ_SETUP (1<<3) /* IRQ handler has been set */
107 #define CHIP_IRQ_PCI (1<<4) /* chip is on PCI board and uses PCI interrupt */
108 #define CHIP_IRQ_VME (1<<5) /* interrupt is VME bus and requires VME bridge */
109 #define CHIP_IRQ_CUSTOM (1<<6) /* custom interrupt provided by board or chip code */
110 #define CHIP_IRQ_FAST (1<<7) /* interrupt handler only schedules postponed processing */
112 #define CHIP_MAX_IRQLOOP 1000
114 /* System independent defines of IRQ handled state */
115 #define CANCHIP_IRQ_NONE 0
116 #define CANCHIP_IRQ_HANDLED 1
117 #define CANCHIP_IRQ_ACCEPTED 2
118 #define CANCHIP_IRQ_STUCK 3
120 /* These flags can be used for the candevices_t structure flags data entry */
121 #define CANDEV_PROGRAMMABLE_IRQ (1<<0)
122 #define CANDEV_IO_RESERVED (1<<1)
124 /* Next flags are specific for struct canuser_t applications connection */
125 #define CANUSER_RTL_CLIENT (1<<0)
126 #define CANUSER_RTL_MEM (1<<1)
127 #define CANUSER_DIRECT (1<<2)
135 /* Flags for baud_rate function */
136 #define BTR1_SAM (1<<1)