]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/app/usbcan/can/main.h
embedded: support access to the chip register wider then 8-bit.
[lincan.git] / embedded / app / usbcan / can / main.h
1 /**************************************************************************/
2 /* File: main.h - the CAN driver basic data structures and functions      */
3 /*                                                                        */
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>      */
9 /*                                                                        */
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.                                              */
20 /*                                                                        */
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:                                                     */
24 /*                                                                        */
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 /**************************************************************************/
34
35 #ifndef _CAN_MAIN_H
36 #define _CAN_MAIN_H
37
38 #include "./can.h"
39 #include "./constants.h"
40 #include "./ul_listbase.h"
41 #include "./can_sysdep.h"
42 #include "./can_queue.h"
43 #include "./errno.h"
44
45 #ifdef CAN_DEBUG
46         #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "USBCAN(debug): " fmt,\
47         ##args)
48 #else
49         #define DEBUGMSG(fmt,args...)
50 #endif
51
52 #define CANMSG(fmt,args...) can_printk(KERN_ERR "USBCAN: " fmt,##args)
53
54
55 extern can_spinlock_t canuser_manipulation_lock;
56
57 /**
58  * struct canhardware_t - structure representing pointers to all CAN boards
59  * @nr_boards: number of present boards
60  * @rtr_queue: RTR - remote transmission request queue (expect some changes there)
61  * @rtr_lock: locking for RTR queue
62  * @candevice: array of pointers to CAN devices/boards
63  */
64 struct canhardware_t {
65         int nr_boards;
66         struct rtr_id *rtr_queue;
67         can_spinlock_t rtr_lock;
68         struct candevice_t *candevice[MAX_HW_CARDS];
69 };
70
71 /**
72  * struct candevice_t - CAN device/board structure
73  * @hwname: text string with board type
74  * @candev_idx: board index in canhardware_t.candevice[]
75  * @io_addr: IO/physical MEM address
76  * @res_addr: optional reset register port
77  * @dev_base_addr: CPU translated IO/virtual MEM address
78  * @flags: board flags: %PROGRAMMABLE_IRQ .. interrupt number
79  *      can be programmed into board
80  * @nr_all_chips: number of chips present on the board
81  * @nr_82527_chips: number of Intel 8257 chips
82  * @nr_sja1000_chips: number of Philips SJA100 chips
83  * @chip: array of pointers to the chip structures
84  * @hwspecops: pointer to board specific operations
85  * @hosthardware_p: pointer to the root hardware structure
86  * @sysdevptr: union reserved for pointer to bus specific
87  *      device structure (case @pcidev is used for PCI devices)
88  *
89  * The structure represent configuration and state of associated board.
90  * The driver infrastructure prepares this structure and calls
91  * board type specific board_register() function. The board support provided
92  * register function fills right function pointers in @hwspecops structure.
93  * Then driver setup calls functions init_hw_data(), init_chip_data(),
94  * init_chip_data(), init_obj_data() and program_irq(). Function init_hw_data()
95  * and init_chip_data() have to specify number and types of connected chips
96  * or objects respectively.
97  * The use of @nr_all_chips is preferred over use of fields @nr_82527_chips
98  * and @nr_sja1000_chips in the board non-specific functions.
99  * The @io_addr and @dev_base_addr is filled from module parameters
100  * to the same value. The request_io function can fix-up @dev_base_addr
101  * field if virtual address is different than bus address.
102  */
103 struct candevice_t {
104         char *hwname;                   /* text board type */
105         int candev_idx;                 /* board index in canhardware_t.candevice[] */
106         unsigned long io_addr;          /* IO/physical MEM address */
107         unsigned long res_addr;         /* optional reset register port */
108         can_ioptr_t dev_base_addr;      /* CPU translated IO/virtual MEM address */
109         can_ioptr_t aux_base_addr;      /* CPU translated IO/virtual MEM address */
110         unsigned int flags;
111         int nr_all_chips;
112         int nr_82527_chips;
113         int nr_sja1000_chips;
114         can_spinlock_t device_lock;
115         struct canchip_t *chip[MAX_HW_CHIPS];
116
117         struct hwspecops_t *hwspecops;
118
119         struct canhardware_t *hosthardware_p;
120
121         union {
122                 void *anydev;
123             #ifdef CAN_ENABLE_PCI_SUPPORT
124                 struct pci_dev *pcidev;
125             #endif /*CAN_ENABLE_PCI_SUPPORT*/
126         } sysdevptr;
127
128 };
129
130 /**
131  * struct canchip_t - CAN chip state and type information
132  * @chip_type: text string describing chip type
133  * @chip_idx: index of the chip in candevice_t.chip[] array
134  * @chip_irq: chip interrupt number if any
135  * @chip_base_addr: chip base address in the CPU IO or virtual memory space
136  * @flags: chip flags: %CHIP_CONFIGURED .. chip is configured,
137  *      %CHIP_SEGMENTED .. access to the chip is segmented (mainly for i82527 chips)
138  * @clock: chip base clock frequency in Hz
139  * @baudrate: selected chip baudrate in Hz
140  * @write_register: write chip register function copy
141  * @read_register: read chip register function copy
142  * @chip_data: pointer for optional chip specific data extension
143  * @sja_cdr_reg: SJA specific register -
144  *      holds hardware specific options for the Clock Divider
145  *      register. Options defined in the sja1000.h file:
146  *      %CDR_CLKOUT_MASK, %CDR_CLK_OFF, %CDR_RXINPEN, %CDR_CBP, %CDR_PELICAN
147  * @sja_ocr_reg: SJA specific register -
148  *      hold hardware specific options for the Output Control
149  *      register. Options defined in the sja1000.h file:
150  *      %OCR_MODE_BIPHASE, %OCR_MODE_TEST, %OCR_MODE_NORMAL, %OCR_MODE_CLOCK,
151  *      %OCR_TX0_LH, %OCR_TX1_ZZ.
152  * @int_cpu_reg: Intel specific register -
153  *      holds hardware specific options for the CPU Interface
154  *      register. Options defined in the i82527.h file:
155  *      %iCPU_CEN, %iCPU_MUX, %iCPU_SLP, %iCPU_PWD, %iCPU_DMC, %iCPU_DSC, %iCPU_RST.
156  * @int_clk_reg: Intel specific register -
157  *      holds hardware specific options for the Clock Out
158  *      register. Options defined in the i82527.h file:
159  *      %iCLK_CD0, %iCLK_CD1, %iCLK_CD2, %iCLK_CD3, %iCLK_SL0, %iCLK_SL1.
160  * @int_bus_reg: Intel specific register -
161  *      holds hardware specific options for the Bus Configuration
162  *      register. Options defined in the i82527.h file:
163  *      %iBUS_DR0, %iBUS_DR1, %iBUS_DT1, %iBUS_POL, %iBUS_CBY.
164  * @msgobj: array of pointers to individual communication objects
165  * @chipspecops: pointer to the set of chip specific object filled by init_chip_data() function
166  * @hostdevice: pointer to chip hosting board
167  * @max_objects: maximal number of communication objects connected to this chip
168  * @chip_lock: reserved for synchronization of the chip supporting routines
169  *      (not used in the current driver version)
170  * @worker_thread: chip worker thread ID (RT-Linux specific field)
171  * @pend_flags: holds information about pending interrupt and tx_wake() operations
172  *      (RT-Linux specific field). Masks values:
173  *      %MSGOBJ_TX_REQUEST .. some of the message objects requires tx_wake() call,
174  *      %MSGOBJ_IRQ_REQUEST .. chip interrupt processing required
175  *      %MSGOBJ_WORKER_WAKE .. marks, that worker thread should be waked
176  *              for some of above reasons
177  *
178  * The fields @write_register and @read_register are copied from
179  * corresponding fields from @hwspecops structure
180  * (chip->hostdevice->hwspecops->write_register and
181  * chip->hostdevice->hwspecops->read_register)
182  * to speedup can_write_reg() and can_read_reg() functions.
183  */
184 struct canchip_t {
185         char *chip_type;
186         int chip_idx;   /* chip index in candevice_t.chip[] */
187         int chip_irq;
188         can_ioptr_t chip_base_addr;
189         unsigned int flags;
190         long clock; /* Chip clock in Hz */
191         long baudrate;
192
193         void (*write_register)(unsigned data, can_ioptr_t address);
194         unsigned (*read_register)(can_ioptr_t address);
195
196         void *chip_data;
197
198         unsigned short sja_cdr_reg; /* sja1000 only! */
199         unsigned short sja_ocr_reg; /* sja1000 only! */
200         unsigned short int_cpu_reg; /* intel 82527 only! */
201         unsigned short int_clk_reg; /* intel 82527 only! */
202         unsigned short int_bus_reg; /* intel 82527 only! */
203
204         struct msgobj_t *msgobj[MAX_MSGOBJS];
205
206         struct chipspecops_t *chipspecops;
207
208         struct candevice_t *hostdevice;
209
210         int max_objects;        /* 1 for sja1000, 15 for i82527 */
211
212         can_spinlock_t chip_lock;
213
214     #ifdef CAN_WITH_RTL
215         pthread_t worker_thread;
216         unsigned long pend_flags;
217     #endif /*CAN_WITH_RTL*/
218 };
219
220 /**
221  * struct msgobj_t - structure holding communication object state
222  * @obj_base_addr:
223  * @minor: associated device minor number
224  * @object: object number in canchip_t structure +1
225  * @flags: message object flags
226  * @ret: field holding status of the last Tx operation
227  * @qends: pointer to message object corresponding ends structure
228  * @tx_qedge: edge corresponding to transmitted message
229  * @tx_slot: slot holding transmitted message, slot is taken from
230  *      canque_test_outslot() call and is freed by canque_free_outslot()
231  *      or rescheduled canque_again_outslot()
232  * @tx_retry_cnt: transmission attempt counter
233  * @tx_timeout: can be used by chip driver to check for the transmission timeout
234  * @rx_msg: temporary storage to hold received messages before
235  *      calling to canque_filter_msg2edges()
236  * @hostchip: pointer to the &canchip_t structure this object belongs to
237  * @obj_used: counter of users (associated file structures for Linux
238  *      userspace clients) of this object
239  * @obj_users: list of user structures of type &canuser_t.
240  * @obj_flags: message object specific flags. Masks values:
241  *      %MSGOBJ_TX_REQUEST .. the message object requests TX activation
242  *      %MSGOBJ_TX_LOCK .. some IRQ routine or callback on some CPU
243  *              is running inside TX activation processing code
244  * @rx_preconfig_id: place to store RX message identifier for some chip types
245  *               that reuse same object for TX
246  */
247 struct msgobj_t {
248         can_ioptr_t obj_base_addr;
249         unsigned int minor;     /* associated device minor number  */
250         unsigned int object;    /* object number in canchip_t +1 for debug printk */
251         unsigned long obj_flags;
252         int ret;
253
254         struct canque_ends_t *qends;
255
256         struct canque_edge_t *tx_qedge;
257         struct canque_slot_t *tx_slot;
258         int tx_retry_cnt;
259         struct timer_list tx_timeout;
260
261         struct canmsg_t rx_msg;
262
263         struct canchip_t *hostchip;
264
265         unsigned long rx_preconfig_id;
266
267         atomic_t obj_used;
268         struct list_head obj_users;
269 };
270
271 #define CAN_USER_MAGIC 0x05402033
272
273 /**
274  * struct canuser_t - structure holding CAN user/client state
275  * @flags: used to distinguish Linux/RT-Linux type
276  * @peers: for connection into list of object users
277  * @qends: pointer to the ends structure corresponding for this user
278  * @msgobj: communication object the user is connected to
279  * @rx_edge0: default receive queue for filter IOCTL
280  * @userinfo: stores user context specific information.
281  *      The field @fileinfo.file holds pointer to open device file state structure
282  *      for the Linux user-space client applications
283  * @magic: magic number to check consistency when pointer is retrieved
284  *      from file private field
285  */
286 struct canuser_t {
287         unsigned long flags;
288         struct list_head peers;
289         struct canque_ends_t *qends;
290         struct msgobj_t *msgobj;
291         struct canque_edge_t *rx_edge0; /* simplifies IOCTL */
292         union {
293                 struct {
294                         struct file *file;  /* back ptr to file */
295                 } fileinfo;
296             #ifdef CAN_WITH_RTL
297                 struct {
298                         struct rtl_file *file;
299                 } rtlinfo;
300             #endif /*CAN_WITH_RTL*/
301         } userinfo;
302         int magic;
303 };
304
305 /**
306  * struct hwspecops_t - hardware/board specific operations
307  * @request_io: reserve io or memory range for can board
308  * @release_io: free reserved io memory range
309  * @reset: hardware reset routine
310  * @init_hw_data: called to initialize &candevice_t structure, mainly
311  *      @res_add, @nr_all_chips, @nr_82527_chips, @nr_sja1000_chips
312  *      and @flags fields
313  * @init_chip_data: called initialize each &canchip_t structure, mainly
314  *      @chip_type, @chip_base_addr, @clock and chip specific registers.
315  *      It is responsible to setup &canchip_t->@chipspecops functions
316  *      for non-standard chip types (type other than "i82527", "sja1000" or "sja1000p")
317  * @init_obj_data: called initialize each &msgobj_t structure,
318  *      mainly @obj_base_addr field.
319  * @program_irq: program interrupt generation hardware of the board
320  *      if flag %PROGRAMMABLE_IRQ is present for specified device/board
321  * @write_register: low level write register routine
322  * @read_register: low level read register routine
323  */
324 struct hwspecops_t {
325         int (*request_io)(struct candevice_t *candev);
326         int (*release_io)(struct candevice_t *candev);
327         int (*reset)(struct candevice_t *candev);
328         int (*init_hw_data)(struct candevice_t *candev);
329         void (*done_hw_data)(struct candevice_t *candev);
330         int (*init_chip_data)(struct candevice_t *candev, int chipnr);
331         int (*init_obj_data)(struct canchip_t *chip, int objnr);
332         int (*program_irq)(struct candevice_t *candev);
333         void (*write_register)(unsigned data, can_ioptr_t address);
334         unsigned (*read_register)(can_ioptr_t address);
335 };
336
337 /**
338  * struct chipspecops_t - can controller chip specific operations
339  * @chip_config: CAN chip configuration
340  * @baud_rate: set communication parameters
341  * @standard_mask: setup of mask for message filtering
342  * @extended_mask: setup of extended mask for message filtering
343  * @message15_mask: set mask of i82527 message object 15
344  * @clear_objects: clears state of all message object residing in chip
345  * @config_irqs: tunes chip hardware interrupt delivery
346  * @pre_read_config: prepares message object for message reception
347  * @pre_write_config: prepares message object for message transmission
348  * @send_msg: initiate message transmission
349  * @remote_request: configures message object and asks for RTR message
350  * @check_tx_stat: checks state of transmission engine
351  * @wakeup_tx: wakeup TX processing
352  * @filtch_rq: optional routine for propagation of outgoing edges filters to HW
353  * @enable_configuration: enable chip configuration mode
354  * @disable_configuration: disable chip configuration mode
355  * @set_btregs: configures bitrate registers
356  * @attach_to_chip: attaches to the chip, setups registers and possibly state informations
357  * @release_chip: called before chip structure removal if %CHIP_ATTACHED is set
358  * @start_chip: starts chip message processing
359  * @stop_chip: stops chip message processing
360  * @irq_handler: interrupt service routine
361  * @irq_accept: optional fast irq accept routine responsible for blocking further interrupts
362  */
363 struct chipspecops_t {
364         int (*chip_config)(struct canchip_t *chip);
365         int (*baud_rate)(struct canchip_t *chip, int rate, int clock, int sjw,
366                                                 int sampl_pt, int flags);
367         int (*standard_mask)(struct canchip_t *chip, unsigned short code,
368                                                         unsigned short mask);
369         int (*extended_mask)(struct canchip_t *chip, unsigned long code,
370                                                         unsigned long mask);
371         int (*message15_mask)(struct canchip_t *chip, unsigned long code,
372                                                         unsigned long mask);
373         int (*clear_objects)(struct canchip_t *chip);
374         int (*config_irqs)(struct canchip_t *chip, short irqs);
375         int (*pre_read_config)(struct canchip_t *chip, struct msgobj_t *obj);
376         int (*pre_write_config)(struct canchip_t *chip, struct msgobj_t *obj,
377                                                         struct canmsg_t *msg);
378         int (*send_msg)(struct canchip_t *chip, struct msgobj_t *obj,
379                                                         struct canmsg_t *msg);
380         int (*remote_request)(struct canchip_t *chip, struct msgobj_t *obj);
381         int (*check_tx_stat)(struct canchip_t *chip);
382         int (*wakeup_tx)(struct canchip_t *chip, struct msgobj_t *obj);
383         int (*filtch_rq)(struct canchip_t *chip, struct msgobj_t *obj);
384         int (*enable_configuration)(struct canchip_t *chip);
385         int (*disable_configuration)(struct canchip_t *chip);
386         int (*set_btregs)(struct canchip_t *chip, unsigned short btr0,
387                                                         unsigned short btr1);
388         int (*attach_to_chip)(struct canchip_t *chip);
389         int (*release_chip)(struct canchip_t *chip);
390         int (*start_chip)(struct canchip_t *chip);
391         int (*stop_chip)(struct canchip_t *chip);
392         int (*irq_handler)(int irq, struct canchip_t *chip);
393         int (*irq_accept)(int irq, struct canchip_t *chip);
394 };
395
396 struct mem_addr {
397         void *address;
398         struct mem_addr *next;
399         size_t size;
400 };
401
402 /* Structure for the RTR queue */
403 struct rtr_id {
404         unsigned long id;
405         struct canmsg_t *rtr_message;
406         wait_queue_head_t rtr_wq;
407         struct rtr_id *next;
408 };
409
410 extern int major;
411 extern int minor[MAX_TOT_CHIPS];
412 extern int extended;
413 extern int baudrate[MAX_TOT_CHIPS];
414 extern int irq[MAX_IRQ];
415 extern char *hw[MAX_HW_CARDS];
416 extern unsigned long io[MAX_HW_CARDS];
417 extern long clockfreq[MAX_HW_CARDS];
418 extern int processlocal;
419
420 extern struct canhardware_t *hardware_p;
421 extern struct canchip_t *chips_p[MAX_TOT_CHIPS];
422 extern struct msgobj_t *objects_p[MAX_TOT_MSGOBJS];
423
424 extern struct mem_addr *mem_head;
425
426
427 #if defined(CONFIG_OC_LINCAN_PORTIO_ONLY)
428 extern inline void can_write_reg(const struct canchip_t *chip, unsigned data, unsigned reg_offs)
429 {
430         can_outb(data, chip->chip_base_addr+reg_offs);
431 }
432 extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
433 {
434         return can_inb(chip->chip_base_addr+reg_offs);
435 }
436 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
437                                 unsigned data, unsigned reg_offs)
438 {
439         can_outb(data, obj->obj_base_addr+reg_offs);
440 }
441 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
442                                 unsigned reg_offs)
443 {
444         return can_inb(obj->obj_base_addr+reg_offs);
445 }
446
447 #elif defined(CONFIG_OC_LINCAN_MEMIO_ONLY)
448 extern inline void can_write_reg(const struct canchip_t *chip, unsigned data, unsigned reg_offs)
449 {
450         can_writeb(data, chip->chip_base_addr+reg_offs);
451 }
452 extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
453 {
454         return can_readb(chip->chip_base_addr+reg_offs);
455 }
456 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
457                                 unsigned data, unsigned reg_offs)
458 {
459         can_writeb(data, obj->obj_base_addr+reg_offs);
460 }
461 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
462                                 unsigned reg_offs)
463 {
464         return can_readb(obj->obj_base_addr+reg_offs);
465 }
466
467 #else /*CONFIG_OC_LINCAN_DYNAMICIO*/
468 #ifndef CONFIG_OC_LINCAN_DYNAMICIO
469 #define CONFIG_OC_LINCAN_DYNAMICIO
470 #endif
471
472 /* Inline function to write to the hardware registers. The argument reg_offs is
473  * relative to the memory map of the chip and not the absolute memory reg_offs.
474  */
475 extern inline void can_write_reg(const struct canchip_t *chip, unsigned data, unsigned reg_offs)
476 {
477         can_ioptr_t address_to_write;
478         address_to_write = chip->chip_base_addr+reg_offs;
479         chip->write_register(data, address_to_write);
480 }
481
482 extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
483 {
484         can_ioptr_t address_to_read;
485         address_to_read = chip->chip_base_addr+reg_offs;
486         return chip->read_register(address_to_read);
487 }
488
489 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
490                                 unsigned data, unsigned reg_offs)
491 {
492         can_ioptr_t address_to_write;
493         address_to_write = obj->obj_base_addr+reg_offs;
494         chip->write_register(data, address_to_write);
495 }
496
497 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
498                                 unsigned reg_offs)
499 {
500         can_ioptr_t address_to_read;
501         address_to_read = obj->obj_base_addr+reg_offs;
502         return chip->read_register(address_to_read);
503 }
504
505 #endif /*CONFIG_OC_LINCAN_DYNAMICIO*/
506
507 int can_base_addr_fixup(struct candevice_t *candev, can_ioptr_t new_base);
508 int can_request_io_region(unsigned long start, unsigned long n, const char *name);
509 void can_release_io_region(unsigned long start, unsigned long n);
510 int can_request_mem_region(unsigned long start, unsigned long n, const char *name);
511 void can_release_mem_region(unsigned long start, unsigned long n);
512
513 #ifdef CAN_ENABLE_PCI_SUPPORT
514 struct pci_dev *can_pci_get_next_untaken_device(unsigned int vendor, unsigned int device);
515 struct pci_dev *can_pci_get_next_untaken_subsyst(unsigned int vendor, unsigned int device,
516                         unsigned int ss_vendor, unsigned int ss_device);
517 #endif /*CAN_ENABLE_PCI_SUPPORT*/
518
519 struct boardtype_t {
520         const char *boardtype;
521         int (*board_register)(struct hwspecops_t *hwspecops);
522         int irqnum;
523 };
524
525 const struct boardtype_t* boardtype_find(const char *str);
526
527 int can_check_dev_taken(void *anydev);
528
529 #if defined(can_gettimeofday) && defined(CAN_MSG_VERSION_2) && 1
530 static inline
531 void can_filltimestamp(canmsg_tstamp_t *ptimestamp)
532 {
533         can_gettimeofday(ptimestamp);
534 }
535 #else /* No timestamp support, set field to zero */
536 static inline
537 void can_filltimestamp(canmsg_tstamp_t *ptimestamp)
538 {
539     #ifdef CAN_MSG_VERSION_2
540         ptimestamp->tv_sec = 0;
541         ptimestamp->tv_usec = 0;
542     #else /* CAN_MSG_VERSION_2 */
543         *ptimestamp = 0;
544     #endif /* CAN_MSG_VERSION_2 */
545
546 }
547 #endif /* End of timestamp source selection */
548
549 #ifdef CAN_WITH_RTL
550 extern int can_rtl_priority;
551 #endif /*CAN_WITH_RTL*/
552
553 extern struct candevice_t* register_hotplug_dev(const char *hwname,int (*chipdataregfnc)(struct canchip_t *chip,void *data),void *devdata);
554 extern void deregister_hotplug_dev(struct candevice_t *dev);
555 extern void cleanup_hotplug_dev(struct candevice_t *dev);
556
557 #endif /* _CAN_MAIN_H */
558