9e667989857751e5d9a2f204ede43a310ee91bd1
[openwrt.git] / target / linux / brcm63xx-2.6 / patches / 001-brcm_boards.patch
1 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c
2 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c        2006-08-03 16:36:58.000000000 +0200
4 @@ -0,0 +1,775 @@
5 +/*
6 +<:copyright-gpl
7 + Copyright 2002 Broadcom Corp. All Rights Reserved.
8 +
9 + This program is free software; you can distribute it and/or modify it
10 + under the terms of the GNU General Public License (Version 2) as
11 + published by the Free Software Foundation.
12 +
13 + This program is distributed in the hope it will be useful, but WITHOUT
14 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 + for more details.
17 +
18 + You should have received a copy of the GNU General Public License along
19 + with this program; if not, write to the Free Software Foundation, Inc.,
20 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 +:>
22 +*/
23 +/*
24 + ***************************************************************************
25 + * File Name  : bcm63xx_flash.c
26 + *
27 + * Description: This file contains the flash device driver APIs for bcm63xx board. 
28 + *
29 + * Created on :  8/10/2002  seanl:  use cfiflash.c, cfliflash.h (AMD specific)
30 + *
31 + ***************************************************************************/
32 +
33 +
34 +/* Includes. */
35 +#include <linux/fs.h>
36 +#include <linux/capability.h>
37 +#include <linux/slab.h>
38 +#include <linux/errno.h>
39 +#include <linux/module.h>
40 +#include <asm/uaccess.h>
41 +
42 +#include <bcm_map_part.h>
43 +#include <board.h>
44 +#define  BCMTAG_EXE_USE
45 +#include <bcmTag.h>
46 +#include "cfiflash.h"
47 +#include "boardparms.h"
48 +
49 +//#define DEBUG_FLASH
50 +
51 +static FLASH_ADDR_INFO fInfo;
52 +static int flashInitialized = 0;
53 +
54 +void *retriedKmalloc(size_t size)
55 +{
56 +       void *pBuf;
57 +    int tryCount = 0;
58 +
59 +    // try 1000 times before quit
60 +    while (((pBuf = kmalloc(size, GFP_KERNEL)) == NULL) && (tryCount++ < 1000))
61 +    {
62 +               current->state   = TASK_INTERRUPTIBLE;
63 +               schedule_timeout(HZ/10);
64 +       }
65 +    if (tryCount >= 1000)
66 +        pBuf = NULL;
67 +    else
68 +           memset(pBuf, 0, size);
69 +
70 +    return pBuf;
71 +}
72 +
73 +void retriedKfree(void *pBuf)
74 +{
75 +       kfree(pBuf);
76 +}
77 +
78 +/***************************************************************************
79 +// Function Name: getCrc32
80 +// Description  : caculate the CRC 32 of the given data.
81 +// Parameters   : pdata - array of data.
82 +//                size - number of input data bytes.
83 +//                crc - either CRC32_INIT_VALUE or previous return value.
84 +// Returns      : crc.
85 +****************************************************************************/
86 +UINT32 getCrc32(byte *pdata, UINT32 size, UINT32 crc) 
87 +{
88 +    while (size-- > 0)
89 +        crc = (crc >> 8) ^ Crc32_table[(crc ^ *pdata++) & 0xff];
90 +
91 +    return crc;
92 +}
93 +
94 +// get the nvram start addr
95 +//
96 +unsigned long get_nvram_start_addr(void)
97 +{
98 +    return ((unsigned long) 
99 +        (flash_get_memptr(fInfo.flash_nvram_start_blk) + fInfo.flash_nvram_blk_offset));
100 +}
101 +
102 +// get the scratch_pad start addr
103 +//
104 +unsigned long get_scratch_pad_start_addr(void)
105 +{
106 +    return ((unsigned long) 
107 +        (flash_get_memptr(fInfo.flash_scratch_pad_start_blk) + fInfo.flash_scratch_pad_blk_offset));
108 +}
109 +
110 +
111 +
112 +/*  *********************************************************************
113 +    *  kerSysImageTagGet()
114 +    *   Get the image tag
115 +    *  Input parameters:
116 +    *      none
117 +    *  Return value:
118 +    *      point to tag -- Found
119 +    *      NULL -- failed
120 +    ********************************************************************* */
121 +PFILE_TAG kerSysImageTagGet(void)
122 +{
123 +    int i;
124 +    int totalBlks = flash_get_numsectors();
125 +    UINT32 crc;
126 +    unsigned char *sectAddr;
127 +    PFILE_TAG pTag;
128 +
129 +#if defined(DEBUG_FLASH)
130 +    printk("totalblks in tagGet=%d\n", totalBlks);
131 +#endif
132 +
133 +    // start from 2nd blk, assume 1st one is always CFE
134 +    for (i = 1; i < totalBlks; i++)
135 +    {
136 +        sectAddr =  flash_get_memptr((byte) i);
137 +        crc = CRC32_INIT_VALUE;
138 +        crc = getCrc32(sectAddr, (UINT32)TAG_LEN-TOKEN_LEN, crc);      
139 +        pTag = (PFILE_TAG) sectAddr;
140 +
141 +#if defined(DEBUG_FLASH)
142 +        printk("Check Tag crc on blk [%d]\n", i);
143 +#endif
144 +
145 +        if (crc == (UINT32)(*(UINT32*)(pTag->tagValidationToken)))
146 +            return pTag;
147 +    }
148 +
149 +    return (PFILE_TAG) NULL;
150 +}
151 +
152 +// Initialize the flash and fill out the fInfo structure
153 +void kerSysFlashInit( void )
154 +{
155 +    int i = 0;
156 +    int totalBlks = 0;
157 +    int totalSize = 0;
158 +    int startAddr = 0;
159 +    int usedBlkSize = 0;
160 +    NVRAM_DATA nvramData;
161 +    UINT32 crc = CRC32_INIT_VALUE, savedCrc;
162 +    PFILE_TAG pTag = NULL;
163 +    unsigned long kernelEndAddr = 0;
164 +    unsigned long spAddr = 0;
165 +
166 +    if (flashInitialized)
167 +        return;
168 +
169 +    flashInitialized = 1;
170 +    flash_init();
171 +
172 +    totalBlks = flash_get_numsectors();
173 +    totalSize = flash_get_total_size();
174 +
175 +    printk("Total Flash size: %dK with %d sectors\n", totalSize/1024, totalBlks);
176 +
177 +    /* nvram is always at the end of flash */
178 +    fInfo.flash_nvram_length = FLASH45_LENGTH_NVRAM;
179 +    fInfo.flash_nvram_start_blk = 0;  /* always the first block */
180 +    fInfo.flash_nvram_number_blk = 1; /*always fits in the first block */
181 +    fInfo.flash_nvram_blk_offset = NVRAM_DATA_OFFSET;
182
183 +    // check nvram CRC
184 +    memcpy((char *)&nvramData, (char *)get_nvram_start_addr(), sizeof(NVRAM_DATA));
185 +    savedCrc = nvramData.ulCheckSum;
186 +    nvramData.ulCheckSum = 0;
187 +    crc = getCrc32((char *)&nvramData, (UINT32) sizeof(NVRAM_DATA), crc);   
188 +
189 +    BpSetBoardId( nvramData.szBoardId );
190 +
191 +    fInfo.flash_persistent_length = NVRAM_PSI_DEFAULT;
192 +    if (savedCrc != crc)
193 +    {
194 +        printk("***Board is not initialized****: Using the default PSI size: %d\n",
195 +            fInfo.flash_persistent_length);
196 +    }
197 +    else
198 +    {
199 +        unsigned long ulPsiSize;
200 +        if( BpGetPsiSize( &ulPsiSize ) == BP_SUCCESS )
201 +            fInfo.flash_persistent_length = ulPsiSize;
202 +        else
203 +        {
204 +            printk("***Board id is not set****: Using the default PSI size: %d\n",
205 +                fInfo.flash_persistent_length);
206 +        }
207 +    }
208 +
209 +    fInfo.flash_persistent_length *= ONEK;
210 +    startAddr = totalSize - fInfo.flash_persistent_length;
211 +    fInfo.flash_persistent_start_blk = flash_get_blk(startAddr+FLASH_BASE_ADDR_REG);
212 +    fInfo.flash_persistent_number_blk = totalBlks - fInfo.flash_persistent_start_blk;
213 +    // save abs SP address (Scratch Pad). it is before PSI 
214 +    spAddr = startAddr - SP_MAX_LEN ;
215 +    // find out the offset in the start_blk
216 +    usedBlkSize = 0;
217 +    for (i = fInfo.flash_persistent_start_blk; 
218 +        i < (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk); i++)
219 +    {
220 +        usedBlkSize += flash_get_sector_size((byte) i);
221 +    }
222 +    fInfo.flash_persistent_blk_offset =  usedBlkSize - fInfo.flash_persistent_length;
223 +
224 +    // get the info for sp
225 +    if (!(pTag = kerSysImageTagGet()))
226 +    {
227 +        printk("Failed to read image tag from flash\n");
228 +        return;
229 +    }
230 +    kernelEndAddr = (unsigned long) simple_strtoul(pTag->kernelAddress, NULL, 10) + \
231 +        (unsigned long) simple_strtoul(pTag->kernelLen, NULL, 10);
232 +
233 +    // make suer sp does not share kernel block
234 +    fInfo.flash_scratch_pad_start_blk = flash_get_blk(spAddr+FLASH_BASE_ADDR_REG);
235 +    if (fInfo.flash_scratch_pad_start_blk != flash_get_blk(kernelEndAddr))
236 +    {
237 +        fInfo.flash_scratch_pad_length = SP_MAX_LEN;
238 +        if (fInfo.flash_persistent_start_blk == fInfo.flash_scratch_pad_start_blk)  // share blk
239 +        {
240 +#if 1 /* do not used scratch pad unless it's in its own sector */
241 +            printk("Scratch pad is not used for this flash part.\n");  
242 +            fInfo.flash_scratch_pad_length = 0;     // no sp
243 +#else /* allow scratch pad to share a sector with another section such as PSI */
244 +            fInfo.flash_scratch_pad_number_blk = 1;
245 +            fInfo.flash_scratch_pad_blk_offset = fInfo.flash_persistent_blk_offset - fInfo.flash_scratch_pad_length;
246 +#endif
247 +        }
248 +        else // on different blk
249 +        {
250 +            fInfo.flash_scratch_pad_number_blk = fInfo.flash_persistent_start_blk\
251 +                - fInfo.flash_scratch_pad_start_blk;
252 +            // find out the offset in the start_blk
253 +            usedBlkSize = 0;
254 +            for (i = fInfo.flash_scratch_pad_start_blk; 
255 +                i < (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk); i++)
256 +                usedBlkSize += flash_get_sector_size((byte) i);
257 +                fInfo.flash_scratch_pad_blk_offset =  usedBlkSize - fInfo.flash_scratch_pad_length;
258 +        }
259 +    }
260 +    else
261 +    {
262 +        printk("No flash for scratch pad!\n");  
263 +        fInfo.flash_scratch_pad_length = 0;     // no sp
264 +    }
265 +
266 +#if defined(DEBUG_FLASH)
267 +    printk("fInfo.flash_scratch_pad_start_blk = %d\n", fInfo.flash_scratch_pad_start_blk);
268 +    printk("fInfo.flash_scratch_pad_number_blk = %d\n", fInfo.flash_scratch_pad_number_blk);
269 +    printk("fInfo.flash_scratch_pad_length = 0x%x\n", fInfo.flash_scratch_pad_length);
270 +    printk("fInfo.flash_scratch_pad_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_scratch_pad_blk_offset);
271 +
272 +    printk("fInfo.flash_nvram_start_blk = %d\n", fInfo.flash_nvram_start_blk);
273 +    printk("fInfo.flash_nvram_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_nvram_blk_offset);
274 +    printk("fInfo.flash_nvram_number_blk = %d\n", fInfo.flash_nvram_number_blk);
275 +
276 +    printk("psi startAddr = %x\n", startAddr+FLASH_BASE_ADDR_REG);
277 +    printk("fInfo.flash_persistent_start_blk = %d\n", fInfo.flash_persistent_start_blk);
278 +    printk("fInfo.flash_persistent_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_persistent_blk_offset);
279 +    printk("fInfo.flash_persistent_number_blk = %d\n", fInfo.flash_persistent_number_blk);
280 +#endif
281 +
282 +}
283 +
284 +
285 +
286 +/***********************************************************************
287 + * Function Name: kerSysFlashAddrInfoGet
288 + * Description  : Fills in a structure with information about the NVRAM
289 + *                and persistent storage sections of flash memory.  
290 + *                Fro physmap.c to mount the fs vol.
291 + * Returns      : None.
292 + ***********************************************************************/
293 +void kerSysFlashAddrInfoGet(PFLASH_ADDR_INFO pflash_addr_info)
294 +{
295 +    pflash_addr_info->flash_nvram_blk_offset = fInfo.flash_nvram_blk_offset;
296 +    pflash_addr_info->flash_nvram_length = fInfo.flash_nvram_length;
297 +    pflash_addr_info->flash_nvram_number_blk = fInfo.flash_nvram_number_blk;
298 +    pflash_addr_info->flash_nvram_start_blk = fInfo.flash_nvram_start_blk;
299 +    pflash_addr_info->flash_persistent_blk_offset = fInfo.flash_persistent_blk_offset;
300 +    pflash_addr_info->flash_persistent_length = fInfo.flash_persistent_length;
301 +    pflash_addr_info->flash_persistent_number_blk = fInfo.flash_persistent_number_blk;
302 +    pflash_addr_info->flash_persistent_start_blk = fInfo.flash_persistent_start_blk;
303 +}
304 +
305 +
306 +// get shared blks into *** pTempBuf *** which has to be released bye the caller!
307 +// return: if pTempBuf != NULL, poits to the data with the dataSize of the buffer
308 +// !NULL -- ok
309 +// NULL  -- fail
310 +static char *getSharedBlks(int start_blk, int end_blk)
311 +{
312 +    int i = 0;
313 +    int usedBlkSize = 0;
314 +    int sect_size = 0;
315 +    char *pTempBuf = NULL;
316 +    char *pBuf = NULL;
317 +
318 +    for (i = start_blk; i < end_blk; i++)
319 +        usedBlkSize += flash_get_sector_size((byte) i);
320 +
321 +#if defined(DEBUG_FLASH)
322 +    printk("usedBlkSize = %d\n", usedBlkSize);
323 +#endif
324 +
325 +    if ((pTempBuf = (char *) retriedKmalloc(usedBlkSize)) == NULL)
326 +    {
327 +        printk("failed to allocate memory with size: %d\n", usedBlkSize);
328 +        return pTempBuf;
329 +    }
330 +    
331 +    pBuf = pTempBuf;
332 +    for (i = start_blk; i < end_blk; i++)
333 +    {
334 +        sect_size = flash_get_sector_size((byte) i);
335 +
336 +#if defined(DEBUG_FLASH)
337 +        printk("i = %d, sect_size = %d, end_blk = %d\n", i, sect_size, end_blk);
338 +#endif
339 +        flash_read_buf((byte)i, 0, pBuf, sect_size);
340 +        pBuf += sect_size;
341 +    }
342 +    
343 +    return pTempBuf;
344 +}
345 +
346 +
347 +
348 +// Set the pTempBuf to flash from start_blk to end_blk
349 +// return:
350 +// 0 -- ok
351 +// -1 -- fail
352 +static int setSharedBlks(int start_blk, int end_blk, char *pTempBuf)
353 +{
354 +    int i = 0;
355 +    int sect_size = 0;
356 +    int sts = 0;
357 +    char *pBuf = pTempBuf;
358 +
359 +    for (i = start_blk; i < end_blk; i++)
360 +    {
361 +        sect_size = flash_get_sector_size((byte) i);
362 +        flash_sector_erase_int(i);
363 +        if (flash_write_buf(i, 0, pBuf, sect_size) != sect_size)
364 +        {
365 +            printk("Error writing flash sector %d.", i);
366 +            sts = -1;
367 +            break;
368 +        }
369 +        pBuf += sect_size;
370 +    }
371 +
372 +    return sts;
373 +}
374 +
375 +
376 +
377 +/*******************************************************************************
378 + * NVRAM functions
379 + *******************************************************************************/
380 +
381 +// get nvram data
382 +// return:
383 +//  0 - ok
384 +//  -1 - fail
385 +int kerSysNvRamGet(char *string, int strLen, int offset)
386 +{
387 +    char *pBuf = NULL;
388 +
389 +    if (!flashInitialized)
390 +        kerSysFlashInit();
391 +
392 +    if (strLen > FLASH45_LENGTH_NVRAM)
393 +        return -1;
394 +
395 +    if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
396 +        (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
397 +        return -1;
398 +
399 +    // get string off the memory buffer
400 +    memcpy(string, (pBuf + fInfo.flash_nvram_blk_offset + offset), strLen);
401 +
402 +    retriedKfree(pBuf);
403 +
404 +    return 0;
405 +}
406 +
407 +
408 +// set nvram 
409 +// return:
410 +//  0 - ok
411 +//  -1 - fail
412 +int kerSysNvRamSet(char *string, int strLen, int offset)
413 +{
414 +    int sts = 0;
415 +    char *pBuf = NULL;
416 +
417 +    if (strLen > FLASH45_LENGTH_NVRAM)
418 +        return -1;
419 +
420 +    if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
421 +        (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
422 +        return -1;
423 +
424 +    // set string to the memory buffer
425 +    memcpy((pBuf + fInfo.flash_nvram_blk_offset + offset), string, strLen);
426 +
427 +    if (setSharedBlks(fInfo.flash_nvram_start_blk, 
428 +        (fInfo.flash_nvram_number_blk + fInfo.flash_nvram_start_blk), pBuf) != 0)
429 +        sts = -1;
430 +    
431 +    retriedKfree(pBuf);
432 +
433 +    return sts;
434 +}
435 +
436 +
437 +/***********************************************************************
438 + * Function Name: kerSysEraseNvRam
439 + * Description  : Erase the NVRAM storage section of flash memory.
440 + * Returns      : 1 -- ok, 0 -- fail
441 + ***********************************************************************/
442 +int kerSysEraseNvRam(void)
443 +{
444 +    int sts = 1;
445 +    char *tempStorage = retriedKmalloc(FLASH45_LENGTH_NVRAM);
446 +    
447 +    // just write the whole buf with '0xff' to the flash
448 +    if (!tempStorage)
449 +        sts = 0;
450 +    else
451 +    {
452 +        memset(tempStorage, 0xff, FLASH45_LENGTH_NVRAM);
453 +        if (kerSysNvRamSet(tempStorage, FLASH45_LENGTH_NVRAM, 0) != 0)
454 +            sts = 0;
455 +        retriedKfree(tempStorage);
456 +    }
457 +
458 +    return sts;
459 +}
460 +
461 +
462 +/*******************************************************************************
463 + * PSI functions
464 + *******************************************************************************/
465 +// get psi data
466 +// return:
467 +//  0 - ok
468 +//  -1 - fail
469 +int kerSysPersistentGet(char *string, int strLen, int offset)
470 +{
471 +    char *pBuf = NULL;
472 +
473 +    if (strLen > fInfo.flash_persistent_length)
474 +        return -1;
475 +
476 +    if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
477 +        (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
478 +        return -1;
479 +
480 +    // get string off the memory buffer
481 +    memcpy(string, (pBuf + fInfo.flash_persistent_blk_offset + offset), strLen);
482 +
483 +    retriedKfree(pBuf);
484 +
485 +    return 0;
486 +}
487 +
488 +
489 +// set psi 
490 +// return:
491 +//  0 - ok
492 +//  -1 - fail
493 +int kerSysPersistentSet(char *string, int strLen, int offset)
494 +{
495 +    int sts = 0;
496 +    char *pBuf = NULL;
497 +
498 +    if (strLen > fInfo.flash_persistent_length)
499 +        return -1;
500 +
501 +    if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
502 +        (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
503 +        return -1;
504 +
505 +    // set string to the memory buffer
506 +    memcpy((pBuf + fInfo.flash_persistent_blk_offset + offset), string, strLen);
507 +
508 +    if (setSharedBlks(fInfo.flash_persistent_start_blk, 
509 +        (fInfo.flash_persistent_number_blk + fInfo.flash_persistent_start_blk), pBuf) != 0)
510 +        sts = -1;
511 +    
512 +    retriedKfree(pBuf);
513 +
514 +    return sts;
515 +}
516 +
517 +
518 +// flash bcm image 
519 +// return: 
520 +// 0 - ok
521 +// !0 - the sector number fail to be flashed (should not be 0)
522 +int kerSysBcmImageSet( int flash_start_addr, char *string, int size)
523 +{
524 +    int sts;
525 +    int sect_size;
526 +    int blk_start;
527 +    int i;
528 +    char *pTempBuf = NULL;
529 +    int whole_image = 0;
530 +
531 +    blk_start = flash_get_blk(flash_start_addr);
532 +    if( blk_start < 0 )
533 +        return( -1 );
534 +
535 +    if (flash_start_addr == FLASH_BASE && size > FLASH45_LENGTH_BOOT_ROM)
536 +        whole_image = 1;
537 +
538 +   /* write image to flash memory */
539 +    do 
540 +    {
541 +        sect_size = flash_get_sector_size(blk_start);
542 +// NOTE: for memory problem in multiple PVC configuration, temporary get rid of kmalloc this 64K for now.
543 +//        if ((pTempBuf = (char *)retriedKmalloc(sect_size)) == NULL)
544 +//        {
545 +//            printk("Failed to allocate memory with size: %d.  Reset the router...\n", sect_size);
546 +//            kerSysMipsSoftReset();     // reset the board right away.
547 +//        }
548 +        // for whole image, no check on psi
549 +        if (!whole_image && blk_start == fInfo.flash_persistent_start_blk)  // share the blk with psi
550 +        {
551 +            if (size > (sect_size - fInfo.flash_persistent_length))
552 +            {
553 +                printk("Image is too big\n");
554 +                break;          // image is too big. Can not overwrite to nvram
555 +            }
556 +            if ((pTempBuf = (char *)retriedKmalloc(sect_size)) == NULL)
557 +            {
558 +               printk("Failed to allocate memory with size: %d.  Reset the router...\n", sect_size);
559 +               kerSysMipsSoftReset();     // reset the board right away.
560 +            }
561 +            flash_read_buf((byte)blk_start, 0, pTempBuf, sect_size);
562 +            if (copy_from_user((void *)pTempBuf,(void *)string, size) != 0)
563 +                break;  // failed ?
564 +            flash_sector_erase_int(blk_start);     // erase blk before flash
565 +            if (flash_write_buf(blk_start, 0, pTempBuf, sect_size) == sect_size) 
566 +                size = 0;   // break out and say all is ok
567 +            retriedKfree(pTempBuf);
568 +            break;
569 +        }
570 +        
571 +        flash_sector_erase_int(blk_start);     // erase blk before flash
572 +
573 +        if (sect_size > size) 
574 +        {
575 +            if (size & 1) 
576 +                size++;
577 +            sect_size = size;
578 +        }
579 +        
580 +        if ((i = flash_write_buf(blk_start, 0, string, sect_size)) != sect_size) {
581 +            break;
582 +        }
583 +        blk_start++;
584 +        string += sect_size;
585 +        size -= sect_size; 
586 +    } while (size > 0);
587 +
588 +    if (whole_image)  
589 +    {
590 +        // If flashing a whole image, erase to end of flash.
591 +        int total_blks = flash_get_numsectors();
592 +        while( blk_start < total_blks )
593 +        {
594 +            flash_sector_erase_int(blk_start);
595 +            blk_start++;
596 +        }
597 +    }
598 +    if (pTempBuf)
599 +        retriedKfree(pTempBuf);
600 +
601 +    if( size == 0 ) 
602 +        sts = 0;  // ok
603 +    else  
604 +        sts = blk_start;    // failed to flash this sector
605 +
606 +    return sts;
607 +}
608 +
609 +/*******************************************************************************
610 + * SP functions
611 + *******************************************************************************/
612 +// get sp data.  NOTE: memcpy work here -- not using copy_from/to_user
613 +// return:
614 +//  0 - ok
615 +//  -1 - fail
616 +int kerSysScratchPadGet(char *tokenId, char *tokBuf, int bufLen)
617 +{
618 +    PSP_HEADER pHead = NULL;
619 +    PSP_TOKEN pToken = NULL;
620 +    char *pBuf = NULL;
621 +    char *pShareBuf = NULL;
622 +    char *startPtr = NULL;
623 +    char *endPtr = NULL;
624 +    char *spEndPtr = NULL;
625 +    int sts = -1;
626 +
627 +    if (fInfo.flash_scratch_pad_length == 0)
628 +        return sts;
629 +
630 +    if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN))) 
631 +    {
632 +        printk("Exceed scratch pad space by %d\n", bufLen  - fInfo.flash_scratch_pad_length \
633 +            - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
634 +        return sts;
635 +    }
636 +
637 +    if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
638 +        (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
639 +        return sts;
640 +
641 +    // pBuf points to SP buf
642 +    pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;  
643 +
644 +    pHead = (PSP_HEADER) pBuf;
645 +    if (memcmp(pHead->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0) 
646 +    {
647 +        printk("Scrap pad is not initialized.\n");
648 +        return sts;
649 +    }
650 +
651 +    // search up to SPUsedLen for the token
652 +    startPtr = pBuf + sizeof(SP_HEADER);
653 +    endPtr = pBuf + pHead->SPUsedLen;
654 +    spEndPtr = pBuf + SP_MAX_LEN;
655 +    while (startPtr < endPtr && startPtr < spEndPtr)
656 +    {
657 +        pToken = (PSP_TOKEN) startPtr;
658 +        if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
659 +        {
660 +            memcpy(tokBuf, startPtr + sizeof(SP_TOKEN), bufLen);
661 +            sts = 0;
662 +            break;
663 +        }
664 +        // get next token
665 +        startPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
666 +    }
667 +
668 +    retriedKfree(pShareBuf);
669 +
670 +    return sts;
671 +}
672 +
673 +
674 +// set sp.  NOTE: memcpy work here -- not using copy_from/to_user
675 +// return:
676 +//  0 - ok
677 +//  -1 - fail
678 +int kerSysScratchPadSet(char *tokenId, char *tokBuf, int bufLen)
679 +{
680 +    PSP_TOKEN pToken = NULL;
681 +    PSP_HEADER pHead = NULL;
682 +    char *pShareBuf = NULL;
683 +    char *pBuf = NULL;
684 +    SP_HEADER SPHead;
685 +    SP_TOKEN SPToken;
686 +    char *curPtr;
687 +    int sts = -1;
688 +
689 +    if (fInfo.flash_scratch_pad_length == 0)
690 +        return sts;
691 +
692 +    if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN))) 
693 +    {
694 +        printk("Exceed scratch pad space by %d\n", bufLen  - fInfo.flash_scratch_pad_length \
695 +            - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
696 +        return sts;
697 +    }
698 +
699 +    if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
700 +        (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
701 +        return sts;
702 +
703 +    // pBuf points to SP buf
704 +    pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;  
705 +    pHead = (PSP_HEADER) pBuf;
706 +
707 +    // form header info.  SPUsedLen later on...
708 +    memset((char *)&SPHead, 0, sizeof(SP_HEADER));
709 +    memcpy(SPHead.SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN);
710 +    SPHead.SPVersion = SP_VERSION;
711 +
712 +    // form token info.
713 +    memset((char*)&SPToken, 0, sizeof(SP_TOKEN));
714 +    strncpy(SPToken.tokenName, tokenId, TOKEN_NAME_LEN - 1);
715 +    SPToken.tokenLen = bufLen;
716 +    if (memcmp(pHead->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0) 
717 +    {
718 +        // new sp, so just flash the token
719 +        printk("No Scrap pad found.  Initialize scratch pad...\n");
720 +        SPHead.SPUsedLen = sizeof(SP_HEADER) + sizeof(SP_TOKEN) + bufLen;
721 +        memcpy(pBuf, (char *)&SPHead, sizeof(SP_HEADER));
722 +        curPtr = pBuf + sizeof(SP_HEADER);
723 +        memcpy(curPtr, (char *)&SPToken, sizeof(SP_TOKEN));
724 +        curPtr += sizeof(SP_TOKEN);
725 +        memcpy(curPtr, tokBuf, bufLen);
726 +    }
727 +    else  
728 +    {
729 +        // need search for the token, if exist with same size overwrite it. if sizes differ, 
730 +        // move over the later token data over and put the new one at the end
731 +        char *endPtr = pBuf + pHead->SPUsedLen;
732 +        char *spEndPtr = pBuf + SP_MAX_LEN;
733 +        curPtr = pBuf + sizeof(SP_HEADER);
734 +        while (curPtr < endPtr && curPtr < spEndPtr)
735 +        {
736 +            pToken = (PSP_TOKEN) curPtr;
737 +            if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
738 +            {
739 +                if (pToken->tokenLen == bufLen) // overwirte it
740 +                {
741 +                    memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen);
742 +                    break;
743 +                }
744 +                else // move later data over and put the new token at the end
745 +                {
746 +                    memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen);  // ~~~
747 +                    break;
748 +                }
749 +            }
750 +            else // not same token ~~~
751 +            {
752 +            }
753 +            // get next token
754 +            curPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
755 +        } // end while
756 +        SPHead.SPUsedLen = sizeof(SP_HEADER) + sizeof(SP_TOKEN) + bufLen; // ~~~
757 +        if (SPHead.SPUsedLen > SP_MAX_LEN)
758 +        {
759 +            printk("No more Scratch pad space left! Over limit by %d bytes\n", SPHead.SPUsedLen - SP_MAX_LEN);
760 +            return sts;
761 +        }
762 +
763 +    } // else if not new sp
764 +
765 +    sts = setSharedBlks(fInfo.flash_scratch_pad_start_blk, 
766 +        (fInfo.flash_scratch_pad_number_blk + fInfo.flash_scratch_pad_start_blk), pShareBuf);
767 +    
768 +    retriedKfree(pShareBuf);
769 +
770 +    return sts;
771 +
772 +    
773 +}
774 +
775 +int kerSysFlashSizeGet(void)
776 +{
777 +   return flash_get_total_size();
778 +}
779 +
780 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c
781 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c   1970-01-01 01:00:00.000000000 +0100
782 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c  2006-08-03 16:36:58.000000000 +0200
783 @@ -0,0 +1,582 @@
784 +/*
785 +<:copyright-gpl 
786 + Copyright 2002 Broadcom Corp. All Rights Reserved. 
787
788 + This program is free software; you can distribute it and/or modify it 
789 + under the terms of the GNU General Public License (Version 2) as 
790 + published by the Free Software Foundation. 
791
792 + This program is distributed in the hope it will be useful, but WITHOUT 
793 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
794 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
795 + for more details. 
796
797 + You should have received a copy of the GNU General Public License along 
798 + with this program; if not, write to the Free Software Foundation, Inc., 
799 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
800 +:>
801 +*/
802 +/***************************************************************************
803 + * File Name  : bcm63xx_led.c
804 + *
805 + * Description: 
806 + *
807 + *    This file contains bcm963xx board led control API functions. 
808 + *
809 + *    To use it, do the following
810 + *
811 + *    1). define in the board.c the following led mappping (this is for 6345GW board):
812 + *        const LED_MAP_PAIR cLedMapping45GW[] =
813 + *        {   // led name     Initial state       physical pin (ledMask)
814 + *            {kLedUsb,       kLedStateOff,       GPIO_LED_PIN_7}, 
815 + *            {kLedAdsl,      kLedStateOff,       GPIO_LED_PIN_8},
816 + *            {kLedPPP,       kLedStateOff,       GPIO_LED_PIN_9},    // PPP and WanData share PIN_9
817 + *            {kLedWanData,   kLedStateOff,       GPIO_LED_PIN_9},
818 + *            {kLedWireless,  kLedStateOff,       GPIO_LED_PIN_10},
819 + *            {kLedEnd,       kLedStateOff,       0              } // NOTE: kLedEnd has to be at the end.
820 + *
821 + *    2). };To initialize led API and initial state of the leds, call the following function with the mapping 
822 + *        pointer from the above struct
823 + *
824 + *        boardLedInit((PLED_MAP_PAIR) &cLedMapping45R);
825 + *
826 + *    3). Sample call for kernel mode:
827 + *
828 + *        kerSysLedCtrl(kLedAdsl, kLedStateBlinkOnce);        // kLedxxx defines in board.h
829 + *
830 + *    4). Sample call for user mode
831 + *
832 + *        sysLedCtrl(kLedAdsl, kLedStateBlinkOnce);           // kLedxxx defines in board_api.h
833 + *
834 + *
835 + * Created on :  10/28/2002  seanl
836 + *
837 + ***************************************************************************/
838 +
839 +/* Includes. */
840 +#include <linux/init.h>
841 +#include <linux/fs.h>
842 +#include <linux/capability.h>
843 +#include <linux/slab.h>
844 +#include <linux/errno.h>
845 +#include <linux/module.h>
846 +#include <linux/netdevice.h>
847 +#include <asm/uaccess.h>
848 +
849 +#include <bcm_map_part.h>
850 +#include <board.h>
851 +
852 +#define k100ms              (HZ / 10)     // ~100 ms
853 +#define kFastBlinkCount     0             // ~100ms
854 +#define kSlowBlinkCount     5             // ~600ms
855 +
856 +#define MAX_VIRT_LEDS       12
857 +
858 +// uncomment // for debug led
859 +//#define DEBUG_LED
860 +
861 +// global variables:
862 +struct timer_list gLedTimer;
863 +int gTimerOn = FALSE;
864 +int gLedCount = 0;
865 +
866 +typedef struct ledinfo
867 +{
868 +    unsigned short ledMask;         // mask for led: ie. giop 10 = 0x0400
869 +    unsigned short ledActiveLow;    // GPIO bit reset to turn on LED
870 +    unsigned short ledMaskFail;     // mask for led: ie. giop 10 = 0x0400
871 +    unsigned short ledActiveLowFail;// GPIO bit reset to turn on LED
872 +    BOARD_LED_STATE ledState;       // current led state
873 +    BOARD_LED_STATE savedLedState;  // used in blink once for restore to the orignal ledState
874 +    int blinkCountDown;             // if == 0, do blink (toggle).  Is assgined value and dec by 1 at each timer.
875 +} LED_INFO, *PLED_INFO;
876 +
877 +static PLED_INFO gLed = NULL;
878 +static PLED_INFO gpVirtLeds[MAX_VIRT_LEDS];
879 +static HANDLE_LED_FUNC gLedHwFunc[MAX_VIRT_LEDS];
880 +static HANDLE_LED_FUNC gLedHwFailFunc[MAX_VIRT_LEDS];
881 +
882 +#if 0 /* BROKEN */
883 +#if defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
884 +static int gLedOffInBridgeMode = 1;
885 +#elif defined(CONFIG_BCM96345)
886 +static int gLedOffInBridgeMode = 0;
887 +#endif
888 +#endif
889 +
890 +void ledTimerExpire(void);
891 +int initLedInfo( PLED_MAP_PAIR pCurMap, PLED_INFO pCurLed );
892 +
893 +//**************************************************************************************
894 +// LED operations
895 +//**************************************************************************************
896 +
897 +// turn led on and set the ledState
898 +void ledOn(PLED_INFO pLed)
899 +{
900 +    if( pLed->ledMask )
901 +    {
902 +        GPIO->GPIODir |= pLed->ledMask;         // turn on the direction bit in case was turned off by some one
903 +        if( pLed->ledActiveLow )
904 +            GPIO->GPIOio  &= ~pLed->ledMask;    // turn on the led
905 +        else
906 +            GPIO->GPIOio  |= pLed->ledMask;     // turn on the led
907 +        pLed->ledState = pLed->savedLedState = kLedStateOn;
908 +    }
909 +}
910 +
911 +
912 +// turn led off and set the ledState
913 +void ledOff(PLED_INFO pLed)
914 +{
915 +    if( pLed->ledMask )
916 +    {
917 +        GPIO->GPIODir |= pLed->ledMask;         // turn on the direction bit in case was turned off by some one
918 +        if( pLed->ledActiveLow )
919 +            GPIO->GPIOio  |= pLed->ledMask;     // turn off the led
920 +        else
921 +            GPIO->GPIOio  &= ~pLed->ledMask;    // turn off the led
922 +        pLed->ledState = pLed->savedLedState = kLedStateOff;
923 +    }
924 +}
925 +
926 +// turn led on and set the ledState
927 +void ledOnFail(PLED_INFO pLed)
928 +{
929 +    if( pLed->ledMaskFail )
930 +    {
931 +        GPIO->GPIODir |= pLed->ledMaskFail;     // turn on the direction bit in case was turned off by some one
932 +        if( pLed->ledActiveLowFail )
933 +            GPIO->GPIOio  &= ~pLed->ledMaskFail;// turn on the led
934 +        else
935 +            GPIO->GPIOio  |= pLed->ledMaskFail; // turn on the led
936 +        pLed->ledState = pLed->savedLedState = kLedStateFail;
937 +    }
938 +}
939 +
940 +
941 +// turn led off and set the ledState
942 +void ledOffFail(PLED_INFO pLed)
943 +{
944 +    if( pLed->ledMaskFail )
945 +    {
946 +        GPIO->GPIODir |= pLed->ledMaskFail;     // turn on the direction bit in case was turned off by some one
947 +        if( pLed->ledActiveLowFail )
948 +            GPIO->GPIOio  |= pLed->ledMaskFail; // turn off the led
949 +        else
950 +            GPIO->GPIOio  &= ~pLed->ledMaskFail;// turn off the led
951 +        pLed->ledState = pLed->savedLedState = kLedStateOff;
952 +    }
953 +}
954 +
955 +
956 +// toggle the led and return the current ledState
957 +BOARD_LED_STATE ledToggle(PLED_INFO pLed)
958 +{
959 +    GPIO->GPIODir |= pLed->ledMask;         // turn on the direction bit in case was turned off by some one
960 +    if (GPIO->GPIOio & pLed->ledMask)
961 +    {
962 +        GPIO->GPIOio &= ~(pLed->ledMask);
963 +        return( (pLed->ledActiveLow) ? kLedStateOn : kLedStateOff );
964 +    }
965 +    else
966 +    {
967 +        GPIO->GPIOio |= pLed->ledMask;
968 +        return( (pLed->ledActiveLow) ? kLedStateOff : kLedStateOn );
969 +    }
970 +}   
971 +
972 +
973 +// led timer.  Will return if timer is already on
974 +void ledTimerStart(void)
975 +{
976 +    if (gTimerOn)
977 +        return;
978 +
979 +#if defined(DEBUG_LED)
980 +    printk("led: add_timer\n");
981 +#endif
982 +
983 +    init_timer(&gLedTimer);
984 +    gLedTimer.function = (void*)ledTimerExpire;
985 +    gLedTimer.expires = jiffies + k100ms;        // timer expires in ~100ms
986 +    add_timer (&gLedTimer);
987 +    gTimerOn = TRUE;
988 +} 
989 +
990 +
991 +// led timer expire kicks in about ~100ms and perform the led operation according to the ledState and
992 +// restart the timer according to ledState
993 +void ledTimerExpire(void)
994 +{
995 +    int i;
996 +    PLED_INFO pCurLed;
997 +
998 +    gTimerOn = FALSE;
999 +
1000 +    for (i = 0, pCurLed = gLed; i < gLedCount; i++, pCurLed++)
1001 +    {
1002 +#if defined(DEBUG_LED)
1003 +        printk("led[%d]: Mask=0x%04x, State = %d, blcd=%d\n", i, pCurLed->ledMask, pCurLed->ledState, pCurLed->blinkCountDown);
1004 +#endif
1005 +        switch (pCurLed->ledState)
1006 +        {
1007 +            case kLedStateOn:
1008 +            case kLedStateOff:
1009 +            case kLedStateFail:
1010 +                pCurLed->blinkCountDown = 0;            // reset the blink count down
1011 +                break;
1012 +
1013 +            case kLedStateBlinkOnce:
1014 +                ledToggle(pCurLed);
1015 +                pCurLed->blinkCountDown = 0;                      // reset to 0
1016 +                pCurLed->ledState = pCurLed->savedLedState;
1017 +                if (pCurLed->ledState == kLedStateSlowBlinkContinues || 
1018 +                    pCurLed->ledState == kLedStateFastBlinkContinues)
1019 +                    ledTimerStart();                  // start timer if in blinkContinues stats
1020 +                break;
1021 +
1022 +            case kLedStateSlowBlinkContinues:
1023 +                if (pCurLed->blinkCountDown-- == 0)
1024 +                {
1025 +                    pCurLed->blinkCountDown = kSlowBlinkCount;
1026 +                    ledToggle(pCurLed);
1027 +                }
1028 +                ledTimerStart();
1029 +                break;
1030 +
1031 +            case kLedStateFastBlinkContinues:
1032 +                if (pCurLed->blinkCountDown-- == 0)
1033 +                {
1034 +                    pCurLed->blinkCountDown = kFastBlinkCount;
1035 +                    ledToggle(pCurLed);
1036 +                }
1037 +                ledTimerStart();
1038 +                break;
1039 +
1040 +            default:
1041 +                printk("Invalid state = %d\n", pCurLed->ledState);
1042 +        }
1043 +    }
1044 +}
1045 +
1046 +// initialize the gLedCount and allocate and fill gLed struct
1047 +void __init boardLedInit(PLED_MAP_PAIR cLedMapping)
1048 +{
1049 +    PLED_MAP_PAIR p1, p2;
1050 +    PLED_INFO pCurLed;
1051 +    int needTimer = FALSE;
1052 +    int alreadyUsed = 0;
1053 +
1054 +#if defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
1055 +    /* Set blink rate for BCM6348/BCM6338 hardware LEDs. */
1056 +    GPIO->LEDCtrl &= ~LED_INTERVAL_SET_MASK;
1057 +    GPIO->LEDCtrl |= LED_INTERVAL_SET_80MS;
1058 +#endif
1059 +
1060 +    memset( gpVirtLeds, 0x00, sizeof(gpVirtLeds) );
1061 +    memset( gLedHwFunc, 0x00, sizeof(gLedHwFunc) );
1062 +    memset( gLedHwFailFunc, 0x00, sizeof(gLedHwFailFunc) );
1063 +
1064 +    gLedCount = 0;
1065 +
1066 +    // Check for multiple LED names and multiple LED GPIO pins that share the
1067 +    // same physical board LED.
1068 +    for( p1 = cLedMapping; p1->ledName != kLedEnd; p1++ )
1069 +    {
1070 +        alreadyUsed = 0;
1071 +        for( p2 = cLedMapping; p2 != p1; p2++ )
1072 +        {
1073 +            if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1074 +                (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1075 +            {
1076 +                alreadyUsed = 1;
1077 +                break;
1078 +            }
1079 +        }
1080 +
1081 +        if( alreadyUsed == 0  )
1082 +            gLedCount++;
1083 +    }
1084 +
1085 +    gLed = (PLED_INFO) kmalloc((gLedCount * sizeof(LED_INFO)), GFP_KERNEL);
1086 +    if( gLed == NULL )
1087 +    {
1088 +        printk( "LED memory allocation error.\n" );
1089 +        return;
1090 +    }
1091 +
1092 +    memset( gLed, 0x00, gLedCount * sizeof(LED_INFO) );
1093 +
1094 +    // initial the gLed with unique ledMask and initial state. If more than 1 ledNames share the physical led 
1095 +    // (ledMask) the first defined led's ledInitState will be used.
1096 +    pCurLed = gLed;
1097 +    for( p1 = cLedMapping; p1->ledName != kLedEnd; p1++ )
1098 +    {
1099 +        if( (int) p1->ledName > MAX_VIRT_LEDS )
1100 +            continue;
1101 +
1102 +        alreadyUsed = 0;
1103 +        for( p2 = cLedMapping; p2 != p1; p2++ )
1104 +        {
1105 +            if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1106 +                (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1107 +            {
1108 +                alreadyUsed = 1;
1109 +                break;
1110 +            }
1111 +        }
1112 +
1113 +        if( alreadyUsed == 0 )
1114 +        {
1115 +            // Initialize the board LED for the first time.
1116 +            needTimer = initLedInfo( p1, pCurLed );
1117 +            gpVirtLeds[(int) p1->ledName] = pCurLed;
1118 +            pCurLed++;
1119 +        }
1120 +        else
1121 +        {
1122 +            PLED_INFO pLed;
1123 +            for( pLed = gLed; pLed != pCurLed; pLed++ )
1124 +            {
1125 +                // Find the LED_INFO structure that has already been initialized.
1126 +                if((pLed->ledMask && pLed->ledMask == p1->ledMask) ||
1127 +                   (pLed->ledMaskFail && pLed->ledMaskFail==p1->ledMaskFail))
1128 +                {
1129 +                    // The board LED has already been initialized but possibly
1130 +                    // not completely initialized.
1131 +                    if( p1->ledMask )
1132 +                    {
1133 +                        pLed->ledMask = p1->ledMask;
1134 +                        pLed->ledActiveLow = p1->ledActiveLow;
1135 +                    }
1136 +                    if( p1->ledMaskFail )
1137 +                    {
1138 +                        pLed->ledMaskFail = p1->ledMaskFail;
1139 +                        pLed->ledActiveLowFail = p1->ledActiveLowFail;
1140 +                    }
1141 +                    gpVirtLeds[(int) p1->ledName] = pLed;
1142 +                    break;
1143 +                }
1144 +            }
1145 +        }
1146 +    }
1147 +
1148 +    if (needTimer)
1149 +        ledTimerStart();
1150 +
1151 +#if defined(DEBUG_LED)
1152 +    int i;
1153 +    for (i=0; i < gLedCount; i++)
1154 +        printk("initLed: led[%d]: mask=0x%04x, state=%d\n", i,(gLed+i)->ledMask, (gLed+i)->ledState);
1155 +#endif
1156 +
1157 +}
1158 +
1159 +// Initialize a structure that contains information about a physical board LED
1160 +// control.  The board LED may contain more than one GPIO pin to control a
1161 +// normal condition (green) or a failure condition (red).
1162 +int initLedInfo( PLED_MAP_PAIR pCurMap, PLED_INFO pCurLed )
1163 +{
1164 +    int needTimer = FALSE;
1165 +    pCurLed->ledState = pCurLed->savedLedState = pCurMap->ledInitState;
1166 +    pCurLed->ledMask = pCurMap->ledMask;
1167 +    pCurLed->ledActiveLow = pCurMap->ledActiveLow;
1168 +    pCurLed->ledMaskFail = pCurMap->ledMaskFail;
1169 +    pCurLed->ledActiveLowFail = pCurMap->ledActiveLowFail;
1170 +
1171 +    switch (pCurLed->ledState)
1172 +    {
1173 +        case kLedStateOn:
1174 +            pCurLed->blinkCountDown = 0;            // reset the blink count down
1175 +            ledOn(pCurLed);
1176 +            break;
1177 +        case kLedStateOff:
1178 +            pCurLed->blinkCountDown = 0;            // reset the blink count down
1179 +            ledOff(pCurLed);
1180 +            break;
1181 +        case kLedStateFail:
1182 +            pCurLed->blinkCountDown = 0;            // reset the blink count down
1183 +            ledOnFail(pCurLed);
1184 +            break;
1185 +        case kLedStateBlinkOnce:
1186 +            pCurLed->blinkCountDown = 1;
1187 +            needTimer = TRUE;
1188 +            break;
1189 +        case kLedStateSlowBlinkContinues:
1190 +            pCurLed->blinkCountDown = kSlowBlinkCount;
1191 +            needTimer = TRUE;
1192 +            break;
1193 +        case kLedStateFastBlinkContinues:
1194 +            pCurLed->blinkCountDown = kFastBlinkCount;
1195 +            needTimer = TRUE;
1196 +            break;
1197 +        default:
1198 +            printk("Invalid state = %d\n", pCurLed->ledState);
1199 +    }
1200 +
1201 +    return( needTimer );
1202 +}
1203 +
1204 +#if 0 /* BROKEN */
1205 +// Determines if there is at least one interface in bridge mode.  Bridge mode
1206 +// is determined by the cfm convention of naming bridge interfaces nas17
1207 +// through nas24.
1208 +static int isBridgedProtocol(void)
1209 +{
1210 +    extern int dev_get(const char *name);
1211 +    const int firstBridgeId = 17;
1212 +    const int lastBridgeId = 24;
1213 +    int i;
1214 +    int ret = FALSE;
1215 +    char name[16];
1216 +
1217 +    for( i = firstBridgeId; i <= lastBridgeId; i++ )
1218 +    {
1219 +        sprintf( name, "nas%d", i );
1220 +
1221 +        if( dev_get(name) )
1222 +        {
1223 +            ret = TRUE;
1224 +            break;
1225 +        }
1226 +    }
1227 +
1228 +    return(ret);
1229 +}
1230 +#endif
1231 +
1232 +// led ctrl.  Maps the ledName to the corresponding ledInfoPtr and perform the led operation
1233 +void boardLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
1234 +{
1235 +    PLED_INFO ledInfoPtr;
1236 +
1237 +    // do the mapping from virtual to physical led
1238 +    if( (int) ledName < MAX_VIRT_LEDS )
1239 +        ledInfoPtr = gpVirtLeds[(int) ledName];
1240 +    else
1241 +        ledInfoPtr = NULL;
1242 +
1243 +    if (ledInfoPtr == NULL)
1244 +        return;
1245 +
1246 +    if( ledState != kLedStateFail && gLedHwFunc[(int) ledName] )
1247 +    {
1248 +        (*gLedHwFunc[(int) ledName]) (ledName, ledState);
1249 +        ledOffFail(ledInfoPtr);
1250 +        return;
1251 +    }
1252 +    else
1253 +        if( ledState == kLedStateFail && gLedHwFailFunc[(int) ledName] )
1254 +        {
1255 +            (*gLedHwFailFunc[(int) ledName]) (ledName, ledState);
1256 +            ledOff(ledInfoPtr);
1257 +            return;
1258 +        }
1259 +
1260 +#if 0 /* BROKEN */
1261 +    // Do not blink the WAN Data LED if at least one interface is in bridge mode.
1262 +    if(gLedOffInBridgeMode == 1 && (ledName == kLedWanData || ledName == kLedPPP))
1263 +    {
1264 +        static int BridgedProtocol = -1;
1265 +
1266 +        if( BridgedProtocol == -1 )
1267 +            BridgedProtocol = isBridgedProtocol();
1268 +
1269 +        if( BridgedProtocol == TRUE )
1270 +            return;
1271 +    }
1272 +#endif
1273 +
1274 +    // If the state is kLedStateFail and there is not a failure LED defined
1275 +    // in the board parameters, change the state to kLedStateFastBlinkContinues.
1276 +    if( ledState == kLedStateFail && ledInfoPtr->ledMaskFail == 0 )
1277 +        ledState = kLedStateFastBlinkContinues;
1278 +
1279 +    switch (ledState)
1280 +    {
1281 +        case kLedStateOn:
1282 +            // First, turn off the complimentary (failure) LED GPIO.
1283 +            if( ledInfoPtr->ledMaskFail )
1284 +                ledOffFail(ledInfoPtr);
1285 +            else
1286 +                if( gLedHwFailFunc[(int) ledName] )
1287 +                    (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1288 +
1289 +            // Next, turn on the specified LED GPIO.
1290 +            ledOn(ledInfoPtr);
1291 +            break;
1292 +
1293 +        case kLedStateOff: 
1294 +            // First, turn off the complimentary (failure) LED GPIO.
1295 +            if( ledInfoPtr->ledMaskFail )
1296 +                ledOffFail(ledInfoPtr);
1297 +            else
1298 +                if( gLedHwFailFunc[(int) ledName] )
1299 +                    (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1300 +
1301 +            // Next, turn off the specified LED GPIO.
1302 +            ledOff(ledInfoPtr);
1303 +            break;
1304 +
1305 +        case kLedStateFail:
1306 +            // First, turn off the complimentary (normal) LED GPIO.
1307 +            if( ledInfoPtr->ledMask )
1308 +                ledOff(ledInfoPtr);
1309 +            else
1310 +                if( gLedHwFunc[(int) ledName] )
1311 +                    (*gLedHwFunc[(int) ledName]) (ledName, kLedStateOff);
1312 +
1313 +            // Next, turn on (red) the specified LED GPIO.
1314 +            ledOnFail(ledInfoPtr);
1315 +            break;
1316 +
1317 +        case kLedStateBlinkOnce:
1318 +            // skip blinkOnce if it is already in Slow/Fast blink continues state
1319 +            if (ledInfoPtr->savedLedState == kLedStateSlowBlinkContinues ||
1320 +                ledInfoPtr->savedLedState == kLedStateFastBlinkContinues)
1321 +                ;
1322 +            else
1323 +            {
1324 +                if (ledInfoPtr->blinkCountDown == 0)  // skip the call if it is 1
1325 +                {
1326 +                    ledToggle(ledInfoPtr);
1327 +                    ledInfoPtr->blinkCountDown = 1;  // it will be reset to 0 when timer expires
1328 +                    ledInfoPtr->ledState = kLedStateBlinkOnce;
1329 +                    ledTimerStart();
1330 +                }
1331 +            }
1332 +            break;
1333 +
1334 +        case kLedStateSlowBlinkContinues:
1335 +            ledInfoPtr->blinkCountDown = kSlowBlinkCount;
1336 +            ledInfoPtr->ledState = kLedStateSlowBlinkContinues;
1337 +            ledInfoPtr->savedLedState = kLedStateSlowBlinkContinues;
1338 +            ledTimerStart();
1339 +            break;
1340 +
1341 +        case kLedStateFastBlinkContinues:
1342 +            ledInfoPtr->blinkCountDown = kFastBlinkCount;
1343 +            ledInfoPtr->ledState = kLedStateFastBlinkContinues;
1344 +            ledInfoPtr->savedLedState = kLedStateFastBlinkContinues;
1345 +            ledTimerStart();
1346 +            break;
1347 +
1348 +        default:
1349 +            printk("Invalid led state\n");
1350 +    }
1351 +}
1352 +
1353 +// This function is called for an LED that is controlled by hardware.
1354 +void kerSysLedRegisterHwHandler( BOARD_LED_NAME ledName,
1355 +    HANDLE_LED_FUNC ledHwFunc, int ledFailType )
1356 +{
1357 +    if( (int) ledName < MAX_VIRT_LEDS )
1358 +    {
1359 +        if( ledFailType == 1 )
1360 +            gLedHwFailFunc[(int) ledName] = ledHwFunc;
1361 +        else
1362 +            gLedHwFunc[(int) ledName] = ledHwFunc;
1363 +    }
1364 +}
1365 +
1366 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c
1367 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c 1970-01-01 01:00:00.000000000 +0100
1368 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c        2006-08-03 16:37:21.000000000 +0200
1369 @@ -0,0 +1,1781 @@
1370 +/*
1371 +<:copyright-gpl 
1372 + Copyright 2002 Broadcom Corp. All Rights Reserved. 
1373
1374 + This program is free software; you can distribute it and/or modify it 
1375 + under the terms of the GNU General Public License (Version 2) as 
1376 + published by the Free Software Foundation. 
1377
1378 + This program is distributed in the hope it will be useful, but WITHOUT 
1379 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
1380 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
1381 + for more details. 
1382
1383 + You should have received a copy of the GNU General Public License along 
1384 + with this program; if not, write to the Free Software Foundation, Inc., 
1385 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
1386 +:>
1387 +*/
1388 +/***************************************************************************
1389 + * File Name  : board.c
1390 + *
1391 + * Description: This file contains Linux character device driver entry 
1392 + *              for the board related ioctl calls: flash, get free kernel
1393 + *              page and dump kernel memory, etc.
1394 + *
1395 + * Created on :  2/20/2002  seanl:  use cfiflash.c, cfliflash.h (AMD specific)
1396 + *
1397 + ***************************************************************************/
1398 +
1399 +
1400 +/* Includes. */
1401 +#include <linux/version.h>
1402 +#include <linux/init.h>
1403 +#include <linux/fs.h>
1404 +#include <linux/interrupt.h>
1405 +#include <linux/capability.h>
1406 +#include <linux/slab.h>
1407 +#include <linux/errno.h>
1408 +#include <linux/module.h>
1409 +#include <linux/pagemap.h>
1410 +#include <asm/uaccess.h>
1411 +#include <linux/wait.h>
1412 +#include <linux/poll.h>
1413 +#include <linux/sched.h>
1414 +#include <linux/list.h>
1415 +#include <linux/if.h>
1416 +#include <linux/spinlock.h>
1417 +
1418 +#include <bcm_map_part.h>
1419 +#include <board.h>
1420 +#include <bcmTag.h>
1421 +#include "boardparms.h"
1422 +#include "cfiflash.h"
1423 +#include "bcm_intr.h"
1424 +#include "board.h"
1425 +#include "bcm_map_part.h"
1426 +
1427 +static DEFINE_SPINLOCK(board_lock);
1428 +
1429 +/* Typedefs. */
1430 +#if defined (NON_CONSECUTIVE_MAC)
1431 +// used to be the last octet. Now changed to the first 5 bits of the the forth octet
1432 +// to reduced the duplicated MAC addresses.
1433 +#define CHANGED_OCTET   3
1434 +#define SHIFT_BITS      3
1435 +#else
1436 +#define CHANGED_OCTET   1
1437 +#define SHIFT_BITS      0
1438 +#endif
1439 +
1440 +#if defined (WIRELESS)
1441 +#define SES_BTN_PRESSED 0x00000001
1442 +#define SES_EVENTS      SES_BTN_PRESSED /*OR all values if any*/
1443 +#define SES_LED_OFF     0
1444 +#define SES_LED_ON      1
1445 +#define SES_LED_BLINK   2
1446 +#endif
1447 +
1448 +typedef struct
1449 +{
1450 +    unsigned long ulId;
1451 +    char chInUse;
1452 +    char chReserved[3];
1453 +} MAC_ADDR_INFO, *PMAC_ADDR_INFO;
1454 +
1455 +typedef struct
1456 +{
1457 +    unsigned long ulSdramSize;
1458 +    unsigned long ulPsiSize;
1459 +    unsigned long ulNumMacAddrs;
1460 +    unsigned long ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN];
1461 +    MAC_ADDR_INFO MacAddrs[1];
1462 +} NVRAM_INFO, *PNVRAM_INFO;
1463 +
1464 +typedef struct
1465 +{
1466 +    unsigned long eventmask;    
1467 +} BOARD_IOC, *PBOARD_IOC;
1468 +
1469 +
1470 +/*Dyinggasp callback*/
1471 +typedef void (*cb_dgasp_t)(void *arg);
1472 +typedef struct _CB_DGASP__LIST
1473 +{
1474 +    struct list_head list;
1475 +    char name[IFNAMSIZ];
1476 +    cb_dgasp_t cb_dgasp_fn;
1477 +    void *context;
1478 +}CB_DGASP_LIST , *PCB_DGASP_LIST;
1479 +
1480 +
1481 +static LED_MAP_PAIR LedMapping[] =
1482 +{   // led name     Initial state       physical pin (ledMask)
1483 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},
1484 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},
1485 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},
1486 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},
1487 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},
1488 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0}, 
1489 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0}, 
1490 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0},     
1491 +    {kLedEnd,       kLedStateOff,       0, 0, 0, 0} // NOTE: kLedEnd has to be at the end.
1492 +};
1493 +
1494 +/* Externs. */
1495 +extern struct file fastcall *fget_light(unsigned int fd, int *fput_needed);
1496 +extern unsigned int nr_free_pages (void);
1497 +extern const char *get_system_type(void);
1498 +extern void kerSysFlashInit(void);
1499 +extern unsigned long get_nvram_start_addr(void);
1500 +extern unsigned long get_scratch_pad_start_addr(void);
1501 +extern unsigned long getMemorySize(void);
1502 +extern void __init boardLedInit(PLED_MAP_PAIR);
1503 +extern void boardLedCtrl(BOARD_LED_NAME, BOARD_LED_STATE);
1504 +extern void kerSysLedRegisterHandler( BOARD_LED_NAME ledName,
1505 +    HANDLE_LED_FUNC ledHwFunc, int ledFailType );
1506 +
1507 +/* Prototypes. */
1508 +void __init InitNvramInfo( void );
1509 +static int board_open( struct inode *inode, struct file *filp );
1510 +static int board_ioctl( struct inode *inode, struct file *flip, unsigned int command, unsigned long arg );
1511 +static ssize_t board_read(struct file *filp,  char __user *buffer, size_t count, loff_t *ppos); 
1512 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait);
1513 +static int board_release(struct inode *inode, struct file *filp);                        
1514 +
1515 +static BOARD_IOC* borad_ioc_alloc(void);
1516 +static void borad_ioc_free(BOARD_IOC* board_ioc);
1517 +
1518 +/* DyingGasp function prototype */
1519 +static void __init kerSysDyingGaspMapIntr(void);
1520 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
1521 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs);
1522 +#else
1523 +static unsigned int kerSysDyingGaspIsr(void);
1524 +#endif
1525 +static void __init kerSysInitDyingGaspHandler( void );
1526 +static void __exit kerSysDeinitDyingGaspHandler( void );
1527 +/* -DyingGasp function prototype - */
1528 +
1529 +
1530 +#if defined (WIRELESS)
1531 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs);
1532 +static void __init sesBtn_mapGpio(void);
1533 +static void __init sesBtn_mapIntr(int context);
1534 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait);
1535 +static ssize_t sesBtn_read(struct file *file,  char __user *buffer, size_t count, loff_t *ppos);
1536 +static void __init sesLed_mapGpio(void);
1537 +static void sesLed_ctrl(int action);
1538 +static void __init ses_board_init(void);
1539 +static void __exit ses_board_deinit(void);
1540 +#endif
1541 +
1542 +static PNVRAM_INFO g_pNvramInfo = NULL;
1543 +static int g_ledInitialized = 0;
1544 +static wait_queue_head_t g_board_wait_queue;
1545 +static CB_DGASP_LIST *g_cb_dgasp_list_head = NULL;
1546 +
1547 +static int g_wakeup_monitor = 0;
1548 +static struct file *g_monitor_file = NULL;
1549 +static struct task_struct *g_monitor_task = NULL;
1550 +static unsigned int (*g_orig_fop_poll)
1551 +    (struct file *, struct poll_table_struct *) = NULL;
1552 +
1553 +static struct file_operations board_fops =
1554 +{
1555 +  open:       board_open,
1556 +  ioctl:      board_ioctl,
1557 +  poll:       board_poll,
1558 +  read:       board_read,
1559 +  release:    board_release,
1560 +};
1561 +
1562 +uint32 board_major = 0;
1563 +
1564 +#if defined (WIRELESS)
1565 +static unsigned short sesBtn_irq = BP_NOT_DEFINED;
1566 +static unsigned short sesBtn_gpio = BP_NOT_DEFINED;
1567 +static unsigned short sesLed_gpio = BP_NOT_DEFINED;
1568 +#endif
1569 +
1570 +#if defined(MODULE)
1571 +int init_module(void)
1572 +{
1573 +    return( brcm_board_init() );              
1574 +}
1575 +
1576 +void cleanup_module(void)
1577 +{
1578 +    if (MOD_IN_USE)
1579 +        printk("brcm flash: cleanup_module failed because module is in use\n");
1580 +    else
1581 +        brcm_board_cleanup();
1582 +}
1583 +#endif //MODULE 
1584 +
1585 +
1586 +
1587 +static int __init brcm_board_init( void )
1588 +{
1589 +    typedef int (*BP_LED_FUNC) (unsigned short *);
1590 +    static struct BpLedInformation
1591 +    {
1592 +        BOARD_LED_NAME ledName;
1593 +        BP_LED_FUNC bpFunc;
1594 +        BP_LED_FUNC bpFuncFail;
1595 +    } bpLedInfo[] =
1596 +    {{kLedAdsl, BpGetAdslLedGpio, BpGetAdslFailLedGpio},
1597 +     {kLedWireless, BpGetWirelessLedGpio, NULL},
1598 +     {kLedUsb, BpGetUsbLedGpio, NULL},
1599 +     {kLedHpna, BpGetHpnaLedGpio, NULL},
1600 +     {kLedWanData, BpGetWanDataLedGpio, NULL},
1601 +     {kLedPPP, BpGetPppLedGpio, BpGetPppFailLedGpio},
1602 +     {kLedVoip, BpGetVoipLedGpio, NULL},
1603 +     {kLedSes, BpGetWirelessSesLedGpio, NULL},     
1604 +     {kLedEnd, NULL, NULL}
1605 +    };
1606 +
1607 +    int ret;
1608 +        
1609 +    ret = register_chrdev(BOARD_DRV_MAJOR, "bcrmboard", &board_fops );
1610 +    if (ret < 0)
1611 +        printk( "brcm_board_init(major %d): fail to register device.\n",BOARD_DRV_MAJOR);
1612 +    else 
1613 +    {
1614 +        PLED_MAP_PAIR pLedMap = LedMapping;
1615 +        unsigned short gpio;
1616 +        struct BpLedInformation *pInfo;
1617 +
1618 +        printk("brcmboard: brcm_board_init entry\n");
1619 +        board_major = BOARD_DRV_MAJOR;
1620 +       if (boot_loader_type == BOOT_CFE) 
1621 +               InitNvramInfo();
1622 +
1623 +#if !defined(CONFIG_BCM96338)
1624 +        GPIO->GPIOMode &= ~(0x000F0000);
1625 +#endif
1626 +
1627 +        pLedMap[0].ledName = kLedSelfTest ;
1628 +        pLedMap[0].ledMask = GPIO_NUM_TO_MASK(0);
1629 +        pLedMap[0].ledActiveLow = 0;
1630 +
1631 +        pLedMap[1].ledName = kLedAdsl;
1632 +        pLedMap[1].ledMask = GPIO_NUM_TO_MASK(1);
1633 +        pLedMap[1].ledActiveLow = 0;
1634 +
1635 +        pLedMap[2].ledName = kLedLan ;
1636 +        pLedMap[2].ledMask = GPIO_NUM_TO_MASK(2);
1637 +        pLedMap[2].ledActiveLow = 0;
1638 +
1639 +        pLedMap[3].ledName = kLedVoip  ;
1640 +        pLedMap[3].ledMask = GPIO_NUM_TO_MASK(3);
1641 +        pLedMap[3].ledActiveLow = 0;
1642 +
1643 +        pLedMap[4].ledName = kLedWireless ;
1644 +        pLedMap[4].ledMask = GPIO_NUM_TO_MASK(4);
1645 +        pLedMap[4].ledActiveLow = 0;
1646 +
1647 +        pLedMap[5].ledName = kLedEnd;
1648 +
1649 +#if 0
1650 +        for( pInfo = bpLedInfo; pInfo->ledName != kLedEnd; pInfo++ )
1651 +        {
1652 +            if( pInfo->bpFunc && (*pInfo->bpFunc) (&gpio) == BP_SUCCESS )
1653 +            {
1654 +                pLedMap->ledName = pInfo->ledName;
1655 +                pLedMap->ledMask = GPIO_NUM_TO_MASK(gpio);
1656 +                pLedMap->ledActiveLow = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1657 +            }
1658 +            if( pInfo->bpFuncFail && (*pInfo->bpFuncFail) (&gpio) == BP_SUCCESS )
1659 +            {
1660 +                pLedMap->ledName = pInfo->ledName;
1661 +                pLedMap->ledMaskFail = GPIO_NUM_TO_MASK(gpio);
1662 +                pLedMap->ledActiveLowFail = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1663 +            }
1664 +            if( pLedMap->ledName != kLedEnd )
1665 +                pLedMap++;
1666 +        }
1667 +#endif
1668 +        init_waitqueue_head(&g_board_wait_queue);
1669 +#if defined (WIRELESS)
1670 +        ses_board_init();
1671 +#endif        
1672 +        kerSysInitDyingGaspHandler();
1673 +        kerSysDyingGaspMapIntr();
1674 +
1675 +        boardLedInit(LedMapping);
1676 +        g_ledInitialized = 1;
1677 +    }
1678 +
1679 +    return ret;
1680 +} 
1681 +
1682 +void __init InitNvramInfo( void )
1683 +{
1684 +    PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
1685 +    unsigned long ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1686 +
1687 +    if( ulNumMacAddrs > 0 && ulNumMacAddrs <= NVRAM_MAC_COUNT_MAX )
1688 +    {
1689 +        unsigned long ulNvramInfoSize =
1690 +            sizeof(NVRAM_INFO) + ((sizeof(MAC_ADDR_INFO) - 1) * ulNumMacAddrs);
1691 +
1692 +        g_pNvramInfo = (PNVRAM_INFO) kmalloc( ulNvramInfoSize, GFP_KERNEL );
1693 +
1694 +        if( g_pNvramInfo )
1695 +        {
1696 +            unsigned long ulPsiSize;
1697 +            if( BpGetPsiSize( &ulPsiSize ) != BP_SUCCESS )
1698 +                ulPsiSize = NVRAM_PSI_DEFAULT;
1699 +            memset( g_pNvramInfo, 0x00, ulNvramInfoSize );
1700 +            g_pNvramInfo->ulPsiSize = ulPsiSize * 1024;
1701 +            g_pNvramInfo->ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1702 +            memcpy( g_pNvramInfo->ucaBaseMacAddr, pNvramData->ucaBaseMacAddr,
1703 +                NVRAM_MAC_ADDRESS_LEN );
1704 +            g_pNvramInfo->ulSdramSize = getMemorySize();
1705 +        }
1706 +        else
1707 +            printk("ERROR - Could not allocate memory for NVRAM data\n");
1708 +    }
1709 +    else
1710 +        printk("ERROR - Invalid number of MAC addresses (%ld) is configured.\n",
1711 +            ulNumMacAddrs);
1712 +}
1713 +
1714 +void __exit brcm_board_cleanup( void )
1715 +{
1716 +    printk("brcm_board_cleanup()\n");
1717 +       
1718 +    if (board_major != -1) 
1719 +    {
1720 +#if defined (WIRELESS)         
1721 +       ses_board_deinit();
1722 +#endif         
1723 +        kerSysDeinitDyingGaspHandler();
1724 +        unregister_chrdev(board_major, "board_ioctl");
1725 +    }
1726 +} 
1727 +
1728 +static BOARD_IOC* borad_ioc_alloc(void)
1729 +{
1730 +    BOARD_IOC *board_ioc =NULL;
1731 +    board_ioc = (BOARD_IOC*) kmalloc( sizeof(BOARD_IOC) , GFP_KERNEL );
1732 +    if(board_ioc)
1733 +    {
1734 +        memset(board_ioc, 0, sizeof(BOARD_IOC));
1735 +    }
1736 +    return board_ioc;
1737 +}
1738 +
1739 +static void borad_ioc_free(BOARD_IOC* board_ioc)
1740 +{
1741 +    if(board_ioc)
1742 +    {
1743 +        kfree(board_ioc);
1744 +    }  
1745 +}
1746 +
1747 +
1748 +static int board_open( struct inode *inode, struct file *filp )
1749 +{
1750 +    filp->private_data = borad_ioc_alloc();
1751 +
1752 +    if (filp->private_data == NULL)
1753 +        return -ENOMEM;
1754 +            
1755 +    return( 0 );
1756 +} 
1757 +
1758 +static int board_release(struct inode *inode, struct file *filp)
1759 +{
1760 +    BOARD_IOC *board_ioc = filp->private_data;
1761 +    
1762 +    wait_event_interruptible(g_board_wait_queue, 1);    
1763 +    borad_ioc_free(board_ioc);
1764 +
1765 +    return( 0 );
1766 +} 
1767 +
1768 +
1769 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait)
1770 +{
1771 +    unsigned int mask = 0;
1772 +#if defined (WIRELESS)         
1773 +    BOARD_IOC *board_ioc = filp->private_data;         
1774 +#endif
1775 +       
1776 +    poll_wait(filp, &g_board_wait_queue, wait);
1777 +#if defined (WIRELESS)         
1778 +    if(board_ioc->eventmask & SES_EVENTS){
1779 +        mask |= sesBtn_poll(filp, wait);
1780 +    }                  
1781 +#endif    
1782 +
1783 +    return mask;
1784 +}
1785 +
1786 +
1787 +static ssize_t board_read(struct file *filp,  char __user *buffer, size_t count, loff_t *ppos)
1788 +{
1789 +#if defined (WIRELESS)    
1790 +    BOARD_IOC *board_ioc = filp->private_data;
1791 +    if(board_ioc->eventmask & SES_EVENTS){
1792 +       return sesBtn_read(filp, buffer, count, ppos);
1793 +    }
1794 +#endif    
1795 +    return 0;
1796 +}
1797 +
1798 +//**************************************************************************************
1799 +// Utitlities for dump memory, free kernel pages, mips soft reset, etc.
1800 +//**************************************************************************************
1801 +
1802 +/***********************************************************************
1803 + * Function Name: dumpaddr
1804 + * Description  : Display a hex dump of the specified address.
1805 + ***********************************************************************/
1806 +void dumpaddr( unsigned char *pAddr, int nLen )
1807 +{
1808 +    static char szHexChars[] = "0123456789abcdef";
1809 +    char szLine[80];
1810 +    char *p = szLine;
1811 +    unsigned char ch, *q;
1812 +    int i, j;
1813 +    unsigned long ul;
1814 +
1815 +    while( nLen > 0 )
1816 +    {
1817 +        sprintf( szLine, "%8.8lx: ", (unsigned long) pAddr );
1818 +        p = szLine + strlen(szLine);
1819 +
1820 +        for(i = 0; i < 16 && nLen > 0; i += sizeof(long), nLen -= sizeof(long))
1821 +        {
1822 +            ul = *(unsigned long *) &pAddr[i];
1823 +            q = (unsigned char *) &ul;
1824 +            for( j = 0; j < sizeof(long); j++ )
1825 +            {
1826 +                *p++ = szHexChars[q[j] >> 4];
1827 +                *p++ = szHexChars[q[j] & 0x0f];
1828 +                *p++ = ' ';
1829 +            }
1830 +        }
1831 +
1832 +        for( j = 0; j < 16 - i; j++ )
1833 +            *p++ = ' ', *p++ = ' ', *p++ = ' ';
1834 +
1835 +        *p++ = ' ', *p++ = ' ', *p++ = ' ';
1836 +
1837 +        for( j = 0; j < i; j++ )
1838 +        {
1839 +            ch = pAddr[j];
1840 +            *p++ = (ch > ' ' && ch < '~') ? ch : '.';
1841 +        }
1842 +
1843 +        *p++ = '\0';
1844 +        printk( "%s\r\n", szLine );
1845 +
1846 +        pAddr += i;
1847 +    }
1848 +    printk( "\r\n" );
1849 +} /* dumpaddr */
1850 +
1851 +
1852 +void kerSysMipsSoftReset(void)
1853 +{
1854 +#if defined(CONFIG_BCM96348)
1855 +    if (PERF->RevID == 0x634800A1) {
1856 +        typedef void (*FNPTR) (void);
1857 +        FNPTR bootaddr = (FNPTR) FLASH_BASE;
1858 +        int i;
1859 +
1860 +        /* Disable interrupts. */
1861 +        //cli();
1862 +       spin_lock_irq(&board_lock);
1863 +       
1864 +        /* Reset all blocks. */
1865 +        PERF->BlockSoftReset &= ~BSR_ALL_BLOCKS;
1866 +        for( i = 0; i < 1000000; i++ )
1867 +            ;
1868 +        PERF->BlockSoftReset |= BSR_ALL_BLOCKS;
1869 +        /* Jump to the power on address. */
1870 +        (*bootaddr) ();
1871 +    }
1872 +    else
1873 +        PERF->pll_control |= SOFT_RESET;    // soft reset mips
1874 +#else
1875 +    PERF->pll_control |= SOFT_RESET;    // soft reset mips
1876 +#endif
1877 +}
1878 +
1879 +
1880 +int kerSysGetMacAddress( unsigned char *pucaMacAddr, unsigned long ulId )
1881 +{
1882 +    int nRet = 0;
1883 +    PMAC_ADDR_INFO pMai = NULL;
1884 +    PMAC_ADDR_INFO pMaiFreeNoId = NULL;
1885 +    PMAC_ADDR_INFO pMaiFreeId = NULL;
1886 +    unsigned long i = 0, ulIdxNoId = 0, ulIdxId = 0, shiftedIdx = 0;
1887 +
1888 +    /* CMO -- Fix le problème avec les adresses mac que l'on n'arrive pas
1889 +     *  * Ã  relire plusieurs fois */
1890 +    /* inv_xde */
1891 +    if (boot_loader_type == BOOT_CFE)
1892 +      memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1893 +              NVRAM_MAC_ADDRESS_LEN );
1894 +    else {
1895 +      pucaMacAddr[0] = 0x00;
1896 +      pucaMacAddr[1] = 0x07;
1897 +      pucaMacAddr[2] = 0x3A;
1898 +      pucaMacAddr[3] = 0xFF;
1899 +      pucaMacAddr[4] = 0xFF;
1900 +      pucaMacAddr[5] = 0xFF;
1901 +    }
1902 +
1903 +    return nRet;
1904 +#if 0
1905 +    for( i = 0, pMai = g_pNvramInfo->MacAddrs; i < g_pNvramInfo->ulNumMacAddrs;
1906 +        i++, pMai++ )
1907 +    {
1908 +        if( ulId == pMai->ulId || ulId == MAC_ADDRESS_ANY )
1909 +        {
1910 +            /* This MAC address has been used by the caller in the past. */
1911 +            memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1912 +                NVRAM_MAC_ADDRESS_LEN );
1913 +            shiftedIdx = i;
1914 +            pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1915 +            pMai->chInUse = 1;
1916 +            pMaiFreeNoId = pMaiFreeId = NULL;
1917 +            break;
1918 +        }
1919 +        else
1920 +            if( pMai->chInUse == 0 )
1921 +            {
1922 +                if( pMai->ulId == 0 && pMaiFreeNoId == NULL )
1923 +                {
1924 +                    /* This is an available MAC address that has never been
1925 +                     * used.
1926 +                     */
1927 +                    pMaiFreeNoId = pMai;
1928 +                    ulIdxNoId = i;
1929 +                }
1930 +                else
1931 +                    if( pMai->ulId != 0 && pMaiFreeId == NULL )
1932 +                    {
1933 +                        /* This is an available MAC address that has been used
1934 +                         * before.  Use addresses that have never been used
1935 +                         * first, before using this one.
1936 +                         */
1937 +                        pMaiFreeId = pMai;
1938 +                        ulIdxId = i;
1939 +                    }
1940 +            }
1941 +    }
1942 +
1943 +    if( pMaiFreeNoId || pMaiFreeId )
1944 +    {
1945 +        /* An available MAC address was found. */
1946 +        memcpy(pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,NVRAM_MAC_ADDRESS_LEN);
1947 +        if( pMaiFreeNoId )
1948 +        {
1949 +            shiftedIdx = ulIdxNoId;
1950 +            pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1951 +            pMaiFreeNoId->ulId = ulId;
1952 +            pMaiFreeNoId->chInUse = 1;
1953 +        }
1954 +        else
1955 +        {
1956 +            shiftedIdx = ulIdxId;
1957 +            pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1958 +            pMaiFreeId->ulId = ulId;
1959 +            pMaiFreeId->chInUse = 1;
1960 +        }
1961 +    }
1962 +    else
1963 +        if( i == g_pNvramInfo->ulNumMacAddrs )
1964 +            nRet = -EADDRNOTAVAIL;
1965 +
1966 +    return( nRet );
1967 +#endif
1968 +} /* kerSysGetMacAddr */
1969 +
1970 +int kerSysReleaseMacAddress( unsigned char *pucaMacAddr )
1971 +{
1972 +    int nRet = -EINVAL;
1973 +    unsigned long ulIdx = 0;
1974 +    int idx = (pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] -
1975 +        g_pNvramInfo->ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET]);
1976 +
1977 +    // if overflow 255 (negitive), add 256 to have the correct index
1978 +    if (idx < 0)
1979 +        idx += 256;
1980 +    ulIdx = (unsigned long) (idx >> SHIFT_BITS);
1981 +
1982 +    if( ulIdx < g_pNvramInfo->ulNumMacAddrs )
1983 +    {
1984 +        PMAC_ADDR_INFO pMai = &g_pNvramInfo->MacAddrs[ulIdx];
1985 +        if( pMai->chInUse == 1 )
1986 +        {
1987 +            pMai->chInUse = 0;
1988 +            nRet = 0;
1989 +        }
1990 +    }
1991 +
1992 +    return( nRet );
1993 +} /* kerSysReleaseMacAddr */
1994 +
1995 +int kerSysGetSdramSize( void )
1996 +{
1997 +  if (boot_loader_type == BOOT_CFE) {
1998 +    return( (int) g_pNvramInfo->ulSdramSize );
1999 +  }
2000 +  else {
2001 +    printk("kerSysGetSdramSize : 0x%08X\n", (int)getMemorySize() + 0x00040000);
2002 +    return((int)getMemorySize() + 0x00040000);
2003 +  }
2004 +} /* kerSysGetSdramSize */
2005 +
2006 +
2007 +void kerSysLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
2008 +{
2009 +    if (g_ledInitialized)
2010 +      boardLedCtrl(ledName, ledState);
2011 +}
2012 +
2013 +unsigned int kerSysMonitorPollHook( struct file *f, struct poll_table_struct *t)
2014 +{
2015 +    int mask = (*g_orig_fop_poll) (f, t);
2016 +
2017 +    if( g_wakeup_monitor == 1 && g_monitor_file == f )
2018 +    {
2019 +        /* If g_wakeup_monitor is non-0, the user mode application needs to
2020 +         * return from a blocking select function.  Return POLLPRI which will
2021 +         * cause the select to return with the exception descriptor set.
2022 +         */
2023 +        mask |= POLLPRI;
2024 +        g_wakeup_monitor = 0;
2025 +    }
2026 +
2027 +    return( mask );
2028 +}
2029 +
2030 +/* Put the user mode application that monitors link state on a run queue. */
2031 +void kerSysWakeupMonitorTask( void )
2032 +{
2033 +    g_wakeup_monitor = 1;
2034 +    if( g_monitor_task )
2035 +        wake_up_process( g_monitor_task );
2036 +}
2037 +
2038 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2039 +int kerSysGetResetHold(void)
2040 +{
2041 +       unsigned short gpio;
2042 +
2043 +       if( BpGetPressAndHoldResetGpio( &gpio ) == BP_SUCCESS )
2044 +       {
2045 +#if defined(CONFIG_BCM96338)
2046 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
2047 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2048 +#endif
2049 +#if defined(CONFIG_BCM96345)
2050 +    unsigned short gpio_mask = GPIO_NUM_TO_MASK(gpio);
2051 +    volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2052 +#endif
2053 +#if defined(CONFIG_BCM96348)
2054 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
2055 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2056 +
2057 +    if( (gpio & ~BP_ACTIVE_MASK) >= 32 )
2058 +    {
2059 +        gpio_mask = GPIO_NUM_TO_MASK_HIGH(gpio);
2060 +        gpio_reg = &GPIO->GPIOio_high;
2061 +    }
2062 +#endif
2063 +       //printk("gpio=%04x,gpio_mask=%04x,gpio_reg=%04x\n",gpio,gpio_mask,*gpio_reg);
2064 +       if(*gpio_reg & gpio_mask)  //press down
2065 +               return RESET_BUTTON_UP;
2066 +       }
2067 +       return RESET_BUTTON_PRESSDOWN;
2068 +}
2069 +//<<JUNHON, 2004/09/15
2070 +
2071 +//********************************************************************************************
2072 +// misc. ioctl calls come to here. (flash, led, reset, kernel memory access, etc.)
2073 +//********************************************************************************************
2074 +static int board_ioctl( struct inode *inode, struct file *flip,
2075 +                        unsigned int command, unsigned long arg )
2076 +{
2077 +    int ret = 0;
2078 +    BOARD_IOCTL_PARMS ctrlParms;
2079 +    unsigned char ucaMacAddr[NVRAM_MAC_ADDRESS_LEN];
2080 +    int allowedSize;
2081 +
2082 +    switch (command) 
2083 +    {
2084 +        case BOARD_IOCTL_FLASH_INIT:
2085 +            // not used for now.  kerSysBcmImageInit();
2086 +            break;
2087 +
2088 +
2089 +        case BOARD_IOCTL_FLASH_WRITE:
2090 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2091 +            {
2092 +                NVRAM_DATA SaveNvramData;
2093 +                PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
2094 +
2095 +                switch (ctrlParms.action)
2096 +                {
2097 +                    case SCRATCH_PAD:
2098 +                       if (boot_loader_type == BOOT_CFE) {
2099 +                         ret = kerSysScratchPadSet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2100 +                        }
2101 +                        else {
2102 +                          printk("RedBoot :  not supported\n");
2103 +                          return(-EINVAL);
2104 +                        }
2105 +                        break;
2106 +
2107 +                    case PERSISTENT:
2108 +                       if (boot_loader_type == BOOT_CFE) {
2109 +                          ret = kerSysPersistentSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2110 +                        }
2111 +                        else {
2112 +                          printk("RedBoot :  not supported\n");
2113 +                          return(-EINVAL);
2114 +                        }
2115 +                        break;
2116 +                
2117 +                    case NVRAM:
2118 +                       if (boot_loader_type == BOOT_CFE) {
2119 +                          ret = kerSysNvRamSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2120 +                        }
2121 +                        else {
2122 +                          printk("RedBoot :  not supported\n");
2123 +                          return(-EINVAL);
2124 +                        }
2125 +                        break;
2126 +
2127 +                    case BCM_IMAGE_CFE:
2128 +                       if (boot_loader_type == BOOT_CFE) {
2129 +                          if( ctrlParms.strLen <= 0 || ctrlParms.strLen > FLASH45_LENGTH_BOOT_ROM )
2130 +                          {
2131 +                            printk("Illegal CFE size [%d]. Size allowed: [%d]\n",
2132 +                                ctrlParms.strLen, FLASH45_LENGTH_BOOT_ROM);
2133 +                            ret = -1;
2134 +                            break;
2135 +                          }
2136 +
2137 +                        // save NVRAM data into a local structure
2138 +                        memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2139 +
2140 +                        ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2141 +
2142 +                        // if nvram is not valid, restore the current nvram settings
2143 +                        if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2144 +                            *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2145 +                            {
2146 +                              kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2147 +                            }
2148 +                         }
2149 +                      else {
2150 +                          printk("RedBoot :  not supported\n");
2151 +                          return(-EINVAL);
2152 +                        }
2153 +                      break;  
2154 +                    case BCM_IMAGE_FS:
2155 +                       if (boot_loader_type == BOOT_CFE) {
2156 +                        allowedSize = (int) flash_get_total_size() - FLASH_RESERVED_AT_END - TAG_LEN - FLASH45_LENGTH_BOOT_ROM;
2157 +                        if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize)
2158 +                        {
2159 +                            printk("Illegal root file system size [%d]. Size allowed: [%d]\n",
2160 +                                ctrlParms.strLen,  ctrlParms.offset - allowedSize);
2161 +                            ret = -1;
2162 +                            break;
2163 +                        }
2164 +                        ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2165 +                        kerSysMipsSoftReset();
2166 +                      }
2167 +                      else {
2168 +                        printk("RedBoot :  not supported\n");
2169 +                        return(-EINVAL);
2170 +                      }
2171 +                        break;
2172 +
2173 +                    case BCM_IMAGE_KERNEL:  // not used for now.
2174 +                       if (boot_loader_type == BOOT_CFE) {
2175 +                        allowedSize = (int) flash_get_total_size() - FLASH_RESERVED_AT_END - TAG_LEN - ctrlParms.offset;
2176 +
2177 +                        printk("kernel size = [%d]. Allowed size = [%d]\n", ctrlParms.strLen, allowedSize);
2178 +
2179 +                        if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize )
2180 +                        {
2181 +                            printk("Kernel size is over the limit by [%d] bytes\n",
2182 +                                ctrlParms.strLen - allowedSize);
2183 +                            ret = -1;
2184 +                            break;
2185 +                        }
2186 +                        ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2187 +                      }
2188 +                      else {
2189 +                        printk("RedBoot :  not supported\n");
2190 +                        return(-EINVAL);
2191 +                      }
2192 +                        break;
2193 +                    case BCM_IMAGE_WHOLE:
2194 +                       if (boot_loader_type == BOOT_CFE) {
2195 +                        if(ctrlParms.strLen <= 0)
2196 +                        {
2197 +                            printk("Illegal flash image size [%d].\n", ctrlParms.strLen);
2198 +                            ret = -1;
2199 +                            break;
2200 +                        }
2201 +
2202 +                        // save NVRAM data into a local structure
2203 +                        memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2204 +
2205 +                        ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2206 +
2207 +                        // if nvram is not valid, restore the current nvram settings
2208 +                        if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2209 +                            *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2210 +                        {
2211 +                            kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2212 +                        }
2213 +
2214 +                        kerSysMipsSoftReset();
2215 +                      }
2216 +                      else {
2217 +                        printk("RedBoot :  not supported\n");
2218 +                        return(-EINVAL);
2219 +                      }
2220 +                        break;
2221 +
2222 +                    default:
2223 +                        ret = -EINVAL;
2224 +                        printk("flash_ioctl_command: invalid command %d\n", ctrlParms.action);
2225 +                        break;
2226 +                }
2227 +                ctrlParms.result = ret;
2228 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2229 +            }
2230 +            else
2231 +                ret = -EFAULT;
2232 +            break;
2233 +
2234 +        case BOARD_IOCTL_FLASH_READ:
2235 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2236 +            {
2237 +                switch (ctrlParms.action)
2238 +                {
2239 +                    case SCRATCH_PAD:
2240 +                       if (boot_loader_type == BOOT_CFE) {
2241 +                        ret = kerSysScratchPadGet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2242 +                      }
2243 +                      else {
2244 +                        printk("RedBoot :  not supported\n");
2245 +                        return(-EINVAL);
2246 +                      }
2247 +                        break;
2248 +
2249 +                    case PERSISTENT:
2250 +                       if (boot_loader_type == BOOT_CFE) {
2251 +                        ret = kerSysPersistentGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2252 +                      }
2253 +                      else {
2254 +                        printk("RedBoot :  not supported\n");
2255 +                        return(-EINVAL);
2256 +                      }
2257 +                        break;
2258 +
2259 +                    case NVRAM:
2260 +                       if (boot_loader_type == BOOT_CFE) {
2261 +                        ret = kerSysNvRamGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2262 +                      }
2263 +                      else {
2264 +                        printk("RedBoot :  not supported\n");
2265 +                        return(-EINVAL);
2266 +                      }
2267 +                        break;
2268 +
2269 +                    case FLASH_SIZE:
2270 +                       if (boot_loader_type == BOOT_CFE) {
2271 +                        ret = kerSysFlashSizeGet();
2272 +                      }
2273 +                      else {
2274 +                        printk("RedBoot :  not supported\n");
2275 +                        return(-EINVAL);
2276 +                      }
2277 +                        break;
2278 +
2279 +                    default:
2280 +                        ret = -EINVAL;
2281 +                        printk("Not supported.  invalid command %d\n", ctrlParms.action);
2282 +                        break;
2283 +                }
2284 +                ctrlParms.result = ret;
2285 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2286 +            }
2287 +            else
2288 +                ret = -EFAULT;
2289 +            break;
2290 +
2291 +        case BOARD_IOCTL_GET_NR_PAGES:
2292 +            ctrlParms.result = nr_free_pages() + get_page_cache_size();
2293 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2294 +            ret = 0;
2295 +            break;
2296 +
2297 +        case BOARD_IOCTL_DUMP_ADDR:
2298 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2299 +            {
2300 +                dumpaddr( (unsigned char *) ctrlParms.string, ctrlParms.strLen );
2301 +                ctrlParms.result = 0;
2302 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2303 +                ret = 0;
2304 +            }
2305 +            else
2306 +                ret = -EFAULT;
2307 +            break;
2308 +
2309 +        case BOARD_IOCTL_SET_MEMORY:
2310 +         if (boot_loader_type == BOOT_CFE) {
2311 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2312 +            {
2313 +                unsigned long  *pul = (unsigned long *)  ctrlParms.string;
2314 +                unsigned short *pus = (unsigned short *) ctrlParms.string;
2315 +                unsigned char  *puc = (unsigned char *)  ctrlParms.string;
2316 +                switch( ctrlParms.strLen )
2317 +                {
2318 +                    case 4:
2319 +                        *pul = (unsigned long) ctrlParms.offset;
2320 +                        break;
2321 +                    case 2:
2322 +                        *pus = (unsigned short) ctrlParms.offset;
2323 +                        break;
2324 +                    case 1:
2325 +                        *puc = (unsigned char) ctrlParms.offset;
2326 +                        break;
2327 +                }
2328 +                dumpaddr( (unsigned char *) ctrlParms.string, sizeof(long) );
2329 +                ctrlParms.result = 0;
2330 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2331 +                ret = 0;
2332 +            }
2333 +            else
2334 +                ret = -EFAULT;
2335 +         }
2336 +         else {
2337 +            printk("RedBoot :  not supported\n");
2338 +             return(-EINVAL);
2339 +
2340 +         }
2341 +            break;
2342 +      
2343 +        case BOARD_IOCTL_MIPS_SOFT_RESET:
2344 +            kerSysMipsSoftReset();
2345 +            break;
2346 +
2347 +        case BOARD_IOCTL_LED_CTRL:
2348 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2349 +            {
2350 +                   kerSysLedCtrl((BOARD_LED_NAME)ctrlParms.strLen, (BOARD_LED_STATE)ctrlParms.offset);
2351 +                   ret = 0;
2352 +               }
2353 +            break;
2354 +
2355 +        case BOARD_IOCTL_GET_ID:
2356 +         if (boot_loader_type == BOOT_CFE) {
2357 +            if (copy_from_user((void*)&ctrlParms, (void*)arg,
2358 +                sizeof(ctrlParms)) == 0) 
2359 +            {
2360 +                if( ctrlParms.string )
2361 +                {
2362 +                    char *p = (char *) get_system_type();
2363 +                    if( strlen(p) + 1 < ctrlParms.strLen )
2364 +                        ctrlParms.strLen = strlen(p) + 1;
2365 +                    __copy_to_user(ctrlParms.string, p, ctrlParms.strLen);
2366 +                }
2367 +
2368 +                ctrlParms.result = 0;
2369 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2370 +                    sizeof(BOARD_IOCTL_PARMS));
2371 +            }
2372 +          }
2373 +          else {
2374 +            printk("RedBoot :  not supported\n");
2375 +             return(-EINVAL);  
2376 +          }
2377 +            break;
2378 +
2379 +        case BOARD_IOCTL_GET_MAC_ADDRESS:
2380 +         if (boot_loader_type == BOOT_CFE) {
2381 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2382 +            {
2383 +                ctrlParms.result = kerSysGetMacAddress( ucaMacAddr,
2384 +                    ctrlParms.offset );
2385 +
2386 +                if( ctrlParms.result == 0 )
2387 +                {
2388 +                    __copy_to_user(ctrlParms.string, ucaMacAddr,
2389 +                        sizeof(ucaMacAddr));
2390 +                }
2391 +
2392 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2393 +                    sizeof(BOARD_IOCTL_PARMS));
2394 +                ret = 0;
2395 +            }
2396 +            else
2397 +                ret = -EFAULT;
2398 +          }
2399 +         else {
2400 +           printk("RedBoot :  not supported\n");
2401 +            return(-EINVAL);
2402 +         }
2403 +            break;
2404 +
2405 +        case BOARD_IOCTL_RELEASE_MAC_ADDRESS:
2406 +         if (boot_loader_type == BOOT_CFE) {
2407 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2408 +            {
2409 +                if (copy_from_user((void*)ucaMacAddr, (void*)ctrlParms.string, \
2410 +                     NVRAM_MAC_ADDRESS_LEN) == 0) 
2411 +                {
2412 +                    ctrlParms.result = kerSysReleaseMacAddress( ucaMacAddr );
2413 +                }
2414 +                else
2415 +                {
2416 +                    ctrlParms.result = -EACCES;
2417 +                }
2418 +
2419 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2420 +                    sizeof(BOARD_IOCTL_PARMS));
2421 +                ret = 0;
2422 +            }
2423 +            else
2424 +                ret = -EFAULT;
2425 +          }
2426 +          else {
2427 +             printk("RedBoot :  not supported\n");
2428 +              return(-EINVAL);
2429 +          }
2430 +            break;
2431 +
2432 +        case BOARD_IOCTL_GET_PSI_SIZE:
2433 +         if (boot_loader_type == BOOT_CFE) {
2434 +            ctrlParms.result = (int) g_pNvramInfo->ulPsiSize;
2435 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2436 +            ret = 0;
2437 +         }
2438 +         else {
2439 +           printk("RedBoot :  not supported\n");
2440 +            return(-EINVAL);
2441 +         }
2442 +            break;
2443 +
2444 +        case BOARD_IOCTL_GET_SDRAM_SIZE:
2445 +         if (boot_loader_type == BOOT_CFE) {
2446 +            ctrlParms.result = (int) g_pNvramInfo->ulSdramSize;
2447 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2448 +            ret = 0;
2449 +         }
2450 +         else {
2451 +           printk("RedBoot :  not supported\n");
2452 +            return(-EINVAL);
2453 +         }
2454 +            break;
2455 +
2456 +        case BOARD_IOCTL_GET_BASE_MAC_ADDRESS:
2457 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) 
2458 +            {
2459 +                __copy_to_user(ctrlParms.string, g_pNvramInfo->ucaBaseMacAddr, NVRAM_MAC_ADDRESS_LEN);
2460 +                ctrlParms.result = 0;
2461 +
2462 +                __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2463 +                    sizeof(BOARD_IOCTL_PARMS));
2464 +                ret = 0;
2465 +            }
2466 +            else
2467 +                ret = -EFAULT;
2468 +            break;
2469 +
2470 +        case BOARD_IOCTL_GET_CHIP_ID:
2471 +            ctrlParms.result = (int) (PERF->RevID & 0xFFFF0000) >> 16;
2472 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2473 +            ret = 0;
2474 +            break;
2475 +
2476 +        case BOARD_IOCTL_GET_NUM_ENET: {
2477 +            ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2478 +            int i, numeth = 0;
2479 +            if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2480 +            for( i = 0; i < BP_MAX_ENET_MACS; i++) {
2481 +                if (EnetInfos[i].ucPhyType != BP_ENET_NO_PHY) {
2482 +                numeth++;
2483 +                }
2484 +            }
2485 +            ctrlParms.result = numeth;
2486 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,         sizeof(BOARD_IOCTL_PARMS));   
2487 +            ret = 0;
2488 +            }
2489 +               else {
2490 +                   ret = -EFAULT;
2491 +               }
2492 +               break;
2493 +            }
2494 +
2495 +        case BOARD_IOCTL_GET_CFE_VER:
2496 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2497 +                char *vertag =  (char *)(FLASH_BASE + CFE_VERSION_OFFSET);
2498 +                if (ctrlParms.strLen < CFE_VERSION_SIZE) {
2499 +                    ctrlParms.result = 0;
2500 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2501 +                    ret = -EFAULT;
2502 +                }
2503 +                else if (strncmp(vertag, "cfe-v", 5)) { // no tag info in flash
2504 +                    ctrlParms.result = 0;
2505 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2506 +                    ret = 0;
2507 +                }
2508 +                else {
2509 +                    ctrlParms.result = 1;
2510 +                    __copy_to_user(ctrlParms.string, vertag+CFE_VERSION_MARK_SIZE, CFE_VERSION_SIZE);
2511 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2512 +                    ret = 0;
2513 +                }
2514 +            }
2515 +            else {
2516 +                ret = -EFAULT;
2517 +            }
2518 +            break;
2519 +
2520 +        case BOARD_IOCTL_GET_ENET_CFG:
2521 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2522 +                ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2523 +                if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2524 +                    if (ctrlParms.strLen == sizeof(EnetInfos)) {
2525 +                        __copy_to_user(ctrlParms.string, EnetInfos, sizeof(EnetInfos));
2526 +                        ctrlParms.result = 0;
2527 +                        __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));   
2528 +                        ret = 0;
2529 +                    } else
2530 +                           ret = -EFAULT;
2531 +                }
2532 +                   else {
2533 +                       ret = -EFAULT;
2534 +                   }
2535 +                   break;
2536 +            }
2537 +            else {
2538 +                ret = -EFAULT;
2539 +            }
2540 +            break;  
2541 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2542 +        case BOARD_IOCTL_GET_RESETHOLD:
2543 +            ctrlParms.result = kerSysGetResetHold();
2544 +            __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2545 +            ret = 0;
2546 +               break;
2547 +//>>JUNHON, 2004/09/15
2548 +          
2549 +
2550 +#if defined (WIRELESS)
2551 +        case BOARD_IOCTL_GET_WLAN_ANT_INUSE:
2552 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2553 +                unsigned short antInUse = 0;
2554 +                if (BpGetWirelessAntInUse(&antInUse) == BP_SUCCESS) {
2555 +                    if (ctrlParms.strLen == sizeof(antInUse)) {
2556 +                        __copy_to_user(ctrlParms.string, &antInUse, sizeof(antInUse));
2557 +                        ctrlParms.result = 0;
2558 +                        __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));   
2559 +                        ret = 0;
2560 +                    } else
2561 +                           ret = -EFAULT;
2562 +                }
2563 +               else {
2564 +                  ret = -EFAULT;
2565 +               }
2566 +               break;
2567 +            }
2568 +            else {
2569 +                ret = -EFAULT;
2570 +            }
2571 +            break;            
2572 +#endif            
2573 +        case BOARD_IOCTL_SET_TRIGGER_EVENT:
2574 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {               
2575 +               BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;                 
2576 +                ctrlParms.result = -EFAULT;
2577 +                ret = -EFAULT;
2578 +                if (ctrlParms.strLen == sizeof(unsigned long)) {                                           
2579 +                    board_ioc->eventmask |= *((int*)ctrlParms.string);                    
2580 +#if defined (WIRELESS)                    
2581 +                    if((board_ioc->eventmask & SES_EVENTS)) {
2582 +                        if(sesBtn_irq != BP_NOT_DEFINED) {
2583 +                            BcmHalInterruptEnable(sesBtn_irq);
2584 +                            ctrlParms.result = 0;
2585 +                            ret = 0;
2586 +                        }                                                
2587 +                    } 
2588 +#endif                                                
2589 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));                        
2590 +                }
2591 +               break;
2592 +            }
2593 +            else {
2594 +                ret = -EFAULT;
2595 +            }
2596 +            break;                        
2597 +
2598 +        case BOARD_IOCTL_GET_TRIGGER_EVENT:
2599 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2600 +               BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2601 +                if (ctrlParms.strLen == sizeof(unsigned long)) {
2602 +                    __copy_to_user(ctrlParms.string, &board_ioc->eventmask, sizeof(unsigned long));
2603 +                    ctrlParms.result = 0;
2604 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));   
2605 +                    ret = 0;
2606 +                } else
2607 +                   ret = -EFAULT;
2608 +
2609 +               break;
2610 +            }
2611 +            else {
2612 +                ret = -EFAULT;
2613 +            }
2614 +            break;                
2615 +            
2616 +        case BOARD_IOCTL_UNSET_TRIGGER_EVENT:
2617 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2618 +                if (ctrlParms.strLen == sizeof(unsigned long)) {
2619 +                    BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;                    
2620 +                    board_ioc->eventmask &= (~(*((int*)ctrlParms.string)));                  
2621 +                    ctrlParms.result = 0;
2622 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));   
2623 +                    ret = 0;
2624 +                } else
2625 +                   ret = -EFAULT;
2626 +
2627 +               break;
2628 +            } 
2629 +            else {
2630 +                ret = -EFAULT;
2631 +            }
2632 +            break;            
2633 +#if defined (WIRELESS)
2634 +        case BOARD_IOCTL_SET_SES_LED:
2635 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2636 +                if (ctrlParms.strLen == sizeof(int)) {
2637 +                    sesLed_ctrl(*(int*)ctrlParms.string);
2638 +                    ctrlParms.result = 0;
2639 +                    __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));   
2640 +                    ret = 0;
2641 +                } else
2642 +                   ret = -EFAULT;
2643 +
2644 +               break;
2645 +            }
2646 +            else {
2647 +                ret = -EFAULT;
2648 +            }
2649 +            break;            
2650 +#endif                                                            
2651 +
2652 +        case BOARD_IOCTL_SET_MONITOR_FD:
2653 +            if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2654 +                int fput_needed = 0;
2655 +
2656 +                g_monitor_file = fget_light( ctrlParms.offset, &fput_needed );
2657 +                if( g_monitor_file ) {
2658 +                    /* Hook this file descriptor's poll function in order to set
2659 +                     * the exception descriptor when there is a change in link
2660 +                     * state.
2661 +                     */
2662 +                    g_monitor_task = current;
2663 +                   g_orig_fop_poll = kerSysMonitorPollHook;
2664 +                    /*g_orig_fop_poll = g_monitor_file->f_op->poll;
2665 +                    g_monitor_file->f_op->poll = kerSysMonitorPollHook;*/
2666 +                }
2667 +            }
2668 +            break;
2669 +
2670 +        case BOARD_IOCTL_WAKEUP_MONITOR_TASK:
2671 +            kerSysWakeupMonitorTask();
2672 +            break;
2673 +
2674 +        default:
2675 +            ret = -EINVAL;
2676 +            ctrlParms.result = 0;
2677 +            printk("board_ioctl: invalid command %x, cmd %d .\n",command,_IOC_NR(command));
2678 +            break;
2679 +
2680 +  } /* switch */
2681 +
2682 +  return (ret);
2683 +
2684 +} /* board_ioctl */
2685 +
2686 +/***************************************************************************
2687 + * SES Button ISR/GPIO/LED functions.
2688 + ***************************************************************************/
2689 +#if defined (WIRELESS) 
2690 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs)
2691 +{   
2692 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2693 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2694 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2695 +#endif
2696 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2697 +    unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2698 +    volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2699 +#endif
2700 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2701 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2702 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2703 +
2704 +    if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2705 +    {
2706 +        gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2707 +        gpio_reg = &GPIO->GPIOio_high;
2708 +    }
2709 +#endif 
2710 +               
2711 +    if (!(*gpio_reg & gpio_mask)){
2712 +        wake_up_interruptible(&g_board_wait_queue);
2713 +        return IRQ_RETVAL(1);
2714 +    } else {
2715 +        return IRQ_RETVAL(0);          
2716 +    }
2717 +}
2718 +
2719 +static void __init sesBtn_mapGpio()
2720 +{      
2721 +    if( BpGetWirelessSesBtnGpio(&sesBtn_gpio) == BP_SUCCESS )
2722 +    {
2723 +        printk("SES: Button GPIO 0x%x is enabled\n", sesBtn_gpio);    
2724 +    }
2725 +}
2726 +
2727 +static void __init sesBtn_mapIntr(int context)
2728 +{      
2729 +    if( BpGetWirelessSesExtIntr(&sesBtn_irq) == BP_SUCCESS )
2730 +    {
2731 +       printk("SES: Button Interrupt 0x%x is enabled\n", sesBtn_irq);
2732 +    }
2733 +    else
2734 +       return;
2735 +           
2736 +    sesBtn_irq += INTERRUPT_ID_EXTERNAL_0;     
2737 +               
2738 +    if (BcmHalMapInterrupt((FN_HANDLER)sesBtn_isr, context, sesBtn_irq)) {
2739 +       printk("SES: Interrupt mapping failed\n");
2740 +    }    
2741 +    BcmHalInterruptEnable(sesBtn_irq);
2742 +}
2743 +
2744 +
2745 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait)
2746 +{
2747 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2748 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2749 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2750 +#endif
2751 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2752 +    unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2753 +    volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2754 +#endif
2755 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2756 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2757 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2758 +
2759 +    if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2760 +    {
2761 +        gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2762 +        gpio_reg = &GPIO->GPIOio_high;
2763 +    }
2764 +#endif 
2765 +               
2766 +    if (!(*gpio_reg & gpio_mask)){
2767 +       return POLLIN;
2768 +    }  
2769 +    return 0;
2770 +}
2771 +
2772 +static ssize_t sesBtn_read(struct file *file,  char __user *buffer, size_t count, loff_t *ppos)
2773 +{
2774 +    volatile unsigned int event=0;
2775 +    ssize_t ret=0;     
2776 +
2777 +#if defined(_BCM96338_) || defined (CONFIG_BCM96338)
2778 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2779 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2780 +#endif
2781 +#if defined(_BCM96345_) || defined (CONFIG_BCM96345)
2782 +    unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2783 +    volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2784 +#endif
2785 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2786 +    unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2787 +    volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2788 +    
2789 +    if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2790 +    {
2791 +        gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2792 +        gpio_reg = &GPIO->GPIOio_high;
2793 +    }
2794 +#endif 
2795 +
2796 +    if(*gpio_reg & gpio_mask){
2797 +       BcmHalInterruptEnable(sesBtn_irq);              
2798 +       return ret;
2799 +    }  
2800 +    event = SES_EVENTS;
2801 +    __copy_to_user((char*)buffer, (char*)&event, sizeof(event));       
2802 +    BcmHalInterruptEnable(sesBtn_irq); 
2803 +    count -= sizeof(event);
2804 +    buffer += sizeof(event);
2805 +    ret += sizeof(event);      
2806 +    return ret;        
2807 +}
2808 +
2809 +static void __init sesLed_mapGpio()
2810 +{      
2811 +    if( BpGetWirelessSesBtnGpio(&sesLed_gpio) == BP_SUCCESS )
2812 +    {
2813 +        printk("SES: LED GPIO 0x%x is enabled\n", sesBtn_gpio);    
2814 +    }
2815 +}
2816 +
2817 +static void sesLed_ctrl(int action)
2818 +{
2819 +
2820 +    //char status = ((action >> 8) & 0xff); /* extract status */
2821 +    //char event = ((action >> 16) & 0xff); /* extract event */        
2822 +    //char blinktype = ((action >> 24) & 0xff); /* extract blink type for SES_LED_BLINK  */
2823 +    
2824 +    BOARD_LED_STATE led;
2825 +    
2826 +    if(sesLed_gpio == BP_NOT_DEFINED)
2827 +        return;
2828 +       
2829 +    action &= 0xff; /* extract led */
2830 +
2831 +    //printk("blinktype=%d, event=%d, status=%d\n",(int)blinktype, (int)event, (int)status);
2832 +               
2833 +    switch (action) 
2834 +    {
2835 +        case SES_LED_ON:
2836 +            //printk("SES: led on\n");
2837 +            led = kLedStateOn;                                          
2838 +            break;
2839 +        case SES_LED_BLINK:
2840 +            //printk("SES: led blink\n");
2841 +            led = kLedStateSlowBlinkContinues;                         
2842 +            break;
2843 +        case SES_LED_OFF:
2844 +            default:
2845 +            //printk("SES: led off\n");
2846 +            led = kLedStateOff;                                                
2847 +    }  
2848 +    
2849 +    kerSysLedCtrl(kLedSes, led);
2850 +}
2851 +
2852 +static void __init ses_board_init()
2853 +{
2854 +    sesBtn_mapGpio();
2855 +    sesBtn_mapIntr(0);
2856 +    sesLed_mapGpio();
2857 +}
2858 +static void __exit ses_board_deinit()
2859 +{
2860 +    if(sesBtn_irq)
2861 +        BcmHalInterruptDisable(sesBtn_irq);
2862 +}
2863 +#endif
2864 +
2865 +/***************************************************************************
2866 + * Dying gasp ISR and functions.
2867 + ***************************************************************************/
2868 +#define KERSYS_DBG     printk
2869 +
2870 +#if defined(CONFIG_BCM96345)
2871 +#define        CYCLE_PER_US    70
2872 +#elif defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
2873 +/* The BCM6348 cycles per microsecond is really variable since the BCM6348
2874 + * MIPS speed can vary depending on the PLL settings.  However, an appoximate
2875 + * value of 120 will still work OK for the test being done.
2876 + */
2877 +#define        CYCLE_PER_US    120
2878 +#endif
2879 +#define        DG_GLITCH_TO    (100*CYCLE_PER_US)
2880
2881 +static void __init kerSysDyingGaspMapIntr()
2882 +{
2883 +    unsigned long ulIntr;
2884 +       
2885 +#if defined(CONFIG_BCM96348) || defined(_BCM96348_) || defined(CONFIG_BCM96338) || defined(_BCM96338_)
2886 +    if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2887 +               BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, INTERRUPT_ID_DG);
2888 +               BcmHalInterruptEnable( INTERRUPT_ID_DG );
2889 +    }
2890 +#elif defined(CONFIG_BCM96345) || defined(_BCM96345_)
2891 +    if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2892 +        ulIntr += INTERRUPT_ID_EXTERNAL_0;
2893 +        BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, ulIntr);
2894 +        BcmHalInterruptEnable( ulIntr );
2895 +    }
2896 +#endif
2897 +
2898 +} 
2899 +
2900 +void kerSysSetWdTimer(ulong timeUs)
2901 +{
2902 +       TIMER->WatchDogDefCount = timeUs * (FPERIPH/1000000);
2903 +       TIMER->WatchDogCtl = 0xFF00;
2904 +       TIMER->WatchDogCtl = 0x00FF;
2905 +}
2906 +
2907 +ulong kerSysGetCycleCount(void)
2908 +{
2909 +    ulong cnt; 
2910 +#ifdef _WIN32_WCE
2911 +    cnt = 0;
2912 +#else
2913 +    __asm volatile("mfc0 %0, $9":"=d"(cnt));
2914 +#endif
2915 +    return(cnt); 
2916 +}
2917 +
2918 +static Bool kerSysDyingGaspCheckPowerLoss(void)
2919 +{
2920 +    ulong clk0;
2921 +    ulong ulIntr;
2922 +
2923 +    ulIntr = 0;
2924 +    clk0 = kerSysGetCycleCount();
2925 +
2926 +    UART->Data = 'D';
2927 +    UART->Data = '%';
2928 +    UART->Data = 'G';
2929 +
2930 +#if defined(CONFIG_BCM96345)
2931 +    BpGetAdslDyingGaspExtIntr( &ulIntr );
2932 +
2933 +    do {
2934 +        ulong clk1;
2935 +        
2936 +        clk1 = kerSysGetCycleCount();          /* time cleared */
2937 +       /* wait a little to get new reading */
2938 +        while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2939 +            ;
2940 +    } while ((0 == (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT)))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2941 +
2942 +    if (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT))) {  /* power glitch */
2943 +        BcmHalInterruptEnable( ulIntr + INTERRUPT_ID_EXTERNAL_0);
2944 +        KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2945 +        return 0;
2946 +    }
2947 +#elif (defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)) && !defined(VXWORKS)
2948 +    do {
2949 +        ulong clk1;
2950 +        
2951 +        clk1 = kerSysGetCycleCount();          /* time cleared */
2952 +       /* wait a little to get new reading */
2953 +        while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2954 +            ;
2955 +     } while ((PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2956 +
2957 +    if (!(PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET)))) {
2958 +        BcmHalInterruptEnable( INTERRUPT_ID_DG );
2959 +        KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2960 +        return 0;
2961 +    }
2962 +#endif
2963 +    return 1;
2964 +}
2965 +
2966 +static void kerSysDyingGaspShutdown( void )
2967 +{
2968 +    kerSysSetWdTimer(1000000);
2969 +#if defined(CONFIG_BCM96345)
2970 +    PERF->blkEnables &= ~(EMAC_CLK_EN | USB_CLK_EN | CPU_CLK_EN);
2971 +#elif defined(CONFIG_BCM96348)
2972 +    PERF->blkEnables &= ~(EMAC_CLK_EN | USBS_CLK_EN | USBH_CLK_EN | SAR_CLK_EN);
2973 +#endif
2974 +}
2975 +
2976 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2977 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs)
2978 +#else
2979 +static unsigned int kerSysDyingGaspIsr(void)
2980 +#endif
2981 +{      
2982 +    struct list_head *pos;
2983 +    CB_DGASP_LIST *tmp, *dsl = NULL;   
2984 +
2985 +    if (kerSysDyingGaspCheckPowerLoss()) {        
2986 +
2987 +        /* first to turn off everything other than dsl */        
2988 +        list_for_each(pos, &g_cb_dgasp_list_head->list) {      
2989 +            tmp = list_entry(pos, CB_DGASP_LIST, list);
2990 +           if(strncmp(tmp->name, "dsl", 3)) {
2991 +               (tmp->cb_dgasp_fn)(tmp->context); 
2992 +           }else {
2993 +               dsl = tmp;                      
2994 +           }       
2995 +        }  
2996 +        
2997 +        /* now send dgasp */
2998 +        if(dsl)
2999 +            (dsl->cb_dgasp_fn)(dsl->context); 
3000 +
3001 +        /* reset and shutdown system */
3002 +        kerSysDyingGaspShutdown();
3003 +    }
3004 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
3005 +return( IRQ_HANDLED );
3006 +#else
3007 +    return( 1 );
3008 +#endif
3009 +}
3010 +
3011 +static void __init kerSysInitDyingGaspHandler( void )
3012 +{
3013 +    CB_DGASP_LIST *new_node;
3014 +
3015 +    if( g_cb_dgasp_list_head != NULL) {
3016 +        printk("Error: kerSysInitDyingGaspHandler: list head is not null\n");
3017 +        return;        
3018 +    }
3019 +    new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
3020 +    memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
3021 +    INIT_LIST_HEAD(&new_node->list);    
3022 +    g_cb_dgasp_list_head = new_node; 
3023 +               
3024 +} /* kerSysInitDyingGaspHandler */
3025 +
3026 +static void __exit kerSysDeinitDyingGaspHandler( void )
3027 +{
3028 +    struct list_head *pos;
3029 +    CB_DGASP_LIST *tmp; 
3030 +       
3031 +    if(g_cb_dgasp_list_head == NULL)
3032 +        return;
3033 +        
3034 +    list_for_each(pos, &g_cb_dgasp_list_head->list) {          
3035 +       tmp = list_entry(pos, CB_DGASP_LIST, list);
3036 +        list_del(pos);
3037 +       kfree(tmp);
3038 +    }       
3039 +
3040 +    kfree(g_cb_dgasp_list_head);       
3041 +    g_cb_dgasp_list_head = NULL;
3042 +    
3043 +} /* kerSysDeinitDyingGaspHandler */
3044 +
3045 +void kerSysRegisterDyingGaspHandler(char *devname, void *cbfn, void *context)
3046 +{
3047 +    CB_DGASP_LIST *new_node;
3048 +
3049 +    if( g_cb_dgasp_list_head == NULL) {
3050 +        printk("Error: kerSysRegisterDyingGaspHandler: list head is null\n");  
3051 +        return;    
3052 +    }
3053 +    
3054 +    if( devname == NULL || cbfn == NULL ) {
3055 +        printk("Error: kerSysRegisterDyingGaspHandler: register info not enough (%s,%x,%x)\n", devname, (unsigned int)cbfn, (unsigned int)context);            
3056 +        return;
3057 +    }
3058 +       
3059 +    new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
3060 +    memset(new_node, 0x00, sizeof(CB_DGASP_LIST));    
3061 +    INIT_LIST_HEAD(&new_node->list);
3062 +    strncpy(new_node->name, devname, IFNAMSIZ);
3063 +    new_node->cb_dgasp_fn = (cb_dgasp_t)cbfn;
3064 +    new_node->context = context;
3065 +    list_add(&new_node->list, &g_cb_dgasp_list_head->list);
3066 +    
3067 +    printk("dgasp: kerSysRegisterDyingGaspHandler: %s registered \n", devname);
3068 +               
3069 +} /* kerSysRegisterDyingGaspHandler */
3070 +
3071 +void kerSysDeregisterDyingGaspHandler(char *devname)
3072 +{
3073 +    struct list_head *pos;
3074 +    CB_DGASP_LIST *tmp;    
3075 +    
3076 +    if(g_cb_dgasp_list_head == NULL) {
3077 +        printk("Error: kerSysDeregisterDyingGaspHandler: list head is null\n");
3078 +        return;        
3079 +    }
3080 +
3081 +    if(devname == NULL) {
3082 +        printk("Error: kerSysDeregisterDyingGaspHandler: devname is null\n");
3083 +        return;        
3084 +    }
3085 +    
3086 +    printk("kerSysDeregisterDyingGaspHandler: %s is deregistering\n", devname);
3087 +
3088 +    list_for_each(pos, &g_cb_dgasp_list_head->list) {          
3089 +       tmp = list_entry(pos, CB_DGASP_LIST, list);
3090 +       if(!strcmp(tmp->name, devname)) {
3091 +            list_del(pos);
3092 +           kfree(tmp);
3093 +           printk("kerSysDeregisterDyingGaspHandler: %s is deregistered\n", devname);
3094 +           return;
3095 +       }
3096 +    }  
3097 +    printk("kerSysDeregisterDyingGaspHandler: %s not (de)registered\n", devname);
3098 +       
3099 +} /* kerSysDeregisterDyingGaspHandler */
3100 +
3101 +/***************************************************************************
3102 + * MACRO to call driver initialization and cleanup functions.
3103 + ***************************************************************************/
3104 +module_init( brcm_board_init );
3105 +module_exit( brcm_board_cleanup );
3106 +
3107 +EXPORT_SYMBOL(kerSysNvRamGet);
3108 +EXPORT_SYMBOL(dumpaddr);
3109 +EXPORT_SYMBOL(kerSysGetMacAddress);
3110 +EXPORT_SYMBOL(kerSysReleaseMacAddress);
3111 +EXPORT_SYMBOL(kerSysGetSdramSize);
3112 +EXPORT_SYMBOL(kerSysLedCtrl);
3113 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
3114 +EXPORT_SYMBOL(kerSysGetResetHold);
3115 +//>>JUNHON, 2004/09/15
3116 +EXPORT_SYMBOL(kerSysLedRegisterHwHandler);
3117 +EXPORT_SYMBOL(BpGetBoardIds);
3118 +EXPORT_SYMBOL(BpGetSdramSize);
3119 +EXPORT_SYMBOL(BpGetPsiSize);
3120 +EXPORT_SYMBOL(BpGetEthernetMacInfo);
3121 +EXPORT_SYMBOL(BpGetRj11InnerOuterPairGpios);
3122 +EXPORT_SYMBOL(BpGetPressAndHoldResetGpio);
3123 +EXPORT_SYMBOL(BpGetVoipResetGpio);
3124 +EXPORT_SYMBOL(BpGetVoipIntrGpio);
3125 +EXPORT_SYMBOL(BpGetPcmciaResetGpio);
3126 +EXPORT_SYMBOL(BpGetRtsCtsUartGpios);
3127 +EXPORT_SYMBOL(BpGetAdslLedGpio);
3128 +EXPORT_SYMBOL(BpGetAdslFailLedGpio);
3129 +EXPORT_SYMBOL(BpGetWirelessLedGpio);
3130 +EXPORT_SYMBOL(BpGetUsbLedGpio);
3131 +EXPORT_SYMBOL(BpGetHpnaLedGpio);
3132 +EXPORT_SYMBOL(BpGetWanDataLedGpio);
3133 +EXPORT_SYMBOL(BpGetPppLedGpio);
3134 +EXPORT_SYMBOL(BpGetPppFailLedGpio);
3135 +EXPORT_SYMBOL(BpGetVoipLedGpio);
3136 +EXPORT_SYMBOL(BpGetWirelessExtIntr);
3137 +EXPORT_SYMBOL(BpGetAdslDyingGaspExtIntr);
3138 +EXPORT_SYMBOL(BpGetVoipExtIntr);
3139 +EXPORT_SYMBOL(BpGetHpnaExtIntr);
3140 +EXPORT_SYMBOL(BpGetHpnaChipSelect);
3141 +EXPORT_SYMBOL(BpGetVoipChipSelect);
3142 +EXPORT_SYMBOL(BpGetWirelessSesBtnGpio);
3143 +EXPORT_SYMBOL(BpGetWirelessSesExtIntr);
3144 +EXPORT_SYMBOL(BpGetWirelessSesLedGpio);
3145 +EXPORT_SYMBOL(kerSysRegisterDyingGaspHandler);
3146 +EXPORT_SYMBOL(kerSysDeregisterDyingGaspHandler);
3147 +EXPORT_SYMBOL(kerSysGetCycleCount);
3148 +EXPORT_SYMBOL(kerSysSetWdTimer);
3149 +EXPORT_SYMBOL(kerSysWakeupMonitorTask);
3150 +
3151 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c
3152 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c    1970-01-01 01:00:00.000000000 +0100
3153 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c   2006-08-03 16:36:58.000000000 +0200
3154 @@ -0,0 +1,2391 @@
3155 +/*
3156 +<:copyright-gpl 
3157 +
3158 + Copyright 2003 Broadcom Corp. All Rights Reserved. 
3159
3160 + This program is free software; you can distribute it and/or modify it 
3161 + under the terms of the GNU General Public License (Version 2) as 
3162 + published by the Free Software Foundation. 
3163
3164 + This program is distributed in the hope it will be useful, but WITHOUT 
3165 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
3166 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
3167 + for more details. 
3168
3169 + You should have received a copy of the GNU General Public License along 
3170 + with this program; if not, write to the Free Software Foundation, Inc., 
3171 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
3172 +
3173 +:>
3174 +*/
3175 +/**************************************************************************
3176 + * File Name  : boardparms.c
3177 + *
3178 + * Description: This file contains the implementation for the BCM63xx board
3179 + *              parameter access functions.
3180 + * 
3181 + * Updates    : 07/14/2003  Created.
3182 + ***************************************************************************/
3183 +
3184 +/* Includes. */
3185 +#include "boardparms.h"
3186 +
3187 +/* Defines. */
3188 +
3189 +/* Default psi size in K bytes */
3190 +#define BP_PSI_DEFAULT_SIZE                     24   
3191 +
3192 +/* Typedefs */
3193 +typedef struct boardparameters
3194 +{
3195 +    char szBoardId[BP_BOARD_ID_LEN];        /* board id string */
3196 +    ETHERNET_MAC_INFO EnetMacInfos[BP_MAX_ENET_MACS];
3197 +    VOIP_DSP_INFO VoIPDspInfo[BP_MAX_VOIP_DSP];
3198 +    unsigned short usSdramSize;             /* SDRAM size and type */
3199 +    unsigned short usPsiSize;               /* persistent storage in K bytes */
3200 +    unsigned short usGpioRj11InnerPair;     /* GPIO pin or not defined */
3201 +    unsigned short usGpioRj11OuterPair;     /* GPIO pin or not defined */
3202 +    unsigned short usGpioPressAndHoldReset; /* GPIO pin or not defined */
3203 +    unsigned short usGpioPcmciaReset;       /* GPIO pin or not defined */
3204 +    unsigned short usGpioUartRts;           /* GPIO pin or not defined */
3205 +    unsigned short usGpioUartCts;           /* GPIO pin or not defined */
3206 +    unsigned short usGpioLedAdsl;           /* GPIO pin or not defined */
3207 +    unsigned short usGpioLedAdslFail;       /* GPIO pin or not defined */
3208 +    unsigned short usGpioLedWireless;       /* GPIO pin or not defined */
3209 +    unsigned short usGpioLedUsb;            /* GPIO pin or not defined */
3210 +    unsigned short usGpioLedHpna;           /* GPIO pin or not defined */
3211 +    unsigned short usGpioLedWanData;        /* GPIO pin or not defined */
3212 +    unsigned short usGpioLedPpp;            /* GPIO pin or not defined */
3213 +    unsigned short usGpioLedPppFail;        /* GPIO pin or not defined */
3214 +    unsigned short usGpioLedBlPowerOn;      /* GPIO pin or not defined */
3215 +    unsigned short usGpioLedBlAlarm;        /* GPIO pin or not defined */
3216 +    unsigned short usGpioLedBlResetCfg;     /* GPIO pin or not defined */
3217 +    unsigned short usGpioLedBlStop;         /* GPIO pin or not defined */
3218 +    unsigned short usExtIntrWireless;       /* ext intr or not defined */
3219 +    unsigned short usExtIntrAdslDyingGasp;  /* ext intr or not defined */
3220 +    unsigned short usExtIntrHpna;           /* ext intr or not defined */
3221 +    unsigned short usCsHpna;                /* chip select not defined */
3222 +    unsigned short usAntInUseWireless;     /* antenna in use or not defined */
3223 +    unsigned short usGpioSesBtnWireless;    /* GPIO pin or not defined */
3224 +    unsigned short usExtIntrSesBtnWireless; /* ext intr or not defined */        
3225 +    unsigned short usGpioLedSesWireless;    /* GPIO pin or not defined */        
3226 +} BOARD_PARAMETERS, *PBOARD_PARAMETERS;
3227 +
3228 +/* Variables */
3229 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
3230 +static BOARD_PARAMETERS g_bcm96338sv =
3231 +{
3232 +    "96338SV",                               /* szBoardId */
3233 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3234 +      0x01,                                 /* ucPhyAddress */
3235 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3236 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3237 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3238 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3239 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3240 +      0x01,                                 /* numSwitchPorts */
3241 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3242 +      BP_NOT_DEFINED},                      /* usReverseMii */
3243 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3244 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3245 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3246 +    BP_MEMORY_16MB_1_CHIP,                  /* usSdramSize */
3247 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3248 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3249 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3250 +    BP_NOT_DEFINED,                         /* usGpioPressAndHoldReset */
3251 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3252 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3253 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3254 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3255 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3256 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3257 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3258 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3259 +    BP_NOT_DEFINED,                         /* usGpioLedWanData */
3260 +    BP_NOT_DEFINED,                         /* usGpioLedPpp */
3261 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3262 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3263 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3264 +    BP_NOT_DEFINED,                         /* usGpioLedBlResetCfg */
3265 +    BP_NOT_DEFINED,                         /* usGpioLedBlStop */
3266 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3267 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3268 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3269 +    BP_NOT_DEFINED,                         /* usCsHpna */
3270 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3271 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3272 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3273 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */     
3274 +};
3275 +static BOARD_PARAMETERS g_bcm96338l2m8m =
3276 +{
3277 +    "96338L-2M-8M",                         /* szBoardId */
3278 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3279 +      0x01,                                 /* ucPhyAddress */
3280 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3281 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3282 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3283 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3284 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3285 +      0x01,                                 /* numSwitchPorts */
3286 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3287 +      BP_NOT_DEFINED},                      /* usReverseMii */
3288 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3289 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3290 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3291 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3292 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3293 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3294 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3295 +    BP_NOT_DEFINED,                         /* usGpioPressAndHoldReset */
3296 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3297 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3298 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3299 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3300 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3301 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3302 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3303 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3304 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3305 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3306 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3307 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3308 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3309 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3310 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3311 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3312 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3313 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3314 +    BP_NOT_DEFINED,                         /* usCsHpna */
3315 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3316 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */    
3317 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3318 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */         
3319 +};
3320 +static PBOARD_PARAMETERS g_BoardParms[] =
3321 +    {&g_bcm96338sv, &g_bcm96338l2m8m, 0};
3322 +#endif
3323 +
3324 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
3325 +static BOARD_PARAMETERS g_bcm96345r =
3326 +{
3327 +    "96345R",                               /* szBoardId */
3328 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3329 +      0x01,                                 /* ucPhyAddress */
3330 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3331 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3332 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3333 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3334 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3335 +      0x01,                                 /* numSwitchPorts */
3336 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3337 +      BP_NOT_DEFINED},                      /* usReverseMii */
3338 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3339 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3340 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3341 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3342 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3343 +    BP_GPIO_11_AH,                          /* usGpioRj11InnerPair */
3344 +    BP_GPIO_12_AH,                          /* usGpioRj11OuterPair */
3345 +    BP_GPIO_13_AH,                          /* usGpioPressAndHoldReset */
3346 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3347 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3348 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3349 +    BP_GPIO_8_AH,                           /* usGpioLedAdsl */
3350 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3351 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3352 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3353 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3354 +    BP_GPIO_8_AH,                           /* usGpioLedWanData */
3355 +    BP_GPIO_9_AH,                           /* usGpioLedPpp */
3356 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3357 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3358 +    BP_GPIO_10_AH,                          /* usGpioLedBlAlarm */
3359 +    BP_GPIO_9_AH,                           /* usGpioLedBlResetCfg */
3360 +    BP_GPIO_8_AH,                           /* usGpioLedBlStop */
3361 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3362 +    BP_EXT_INTR_0,                          /* usExtIntrAdslDyingGasp */
3363 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3364 +    BP_NOT_DEFINED,                         /* usCsHpna */
3365 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3366 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3367 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3368 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3369 +};
3370 +
3371 +static BOARD_PARAMETERS g_bcm96345gw2 =
3372 +{
3373 +    /* A hardware jumper determines whether GPIO 13 is used for Press and Hold
3374 +     * Reset or RTS.
3375 +     */
3376 +    "96345GW2",                             /* szBoardId */
3377 +    {{BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3378 +      0x00,                                 /* ucPhyAddress */
3379 +      BP_GPIO_0_AH,                         /* usGpioPhySpiSck */
3380 +      BP_GPIO_4_AH,                         /* usGpioPhySpiSs */
3381 +      BP_GPIO_12_AH,                        /* usGpioPhySpiMosi */
3382 +      BP_GPIO_11_AH,                        /* usGpioPhySpiMiso */
3383 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3384 +      0x04,                                 /* numSwitchPorts */
3385 +      BP_ENET_CONFIG_GPIO,                  /* usConfigType */
3386 +      BP_ENET_REVERSE_MII},                 /* usReverseMii */
3387 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3388 +    {{BP_VOIP_DSP,                          /* ucDspType */
3389 +      0x00,                                 /* ucDspAddress */
3390 +      BP_EXT_INTR_1,                        /* usExtIntrVoip */
3391 +      BP_GPIO_6_AH,                         /* usGpioVoipReset */
3392 +      BP_GPIO_15_AH,                        /* usGpioVoipIntr */
3393 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3394 +      BP_CS_2},                             /* usCsVoip */
3395 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3396 +    BP_MEMORY_16MB_1_CHIP,                  /* usSdramSize */
3397 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3398 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3399 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3400 +    BP_GPIO_13_AH,                          /* usGpioPressAndHoldReset */
3401 +    BP_GPIO_2_AH,                           /* usGpioPcmciaReset */
3402 +    BP_GPIO_13_AH,                          /* usGpioUartRts */
3403 +    BP_GPIO_9_AH,                           /* usGpioUartCts */
3404 +    BP_GPIO_8_AH,                           /* usGpioLedAdsl */
3405 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3406 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3407 +    BP_GPIO_7_AH,                           /* usGpioLedUsb */
3408 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3409 +    BP_GPIO_8_AH,                           /* usGpioLedWanData */
3410 +    BP_NOT_DEFINED,                         /* usGpioLedPpp */
3411 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3412 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3413 +    BP_GPIO_10_AH,                          /* usGpioLedBlAlarm */
3414 +    BP_GPIO_7_AH,                           /* usGpioLedBlResetCfg */
3415 +    BP_GPIO_8_AH,                           /* usGpioLedBlStop */
3416 +    BP_EXT_INTR_2,                          /* usExtIntrWireless */
3417 +    BP_EXT_INTR_0,                          /* usExtIntrAdslDyingGasp */
3418 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3419 +    BP_NOT_DEFINED,                         /* usCsHpna */
3420 +    BP_WLAN_ANT_MAIN,                       /* usAntInUseWireless */
3421 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3422 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3423 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */    
3424 +};
3425 +
3426 +static BOARD_PARAMETERS g_bcm96345gw =
3427 +{
3428 +    "96345GW",                              /* szBoardId */
3429 +    {{BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3430 +      0x00,                                 /* ucPhyAddress */
3431 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3432 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3433 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3434 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3435 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3436 +      0x04,                                 /* numSwitchPorts */
3437 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3438 +      BP_ENET_NO_REVERSE_MII},              /* usReverseMii */
3439 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3440 +    {{BP_VOIP_DSP,                          /* ucDspType */
3441 +      0x00,                                 /* ucDspAddress */
3442 +      BP_EXT_INTR_1,                        /* usExtIntrVoip */
3443 +      BP_GPIO_6_AH,                         /* usGpioVoipReset */
3444 +      BP_GPIO_15_AH,                        /* usGpioVoipIntr */
3445 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3446 +      BP_CS_2},                             /* usCsVoip */
3447 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3448 +    BP_MEMORY_16MB_1_CHIP,                  /* usSdramSize */
3449 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3450 +    BP_GPIO_11_AH,                          /* usGpioRj11InnerPair */
3451 +    BP_GPIO_1_AH,                           /* usGpioRj11OuterPair */
3452 +    BP_GPIO_13_AH,                          /* usGpioPressAndHoldReset */
3453 +    BP_GPIO_2_AH,                           /* usGpioPcmciaReset */
3454 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3455 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3456 +    BP_GPIO_8_AH,                           /* usGpioLedAdsl */
3457 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3458 +    BP_GPIO_10_AH,                          /* usGpioLedWireless */
3459 +    BP_GPIO_7_AH,                           /* usGpioLedUsb */
3460 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3461 +    BP_GPIO_8_AH,                           /* usGpioLedWanData */
3462 +    BP_NOT_DEFINED,                         /* usGpioLedPpp */
3463 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3464 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3465 +    BP_GPIO_9_AH,                           /* usGpioLedBlAlarm */
3466 +    BP_GPIO_10_AH,                          /* usGpioLedBlResetCfg */
3467 +    BP_GPIO_8_AH,                           /* usGpioLedBlStop */
3468 +    BP_EXT_INTR_2,                          /* usExtIntrWireless */
3469 +    BP_EXT_INTR_0,                          /* usExtIntrAdslDyingGasp */
3470 +    BP_EXT_INTR_3,                          /* usExtIntrHpna */
3471 +    BP_CS_1,                                /* usCsHpna */
3472 +    BP_WLAN_ANT_MAIN,                       /* usAntInUseWireless */
3473 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3474 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3475 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3476 +};
3477 +
3478 +static BOARD_PARAMETERS g_bcm96335r =
3479 +{
3480 +    "96335R",                               /* szBoardId */
3481 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3482 +      0x01,                                 /* ucPhyAddress */
3483 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3484 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3485 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3486 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3487 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3488 +      0x01,                                 /* numSwitchPorts */
3489 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3490 +      BP_NOT_DEFINED},                      /* usReverseMii */
3491 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3492 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3493 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3494 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3495 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3496 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3497 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3498 +    BP_GPIO_14_AH,                          /* usGpioPressAndHoldReset */
3499 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3500 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3501 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3502 +    BP_GPIO_9_AH,                           /* usGpioLedAdsl */
3503 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3504 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3505 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3506 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3507 +    BP_GPIO_9_AH,                           /* usGpioLedWanData */
3508 +    BP_GPIO_8_AH,                           /* usGpioLedPpp */
3509 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3510 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3511 +    BP_GPIO_10_AH,                          /* usGpioLedBlAlarm */
3512 +    BP_GPIO_8_AH,                           /* usGpioLedBlResetCfg */
3513 +    BP_GPIO_9_AH,                           /* usGpioLedBlStop */
3514 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3515 +    BP_NOT_DEFINED,                         /* usExtIntrAdslDyingGasp */
3516 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3517 +    BP_NOT_DEFINED,                         /* usCsHpna */
3518 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3519 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3520 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3521 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3522 +};
3523 +
3524 +static BOARD_PARAMETERS g_bcm96345r0 =
3525 +{
3526 +    "96345R0",                              /* szBoardId */
3527 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3528 +      0x01,                                 /* ucPhyAddress */
3529 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3530 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3531 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3532 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3533 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3534 +      0x01,                                 /* numSwitchPorts */
3535 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3536 +      BP_NOT_DEFINED},                      /* usReverseMii */
3537 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3538 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3539 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3540 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3541 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3542 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3543 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3544 +    BP_NOT_DEFINED,                         /* usGpioPressAndHoldReset */
3545 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3546 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3547 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3548 +    BP_GPIO_8_AH,                           /* usGpioLedAdsl */
3549 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3550 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3551 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3552 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3553 +    BP_GPIO_9_AH,                           /* usGpioLedWanData */
3554 +    BP_GPIO_9_AH,                           /* usGpioLedPpp */
3555 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3556 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3557 +    BP_GPIO_9_AH,                           /* usGpioLedBlAlarm */
3558 +    BP_GPIO_8_AH,                           /* usGpioLedBlResetCfg */
3559 +    BP_GPIO_8_AH,                           /* usGpioLedBlStop */
3560 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3561 +    BP_NOT_DEFINED,                         /* usExtIntrAdslDyingGasp */
3562 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3563 +    BP_NOT_DEFINED,                         /* usCsHpna */
3564 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3565 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */     
3566 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3567 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */    
3568 +};
3569 +
3570 +static BOARD_PARAMETERS g_bcm96345rs =
3571 +{
3572 +    "96345RS",                              /* szBoardId */
3573 +    {{BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3574 +      0x00,                                 /* ucPhyAddress */
3575 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3576 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3577 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3578 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3579 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3580 +      0x01,                                 /* numSwitchPorts */
3581 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3582 +      BP_ENET_NO_REVERSE_MII},              /* usReverseMii */
3583 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3584 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3585 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3586 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3587 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3588 +    BP_GPIO_11_AH,                          /* usGpioRj11InnerPair */
3589 +    BP_GPIO_12_AH,                          /* usGpioRj11OuterPair */
3590 +    BP_GPIO_13_AH,                          /* usGpioPressAndHoldReset */
3591 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3592 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3593 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3594 +    BP_GPIO_8_AH,                           /* usGpioLedAdsl */
3595 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3596 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3597 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3598 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3599 +    BP_GPIO_8_AH,                           /* usGpioLedWanData */
3600 +    BP_GPIO_9_AH,                           /* usGpioLedPpp */
3601 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3602 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3603 +    BP_GPIO_10_AH,                          /* usGpioLedBlAlarm */
3604 +    BP_GPIO_9_AH,                           /* usGpioLedBlResetCfg */
3605 +    BP_GPIO_8_AH,                           /* usGpioLedBlStop */
3606 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3607 +    BP_EXT_INTR_0,                          /* usExtIntrAdslDyingGasp */
3608 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3609 +    BP_NOT_DEFINED,                         /* usCsHpna */
3610 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3611 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3612 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3613 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3614 +};
3615 +
3616 +static PBOARD_PARAMETERS g_BoardParms[] =
3617 +    {&g_bcm96345r, &g_bcm96345gw2, &g_bcm96345gw, &g_bcm96335r, &g_bcm96345r0,
3618 +     &g_bcm96345rs, 0};
3619 +#endif
3620 +
3621 +#if defined(_BCM96348_) || defined(CONFIG_BCM96348)
3622 +
3623 +static BOARD_PARAMETERS g_bcm96348r =
3624 +{
3625 +    "96348R",                               /* szBoardId */
3626 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3627 +      0x01,                                 /* ucPhyAddress */
3628 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3629 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3630 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3631 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3632 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3633 +      0x01,                                 /* numSwitchPorts */
3634 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3635 +      BP_NOT_DEFINED},                      /* usReverseMii */
3636 +     {BP_ENET_NO_PHY}},                     /* ucPhyType */
3637 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3638 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3639 +    BP_MEMORY_8MB_1_CHIP,                   /* usSdramSize */
3640 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3641 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3642 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3643 +    BP_GPIO_7_AH,                           /* usGpioPressAndHoldReset */
3644 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3645 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3646 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3647 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3648 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3649 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3650 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3651 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3652 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3653 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3654 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3655 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3656 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3657 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3658 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3659 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3660 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3661 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3662 +    BP_NOT_DEFINED,                         /* usCsHpna */
3663 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3664 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3665 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3666 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */    
3667 +};
3668 +
3669 +static BOARD_PARAMETERS g_bcm96348lv =
3670 +{
3671 +    "96348LV",                               /* szBoardId */
3672 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3673 +      0x01,                                 /* ucPhyAddress */
3674 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3675 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3676 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3677 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3678 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3679 +      0x01,                                 /* numSwitchPorts */
3680 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3681 +      BP_NOT_DEFINED},                      /* usReverseMii */
3682 +     {BP_ENET_EXTERNAL_PHY,                 /* ucPhyType */
3683 +      0x02,                                 /* ucPhyAddress */
3684 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3685 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3686 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3687 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3688 +      BP_GPIO_5_AL,                         /* usGpioPhyReset */
3689 +      0x01,                                 /* numSwitchPorts */
3690 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3691 +      BP_NOT_DEFINED}},                     /* usReverseMii */
3692 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3693 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3694 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
3695 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3696 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3697 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3698 +    BP_GPIO_7_AH,                           /* usGpioPressAndHoldReset */
3699 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3700 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3701 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3702 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3703 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3704 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3705 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3706 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3707 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3708 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3709 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3710 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3711 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3712 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3713 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3714 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3715 +    BP_NOT_DEFINED,                         /* usExtIntrAdslDyingGasp */
3716 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3717 +    BP_NOT_DEFINED,                         /* usCsHpna */
3718 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3719 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3720 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3721 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3722 +};
3723 +
3724 +static BOARD_PARAMETERS g_bcm96348gw =
3725 +{
3726 +    "96348GW",                              /* szBoardId */
3727 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3728 +      0x01,                                 /* ucPhyAddress */
3729 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3730 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3731 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3732 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3733 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3734 +      0x01,                                 /* numSwitchPorts */
3735 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3736 +      BP_NOT_DEFINED},                      /* usReverseMii */
3737 +     {BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3738 +      0x00,                                 /* ucPhyAddress */
3739 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3740 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3741 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3742 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3743 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3744 +      0x03,                                 /* numSwitchPorts */
3745 +      BP_ENET_CONFIG_SPI_SSB_0,             /* usConfigType */
3746 +      BP_ENET_REVERSE_MII}},                /* usReverseMii */
3747 +    {{BP_VOIP_DSP,                          /* ucDspType */
3748 +      0x00,                                 /* ucDspAddress */
3749 +      BP_EXT_INTR_2,                        /* usExtIntrVoip */
3750 +      BP_GPIO_6_AH,                         /* usGpioVoipReset */
3751 +      BP_GPIO_34_AH,                        /* usGpioVoipIntr */
3752 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3753 +      BP_CS_2},                             /* usCsVoip */
3754 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3755 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
3756 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3757 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3758 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3759 +    BP_GPIO_33_AL,                          /* usGpioPressAndHoldReset */
3760 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3761 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3762 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3763 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3764 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3765 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3766 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3767 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3768 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3769 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3770 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3771 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3772 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3773 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3774 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3775 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3776 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3777 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3778 +    BP_NOT_DEFINED,                         /* usCsHpna */
3779 +    BP_WLAN_ANT_MAIN,                       /* usAntInUseWireless */
3780 +    BP_NOT_DEFINED, /* BP_GPIO_35_AH, */    /* usGpioSesBtnWireless */
3781 +    BP_NOT_DEFINED, /* BP_EXT_INTR_3, */    /* usExtIntrSesBtnWireless */
3782 +    BP_NOT_DEFINED  /* BP_GPIO_0_AL   */    /* usGpioLedSesWireless */
3783 +};
3784 +
3785 +
3786 +static BOARD_PARAMETERS g_bcm96348gw_10 =
3787 +{
3788 +    "96348GW-10",                           /* szBoardId */
3789 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3790 +      0x01,                                 /* ucPhyAddress */
3791 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3792 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3793 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3794 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3795 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3796 +      0x01,                                 /* numSwitchPorts */
3797 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3798 +      BP_NOT_DEFINED},                      /* usReverseMii */
3799 +     {BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3800 +      0x00,                                 /* ucPhyAddress */
3801 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3802 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3803 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3804 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3805 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3806 +      0x03,                                 /* numSwitchPorts */
3807 +      BP_ENET_CONFIG_SPI_SSB_1,             /* usConfigType */
3808 +      BP_ENET_REVERSE_MII}},                /* usReverseMii */
3809 +    {{BP_VOIP_DSP,                          /* ucDspType */
3810 +      0x00,                                 /* ucDspAddress */
3811 +      BP_EXT_INTR_2,                        /* usExtIntrVoip */
3812 +      BP_GPIO_6_AH,                         /* usGpioVoipReset */
3813 +      BP_GPIO_34_AH,                        /* usGpioVoipIntr */
3814 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3815 +      BP_CS_2},                             /* usCsVoip */
3816 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3817 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
3818 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3819 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3820 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3821 +    BP_GPIO_33_AL,                          /* usGpioPressAndHoldReset */
3822 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3823 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3824 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3825 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3826 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3827 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3828 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3829 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3830 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3831 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3832 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3833 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3834 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3835 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3836 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3837 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3838 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3839 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3840 +    BP_NOT_DEFINED,                         /* usCsHpna */
3841 +    BP_WLAN_ANT_MAIN,                       /* usAntInUseWireless */
3842 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3843 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3844 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3845 +};
3846 +
3847 +static BOARD_PARAMETERS g_bcm96348gw_11 =
3848 +{
3849 +    "96348GW-11",                           /* szBoardId */
3850 +    {{BP_ENET_NO_PHY},                      /* ucPhyType */
3851 +     {BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3852 +      0x00,                                 /* ucPhyAddress */
3853 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3854 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3855 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3856 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3857 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3858 +      0x04,                                 /* numSwitchPorts */
3859 +      BP_ENET_CONFIG_SPI_SSB_1,             /* usConfigType */
3860 +      BP_ENET_REVERSE_MII}},                /* usReverseMii */
3861 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3862 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3863 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
3864 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3865 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3866 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3867 +    BP_GPIO_33_AL,                          /* usGpioPressAndHoldReset */
3868 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3869 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3870 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3871 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3872 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3873 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3874 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3875 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3876 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
3877 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
3878 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
3879 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
3880 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3881 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
3882 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
3883 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3884 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3885 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3886 +    BP_NOT_DEFINED,                         /* usCsHpna */
3887 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3888 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3889 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3890 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */    
3891 +};
3892 +
3893 +static BOARD_PARAMETERS g_bcm96348sv =
3894 +{
3895 +    "96348SV",                              /* szBoardId */
3896 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3897 +      0x01,                                 /* ucPhyAddress */
3898 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3899 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3900 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3901 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3902 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3903 +      0x01,                                 /* numSwitchPorts */
3904 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3905 +      BP_NOT_DEFINED},                      /* usReverseMii */
3906 +     {BP_ENET_EXTERNAL_PHY,                 /* ucPhyType */
3907 +      0x1f,                                 /* ucPhyAddress */
3908 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3909 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3910 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3911 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3912 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3913 +      0x01,                                 /* numSwitchPorts */
3914 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3915 +      BP_NOT_DEFINED}},                     /* usReverseMii */
3916 +    {{BP_VOIP_NO_DSP},                      /* ucDspType */
3917 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
3918 +    BP_MEMORY_32MB_2_CHIP,                  /* usSdramSize */
3919 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3920 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3921 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3922 +    BP_NOT_DEFINED,                         /* usGpioPressAndHoldReset */
3923 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3924 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3925 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3926 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3927 +    BP_NOT_DEFINED,                         /* usGpioLedAdslFail */
3928 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3929 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3930 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3931 +    BP_NOT_DEFINED,                         /* usGpioLedWanData */
3932 +    BP_NOT_DEFINED,                         /* usGpioLedPpp */
3933 +    BP_NOT_DEFINED,                         /* usGpioLedPppFail */
3934 +    BP_NOT_DEFINED,                         /* usGpioLedBlPowerOn */
3935 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
3936 +    BP_NOT_DEFINED,                         /* usGpioLedBlResetCfg */
3937 +    BP_NOT_DEFINED,                         /* usGpioLedBlStop */
3938 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
3939 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
3940 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
3941 +    BP_NOT_DEFINED,                         /* usCsHpna */
3942 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
3943 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
3944 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
3945 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
3946 +};
3947 +
3948 +
3949 +static BOARD_PARAMETERS g_bcm96348gw_dualDsp =
3950 +{
3951 +    "96348GW-DualDSP",                      /* szBoardId */
3952 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
3953 +      0x01,                                 /* ucPhyAddress */
3954 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3955 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3956 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3957 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3958 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3959 +      0x01,                                 /* numSwitchPorts */
3960 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
3961 +      BP_NOT_DEFINED},                      /* usReverseMii */
3962 +     {BP_ENET_EXTERNAL_SWITCH,              /* ucPhyType */
3963 +      0x00,                                 /* ucPhyAddress */
3964 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
3965 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
3966 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
3967 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
3968 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
3969 +      0x03,                                 /* numSwitchPorts */
3970 +      BP_ENET_CONFIG_SPI_SSB_1,             /* usConfigType */
3971 +      BP_ENET_REVERSE_MII}},                /* usReverseMii */
3972 +    {{BP_VOIP_DSP,                          /* ucDspType */
3973 +      0x00,                                 /* ucDspAddress */
3974 +      BP_EXT_INTR_2,                        /* usExtIntrVoip */
3975 +      BP_UNEQUIPPED,                        /* usGpioVoipReset */
3976 +      BP_GPIO_34_AH,                        /* usGpioVoipIntr */
3977 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3978 +      BP_CS_2},                             /* usCsVoip */
3979 +     {BP_VOIP_DSP,                          /* ucDspType */
3980 +      0x01,                                 /* ucDspAddress */
3981 +      BP_EXT_INTR_3,                        /* usExtIntrVoip */
3982 +      BP_UNEQUIPPED ,                       /* usGpioVoipReset */
3983 +      BP_GPIO_35_AH,                        /* usGpioVoipIntr */
3984 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
3985 +      BP_CS_3}},                            /* usCsVoip */
3986 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
3987 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
3988 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
3989 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
3990 +    BP_GPIO_33_AL,                          /* usGpioPressAndHoldReset */
3991 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
3992 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
3993 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
3994 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
3995 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
3996 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
3997 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
3998 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
3999 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
4000 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
4001 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
4002 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
4003 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
4004 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
4005 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
4006 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
4007 +    BP_HW_DEFINED,                          /* usExtIntrAdslDyingGasp */
4008 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
4009 +    BP_NOT_DEFINED,                         /* usCsHpna */
4010 +    BP_WLAN_ANT_MAIN,                       /* usAntInUseWireless */
4011 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
4012 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
4013 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
4014 +};
4015 +
4016 +
4017 +static BOARD_PARAMETERS g_bcmCustom_01 =
4018 +{
4019 +     "BCMCUST_01",                          /* szBoardId */
4020 +    {{BP_ENET_INTERNAL_PHY,                 /* ucPhyType */
4021 +      0x01,                                 /* ucPhyAddress */
4022 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
4023 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
4024 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
4025 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
4026 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
4027 +      0x01,                                 /* numSwitchPorts */
4028 +      BP_ENET_CONFIG_MDIO,                  /* usConfigType */
4029 +      BP_NOT_DEFINED},                      /* usReverseMii */
4030 +     {BP_ENET_NO_PHY,                       /* ucPhyType */
4031 +      0x00,                                 /* ucPhyAddress */
4032 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSck */
4033 +      BP_NOT_DEFINED,                       /* usGpioPhySpiSs */
4034 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMosi */
4035 +      BP_NOT_DEFINED,                       /* usGpioPhySpiMiso */
4036 +      BP_NOT_DEFINED,                       /* usGpioPhyReset */
4037 +      0x01,                                 /* numSwitchPorts */
4038 +      BP_ENET_CONFIG_SPI_SSB_1,             /* usConfigType */
4039 +      BP_ENET_REVERSE_MII}},                /* usReverseMii */
4040 +    {{BP_VOIP_DSP,                          /* ucDspType */
4041 +      0x00,                                 /* ucDspAddress */
4042 +      BP_EXT_INTR_2,                        /* usExtIntrVoip */
4043 +      BP_GPIO_36_AH,                        /* usGpioVoipReset */
4044 +      BP_GPIO_34_AL,                        /* usGpioVoipIntr */
4045 +      BP_NOT_DEFINED,                       /* usGpioLedVoip */
4046 +      BP_CS_2},                             /* usCsVoip */
4047 +     {BP_VOIP_NO_DSP}},                     /* ucDspType */
4048 +    BP_MEMORY_16MB_2_CHIP,                  /* usSdramSize */
4049 +    BP_PSI_DEFAULT_SIZE,                    /* usPsiSize */
4050 +    BP_NOT_DEFINED,                         /* usGpioRj11InnerPair */
4051 +    BP_NOT_DEFINED,                         /* usGpioRj11OuterPair */
4052 +    BP_GPIO_33_AL,                          /* usGpioPressAndHoldReset */
4053 +    BP_NOT_DEFINED,                         /* usGpioPcmciaReset */
4054 +    BP_NOT_DEFINED,                         /* usGpioUartRts */
4055 +    BP_NOT_DEFINED,                         /* usGpioUartCts */
4056 +    BP_NOT_DEFINED,                         /* usGpioLedAdsl */
4057 +    BP_GPIO_2_AL,                           /* usGpioLedAdslFail */
4058 +    BP_NOT_DEFINED,                         /* usGpioLedWireless */
4059 +    BP_NOT_DEFINED,                         /* usGpioLedUsb */
4060 +    BP_NOT_DEFINED,                         /* usGpioLedHpna */
4061 +    BP_GPIO_3_AL,                           /* usGpioLedWanData */
4062 +    BP_GPIO_3_AL,                           /* usGpioLedPpp */
4063 +    BP_GPIO_4_AL,                           /* usGpioLedPppFail */
4064 +    BP_GPIO_0_AL,                           /* usGpioLedBlPowerOn */
4065 +    BP_NOT_DEFINED,                         /* usGpioLedBlAlarm */
4066 +    BP_GPIO_3_AL,                           /* usGpioLedBlResetCfg */
4067 +    BP_GPIO_1_AL,                           /* usGpioLedBlStop */
4068 +    BP_NOT_DEFINED,                         /* usExtIntrWireless */
4069 +    BP_NOT_DEFINED,                         /* usExtIntrAdslDyingGasp */
4070 +    BP_NOT_DEFINED,                         /* usExtIntrHpna */
4071 +    BP_NOT_DEFINED,                         /* usCsHpna */
4072 +    BP_NOT_DEFINED,                         /* usAntInUseWireless */
4073 +    BP_NOT_DEFINED,                         /* usGpioSesBtnWireless */
4074 +    BP_NOT_DEFINED,                         /* usExtIntrSesBtnWireless */
4075 +    BP_NOT_DEFINED                          /* usGpioLedSesWireless */
4076 +};
4077 +
4078 +static PBOARD_PARAMETERS g_BoardParms[] =
4079 +    {&g_bcm96348r, &g_bcm96348lv, &g_bcm96348gw, &g_bcm96348gw_10,
4080 +     &g_bcm96348gw_11, &g_bcm96348sv, &g_bcm96348gw_dualDsp,
4081 +     &g_bcmCustom_01, 0};
4082 +#endif
4083 +
4084 +static PBOARD_PARAMETERS g_pCurrentBp = 0;
4085 +
4086 +/**************************************************************************
4087 + * Name       : bpstrcmp
4088 + *
4089 + * Description: String compare for this file so it does not depend on an OS.
4090 + *              (Linux kernel and CFE share this source file.)
4091 + *
4092 + * Parameters : [IN] dest - destination string
4093 + *              [IN] src - source string
4094 + *
4095 + * Returns    : -1 - dest < src, 1 - dest > src, 0 dest == src
4096 + ***************************************************************************/
4097 +static int bpstrcmp(const char *dest,const char *src);
4098 +static int bpstrcmp(const char *dest,const char *src)
4099 +{
4100 +    while (*src && *dest)
4101 +    {
4102 +        if (*dest < *src) return -1;
4103 +        if (*dest > *src) return 1;
4104 +        dest++;
4105 +        src++;
4106 +    }
4107 +
4108 +    if (*dest && !*src) return 1;
4109 +    if (!*dest && *src) return -1;
4110 +    return 0;
4111 +} /* bpstrcmp */
4112 +
4113 +/**************************************************************************
4114 + * Name       : BpGetVoipDspConfig
4115 + *
4116 + * Description: Gets the DSP configuration from the board parameter
4117 + *              structure for a given DSP index.
4118 + *
4119 + * Parameters : [IN] dspNum - DSP index (number)
4120 + *
4121 + * Returns    : Pointer to DSP configuration block if found/valid, NULL
4122 + *              otherwise.
4123 + ***************************************************************************/
4124 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum );
4125 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum )
4126 +{
4127 +    VOIP_DSP_INFO *pDspConfig = 0;
4128 +    int i;
4129 +
4130 +    if( g_pCurrentBp )
4131 +    {
4132 +        for( i = 0 ; i < BP_MAX_VOIP_DSP ; i++ )
4133 +        {
4134 +            if( g_pCurrentBp->VoIPDspInfo[i].ucDspType != BP_VOIP_NO_DSP &&
4135 +                g_pCurrentBp->VoIPDspInfo[i].ucDspAddress == dspNum )
4136 +            {
4137 +                pDspConfig = &g_pCurrentBp->VoIPDspInfo[i];
4138 +                break;
4139 +            }
4140 +        }
4141 +    }
4142 +
4143 +    return pDspConfig;
4144 +}
4145 +
4146 +
4147 +/**************************************************************************
4148 + * Name       : BpSetBoardId
4149 + *
4150 + * Description: This function find the BOARD_PARAMETERS structure for the
4151 + *              specified board id string and assigns it to a global, static
4152 + *              variable.
4153 + *
4154 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
4155 + *
4156 + * Returns    : BP_SUCCESS - Success, value is returned.
4157 + *              BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
4158 + *                  have a board parameters configuration record.
4159 + ***************************************************************************/
4160 +int BpSetBoardId( char *pszBoardId )
4161 +{
4162 +    int nRet = BP_BOARD_ID_NOT_FOUND;
4163 +    PBOARD_PARAMETERS *ppBp;
4164 +
4165 +    for( ppBp = g_BoardParms; *ppBp; ppBp++ )
4166 +    {
4167 +        if( !bpstrcmp((*ppBp)->szBoardId, pszBoardId) )
4168 +        {
4169 +            g_pCurrentBp = *ppBp;
4170 +            nRet = BP_SUCCESS;
4171 +            break;
4172 +        }
4173 +    }
4174 +
4175 +    return( nRet );
4176 +} /* BpSetBoardId */
4177 +
4178 +/**************************************************************************
4179 + * Name       : BpGetBoardIds
4180 + *
4181 + * Description: This function returns all of the supported board id strings.
4182 + *
4183 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
4184 + *                  strings are returned in.  Each id starts at BP_BOARD_ID_LEN
4185 + *                  boundary.
4186 + *              [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
4187 + *                  were allocated in pszBoardIds.
4188 + *
4189 + * Returns    : Number of board id strings returned.
4190 + ***************************************************************************/
4191 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize )
4192 +{
4193 +    PBOARD_PARAMETERS *ppBp;
4194 +    int i;
4195 +    char *src;
4196 +    char *dest;
4197 +
4198 +    for( i = 0, ppBp = g_BoardParms; *ppBp && nBoardIdsSize;
4199 +        i++, ppBp++, nBoardIdsSize--, pszBoardIds += BP_BOARD_ID_LEN )
4200 +    {
4201 +        dest = pszBoardIds;
4202 +        src = (*ppBp)->szBoardId;
4203 +        while( *src )
4204 +            *dest++ = *src++;
4205 +        *dest = '\0';
4206 +    }
4207 +
4208 +    return( i );
4209 +} /* BpGetBoardIds */
4210 +
4211 +/**************************************************************************
4212 + * Name       : BpGetEthernetMacInfo
4213 + *
4214 + * Description: This function returns all of the supported board id strings.
4215 + *
4216 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
4217 + *                  buffers.
4218 + *              [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
4219 + *                  are pointed to by pEnetInfos.
4220 + *
4221 + * Returns    : BP_SUCCESS - Success, value is returned.
4222 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4223 + ***************************************************************************/
4224 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos )
4225 +{
4226 +    int i, nRet;
4227 +
4228 +    if( g_pCurrentBp )
4229 +    {
4230 +        for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4231 +        {
4232 +            if( i < BP_MAX_ENET_MACS )
4233 +            {
4234 +                unsigned char *src = (unsigned char *)
4235 +                    &g_pCurrentBp->EnetMacInfos[i];
4236 +                unsigned char *dest = (unsigned char *) pEnetInfos;
4237 +                int len = sizeof(ETHERNET_MAC_INFO);
4238 +                while( len-- )
4239 +                    *dest++ = *src++;
4240 +            }
4241 +            else
4242 +                pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4243 +        }
4244 +
4245 +        nRet = BP_SUCCESS;
4246 +    }
4247 +    else
4248 +    {
4249 +        for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4250 +            pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4251 +
4252 +        nRet = BP_BOARD_ID_NOT_SET;
4253 +    }
4254 +
4255 +    return( nRet );
4256 +} /* BpGetEthernetMacInfo */
4257 +
4258 +/**************************************************************************
4259 + * Name       : BpGetSdramSize
4260 + *
4261 + * Description: This function returns a constant that describees the board's
4262 + *              SDRAM type and size.
4263 + *
4264 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
4265 + *                  is returned in.
4266 + *
4267 + * Returns    : BP_SUCCESS - Success, value is returned.
4268 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4269 + ***************************************************************************/
4270 +int BpGetSdramSize( unsigned long *pulSdramSize )
4271 +{
4272 +    int nRet;
4273 +
4274 +    if( g_pCurrentBp )
4275 +    {
4276 +        *pulSdramSize = g_pCurrentBp->usSdramSize;
4277 +        nRet = BP_SUCCESS;
4278 +    }
4279 +    else
4280 +    {
4281 +        *pulSdramSize = BP_NOT_DEFINED;
4282 +        nRet = BP_BOARD_ID_NOT_SET;
4283 +    }
4284 +
4285 +    return( nRet );
4286 +} /* BpGetSdramSize */
4287 +
4288 +/**************************************************************************
4289 + * Name       : BpGetPsiSize
4290 + *
4291 + * Description: This function returns the persistent storage size in K bytes.
4292 + *
4293 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
4294 + *                  storage size is returned in.
4295 + *
4296 + * Returns    : BP_SUCCESS - Success, value is returned.
4297 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4298 + ***************************************************************************/
4299 +int BpGetPsiSize( unsigned long *pulPsiSize )
4300 +{
4301 +    int nRet;
4302 +
4303 +    if( g_pCurrentBp )
4304 +    {
4305 +        *pulPsiSize = g_pCurrentBp->usPsiSize;
4306 +        nRet = BP_SUCCESS;
4307 +    }
4308 +    else
4309 +    {
4310 +        *pulPsiSize = BP_NOT_DEFINED;
4311 +        nRet = BP_BOARD_ID_NOT_SET;
4312 +    }
4313 +
4314 +    return( nRet );
4315 +} /* BpGetPsiSize */
4316 +
4317 +/**************************************************************************
4318 + * Name       : BpGetRj11InnerOuterPairGpios
4319 + *
4320 + * Description: This function returns the GPIO pin assignments for changing
4321 + *              between the RJ11 inner pair and RJ11 outer pair.
4322 + *
4323 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
4324 + *                  GPIO pin is returned in.
4325 + *              [OUT] pusOuter - Address of short word that the RJ11 outer pair
4326 + *                  GPIO pin is returned in.
4327 + *
4328 + * Returns    : BP_SUCCESS - Success, values are returned.
4329 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4330 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4331 + *                  for the board.
4332 + ***************************************************************************/
4333 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
4334 +    unsigned short *pusOuter )
4335 +{
4336 +    int nRet;
4337 +
4338 +    if( g_pCurrentBp )
4339 +    {
4340 +        *pusInner = g_pCurrentBp->usGpioRj11InnerPair;
4341 +        *pusOuter = g_pCurrentBp->usGpioRj11OuterPair;
4342 +
4343 +        if( g_pCurrentBp->usGpioRj11InnerPair != BP_NOT_DEFINED &&
4344 +            g_pCurrentBp->usGpioRj11OuterPair != BP_NOT_DEFINED )
4345 +        {
4346 +            nRet = BP_SUCCESS;
4347 +        }
4348 +        else
4349 +        {
4350 +            nRet = BP_VALUE_NOT_DEFINED;
4351 +        }
4352 +    }
4353 +    else
4354 +    {
4355 +        *pusInner = *pusOuter = BP_NOT_DEFINED;
4356 +        nRet = BP_BOARD_ID_NOT_SET;
4357 +    }
4358 +
4359 +    return( nRet );
4360 +} /* BpGetRj11InnerOuterPairGpios */
4361 +
4362 +/**************************************************************************
4363 + * Name       : BpGetPressAndHoldResetGpio
4364 + *
4365 + * Description: This function returns the GPIO pin assignment for the press
4366 + *              and hold reset button.
4367 + *
4368 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
4369 + *                  reset button GPIO pin is returned in.
4370 + *
4371 + * Returns    : BP_SUCCESS - Success, value is returned.
4372 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4373 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4374 + *                  for the board.
4375 + ***************************************************************************/
4376 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue )
4377 +{
4378 +    int nRet;
4379 +
4380 +    if( g_pCurrentBp )
4381 +    {
4382 +        *pusValue = g_pCurrentBp->usGpioPressAndHoldReset;
4383 +
4384 +        if( g_pCurrentBp->usGpioPressAndHoldReset != BP_NOT_DEFINED )
4385 +        {
4386 +            nRet = BP_SUCCESS;
4387 +        }
4388 +        else
4389 +        {
4390 +            nRet = BP_VALUE_NOT_DEFINED;
4391 +        }
4392 +    }
4393 +    else
4394 +    {
4395 +        *pusValue = BP_NOT_DEFINED;
4396 +        nRet = BP_BOARD_ID_NOT_SET;
4397 +    }
4398 +
4399 +    return( nRet );
4400 +} /* BpGetPressAndHoldResetGpio */
4401 +
4402 +/**************************************************************************
4403 + * Name       : BpGetVoipResetGpio
4404 + *
4405 + * Description: This function returns the GPIO pin assignment for the VOIP
4406 + *              Reset operation.
4407 + *
4408 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
4409 + *                  GPIO pin is returned in.
4410 + *              [IN] dspNum - Address of the DSP to query.
4411 + *
4412 + * Returns    : BP_SUCCESS - Success, value is returned.
4413 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4414 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4415 + *                  for the board.
4416 + ***************************************************************************/
4417 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue )
4418 +{
4419 +    int nRet;
4420 +
4421 +    if( g_pCurrentBp )
4422 +    {
4423 +        VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4424 +
4425 +        if( pDspInfo )
4426 +        {
4427 +           *pusValue = pDspInfo->usGpioVoipReset;
4428 +
4429 +           if( *pusValue != BP_NOT_DEFINED ||
4430 +               *pusValue == BP_UNEQUIPPED )
4431 +           {
4432 +              nRet = BP_SUCCESS;
4433 +           }
4434 +           else
4435 +           {
4436 +              nRet = BP_VALUE_NOT_DEFINED;
4437 +           }
4438 +        }
4439 +        else
4440 +        {
4441 +           *pusValue = BP_NOT_DEFINED;
4442 +           nRet = BP_BOARD_ID_NOT_FOUND;
4443 +        }
4444 +    }
4445 +    else
4446 +    {
4447 +        *pusValue = BP_NOT_DEFINED;
4448 +        nRet = BP_BOARD_ID_NOT_SET;
4449 +    }
4450 +
4451 +    return( nRet );
4452 +} /* BpGetVoipResetGpio */
4453 +
4454 +/**************************************************************************
4455 + * Name       : BpGetVoipIntrGpio
4456 + *
4457 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
4458 + *
4459 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
4460 + *                  GPIO pin is returned in.
4461 + *              [IN] dspNum - Address of the DSP to query.
4462 + *
4463 + * Returns    : BP_SUCCESS - Success, value is returned.
4464 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4465 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4466 + *                  for the board.
4467 + ***************************************************************************/
4468 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue )
4469 +{
4470 +    int nRet;
4471 +
4472 +    if( g_pCurrentBp )
4473 +    {
4474 +        VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4475 +
4476 +        if( pDspInfo )
4477 +        {
4478 +           *pusValue = pDspInfo->usGpioVoipIntr;
4479 +
4480 +           if( *pusValue != BP_NOT_DEFINED )
4481 +           {
4482 +              nRet = BP_SUCCESS;
4483 +           }
4484 +           else
4485 +           {
4486 +              nRet = BP_VALUE_NOT_DEFINED;
4487 +           }
4488 +        }
4489 +        else
4490 +        {
4491 +           *pusValue = BP_NOT_DEFINED;
4492 +           nRet = BP_BOARD_ID_NOT_FOUND;
4493 +        }
4494 +    }
4495 +    else
4496 +    {
4497 +        *pusValue = BP_NOT_DEFINED;
4498 +        nRet = BP_BOARD_ID_NOT_SET;
4499 +    }
4500 +
4501 +    return( nRet );
4502 +} /* BpGetVoipIntrGpio */
4503 +
4504 +/**************************************************************************
4505 + * Name       : BpGetPcmciaResetGpio
4506 + *
4507 + * Description: This function returns the GPIO pin assignment for the PCMCIA
4508 + *              Reset operation.
4509 + *
4510 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
4511 + *                  GPIO pin is returned in.
4512 + *
4513 + * Returns    : BP_SUCCESS - Success, value is returned.
4514 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4515 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4516 + *                  for the board.
4517 + ***************************************************************************/
4518 +int BpGetPcmciaResetGpio( unsigned short *pusValue )
4519 +{
4520 +    int nRet;
4521 +
4522 +    if( g_pCurrentBp )
4523 +    {
4524 +        *pusValue = g_pCurrentBp->usGpioPcmciaReset;
4525 +
4526 +        if( g_pCurrentBp->usGpioPcmciaReset != BP_NOT_DEFINED )
4527 +        {
4528 +            nRet = BP_SUCCESS;
4529 +        }
4530 +        else
4531 +        {
4532 +            nRet = BP_VALUE_NOT_DEFINED;
4533 +        }
4534 +    }
4535 +    else
4536 +    {
4537 +        *pusValue = BP_NOT_DEFINED;
4538 +        nRet = BP_BOARD_ID_NOT_SET;
4539 +    }
4540 +
4541 +    return( nRet );
4542 +} /* BpGetPcmciaResetGpio */
4543 +
4544 +/**************************************************************************
4545 + * Name       : BpGetUartRtsCtsGpios
4546 + *
4547 + * Description: This function returns the GPIO pin assignments for RTS and CTS
4548 + *              UART signals.
4549 + *
4550 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
4551 + *                  pin is returned in.
4552 + *              [OUT] pusCts - Address of short word that the UART CTS GPIO
4553 + *                  pin is returned in.
4554 + *
4555 + * Returns    : BP_SUCCESS - Success, values are returned.
4556 + *              BP_BOARD_ID_NOT_SET - Error, board id input string does not
4557 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4558 + *                  for the board.
4559 + ***************************************************************************/
4560 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts )
4561 +{
4562 +    int nRet;
4563 +
4564 +    if( g_pCurrentBp )
4565 +    {
4566 +        *pusRts = g_pCurrentBp->usGpioUartRts;
4567 +        *pusCts = g_pCurrentBp->usGpioUartCts;
4568 +
4569 +        if( g_pCurrentBp->usGpioUartRts != BP_NOT_DEFINED &&
4570 +            g_pCurrentBp->usGpioUartCts != BP_NOT_DEFINED )
4571 +        {
4572 +            nRet = BP_SUCCESS;
4573 +        }
4574 +        else
4575 +        {
4576 +            nRet = BP_VALUE_NOT_DEFINED;
4577 +        }
4578 +    }
4579 +    else
4580 +    {
4581 +        *pusRts = *pusCts = BP_NOT_DEFINED;
4582 +        nRet = BP_BOARD_ID_NOT_SET;
4583 +    }
4584 +
4585 +    return( nRet );
4586 +} /* BpGetUartRtsCtsGpios */
4587 +
4588 +/**************************************************************************
4589 + * Name       : BpGetAdslLedGpio
4590 + *
4591 + * Description: This function returns the GPIO pin assignment for the ADSL
4592 + *              LED.
4593 + *
4594 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4595 + *                  GPIO pin is returned in.
4596 + *
4597 + * Returns    : BP_SUCCESS - Success, value is returned.
4598 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4599 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4600 + *                  for the board.
4601 + ***************************************************************************/
4602 +int BpGetAdslLedGpio( unsigned short *pusValue )
4603 +{
4604 +    int nRet;
4605 +
4606 +    if( g_pCurrentBp )
4607 +    {
4608 +        *pusValue = g_pCurrentBp->usGpioLedAdsl;
4609 +
4610 +        if( g_pCurrentBp->usGpioLedAdsl != BP_NOT_DEFINED )
4611 +        {
4612 +            nRet = BP_SUCCESS;
4613 +        }
4614 +        else
4615 +        {
4616 +            nRet = BP_VALUE_NOT_DEFINED;
4617 +        }
4618 +    }
4619 +    else
4620 +    {
4621 +        *pusValue = BP_NOT_DEFINED;
4622 +        nRet = BP_BOARD_ID_NOT_SET;
4623 +    }
4624 +
4625 +    return( nRet );
4626 +} /* BpGetAdslLedGpio */
4627 +
4628 +/**************************************************************************
4629 + * Name       : BpGetAdslFailLedGpio
4630 + *
4631 + * Description: This function returns the GPIO pin assignment for the ADSL
4632 + *              LED that is used when there is a DSL connection failure.
4633 + *
4634 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4635 + *                  GPIO pin is returned in.
4636 + *
4637 + * Returns    : BP_SUCCESS - Success, value is returned.
4638 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4639 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4640 + *                  for the board.
4641 + ***************************************************************************/
4642 +int BpGetAdslFailLedGpio( unsigned short *pusValue )
4643 +{
4644 +    int nRet;
4645 +
4646 +    if( g_pCurrentBp )
4647 +    {
4648 +        *pusValue = g_pCurrentBp->usGpioLedAdslFail;
4649 +
4650 +        if( g_pCurrentBp->usGpioLedAdslFail != BP_NOT_DEFINED )
4651 +        {
4652 +            nRet = BP_SUCCESS;
4653 +        }
4654 +        else
4655 +        {
4656 +            nRet = BP_VALUE_NOT_DEFINED;
4657 +        }
4658 +    }
4659 +    else
4660 +    {
4661 +        *pusValue = BP_NOT_DEFINED;
4662 +        nRet = BP_BOARD_ID_NOT_SET;
4663 +    }
4664 +
4665 +    return( nRet );
4666 +} /* BpGetAdslFailLedGpio */
4667 +
4668 +/**************************************************************************
4669 + * Name       : BpGetWirelessLedGpio
4670 + *
4671 + * Description: This function returns the GPIO pin assignment for the Wireless
4672 + *              LED.
4673 + *
4674 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4675 + *                  GPIO pin is returned in.
4676 + *
4677 + * Returns    : BP_SUCCESS - Success, value is returned.
4678 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4679 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4680 + *                  for the board.
4681 + ***************************************************************************/
4682 +int BpGetWirelessLedGpio( unsigned short *pusValue )
4683 +{
4684 +    int nRet;
4685 +
4686 +    if( g_pCurrentBp )
4687 +    {
4688 +        *pusValue = g_pCurrentBp->usGpioLedWireless;
4689 +
4690 +        if( g_pCurrentBp->usGpioLedWireless != BP_NOT_DEFINED )
4691 +        {
4692 +            nRet = BP_SUCCESS;
4693 +        }
4694 +        else
4695 +        {
4696 +            nRet = BP_VALUE_NOT_DEFINED;
4697 +        }
4698 +    }
4699 +    else
4700 +    {
4701 +        *pusValue = BP_NOT_DEFINED;
4702 +        nRet = BP_BOARD_ID_NOT_SET;
4703 +    }
4704 +
4705 +    return( nRet );
4706 +} /* BpGetWirelessLedGpio */
4707 +
4708 +/**************************************************************************
4709 + * Name       : BpGetWirelessAntInUse
4710 + *
4711 + * Description: This function returns the antennas in use for wireless
4712 + *
4713 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
4714 + *                  is in use.
4715 + *
4716 + * Returns    : BP_SUCCESS - Success, value is returned.
4717 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4718 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4719 + *                  for the board.
4720 + ***************************************************************************/
4721 +int BpGetWirelessAntInUse( unsigned short *pusValue )
4722 +{
4723 +    int nRet;
4724 +
4725 +    if( g_pCurrentBp )
4726 +    {
4727 +        *pusValue = g_pCurrentBp->usAntInUseWireless;
4728 +
4729 +        if( g_pCurrentBp->usAntInUseWireless != BP_NOT_DEFINED )
4730 +        {
4731 +            nRet = BP_SUCCESS;
4732 +        }
4733 +        else
4734 +        {
4735 +            nRet = BP_VALUE_NOT_DEFINED;
4736 +        }
4737 +    }
4738 +    else
4739 +    {
4740 +        *pusValue = BP_NOT_DEFINED;
4741 +        nRet = BP_BOARD_ID_NOT_SET;
4742 +    }
4743 +
4744 +    return( nRet );    
4745 +} /* BpGetWirelessAntInUse */
4746 +
4747 +/**************************************************************************
4748 + * Name       : BpGetWirelessSesBtnGpio
4749 + *
4750 + * Description: This function returns the GPIO pin assignment for the Wireless
4751 + *              Ses Button.
4752 + *
4753 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4754 + *                  GPIO pin is returned in.
4755 + *
4756 + * Returns    : BP_SUCCESS - Success, value is returned.
4757 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4758 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4759 + *                  for the board.
4760 + ***************************************************************************/
4761 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue )
4762 +{
4763 +    int nRet;
4764 +
4765 +    if( g_pCurrentBp )
4766 +    {
4767 +        *pusValue = g_pCurrentBp->usGpioSesBtnWireless;
4768 +
4769 +        if( g_pCurrentBp->usGpioSesBtnWireless != BP_NOT_DEFINED )
4770 +        {
4771 +            nRet = BP_SUCCESS;
4772 +        }
4773 +        else
4774 +        {
4775 +            nRet = BP_VALUE_NOT_DEFINED;
4776 +        }
4777 +    }
4778 +    else
4779 +    {
4780 +        *pusValue = BP_NOT_DEFINED;
4781 +        nRet = BP_BOARD_ID_NOT_SET;
4782 +    }
4783 +
4784 +    return( nRet );    
4785 +} /* BpGetWirelessSesBtnGpio */
4786 +
4787 +/**************************************************************************
4788 + * Name       : BpGetWirelessSesExtIntr
4789 + *
4790 + * Description: This function returns the external interrupt number for the 
4791 + *              Wireless Ses Button.
4792 + *
4793 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4794 + *                  external interrup is returned in.
4795 + *
4796 + * Returns    : BP_SUCCESS - Success, value is returned.
4797 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4798 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4799 + *                  for the board.
4800 + ***************************************************************************/
4801 +int BpGetWirelessSesExtIntr( unsigned short *pusValue )
4802 +{
4803 +    int nRet;
4804 +
4805 +    if( g_pCurrentBp )
4806 +    {
4807 +        *pusValue = g_pCurrentBp->usExtIntrSesBtnWireless;
4808 +
4809 +        if( g_pCurrentBp->usExtIntrSesBtnWireless != BP_NOT_DEFINED )
4810 +        {
4811 +            nRet = BP_SUCCESS;
4812 +        }
4813 +        else
4814 +        {
4815 +            nRet = BP_VALUE_NOT_DEFINED;
4816 +        }
4817 +    }
4818 +    else
4819 +    {
4820 +        *pusValue = BP_NOT_DEFINED;
4821 +        nRet = BP_BOARD_ID_NOT_SET;
4822 +    }
4823 +
4824 +    return( nRet );    
4825 +               
4826 +} /* BpGetWirelessSesExtIntr */
4827 +
4828 +/**************************************************************************
4829 + * Name       : BpGetWirelessSesLedGpio
4830 + *
4831 + * Description: This function returns the GPIO pin assignment for the Wireless
4832 + *              Ses Led.
4833 + *
4834 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4835 + *                  Led GPIO pin is returned in.
4836 + *
4837 + * Returns    : BP_SUCCESS - Success, value is returned.
4838 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4839 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4840 + *                  for the board.
4841 + ***************************************************************************/
4842 +int BpGetWirelessSesLedGpio( unsigned short *pusValue )
4843 +{
4844 +    int nRet;
4845 +
4846 +    if( g_pCurrentBp )
4847 +    {
4848 +        *pusValue = g_pCurrentBp->usGpioLedSesWireless;
4849 +
4850 +        if( g_pCurrentBp->usGpioLedSesWireless != BP_NOT_DEFINED )
4851 +        {
4852 +            nRet = BP_SUCCESS;
4853 +        }
4854 +        else
4855 +        {
4856 +            nRet = BP_VALUE_NOT_DEFINED;
4857 +        }
4858 +    }
4859 +    else
4860 +    {
4861 +        *pusValue = BP_NOT_DEFINED;
4862 +        nRet = BP_BOARD_ID_NOT_SET;
4863 +    }
4864 +
4865 +    return( nRet );
4866 +       
4867 +} /* BpGetWirelessSesLedGpio */
4868 +
4869 +/**************************************************************************
4870 + * Name       : BpGetUsbLedGpio
4871 + *
4872 + * Description: This function returns the GPIO pin assignment for the USB
4873 + *              LED.
4874 + *
4875 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
4876 + *                  GPIO pin is returned in.
4877 + *
4878 + * Returns    : BP_SUCCESS - Success, value is returned.
4879 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4880 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4881 + *                  for the board.
4882 + ***************************************************************************/
4883 +int BpGetUsbLedGpio( unsigned short *pusValue )
4884 +{
4885 +    int nRet;
4886 +
4887 +    if( g_pCurrentBp )
4888 +    {
4889 +        *pusValue = g_pCurrentBp->usGpioLedUsb;
4890 +
4891 +        if( g_pCurrentBp->usGpioLedUsb != BP_NOT_DEFINED )
4892 +        {
4893 +            nRet = BP_SUCCESS;
4894 +        }
4895 +        else
4896 +        {
4897 +            nRet = BP_VALUE_NOT_DEFINED;
4898 +        }
4899 +    }
4900 +    else
4901 +    {
4902 +        *pusValue = BP_NOT_DEFINED;
4903 +        nRet = BP_BOARD_ID_NOT_SET;
4904 +    }
4905 +
4906 +    return( nRet );
4907 +} /* BpGetUsbLedGpio */
4908 +
4909 +/**************************************************************************
4910 + * Name       : BpGetHpnaLedGpio
4911 + *
4912 + * Description: This function returns the GPIO pin assignment for the HPNA
4913 + *              LED.
4914 + *
4915 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
4916 + *                  GPIO pin is returned in.
4917 + *
4918 + * Returns    : BP_SUCCESS - Success, value is returned.
4919 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4920 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4921 + *                  for the board.
4922 + ***************************************************************************/
4923 +int BpGetHpnaLedGpio( unsigned short *pusValue )
4924 +{
4925 +    int nRet;
4926 +
4927 +    if( g_pCurrentBp )
4928 +    {
4929 +        *pusValue = g_pCurrentBp->usGpioLedHpna;
4930 +
4931 +        if( g_pCurrentBp->usGpioLedHpna != BP_NOT_DEFINED )
4932 +        {
4933 +            nRet = BP_SUCCESS;
4934 +        }
4935 +        else
4936 +        {
4937 +            nRet = BP_VALUE_NOT_DEFINED;
4938 +        }
4939 +    }
4940 +    else
4941 +    {
4942 +        *pusValue = BP_NOT_DEFINED;
4943 +        nRet = BP_BOARD_ID_NOT_SET;
4944 +    }
4945 +
4946 +    return( nRet );
4947 +} /* BpGetHpnaLedGpio */
4948 +
4949 +/**************************************************************************
4950 + * Name       : BpGetWanDataLedGpio
4951 + *
4952 + * Description: This function returns the GPIO pin assignment for the WAN Data
4953 + *              LED.
4954 + *
4955 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
4956 + *                  GPIO pin is returned in.
4957 + *
4958 + * Returns    : BP_SUCCESS - Success, value is returned.
4959 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4960 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
4961 + *                  for the board.
4962 + ***************************************************************************/
4963 +int BpGetWanDataLedGpio( unsigned short *pusValue )
4964 +{
4965 +    int nRet;
4966 +
4967 +    if( g_pCurrentBp )
4968 +    {
4969 +        *pusValue = g_pCurrentBp->usGpioLedWanData;
4970 +
4971 +        if( g_pCurrentBp->usGpioLedWanData != BP_NOT_DEFINED )
4972 +        {
4973 +            nRet = BP_SUCCESS;
4974 +        }
4975 +        else
4976 +        {
4977 +            nRet = BP_VALUE_NOT_DEFINED;
4978 +        }
4979 +    }
4980 +    else
4981 +    {
4982 +        *pusValue = BP_NOT_DEFINED;
4983 +        nRet = BP_BOARD_ID_NOT_SET;
4984 +    }
4985 +
4986 +    return( nRet );
4987 +} /* BpGetWanDataLedGpio */
4988 +
4989 +/**************************************************************************
4990 + * Name       : BpGetPppLedGpio
4991 + *
4992 + * Description: This function returns the GPIO pin assignment for the PPP
4993 + *              LED.
4994 + *
4995 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4996 + *                  GPIO pin is returned in.
4997 + *
4998 + * Returns    : BP_SUCCESS - Success, value is returned.
4999 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5000 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5001 + *                  for the board.
5002 + ***************************************************************************/
5003 +int BpGetPppLedGpio( unsigned short *pusValue )
5004 +{
5005 +    int nRet;
5006 +
5007 +    if( g_pCurrentBp )
5008 +    {
5009 +        *pusValue = g_pCurrentBp->usGpioLedPpp;
5010 +
5011 +        if( g_pCurrentBp->usGpioLedPpp != BP_NOT_DEFINED )
5012 +        {
5013 +            nRet = BP_SUCCESS;
5014 +        }
5015 +        else
5016 +        {
5017 +            nRet = BP_VALUE_NOT_DEFINED;
5018 +        }
5019 +    }
5020 +    else
5021 +    {
5022 +        *pusValue = BP_NOT_DEFINED;
5023 +        nRet = BP_BOARD_ID_NOT_SET;
5024 +    }
5025 +
5026 +    return( nRet );
5027 +} /* BpGetPppLedGpio */
5028 +
5029 +/**************************************************************************
5030 + * Name       : BpGetPppFailLedGpio
5031 + *
5032 + * Description: This function returns the GPIO pin assignment for the PPP
5033 + *              LED that is used when there is a PPP connection failure.
5034 + *
5035 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5036 + *                  GPIO pin is returned in.
5037 + *
5038 + * Returns    : BP_SUCCESS - Success, value is returned.
5039 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5040 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5041 + *                  for the board.
5042 + ***************************************************************************/
5043 +int BpGetPppFailLedGpio( unsigned short *pusValue )
5044 +{
5045 +    int nRet;
5046 +
5047 +    if( g_pCurrentBp )
5048 +    {
5049 +        *pusValue = g_pCurrentBp->usGpioLedPppFail;
5050 +
5051 +        if( g_pCurrentBp->usGpioLedPppFail != BP_NOT_DEFINED )
5052 +        {
5053 +            nRet = BP_SUCCESS;
5054 +        }
5055 +        else
5056 +        {
5057 +            nRet = BP_VALUE_NOT_DEFINED;
5058 +        }
5059 +    }
5060 +    else
5061 +    {
5062 +        *pusValue = BP_NOT_DEFINED;
5063 +        nRet = BP_BOARD_ID_NOT_SET;
5064 +    }
5065 +
5066 +    return( nRet );
5067 +} /* BpGetPppFailLedGpio */
5068 +
5069 +/**************************************************************************
5070 + * Name       : BpGetBootloaderPowerOnLedGpio
5071 + *
5072 + * Description: This function returns the GPIO pin assignment for the power
5073 + *              on LED that is set by the bootloader.
5074 + *
5075 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5076 + *                  GPIO pin is returned in.
5077 + *
5078 + * Returns    : BP_SUCCESS - Success, value is returned.
5079 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5080 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5081 + *                  for the board.
5082 + ***************************************************************************/
5083 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue )
5084 +{
5085 +    int nRet;
5086 +
5087 +    if( g_pCurrentBp )
5088 +    {
5089 +        *pusValue = g_pCurrentBp->usGpioLedBlPowerOn;
5090 +
5091 +        if( g_pCurrentBp->usGpioLedBlPowerOn != BP_NOT_DEFINED )
5092 +        {
5093 +            nRet = BP_SUCCESS;
5094 +        }
5095 +        else
5096 +        {
5097 +            nRet = BP_VALUE_NOT_DEFINED;
5098 +        }
5099 +    }
5100 +    else
5101 +    {
5102 +        *pusValue = BP_NOT_DEFINED;
5103 +        nRet = BP_BOARD_ID_NOT_SET;
5104 +    }
5105 +
5106 +    return( nRet );
5107 +} /* BpGetBootloaderPowerOn */
5108 +
5109 +/**************************************************************************
5110 + * Name       : BpGetBootloaderAlarmLedGpio
5111 + *
5112 + * Description: This function returns the GPIO pin assignment for the alarm
5113 + *              LED that is set by the bootloader.
5114 + *
5115 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5116 + *                  GPIO pin is returned in.
5117 + *
5118 + * Returns    : BP_SUCCESS - Success, value is returned.
5119 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5120 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5121 + *                  for the board.
5122 + ***************************************************************************/
5123 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue )
5124 +{
5125 +    int nRet;
5126 +
5127 +    if( g_pCurrentBp )
5128 +    {
5129 +        *pusValue = g_pCurrentBp->usGpioLedBlAlarm;
5130 +
5131 +        if( g_pCurrentBp->usGpioLedBlAlarm != BP_NOT_DEFINED )
5132 +        {
5133 +            nRet = BP_SUCCESS;
5134 +        }
5135 +        else
5136 +        {
5137 +            nRet = BP_VALUE_NOT_DEFINED;
5138 +        }
5139 +    }
5140 +    else
5141 +    {
5142 +        *pusValue = BP_NOT_DEFINED;
5143 +        nRet = BP_BOARD_ID_NOT_SET;
5144 +    }
5145 +
5146 +    return( nRet );
5147 +} /* BpGetBootloaderAlarmLedGpio */
5148 +
5149 +/**************************************************************************
5150 + * Name       : BpGetBootloaderResetCfgLedGpio
5151 + *
5152 + * Description: This function returns the GPIO pin assignment for the reset
5153 + *              configuration LED that is set by the bootloader.
5154 + *
5155 + * Parameters : [OUT] pusValue - Address of short word that the reset
5156 + *                  configuration LED GPIO pin is returned in.
5157 + *
5158 + * Returns    : BP_SUCCESS - Success, value is returned.
5159 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5160 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5161 + *                  for the board.
5162 + ***************************************************************************/
5163 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue )
5164 +{
5165 +    int nRet;
5166 +
5167 +    if( g_pCurrentBp )
5168 +    {
5169 +        *pusValue = g_pCurrentBp->usGpioLedBlResetCfg;
5170 +
5171 +        if( g_pCurrentBp->usGpioLedBlResetCfg != BP_NOT_DEFINED )
5172 +        {
5173 +            nRet = BP_SUCCESS;
5174 +        }
5175 +        else
5176 +        {
5177 +            nRet = BP_VALUE_NOT_DEFINED;
5178 +        }
5179 +    }
5180 +    else
5181 +    {
5182 +        *pusValue = BP_NOT_DEFINED;
5183 +        nRet = BP_BOARD_ID_NOT_SET;
5184 +    }
5185 +
5186 +    return( nRet );
5187 +} /* BpGetBootloaderResetCfgLedGpio */
5188 +
5189 +/**************************************************************************
5190 + * Name       : BpGetBootloaderStopLedGpio
5191 + *
5192 + * Description: This function returns the GPIO pin assignment for the break
5193 + *              into bootloader LED that is set by the bootloader.
5194 + *
5195 + * Parameters : [OUT] pusValue - Address of short word that the break into
5196 + *                  bootloader LED GPIO pin is returned in.
5197 + *
5198 + * Returns    : BP_SUCCESS - Success, value is returned.
5199 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5200 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5201 + *                  for the board.
5202 + ***************************************************************************/
5203 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue )
5204 +{
5205 +    int nRet;
5206 +
5207 +    if( g_pCurrentBp )
5208 +    {
5209 +        *pusValue = g_pCurrentBp->usGpioLedBlStop;
5210 +
5211 +        if( g_pCurrentBp->usGpioLedBlStop != BP_NOT_DEFINED )
5212 +        {
5213 +            nRet = BP_SUCCESS;
5214 +        }
5215 +        else
5216 +        {
5217 +            nRet = BP_VALUE_NOT_DEFINED;
5218 +        }
5219 +    }
5220 +    else
5221 +    {
5222 +        *pusValue = BP_NOT_DEFINED;
5223 +        nRet = BP_BOARD_ID_NOT_SET;
5224 +    }
5225 +
5226 +    return( nRet );
5227 +} /* BpGetBootloaderStopLedGpio */
5228 +
5229 +/**************************************************************************
5230 + * Name       : BpGetVoipLedGpio
5231 + *
5232 + * Description: This function returns the GPIO pin assignment for the VOIP
5233 + *              LED.
5234 + *
5235 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5236 + *                  GPIO pin is returned in.
5237 + *
5238 + * Returns    : BP_SUCCESS - Success, value is returned.
5239 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5240 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5241 + *                  for the board.
5242 + *
5243 + * Note       : The VoIP structure would allow for having one LED per DSP
5244 + *              however, the board initialization function assumes only one
5245 + *              LED per functionality (ie one LED for VoIP).  Therefore in
5246 + *              order to keep this tidy and simple we do not make usage of the
5247 + *              one-LED-per-DSP function.  Instead, we assume that the LED for
5248 + *              VoIP is unique and associated with DSP 0 (always present on
5249 + *              any VoIP platform).  If changing this to a LED-per-DSP function
5250 + *              then one need to update the board initialization driver in
5251 + *              bcmdrivers\opensource\char\board\bcm963xx\impl1
5252 + ***************************************************************************/
5253 +int BpGetVoipLedGpio( unsigned short *pusValue )
5254 +{
5255 +    int nRet;
5256 +
5257 +    if( g_pCurrentBp )
5258 +    {
5259 +        VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( 0 );
5260 +
5261 +        if( pDspInfo )
5262 +        {
5263 +           *pusValue = pDspInfo->usGpioLedVoip;
5264 +
5265 +           if( *pusValue != BP_NOT_DEFINED )
5266 +           {
5267 +              nRet = BP_SUCCESS;
5268 +           }
5269 +           else
5270 +           {
5271 +              nRet = BP_VALUE_NOT_DEFINED;
5272 +           }
5273 +        }
5274 +        else
5275 +        {
5276 +           *pusValue = BP_NOT_DEFINED;
5277 +           nRet = BP_BOARD_ID_NOT_FOUND;
5278 +        }
5279 +    }
5280 +    else
5281 +    {
5282 +        *pusValue = BP_NOT_DEFINED;
5283 +        nRet = BP_BOARD_ID_NOT_SET;
5284 +    }
5285 +
5286 +    return( nRet );
5287 +} /* BpGetVoipLedGpio */
5288 +
5289 +/**************************************************************************
5290 + * Name       : BpGetWirelessExtIntr
5291 + *
5292 + * Description: This function returns the Wireless external interrupt number.
5293 + *
5294 + * Parameters : [OUT] pulValue - Address of short word that the wireless
5295 + *                  external interrupt number is returned in.
5296 + *
5297 + * Returns    : BP_SUCCESS - Success, value is returned.
5298 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5299 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5300 + *                  for the board.
5301 + ***************************************************************************/
5302 +int BpGetWirelessExtIntr( unsigned long *pulValue )
5303 +{
5304 +    int nRet;
5305 +
5306 +    if( g_pCurrentBp )
5307 +    {
5308 +        *pulValue = g_pCurrentBp->usExtIntrWireless;
5309 +
5310 +        if( g_pCurrentBp->usExtIntrWireless != BP_NOT_DEFINED )
5311 +        {
5312 +            nRet = BP_SUCCESS;
5313 +        }
5314 +        else
5315 +        {
5316 +            nRet = BP_VALUE_NOT_DEFINED;
5317 +        }
5318 +    }
5319 +    else
5320 +    {
5321 +        *pulValue = BP_NOT_DEFINED;
5322 +        nRet = BP_BOARD_ID_NOT_SET;
5323 +    }
5324 +
5325 +    return( nRet );
5326 +} /* BpGetWirelessExtIntr */
5327 +
5328 +/**************************************************************************
5329 + * Name       : BpGetAdslDyingGaspExtIntr
5330 + *
5331 + * Description: This function returns the ADSL Dying Gasp external interrupt
5332 + *              number.
5333 + *
5334 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
5335 + *                  external interrupt number is returned in.
5336 + *
5337 + * Returns    : BP_SUCCESS - Success, value is returned.
5338 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5339 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5340 + *                  for the board.
5341 + ***************************************************************************/
5342 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue )
5343 +{
5344 +    int nRet;
5345 +
5346 +    if( g_pCurrentBp )
5347 +    {
5348 +        *pulValue = g_pCurrentBp->usExtIntrAdslDyingGasp;
5349 +
5350 +        if( g_pCurrentBp->usExtIntrAdslDyingGasp != BP_NOT_DEFINED )
5351 +        {
5352 +            nRet = BP_SUCCESS;
5353 +        }
5354 +        else
5355 +        {
5356 +            nRet = BP_VALUE_NOT_DEFINED;
5357 +        }
5358 +    }
5359 +    else
5360 +    {
5361 +        *pulValue = BP_NOT_DEFINED;
5362 +        nRet = BP_BOARD_ID_NOT_SET;
5363 +    }
5364 +
5365 +    return( nRet );
5366 +} /* BpGetAdslDyingGaspExtIntr */
5367 +
5368 +/**************************************************************************
5369 + * Name       : BpGetVoipExtIntr
5370 + *
5371 + * Description: This function returns the VOIP external interrupt number.
5372 + *
5373 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5374 + *                  external interrupt number is returned in.
5375 + *              [IN] dspNum - Address of the DSP to query.
5376 + *
5377 + * Returns    : BP_SUCCESS - Success, value is returned.
5378 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5379 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5380 + *                  for the board.
5381 + ***************************************************************************/
5382 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue )
5383 +{
5384 +    int nRet;
5385 +
5386 +    if( g_pCurrentBp )
5387 +    {
5388 +        VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5389 +
5390 +        if( pDspInfo )
5391 +        {
5392 +           *pulValue = pDspInfo->usExtIntrVoip;
5393 +
5394 +           if( *pulValue != BP_NOT_DEFINED )
5395 +           {
5396 +              nRet = BP_SUCCESS;
5397 +           }
5398 +           else
5399 +           {
5400 +              nRet = BP_VALUE_NOT_DEFINED;
5401 +           }
5402 +        }
5403 +        else
5404 +        {
5405 +           *pulValue = BP_NOT_DEFINED;
5406 +           nRet = BP_BOARD_ID_NOT_FOUND;
5407 +        }
5408 +    }
5409 +    else
5410 +    {
5411 +        *pulValue = BP_NOT_DEFINED;
5412 +        nRet = BP_BOARD_ID_NOT_SET;
5413 +    }
5414 +
5415 +    return( nRet );
5416 +} /* BpGetVoipExtIntr */
5417 +
5418 +/**************************************************************************
5419 + * Name       : BpGetHpnaExtIntr
5420 + *
5421 + * Description: This function returns the HPNA external interrupt number.
5422 + *
5423 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5424 + *                  external interrupt number is returned in.
5425 + *
5426 + * Returns    : BP_SUCCESS - Success, value is returned.
5427 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5428 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5429 + *                  for the board.
5430 + ***************************************************************************/
5431 +int BpGetHpnaExtIntr( unsigned long *pulValue )
5432 +{
5433 +    int nRet;
5434 +
5435 +    if( g_pCurrentBp )
5436 +    {
5437 +        *pulValue = g_pCurrentBp->usExtIntrHpna;
5438 +
5439 +        if( g_pCurrentBp->usExtIntrHpna != BP_NOT_DEFINED )
5440 +        {
5441 +            nRet = BP_SUCCESS;
5442 +        }
5443 +        else
5444 +        {
5445 +            nRet = BP_VALUE_NOT_DEFINED;
5446 +        }
5447 +    }
5448 +    else
5449 +    {
5450 +        *pulValue = BP_NOT_DEFINED;
5451 +        nRet = BP_BOARD_ID_NOT_SET;
5452 +    }
5453 +
5454 +    return( nRet );
5455 +} /* BpGetHpnaExtIntr */
5456 +
5457 +/**************************************************************************
5458 + * Name       : BpGetHpnaChipSelect
5459 + *
5460 + * Description: This function returns the HPNA chip select number.
5461 + *
5462 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5463 + *                  chip select number is returned in.
5464 + *
5465 + * Returns    : BP_SUCCESS - Success, value is returned.
5466 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5467 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5468 + *                  for the board.
5469 + ***************************************************************************/
5470 +int BpGetHpnaChipSelect( unsigned long *pulValue )
5471 +{
5472 +    int nRet;
5473 +
5474 +    if( g_pCurrentBp )
5475 +    {
5476 +        *pulValue = g_pCurrentBp->usCsHpna;
5477 +
5478 +        if( g_pCurrentBp->usCsHpna != BP_NOT_DEFINED )
5479 +        {
5480 +            nRet = BP_SUCCESS;
5481 +        }
5482 +        else
5483 +        {
5484 +            nRet = BP_VALUE_NOT_DEFINED;
5485 +        }
5486 +    }
5487 +    else
5488 +    {
5489 +        *pulValue = BP_NOT_DEFINED;
5490 +        nRet = BP_BOARD_ID_NOT_SET;
5491 +    }
5492 +
5493 +    return( nRet );
5494 +} /* BpGetHpnaChipSelect */
5495 +
5496 +/**************************************************************************
5497 + * Name       : BpGetVoipChipSelect
5498 + *
5499 + * Description: This function returns the VOIP chip select number.
5500 + *
5501 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5502 + *                  chip select number is returned in.
5503 + *              [IN] dspNum - Address of the DSP to query.
5504 + *
5505 + * Returns    : BP_SUCCESS - Success, value is returned.
5506 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5507 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5508 + *                  for the board.
5509 + ***************************************************************************/
5510 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue )
5511 +{
5512 +    int nRet;
5513 +
5514 +    if( g_pCurrentBp )
5515 +    {
5516 +        VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5517 +
5518 +        if( pDspInfo )
5519 +        {
5520 +           *pulValue = pDspInfo->usCsVoip;
5521 +
5522 +           if( *pulValue != BP_NOT_DEFINED )
5523 +           {
5524 +              nRet = BP_SUCCESS;
5525 +           }
5526 +           else
5527 +           {
5528 +              nRet = BP_VALUE_NOT_DEFINED;
5529 +           }
5530 +        }
5531 +        else
5532 +        {
5533 +           *pulValue = BP_NOT_DEFINED;
5534 +           nRet = BP_BOARD_ID_NOT_FOUND;
5535 +        }
5536 +    }
5537 +    else
5538 +    {
5539 +        *pulValue = BP_NOT_DEFINED;
5540 +        nRet = BP_BOARD_ID_NOT_SET;
5541 +    }
5542 +
5543 +    return( nRet );
5544 +} /* BpGetVoipChipSelect */
5545 +
5546 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h
5547 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h    1970-01-01 01:00:00.000000000 +0100
5548 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h   2006-08-03 16:36:58.000000000 +0200
5549 @@ -0,0 +1,758 @@
5550 +/*
5551 +<:copyright-gpl 
5552 +
5553 + Copyright 2003 Broadcom Corp. All Rights Reserved. 
5554
5555 + This program is free software; you can distribute it and/or modify it 
5556 + under the terms of the GNU General Public License (Version 2) as 
5557 + published by the Free Software Foundation. 
5558
5559 + This program is distributed in the hope it will be useful, but WITHOUT 
5560 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
5561 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
5562 + for more details. 
5563
5564 + You should have received a copy of the GNU General Public License along 
5565 + with this program; if not, write to the Free Software Foundation, Inc., 
5566 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
5567 +
5568 +:>
5569 +*/
5570 +/**************************************************************************
5571 + * File Name  : boardparms.h
5572 + *
5573 + * Description: This file contains definitions and function prototypes for
5574 + *              the BCM63xx board parameter access functions.
5575 + * 
5576 + * Updates    : 07/14/2003  Created.
5577 + ***************************************************************************/
5578 +
5579 +#if !defined(_BOARDPARMS_H)
5580 +#define _BOARDPARMS_H
5581 +
5582 +/* Return codes. */
5583 +#define BP_SUCCESS                              0
5584 +#define BP_BOARD_ID_NOT_FOUND                   1
5585 +#define BP_VALUE_NOT_DEFINED                    2
5586 +#define BP_BOARD_ID_NOT_SET                     3
5587 +
5588 +/* Values for BpGetSdramSize. */
5589 +#define BP_MEMORY_8MB_1_CHIP                    0
5590 +#define BP_MEMORY_16MB_1_CHIP                   1
5591 +#define BP_MEMORY_32MB_1_CHIP                   2
5592 +#define BP_MEMORY_64MB_2_CHIP                   3
5593 +#define BP_MEMORY_32MB_2_CHIP                   4
5594 +#define BP_MEMORY_16MB_2_CHIP                   5
5595 +
5596 +/* Values for EthernetMacInfo PhyType. */
5597 +#define BP_ENET_NO_PHY                          0
5598 +#define BP_ENET_INTERNAL_PHY                    1
5599 +#define BP_ENET_EXTERNAL_PHY                    2
5600 +#define BP_ENET_EXTERNAL_SWITCH                 3
5601 +
5602 +/* Values for EthernetMacInfo Configuration type. */
5603 +#define BP_ENET_CONFIG_MDIO                     0       /* Internal PHY, External PHY, Switch+(no GPIO, no SPI, no MDIO Pseudo phy */
5604 +#define BP_ENET_CONFIG_GPIO                     1       /* Bcm96345GW board + Bcm5325M/E */
5605 +#define BP_ENET_CONFIG_MDIO_PSEUDO_PHY          2       /* Bcm96348GW board + Bcm5325E */
5606 +#define BP_ENET_CONFIG_SPI_SSB_0                3       /* Bcm96348GW board + Bcm5325M/E */
5607 +#define BP_ENET_CONFIG_SPI_SSB_1                4       /* Bcm96348GW board + Bcm5325M/E */
5608 +#define BP_ENET_CONFIG_SPI_SSB_2                5       /* Bcm96348GW board + Bcm5325M/E */
5609 +#define BP_ENET_CONFIG_SPI_SSB_3                6       /* Bcm96348GW board + Bcm5325M/E */
5610 +
5611 +/* Values for EthernetMacInfo Reverse MII. */
5612 +#define BP_ENET_NO_REVERSE_MII                  0
5613 +#define BP_ENET_REVERSE_MII                     1
5614 +
5615 +/* Values for VoIPDSPInfo DSPType. */
5616 +#define BP_VOIP_NO_DSP                          0
5617 +#define BP_VOIP_DSP                             1
5618 +
5619 +
5620 +/* Values for GPIO pin assignments (AH = Active High, AL = Active Low). */
5621 +#define BP_ACTIVE_MASK                          0x8000
5622 +#define BP_ACTIVE_HIGH                          0x0000
5623 +#define BP_ACTIVE_LOW                           0x8000
5624 +#define BP_GPIO_0_AH                            (0  | BP_ACTIVE_HIGH)
5625 +#define BP_GPIO_0_AL                            (0  | BP_ACTIVE_LOW)
5626 +#define BP_GPIO_1_AH                            (1  | BP_ACTIVE_HIGH)
5627 +#define BP_GPIO_1_AL                            (1  | BP_ACTIVE_LOW)
5628 +#define BP_GPIO_2_AH                            (2  | BP_ACTIVE_HIGH)
5629 +#define BP_GPIO_2_AL                            (2  | BP_ACTIVE_LOW)
5630 +#define BP_GPIO_3_AH                            (3  | BP_ACTIVE_HIGH)
5631 +#define BP_GPIO_3_AL                            (3  | BP_ACTIVE_LOW)
5632 +#define BP_GPIO_4_AH                            (4  | BP_ACTIVE_HIGH)
5633 +#define BP_GPIO_4_AL                            (4  | BP_ACTIVE_LOW)
5634 +#define BP_GPIO_5_AH                            (5  | BP_ACTIVE_HIGH)
5635 +#define BP_GPIO_5_AL                            (5  | BP_ACTIVE_LOW)
5636 +#define BP_GPIO_6_AH                            (6  | BP_ACTIVE_HIGH)
5637 +#define BP_GPIO_6_AL                            (6  | BP_ACTIVE_LOW)
5638 +#define BP_GPIO_7_AH                            (7  | BP_ACTIVE_HIGH)
5639 +#define BP_GPIO_7_AL                            (7  | BP_ACTIVE_LOW)
5640 +#define BP_GPIO_8_AH                            (8  | BP_ACTIVE_HIGH)
5641 +#define BP_GPIO_8_AL                            (8  | BP_ACTIVE_LOW)
5642 +#define BP_GPIO_9_AH                            (9  | BP_ACTIVE_HIGH)
5643 +#define BP_GPIO_9_AL                            (9  | BP_ACTIVE_LOW)
5644 +#define BP_GPIO_10_AH                           (10 | BP_ACTIVE_HIGH)
5645 +#define BP_GPIO_10_AL                           (10 | BP_ACTIVE_LOW)
5646 +#define BP_GPIO_11_AH                           (11 | BP_ACTIVE_HIGH)
5647 +#define BP_GPIO_11_AL                           (11 | BP_ACTIVE_LOW)
5648 +#define BP_GPIO_12_AH                           (12 | BP_ACTIVE_HIGH)
5649 +#define BP_GPIO_12_AL                           (12 | BP_ACTIVE_LOW)
5650 +#define BP_GPIO_13_AH                           (13 | BP_ACTIVE_HIGH)
5651 +#define BP_GPIO_13_AL                           (13 | BP_ACTIVE_LOW)
5652 +#define BP_GPIO_14_AH                           (14 | BP_ACTIVE_HIGH)
5653 +#define BP_GPIO_14_AL                           (14 | BP_ACTIVE_LOW)
5654 +#define BP_GPIO_15_AH                           (15 | BP_ACTIVE_HIGH)
5655 +#define BP_GPIO_15_AL                           (15 | BP_ACTIVE_LOW)
5656 +#define BP_GPIO_16_AH                           (16 | BP_ACTIVE_HIGH)
5657 +#define BP_GPIO_16_AL                           (16 | BP_ACTIVE_LOW)
5658 +#define BP_GPIO_17_AH                           (17 | BP_ACTIVE_HIGH)
5659 +#define BP_GPIO_17_AL                           (17 | BP_ACTIVE_LOW)
5660 +#define BP_GPIO_18_AH                           (18 | BP_ACTIVE_HIGH)
5661 +#define BP_GPIO_18_AL                           (18 | BP_ACTIVE_LOW)
5662 +#define BP_GPIO_19_AH                           (19 | BP_ACTIVE_HIGH)
5663 +#define BP_GPIO_19_AL                           (19 | BP_ACTIVE_LOW)
5664 +#define BP_GPIO_20_AH                           (20 | BP_ACTIVE_HIGH)
5665 +#define BP_GPIO_20_AL                           (20 | BP_ACTIVE_LOW)
5666 +#define BP_GPIO_21_AH                           (21 | BP_ACTIVE_HIGH)
5667 +#define BP_GPIO_21_AL                           (21 | BP_ACTIVE_LOW)
5668 +#define BP_GPIO_22_AH                           (22 | BP_ACTIVE_HIGH)
5669 +#define BP_GPIO_22_AL                           (22 | BP_ACTIVE_LOW)
5670 +#define BP_GPIO_23_AH                           (23 | BP_ACTIVE_HIGH)
5671 +#define BP_GPIO_23_AL                           (23 | BP_ACTIVE_LOW)
5672 +#define BP_GPIO_24_AH                           (24 | BP_ACTIVE_HIGH)
5673 +#define BP_GPIO_24_AL                           (24 | BP_ACTIVE_LOW)
5674 +#define BP_GPIO_25_AH                           (25 | BP_ACTIVE_HIGH)
5675 +#define BP_GPIO_25_AL                           (25 | BP_ACTIVE_LOW)
5676 +#define BP_GPIO_26_AH                           (26 | BP_ACTIVE_HIGH)
5677 +#define BP_GPIO_26_AL                           (26 | BP_ACTIVE_LOW)
5678 +#define BP_GPIO_27_AH                           (27 | BP_ACTIVE_HIGH)
5679 +#define BP_GPIO_27_AL                           (27 | BP_ACTIVE_LOW)
5680 +#define BP_GPIO_28_AH                           (28 | BP_ACTIVE_HIGH)
5681 +#define BP_GPIO_28_AL                           (28 | BP_ACTIVE_LOW)
5682 +#define BP_GPIO_29_AH                           (29 | BP_ACTIVE_HIGH)
5683 +#define BP_GPIO_29_AL                           (29 | BP_ACTIVE_LOW)
5684 +#define BP_GPIO_30_AH                           (30 | BP_ACTIVE_HIGH)
5685 +#define BP_GPIO_30_AL                           (30 | BP_ACTIVE_LOW)
5686 +#define BP_GPIO_31_AH                           (31 | BP_ACTIVE_HIGH)
5687 +#define BP_GPIO_31_AL                           (31 | BP_ACTIVE_LOW)
5688 +#define BP_GPIO_32_AH                           (32 | BP_ACTIVE_HIGH)
5689 +#define BP_GPIO_32_AL                           (32 | BP_ACTIVE_LOW)
5690 +#define BP_GPIO_33_AH                           (33 | BP_ACTIVE_HIGH)
5691 +#define BP_GPIO_33_AL                           (33 | BP_ACTIVE_LOW)
5692 +#define BP_GPIO_34_AH                           (34 | BP_ACTIVE_HIGH)
5693 +#define BP_GPIO_34_AL                           (34 | BP_ACTIVE_LOW)
5694 +#define BP_GPIO_35_AH                           (35 | BP_ACTIVE_HIGH)
5695 +#define BP_GPIO_35_AL                           (35 | BP_ACTIVE_LOW)
5696 +#define BP_GPIO_36_AH                           (36 | BP_ACTIVE_HIGH)
5697 +#define BP_GPIO_36_AL                           (36 | BP_ACTIVE_LOW)
5698 +
5699 +/* Values for external interrupt assignments. */
5700 +#define BP_EXT_INTR_0                           0
5701 +#define BP_EXT_INTR_1                           1
5702 +#define BP_EXT_INTR_2                           2
5703 +#define BP_EXT_INTR_3                           3
5704 +
5705 +/* Values for chip select assignments. */
5706 +#define BP_CS_0                                 0
5707 +#define BP_CS_1                                 1
5708 +#define BP_CS_2                                 2
5709 +#define BP_CS_3                                 3
5710 +
5711 +/* Value for GPIO and external interrupt fields that are not used. */
5712 +#define BP_NOT_DEFINED                          0xffff
5713 +#define BP_HW_DEFINED                           0xfff0
5714 +#define BP_UNEQUIPPED                           0xfff1
5715 +
5716 +/* Maximum size of the board id string. */
5717 +#define BP_BOARD_ID_LEN                         16
5718 +
5719 +/* Maximum number of Ethernet MACs. */
5720 +#define BP_MAX_ENET_MACS                        2
5721 +
5722 +/* Maximum number of VoIP DSPs. */
5723 +#define BP_MAX_VOIP_DSP                         2
5724 +
5725 +/* Wireless Antenna Settings. */
5726 +#define BP_WLAN_ANT_MAIN                        0
5727 +#define BP_WLAN_ANT_AUX                         1
5728 +#define BP_WLAN_ANT_BOTH                        3
5729 +
5730 +#if !defined(__ASSEMBLER__)
5731 +
5732 +/* Information about an Ethernet MAC.  If ucPhyType is BP_ENET_NO_PHY,
5733 + * then the other fields are not valid.
5734 + */
5735 +typedef struct EthernetMacInfo
5736 +{
5737 +    unsigned char ucPhyType;                    /* BP_ENET_xxx             */
5738 +    unsigned char ucPhyAddress;                 /* 0 to 31                 */
5739 +    unsigned short usGpioPhySpiSck;             /* GPIO pin or not defined */
5740 +    unsigned short usGpioPhySpiSs;              /* GPIO pin or not defined */
5741 +    unsigned short usGpioPhySpiMosi;            /* GPIO pin or not defined */
5742 +    unsigned short usGpioPhySpiMiso;            /* GPIO pin or not defined */
5743 +    unsigned short usGpioPhyReset;              /* GPIO pin or not defined (96348LV) */
5744 +    unsigned short numSwitchPorts;              /* Number of PHY ports */
5745 +    unsigned short usConfigType;                /* Configuration type */
5746 +    unsigned short usReverseMii;                /* Reverse MII */
5747 +} ETHERNET_MAC_INFO, *PETHERNET_MAC_INFO;
5748 +
5749 +
5750 +/* Information about VoIP DSPs.  If ucDspType is BP_VOIP_NO_DSP,
5751 + * then the other fields are not valid.
5752 + */
5753 +typedef struct VoIPDspInfo
5754 +{
5755 +    unsigned char  ucDspType;
5756 +    unsigned char  ucDspAddress;
5757 +    unsigned short usExtIntrVoip;
5758 +    unsigned short usGpioVoipReset;
5759 +    unsigned short usGpioVoipIntr;
5760 +    unsigned short usGpioLedVoip;
5761 +    unsigned short usCsVoip;
5762 +
5763 +} VOIP_DSP_INFO;
5764 +
5765 +
5766 +/**************************************************************************
5767 + * Name       : BpSetBoardId
5768 + *
5769 + * Description: This function find the BOARD_PARAMETERS structure for the
5770 + *              specified board id string and assigns it to a global, static
5771 + *              variable.
5772 + *
5773 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
5774 + *
5775 + * Returns    : BP_SUCCESS - Success, value is returned.
5776 + *              BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
5777 + *                  have a board parameters configuration record.
5778 + ***************************************************************************/
5779 +int BpSetBoardId( char *pszBoardId );
5780 +
5781 +/**************************************************************************
5782 + * Name       : BpGetBoardIds
5783 + *
5784 + * Description: This function returns all of the supported board id strings.
5785 + *
5786 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
5787 + *                  strings are returned in.  Each id starts at BP_BOARD_ID_LEN
5788 + *                  boundary.
5789 + *              [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
5790 + *                  were allocated in pszBoardIds.
5791 + *
5792 + * Returns    : Number of board id strings returned.
5793 + ***************************************************************************/
5794 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize );
5795 +
5796 +/**************************************************************************
5797 + * Name       : BpGetEthernetMacInfo
5798 + *
5799 + * Description: This function returns all of the supported board id strings.
5800 + *
5801 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
5802 + *                  buffers.
5803 + *              [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
5804 + *                  are pointed to by pEnetInfos.
5805 + *
5806 + * Returns    : BP_SUCCESS - Success, value is returned.
5807 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5808 + ***************************************************************************/
5809 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos );
5810 +
5811 +/**************************************************************************
5812 + * Name       : BpGetSdramSize
5813 + *
5814 + * Description: This function returns a constant that describees the board's
5815 + *              SDRAM type and size.
5816 + *
5817 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
5818 + *                  is returned in.
5819 + *
5820 + * Returns    : BP_SUCCESS - Success, value is returned.
5821 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5822 + ***************************************************************************/
5823 +int BpGetSdramSize( unsigned long *pulSdramSize );
5824 +
5825 +/**************************************************************************
5826 + * Name       : BpGetPsiSize
5827 + *
5828 + * Description: This function returns the persistent storage size in K bytes.
5829 + *
5830 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
5831 + *                  storage size is returned in.
5832 + *
5833 + * Returns    : BP_SUCCESS - Success, value is returned.
5834 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5835 + ***************************************************************************/
5836 +int BpGetPsiSize( unsigned long *pulPsiSize );
5837 +
5838 +/**************************************************************************
5839 + * Name       : BpGetRj11InnerOuterPairGpios
5840 + *
5841 + * Description: This function returns the GPIO pin assignments for changing
5842 + *              between the RJ11 inner pair and RJ11 outer pair.
5843 + *
5844 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
5845 + *                  GPIO pin is returned in.
5846 + *              [OUT] pusOuter - Address of short word that the RJ11 outer pair
5847 + *                  GPIO pin is returned in.
5848 + *
5849 + * Returns    : BP_SUCCESS - Success, values are returned.
5850 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5851 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5852 + *                  for the board.
5853 + ***************************************************************************/
5854 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
5855 +    unsigned short *pusOuter );
5856 +
5857 +/**************************************************************************
5858 + * Name       : BpGetPressAndHoldResetGpio
5859 + *
5860 + * Description: This function returns the GPIO pin assignment for the press
5861 + *              and hold reset button.
5862 + *
5863 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
5864 + *                  reset button GPIO pin is returned in.
5865 + *
5866 + * Returns    : BP_SUCCESS - Success, value is returned.
5867 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5868 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5869 + *                  for the board.
5870 + ***************************************************************************/
5871 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue );
5872 +
5873 +/**************************************************************************
5874 + * Name       : BpGetVoipResetGpio
5875 + *
5876 + * Description: This function returns the GPIO pin assignment for the VOIP
5877 + *              Reset operation.
5878 + *
5879 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
5880 + *                  GPIO pin is returned in.
5881 + *              [IN] dspNum - Address of the DSP to query.
5882 + *
5883 + * Returns    : BP_SUCCESS - Success, value is returned.
5884 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5885 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5886 + *                  for the board.
5887 + ***************************************************************************/
5888 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue );
5889 +
5890 +/**************************************************************************
5891 + * Name       : BpGetVoipIntrGpio
5892 + *
5893 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
5894 + *
5895 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
5896 + *                  GPIO pin is returned in.
5897 + *              [IN] dspNum - Address of the DSP to query.
5898 + *
5899 + * Returns    : BP_SUCCESS - Success, value is returned.
5900 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5901 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5902 + *                  for the board.
5903 + ***************************************************************************/
5904 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue );
5905 +
5906 +/**************************************************************************
5907 + * Name       : BpGetPcmciaResetGpio
5908 + *
5909 + * Description: This function returns the GPIO pin assignment for the PCMCIA
5910 + *              Reset operation.
5911 + *
5912 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
5913 + *                  GPIO pin is returned in.
5914 + *
5915 + * Returns    : BP_SUCCESS - Success, value is returned.
5916 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5917 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5918 + *                  for the board.
5919 + ***************************************************************************/
5920 +int BpGetPcmciaResetGpio( unsigned short *pusValue );
5921 +
5922 +/**************************************************************************
5923 + * Name       : BpGetUartRtsCtsGpios
5924 + *
5925 + * Description: This function returns the GPIO pin assignments for RTS and CTS
5926 + *              UART signals.
5927 + *
5928 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
5929 + *                  pin is returned in.
5930 + *              [OUT] pusCts - Address of short word that the UART CTS GPIO
5931 + *                  pin is returned in.
5932 + *
5933 + * Returns    : BP_SUCCESS - Success, values are returned.
5934 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5935 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5936 + *                  for the board.
5937 + ***************************************************************************/
5938 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts );
5939 +
5940 +/**************************************************************************
5941 + * Name       : BpGetAdslLedGpio
5942 + *
5943 + * Description: This function returns the GPIO pin assignment for the ADSL
5944 + *              LED.
5945 + *
5946 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5947 + *                  GPIO pin is returned in.
5948 + *
5949 + * Returns    : BP_SUCCESS - Success, value is returned.
5950 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5951 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5952 + *                  for the board.
5953 + ***************************************************************************/
5954 +int BpGetAdslLedGpio( unsigned short *pusValue );
5955 +
5956 +/**************************************************************************
5957 + * Name       : BpGetAdslFailLedGpio
5958 + *
5959 + * Description: This function returns the GPIO pin assignment for the ADSL
5960 + *              LED that is used when there is a DSL connection failure.
5961 + *
5962 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5963 + *                  GPIO pin is returned in.
5964 + *
5965 + * Returns    : BP_SUCCESS - Success, value is returned.
5966 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5967 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5968 + *                  for the board.
5969 + ***************************************************************************/
5970 +int BpGetAdslFailLedGpio( unsigned short *pusValue );
5971 +
5972 +/**************************************************************************
5973 + * Name       : BpGetWirelessLedGpio
5974 + *
5975 + * Description: This function returns the GPIO pin assignment for the Wireless
5976 + *              LED.
5977 + *
5978 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
5979 + *                  GPIO pin is returned in.
5980 + *
5981 + * Returns    : BP_SUCCESS - Success, value is returned.
5982 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5983 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5984 + *                  for the board.
5985 + ***************************************************************************/
5986 +int BpGetWirelessLedGpio( unsigned short *pusValue );
5987 +
5988 +/**************************************************************************
5989 + * Name       : BpGetWirelessAntInUse
5990 + *
5991 + * Description: This function returns the antennas in use for wireless
5992 + *
5993 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
5994 + *                  is in use.
5995 + *
5996 + * Returns    : BP_SUCCESS - Success, value is returned.
5997 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5998 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
5999 + *                  for the board.
6000 + ***************************************************************************/
6001 +int BpGetWirelessAntInUse( unsigned short *pusValue );
6002 +
6003 +/**************************************************************************
6004 + * Name       : BpGetWirelessSesBtnGpio
6005 + *
6006 + * Description: This function returns the GPIO pin assignment for the Wireless
6007 + *              Ses Button.
6008 + *
6009 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6010 + *                  Button GPIO pin is returned in.
6011 + *
6012 + * Returns    : BP_SUCCESS - Success, value is returned.
6013 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6014 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6015 + *                  for the board.
6016 + ***************************************************************************/
6017 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue );
6018 +
6019 +/**************************************************************************
6020 + * Name       : BpGetWirelessSesExtIntr
6021 + *
6022 + * Description: This function returns the external interrupt number for the 
6023 + *              Wireless Ses Button.
6024 + *
6025 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6026 + *                  external interrup is returned in.
6027 + *
6028 + * Returns    : BP_SUCCESS - Success, value is returned.
6029 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6030 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6031 + *                  for the board.
6032 + ***************************************************************************/
6033 +int BpGetWirelessSesExtIntr( unsigned short *pusValue );
6034 +
6035 +/**************************************************************************
6036 + * Name       : BpGetWirelessSesLedGpio
6037 + *
6038 + * Description: This function returns the GPIO pin assignment for the Wireless
6039 + *              Ses Led.
6040 + *
6041 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6042 + *                  Led GPIO pin is returned in.
6043 + *
6044 + * Returns    : BP_SUCCESS - Success, value is returned.
6045 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6046 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6047 + *                  for the board.
6048 + ***************************************************************************/
6049 +int BpGetWirelessSesLedGpio( unsigned short *pusValue );
6050 +
6051 +/**************************************************************************
6052 + * Name       : BpGetUsbLedGpio
6053 + *
6054 + * Description: This function returns the GPIO pin assignment for the USB
6055 + *              LED.
6056 + *
6057 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
6058 + *                  GPIO pin is returned in.
6059 + *
6060 + * Returns    : BP_SUCCESS - Success, value is returned.
6061 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6062 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6063 + *                  for the board.
6064 + ***************************************************************************/
6065 +int BpGetUsbLedGpio( unsigned short *pusValue );
6066 +
6067 +/**************************************************************************
6068 + * Name       : BpGetHpnaLedGpio
6069 + *
6070 + * Description: This function returns the GPIO pin assignment for the HPNA
6071 + *              LED.
6072 + *
6073 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
6074 + *                  GPIO pin is returned in.
6075 + *
6076 + * Returns    : BP_SUCCESS - Success, value is returned.
6077 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6078 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6079 + *                  for the board.
6080 + ***************************************************************************/
6081 +int BpGetHpnaLedGpio( unsigned short *pusValue );
6082 +
6083 +/**************************************************************************
6084 + * Name       : BpGetWanDataLedGpio
6085 + *
6086 + * Description: This function returns the GPIO pin assignment for the WAN Data
6087 + *              LED.
6088 + *
6089 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
6090 + *                  GPIO pin is returned in.
6091 + *
6092 + * Returns    : BP_SUCCESS - Success, value is returned.
6093 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6094 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6095 + *                  for the board.
6096 + ***************************************************************************/
6097 +int BpGetWanDataLedGpio( unsigned short *pusValue );
6098 +
6099 +/**************************************************************************
6100 + * Name       : BpGetPppLedGpio
6101 + *
6102 + * Description: This function returns the GPIO pin assignment for the PPP
6103 + *              LED.
6104 + *
6105 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
6106 + *                  GPIO pin is returned in.
6107 + *
6108 + * Returns    : BP_SUCCESS - Success, value is returned.
6109 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6110 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6111 + *                  for the board.
6112 + ***************************************************************************/
6113 +int BpGetPppLedGpio( unsigned short *pusValue );
6114 +
6115 +/**************************************************************************
6116 + * Name       : BpGetPppFailLedGpio
6117 + *
6118 + * Description: This function returns the GPIO pin assignment for the PPP
6119 + *              LED that is used when there is a PPP connection failure.
6120 + *
6121 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
6122 + *                  GPIO pin is returned in.
6123 + *
6124 + * Returns    : BP_SUCCESS - Success, value is returned.
6125 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6126 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6127 + *                  for the board.
6128 + ***************************************************************************/
6129 +int BpGetPppFailLedGpio( unsigned short *pusValue );
6130 +
6131 +/**************************************************************************
6132 + * Name       : BpGetVoipLedGpio
6133 + *
6134 + * Description: This function returns the GPIO pin assignment for the VOIP
6135 + *              LED.
6136 + *
6137 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
6138 + *                  GPIO pin is returned in.
6139 + *
6140 + * Returns    : BP_SUCCESS - Success, value is returned.
6141 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6142 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6143 + *                  for the board.
6144 + ***************************************************************************/
6145 +int BpGetVoipLedGpio( unsigned short *pusValue );
6146 +
6147 +/**************************************************************************
6148 + * Name       : BpGetBootloaderPowerOnLedGpio
6149 + *
6150 + * Description: This function returns the GPIO pin assignment for the power
6151 + *              on LED that is set by the bootloader.
6152 + *
6153 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6154 + *                  GPIO pin is returned in.
6155 + *
6156 + * Returns    : BP_SUCCESS - Success, value is returned.
6157 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6158 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6159 + *                  for the board.
6160 + ***************************************************************************/
6161 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue );
6162 +
6163 +/**************************************************************************
6164 + * Name       : BpGetBootloaderAlarmLedGpio
6165 + *
6166 + * Description: This function returns the GPIO pin assignment for the alarm
6167 + *              LED that is set by the bootloader.
6168 + *
6169 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6170 + *                  GPIO pin is returned in.
6171 + *
6172 + * Returns    : BP_SUCCESS - Success, value is returned.
6173 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6174 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6175 + *                  for the board.
6176 + ***************************************************************************/
6177 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue );
6178 +
6179 +/**************************************************************************
6180 + * Name       : BpGetBootloaderResetCfgLedGpio
6181 + *
6182 + * Description: This function returns the GPIO pin assignment for the reset
6183 + *              configuration LED that is set by the bootloader.
6184 + *
6185 + * Parameters : [OUT] pusValue - Address of short word that the reset
6186 + *                  configuration LED GPIO pin is returned in.
6187 + *
6188 + * Returns    : BP_SUCCESS - Success, value is returned.
6189 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6190 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6191 + *                  for the board.
6192 + ***************************************************************************/
6193 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue );
6194 +
6195 +/**************************************************************************
6196 + * Name       : BpGetBootloaderStopLedGpio
6197 + *
6198 + * Description: This function returns the GPIO pin assignment for the break
6199 + *              into bootloader LED that is set by the bootloader.
6200 + *
6201 + * Parameters : [OUT] pusValue - Address of short word that the break into
6202 + *                  bootloader LED GPIO pin is returned in.
6203 + *
6204 + * Returns    : BP_SUCCESS - Success, value is returned.
6205 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6206 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6207 + *                  for the board.
6208 + ***************************************************************************/
6209 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue );
6210 +
6211 +/**************************************************************************
6212 + * Name       : BpGetWirelessExtIntr
6213 + *
6214 + * Description: This function returns the Wireless external interrupt number.
6215 + *
6216 + * Parameters : [OUT] pulValue - Address of short word that the wireless
6217 + *                  external interrupt number is returned in.
6218 + *
6219 + * Returns    : BP_SUCCESS - Success, value is returned.
6220 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6221 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6222 + *                  for the board.
6223 + ***************************************************************************/
6224 +int BpGetWirelessExtIntr( unsigned long *pulValue );
6225 +
6226 +/**************************************************************************
6227 + * Name       : BpGetAdslDyingGaspExtIntr
6228 + *
6229 + * Description: This function returns the ADSL Dying Gasp external interrupt
6230 + *              number.
6231 + *
6232 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
6233 + *                  external interrupt number is returned in.
6234 + *
6235 + * Returns    : BP_SUCCESS - Success, value is returned.
6236 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6237 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6238 + *                  for the board.
6239 + ***************************************************************************/
6240 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue );
6241 +
6242 +/**************************************************************************
6243 + * Name       : BpGetVoipExtIntr
6244 + *
6245 + * Description: This function returns the VOIP external interrupt number.
6246 + *
6247 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6248 + *                  external interrupt number is returned in.
6249 + *              [IN] dspNum - Address of the DSP to query.
6250 + *
6251 + * Returns    : BP_SUCCESS - Success, value is returned.
6252 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6253 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6254 + *                  for the board.
6255 + ***************************************************************************/
6256 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue );
6257 +
6258 +/**************************************************************************
6259 + * Name       : BpGetHpnaExtIntr
6260 + *
6261 + * Description: This function returns the HPNA external interrupt number.
6262 + *
6263 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6264 + *                  external interrupt number is returned in.
6265 + *
6266 + * Returns    : BP_SUCCESS - Success, value is returned.
6267 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6268 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6269 + *                  for the board.
6270 + ***************************************************************************/
6271 +int BpGetHpnaExtIntr( unsigned long *pulValue );
6272 +
6273 +/**************************************************************************
6274 + * Name       : BpGetHpnaChipSelect
6275 + *
6276 + * Description: This function returns the HPNA chip select number.
6277 + *
6278 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6279 + *                  chip select number is returned in.
6280 + *
6281 + * Returns    : BP_SUCCESS - Success, value is returned.
6282 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6283 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6284 + *                  for the board.
6285 + ***************************************************************************/
6286 +int BpGetHpnaChipSelect( unsigned long *pulValue );
6287 +
6288 +/**************************************************************************
6289 + * Name       : BpGetVoipChipSelect
6290 + *
6291 + * Description: This function returns the VOIP chip select number.
6292 + *
6293 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6294 + *                  chip select number is returned in.
6295 + *              [IN] dspNum - Address of the DSP to query.
6296 + *
6297 + * Returns    : BP_SUCCESS - Success, value is returned.
6298 + *              BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6299 + *              BP_VALUE_NOT_DEFINED - At least one return value is not defined
6300 + *                  for the board.
6301 + ***************************************************************************/
6302 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue );
6303 +
6304 +#endif /* __ASSEMBLER__ */
6305 +
6306 +#endif /* _BOARDPARMS_H */
6307 +
6308 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c
6309 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c      1970-01-01 01:00:00.000000000 +0100
6310 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c     2006-08-03 16:36:58.000000000 +0200
6311 @@ -0,0 +1,692 @@
6312 +/************************************************************************/
6313 +/*                                                                      */
6314 +/*  AMD CFI Enabled Flash Memory Drivers                                */
6315 +/*  File name: CFIFLASH.C                                               */
6316 +/*  Revision:  1.0  5/07/98                                             */
6317 +/*                                                                      */
6318 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6319 +/* This software is unpublished and contains the trade secrets and      */
6320 +/* confidential proprietary information of AMD. Unless otherwise        */
6321 +/* provided in the Software Agreement associated herewith, it is        */
6322 +/* licensed in confidence "AS IS" and is not to be reproduced in whole  */
6323 +/* or part by any means except for backup. Use, duplication, or         */
6324 +/* disclosure by the Government is subject to the restrictions in       */
6325 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer   */
6326 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988).                  */
6327 +/* Software owned by                                                    */
6328 +/* Advanced Micro Devices, Inc.,                                        */
6329 +/* One AMD Place,                                                       */
6330 +/* P.O. Box 3453                                                        */
6331 +/* Sunnyvale, CA 94088-3453.                                            */
6332 +/************************************************************************/
6333 +/*  This software constitutes a basic shell of source code for          */
6334 +/*  programming all AMD Flash components. AMD                           */
6335 +/*  will not be responsible for misuse or illegal use of this           */
6336 +/*  software for devices not supported herein. AMD is providing         */
6337 +/*  this source code "AS IS" and will not be responsible for            */
6338 +/*  issues arising from incorrect user implementation of the            */
6339 +/*  source code herein. It is the user's responsibility to              */
6340 +/*  properly design-in this source code.                                */
6341 +/*                                                                      */ 
6342 +/************************************************************************/                        
6343 +#ifdef _CFE_                                                
6344 +#include "lib_types.h"
6345 +#include "lib_printf.h"
6346 +#include "lib_string.h"
6347 +#include "cfe_timer.h"
6348 +#define printk  printf
6349 +#else       // linux
6350 +#include <linux/param.h>
6351 +#include <linux/sched.h>
6352 +#include <linux/timer.h>
6353 +#endif
6354 +
6355 +#include "cfiflash.h"
6356 +
6357 +static int flash_wait(WORD sector, int offset, UINT16 data);
6358 +static UINT16 flash_get_device_id(void);
6359 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily);
6360 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes);
6361 +static void flash_command(int command, WORD sector, int offset, UINT16 data);
6362 +
6363 +/*********************************************************************/
6364 +/* 'meminfo' should be a pointer, but most C compilers will not      */
6365 +/* allocate static storage for a pointer without calling             */
6366 +/* non-portable functions such as 'new'.  We also want to avoid      */
6367 +/* the overhead of passing this pointer for every driver call.       */
6368 +/* Systems with limited heap space will need to do this.             */
6369 +/*********************************************************************/
6370 +struct flashinfo meminfo; /* Flash information structure */
6371 +static int flashFamily = FLASH_UNDEFINED;
6372 +static int totalSize = 0;
6373 +static struct cfi_query query;
6374 +
6375 +static UINT16 cfi_data_struct_29W160[] = {
6376 +    0x0020, 0x0049, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6377 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6378 +    0x0051, 0x0052, 0x0059, 0x0002, 0x0000, 0x0040, 0x0000, 0x0000,
6379 +    0x0000, 0x0000, 0x0000, 0x0027, 0x0036, 0x0000, 0x0000, 0x0004,
6380 +    0x0000, 0x000a, 0x0000, 0x0004, 0x0000, 0x0003, 0x0000, 0x0015,
6381 +    0x0002, 0x0000, 0x0000, 0x0000, 0x0004, 0x0000, 0x0000, 0x0040,
6382 +    0x0000, 0x0001, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0080,
6383 +    0x0000, 0x001e, 0x0000, 0x0000, 0x0001, 0xffff, 0xffff, 0xffff,
6384 +    0x0050, 0x0052, 0x0049, 0x0031, 0x0030, 0x0000, 0x0002, 0x0001,
6385 +    0x0001, 0x0004, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0002,
6386 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6387 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6388 +    0xffff, 0x0888, 0x252b, 0x8c84, 0x7dbc, 0xffff, 0xffff, 0xffff,
6389 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6390 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6391 +    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
6392 +};
6393 +
6394 +
6395 +/*********************************************************************/
6396 +/* Init_flash is used to build a sector table from the information   */
6397 +/* provided through the CFI query.  This information is translated   */
6398 +/* from erase_block information to base:offset information for each  */
6399 +/* individual sector. This information is then stored in the meminfo */
6400 +/* structure, and used throughout the driver to access sector        */
6401 +/* information.                                                      */
6402 +/*                                                                   */
6403 +/* This is more efficient than deriving the sector base:offset       */
6404 +/* information every time the memory map switches (since on the      */
6405 +/* development platform can only map 64k at a time).  If the entire  */
6406 +/* flash memory array can be mapped in, then the addition static     */
6407 +/* allocation for the meminfo structure can be eliminated, but the   */
6408 +/* drivers will have to be re-written.                               */
6409 +/*                                                                   */
6410 +/* The meminfo struct occupies 653 bytes of heap space, depending    */
6411 +/* on the value of the define MAXSECTORS.  Adjust to suit            */
6412 +/* application                                                       */ 
6413 +/*********************************************************************/
6414 +byte flash_init(void)
6415 +{
6416 +    int i=0, j=0, count=0;
6417 +    int basecount=0L;
6418 +    UINT16 device_id;
6419 +    int flipCFIGeometry = FALSE;
6420 +
6421 +    /* First, assume
6422 +    * a single 8k sector for sector 0.  This is to allow
6423 +    * the system to perform memory mapping to the device,
6424 +    * even though the actual physical layout is unknown.
6425 +    * Once mapped in, the CFI query will produce all
6426 +    * relevant information.
6427 +    */
6428 +    meminfo.addr = 0L;
6429 +    meminfo.areg = 0;
6430 +    meminfo.nsect = 1;
6431 +    meminfo.bank1start = 0;
6432 +    meminfo.bank2start = 0;
6433 +    
6434 +    meminfo.sec[0].size = 8192;
6435 +    meminfo.sec[0].base = 0x00000;
6436 +    meminfo.sec[0].bank = 1;
6437 +        
6438 +    flash_command(FLASH_RESET, 0, 0, 0);
6439 +
6440 +    device_id = flash_get_device_id();
6441 +
6442 +    switch (device_id) {
6443 +        case ID_I28F160C3B:
6444 +        case ID_I28F320C3B:
6445 +        case ID_I28F160C3T:
6446 +        case ID_I28F320C3T:
6447 +            flashFamily = FLASH_INTEL;
6448 +            break;
6449 +        case ID_AM29DL800B:
6450 +        case ID_AM29LV800B:
6451 +        case ID_AM29LV400B:   
6452 +        case ID_AM29LV160B:
6453 +        case ID_AM29LV320B:
6454 +        case ID_MX29LV320AB:
6455 +        case ID_AM29LV320MB:
6456 +        case ID_AM29DL800T:
6457 +        case ID_AM29LV800T:
6458 +        case ID_AM29LV160T:
6459 +        case ID_AM29LV320T:
6460 +        case ID_MX29LV320AT:
6461 +        case ID_AM29LV320MT:
6462 +            flashFamily = FLASH_AMD;
6463 +            break;
6464 +        case ID_SST39VF1601:
6465 +               case ID_SST39VF3201:
6466 +            flashFamily = FLASH_SST;
6467 +            break;
6468 +        default:
6469 +            printk("Flash memory not supported!  Device id = %x\n", device_id);
6470 +            return -1;           
6471 +    }
6472 +
6473 +    if (flash_get_cfi(&query, 0, flashFamily) == -1) {
6474 +        switch(device_id) {
6475 +        case ID_AM29LV160T:
6476 +        case ID_AM29LV160B:
6477 +            flash_get_cfi(&query, cfi_data_struct_29W160, flashFamily);
6478 +            break;
6479 +        default:
6480 +            printk("CFI data structure not found. Device id = %x\n", device_id);
6481 +            return -1;           
6482 +        }
6483 +    }
6484 +
6485 +    // need to determine if it top or bottom boot here
6486 +    switch (device_id)
6487 +    {
6488 +        case ID_AM29DL800B:
6489 +        case ID_AM29LV800B:
6490 +        case ID_AM29LV400B:   
6491 +        case ID_AM29LV160B:
6492 +        case ID_AM29LV320B:
6493 +        case ID_MX29LV320AB:
6494 +        case ID_AM29LV320MB:
6495 +        case ID_I28F160C3B:
6496 +        case ID_I28F320C3B:
6497 +        case ID_I28F160C3T:
6498 +        case ID_I28F320C3T:
6499 +               case ID_SST39VF1601:
6500 +               case ID_SST39VF3201:
6501 +            flipCFIGeometry = FALSE;
6502 +            break;
6503 +        case ID_AM29DL800T:
6504 +        case ID_AM29LV800T:
6505 +        case ID_AM29LV160T:
6506 +        case ID_AM29LV320T:
6507 +        case ID_MX29LV320AT:
6508 +        case ID_AM29LV320MT:
6509 +            flipCFIGeometry = TRUE;
6510 +            break;
6511 +        default:
6512 +            printk("Flash memory not supported!  Device id = %x\n", device_id);
6513 +            return -1;           
6514 +    }
6515 +
6516 +    count=0;basecount=0L;
6517 +
6518 +    if (!flipCFIGeometry)
6519 +    {
6520 +       for (i=0; i<query.num_erase_blocks; i++) {
6521 +            for(j=0; j<query.erase_block[i].num_sectors; j++) {
6522 +                meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6523 +                meminfo.sec[count].base = (int) basecount;
6524 +                basecount += (int) query.erase_block[i].sector_size;
6525 +                count++;
6526 +            }
6527 +        }
6528 +    }
6529 +    else
6530 +    {
6531 +        for (i = (query.num_erase_blocks - 1); i >= 0; i--) {
6532 +            for(j=0; j<query.erase_block[i].num_sectors; j++) {
6533 +                meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6534 +                meminfo.sec[count].base = (int) basecount;
6535 +                basecount += (int) query.erase_block[i].sector_size;
6536 +                               count++;
6537 +            }
6538 +        }
6539 +    }
6540 +
6541 +    meminfo.nsect = count;
6542 +    totalSize = meminfo.sec[count-1].base + meminfo.sec[count-1].size;
6543 +    return (0);
6544 +}
6545 +
6546 +/*********************************************************************/
6547 +/* Flash_sector_erase_int() is identical to flash_sector_erase(),    */
6548 +/* except it will wait until the erase is completed before returning */
6549 +/* control to the calling function.  This can be used in cases which */
6550 +/* require the program to hold until a sector is erased, without     */
6551 +/* adding the wait check external to this function.                  */
6552 +/*********************************************************************/
6553 +byte flash_sector_erase_int(WORD sector)
6554 +{
6555 +    int i;
6556 +
6557 +    for( i = 0; i < 3; i++ ) {
6558 +        flash_command(FLASH_SERASE, sector, 0, 0);
6559 +        if (flash_wait(sector, 0, 0xffff) == STATUS_READY)
6560 +            break;
6561 +    }
6562 +
6563 +    return(1);
6564 +}
6565 +
6566 +/*********************************************************************/
6567 +/* flash_read_buf() reads buffer of data from the specified          */
6568 +/* offset from the sector parameter.                                 */
6569 +/*********************************************************************/
6570 +int flash_read_buf(WORD sector, int offset,
6571 +                        byte *buffer, int numbytes)
6572 +{
6573 +    byte *fwp;
6574 +
6575 +    fwp = (byte *)flash_get_memptr(sector);
6576 +
6577 +       while (numbytes) {
6578 +               *buffer++ = *(fwp + offset);
6579 +               numbytes--;
6580 +               fwp++;
6581 +    }
6582 +
6583 +    return (1);
6584 +}
6585 +
6586 +/*********************************************************************/
6587 +/* flash_write_buf() utilizes                                        */
6588 +/* the unlock bypass mode of the flash device.  This can remove      */
6589 +/* significant overhead from the bulk programming operation, and     */
6590 +/* when programming bulk data a sizeable performance increase can be */
6591 +/* observed.                                                         */
6592 +/*********************************************************************/
6593 +int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes)
6594 +{
6595 +    int ret = -1;
6596 +    int i;
6597 +    unsigned char *p = flash_get_memptr(sector) + offset;
6598 +
6599 +    /* After writing the flash block, compare the contents to the source
6600 +     * buffer.  Try to write the sector successfully up to three times.
6601 +     */
6602 +    for( i = 0; i < 3; i++ ) {
6603 +        ret = flash_write(sector, offset, buffer, numbytes);
6604 +        if( !memcmp( p, buffer, numbytes ) )
6605 +            break;
6606 +        /* Erase and try again */
6607 +        flash_sector_erase_int(sector);
6608 +        ret = -1;
6609 +    }
6610 +
6611 +    if( ret == -1 )
6612 +        printk( "Flash write error.  Verify failed\n" );
6613 +
6614 +    return( ret );
6615 +}
6616 +
6617 +/*********************************************************************/
6618 +/* Usefull funtion to return the number of sectors in the device.    */
6619 +/* Can be used for functions which need to loop among all the        */
6620 +/* sectors, or wish to know the number of the last sector.           */
6621 +/*********************************************************************/
6622 +int flash_get_numsectors(void)
6623 +{
6624 +    return meminfo.nsect;
6625 +}
6626 +
6627 +/*********************************************************************/
6628 +/* flash_get_sector_size() is provided for cases in which the size   */
6629 +/* of a sector is required by a host application.  The sector size   */
6630 +/* (in bytes) is returned in the data location pointed to by the     */
6631 +/* 'size' parameter.                                                 */
6632 +/*********************************************************************/
6633 +int flash_get_sector_size(WORD sector)
6634 +{
6635 +    return meminfo.sec[sector].size;
6636 +}
6637 +
6638 +/*********************************************************************/
6639 +/* The purpose of flash_get_memptr() is to return a memory pointer   */
6640 +/* which points to the beginning of memory space allocated for the   */
6641 +/* flash.  All function pointers are then referenced from this       */
6642 +/* pointer.                                                         */
6643 +/*                                                                   */
6644 +/* Different systems will implement this in different ways:          */
6645 +/* possibilities include:                                            */
6646 +/*  - A direct memory pointer                                        */
6647 +/*  - A pointer to a memory map                                      */
6648 +/*  - A pointer to a hardware port from which the linear             */
6649 +/*    address is translated                                          */
6650 +/*  - Output of an MMU function / service                            */
6651 +/*                                                                   */
6652 +/* Also note that this function expects the pointer to a specific    */
6653 +/* sector of the device.  This can be provided by dereferencing      */
6654 +/* the pointer from a translated offset of the sector from a         */
6655 +/* global base pointer (e.g. flashptr = base_pointer + sector_offset)*/
6656 +/*                                                                   */
6657 +/* Important: Many AMD flash devices need both bank and or sector    */
6658 +/* address bits to be correctly set (bank address bits are A18-A16,  */
6659 +/* and sector address bits are A18-A12, or A12-A15).  Flash parts    */
6660 +/* which do not need these bits will ignore them, so it is safe to   */
6661 +/* assume that every part will require these bits to be set.         */
6662 +/*********************************************************************/
6663 +unsigned char *flash_get_memptr(WORD sector)
6664 +{
6665 +       unsigned char *memptr = (unsigned char*)(FLASH_BASE_ADDR_REG + meminfo.sec[sector].base);
6666 +
6667 +       return (memptr);
6668 +}
6669 +
6670 +/*********************************************************************/
6671 +/* The purpose of flash_get_blk() is to return a the block number    */
6672 +/* for a given memory address.                                       */
6673 +/*********************************************************************/
6674 +int flash_get_blk(int addr)
6675 +{
6676 +    int blk_start, i;
6677 +    int last_blk = flash_get_numsectors();
6678 +    int relative_addr = addr - (int) FLASH_BASE_ADDR_REG;
6679 +
6680 +    for(blk_start=0, i=0; i < relative_addr && blk_start < last_blk; blk_start++)
6681 +        i += flash_get_sector_size(blk_start);
6682 +
6683 +    if( i > relative_addr )
6684 +    {
6685 +        blk_start--;        // last blk, dec by 1
6686 +    }
6687 +    else
6688 +        if( blk_start == last_blk )
6689 +        {
6690 +            printk("Address is too big.\n");
6691 +            blk_start = -1;
6692 +        }
6693 +
6694 +    return( blk_start );
6695 +}
6696 +
6697 +/************************************************************************/
6698 +/* The purpose of flash_get_total_size() is to return the total size of */
6699 +/* the flash                                                            */
6700 +/************************************************************************/
6701 +int flash_get_total_size()
6702 +{
6703 +    return totalSize;
6704 +}
6705 +
6706 +/*********************************************************************/
6707 +/* Flash_command() is the main driver function.  It performs         */
6708 +/* every possible command available to AMD B revision                */
6709 +/* flash parts. Note that this command is not used directly, but     */
6710 +/* rather called through the API wrapper functions provided below.   */
6711 +/*********************************************************************/
6712 +static void flash_command(int command, WORD sector, int offset, UINT16 data)
6713 +{
6714 +    volatile UINT16 *flashptr;
6715 +    volatile UINT16 *flashbase;
6716 +
6717 +    flashptr = (UINT16 *) flash_get_memptr(sector);
6718 +    flashbase = (UINT16 *) flash_get_memptr(0);
6719 +    
6720 +    switch (flashFamily) {
6721 +    case FLASH_UNDEFINED:
6722 +        /* These commands should work for AMD, Intel and SST flashes */
6723 +        switch (command) {
6724 +        case FLASH_RESET:
6725 +            flashptr[0] = 0xF0;
6726 +            flashptr[0] = 0xFF;
6727 +            break;
6728 +        case FLASH_READ_ID:
6729 +                       flashptr[0x5555] = 0xAA;       /* unlock 1 */
6730 +            flashptr[0x2AAA] = 0x55;       /* unlock 2 */
6731 +            flashptr[0x5555] = 0x90;
6732 +            break;
6733 +        default:
6734 +            break;
6735 +        }
6736 +        break;
6737 +    case FLASH_AMD:
6738 +        switch (command) {
6739 +        case FLASH_RESET:
6740 +            flashptr[0] = 0xF0;
6741 +            break;
6742 +        case FLASH_READ_ID:
6743 +            flashptr[0x555] = 0xAA;       /* unlock 1 */
6744 +            flashptr[0x2AA] = 0x55;       /* unlock 2 */
6745 +            flashptr[0x555] = 0x90;
6746 +            break;
6747 +        case FLASH_CFIQUERY:
6748 +            flashptr[0x55] = 0x98;
6749 +            break;
6750 +        case FLASH_UB:
6751 +            flashptr[0x555] = 0xAA;       /* unlock 1 */
6752 +            flashptr[0x2AA] = 0x55;       /* unlock 2 */
6753 +            flashptr[0x555] = 0x20;
6754 +            break;
6755 +        case FLASH_PROG:
6756 +            flashptr[0] = 0xA0;
6757 +            flashptr[offset/2] = data;
6758 +            break;
6759 +        case FLASH_UBRESET:
6760 +            flashptr[0] = 0x90;
6761 +            flashptr[0] = 0x00;
6762 +            break;
6763 +        case FLASH_SERASE:
6764 +            flashptr[0x555] = 0xAA;       /* unlock 1 */
6765 +            flashptr[0x2AA] = 0x55;       /* unlock 2 */
6766 +            flashptr[0x555] = 0x80;
6767 +            flashptr[0x555] = 0xAA;
6768 +            flashptr[0x2AA] = 0x55;
6769 +            flashptr[0] = 0x30;
6770 +            break;
6771 +        default:
6772 +            break;
6773 +        }
6774 +        break;
6775 +    case FLASH_INTEL:
6776 +        switch (command) {
6777 +        case FLASH_RESET:
6778 +            flashptr[0] = 0xFF;
6779 +            break;
6780 +        case FLASH_READ_ID:
6781 +            flashptr[0] = 0x90;
6782 +            break;
6783 +        case FLASH_CFIQUERY:
6784 +            flashptr[0] = 0x98;
6785 +            break;
6786 +        case FLASH_PROG:
6787 +            flashptr[0] = 0x40;
6788 +            flashptr[offset/2] = data;
6789 +            break;
6790 +        case FLASH_SERASE:
6791 +            flashptr[0] = 0x60;
6792 +            flashptr[0] = 0xD0;
6793 +            flashptr[0] = 0x20;
6794 +            flashptr[0] = 0xD0;
6795 +            break;
6796 +        default:
6797 +            break;
6798 +        }
6799 +        break;
6800 +    case FLASH_SST:
6801 +        switch (command) {
6802 +        case FLASH_RESET:
6803 +            flashbase[0x5555] = 0xAA;       /* unlock 1 */
6804 +            flashbase[0x2AAA] = 0x55;       /* unlock 2 */
6805 +            flashbase[0x5555] = 0xf0;
6806 +            break;
6807 +        case FLASH_READ_ID:
6808 +            flashbase[0x5555] = 0xAA;       /* unlock 1 */
6809 +            flashbase[0x2AAA] = 0x55;       /* unlock 2 */
6810 +            flashbase[0x5555] = 0x90;
6811 +            break;
6812 +        case FLASH_CFIQUERY:
6813 +            flashbase[0x5555] = 0xAA;       /* unlock 1 */
6814 +            flashbase[0x2AAA] = 0x55;       /* unlock 2 */
6815 +            flashbase[0x5555] = 0x98;
6816 +            break;
6817 +        case FLASH_UB:
6818 +            break;
6819 +        case FLASH_PROG:
6820 +            flashbase[0x5555] = 0xAA;       /* unlock 1 */
6821 +            flashbase[0x2AAA] = 0x55;       /* unlock 2 */
6822 +            flashbase[0x5555] = 0xa0;
6823 +            flashptr[offset/2] = data;
6824 +            break;
6825 +        case FLASH_UBRESET:
6826 +            break;
6827 +        case FLASH_SERASE:
6828 +            flashbase[0x5555] = 0xAA;       /* unlock 1 */
6829 +            flashbase[0x2AAA] = 0x55;       /* unlock 2 */
6830 +            flashbase[0x5555] = 0x80;
6831 +            flashbase[0x5555] = 0xAA;
6832 +            flashbase[0x2AAA] = 0x55;
6833 +            flashptr[0] = 0x30;
6834 +            break;
6835 +        default:
6836 +            break;
6837 +        }
6838 +        break;
6839 +    default:
6840 +        break;
6841 +    }
6842 +}
6843 +
6844 +/*********************************************************************/
6845 +/* flash_write extends the functionality of flash_program() by       */
6846 +/* providing an faster way to program multiple data words, without   */
6847 +/* needing the function overhead of looping algorithms which         */
6848 +/* program word by word.  This function utilizes fast pointers       */
6849 +/* to quickly loop through bulk data.                                */
6850 +/*********************************************************************/
6851 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes)
6852 +{
6853 +    UINT16 *src;
6854 +    src = (UINT16 *)buf;
6855 +
6856 +    if ((nbytes | offset) & 1) {
6857 +        return -1;
6858 +    }
6859 +
6860 +    flash_command(FLASH_UB, 0, 0, 0);
6861 +    while (nbytes > 0) {
6862 +        flash_command(FLASH_PROG, sector, offset, *src);
6863 +        if (flash_wait(sector, offset, *src) != STATUS_READY)
6864 +            break;
6865 +        offset +=2;
6866 +        nbytes -=2;
6867 +        src++;
6868 +    }
6869 +    flash_command(FLASH_UBRESET, 0, 0, 0);
6870 +    
6871 +    return (byte*)src - buf;
6872 +}
6873 +
6874 +/*********************************************************************/
6875 +/* flash_wait utilizes the DQ6, DQ5, and DQ2 polling algorithms      */
6876 +/* described in the flash data book.  It can quickly ascertain the   */
6877 +/* operational status of the flash device, and return an             */
6878 +/* appropriate status code (defined in flash.h)                      */
6879 +/*********************************************************************/
6880 +static int flash_wait(WORD sector, int offset, UINT16 data)
6881 +{
6882 +    volatile UINT16 *flashptr; /* flash window */
6883 +    UINT16 d1;
6884 +
6885 +    flashptr = (UINT16 *) flash_get_memptr(sector);
6886 +
6887 +    if (flashFamily == FLASH_AMD || flashFamily == FLASH_SST) {
6888 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
6889 +        do {
6890 +            d1 = flashptr[offset/2];
6891 +            if (d1 == data)
6892 +                return STATUS_READY;
6893 +        } while (!(d1 & 0x20));
6894 +
6895 +        d1 = flashptr[offset/2];
6896 +
6897 +        if (d1 != data) {
6898 +            flash_command(FLASH_RESET, 0, 0, 0);
6899 +            return STATUS_TIMEOUT;
6900 +        }
6901 +#else
6902 +        do {
6903 +            d1 = *flashptr;    /* read data */
6904 +            d1 ^= *flashptr;   /* read it again and see what toggled */
6905 +            if (d1 == 0)       /* no toggles, nothing's happening */
6906 +                return STATUS_READY;
6907 +        } while (!(d1 & 0x20));
6908 +
6909 +        d1 = *flashptr;        /* read data */
6910 +        d1 ^= *flashptr;   /* read it again and see what toggled */
6911 +
6912 +        if (d1 != 0) {
6913 +            flash_command(FLASH_RESET, 0, 0, 0);
6914 +            return STATUS_TIMEOUT;
6915 +        }
6916 +#endif
6917 +    } else if (flashFamily == FLASH_INTEL) {
6918 +        flashptr[0] = 0x70;
6919 +        /* Wait for completion */
6920 +        while(!(*flashptr & 0x80));
6921 +        if (*flashptr & 0x30) {
6922 +            flashptr[0] = 0x50;
6923 +            flash_command(FLASH_RESET, 0, 0, 0);
6924 +            return STATUS_TIMEOUT;
6925 +        }
6926 +        flashptr[0] = 0x50;
6927 +        flash_command(FLASH_RESET, 0, 0, 0);
6928 +    }
6929 +    
6930 +    return STATUS_READY;
6931 +}
6932 +
6933 +/*********************************************************************/
6934 +/* flash_get_device_id() will perform an autoselect sequence on the  */
6935 +/* flash device, and return the device id of the component.          */
6936 +/* This function automatically resets to read mode.                  */
6937 +/*********************************************************************/
6938 +static UINT16 flash_get_device_id()
6939 +{
6940 +    volatile UINT16 *fwp; /* flash window */
6941 +    UINT16 answer;
6942 +    
6943 +    fwp = (UINT16 *)flash_get_memptr(0);
6944 +    
6945 +    flash_command(FLASH_READ_ID, 0, 0, 0);
6946 +    answer = *(fwp + 1);
6947 +    if (answer == ID_AM29LV320M) {
6948 +        answer = *(fwp + 0xe);
6949 +        answer = *(fwp + 0xf);
6950 +    }
6951 +    
6952 +    flash_command(FLASH_RESET, 0, 0, 0);
6953 +    return( (UINT16) answer );
6954 +}
6955 +
6956 +/*********************************************************************/
6957 +/* flash_get_cfi() is the main CFI workhorse function.  Due to it's  */
6958 +/* complexity and size it need only be called once upon              */
6959 +/* initializing the flash system.  Once it is called, all operations */
6960 +/* are performed by looking at the meminfo structure.                */
6961 +/* All possible care was made to make this algorithm as efficient as */
6962 +/* possible.  90% of all operations are memory reads, and all        */
6963 +/* calculations are done using bit-shifts when possible              */
6964 +/*********************************************************************/
6965 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily)
6966 +{
6967 +    volatile UINT16 *fwp; /* flash window */
6968 +    int i=0;
6969 +
6970 +    flash_command(FLASH_CFIQUERY, 0, 0, 0);
6971 +    
6972 +    if (cfi_struct == 0)
6973 +        fwp = (UINT16 *)flash_get_memptr(0);
6974 +    else
6975 +        fwp = cfi_struct;
6976 +    
6977 +    /* Initial house-cleaning */
6978 +    for(i=0; i < 8; i++) {
6979 +        query->erase_block[i].sector_size = 0;
6980 +        query->erase_block[i].num_sectors = 0;
6981 +    }
6982 +    
6983 +    /* If not 'QRY', then we dont have a CFI enabled device in the socket */
6984 +    if( fwp[0x10] != 'Q' &&
6985 +        fwp[0x11] != 'R' &&
6986 +        fwp[0x12] != 'Y') {
6987 +        flash_command(FLASH_RESET, 0, 0, 0);
6988 +        return(-1);
6989 +    }
6990 +    
6991 +       query->num_erase_blocks = fwp[0x2C];
6992 +       if(flashFamily == FLASH_SST)
6993 +               query->num_erase_blocks = 1;
6994 +       
6995 +    for(i=0; i < query->num_erase_blocks; i++) {
6996 +                       query->erase_block[i].num_sectors = fwp[(0x2D+(4*i))] + (fwp[0x2E + (4*i)] << 8);
6997 +                       query->erase_block[i].num_sectors++;
6998 +                       query->erase_block[i].sector_size = 256 * (256 * fwp[(0x30+(4*i))] + fwp[(0x2F+(4*i))]);
6999 +    }
7000 +    
7001 +    flash_command(FLASH_RESET, 0, 0, 0);
7002 +    return(1);
7003 +}
7004 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h
7005 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h      1970-01-01 01:00:00.000000000 +0100
7006 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h     2006-08-03 16:36:58.000000000 +0200
7007 @@ -0,0 +1,142 @@
7008 +/************************************************************************/
7009 +/*                                                                      */
7010 +/*  AMD CFI Enabled Flash Memory Drivers                                */
7011 +/*  File name: CFIFLASH.H                                               */
7012 +/*  Revision:  1.0  5/07/98                                             */
7013 +/*                                                                      */
7014 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
7015 +/* This software is unpublished and contains the trade secrets and      */
7016 +/* confidential proprietary information of AMD. Unless otherwise        */
7017 +/* provided in the Software Agreement associated herewith, it is        */
7018 +/* licensed in confidence "AS IS" and is not to be reproduced in whole  */
7019 +/* or part by any means except for backup. Use, duplication, or         */
7020 +/* disclosure by the Government is subject to the restrictions in       */
7021 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer   */
7022 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988).                  */
7023 +/* Software owned by                                                    */
7024 +/* Advanced Micro Devices, Inc.,                                        */
7025 +/* One AMD Place,                                                       */
7026 +/* P.O. Box 3453                                                        */
7027 +/* Sunnyvale, CA 94088-3453.                                            */
7028 +/************************************************************************/
7029 +/*  This software constitutes a basic shell of source code for          */
7030 +/*  programming all AMD Flash components. AMD                           */
7031 +/*  will not be responsible for misuse or illegal use of this           */
7032 +/*  software for devices not supported herein. AMD is providing         */
7033 +/*  this source code "AS IS" and will not be responsible for            */
7034 +/*  issues arising from incorrect user implementation of the            */
7035 +/*  source code herein. It is the user's responsibility to              */
7036 +/*  properly design-in this source code.                                */
7037 +/*                                                                      */ 
7038 +/************************************************************************/
7039 +#ifndef _CFIFLASH_H
7040 +#define _CFIFLASH_H
7041 +
7042 +/* include board/CPU specific definitions */
7043 +#include "bcmtypes.h"
7044 +#include "board.h"
7045 +
7046 +#define FLASH_BASE_ADDR_REG FLASH_BASE
7047 +
7048 +#ifndef NULL
7049 +#define NULL 0
7050 +#endif
7051 +
7052 +#define MAXSECTORS  1024      /* maximum number of sectors supported */
7053 +
7054 +/* A structure for identifying a flash part.  There is one for each
7055 + * of the flash part definitions.  We need to keep track of the
7056 + * sector organization, the address register used, and the size
7057 + * of the sectors.
7058 + */
7059 +struct flashinfo {
7060 +        char *name;         /* "Am29DL800T", etc. */
7061 +        unsigned long addr; /* physical address, once translated */
7062 +        int areg;           /* Can be set to zero for all parts */
7063 +        int nsect;          /* # of sectors -- 19 in LV, 22 in DL */
7064 +        int bank1start;     /* first sector # in bank 1 */
7065 +        int bank2start;     /* first sector # in bank 2, if DL part */
7066 + struct {
7067 +       long size;           /* # of bytes in this sector */
7068 +       long base;           /* offset from beginning of device */
7069 +       int bank;            /* 1 or 2 for DL; 1 for LV */
7070 +        } sec[MAXSECTORS];  /* per-sector info */
7071 +};
7072 +
7073 +/*
7074 + * This structure holds all CFI query information as defined
7075 + * in the JEDEC standard. All information up to 
7076 + * primary_extended_query is standard among all manufactures
7077 + * with CFI enabled devices.
7078 + */
7079 +
7080 +struct cfi_query {
7081 +       int num_erase_blocks;           /* Number of sector defs. */
7082 +       struct {
7083 +         unsigned long sector_size;    /* byte size of sector */
7084 +         int num_sectors;              /* Num sectors of this size */
7085 +       } erase_block[8];               /* Max of 256, but 8 is good */
7086 +};
7087 +
7088 +/* Standard Boolean declarations */
7089 +#define TRUE                           1
7090 +#define FALSE                          0
7091 +
7092 +/* Define different type of flash */
7093 +#define FLASH_UNDEFINED 0
7094 +#define FLASH_AMD       1
7095 +#define FLASH_INTEL     2
7096 +#define FLASH_SST       3
7097 +
7098 +/* Command codes for the flash_command routine */
7099 +#define FLASH_RESET     0       /* reset to read mode */
7100 +#define FLASH_READ_ID   1       /* read device ID */
7101 +#define FLASH_CFIQUERY  2       /* CFI query */
7102 +#define FLASH_UB        3       /* go into unlock bypass mode */
7103 +#define FLASH_PROG      4       /* program a word */
7104 +#define FLASH_UBRESET   5       /* reset to read mode from unlock bypass mode */
7105 +#define FLASH_SERASE    6       /* sector erase */
7106 +
7107 +/* Return codes from flash_status */
7108 +#define STATUS_READY    0       /* ready for action */
7109 +#define STATUS_TIMEOUT  1       /* operation timed out */
7110 +
7111 +/* A list of AMD compatible device ID's - add others as needed */
7112 +#define ID_AM29DL800T   0x224A
7113 +#define ID_AM29DL800B   0x22CB
7114 +#define ID_AM29LV800T   0x22DA
7115 +#define ID_AM29LV800B   0x225B
7116 +#define ID_AM29LV400B   0x22BA
7117 +
7118 +#define ID_AM29LV160B   0x2249
7119 +#define ID_AM29LV160T   0x22C4
7120 +
7121 +#define ID_AM29LV320T   0x22F6
7122 +#define ID_MX29LV320AT  0x22A7
7123 +#define ID_AM29LV320B   0x22F9
7124 +#define ID_MX29LV320AB  0x22A8
7125 +
7126 +#define ID_AM29LV320M   0x227E
7127 +#define ID_AM29LV320MB  0x2200
7128 +#define ID_AM29LV320MT  0x2201
7129 +
7130 +#define ID_SST39VF1601  0x234B
7131 +#define ID_SST39VF3201  0x235B
7132 +
7133 +/* A list of Intel compatible device ID's - add others as needed */
7134 +#define ID_I28F160C3T   0x88C2
7135 +#define ID_I28F160C3B   0x88C3
7136 +#define ID_I28F320C3T   0x88C4
7137 +#define ID_I28F320C3B   0x88C5
7138 +
7139 +extern byte flash_init(void);
7140 +extern int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes);
7141 +extern int flash_read_buf(WORD sector, int offset, byte *buffer, int numbytes);
7142 +extern byte flash_sector_erase_int(WORD sector);
7143 +extern int flash_get_numsectors(void);
7144 +extern int flash_get_sector_size(WORD sector);
7145 +extern int flash_get_total_size(void);
7146 +extern unsigned char *flash_get_memptr(WORD sector);
7147 +extern int flash_get_blk(int addr);
7148 +
7149 +#endif
7150 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c
7151 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c   1970-01-01 01:00:00.000000000 +0100
7152 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c  2006-08-03 16:36:58.000000000 +0200
7153 @@ -0,0 +1,299 @@
7154 +/*
7155 +<:copyright-gpl 
7156 + Copyright 2002 Broadcom Corp. All Rights Reserved. 
7157
7158 + This program is free software; you can distribute it and/or modify it 
7159 + under the terms of the GNU General Public License (Version 2) as 
7160 + published by the Free Software Foundation. 
7161
7162 + This program is distributed in the hope it will be useful, but WITHOUT 
7163 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
7164 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
7165 + for more details. 
7166
7167 + You should have received a copy of the GNU General Public License along 
7168 + with this program; if not, write to the Free Software Foundation, Inc., 
7169 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
7170 +:>
7171 +*/
7172 +/*
7173 + * Interrupt control functions for Broadcom 963xx MIPS boards
7174 + */
7175 +
7176 +#include <asm/atomic.h>
7177 +
7178 +#include <linux/delay.h>
7179 +#include <linux/init.h>
7180 +#include <linux/ioport.h>
7181 +#include <linux/irq.h>
7182 +#include <linux/interrupt.h>
7183 +#include <linux/kernel.h>
7184 +#include <linux/slab.h>
7185 +#include <linux/module.h>
7186 +#include <linux/spinlock.h>
7187 +
7188 +#include <asm/irq.h>
7189 +#include <asm/mipsregs.h>
7190 +#include <asm/addrspace.h>
7191 +#include <asm/signal.h>
7192 +#include <bcm_map_part.h>
7193 +#include <bcm_intr.h>
7194 +
7195 +static DEFINE_SPINLOCK(irq_lock);
7196 +
7197 +static void irq_dispatch_int(struct pt_regs *regs)
7198 +{
7199 +    unsigned int pendingIrqs;
7200 +    static unsigned int irqBit;
7201 +    static unsigned int isrNumber = 31;
7202 +
7203 +    pendingIrqs = PERF->IrqStatus & PERF->IrqMask;
7204 +    if (!pendingIrqs) {
7205 +        return;
7206 +    }
7207 +
7208 +    while (1) {
7209 +       irqBit <<= 1;
7210 +       isrNumber++;
7211 +       if (isrNumber == 32) {
7212 +               isrNumber = 0;
7213 +               irqBit = 0x1;
7214 +       }
7215 +       if (pendingIrqs & irqBit) {
7216 +               PERF->IrqMask &= ~irqBit; // mask
7217 +               do_IRQ(isrNumber + INTERNAL_ISR_TABLE_OFFSET, regs);
7218 +               break;
7219 +       }
7220 +    }
7221 +}
7222 +
7223 +static void irq_dispatch_ext(uint32 irq, struct pt_regs *regs)
7224 +{
7225 +    if (!(PERF->ExtIrqCfg & (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)))) {
7226 +       printk("**** Ext IRQ mask. Should not dispatch ****\n");
7227 +    }
7228 +    /* disable and clear interrupt in the controller */
7229 +    PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7230 +    PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7231 +    do_IRQ(irq, regs);
7232 +}
7233 +
7234 +void brcm_irq_dispatch(struct pt_regs *regs)
7235 +{
7236 +    u32 cause;
7237 +    while((cause = (read_c0_cause()& CAUSEF_IP))) {
7238 +       if (cause & CAUSEF_IP7)
7239 +               do_IRQ(MIPS_TIMER_INT, regs);
7240 +       else if (cause & CAUSEF_IP2)
7241 +               irq_dispatch_int(regs);
7242 +       else if (cause & CAUSEF_IP3)
7243 +               irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7244 +       else if (cause & CAUSEF_IP4)
7245 +               irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7246 +       else if (cause & CAUSEF_IP5)
7247 +               irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7248 +       else if (cause & CAUSEF_IP6)
7249 +               irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7250 +       //cli();
7251 +       spin_lock_irq(&irq_lock);
7252 +    }
7253 +}
7254 +
7255 +void plat_irq_dispatch(struct pt_regs *regs)
7256 +{
7257 +    u32 cause;
7258 +    while((cause = (read_c0_cause()& CAUSEF_IP))) {
7259 +        if (cause & CAUSEF_IP7)
7260 +                do_IRQ(MIPS_TIMER_INT, regs);
7261 +        else if (cause & CAUSEF_IP2)
7262 +                irq_dispatch_int(regs);
7263 +        else if (cause & CAUSEF_IP3)
7264 +                irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7265 +        else if (cause & CAUSEF_IP4)
7266 +                irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7267 +        else if (cause & CAUSEF_IP5)
7268 +                irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7269 +        else if (cause & CAUSEF_IP6)
7270 +                irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7271 +        //cli();
7272 +       spin_lock_irq(&irq_lock);
7273 +    }
7274 +}
7275 +
7276 +
7277 +void enable_brcm_irq(unsigned int irq)
7278 +{
7279 +    unsigned long flags;
7280 +
7281 +    local_irq_save(flags);
7282 +    if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7283 +       PERF->IrqMask |= (1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7284 +    }
7285 +    else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7286 +    /* enable and clear interrupt in the controller */
7287 +       PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7288 +       PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7289 +    }
7290 +    local_irq_restore(flags);
7291 +}
7292 +
7293 +void disable_brcm_irq(unsigned int irq)
7294 +{
7295 +    unsigned long flags;
7296 +
7297 +    local_irq_save(flags);
7298 +    if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7299 +       PERF->IrqMask &= ~(1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7300 +    }
7301 +    else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7302 +    /* disable interrupt in the controller */
7303 +       PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7304 +    }
7305 +    local_irq_restore(flags);
7306 +}
7307 +
7308 +void ack_brcm_irq(unsigned int irq)
7309 +{
7310 +    /* Already done in brcm_irq_dispatch */
7311 +}
7312 +
7313 +unsigned int startup_brcm_irq(unsigned int irq)
7314 +{
7315 +    enable_brcm_irq(irq);
7316 +
7317 +    return 0; /* never anything pending */
7318 +}
7319 +
7320 +unsigned int startup_brcm_none(unsigned int irq)
7321 +{
7322 +    return 0;
7323 +}
7324 +
7325 +void end_brcm_irq(unsigned int irq)
7326 +{
7327 +    if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
7328 +        enable_brcm_irq(irq);
7329 +}
7330 +
7331 +void end_brcm_none(unsigned int irq)
7332 +{
7333 +}
7334 +
7335 +#define ALLINTS_NOTIMER (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
7336 +
7337 +static void __init brcm_irq_setup(void)
7338 +{
7339 +       extern asmlinkage void brcmIRQ(void);
7340 +
7341 +       clear_c0_status(ST0_BEV);
7342 +       set_except_vector(0, brcmIRQ);
7343 +       change_c0_status(ST0_IM, ALLINTS_NOTIMER);
7344 +
7345 +#ifdef CONFIG_REMOTE_DEBUG
7346 +       rs_kgdb_hook(0);
7347 +#endif
7348 +}
7349 +
7350 +static struct hw_interrupt_type brcm_irq_type = {
7351 +    .typename  = "MIPS",
7352 +    .startup   = startup_brcm_irq,
7353 +    .shutdown  = disable_brcm_irq,
7354 +    .enable    = enable_brcm_irq,
7355 +    .disable   = disable_brcm_irq,
7356 +    .ack       = ack_brcm_irq,
7357 +    .end       = end_brcm_irq,
7358 +    .set_affinity = NULL
7359 +};
7360 +
7361 +static struct hw_interrupt_type brcm_irq_no_end_type = {
7362 +    .typename  = "MIPS",
7363 +    .startup   = startup_brcm_none,
7364 +    .shutdown  = disable_brcm_irq,
7365 +    .enable    = enable_brcm_irq,
7366 +    .disable   = disable_brcm_irq,
7367 +    .ack       = ack_brcm_irq,
7368 +    .end       = end_brcm_none,
7369 +    .set_affinity = NULL
7370 +};
7371 +
7372 +void __init arch_init_irq(void)
7373 +{
7374 +    int i;
7375 +
7376 +    for (i = 0; i < NR_IRQS; i++) {
7377 +        irq_desc[i].status = IRQ_DISABLED;
7378 +        irq_desc[i].action = 0;
7379 +        irq_desc[i].depth = 1;
7380 +        irq_desc[i].handler = &brcm_irq_type;
7381 +    }
7382 +
7383 +    brcm_irq_setup();
7384 +}
7385 +
7386 +int request_external_irq(unsigned int irq, 
7387 +       FN_HANDLER handler,
7388 +        unsigned long irqflags, 
7389 +        const char * devname,
7390 +        void *dev_id)
7391 +{
7392 +    unsigned long flags;
7393 +
7394 +    local_irq_save(flags);
7395 +
7396 +    PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));      // Clear
7397 +    PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));      // Mask
7398 +    PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_INSENS_SHFT));    // Edge insesnsitive
7399 +    PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_LEVEL_SHFT));      // Level triggered
7400 +    PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_SENSE_SHFT));     // Low level
7401 +
7402 +    local_irq_restore(flags);
7403 +
7404 +    return( request_irq(irq, handler, irqflags, devname, dev_id) );
7405 +}
7406 +
7407 +/* VxWorks compatibility function(s). */
7408 +
7409 +unsigned int BcmHalMapInterrupt(FN_HANDLER pfunc, unsigned int param,
7410 +    unsigned int interruptId)
7411 +{
7412 +    int nRet = -1;
7413 +    char *devname;
7414 +
7415 +    devname = kmalloc(16, GFP_KERNEL);
7416 +    if (devname)
7417 +        sprintf( devname, "brcm_%d", interruptId );
7418 +
7419 +    /* Set the IRQ description to not automatically enable the interrupt at
7420 +     * the end of an ISR.  The driver that handles the interrupt must
7421 +     * explicitly call BcmHalInterruptEnable or enable_brcm_irq.  This behavior
7422 +     * is consistent with interrupt handling on VxWorks.
7423 +     */
7424 +    irq_desc[interruptId].handler = &brcm_irq_no_end_type;
7425 +
7426 +    if( interruptId >= INTERNAL_ISR_TABLE_OFFSET )
7427 +    {
7428 +        nRet = request_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7429 +            devname, (void *) param );
7430 +    }
7431 +    else if (interruptId >= INTERRUPT_ID_EXTERNAL_0 && interruptId <= INTERRUPT_ID_EXTERNAL_3)
7432 +    {
7433 +        nRet = request_external_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7434 +            devname, (void *) param );
7435 +    }
7436 +
7437 +    return( nRet );
7438 +}
7439 +
7440 +
7441 +/* Debug function. */
7442 +
7443 +void dump_intr_regs(void)
7444 +{
7445 +    printk("PERF->ExtIrqCfg [%08x]\n", *(&(PERF->ExtIrqCfg)));
7446 +} 
7447 +
7448 +EXPORT_SYMBOL(enable_brcm_irq);
7449 +EXPORT_SYMBOL(disable_brcm_irq);
7450 +EXPORT_SYMBOL(request_external_irq);
7451 +EXPORT_SYMBOL(BcmHalMapInterrupt);
7452 +
7453 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig
7454 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
7455 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig        2006-08-03 16:36:58.000000000 +0200
7456 @@ -0,0 +1,172 @@
7457 +# Kernel and Driver configuration for Broadcom Commengine ADSL board
7458 +choice
7459 +       prompt "Broadcom Commengine ADSL board"
7460 +       depends on MIPS_BRCM
7461 +       default BCM96345
7462 +       help
7463 +         Select different Broadcom ADSL board
7464 +
7465 +config BCM96338
7466 +       bool "96338 ADSL board"
7467 +       select DMA_NONCOHERENT
7468 +       select HW_HAS_PCI
7469 +
7470 +config BCM96345
7471 +       bool "96345 ADSL board"
7472 +       select DMA_NONCOHERENT
7473 +       select HW_HAS_PCI
7474 +
7475 +config BCM96348
7476 +       bool "96348 ADSL board"
7477 +       select DMA_NONCOHERENT
7478 +       select HW_HAS_PCI
7479 +
7480 +endchoice
7481 +
7482 +config BCM_BOARD
7483 +       bool "Support for Broadcom Board"
7484 +       depends on BCM96338 || BCM96345 || BCM96348
7485 +
7486 +config BCM_SERIAL
7487 +       bool "Support for Serial Port"
7488 +       depends on BCM96338 || BCM96345 || BCM96348
7489 +
7490 +config BCM_ENET
7491 +       tristate "Support for Ethernet"
7492 +       depends on BCM96338 || BCM96345 || BCM96348
7493 +
7494 +config BCM_USB
7495 +       tristate "Support for USB"
7496 +       depends on BCM96338 || BCM96345 || BCM96348
7497 +
7498 +config BCM_WLAN
7499 +       tristate "Support for Wireless"
7500 +       depends on BCM96338 || BCM96345 || BCM96348
7501 +
7502 +config BCM_PCI
7503 +       bool "Support for PCI"
7504 +       depends on BCM96338 || BCM96345 || BCM96348
7505 +       select PCI
7506 +
7507 +config BCM_ATMAPI
7508 +       tristate "Support for ATM"
7509 +       depends on BCM96338 || BCM96345 || BCM96348
7510 +
7511 +config BCM_ATMTEST
7512 +       tristate "Support for ATM Diagnostic"
7513 +       depends on BCM96338 || BCM96345 || BCM96348
7514 +
7515 +config BCM_ADSL
7516 +       tristate "Support for ADSL"
7517 +       depends on BCM96338 || BCM96345 || BCM96348
7518 +
7519 +config BCM_ENDPOINT
7520 +       tristate "Support for VOICE"
7521 +       depends on BCM96338 || BCM96345 || BCM96348
7522 +
7523 +config BCM_PROCFS
7524 +       tristate "Support for PROCFS"
7525 +       depends on BCM96338 || BCM96345 || BCM96348
7526 +
7527 +config BCM_VDSL
7528 +       tristate "Support for VDSL"
7529 +       depends on BCM96338 || BCM96345 || BCM96348
7530 +
7531 +config BCM_SECURITY
7532 +       tristate "Support for SECURITY"
7533 +       depends on BCM96338 || BCM96345 || BCM96348
7534 +
7535 +config BCM_HPNA
7536 +       tristate "Support for HPNA"
7537 +       depends on BCM96338 || BCM96345 || BCM96348
7538 +
7539 +config BCM_BOARD_IMPL
7540 +       int "Implementation index for ADSL Board"
7541 +       depends on BCM96338 || BCM96345 || BCM96348
7542 +
7543 +config BCM_SERIAL_IMPL
7544 +       int "Implementation index for Serial"
7545 +       depends on BCM96338 || BCM96345 || BCM96348
7546 +
7547 +config BCM_ENET_IMPL
7548 +       int "Implementation index for Ethernet"
7549 +       depends on BCM96338 || BCM96345 || BCM96348
7550 +
7551 +config BCM_USB_IMPL
7552 +       int "Implementation index for USB"
7553 +       depends on BCM96338 || BCM96345 || BCM96348
7554 +
7555 +config BCM_WLAN_IMPL
7556 +       int "Implementation index for WIRELESS"
7557 +       depends on BCM96338 || BCM96345 || BCM96348
7558 +
7559 +config BCM_ATMAPI_IMPL
7560 +       int "Implementation index for ATM"
7561 +       depends on BCM96338 || BCM96345 || BCM96348
7562 +
7563 +config BCM_ATMTEST_IMPL
7564 +       int "Implementation index for ATM Diagnostic"
7565 +       depends on BCM96338 || BCM96345 || BCM96348
7566 +
7567 +config BCM_BLAA_IMPL
7568 +       int "Implementation index for BLAA"
7569 +       depends on BCM96338 || BCM96345 || BCM96348
7570 +
7571 +config BCM_ADSL_IMPL
7572 +       int "Implementation index for ADSL"
7573 +       depends on BCM96338 || BCM96345 || BCM96348
7574 +
7575 +config BCM_ENDPOINT_IMPL
7576 +       int "Implementation index for VOICE"
7577 +       depends on BCM96338 || BCM96345 || BCM96348
7578 +
7579 +config BCM_PROCFS_IMPL
7580 +       int "Implementation index for PROCFS"
7581 +       depends on BCM96338 || BCM96345 || BCM96348
7582 +
7583 +config BCM_VDSL_IMPL
7584 +       int "Implementation index for VDSL"
7585 +       depends on BCM96338 || BCM96345 || BCM96348
7586 +
7587 +config BCM_SECURITY_IMPL
7588 +       int "Implementation index for SECURITY"
7589 +       depends on BCM96338 || BCM96345 || BCM96348
7590 +
7591 +config BCM_HPNA_IMPL
7592 +       int "Implementation index for HPNA"
7593 +       depends on BCM96338 || BCM96345 || BCM96348
7594 +
7595 +choice
7596 +       prompt "Root File System"
7597 +       depends on MIPS_BRCM
7598 +       default ROOTFS_SQUASHFS
7599 +       help
7600 +         Select root file system on the board flash. 
7601 +
7602 +config ROOTFS_SQUASHFS
7603 +        bool "SQUASHFS"
7604 +config ROOTFS_CRAMFS
7605 +        bool "CRAMFS"
7606 +config ROOTFS_JFFS2
7607 +        bool "JFFS2"
7608 +config ROOTFS_NFS
7609 +        bool "NFS"
7610 +
7611 +endchoice
7612 +
7613 +config ROOT_FLASHFS
7614 +       string "flash partition"
7615 +       depends on ROOTFS_SQUASHFS || ROOTFS_CRAMFS || ROOTFS_JFFS2
7616 +       default "root=31:0 ro noinitrd" if ROOTFS_SQUASHFS = y || ROOTFS_CRAMFS = y
7617 +       default "root=31:2 ro noinitrd" if ROOTFS_JFFS2 = y
7618 +       help
7619 +         This is the root file system partition on flash memory
7620 +
7621 +config ROOT_NFS_DIR
7622 +       string "NFS server path"
7623 +       depends on ROOTFS_NFS
7624 +       default "/opt/bcm96338/targets/96338R/fs" if BCM96338 = y
7625 +       default "/opt/bcm96345/targets/96345R/fs" if BCM96345 = y
7626 +       default "/opt/bcm96348/targets/96348R/fs" if BCM96348 = y  
7627 +       help
7628 +         This is the path of NFS server (host system)
7629 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile
7630 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile        1970-01-01 01:00:00.000000000 +0100
7631 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile       2006-08-03 16:36:58.000000000 +0200
7632 @@ -0,0 +1,23 @@
7633 +#
7634 +# Makefile for generic Broadcom MIPS boards
7635 +#
7636 +# Copyright (C) 2004 Broadcom Corporation
7637 +#
7638 +obj-y           := irq.o prom.o setup.o time.o ser_init.o bcm63xx_flash.o  bcm63xx_led.o  board.o  boardparms.o  cfiflash.o
7639 +
7640 +SRCBASE         := $(TOPDIR)
7641 +EXTRA_CFLAGS    += -I$(SRCBASE)/include
7642 +#EXTRA_CFLAGS    += -I$(INC_ADSLDRV_PATH) -DDBG
7643 +EXTRA_CFLAGS    += -I$(INC_ADSLDRV_PATH) 
7644 +
7645 +
7646 +ifeq "$(ADSL)" "ANNEX_B"
7647 +EXTRA_CFLAGS += -DADSL_ANNEXB
7648 +endif
7649 +ifeq "$(ADSL)" "SADSL"
7650 +EXTRA_CFLAGS += -DADSL_SADSL
7651 +endif
7652 +ifeq "$(ADSL)" "ANNEX_C"
7653 +EXTRA_CFLAGS += -DADSL_ANNEXC
7654 +endif
7655 +
7656 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c
7657 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c  1970-01-01 01:00:00.000000000 +0100
7658 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c 2006-08-03 16:40:27.000000000 +0200
7659 @@ -0,0 +1,250 @@
7660 +/*
7661 +<:copyright-gpl 
7662 + Copyright 2004 Broadcom Corp. All Rights Reserved. 
7663
7664 + This program is free software; you can distribute it and/or modify it 
7665 + under the terms of the GNU General Public License (Version 2) as 
7666 + published by the Free Software Foundation. 
7667
7668 + This program is distributed in the hope it will be useful, but WITHOUT 
7669 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
7670 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
7671 + for more details. 
7672
7673 + You should have received a copy of the GNU General Public License along 
7674 + with this program; if not, write to the Free Software Foundation, Inc., 
7675 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
7676 +:>
7677 +*/
7678 +/*
7679 + * prom.c: PROM library initialization code.
7680 + *
7681 + */
7682 +#include <linux/init.h>
7683 +#include <linux/mm.h>
7684 +#include <linux/sched.h>
7685 +#include <linux/bootmem.h>
7686 +#include <linux/blkdev.h>
7687 +#include <asm/addrspace.h>
7688 +#include <asm/bootinfo.h>
7689 +#include <asm/cpu.h>
7690 +#include <asm/time.h>
7691 +
7692 +#include <bcm_map_part.h>
7693 +#include <board.h>
7694 +#include "boardparms.h"
7695 +#include "softdsl/AdslCoreDefs.h"
7696 +
7697 +
7698 +//char arcs_cmdline[CL_SIZE] __initdata = {0};
7699 +/* inv_xde */
7700 +int boot_loader_type;
7701 +
7702 +extern int  do_syslog(int, char *, int);
7703 +extern void serial_init(void);
7704 +extern void __init InitNvramInfo( void );
7705 +extern void kerSysFlashInit( void );
7706 +extern unsigned long get_nvram_start_addr(void);
7707 +void __init create_root_nfs_cmdline( char *cmdline );
7708 +
7709 +#if defined(CONFIG_BCM96338)
7710 +#define CPU_CLOCK                   240000000
7711 +#define MACH_BCM                    MACH_BCM96338
7712 +#endif
7713 +#if defined(CONFIG_BCM96345)
7714 +#define CPU_CLOCK                   140000000
7715 +#define MACH_BCM                    MACH_BCM96345
7716 +#endif
7717 +#if defined(CONFIG_BCM96348)
7718 +void __init calculateCpuSpeed(void);
7719 +static unsigned long cpu_speed;
7720 +#define CPU_CLOCK                   cpu_speed
7721 +#define MACH_BCM                    MACH_BCM96348
7722 +#endif
7723 +
7724 +const char *get_system_type(void)
7725 +{
7726 +    /*PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7727 +
7728 +    return( pNvramData->szBoardId );*/
7729 +    return "brcm63xx";
7730 +}
7731 +
7732 +unsigned long getMemorySize(void)
7733 +{
7734 +    unsigned long ulSdramType = BOARD_SDRAM_TYPE;
7735 +
7736 +    unsigned long ulSdramSize;
7737 +
7738 +    switch( ulSdramType )
7739 +    {
7740 +    case BP_MEMORY_16MB_1_CHIP:
7741 +    case BP_MEMORY_16MB_2_CHIP:
7742 +        ulSdramSize = 16 * 1024 * 1024;
7743 +        break;
7744 +    case BP_MEMORY_32MB_1_CHIP:
7745 +    case BP_MEMORY_32MB_2_CHIP:
7746 +        ulSdramSize = 32 * 1024 * 1024;
7747 +        break;
7748 +    case BP_MEMORY_64MB_2_CHIP:
7749 +        ulSdramSize = 64 * 1024 * 1024;
7750 +        break;
7751 +    default:
7752 +        ulSdramSize = 8 * 1024 * 1024;
7753 +        break;
7754 +    }
7755 +    if (boot_loader_type == BOOT_CFE)
7756 +      return ulSdramSize;
7757 +    else
7758 +      // assume that there is one contiguous memory map
7759 +      return boot_mem_map.map[0].size;
7760 +}
7761 +
7762 +/* --------------------------------------------------------------------------
7763 +    Name: prom_init
7764 + -------------------------------------------------------------------------- */
7765 +void __init prom_init(void)
7766 +{
7767 +    extern ulong r4k_interval;
7768 +
7769 +    serial_init();
7770 +
7771 +    /* Need to fixup boot loader detection code 
7772 +     * whithout changing prom_init prototype  
7773 +     */
7774 +
7775 +    if (boot_loader_type == BOOT_CFE)
7776 +       kerSysFlashInit();
7777 +
7778 +    do_syslog(8, NULL, 8);
7779 +
7780 +    printk( "%s prom init\n", get_system_type() );
7781 +
7782 +    PERF->IrqMask = 0;
7783 +
7784 +    arcs_cmdline[0] = '\0';
7785 +#if defined(CONFIG_ROOT_NFS)
7786 +    create_root_nfs_cmdline( arcs_cmdline );
7787 +#elif defined(CONFIG_ROOT_FLASHFS)
7788 +    strcpy(arcs_cmdline, CONFIG_ROOT_FLASHFS);
7789 +#endif
7790 +//#define ADSL_SDRAM_IMAGE_SIZE 0x40000
7791 +    /* inv_xde */
7792 +    //add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7793 +    if (boot_loader_type == BOOT_CFE)
7794 +      add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7795 +    else
7796 +       add_memory_region(0, (0x01000000 - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7797 +#if defined(CONFIG_BCM96348)
7798 +    calculateCpuSpeed();
7799 +#endif
7800 +    /* Count register increments every other clock */
7801 +    r4k_interval = CPU_CLOCK / HZ / 2;
7802 +    mips_hpt_frequency = CPU_CLOCK / 2;
7803 +
7804 +    mips_machgroup = MACH_GROUP_BRCM;
7805 +    mips_machtype = MACH_BCM;
7806 +}
7807 +
7808 +/* --------------------------------------------------------------------------
7809 +    Name: prom_free_prom_memory
7810 +Abstract: 
7811 + -------------------------------------------------------------------------- */
7812 +void __init prom_free_prom_memory(void)
7813 +{
7814 +
7815 +}
7816 +
7817 +#if 0
7818 +#if defined(CONFIG_ROOT_NFS)
7819 +/* This function reads in a line that looks something like this:
7820 + *
7821 + *
7822 + * CFE bootline=bcmEnet(0,0)host:vmlinux e=192.169.0.100:ffffff00 h=192.169.0.1
7823 + *
7824 + *
7825 + * and retuns in the cmdline parameter some that looks like this:
7826 + *
7827 + * CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/opt/targets/96345R/fs
7828 + * ip=192.168.0.100:192.168.0.1::255.255.255.0::eth0:off rw"
7829 + */
7830 +#define BOOT_LINE_ADDR   0x0
7831 +#define HEXDIGIT(d) ((d >= '0' && d <= '9') ? (d - '0') : ((d | 0x20) - 'W'))
7832 +#define HEXBYTE(b)  (HEXDIGIT((b)[0]) << 4) + HEXDIGIT((b)[1])
7833 +extern unsigned long get_nvram_start_addr(void);
7834 +
7835 +void __init create_root_nfs_cmdline( char *cmdline )
7836 +{
7837 +    char root_nfs_cl[] = "root=/dev/nfs nfsroot=%s:" CONFIG_ROOT_NFS_DIR
7838 +        " ip=%s:%s::%s::eth0:off rw";
7839 +
7840 +    char *localip = NULL;
7841 +    char *hostip = NULL;
7842 +    char mask[16] = "";
7843 +    PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7844 +    char bootline[128] = "";
7845 +    char *p = bootline;
7846 +
7847 +    memcpy(bootline, pNvramData->szBootline, sizeof(bootline));
7848 +    while( *p )
7849 +    {
7850 +        if( p[0] == 'e' && p[1] == '=' )
7851 +        {
7852 +            /* Found local ip address */
7853 +            p += 2;
7854 +            localip = p;
7855 +            while( *p && *p != ' ' && *p != ':' )
7856 +                p++;
7857 +            if( *p == ':' )
7858 +            {
7859 +                /* Found network mask (eg FFFFFF00 */
7860 +                *p++ = '\0';
7861 +                sprintf( mask, "%u.%u.%u.%u", HEXBYTE(p), HEXBYTE(p + 2),
7862 +                HEXBYTE(p + 4), HEXBYTE(p + 6) );
7863 +                p += 4;
7864 +            }
7865 +            else if( *p == ' ' )
7866 +                *p++ = '\0';
7867 +        }
7868 +        else if( p[0] == 'h' && p[1] == '=' )
7869 +        {
7870 +            /* Found host ip address */
7871 +            p += 2;
7872 +            hostip = p;
7873 +            while( *p && *p != ' ' )
7874 +                p++;
7875 +            if( *p == ' ' )
7876 +                    *p++ = '\0';
7877 +        }
7878 +        else 
7879 +            p++;
7880 +    }
7881 +
7882 +    if( localip && hostip ) 
7883 +        sprintf( cmdline, root_nfs_cl, hostip, localip, hostip, mask );
7884 +}
7885 +#endif
7886 +#endif
7887 +
7888 +#if defined(CONFIG_BCM96348)
7889 +/*  *********************************************************************
7890 +    *  calculateCpuSpeed()
7891 +    *      Calculate the BCM6348 CPU speed by reading the PLL strap register
7892 +    *      and applying the following formula:
7893 +    *      cpu_clk = (.25 * 64MHz freq) * (N1 + 1) * (N2 + 2) / (M1_CPU + 1)
7894 +    *  Input parameters:
7895 +    *      none
7896 +    *  Return value:
7897 +    *      none
7898 +    ********************************************************************* */
7899 +void __init calculateCpuSpeed(void)
7900 +{
7901 +    UINT32 pllStrap = PERF->PllStrap;
7902 +    int n1 = (pllStrap & PLL_N1_MASK) >> PLL_N1_SHFT;
7903 +    int n2 = (pllStrap & PLL_N2_MASK) >> PLL_N2_SHFT;
7904 +    int m1cpu = (pllStrap & PLL_M1_CPU_MASK) >> PLL_M1_CPU_SHFT;
7905 +
7906 +    cpu_speed = (16 * (n1 + 1) * (n2 + 2) / (m1cpu + 1)) * 1000000;
7907 +}
7908 +#endif
7909 +
7910 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c
7911 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c      1970-01-01 01:00:00.000000000 +0100
7912 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c     2006-08-03 16:36:58.000000000 +0200
7913 @@ -0,0 +1,180 @@
7914 +/*
7915 +<:copyright-gpl 
7916 + Copyright 2004 Broadcom Corp. All Rights Reserved. 
7917
7918 + This program is free software; you can distribute it and/or modify it 
7919 + under the terms of the GNU General Public License (Version 2) as 
7920 + published by the Free Software Foundation. 
7921
7922 + This program is distributed in the hope it will be useful, but WITHOUT 
7923 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
7924 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
7925 + for more details. 
7926
7927 + You should have received a copy of the GNU General Public License along 
7928 + with this program; if not, write to the Free Software Foundation, Inc., 
7929 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
7930 +:>
7931 +*/
7932 +/*
7933 + *  Broadcom bcm63xx serial port initialization, also prepare for printk
7934 + *  by registering with console_init
7935 + *   
7936 + */
7937 +
7938 +#include <linux/config.h>
7939 +#include <linux/init.h>
7940 +#include <linux/interrupt.h>
7941 +#include <linux/kernel.h>
7942 +#include <linux/types.h>
7943 +#include <linux/console.h>
7944 +#include <linux/sched.h>
7945 +
7946 +#include <asm/addrspace.h>
7947 +#include <asm/irq.h>
7948 +#include <asm/reboot.h>
7949 +#include <asm/gdb-stub.h>
7950 +#include <asm/mc146818rtc.h> 
7951 +
7952 +#include <bcm_map_part.h>
7953 +#include <board.h>
7954 +
7955 +#define  SER63XX_DEFAULT_BAUD      115200
7956 +#define BD_BCM63XX_TIMER_CLOCK_INPUT    (FPERIPH)
7957 +#define stUart ((volatile Uart * const) UART_BASE)
7958 +
7959 +// Transmit interrupts
7960 +#define TXINT       (TXFIFOEMT | TXUNDERR | TXOVFERR)
7961 +// Receive interrupts
7962 +#define RXINT       (RXFIFONE | RXOVFERR)
7963 +
7964 +/* --------------------------------------------------------------------------
7965 +    Name: serial_init
7966 + Purpose: Initalize the UART
7967 +-------------------------------------------------------------------------- */
7968 +void __init serial_init(void)
7969 +{
7970 +    UINT32 tmpVal = SER63XX_DEFAULT_BAUD;
7971 +    ULONG clockFreqHz;    
7972 +
7973 +#if defined(CONFIG_BCM96345)
7974 +    // Make sure clock is ticking
7975 +    PERF->blkEnables |= UART_CLK_EN;
7976 +#endif
7977 +               
7978 +    /* Dissable channel's receiver and transmitter.                */
7979 +    stUart->control &= ~(BRGEN|TXEN|RXEN);
7980 +               
7981 +    /*--------------------------------------------------------------------*/
7982 +    /* Write the table value to the clock select register.                */
7983 +    /* DPullen - this is the equation to use:                             */
7984 +    /*       value = clockFreqHz / baud / 32-1;                           */
7985 +    /*   (snmod) Actually you should also take into account any necessary */
7986 +    /*           rounding.  Divide by 16, look at lsb, if 0, divide by 2  */
7987 +    /*           and subtract 1.  If 1, just divide by 2                  */
7988 +    /*--------------------------------------------------------------------*/
7989 +    clockFreqHz = BD_BCM63XX_TIMER_CLOCK_INPUT;
7990 +    tmpVal = (clockFreqHz / tmpVal) / 16;
7991 +    if( tmpVal & 0x01 )
7992 +        tmpVal /= 2;  //Rounding up, so sub is already accounted for
7993 +    else
7994 +        tmpVal = (tmpVal / 2) - 1; // Rounding down so we must sub 1
7995 +    stUart->baudword = tmpVal;
7996 +        
7997 +    /* Finally, re-enable the transmitter and receiver.            */
7998 +    stUart->control |= (BRGEN|TXEN|RXEN);
7999 +
8000 +    stUart->config   = (BITS8SYM | ONESTOP);
8001 +    // Set the FIFO interrupt depth ... stUart->fifocfg  = 0xAA;
8002 +    stUart->fifoctl  =  RSTTXFIFOS | RSTRXFIFOS;
8003 +    stUart->intMask  = 0;       
8004 +    stUart->intMask = RXINT | TXINT;
8005 +}
8006 +
8007 +
8008 +/* prom_putc()
8009 + * Output a character to the UART
8010 + */
8011 +void prom_putc(char c)
8012 +{
8013 +       /* Wait for Tx uffer to empty */
8014 +       while (! (READ16(stUart->intStatus) & TXFIFOEMT));
8015 +       /* Send character */
8016 +       stUart->Data = c;
8017 +}
8018 +
8019 +/* prom_puts()
8020 + * Write a string to the UART
8021 + */
8022 +void prom_puts(const char *s)
8023 +{
8024 +       while (*s) {
8025 +               if (*s == '\n') {
8026 +                       prom_putc('\r');
8027 +               }
8028 +               prom_putc(*s++);
8029 +       }
8030 +}
8031 +
8032 +
8033 +/* prom_getc_nowait()
8034 + * Returns a character from the UART
8035 + * Returns -1 if no characters available or corrupted
8036 + */
8037 +int prom_getc_nowait(void)
8038 +{
8039 +    uint16  uStatus;
8040 +    int    cData = -1;
8041 +
8042 +     uStatus = READ16(stUart->intStatus);
8043 +
8044 +     if (uStatus & RXFIFONE) { /* Do we have a character? */
8045 +           cData =  READ16(stUart->Data) & 0xff; /* Read character */
8046 +           if (uStatus & (RXFRAMERR | RXPARERR)) {  /* If we got an error, throw it away */
8047 +               cData = -1;
8048 +           }
8049 +  }
8050 +
8051 +   return cData;
8052 +}
8053 +
8054 +/* prom_getc()
8055 + * Returns a charcter from the serial port
8056 + * Will block until it receives a valid character
8057 +*/
8058 +char prom_getc(void)
8059 +{
8060 +    int    cData = -1;
8061 +
8062 +    /* Loop until we get a valid character */
8063 +    while(cData == -1) {
8064 +       cData = prom_getc_nowait();
8065 +    }
8066 +   return (char) cData;
8067 +}
8068 +
8069 +/* prom_testc()
8070 + * Returns 0 if no characters available
8071 + */
8072 +int prom_testc(void)
8073 +{
8074 +    uint16  uStatus;
8075 +
8076 +     uStatus = READ16(stUart->intStatus);
8077 +
8078 +     return (uStatus & RXFIFONE);
8079 +}
8080 +
8081 +#if defined (CONFIG_REMOTE_DEBUG)
8082 +/* Prevent other code from writing to the serial port */
8083 +void _putc(char c) { }
8084 +void _puts(const char *ptr) { }
8085 +#else
8086 +/* Low level outputs call prom routines */
8087 +void _putc(char c) {
8088 +       prom_putc(c);
8089 +}
8090 +void _puts(const char *ptr) {
8091 +       prom_puts(ptr);
8092 +}
8093 +#endif
8094 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c
8095 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c 1970-01-01 01:00:00.000000000 +0100
8096 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c        2006-08-03 16:36:58.000000000 +0200
8097 @@ -0,0 +1,523 @@
8098 +/*
8099 +<:copyright-gpl 
8100 + Copyright 2002 Broadcom Corp. All Rights Reserved. 
8101
8102 + This program is free software; you can distribute it and/or modify it 
8103 + under the terms of the GNU General Public License (Version 2) as 
8104 + published by the Free Software Foundation. 
8105
8106 + This program is distributed in the hope it will be useful, but WITHOUT 
8107 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
8108 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
8109 + for more details. 
8110
8111 + You should have received a copy of the GNU General Public License along 
8112 + with this program; if not, write to the Free Software Foundation, Inc., 
8113 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
8114 +:>
8115 +*/
8116 +/*
8117 + * Generic setup routines for Broadcom 963xx MIPS boards
8118 + */
8119 +
8120 +#include <linux/config.h>
8121 +#include <linux/init.h>
8122 +#include <linux/interrupt.h>
8123 +#include <linux/kernel.h>
8124 +#include <linux/kdev_t.h>
8125 +#include <linux/types.h>
8126 +#include <linux/console.h>
8127 +#include <linux/sched.h>
8128 +#include <linux/mm.h>
8129 +#include <linux/slab.h>
8130 +#include <linux/module.h>
8131 +#include <linux/pm.h>
8132 +
8133 +#include <asm/addrspace.h>
8134 +#include <asm/bcache.h>
8135 +#include <asm/irq.h>
8136 +#include <asm/time.h>
8137 +#include <asm/reboot.h>
8138 +#include <asm/gdb-stub.h>
8139 +
8140 +extern void brcm_timer_setup(struct irqaction *irq);
8141 +extern unsigned long getMemorySize(void);
8142 +
8143 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8144 +#include <linux/pci.h>
8145 +#include <linux/delay.h>
8146 +#include <bcm_map_part.h>
8147 +#include <bcmpci.h>
8148 +
8149 +static volatile MpiRegisters * mpi = (MpiRegisters *)(MPI_BASE);
8150 +#endif
8151 +
8152 +/* This function should be in a board specific directory.  For now,
8153 + * assume that all boards that include this file use a Broadcom chip
8154 + * with a soft reset bit in the PLL control register.
8155 + */
8156 +static void brcm_machine_restart(char *command)
8157 +{
8158 +    const unsigned long ulSoftReset = 0x00000001;
8159 +    unsigned long *pulPllCtrl = (unsigned long *) 0xfffe0008;
8160 +    *pulPllCtrl |= ulSoftReset;
8161 +}
8162 +
8163 +static void brcm_machine_halt(void)
8164 +{
8165 +    printk("System halted\n");
8166 +    while (1);
8167 +}
8168 +
8169 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8170 +
8171 +static void mpi_SetLocalPciConfigReg(uint32 reg, uint32 value)
8172 +{
8173 +    /* write index then value */
8174 +    mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
8175 +    mpi->pcicfgdata = value;
8176 +}
8177 +
8178 +static uint32 mpi_GetLocalPciConfigReg(uint32 reg)
8179 +{
8180 +    /* write index then get value */
8181 +    mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
8182 +    return mpi->pcicfgdata;
8183 +}
8184 +
8185 +/*
8186 + * mpi_ResetPcCard: Set/Reset the PcCard
8187 + */
8188 +static void mpi_ResetPcCard(int cardtype, BOOL bReset)
8189 +{
8190 +    if (cardtype == MPI_CARDTYPE_NONE) {
8191 +        return;
8192 +    }
8193 +
8194 +    if (cardtype == MPI_CARDTYPE_CARDBUS) {
8195 +        bReset = ! bReset;
8196 +    }
8197 +
8198 +    if (bReset) {
8199 +        mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8200 +    } else {
8201 +        mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 | PCCARD_CARD_RESET);
8202 +    }
8203 +}
8204 +
8205 +/*
8206 + * mpi_ConfigCs: Configure an MPI/EBI chip select
8207 + */
8208 +static void mpi_ConfigCs(uint32 cs, uint32 base, uint32 size, uint32 flags)
8209 +{
8210 +    mpi->cs[cs].base = ((base & 0x1FFFFFFF) | size);
8211 +    mpi->cs[cs].config = flags;
8212 +}
8213 +
8214 +/*
8215 + * mpi_InitPcmciaSpace
8216 + */
8217 +static void mpi_InitPcmciaSpace(void)
8218 +{
8219 +    // ChipSelect 4 controls PCMCIA Memory accesses
8220 +    mpi_ConfigCs(PCMCIA_COMMON_BASE, pcmciaMem, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8221 +    // ChipSelect 5 controls PCMCIA Attribute accesses
8222 +    mpi_ConfigCs(PCMCIA_ATTRIBUTE_BASE, pcmciaAttr, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8223 +    // ChipSelect 6 controls PCMCIA I/O accesses
8224 +    mpi_ConfigCs(PCMCIA_IO_BASE, pcmciaIo, EBI_SIZE_64K, (EBI_WORD_WIDE|EBI_ENABLE));
8225 +
8226 +    mpi->pcmcia_cntl2 = ((PCMCIA_ATTR_ACTIVE << RW_ACTIVE_CNT_BIT) | 
8227 +                         (PCMCIA_ATTR_INACTIVE << INACTIVE_CNT_BIT) | 
8228 +                         (PCMCIA_ATTR_CE_SETUP << CE_SETUP_CNT_BIT) | 
8229 +                         (PCMCIA_ATTR_CE_HOLD << CE_HOLD_CNT_BIT));
8230 +
8231 +    mpi->pcmcia_cntl2 |= (PCMCIA_HALFWORD_EN | PCMCIA_BYTESWAP_DIS);
8232 +}
8233 +
8234 +/*
8235 + * cardtype_vcc_detect: PC Card's card detect and voltage sense connection
8236 + * 
8237 + *   CD1#/      CD2#/     VS1#/     VS2#/    Card       Initial Vcc
8238 + *  CCD1#      CCD2#     CVS1      CVS2      Type
8239 + *
8240 + *   GND        GND       open      open     16-bit     5 vdc
8241 + *
8242 + *   GND        GND       GND       open     16-bit     3.3 vdc
8243 + *
8244 + *   GND        GND       open      GND      16-bit     x.x vdc
8245 + *
8246 + *   GND        GND       GND       GND      16-bit     3.3 & x.x vdc
8247 + *
8248 + *====================================================================
8249 + *
8250 + *   CVS1       GND       CCD1#     open     CardBus    3.3 vdc
8251 + *
8252 + *   GND        CVS2      open      CCD2#    CardBus    x.x vdc
8253 + *
8254 + *   GND        CVS1      CCD2#     open     CardBus    y.y vdc
8255 + *
8256 + *   GND        CVS2      GND       CCD2#    CardBus    3.3 & x.x vdc
8257 + *
8258 + *   CVS2       GND       open      CCD1#    CardBus    x.x & y.y vdc
8259 + *
8260 + *   GND        CVS1      CCD2#     open     CardBus    3.3, x.x & y.y vdc
8261 + *
8262 + */
8263 +static int cardtype_vcc_detect(void)
8264 +{
8265 +    uint32 data32;
8266 +    int cardtype;
8267 +
8268 +    cardtype = MPI_CARDTYPE_NONE;
8269 +    mpi->pcmcia_cntl1 = 0x0000A000; // Turn on the output enables and drive
8270 +                                        // the CVS pins to 0.
8271 +    data32 = mpi->pcmcia_cntl1;
8272 +    switch (data32 & 0x00000003)  // Test CD1# and CD2#, see if card is plugged in.
8273 +    {
8274 +    case 0x00000003:  // No Card is in the slot.
8275 +        printk("mpi: No Card is in the PCMCIA slot\n");
8276 +        break;
8277 +
8278 +    case 0x00000002:  // Partial insertion, No CD2#.
8279 +        printk("mpi: Card in the PCMCIA slot partial insertion, no CD2 signal\n");
8280 +        break;
8281 +
8282 +    case 0x00000001:  // Partial insertion, No CD1#.
8283 +        printk("mpi: Card in the PCMCIA slot partial insertion, no CD1 signal\n");
8284 +        break;
8285 +
8286 +    case 0x00000000:
8287 +        mpi->pcmcia_cntl1 = 0x0000A0C0; // Turn off the CVS output enables and
8288 +                                        // float the CVS pins.
8289 +        mdelay(1);
8290 +        data32 = mpi->pcmcia_cntl1;
8291 +        // Read the Register.
8292 +        switch (data32 & 0x0000000C)  // See what is on the CVS pins.
8293 +        {
8294 +        case 0x00000000: // CVS1 and CVS2 are tied to ground, only 1 option.
8295 +            printk("mpi: Detected 3.3 & x.x 16-bit PCMCIA card\n");
8296 +            cardtype = MPI_CARDTYPE_PCMCIA;
8297 +            break;
8298 +          
8299 +        case 0x00000004: // CVS1 is open or tied to CCD1/CCD2 and CVS2 is tied to ground.
8300 +                         // 2 valid voltage options.
8301 +        switch (data32 & 0x00000003)  // Test the values of CCD1 and CCD2.
8302 +        {
8303 +            case 0x00000003:  // CCD1 and CCD2 are tied to 1 of the CVS pins.
8304 +                              // This is not a valid combination.
8305 +                printk("mpi: Unknown card plugged into slot\n"); 
8306 +                break;
8307 +      
8308 +            case 0x00000002:  // CCD2 is tied to either CVS1 or CVS2. 
8309 +                mpi->pcmcia_cntl1 = 0x0000A080; // Drive CVS1 to a 0.
8310 +                mdelay(1);
8311 +                data32 = mpi->pcmcia_cntl1;
8312 +                if (data32 & 0x00000002) { // CCD2 is tied to CVS2, not valid.
8313 +                    printk("mpi: Unknown card plugged into slot\n"); 
8314 +                } else {                   // CCD2 is tied to CVS1.
8315 +                    printk("mpi: Detected 3.3, x.x and y.y Cardbus card\n");
8316 +                    cardtype = MPI_CARDTYPE_CARDBUS;
8317 +                }
8318 +                break;
8319 +                
8320 +            case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8321 +                             // This is not a valid combination.
8322 +                printk("mpi: Unknown card plugged into slot\n"); 
8323 +                break;
8324 +                
8325 +            case 0x00000000:  // CCD1 and CCD2 are tied to ground.
8326 +                printk("mpi: Detected x.x vdc 16-bit PCMCIA card\n");
8327 +                cardtype = MPI_CARDTYPE_PCMCIA;
8328 +                break;
8329 +            }
8330 +            break;
8331 +          
8332 +        case 0x00000008: // CVS2 is open or tied to CCD1/CCD2 and CVS1 is tied to ground.
8333 +                         // 2 valid voltage options.
8334 +            switch (data32 & 0x00000003)  // Test the values of CCD1 and CCD2.
8335 +            {
8336 +            case 0x00000003:  // CCD1 and CCD2 are tied to 1 of the CVS pins.
8337 +                              // This is not a valid combination.
8338 +                printk("mpi: Unknown card plugged into slot\n"); 
8339 +                break;
8340 +      
8341 +            case 0x00000002:  // CCD2 is tied to either CVS1 or CVS2.
8342 +                mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8343 +                mdelay(1);
8344 +                data32 = mpi->pcmcia_cntl1;
8345 +                if (data32 & 0x00000002) { // CCD2 is tied to CVS1, not valid.
8346 +                    printk("mpi: Unknown card plugged into slot\n"); 
8347 +                } else {// CCD2 is tied to CVS2.
8348 +                    printk("mpi: Detected 3.3 and x.x Cardbus card\n");
8349 +                    cardtype = MPI_CARDTYPE_CARDBUS;
8350 +                }
8351 +                break;
8352 +
8353 +            case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8354 +                             // This is not a valid combination.
8355 +                printk("mpi: Unknown card plugged into slot\n"); 
8356 +                break;
8357 +
8358 +            case 0x00000000:  // CCD1 and CCD2 are tied to ground.
8359 +                cardtype = MPI_CARDTYPE_PCMCIA;
8360 +                printk("mpi: Detected 3.3 vdc 16-bit PCMCIA card\n");
8361 +                break;
8362 +            }
8363 +            break;
8364 +          
8365 +        case 0x0000000C:  // CVS1 and CVS2 are open or tied to CCD1/CCD2.
8366 +                          // 5 valid voltage options.
8367 +      
8368 +            switch (data32 & 0x00000003)  // Test the values of CCD1 and CCD2.
8369 +            {
8370 +            case 0x00000003:  // CCD1 and CCD2 are tied to 1 of the CVS pins.
8371 +                              // This is not a valid combination.
8372 +                printk("mpi: Unknown card plugged into slot\n"); 
8373 +                break;
8374 +      
8375 +            case 0x00000002:  // CCD2 is tied to either CVS1 or CVS2.
8376 +                              // CCD1 is tied to ground.
8377 +                mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8378 +                mdelay(1);
8379 +                data32 = mpi->pcmcia_cntl1;
8380 +                if (data32 & 0x00000002) {  // CCD2 is tied to CVS1.
8381 +                    printk("mpi: Detected y.y vdc Cardbus card\n");
8382 +                } else {                    // CCD2 is tied to CVS2.
8383 +                    printk("mpi: Detected x.x vdc Cardbus card\n");
8384 +                }
8385 +                cardtype = MPI_CARDTYPE_CARDBUS;
8386 +                break;
8387 +      
8388 +            case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8389 +                             // CCD2 is tied to ground.
8390 +      
8391 +                mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8392 +                mdelay(1);
8393 +                data32 = mpi->pcmcia_cntl1;
8394 +                if (data32 & 0x00000001) {// CCD1 is tied to CVS1.
8395 +                    printk("mpi: Detected 3.3 vdc Cardbus card\n");
8396 +                } else {                    // CCD1 is tied to CVS2.
8397 +                    printk("mpi: Detected x.x and y.y Cardbus card\n");
8398 +                }
8399 +                cardtype = MPI_CARDTYPE_CARDBUS;
8400 +                break;
8401 +      
8402 +            case 0x00000000:  // CCD1 and CCD2 are tied to ground.
8403 +                cardtype = MPI_CARDTYPE_PCMCIA;
8404 +                printk("mpi: Detected 5 vdc 16-bit PCMCIA card\n");
8405 +                break;
8406 +            }
8407 +            break;
8408 +      
8409 +        default:
8410 +            printk("mpi: Unknown card plugged into slot\n"); 
8411 +            break;
8412 +        
8413 +        }
8414 +    }
8415 +    return cardtype;
8416 +}
8417 +
8418 +/*
8419 + * mpi_DetectPcCard: Detect the plugged in PC-Card
8420 + * Return: < 0 => Unknown card detected
8421 + *         0 => No card detected
8422 + *         1 => 16-bit card detected
8423 + *         2 => 32-bit CardBus card detected
8424 + */
8425 +static int mpi_DetectPcCard(void)
8426 +{
8427 +    int cardtype;
8428 +
8429 +    cardtype = cardtype_vcc_detect();
8430 +    switch(cardtype) {
8431 +        case MPI_CARDTYPE_PCMCIA:
8432 +            mpi->pcmcia_cntl1 &= ~0x0000e000; // disable enable bits
8433 +            //mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8434 +            mpi->pcmcia_cntl1 |= (PCMCIA_ENABLE | PCMCIA_GPIO_ENABLE);
8435 +            mpi_InitPcmciaSpace();
8436 +            mpi_ResetPcCard(cardtype, FALSE);
8437 +            // Hold card in reset for 10ms
8438 +            mdelay(10);
8439 +            mpi_ResetPcCard(cardtype, TRUE);
8440 +            // Let card come out of reset
8441 +            mdelay(100);
8442 +            break;
8443 +        case MPI_CARDTYPE_CARDBUS:
8444 +            // 8 => CardBus Enable
8445 +            // 1 => PCI Slot Number
8446 +            // C => Float VS1 & VS2
8447 +            mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & 0xFFFF0000) | 
8448 +                                CARDBUS_ENABLE | 
8449 +                                (CARDBUS_SLOT << 8)| 
8450 +                                VS2_OEN |
8451 +                                VS1_OEN;
8452 +            /* access to this memory window will be to/from CardBus */
8453 +            mpi->l2pmremap1 |= CARDBUS_MEM;
8454 +
8455 +            // Need to reset the Cardbus Card. There's no CardManager to do this, 
8456 +            // and we need to be ready for PCI configuration. 
8457 +            mpi_ResetPcCard(cardtype, FALSE);
8458 +            // Hold card in reset for 10ms
8459 +            mdelay(10);
8460 +            mpi_ResetPcCard(cardtype, TRUE);
8461 +            // Let card come out of reset
8462 +            mdelay(100);
8463 +            break;
8464 +        default:
8465 +            break;
8466 +    }
8467 +    return cardtype;
8468 +}
8469 +
8470 +static int mpi_init(void)
8471 +{
8472 +    unsigned long data;
8473 +    unsigned int chipid;
8474 +    unsigned int chiprev;
8475 +    unsigned int sdramsize;
8476 +
8477 +    chipid  = (PERF->RevID & 0xFFFF0000) >> 16;
8478 +    chiprev = (PERF->RevID & 0xFF);
8479 +    sdramsize = getMemorySize();
8480 +    /*
8481 +     * Init the pci interface 
8482 +     */
8483 +    data = GPIO->GPIOMode; // GPIO mode register
8484 +    data |= GROUP2_PCI | GROUP1_MII_PCCARD; // PCI internal arbiter + Cardbus
8485 +    GPIO->GPIOMode = data; // PCI internal arbiter
8486 +
8487 +    /*
8488 +     * In the BCM6348 CardBus support is defaulted to Slot 0
8489 +     * because there is no external IDSEL for CardBus.  To disable
8490 +     * the CardBus and allow a standard PCI card in Slot 0 
8491 +     * set the cbus_idsel field to 0x1f.
8492 +    */
8493 +    /*
8494 +    uData = mpi->pcmcia_cntl1;
8495 +    uData |= CARDBUS_IDSEL;
8496 +    mpi->pcmcia_cntl1 = uData;
8497 +    */
8498 +    // Setup PCI I/O Window range. Give 64K to PCI I/O
8499 +    mpi->l2piorange = ~(BCM_PCI_IO_SIZE_64KB-1);
8500 +    // UBUS to PCI I/O base address 
8501 +    mpi->l2piobase = BCM_PCI_IO_BASE & BCM_PCI_ADDR_MASK;
8502 +    // UBUS to PCI I/O Window remap
8503 +    mpi->l2pioremap = (BCM_PCI_IO_BASE | MEM_WINDOW_EN);
8504 +
8505 +    // enable PCI related GPIO pins and data swap between system and PCI bus
8506 +    mpi->locbuscntrl = (EN_PCI_GPIO | DIR_U2P_NOSWAP);
8507 +
8508 +    /* Enable 6348 BusMaster and Memory access mode */
8509 +    data = mpi_GetLocalPciConfigReg(PCI_COMMAND);
8510 +    data |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
8511 +    mpi_SetLocalPciConfigReg(PCI_COMMAND, data);
8512 +
8513 +    /* Configure two 16 MByte PCI to System memory regions. */
8514 +    /* These memory regions are used when PCI device is a bus master */
8515 +    /* Accesses to the SDRAM from PCI bus will be "byte swapped" for this region */
8516 +    mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_3, BCM_HOST_MEM_SPACE1);
8517 +    mpi->sp0remap = 0x0;
8518 +
8519 +    /* Accesses to the SDRAM from PCI bus will not be "byte swapped" for this region */
8520 +    mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_4, BCM_HOST_MEM_SPACE2);
8521 +    mpi->sp1remap = 0x0;
8522 +    mpi->pcimodesel |= (PCI_BAR2_NOSWAP | 0x40);
8523 +
8524 +    if ((chipid == 0x6348) && (chiprev == 0xb0)) {
8525 +        mpi->sp0range = ~(sdramsize-1);
8526 +        mpi->sp1range = ~(sdramsize-1);
8527 +    }
8528 +    /*
8529 +     * Change 6348 PCI Cfg Reg. offset 0x40 to PCI memory read retry count infinity
8530 +     * by set 0 in bit 8~15.  This resolve read Bcm4306 srom return 0xffff in
8531 +     * first read.
8532 +     */
8533 +    data = mpi_GetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER);
8534 +    data &= ~BRCM_PCI_CONFIG_TIMER_RETRY_MASK;
8535 +    data |= 0x00000080;
8536 +    mpi_SetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER, data);
8537 +
8538 +    /* enable pci interrupt */
8539 +    mpi->locintstat |= (EXT_PCI_INT << 16);
8540 +
8541 +    mpi_DetectPcCard();
8542 +
8543 +    ioport_resource.start = BCM_PCI_IO_BASE;
8544 +    ioport_resource.end = BCM_PCI_IO_BASE + BCM_PCI_IO_SIZE_64KB;
8545 +
8546 +#if defined(CONFIG_USB)
8547 +    PERF->blkEnables |= USBH_CLK_EN;
8548 +    mdelay(100);
8549 +    *USBH_NON_OHCI = NON_OHCI_BYTE_SWAP;
8550 +#endif
8551 +
8552 +    return 0;
8553 +}
8554 +#endif
8555 +
8556 +static int __init brcm63xx_setup(void)
8557 +{
8558 +    extern int panic_timeout;
8559 +
8560 +    _machine_restart = brcm_machine_restart;
8561 +    _machine_halt = brcm_machine_halt;
8562 +    pm_power_off = brcm_machine_halt;
8563 +
8564 +    board_timer_setup = brcm_timer_setup;
8565 +
8566 +    panic_timeout = 5;
8567 +
8568 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8569 +    /* mpi initialization */
8570 +    mpi_init();
8571 +#endif
8572 +    return 0;
8573 +}
8574 +
8575 +void plat_setup(void)
8576 +{
8577 +    brcm63xx_setup();
8578 +}
8579 +
8580 +/***************************************************************************
8581 + * C++ New and delete operator functions
8582 + ***************************************************************************/
8583 +
8584 +/* void *operator new(unsigned int sz) */
8585 +void *_Znwj(unsigned int sz)
8586 +{
8587 +    return( kmalloc(sz, GFP_KERNEL) );
8588 +}
8589 +
8590 +/* void *operator new[](unsigned int sz)*/
8591 +void *_Znaj(unsigned int sz)
8592 +{
8593 +    return( kmalloc(sz, GFP_KERNEL) );
8594 +}
8595 +
8596 +/* placement new operator */
8597 +/* void *operator new (unsigned int size, void *ptr) */
8598 +void *ZnwjPv(unsigned int size, void *ptr)
8599 +{
8600 +    return ptr;
8601 +}
8602 +
8603 +/* void operator delete(void *m) */
8604 +void _ZdlPv(void *m)
8605 +{
8606 +    kfree(m);
8607 +}
8608 +
8609 +/* void operator delete[](void *m) */
8610 +void _ZdaPv(void *m)
8611 +{
8612 +    kfree(m);
8613 +}
8614 +
8615 +EXPORT_SYMBOL(_Znwj);
8616 +EXPORT_SYMBOL(_Znaj);
8617 +EXPORT_SYMBOL(ZnwjPv);
8618 +EXPORT_SYMBOL(_ZdlPv);
8619 +EXPORT_SYMBOL(_ZdaPv);
8620 +
8621 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h
8622 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h  1970-01-01 01:00:00.000000000 +0100
8623 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 2006-08-03 16:36:58.000000000 +0200
8624 @@ -0,0 +1,2 @@
8625 +#define ADSL_SDRAM_IMAGE_SIZE (384*1024)
8626 +
8627 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c
8628 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c  1970-01-01 01:00:00.000000000 +0100
8629 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c 2006-08-03 16:36:58.000000000 +0200
8630 @@ -0,0 +1,277 @@
8631 +/*
8632 +<:copyright-gpl
8633 + Copyright 2004 Broadcom Corp. All Rights Reserved.
8634 +
8635 + This program is free software; you can distribute it and/or modify it
8636 + under the terms of the GNU General Public License (Version 2) as
8637 + published by the Free Software Foundation.
8638 +
8639 + This program is distributed in the hope it will be useful, but WITHOUT
8640 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8641 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8642 + for more details.
8643 +
8644 + You should have received a copy of the GNU General Public License along
8645 + with this program; if not, write to the Free Software Foundation, Inc.,
8646 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8647 +:>
8648 +*/
8649 +/*
8650 + * Setup time for Broadcom 963xx MIPS boards
8651 + */
8652 +
8653 +#include <linux/config.h>
8654 +#include <linux/init.h>
8655 +#include <linux/kernel_stat.h>
8656 +#include <linux/sched.h>
8657 +#include <linux/spinlock.h>
8658 +#include <linux/interrupt.h>
8659 +#include <linux/module.h>
8660 +#include <linux/time.h>
8661 +#include <linux/timex.h>
8662 +
8663 +#include <asm/mipsregs.h>
8664 +#include <asm/ptrace.h>
8665 +#include <asm/div64.h>
8666 +#include <asm/time.h>
8667 +
8668 +#include <bcm_map_part.h>
8669 +#include <bcm_intr.h>
8670 +
8671 +unsigned long r4k_interval;    /* Amount to increment compare reg each time */
8672 +static unsigned long r4k_cur;  /* What counter should be at next timer irq */
8673 +
8674 +/* Cycle counter value at the previous timer interrupt.. */
8675 +static unsigned int timerhi = 0, timerlo = 0;
8676 +
8677 +extern volatile unsigned long wall_jiffies;
8678 +
8679 +/* Optional board-specific timer routine */
8680 +void (*board_timer_interrupt)(int irq, void *dev_id, struct pt_regs * regs);
8681 +
8682 +static inline void ack_r4ktimer(unsigned long newval)
8683 +{
8684 +       write_c0_compare(newval);
8685 +}
8686 +
8687 +/*
8688 + * There are a lot of conceptually broken versions of the MIPS timer interrupt
8689 + * handler floating around.  This one is rather different, but the algorithm
8690 + * is provably more robust.
8691 + */
8692 +static irqreturn_t brcm_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
8693 +{
8694 +       unsigned int count;
8695 +
8696 +       if (r4k_interval == 0)
8697 +               goto null;
8698 +
8699 +       do {
8700 +               do_timer(regs);
8701 +
8702 +               if (board_timer_interrupt)
8703 +                       board_timer_interrupt(irq, dev_id, regs);
8704 +
8705 +               r4k_cur += r4k_interval;
8706 +               ack_r4ktimer(r4k_cur);
8707 +
8708 +       } while (((count = (unsigned long)read_c0_count())
8709 +                 - r4k_cur) < 0x7fffffff);
8710 +
8711 +       if (!jiffies) {
8712 +               /*
8713 +                * If jiffies has overflowed in this timer_interrupt we must
8714 +                * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
8715 +                * quotient calc still valid. -arca
8716 +                */
8717 +               timerhi = timerlo = 0;
8718 +       } else {
8719 +               /*
8720 +                * The cycle counter is only 32 bit which is good for about
8721 +                * a minute at current count rates of upto 150MHz or so.
8722 +                */
8723 +               timerhi += (count < timerlo);   /* Wrap around */
8724 +               timerlo = count;
8725 +       }
8726 +
8727 +       return IRQ_HANDLED;
8728 +
8729 +null:
8730 +       ack_r4ktimer(0);
8731 +       return IRQ_NONE;
8732 +}
8733 +
8734 +static struct irqaction brcm_timer_action = {
8735 +       .handler        = brcm_timer_interrupt,
8736 +       .flags          = SA_INTERRUPT,
8737 +       .mask           = CPU_MASK_NONE,
8738 +       .name           = "timer",
8739 +       .next           = NULL,
8740 +       .dev_id         = brcm_timer_interrupt,
8741 +};
8742 +
8743 +
8744 +void __init brcm_timer_setup(struct irqaction *irq)
8745 +{
8746 +       r4k_cur = (read_c0_count() + r4k_interval);
8747 +       write_c0_compare(r4k_cur);
8748 +
8749 +       /* we are using the cpu counter for timer interrupts */
8750 +        irq->handler = no_action;     /* we use our own handler */
8751 +       setup_irq(MIPS_TIMER_INT, &brcm_timer_action);
8752 +       set_c0_status(IE_IRQ5);
8753 +}
8754 +
8755 +#if 0
8756 +/* This is for machines which generate the exact clock. */
8757 +#define USECS_PER_JIFFY (1000000/HZ)
8758 +#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
8759 +
8760 +static void call_do_div64_32( unsigned long *res, unsigned int high,
8761 +    unsigned int low, unsigned long base )
8762 +{
8763 +    do_div64_32(*res, high, low, base);
8764 +}
8765 +
8766 +/*
8767 + * FIXME: Does playing with the RP bit in c0_status interfere with this code?
8768 + */
8769 +static unsigned long do_fast_gettimeoffset(void)
8770 +{
8771 +       u32 count;
8772 +       unsigned long res, tmp;
8773 +
8774 +       /* Last jiffy when do_fast_gettimeoffset() was called. */
8775 +       static unsigned long last_jiffies=0;
8776 +       unsigned long quotient;
8777 +
8778 +       /*
8779 +        * Cached "1/(clocks per usec)*2^32" value.
8780 +        * It has to be recalculated once each jiffy.
8781 +        */
8782 +       static unsigned long cached_quotient=0;
8783 +
8784 +       tmp = jiffies;
8785 +
8786 +       quotient = cached_quotient;
8787 +
8788 +       if (tmp && last_jiffies != tmp) {
8789 +               last_jiffies = tmp;
8790 +#ifdef CONFIG_CPU_MIPS32
8791 +               if (last_jiffies != 0) {
8792 +
8793 +                       unsigned long r0;
8794 +                       /* gcc 3.0.1 gets an internal compiler error if there are two
8795 +                        * do_div64_32 inline macros.  To work around this problem,
8796 +                        * do_div64_32 is called as a function.
8797 +                        */
8798 +                       call_do_div64_32(&r0, timerhi, timerlo, tmp);
8799 +                       call_do_div64_32(&quotient, USECS_PER_JIFFY,
8800 +                                   USECS_PER_JIFFY_FRAC, r0);
8801 +
8802 +                       cached_quotient = quotient;
8803 +
8804 +               }
8805 +#else
8806 +               __asm__(".set\tnoreorder\n\t"
8807 +                       ".set\tnoat\n\t"
8808 +                       ".set\tmips3\n\t"
8809 +                       "lwu\t%0,%2\n\t"
8810 +                       "dsll32\t$1,%1,0\n\t"
8811 +                       "or\t$1,$1,%0\n\t"
8812 +                       "ddivu\t$0,$1,%3\n\t"
8813 +                       "mflo\t$1\n\t"
8814 +                       "dsll32\t%0,%4,0\n\t"
8815 +                       "nop\n\t"
8816 +                       "ddivu\t$0,%0,$1\n\t"
8817 +                       "mflo\t%0\n\t"
8818 +                       ".set\tmips0\n\t"
8819 +                       ".set\tat\n\t"
8820 +                       ".set\treorder"
8821 +                       :"=&r" (quotient)
8822 +                       :"r" (timerhi),
8823 +                        "m" (timerlo),
8824 +                        "r" (tmp),
8825 +                        "r" (USECS_PER_JIFFY)
8826 +                       :"$1");
8827 +               cached_quotient = quotient;
8828 +#endif
8829 +       }
8830 +
8831 +       /* Get last timer tick in absolute kernel time */
8832 +       count = read_c0_count();
8833 +
8834 +       /* .. relative to previous jiffy (32 bits is enough) */
8835 +       count -= timerlo;
8836 +
8837 +       __asm__("multu\t%1,%2\n\t"
8838 +               "mfhi\t%0"
8839 +               :"=r" (res)
8840 +               :"r" (count),
8841 +                "r" (quotient));
8842 +
8843 +       /*
8844 +        * Due to possible jiffies inconsistencies, we need to check 
8845 +        * the result so that we'll get a timer that is monotonic.
8846 +        */
8847 +       if (res >= USECS_PER_JIFFY)
8848 +               res = USECS_PER_JIFFY-1;
8849 +
8850 +       return res;
8851 +}
8852 +
8853 +void do_gettimeofday(struct timeval *tv)
8854 +{
8855 +       unsigned int flags;
8856 +
8857 +       read_lock_irqsave (&xtime_lock, flags);
8858 +       tv->tv_sec = xtime.tv_sec;
8859 +       tv->tv_usec = xtime.tv_nsec/1000;
8860 +       tv->tv_usec += do_fast_gettimeoffset();
8861 +
8862 +       /*
8863 +        * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
8864 +        * is nonzero if the timer bottom half hasnt executed yet.
8865 +        */
8866 +       if (jiffies - wall_jiffies)
8867 +               tv->tv_usec += USECS_PER_JIFFY;
8868 +
8869 +       read_unlock_irqrestore (&xtime_lock, flags);
8870 +
8871 +       if (tv->tv_usec >= 1000000) {
8872 +               tv->tv_usec -= 1000000;
8873 +               tv->tv_sec++;
8874 +       }
8875 +}
8876 +
8877 +EXPORT_SYMBOL(do_gettimeofday);
8878 +
8879 +int do_settimeofday(struct timespec *tv)
8880 +{
8881 +       write_lock_irq (&xtime_lock);
8882 +
8883 +       /* This is revolting. We need to set the xtime.tv_usec correctly.
8884 +        * However, the value in this location is is value at the last tick.
8885 +        * Discover what correction gettimeofday would have done, and then
8886 +        * undo it!
8887 +        */
8888 +       tv->tv_nsec -= do_fast_gettimeoffset()*NSEC_PER_USEC;
8889 +
8890 +       if (tv->tv_nsec < 0) {
8891 +               tv->tv_nsec += 1000000*NSEC_PER_USEC;
8892 +               tv->tv_sec--;
8893 +       }
8894 +
8895 +       xtime.tv_sec = tv->tv_sec;
8896 +       xtime.tv_nsec = tv->tv_nsec;
8897 +       time_adjust = 0;                /* stop active adjtime() */
8898 +       time_status |= STA_UNSYNC;
8899 +       time_maxerror = NTP_PHASE_LIMIT;
8900 +       time_esterror = NTP_PHASE_LIMIT;
8901 +
8902 +       write_unlock_irq (&xtime_lock);
8903 +}
8904 +
8905 +EXPORT_SYMBOL(do_settimeofday);
8906 +
8907 +#endif
8908 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c
8909 --- linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c 1970-01-01 01:00:00.000000000 +0100
8910 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c        2006-08-03 16:36:58.000000000 +0200
8911 @@ -0,0 +1,260 @@
8912 +/*
8913 +<:copyright-gpl 
8914 + Copyright 2003 Broadcom Corp. All Rights Reserved. 
8915
8916 + This program is free software; you can distribute it and/or modify it 
8917 + under the terms of the GNU General Public License (Version 2) as 
8918 + published by the Free Software Foundation. 
8919
8920 + This program is distributed in the hope it will be useful, but WITHOUT 
8921 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
8922 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
8923 + for more details. 
8924
8925 + You should have received a copy of the GNU General Public License along 
8926 + with this program; if not, write to the Free Software Foundation, Inc., 
8927 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
8928 +:>
8929 +*/
8930 +
8931 +#include <linux/config.h>
8932 +#include <linux/tty.h>
8933 +#include <linux/major.h>
8934 +#include <linux/init.h>
8935 +#include <linux/console.h>
8936 +#include <linux/fs.h>
8937 +#include <linux/interrupt.h>
8938 +#include <linux/kernel.h>
8939 +#include <linux/types.h>
8940 +#include <linux/sched.h>
8941 +
8942 +#include <bcm_map_part.h>
8943 +
8944 +#undef PRNT                            /* define for debug printing */
8945 +
8946 +#define         UART16550_BAUD_2400             2400
8947 +#define         UART16550_BAUD_4800             4800
8948 +#define         UART16550_BAUD_9600             9600
8949 +#define         UART16550_BAUD_19200            19200
8950 +#define         UART16550_BAUD_38400            38400
8951 +#define         UART16550_BAUD_57600            57600
8952 +#define         UART16550_BAUD_115200           115200
8953 +
8954 +#define         UART16550_PARITY_NONE           0
8955 +#define         UART16550_PARITY_ODD            0x08
8956 +#define         UART16550_PARITY_EVEN           0x18
8957 +#define         UART16550_PARITY_MARK           0x28
8958 +#define         UART16550_PARITY_SPACE          0x38
8959 +
8960 +#define         UART16550_DATA_5BIT             0x0
8961 +#define         UART16550_DATA_6BIT             0x1
8962 +#define         UART16550_DATA_7BIT             0x2
8963 +#define         UART16550_DATA_8BIT             0x3
8964 +
8965 +#define         UART16550_STOP_1BIT             0x0
8966 +#define         UART16550_STOP_2BIT             0x4
8967 +
8968 +volatile Uart * stUart =  UART_BASE;
8969 +
8970 +#define WRITE16(addr, value)        ((*(volatile UINT16 *)((ULONG)&addr)) = value)
8971 +
8972 +/* Low level UART routines from promcon.c */
8973 +extern void prom_putc(char c);
8974 +extern char prom_getc(void);
8975 +extern int prom_getc_nowait(void);
8976 +extern int prom_testc(void);
8977 +
8978 +extern void set_debug_traps(void);
8979 +extern void breakpoint(void);
8980 +extern void enable_brcm_irq(unsigned int);
8981 +extern void set_async_breakpoint(unsigned int epc);
8982 +
8983 +#ifdef CONFIG_GDB_CONSOLE
8984 +extern void register_gdb_console(void);
8985 +#endif
8986 +
8987 +int gdb_initialized = 0;
8988 +
8989 +#define        GDB_BUF_SIZE    512             /* power of 2, please */
8990 +
8991 +static char    gdb_buf[GDB_BUF_SIZE] ;
8992 +static int     gdb_buf_in_inx ;
8993 +static atomic_t        gdb_buf_in_cnt ;
8994 +static int     gdb_buf_out_inx ;
8995 +
8996 +void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
8997 +{
8998 +       /* Do nothing, assume boot loader has already set up serial port */
8999 +       printk("debugInit called\n");
9000 +}
9001 +
9002 +/*
9003 + * Get a char if available, return -1 if nothing available.
9004 + * Empty the receive buffer first, then look at the interface hardware.
9005 + */
9006 +static int     read_char(void)
9007 +{
9008 +    if (atomic_read(&gdb_buf_in_cnt) != 0)     /* intr routine has q'd chars */
9009 +    {
9010 +       int             chr ;
9011 +
9012 +       chr = gdb_buf[gdb_buf_out_inx++] ;
9013 +       gdb_buf_out_inx &= (GDB_BUF_SIZE - 1) ;
9014 +       atomic_dec(&gdb_buf_in_cnt) ;
9015 +       return(chr) ;
9016 +    }
9017 +    return(prom_getc_nowait()) ;       /* read from hardware */
9018 +} /* read_char */
9019 +
9020 +/*
9021 + * This is the receiver interrupt routine for the GDB stub.
9022 + * It will receive a limited number of characters of input
9023 + * from the gdb  host machine and save them up in a buffer.
9024 + *
9025 + * When the gdb stub routine getDebugChar() is called it
9026 + * draws characters out of the buffer until it is empty and
9027 + * then reads directly from the serial port.
9028 + *
9029 + * We do not attempt to write chars from the interrupt routine
9030 + * since the stubs do all of that via putDebugChar() which
9031 + * writes one byte after waiting for the interface to become
9032 + * ready.
9033 + *
9034 + * The debug stubs like to run with interrupts disabled since,
9035 + * after all, they run as a consequence of a breakpoint in
9036 + * the kernel.
9037 + *
9038 + * Perhaps someone who knows more about the tty driver than I
9039 + * care to learn can make this work for any low level serial
9040 + * driver.
9041 + */
9042 +static void gdb_interrupt(int irq, void *dev_id, struct pt_regs * regs)
9043 +{
9044 +    int         chr ;
9045 +    int        more;
9046 +    do
9047 +    {
9048 +       chr = prom_getc_nowait() ;
9049 +       more = prom_testc();
9050 +       if (chr < 0) continue ;
9051 +
9052 +        /* If we receive a Ctrl-C then this is GDB trying to break in */
9053 +        if (chr == 3)
9054 +       {
9055 +           /* Replace current instruction with breakpoint */
9056 +           set_async_breakpoint(regs->cp0_epc);
9057 +            //breakpoint();
9058 +       }
9059 +               
9060 +#ifdef PRNT
9061 +       printk("gdb_interrupt: chr=%02x '%c', more = %x\n",
9062 +               chr, chr > ' ' && chr < 0x7F ? chr : ' ', more) ;
9063 +#endif
9064 +
9065 +       if (atomic_read(&gdb_buf_in_cnt) >= GDB_BUF_SIZE)
9066 +       {                               /* buffer overflow, clear it */
9067 +           gdb_buf_in_inx = 0 ;
9068 +           atomic_set(&gdb_buf_in_cnt, 0) ;
9069 +           gdb_buf_out_inx = 0 ;
9070 +           break ;
9071 +       }
9072 +
9073 +       gdb_buf[gdb_buf_in_inx++] = chr ;
9074 +       gdb_buf_in_inx &= (GDB_BUF_SIZE - 1) ;
9075 +       atomic_inc(&gdb_buf_in_cnt) ;
9076 +    }
9077 +    while (more !=0);
9078 +
9079 +} /* gdb_interrupt */
9080 +
9081 +/*
9082 + * getDebugChar
9083 + *
9084 + * This is a GDB stub routine.  It waits for a character from the
9085 + * serial interface and then returns it.  If there is no serial
9086 + * interface connection then it returns a bogus value which will
9087 + * almost certainly cause the system to hang.
9088 + */
9089 +int    getDebugChar(void)
9090 +{
9091 +    volatile int       chr ;
9092 +
9093 +#ifdef PRNT
9094 +    printk("getDebugChar: ") ;
9095 +#endif
9096 +
9097 +    while ( (chr = read_char()) < 0 ) ;
9098 +
9099 +#ifdef PRNT
9100 +    printk("%c\n", chr > ' ' && chr < 0x7F ? chr : ' ') ;
9101 +#endif
9102 +    return(chr) ;
9103 +
9104 +} /* getDebugChar */
9105 +
9106 +/*
9107 + * putDebugChar
9108 + *
9109 + * This is a GDB stub routine.  It waits until the interface is ready
9110 + * to transmit a char and then sends it.  If there is no serial
9111 + * interface connection then it simply returns to its caller, having
9112 + * pretended to send the char.
9113 + */
9114 +int putDebugChar(unsigned char chr)
9115 +{
9116 +#ifdef PRNT
9117 +    printk("putDebugChar: chr=%02x '%c'\n", chr,
9118 +               chr > ' ' && chr < 0x7F ? chr : ' ') ;
9119 +#endif
9120 +
9121 +    prom_putc(chr) ;   /* this routine will wait */
9122 +     return 1;
9123 +
9124 +} /* putDebugChar */
9125 +
9126 +/* Just a NULL routine for testing. */
9127 +void gdb_null(void)
9128 +{
9129 +}
9130 +
9131 +void rs_kgdb_hook(int tty_no)
9132 +{
9133 +    printk("rs_kgdb_hook: tty %d\n", tty_no);
9134 +
9135 +    /* Call GDB routine to setup the exception vectors for the debugger */
9136 +   set_debug_traps();
9137 +
9138 +   printk("Breaking into debugger...\n");
9139 +   breakpoint();
9140 +   gdb_null() ;
9141 +   printk("Connected.\n");
9142 +
9143 +   gdb_initialized = 1;
9144 +
9145 +#ifdef CONFIG_GDB_CONSOLE
9146 +    register_gdb_console();
9147 +#endif
9148 +}
9149 +
9150 +void kgdb_hook_irq()
9151 +{
9152 +    int         retval ;
9153 +    uint16 uMask;
9154 +
9155 +    printk("GDB: Hooking UART interrupt\n");
9156 +
9157 +    retval = request_irq(INTERRUPT_ID_UART,
9158 +                         gdb_interrupt,
9159 +                         SA_INTERRUPT,
9160 +                         "GDB-stub", NULL);
9161 +
9162 +    if (retval != 0)
9163 +       printk("gdb_hook: request_irq(irq=%d) failed: %d\n", INTERRUPT_ID_UART, retval);
9164 +
9165 +      // Enable UART config Rx not empty IRQ
9166 +     uMask = READ16(stUart->intMask) ;
9167 +      //     printk("intMask: 0x%x\n", uMask);
9168 +     WRITE16(stUart->intMask, uMask | RXFIFONE);
9169 +}
9170 +
9171 +
9172 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S
9173 --- linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S    1970-01-01 01:00:00.000000000 +0100
9174 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S   2006-08-03 16:36:58.000000000 +0200
9175 @@ -0,0 +1,59 @@
9176 +/*
9177 +<:copyright-gpl 
9178 + Copyright 2002 Broadcom Corp. All Rights Reserved. 
9179
9180 + This program is free software; you can distribute it and/or modify it 
9181 + under the terms of the GNU General Public License (Version 2) as 
9182 + published by the Free Software Foundation. 
9183
9184 + This program is distributed in the hope it will be useful, but WITHOUT 
9185 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
9186 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
9187 + for more details. 
9188
9189 + You should have received a copy of the GNU General Public License along 
9190 + with this program; if not, write to the Free Software Foundation, Inc., 
9191 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
9192 +:>
9193 +*/
9194 +/*
9195 + * Generic interrupt handler for Broadcom MIPS boards
9196 + */
9197 +
9198 +#include <linux/config.h>
9199 +
9200 +#include <asm/asm.h>
9201 +#include <asm/mipsregs.h>
9202 +#include <asm/regdef.h>
9203 +#include <asm/stackframe.h>
9204 +
9205 +/*
9206 + *     MIPS IRQ        Source
9207 + *      --------        ------
9208 + *             0       Software (ignored)
9209 + *             1        Software (ignored)
9210 + *             2        Combined hardware interrupt (hw0)
9211 + *             3        Hardware
9212 + *             4        Hardware
9213 + *             5        Hardware
9214 + *             6        Hardware
9215 + *             7        R4k timer
9216 + */
9217 +
9218 +       .text
9219 +       .set    noreorder
9220 +       .set    noat
9221 +       .align  5
9222 +       NESTED(brcmIRQ, PT_SIZE, sp)
9223 +       SAVE_ALL
9224 +       CLI
9225 +       .set    noreorder
9226 +       .set    at
9227 +
9228 +       jal             brcm_irq_dispatch
9229 +       move    a0, sp
9230 +
9231 +       j       ret_from_irq
9232 +       nop
9233 +               
9234 +       END(brcmIRQ)
9235 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile
9236 --- linux-2.6.17/arch/mips/brcm-boards/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
9237 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile        2006-08-03 16:36:58.000000000 +0200
9238 @@ -0,0 +1,11 @@
9239 +#
9240 +# Makefile for generic Broadcom MIPS boards
9241 +#
9242 +# Copyright (C) 2001 Broadcom Corporation
9243 +#
9244 +obj-y          := int-handler.o
9245 +
9246 +ifdef CONFIG_REMOTE_DEBUG
9247 +obj-y += dbg_io.o
9248 +endif
9249 +