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