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