1 /**************************************************************************/
2 /* File: modparms.c - driver module parameters parsing */
4 /* LinCAN - (Not only) Linux CAN bus driver */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
7 /* Funded by OCERA and FRESCOR IST projects */
8 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl> */
10 /* LinCAN is free software; you can redistribute it and/or modify it */
11 /* under terms of the GNU General Public License as published by the */
12 /* Free Software Foundation; either version 2, or (at your option) any */
13 /* later version. LinCAN is distributed in the hope that it will be */
14 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
15 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* General Public License for more details. You should have received a */
17 /* copy of the GNU General Public License along with LinCAN; see file */
18 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
19 /* Cambridge, MA 02139, USA. */
21 /* To allow use of LinCAN in the compact embedded systems firmware */
22 /* and RT-executives (RTEMS for example), main authors agree with next */
23 /* special exception: */
25 /* Including LinCAN header files in a file, instantiating LinCAN generics */
26 /* or templates, or linking other files with LinCAN objects to produce */
27 /* an application image/executable, does not by itself cause the */
28 /* resulting application image/executable to be covered by */
29 /* the GNU General Public License. */
30 /* This exception does not however invalidate any other reasons */
31 /* why the executable file might be covered by the GNU Public License. */
32 /* Publication of enhanced or derived LinCAN files is required although. */
33 /**************************************************************************/
36 #include "../include/can.h"
37 #include "../include/can_sysdep.h"
38 #include "../include/main.h"
39 #include "../include/modparms.h"
41 int parse_mod_parms(void)
43 int i=0,j=0,irq_needed=0,irq_supplied=0,io_needed=0,io_supplied=0,minor_needed=0,minor_supplied=0;
44 const struct boardtype_t *brp;
46 if ( (hw[0] == NULL) | (io[0] == -1) ) {
47 CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
48 CANMSG("Example: # insmod lincan.ko hw=pip5 irq=4 io=0x8000\n");
52 while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
53 brp = boardtype_find(hw[i]);
55 CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hw[i]);
58 irq_needed += brp->irqnum;
62 /* Check wether the supplied number of io addresses is correct. */
64 while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) )
66 if (io_needed != io_supplied) {
67 CANMSG("Invalid number of io addresses.\n");
68 CANMSG("Supplied hardware needs %d io address(es).\n",io_needed);
72 /* Check wether the supplied number of irq's is correct. */
73 while ( (irq[irq_supplied] != -1) & (irq_supplied<MAX_IRQ) )
75 while ( (hw[j] != NULL) && (j<MAX_HW_CARDS) ) {
76 if (!strcmp(hw[j],"template"))
77 irq_needed = irq_supplied;
80 if (irq_needed != irq_supplied) {
81 CANMSG("Invalid number of interrupts.\n");
82 CANMSG("Supplied harware needs %d irq number(s).\n",irq_needed);
86 /* In case minor numbers were assigned check wether the correct number
87 * of minor numbers was supplied.
90 minor_needed=irq_needed;
91 while ((minor[minor_supplied] != -1) & (minor_supplied<MAX_IRQ))
93 if (minor_supplied != minor_needed) {
94 CANMSG("Invalid number of minor numbers.\n");
95 CANMSG("Supplied hardware needs %d minor number(s).\n",minor_needed);
102 /* list_hw is used when debugging is on to show the hardware layout */
107 DEBUGMSG("Number of boards : %d\n",hardware_p->nr_boards);
109 while ( (hw[i] != NULL) & (i<=MAX_HW_CARDS-1) ) {
110 printk(KERN_ERR "\n");
111 DEBUGMSG("Hardware : %s\n",hardware_p->candevice[i]->hwname);
112 DEBUGMSG("IO address : 0x%lx\n",hardware_p->candevice[i]->io_addr);
113 DEBUGMSG("Nr. all chips : %d\n",hardware_p->candevice[i]->nr_all_chips);
114 DEBUGMSG("Nr. of i82527 : %d\n",hardware_p->candevice[i]->nr_82527_chips);
115 DEBUGMSG("Nr. of sja1000 : %d\n",hardware_p->candevice[i]->nr_sja1000_chips);
116 for (j=0; j<hardware_p->candevice[i]->nr_all_chips; j++) {
117 DEBUGMSG("Chip%d type : %s\n", j+1, hardware_p->candevice[i]->chip[j]->chip_type);
118 DEBUGMSG("Chip base : 0x%lx\n",hardware_p->candevice[i]->chip[j]->chip_base_addr);
119 DEBUGMSG("Interrupt : %d\n",hardware_p->candevice[i]->chip[j]->chip_irq);
122 for (k=0; k<hardware_p->candevice[i]->chip[j]->max_objects; k++)
123 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);