2 * Linux CAN-bus device driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
5 * email:pisa@cmp.felk.cvut.cz
6 * This software is released under the GPL-License.
7 * Version lincan-0.2 9 Jul 2003
11 #include <linux/autoconf.h>
13 #include ".supported_cards.h"
15 #ifndef ENABLE_CARD_pip
16 #define ENABLE_CARD_pip 0
18 #ifndef ENABLE_CARD_smartcan
19 #define ENABLE_CARD_smartcan 0
21 #ifndef ENABLE_CARD_pccan
22 #define ENABLE_CARD_pccan 0
24 #ifndef ENABLE_CARD_nsi
25 #define ENABLE_CARD_nsi 0
27 #ifndef ENABLE_CARD_cc_can104
28 #define ENABLE_CARD_cc_can104 0
30 #ifndef ENABLE_CARD_aim104
31 #define ENABLE_CARD_aim104 0
33 #ifndef ENABLE_CARD_pc_i03
34 #define ENABLE_CARD_pc_i03 0
36 #ifndef ENABLE_CARD_pcm3680
37 #define ENABLE_CARD_pcm3680 0
39 #ifndef ENABLE_CARD_m437
40 #define ENABLE_CARD_m437 0
42 #ifndef ENABLE_CARD_pcccan
43 #define ENABLE_CARD_pcccan 0
45 #ifndef ENABLE_CARD_ssv
46 #define ENABLE_CARD_ssv 0
48 #ifndef ENABLE_CARD_bfadcan
49 #define ENABLE_CARD_bfadcan 0
51 #ifndef ENABLE_CARD_pikronisa
52 #define ENABLE_CARD_pikronisa 0
54 #ifndef ENABLE_CARD_template
55 #define ENABLE_CARD_template 0
58 #include <linux/string.h>
61 #include "../include/main.h"
62 #include "../include/modparms.h"
64 int parse_mod_parms(void)
66 int i=0,j=0,irq_needed=0,irq_supplied=0,io_needed=0,io_supplied=0,minor_needed=0,minor_supplied=0;
68 if ( (hw[0] == NULL) | (irq[0] == -1) | (io[0] == -1) ) {
69 CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
70 CANMSG("Example: # insmod can.o hw=pip5 irq=4 io=0x8000\n");
74 while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
75 if ( !strcmp(hw[i],"pip5") && ENABLE_CARD_pip )
77 else if (!strcmp(hw[i],"pip6") && ENABLE_CARD_pip)
79 else if (!strcmp(hw[i],"smartcan") && ENABLE_CARD_smartcan)
81 else if (!strcmp(hw[i],"pccan-q") && ENABLE_CARD_pccan)
82 irq_needed=irq_needed+4;
83 else if (!strcmp(hw[i],"pccan-f") && ENABLE_CARD_pccan)
85 else if (!strcmp(hw[i],"pccan-s") && ENABLE_CARD_pccan)
87 else if (!strcmp(hw[i],"pccan-d") && ENABLE_CARD_pccan)
88 irq_needed=irq_needed+2;
89 else if (!strcmp(hw[i],"nsican") && ENABLE_CARD_nsi)
91 else if (!strcmp(hw[i],"cc104") && ENABLE_CARD_cc_can104)
93 else if (!strcmp(hw[i],"aim104") && ENABLE_CARD_aim104)
95 else if (!strcmp(hw[i],"pc-i03") && ENABLE_CARD_pc_i03)
97 else if (!strcmp(hw[i],"pcm3680") && ENABLE_CARD_pcm3680)
98 irq_needed=irq_needed+2;
99 else if (!strcmp(hw[i],"m437") && ENABLE_CARD_m437)
101 else if (!strcmp(hw[i],"pcccan") && ENABLE_CARD_pcccan)
103 else if (!strcmp(hw[i],"ssv") && ENABLE_CARD_ssv)
104 irq_needed=irq_needed+2;
105 else if (!strcmp(hw[i],"bfadcan") && ENABLE_CARD_bfadcan)
107 else if (!strcmp(hw[i],"pikronisa") && ENABLE_CARD_pikronisa)
109 else if (!strcmp(hw[i],"template") && ENABLE_CARD_template);
111 CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hw[i]);
117 /* Check wether the supplied number of io addresses is correct. */
119 while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) )
121 if (io_needed != io_supplied) {
122 CANMSG("Invalid number of io addresses.\n");
123 CANMSG("Supplied hardware needs %d io address(es).\n",io_needed);
127 /* Check wether the supplied number of irq's is correct. */
128 while ( (irq[irq_supplied] != -1) & (irq_supplied<MAX_IRQ) )
130 while ( (hw[j] != NULL) && (j<MAX_HW_CARDS) ) {
131 if (!strcmp(hw[j],"template") && ENABLE_CARD_template)
132 irq_needed = irq_supplied;
135 if (irq_needed != irq_supplied) {
136 CANMSG("Invalid number of interrupts.\n");
137 CANMSG("Supplied harware needs %d irq number(s).\n",irq_needed);
141 /* In case minor numbers were assigned check wether the correct number
142 * of minor numbers was supplied.
144 if (minor[0] != -1) {
145 minor_needed=irq_needed;
146 while ((minor[minor_supplied] != -1) & (minor_supplied<MAX_IRQ))
148 if (minor_supplied != minor_needed) {
149 CANMSG("Invalid number of minor numbers.\n");
150 CANMSG("Supplied hardware needs %d minor number(s).\n",minor_needed);
157 /* list_hw is used when debugging is on to show the hardware layout */
162 DEBUGMSG("Number of boards : %d\n",hardware_p->nr_boards);
164 while ( (hw[i] != NULL) & (i<=MAX_HW_CARDS-1) ) {
165 printk(KERN_ERR "\n");
166 DEBUGMSG("Hardware : %s\n",hardware_p->candevice[i]->hwname);
167 DEBUGMSG("IO address : 0x%lx\n",hardware_p->candevice[i]->io_addr);
168 DEBUGMSG("Nr. all chips : %d\n",hardware_p->candevice[i]->nr_all_chips);
169 DEBUGMSG("Nr. of i82527 : %d\n",hardware_p->candevice[i]->nr_82527_chips);
170 DEBUGMSG("Nr. of sja1000 : %d\n",hardware_p->candevice[i]->nr_sja1000_chips);
171 for (j=0; j<hardware_p->candevice[i]->nr_all_chips; j++) {
172 DEBUGMSG("Chip%d type : %s\n", j+1, hardware_p->candevice[i]->chip[j]->chip_type);
173 DEBUGMSG("Chip base : 0x%lx\n",hardware_p->candevice[i]->chip[j]->chip_base_addr);
174 DEBUGMSG("Interrupt : %d\n",hardware_p->candevice[i]->chip[j]->chip_irq);
177 for (k=0; k<hardware_p->candevice[i]->chip[j]->max_objects; k++)
178 DEBUGMSG("Obj%d: minor: %d base: 0x%lx\n",k,hardware_p->candevice[i]->chip[j]->msgobj[k]->minor,hardware_p->candevice[i]->chip[j]->msgobj[k]->obj_base_addr);