2 * Linux CAN-bus device driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * This software is released under the GPL-License.
5 * Version 0.7 6 Aug 2001
9 #include <linux/autoconf.h>
10 #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
14 #if defined (MODVERSIONS)
15 #include <linux/modversions.h>
18 #include ".supported_cards.h"
20 #ifndef ENABLE_CARD_pip
21 #define ENABLE_CARD_pip 0
23 #ifndef ENABLE_CARD_smartcan
24 #define ENABLE_CARD_smartcan 0
26 #ifndef ENABLE_CARD_pccan
27 #define ENABLE_CARD_pccan 0
29 #ifndef ENABLE_CARD_nsi
30 #define ENABLE_CARD_nsi 0
32 #ifndef ENABLE_CARD_cc_can104
33 #define ENABLE_CARD_cc_can104 0
35 #ifndef ENABLE_CARD_aim104
36 #define ENABLE_CARD_aim104 0
38 #ifndef ENABLE_CARD_pc_i03
39 #define ENABLE_CARD_pc_i03 0
41 #ifndef ENABLE_CARD_pcm3680
42 #define ENABLE_CARD_pcm3680 0
44 #ifndef ENABLE_CARD_m437
45 #define ENABLE_CARD_m437 0
47 #ifndef ENABLE_CARD_pcccan
48 #define ENABLE_CARD_pcccan 0
50 #ifndef ENABLE_CARD_ssv
51 #define ENABLE_CARD_ssv 0
53 #ifndef ENABLE_CARD_bfadcan
54 #define ENABLE_CARD_bfadcan 0
56 #ifndef ENABLE_CARD_pikronisa
57 #define ENABLE_CARD_pikronisa 0
59 #ifndef ENABLE_CARD_template
60 #define ENABLE_CARD_template 0
63 #include <linux/string.h>
66 #include "../include/main.h"
67 #include "../include/modparms.h"
69 int parse_mod_parms(void)
71 int i=0,j=0,irq_needed=0,irq_supplied=0,io_needed=0,io_supplied=0,minor_needed=0,minor_supplied=0;
73 if ( (hw[0] == NULL) | (irq[0] == -1) | (io[0] == -1) ) {
74 CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
75 CANMSG("Example: # insmod can.o hw=pip5 irq=4 io=0x8000\n");
79 while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
80 if ( !strcmp(hw[i],"pip5") && ENABLE_CARD_pip )
82 else if (!strcmp(hw[i],"pip6") && ENABLE_CARD_pip)
84 else if (!strcmp(hw[i],"smartcan") && ENABLE_CARD_smartcan)
86 else if (!strcmp(hw[i],"pccan-q") && ENABLE_CARD_pccan)
87 irq_needed=irq_needed+4;
88 else if (!strcmp(hw[i],"pccan-f") && ENABLE_CARD_pccan)
90 else if (!strcmp(hw[i],"pccan-s") && ENABLE_CARD_pccan)
92 else if (!strcmp(hw[i],"pccan-d") && ENABLE_CARD_pccan)
93 irq_needed=irq_needed+2;
94 else if (!strcmp(hw[i],"nsican") && ENABLE_CARD_nsi)
96 else if (!strcmp(hw[i],"cc104") && ENABLE_CARD_cc_can104)
98 else if (!strcmp(hw[i],"aim104") && ENABLE_CARD_aim104)
100 else if (!strcmp(hw[i],"pc-i03") && ENABLE_CARD_pc_i03)
102 else if (!strcmp(hw[i],"pcm3680") && ENABLE_CARD_pcm3680)
103 irq_needed=irq_needed+2;
104 else if (!strcmp(hw[i],"m437") && ENABLE_CARD_m437)
106 else if (!strcmp(hw[i],"pcccan") && ENABLE_CARD_pcccan)
108 else if (!strcmp(hw[i],"ssv") && ENABLE_CARD_ssv)
109 irq_needed=irq_needed+2;
110 else if (!strcmp(hw[i],"bfadcan") && ENABLE_CARD_bfadcan)
112 else if (!strcmp(hw[i],"pikronisa") && ENABLE_CARD_pikronisa)
114 else if (!strcmp(hw[i],"template") && ENABLE_CARD_template);
116 CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hw[i]);
122 /* Check wether the supplied number of io addresses is correct. */
124 while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) )
126 if (io_needed != io_supplied) {
127 CANMSG("Invalid number of io addresses.\n");
128 CANMSG("Supplied hardware needs %d io address(es).\n",io_needed);
132 /* Check wether the supplied number of irq's is correct. */
133 while ( (irq[irq_supplied] != -1) & (irq_supplied<MAX_IRQ) )
135 while ( (hw[j] != NULL) && (j<MAX_HW_CARDS) ) {
136 if (!strcmp(hw[j],"template") && ENABLE_CARD_template)
137 irq_needed = irq_supplied;
140 if (irq_needed != irq_supplied) {
141 CANMSG("Invalid number of interrupts.\n");
142 CANMSG("Supplied harware needs %d irq number(s).\n",irq_needed);
146 /* In case minor numbers were assigned check wether the correct number
147 * of minor numbers was supplied.
149 if (minor[0] != -1) {
150 minor_needed=irq_needed;
151 while ((minor[minor_supplied] != -1) & (minor_supplied<MAX_IRQ))
153 if (minor_supplied != minor_needed) {
154 CANMSG("Invalid number of minor numbers.\n");
155 CANMSG("Supplied hardware needs %d minor number(s).\n",minor_needed);
162 /* list_hw is used when debugging is on to show the hardware layout */
167 DEBUGMSG("Number of boards : %d\n",hardware_p->nr_boards);
169 while ( (hw[i] != NULL) & (i<=MAX_HW_CARDS-1) ) {
170 printk(KERN_ERR "\n");
171 DEBUGMSG("Hardware : %s\n",hardware_p->candevice[i]->hwname);
172 DEBUGMSG("IO address : 0x%lx\n",hardware_p->candevice[i]->io_addr);
173 DEBUGMSG("Nr. of i82527 : %d\n",hardware_p->candevice[i]->nr_82527_chips);
174 DEBUGMSG("Nr. of sja1000 : %d\n",hardware_p->candevice[i]->nr_sja1000_chips);
175 for (j=0; j<hardware_p->candevice[i]->nr_82527_chips+hardware_p->candevice[i]->nr_sja1000_chips; j++) {
176 DEBUGMSG("Chip%d type : %s\n", j+1, hardware_p->candevice[i]->chip[j]->chip_type);
177 DEBUGMSG("Chip base : 0x%lx\n",hardware_p->candevice[i]->chip[j]->chip_base_addr);
178 DEBUGMSG("Interrupt : %d\n",hardware_p->candevice[i]->chip[j]->chip_irq);
181 if (!strcmp(hardware_p->candevice[i]->chip[j]->chip_type,"i82527")) {
183 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);
186 if (!strcmp(hardware_p->candevice[i]->chip[j]->chip_type,"sja1000")) {
188 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);