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