1 <?xml version="1.0" encoding="UTF-8"?>
3 <title>Linux CAN Driver (LINCAN)</title>
5 <para>The LINCAN is an implementation of the Linux device driver supporting
6 more CAN controller chips and many CAN interface boards. Its
7 implementation has long history already. The OCERA version of the driver
8 adds new features, continuous enhancements and reimplementation of
9 structure of the driver. The usage of the driver is tightly coupled to
10 the virtual CAN API interface component which hides driver low level
11 interface to the application programmers.</para>
14 <title>Summary</title>
18 <term>Name of the component</term>
21 <para>Linux CAN Driver (LINCAN)</para>
29 <para>Arnaud Westenberg</para>
31 <para>Tomasz Motylewski</para>
33 <para>Pavel Pisa</para>
41 <para>The previous driver versions were tested by more users. The
42 actual version was tested at CTU by more OCERA developers and by
43 BFAD GmbH, which use pre-OCERA and current version of the driver
44 in their products.</para>
52 <para>High-level available</para>
60 <para>0.7-pi3.4 alpha</para>
73 <term>Dependencies</term>
76 <para>The driver requires CAN interface hardware.</para>
78 <para>Linux kernels from 2.2.x and 2.4.x series are fully
81 <para>Support for latest 2.5.x and future 2.6.x. is in
84 <para>The use of VCA API library is suggested for seamless
85 application transitions between driver kinds and versions.</para>
90 <term>Release date</term>
100 <title>Description</title>
102 <para id="LINCAN" xreflabel="LINCAN">The LINCAN driver is the loadable
103 module for the Linux kernel which implements CAN driver. The driver
104 communicates and controls one or more CAN controllers chips. The each
105 chip/CAN interface is represented to the applications as one or more CAN
106 message objects through the character device interface. The application
107 can open the character device and use <function>read</function>/<function>write</function>
108 system calls for CAN messages transmission or reception through
109 the connected message object. The parameters of the message object can be
110 modified by the <function>IOCTL</function> system call. The closing of
111 the character device releases resources allocated by the application.</para>
113 <para>The present version of the driver supports three most common CAN
114 controllers:<itemizedlist><listitem><para>Intel i82527 chips</para></listitem><listitem><para>Philips
115 82c200 chips</para></listitem><listitem><para>Philips SJA1000 chips in
116 standard and PeliCAN mode</para></listitem></itemizedlist>The
117 intelligent CAN/CANopen cards should be supported by future versions.
118 One of such cards is P-CAN series of cards produced by Unicontrols.
119 The driver contains support for more than ten CAN cards basic types
120 with different combinations of the above mentioned chips. Not all card
121 types are held by OCERA members, but CTU has and tested more SJA1000
122 type cards and will test some i82527 cards in near future.</para>
125 <section id="lincan-api" xreflabel="lincan-api-fops">
126 <title>API / Compatibility</title>
129 <title>Driver API Overview</title>
131 <para>Each driver is a subsystem which has no direct application level
132 API. The operating system is responsible for user space calls
133 transformation into driver functions calls or dispatch routines
134 invocations. The CAN driver is implemented as a character device with
135 the standard device node names <filename>/dev/can0</filename>,
136 <filename>/dev/can1</filename>, etc. The application program
137 communicates with the driver through the standard system low level
138 input/output primitives (<function>open</function>,
139 <function>close</function>, <function>read</function>,
140 <function>write</function>, <function>select</function> and
141 <function>ioctl</function>). The CAN driver convention of usage of
142 these functions is described in the next subsection.</para>
144 <para>The <function>read</function> and <function>write</function>
145 functions need to transfer one or more CAN messages. The structure
146 <structname>canmsg_t</structname> is defined for this purpose and is
147 defined in include file <filename>can/can.h</filename>. The
148 <structname>canmsg_t</structname> structure has next fields:</para>
155 canmsg_tstamp_t timestamp;
156 unsigned short length;
157 unsigned char data[CAN_MSG_LENGTH];
165 <para>The flags field holds information about message type.
166 The bit <constant>MSG_RTR</constant> marks remote transmission
167 request messages. Writing of such message into the CAN message object
168 handle results in transmission of the RTR message. The RTR message
169 can be received by the read call if no buffer with corresponding
170 ID is pre-filled in the driver. The bit <constant>MSG_EXT</constant>
171 indicates that the message with extended (29 bit) ID will
172 be send or was received. The bit <constant>MSG_OVR</constant>
173 is intended for fast indication of the reception message queue
182 <para>The field reserved for a holding message communication
183 object number. It could be used for serialization of
184 received messages from more message object into one message
185 queue in the future.</para>
193 <para>CAN message ID.</para>
198 <term>timestamp</term>
201 <para>The field intended for storing of the message reception
210 <para>The number of the data bytes send or received in the CAN message.
211 The number of data load bytes is from 0 to 8.</para>
219 <para>The byte array holding message data.</para>
224 <para>As was mentioned above, direct communication with the driver
225 through system calls is not encouraged because this interface is
226 partially system dependent and cannot be ported to all environments.
227 The suggested alternative is to use OCERA provided VCA library which
228 defines the portable and clean interface to the CAN driver implementation.</para>
230 <para>The other issue is addition of the support for new CAN
231 interface boards and CAN controller chips. The subsection <link
232 linkend="lincan-api-board">Driver Board Support Interface</link>
233 describes template functions, which needs to be implemented for
234 newly supported board. The template of board support can be found in
235 the file <filename>src/template.c</filename>.</para>
237 <para>The other task for more brave souls is addition of the support for
238 the unsupported chip type. The source supporting the SJA1000 chip in the
239 PeliCAN mode can serve as an example. The full source of this chip
240 support is stored in the file <filename>src/sja1000p.c</filename>. The
241 subsection <link linkend="lincan-api-board">Driver Chip Support
242 Interface</link> describes basic functions necessary for the new chip
246 <section id="lincan-api-fops" xreflabel="lincan-api-fops">
247 <title>CAN Driver File Operations</title>
251 <refentrytitle><phrase id="LINCAN-open">open</phrase></refentrytitle>
255 <refname>open</refname>
257 <refpurpose>message communication object open system call</refpurpose>
261 <title>Synopsis</title>
265 <funcdef>int <function>open </function></funcdef>
267 <paramdef>const char * <parameter>pathname</parameter></paramdef>
269 <paramdef>int <parameter>flags</parameter></paramdef>
275 <title>Arguments</title>
279 <term><parameter>pathname</parameter></term>
282 <para>The path to driver device node is specified there.
283 The conventional device names for Linux CAN driver are
284 <filename>/dev/can0</filename>, <filename>/dev/can1</filename>,
290 <term><parameter>flags</parameter></term>
293 <para>flags modifying style of open call. The standard
294 <constant>O_RDWR</constant> mode should be used for CAN
295 device. The mode <constant>O_NOBLOCK</constant> can be
296 used with driver as well. This mode results in immediate
297 return of <function>read</function> and
298 <function>write</function>.</para>
305 <title>Description</title>
307 <para>Returns negative number in the case of error. Returns the
308 file descriptor for named CAN message object in other cases.</para>
314 <refentrytitle><phrase id="LINCAN-close">close</phrase></refentrytitle>
318 <refname>close</refname>
320 <refpurpose>message communication object close system call</refpurpose>
324 <title>Synopsis</title>
328 <funcdef>int <function>close </function></funcdef>
330 <paramdef>int <parameter>fd</parameter></paramdef>
336 <title>Arguments</title>
340 <term><parameter>fd</parameter></term>
343 <para>file descriptor to opened can message communication
351 <title>Description</title>
353 <para>Returns negative number in the case of error.</para>
359 <refentrytitle><phrase id="LINCAN-read">read</phrase></refentrytitle>
363 <refname>read</refname>
365 <refpurpose>reads received CAN messages from message object</refpurpose>
369 <title>Synopsis</title>
373 <funcdef>ssize_t <function>read</function></funcdef>
375 <paramdef>int <parameter>fd</parameter></paramdef>
377 <paramdef>void * <parameter>buf</parameter></paramdef>
379 <paramdef>size_t <parameter>count</parameter></paramdef>
385 <title>Arguments</title>
389 <term><parameter>fd</parameter></term>
392 <para>file descriptor to opened can message communication
398 <term><parameter>buf</parameter></term>
401 <para>pointer to array of <structname>canmsg_t</structname>
407 <term><parameter>count</parameter></term>
410 <para>size of message array buffer in number of bytes</para>
417 <title>Description</title>
419 <para>Returns negative value in the case of error else returns
420 number of read bytes which is multiple of
421 <structname>canmsg_t</structname> structure size.</para>
427 <refentrytitle><phrase id="LINCAN-write">write</phrase></refentrytitle>
431 <refname>write</refname>
433 <refpurpose>writes CAN messages to message object for
434 transmission</refpurpose>
438 <title>Synopsis</title>
442 <funcdef>ssize_t <function>write</function></funcdef>
444 <paramdef>int <parameter>fd</parameter></paramdef>
446 <paramdef>const void * <parameter>buf</parameter></paramdef>
448 <paramdef>size_t <parameter>count</parameter></paramdef>
454 <title>Arguments</title>
458 <term><parameter>fd</parameter></term>
461 <para>file descriptor to opened can message communication
467 <term><parameter>buf</parameter></term>
470 <para>pointer to array of <structname>canmsg_t</structname>
476 <term><parameter>count</parameter></term>
479 <para>size of message array buffer in number of bytes. The
480 parameter informs driver about number of messages prepared
481 for transmission and should be multiple of
482 <structname>canmsg_t</structname> structure size.</para>
489 <title>Description</title>
491 <para>Returns negative value in the case of error else returns
492 number of bytes successfully stored into message object
493 transmission queue. The positive returned number is multiple of
494 <structname>canmsg_t</structname> structure size.</para>
499 <section id="lincan-api-board" xreflabel="lincan-api-board">
500 <title>Driver Board Support Interface</title>
504 <refentrytitle><phrase id="API-template-request-io">template_request_io</phrase></refentrytitle>
508 <refname>template_request_io</refname>
510 <refpurpose>reserve io memory</refpurpose>
514 <title>Synopsis</title>
518 <funcdef>int <function>template_request_io </function></funcdef>
520 <paramdef>unsigned long <parameter>io_addr</parameter></paramdef>
526 <title>Arguments</title>
530 <term><parameter>io_addr</parameter></term>
533 <para>The reserved memory starts at
534 <parameter>io_addr</parameter>, which is the module
535 parameter <parameter>io</parameter>.</para>
542 <title>Description</title>
544 <para>The function <function>template_request_io</function> is
545 used to reserve the io-memory. If your hardware uses a dedicated
546 memory range as hardware control registers you will have to add
547 the code to reserve this memory as well. <constant>IO_RANGE</constant>
548 is the io-memory range that gets reserved, please adjust
549 according your hardware. Example: #define IO_RANGE 0x100 for
550 i82527 chips or #define IO_RANGE 0x20 for sja1000 chips in basic
555 <title>Return Value</title>
557 <para>The function returns zero on success or
558 <constant>-ENODEV</constant> on failure</para>
564 <para>src/template.c</para>
570 <refentrytitle><phrase id="API-template-release-io">template_release_io</phrase></refentrytitle>
574 <refname>template_release_io</refname>
576 <refpurpose>free reserved io-memory</refpurpose>
580 <title>Synopsis</title>
584 <funcdef>int <function>template_release_io </function></funcdef>
586 <paramdef>unsigned long <parameter>io_addr</parameter></paramdef>
592 <title>Arguments</title>
596 <term><parameter>io_addr</parameter></term>
599 <para>Start of the memory range to be released.</para>
606 <title>Description</title>
608 <para>The function <function>template_release_io</function> is
609 used to free reserved io-memory. In case you have reserved more
610 io memory, don't forget to free it here. IO_RANGE is the
611 io-memory range that gets released, please adjust according your
612 hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
613 #define IO_RANGE 0x20 for sja1000 chips in basic CAN mode.</para>
617 <title>Return Value</title>
619 <para>The function always returns zero</para>
625 <para>src/template.c</para>
631 <refentrytitle><phrase id="API-template-reset">template_reset</phrase></refentrytitle>
635 <refname>template_reset</refname>
637 <refpurpose>hardware reset routine</refpurpose>
641 <title>Synopsis</title>
645 <funcdef>int <function>template_reset </function></funcdef>
647 <paramdef>int <parameter>card</parameter></paramdef>
653 <title>Arguments</title>
657 <term><parameter>card</parameter></term>
660 <para>Number of the hardware card.</para>
667 <title>Description</title>
669 <para>The function <function>template_reset</function> is used
670 to give a hardware reset. This is rather hardware specific so I
671 haven't included example code. Don't forget to check the
672 reset status of the chip before returning.</para>
676 <title>Return Value</title>
678 <para>The function returns zero on success or
679 <constant>-ENODEV</constant> on failure</para>
685 <para>src/template.c</para>
691 <refentrytitle><phrase id="API-template-init-hw-data">template_init_hw_data</phrase></refentrytitle>
695 <refname>template_init_hw_data</refname>
697 <refpurpose>Initialize hardware cards</refpurpose>
701 <title>Synopsis</title>
705 <funcdef>int <function>template_init_hw_data </function></funcdef>
707 <paramdef>int <parameter>card</parameter></paramdef>
713 <title>Arguments</title>
717 <term><parameter>card</parameter></term>
720 <para>Number of the hardware card.</para>
727 <title>Description</title>
729 <para>The function <function>template_init_hw_data</function> is
730 used to initialize the hardware structure containing information
731 about the installed CAN-board. <constant>RESET_ADDR</constant>
732 represents the io-address of the hardware reset register.
733 <constant>NR_82527</constant> represents the number of Intel
734 82527 chips on the board. <constant>NR_SJA1000</constant>
735 represents the number of Philips sja1000 chips on the board. The
736 flags entry can currently only be <constant>PROGRAMMABLE_IRQ</constant>
737 to indicate that the hardware uses programmable interrupts.</para>
741 <title>Return Value</title>
743 <para>The function always returns zero</para>
749 <para>src/template.c</para>
755 <refentrytitle><phrase id="API-template-init-chip-data">template_init_chip_data</phrase></refentrytitle>
759 <refname>template_init_chip_data</refname>
761 <refpurpose>Initialize chips</refpurpose>
765 <title>Synopsis</title>
769 <funcdef>int <function>template_init_chip_data </function></funcdef>
771 <paramdef>int <parameter>card</parameter></paramdef>
773 <paramdef>int <parameter>chipnr</parameter></paramdef>
779 <title>Arguments</title>
783 <term><parameter>card</parameter></term>
786 <para>Number of the hardware card</para>
791 <term><parameter>chipnr</parameter></term>
794 <para>Number of the CAN chip on the hardware card</para>
801 <title>Description</title>
803 <para>The function <function>template_init_chip_data</function>
804 is used to initialize the hardware structure containing
805 information about the CAN chips. <constant>CHIP_TYPE</constant>
806 represents the type of CAN chip. <constant>CHIP_TYPE</constant>
807 can be <quote>i82527</quote> or <quote>sja1000</quote>. The
808 <parameter>chip_base_addr</parameter> entry represents the start
809 of the 'official' memory map of the installed chip.
810 It's likely that this is the same as the
811 <parameter>io_addr</parameter> argument supplied at module
812 loading time. The <parameter>clock</parameter> entry holds the
813 chip clock value in Hz. The entry <parameter>sja_cdr_reg</parameter>
814 holds hardware specific options for the Clock Divider register.
815 Options defined in the <constant>sja1000</constant>.h file:
816 <constant>CDR_CLKOUT_MASK</constant>, <constant>CDR_CLK_OFF</constant>,
817 <constant>CDR_RXINPEN</constant>, <constant>CDR_CBP</constant>,
818 <constant>CDR_PELICAN</constant> The entry
819 <parameter>sja_ocr_reg</parameter> holds hardware specific
820 options for the Output Control register. Options defined in the
821 <constant>sja1000</constant>.h file: <constant>OCR_MODE_BIPHASE</constant>,
822 <constant>OCR_MODE_TEST</constant>, <constant>OCR_MODE_NORMAL</constant>,
823 <constant>OCR_MODE_CLOCK</constant>, <constant>OCR_TX0_LH</constant>,
824 <constant>OCR_TX1_ZZ</constant>. The entry
825 <parameter>int_clk_reg</parameter> holds hardware specific
826 options for the Clock Out register. Options defined in the
827 <constant>i82527</constant>.h file: <constant>iCLK_CD0</constant>,
828 <constant>iCLK_CD1</constant>, <constant>iCLK_CD2</constant>,
829 <constant>iCLK_CD3</constant>, <constant>iCLK_SL0</constant>,
830 <constant>iCLK_SL1</constant>. The entry <parameter>int_bus_reg</parameter>
831 holds hardware specific options for the Bus Configuration
832 register. Options defined in the <constant>i82527</constant>.h
833 file: <constant>iBUS_DR0</constant>, <constant>iBUS_DR1</constant>,
834 <constant>iBUS_DT1</constant>, <constant>iBUS_POL</constant>,
835 <constant>iBUS_CBY</constant>. The entry <parameter>int_cpu_reg</parameter>
836 holds hardware specific options for the cpu interface register.
837 Options defined in the <constant>i82527</constant>.h file:
838 <constant>iCPU_CEN</constant>, <constant>iCPU_MUX</constant>,
839 <constant>iCPU_SLP</constant>, <constant>iCPU_PWD</constant>,
840 <constant>iCPU_DMC</constant>, <constant>iCPU_DSC</constant>,
841 <constant>iCPU_RST</constant>.</para>
845 <title>Return Value</title>
847 <para>The function always returns zero</para>
853 <para>src/template.c</para>
859 <refentrytitle><phrase id="API-template-init-obj-data">template_init_obj_data</phrase></refentrytitle>
863 <refname>template_init_obj_data</refname>
865 <refpurpose>Initialize message buffers</refpurpose>
869 <title>Synopsis</title>
873 <funcdef>int <function>template_init_obj_data </function></funcdef>
875 <paramdef>int <parameter>chipnr</parameter></paramdef>
877 <paramdef>int <parameter>objnr</parameter></paramdef>
883 <title>Arguments</title>
887 <term><parameter>chipnr</parameter></term>
890 <para>Number of the CAN chip</para>
895 <term><parameter>objnr</parameter></term>
898 <para>Number of the message buffer</para>
905 <title>Description</title>
907 <para>The function <function>template_init_obj_data</function>
908 is used to initialize the hardware structure containing
909 information about the different message objects on the CAN chip.
910 In case of the sja1000 there's only one message object but
911 on the i82527 chip there are 15. The code below is for a i82527
912 chip and initializes the object base addresses The entry
913 <parameter>obj_base_addr</parameter> represents the first memory
914 address of the message object. In case of the sja1000
915 <parameter>obj_base_addr</parameter> is taken the same as the
916 chips base address. Unless the hardware uses a segmented memory
917 map, flags can be set zero.</para>
921 <title>Return Value</title>
923 <para>The function always returns zero</para>
929 <para>src/template.c</para>
935 <refentrytitle><phrase id="API-template-program-irq">template_program_irq</phrase></refentrytitle>
939 <refname>template_program_irq</refname>
941 <refpurpose>program interrupts</refpurpose>
945 <title>Synopsis</title>
949 <funcdef>int <function>template_program_irq </function></funcdef>
951 <paramdef>int <parameter>card</parameter></paramdef>
957 <title>Arguments</title>
961 <term><parameter>card</parameter></term>
964 <para>Number of the hardware card.</para>
971 <title>Description</title>
973 <para>The function <function>template_program_irq</function> is
974 used for hardware that uses programmable interrupts. If your
975 hardware doesn't use programmable interrupts you should not
976 set the <parameter>candevices_t</parameter>->flags entry to
977 <constant>PROGRAMMABLE_IRQ</constant> and leave this function
978 unedited. Again this function is hardware specific so
979 there's no example code.</para>
983 <title>Return value</title>
985 <para>The function returns zero on success or
986 <constant>-ENODEV</constant> on failure</para>
992 <para>src/template.c</para>
998 <refentrytitle><phrase id="API-template-write-register">template_write_register</phrase></refentrytitle>
1002 <refname>template_write_register</refname>
1004 <refpurpose>Low level write register routine</refpurpose>
1008 <title>Synopsis</title>
1012 <funcdef>void <function>template_write_register </function></funcdef>
1014 <paramdef>unsigned char <parameter>data</parameter></paramdef>
1016 <paramdef>unsigned long <parameter>address</parameter></paramdef>
1022 <title>Arguments</title>
1026 <term><parameter>data</parameter></term>
1029 <para>data to be written</para>
1034 <term><parameter>address</parameter></term>
1037 <para>memory address to write to</para>
1044 <title>Description</title>
1046 <para>The function <function>template_write_register</function>
1047 is used to write to hardware registers on the CAN chip. You
1048 should only have to edit this function if your hardware uses
1049 some specific write process.</para>
1053 <title>Return Value</title>
1055 <para>The function does not return a value</para>
1061 <para>src/template.c</para>
1067 <refentrytitle><phrase id="API-template-read-register">template_read_register</phrase></refentrytitle>
1071 <refname>template_read_register</refname>
1073 <refpurpose>Low level read register routine</refpurpose>
1077 <title>Synopsis</title>
1081 <funcdef>unsigned <function>template_read_register
1082 </function></funcdef>
1084 <paramdef>unsigned long <parameter>address</parameter></paramdef>
1090 <title>Arguments</title>
1094 <term><parameter>address</parameter></term>
1097 <para>memory address to read from</para>
1104 <title>Description</title>
1106 <para>The function <function>template_read_register</function>
1107 is used to read from hardware registers on the CAN chip. You
1108 should only have to edit this function if your hardware uses
1109 some specific read process.</para>
1113 <title>Return Value</title>
1115 <para>The function returns the value stored in
1116 <parameter>address</parameter></para>
1122 <para>src/template.c</para>
1127 <section id="lincan-api-chip" xreflabel="lincan-api-chip">
1128 <title>Driver Chip Support Interface</title>
1132 <refentrytitle><phrase id="API-sja1000p-chip-config">sja1000p_chip_config</phrase></refentrytitle>
1136 <refname>sja1000p_chip_config</refname>
1138 <refpurpose>can chip configuration</refpurpose>
1142 <title>Synopsis</title>
1146 <funcdef>int <function>sja1000p_chip_config </function></funcdef>
1148 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1154 <title>Arguments</title>
1158 <term><parameter>chip</parameter></term>
1161 <para>pointer to chip state structure</para>
1168 <title>Description</title>
1170 <para>This function configures chip and prepares it for message
1171 transmission and reception. The function resets chip, resets
1172 mask for acceptance of all messages by call to
1173 <function>sja1000p_extended_mask</function> function and then
1174 computes and sets baudrate with use of function
1175 <function>sja1000p_baud_rate</function>.</para>
1179 <title>Return Value</title>
1181 <para>negative value reports error.</para>
1187 <para>src/sja1000p.c</para>
1193 <refentrytitle><phrase id="API-sja1000p-extended-mask">sja1000p_extended_mask</phrase></refentrytitle>
1197 <refname>sja1000p_extended_mask</refname>
1199 <refpurpose>setup of extended mask for message filtering</refpurpose>
1203 <title>Synopsis</title>
1207 <funcdef>int <function>sja1000p_extended_mask </function></funcdef>
1209 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1211 <paramdef>unsigned long <parameter>code</parameter></paramdef>
1213 <paramdef>unsigned long <parameter>mask</parameter></paramdef>
1219 <title>Arguments</title>
1223 <term><parameter>chip</parameter></term>
1226 <para>pointer to chip state structure</para>
1231 <term><parameter>code</parameter></term>
1234 <para>can message acceptance code</para>
1239 <term><parameter>mask</parameter></term>
1242 <para>can message acceptance mask</para>
1249 <title>Return Value</title>
1251 <para>negative value reports error.</para>
1257 <para>src/sja1000p.c</para>
1263 <refentrytitle><phrase id="API-sja1000p-baud-rate">sja1000p_baud_rate</phrase></refentrytitle>
1267 <refname>sja1000p_baud_rate</refname>
1269 <refpurpose>set communication parameters.</refpurpose>
1273 <title>Synopsis</title>
1277 <funcdef>int <function>sja1000p_baud_rate </function></funcdef>
1279 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1281 <paramdef>int <parameter>rate</parameter></paramdef>
1283 <paramdef>int <parameter>clock</parameter></paramdef>
1285 <paramdef>int <parameter>sjw</parameter></paramdef>
1287 <paramdef>int <parameter>sampl_pt</parameter></paramdef>
1289 <paramdef>int <parameter>flags</parameter></paramdef>
1295 <title>Arguments</title>
1299 <term><parameter>chip</parameter></term>
1302 <para>pointer to chip state structure</para>
1307 <term><parameter>rate</parameter></term>
1310 <para>baud rate in Hz</para>
1315 <term><parameter>clock</parameter></term>
1318 <para>frequency of sja1000 clock in Hz (ISA osc is
1324 <term><parameter>sjw</parameter></term>
1327 <para>synchronization jump width (0-3) prescaled clock
1333 <term><parameter>sampl_pt</parameter></term>
1336 <para>sample point in % (0-100) sets
1337 (TSEG1+1)/(TSEG1+TSEG2+2) ratio</para>
1342 <term><parameter>flags</parameter></term>
1345 <para>fields <constant>BTR1_SAM</constant>,
1346 <constant>OCMODE</constant>, <constant>OCPOL</constant>,
1347 <constant>OCTP</constant>, <constant>OCTN</constant>,
1348 <constant>CLK_OFF</constant>, <constant>CBP</constant></para>
1355 <title>Return Value</title>
1357 <para>negative value reports error.</para>
1363 <para>src/sja1000p.c</para>
1369 <refentrytitle><phrase id="API-sja1000p-read">sja1000p_read</phrase></refentrytitle>
1373 <refname>sja1000p_read</refname>
1375 <refpurpose>reads and distributes one or more received messages</refpurpose>
1379 <title>Synopsis</title>
1383 <funcdef>void <function>sja1000p_read </function></funcdef>
1385 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1387 <paramdef>struct canfifo_t * <parameter>fifo</parameter></paramdef>
1393 <title>Arguments</title>
1397 <term><parameter>chip</parameter></term>
1400 <para>pointer to chip state structure</para>
1405 <term><parameter>fifo</parameter></term>
1408 <para>pinter to CAN message queue information</para>
1417 <para>src/sja1000p.c</para>
1423 <refentrytitle><phrase id="API-sja1000p-pre-read-config">sja1000p_pre_read_config</phrase></refentrytitle>
1427 <refname>sja1000p_pre_read_config</refname>
1429 <refpurpose>prepares message object for message reception</refpurpose>
1433 <title>Synopsis</title>
1437 <funcdef>int <function>sja1000p_pre_read_config </function></funcdef>
1439 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1441 <paramdef>struct msgobj_t * <parameter>obj</parameter></paramdef>
1447 <title>Arguments</title>
1451 <term><parameter>chip</parameter></term>
1454 <para>pointer to chip state structure</para>
1459 <term><parameter>obj</parameter></term>
1462 <para>pointer to message object state structure</para>
1469 <title>Return Value</title>
1471 <para>negative value reports error. Positive value indicates
1472 immediate reception of message.</para>
1478 <para>src/sja1000p.c</para>
1484 <refentrytitle><phrase id="API-sja1000p-pre-write-config">sja1000p_pre_write_config</phrase></refentrytitle>
1488 <refname>sja1000p_pre_write_config</refname>
1490 <refpurpose>prepares message object for message transmission</refpurpose>
1494 <title>Synopsis</title>
1498 <funcdef>int <function>sja1000p_pre_write_config </function></funcdef>
1500 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1502 <paramdef>struct msgobj_t * <parameter>obj</parameter></paramdef>
1504 <paramdef>struct canmsg_t * <parameter>msg</parameter></paramdef>
1510 <title>Arguments</title>
1514 <term><parameter>chip</parameter></term>
1517 <para>pointer to chip state structure</para>
1522 <term><parameter>obj</parameter></term>
1525 <para>pointer to message object state structure</para>
1530 <term><parameter>msg</parameter></term>
1533 <para>pointer to CAN message</para>
1540 <title>Description</title>
1542 <para>This function prepares selected message object for future
1543 initiation of message transmission by <function>sja1000p_send_msg</function>
1544 function. The CAN message data and message ID are transfered
1545 from <parameter>msg</parameter> slot into chip buffer in this
1550 <title>Return Value</title>
1552 <para>negative value reports error.</para>
1558 <para>src/sja1000p.c</para>
1564 <refentrytitle><phrase id="API-sja1000p-send-msg">sja1000p_send_msg</phrase></refentrytitle>
1568 <refname>sja1000p_send_msg</refname>
1570 <refpurpose>initiate message transmission</refpurpose>
1574 <title>Synopsis</title>
1578 <funcdef>iint <function>sja1000p_send_msg </function></funcdef>
1580 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1582 <paramdef>struct msgobj_t * <parameter>obj</parameter></paramdef>
1584 <paramdef>struct canmsg_t * <parameter>msg</parameter></paramdef>
1590 <title>Arguments</title>
1594 <term><parameter>chip</parameter></term>
1597 <para>pointer to chip state structure</para>
1602 <term><parameter>obj</parameter></term>
1605 <para>pointer to message object state structure</para>
1610 <term><parameter>msg</parameter></term>
1613 <para>pointer to CAN message</para>
1620 <title>Description</title>
1622 <para>This function is called after <function>sja1000p_pre_write_config</function>
1623 function, which prepares data in chip buffer.</para>
1627 <title>Return Value</title>
1629 <para>negative value reports error.</para>
1635 <para>src/sja1000p.c</para>
1641 <refentrytitle><phrase id="API-sja1000p-check-tx-stat">sja1000p_check_tx_stat</phrase></refentrytitle>
1645 <refname>sja1000p_check_tx_stat</refname>
1647 <refpurpose>checks state of transmission engine</refpurpose>
1651 <title>Synopsis</title>
1655 <funcdef>int <function>sja1000p_check_tx_stat </function></funcdef>
1657 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1663 <title>Arguments</title>
1667 <term><parameter>chip</parameter></term>
1670 <para>pointer to chip state structure</para>
1677 <title>Return Value</title>
1679 <para>negative value reports error. Positive return value
1680 indicates transmission under way status. Zero value indicates
1681 finishing of all issued transmission requests.</para>
1687 <para>src/sja1000p.c</para>
1693 <refentrytitle><phrase id="API-sja1000p-set-btregs">sja1000p_set_btregs</phrase></refentrytitle>
1697 <refname>sja1000p_set_btregs</refname>
1699 <refpurpose>configures bitrate registers</refpurpose>
1703 <title>Synopsis</title>
1707 <funcdef>int <function>sja1000p_set_btregs </function></funcdef>
1709 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1711 <paramdef>unsigned short <parameter>btr0</parameter></paramdef>
1713 <paramdef>unsigned short <parameter>btr1</parameter></paramdef>
1719 <title>Arguments</title>
1723 <term><parameter>chip</parameter></term>
1726 <para>pointer to chip state structure</para>
1731 <term><parameter>btr0</parameter></term>
1734 <para>bitrate register 0</para>
1739 <term><parameter>btr1</parameter></term>
1742 <para>bitrate register 1</para>
1749 <title>Return Value</title>
1751 <para>negative value reports error.</para>
1757 <para>src/sja1000p.c</para>
1763 <refentrytitle><phrase id="API-sja1000p-start-chip">sja1000p_start_chip</phrase></refentrytitle>
1767 <refname>sja1000p_start_chip</refname>
1769 <refpurpose>starts chip message processing</refpurpose>
1773 <title>Synopsis</title>
1777 <funcdef>int <function>sja1000p_start_chip </function></funcdef>
1779 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1785 <title>Arguments</title>
1789 <term><parameter>chip</parameter></term>
1792 <para>pointer to chip state structure</para>
1799 <title>Return Value</title>
1801 <para>negative value reports error.</para>
1807 <para>src/sja1000p.c</para>
1813 <refentrytitle><phrase id="API-sja1000p-stop-chip">sja1000p_stop_chip</phrase></refentrytitle>
1817 <refname>sja1000p_stop_chip</refname>
1819 <refpurpose>stops chip message processing</refpurpose>
1823 <title>Synopsis</title>
1827 <funcdef>int <function>sja1000p_stop_chip </function></funcdef>
1829 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1835 <title>Arguments</title>
1839 <term><parameter>chip</parameter></term>
1842 <para>pointer to chip state structure</para>
1849 <title>Return Value</title>
1851 <para>negative value reports error.</para>
1857 <para>src/sja1000p.c</para>
1863 <refentrytitle><phrase id="API-sja1000p-remote-request">sja1000p_remote_request</phrase></refentrytitle>
1867 <refname>sja1000p_remote_request</refname>
1869 <refpurpose>configures message object and asks for RTR message</refpurpose>
1873 <title>Synopsis</title>
1877 <funcdef>int <function>sja1000p_remote_request </function></funcdef>
1879 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1881 <paramdef>struct msgobj_t * <parameter>obj</parameter></paramdef>
1887 <title>Arguments</title>
1891 <term><parameter>chip</parameter></term>
1894 <para>pointer to chip state structure</para>
1899 <term><parameter>obj</parameter></term>
1902 <para>pointer to message object structure</para>
1909 <title>Return Value</title>
1911 <para>negative value reports error.</para>
1917 <para>src/sja1000p.c</para>
1923 <refentrytitle><phrase id="API-sja1000p-standard-mask">sja1000p_standard_mask</phrase></refentrytitle>
1927 <refname>sja1000p_standard_mask</refname>
1929 <refpurpose>setup of mask for message filtering</refpurpose>
1933 <title>Synopsis</title>
1937 <funcdef>int <function>sja1000p_standard_mask </function></funcdef>
1939 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
1941 <paramdef>unsigned short <parameter>code</parameter></paramdef>
1943 <paramdef>unsigned short <parameter>mask</parameter></paramdef>
1949 <title>Arguments</title>
1953 <term><parameter>chip</parameter></term>
1956 <para>pointer to chip state structure</para>
1961 <term><parameter>code</parameter></term>
1964 <para>can message acceptance code</para>
1969 <term><parameter>mask</parameter></term>
1972 <para>can message acceptance mask</para>
1979 <title>Return Value</title>
1981 <para>negative value reports error.</para>
1987 <para>src/sja1000p.c</para>
1993 <refentrytitle><phrase id="API-sja1000p-clear-objects">sja1000p_clear_objects</phrase></refentrytitle>
1997 <refname>sja1000p_clear_objects</refname>
1999 <refpurpose>clears state of all message object residing in chip</refpurpose>
2003 <title>Synopsis</title>
2007 <funcdef>int <function>sja1000p_clear_objects </function></funcdef>
2009 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
2015 <title>Arguments</title>
2019 <term><parameter>chip</parameter></term>
2022 <para>pointer to chip state structure</para>
2029 <title>Return Value</title>
2031 <para>negative value reports error.</para>
2037 <para>src/sja1000p.c</para>
2043 <refentrytitle><phrase id="API-sja1000p-config-irqs">sja1000p_config_irqs</phrase></refentrytitle>
2047 <refname>sja1000p_config_irqs</refname>
2049 <refpurpose>tunes chip hardware interrupt delivery</refpurpose>
2053 <title>Synopsis</title>
2057 <funcdef>int <function>sja1000p_config_irqs </function></funcdef>
2059 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
2061 <paramdef>short <parameter>irqs</parameter></paramdef>
2067 <title>Arguments</title>
2071 <term><parameter>chip</parameter></term>
2074 <para>pointer to chip state structure</para>
2079 <term><parameter>irqs</parameter></term>
2082 <para>requested chip IRQ configuration</para>
2089 <title>Return Value</title>
2091 <para>negative value reports error.</para>
2097 <para>src/sja1000p.c</para>
2103 <refentrytitle><phrase id="API-sja1000p-irq-write-handler">sja1000p_irq_write_handler</phrase></refentrytitle>
2107 <refname>sja1000p_irq_write_handler</refname>
2109 <refpurpose>part of ISR code responsible for transmit events</refpurpose>
2113 <title>Synopsis</title>
2117 <funcdef>void <function>sja1000p_irq_write_handler
2118 </function></funcdef>
2120 <paramdef>struct chip_t * <parameter>chip</parameter></paramdef>
2122 <paramdef>struct canfifo_t * <parameter>fifo</parameter></paramdef>
2128 <title>Arguments</title>
2132 <term><parameter>chip</parameter></term>
2135 <para>pointer to chip state structure</para>
2140 <term><parameter>fifo</parameter></term>
2143 <para>pointer to attached queue description</para>
2150 <title>Description</title>
2152 <para>The main purpose of this function is to read message from
2153 attached queues and transfer message contents into CAN
2154 controller chip. This subroutine is called by
2155 <function>sja1000p_irq_write_handler</function> for transmit
2162 <para>src/sja1000p.c</para>
2168 <refentrytitle><phrase id="API-sja1000p-irq-handler">sja1000p_irq_handler</phrase></refentrytitle>
2172 <refname>sja1000p_irq_handler</refname>
2174 <refpurpose>interrupt service routine</refpurpose>
2178 <title>Synopsis</title>
2182 <funcdef>void <function>sja1000p_irq_handler </function></funcdef>
2184 <paramdef>int <parameter>irq</parameter></paramdef>
2186 <paramdef>void * <parameter>dev_id</parameter></paramdef>
2188 <paramdef>struct pt_regs * <parameter>regs</parameter></paramdef>
2194 <title>Arguments</title>
2198 <term><parameter>irq</parameter></term>
2201 <para>interrupt vector number, this value is system
2207 <term><parameter>dev_id</parameter></term>
2210 <para>driver private pointer registered at time of
2211 <function>request_irq</function> call. The CAN driver uses
2212 this pointer to store relationship of interrupt to chip
2213 state structure - <parameter>struct</parameter> chip_t</para>
2218 <term><parameter>regs</parameter></term>
2221 <para>system dependent value pointing to registers stored
2222 in exception frame</para>
2229 <title>Description</title>
2231 <para>Interrupt handler is activated when state of CAN
2232 controller chip changes, there is message to be read or there is
2233 more space for new messages or error occurs. The receive events
2234 results in reading of the message from CAN controller chip and
2235 distribution of message through attached message queues.</para>
2241 <para>src/sja1000p.c</para>
2248 <title>Implementation issues</title>
2250 <para>The development of the CAN drivers for Linux has long history.
2251 We have been faced before two basic alternatives, start new project
2252 from scratch or use some other project as basis of our development.
2253 The first approach would probably lead faster to more simple and clean
2254 internal architecture but it would mean to introduce new driver with
2255 probably incompatible interface unusable for already existing
2256 applications. The support of many types of cards is thing which takes
2257 long time as well. More existing projects aimed to development of
2258 a Linux CAN driver has been analyzed:</para>
2262 <term>Original LDDK CAN driver project</term>
2265 <para>The driver project aborted on the kernel evolution and LDDK
2266 concept. The LDDK tried to prepare infrastructure for
2267 development of the kernel version independent character device
2268 drivers written in meta code. The goal was top-ranking, but it
2269 proves, that well written "C" language driver can be
2270 more portable than the LDDK complex infrastructure.</para>
2275 <term>can4linux-0.9 by PORT GmbH</term>
2278 <para>This is version of the above LDDK driver maintained by Port
2279 GmbH. The card type is hard compiled into the driver by selected
2280 defines and only Philips 82c200 chips are supported.</para>
2285 <term>CanFestival</term>
2288 <para>The big advantage of this driver is an integrated support for
2289 the RT-Linux, but driver implementation is highly coupled to one
2290 card. Some concepts of the driver are interesting but the driver has
2291 the hardcoded number of message queues.</para>
2296 <term>can-0.7.1 by Arnaud Westenberg</term>
2299 <para>This driver has its roots in the LDDK project as well. The
2300 original LDDK concept has been eliminated in the driver source
2301 and necessary adaptation of the driver for the different Linux kernel
2302 versions is achieved by the controllable number of defines and
2303 conditional compilation. There is more independent contributors.
2304 The main advantages of the driver are support of many cards working
2305 in parallel, IO and memory space chip connection support and more
2306 cards of different types can be selected at module load time.
2307 There exist more users and applications compatible with the driver
2308 interface. Disadvantages of the original version of this driver are
2309 non-optimal infrastructure, non-portable make system and lack of the
2310 select support.</para>
2315 <para>The responsible OCERA developers selected the
2316 <interfacename>can-0.7.1</interfacename> driver as a base of their
2317 development for next reasons:</para>
2321 <para>Best support for more cards in system</para>
2325 <para>Supports for many types of cards</para>
2329 <para>The internal abstraction of the peripheral access method and
2330 the chip support</para>
2334 <para>The most important features added in the first stage of OCERA
2335 development are:</para>
2339 <para>Added the select system call support</para>
2343 <para>The support for our memory mapped ISA card added, which proved
2344 simplicity of addition of the support for new type of CAN cards</para>
2348 <para>Revised and bug-fixed the IRQ support</para>
2352 <para>Rebuilt the make system to compile options fully follow the running
2353 kernel options, cross-compilation still possible when the kernel
2354 location and compiler is specified. The driver checked with more 2.2.x
2355 and 2.4.x kernels and hardware configurations. (compiles even with
2356 latest 2.5.x kernels for UP, but needs more work to be ready for
2357 2.6.x kernels)</para>
2361 <para>Added devfs support</para>
2365 <para>We are planning next changes in the driver in the next stage of
2366 the development</para>
2370 <para>Full support for 2.6.x kernels</para>
2374 <para>The second deeper rebuilt of the driver infrastructure to enable porting to
2375 more systems (most important RT-Linux). The big advantage of continuous
2376 development should be ability to keep compatibility with many
2377 cards and applications</para>
2381 <para>Support for multiple opening of the single minor device</para>
2385 <para>Support for intelligent CAN/CANopen cards</para>
2389 <para>PCI and USB hardware hot-swapping and PnP recognition</para>
2397 <title>Tests</title>
2399 <para>No heavy tests have been run yet. The driver has been used with
2400 more CAN devices (commercial and CTU made) on more Linux system setups
2401 (different kernels 2.4.18, 2.4.19, 2.2.19, 2.2.22) with more compilers
2402 (GCC 2.95.3 and 3.2.x). The test application from the driver sources
2403 and VCA API sources has been tested. The driver is used for the CanMonitor
2404 development and other CTU CAN related projects. The success has been
2405 reported from the BFAD company as well.</para>
2409 <title>Examples</title>
2411 <para>The simple test utilities can be found in the <filename>utils</filename>
2412 subdirectory of the LINCAN driver source subtree. These utilities can
2413 be used as base for user programs directly communicating with the LINCAN
2414 driver. We do not suggest to build applications directly dependent on
2415 the driver operating system specific interface. We suggest to use the VCA
2416 API library for communication with the driver which brings higher level of
2417 system interface abstraction and ensures compatibility with the future
2418 versions of LINCAN driver and RT-Linux driver clone versions.</para>
2420 <para>The basic utilities provided with LINCAN driver are:</para>
2427 <para>the simple utility to receive or send message which guides
2428 user through operation, the message type, the message ID and the
2429 message contents by simple prompts</para>
2437 <para>even more simplistic message sending program</para>
2442 <term>readburst</term>
2445 <para>the utility for continuous messages reception and printing of
2446 the message contents. This utility can be used as an example of the
2447 <function>select</function> system call usage.</para>
2452 <term>sendburst</term>
2455 <para>the periodic message generator. Each message is filled by
2456 the constant pattern and the message sequence number. This utility
2457 can be used for throughput and message drops tests.</para>
2462 <term>can-proxy</term>
2465 <para>the simple TCP/IP to CAN proxy. The proxy receives simple
2466 commands from IP datagrams and processes command sending and
2467 state manipulations. Received messages are packed into IP
2468 datagrams and send back to the client.</para>
2475 <title>Installation Instructions</title>
2478 <title>Installation Prerequisites</title>
2480 <para>The next basic conditions are necessary for the LINCAN driver
2485 <para>some of supported types of CAN interface boards (high or
2492 <para>cables and at least one device compatible with the board or
2493 the second computer with an another CAN interface board</para>
2499 <para>working Linux system with any recent 2.4.x or 2.2.x kernel
2500 (successfully tested on 2.4.18, 2.4.19, 2.2.19, 2.2.20, 2.2.22
2501 kernels) or working setup for kernel cross-compilation</para>
2507 <para>installed native and or target specific development tools
2508 (GCC and binutils) and pre-configured kernel sources
2509 corresponding to the running kernel or intended target for
2510 cross-compilation</para>
2514 <para>Every non-archaic Linux distribution should provide good
2515 starting point for the LINCAN driver installation.</para>
2519 <title>Quick Installation Instructions</title>
2521 <para>Change current directory into the LINCAN driver source root
2522 directory <programlisting>cd lincan-dir</programlisting>invoke make
2523 utility. Just type '<command>make</command>' at the command
2524 line and driver should compile without errors<programlisting>make</programlisting></para>
2526 <para>If there is problem with compilation, look at first lines
2527 produced by 'make' command or store make output in file.
2528 More about possible problems and more complex compilation examples
2529 is in the next subsection.</para>
2531 <para>Install built LINCAN driver object file (<filename>can.o</filename>)
2532 into Linux kernel loadable module directory (<filename>/lib/modules/2.<replaceable>x</replaceable>.<replaceable>y</replaceable>/kernel/drivers/char</filename>).
2533 This and next commands needs root privileges to proceed
2534 successfully.<programlisting>make install</programlisting>If device
2535 filesystem (devfs) is not used on the computer, device nodes have to
2536 be created manually.<programlisting>
2537 mknod -m666 /dev/can0 c 91 0
2538 mknod -m666 /dev/can1 c 91 1
2540 mknod -m666 /dev/can7 c 97 7
2541 </programlisting></para>
2543 <para>The parameters, IO address and interrupt line of inserted CAN
2544 interface card need to be determined and configured. The manual
2545 driver load can be invoked from the command line with parameters
2546 similar to example below
2548 insmod can.o hw=pip5 irq=4 io=0x8000
2549 </programlisting>This commands loads module with selected
2550 one card support for PIP5 board type with IO port base address
2551 <constant>0x8000</constant> and interrupt line <constant>4</constant>.
2552 The full description of module parameters is in the next subsection.
2553 If module starts correctly utilities from <filename>utils</filename>
2554 subdirectory can be used to test CAN message interchange with device
2555 or another computer. The parameters should be written into file
2556 <filename>/etc/modules.conf </filename>for subsequent module startup
2557 by modprobe command.</para>
2559 <para>Line added to file <filename>/etc/modules.conf</filename>
2560 follows<programlisting>options can hw=pip5 irq=4 io=0x8000</programlisting>The
2561 module dependencies should be updated by command
2562 <programlisting>depmod -a</programlisting>The driver can be now stopped and started by
2563 simple <command>modprobe</command> command
2564 <programlisting>modprobe -r can modprobe can</programlisting></para>
2568 <title>Installation instructions</title>
2570 <para>The LINCAN make solutions tries to fully automate native
2571 kernel out of tree module compilation. Make system recurses through
2572 kernel <filename>Makefile</filename> to achieve selection of right
2573 preprocessor, compiler and linker directives. The description of
2574 make targets after make invocation in driver top directory follows</para>
2578 <term>lincan-drv/Makefile (all)</term>
2581 <para>LINCAN driver top makefile</para>
2586 <term>lincan-drv/src/Makefile (default or all ->
2587 make_this_module)</term>
2590 <para>Needs to resolve target system kernel sources location.
2591 This can be selected manually by uncommenting the
2592 <filename>Makefile</filename> definition <command>KERNEL_LOCATION=/usr/src/linux-2.2.22</command>.
2593 The default behavior is to find the running kernel version and
2594 look for path to sources of found kernel version in
2595 <filename>/lib/modules/2.<replaceable>x</replaceable>.<replaceable>y</replaceable>/build</filename>
2596 directory. If no such directory exists, older version of
2597 kernel is assumed and makefile tries the <filename>/usr/src/linux</filename>
2603 <term>lib/modules/2.<replaceable>x</replaceable>.<replaceable>y</replaceable>/build/Makefile
2604 <envar>SUBDIRS</envar>=.../lincan-drv/src (modules)</term>
2607 <para>The kernel supplied <filename>Makefile</filename> is
2608 responsible for defining of right defines for preprocessor,
2609 compiler and linker. If the Linux kernel is cross-compiled,
2610 Linux kernel sources root <filename>Makefile</filename> needs
2611 be edited before Linux kernel compilation. The variable
2612 <envar>CROSS_COMPILE</envar> should contain development
2613 toolchain prefix, for example <command>arm-linux-</command>.
2614 The Linux kernel make process recurses back into LINCAN driver
2615 <filename>src/Makefile</filename>.</para>
2620 <term>lincan-drv/src/Makefile (modules)</term>
2623 <para>This pass starts real LINCAN driver build actions.</para>
2628 <para>If there is problem with automatic build process, the next
2629 commands can help to diagnose the problem.</para>
2631 <para><programlisting>make clean make >make.out 2>&1</programlisting></para>
2633 <para>The first lines of file <filename>make.out</filename>
2634 indicates autodetected values and can help with resolving of
2635 possible problems.</para>
2638 make -C src default ;
2639 make -C utils default ;
2640 make[1]: /scripts/pathdown.sh: Command not found
2641 make[1]: Entering directory `/usr/src/can-0.7.1-pi3.4/src'
2642 echo >.supported_cards.h echo \#define ENABLE_CARD_pip 1 >>.supported_cards.h ; ...
2643 Linux kernel version 2.4.19
2644 echo Linux kernel sources /lib/modules/2.4.19/build
2645 Linux kernel sources /lib/modules/2.4.19/build
2646 echo Module target can.o
2648 echo Module objects proc.o pip.o pccan.o smartcan.o nsi.o ...
2649 make[2]: Entering directory `/usr/src/linux-2.4.19'</screen>
2651 <para>The driver size can be decreased by restricting of number of
2652 supported types of boards. This can be done by editing of definition
2653 for <envar>SUPPORTED_CARDS</envar> variable.</para>
2655 <para> There is complete description of driver supported parameters.
2657 insmod can.o hw=<replaceable>'your hardware'</replaceable> irq=<replaceable>'irq number'</replaceable> io=<replaceable>'io address'</replaceable> <replaceable><more options></replaceable>
2660 <para>The more values can be specified for <parameter>hw</parameter>,
2661 <parameter>irq</parameter> and <parameter>io</parameter> parameters
2662 if more cards is used. Values are separated by commas in such case.
2663 The <parameter>hw</parameter> argument can be one of:</para>
2667 <para><option>pip5</option>, for the PIP5 computer by MPL AG</para>
2671 <para><option>pip6</option>, for the PIP6 computer by MPL AG</para>
2675 <para><option>pip7</option>, for the PIP7 computer by MPL AG</para>
2679 <para><option>pip8</option>, for the PIP8 computer by MPL AG</para>
2683 <para><option>pccan-q</option>, for the PCcan-Q ISA card by
2688 <para><option>pccan-f</option>, for the PCcan-F ISA card by
2693 <para><option>pccan-s</option>, for the PCcan-S ISA card by
2698 <para><option>pccan-d</option>, for the PCcan-D ISA card by
2703 <para><option>nsican</option>, for the CAN104 PC/104 card by NSI</para>
2707 <para><option>cc104</option>, for the CAN104 PC/104 card by
2708 Contemporary Controls</para>
2712 <para><option>aim104</option>, for the AIM104CAN PC/104 card by
2713 Arcom Control Systems </para>
2717 <para><option>pc-i03</option>, for the PC-I03 ISA card by IXXAT</para>
2721 <para><option>pcm3680</option>, for the PCM-3680 PC/104 card by
2726 <para><option>m437</option>, for the M436 PC/104 card by SECO</para>
2730 <para><option>bfadcan</option> for sja1000 CAN embedded card
2731 made by BFAD GmbH</para>
2735 <para><option>pikronisa</option> for ISA memory mapped sja1000
2736 CAN card made by PiKRON Ltd.</para>
2740 <para><option>template</option>, for yet unsupported hardware
2741 (you need to edit <filename>src/template.c</filename>)</para>
2745 <para>The <parameter><more options></parameter> can be one
2750 <para><parameter>major</parameter>=<replaceable><nr></replaceable>,
2751 major specifies the major number of the driver.</para>
2755 <para><parameter>minor</parameter>=<replaceable><nr></replaceable>,
2756 you can specify which minor numbers the driver should use for
2757 your hardware</para>
2761 <para><parameter>extended</parameter>=<replaceable>[</replaceable>1<replaceable>|</replaceable>0<replaceable>]</replaceable>,
2762 configures the driver to use extended message format</para>
2766 <para><parameter>pelican</parameter>=<replaceable>[</replaceable>1<replaceable>|</replaceable>0<replaceable>]</replaceable>,
2767 configures the driver to set the CAN chips into pelican mode.</para>
2771 <para><parameter>baudrate</parameter>=<replaceable><nr></replaceable>,
2772 sets the baudrate of the device(s) </para>
2776 <para><parameter>clock_freq</parameter>=<replaceable><nr></replaceable>,
2777 the frequency of the CAN quartz </para>
2781 <para><parameter>stdmask</parameter>=<replaceable><nr></replaceable>,
2782 sets the standard mask of the device </para>
2786 <para><parameter>mo15mask</parameter>=<replaceable><nr></replaceable>,
2787 sets the mask for message object 15 (i82527 only)</para>