]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/modparms.c
changed usb vendor and product id.
[lincan.git] / lincan / src / modparms.c
1 /* mod_parms.c
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.3  17 Jun 2004
8  */
9
10
11 #include "../include/can.h"
12 #include "../include/can_sysdep.h"
13 #include "../include/main.h"
14 #include "../include/modparms.h"
15
16 int parse_mod_parms(void)
17 {
18         int i=0,j=0,irq_needed=0,irq_supplied=0,io_needed=0,io_supplied=0,minor_needed=0,minor_supplied=0;
19         const struct boardtype_t *brp;
20
21         if ( (hw[0] == NULL) | (io[0] == -1) ) {
22                 //CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
23                 CANMSG("Autodetection works only for USB devices, supply your type of hardware for PCI devices \n");
24                 CANMSG("Example: # insmod can.o hw=pip5 irq=4 io=0x8000\n");
25                 //return -ENODEV;
26         }
27
28         while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
29                 brp = boardtype_find(hw[i]);
30                 if(!brp) {
31                         CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hw[i]);
32                         return -EINVAL;
33                 }
34                 irq_needed += brp->irqnum;
35                 i++;
36         }
37
38         /* Check wether the supplied number of io addresses is correct. */
39         io_needed=i;
40         while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) )
41                 io_supplied++;
42         if (io_needed != io_supplied) {
43                 CANMSG("Invalid number of io addresses.\n");
44                 CANMSG("Supplied hardware needs %d io address(es).\n",io_needed);
45                 return -EINVAL;
46         }
47
48         /* Check wether the supplied number of irq's is correct. */
49         while ( (irq[irq_supplied] != -1) & (irq_supplied<MAX_IRQ) )
50                 irq_supplied++;
51         while ( (hw[j] != NULL) && (j<MAX_HW_CARDS) ) {
52                 if (!strcmp(hw[j],"template"))
53                         irq_needed = irq_supplied;
54                 j++;
55         }
56         if (irq_needed != irq_supplied) {
57                 CANMSG("Invalid number of interrupts.\n");
58                 CANMSG("Supplied harware needs %d irq number(s).\n",irq_needed);
59                 return -EINVAL;
60         }
61
62         /* In case minor numbers were assigned check wether the correct number
63          * of minor numbers was supplied.
64          */
65         if (minor[0] != -1) {
66                 minor_needed=irq_needed;
67                 while ((minor[minor_supplied] != -1) & (minor_supplied<MAX_IRQ))
68                         minor_supplied++;
69                 if (minor_supplied != minor_needed) {
70                         CANMSG("Invalid number of minor numbers.\n");
71                         CANMSG("Supplied hardware needs %d minor number(s).\n",minor_needed);
72                         return -EINVAL;
73                 }
74         }
75
76         return 0;
77 }
78 /* list_hw is used when debugging is on to show the hardware layout */
79 int list_hw(void)
80 {
81         int i=0,j=0,k=0;
82
83         DEBUGMSG("Number of boards : %d\n",hardware_p->nr_boards);
84
85         while ( (hw[i] != NULL) & (i<=MAX_HW_CARDS-1) ) {
86                 printk(KERN_ERR "\n");
87                 DEBUGMSG("Hardware         : %s\n",hardware_p->candevice[i]->hwname);
88                 DEBUGMSG("IO address       : 0x%lx\n",hardware_p->candevice[i]->io_addr);
89                 DEBUGMSG("Nr. all chips    : %d\n",hardware_p->candevice[i]->nr_all_chips);
90                 DEBUGMSG("Nr. of i82527    : %d\n",hardware_p->candevice[i]->nr_82527_chips);
91                 DEBUGMSG("Nr. of sja1000   : %d\n",hardware_p->candevice[i]->nr_sja1000_chips);
92                 for (j=0; j<hardware_p->candevice[i]->nr_all_chips; j++) {
93                         DEBUGMSG("Chip%d type       : %s\n", j+1, hardware_p->candevice[i]->chip[j]->chip_type);
94                         DEBUGMSG("Chip base        : 0x%lx\n",hardware_p->candevice[i]->chip[j]->chip_base_addr);
95                         DEBUGMSG("Interrupt        : %d\n",hardware_p->candevice[i]->chip[j]->chip_irq);
96
97
98                         for (k=0; k<hardware_p->candevice[i]->chip[j]->max_objects; k++)
99                                 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);
100
101                 }
102                 i++;
103         }
104         return 0;
105 }