--- sangam-atm-1.0.orig/tn7atm.c	2007-05-18 09:45:50.000000000 +0200
+++ sangam-atm-1.0/tn7atm.c	2009-12-17 19:10:27.616421480 +0100
@@ -61,7 +61,6 @@
  *    UR8_MERGE_END   CQ11057*
 *********************************************************************************************/
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -69,11 +68,20 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
 #include <linux/proc_fs.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
+#include <linux/version.h>
+
+#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
+
 #include "dsl_hal_api.h"
 #include "tn7atm.h"
 #include "tn7api.h"
@@ -82,8 +90,149 @@
 #include "dsl_hal_register.h"
 
 #ifdef MODULE
+MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
 MODULE_AUTHOR ("Zhicheng Tang");
+
+int mp_sar_ipacemax = -1;
+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
+
+char *mp_macc = NULL;
+module_param_named(macc, mp_macc, charp, 0);
+MODULE_PARM_DESC(macc, "MAC address");
+
+int mp_dsp_noboost = -1;
+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
+
+int mp_dsp_freq = -1;
+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
+
+char *mp_featctl0 = NULL;
+module_param_named(featctl0, mp_featctl0, charp, 0);
+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
+
+char *mp_featctl1 = NULL;
+module_param_named(featctl1, mp_featctl1, charp, 0);
+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
+
+char *mp_phyctl0 = NULL;
+module_param_named(phyctl0, mp_phyctl0, charp, 0);
+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
+
+char *mp_phyctl1 = NULL;
+module_param_named(phyctl1, mp_phyctl1, charp, 0);
+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
+
+int mp_turbodsl = -1;
+module_param_named(turbodsl, mp_turbodsl, int, 0);
+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
+
+int mp_sar_rxbuf = -1;
+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
+
+int mp_sar_rxmax = -1;
+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
+
+int mp_sar_txbuf = -1;
+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
+
+int mp_sar_txmax = -1;
+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
+
+char *mp_modulation = NULL;
+module_param_named(modulation, mp_modulation, charp, 0);
+MODULE_PARM_DESC(modulation, "Modulation");
+
+int mp_fine_gain_control = -1;
+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
+
+int mp_fine_gain_value = -1;
+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
+
+int mp_enable_margin_retrain = -1;
+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
+
+int mp_margin_threshold = -1;
+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
+
+int mp_enable_rate_adapt = -1;
+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
+
+int mp_powercutback = -1;
+module_param_named(powercutback, mp_powercutback, int, 0);
+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
+
+int mp_trellis = -1;
+module_param_named(trellis, mp_trellis, int, 0);
+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
+
+int mp_bitswap = -1;
+module_param_named(bitswap, mp_bitswap, int, 0);
+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
+
+int mp_maximum_bits_per_carrier = -1;
+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
+
+int mp_maximum_interleave_depth = -1;
+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
+
+int mp_pair_selection = -1;
+module_param_named(pair_selection, mp_pair_selection, int, 0);
+MODULE_PARM_DESC(pair_selection, "Pair selection");
+
+int mp_dgas_polarity = -1;
+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
+
+int mp_los_alarm = -1;
+module_param_named(los_alarm, mp_los_alarm, int, 0);
+MODULE_PARM_DESC(los_alarm, "LOS alarm");
+
+char *mp_eoc_vendor_id = NULL;
+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
+
+int mp_eoc_vendor_revision = -1;
+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
+
+char *mp_eoc_vendor_serialnum = NULL;
+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
+
+char *mp_invntry_vernum = NULL;
+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
+
+int mp_dsl_bit_tmode = -1;
+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
+
+int mp_high_precision = -1;
+module_param_named(high_precision, mp_high_precision, int, 0);
+MODULE_PARM_DESC(high_precision, "High precision");
+
+int mp_autopvc_enable = -1;
+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
+
+int mp_oam_lb_timeout = -1;
+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
 #endif
 
 #ifndef TRUE
@@ -100,9 +249,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
 
 /*end of externs */
 
-#ifndef TI_STATIC_ALLOCATIONS
-#define TI_STATIC_ALLOCATIONS
-#endif
+//#ifndef TI_STATIC_ALLOCATIONS
+//#define TI_STATIC_ALLOCATIONS
+//#endif
 
 #define tn7atm_kfree_skb(x)     dev_kfree_skb(x)
 
@@ -114,7 +263,7 @@ static int EnableQoS = FALSE;
 /* prototypes */
 static int tn7atm_set_can_support_adsl2 (int can);
 
-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
+static int tn7atm_open (struct atm_vcc *vcc);
 
 static void tn7atm_close (struct atm_vcc *vcc);
 
@@ -257,13 +406,12 @@ static const struct atmdev_ops tn7atm_op
         getsockopt:     NULL,
         setsockopt:     NULL,
         send:           tn7atm_send,
-        sg_send:        NULL,
         phy_put:        NULL,
         phy_get:        NULL,
         change_qos:     tn7atm_change_qos,
 };
 
-const char drv_proc_root_folder[] = "avalanche/";
+const char drv_proc_root_folder[] = "avalanche";
 static struct proc_dir_entry *root_proc_dir_entry = NULL;
 #define DRV_PROC_MODE 0644
 static int proc_root_already_exists = TRUE;
@@ -559,62 +707,12 @@ static int turbodsl_check_priority_type(
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
- *  Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
- *
- *  Description: retrieve VPI/VCI for connection
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
-{
-  struct atm_vcc *walk;
-
-  /*
-   * find a free VPI
-   */
-  if (*vpi == ATM_VPI_ANY)
-  {
-
-    for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
-    {
-
-      if ((walk->vci == *vci) && (walk->vpi == *vpi))
-      {
-        (*vpi)++;
-        walk = vcc->dev->vccs;
-      }
-    }
-  }
-
-  /*
-   * find a free VCI
-   */
-  if (*vci == ATM_VCI_ANY)
-  {
-
-    for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
-         walk = walk->next)
-    {
-
-      if ((walk->vpi = *vpi) && (walk->vci == *vci))
-      {
-        *vci = walk->vci + 1;
-        walk = vcc->dev->vccs;
-      }
-    }
-  }
-
-  return 0;
-}
-
-
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
  *  Function: int tn7atm_sar_irq(void)
  *
  *  Description: tnetd73xx SAR interrupt.
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
 {
   struct atm_dev *atmdev;
   Tn7AtmPrivate *priv;
@@ -641,6 +739,7 @@ static void tn7atm_sar_irq (int irq, voi
 #ifdef TIATM_INST_SUPP
   psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
 #endif
+  return IRQ_HANDLED;
 }
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -650,7 +749,7 @@ static void tn7atm_sar_irq (int irq, voi
  *  Description: tnetd73xx DSL interrupt.
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
 {
   struct atm_dev *atmdev;
   Tn7AtmPrivate *priv;
@@ -672,6 +771,8 @@ static void tn7atm_dsl_irq (int irq, voi
 #ifdef TIATM_INST_SUPP
   psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
 #endif
+
+  return IRQ_HANDLED;
 }
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -693,25 +794,25 @@ static int __init tn7atm_irq_request (st
    * Register SAR interrupt
    */
   priv->sar_irq = LNXINTNUM (ATM_SAR_INT);      /* Interrupt line # */
-  if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
+  if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
     printk ("Could not register tn7atm_sar_irq\n");
 
   /*
    * interrupt pacing
    */
   ptr = prom_getenv ("sar_ipacemax");
-  if (ptr)
+  if (ptr || mp_sar_ipacemax != -1)
   {
-    def_sar_inter_pace = os_atoi (ptr);
+    def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
   }
-  avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
-                            def_sar_inter_pace);
+/*  avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+                            def_sar_inter_pace);*/
 
   /*
    * Reigster Receive interrupt A
    */
   priv->dsl_irq = LNXINTNUM (ATM_DSL_INT);      /* Interrupt line # */
-  if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
+  if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
     printk ("Could not register tn7atm_dsl_irq\n");
 
 /***** VRB Tasklet Mode ****/
@@ -842,7 +943,7 @@ static int __init tn7atm_get_ESI (struct
   char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
   char *esiaddr_str = NULL;
 
-  esiaddr_str = prom_getenv ("maca");
+  esiaddr_str = mp_macc ? mp_macc : prom_getenv ("maca");
 
   if (!esiaddr_str)
   {
@@ -875,11 +976,15 @@ static int __init tn7atm_get_ESI (struct
 #define ATM_VBR_RT     5
 #endif
 
-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
+int tn7atm_open (struct atm_vcc *vcc)
 {
   tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
   int rc;
   //int flags;
+  tn7atm_activate_vc_parm.pcr = 0x20000;
+  tn7atm_activate_vc_parm.scr = 0x20000;
+  tn7atm_activate_vc_parm.mbs = 0x20000;
+  tn7atm_activate_vc_parm.cdvt = 10000;
 
   dgprintf(1, "tn7atm_open()\n");
 
@@ -891,24 +996,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
     return -1;
   }
 
-  MOD_INC_USE_COUNT;
-
-  /* find a free VPI/VCI */
-  tn7atm_walk_vccs(vcc, &vpi, &vci);
-
-  vcc->vpi = vpi;
-  vcc->vci = vci;
+//  MOD_INC_USE_COUNT;
 
-  if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
+  if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
   {
-    MOD_DEC_USE_COUNT;
+//    MOD_DEC_USE_COUNT;
     return -EBUSY;
   }
 
-  tn7atm_activate_vc_parm.vpi = vpi;
-  tn7atm_activate_vc_parm.vci = vci;
+  tn7atm_activate_vc_parm.vpi = vcc->vpi;
+  tn7atm_activate_vc_parm.vci = vcc->vci;
 
-  if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
+  if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
   {
     /* always use (max_dma_chan+1) for clear eoc */
     tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
@@ -916,7 +1015,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
     /* check to see whether clear eoc is opened or not */
     if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
     {
-      MOD_DEC_USE_COUNT;
+//      MOD_DEC_USE_COUNT;
       printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
       return -EBUSY;
     }
@@ -925,7 +1024,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
     if (rc)
     {
       printk("tn7atm_open: failed to setup clear_eoc\n");
-      MOD_DEC_USE_COUNT;
+//      MOD_DEC_USE_COUNT;
       return -EBUSY;
     }
     tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
@@ -934,17 +1033,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
   }
   else  /* PVC channel setup */
   {
-    if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
+    if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
     {
       tn7atm_activate_vc_parm.chan = 14;   /* always use chan 14 for MII PVC-base romote mgmt */
     }
     else
     {
-       rc = tn7atm_lut_find(vpi, vci);
+       rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
       /* check to see whether PVC is opened or not */
       if(ATM_NO_DMA_CHAN != rc)
       {
-        MOD_DEC_USE_COUNT;
+//        MOD_DEC_USE_COUNT;
         printk("PVC already opened. dmachan = %d\n", rc);
         return -EBUSY;
       }
@@ -976,6 +1075,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
        tn7atm_activate_vc_parm.priority = 2;
        break;
 
+#if 0
      case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
        tn7atm_activate_vc_parm.qos = 1;
        tn7atm_activate_vc_parm.priority = 1;
@@ -997,6 +1097,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
            tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
        tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
        break;
+#endif
 
      default:
          tn7atm_activate_vc_parm.qos = 2;
@@ -1024,7 +1125,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
    if (rc < 0)
    {
       printk("failed to activate hw channel\n");
-      MOD_DEC_USE_COUNT;
+//      MOD_DEC_USE_COUNT;
       tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
       //spin_unlock_irqrestore(&chan_init_lock, flags);
       return -EBUSY;
@@ -1114,7 +1215,7 @@ void tn7atm_close (struct atm_vcc *vcc)
   tn7atm_lut_clear (vcc, dmachan);
   //spin_unlock_irqrestore (&closeLock, closeFlag);
 
-  MOD_DEC_USE_COUNT;
+//  MOD_DEC_USE_COUNT;
 
   dgprintf (1, "Leave tn7atm_close\n");
 }
@@ -1528,8 +1629,7 @@ int tn7atm_receive (void *os_dev, int ch
                                  * firewall is on */
 
   dgprintf (3, "pushing the skb...\n");
-
-  skb->stamp = vcc->timestamp = xtime;
+  __net_timestamp(skb);
 
   xdump ((unsigned char *) skb->data, skb->len, 5);
 
@@ -1725,8 +1825,7 @@ static void tn7atm_exit (void)
 
   kfree (dev->dev_data);
 
-  // atm_dev_deregister (dev);
-  shutdown_atm_dev (dev);
+  atm_dev_deregister (dev);
 
   /*
    * remove proc entries
@@ -1885,9 +1984,6 @@ static int __init tn7atm_detect (void)
   /*
    * Set up proc entry for atm stats
    */
-  if (tn7atm_xlate_proc_name
-      (drv_proc_root_folder, &root_proc_dir_entry, &residual))
-  {
     printk ("Creating new root folder %s in the proc for the driver stats \n",
             drv_proc_root_folder);
     root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
@@ -1897,7 +1993,6 @@ static int __init tn7atm_detect (void)
       return -ENOMEM;
     }
     proc_root_already_exists = FALSE;
-  }
 
   /*
    * AV: Clean-up. Moved all the definitions to the data structure.
@@ -1981,15 +2076,15 @@ static int tn7atm_autoDetectDspBoost (vo
 //UR8_MERGE_END   CQ10450*
 
   cp = prom_getenv ("dsp_noboost");
-  if (cp)
+  if (cp || mp_dsp_noboost != -1)
   {
-    dsp_noboost = os_atoi (cp);
+    dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
   }
 
   cp = (char *) prom_getenv ("dsp_freq");
-  if (cp)
+  if (cp || mp_dsp_freq != -1)
   {
-    dspfreq = os_atoi (cp);
+    dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
     if (dspfreq == 250)
     {
       boostDsp = 1;
@@ -2238,8 +2333,9 @@ static int __init tn7atm_init (struct at
   // Inter-Op DSL phy Control
   // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
   // dslhal_api_dslStartup (in tn7dsl_init()).
-  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
+  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
   {
+    if (mp_featctl0 != NULL) ptr = mp_featctl0;
     if ((ptr[0] == '0') && (ptr[1] == 'x'))     // skip 0x before pass to
       // os_atoh
       ptr += 2;
@@ -2247,8 +2343,9 @@ static int __init tn7atm_init (struct at
     _dsl_Feature_0_defined = 1;
   }
 
-  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
+  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
   {
+    if (mp_featctl1 != NULL) ptr = mp_featctl1;
     if ((ptr[0] == '0') && (ptr[1] == 'x'))     // skip 0x before pass to
       // os_atoh
       ptr += 2;
@@ -2260,8 +2357,9 @@ static int __init tn7atm_init (struct at
   // DSL phy Feature Control
   // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
   // dslhal_api_dslStartup (in tn7dsl_init()).
-  if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
+  if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
   {
+    if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
     if ((ptr[0] == '0') && (ptr[1] == 'x'))     // skip 0x before pass to
       // os_atoh
       ptr += 2;
@@ -2269,8 +2367,9 @@ static int __init tn7atm_init (struct at
     _dsl_PhyControl_0_defined = 1;
   }
 
-  if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
+  if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
   {
+    if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
     if ((ptr[0] == '0') && (ptr[1] == 'x'))     // skip 0x before pass to
       // os_atoh
       ptr += 2;
@@ -2298,9 +2397,9 @@ static int __init tn7atm_init (struct at
   priv->bTurboDsl = 1;
   // read config for turbo dsl
   ptr = prom_getenv ("TurboDSL");
-  if (ptr)
+  if (ptr || mp_turbodsl != -1)
   {
-    priv->bTurboDsl = os_atoi (ptr);
+    priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
   }
 
   // @Added to make Rx buffer number & Service max configurable through
@@ -2308,30 +2407,30 @@ static int __init tn7atm_init (struct at
   priv->sarRxBuf = RX_BUFFER_NUM;
   ptr = NULL;
   ptr = prom_getenv ("SarRxBuf");
-  if (ptr)
+  if (ptr || mp_sar_rxbuf != -1)
   {
-    priv->sarRxBuf = os_atoi (ptr);
+    priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
   }
   priv->sarRxMax = RX_SERVICE_MAX;
   ptr = NULL;
   ptr = prom_getenv ("SarRxMax");
-  if (ptr)
+  if (ptr || mp_sar_rxmax != -1)
   {
-    priv->sarRxMax = os_atoi (ptr);
+    priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
   }
   priv->sarTxBuf = TX_BUFFER_NUM;
   ptr = NULL;
   ptr = prom_getenv ("SarTxBuf");
-  if (ptr)
+  if (ptr || mp_sar_txbuf != -1)
   {
-    priv->sarTxBuf = os_atoi (ptr);
+    priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
   }
   priv->sarTxMax = TX_SERVICE_MAX;
   ptr = NULL;
   ptr = prom_getenv ("SarTxMax");
-  if (ptr)
+  if (ptr || mp_sar_txmax != -1)
   {
-    priv->sarTxMax = os_atoi (ptr);
+    priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
   }
 
   return 0;
@@ -2479,7 +2578,5 @@ static int tn7atm_proc_qos_write(struct 
     return count;
 }
 
-#ifdef MODULE
 module_init (tn7atm_detect);
 module_exit (tn7atm_exit);
-#endif /* MODULE */
