2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <linux/types.h>
25 #include <linux/moduleparam.h>
29 * This is the only thing that needs to be changed to adjust the
30 * maximum number of ports that the driver can manage.
32 #define ATL1_MAX_NIC 4
34 #define OPTION_UNSET -1
35 #define OPTION_DISABLED 0
36 #define OPTION_ENABLED 1
38 #define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET }
41 * Interrupt Moderate Timer in units of 2 us
43 * Valid Range: 10-65535
45 * Default Value: 100 (200us)
47 static int __devinitdata int_mod_timer
[ATL1_MAX_NIC
+1] = ATL1_PARAM_INIT
;
48 static int num_int_mod_timer
= 0;
49 module_param_array_named(int_mod_timer
, int_mod_timer
, int, &num_int_mod_timer
, 0);
50 MODULE_PARM_DESC(int_mod_timer
, "Interrupt moderator timer");
63 static int __devinitdata flash_vendor
[ATL1_MAX_NIC
+1] = ATL1_PARAM_INIT
;
64 static int num_flash_vendor
= 0;
65 module_param_array_named(flash_vendor
, flash_vendor
, int, &num_flash_vendor
, 0);
66 MODULE_PARM_DESC(flash_vendor
, "SPI flash vendor");
68 #define DEFAULT_INT_MOD_CNT 100 /* 200us */
69 #define MAX_INT_MOD_CNT 65000
70 #define MIN_INT_MOD_CNT 50
72 #define FLASH_VENDOR_DEFAULT 0
73 #define FLASH_VENDOR_MIN 0
74 #define FLASH_VENDOR_MAX 2
77 enum { enable_option
, range_option
, list_option
} type
;
82 struct { /* range_option info */
86 struct { /* list_option info */
88 struct atl1_opt_list
{
96 static int __devinit
atl1_validate_option(int *value
, struct atl1_option
*opt
)
98 if (*value
== OPTION_UNSET
) {
107 printk(KERN_INFO
"%s: %s Enabled\n", atl1_driver_name
,
110 case OPTION_DISABLED
:
111 printk(KERN_INFO
"%s: %s Disabled\n", atl1_driver_name
,
117 if (*value
>= opt
->arg
.r
.min
&& *value
<= opt
->arg
.r
.max
) {
118 printk(KERN_INFO
"%s: %s set to %i\n",
119 atl1_driver_name
, opt
->name
, *value
);
125 struct atl1_opt_list
*ent
;
127 for (i
= 0; i
< opt
->arg
.l
.nr
; i
++) {
128 ent
= &opt
->arg
.l
.p
[i
];
129 if (*value
== ent
->i
) {
130 if (ent
->str
[0] != '\0')
131 printk(KERN_INFO
"%s: %s\n",
132 atl1_driver_name
, ent
->str
);
143 printk(KERN_INFO
"%s: invalid %s specified (%i) %s\n",
144 atl1_driver_name
, opt
->name
, *value
, opt
->err
);
150 * atl1_check_options - Range Checking for Command Line Parameters
151 * @adapter: board private structure
153 * This routine checks all command line parameters for valid user
154 * input. If an invalid value is given, or if no user specified
155 * value exists, a default value is used. The final value is stored
156 * in a variable in the adapter structure.
158 void __devinit
atl1_check_options(struct atl1_adapter
*adapter
)
160 int bd
= adapter
->bd_number
;
161 if (bd
>= ATL1_MAX_NIC
) {
162 printk(KERN_NOTICE
"%s: warning: no configuration for board #%i\n",
163 atl1_driver_name
, bd
);
164 printk(KERN_NOTICE
"%s: using defaults for all values\n",
167 { /* Interrupt Moderate Timer */
168 struct atl1_option opt
= {
169 .type
= range_option
,
170 .name
= "Interrupt Moderator Timer",
171 .err
= "using default of "
172 __MODULE_STRING(DEFAULT_INT_MOD_CNT
),
173 .def
= DEFAULT_INT_MOD_CNT
,
175 {.min
= MIN_INT_MOD_CNT
,.max
= MAX_INT_MOD_CNT
}}
178 if (num_int_mod_timer
> bd
) {
179 val
= int_mod_timer
[bd
];
180 atl1_validate_option(&val
, &opt
);
181 adapter
->imt
= (u16
) val
;
183 adapter
->imt
= (u16
) (opt
.def
);
187 struct atl1_option opt
= {
188 .type
= range_option
,
189 .name
= "SPI Flash Vendor",
190 .err
= "using default of "
191 __MODULE_STRING(FLASH_VENDOR_DEFAULT
),
192 .def
= DEFAULT_INT_MOD_CNT
,
194 {.min
= FLASH_VENDOR_MIN
,.max
=
198 if (num_flash_vendor
> bd
) {
199 val
= flash_vendor
[bd
];
200 atl1_validate_option(&val
, &opt
);
201 adapter
->hw
.flash_vendor
= (u8
) val
;
203 adapter
->hw
.flash_vendor
= (u8
) (opt
.def
);