ssb: Update the GPIO API
[openwrt.git] / package / ar7-atm / patches / 100-compile_fix.patch
1 diff -u sangam_atm-D7.03.01.00.orig/cppi_cpaal5.c sangam_atm-D7.03.01.00/cppi_cpaal5.c
2 --- sangam_atm-D7.03.01.00.orig/cppi_cpaal5.c   2005-04-08 09:22:04.000000000 +0100
3 +++ sangam_atm-D7.03.01.00/cppi_cpaal5.c        2008-02-08 19:15:02.000000000 +0100
4 @@ -352,7 +352,7 @@
5             {
6              /* malloc failed, add this RCB to Needs Buffer List */
7              TempRcb->FragCount = 1;                                             /*MJH+030417*/
8 -            (HAL_RCB *)TempRcb->Eop = TempRcb;                                  /* GSG +030430 */
9 +            TempRcb->Eop = TempRcb;                                             /* GSG +030430 */
10  
11              if(HalDev->NeedsCount < MAX_NEEDS)                                  /* +MJH 030410 */
12                {                                                                 /* +MJH 030410 */
13 diff -u sangam_atm-D7.03.01.00.orig/dsl_hal_api.c sangam_atm-D7.03.01.00/dsl_hal_api.c
14 --- sangam_atm-D7.03.01.00.orig/dsl_hal_api.c   2007-03-07 04:13:06.000000000 +0100
15 +++ sangam_atm-D7.03.01.00/dsl_hal_api.c        2008-02-08 19:15:02.000000000 +0100
16 @@ -254,15 +254,15 @@
17  *                            of phyEnableDisableWord & phyControlWord to avoid changing API struct
18  *                            which may cause change required to application data structure.
19  ******************************************************************************/
20 -#include <dev_host_interface.h>
21 -#include <dsl_hal_register.h>
22 -#include <dsl_hal_support.h>
23 +#include "dev_host_interface.h"
24 +#include "dsl_hal_register.h"
25 +#include "dsl_hal_support.h"
26  
27  #ifndef NO_ADV_STATS
28 -#include <dsl_hal_logtable.h>
29 +#include "dsl_hal_logtable.h"
30  #endif
31  
32 -#include <dsl_hal_version.h>
33 +#include "dsl_hal_version.h"
34  
35  //  UR8_MERGE_START CQ11054   Jack Zhang
36  static unsigned int highprecision_selected = 0;  //By default we use low precision for backward compt.
37 diff -u sangam_atm-D7.03.01.00.orig/dsl_hal_support.c sangam_atm-D7.03.01.00/dsl_hal_support.c
38 --- sangam_atm-D7.03.01.00.orig/dsl_hal_support.c       2007-05-18 08:47:33.000000000 +0100
39 +++ sangam_atm-D7.03.01.00/dsl_hal_support.c    2008-02-08 19:15:02.000000000 +0100
40 @@ -140,9 +140,9 @@
41  *                                          oamFeature are overriden
42  // UR8_MERGE_END CQ10774 Ram
43  *******************************************************************************/
44 -#include <dev_host_interface.h>
45 -#include <dsl_hal_register.h>
46 -#include <dsl_hal_support.h>
47 +#include "dev_host_interface.h"
48 +#include "dsl_hal_register.h"
49 +#include "dsl_hal_support.h"
50  
51  #define NUM_READ_RETRIES 3
52  static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
53 diff -u sangam_atm-D7.03.01.00.orig/dsl_hal_support.h sangam_atm-D7.03.01.00/dsl_hal_support.h
54 --- sangam_atm-D7.03.01.00.orig/dsl_hal_support.h       2005-11-11 09:07:04.000000000 +0100
55 +++ sangam_atm-D7.03.01.00/dsl_hal_support.h    2008-02-08 19:15:02.000000000 +0100
56 @@ -49,7 +49,7 @@
57  *    04Nov05     0.11.00            CPH    Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
58  *******************************************************************************/
59  
60 -#include <dsl_hal_api.h>
61 +#include "dsl_hal_api.h"
62  
63  #define virtual2Physical(a)    (((int)a)&~0xe0000000)
64  /* External Function Prototype Declarations */
65 diff -u sangam_atm-D7.03.01.00.orig/Makefile sangam_atm-D7.03.01.00/Makefile
66 --- sangam_atm-D7.03.01.00.orig/Makefile        2005-06-01 04:46:28.000000000 +0100
67 +++ sangam_atm-D7.03.01.00/Makefile     2008-02-08 19:15:02.000000000 +0100
68 @@ -1,18 +1,9 @@
69 -# File: drivers/atm/ti_evm3/Makefile
70  #
71 -# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
72 +# Makefile for the TIATM device driver.
73  #
74 -#
75 -# Copyright (c) 2000 Texas Instruments Incorporated.
76 -#      Jeff Harrell (jharrell@telogy.com)
77 -#      Viren Balar  (vbalar@ti.com)
78 -#      Victor Wells (vwells@telogy.com)
79 -#
80 -include $(TOPDIR)/Rules.make
81 -
82 -
83 -
84 -
85 -
86 -
87  
88 +CONFIG_SANGAM_ATM=m
89 +#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
90 +EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
91 +obj-$(CONFIG_SANGAM_ATM) := tiatm.o
92 +tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
93 diff -u sangam_atm-D7.03.01.00.orig/tn7atm.c sangam_atm-D7.03.01.00/tn7atm.c
94 --- sangam_atm-D7.03.01.00.orig/tn7atm.c        2007-05-18 08:45:50.000000000 +0100
95 +++ sangam_atm-D7.03.01.00/tn7atm.c     2008-02-08 19:15:30.000000000 +0100
96 @@ -61,7 +61,6 @@
97   *    UR8_MERGE_END   CQ11057*
98  *********************************************************************************************/
99  
100 -#include <linux/config.h>
101  #include <linux/kernel.h>
102  #include <linux/module.h>
103  #include <linux/init.h>
104 @@ -69,11 +68,14 @@
105  #include <linux/delay.h>
106  #include <linux/spinlock.h>
107  #include <linux/smp_lock.h>
108 -#include <asm/io.h>
109 -#include <asm/mips-boards/prom.h>
110  #include <linux/proc_fs.h>
111  #include <linux/string.h>
112  #include <linux/ctype.h>
113 +
114 +#include <asm/io.h>
115 +#include <asm/ar7/ar7.h>
116 +#include <asm/ar7/prom.h>
117 +
118  #include "dsl_hal_api.h"
119  #include "tn7atm.h"
120  #include "tn7api.h"
121 @@ -82,6 +84,7 @@
122  #include "dsl_hal_register.h"
123  
124  #ifdef MODULE
125 +MODULE_LICENSE("GPL");
126  MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
127  MODULE_AUTHOR ("Zhicheng Tang");
128  #endif
129 @@ -100,9 +103,9 @@
130  
131  /*end of externs */
132  
133 -#ifndef TI_STATIC_ALLOCATIONS
134 -#define TI_STATIC_ALLOCATIONS
135 -#endif
136 +//#ifndef TI_STATIC_ALLOCATIONS
137 +//#define TI_STATIC_ALLOCATIONS
138 +//#endif
139  
140  #define tn7atm_kfree_skb(x)     dev_kfree_skb(x)
141  
142 @@ -114,7 +117,7 @@
143  /* prototypes */
144  static int tn7atm_set_can_support_adsl2 (int can);
145  
146 -static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
147 +static int tn7atm_open (struct atm_vcc *vcc);
148  
149  static void tn7atm_close (struct atm_vcc *vcc);
150  
151 @@ -257,13 +260,12 @@
152          getsockopt:     NULL,
153          setsockopt:     NULL,
154          send:           tn7atm_send,
155 -        sg_send:        NULL,
156          phy_put:        NULL,
157          phy_get:        NULL,
158          change_qos:     tn7atm_change_qos,
159  };
160  
161 -const char drv_proc_root_folder[] = "avalanche/";
162 +const char drv_proc_root_folder[] = "avalanche";
163  static struct proc_dir_entry *root_proc_dir_entry = NULL;
164  #define DRV_PROC_MODE 0644
165  static int proc_root_already_exists = TRUE;
166 @@ -559,56 +561,6 @@
167  
168  /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169   *
170 - *  Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
171 - *
172 - *  Description: retrieve VPI/VCI for connection
173 - *
174 - *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
175 -static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
176 -{
177 -  struct atm_vcc *walk;
178 -
179 -  /*
180 -   * find a free VPI
181 -   */
182 -  if (*vpi == ATM_VPI_ANY)
183 -  {
184 -
185 -    for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
186 -    {
187 -
188 -      if ((walk->vci == *vci) && (walk->vpi == *vpi))
189 -      {
190 -        (*vpi)++;
191 -        walk = vcc->dev->vccs;
192 -      }
193 -    }
194 -  }
195 -
196 -  /*
197 -   * find a free VCI
198 -   */
199 -  if (*vci == ATM_VCI_ANY)
200 -  {
201 -
202 -    for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
203 -         walk = walk->next)
204 -    {
205 -
206 -      if ((walk->vpi = *vpi) && (walk->vci == *vci))
207 -      {
208 -        *vci = walk->vci + 1;
209 -        walk = vcc->dev->vccs;
210 -      }
211 -    }
212 -  }
213 -
214 -  return 0;
215 -}
216 -
217 -
218 -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219 - *
220   *  Function: int tn7atm_sar_irq(void)
221   *
222   *  Description: tnetd73xx SAR interrupt.
223 @@ -693,7 +645,7 @@
224     * Register SAR interrupt
225     */
226    priv->sar_irq = LNXINTNUM (ATM_SAR_INT);      /* Interrupt line # */
227 -  if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
228 +  if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
229      printk ("Could not register tn7atm_sar_irq\n");
230  
231    /*
232 @@ -704,14 +656,14 @@
233    {
234      def_sar_inter_pace = os_atoi (ptr);
235    }
236 -  avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
237 -                            def_sar_inter_pace);
238 +/*  avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
239 +                            def_sar_inter_pace);*/
240  
241    /*
242     * Reigster Receive interrupt A
243     */
244    priv->dsl_irq = LNXINTNUM (ATM_DSL_INT);      /* Interrupt line # */
245 -  if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
246 +  if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
247      printk ("Could not register tn7atm_dsl_irq\n");
248  
249  /***** VRB Tasklet Mode ****/
250 @@ -875,11 +827,15 @@
251  #define ATM_VBR_RT     5
252  #endif
253  
254 -int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
255 +int tn7atm_open (struct atm_vcc *vcc)
256  {
257    tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
258    int rc;
259    //int flags;
260 +  tn7atm_activate_vc_parm.pcr = 0x20000;
261 +  tn7atm_activate_vc_parm.scr = 0x20000;
262 +  tn7atm_activate_vc_parm.mbs = 0x20000;
263 +  tn7atm_activate_vc_parm.cdvt = 10000;
264  
265    dgprintf(1, "tn7atm_open()\n");
266  
267 @@ -891,24 +847,18 @@
268      return -1;
269    }
270  
271 -  MOD_INC_USE_COUNT;
272 +//  MOD_INC_USE_COUNT;
273  
274 -  /* find a free VPI/VCI */
275 -  tn7atm_walk_vccs(vcc, &vpi, &vci);
276 -
277 -  vcc->vpi = vpi;
278 -  vcc->vci = vci;
279 -
280 -  if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
281 +  if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
282    {
283 -    MOD_DEC_USE_COUNT;
284 +//    MOD_DEC_USE_COUNT;
285      return -EBUSY;
286    }
287  
288 -  tn7atm_activate_vc_parm.vpi = vpi;
289 -  tn7atm_activate_vc_parm.vci = vci;
290 +  tn7atm_activate_vc_parm.vpi = vcc->vpi;
291 +  tn7atm_activate_vc_parm.vci = vcc->vci;
292  
293 -  if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
294 +  if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
295    {
296      /* always use (max_dma_chan+1) for clear eoc */
297      tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
298 @@ -916,7 +866,7 @@
299      /* check to see whether clear eoc is opened or not */
300      if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
301      {
302 -      MOD_DEC_USE_COUNT;
303 +//      MOD_DEC_USE_COUNT;
304        printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
305        return -EBUSY;
306      }
307 @@ -925,7 +875,7 @@
308      if (rc)
309      {
310        printk("tn7atm_open: failed to setup clear_eoc\n");
311 -      MOD_DEC_USE_COUNT;
312 +//      MOD_DEC_USE_COUNT;
313        return -EBUSY;
314      }
315      tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
316 @@ -934,17 +884,17 @@
317    }
318    else  /* PVC channel setup */
319    {
320 -    if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
321 +    if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
322      {
323        tn7atm_activate_vc_parm.chan = 14;   /* always use chan 14 for MII PVC-base romote mgmt */
324      }
325      else
326      {
327 -       rc = tn7atm_lut_find(vpi, vci);
328 +       rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
329        /* check to see whether PVC is opened or not */
330        if(ATM_NO_DMA_CHAN != rc)
331        {
332 -        MOD_DEC_USE_COUNT;
333 +//        MOD_DEC_USE_COUNT;
334          printk("PVC already opened. dmachan = %d\n", rc);
335          return -EBUSY;
336        }
337 @@ -976,6 +926,7 @@
338         tn7atm_activate_vc_parm.priority = 2;
339         break;
340  
341 +#if 0
342       case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
343         tn7atm_activate_vc_parm.qos = 1;
344         tn7atm_activate_vc_parm.priority = 1;
345 @@ -997,6 +948,7 @@
346             tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
347         tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
348         break;
349 +#endif
350  
351       default:
352           tn7atm_activate_vc_parm.qos = 2;
353 @@ -1024,7 +976,7 @@
354     if (rc < 0)
355     {
356        printk("failed to activate hw channel\n");
357 -      MOD_DEC_USE_COUNT;
358 +//      MOD_DEC_USE_COUNT;
359        tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
360        //spin_unlock_irqrestore(&chan_init_lock, flags);
361        return -EBUSY;
362 @@ -1114,7 +1066,7 @@
363    tn7atm_lut_clear (vcc, dmachan);
364    //spin_unlock_irqrestore (&closeLock, closeFlag);
365  
366 -  MOD_DEC_USE_COUNT;
367 +//  MOD_DEC_USE_COUNT;
368  
369    dgprintf (1, "Leave tn7atm_close\n");
370  }
371 @@ -1528,8 +1480,7 @@
372                                   * firewall is on */
373  
374    dgprintf (3, "pushing the skb...\n");
375 -
376 -  skb->stamp = vcc->timestamp = xtime;
377 +  __net_timestamp(skb);
378  
379    xdump ((unsigned char *) skb->data, skb->len, 5);
380  
381 @@ -1725,8 +1676,7 @@
382  
383    kfree (dev->dev_data);
384  
385 -  // atm_dev_deregister (dev);
386 -  shutdown_atm_dev (dev);
387 +  atm_dev_deregister (dev);
388  
389    /*
390     * remove proc entries
391 @@ -1885,9 +1835,6 @@
392    /*
393     * Set up proc entry for atm stats
394     */
395 -  if (tn7atm_xlate_proc_name
396 -      (drv_proc_root_folder, &root_proc_dir_entry, &residual))
397 -  {
398      printk ("Creating new root folder %s in the proc for the driver stats \n",
399              drv_proc_root_folder);
400      root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
401 @@ -1897,7 +1844,6 @@
402        return -ENOMEM;
403      }
404      proc_root_already_exists = FALSE;
405 -  }
406  
407    /*
408     * AV: Clean-up. Moved all the definitions to the data structure.
409 @@ -2479,7 +2425,5 @@
410      return count;
411  }
412  
413 -#ifdef MODULE
414  module_init (tn7atm_detect);
415  module_exit (tn7atm_exit);
416 -#endif /* MODULE */
417 diff -u sangam_atm-D7.03.01.00.orig/tn7atm.h sangam_atm-D7.03.01.00/tn7atm.h
418 --- sangam_atm-D7.03.01.00.orig/tn7atm.h        2006-04-05 06:33:06.000000000 +0100
419 +++ sangam_atm-D7.03.01.00/tn7atm.h     2008-02-08 19:15:02.000000000 +0100
420 @@ -19,7 +19,8 @@
421  //#include  "mips_support.h"
422  #include  <linux/list.h>
423  
424 -#include <linux/config.h>
425 +#define MIPS_EXCEPTION_OFFSET 8
426 +#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
427  
428  #ifdef CONFIG_MODVERSIONS
429  #include <linux/modversions.h>
430 diff -u sangam_atm-D7.03.01.00.orig/tn7dsl.c sangam_atm-D7.03.01.00/tn7dsl.c
431 --- sangam_atm-D7.03.01.00.orig/tn7dsl.c        2007-01-04 09:04:14.000000000 +0100
432 +++ sangam_atm-D7.03.01.00/tn7dsl.c     2008-02-08 19:16:46.000000000 +0100
433 @@ -94,7 +94,6 @@
434  *  1/02/07  JZ     CQ11054: Data Precision and Range Changes for TR-069 Conformance
435  *  UR8_MERGE_END   CQ11054*
436   *********************************************************************************************/
437 -#include <linux/config.h>
438  #include <linux/kernel.h>
439  #include <linux/module.h>
440  #include <linux/init.h>
441 @@ -102,8 +101,6 @@
442  #include <linux/delay.h>
443  #include <linux/spinlock.h>
444  #include <linux/smp_lock.h>
445 -#include <asm/io.h>
446 -#include <asm/mips-boards/prom.h>
447  #include <linux/proc_fs.h>
448  #include <linux/string.h>
449  #include <linux/ctype.h>
450 @@ -111,6 +108,12 @@
451  #include <linux/timer.h>
452  #include <linux/vmalloc.h>
453  #include <linux/file.h>
454 +#include <linux/firmware.h>
455 +
456 +#include <asm/io.h>
457 +#include <asm/ar7/ar7.h>
458 +#include <asm/ar7/prom.h>
459 +
460  /* Modules specific header files */
461  #include "tn7atm.h"
462  #include "tn7api.h"
463 @@ -299,7 +302,7 @@
464  static volatile int bshutdown;
465  static char info[MAX_STR_SIZE];
466  /* Used for DSL Polling enable */
467 -static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
468 +static struct semaphore adsl_sem_overlay;
469  
470  //kthread_t overlay_thread;
471  /* end of module wide declars */
472 @@ -323,6 +326,14 @@
473  #define gDot1(a) ((a>0)?(a%10):((-a)%10))
474  //  UR8_MERGE_END   CQ11054*
475  
476 +int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
477 +                            unsigned int pace_value)
478 +{
479 +       printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
480 +       return 0;
481 +}
482 +
483 +
484  int os_atoi(const char *pStr)
485  {
486    int MulNeg = (*pStr == '-' ? -1 : 1);
487 @@ -359,39 +370,6 @@
488  #endif
489  }
490  
491 -int strcmp(const char *s1, const char *s2)
492 -{
493 -
494 -  int size = strlen(s1);
495 -
496 -  return(strncmp(s1, s2, size));
497 -}
498 -
499 -int strncmp(const char *s1, const char *s2, size_t size)
500 -{
501 -  int i = 0;
502 -  int max_size = (int)size;
503 -
504 -  while((s1[i] != 0) && i < max_size)
505 -  {
506 -    if(s2[i] == 0)
507 -    {
508 -      return -1;
509 -    }
510 -    if(s1[i] != s2[i])
511 -    {
512 -       return 1;
513 -    }
514 -    i++;
515 -  }
516 -  if(s2[i] != 0)
517 -  {
518 -    return 1;
519 -  }
520 -
521 -  return 0;
522 -}
523 -
524  // * UR8_MERGE_START CQ10640   Jack Zhang
525  int tn7dsl_dump_dsp_memory(char *input_str) //cph99
526    {
527 @@ -441,101 +419,74 @@
528    return CpuFrequency;
529  }
530  
531 -int shim_osLoadFWImage(unsigned char *ptr)
532 +static void avsar_release(struct device *dev)
533  {
534 -  unsigned int bytesRead;
535 -  mm_segment_t  oldfs;
536 -  static struct file *filp;
537 -  unsigned int imageLength=0x5ffff;
538 -
539 -
540 -  dgprintf(4, "tn7dsl_read_dsp()\n");
541 -
542 -  dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
543 -
544 -  filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
545 -  if(filp ==NULL)
546 -  {
547 -    printk("Failed: Could not open DSP binary file\n");
548 -          return -1;
549 -  }
550 -
551 -  if (filp->f_dentry != NULL)
552 -  {
553 -    if (filp->f_dentry->d_inode != NULL)
554 -    {
555 -      printk ("DSP binary filesize = %d bytes\n",
556 -              (int) filp->f_dentry->d_inode->i_size);
557 -      imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
558 -    }
559 -  }
560 -
561 -  if (filp->f_op->read==NULL)
562 -          return -1;  /* File(system) doesn't allow reads */
563 -
564 -  /*
565 -   * Disable parameter checking
566 -   */
567 -  oldfs = get_fs();
568 -  set_fs(KERNEL_DS);
569 -
570 -  /*
571 -   * Now read bytes from postion "StartPos"
572 -   */
573 -  filp->f_pos = 0;
574 -
575 -  bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
576 -
577 -  dgprintf(4,"file length = %d\n", bytesRead);
578 -
579 -  set_fs(oldfs);
580 -
581 -  /*
582 -   * Close the file
583 -   */
584 -  fput(filp);
585 -
586 -  return bytesRead;
587 +       printk(KERN_DEBUG "avsar firmware released\n");
588  }
589  
590 +static struct device avsar = {
591 +       .bus_id    = "vlynq",
592 +       .release   = avsar_release,
593 +};
594  
595 -unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
596 -                                     unsigned int secLength)
597 +int shim_osLoadFWImage(unsigned char *ptr)
598  {
599 -  unsigned int bytesRead;
600 -  mm_segment_t  oldfs;
601 -  struct file *filp;
602 -
603 -  dgprintf(4,"shim_read_overlay_page\n");
604 -  //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
605 +       const struct firmware *fw_entry;
606 +       size_t size;
607  
608 -  filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
609 -  if(filp ==NULL)
610 -  {
611 -    printk("Failed: Could not open DSP binary file\n");
612 -          return -1;
613 -  }
614 -
615 -  if (filp->f_op->read==NULL)
616 -          return -1;  /* File(system) doesn't allow reads */
617 -
618 -  /*
619 -   * Now read bytes from postion "StartPos"
620 -   */
621 -
622 -  if(filp->f_op->llseek)
623 -    filp->f_op->llseek(filp,secOffset, 0);
624 -  oldfs = get_fs();
625 -  set_fs(KERNEL_DS);
626 -  filp->f_pos = secOffset;
627 -  bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
628 -
629 -  set_fs(oldfs);
630 -  /*
631 -   * Close the file
632 -   */
633 -  fput(filp);
634 -  return bytesRead;
635 +       printk("requesting firmware image \"ar0700xx.bin\"\n");
636 +       if(device_register(&avsar) < 0) {
637 +               printk(KERN_ERR
638 +                       "avsar: device_register fails\n");
639 +               return -1;
640 +       }
641 +
642 +       if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
643 +               printk(KERN_ERR
644 +                       "avsar: Firmware not available\n");
645 +               device_unregister(&avsar);
646 +               return -1;
647 +       }
648 +       size = fw_entry->size;
649 +       device_unregister(&avsar);
650 +       if(size > 0x5ffff) {
651 +                       printk(KERN_ERR
652 +                       "avsar: Firmware too big (%d bytes)\n", size);
653 +                       release_firmware(fw_entry);
654 +                       return -1;
655 +               }
656 +       memcpy(ptr, fw_entry->data, size);
657 +       release_firmware(fw_entry);
658 +       return size;
659 +}
660 +
661 +unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
662 +{
663 +       const struct firmware *fw_entry;
664 +
665 +       printk("requesting firmware image \"ar0700xx.bin\"\n");
666 +       if(device_register(&avsar) < 0) {
667 +               printk(KERN_ERR
668 +                       "avsar: device_register fails\n");
669 +               return -1;
670 +       }
671 +
672 +       if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
673 +               printk(KERN_ERR
674 +                       "avsar: Firmware not available\n");
675 +               device_unregister(&avsar);
676 +               return -1;
677 +       }
678 +       device_unregister(&avsar);
679 +       if(fw_entry->size > secLength) {
680 +               printk(KERN_ERR
681 +                       "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
682 +               release_firmware(fw_entry);
683 +               return -1;
684 +       }
685 +       memcpy(ptr + secOffset, fw_entry->data, secLength);
686 +       release_firmware(fw_entry);
687 +       return secLength;
688  }
689  
690  int shim_osLoadDebugFWImage(unsigned char *ptr)
691 @@ -3064,6 +3015,7 @@
692    int high_precision_selected = 0;  
693  //  UR8_MERGE_END   CQ11054*
694  
695 +  sema_init(&adsl_sem_overlay, 0);
696    /*
697     * start dsl
698     */
699 @@ -3442,7 +3394,7 @@
700     */
701    if(write)
702      {
703 -    ret = proc_dostring(ctl, write, filp, buffer, lenp);
704 +    ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
705  
706      switch (ctl->ctl_name)
707        {
708 @@ -3528,7 +3480,7 @@
709    else
710      {
711      len += sprintf(info+len, mod_req);
712 -    ret = proc_dostring(ctl, write, filp, buffer, lenp);
713 +    ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
714      }
715    return ret;
716  }
717 @@ -3558,8 +3510,7 @@
718    if (initialized == 1)
719      return;
720  
721 -  dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
722 -  dslmod_root_table->child->de->owner = THIS_MODULE;
723 +  dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
724  
725    /*
726     * set the defaults
727 diff -u sangam_atm-D7.03.01.00.orig/tn7sar.c sangam_atm-D7.03.01.00/tn7sar.c
728 --- sangam_atm-D7.03.01.00.orig/tn7sar.c        2007-05-18 08:46:30.000000000 +0100
729 +++ sangam_atm-D7.03.01.00/tn7sar.c     2008-02-08 19:15:02.000000000 +0100
730 @@ -42,7 +42,6 @@
731   * UR8_MERGE_END CQ10700
732   *******************************************************************************/
733  
734 -#include <linux/config.h>
735  #include <linux/kernel.h>
736  #include <linux/module.h>
737  #include <linux/init.h>
738 @@ -50,12 +49,13 @@
739  #include <linux/delay.h>
740  #include <linux/spinlock.h>
741  #include <linux/smp_lock.h>
742 -#include <asm/io.h>
743 -#include <asm/mips-boards/prom.h>
744  #include <linux/proc_fs.h>
745  #include <linux/string.h>
746  #include <linux/ctype.h>
747  
748 +#include <asm/io.h>
749 +#include <asm/ar7/ar7.h>
750 +#include <asm/ar7/prom.h>
751  
752  #define _CPHAL_AAL5
753  #define _CPHAL_SAR