]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/e1000e/param.c
Merge branches 'sched/devel', 'sched/cpu-hotplug', 'sched/cpusets' and 'sched/urgent...
[linux-2.6-omap-h63xx.git] / drivers / net / e1000e / param.c
index a66b92efcf80c231a35694fe3b5fb63e3ca69f64..d91dbf7ba4341665c403fe9491f81355098db80d 100644 (file)
@@ -27,6 +27,7 @@
 *******************************************************************************/
 
 #include <linux/netdevice.h>
+#include <linux/pci.h>
 
 #include "e1000.h"
 
@@ -132,6 +133,15 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
  */
 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
 
+/*
+ * Write Protect NVM
+ *
+ * Valid Range: 0, 1
+ *
+ * Default Value: 1 (enabled)
+ */
+E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
+
 struct e1000_option {
        enum { enable_option, range_option, list_option } type;
        const char *name;
@@ -162,17 +172,16 @@ static int __devinit e1000_validate_option(unsigned int *value,
        case enable_option:
                switch (*value) {
                case OPTION_ENABLED:
-                       ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
+                       e_info("%s Enabled\n", opt->name);
                        return 0;
                case OPTION_DISABLED:
-                       ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
+                       e_info("%s Disabled\n", opt->name);
                        return 0;
                }
                break;
        case range_option:
                if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
-                       ndev_info(adapter->netdev,
-                                       "%s set to %i\n", opt->name, *value);
+                       e_info("%s set to %i\n", opt->name, *value);
                        return 0;
                }
                break;
@@ -184,8 +193,7 @@ static int __devinit e1000_validate_option(unsigned int *value,
                        ent = &opt->arg.l.p[i];
                        if (*value == ent->i) {
                                if (ent->str[0] != '\0')
-                                       ndev_info(adapter->netdev, "%s\n",
-                                                 ent->str);
+                                       e_info("%s\n", ent->str);
                                return 0;
                        }
                }
@@ -195,8 +203,8 @@ static int __devinit e1000_validate_option(unsigned int *value,
                BUG();
        }
 
-       ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
-              opt->name, *value, opt->err);
+       e_info("Invalid %s value specified (%i) %s\n", opt->name, *value,
+              opt->err);
        *value = opt->def;
        return -1;
 }
@@ -213,13 +221,11 @@ static int __devinit e1000_validate_option(unsigned int *value,
 void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
-       struct net_device *netdev = adapter->netdev;
        int bd = adapter->bd_number;
 
        if (bd >= E1000_MAX_NIC) {
-               ndev_notice(netdev,
-                      "Warning: no configuration for board #%i\n", bd);
-               ndev_notice(netdev, "Using defaults for all values\n");
+               e_notice("Warning: no configuration for board #%i\n", bd);
+               e_notice("Using defaults for all values\n");
        }
 
        { /* Transmit Interrupt Delay */
@@ -313,32 +319,41 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                        adapter->itr = InterruptThrottleRate[bd];
                        switch (adapter->itr) {
                        case 0:
-                               ndev_info(netdev, "%s turned off\n",
-                                       opt.name);
+                               e_info("%s turned off\n", opt.name);
                                break;
                        case 1:
-                               ndev_info(netdev,
-                                         "%s set to dynamic mode\n",
-                                         opt.name);
+                               e_info("%s set to dynamic mode\n", opt.name);
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
                        case 3:
-                               ndev_info(netdev,
-                                       "%s set to dynamic conservative mode\n",
+                               e_info("%s set to dynamic conservative mode\n",
                                        opt.name);
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
                        default:
-                               e1000_validate_option(&adapter->itr, &opt,
-                                       adapter);
                                /*
-                                * save the setting, because the dynamic bits
-                                * change itr. clear the lower two bits
-                                * because they are used as control
+                                * Save the setting, because the dynamic bits
+                                * change itr.
                                 */
-                               adapter->itr_setting = adapter->itr & ~3;
+                               if (e1000_validate_option(&adapter->itr, &opt,
+                                                         adapter) &&
+                                   (adapter->itr == 3)) {
+                                       /*
+                                        * In case of invalid user value,
+                                        * default to conservative mode.
+                                        */
+                                       adapter->itr_setting = adapter->itr;
+                                       adapter->itr = 20000;
+                               } else {
+                                       /*
+                                        * Clear the lower two bits because
+                                        * they are used as control.
+                                        */
+                                       adapter->itr_setting =
+                                               adapter->itr & ~3;
+                               }
                                break;
                        }
                } else {
@@ -382,4 +397,25 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                                                                       opt.def);
                }
        }
+       { /* Write-protect NVM */
+               const struct e1000_option opt = {
+                       .type = enable_option,
+                       .name = "Write-protect NVM",
+                       .err  = "defaulting to Enabled",
+                       .def  = OPTION_ENABLED
+               };
+
+               if (adapter->flags & FLAG_IS_ICH) {
+                       if (num_WriteProtectNVM > bd) {
+                               unsigned int write_protect_nvm = WriteProtectNVM[bd];
+                               e1000_validate_option(&write_protect_nvm, &opt,
+                                                     adapter);
+                               if (write_protect_nvm)
+                                       adapter->flags |= FLAG_READ_ONLY_NVM;
+                       } else {
+                               if (opt.def)
+                                       adapter->flags |= FLAG_READ_ONLY_NVM;
+                       }
+               }
+       }
 }