1 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c
2 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 2006-07-13 19:11:33.000000000 +0200
7 + Copyright 2002 Broadcom Corp. All Rights Reserved.
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.
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
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.
24 + ***************************************************************************
25 + * File Name : bcm63xx_flash.c
27 + * Description: This file contains the flash device driver APIs for bcm63xx board.
29 + * Created on : 8/10/2002 seanl: use cfiflash.c, cfliflash.h (AMD specific)
31 + ***************************************************************************/
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>
42 +#include <bcm_map_part.h>
44 +#define BCMTAG_EXE_USE
46 +#include "cfiflash.h"
47 +#include "boardparms.h"
49 +//#define DEBUG_FLASH
51 +static FLASH_ADDR_INFO fInfo;
52 +static int flashInitialized = 0;
54 +void *retriedKmalloc(size_t size)
59 + // try 1000 times before quit
60 + while (((pBuf = kmalloc(size, GFP_KERNEL)) == NULL) && (tryCount++ < 1000))
62 + current->state = TASK_INTERRUPTIBLE;
63 + schedule_timeout(HZ/10);
65 + if (tryCount >= 1000)
68 + memset(pBuf, 0, size);
73 +void retriedKfree(void *pBuf)
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.
85 +****************************************************************************/
86 +UINT32 getCrc32(byte *pdata, UINT32 size, UINT32 crc)
89 + crc = (crc >> 8) ^ Crc32_table[(crc ^ *pdata++) & 0xff];
94 +// get the nvram start addr
96 +unsigned long get_nvram_start_addr(void)
98 + return ((unsigned long)
99 + (flash_get_memptr(fInfo.flash_nvram_start_blk) + fInfo.flash_nvram_blk_offset));
102 +// get the scratch_pad start addr
104 +unsigned long get_scratch_pad_start_addr(void)
106 + return ((unsigned long)
107 + (flash_get_memptr(fInfo.flash_scratch_pad_start_blk) + fInfo.flash_scratch_pad_blk_offset));
112 +/* *********************************************************************
113 + * kerSysImageTagGet()
114 + * Get the image tag
115 + * Input parameters:
118 + * point to tag -- Found
120 + ********************************************************************* */
121 +PFILE_TAG kerSysImageTagGet(void)
124 + int totalBlks = flash_get_numsectors();
126 + unsigned char *sectAddr;
129 +#if defined(DEBUG_FLASH)
130 + printk("totalblks in tagGet=%d\n", totalBlks);
133 + // start from 2nd blk, assume 1st one is always CFE
134 + for (i = 1; i < totalBlks; i++)
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;
141 +#if defined(DEBUG_FLASH)
142 + printk("Check Tag crc on blk [%d]\n", i);
145 + if (crc == (UINT32)(*(UINT32*)(pTag->tagValidationToken)))
149 + return (PFILE_TAG) NULL;
152 +// Initialize the flash and fill out the fInfo structure
153 +void kerSysFlashInit( void )
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;
166 + if (flashInitialized)
169 + flashInitialized = 1;
172 + totalBlks = flash_get_numsectors();
173 + totalSize = flash_get_total_size();
175 + printk("Total Flash size: %dK with %d sectors\n", totalSize/1024, totalBlks);
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;
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);
189 + BpSetBoardId( nvramData.szBoardId );
191 + fInfo.flash_persistent_length = NVRAM_PSI_DEFAULT;
192 + if (savedCrc != crc)
194 + printk("***Board is not initialized****: Using the default PSI size: %d\n",
195 + fInfo.flash_persistent_length);
199 + unsigned long ulPsiSize;
200 + if( BpGetPsiSize( &ulPsiSize ) == BP_SUCCESS )
201 + fInfo.flash_persistent_length = ulPsiSize;
204 + printk("***Board id is not set****: Using the default PSI size: %d\n",
205 + fInfo.flash_persistent_length);
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
217 + for (i = fInfo.flash_persistent_start_blk;
218 + i < (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk); i++)
220 + usedBlkSize += flash_get_sector_size((byte) i);
222 + fInfo.flash_persistent_blk_offset = usedBlkSize - fInfo.flash_persistent_length;
224 + // get the info for sp
225 + if (!(pTag = kerSysImageTagGet()))
227 + printk("Failed to read image tag from flash\n");
230 + kernelEndAddr = (unsigned long) simple_strtoul(pTag->kernelAddress, NULL, 10) + \
231 + (unsigned long) simple_strtoul(pTag->kernelLen, NULL, 10);
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))
237 + fInfo.flash_scratch_pad_length = SP_MAX_LEN;
238 + if (fInfo.flash_persistent_start_blk == fInfo.flash_scratch_pad_start_blk) // share blk
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;
248 + else // on different blk
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
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;
262 + printk("No flash for scratch pad!\n");
263 + fInfo.flash_scratch_pad_length = 0; // no sp
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);
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);
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);
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.
292 + ***********************************************************************/
293 +void kerSysFlashAddrInfoGet(PFLASH_ADDR_INFO pflash_addr_info)
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;
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
310 +static char *getSharedBlks(int start_blk, int end_blk)
313 + int usedBlkSize = 0;
315 + char *pTempBuf = NULL;
318 + for (i = start_blk; i < end_blk; i++)
319 + usedBlkSize += flash_get_sector_size((byte) i);
321 +#if defined(DEBUG_FLASH)
322 + printk("usedBlkSize = %d\n", usedBlkSize);
325 + if ((pTempBuf = (char *) retriedKmalloc(usedBlkSize)) == NULL)
327 + printk("failed to allocate memory with size: %d\n", usedBlkSize);
332 + for (i = start_blk; i < end_blk; i++)
334 + sect_size = flash_get_sector_size((byte) i);
336 +#if defined(DEBUG_FLASH)
337 + printk("i = %d, sect_size = %d, end_blk = %d\n", i, sect_size, end_blk);
339 + flash_read_buf((byte)i, 0, pBuf, sect_size);
348 +// Set the pTempBuf to flash from start_blk to end_blk
352 +static int setSharedBlks(int start_blk, int end_blk, char *pTempBuf)
357 + char *pBuf = pTempBuf;
359 + for (i = start_blk; i < end_blk; i++)
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)
365 + printk("Error writing flash sector %d.", i);
377 +/*******************************************************************************
379 + *******************************************************************************/
385 +int kerSysNvRamGet(char *string, int strLen, int offset)
389 + if (!flashInitialized)
392 + if (strLen > FLASH45_LENGTH_NVRAM)
395 + if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
396 + (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
399 + // get string off the memory buffer
400 + memcpy(string, (pBuf + fInfo.flash_nvram_blk_offset + offset), strLen);
402 + retriedKfree(pBuf);
412 +int kerSysNvRamSet(char *string, int strLen, int offset)
417 + if (strLen > FLASH45_LENGTH_NVRAM)
420 + if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
421 + (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
424 + // set string to the memory buffer
425 + memcpy((pBuf + fInfo.flash_nvram_blk_offset + offset), string, strLen);
427 + if (setSharedBlks(fInfo.flash_nvram_start_blk,
428 + (fInfo.flash_nvram_number_blk + fInfo.flash_nvram_start_blk), pBuf) != 0)
431 + retriedKfree(pBuf);
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)
445 + char *tempStorage = retriedKmalloc(FLASH45_LENGTH_NVRAM);
447 + // just write the whole buf with '0xff' to the flash
452 + memset(tempStorage, 0xff, FLASH45_LENGTH_NVRAM);
453 + if (kerSysNvRamSet(tempStorage, FLASH45_LENGTH_NVRAM, 0) != 0)
455 + retriedKfree(tempStorage);
462 +/*******************************************************************************
464 + *******************************************************************************/
469 +int kerSysPersistentGet(char *string, int strLen, int offset)
473 + if (strLen > fInfo.flash_persistent_length)
476 + if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
477 + (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
480 + // get string off the memory buffer
481 + memcpy(string, (pBuf + fInfo.flash_persistent_blk_offset + offset), strLen);
483 + retriedKfree(pBuf);
493 +int kerSysPersistentSet(char *string, int strLen, int offset)
498 + if (strLen > fInfo.flash_persistent_length)
501 + if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
502 + (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
505 + // set string to the memory buffer
506 + memcpy((pBuf + fInfo.flash_persistent_blk_offset + offset), string, strLen);
508 + if (setSharedBlks(fInfo.flash_persistent_start_blk,
509 + (fInfo.flash_persistent_number_blk + fInfo.flash_persistent_start_blk), pBuf) != 0)
512 + retriedKfree(pBuf);
521 +// !0 - the sector number fail to be flashed (should not be 0)
522 +int kerSysBcmImageSet( int flash_start_addr, char *string, int size)
528 + char *pTempBuf = NULL;
529 + int whole_image = 0;
531 + blk_start = flash_get_blk(flash_start_addr);
532 + if( blk_start < 0 )
535 + if (flash_start_addr == FLASH_BASE && size > FLASH45_LENGTH_BOOT_ROM)
538 + /* write image to flash memory */
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)
545 +// printk("Failed to allocate memory with size: %d. Reset the router...\n", sect_size);
546 +// kerSysMipsSoftReset(); // reset the board right away.
548 + // for whole image, no check on psi
549 + if (!whole_image && blk_start == fInfo.flash_persistent_start_blk) // share the blk with psi
551 + if (size > (sect_size - fInfo.flash_persistent_length))
553 + printk("Image is too big\n");
554 + break; // image is too big. Can not overwrite to nvram
556 + if ((pTempBuf = (char *)retriedKmalloc(sect_size)) == NULL)
558 + printk("Failed to allocate memory with size: %d. Reset the router...\n", sect_size);
559 + kerSysMipsSoftReset(); // reset the board right away.
561 + flash_read_buf((byte)blk_start, 0, pTempBuf, sect_size);
562 + if (copy_from_user((void *)pTempBuf,(void *)string, size) != 0)
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);
571 + flash_sector_erase_int(blk_start); // erase blk before flash
573 + if (sect_size > size)
580 + if ((i = flash_write_buf(blk_start, 0, string, sect_size)) != sect_size) {
584 + string += sect_size;
586 + } while (size > 0);
590 + // If flashing a whole image, erase to end of flash.
591 + int total_blks = flash_get_numsectors();
592 + while( blk_start < total_blks )
594 + flash_sector_erase_int(blk_start);
599 + retriedKfree(pTempBuf);
604 + sts = blk_start; // failed to flash this sector
609 +/*******************************************************************************
611 + *******************************************************************************/
612 +// get sp data. NOTE: memcpy work here -- not using copy_from/to_user
616 +int kerSysScratchPadGet(char *tokenId, char *tokBuf, int bufLen)
618 + PSP_HEADER pHead = NULL;
619 + PSP_TOKEN pToken = NULL;
621 + char *pShareBuf = NULL;
622 + char *startPtr = NULL;
623 + char *endPtr = NULL;
624 + char *spEndPtr = NULL;
627 + if (fInfo.flash_scratch_pad_length == 0)
630 + if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN)))
632 + printk("Exceed scratch pad space by %d\n", bufLen - fInfo.flash_scratch_pad_length \
633 + - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
637 + if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
638 + (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
641 + // pBuf points to SP buf
642 + pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;
644 + pHead = (PSP_HEADER) pBuf;
645 + if (memcmp(pHead->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0)
647 + printk("Scrap pad is not initialized.\n");
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)
657 + pToken = (PSP_TOKEN) startPtr;
658 + if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
660 + memcpy(tokBuf, startPtr + sizeof(SP_TOKEN), bufLen);
665 + startPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
668 + retriedKfree(pShareBuf);
674 +// set sp. NOTE: memcpy work here -- not using copy_from/to_user
678 +int kerSysScratchPadSet(char *tokenId, char *tokBuf, int bufLen)
680 + PSP_TOKEN pToken = NULL;
681 + PSP_HEADER pHead = NULL;
682 + char *pShareBuf = NULL;
689 + if (fInfo.flash_scratch_pad_length == 0)
692 + if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN)))
694 + printk("Exceed scratch pad space by %d\n", bufLen - fInfo.flash_scratch_pad_length \
695 + - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
699 + if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
700 + (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
703 + // pBuf points to SP buf
704 + pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;
705 + pHead = (PSP_HEADER) pBuf;
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;
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)
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);
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)
736 + pToken = (PSP_TOKEN) curPtr;
737 + if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
739 + if (pToken->tokenLen == bufLen) // overwirte it
741 + memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen);
744 + else // move later data over and put the new token at the end
746 + memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen); // ~~~
750 + else // not same token ~~~
754 + curPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
756 + SPHead.SPUsedLen = sizeof(SP_HEADER) + sizeof(SP_TOKEN) + bufLen; // ~~~
757 + if (SPHead.SPUsedLen > SP_MAX_LEN)
759 + printk("No more Scratch pad space left! Over limit by %d bytes\n", SPHead.SPUsedLen - SP_MAX_LEN);
763 + } // else if not new sp
765 + sts = setSharedBlks(fInfo.flash_scratch_pad_start_blk,
766 + (fInfo.flash_scratch_pad_number_blk + fInfo.flash_scratch_pad_start_blk), pShareBuf);
768 + retriedKfree(pShareBuf);
775 +int kerSysFlashSizeGet(void)
777 + return flash_get_total_size();
780 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c
781 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 1970-01-01 01:00:00.000000000 +0100
782 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 2006-07-13 19:11:33.000000000 +0200
786 + Copyright 2002 Broadcom Corp. All Rights Reserved.
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.
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
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.
802 +/***************************************************************************
803 + * File Name : bcm63xx_led.c
807 + * This file contains bcm963xx board led control API functions.
809 + * To use it, do the following
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.
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
824 + * boardLedInit((PLED_MAP_PAIR) &cLedMapping45R);
826 + * 3). Sample call for kernel mode:
828 + * kerSysLedCtrl(kLedAdsl, kLedStateBlinkOnce); // kLedxxx defines in board.h
830 + * 4). Sample call for user mode
832 + * sysLedCtrl(kLedAdsl, kLedStateBlinkOnce); // kLedxxx defines in board_api.h
835 + * Created on : 10/28/2002 seanl
837 + ***************************************************************************/
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>
849 +#include <bcm_map_part.h>
852 +#define k100ms (HZ / 10) // ~100 ms
853 +#define kFastBlinkCount 0 // ~100ms
854 +#define kSlowBlinkCount 5 // ~600ms
856 +#define MAX_VIRT_LEDS 12
858 +// uncomment // for debug led
861 +// global variables:
862 +struct timer_list gLedTimer;
863 +int gTimerOn = FALSE;
866 +typedef struct ledinfo
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;
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];
883 +#if defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
884 +static int gLedOffInBridgeMode = 1;
885 +#elif defined(CONFIG_BCM96345)
886 +static int gLedOffInBridgeMode = 0;
890 +void ledTimerExpire(void);
891 +int initLedInfo( PLED_MAP_PAIR pCurMap, PLED_INFO pCurLed );
893 +//**************************************************************************************
895 +//**************************************************************************************
897 +// turn led on and set the ledState
898 +void ledOn(PLED_INFO pLed)
900 + if( pLed->ledMask )
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
906 + GPIO->GPIOio |= pLed->ledMask; // turn on the led
907 + pLed->ledState = pLed->savedLedState = kLedStateOn;
912 +// turn led off and set the ledState
913 +void ledOff(PLED_INFO pLed)
915 + if( pLed->ledMask )
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
921 + GPIO->GPIOio &= ~pLed->ledMask; // turn off the led
922 + pLed->ledState = pLed->savedLedState = kLedStateOff;
926 +// turn led on and set the ledState
927 +void ledOnFail(PLED_INFO pLed)
929 + if( pLed->ledMaskFail )
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
935 + GPIO->GPIOio |= pLed->ledMaskFail; // turn on the led
936 + pLed->ledState = pLed->savedLedState = kLedStateFail;
941 +// turn led off and set the ledState
942 +void ledOffFail(PLED_INFO pLed)
944 + if( pLed->ledMaskFail )
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
950 + GPIO->GPIOio &= ~pLed->ledMaskFail;// turn off the led
951 + pLed->ledState = pLed->savedLedState = kLedStateOff;
956 +// toggle the led and return the current ledState
957 +BOARD_LED_STATE ledToggle(PLED_INFO pLed)
959 + GPIO->GPIODir |= pLed->ledMask; // turn on the direction bit in case was turned off by some one
960 + if (GPIO->GPIOio & pLed->ledMask)
962 + GPIO->GPIOio &= ~(pLed->ledMask);
963 + return( (pLed->ledActiveLow) ? kLedStateOn : kLedStateOff );
967 + GPIO->GPIOio |= pLed->ledMask;
968 + return( (pLed->ledActiveLow) ? kLedStateOff : kLedStateOn );
973 +// led timer. Will return if timer is already on
974 +void ledTimerStart(void)
979 +#if defined(DEBUG_LED)
980 + printk("led: add_timer\n");
983 + init_timer(&gLedTimer);
984 + gLedTimer.function = (void*)ledTimerExpire;
985 + gLedTimer.expires = jiffies + k100ms; // timer expires in ~100ms
986 + add_timer (&gLedTimer);
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)
1000 + for (i = 0, pCurLed = gLed; i < gLedCount; i++, pCurLed++)
1002 +#if defined(DEBUG_LED)
1003 + printk("led[%d]: Mask=0x%04x, State = %d, blcd=%d\n", i, pCurLed->ledMask, pCurLed->ledState, pCurLed->blinkCountDown);
1005 + switch (pCurLed->ledState)
1008 + case kLedStateOff:
1009 + case kLedStateFail:
1010 + pCurLed->blinkCountDown = 0; // reset the blink count down
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
1022 + case kLedStateSlowBlinkContinues:
1023 + if (pCurLed->blinkCountDown-- == 0)
1025 + pCurLed->blinkCountDown = kSlowBlinkCount;
1026 + ledToggle(pCurLed);
1031 + case kLedStateFastBlinkContinues:
1032 + if (pCurLed->blinkCountDown-- == 0)
1034 + pCurLed->blinkCountDown = kFastBlinkCount;
1035 + ledToggle(pCurLed);
1041 + printk("Invalid state = %d\n", pCurLed->ledState);
1046 +// initialize the gLedCount and allocate and fill gLed struct
1047 +void __init boardLedInit(PLED_MAP_PAIR cLedMapping)
1049 + PLED_MAP_PAIR p1, p2;
1050 + PLED_INFO pCurLed;
1051 + int needTimer = FALSE;
1052 + int alreadyUsed = 0;
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;
1060 + memset( gpVirtLeds, 0x00, sizeof(gpVirtLeds) );
1061 + memset( gLedHwFunc, 0x00, sizeof(gLedHwFunc) );
1062 + memset( gLedHwFailFunc, 0x00, sizeof(gLedHwFailFunc) );
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++ )
1071 + for( p2 = cLedMapping; p2 != p1; p2++ )
1073 + if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1074 + (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1081 + if( alreadyUsed == 0 )
1085 + gLed = (PLED_INFO) kmalloc((gLedCount * sizeof(LED_INFO)), GFP_KERNEL);
1086 + if( gLed == NULL )
1088 + printk( "LED memory allocation error.\n" );
1092 + memset( gLed, 0x00, gLedCount * sizeof(LED_INFO) );
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.
1097 + for( p1 = cLedMapping; p1->ledName != kLedEnd; p1++ )
1099 + if( (int) p1->ledName > MAX_VIRT_LEDS )
1103 + for( p2 = cLedMapping; p2 != p1; p2++ )
1105 + if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1106 + (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1113 + if( alreadyUsed == 0 )
1115 + // Initialize the board LED for the first time.
1116 + needTimer = initLedInfo( p1, pCurLed );
1117 + gpVirtLeds[(int) p1->ledName] = pCurLed;
1123 + for( pLed = gLed; pLed != pCurLed; pLed++ )
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))
1129 + // The board LED has already been initialized but possibly
1130 + // not completely initialized.
1133 + pLed->ledMask = p1->ledMask;
1134 + pLed->ledActiveLow = p1->ledActiveLow;
1136 + if( p1->ledMaskFail )
1138 + pLed->ledMaskFail = p1->ledMaskFail;
1139 + pLed->ledActiveLowFail = p1->ledActiveLowFail;
1141 + gpVirtLeds[(int) p1->ledName] = pLed;
1151 +#if defined(DEBUG_LED)
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);
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 )
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;
1171 + switch (pCurLed->ledState)
1174 + pCurLed->blinkCountDown = 0; // reset the blink count down
1177 + case kLedStateOff:
1178 + pCurLed->blinkCountDown = 0; // reset the blink count down
1181 + case kLedStateFail:
1182 + pCurLed->blinkCountDown = 0; // reset the blink count down
1183 + ledOnFail(pCurLed);
1185 + case kLedStateBlinkOnce:
1186 + pCurLed->blinkCountDown = 1;
1189 + case kLedStateSlowBlinkContinues:
1190 + pCurLed->blinkCountDown = kSlowBlinkCount;
1193 + case kLedStateFastBlinkContinues:
1194 + pCurLed->blinkCountDown = kFastBlinkCount;
1198 + printk("Invalid state = %d\n", pCurLed->ledState);
1201 + return( needTimer );
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
1208 +static int isBridgedProtocol(void)
1210 + extern int dev_get(const char *name);
1211 + const int firstBridgeId = 17;
1212 + const int lastBridgeId = 24;
1217 + for( i = firstBridgeId; i <= lastBridgeId; i++ )
1219 + sprintf( name, "nas%d", i );
1221 + if( dev_get(name) )
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)
1235 + PLED_INFO ledInfoPtr;
1237 + // do the mapping from virtual to physical led
1238 + if( (int) ledName < MAX_VIRT_LEDS )
1239 + ledInfoPtr = gpVirtLeds[(int) ledName];
1241 + ledInfoPtr = NULL;
1243 + if (ledInfoPtr == NULL)
1246 + if( ledState != kLedStateFail && gLedHwFunc[(int) ledName] )
1248 + (*gLedHwFunc[(int) ledName]) (ledName, ledState);
1249 + ledOffFail(ledInfoPtr);
1253 + if( ledState == kLedStateFail && gLedHwFailFunc[(int) ledName] )
1255 + (*gLedHwFailFunc[(int) ledName]) (ledName, ledState);
1256 + ledOff(ledInfoPtr);
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))
1264 + static int BridgedProtocol = -1;
1266 + if( BridgedProtocol == -1 )
1267 + BridgedProtocol = isBridgedProtocol();
1269 + if( BridgedProtocol == TRUE )
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;
1282 + // First, turn off the complimentary (failure) LED GPIO.
1283 + if( ledInfoPtr->ledMaskFail )
1284 + ledOffFail(ledInfoPtr);
1286 + if( gLedHwFailFunc[(int) ledName] )
1287 + (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1289 + // Next, turn on the specified LED GPIO.
1290 + ledOn(ledInfoPtr);
1293 + case kLedStateOff:
1294 + // First, turn off the complimentary (failure) LED GPIO.
1295 + if( ledInfoPtr->ledMaskFail )
1296 + ledOffFail(ledInfoPtr);
1298 + if( gLedHwFailFunc[(int) ledName] )
1299 + (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1301 + // Next, turn off the specified LED GPIO.
1302 + ledOff(ledInfoPtr);
1305 + case kLedStateFail:
1306 + // First, turn off the complimentary (normal) LED GPIO.
1307 + if( ledInfoPtr->ledMask )
1308 + ledOff(ledInfoPtr);
1310 + if( gLedHwFunc[(int) ledName] )
1311 + (*gLedHwFunc[(int) ledName]) (ledName, kLedStateOff);
1313 + // Next, turn on (red) the specified LED GPIO.
1314 + ledOnFail(ledInfoPtr);
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)
1324 + if (ledInfoPtr->blinkCountDown == 0) // skip the call if it is 1
1326 + ledToggle(ledInfoPtr);
1327 + ledInfoPtr->blinkCountDown = 1; // it will be reset to 0 when timer expires
1328 + ledInfoPtr->ledState = kLedStateBlinkOnce;
1334 + case kLedStateSlowBlinkContinues:
1335 + ledInfoPtr->blinkCountDown = kSlowBlinkCount;
1336 + ledInfoPtr->ledState = kLedStateSlowBlinkContinues;
1337 + ledInfoPtr->savedLedState = kLedStateSlowBlinkContinues;
1341 + case kLedStateFastBlinkContinues:
1342 + ledInfoPtr->blinkCountDown = kFastBlinkCount;
1343 + ledInfoPtr->ledState = kLedStateFastBlinkContinues;
1344 + ledInfoPtr->savedLedState = kLedStateFastBlinkContinues;
1349 + printk("Invalid led state\n");
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 )
1357 + if( (int) ledName < MAX_VIRT_LEDS )
1359 + if( ledFailType == 1 )
1360 + gLedHwFailFunc[(int) ledName] = ledHwFunc;
1362 + gLedHwFunc[(int) ledName] = ledHwFunc;
1366 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c
1367 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c 1970-01-01 01:00:00.000000000 +0100
1368 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c 2006-07-25 10:59:34.000000000 +0200
1372 + Copyright 2002 Broadcom Corp. All Rights Reserved.
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.
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
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.
1388 +/***************************************************************************
1389 + * File Name : board.c
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.
1395 + * Created on : 2/20/2002 seanl: use cfiflash.c, cfliflash.h (AMD specific)
1397 + ***************************************************************************/
1401 +#include <linux/version.h>
1402 +#include <linux/init.h>
1403 +#include <linux/fs.h>
1404 +#include <linux/interrupt.h>
1405 +#include <linux/capability.h>
1406 +#include <linux/slab.h>
1407 +#include <linux/errno.h>
1408 +#include <linux/module.h>
1409 +#include <linux/pagemap.h>
1410 +#include <asm/uaccess.h>
1411 +#include <linux/wait.h>
1412 +#include <linux/poll.h>
1413 +#include <linux/sched.h>
1414 +#include <linux/list.h>
1415 +#include <linux/if.h>
1416 +#include <linux/spinlock.h>
1418 +#include <bcm_map_part.h>
1420 +#include <bcmTag.h>
1421 +#include "boardparms.h"
1422 +#include "cfiflash.h"
1423 +#include "bcm_intr.h"
1425 +#include "bcm_map_part.h"
1427 +static DEFINE_SPINLOCK(board_lock);
1430 +#if defined (NON_CONSECUTIVE_MAC)
1431 +// used to be the last octet. Now changed to the first 5 bits of the the forth octet
1432 +// to reduced the duplicated MAC addresses.
1433 +#define CHANGED_OCTET 3
1434 +#define SHIFT_BITS 3
1436 +#define CHANGED_OCTET 1
1437 +#define SHIFT_BITS 0
1440 +#if defined (WIRELESS)
1441 +#define SES_BTN_PRESSED 0x00000001
1442 +#define SES_EVENTS SES_BTN_PRESSED /*OR all values if any*/
1443 +#define SES_LED_OFF 0
1444 +#define SES_LED_ON 1
1445 +#define SES_LED_BLINK 2
1450 + unsigned long ulId;
1452 + char chReserved[3];
1453 +} MAC_ADDR_INFO, *PMAC_ADDR_INFO;
1457 + unsigned long ulSdramSize;
1458 + unsigned long ulPsiSize;
1459 + unsigned long ulNumMacAddrs;
1460 + unsigned long ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN];
1461 + MAC_ADDR_INFO MacAddrs[1];
1462 +} NVRAM_INFO, *PNVRAM_INFO;
1466 + unsigned long eventmask;
1467 +} BOARD_IOC, *PBOARD_IOC;
1470 +/*Dyinggasp callback*/
1471 +typedef void (*cb_dgasp_t)(void *arg);
1472 +typedef struct _CB_DGASP__LIST
1474 + struct list_head list;
1475 + char name[IFNAMSIZ];
1476 + cb_dgasp_t cb_dgasp_fn;
1478 +}CB_DGASP_LIST , *PCB_DGASP_LIST;
1481 +static LED_MAP_PAIR LedMapping[] =
1482 +{ // led name Initial state physical pin (ledMask)
1483 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1484 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1485 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1486 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1487 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1488 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1489 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1490 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1491 + {kLedEnd, kLedStateOff, 0, 0, 0, 0} // NOTE: kLedEnd has to be at the end.
1495 +extern struct file fastcall *fget_light(unsigned int fd, int *fput_needed);
1496 +extern unsigned int nr_free_pages (void);
1497 +extern const char *get_system_type(void);
1498 +extern void kerSysFlashInit(void);
1499 +extern unsigned long get_nvram_start_addr(void);
1500 +extern unsigned long get_scratch_pad_start_addr(void);
1501 +extern unsigned long getMemorySize(void);
1502 +extern void __init boardLedInit(PLED_MAP_PAIR);
1503 +extern void boardLedCtrl(BOARD_LED_NAME, BOARD_LED_STATE);
1504 +extern void kerSysLedRegisterHandler( BOARD_LED_NAME ledName,
1505 + HANDLE_LED_FUNC ledHwFunc, int ledFailType );
1508 +void __init InitNvramInfo( void );
1509 +static int board_open( struct inode *inode, struct file *filp );
1510 +static int board_ioctl( struct inode *inode, struct file *flip, unsigned int command, unsigned long arg );
1511 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos);
1512 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait);
1513 +static int board_release(struct inode *inode, struct file *filp);
1515 +static BOARD_IOC* borad_ioc_alloc(void);
1516 +static void borad_ioc_free(BOARD_IOC* board_ioc);
1518 +/* DyingGasp function prototype */
1519 +static void __init kerSysDyingGaspMapIntr(void);
1520 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
1521 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs);
1523 +static unsigned int kerSysDyingGaspIsr(void);
1525 +static void __init kerSysInitDyingGaspHandler( void );
1526 +static void __exit kerSysDeinitDyingGaspHandler( void );
1527 +/* -DyingGasp function prototype - */
1530 +#if defined (WIRELESS)
1531 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs);
1532 +static void __init sesBtn_mapGpio(void);
1533 +static void __init sesBtn_mapIntr(int context);
1534 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait);
1535 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos);
1536 +static void __init sesLed_mapGpio(void);
1537 +static void sesLed_ctrl(int action);
1538 +static void __init ses_board_init(void);
1539 +static void __exit ses_board_deinit(void);
1542 +static PNVRAM_INFO g_pNvramInfo = NULL;
1543 +static int g_ledInitialized = 0;
1544 +static wait_queue_head_t g_board_wait_queue;
1545 +static CB_DGASP_LIST *g_cb_dgasp_list_head = NULL;
1547 +static int g_wakeup_monitor = 0;
1548 +static struct file *g_monitor_file = NULL;
1549 +static struct task_struct *g_monitor_task = NULL;
1550 +static unsigned int (*g_orig_fop_poll)
1551 + (struct file *, struct poll_table_struct *) = NULL;
1553 +static struct file_operations board_fops =
1556 + ioctl: board_ioctl,
1559 + release: board_release,
1562 +uint32 board_major = 0;
1564 +#if defined (WIRELESS)
1565 +static unsigned short sesBtn_irq = BP_NOT_DEFINED;
1566 +static unsigned short sesBtn_gpio = BP_NOT_DEFINED;
1567 +static unsigned short sesLed_gpio = BP_NOT_DEFINED;
1570 +#if defined(MODULE)
1571 +int init_module(void)
1573 + return( brcm_board_init() );
1576 +void cleanup_module(void)
1579 + printk("brcm flash: cleanup_module failed because module is in use\n");
1581 + brcm_board_cleanup();
1587 +static int __init brcm_board_init( void )
1589 + typedef int (*BP_LED_FUNC) (unsigned short *);
1590 + static struct BpLedInformation
1592 + BOARD_LED_NAME ledName;
1593 + BP_LED_FUNC bpFunc;
1594 + BP_LED_FUNC bpFuncFail;
1596 + {{kLedAdsl, BpGetAdslLedGpio, BpGetAdslFailLedGpio},
1597 + {kLedWireless, BpGetWirelessLedGpio, NULL},
1598 + {kLedUsb, BpGetUsbLedGpio, NULL},
1599 + {kLedHpna, BpGetHpnaLedGpio, NULL},
1600 + {kLedWanData, BpGetWanDataLedGpio, NULL},
1601 + {kLedPPP, BpGetPppLedGpio, BpGetPppFailLedGpio},
1602 + {kLedVoip, BpGetVoipLedGpio, NULL},
1603 + {kLedSes, BpGetWirelessSesLedGpio, NULL},
1604 + {kLedEnd, NULL, NULL}
1609 + ret = register_chrdev(BOARD_DRV_MAJOR, "bcrmboard", &board_fops );
1611 + printk( "brcm_board_init(major %d): fail to register device.\n",BOARD_DRV_MAJOR);
1614 + PLED_MAP_PAIR pLedMap = LedMapping;
1615 + unsigned short gpio;
1616 + struct BpLedInformation *pInfo;
1618 + printk("brcmboard: brcm_board_init entry\n");
1619 + board_major = BOARD_DRV_MAJOR;
1622 + for( pInfo = bpLedInfo; pInfo->ledName != kLedEnd; pInfo++ )
1624 + if( pInfo->bpFunc && (*pInfo->bpFunc) (&gpio) == BP_SUCCESS )
1626 + pLedMap->ledName = pInfo->ledName;
1627 + pLedMap->ledMask = GPIO_NUM_TO_MASK(gpio);
1628 + pLedMap->ledActiveLow = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1630 + if( pInfo->bpFuncFail && (*pInfo->bpFuncFail) (&gpio) == BP_SUCCESS )
1632 + pLedMap->ledName = pInfo->ledName;
1633 + pLedMap->ledMaskFail = GPIO_NUM_TO_MASK(gpio);
1634 + pLedMap->ledActiveLowFail = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1636 + if( pLedMap->ledName != kLedEnd )
1640 + init_waitqueue_head(&g_board_wait_queue);
1641 +#if defined (WIRELESS)
1644 + kerSysInitDyingGaspHandler();
1645 + kerSysDyingGaspMapIntr();
1647 + boardLedInit(LedMapping);
1648 + g_ledInitialized = 1;
1654 +void __init InitNvramInfo( void )
1656 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
1657 + unsigned long ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1659 + if( ulNumMacAddrs > 0 && ulNumMacAddrs <= NVRAM_MAC_COUNT_MAX )
1661 + unsigned long ulNvramInfoSize =
1662 + sizeof(NVRAM_INFO) + ((sizeof(MAC_ADDR_INFO) - 1) * ulNumMacAddrs);
1664 + g_pNvramInfo = (PNVRAM_INFO) kmalloc( ulNvramInfoSize, GFP_KERNEL );
1666 + if( g_pNvramInfo )
1668 + unsigned long ulPsiSize;
1669 + if( BpGetPsiSize( &ulPsiSize ) != BP_SUCCESS )
1670 + ulPsiSize = NVRAM_PSI_DEFAULT;
1671 + memset( g_pNvramInfo, 0x00, ulNvramInfoSize );
1672 + g_pNvramInfo->ulPsiSize = ulPsiSize * 1024;
1673 + g_pNvramInfo->ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1674 + memcpy( g_pNvramInfo->ucaBaseMacAddr, pNvramData->ucaBaseMacAddr,
1675 + NVRAM_MAC_ADDRESS_LEN );
1676 + g_pNvramInfo->ulSdramSize = getMemorySize();
1679 + printk("ERROR - Could not allocate memory for NVRAM data\n");
1682 + printk("ERROR - Invalid number of MAC addresses (%ld) is configured.\n",
1686 +void __exit brcm_board_cleanup( void )
1688 + printk("brcm_board_cleanup()\n");
1690 + if (board_major != -1)
1692 +#if defined (WIRELESS)
1693 + ses_board_deinit();
1695 + kerSysDeinitDyingGaspHandler();
1696 + unregister_chrdev(board_major, "board_ioctl");
1700 +static BOARD_IOC* borad_ioc_alloc(void)
1702 + BOARD_IOC *board_ioc =NULL;
1703 + board_ioc = (BOARD_IOC*) kmalloc( sizeof(BOARD_IOC) , GFP_KERNEL );
1706 + memset(board_ioc, 0, sizeof(BOARD_IOC));
1711 +static void borad_ioc_free(BOARD_IOC* board_ioc)
1720 +static int board_open( struct inode *inode, struct file *filp )
1722 + filp->private_data = borad_ioc_alloc();
1724 + if (filp->private_data == NULL)
1730 +static int board_release(struct inode *inode, struct file *filp)
1732 + BOARD_IOC *board_ioc = filp->private_data;
1734 + wait_event_interruptible(g_board_wait_queue, 1);
1735 + borad_ioc_free(board_ioc);
1741 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait)
1743 + unsigned int mask = 0;
1744 +#if defined (WIRELESS)
1745 + BOARD_IOC *board_ioc = filp->private_data;
1748 + poll_wait(filp, &g_board_wait_queue, wait);
1749 +#if defined (WIRELESS)
1750 + if(board_ioc->eventmask & SES_EVENTS){
1751 + mask |= sesBtn_poll(filp, wait);
1759 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
1761 +#if defined (WIRELESS)
1762 + BOARD_IOC *board_ioc = filp->private_data;
1763 + if(board_ioc->eventmask & SES_EVENTS){
1764 + return sesBtn_read(filp, buffer, count, ppos);
1770 +//**************************************************************************************
1771 +// Utitlities for dump memory, free kernel pages, mips soft reset, etc.
1772 +//**************************************************************************************
1774 +/***********************************************************************
1775 + * Function Name: dumpaddr
1776 + * Description : Display a hex dump of the specified address.
1777 + ***********************************************************************/
1778 +void dumpaddr( unsigned char *pAddr, int nLen )
1780 + static char szHexChars[] = "0123456789abcdef";
1783 + unsigned char ch, *q;
1789 + sprintf( szLine, "%8.8lx: ", (unsigned long) pAddr );
1790 + p = szLine + strlen(szLine);
1792 + for(i = 0; i < 16 && nLen > 0; i += sizeof(long), nLen -= sizeof(long))
1794 + ul = *(unsigned long *) &pAddr[i];
1795 + q = (unsigned char *) &ul;
1796 + for( j = 0; j < sizeof(long); j++ )
1798 + *p++ = szHexChars[q[j] >> 4];
1799 + *p++ = szHexChars[q[j] & 0x0f];
1804 + for( j = 0; j < 16 - i; j++ )
1805 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1807 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1809 + for( j = 0; j < i; j++ )
1812 + *p++ = (ch > ' ' && ch < '~') ? ch : '.';
1816 + printk( "%s\r\n", szLine );
1824 +void kerSysMipsSoftReset(void)
1826 +#if defined(CONFIG_BCM96348)
1827 + if (PERF->RevID == 0x634800A1) {
1828 + typedef void (*FNPTR) (void);
1829 + FNPTR bootaddr = (FNPTR) FLASH_BASE;
1832 + /* Disable interrupts. */
1834 + spin_lock_irq(&board_lock);
1836 + /* Reset all blocks. */
1837 + PERF->BlockSoftReset &= ~BSR_ALL_BLOCKS;
1838 + for( i = 0; i < 1000000; i++ )
1840 + PERF->BlockSoftReset |= BSR_ALL_BLOCKS;
1841 + /* Jump to the power on address. */
1845 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1847 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1852 +int kerSysGetMacAddress( unsigned char *pucaMacAddr, unsigned long ulId )
1855 + PMAC_ADDR_INFO pMai = NULL;
1856 + PMAC_ADDR_INFO pMaiFreeNoId = NULL;
1857 + PMAC_ADDR_INFO pMaiFreeId = NULL;
1858 + unsigned long i = 0, ulIdxNoId = 0, ulIdxId = 0, shiftedIdx = 0;
1860 + for( i = 0, pMai = g_pNvramInfo->MacAddrs; i < g_pNvramInfo->ulNumMacAddrs;
1863 + if( ulId == pMai->ulId || ulId == MAC_ADDRESS_ANY )
1865 + /* This MAC address has been used by the caller in the past. */
1866 + memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1867 + NVRAM_MAC_ADDRESS_LEN );
1869 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1870 + pMai->chInUse = 1;
1871 + pMaiFreeNoId = pMaiFreeId = NULL;
1875 + if( pMai->chInUse == 0 )
1877 + if( pMai->ulId == 0 && pMaiFreeNoId == NULL )
1879 + /* This is an available MAC address that has never been
1882 + pMaiFreeNoId = pMai;
1886 + if( pMai->ulId != 0 && pMaiFreeId == NULL )
1888 + /* This is an available MAC address that has been used
1889 + * before. Use addresses that have never been used
1890 + * first, before using this one.
1892 + pMaiFreeId = pMai;
1898 + if( pMaiFreeNoId || pMaiFreeId )
1900 + /* An available MAC address was found. */
1901 + memcpy(pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,NVRAM_MAC_ADDRESS_LEN);
1902 + if( pMaiFreeNoId )
1904 + shiftedIdx = ulIdxNoId;
1905 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1906 + pMaiFreeNoId->ulId = ulId;
1907 + pMaiFreeNoId->chInUse = 1;
1911 + shiftedIdx = ulIdxId;
1912 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1913 + pMaiFreeId->ulId = ulId;
1914 + pMaiFreeId->chInUse = 1;
1918 + if( i == g_pNvramInfo->ulNumMacAddrs )
1919 + nRet = -EADDRNOTAVAIL;
1922 +} /* kerSysGetMacAddr */
1924 +int kerSysReleaseMacAddress( unsigned char *pucaMacAddr )
1926 + int nRet = -EINVAL;
1927 + unsigned long ulIdx = 0;
1928 + int idx = (pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] -
1929 + g_pNvramInfo->ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET]);
1931 + // if overflow 255 (negitive), add 256 to have the correct index
1934 + ulIdx = (unsigned long) (idx >> SHIFT_BITS);
1936 + if( ulIdx < g_pNvramInfo->ulNumMacAddrs )
1938 + PMAC_ADDR_INFO pMai = &g_pNvramInfo->MacAddrs[ulIdx];
1939 + if( pMai->chInUse == 1 )
1941 + pMai->chInUse = 0;
1947 +} /* kerSysReleaseMacAddr */
1949 +int kerSysGetSdramSize( void )
1951 + return( (int) g_pNvramInfo->ulSdramSize );
1952 +} /* kerSysGetSdramSize */
1955 +void kerSysLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
1957 + if (g_ledInitialized)
1958 + boardLedCtrl(ledName, ledState);
1961 +unsigned int kerSysMonitorPollHook( struct file *f, struct poll_table_struct *t)
1963 + int mask = (*g_orig_fop_poll) (f, t);
1965 + if( g_wakeup_monitor == 1 && g_monitor_file == f )
1967 + /* If g_wakeup_monitor is non-0, the user mode application needs to
1968 + * return from a blocking select function. Return POLLPRI which will
1969 + * cause the select to return with the exception descriptor set.
1972 + g_wakeup_monitor = 0;
1978 +/* Put the user mode application that monitors link state on a run queue. */
1979 +void kerSysWakeupMonitorTask( void )
1981 + g_wakeup_monitor = 1;
1982 + if( g_monitor_task )
1983 + wake_up_process( g_monitor_task );
1986 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
1987 +int kerSysGetResetHold(void)
1989 + unsigned short gpio;
1991 + if( BpGetPressAndHoldResetGpio( &gpio ) == BP_SUCCESS )
1993 +#if defined(CONFIG_BCM96338)
1994 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
1995 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
1997 +#if defined(CONFIG_BCM96345)
1998 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(gpio);
1999 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2001 +#if defined(CONFIG_BCM96348)
2002 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
2003 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2005 + if( (gpio & ~BP_ACTIVE_MASK) >= 32 )
2007 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(gpio);
2008 + gpio_reg = &GPIO->GPIOio_high;
2011 + //printk("gpio=%04x,gpio_mask=%04x,gpio_reg=%04x\n",gpio,gpio_mask,*gpio_reg);
2012 + if(*gpio_reg & gpio_mask) //press down
2013 + return RESET_BUTTON_UP;
2015 + return RESET_BUTTON_PRESSDOWN;
2017 +//<<JUNHON, 2004/09/15
2019 +//********************************************************************************************
2020 +// misc. ioctl calls come to here. (flash, led, reset, kernel memory access, etc.)
2021 +//********************************************************************************************
2022 +static int board_ioctl( struct inode *inode, struct file *flip,
2023 + unsigned int command, unsigned long arg )
2026 + BOARD_IOCTL_PARMS ctrlParms;
2027 + unsigned char ucaMacAddr[NVRAM_MAC_ADDRESS_LEN];
2032 + case BOARD_IOCTL_FLASH_INIT:
2033 + // not used for now. kerSysBcmImageInit();
2037 + case BOARD_IOCTL_FLASH_WRITE:
2038 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2040 + NVRAM_DATA SaveNvramData;
2041 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
2043 + switch (ctrlParms.action)
2046 + ret = kerSysScratchPadSet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2050 + ret = kerSysPersistentSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2054 + ret = kerSysNvRamSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2057 + case BCM_IMAGE_CFE:
2058 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > FLASH45_LENGTH_BOOT_ROM )
2060 + printk("Illegal CFE size [%d]. Size allowed: [%d]\n",
2061 + ctrlParms.strLen, FLASH45_LENGTH_BOOT_ROM);
2066 + // save NVRAM data into a local structure
2067 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2069 + // set memory type field
2070 + BpGetSdramSize( (unsigned long *) &ctrlParms.string[SDRAM_TYPE_ADDRESS_OFFSET] );
2072 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2074 + // if nvram is not valid, restore the current nvram settings
2075 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2076 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2078 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2082 + case BCM_IMAGE_FS:
2083 + allowedSize = (int) flash_get_total_size() - \
2084 + FLASH_RESERVED_AT_END - TAG_LEN - FLASH45_LENGTH_BOOT_ROM;
2085 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize)
2087 + printk("Illegal root file system size [%d]. Size allowed: [%d]\n",
2088 + ctrlParms.strLen, allowedSize);
2092 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2093 + kerSysMipsSoftReset();
2096 + case BCM_IMAGE_KERNEL: // not used for now.
2098 + case BCM_IMAGE_WHOLE:
2099 + if(ctrlParms.strLen <= 0)
2101 + printk("Illegal flash image size [%d].\n", ctrlParms.strLen);
2106 + // save NVRAM data into a local structure
2107 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2109 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2111 + // if nvram is not valid, restore the current nvram settings
2112 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2113 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2115 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2118 + kerSysMipsSoftReset();
2123 + printk("flash_ioctl_command: invalid command %d\n", ctrlParms.action);
2126 + ctrlParms.result = ret;
2127 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2133 + case BOARD_IOCTL_FLASH_READ:
2134 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2136 + switch (ctrlParms.action)
2139 + ret = kerSysScratchPadGet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2143 + ret = kerSysPersistentGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2147 + ret = kerSysNvRamGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2151 + ret = kerSysFlashSizeGet();
2156 + printk("Not supported. invalid command %d\n", ctrlParms.action);
2159 + ctrlParms.result = ret;
2160 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2166 + case BOARD_IOCTL_GET_NR_PAGES:
2167 + ctrlParms.result = nr_free_pages() + get_page_cache_size();
2168 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2172 + case BOARD_IOCTL_DUMP_ADDR:
2173 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2175 + dumpaddr( (unsigned char *) ctrlParms.string, ctrlParms.strLen );
2176 + ctrlParms.result = 0;
2177 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2184 + case BOARD_IOCTL_SET_MEMORY:
2185 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2187 + unsigned long *pul = (unsigned long *) ctrlParms.string;
2188 + unsigned short *pus = (unsigned short *) ctrlParms.string;
2189 + unsigned char *puc = (unsigned char *) ctrlParms.string;
2190 + switch( ctrlParms.strLen )
2193 + *pul = (unsigned long) ctrlParms.offset;
2196 + *pus = (unsigned short) ctrlParms.offset;
2199 + *puc = (unsigned char) ctrlParms.offset;
2202 + dumpaddr( (unsigned char *) ctrlParms.string, sizeof(long) );
2203 + ctrlParms.result = 0;
2204 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2211 + case BOARD_IOCTL_MIPS_SOFT_RESET:
2212 + kerSysMipsSoftReset();
2215 + case BOARD_IOCTL_LED_CTRL:
2216 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2218 + kerSysLedCtrl((BOARD_LED_NAME)ctrlParms.strLen, (BOARD_LED_STATE)ctrlParms.offset);
2223 + case BOARD_IOCTL_GET_ID:
2224 + if (copy_from_user((void*)&ctrlParms, (void*)arg,
2225 + sizeof(ctrlParms)) == 0)
2227 + if( ctrlParms.string )
2229 + char *p = (char *) get_system_type();
2230 + if( strlen(p) + 1 < ctrlParms.strLen )
2231 + ctrlParms.strLen = strlen(p) + 1;
2232 + __copy_to_user(ctrlParms.string, p, ctrlParms.strLen);
2235 + ctrlParms.result = 0;
2236 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2237 + sizeof(BOARD_IOCTL_PARMS));
2241 + case BOARD_IOCTL_GET_MAC_ADDRESS:
2242 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2244 + ctrlParms.result = kerSysGetMacAddress( ucaMacAddr,
2245 + ctrlParms.offset );
2247 + if( ctrlParms.result == 0 )
2249 + __copy_to_user(ctrlParms.string, ucaMacAddr,
2250 + sizeof(ucaMacAddr));
2253 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2254 + sizeof(BOARD_IOCTL_PARMS));
2261 + case BOARD_IOCTL_RELEASE_MAC_ADDRESS:
2262 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2264 + if (copy_from_user((void*)ucaMacAddr, (void*)ctrlParms.string, \
2265 + NVRAM_MAC_ADDRESS_LEN) == 0)
2267 + ctrlParms.result = kerSysReleaseMacAddress( ucaMacAddr );
2271 + ctrlParms.result = -EACCES;
2274 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2275 + sizeof(BOARD_IOCTL_PARMS));
2282 + case BOARD_IOCTL_GET_PSI_SIZE:
2283 + ctrlParms.result = (int) g_pNvramInfo->ulPsiSize;
2284 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2288 + case BOARD_IOCTL_GET_SDRAM_SIZE:
2289 + ctrlParms.result = (int) g_pNvramInfo->ulSdramSize;
2290 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2294 + case BOARD_IOCTL_GET_BASE_MAC_ADDRESS:
2295 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2297 + __copy_to_user(ctrlParms.string, g_pNvramInfo->ucaBaseMacAddr, NVRAM_MAC_ADDRESS_LEN);
2298 + ctrlParms.result = 0;
2300 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2301 + sizeof(BOARD_IOCTL_PARMS));
2308 + case BOARD_IOCTL_GET_CHIP_ID:
2309 + ctrlParms.result = (int) (PERF->RevID & 0xFFFF0000) >> 16;
2310 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2314 + case BOARD_IOCTL_GET_NUM_ENET: {
2315 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2316 + int i, numeth = 0;
2317 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2318 + for( i = 0; i < BP_MAX_ENET_MACS; i++) {
2319 + if (EnetInfos[i].ucPhyType != BP_ENET_NO_PHY) {
2323 + ctrlParms.result = numeth;
2324 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2333 + case BOARD_IOCTL_GET_CFE_VER:
2334 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2335 + char *vertag = (char *)(FLASH_BASE + CFE_VERSION_OFFSET);
2336 + if (ctrlParms.strLen < CFE_VERSION_SIZE) {
2337 + ctrlParms.result = 0;
2338 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2341 + else if (strncmp(vertag, "cfe-v", 5)) { // no tag info in flash
2342 + ctrlParms.result = 0;
2343 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2347 + ctrlParms.result = 1;
2348 + __copy_to_user(ctrlParms.string, vertag+CFE_VERSION_MARK_SIZE, CFE_VERSION_SIZE);
2349 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2358 + case BOARD_IOCTL_GET_ENET_CFG:
2359 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2360 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2361 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2362 + if (ctrlParms.strLen == sizeof(EnetInfos)) {
2363 + __copy_to_user(ctrlParms.string, EnetInfos, sizeof(EnetInfos));
2364 + ctrlParms.result = 0;
2365 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2379 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2380 + case BOARD_IOCTL_GET_RESETHOLD:
2381 + ctrlParms.result = kerSysGetResetHold();
2382 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2385 +//>>JUNHON, 2004/09/15
2388 +#if defined (WIRELESS)
2389 + case BOARD_IOCTL_GET_WLAN_ANT_INUSE:
2390 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2391 + unsigned short antInUse = 0;
2392 + if (BpGetWirelessAntInUse(&antInUse) == BP_SUCCESS) {
2393 + if (ctrlParms.strLen == sizeof(antInUse)) {
2394 + __copy_to_user(ctrlParms.string, &antInUse, sizeof(antInUse));
2395 + ctrlParms.result = 0;
2396 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2411 + case BOARD_IOCTL_SET_TRIGGER_EVENT:
2412 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2413 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2414 + ctrlParms.result = -EFAULT;
2416 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2417 + board_ioc->eventmask |= *((int*)ctrlParms.string);
2418 +#if defined (WIRELESS)
2419 + if((board_ioc->eventmask & SES_EVENTS)) {
2420 + if(sesBtn_irq != BP_NOT_DEFINED) {
2421 + BcmHalInterruptEnable(sesBtn_irq);
2422 + ctrlParms.result = 0;
2427 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2436 + case BOARD_IOCTL_GET_TRIGGER_EVENT:
2437 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2438 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2439 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2440 + __copy_to_user(ctrlParms.string, &board_ioc->eventmask, sizeof(unsigned long));
2441 + ctrlParms.result = 0;
2442 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2454 + case BOARD_IOCTL_UNSET_TRIGGER_EVENT:
2455 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2456 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2457 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2458 + board_ioc->eventmask &= (~(*((int*)ctrlParms.string)));
2459 + ctrlParms.result = 0;
2460 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2471 +#if defined (WIRELESS)
2472 + case BOARD_IOCTL_SET_SES_LED:
2473 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2474 + if (ctrlParms.strLen == sizeof(int)) {
2475 + sesLed_ctrl(*(int*)ctrlParms.string);
2476 + ctrlParms.result = 0;
2477 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2490 + case BOARD_IOCTL_SET_MONITOR_FD:
2491 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2492 + int fput_needed = 0;
2494 + g_monitor_file = fget_light( ctrlParms.offset, &fput_needed );
2495 + if( g_monitor_file ) {
2496 + /* Hook this file descriptor's poll function in order to set
2497 + * the exception descriptor when there is a change in link
2500 + g_monitor_task = current;
2501 + g_orig_fop_poll = kerSysMonitorPollHook;
2502 + /*g_orig_fop_poll = g_monitor_file->f_op->poll;
2503 + g_monitor_file->f_op->poll = kerSysMonitorPollHook;*/
2508 + case BOARD_IOCTL_WAKEUP_MONITOR_TASK:
2509 + kerSysWakeupMonitorTask();
2514 + ctrlParms.result = 0;
2515 + printk("board_ioctl: invalid command %x, cmd %d .\n",command,_IOC_NR(command));
2522 +} /* board_ioctl */
2524 +/***************************************************************************
2525 + * SES Button ISR/GPIO/LED functions.
2526 + ***************************************************************************/
2527 +#if defined (WIRELESS)
2528 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs)
2530 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2531 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2532 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2534 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2535 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2536 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2538 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2539 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2540 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2542 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2544 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2545 + gpio_reg = &GPIO->GPIOio_high;
2549 + if (!(*gpio_reg & gpio_mask)){
2550 + wake_up_interruptible(&g_board_wait_queue);
2551 + return IRQ_RETVAL(1);
2553 + return IRQ_RETVAL(0);
2557 +static void __init sesBtn_mapGpio()
2559 + if( BpGetWirelessSesBtnGpio(&sesBtn_gpio) == BP_SUCCESS )
2561 + printk("SES: Button GPIO 0x%x is enabled\n", sesBtn_gpio);
2565 +static void __init sesBtn_mapIntr(int context)
2567 + if( BpGetWirelessSesExtIntr(&sesBtn_irq) == BP_SUCCESS )
2569 + printk("SES: Button Interrupt 0x%x is enabled\n", sesBtn_irq);
2574 + sesBtn_irq += INTERRUPT_ID_EXTERNAL_0;
2576 + if (BcmHalMapInterrupt((FN_HANDLER)sesBtn_isr, context, sesBtn_irq)) {
2577 + printk("SES: Interrupt mapping failed\n");
2579 + BcmHalInterruptEnable(sesBtn_irq);
2583 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait)
2585 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2586 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2587 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2589 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2590 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2591 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2593 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2594 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2595 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2597 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2599 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2600 + gpio_reg = &GPIO->GPIOio_high;
2604 + if (!(*gpio_reg & gpio_mask)){
2610 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
2612 + volatile unsigned int event=0;
2615 +#if defined(_BCM96338_) || defined (CONFIG_BCM96338)
2616 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2617 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2619 +#if defined(_BCM96345_) || defined (CONFIG_BCM96345)
2620 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2621 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2623 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2624 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2625 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2627 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2629 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2630 + gpio_reg = &GPIO->GPIOio_high;
2634 + if(*gpio_reg & gpio_mask){
2635 + BcmHalInterruptEnable(sesBtn_irq);
2638 + event = SES_EVENTS;
2639 + __copy_to_user((char*)buffer, (char*)&event, sizeof(event));
2640 + BcmHalInterruptEnable(sesBtn_irq);
2641 + count -= sizeof(event);
2642 + buffer += sizeof(event);
2643 + ret += sizeof(event);
2647 +static void __init sesLed_mapGpio()
2649 + if( BpGetWirelessSesBtnGpio(&sesLed_gpio) == BP_SUCCESS )
2651 + printk("SES: LED GPIO 0x%x is enabled\n", sesBtn_gpio);
2655 +static void sesLed_ctrl(int action)
2658 + //char status = ((action >> 8) & 0xff); /* extract status */
2659 + //char event = ((action >> 16) & 0xff); /* extract event */
2660 + //char blinktype = ((action >> 24) & 0xff); /* extract blink type for SES_LED_BLINK */
2662 + BOARD_LED_STATE led;
2664 + if(sesLed_gpio == BP_NOT_DEFINED)
2667 + action &= 0xff; /* extract led */
2669 + //printk("blinktype=%d, event=%d, status=%d\n",(int)blinktype, (int)event, (int)status);
2674 + //printk("SES: led on\n");
2675 + led = kLedStateOn;
2677 + case SES_LED_BLINK:
2678 + //printk("SES: led blink\n");
2679 + led = kLedStateSlowBlinkContinues;
2683 + //printk("SES: led off\n");
2684 + led = kLedStateOff;
2687 + kerSysLedCtrl(kLedSes, led);
2690 +static void __init ses_board_init()
2693 + sesBtn_mapIntr(0);
2696 +static void __exit ses_board_deinit()
2699 + BcmHalInterruptDisable(sesBtn_irq);
2703 +/***************************************************************************
2704 + * Dying gasp ISR and functions.
2705 + ***************************************************************************/
2706 +#define KERSYS_DBG printk
2708 +#if defined(CONFIG_BCM96345)
2709 +#define CYCLE_PER_US 70
2710 +#elif defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
2711 +/* The BCM6348 cycles per microsecond is really variable since the BCM6348
2712 + * MIPS speed can vary depending on the PLL settings. However, an appoximate
2713 + * value of 120 will still work OK for the test being done.
2715 +#define CYCLE_PER_US 120
2717 +#define DG_GLITCH_TO (100*CYCLE_PER_US)
2719 +static void __init kerSysDyingGaspMapIntr()
2721 + unsigned long ulIntr;
2723 +#if defined(CONFIG_BCM96348) || defined(_BCM96348_) || defined(CONFIG_BCM96338) || defined(_BCM96338_)
2724 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2725 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, INTERRUPT_ID_DG);
2726 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2728 +#elif defined(CONFIG_BCM96345) || defined(_BCM96345_)
2729 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2730 + ulIntr += INTERRUPT_ID_EXTERNAL_0;
2731 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, ulIntr);
2732 + BcmHalInterruptEnable( ulIntr );
2738 +void kerSysSetWdTimer(ulong timeUs)
2740 + TIMER->WatchDogDefCount = timeUs * (FPERIPH/1000000);
2741 + TIMER->WatchDogCtl = 0xFF00;
2742 + TIMER->WatchDogCtl = 0x00FF;
2745 +ulong kerSysGetCycleCount(void)
2751 + __asm volatile("mfc0 %0, $9":"=d"(cnt));
2756 +static Bool kerSysDyingGaspCheckPowerLoss(void)
2762 + clk0 = kerSysGetCycleCount();
2768 +#if defined(CONFIG_BCM96345)
2769 + BpGetAdslDyingGaspExtIntr( &ulIntr );
2774 + clk1 = kerSysGetCycleCount(); /* time cleared */
2775 + /* wait a little to get new reading */
2776 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2778 + } while ((0 == (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT)))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2780 + if (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT))) { /* power glitch */
2781 + BcmHalInterruptEnable( ulIntr + INTERRUPT_ID_EXTERNAL_0);
2782 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2785 +#elif (defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)) && !defined(VXWORKS)
2789 + clk1 = kerSysGetCycleCount(); /* time cleared */
2790 + /* wait a little to get new reading */
2791 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2793 + } while ((PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2795 + if (!(PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET)))) {
2796 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2797 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2804 +static void kerSysDyingGaspShutdown( void )
2806 + kerSysSetWdTimer(1000000);
2807 +#if defined(CONFIG_BCM96345)
2808 + PERF->blkEnables &= ~(EMAC_CLK_EN | USB_CLK_EN | CPU_CLK_EN);
2809 +#elif defined(CONFIG_BCM96348)
2810 + PERF->blkEnables &= ~(EMAC_CLK_EN | USBS_CLK_EN | USBH_CLK_EN | SAR_CLK_EN);
2814 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2815 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs)
2817 +static unsigned int kerSysDyingGaspIsr(void)
2820 + struct list_head *pos;
2821 + CB_DGASP_LIST *tmp, *dsl = NULL;
2823 + if (kerSysDyingGaspCheckPowerLoss()) {
2825 + /* first to turn off everything other than dsl */
2826 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2827 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2828 + if(strncmp(tmp->name, "dsl", 3)) {
2829 + (tmp->cb_dgasp_fn)(tmp->context);
2835 + /* now send dgasp */
2837 + (dsl->cb_dgasp_fn)(dsl->context);
2839 + /* reset and shutdown system */
2840 + kerSysDyingGaspShutdown();
2842 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2843 +return( IRQ_HANDLED );
2849 +static void __init kerSysInitDyingGaspHandler( void )
2851 + CB_DGASP_LIST *new_node;
2853 + if( g_cb_dgasp_list_head != NULL) {
2854 + printk("Error: kerSysInitDyingGaspHandler: list head is not null\n");
2857 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
2858 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
2859 + INIT_LIST_HEAD(&new_node->list);
2860 + g_cb_dgasp_list_head = new_node;
2862 +} /* kerSysInitDyingGaspHandler */
2864 +static void __exit kerSysDeinitDyingGaspHandler( void )
2866 + struct list_head *pos;
2867 + CB_DGASP_LIST *tmp;
2869 + if(g_cb_dgasp_list_head == NULL)
2872 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2873 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2878 + kfree(g_cb_dgasp_list_head);
2879 + g_cb_dgasp_list_head = NULL;
2881 +} /* kerSysDeinitDyingGaspHandler */
2883 +void kerSysRegisterDyingGaspHandler(char *devname, void *cbfn, void *context)
2885 + CB_DGASP_LIST *new_node;
2887 + if( g_cb_dgasp_list_head == NULL) {
2888 + printk("Error: kerSysRegisterDyingGaspHandler: list head is null\n");
2892 + if( devname == NULL || cbfn == NULL ) {
2893 + printk("Error: kerSysRegisterDyingGaspHandler: register info not enough (%s,%x,%x)\n", devname, (unsigned int)cbfn, (unsigned int)context);
2897 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
2898 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
2899 + INIT_LIST_HEAD(&new_node->list);
2900 + strncpy(new_node->name, devname, IFNAMSIZ);
2901 + new_node->cb_dgasp_fn = (cb_dgasp_t)cbfn;
2902 + new_node->context = context;
2903 + list_add(&new_node->list, &g_cb_dgasp_list_head->list);
2905 + printk("dgasp: kerSysRegisterDyingGaspHandler: %s registered \n", devname);
2907 +} /* kerSysRegisterDyingGaspHandler */
2909 +void kerSysDeregisterDyingGaspHandler(char *devname)
2911 + struct list_head *pos;
2912 + CB_DGASP_LIST *tmp;
2914 + if(g_cb_dgasp_list_head == NULL) {
2915 + printk("Error: kerSysDeregisterDyingGaspHandler: list head is null\n");
2919 + if(devname == NULL) {
2920 + printk("Error: kerSysDeregisterDyingGaspHandler: devname is null\n");
2924 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistering\n", devname);
2926 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2927 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2928 + if(!strcmp(tmp->name, devname)) {
2931 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistered\n", devname);
2935 + printk("kerSysDeregisterDyingGaspHandler: %s not (de)registered\n", devname);
2937 +} /* kerSysDeregisterDyingGaspHandler */
2939 +/***************************************************************************
2940 + * MACRO to call driver initialization and cleanup functions.
2941 + ***************************************************************************/
2942 +module_init( brcm_board_init );
2943 +module_exit( brcm_board_cleanup );
2945 +EXPORT_SYMBOL(kerSysNvRamGet);
2946 +EXPORT_SYMBOL(dumpaddr);
2947 +EXPORT_SYMBOL(kerSysGetMacAddress);
2948 +EXPORT_SYMBOL(kerSysReleaseMacAddress);
2949 +EXPORT_SYMBOL(kerSysGetSdramSize);
2950 +EXPORT_SYMBOL(kerSysLedCtrl);
2951 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2952 +EXPORT_SYMBOL(kerSysGetResetHold);
2953 +//>>JUNHON, 2004/09/15
2954 +EXPORT_SYMBOL(kerSysLedRegisterHwHandler);
2955 +EXPORT_SYMBOL(BpGetBoardIds);
2956 +EXPORT_SYMBOL(BpGetSdramSize);
2957 +EXPORT_SYMBOL(BpGetPsiSize);
2958 +EXPORT_SYMBOL(BpGetEthernetMacInfo);
2959 +EXPORT_SYMBOL(BpGetRj11InnerOuterPairGpios);
2960 +EXPORT_SYMBOL(BpGetPressAndHoldResetGpio);
2961 +EXPORT_SYMBOL(BpGetVoipResetGpio);
2962 +EXPORT_SYMBOL(BpGetVoipIntrGpio);
2963 +EXPORT_SYMBOL(BpGetPcmciaResetGpio);
2964 +EXPORT_SYMBOL(BpGetRtsCtsUartGpios);
2965 +EXPORT_SYMBOL(BpGetAdslLedGpio);
2966 +EXPORT_SYMBOL(BpGetAdslFailLedGpio);
2967 +EXPORT_SYMBOL(BpGetWirelessLedGpio);
2968 +EXPORT_SYMBOL(BpGetUsbLedGpio);
2969 +EXPORT_SYMBOL(BpGetHpnaLedGpio);
2970 +EXPORT_SYMBOL(BpGetWanDataLedGpio);
2971 +EXPORT_SYMBOL(BpGetPppLedGpio);
2972 +EXPORT_SYMBOL(BpGetPppFailLedGpio);
2973 +EXPORT_SYMBOL(BpGetVoipLedGpio);
2974 +EXPORT_SYMBOL(BpGetWirelessExtIntr);
2975 +EXPORT_SYMBOL(BpGetAdslDyingGaspExtIntr);
2976 +EXPORT_SYMBOL(BpGetVoipExtIntr);
2977 +EXPORT_SYMBOL(BpGetHpnaExtIntr);
2978 +EXPORT_SYMBOL(BpGetHpnaChipSelect);
2979 +EXPORT_SYMBOL(BpGetVoipChipSelect);
2980 +EXPORT_SYMBOL(BpGetWirelessSesBtnGpio);
2981 +EXPORT_SYMBOL(BpGetWirelessSesExtIntr);
2982 +EXPORT_SYMBOL(BpGetWirelessSesLedGpio);
2983 +EXPORT_SYMBOL(kerSysRegisterDyingGaspHandler);
2984 +EXPORT_SYMBOL(kerSysDeregisterDyingGaspHandler);
2985 +EXPORT_SYMBOL(kerSysGetCycleCount);
2986 +EXPORT_SYMBOL(kerSysSetWdTimer);
2987 +EXPORT_SYMBOL(kerSysWakeupMonitorTask);
2989 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c
2990 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c 1970-01-01 01:00:00.000000000 +0100
2991 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c 2006-07-13 19:11:33.000000000 +0200
2996 + Copyright 2003 Broadcom Corp. All Rights Reserved.
2998 + This program is free software; you can distribute it and/or modify it
2999 + under the terms of the GNU General Public License (Version 2) as
3000 + published by the Free Software Foundation.
3002 + This program is distributed in the hope it will be useful, but WITHOUT
3003 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3004 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3007 + You should have received a copy of the GNU General Public License along
3008 + with this program; if not, write to the Free Software Foundation, Inc.,
3009 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
3013 +/**************************************************************************
3014 + * File Name : boardparms.c
3016 + * Description: This file contains the implementation for the BCM63xx board
3017 + * parameter access functions.
3019 + * Updates : 07/14/2003 Created.
3020 + ***************************************************************************/
3023 +#include "boardparms.h"
3027 +/* Default psi size in K bytes */
3028 +#define BP_PSI_DEFAULT_SIZE 24
3031 +typedef struct boardparameters
3033 + char szBoardId[BP_BOARD_ID_LEN]; /* board id string */
3034 + ETHERNET_MAC_INFO EnetMacInfos[BP_MAX_ENET_MACS];
3035 + VOIP_DSP_INFO VoIPDspInfo[BP_MAX_VOIP_DSP];
3036 + unsigned short usSdramSize; /* SDRAM size and type */
3037 + unsigned short usPsiSize; /* persistent storage in K bytes */
3038 + unsigned short usGpioRj11InnerPair; /* GPIO pin or not defined */
3039 + unsigned short usGpioRj11OuterPair; /* GPIO pin or not defined */
3040 + unsigned short usGpioPressAndHoldReset; /* GPIO pin or not defined */
3041 + unsigned short usGpioPcmciaReset; /* GPIO pin or not defined */
3042 + unsigned short usGpioUartRts; /* GPIO pin or not defined */
3043 + unsigned short usGpioUartCts; /* GPIO pin or not defined */
3044 + unsigned short usGpioLedAdsl; /* GPIO pin or not defined */
3045 + unsigned short usGpioLedAdslFail; /* GPIO pin or not defined */
3046 + unsigned short usGpioLedWireless; /* GPIO pin or not defined */
3047 + unsigned short usGpioLedUsb; /* GPIO pin or not defined */
3048 + unsigned short usGpioLedHpna; /* GPIO pin or not defined */
3049 + unsigned short usGpioLedWanData; /* GPIO pin or not defined */
3050 + unsigned short usGpioLedPpp; /* GPIO pin or not defined */
3051 + unsigned short usGpioLedPppFail; /* GPIO pin or not defined */
3052 + unsigned short usGpioLedBlPowerOn; /* GPIO pin or not defined */
3053 + unsigned short usGpioLedBlAlarm; /* GPIO pin or not defined */
3054 + unsigned short usGpioLedBlResetCfg; /* GPIO pin or not defined */
3055 + unsigned short usGpioLedBlStop; /* GPIO pin or not defined */
3056 + unsigned short usExtIntrWireless; /* ext intr or not defined */
3057 + unsigned short usExtIntrAdslDyingGasp; /* ext intr or not defined */
3058 + unsigned short usExtIntrHpna; /* ext intr or not defined */
3059 + unsigned short usCsHpna; /* chip select not defined */
3060 + unsigned short usAntInUseWireless; /* antenna in use or not defined */
3061 + unsigned short usGpioSesBtnWireless; /* GPIO pin or not defined */
3062 + unsigned short usExtIntrSesBtnWireless; /* ext intr or not defined */
3063 + unsigned short usGpioLedSesWireless; /* GPIO pin or not defined */
3064 +} BOARD_PARAMETERS, *PBOARD_PARAMETERS;
3067 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
3068 +static BOARD_PARAMETERS g_bcm96338sv =
3070 + "96338SV", /* szBoardId */
3071 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3072 + 0x01, /* ucPhyAddress */
3073 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3074 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3075 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3076 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3077 + BP_NOT_DEFINED, /* usGpioPhyReset */
3078 + 0x01, /* numSwitchPorts */
3079 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3080 + BP_NOT_DEFINED}, /* usReverseMii */
3081 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3082 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3083 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3084 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3085 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3086 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3087 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3088 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3089 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3090 + BP_NOT_DEFINED, /* usGpioUartRts */
3091 + BP_NOT_DEFINED, /* usGpioUartCts */
3092 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3093 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3094 + BP_NOT_DEFINED, /* usGpioLedWireless */
3095 + BP_NOT_DEFINED, /* usGpioLedUsb */
3096 + BP_NOT_DEFINED, /* usGpioLedHpna */
3097 + BP_NOT_DEFINED, /* usGpioLedWanData */
3098 + BP_NOT_DEFINED, /* usGpioLedPpp */
3099 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3100 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3101 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3102 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3103 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3104 + BP_NOT_DEFINED, /* usExtIntrWireless */
3105 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3106 + BP_NOT_DEFINED, /* usExtIntrHpna */
3107 + BP_NOT_DEFINED, /* usCsHpna */
3108 + BP_NOT_DEFINED, /* usAntInUseWireless */
3109 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3110 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3111 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3113 +static BOARD_PARAMETERS g_bcm96338l2m8m =
3115 + "96338L-2M-8M", /* szBoardId */
3116 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3117 + 0x01, /* ucPhyAddress */
3118 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3119 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3120 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3121 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3122 + BP_NOT_DEFINED, /* usGpioPhyReset */
3123 + 0x01, /* numSwitchPorts */
3124 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3125 + BP_NOT_DEFINED}, /* usReverseMii */
3126 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3127 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3128 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3129 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3130 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3131 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3132 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3133 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3134 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3135 + BP_NOT_DEFINED, /* usGpioUartRts */
3136 + BP_NOT_DEFINED, /* usGpioUartCts */
3137 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3138 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3139 + BP_NOT_DEFINED, /* usGpioLedWireless */
3140 + BP_NOT_DEFINED, /* usGpioLedUsb */
3141 + BP_NOT_DEFINED, /* usGpioLedHpna */
3142 + BP_GPIO_3_AL, /* usGpioLedWanData */
3143 + BP_GPIO_3_AL, /* usGpioLedPpp */
3144 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3145 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3146 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3147 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3148 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3149 + BP_NOT_DEFINED, /* usExtIntrWireless */
3150 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3151 + BP_NOT_DEFINED, /* usExtIntrHpna */
3152 + BP_NOT_DEFINED, /* usCsHpna */
3153 + BP_NOT_DEFINED, /* usAntInUseWireless */
3154 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3155 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3156 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3158 +static PBOARD_PARAMETERS g_BoardParms[] =
3159 + {&g_bcm96338sv, &g_bcm96338l2m8m, 0};
3162 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
3163 +static BOARD_PARAMETERS g_bcm96345r =
3165 + "96345R", /* szBoardId */
3166 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3167 + 0x01, /* ucPhyAddress */
3168 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3169 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3170 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3171 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3172 + BP_NOT_DEFINED, /* usGpioPhyReset */
3173 + 0x01, /* numSwitchPorts */
3174 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3175 + BP_NOT_DEFINED}, /* usReverseMii */
3176 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3177 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3178 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3179 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3180 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3181 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3182 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3183 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3184 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3185 + BP_NOT_DEFINED, /* usGpioUartRts */
3186 + BP_NOT_DEFINED, /* usGpioUartCts */
3187 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3188 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3189 + BP_NOT_DEFINED, /* usGpioLedWireless */
3190 + BP_NOT_DEFINED, /* usGpioLedUsb */
3191 + BP_NOT_DEFINED, /* usGpioLedHpna */
3192 + BP_GPIO_8_AH, /* usGpioLedWanData */
3193 + BP_GPIO_9_AH, /* usGpioLedPpp */
3194 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3195 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3196 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3197 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3198 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3199 + BP_NOT_DEFINED, /* usExtIntrWireless */
3200 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3201 + BP_NOT_DEFINED, /* usExtIntrHpna */
3202 + BP_NOT_DEFINED, /* usCsHpna */
3203 + BP_NOT_DEFINED, /* usAntInUseWireless */
3204 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3205 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3206 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3209 +static BOARD_PARAMETERS g_bcm96345gw2 =
3211 + /* A hardware jumper determines whether GPIO 13 is used for Press and Hold
3214 + "96345GW2", /* szBoardId */
3215 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3216 + 0x00, /* ucPhyAddress */
3217 + BP_GPIO_0_AH, /* usGpioPhySpiSck */
3218 + BP_GPIO_4_AH, /* usGpioPhySpiSs */
3219 + BP_GPIO_12_AH, /* usGpioPhySpiMosi */
3220 + BP_GPIO_11_AH, /* usGpioPhySpiMiso */
3221 + BP_NOT_DEFINED, /* usGpioPhyReset */
3222 + 0x04, /* numSwitchPorts */
3223 + BP_ENET_CONFIG_GPIO, /* usConfigType */
3224 + BP_ENET_REVERSE_MII}, /* usReverseMii */
3225 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3226 + {{BP_VOIP_DSP, /* ucDspType */
3227 + 0x00, /* ucDspAddress */
3228 + BP_EXT_INTR_1, /* usExtIntrVoip */
3229 + BP_GPIO_6_AH, /* usGpioVoipReset */
3230 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3231 + BP_NOT_DEFINED, /* usGpioLedVoip */
3232 + BP_CS_2}, /* usCsVoip */
3233 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3234 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3235 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3236 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3237 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3238 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3239 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3240 + BP_GPIO_13_AH, /* usGpioUartRts */
3241 + BP_GPIO_9_AH, /* usGpioUartCts */
3242 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3243 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3244 + BP_NOT_DEFINED, /* usGpioLedWireless */
3245 + BP_GPIO_7_AH, /* usGpioLedUsb */
3246 + BP_NOT_DEFINED, /* usGpioLedHpna */
3247 + BP_GPIO_8_AH, /* usGpioLedWanData */
3248 + BP_NOT_DEFINED, /* usGpioLedPpp */
3249 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3250 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3251 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3252 + BP_GPIO_7_AH, /* usGpioLedBlResetCfg */
3253 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3254 + BP_EXT_INTR_2, /* usExtIntrWireless */
3255 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3256 + BP_NOT_DEFINED, /* usExtIntrHpna */
3257 + BP_NOT_DEFINED, /* usCsHpna */
3258 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3259 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3260 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3261 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3264 +static BOARD_PARAMETERS g_bcm96345gw =
3266 + "96345GW", /* szBoardId */
3267 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3268 + 0x00, /* ucPhyAddress */
3269 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3270 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3271 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3272 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3273 + BP_NOT_DEFINED, /* usGpioPhyReset */
3274 + 0x04, /* numSwitchPorts */
3275 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3276 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3277 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3278 + {{BP_VOIP_DSP, /* ucDspType */
3279 + 0x00, /* ucDspAddress */
3280 + BP_EXT_INTR_1, /* usExtIntrVoip */
3281 + BP_GPIO_6_AH, /* usGpioVoipReset */
3282 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3283 + BP_NOT_DEFINED, /* usGpioLedVoip */
3284 + BP_CS_2}, /* usCsVoip */
3285 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3286 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3287 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3288 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3289 + BP_GPIO_1_AH, /* usGpioRj11OuterPair */
3290 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3291 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3292 + BP_NOT_DEFINED, /* usGpioUartRts */
3293 + BP_NOT_DEFINED, /* usGpioUartCts */
3294 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3295 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3296 + BP_GPIO_10_AH, /* usGpioLedWireless */
3297 + BP_GPIO_7_AH, /* usGpioLedUsb */
3298 + BP_NOT_DEFINED, /* usGpioLedHpna */
3299 + BP_GPIO_8_AH, /* usGpioLedWanData */
3300 + BP_NOT_DEFINED, /* usGpioLedPpp */
3301 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3302 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3303 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3304 + BP_GPIO_10_AH, /* usGpioLedBlResetCfg */
3305 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3306 + BP_EXT_INTR_2, /* usExtIntrWireless */
3307 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3308 + BP_EXT_INTR_3, /* usExtIntrHpna */
3309 + BP_CS_1, /* usCsHpna */
3310 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3311 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3312 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3313 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3316 +static BOARD_PARAMETERS g_bcm96335r =
3318 + "96335R", /* szBoardId */
3319 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3320 + 0x01, /* ucPhyAddress */
3321 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3322 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3323 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3324 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3325 + BP_NOT_DEFINED, /* usGpioPhyReset */
3326 + 0x01, /* numSwitchPorts */
3327 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3328 + BP_NOT_DEFINED}, /* usReverseMii */
3329 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3330 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3331 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3332 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3333 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3334 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3335 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3336 + BP_GPIO_14_AH, /* usGpioPressAndHoldReset */
3337 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3338 + BP_NOT_DEFINED, /* usGpioUartRts */
3339 + BP_NOT_DEFINED, /* usGpioUartCts */
3340 + BP_GPIO_9_AH, /* usGpioLedAdsl */
3341 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3342 + BP_NOT_DEFINED, /* usGpioLedWireless */
3343 + BP_NOT_DEFINED, /* usGpioLedUsb */
3344 + BP_NOT_DEFINED, /* usGpioLedHpna */
3345 + BP_GPIO_9_AH, /* usGpioLedWanData */
3346 + BP_GPIO_8_AH, /* usGpioLedPpp */
3347 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3348 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3349 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3350 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3351 + BP_GPIO_9_AH, /* usGpioLedBlStop */
3352 + BP_NOT_DEFINED, /* usExtIntrWireless */
3353 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3354 + BP_NOT_DEFINED, /* usExtIntrHpna */
3355 + BP_NOT_DEFINED, /* usCsHpna */
3356 + BP_NOT_DEFINED, /* usAntInUseWireless */
3357 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3358 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3359 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3362 +static BOARD_PARAMETERS g_bcm96345r0 =
3364 + "96345R0", /* szBoardId */
3365 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3366 + 0x01, /* ucPhyAddress */
3367 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3368 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3369 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3370 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3371 + BP_NOT_DEFINED, /* usGpioPhyReset */
3372 + 0x01, /* numSwitchPorts */
3373 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3374 + BP_NOT_DEFINED}, /* usReverseMii */
3375 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3376 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3377 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3378 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3379 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3380 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3381 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3382 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3383 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3384 + BP_NOT_DEFINED, /* usGpioUartRts */
3385 + BP_NOT_DEFINED, /* usGpioUartCts */
3386 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3387 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3388 + BP_NOT_DEFINED, /* usGpioLedWireless */
3389 + BP_NOT_DEFINED, /* usGpioLedUsb */
3390 + BP_NOT_DEFINED, /* usGpioLedHpna */
3391 + BP_GPIO_9_AH, /* usGpioLedWanData */
3392 + BP_GPIO_9_AH, /* usGpioLedPpp */
3393 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3394 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3395 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3396 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3397 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3398 + BP_NOT_DEFINED, /* usExtIntrWireless */
3399 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3400 + BP_NOT_DEFINED, /* usExtIntrHpna */
3401 + BP_NOT_DEFINED, /* usCsHpna */
3402 + BP_NOT_DEFINED, /* usAntInUseWireless */
3403 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3404 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3405 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3408 +static BOARD_PARAMETERS g_bcm96345rs =
3410 + "96345RS", /* szBoardId */
3411 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3412 + 0x00, /* ucPhyAddress */
3413 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3414 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3415 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3416 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3417 + BP_NOT_DEFINED, /* usGpioPhyReset */
3418 + 0x01, /* numSwitchPorts */
3419 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3420 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3421 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3422 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3423 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3424 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3425 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3426 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3427 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3428 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3429 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3430 + BP_NOT_DEFINED, /* usGpioUartRts */
3431 + BP_NOT_DEFINED, /* usGpioUartCts */
3432 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3433 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3434 + BP_NOT_DEFINED, /* usGpioLedWireless */
3435 + BP_NOT_DEFINED, /* usGpioLedUsb */
3436 + BP_NOT_DEFINED, /* usGpioLedHpna */
3437 + BP_GPIO_8_AH, /* usGpioLedWanData */
3438 + BP_GPIO_9_AH, /* usGpioLedPpp */
3439 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3440 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3441 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3442 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3443 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3444 + BP_NOT_DEFINED, /* usExtIntrWireless */
3445 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3446 + BP_NOT_DEFINED, /* usExtIntrHpna */
3447 + BP_NOT_DEFINED, /* usCsHpna */
3448 + BP_NOT_DEFINED, /* usAntInUseWireless */
3449 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3450 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3451 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3454 +static PBOARD_PARAMETERS g_BoardParms[] =
3455 + {&g_bcm96345r, &g_bcm96345gw2, &g_bcm96345gw, &g_bcm96335r, &g_bcm96345r0,
3456 + &g_bcm96345rs, 0};
3459 +#if defined(_BCM96348_) || defined(CONFIG_BCM96348)
3461 +static BOARD_PARAMETERS g_bcm96348r =
3463 + "96348R", /* szBoardId */
3464 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3465 + 0x01, /* ucPhyAddress */
3466 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3467 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3468 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3469 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3470 + BP_NOT_DEFINED, /* usGpioPhyReset */
3471 + 0x01, /* numSwitchPorts */
3472 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3473 + BP_NOT_DEFINED}, /* usReverseMii */
3474 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3475 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3476 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3477 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3478 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3479 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3480 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3481 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3482 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3483 + BP_NOT_DEFINED, /* usGpioUartRts */
3484 + BP_NOT_DEFINED, /* usGpioUartCts */
3485 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3486 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3487 + BP_NOT_DEFINED, /* usGpioLedWireless */
3488 + BP_NOT_DEFINED, /* usGpioLedUsb */
3489 + BP_NOT_DEFINED, /* usGpioLedHpna */
3490 + BP_GPIO_3_AL, /* usGpioLedWanData */
3491 + BP_GPIO_3_AL, /* usGpioLedPpp */
3492 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3493 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3494 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3495 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3496 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3497 + BP_NOT_DEFINED, /* usExtIntrWireless */
3498 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3499 + BP_NOT_DEFINED, /* usExtIntrHpna */
3500 + BP_NOT_DEFINED, /* usCsHpna */
3501 + BP_NOT_DEFINED, /* usAntInUseWireless */
3502 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3503 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3504 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3507 +static BOARD_PARAMETERS g_bcm96348lv =
3509 + "96348LV", /* szBoardId */
3510 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3511 + 0x01, /* ucPhyAddress */
3512 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3513 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3514 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3515 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3516 + BP_NOT_DEFINED, /* usGpioPhyReset */
3517 + 0x01, /* numSwitchPorts */
3518 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3519 + BP_NOT_DEFINED}, /* usReverseMii */
3520 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3521 + 0x02, /* ucPhyAddress */
3522 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3523 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3524 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3525 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3526 + BP_GPIO_5_AL, /* usGpioPhyReset */
3527 + 0x01, /* numSwitchPorts */
3528 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3529 + BP_NOT_DEFINED}}, /* usReverseMii */
3530 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3531 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3532 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3533 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3534 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3535 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3536 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3537 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3538 + BP_NOT_DEFINED, /* usGpioUartRts */
3539 + BP_NOT_DEFINED, /* usGpioUartCts */
3540 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3541 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3542 + BP_NOT_DEFINED, /* usGpioLedWireless */
3543 + BP_NOT_DEFINED, /* usGpioLedUsb */
3544 + BP_NOT_DEFINED, /* usGpioLedHpna */
3545 + BP_GPIO_3_AL, /* usGpioLedWanData */
3546 + BP_GPIO_3_AL, /* usGpioLedPpp */
3547 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3548 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3549 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3550 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3551 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3552 + BP_NOT_DEFINED, /* usExtIntrWireless */
3553 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3554 + BP_NOT_DEFINED, /* usExtIntrHpna */
3555 + BP_NOT_DEFINED, /* usCsHpna */
3556 + BP_NOT_DEFINED, /* usAntInUseWireless */
3557 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3558 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3559 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3562 +static BOARD_PARAMETERS g_bcm96348gw =
3564 + "96348GW", /* szBoardId */
3565 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3566 + 0x01, /* ucPhyAddress */
3567 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3568 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3569 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3570 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3571 + BP_NOT_DEFINED, /* usGpioPhyReset */
3572 + 0x01, /* numSwitchPorts */
3573 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3574 + BP_NOT_DEFINED}, /* usReverseMii */
3575 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3576 + 0x00, /* ucPhyAddress */
3577 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3578 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3579 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3580 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3581 + BP_NOT_DEFINED, /* usGpioPhyReset */
3582 + 0x03, /* numSwitchPorts */
3583 + BP_ENET_CONFIG_SPI_SSB_0, /* usConfigType */
3584 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3585 + {{BP_VOIP_DSP, /* ucDspType */
3586 + 0x00, /* ucDspAddress */
3587 + BP_EXT_INTR_2, /* usExtIntrVoip */
3588 + BP_GPIO_6_AH, /* usGpioVoipReset */
3589 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3590 + BP_NOT_DEFINED, /* usGpioLedVoip */
3591 + BP_CS_2}, /* usCsVoip */
3592 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3593 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3594 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3595 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3596 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3597 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3598 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3599 + BP_NOT_DEFINED, /* usGpioUartRts */
3600 + BP_NOT_DEFINED, /* usGpioUartCts */
3601 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3602 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3603 + BP_NOT_DEFINED, /* usGpioLedWireless */
3604 + BP_NOT_DEFINED, /* usGpioLedUsb */
3605 + BP_NOT_DEFINED, /* usGpioLedHpna */
3606 + BP_GPIO_3_AL, /* usGpioLedWanData */
3607 + BP_GPIO_3_AL, /* usGpioLedPpp */
3608 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3609 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3610 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3611 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3612 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3613 + BP_NOT_DEFINED, /* usExtIntrWireless */
3614 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3615 + BP_NOT_DEFINED, /* usExtIntrHpna */
3616 + BP_NOT_DEFINED, /* usCsHpna */
3617 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3618 + BP_NOT_DEFINED, /* BP_GPIO_35_AH, */ /* usGpioSesBtnWireless */
3619 + BP_NOT_DEFINED, /* BP_EXT_INTR_3, */ /* usExtIntrSesBtnWireless */
3620 + BP_NOT_DEFINED /* BP_GPIO_0_AL */ /* usGpioLedSesWireless */
3624 +static BOARD_PARAMETERS g_bcm96348gw_10 =
3626 + "96348GW-10", /* szBoardId */
3627 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3628 + 0x01, /* ucPhyAddress */
3629 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3630 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3631 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3632 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3633 + BP_NOT_DEFINED, /* usGpioPhyReset */
3634 + 0x01, /* numSwitchPorts */
3635 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3636 + BP_NOT_DEFINED}, /* usReverseMii */
3637 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3638 + 0x00, /* ucPhyAddress */
3639 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3640 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3641 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3642 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3643 + BP_NOT_DEFINED, /* usGpioPhyReset */
3644 + 0x03, /* numSwitchPorts */
3645 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3646 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3647 + {{BP_VOIP_DSP, /* ucDspType */
3648 + 0x00, /* ucDspAddress */
3649 + BP_EXT_INTR_2, /* usExtIntrVoip */
3650 + BP_GPIO_6_AH, /* usGpioVoipReset */
3651 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3652 + BP_NOT_DEFINED, /* usGpioLedVoip */
3653 + BP_CS_2}, /* usCsVoip */
3654 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3655 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3656 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3657 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3658 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3659 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3660 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3661 + BP_NOT_DEFINED, /* usGpioUartRts */
3662 + BP_NOT_DEFINED, /* usGpioUartCts */
3663 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3664 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3665 + BP_NOT_DEFINED, /* usGpioLedWireless */
3666 + BP_NOT_DEFINED, /* usGpioLedUsb */
3667 + BP_NOT_DEFINED, /* usGpioLedHpna */
3668 + BP_GPIO_3_AL, /* usGpioLedWanData */
3669 + BP_GPIO_3_AL, /* usGpioLedPpp */
3670 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3671 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3672 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3673 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3674 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3675 + BP_NOT_DEFINED, /* usExtIntrWireless */
3676 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3677 + BP_NOT_DEFINED, /* usExtIntrHpna */
3678 + BP_NOT_DEFINED, /* usCsHpna */
3679 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3680 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3681 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3682 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3685 +static BOARD_PARAMETERS g_bcm96348gw_11 =
3687 + "96348GW-11", /* szBoardId */
3688 + {{BP_ENET_NO_PHY}, /* ucPhyType */
3689 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3690 + 0x00, /* ucPhyAddress */
3691 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3692 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3693 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3694 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3695 + BP_NOT_DEFINED, /* usGpioPhyReset */
3696 + 0x04, /* numSwitchPorts */
3697 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3698 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3699 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3700 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3701 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3702 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3703 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3704 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3705 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3706 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3707 + BP_NOT_DEFINED, /* usGpioUartRts */
3708 + BP_NOT_DEFINED, /* usGpioUartCts */
3709 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3710 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3711 + BP_NOT_DEFINED, /* usGpioLedWireless */
3712 + BP_NOT_DEFINED, /* usGpioLedUsb */
3713 + BP_NOT_DEFINED, /* usGpioLedHpna */
3714 + BP_GPIO_3_AL, /* usGpioLedWanData */
3715 + BP_GPIO_3_AL, /* usGpioLedPpp */
3716 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3717 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3718 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3719 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3720 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3721 + BP_NOT_DEFINED, /* usExtIntrWireless */
3722 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3723 + BP_NOT_DEFINED, /* usExtIntrHpna */
3724 + BP_NOT_DEFINED, /* usCsHpna */
3725 + BP_NOT_DEFINED, /* usAntInUseWireless */
3726 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3727 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3728 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3731 +static BOARD_PARAMETERS g_bcm96348sv =
3733 + "96348SV", /* szBoardId */
3734 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3735 + 0x01, /* ucPhyAddress */
3736 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3737 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3738 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3739 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3740 + BP_NOT_DEFINED, /* usGpioPhyReset */
3741 + 0x01, /* numSwitchPorts */
3742 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3743 + BP_NOT_DEFINED}, /* usReverseMii */
3744 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3745 + 0x1f, /* ucPhyAddress */
3746 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3747 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3748 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3749 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3750 + BP_NOT_DEFINED, /* usGpioPhyReset */
3751 + 0x01, /* numSwitchPorts */
3752 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3753 + BP_NOT_DEFINED}}, /* usReverseMii */
3754 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3755 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3756 + BP_MEMORY_32MB_2_CHIP, /* usSdramSize */
3757 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3758 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3759 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3760 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3761 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3762 + BP_NOT_DEFINED, /* usGpioUartRts */
3763 + BP_NOT_DEFINED, /* usGpioUartCts */
3764 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3765 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3766 + BP_NOT_DEFINED, /* usGpioLedWireless */
3767 + BP_NOT_DEFINED, /* usGpioLedUsb */
3768 + BP_NOT_DEFINED, /* usGpioLedHpna */
3769 + BP_NOT_DEFINED, /* usGpioLedWanData */
3770 + BP_NOT_DEFINED, /* usGpioLedPpp */
3771 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3772 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3773 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3774 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3775 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3776 + BP_NOT_DEFINED, /* usExtIntrWireless */
3777 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3778 + BP_NOT_DEFINED, /* usExtIntrHpna */
3779 + BP_NOT_DEFINED, /* usCsHpna */
3780 + BP_NOT_DEFINED, /* usAntInUseWireless */
3781 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3782 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3783 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3787 +static BOARD_PARAMETERS g_bcm96348gw_dualDsp =
3789 + "96348GW-DualDSP", /* szBoardId */
3790 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3791 + 0x01, /* ucPhyAddress */
3792 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3793 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3794 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3795 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3796 + BP_NOT_DEFINED, /* usGpioPhyReset */
3797 + 0x01, /* numSwitchPorts */
3798 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3799 + BP_NOT_DEFINED}, /* usReverseMii */
3800 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3801 + 0x00, /* ucPhyAddress */
3802 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3803 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3804 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3805 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3806 + BP_NOT_DEFINED, /* usGpioPhyReset */
3807 + 0x03, /* numSwitchPorts */
3808 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3809 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3810 + {{BP_VOIP_DSP, /* ucDspType */
3811 + 0x00, /* ucDspAddress */
3812 + BP_EXT_INTR_2, /* usExtIntrVoip */
3813 + BP_UNEQUIPPED, /* usGpioVoipReset */
3814 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3815 + BP_NOT_DEFINED, /* usGpioLedVoip */
3816 + BP_CS_2}, /* usCsVoip */
3817 + {BP_VOIP_DSP, /* ucDspType */
3818 + 0x01, /* ucDspAddress */
3819 + BP_EXT_INTR_3, /* usExtIntrVoip */
3820 + BP_UNEQUIPPED , /* usGpioVoipReset */
3821 + BP_GPIO_35_AH, /* usGpioVoipIntr */
3822 + BP_NOT_DEFINED, /* usGpioLedVoip */
3823 + BP_CS_3}}, /* usCsVoip */
3824 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3825 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3826 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3827 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3828 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3829 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3830 + BP_NOT_DEFINED, /* usGpioUartRts */
3831 + BP_NOT_DEFINED, /* usGpioUartCts */
3832 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3833 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3834 + BP_NOT_DEFINED, /* usGpioLedWireless */
3835 + BP_NOT_DEFINED, /* usGpioLedUsb */
3836 + BP_NOT_DEFINED, /* usGpioLedHpna */
3837 + BP_GPIO_3_AL, /* usGpioLedWanData */
3838 + BP_GPIO_3_AL, /* usGpioLedPpp */
3839 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3840 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3841 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3842 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3843 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3844 + BP_NOT_DEFINED, /* usExtIntrWireless */
3845 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3846 + BP_NOT_DEFINED, /* usExtIntrHpna */
3847 + BP_NOT_DEFINED, /* usCsHpna */
3848 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3849 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3850 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3851 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3855 +static BOARD_PARAMETERS g_bcmCustom_01 =
3857 + "BCMCUST_01", /* szBoardId */
3858 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3859 + 0x01, /* ucPhyAddress */
3860 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3861 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3862 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3863 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3864 + BP_NOT_DEFINED, /* usGpioPhyReset */
3865 + 0x01, /* numSwitchPorts */
3866 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3867 + BP_NOT_DEFINED}, /* usReverseMii */
3868 + {BP_ENET_NO_PHY, /* ucPhyType */
3869 + 0x00, /* ucPhyAddress */
3870 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3871 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3872 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3873 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3874 + BP_NOT_DEFINED, /* usGpioPhyReset */
3875 + 0x01, /* numSwitchPorts */
3876 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3877 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3878 + {{BP_VOIP_DSP, /* ucDspType */
3879 + 0x00, /* ucDspAddress */
3880 + BP_EXT_INTR_2, /* usExtIntrVoip */
3881 + BP_GPIO_36_AH, /* usGpioVoipReset */
3882 + BP_GPIO_34_AL, /* usGpioVoipIntr */
3883 + BP_NOT_DEFINED, /* usGpioLedVoip */
3884 + BP_CS_2}, /* usCsVoip */
3885 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3886 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3887 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3888 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3889 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3890 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3891 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3892 + BP_NOT_DEFINED, /* usGpioUartRts */
3893 + BP_NOT_DEFINED, /* usGpioUartCts */
3894 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3895 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3896 + BP_NOT_DEFINED, /* usGpioLedWireless */
3897 + BP_NOT_DEFINED, /* usGpioLedUsb */
3898 + BP_NOT_DEFINED, /* usGpioLedHpna */
3899 + BP_GPIO_3_AL, /* usGpioLedWanData */
3900 + BP_GPIO_3_AL, /* usGpioLedPpp */
3901 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3902 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3903 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3904 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3905 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3906 + BP_NOT_DEFINED, /* usExtIntrWireless */
3907 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3908 + BP_NOT_DEFINED, /* usExtIntrHpna */
3909 + BP_NOT_DEFINED, /* usCsHpna */
3910 + BP_NOT_DEFINED, /* usAntInUseWireless */
3911 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3912 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3913 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3916 +static PBOARD_PARAMETERS g_BoardParms[] =
3917 + {&g_bcm96348r, &g_bcm96348lv, &g_bcm96348gw, &g_bcm96348gw_10,
3918 + &g_bcm96348gw_11, &g_bcm96348sv, &g_bcm96348gw_dualDsp,
3919 + &g_bcmCustom_01, 0};
3922 +static PBOARD_PARAMETERS g_pCurrentBp = 0;
3924 +/**************************************************************************
3927 + * Description: String compare for this file so it does not depend on an OS.
3928 + * (Linux kernel and CFE share this source file.)
3930 + * Parameters : [IN] dest - destination string
3931 + * [IN] src - source string
3933 + * Returns : -1 - dest < src, 1 - dest > src, 0 dest == src
3934 + ***************************************************************************/
3935 +static int bpstrcmp(const char *dest,const char *src);
3936 +static int bpstrcmp(const char *dest,const char *src)
3938 + while (*src && *dest)
3940 + if (*dest < *src) return -1;
3941 + if (*dest > *src) return 1;
3946 + if (*dest && !*src) return 1;
3947 + if (!*dest && *src) return -1;
3951 +/**************************************************************************
3952 + * Name : BpGetVoipDspConfig
3954 + * Description: Gets the DSP configuration from the board parameter
3955 + * structure for a given DSP index.
3957 + * Parameters : [IN] dspNum - DSP index (number)
3959 + * Returns : Pointer to DSP configuration block if found/valid, NULL
3961 + ***************************************************************************/
3962 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum );
3963 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum )
3965 + VOIP_DSP_INFO *pDspConfig = 0;
3968 + if( g_pCurrentBp )
3970 + for( i = 0 ; i < BP_MAX_VOIP_DSP ; i++ )
3972 + if( g_pCurrentBp->VoIPDspInfo[i].ucDspType != BP_VOIP_NO_DSP &&
3973 + g_pCurrentBp->VoIPDspInfo[i].ucDspAddress == dspNum )
3975 + pDspConfig = &g_pCurrentBp->VoIPDspInfo[i];
3981 + return pDspConfig;
3985 +/**************************************************************************
3986 + * Name : BpSetBoardId
3988 + * Description: This function find the BOARD_PARAMETERS structure for the
3989 + * specified board id string and assigns it to a global, static
3992 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
3994 + * Returns : BP_SUCCESS - Success, value is returned.
3995 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
3996 + * have a board parameters configuration record.
3997 + ***************************************************************************/
3998 +int BpSetBoardId( char *pszBoardId )
4000 + int nRet = BP_BOARD_ID_NOT_FOUND;
4001 + PBOARD_PARAMETERS *ppBp;
4003 + for( ppBp = g_BoardParms; *ppBp; ppBp++ )
4005 + if( !bpstrcmp((*ppBp)->szBoardId, pszBoardId) )
4007 + g_pCurrentBp = *ppBp;
4008 + nRet = BP_SUCCESS;
4014 +} /* BpSetBoardId */
4016 +/**************************************************************************
4017 + * Name : BpGetBoardIds
4019 + * Description: This function returns all of the supported board id strings.
4021 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
4022 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
4024 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
4025 + * were allocated in pszBoardIds.
4027 + * Returns : Number of board id strings returned.
4028 + ***************************************************************************/
4029 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize )
4031 + PBOARD_PARAMETERS *ppBp;
4036 + for( i = 0, ppBp = g_BoardParms; *ppBp && nBoardIdsSize;
4037 + i++, ppBp++, nBoardIdsSize--, pszBoardIds += BP_BOARD_ID_LEN )
4039 + dest = pszBoardIds;
4040 + src = (*ppBp)->szBoardId;
4047 +} /* BpGetBoardIds */
4049 +/**************************************************************************
4050 + * Name : BpGetEthernetMacInfo
4052 + * Description: This function returns all of the supported board id strings.
4054 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
4056 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
4057 + * are pointed to by pEnetInfos.
4059 + * Returns : BP_SUCCESS - Success, value is returned.
4060 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4061 + ***************************************************************************/
4062 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos )
4066 + if( g_pCurrentBp )
4068 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4070 + if( i < BP_MAX_ENET_MACS )
4072 + unsigned char *src = (unsigned char *)
4073 + &g_pCurrentBp->EnetMacInfos[i];
4074 + unsigned char *dest = (unsigned char *) pEnetInfos;
4075 + int len = sizeof(ETHERNET_MAC_INFO);
4080 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4083 + nRet = BP_SUCCESS;
4087 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4088 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4090 + nRet = BP_BOARD_ID_NOT_SET;
4094 +} /* BpGetEthernetMacInfo */
4096 +/**************************************************************************
4097 + * Name : BpGetSdramSize
4099 + * Description: This function returns a constant that describees the board's
4100 + * SDRAM type and size.
4102 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
4105 + * Returns : BP_SUCCESS - Success, value is returned.
4106 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4107 + ***************************************************************************/
4108 +int BpGetSdramSize( unsigned long *pulSdramSize )
4112 + if( g_pCurrentBp )
4114 + *pulSdramSize = g_pCurrentBp->usSdramSize;
4115 + nRet = BP_SUCCESS;
4119 + *pulSdramSize = BP_NOT_DEFINED;
4120 + nRet = BP_BOARD_ID_NOT_SET;
4124 +} /* BpGetSdramSize */
4126 +/**************************************************************************
4127 + * Name : BpGetPsiSize
4129 + * Description: This function returns the persistent storage size in K bytes.
4131 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
4132 + * storage size is returned in.
4134 + * Returns : BP_SUCCESS - Success, value is returned.
4135 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4136 + ***************************************************************************/
4137 +int BpGetPsiSize( unsigned long *pulPsiSize )
4141 + if( g_pCurrentBp )
4143 + *pulPsiSize = g_pCurrentBp->usPsiSize;
4144 + nRet = BP_SUCCESS;
4148 + *pulPsiSize = BP_NOT_DEFINED;
4149 + nRet = BP_BOARD_ID_NOT_SET;
4153 +} /* BpGetPsiSize */
4155 +/**************************************************************************
4156 + * Name : BpGetRj11InnerOuterPairGpios
4158 + * Description: This function returns the GPIO pin assignments for changing
4159 + * between the RJ11 inner pair and RJ11 outer pair.
4161 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
4162 + * GPIO pin is returned in.
4163 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
4164 + * GPIO pin is returned in.
4166 + * Returns : BP_SUCCESS - Success, values are returned.
4167 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4168 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4170 + ***************************************************************************/
4171 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
4172 + unsigned short *pusOuter )
4176 + if( g_pCurrentBp )
4178 + *pusInner = g_pCurrentBp->usGpioRj11InnerPair;
4179 + *pusOuter = g_pCurrentBp->usGpioRj11OuterPair;
4181 + if( g_pCurrentBp->usGpioRj11InnerPair != BP_NOT_DEFINED &&
4182 + g_pCurrentBp->usGpioRj11OuterPair != BP_NOT_DEFINED )
4184 + nRet = BP_SUCCESS;
4188 + nRet = BP_VALUE_NOT_DEFINED;
4193 + *pusInner = *pusOuter = BP_NOT_DEFINED;
4194 + nRet = BP_BOARD_ID_NOT_SET;
4198 +} /* BpGetRj11InnerOuterPairGpios */
4200 +/**************************************************************************
4201 + * Name : BpGetPressAndHoldResetGpio
4203 + * Description: This function returns the GPIO pin assignment for the press
4204 + * and hold reset button.
4206 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
4207 + * reset button GPIO pin is returned in.
4209 + * Returns : BP_SUCCESS - Success, value is returned.
4210 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4211 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4213 + ***************************************************************************/
4214 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue )
4218 + if( g_pCurrentBp )
4220 + *pusValue = g_pCurrentBp->usGpioPressAndHoldReset;
4222 + if( g_pCurrentBp->usGpioPressAndHoldReset != BP_NOT_DEFINED )
4224 + nRet = BP_SUCCESS;
4228 + nRet = BP_VALUE_NOT_DEFINED;
4233 + *pusValue = BP_NOT_DEFINED;
4234 + nRet = BP_BOARD_ID_NOT_SET;
4238 +} /* BpGetPressAndHoldResetGpio */
4240 +/**************************************************************************
4241 + * Name : BpGetVoipResetGpio
4243 + * Description: This function returns the GPIO pin assignment for the VOIP
4244 + * Reset operation.
4246 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
4247 + * GPIO pin is returned in.
4248 + * [IN] dspNum - Address of the DSP to query.
4250 + * Returns : BP_SUCCESS - Success, value is returned.
4251 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4252 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4254 + ***************************************************************************/
4255 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue )
4259 + if( g_pCurrentBp )
4261 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4265 + *pusValue = pDspInfo->usGpioVoipReset;
4267 + if( *pusValue != BP_NOT_DEFINED ||
4268 + *pusValue == BP_UNEQUIPPED )
4270 + nRet = BP_SUCCESS;
4274 + nRet = BP_VALUE_NOT_DEFINED;
4279 + *pusValue = BP_NOT_DEFINED;
4280 + nRet = BP_BOARD_ID_NOT_FOUND;
4285 + *pusValue = BP_NOT_DEFINED;
4286 + nRet = BP_BOARD_ID_NOT_SET;
4290 +} /* BpGetVoipResetGpio */
4292 +/**************************************************************************
4293 + * Name : BpGetVoipIntrGpio
4295 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
4297 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
4298 + * GPIO pin is returned in.
4299 + * [IN] dspNum - Address of the DSP to query.
4301 + * Returns : BP_SUCCESS - Success, value is returned.
4302 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4303 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4305 + ***************************************************************************/
4306 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue )
4310 + if( g_pCurrentBp )
4312 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4316 + *pusValue = pDspInfo->usGpioVoipIntr;
4318 + if( *pusValue != BP_NOT_DEFINED )
4320 + nRet = BP_SUCCESS;
4324 + nRet = BP_VALUE_NOT_DEFINED;
4329 + *pusValue = BP_NOT_DEFINED;
4330 + nRet = BP_BOARD_ID_NOT_FOUND;
4335 + *pusValue = BP_NOT_DEFINED;
4336 + nRet = BP_BOARD_ID_NOT_SET;
4340 +} /* BpGetVoipIntrGpio */
4342 +/**************************************************************************
4343 + * Name : BpGetPcmciaResetGpio
4345 + * Description: This function returns the GPIO pin assignment for the PCMCIA
4346 + * Reset operation.
4348 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
4349 + * GPIO pin is returned in.
4351 + * Returns : BP_SUCCESS - Success, value is returned.
4352 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4353 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4355 + ***************************************************************************/
4356 +int BpGetPcmciaResetGpio( unsigned short *pusValue )
4360 + if( g_pCurrentBp )
4362 + *pusValue = g_pCurrentBp->usGpioPcmciaReset;
4364 + if( g_pCurrentBp->usGpioPcmciaReset != BP_NOT_DEFINED )
4366 + nRet = BP_SUCCESS;
4370 + nRet = BP_VALUE_NOT_DEFINED;
4375 + *pusValue = BP_NOT_DEFINED;
4376 + nRet = BP_BOARD_ID_NOT_SET;
4380 +} /* BpGetPcmciaResetGpio */
4382 +/**************************************************************************
4383 + * Name : BpGetUartRtsCtsGpios
4385 + * Description: This function returns the GPIO pin assignments for RTS and CTS
4388 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
4389 + * pin is returned in.
4390 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
4391 + * pin is returned in.
4393 + * Returns : BP_SUCCESS - Success, values are returned.
4394 + * BP_BOARD_ID_NOT_SET - Error, board id input string does not
4395 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4397 + ***************************************************************************/
4398 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts )
4402 + if( g_pCurrentBp )
4404 + *pusRts = g_pCurrentBp->usGpioUartRts;
4405 + *pusCts = g_pCurrentBp->usGpioUartCts;
4407 + if( g_pCurrentBp->usGpioUartRts != BP_NOT_DEFINED &&
4408 + g_pCurrentBp->usGpioUartCts != BP_NOT_DEFINED )
4410 + nRet = BP_SUCCESS;
4414 + nRet = BP_VALUE_NOT_DEFINED;
4419 + *pusRts = *pusCts = BP_NOT_DEFINED;
4420 + nRet = BP_BOARD_ID_NOT_SET;
4424 +} /* BpGetUartRtsCtsGpios */
4426 +/**************************************************************************
4427 + * Name : BpGetAdslLedGpio
4429 + * Description: This function returns the GPIO pin assignment for the ADSL
4432 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4433 + * GPIO pin is returned in.
4435 + * Returns : BP_SUCCESS - Success, value is returned.
4436 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4437 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4439 + ***************************************************************************/
4440 +int BpGetAdslLedGpio( unsigned short *pusValue )
4444 + if( g_pCurrentBp )
4446 + *pusValue = g_pCurrentBp->usGpioLedAdsl;
4448 + if( g_pCurrentBp->usGpioLedAdsl != BP_NOT_DEFINED )
4450 + nRet = BP_SUCCESS;
4454 + nRet = BP_VALUE_NOT_DEFINED;
4459 + *pusValue = BP_NOT_DEFINED;
4460 + nRet = BP_BOARD_ID_NOT_SET;
4464 +} /* BpGetAdslLedGpio */
4466 +/**************************************************************************
4467 + * Name : BpGetAdslFailLedGpio
4469 + * Description: This function returns the GPIO pin assignment for the ADSL
4470 + * LED that is used when there is a DSL connection failure.
4472 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4473 + * GPIO pin is returned in.
4475 + * Returns : BP_SUCCESS - Success, value is returned.
4476 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4477 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4479 + ***************************************************************************/
4480 +int BpGetAdslFailLedGpio( unsigned short *pusValue )
4484 + if( g_pCurrentBp )
4486 + *pusValue = g_pCurrentBp->usGpioLedAdslFail;
4488 + if( g_pCurrentBp->usGpioLedAdslFail != BP_NOT_DEFINED )
4490 + nRet = BP_SUCCESS;
4494 + nRet = BP_VALUE_NOT_DEFINED;
4499 + *pusValue = BP_NOT_DEFINED;
4500 + nRet = BP_BOARD_ID_NOT_SET;
4504 +} /* BpGetAdslFailLedGpio */
4506 +/**************************************************************************
4507 + * Name : BpGetWirelessLedGpio
4509 + * Description: This function returns the GPIO pin assignment for the Wireless
4512 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4513 + * GPIO pin is returned in.
4515 + * Returns : BP_SUCCESS - Success, value is returned.
4516 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4517 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4519 + ***************************************************************************/
4520 +int BpGetWirelessLedGpio( unsigned short *pusValue )
4524 + if( g_pCurrentBp )
4526 + *pusValue = g_pCurrentBp->usGpioLedWireless;
4528 + if( g_pCurrentBp->usGpioLedWireless != BP_NOT_DEFINED )
4530 + nRet = BP_SUCCESS;
4534 + nRet = BP_VALUE_NOT_DEFINED;
4539 + *pusValue = BP_NOT_DEFINED;
4540 + nRet = BP_BOARD_ID_NOT_SET;
4544 +} /* BpGetWirelessLedGpio */
4546 +/**************************************************************************
4547 + * Name : BpGetWirelessAntInUse
4549 + * Description: This function returns the antennas in use for wireless
4551 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
4554 + * Returns : BP_SUCCESS - Success, value is returned.
4555 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4556 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4558 + ***************************************************************************/
4559 +int BpGetWirelessAntInUse( unsigned short *pusValue )
4563 + if( g_pCurrentBp )
4565 + *pusValue = g_pCurrentBp->usAntInUseWireless;
4567 + if( g_pCurrentBp->usAntInUseWireless != BP_NOT_DEFINED )
4569 + nRet = BP_SUCCESS;
4573 + nRet = BP_VALUE_NOT_DEFINED;
4578 + *pusValue = BP_NOT_DEFINED;
4579 + nRet = BP_BOARD_ID_NOT_SET;
4583 +} /* BpGetWirelessAntInUse */
4585 +/**************************************************************************
4586 + * Name : BpGetWirelessSesBtnGpio
4588 + * Description: This function returns the GPIO pin assignment for the Wireless
4591 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4592 + * GPIO pin is returned in.
4594 + * Returns : BP_SUCCESS - Success, value is returned.
4595 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4596 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4598 + ***************************************************************************/
4599 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue )
4603 + if( g_pCurrentBp )
4605 + *pusValue = g_pCurrentBp->usGpioSesBtnWireless;
4607 + if( g_pCurrentBp->usGpioSesBtnWireless != BP_NOT_DEFINED )
4609 + nRet = BP_SUCCESS;
4613 + nRet = BP_VALUE_NOT_DEFINED;
4618 + *pusValue = BP_NOT_DEFINED;
4619 + nRet = BP_BOARD_ID_NOT_SET;
4623 +} /* BpGetWirelessSesBtnGpio */
4625 +/**************************************************************************
4626 + * Name : BpGetWirelessSesExtIntr
4628 + * Description: This function returns the external interrupt number for the
4629 + * Wireless Ses Button.
4631 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4632 + * external interrup is returned in.
4634 + * Returns : BP_SUCCESS - Success, value is returned.
4635 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4636 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4638 + ***************************************************************************/
4639 +int BpGetWirelessSesExtIntr( unsigned short *pusValue )
4643 + if( g_pCurrentBp )
4645 + *pusValue = g_pCurrentBp->usExtIntrSesBtnWireless;
4647 + if( g_pCurrentBp->usExtIntrSesBtnWireless != BP_NOT_DEFINED )
4649 + nRet = BP_SUCCESS;
4653 + nRet = BP_VALUE_NOT_DEFINED;
4658 + *pusValue = BP_NOT_DEFINED;
4659 + nRet = BP_BOARD_ID_NOT_SET;
4664 +} /* BpGetWirelessSesExtIntr */
4666 +/**************************************************************************
4667 + * Name : BpGetWirelessSesLedGpio
4669 + * Description: This function returns the GPIO pin assignment for the Wireless
4672 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4673 + * Led GPIO pin is returned in.
4675 + * Returns : BP_SUCCESS - Success, value is returned.
4676 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4677 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4679 + ***************************************************************************/
4680 +int BpGetWirelessSesLedGpio( unsigned short *pusValue )
4684 + if( g_pCurrentBp )
4686 + *pusValue = g_pCurrentBp->usGpioLedSesWireless;
4688 + if( g_pCurrentBp->usGpioLedSesWireless != BP_NOT_DEFINED )
4690 + nRet = BP_SUCCESS;
4694 + nRet = BP_VALUE_NOT_DEFINED;
4699 + *pusValue = BP_NOT_DEFINED;
4700 + nRet = BP_BOARD_ID_NOT_SET;
4705 +} /* BpGetWirelessSesLedGpio */
4707 +/**************************************************************************
4708 + * Name : BpGetUsbLedGpio
4710 + * Description: This function returns the GPIO pin assignment for the USB
4713 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
4714 + * GPIO pin is returned in.
4716 + * Returns : BP_SUCCESS - Success, value is returned.
4717 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4718 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4720 + ***************************************************************************/
4721 +int BpGetUsbLedGpio( unsigned short *pusValue )
4725 + if( g_pCurrentBp )
4727 + *pusValue = g_pCurrentBp->usGpioLedUsb;
4729 + if( g_pCurrentBp->usGpioLedUsb != BP_NOT_DEFINED )
4731 + nRet = BP_SUCCESS;
4735 + nRet = BP_VALUE_NOT_DEFINED;
4740 + *pusValue = BP_NOT_DEFINED;
4741 + nRet = BP_BOARD_ID_NOT_SET;
4745 +} /* BpGetUsbLedGpio */
4747 +/**************************************************************************
4748 + * Name : BpGetHpnaLedGpio
4750 + * Description: This function returns the GPIO pin assignment for the HPNA
4753 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
4754 + * GPIO pin is returned in.
4756 + * Returns : BP_SUCCESS - Success, value is returned.
4757 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4758 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4760 + ***************************************************************************/
4761 +int BpGetHpnaLedGpio( unsigned short *pusValue )
4765 + if( g_pCurrentBp )
4767 + *pusValue = g_pCurrentBp->usGpioLedHpna;
4769 + if( g_pCurrentBp->usGpioLedHpna != BP_NOT_DEFINED )
4771 + nRet = BP_SUCCESS;
4775 + nRet = BP_VALUE_NOT_DEFINED;
4780 + *pusValue = BP_NOT_DEFINED;
4781 + nRet = BP_BOARD_ID_NOT_SET;
4785 +} /* BpGetHpnaLedGpio */
4787 +/**************************************************************************
4788 + * Name : BpGetWanDataLedGpio
4790 + * Description: This function returns the GPIO pin assignment for the WAN Data
4793 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
4794 + * GPIO pin is returned in.
4796 + * Returns : BP_SUCCESS - Success, value is returned.
4797 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4798 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4800 + ***************************************************************************/
4801 +int BpGetWanDataLedGpio( unsigned short *pusValue )
4805 + if( g_pCurrentBp )
4807 + *pusValue = g_pCurrentBp->usGpioLedWanData;
4809 + if( g_pCurrentBp->usGpioLedWanData != BP_NOT_DEFINED )
4811 + nRet = BP_SUCCESS;
4815 + nRet = BP_VALUE_NOT_DEFINED;
4820 + *pusValue = BP_NOT_DEFINED;
4821 + nRet = BP_BOARD_ID_NOT_SET;
4825 +} /* BpGetWanDataLedGpio */
4827 +/**************************************************************************
4828 + * Name : BpGetPppLedGpio
4830 + * Description: This function returns the GPIO pin assignment for the PPP
4833 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4834 + * GPIO pin is returned in.
4836 + * Returns : BP_SUCCESS - Success, value is returned.
4837 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4838 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4840 + ***************************************************************************/
4841 +int BpGetPppLedGpio( unsigned short *pusValue )
4845 + if( g_pCurrentBp )
4847 + *pusValue = g_pCurrentBp->usGpioLedPpp;
4849 + if( g_pCurrentBp->usGpioLedPpp != BP_NOT_DEFINED )
4851 + nRet = BP_SUCCESS;
4855 + nRet = BP_VALUE_NOT_DEFINED;
4860 + *pusValue = BP_NOT_DEFINED;
4861 + nRet = BP_BOARD_ID_NOT_SET;
4865 +} /* BpGetPppLedGpio */
4867 +/**************************************************************************
4868 + * Name : BpGetPppFailLedGpio
4870 + * Description: This function returns the GPIO pin assignment for the PPP
4871 + * LED that is used when there is a PPP connection failure.
4873 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4874 + * GPIO pin is returned in.
4876 + * Returns : BP_SUCCESS - Success, value is returned.
4877 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4878 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4880 + ***************************************************************************/
4881 +int BpGetPppFailLedGpio( unsigned short *pusValue )
4885 + if( g_pCurrentBp )
4887 + *pusValue = g_pCurrentBp->usGpioLedPppFail;
4889 + if( g_pCurrentBp->usGpioLedPppFail != BP_NOT_DEFINED )
4891 + nRet = BP_SUCCESS;
4895 + nRet = BP_VALUE_NOT_DEFINED;
4900 + *pusValue = BP_NOT_DEFINED;
4901 + nRet = BP_BOARD_ID_NOT_SET;
4905 +} /* BpGetPppFailLedGpio */
4907 +/**************************************************************************
4908 + * Name : BpGetBootloaderPowerOnLedGpio
4910 + * Description: This function returns the GPIO pin assignment for the power
4911 + * on LED that is set by the bootloader.
4913 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
4914 + * GPIO pin is returned in.
4916 + * Returns : BP_SUCCESS - Success, value is returned.
4917 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4918 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4920 + ***************************************************************************/
4921 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue )
4925 + if( g_pCurrentBp )
4927 + *pusValue = g_pCurrentBp->usGpioLedBlPowerOn;
4929 + if( g_pCurrentBp->usGpioLedBlPowerOn != BP_NOT_DEFINED )
4931 + nRet = BP_SUCCESS;
4935 + nRet = BP_VALUE_NOT_DEFINED;
4940 + *pusValue = BP_NOT_DEFINED;
4941 + nRet = BP_BOARD_ID_NOT_SET;
4945 +} /* BpGetBootloaderPowerOn */
4947 +/**************************************************************************
4948 + * Name : BpGetBootloaderAlarmLedGpio
4950 + * Description: This function returns the GPIO pin assignment for the alarm
4951 + * LED that is set by the bootloader.
4953 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
4954 + * GPIO pin is returned in.
4956 + * Returns : BP_SUCCESS - Success, value is returned.
4957 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4958 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4960 + ***************************************************************************/
4961 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue )
4965 + if( g_pCurrentBp )
4967 + *pusValue = g_pCurrentBp->usGpioLedBlAlarm;
4969 + if( g_pCurrentBp->usGpioLedBlAlarm != BP_NOT_DEFINED )
4971 + nRet = BP_SUCCESS;
4975 + nRet = BP_VALUE_NOT_DEFINED;
4980 + *pusValue = BP_NOT_DEFINED;
4981 + nRet = BP_BOARD_ID_NOT_SET;
4985 +} /* BpGetBootloaderAlarmLedGpio */
4987 +/**************************************************************************
4988 + * Name : BpGetBootloaderResetCfgLedGpio
4990 + * Description: This function returns the GPIO pin assignment for the reset
4991 + * configuration LED that is set by the bootloader.
4993 + * Parameters : [OUT] pusValue - Address of short word that the reset
4994 + * configuration LED GPIO pin is returned in.
4996 + * Returns : BP_SUCCESS - Success, value is returned.
4997 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4998 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5000 + ***************************************************************************/
5001 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue )
5005 + if( g_pCurrentBp )
5007 + *pusValue = g_pCurrentBp->usGpioLedBlResetCfg;
5009 + if( g_pCurrentBp->usGpioLedBlResetCfg != BP_NOT_DEFINED )
5011 + nRet = BP_SUCCESS;
5015 + nRet = BP_VALUE_NOT_DEFINED;
5020 + *pusValue = BP_NOT_DEFINED;
5021 + nRet = BP_BOARD_ID_NOT_SET;
5025 +} /* BpGetBootloaderResetCfgLedGpio */
5027 +/**************************************************************************
5028 + * Name : BpGetBootloaderStopLedGpio
5030 + * Description: This function returns the GPIO pin assignment for the break
5031 + * into bootloader LED that is set by the bootloader.
5033 + * Parameters : [OUT] pusValue - Address of short word that the break into
5034 + * bootloader LED GPIO pin is returned in.
5036 + * Returns : BP_SUCCESS - Success, value is returned.
5037 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5038 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5040 + ***************************************************************************/
5041 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue )
5045 + if( g_pCurrentBp )
5047 + *pusValue = g_pCurrentBp->usGpioLedBlStop;
5049 + if( g_pCurrentBp->usGpioLedBlStop != BP_NOT_DEFINED )
5051 + nRet = BP_SUCCESS;
5055 + nRet = BP_VALUE_NOT_DEFINED;
5060 + *pusValue = BP_NOT_DEFINED;
5061 + nRet = BP_BOARD_ID_NOT_SET;
5065 +} /* BpGetBootloaderStopLedGpio */
5067 +/**************************************************************************
5068 + * Name : BpGetVoipLedGpio
5070 + * Description: This function returns the GPIO pin assignment for the VOIP
5073 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5074 + * GPIO pin is returned in.
5076 + * Returns : BP_SUCCESS - Success, value is returned.
5077 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5078 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5081 + * Note : The VoIP structure would allow for having one LED per DSP
5082 + * however, the board initialization function assumes only one
5083 + * LED per functionality (ie one LED for VoIP). Therefore in
5084 + * order to keep this tidy and simple we do not make usage of the
5085 + * one-LED-per-DSP function. Instead, we assume that the LED for
5086 + * VoIP is unique and associated with DSP 0 (always present on
5087 + * any VoIP platform). If changing this to a LED-per-DSP function
5088 + * then one need to update the board initialization driver in
5089 + * bcmdrivers\opensource\char\board\bcm963xx\impl1
5090 + ***************************************************************************/
5091 +int BpGetVoipLedGpio( unsigned short *pusValue )
5095 + if( g_pCurrentBp )
5097 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( 0 );
5101 + *pusValue = pDspInfo->usGpioLedVoip;
5103 + if( *pusValue != BP_NOT_DEFINED )
5105 + nRet = BP_SUCCESS;
5109 + nRet = BP_VALUE_NOT_DEFINED;
5114 + *pusValue = BP_NOT_DEFINED;
5115 + nRet = BP_BOARD_ID_NOT_FOUND;
5120 + *pusValue = BP_NOT_DEFINED;
5121 + nRet = BP_BOARD_ID_NOT_SET;
5125 +} /* BpGetVoipLedGpio */
5127 +/**************************************************************************
5128 + * Name : BpGetWirelessExtIntr
5130 + * Description: This function returns the Wireless external interrupt number.
5132 + * Parameters : [OUT] pulValue - Address of short word that the wireless
5133 + * external interrupt number is returned in.
5135 + * Returns : BP_SUCCESS - Success, value is returned.
5136 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5137 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5139 + ***************************************************************************/
5140 +int BpGetWirelessExtIntr( unsigned long *pulValue )
5144 + if( g_pCurrentBp )
5146 + *pulValue = g_pCurrentBp->usExtIntrWireless;
5148 + if( g_pCurrentBp->usExtIntrWireless != BP_NOT_DEFINED )
5150 + nRet = BP_SUCCESS;
5154 + nRet = BP_VALUE_NOT_DEFINED;
5159 + *pulValue = BP_NOT_DEFINED;
5160 + nRet = BP_BOARD_ID_NOT_SET;
5164 +} /* BpGetWirelessExtIntr */
5166 +/**************************************************************************
5167 + * Name : BpGetAdslDyingGaspExtIntr
5169 + * Description: This function returns the ADSL Dying Gasp external interrupt
5172 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
5173 + * external interrupt number is returned in.
5175 + * Returns : BP_SUCCESS - Success, value is returned.
5176 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5177 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5179 + ***************************************************************************/
5180 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue )
5184 + if( g_pCurrentBp )
5186 + *pulValue = g_pCurrentBp->usExtIntrAdslDyingGasp;
5188 + if( g_pCurrentBp->usExtIntrAdslDyingGasp != BP_NOT_DEFINED )
5190 + nRet = BP_SUCCESS;
5194 + nRet = BP_VALUE_NOT_DEFINED;
5199 + *pulValue = BP_NOT_DEFINED;
5200 + nRet = BP_BOARD_ID_NOT_SET;
5204 +} /* BpGetAdslDyingGaspExtIntr */
5206 +/**************************************************************************
5207 + * Name : BpGetVoipExtIntr
5209 + * Description: This function returns the VOIP external interrupt number.
5211 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5212 + * external interrupt number is returned in.
5213 + * [IN] dspNum - Address of the DSP to query.
5215 + * Returns : BP_SUCCESS - Success, value is returned.
5216 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5217 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5219 + ***************************************************************************/
5220 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue )
5224 + if( g_pCurrentBp )
5226 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5230 + *pulValue = pDspInfo->usExtIntrVoip;
5232 + if( *pulValue != BP_NOT_DEFINED )
5234 + nRet = BP_SUCCESS;
5238 + nRet = BP_VALUE_NOT_DEFINED;
5243 + *pulValue = BP_NOT_DEFINED;
5244 + nRet = BP_BOARD_ID_NOT_FOUND;
5249 + *pulValue = BP_NOT_DEFINED;
5250 + nRet = BP_BOARD_ID_NOT_SET;
5254 +} /* BpGetVoipExtIntr */
5256 +/**************************************************************************
5257 + * Name : BpGetHpnaExtIntr
5259 + * Description: This function returns the HPNA external interrupt number.
5261 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5262 + * external interrupt number is returned in.
5264 + * Returns : BP_SUCCESS - Success, value is returned.
5265 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5266 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5268 + ***************************************************************************/
5269 +int BpGetHpnaExtIntr( unsigned long *pulValue )
5273 + if( g_pCurrentBp )
5275 + *pulValue = g_pCurrentBp->usExtIntrHpna;
5277 + if( g_pCurrentBp->usExtIntrHpna != BP_NOT_DEFINED )
5279 + nRet = BP_SUCCESS;
5283 + nRet = BP_VALUE_NOT_DEFINED;
5288 + *pulValue = BP_NOT_DEFINED;
5289 + nRet = BP_BOARD_ID_NOT_SET;
5293 +} /* BpGetHpnaExtIntr */
5295 +/**************************************************************************
5296 + * Name : BpGetHpnaChipSelect
5298 + * Description: This function returns the HPNA chip select number.
5300 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5301 + * chip select number is returned in.
5303 + * Returns : BP_SUCCESS - Success, value is returned.
5304 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5305 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5307 + ***************************************************************************/
5308 +int BpGetHpnaChipSelect( unsigned long *pulValue )
5312 + if( g_pCurrentBp )
5314 + *pulValue = g_pCurrentBp->usCsHpna;
5316 + if( g_pCurrentBp->usCsHpna != BP_NOT_DEFINED )
5318 + nRet = BP_SUCCESS;
5322 + nRet = BP_VALUE_NOT_DEFINED;
5327 + *pulValue = BP_NOT_DEFINED;
5328 + nRet = BP_BOARD_ID_NOT_SET;
5332 +} /* BpGetHpnaChipSelect */
5334 +/**************************************************************************
5335 + * Name : BpGetVoipChipSelect
5337 + * Description: This function returns the VOIP chip select number.
5339 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5340 + * chip select number is returned in.
5341 + * [IN] dspNum - Address of the DSP to query.
5343 + * Returns : BP_SUCCESS - Success, value is returned.
5344 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5345 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5347 + ***************************************************************************/
5348 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue )
5352 + if( g_pCurrentBp )
5354 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5358 + *pulValue = pDspInfo->usCsVoip;
5360 + if( *pulValue != BP_NOT_DEFINED )
5362 + nRet = BP_SUCCESS;
5366 + nRet = BP_VALUE_NOT_DEFINED;
5371 + *pulValue = BP_NOT_DEFINED;
5372 + nRet = BP_BOARD_ID_NOT_FOUND;
5377 + *pulValue = BP_NOT_DEFINED;
5378 + nRet = BP_BOARD_ID_NOT_SET;
5382 +} /* BpGetVoipChipSelect */
5384 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h
5385 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h 1970-01-01 01:00:00.000000000 +0100
5386 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h 2006-07-25 10:18:49.000000000 +0200
5391 + Copyright 2003 Broadcom Corp. All Rights Reserved.
5393 + This program is free software; you can distribute it and/or modify it
5394 + under the terms of the GNU General Public License (Version 2) as
5395 + published by the Free Software Foundation.
5397 + This program is distributed in the hope it will be useful, but WITHOUT
5398 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5399 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5402 + You should have received a copy of the GNU General Public License along
5403 + with this program; if not, write to the Free Software Foundation, Inc.,
5404 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
5408 +/**************************************************************************
5409 + * File Name : boardparms.h
5411 + * Description: This file contains definitions and function prototypes for
5412 + * the BCM63xx board parameter access functions.
5414 + * Updates : 07/14/2003 Created.
5415 + ***************************************************************************/
5417 +#if !defined(_BOARDPARMS_H)
5418 +#define _BOARDPARMS_H
5420 +/* Return codes. */
5421 +#define BP_SUCCESS 0
5422 +#define BP_BOARD_ID_NOT_FOUND 1
5423 +#define BP_VALUE_NOT_DEFINED 2
5424 +#define BP_BOARD_ID_NOT_SET 3
5426 +/* Values for BpGetSdramSize. */
5427 +#define BP_MEMORY_8MB_1_CHIP 0
5428 +#define BP_MEMORY_16MB_1_CHIP 1
5429 +#define BP_MEMORY_32MB_1_CHIP 2
5430 +#define BP_MEMORY_64MB_2_CHIP 3
5431 +#define BP_MEMORY_32MB_2_CHIP 4
5432 +#define BP_MEMORY_16MB_2_CHIP 5
5434 +/* Values for EthernetMacInfo PhyType. */
5435 +#define BP_ENET_NO_PHY 0
5436 +#define BP_ENET_INTERNAL_PHY 1
5437 +#define BP_ENET_EXTERNAL_PHY 2
5438 +#define BP_ENET_EXTERNAL_SWITCH 3
5440 +/* Values for EthernetMacInfo Configuration type. */
5441 +#define BP_ENET_CONFIG_MDIO 0 /* Internal PHY, External PHY, Switch+(no GPIO, no SPI, no MDIO Pseudo phy */
5442 +#define BP_ENET_CONFIG_GPIO 1 /* Bcm96345GW board + Bcm5325M/E */
5443 +#define BP_ENET_CONFIG_MDIO_PSEUDO_PHY 2 /* Bcm96348GW board + Bcm5325E */
5444 +#define BP_ENET_CONFIG_SPI_SSB_0 3 /* Bcm96348GW board + Bcm5325M/E */
5445 +#define BP_ENET_CONFIG_SPI_SSB_1 4 /* Bcm96348GW board + Bcm5325M/E */
5446 +#define BP_ENET_CONFIG_SPI_SSB_2 5 /* Bcm96348GW board + Bcm5325M/E */
5447 +#define BP_ENET_CONFIG_SPI_SSB_3 6 /* Bcm96348GW board + Bcm5325M/E */
5449 +/* Values for EthernetMacInfo Reverse MII. */
5450 +#define BP_ENET_NO_REVERSE_MII 0
5451 +#define BP_ENET_REVERSE_MII 1
5453 +/* Values for VoIPDSPInfo DSPType. */
5454 +#define BP_VOIP_NO_DSP 0
5455 +#define BP_VOIP_DSP 1
5458 +/* Values for GPIO pin assignments (AH = Active High, AL = Active Low). */
5459 +#define BP_ACTIVE_MASK 0x8000
5460 +#define BP_ACTIVE_HIGH 0x0000
5461 +#define BP_ACTIVE_LOW 0x8000
5462 +#define BP_GPIO_0_AH (0 | BP_ACTIVE_HIGH)
5463 +#define BP_GPIO_0_AL (0 | BP_ACTIVE_LOW)
5464 +#define BP_GPIO_1_AH (1 | BP_ACTIVE_HIGH)
5465 +#define BP_GPIO_1_AL (1 | BP_ACTIVE_LOW)
5466 +#define BP_GPIO_2_AH (2 | BP_ACTIVE_HIGH)
5467 +#define BP_GPIO_2_AL (2 | BP_ACTIVE_LOW)
5468 +#define BP_GPIO_3_AH (3 | BP_ACTIVE_HIGH)
5469 +#define BP_GPIO_3_AL (3 | BP_ACTIVE_LOW)
5470 +#define BP_GPIO_4_AH (4 | BP_ACTIVE_HIGH)
5471 +#define BP_GPIO_4_AL (4 | BP_ACTIVE_LOW)
5472 +#define BP_GPIO_5_AH (5 | BP_ACTIVE_HIGH)
5473 +#define BP_GPIO_5_AL (5 | BP_ACTIVE_LOW)
5474 +#define BP_GPIO_6_AH (6 | BP_ACTIVE_HIGH)
5475 +#define BP_GPIO_6_AL (6 | BP_ACTIVE_LOW)
5476 +#define BP_GPIO_7_AH (7 | BP_ACTIVE_HIGH)
5477 +#define BP_GPIO_7_AL (7 | BP_ACTIVE_LOW)
5478 +#define BP_GPIO_8_AH (8 | BP_ACTIVE_HIGH)
5479 +#define BP_GPIO_8_AL (8 | BP_ACTIVE_LOW)
5480 +#define BP_GPIO_9_AH (9 | BP_ACTIVE_HIGH)
5481 +#define BP_GPIO_9_AL (9 | BP_ACTIVE_LOW)
5482 +#define BP_GPIO_10_AH (10 | BP_ACTIVE_HIGH)
5483 +#define BP_GPIO_10_AL (10 | BP_ACTIVE_LOW)
5484 +#define BP_GPIO_11_AH (11 | BP_ACTIVE_HIGH)
5485 +#define BP_GPIO_11_AL (11 | BP_ACTIVE_LOW)
5486 +#define BP_GPIO_12_AH (12 | BP_ACTIVE_HIGH)
5487 +#define BP_GPIO_12_AL (12 | BP_ACTIVE_LOW)
5488 +#define BP_GPIO_13_AH (13 | BP_ACTIVE_HIGH)
5489 +#define BP_GPIO_13_AL (13 | BP_ACTIVE_LOW)
5490 +#define BP_GPIO_14_AH (14 | BP_ACTIVE_HIGH)
5491 +#define BP_GPIO_14_AL (14 | BP_ACTIVE_LOW)
5492 +#define BP_GPIO_15_AH (15 | BP_ACTIVE_HIGH)
5493 +#define BP_GPIO_15_AL (15 | BP_ACTIVE_LOW)
5494 +#define BP_GPIO_16_AH (16 | BP_ACTIVE_HIGH)
5495 +#define BP_GPIO_16_AL (16 | BP_ACTIVE_LOW)
5496 +#define BP_GPIO_17_AH (17 | BP_ACTIVE_HIGH)
5497 +#define BP_GPIO_17_AL (17 | BP_ACTIVE_LOW)
5498 +#define BP_GPIO_18_AH (18 | BP_ACTIVE_HIGH)
5499 +#define BP_GPIO_18_AL (18 | BP_ACTIVE_LOW)
5500 +#define BP_GPIO_19_AH (19 | BP_ACTIVE_HIGH)
5501 +#define BP_GPIO_19_AL (19 | BP_ACTIVE_LOW)
5502 +#define BP_GPIO_20_AH (20 | BP_ACTIVE_HIGH)
5503 +#define BP_GPIO_20_AL (20 | BP_ACTIVE_LOW)
5504 +#define BP_GPIO_21_AH (21 | BP_ACTIVE_HIGH)
5505 +#define BP_GPIO_21_AL (21 | BP_ACTIVE_LOW)
5506 +#define BP_GPIO_22_AH (22 | BP_ACTIVE_HIGH)
5507 +#define BP_GPIO_22_AL (22 | BP_ACTIVE_LOW)
5508 +#define BP_GPIO_23_AH (23 | BP_ACTIVE_HIGH)
5509 +#define BP_GPIO_23_AL (23 | BP_ACTIVE_LOW)
5510 +#define BP_GPIO_24_AH (24 | BP_ACTIVE_HIGH)
5511 +#define BP_GPIO_24_AL (24 | BP_ACTIVE_LOW)
5512 +#define BP_GPIO_25_AH (25 | BP_ACTIVE_HIGH)
5513 +#define BP_GPIO_25_AL (25 | BP_ACTIVE_LOW)
5514 +#define BP_GPIO_26_AH (26 | BP_ACTIVE_HIGH)
5515 +#define BP_GPIO_26_AL (26 | BP_ACTIVE_LOW)
5516 +#define BP_GPIO_27_AH (27 | BP_ACTIVE_HIGH)
5517 +#define BP_GPIO_27_AL (27 | BP_ACTIVE_LOW)
5518 +#define BP_GPIO_28_AH (28 | BP_ACTIVE_HIGH)
5519 +#define BP_GPIO_28_AL (28 | BP_ACTIVE_LOW)
5520 +#define BP_GPIO_29_AH (29 | BP_ACTIVE_HIGH)
5521 +#define BP_GPIO_29_AL (29 | BP_ACTIVE_LOW)
5522 +#define BP_GPIO_30_AH (30 | BP_ACTIVE_HIGH)
5523 +#define BP_GPIO_30_AL (30 | BP_ACTIVE_LOW)
5524 +#define BP_GPIO_31_AH (31 | BP_ACTIVE_HIGH)
5525 +#define BP_GPIO_31_AL (31 | BP_ACTIVE_LOW)
5526 +#define BP_GPIO_32_AH (32 | BP_ACTIVE_HIGH)
5527 +#define BP_GPIO_32_AL (32 | BP_ACTIVE_LOW)
5528 +#define BP_GPIO_33_AH (33 | BP_ACTIVE_HIGH)
5529 +#define BP_GPIO_33_AL (33 | BP_ACTIVE_LOW)
5530 +#define BP_GPIO_34_AH (34 | BP_ACTIVE_HIGH)
5531 +#define BP_GPIO_34_AL (34 | BP_ACTIVE_LOW)
5532 +#define BP_GPIO_35_AH (35 | BP_ACTIVE_HIGH)
5533 +#define BP_GPIO_35_AL (35 | BP_ACTIVE_LOW)
5534 +#define BP_GPIO_36_AH (36 | BP_ACTIVE_HIGH)
5535 +#define BP_GPIO_36_AL (36 | BP_ACTIVE_LOW)
5537 +/* Values for external interrupt assignments. */
5538 +#define BP_EXT_INTR_0 0
5539 +#define BP_EXT_INTR_1 1
5540 +#define BP_EXT_INTR_2 2
5541 +#define BP_EXT_INTR_3 3
5543 +/* Values for chip select assignments. */
5549 +/* Value for GPIO and external interrupt fields that are not used. */
5550 +#define BP_NOT_DEFINED 0xffff
5551 +#define BP_HW_DEFINED 0xfff0
5552 +#define BP_UNEQUIPPED 0xfff1
5554 +/* Maximum size of the board id string. */
5555 +#define BP_BOARD_ID_LEN 16
5557 +/* Maximum number of Ethernet MACs. */
5558 +#define BP_MAX_ENET_MACS 2
5560 +/* Maximum number of VoIP DSPs. */
5561 +#define BP_MAX_VOIP_DSP 2
5563 +/* Wireless Antenna Settings. */
5564 +#define BP_WLAN_ANT_MAIN 0
5565 +#define BP_WLAN_ANT_AUX 1
5566 +#define BP_WLAN_ANT_BOTH 3
5568 +#if !defined(__ASSEMBLER__)
5570 +/* Information about an Ethernet MAC. If ucPhyType is BP_ENET_NO_PHY,
5571 + * then the other fields are not valid.
5573 +typedef struct EthernetMacInfo
5575 + unsigned char ucPhyType; /* BP_ENET_xxx */
5576 + unsigned char ucPhyAddress; /* 0 to 31 */
5577 + unsigned short usGpioPhySpiSck; /* GPIO pin or not defined */
5578 + unsigned short usGpioPhySpiSs; /* GPIO pin or not defined */
5579 + unsigned short usGpioPhySpiMosi; /* GPIO pin or not defined */
5580 + unsigned short usGpioPhySpiMiso; /* GPIO pin or not defined */
5581 + unsigned short usGpioPhyReset; /* GPIO pin or not defined (96348LV) */
5582 + unsigned short numSwitchPorts; /* Number of PHY ports */
5583 + unsigned short usConfigType; /* Configuration type */
5584 + unsigned short usReverseMii; /* Reverse MII */
5585 +} ETHERNET_MAC_INFO, *PETHERNET_MAC_INFO;
5588 +/* Information about VoIP DSPs. If ucDspType is BP_VOIP_NO_DSP,
5589 + * then the other fields are not valid.
5591 +typedef struct VoIPDspInfo
5593 + unsigned char ucDspType;
5594 + unsigned char ucDspAddress;
5595 + unsigned short usExtIntrVoip;
5596 + unsigned short usGpioVoipReset;
5597 + unsigned short usGpioVoipIntr;
5598 + unsigned short usGpioLedVoip;
5599 + unsigned short usCsVoip;
5604 +/**************************************************************************
5605 + * Name : BpSetBoardId
5607 + * Description: This function find the BOARD_PARAMETERS structure for the
5608 + * specified board id string and assigns it to a global, static
5611 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
5613 + * Returns : BP_SUCCESS - Success, value is returned.
5614 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
5615 + * have a board parameters configuration record.
5616 + ***************************************************************************/
5617 +int BpSetBoardId( char *pszBoardId );
5619 +/**************************************************************************
5620 + * Name : BpGetBoardIds
5622 + * Description: This function returns all of the supported board id strings.
5624 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
5625 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
5627 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
5628 + * were allocated in pszBoardIds.
5630 + * Returns : Number of board id strings returned.
5631 + ***************************************************************************/
5632 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize );
5634 +/**************************************************************************
5635 + * Name : BpGetEthernetMacInfo
5637 + * Description: This function returns all of the supported board id strings.
5639 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
5641 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
5642 + * are pointed to by pEnetInfos.
5644 + * Returns : BP_SUCCESS - Success, value is returned.
5645 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5646 + ***************************************************************************/
5647 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos );
5649 +/**************************************************************************
5650 + * Name : BpGetSdramSize
5652 + * Description: This function returns a constant that describees the board's
5653 + * SDRAM type and size.
5655 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
5658 + * Returns : BP_SUCCESS - Success, value is returned.
5659 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5660 + ***************************************************************************/
5661 +int BpGetSdramSize( unsigned long *pulSdramSize );
5663 +/**************************************************************************
5664 + * Name : BpGetPsiSize
5666 + * Description: This function returns the persistent storage size in K bytes.
5668 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
5669 + * storage size is returned in.
5671 + * Returns : BP_SUCCESS - Success, value is returned.
5672 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5673 + ***************************************************************************/
5674 +int BpGetPsiSize( unsigned long *pulPsiSize );
5676 +/**************************************************************************
5677 + * Name : BpGetRj11InnerOuterPairGpios
5679 + * Description: This function returns the GPIO pin assignments for changing
5680 + * between the RJ11 inner pair and RJ11 outer pair.
5682 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
5683 + * GPIO pin is returned in.
5684 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
5685 + * GPIO pin is returned in.
5687 + * Returns : BP_SUCCESS - Success, values are returned.
5688 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5689 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5691 + ***************************************************************************/
5692 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
5693 + unsigned short *pusOuter );
5695 +/**************************************************************************
5696 + * Name : BpGetPressAndHoldResetGpio
5698 + * Description: This function returns the GPIO pin assignment for the press
5699 + * and hold reset button.
5701 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
5702 + * reset button GPIO pin is returned in.
5704 + * Returns : BP_SUCCESS - Success, value is returned.
5705 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5706 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5708 + ***************************************************************************/
5709 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue );
5711 +/**************************************************************************
5712 + * Name : BpGetVoipResetGpio
5714 + * Description: This function returns the GPIO pin assignment for the VOIP
5715 + * Reset operation.
5717 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
5718 + * GPIO pin is returned in.
5719 + * [IN] dspNum - Address of the DSP to query.
5721 + * Returns : BP_SUCCESS - Success, value is returned.
5722 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5723 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5725 + ***************************************************************************/
5726 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue );
5728 +/**************************************************************************
5729 + * Name : BpGetVoipIntrGpio
5731 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
5733 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
5734 + * GPIO pin is returned in.
5735 + * [IN] dspNum - Address of the DSP to query.
5737 + * Returns : BP_SUCCESS - Success, value is returned.
5738 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5739 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5741 + ***************************************************************************/
5742 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue );
5744 +/**************************************************************************
5745 + * Name : BpGetPcmciaResetGpio
5747 + * Description: This function returns the GPIO pin assignment for the PCMCIA
5748 + * Reset operation.
5750 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
5751 + * GPIO pin is returned in.
5753 + * Returns : BP_SUCCESS - Success, value is returned.
5754 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5755 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5757 + ***************************************************************************/
5758 +int BpGetPcmciaResetGpio( unsigned short *pusValue );
5760 +/**************************************************************************
5761 + * Name : BpGetUartRtsCtsGpios
5763 + * Description: This function returns the GPIO pin assignments for RTS and CTS
5766 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
5767 + * pin is returned in.
5768 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
5769 + * pin is returned in.
5771 + * Returns : BP_SUCCESS - Success, values are returned.
5772 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5773 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5775 + ***************************************************************************/
5776 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts );
5778 +/**************************************************************************
5779 + * Name : BpGetAdslLedGpio
5781 + * Description: This function returns the GPIO pin assignment for the ADSL
5784 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5785 + * GPIO pin is returned in.
5787 + * Returns : BP_SUCCESS - Success, value is returned.
5788 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5789 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5791 + ***************************************************************************/
5792 +int BpGetAdslLedGpio( unsigned short *pusValue );
5794 +/**************************************************************************
5795 + * Name : BpGetAdslFailLedGpio
5797 + * Description: This function returns the GPIO pin assignment for the ADSL
5798 + * LED that is used when there is a DSL connection failure.
5800 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5801 + * GPIO pin is returned in.
5803 + * Returns : BP_SUCCESS - Success, value is returned.
5804 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5805 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5807 + ***************************************************************************/
5808 +int BpGetAdslFailLedGpio( unsigned short *pusValue );
5810 +/**************************************************************************
5811 + * Name : BpGetWirelessLedGpio
5813 + * Description: This function returns the GPIO pin assignment for the Wireless
5816 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
5817 + * GPIO pin is returned in.
5819 + * Returns : BP_SUCCESS - Success, value is returned.
5820 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5821 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5823 + ***************************************************************************/
5824 +int BpGetWirelessLedGpio( unsigned short *pusValue );
5826 +/**************************************************************************
5827 + * Name : BpGetWirelessAntInUse
5829 + * Description: This function returns the antennas in use for wireless
5831 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
5834 + * Returns : BP_SUCCESS - Success, value is returned.
5835 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5836 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5838 + ***************************************************************************/
5839 +int BpGetWirelessAntInUse( unsigned short *pusValue );
5841 +/**************************************************************************
5842 + * Name : BpGetWirelessSesBtnGpio
5844 + * Description: This function returns the GPIO pin assignment for the Wireless
5847 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5848 + * Button GPIO pin is returned in.
5850 + * Returns : BP_SUCCESS - Success, value is returned.
5851 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5852 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5854 + ***************************************************************************/
5855 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue );
5857 +/**************************************************************************
5858 + * Name : BpGetWirelessSesExtIntr
5860 + * Description: This function returns the external interrupt number for the
5861 + * Wireless Ses Button.
5863 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5864 + * external interrup is returned in.
5866 + * Returns : BP_SUCCESS - Success, value is returned.
5867 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5868 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5870 + ***************************************************************************/
5871 +int BpGetWirelessSesExtIntr( unsigned short *pusValue );
5873 +/**************************************************************************
5874 + * Name : BpGetWirelessSesLedGpio
5876 + * Description: This function returns the GPIO pin assignment for the Wireless
5879 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5880 + * Led GPIO pin is returned in.
5882 + * Returns : BP_SUCCESS - Success, value is returned.
5883 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5884 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5886 + ***************************************************************************/
5887 +int BpGetWirelessSesLedGpio( unsigned short *pusValue );
5889 +/**************************************************************************
5890 + * Name : BpGetUsbLedGpio
5892 + * Description: This function returns the GPIO pin assignment for the USB
5895 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
5896 + * GPIO pin is returned in.
5898 + * Returns : BP_SUCCESS - Success, value is returned.
5899 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5900 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5902 + ***************************************************************************/
5903 +int BpGetUsbLedGpio( unsigned short *pusValue );
5905 +/**************************************************************************
5906 + * Name : BpGetHpnaLedGpio
5908 + * Description: This function returns the GPIO pin assignment for the HPNA
5911 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
5912 + * GPIO pin is returned in.
5914 + * Returns : BP_SUCCESS - Success, value is returned.
5915 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5916 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5918 + ***************************************************************************/
5919 +int BpGetHpnaLedGpio( unsigned short *pusValue );
5921 +/**************************************************************************
5922 + * Name : BpGetWanDataLedGpio
5924 + * Description: This function returns the GPIO pin assignment for the WAN Data
5927 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
5928 + * GPIO pin is returned in.
5930 + * Returns : BP_SUCCESS - Success, value is returned.
5931 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5932 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5934 + ***************************************************************************/
5935 +int BpGetWanDataLedGpio( unsigned short *pusValue );
5937 +/**************************************************************************
5938 + * Name : BpGetPppLedGpio
5940 + * Description: This function returns the GPIO pin assignment for the PPP
5943 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5944 + * GPIO pin is returned in.
5946 + * Returns : BP_SUCCESS - Success, value is returned.
5947 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5948 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5950 + ***************************************************************************/
5951 +int BpGetPppLedGpio( unsigned short *pusValue );
5953 +/**************************************************************************
5954 + * Name : BpGetPppFailLedGpio
5956 + * Description: This function returns the GPIO pin assignment for the PPP
5957 + * LED that is used when there is a PPP connection failure.
5959 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5960 + * GPIO pin is returned in.
5962 + * Returns : BP_SUCCESS - Success, value is returned.
5963 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5964 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5966 + ***************************************************************************/
5967 +int BpGetPppFailLedGpio( unsigned short *pusValue );
5969 +/**************************************************************************
5970 + * Name : BpGetVoipLedGpio
5972 + * Description: This function returns the GPIO pin assignment for the VOIP
5975 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5976 + * GPIO pin is returned in.
5978 + * Returns : BP_SUCCESS - Success, value is returned.
5979 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5980 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5982 + ***************************************************************************/
5983 +int BpGetVoipLedGpio( unsigned short *pusValue );
5985 +/**************************************************************************
5986 + * Name : BpGetBootloaderPowerOnLedGpio
5988 + * Description: This function returns the GPIO pin assignment for the power
5989 + * on LED that is set by the bootloader.
5991 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5992 + * GPIO pin is returned in.
5994 + * Returns : BP_SUCCESS - Success, value is returned.
5995 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5996 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5998 + ***************************************************************************/
5999 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue );
6001 +/**************************************************************************
6002 + * Name : BpGetBootloaderAlarmLedGpio
6004 + * Description: This function returns the GPIO pin assignment for the alarm
6005 + * LED that is set by the bootloader.
6007 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6008 + * GPIO pin is returned in.
6010 + * Returns : BP_SUCCESS - Success, value is returned.
6011 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6012 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6014 + ***************************************************************************/
6015 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue );
6017 +/**************************************************************************
6018 + * Name : BpGetBootloaderResetCfgLedGpio
6020 + * Description: This function returns the GPIO pin assignment for the reset
6021 + * configuration LED that is set by the bootloader.
6023 + * Parameters : [OUT] pusValue - Address of short word that the reset
6024 + * configuration LED GPIO pin is returned in.
6026 + * Returns : BP_SUCCESS - Success, value is returned.
6027 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6028 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6030 + ***************************************************************************/
6031 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue );
6033 +/**************************************************************************
6034 + * Name : BpGetBootloaderStopLedGpio
6036 + * Description: This function returns the GPIO pin assignment for the break
6037 + * into bootloader LED that is set by the bootloader.
6039 + * Parameters : [OUT] pusValue - Address of short word that the break into
6040 + * bootloader LED GPIO pin is returned in.
6042 + * Returns : BP_SUCCESS - Success, value is returned.
6043 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6044 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6046 + ***************************************************************************/
6047 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue );
6049 +/**************************************************************************
6050 + * Name : BpGetWirelessExtIntr
6052 + * Description: This function returns the Wireless external interrupt number.
6054 + * Parameters : [OUT] pulValue - Address of short word that the wireless
6055 + * external interrupt number is returned in.
6057 + * Returns : BP_SUCCESS - Success, value is returned.
6058 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6059 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6061 + ***************************************************************************/
6062 +int BpGetWirelessExtIntr( unsigned long *pulValue );
6064 +/**************************************************************************
6065 + * Name : BpGetAdslDyingGaspExtIntr
6067 + * Description: This function returns the ADSL Dying Gasp external interrupt
6070 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
6071 + * external interrupt number is returned in.
6073 + * Returns : BP_SUCCESS - Success, value is returned.
6074 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6075 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6077 + ***************************************************************************/
6078 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue );
6080 +/**************************************************************************
6081 + * Name : BpGetVoipExtIntr
6083 + * Description: This function returns the VOIP external interrupt number.
6085 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6086 + * external interrupt number is returned in.
6087 + * [IN] dspNum - Address of the DSP to query.
6089 + * Returns : BP_SUCCESS - Success, value is returned.
6090 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6091 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6093 + ***************************************************************************/
6094 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue );
6096 +/**************************************************************************
6097 + * Name : BpGetHpnaExtIntr
6099 + * Description: This function returns the HPNA external interrupt number.
6101 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6102 + * external interrupt number is returned in.
6104 + * Returns : BP_SUCCESS - Success, value is returned.
6105 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6106 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6108 + ***************************************************************************/
6109 +int BpGetHpnaExtIntr( unsigned long *pulValue );
6111 +/**************************************************************************
6112 + * Name : BpGetHpnaChipSelect
6114 + * Description: This function returns the HPNA chip select number.
6116 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6117 + * chip select number is returned in.
6119 + * Returns : BP_SUCCESS - Success, value is returned.
6120 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6121 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6123 + ***************************************************************************/
6124 +int BpGetHpnaChipSelect( unsigned long *pulValue );
6126 +/**************************************************************************
6127 + * Name : BpGetVoipChipSelect
6129 + * Description: This function returns the VOIP chip select number.
6131 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6132 + * chip select number is returned in.
6133 + * [IN] dspNum - Address of the DSP to query.
6135 + * Returns : BP_SUCCESS - Success, value is returned.
6136 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6137 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6139 + ***************************************************************************/
6140 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue );
6142 +#endif /* __ASSEMBLER__ */
6144 +#endif /* _BOARDPARMS_H */
6146 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c
6147 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c 1970-01-01 01:00:00.000000000 +0100
6148 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c 2006-07-13 19:11:33.000000000 +0200
6150 +/************************************************************************/
6152 +/* AMD CFI Enabled Flash Memory Drivers */
6153 +/* File name: CFIFLASH.C */
6154 +/* Revision: 1.0 5/07/98 */
6156 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6157 +/* This software is unpublished and contains the trade secrets and */
6158 +/* confidential proprietary information of AMD. Unless otherwise */
6159 +/* provided in the Software Agreement associated herewith, it is */
6160 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
6161 +/* or part by any means except for backup. Use, duplication, or */
6162 +/* disclosure by the Government is subject to the restrictions in */
6163 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
6164 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
6165 +/* Software owned by */
6166 +/* Advanced Micro Devices, Inc., */
6167 +/* One AMD Place, */
6168 +/* P.O. Box 3453 */
6169 +/* Sunnyvale, CA 94088-3453. */
6170 +/************************************************************************/
6171 +/* This software constitutes a basic shell of source code for */
6172 +/* programming all AMD Flash components. AMD */
6173 +/* will not be responsible for misuse or illegal use of this */
6174 +/* software for devices not supported herein. AMD is providing */
6175 +/* this source code "AS IS" and will not be responsible for */
6176 +/* issues arising from incorrect user implementation of the */
6177 +/* source code herein. It is the user's responsibility to */
6178 +/* properly design-in this source code. */
6180 +/************************************************************************/
6182 +#include "lib_types.h"
6183 +#include "lib_printf.h"
6184 +#include "lib_string.h"
6185 +#include "cfe_timer.h"
6186 +#define printk printf
6188 +#include <linux/param.h>
6189 +#include <linux/sched.h>
6190 +#include <linux/timer.h>
6193 +#include "cfiflash.h"
6195 +static int flash_wait(WORD sector, int offset, UINT16 data);
6196 +static UINT16 flash_get_device_id(void);
6197 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily);
6198 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes);
6199 +static void flash_command(int command, WORD sector, int offset, UINT16 data);
6201 +/*********************************************************************/
6202 +/* 'meminfo' should be a pointer, but most C compilers will not */
6203 +/* allocate static storage for a pointer without calling */
6204 +/* non-portable functions such as 'new'. We also want to avoid */
6205 +/* the overhead of passing this pointer for every driver call. */
6206 +/* Systems with limited heap space will need to do this. */
6207 +/*********************************************************************/
6208 +struct flashinfo meminfo; /* Flash information structure */
6209 +static int flashFamily = FLASH_UNDEFINED;
6210 +static int totalSize = 0;
6211 +static struct cfi_query query;
6213 +static UINT16 cfi_data_struct_29W160[] = {
6214 + 0x0020, 0x0049, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6215 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6216 + 0x0051, 0x0052, 0x0059, 0x0002, 0x0000, 0x0040, 0x0000, 0x0000,
6217 + 0x0000, 0x0000, 0x0000, 0x0027, 0x0036, 0x0000, 0x0000, 0x0004,
6218 + 0x0000, 0x000a, 0x0000, 0x0004, 0x0000, 0x0003, 0x0000, 0x0015,
6219 + 0x0002, 0x0000, 0x0000, 0x0000, 0x0004, 0x0000, 0x0000, 0x0040,
6220 + 0x0000, 0x0001, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0080,
6221 + 0x0000, 0x001e, 0x0000, 0x0000, 0x0001, 0xffff, 0xffff, 0xffff,
6222 + 0x0050, 0x0052, 0x0049, 0x0031, 0x0030, 0x0000, 0x0002, 0x0001,
6223 + 0x0001, 0x0004, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0002,
6224 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6225 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6226 + 0xffff, 0x0888, 0x252b, 0x8c84, 0x7dbc, 0xffff, 0xffff, 0xffff,
6227 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6228 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6229 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
6233 +/*********************************************************************/
6234 +/* Init_flash is used to build a sector table from the information */
6235 +/* provided through the CFI query. This information is translated */
6236 +/* from erase_block information to base:offset information for each */
6237 +/* individual sector. This information is then stored in the meminfo */
6238 +/* structure, and used throughout the driver to access sector */
6241 +/* This is more efficient than deriving the sector base:offset */
6242 +/* information every time the memory map switches (since on the */
6243 +/* development platform can only map 64k at a time). If the entire */
6244 +/* flash memory array can be mapped in, then the addition static */
6245 +/* allocation for the meminfo structure can be eliminated, but the */
6246 +/* drivers will have to be re-written. */
6248 +/* The meminfo struct occupies 653 bytes of heap space, depending */
6249 +/* on the value of the define MAXSECTORS. Adjust to suit */
6251 +/*********************************************************************/
6252 +byte flash_init(void)
6254 + int i=0, j=0, count=0;
6257 + int flipCFIGeometry = FALSE;
6260 + * a single 8k sector for sector 0. This is to allow
6261 + * the system to perform memory mapping to the device,
6262 + * even though the actual physical layout is unknown.
6263 + * Once mapped in, the CFI query will produce all
6264 + * relevant information.
6266 + meminfo.addr = 0L;
6268 + meminfo.nsect = 1;
6269 + meminfo.bank1start = 0;
6270 + meminfo.bank2start = 0;
6272 + meminfo.sec[0].size = 8192;
6273 + meminfo.sec[0].base = 0x00000;
6274 + meminfo.sec[0].bank = 1;
6276 + flash_command(FLASH_RESET, 0, 0, 0);
6278 + device_id = flash_get_device_id();
6280 + switch (device_id) {
6281 + case ID_I28F160C3B:
6282 + case ID_I28F320C3B:
6283 + case ID_I28F160C3T:
6284 + case ID_I28F320C3T:
6285 + flashFamily = FLASH_INTEL;
6287 + case ID_AM29DL800B:
6288 + case ID_AM29LV800B:
6289 + case ID_AM29LV400B:
6290 + case ID_AM29LV160B:
6291 + case ID_AM29LV320B:
6292 + case ID_MX29LV320AB:
6293 + case ID_AM29LV320MB:
6294 + case ID_AM29DL800T:
6295 + case ID_AM29LV800T:
6296 + case ID_AM29LV160T:
6297 + case ID_AM29LV320T:
6298 + case ID_MX29LV320AT:
6299 + case ID_AM29LV320MT:
6300 + flashFamily = FLASH_AMD;
6302 + case ID_SST39VF1601:
6303 + case ID_SST39VF3201:
6304 + flashFamily = FLASH_SST;
6307 + printk("Flash memory not supported! Device id = %x\n", device_id);
6311 + if (flash_get_cfi(&query, 0, flashFamily) == -1) {
6312 + switch(device_id) {
6313 + case ID_AM29LV160T:
6314 + case ID_AM29LV160B:
6315 + flash_get_cfi(&query, cfi_data_struct_29W160, flashFamily);
6318 + printk("CFI data structure not found. Device id = %x\n", device_id);
6323 + // need to determine if it top or bottom boot here
6324 + switch (device_id)
6326 + case ID_AM29DL800B:
6327 + case ID_AM29LV800B:
6328 + case ID_AM29LV400B:
6329 + case ID_AM29LV160B:
6330 + case ID_AM29LV320B:
6331 + case ID_MX29LV320AB:
6332 + case ID_AM29LV320MB:
6333 + case ID_I28F160C3B:
6334 + case ID_I28F320C3B:
6335 + case ID_I28F160C3T:
6336 + case ID_I28F320C3T:
6337 + case ID_SST39VF1601:
6338 + case ID_SST39VF3201:
6339 + flipCFIGeometry = FALSE;
6341 + case ID_AM29DL800T:
6342 + case ID_AM29LV800T:
6343 + case ID_AM29LV160T:
6344 + case ID_AM29LV320T:
6345 + case ID_MX29LV320AT:
6346 + case ID_AM29LV320MT:
6347 + flipCFIGeometry = TRUE;
6350 + printk("Flash memory not supported! Device id = %x\n", device_id);
6354 + count=0;basecount=0L;
6356 + if (!flipCFIGeometry)
6358 + for (i=0; i<query.num_erase_blocks; i++) {
6359 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6360 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6361 + meminfo.sec[count].base = (int) basecount;
6362 + basecount += (int) query.erase_block[i].sector_size;
6369 + for (i = (query.num_erase_blocks - 1); i >= 0; i--) {
6370 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6371 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6372 + meminfo.sec[count].base = (int) basecount;
6373 + basecount += (int) query.erase_block[i].sector_size;
6379 + meminfo.nsect = count;
6380 + totalSize = meminfo.sec[count-1].base + meminfo.sec[count-1].size;
6384 +/*********************************************************************/
6385 +/* Flash_sector_erase_int() is identical to flash_sector_erase(), */
6386 +/* except it will wait until the erase is completed before returning */
6387 +/* control to the calling function. This can be used in cases which */
6388 +/* require the program to hold until a sector is erased, without */
6389 +/* adding the wait check external to this function. */
6390 +/*********************************************************************/
6391 +byte flash_sector_erase_int(WORD sector)
6395 + for( i = 0; i < 3; i++ ) {
6396 + flash_command(FLASH_SERASE, sector, 0, 0);
6397 + if (flash_wait(sector, 0, 0xffff) == STATUS_READY)
6404 +/*********************************************************************/
6405 +/* flash_read_buf() reads buffer of data from the specified */
6406 +/* offset from the sector parameter. */
6407 +/*********************************************************************/
6408 +int flash_read_buf(WORD sector, int offset,
6409 + byte *buffer, int numbytes)
6413 + fwp = (byte *)flash_get_memptr(sector);
6415 + while (numbytes) {
6416 + *buffer++ = *(fwp + offset);
6424 +/*********************************************************************/
6425 +/* flash_write_buf() utilizes */
6426 +/* the unlock bypass mode of the flash device. This can remove */
6427 +/* significant overhead from the bulk programming operation, and */
6428 +/* when programming bulk data a sizeable performance increase can be */
6430 +/*********************************************************************/
6431 +int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes)
6435 + unsigned char *p = flash_get_memptr(sector) + offset;
6437 + /* After writing the flash block, compare the contents to the source
6438 + * buffer. Try to write the sector successfully up to three times.
6440 + for( i = 0; i < 3; i++ ) {
6441 + ret = flash_write(sector, offset, buffer, numbytes);
6442 + if( !memcmp( p, buffer, numbytes ) )
6444 + /* Erase and try again */
6445 + flash_sector_erase_int(sector);
6450 + printk( "Flash write error. Verify failed\n" );
6455 +/*********************************************************************/
6456 +/* Usefull funtion to return the number of sectors in the device. */
6457 +/* Can be used for functions which need to loop among all the */
6458 +/* sectors, or wish to know the number of the last sector. */
6459 +/*********************************************************************/
6460 +int flash_get_numsectors(void)
6462 + return meminfo.nsect;
6465 +/*********************************************************************/
6466 +/* flash_get_sector_size() is provided for cases in which the size */
6467 +/* of a sector is required by a host application. The sector size */
6468 +/* (in bytes) is returned in the data location pointed to by the */
6469 +/* 'size' parameter. */
6470 +/*********************************************************************/
6471 +int flash_get_sector_size(WORD sector)
6473 + return meminfo.sec[sector].size;
6476 +/*********************************************************************/
6477 +/* The purpose of flash_get_memptr() is to return a memory pointer */
6478 +/* which points to the beginning of memory space allocated for the */
6479 +/* flash. All function pointers are then referenced from this */
6482 +/* Different systems will implement this in different ways: */
6483 +/* possibilities include: */
6484 +/* - A direct memory pointer */
6485 +/* - A pointer to a memory map */
6486 +/* - A pointer to a hardware port from which the linear */
6487 +/* address is translated */
6488 +/* - Output of an MMU function / service */
6490 +/* Also note that this function expects the pointer to a specific */
6491 +/* sector of the device. This can be provided by dereferencing */
6492 +/* the pointer from a translated offset of the sector from a */
6493 +/* global base pointer (e.g. flashptr = base_pointer + sector_offset)*/
6495 +/* Important: Many AMD flash devices need both bank and or sector */
6496 +/* address bits to be correctly set (bank address bits are A18-A16, */
6497 +/* and sector address bits are A18-A12, or A12-A15). Flash parts */
6498 +/* which do not need these bits will ignore them, so it is safe to */
6499 +/* assume that every part will require these bits to be set. */
6500 +/*********************************************************************/
6501 +unsigned char *flash_get_memptr(WORD sector)
6503 + unsigned char *memptr = (unsigned char*)(FLASH_BASE_ADDR_REG + meminfo.sec[sector].base);
6508 +/*********************************************************************/
6509 +/* The purpose of flash_get_blk() is to return a the block number */
6510 +/* for a given memory address. */
6511 +/*********************************************************************/
6512 +int flash_get_blk(int addr)
6515 + int last_blk = flash_get_numsectors();
6516 + int relative_addr = addr - (int) FLASH_BASE_ADDR_REG;
6518 + for(blk_start=0, i=0; i < relative_addr && blk_start < last_blk; blk_start++)
6519 + i += flash_get_sector_size(blk_start);
6521 + if( i > relative_addr )
6523 + blk_start--; // last blk, dec by 1
6526 + if( blk_start == last_blk )
6528 + printk("Address is too big.\n");
6532 + return( blk_start );
6535 +/************************************************************************/
6536 +/* The purpose of flash_get_total_size() is to return the total size of */
6538 +/************************************************************************/
6539 +int flash_get_total_size()
6544 +/*********************************************************************/
6545 +/* Flash_command() is the main driver function. It performs */
6546 +/* every possible command available to AMD B revision */
6547 +/* flash parts. Note that this command is not used directly, but */
6548 +/* rather called through the API wrapper functions provided below. */
6549 +/*********************************************************************/
6550 +static void flash_command(int command, WORD sector, int offset, UINT16 data)
6552 + volatile UINT16 *flashptr;
6553 + volatile UINT16 *flashbase;
6555 + flashptr = (UINT16 *) flash_get_memptr(sector);
6556 + flashbase = (UINT16 *) flash_get_memptr(0);
6558 + switch (flashFamily) {
6559 + case FLASH_UNDEFINED:
6560 + /* These commands should work for AMD, Intel and SST flashes */
6561 + switch (command) {
6563 + flashptr[0] = 0xF0;
6564 + flashptr[0] = 0xFF;
6566 + case FLASH_READ_ID:
6567 + flashptr[0x5555] = 0xAA; /* unlock 1 */
6568 + flashptr[0x2AAA] = 0x55; /* unlock 2 */
6569 + flashptr[0x5555] = 0x90;
6576 + switch (command) {
6578 + flashptr[0] = 0xF0;
6580 + case FLASH_READ_ID:
6581 + flashptr[0x555] = 0xAA; /* unlock 1 */
6582 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6583 + flashptr[0x555] = 0x90;
6585 + case FLASH_CFIQUERY:
6586 + flashptr[0x55] = 0x98;
6589 + flashptr[0x555] = 0xAA; /* unlock 1 */
6590 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6591 + flashptr[0x555] = 0x20;
6594 + flashptr[0] = 0xA0;
6595 + flashptr[offset/2] = data;
6597 + case FLASH_UBRESET:
6598 + flashptr[0] = 0x90;
6599 + flashptr[0] = 0x00;
6601 + case FLASH_SERASE:
6602 + flashptr[0x555] = 0xAA; /* unlock 1 */
6603 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6604 + flashptr[0x555] = 0x80;
6605 + flashptr[0x555] = 0xAA;
6606 + flashptr[0x2AA] = 0x55;
6607 + flashptr[0] = 0x30;
6614 + switch (command) {
6616 + flashptr[0] = 0xFF;
6618 + case FLASH_READ_ID:
6619 + flashptr[0] = 0x90;
6621 + case FLASH_CFIQUERY:
6622 + flashptr[0] = 0x98;
6625 + flashptr[0] = 0x40;
6626 + flashptr[offset/2] = data;
6628 + case FLASH_SERASE:
6629 + flashptr[0] = 0x60;
6630 + flashptr[0] = 0xD0;
6631 + flashptr[0] = 0x20;
6632 + flashptr[0] = 0xD0;
6639 + switch (command) {
6641 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6642 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6643 + flashbase[0x5555] = 0xf0;
6645 + case FLASH_READ_ID:
6646 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6647 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6648 + flashbase[0x5555] = 0x90;
6650 + case FLASH_CFIQUERY:
6651 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6652 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6653 + flashbase[0x5555] = 0x98;
6658 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6659 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6660 + flashbase[0x5555] = 0xa0;
6661 + flashptr[offset/2] = data;
6663 + case FLASH_UBRESET:
6665 + case FLASH_SERASE:
6666 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6667 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6668 + flashbase[0x5555] = 0x80;
6669 + flashbase[0x5555] = 0xAA;
6670 + flashbase[0x2AAA] = 0x55;
6671 + flashptr[0] = 0x30;
6682 +/*********************************************************************/
6683 +/* flash_write extends the functionality of flash_program() by */
6684 +/* providing an faster way to program multiple data words, without */
6685 +/* needing the function overhead of looping algorithms which */
6686 +/* program word by word. This function utilizes fast pointers */
6687 +/* to quickly loop through bulk data. */
6688 +/*********************************************************************/
6689 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes)
6692 + src = (UINT16 *)buf;
6694 + if ((nbytes | offset) & 1) {
6698 + flash_command(FLASH_UB, 0, 0, 0);
6699 + while (nbytes > 0) {
6700 + flash_command(FLASH_PROG, sector, offset, *src);
6701 + if (flash_wait(sector, offset, *src) != STATUS_READY)
6707 + flash_command(FLASH_UBRESET, 0, 0, 0);
6709 + return (byte*)src - buf;
6712 +/*********************************************************************/
6713 +/* flash_wait utilizes the DQ6, DQ5, and DQ2 polling algorithms */
6714 +/* described in the flash data book. It can quickly ascertain the */
6715 +/* operational status of the flash device, and return an */
6716 +/* appropriate status code (defined in flash.h) */
6717 +/*********************************************************************/
6718 +static int flash_wait(WORD sector, int offset, UINT16 data)
6720 + volatile UINT16 *flashptr; /* flash window */
6723 + flashptr = (UINT16 *) flash_get_memptr(sector);
6725 + if (flashFamily == FLASH_AMD || flashFamily == FLASH_SST) {
6726 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
6728 + d1 = flashptr[offset/2];
6730 + return STATUS_READY;
6731 + } while (!(d1 & 0x20));
6733 + d1 = flashptr[offset/2];
6736 + flash_command(FLASH_RESET, 0, 0, 0);
6737 + return STATUS_TIMEOUT;
6741 + d1 = *flashptr; /* read data */
6742 + d1 ^= *flashptr; /* read it again and see what toggled */
6743 + if (d1 == 0) /* no toggles, nothing's happening */
6744 + return STATUS_READY;
6745 + } while (!(d1 & 0x20));
6747 + d1 = *flashptr; /* read data */
6748 + d1 ^= *flashptr; /* read it again and see what toggled */
6751 + flash_command(FLASH_RESET, 0, 0, 0);
6752 + return STATUS_TIMEOUT;
6755 + } else if (flashFamily == FLASH_INTEL) {
6756 + flashptr[0] = 0x70;
6757 + /* Wait for completion */
6758 + while(!(*flashptr & 0x80));
6759 + if (*flashptr & 0x30) {
6760 + flashptr[0] = 0x50;
6761 + flash_command(FLASH_RESET, 0, 0, 0);
6762 + return STATUS_TIMEOUT;
6764 + flashptr[0] = 0x50;
6765 + flash_command(FLASH_RESET, 0, 0, 0);
6768 + return STATUS_READY;
6771 +/*********************************************************************/
6772 +/* flash_get_device_id() will perform an autoselect sequence on the */
6773 +/* flash device, and return the device id of the component. */
6774 +/* This function automatically resets to read mode. */
6775 +/*********************************************************************/
6776 +static UINT16 flash_get_device_id()
6778 + volatile UINT16 *fwp; /* flash window */
6781 + fwp = (UINT16 *)flash_get_memptr(0);
6783 + flash_command(FLASH_READ_ID, 0, 0, 0);
6784 + answer = *(fwp + 1);
6785 + if (answer == ID_AM29LV320M) {
6786 + answer = *(fwp + 0xe);
6787 + answer = *(fwp + 0xf);
6790 + flash_command(FLASH_RESET, 0, 0, 0);
6791 + return( (UINT16) answer );
6794 +/*********************************************************************/
6795 +/* flash_get_cfi() is the main CFI workhorse function. Due to it's */
6796 +/* complexity and size it need only be called once upon */
6797 +/* initializing the flash system. Once it is called, all operations */
6798 +/* are performed by looking at the meminfo structure. */
6799 +/* All possible care was made to make this algorithm as efficient as */
6800 +/* possible. 90% of all operations are memory reads, and all */
6801 +/* calculations are done using bit-shifts when possible */
6802 +/*********************************************************************/
6803 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily)
6805 + volatile UINT16 *fwp; /* flash window */
6808 + flash_command(FLASH_CFIQUERY, 0, 0, 0);
6810 + if (cfi_struct == 0)
6811 + fwp = (UINT16 *)flash_get_memptr(0);
6815 + /* Initial house-cleaning */
6816 + for(i=0; i < 8; i++) {
6817 + query->erase_block[i].sector_size = 0;
6818 + query->erase_block[i].num_sectors = 0;
6821 + /* If not 'QRY', then we dont have a CFI enabled device in the socket */
6822 + if( fwp[0x10] != 'Q' &&
6823 + fwp[0x11] != 'R' &&
6824 + fwp[0x12] != 'Y') {
6825 + flash_command(FLASH_RESET, 0, 0, 0);
6829 + query->num_erase_blocks = fwp[0x2C];
6830 + if(flashFamily == FLASH_SST)
6831 + query->num_erase_blocks = 1;
6833 + for(i=0; i < query->num_erase_blocks; i++) {
6834 + query->erase_block[i].num_sectors = fwp[(0x2D+(4*i))] + (fwp[0x2E + (4*i)] << 8);
6835 + query->erase_block[i].num_sectors++;
6836 + query->erase_block[i].sector_size = 256 * (256 * fwp[(0x30+(4*i))] + fwp[(0x2F+(4*i))]);
6839 + flash_command(FLASH_RESET, 0, 0, 0);
6842 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h
6843 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h 1970-01-01 01:00:00.000000000 +0100
6844 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h 2006-07-25 10:19:20.000000000 +0200
6846 +/************************************************************************/
6848 +/* AMD CFI Enabled Flash Memory Drivers */
6849 +/* File name: CFIFLASH.H */
6850 +/* Revision: 1.0 5/07/98 */
6852 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6853 +/* This software is unpublished and contains the trade secrets and */
6854 +/* confidential proprietary information of AMD. Unless otherwise */
6855 +/* provided in the Software Agreement associated herewith, it is */
6856 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
6857 +/* or part by any means except for backup. Use, duplication, or */
6858 +/* disclosure by the Government is subject to the restrictions in */
6859 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
6860 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
6861 +/* Software owned by */
6862 +/* Advanced Micro Devices, Inc., */
6863 +/* One AMD Place, */
6864 +/* P.O. Box 3453 */
6865 +/* Sunnyvale, CA 94088-3453. */
6866 +/************************************************************************/
6867 +/* This software constitutes a basic shell of source code for */
6868 +/* programming all AMD Flash components. AMD */
6869 +/* will not be responsible for misuse or illegal use of this */
6870 +/* software for devices not supported herein. AMD is providing */
6871 +/* this source code "AS IS" and will not be responsible for */
6872 +/* issues arising from incorrect user implementation of the */
6873 +/* source code herein. It is the user's responsibility to */
6874 +/* properly design-in this source code. */
6876 +/************************************************************************/
6877 +#ifndef _CFIFLASH_H
6878 +#define _CFIFLASH_H
6880 +/* include board/CPU specific definitions */
6881 +#include "bcmtypes.h"
6884 +#define FLASH_BASE_ADDR_REG FLASH_BASE
6890 +#define MAXSECTORS 1024 /* maximum number of sectors supported */
6892 +/* A structure for identifying a flash part. There is one for each
6893 + * of the flash part definitions. We need to keep track of the
6894 + * sector organization, the address register used, and the size
6898 + char *name; /* "Am29DL800T", etc. */
6899 + unsigned long addr; /* physical address, once translated */
6900 + int areg; /* Can be set to zero for all parts */
6901 + int nsect; /* # of sectors -- 19 in LV, 22 in DL */
6902 + int bank1start; /* first sector # in bank 1 */
6903 + int bank2start; /* first sector # in bank 2, if DL part */
6905 + long size; /* # of bytes in this sector */
6906 + long base; /* offset from beginning of device */
6907 + int bank; /* 1 or 2 for DL; 1 for LV */
6908 + } sec[MAXSECTORS]; /* per-sector info */
6912 + * This structure holds all CFI query information as defined
6913 + * in the JEDEC standard. All information up to
6914 + * primary_extended_query is standard among all manufactures
6915 + * with CFI enabled devices.
6919 + int num_erase_blocks; /* Number of sector defs. */
6921 + unsigned long sector_size; /* byte size of sector */
6922 + int num_sectors; /* Num sectors of this size */
6923 + } erase_block[8]; /* Max of 256, but 8 is good */
6926 +/* Standard Boolean declarations */
6930 +/* Define different type of flash */
6931 +#define FLASH_UNDEFINED 0
6932 +#define FLASH_AMD 1
6933 +#define FLASH_INTEL 2
6934 +#define FLASH_SST 3
6936 +/* Command codes for the flash_command routine */
6937 +#define FLASH_RESET 0 /* reset to read mode */
6938 +#define FLASH_READ_ID 1 /* read device ID */
6939 +#define FLASH_CFIQUERY 2 /* CFI query */
6940 +#define FLASH_UB 3 /* go into unlock bypass mode */
6941 +#define FLASH_PROG 4 /* program a word */
6942 +#define FLASH_UBRESET 5 /* reset to read mode from unlock bypass mode */
6943 +#define FLASH_SERASE 6 /* sector erase */
6945 +/* Return codes from flash_status */
6946 +#define STATUS_READY 0 /* ready for action */
6947 +#define STATUS_TIMEOUT 1 /* operation timed out */
6949 +/* A list of AMD compatible device ID's - add others as needed */
6950 +#define ID_AM29DL800T 0x224A
6951 +#define ID_AM29DL800B 0x22CB
6952 +#define ID_AM29LV800T 0x22DA
6953 +#define ID_AM29LV800B 0x225B
6954 +#define ID_AM29LV400B 0x22BA
6956 +#define ID_AM29LV160B 0x2249
6957 +#define ID_AM29LV160T 0x22C4
6959 +#define ID_AM29LV320T 0x22F6
6960 +#define ID_MX29LV320AT 0x22A7
6961 +#define ID_AM29LV320B 0x22F9
6962 +#define ID_MX29LV320AB 0x22A8
6964 +#define ID_AM29LV320M 0x227E
6965 +#define ID_AM29LV320MB 0x2200
6966 +#define ID_AM29LV320MT 0x2201
6968 +#define ID_SST39VF1601 0x234B
6969 +#define ID_SST39VF3201 0x235B
6971 +/* A list of Intel compatible device ID's - add others as needed */
6972 +#define ID_I28F160C3T 0x88C2
6973 +#define ID_I28F160C3B 0x88C3
6974 +#define ID_I28F320C3T 0x88C4
6975 +#define ID_I28F320C3B 0x88C5
6977 +extern byte flash_init(void);
6978 +extern int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes);
6979 +extern int flash_read_buf(WORD sector, int offset, byte *buffer, int numbytes);
6980 +extern byte flash_sector_erase_int(WORD sector);
6981 +extern int flash_get_numsectors(void);
6982 +extern int flash_get_sector_size(WORD sector);
6983 +extern int flash_get_total_size(void);
6984 +extern unsigned char *flash_get_memptr(WORD sector);
6985 +extern int flash_get_blk(int addr);
6988 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c
6989 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c 1970-01-01 01:00:00.000000000 +0100
6990 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c 2006-07-25 10:58:52.000000000 +0200
6994 + Copyright 2002 Broadcom Corp. All Rights Reserved.
6996 + This program is free software; you can distribute it and/or modify it
6997 + under the terms of the GNU General Public License (Version 2) as
6998 + published by the Free Software Foundation.
7000 + This program is distributed in the hope it will be useful, but WITHOUT
7001 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7002 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7005 + You should have received a copy of the GNU General Public License along
7006 + with this program; if not, write to the Free Software Foundation, Inc.,
7007 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7011 + * Interrupt control functions for Broadcom 963xx MIPS boards
7014 +#include <asm/atomic.h>
7016 +#include <linux/delay.h>
7017 +#include <linux/init.h>
7018 +#include <linux/ioport.h>
7019 +#include <linux/irq.h>
7020 +#include <linux/interrupt.h>
7021 +#include <linux/kernel.h>
7022 +#include <linux/slab.h>
7023 +#include <linux/module.h>
7024 +#include <linux/spinlock.h>
7026 +#include <asm/irq.h>
7027 +#include <asm/mipsregs.h>
7028 +#include <asm/addrspace.h>
7029 +#include <asm/signal.h>
7030 +#include <bcm_map_part.h>
7031 +#include <bcm_intr.h>
7033 +static DEFINE_SPINLOCK(irq_lock);
7035 +static void irq_dispatch_int(struct pt_regs *regs)
7037 + unsigned int pendingIrqs;
7038 + static unsigned int irqBit;
7039 + static unsigned int isrNumber = 31;
7041 + pendingIrqs = PERF->IrqStatus & PERF->IrqMask;
7042 + if (!pendingIrqs) {
7049 + if (isrNumber == 32) {
7053 + if (pendingIrqs & irqBit) {
7054 + PERF->IrqMask &= ~irqBit; // mask
7055 + do_IRQ(isrNumber + INTERNAL_ISR_TABLE_OFFSET, regs);
7061 +static void irq_dispatch_ext(uint32 irq, struct pt_regs *regs)
7063 + if (!(PERF->ExtIrqCfg & (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)))) {
7064 + printk("**** Ext IRQ mask. Should not dispatch ****\n");
7066 + /* disable and clear interrupt in the controller */
7067 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7068 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7069 + do_IRQ(irq, regs);
7072 +void brcm_irq_dispatch(struct pt_regs *regs)
7075 + while((cause = (read_c0_cause()& CAUSEF_IP))) {
7076 + if (cause & CAUSEF_IP7)
7077 + do_IRQ(MIPS_TIMER_INT, regs);
7078 + else if (cause & CAUSEF_IP2)
7079 + irq_dispatch_int(regs);
7080 + else if (cause & CAUSEF_IP3)
7081 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7082 + else if (cause & CAUSEF_IP4)
7083 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7084 + else if (cause & CAUSEF_IP5)
7085 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7086 + else if (cause & CAUSEF_IP6)
7087 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7089 + spin_lock_irq(&irq_lock);
7093 +void plat_irq_dispatch(struct pt_regs *regs)
7096 + while((cause = (read_c0_cause()& CAUSEF_IP))) {
7097 + if (cause & CAUSEF_IP7)
7098 + do_IRQ(MIPS_TIMER_INT, regs);
7099 + else if (cause & CAUSEF_IP2)
7100 + irq_dispatch_int(regs);
7101 + else if (cause & CAUSEF_IP3)
7102 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7103 + else if (cause & CAUSEF_IP4)
7104 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7105 + else if (cause & CAUSEF_IP5)
7106 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7107 + else if (cause & CAUSEF_IP6)
7108 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7110 + spin_lock_irq(&irq_lock);
7115 +void enable_brcm_irq(unsigned int irq)
7117 + unsigned long flags;
7119 + local_irq_save(flags);
7120 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7121 + PERF->IrqMask |= (1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7123 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7124 + /* enable and clear interrupt in the controller */
7125 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7126 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7128 + local_irq_restore(flags);
7131 +void disable_brcm_irq(unsigned int irq)
7133 + unsigned long flags;
7135 + local_irq_save(flags);
7136 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7137 + PERF->IrqMask &= ~(1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7139 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7140 + /* disable interrupt in the controller */
7141 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7143 + local_irq_restore(flags);
7146 +void ack_brcm_irq(unsigned int irq)
7148 + /* Already done in brcm_irq_dispatch */
7151 +unsigned int startup_brcm_irq(unsigned int irq)
7153 + enable_brcm_irq(irq);
7155 + return 0; /* never anything pending */
7158 +unsigned int startup_brcm_none(unsigned int irq)
7163 +void end_brcm_irq(unsigned int irq)
7165 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
7166 + enable_brcm_irq(irq);
7169 +void end_brcm_none(unsigned int irq)
7173 +#define ALLINTS_NOTIMER (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
7175 +static void __init brcm_irq_setup(void)
7177 + extern asmlinkage void brcmIRQ(void);
7179 + clear_c0_status(ST0_BEV);
7180 + set_except_vector(0, brcmIRQ);
7181 + change_c0_status(ST0_IM, ALLINTS_NOTIMER);
7183 +#ifdef CONFIG_REMOTE_DEBUG
7188 +static struct hw_interrupt_type brcm_irq_type = {
7189 + .typename = "MIPS",
7190 + .startup = startup_brcm_irq,
7191 + .shutdown = disable_brcm_irq,
7192 + .enable = enable_brcm_irq,
7193 + .disable = disable_brcm_irq,
7194 + .ack = ack_brcm_irq,
7195 + .end = end_brcm_irq,
7196 + .set_affinity = NULL
7199 +static struct hw_interrupt_type brcm_irq_no_end_type = {
7200 + .typename = "MIPS",
7201 + .startup = startup_brcm_none,
7202 + .shutdown = disable_brcm_irq,
7203 + .enable = enable_brcm_irq,
7204 + .disable = disable_brcm_irq,
7205 + .ack = ack_brcm_irq,
7206 + .end = end_brcm_none,
7207 + .set_affinity = NULL
7210 +void __init arch_init_irq(void)
7214 + for (i = 0; i < NR_IRQS; i++) {
7215 + irq_desc[i].status = IRQ_DISABLED;
7216 + irq_desc[i].action = 0;
7217 + irq_desc[i].depth = 1;
7218 + irq_desc[i].handler = &brcm_irq_type;
7224 +int request_external_irq(unsigned int irq,
7225 + FN_HANDLER handler,
7226 + unsigned long irqflags,
7227 + const char * devname,
7230 + unsigned long flags;
7232 + local_irq_save(flags);
7234 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT)); // Clear
7235 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)); // Mask
7236 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_INSENS_SHFT)); // Edge insesnsitive
7237 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_LEVEL_SHFT)); // Level triggered
7238 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_SENSE_SHFT)); // Low level
7240 + local_irq_restore(flags);
7242 + return( request_irq(irq, handler, irqflags, devname, dev_id) );
7245 +/* VxWorks compatibility function(s). */
7247 +unsigned int BcmHalMapInterrupt(FN_HANDLER pfunc, unsigned int param,
7248 + unsigned int interruptId)
7253 + devname = kmalloc(16, GFP_KERNEL);
7255 + sprintf( devname, "brcm_%d", interruptId );
7257 + /* Set the IRQ description to not automatically enable the interrupt at
7258 + * the end of an ISR. The driver that handles the interrupt must
7259 + * explicitly call BcmHalInterruptEnable or enable_brcm_irq. This behavior
7260 + * is consistent with interrupt handling on VxWorks.
7262 + irq_desc[interruptId].handler = &brcm_irq_no_end_type;
7264 + if( interruptId >= INTERNAL_ISR_TABLE_OFFSET )
7266 + nRet = request_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7267 + devname, (void *) param );
7269 + else if (interruptId >= INTERRUPT_ID_EXTERNAL_0 && interruptId <= INTERRUPT_ID_EXTERNAL_3)
7271 + nRet = request_external_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7272 + devname, (void *) param );
7279 +/* Debug function. */
7281 +void dump_intr_regs(void)
7283 + printk("PERF->ExtIrqCfg [%08x]\n", *(&(PERF->ExtIrqCfg)));
7286 +EXPORT_SYMBOL(enable_brcm_irq);
7287 +EXPORT_SYMBOL(disable_brcm_irq);
7288 +EXPORT_SYMBOL(request_external_irq);
7289 +EXPORT_SYMBOL(BcmHalMapInterrupt);
7291 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig
7292 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
7293 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig 2006-07-13 19:11:33.000000000 +0200
7295 +# Kernel and Driver configuration for Broadcom Commengine ADSL board
7297 + prompt "Broadcom Commengine ADSL board"
7298 + depends on MIPS_BRCM
7301 + Select different Broadcom ADSL board
7304 + bool "96338 ADSL board"
7305 + select DMA_NONCOHERENT
7309 + bool "96345 ADSL board"
7310 + select DMA_NONCOHERENT
7314 + bool "96348 ADSL board"
7315 + select DMA_NONCOHERENT
7321 + bool "Support for Broadcom Board"
7322 + depends on BCM96338 || BCM96345 || BCM96348
7325 + bool "Support for Serial Port"
7326 + depends on BCM96338 || BCM96345 || BCM96348
7329 + tristate "Support for Ethernet"
7330 + depends on BCM96338 || BCM96345 || BCM96348
7333 + tristate "Support for USB"
7334 + depends on BCM96338 || BCM96345 || BCM96348
7337 + tristate "Support for Wireless"
7338 + depends on BCM96338 || BCM96345 || BCM96348
7341 + bool "Support for PCI"
7342 + depends on BCM96338 || BCM96345 || BCM96348
7346 + tristate "Support for ATM"
7347 + depends on BCM96338 || BCM96345 || BCM96348
7350 + tristate "Support for ATM Diagnostic"
7351 + depends on BCM96338 || BCM96345 || BCM96348
7354 + tristate "Support for ADSL"
7355 + depends on BCM96338 || BCM96345 || BCM96348
7357 +config BCM_ENDPOINT
7358 + tristate "Support for VOICE"
7359 + depends on BCM96338 || BCM96345 || BCM96348
7362 + tristate "Support for PROCFS"
7363 + depends on BCM96338 || BCM96345 || BCM96348
7366 + tristate "Support for VDSL"
7367 + depends on BCM96338 || BCM96345 || BCM96348
7369 +config BCM_SECURITY
7370 + tristate "Support for SECURITY"
7371 + depends on BCM96338 || BCM96345 || BCM96348
7374 + tristate "Support for HPNA"
7375 + depends on BCM96338 || BCM96345 || BCM96348
7377 +config BCM_BOARD_IMPL
7378 + int "Implementation index for ADSL Board"
7379 + depends on BCM96338 || BCM96345 || BCM96348
7381 +config BCM_SERIAL_IMPL
7382 + int "Implementation index for Serial"
7383 + depends on BCM96338 || BCM96345 || BCM96348
7385 +config BCM_ENET_IMPL
7386 + int "Implementation index for Ethernet"
7387 + depends on BCM96338 || BCM96345 || BCM96348
7389 +config BCM_USB_IMPL
7390 + int "Implementation index for USB"
7391 + depends on BCM96338 || BCM96345 || BCM96348
7393 +config BCM_WLAN_IMPL
7394 + int "Implementation index for WIRELESS"
7395 + depends on BCM96338 || BCM96345 || BCM96348
7397 +config BCM_ATMAPI_IMPL
7398 + int "Implementation index for ATM"
7399 + depends on BCM96338 || BCM96345 || BCM96348
7401 +config BCM_ATMTEST_IMPL
7402 + int "Implementation index for ATM Diagnostic"
7403 + depends on BCM96338 || BCM96345 || BCM96348
7405 +config BCM_BLAA_IMPL
7406 + int "Implementation index for BLAA"
7407 + depends on BCM96338 || BCM96345 || BCM96348
7409 +config BCM_ADSL_IMPL
7410 + int "Implementation index for ADSL"
7411 + depends on BCM96338 || BCM96345 || BCM96348
7413 +config BCM_ENDPOINT_IMPL
7414 + int "Implementation index for VOICE"
7415 + depends on BCM96338 || BCM96345 || BCM96348
7417 +config BCM_PROCFS_IMPL
7418 + int "Implementation index for PROCFS"
7419 + depends on BCM96338 || BCM96345 || BCM96348
7421 +config BCM_VDSL_IMPL
7422 + int "Implementation index for VDSL"
7423 + depends on BCM96338 || BCM96345 || BCM96348
7425 +config BCM_SECURITY_IMPL
7426 + int "Implementation index for SECURITY"
7427 + depends on BCM96338 || BCM96345 || BCM96348
7429 +config BCM_HPNA_IMPL
7430 + int "Implementation index for HPNA"
7431 + depends on BCM96338 || BCM96345 || BCM96348
7434 + prompt "Root File System"
7435 + depends on MIPS_BRCM
7436 + default ROOTFS_SQUASHFS
7438 + Select root file system on the board flash.
7440 +config ROOTFS_SQUASHFS
7442 +config ROOTFS_CRAMFS
7444 +config ROOTFS_JFFS2
7451 +config ROOT_FLASHFS
7452 + string "flash partition"
7453 + depends on ROOTFS_SQUASHFS || ROOTFS_CRAMFS || ROOTFS_JFFS2
7454 + default "root=31:0 ro noinitrd" if ROOTFS_SQUASHFS = y || ROOTFS_CRAMFS = y
7455 + default "root=31:2 ro noinitrd" if ROOTFS_JFFS2 = y
7457 + This is the root file system partition on flash memory
7459 +config ROOT_NFS_DIR
7460 + string "NFS server path"
7461 + depends on ROOTFS_NFS
7462 + default "/opt/bcm96338/targets/96338R/fs" if BCM96338 = y
7463 + default "/opt/bcm96345/targets/96345R/fs" if BCM96345 = y
7464 + default "/opt/bcm96348/targets/96348R/fs" if BCM96348 = y
7466 + This is the path of NFS server (host system)
7467 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile
7468 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile 1970-01-01 01:00:00.000000000 +0100
7469 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile 2006-07-13 19:11:33.000000000 +0200
7472 +# Makefile for generic Broadcom MIPS boards
7474 +# Copyright (C) 2004 Broadcom Corporation
7476 +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
7478 +SRCBASE := $(TOPDIR)
7479 +EXTRA_CFLAGS += -I$(SRCBASE)/include
7480 +#EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH) -DDBG
7481 +EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH)
7484 +ifeq "$(ADSL)" "ANNEX_B"
7485 +EXTRA_CFLAGS += -DADSL_ANNEXB
7487 +ifeq "$(ADSL)" "SADSL"
7488 +EXTRA_CFLAGS += -DADSL_SADSL
7490 +ifeq "$(ADSL)" "ANNEX_C"
7491 +EXTRA_CFLAGS += -DADSL_ANNEXC
7494 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c
7495 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c 1970-01-01 01:00:00.000000000 +0100
7496 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c 2006-07-13 19:11:33.000000000 +0200
7500 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7502 + This program is free software; you can distribute it and/or modify it
7503 + under the terms of the GNU General Public License (Version 2) as
7504 + published by the Free Software Foundation.
7506 + This program is distributed in the hope it will be useful, but WITHOUT
7507 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7508 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7511 + You should have received a copy of the GNU General Public License along
7512 + with this program; if not, write to the Free Software Foundation, Inc.,
7513 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7517 + * prom.c: PROM library initialization code.
7520 +#include <linux/init.h>
7521 +#include <linux/mm.h>
7522 +#include <linux/sched.h>
7523 +#include <linux/bootmem.h>
7524 +#include <linux/blkdev.h>
7525 +#include <asm/addrspace.h>
7526 +#include <asm/bootinfo.h>
7527 +#include <asm/cpu.h>
7528 +#include <asm/time.h>
7530 +#include <bcm_map_part.h>
7532 +#include "boardparms.h"
7533 +#include "softdsl/AdslCoreDefs.h"
7536 +extern int do_syslog(int, char *, int);
7537 +extern void serial_init(void);
7538 +extern void __init InitNvramInfo( void );
7539 +/*extern void kerSysFlashInit( void );*/
7540 +/*extern unsigned long get_nvram_start_addr(void);*/
7541 +void __init create_root_nfs_cmdline( char *cmdline );
7543 +#if defined(CONFIG_BCM96338)
7544 +#define CPU_CLOCK 240000000
7545 +#define MACH_BCM MACH_BCM96338
7547 +#if defined(CONFIG_BCM96345)
7548 +#define CPU_CLOCK 140000000
7549 +#define MACH_BCM MACH_BCM96345
7551 +#if defined(CONFIG_BCM96348)
7552 +void __init calculateCpuSpeed(void);
7553 +static unsigned long cpu_speed;
7554 +#define CPU_CLOCK cpu_speed
7555 +#define MACH_BCM MACH_BCM96348
7558 +const char *get_system_type(void)
7560 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7562 + return( pNvramData->szBoardId );*/
7563 + return "brcm63xx";
7566 +unsigned long getMemorySize(void)
7568 + unsigned long ulSdramType = BOARD_SDRAM_TYPE;
7570 + unsigned long ulSdramSize;
7572 + switch( ulSdramType )
7574 + case BP_MEMORY_16MB_1_CHIP:
7575 + case BP_MEMORY_16MB_2_CHIP:
7576 + ulSdramSize = 16 * 1024 * 1024;
7578 + case BP_MEMORY_32MB_1_CHIP:
7579 + case BP_MEMORY_32MB_2_CHIP:
7580 + ulSdramSize = 32 * 1024 * 1024;
7582 + case BP_MEMORY_64MB_2_CHIP:
7583 + ulSdramSize = 64 * 1024 * 1024;
7586 + ulSdramSize = 8 * 1024 * 1024;
7590 + return ulSdramSize;
7593 +/* --------------------------------------------------------------------------
7595 + -------------------------------------------------------------------------- */
7596 +void __init prom_init(void)
7598 + extern ulong r4k_interval;
7602 + /*kerSysFlashInit();*/
7604 + do_syslog(8, NULL, 8);
7606 + printk( "%s prom init\n", get_system_type() );
7608 + PERF->IrqMask = 0;
7610 + arcs_cmdline[0] = '\0';
7612 +#if defined(CONFIG_ROOT_NFS)
7613 + create_root_nfs_cmdline( arcs_cmdline );
7615 +#elif defined(CONFIG_ROOT_FLASHFS)
7616 + strcpy(arcs_cmdline, CONFIG_ROOT_FLASHFS);
7619 + add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7621 +#if defined(CONFIG_BCM96348)
7622 + calculateCpuSpeed();
7624 + /* Count register increments every other clock */
7625 + r4k_interval = CPU_CLOCK / HZ / 2;
7626 + mips_hpt_frequency = CPU_CLOCK / 2;
7628 + mips_machgroup = MACH_GROUP_BRCM;
7629 + mips_machtype = MACH_BCM;
7632 +/* --------------------------------------------------------------------------
7633 + Name: prom_free_prom_memory
7635 + -------------------------------------------------------------------------- */
7636 +void __init prom_free_prom_memory(void)
7642 +#if defined(CONFIG_ROOT_NFS)
7643 +/* This function reads in a line that looks something like this:
7646 + * CFE bootline=bcmEnet(0,0)host:vmlinux e=192.169.0.100:ffffff00 h=192.169.0.1
7649 + * and retuns in the cmdline parameter some that looks like this:
7651 + * CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/opt/targets/96345R/fs
7652 + * ip=192.168.0.100:192.168.0.1::255.255.255.0::eth0:off rw"
7654 +#define BOOT_LINE_ADDR 0x0
7655 +#define HEXDIGIT(d) ((d >= '0' && d <= '9') ? (d - '0') : ((d | 0x20) - 'W'))
7656 +#define HEXBYTE(b) (HEXDIGIT((b)[0]) << 4) + HEXDIGIT((b)[1])
7657 +extern unsigned long get_nvram_start_addr(void);
7659 +void __init create_root_nfs_cmdline( char *cmdline )
7661 + char root_nfs_cl[] = "root=/dev/nfs nfsroot=%s:" CONFIG_ROOT_NFS_DIR
7662 + " ip=%s:%s::%s::eth0:off rw";
7664 + char *localip = NULL;
7665 + char *hostip = NULL;
7666 + char mask[16] = "";
7667 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7668 + char bootline[128] = "";
7669 + char *p = bootline;
7671 + memcpy(bootline, pNvramData->szBootline, sizeof(bootline));
7674 + if( p[0] == 'e' && p[1] == '=' )
7676 + /* Found local ip address */
7679 + while( *p && *p != ' ' && *p != ':' )
7683 + /* Found network mask (eg FFFFFF00 */
7685 + sprintf( mask, "%u.%u.%u.%u", HEXBYTE(p), HEXBYTE(p + 2),
7686 + HEXBYTE(p + 4), HEXBYTE(p + 6) );
7689 + else if( *p == ' ' )
7692 + else if( p[0] == 'h' && p[1] == '=' )
7694 + /* Found host ip address */
7697 + while( *p && *p != ' ' )
7706 + if( localip && hostip )
7707 + sprintf( cmdline, root_nfs_cl, hostip, localip, hostip, mask );
7712 +#if defined(CONFIG_BCM96348)
7713 +/* *********************************************************************
7714 + * calculateCpuSpeed()
7715 + * Calculate the BCM6348 CPU speed by reading the PLL strap register
7716 + * and applying the following formula:
7717 + * cpu_clk = (.25 * 64MHz freq) * (N1 + 1) * (N2 + 2) / (M1_CPU + 1)
7718 + * Input parameters:
7722 + ********************************************************************* */
7723 +void __init calculateCpuSpeed(void)
7725 + UINT32 pllStrap = PERF->PllStrap;
7726 + int n1 = (pllStrap & PLL_N1_MASK) >> PLL_N1_SHFT;
7727 + int n2 = (pllStrap & PLL_N2_MASK) >> PLL_N2_SHFT;
7728 + int m1cpu = (pllStrap & PLL_M1_CPU_MASK) >> PLL_M1_CPU_SHFT;
7730 + cpu_speed = (16 * (n1 + 1) * (n2 + 2) / (m1cpu + 1)) * 1000000;
7734 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c
7735 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c 1970-01-01 01:00:00.000000000 +0100
7736 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c 2006-07-25 10:51:12.000000000 +0200
7740 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7742 + This program is free software; you can distribute it and/or modify it
7743 + under the terms of the GNU General Public License (Version 2) as
7744 + published by the Free Software Foundation.
7746 + This program is distributed in the hope it will be useful, but WITHOUT
7747 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7748 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7751 + You should have received a copy of the GNU General Public License along
7752 + with this program; if not, write to the Free Software Foundation, Inc.,
7753 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7757 + * Broadcom bcm63xx serial port initialization, also prepare for printk
7758 + * by registering with console_init
7762 +#include <linux/config.h>
7763 +#include <linux/init.h>
7764 +#include <linux/interrupt.h>
7765 +#include <linux/kernel.h>
7766 +#include <linux/types.h>
7767 +#include <linux/console.h>
7768 +#include <linux/sched.h>
7770 +#include <asm/addrspace.h>
7771 +#include <asm/irq.h>
7772 +#include <asm/reboot.h>
7773 +#include <asm/gdb-stub.h>
7774 +#include <asm/mc146818rtc.h>
7776 +#include <bcm_map_part.h>
7779 +#define SER63XX_DEFAULT_BAUD 115200
7780 +#define BD_BCM63XX_TIMER_CLOCK_INPUT (FPERIPH)
7781 +#define stUart ((volatile Uart * const) UART_BASE)
7783 +// Transmit interrupts
7784 +#define TXINT (TXFIFOEMT | TXUNDERR | TXOVFERR)
7785 +// Receive interrupts
7786 +#define RXINT (RXFIFONE | RXOVFERR)
7788 +/* --------------------------------------------------------------------------
7790 + Purpose: Initalize the UART
7791 +-------------------------------------------------------------------------- */
7792 +void __init serial_init(void)
7794 + UINT32 tmpVal = SER63XX_DEFAULT_BAUD;
7795 + ULONG clockFreqHz;
7797 +#if defined(CONFIG_BCM96345)
7798 + // Make sure clock is ticking
7799 + PERF->blkEnables |= UART_CLK_EN;
7802 + /* Dissable channel's receiver and transmitter. */
7803 + stUart->control &= ~(BRGEN|TXEN|RXEN);
7805 + /*--------------------------------------------------------------------*/
7806 + /* Write the table value to the clock select register. */
7807 + /* DPullen - this is the equation to use: */
7808 + /* value = clockFreqHz / baud / 32-1; */
7809 + /* (snmod) Actually you should also take into account any necessary */
7810 + /* rounding. Divide by 16, look at lsb, if 0, divide by 2 */
7811 + /* and subtract 1. If 1, just divide by 2 */
7812 + /*--------------------------------------------------------------------*/
7813 + clockFreqHz = BD_BCM63XX_TIMER_CLOCK_INPUT;
7814 + tmpVal = (clockFreqHz / tmpVal) / 16;
7815 + if( tmpVal & 0x01 )
7816 + tmpVal /= 2; //Rounding up, so sub is already accounted for
7818 + tmpVal = (tmpVal / 2) - 1; // Rounding down so we must sub 1
7819 + stUart->baudword = tmpVal;
7821 + /* Finally, re-enable the transmitter and receiver. */
7822 + stUart->control |= (BRGEN|TXEN|RXEN);
7824 + stUart->config = (BITS8SYM | ONESTOP);
7825 + // Set the FIFO interrupt depth ... stUart->fifocfg = 0xAA;
7826 + stUart->fifoctl = RSTTXFIFOS | RSTRXFIFOS;
7827 + stUart->intMask = 0;
7828 + stUart->intMask = RXINT | TXINT;
7833 + * Output a character to the UART
7835 +void prom_putc(char c)
7837 + /* Wait for Tx uffer to empty */
7838 + while (! (READ16(stUart->intStatus) & TXFIFOEMT));
7839 + /* Send character */
7844 + * Write a string to the UART
7846 +void prom_puts(const char *s)
7857 +/* prom_getc_nowait()
7858 + * Returns a character from the UART
7859 + * Returns -1 if no characters available or corrupted
7861 +int prom_getc_nowait(void)
7866 + uStatus = READ16(stUart->intStatus);
7868 + if (uStatus & RXFIFONE) { /* Do we have a character? */
7869 + cData = READ16(stUart->Data) & 0xff; /* Read character */
7870 + if (uStatus & (RXFRAMERR | RXPARERR)) { /* If we got an error, throw it away */
7879 + * Returns a charcter from the serial port
7880 + * Will block until it receives a valid character
7882 +char prom_getc(void)
7886 + /* Loop until we get a valid character */
7887 + while(cData == -1) {
7888 + cData = prom_getc_nowait();
7890 + return (char) cData;
7894 + * Returns 0 if no characters available
7896 +int prom_testc(void)
7900 + uStatus = READ16(stUart->intStatus);
7902 + return (uStatus & RXFIFONE);
7905 +#if defined (CONFIG_REMOTE_DEBUG)
7906 +/* Prevent other code from writing to the serial port */
7907 +void _putc(char c) { }
7908 +void _puts(const char *ptr) { }
7910 +/* Low level outputs call prom routines */
7911 +void _putc(char c) {
7914 +void _puts(const char *ptr) {
7918 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c
7919 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c 1970-01-01 01:00:00.000000000 +0100
7920 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c 2006-07-13 19:11:33.000000000 +0200
7924 + Copyright 2002 Broadcom Corp. All Rights Reserved.
7926 + This program is free software; you can distribute it and/or modify it
7927 + under the terms of the GNU General Public License (Version 2) as
7928 + published by the Free Software Foundation.
7930 + This program is distributed in the hope it will be useful, but WITHOUT
7931 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7932 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7935 + You should have received a copy of the GNU General Public License along
7936 + with this program; if not, write to the Free Software Foundation, Inc.,
7937 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7941 + * Generic setup routines for Broadcom 963xx MIPS boards
7944 +#include <linux/config.h>
7945 +#include <linux/init.h>
7946 +#include <linux/interrupt.h>
7947 +#include <linux/kernel.h>
7948 +#include <linux/kdev_t.h>
7949 +#include <linux/types.h>
7950 +#include <linux/console.h>
7951 +#include <linux/sched.h>
7952 +#include <linux/mm.h>
7953 +#include <linux/slab.h>
7954 +#include <linux/module.h>
7955 +#include <linux/pm.h>
7957 +#include <asm/addrspace.h>
7958 +#include <asm/bcache.h>
7959 +#include <asm/irq.h>
7960 +#include <asm/time.h>
7961 +#include <asm/reboot.h>
7962 +#include <asm/gdb-stub.h>
7964 +extern void brcm_timer_setup(struct irqaction *irq);
7965 +extern unsigned long getMemorySize(void);
7967 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
7968 +#include <linux/pci.h>
7969 +#include <linux/delay.h>
7970 +#include <bcm_map_part.h>
7971 +#include <bcmpci.h>
7973 +static volatile MpiRegisters * mpi = (MpiRegisters *)(MPI_BASE);
7976 +/* This function should be in a board specific directory. For now,
7977 + * assume that all boards that include this file use a Broadcom chip
7978 + * with a soft reset bit in the PLL control register.
7980 +static void brcm_machine_restart(char *command)
7982 + const unsigned long ulSoftReset = 0x00000001;
7983 + unsigned long *pulPllCtrl = (unsigned long *) 0xfffe0008;
7984 + *pulPllCtrl |= ulSoftReset;
7987 +static void brcm_machine_halt(void)
7989 + printk("System halted\n");
7993 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
7995 +static void mpi_SetLocalPciConfigReg(uint32 reg, uint32 value)
7997 + /* write index then value */
7998 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
7999 + mpi->pcicfgdata = value;
8002 +static uint32 mpi_GetLocalPciConfigReg(uint32 reg)
8004 + /* write index then get value */
8005 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
8006 + return mpi->pcicfgdata;
8010 + * mpi_ResetPcCard: Set/Reset the PcCard
8012 +static void mpi_ResetPcCard(int cardtype, BOOL bReset)
8014 + if (cardtype == MPI_CARDTYPE_NONE) {
8018 + if (cardtype == MPI_CARDTYPE_CARDBUS) {
8019 + bReset = ! bReset;
8023 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8025 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 | PCCARD_CARD_RESET);
8030 + * mpi_ConfigCs: Configure an MPI/EBI chip select
8032 +static void mpi_ConfigCs(uint32 cs, uint32 base, uint32 size, uint32 flags)
8034 + mpi->cs[cs].base = ((base & 0x1FFFFFFF) | size);
8035 + mpi->cs[cs].config = flags;
8039 + * mpi_InitPcmciaSpace
8041 +static void mpi_InitPcmciaSpace(void)
8043 + // ChipSelect 4 controls PCMCIA Memory accesses
8044 + mpi_ConfigCs(PCMCIA_COMMON_BASE, pcmciaMem, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8045 + // ChipSelect 5 controls PCMCIA Attribute accesses
8046 + mpi_ConfigCs(PCMCIA_ATTRIBUTE_BASE, pcmciaAttr, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8047 + // ChipSelect 6 controls PCMCIA I/O accesses
8048 + mpi_ConfigCs(PCMCIA_IO_BASE, pcmciaIo, EBI_SIZE_64K, (EBI_WORD_WIDE|EBI_ENABLE));
8050 + mpi->pcmcia_cntl2 = ((PCMCIA_ATTR_ACTIVE << RW_ACTIVE_CNT_BIT) |
8051 + (PCMCIA_ATTR_INACTIVE << INACTIVE_CNT_BIT) |
8052 + (PCMCIA_ATTR_CE_SETUP << CE_SETUP_CNT_BIT) |
8053 + (PCMCIA_ATTR_CE_HOLD << CE_HOLD_CNT_BIT));
8055 + mpi->pcmcia_cntl2 |= (PCMCIA_HALFWORD_EN | PCMCIA_BYTESWAP_DIS);
8059 + * cardtype_vcc_detect: PC Card's card detect and voltage sense connection
8061 + * CD1#/ CD2#/ VS1#/ VS2#/ Card Initial Vcc
8062 + * CCD1# CCD2# CVS1 CVS2 Type
8064 + * GND GND open open 16-bit 5 vdc
8066 + * GND GND GND open 16-bit 3.3 vdc
8068 + * GND GND open GND 16-bit x.x vdc
8070 + * GND GND GND GND 16-bit 3.3 & x.x vdc
8072 + *====================================================================
8074 + * CVS1 GND CCD1# open CardBus 3.3 vdc
8076 + * GND CVS2 open CCD2# CardBus x.x vdc
8078 + * GND CVS1 CCD2# open CardBus y.y vdc
8080 + * GND CVS2 GND CCD2# CardBus 3.3 & x.x vdc
8082 + * CVS2 GND open CCD1# CardBus x.x & y.y vdc
8084 + * GND CVS1 CCD2# open CardBus 3.3, x.x & y.y vdc
8087 +static int cardtype_vcc_detect(void)
8092 + cardtype = MPI_CARDTYPE_NONE;
8093 + mpi->pcmcia_cntl1 = 0x0000A000; // Turn on the output enables and drive
8094 + // the CVS pins to 0.
8095 + data32 = mpi->pcmcia_cntl1;
8096 + switch (data32 & 0x00000003) // Test CD1# and CD2#, see if card is plugged in.
8098 + case 0x00000003: // No Card is in the slot.
8099 + printk("mpi: No Card is in the PCMCIA slot\n");
8102 + case 0x00000002: // Partial insertion, No CD2#.
8103 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD2 signal\n");
8106 + case 0x00000001: // Partial insertion, No CD1#.
8107 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD1 signal\n");
8111 + mpi->pcmcia_cntl1 = 0x0000A0C0; // Turn off the CVS output enables and
8112 + // float the CVS pins.
8114 + data32 = mpi->pcmcia_cntl1;
8115 + // Read the Register.
8116 + switch (data32 & 0x0000000C) // See what is on the CVS pins.
8118 + case 0x00000000: // CVS1 and CVS2 are tied to ground, only 1 option.
8119 + printk("mpi: Detected 3.3 & x.x 16-bit PCMCIA card\n");
8120 + cardtype = MPI_CARDTYPE_PCMCIA;
8123 + case 0x00000004: // CVS1 is open or tied to CCD1/CCD2 and CVS2 is tied to ground.
8124 + // 2 valid voltage options.
8125 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8127 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8128 + // This is not a valid combination.
8129 + printk("mpi: Unknown card plugged into slot\n");
8132 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8133 + mpi->pcmcia_cntl1 = 0x0000A080; // Drive CVS1 to a 0.
8135 + data32 = mpi->pcmcia_cntl1;
8136 + if (data32 & 0x00000002) { // CCD2 is tied to CVS2, not valid.
8137 + printk("mpi: Unknown card plugged into slot\n");
8138 + } else { // CCD2 is tied to CVS1.
8139 + printk("mpi: Detected 3.3, x.x and y.y Cardbus card\n");
8140 + cardtype = MPI_CARDTYPE_CARDBUS;
8144 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8145 + // This is not a valid combination.
8146 + printk("mpi: Unknown card plugged into slot\n");
8149 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8150 + printk("mpi: Detected x.x vdc 16-bit PCMCIA card\n");
8151 + cardtype = MPI_CARDTYPE_PCMCIA;
8156 + case 0x00000008: // CVS2 is open or tied to CCD1/CCD2 and CVS1 is tied to ground.
8157 + // 2 valid voltage options.
8158 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8160 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8161 + // This is not a valid combination.
8162 + printk("mpi: Unknown card plugged into slot\n");
8165 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8166 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8168 + data32 = mpi->pcmcia_cntl1;
8169 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1, not valid.
8170 + printk("mpi: Unknown card plugged into slot\n");
8171 + } else {// CCD2 is tied to CVS2.
8172 + printk("mpi: Detected 3.3 and x.x Cardbus card\n");
8173 + cardtype = MPI_CARDTYPE_CARDBUS;
8177 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8178 + // This is not a valid combination.
8179 + printk("mpi: Unknown card plugged into slot\n");
8182 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8183 + cardtype = MPI_CARDTYPE_PCMCIA;
8184 + printk("mpi: Detected 3.3 vdc 16-bit PCMCIA card\n");
8189 + case 0x0000000C: // CVS1 and CVS2 are open or tied to CCD1/CCD2.
8190 + // 5 valid voltage options.
8192 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8194 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8195 + // This is not a valid combination.
8196 + printk("mpi: Unknown card plugged into slot\n");
8199 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8200 + // CCD1 is tied to ground.
8201 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8203 + data32 = mpi->pcmcia_cntl1;
8204 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1.
8205 + printk("mpi: Detected y.y vdc Cardbus card\n");
8206 + } else { // CCD2 is tied to CVS2.
8207 + printk("mpi: Detected x.x vdc Cardbus card\n");
8209 + cardtype = MPI_CARDTYPE_CARDBUS;
8212 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8213 + // CCD2 is tied to ground.
8215 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8217 + data32 = mpi->pcmcia_cntl1;
8218 + if (data32 & 0x00000001) {// CCD1 is tied to CVS1.
8219 + printk("mpi: Detected 3.3 vdc Cardbus card\n");
8220 + } else { // CCD1 is tied to CVS2.
8221 + printk("mpi: Detected x.x and y.y Cardbus card\n");
8223 + cardtype = MPI_CARDTYPE_CARDBUS;
8226 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8227 + cardtype = MPI_CARDTYPE_PCMCIA;
8228 + printk("mpi: Detected 5 vdc 16-bit PCMCIA card\n");
8234 + printk("mpi: Unknown card plugged into slot\n");
8243 + * mpi_DetectPcCard: Detect the plugged in PC-Card
8244 + * Return: < 0 => Unknown card detected
8245 + * 0 => No card detected
8246 + * 1 => 16-bit card detected
8247 + * 2 => 32-bit CardBus card detected
8249 +static int mpi_DetectPcCard(void)
8253 + cardtype = cardtype_vcc_detect();
8254 + switch(cardtype) {
8255 + case MPI_CARDTYPE_PCMCIA:
8256 + mpi->pcmcia_cntl1 &= ~0x0000e000; // disable enable bits
8257 + //mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8258 + mpi->pcmcia_cntl1 |= (PCMCIA_ENABLE | PCMCIA_GPIO_ENABLE);
8259 + mpi_InitPcmciaSpace();
8260 + mpi_ResetPcCard(cardtype, FALSE);
8261 + // Hold card in reset for 10ms
8263 + mpi_ResetPcCard(cardtype, TRUE);
8264 + // Let card come out of reset
8267 + case MPI_CARDTYPE_CARDBUS:
8268 + // 8 => CardBus Enable
8269 + // 1 => PCI Slot Number
8270 + // C => Float VS1 & VS2
8271 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & 0xFFFF0000) |
8273 + (CARDBUS_SLOT << 8)|
8276 + /* access to this memory window will be to/from CardBus */
8277 + mpi->l2pmremap1 |= CARDBUS_MEM;
8279 + // Need to reset the Cardbus Card. There's no CardManager to do this,
8280 + // and we need to be ready for PCI configuration.
8281 + mpi_ResetPcCard(cardtype, FALSE);
8282 + // Hold card in reset for 10ms
8284 + mpi_ResetPcCard(cardtype, TRUE);
8285 + // Let card come out of reset
8294 +static int mpi_init(void)
8296 + unsigned long data;
8297 + unsigned int chipid;
8298 + unsigned int chiprev;
8299 + unsigned int sdramsize;
8301 + chipid = (PERF->RevID & 0xFFFF0000) >> 16;
8302 + chiprev = (PERF->RevID & 0xFF);
8303 + sdramsize = getMemorySize();
8305 + * Init the pci interface
8307 + data = GPIO->GPIOMode; // GPIO mode register
8308 + data |= GROUP2_PCI | GROUP1_MII_PCCARD; // PCI internal arbiter + Cardbus
8309 + GPIO->GPIOMode = data; // PCI internal arbiter
8312 + * In the BCM6348 CardBus support is defaulted to Slot 0
8313 + * because there is no external IDSEL for CardBus. To disable
8314 + * the CardBus and allow a standard PCI card in Slot 0
8315 + * set the cbus_idsel field to 0x1f.
8318 + uData = mpi->pcmcia_cntl1;
8319 + uData |= CARDBUS_IDSEL;
8320 + mpi->pcmcia_cntl1 = uData;
8322 + // Setup PCI I/O Window range. Give 64K to PCI I/O
8323 + mpi->l2piorange = ~(BCM_PCI_IO_SIZE_64KB-1);
8324 + // UBUS to PCI I/O base address
8325 + mpi->l2piobase = BCM_PCI_IO_BASE & BCM_PCI_ADDR_MASK;
8326 + // UBUS to PCI I/O Window remap
8327 + mpi->l2pioremap = (BCM_PCI_IO_BASE | MEM_WINDOW_EN);
8329 + // enable PCI related GPIO pins and data swap between system and PCI bus
8330 + mpi->locbuscntrl = (EN_PCI_GPIO | DIR_U2P_NOSWAP);
8332 + /* Enable 6348 BusMaster and Memory access mode */
8333 + data = mpi_GetLocalPciConfigReg(PCI_COMMAND);
8334 + data |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
8335 + mpi_SetLocalPciConfigReg(PCI_COMMAND, data);
8337 + /* Configure two 16 MByte PCI to System memory regions. */
8338 + /* These memory regions are used when PCI device is a bus master */
8339 + /* Accesses to the SDRAM from PCI bus will be "byte swapped" for this region */
8340 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_3, BCM_HOST_MEM_SPACE1);
8341 + mpi->sp0remap = 0x0;
8343 + /* Accesses to the SDRAM from PCI bus will not be "byte swapped" for this region */
8344 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_4, BCM_HOST_MEM_SPACE2);
8345 + mpi->sp1remap = 0x0;
8346 + mpi->pcimodesel |= (PCI_BAR2_NOSWAP | 0x40);
8348 + if ((chipid == 0x6348) && (chiprev == 0xb0)) {
8349 + mpi->sp0range = ~(sdramsize-1);
8350 + mpi->sp1range = ~(sdramsize-1);
8353 + * Change 6348 PCI Cfg Reg. offset 0x40 to PCI memory read retry count infinity
8354 + * by set 0 in bit 8~15. This resolve read Bcm4306 srom return 0xffff in
8357 + data = mpi_GetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER);
8358 + data &= ~BRCM_PCI_CONFIG_TIMER_RETRY_MASK;
8359 + data |= 0x00000080;
8360 + mpi_SetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER, data);
8362 + /* enable pci interrupt */
8363 + mpi->locintstat |= (EXT_PCI_INT << 16);
8365 + mpi_DetectPcCard();
8367 + ioport_resource.start = BCM_PCI_IO_BASE;
8368 + ioport_resource.end = BCM_PCI_IO_BASE + BCM_PCI_IO_SIZE_64KB;
8370 +#if defined(CONFIG_USB)
8371 + PERF->blkEnables |= USBH_CLK_EN;
8373 + *USBH_NON_OHCI = NON_OHCI_BYTE_SWAP;
8380 +static int __init brcm63xx_setup(void)
8382 + extern int panic_timeout;
8384 + _machine_restart = brcm_machine_restart;
8385 + _machine_halt = brcm_machine_halt;
8386 + pm_power_off = brcm_machine_halt;
8388 + board_timer_setup = brcm_timer_setup;
8390 + panic_timeout = 5;
8392 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8393 + /* mpi initialization */
8399 +void plat_setup(void)
8404 +/***************************************************************************
8405 + * C++ New and delete operator functions
8406 + ***************************************************************************/
8408 +/* void *operator new(unsigned int sz) */
8409 +void *_Znwj(unsigned int sz)
8411 + return( kmalloc(sz, GFP_KERNEL) );
8414 +/* void *operator new[](unsigned int sz)*/
8415 +void *_Znaj(unsigned int sz)
8417 + return( kmalloc(sz, GFP_KERNEL) );
8420 +/* placement new operator */
8421 +/* void *operator new (unsigned int size, void *ptr) */
8422 +void *ZnwjPv(unsigned int size, void *ptr)
8427 +/* void operator delete(void *m) */
8428 +void _ZdlPv(void *m)
8433 +/* void operator delete[](void *m) */
8434 +void _ZdaPv(void *m)
8439 +EXPORT_SYMBOL(_Znwj);
8440 +EXPORT_SYMBOL(_Znaj);
8441 +EXPORT_SYMBOL(ZnwjPv);
8442 +EXPORT_SYMBOL(_ZdlPv);
8443 +EXPORT_SYMBOL(_ZdaPv);
8445 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h
8446 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 1970-01-01 01:00:00.000000000 +0100
8447 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 2006-07-13 19:11:33.000000000 +0200
8449 +#define ADSL_SDRAM_IMAGE_SIZE (384*1024)
8451 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c
8452 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c 1970-01-01 01:00:00.000000000 +0100
8453 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c 2006-07-13 19:11:33.000000000 +0200
8457 + Copyright 2004 Broadcom Corp. All Rights Reserved.
8459 + This program is free software; you can distribute it and/or modify it
8460 + under the terms of the GNU General Public License (Version 2) as
8461 + published by the Free Software Foundation.
8463 + This program is distributed in the hope it will be useful, but WITHOUT
8464 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8465 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8468 + You should have received a copy of the GNU General Public License along
8469 + with this program; if not, write to the Free Software Foundation, Inc.,
8470 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8474 + * Setup time for Broadcom 963xx MIPS boards
8477 +#include <linux/config.h>
8478 +#include <linux/init.h>
8479 +#include <linux/kernel_stat.h>
8480 +#include <linux/sched.h>
8481 +#include <linux/spinlock.h>
8482 +#include <linux/interrupt.h>
8483 +#include <linux/module.h>
8484 +#include <linux/time.h>
8485 +#include <linux/timex.h>
8487 +#include <asm/mipsregs.h>
8488 +#include <asm/ptrace.h>
8489 +#include <asm/div64.h>
8490 +#include <asm/time.h>
8492 +#include <bcm_map_part.h>
8493 +#include <bcm_intr.h>
8495 +unsigned long r4k_interval; /* Amount to increment compare reg each time */
8496 +static unsigned long r4k_cur; /* What counter should be at next timer irq */
8498 +/* Cycle counter value at the previous timer interrupt.. */
8499 +static unsigned int timerhi = 0, timerlo = 0;
8501 +extern volatile unsigned long wall_jiffies;
8503 +/* Optional board-specific timer routine */
8504 +void (*board_timer_interrupt)(int irq, void *dev_id, struct pt_regs * regs);
8506 +static inline void ack_r4ktimer(unsigned long newval)
8508 + write_c0_compare(newval);
8512 + * There are a lot of conceptually broken versions of the MIPS timer interrupt
8513 + * handler floating around. This one is rather different, but the algorithm
8514 + * is provably more robust.
8516 +static irqreturn_t brcm_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
8518 + unsigned int count;
8520 + if (r4k_interval == 0)
8526 + if (board_timer_interrupt)
8527 + board_timer_interrupt(irq, dev_id, regs);
8529 + r4k_cur += r4k_interval;
8530 + ack_r4ktimer(r4k_cur);
8532 + } while (((count = (unsigned long)read_c0_count())
8533 + - r4k_cur) < 0x7fffffff);
8537 + * If jiffies has overflowed in this timer_interrupt we must
8538 + * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
8539 + * quotient calc still valid. -arca
8541 + timerhi = timerlo = 0;
8544 + * The cycle counter is only 32 bit which is good for about
8545 + * a minute at current count rates of upto 150MHz or so.
8547 + timerhi += (count < timerlo); /* Wrap around */
8551 + return IRQ_HANDLED;
8558 +static struct irqaction brcm_timer_action = {
8559 + .handler = brcm_timer_interrupt,
8560 + .flags = SA_INTERRUPT,
8561 + .mask = CPU_MASK_NONE,
8564 + .dev_id = brcm_timer_interrupt,
8568 +void __init brcm_timer_setup(struct irqaction *irq)
8570 + r4k_cur = (read_c0_count() + r4k_interval);
8571 + write_c0_compare(r4k_cur);
8573 + /* we are using the cpu counter for timer interrupts */
8574 + irq->handler = no_action; /* we use our own handler */
8575 + setup_irq(MIPS_TIMER_INT, &brcm_timer_action);
8576 + set_c0_status(IE_IRQ5);
8580 +/* This is for machines which generate the exact clock. */
8581 +#define USECS_PER_JIFFY (1000000/HZ)
8582 +#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
8584 +static void call_do_div64_32( unsigned long *res, unsigned int high,
8585 + unsigned int low, unsigned long base )
8587 + do_div64_32(*res, high, low, base);
8591 + * FIXME: Does playing with the RP bit in c0_status interfere with this code?
8593 +static unsigned long do_fast_gettimeoffset(void)
8596 + unsigned long res, tmp;
8598 + /* Last jiffy when do_fast_gettimeoffset() was called. */
8599 + static unsigned long last_jiffies=0;
8600 + unsigned long quotient;
8603 + * Cached "1/(clocks per usec)*2^32" value.
8604 + * It has to be recalculated once each jiffy.
8606 + static unsigned long cached_quotient=0;
8610 + quotient = cached_quotient;
8612 + if (tmp && last_jiffies != tmp) {
8613 + last_jiffies = tmp;
8614 +#ifdef CONFIG_CPU_MIPS32
8615 + if (last_jiffies != 0) {
8618 + /* gcc 3.0.1 gets an internal compiler error if there are two
8619 + * do_div64_32 inline macros. To work around this problem,
8620 + * do_div64_32 is called as a function.
8622 + call_do_div64_32(&r0, timerhi, timerlo, tmp);
8623 + call_do_div64_32("ient, USECS_PER_JIFFY,
8624 + USECS_PER_JIFFY_FRAC, r0);
8626 + cached_quotient = quotient;
8630 + __asm__(".set\tnoreorder\n\t"
8634 + "dsll32\t$1,%1,0\n\t"
8635 + "or\t$1,$1,%0\n\t"
8636 + "ddivu\t$0,$1,%3\n\t"
8638 + "dsll32\t%0,%4,0\n\t"
8640 + "ddivu\t$0,%0,$1\n\t"
8649 + "r" (USECS_PER_JIFFY)
8651 + cached_quotient = quotient;
8655 + /* Get last timer tick in absolute kernel time */
8656 + count = read_c0_count();
8658 + /* .. relative to previous jiffy (32 bits is enough) */
8661 + __asm__("multu\t%1,%2\n\t"
8668 + * Due to possible jiffies inconsistencies, we need to check
8669 + * the result so that we'll get a timer that is monotonic.
8671 + if (res >= USECS_PER_JIFFY)
8672 + res = USECS_PER_JIFFY-1;
8677 +void do_gettimeofday(struct timeval *tv)
8679 + unsigned int flags;
8681 + read_lock_irqsave (&xtime_lock, flags);
8682 + tv->tv_sec = xtime.tv_sec;
8683 + tv->tv_usec = xtime.tv_nsec/1000;
8684 + tv->tv_usec += do_fast_gettimeoffset();
8687 + * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
8688 + * is nonzero if the timer bottom half hasnt executed yet.
8690 + if (jiffies - wall_jiffies)
8691 + tv->tv_usec += USECS_PER_JIFFY;
8693 + read_unlock_irqrestore (&xtime_lock, flags);
8695 + if (tv->tv_usec >= 1000000) {
8696 + tv->tv_usec -= 1000000;
8701 +EXPORT_SYMBOL(do_gettimeofday);
8703 +int do_settimeofday(struct timespec *tv)
8705 + write_lock_irq (&xtime_lock);
8707 + /* This is revolting. We need to set the xtime.tv_usec correctly.
8708 + * However, the value in this location is is value at the last tick.
8709 + * Discover what correction gettimeofday would have done, and then
8712 + tv->tv_nsec -= do_fast_gettimeoffset()*NSEC_PER_USEC;
8714 + if (tv->tv_nsec < 0) {
8715 + tv->tv_nsec += 1000000*NSEC_PER_USEC;
8719 + xtime.tv_sec = tv->tv_sec;
8720 + xtime.tv_nsec = tv->tv_nsec;
8721 + time_adjust = 0; /* stop active adjtime() */
8722 + time_status |= STA_UNSYNC;
8723 + time_maxerror = NTP_PHASE_LIMIT;
8724 + time_esterror = NTP_PHASE_LIMIT;
8726 + write_unlock_irq (&xtime_lock);
8729 +EXPORT_SYMBOL(do_settimeofday);
8732 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c
8733 --- linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c 1970-01-01 01:00:00.000000000 +0100
8734 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c 2006-07-13 19:11:33.000000000 +0200
8738 + Copyright 2003 Broadcom Corp. All Rights Reserved.
8740 + This program is free software; you can distribute it and/or modify it
8741 + under the terms of the GNU General Public License (Version 2) as
8742 + published by the Free Software Foundation.
8744 + This program is distributed in the hope it will be useful, but WITHOUT
8745 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8746 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8749 + You should have received a copy of the GNU General Public License along
8750 + with this program; if not, write to the Free Software Foundation, Inc.,
8751 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8755 +#include <linux/config.h>
8756 +#include <linux/tty.h>
8757 +#include <linux/major.h>
8758 +#include <linux/init.h>
8759 +#include <linux/console.h>
8760 +#include <linux/fs.h>
8761 +#include <linux/interrupt.h>
8762 +#include <linux/kernel.h>
8763 +#include <linux/types.h>
8764 +#include <linux/sched.h>
8766 +#include <bcm_map_part.h>
8768 +#undef PRNT /* define for debug printing */
8770 +#define UART16550_BAUD_2400 2400
8771 +#define UART16550_BAUD_4800 4800
8772 +#define UART16550_BAUD_9600 9600
8773 +#define UART16550_BAUD_19200 19200
8774 +#define UART16550_BAUD_38400 38400
8775 +#define UART16550_BAUD_57600 57600
8776 +#define UART16550_BAUD_115200 115200
8778 +#define UART16550_PARITY_NONE 0
8779 +#define UART16550_PARITY_ODD 0x08
8780 +#define UART16550_PARITY_EVEN 0x18
8781 +#define UART16550_PARITY_MARK 0x28
8782 +#define UART16550_PARITY_SPACE 0x38
8784 +#define UART16550_DATA_5BIT 0x0
8785 +#define UART16550_DATA_6BIT 0x1
8786 +#define UART16550_DATA_7BIT 0x2
8787 +#define UART16550_DATA_8BIT 0x3
8789 +#define UART16550_STOP_1BIT 0x0
8790 +#define UART16550_STOP_2BIT 0x4
8792 +volatile Uart * stUart = UART_BASE;
8794 +#define WRITE16(addr, value) ((*(volatile UINT16 *)((ULONG)&addr)) = value)
8796 +/* Low level UART routines from promcon.c */
8797 +extern void prom_putc(char c);
8798 +extern char prom_getc(void);
8799 +extern int prom_getc_nowait(void);
8800 +extern int prom_testc(void);
8802 +extern void set_debug_traps(void);
8803 +extern void breakpoint(void);
8804 +extern void enable_brcm_irq(unsigned int);
8805 +extern void set_async_breakpoint(unsigned int epc);
8807 +#ifdef CONFIG_GDB_CONSOLE
8808 +extern void register_gdb_console(void);
8811 +int gdb_initialized = 0;
8813 +#define GDB_BUF_SIZE 512 /* power of 2, please */
8815 +static char gdb_buf[GDB_BUF_SIZE] ;
8816 +static int gdb_buf_in_inx ;
8817 +static atomic_t gdb_buf_in_cnt ;
8818 +static int gdb_buf_out_inx ;
8820 +void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
8822 + /* Do nothing, assume boot loader has already set up serial port */
8823 + printk("debugInit called\n");
8827 + * Get a char if available, return -1 if nothing available.
8828 + * Empty the receive buffer first, then look at the interface hardware.
8830 +static int read_char(void)
8832 + if (atomic_read(&gdb_buf_in_cnt) != 0) /* intr routine has q'd chars */
8836 + chr = gdb_buf[gdb_buf_out_inx++] ;
8837 + gdb_buf_out_inx &= (GDB_BUF_SIZE - 1) ;
8838 + atomic_dec(&gdb_buf_in_cnt) ;
8841 + return(prom_getc_nowait()) ; /* read from hardware */
8845 + * This is the receiver interrupt routine for the GDB stub.
8846 + * It will receive a limited number of characters of input
8847 + * from the gdb host machine and save them up in a buffer.
8849 + * When the gdb stub routine getDebugChar() is called it
8850 + * draws characters out of the buffer until it is empty and
8851 + * then reads directly from the serial port.
8853 + * We do not attempt to write chars from the interrupt routine
8854 + * since the stubs do all of that via putDebugChar() which
8855 + * writes one byte after waiting for the interface to become
8858 + * The debug stubs like to run with interrupts disabled since,
8859 + * after all, they run as a consequence of a breakpoint in
8862 + * Perhaps someone who knows more about the tty driver than I
8863 + * care to learn can make this work for any low level serial
8866 +static void gdb_interrupt(int irq, void *dev_id, struct pt_regs * regs)
8872 + chr = prom_getc_nowait() ;
8873 + more = prom_testc();
8874 + if (chr < 0) continue ;
8876 + /* If we receive a Ctrl-C then this is GDB trying to break in */
8879 + /* Replace current instruction with breakpoint */
8880 + set_async_breakpoint(regs->cp0_epc);
8885 + printk("gdb_interrupt: chr=%02x '%c', more = %x\n",
8886 + chr, chr > ' ' && chr < 0x7F ? chr : ' ', more) ;
8889 + if (atomic_read(&gdb_buf_in_cnt) >= GDB_BUF_SIZE)
8890 + { /* buffer overflow, clear it */
8891 + gdb_buf_in_inx = 0 ;
8892 + atomic_set(&gdb_buf_in_cnt, 0) ;
8893 + gdb_buf_out_inx = 0 ;
8897 + gdb_buf[gdb_buf_in_inx++] = chr ;
8898 + gdb_buf_in_inx &= (GDB_BUF_SIZE - 1) ;
8899 + atomic_inc(&gdb_buf_in_cnt) ;
8903 +} /* gdb_interrupt */
8908 + * This is a GDB stub routine. It waits for a character from the
8909 + * serial interface and then returns it. If there is no serial
8910 + * interface connection then it returns a bogus value which will
8911 + * almost certainly cause the system to hang.
8913 +int getDebugChar(void)
8915 + volatile int chr ;
8918 + printk("getDebugChar: ") ;
8921 + while ( (chr = read_char()) < 0 ) ;
8924 + printk("%c\n", chr > ' ' && chr < 0x7F ? chr : ' ') ;
8928 +} /* getDebugChar */
8933 + * This is a GDB stub routine. It waits until the interface is ready
8934 + * to transmit a char and then sends it. If there is no serial
8935 + * interface connection then it simply returns to its caller, having
8936 + * pretended to send the char.
8938 +int putDebugChar(unsigned char chr)
8941 + printk("putDebugChar: chr=%02x '%c'\n", chr,
8942 + chr > ' ' && chr < 0x7F ? chr : ' ') ;
8945 + prom_putc(chr) ; /* this routine will wait */
8948 +} /* putDebugChar */
8950 +/* Just a NULL routine for testing. */
8951 +void gdb_null(void)
8955 +void rs_kgdb_hook(int tty_no)
8957 + printk("rs_kgdb_hook: tty %d\n", tty_no);
8959 + /* Call GDB routine to setup the exception vectors for the debugger */
8960 + set_debug_traps();
8962 + printk("Breaking into debugger...\n");
8965 + printk("Connected.\n");
8967 + gdb_initialized = 1;
8969 +#ifdef CONFIG_GDB_CONSOLE
8970 + register_gdb_console();
8974 +void kgdb_hook_irq()
8979 + printk("GDB: Hooking UART interrupt\n");
8981 + retval = request_irq(INTERRUPT_ID_UART,
8984 + "GDB-stub", NULL);
8987 + printk("gdb_hook: request_irq(irq=%d) failed: %d\n", INTERRUPT_ID_UART, retval);
8989 + // Enable UART config Rx not empty IRQ
8990 + uMask = READ16(stUart->intMask) ;
8991 + // printk("intMask: 0x%x\n", uMask);
8992 + WRITE16(stUart->intMask, uMask | RXFIFONE);
8996 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S
8997 --- linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
8998 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S 2006-07-13 19:11:33.000000000 +0200
9002 + Copyright 2002 Broadcom Corp. All Rights Reserved.
9004 + This program is free software; you can distribute it and/or modify it
9005 + under the terms of the GNU General Public License (Version 2) as
9006 + published by the Free Software Foundation.
9008 + This program is distributed in the hope it will be useful, but WITHOUT
9009 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9010 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9013 + You should have received a copy of the GNU General Public License along
9014 + with this program; if not, write to the Free Software Foundation, Inc.,
9015 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
9019 + * Generic interrupt handler for Broadcom MIPS boards
9022 +#include <linux/config.h>
9024 +#include <asm/asm.h>
9025 +#include <asm/mipsregs.h>
9026 +#include <asm/regdef.h>
9027 +#include <asm/stackframe.h>
9032 + * 0 Software (ignored)
9033 + * 1 Software (ignored)
9034 + * 2 Combined hardware interrupt (hw0)
9046 + NESTED(brcmIRQ, PT_SIZE, sp)
9052 + jal brcm_irq_dispatch
9059 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile
9060 --- linux-2.6.17/arch/mips/brcm-boards/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
9061 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile 2006-07-13 19:11:33.000000000 +0200
9064 +# Makefile for generic Broadcom MIPS boards
9066 +# Copyright (C) 2001 Broadcom Corporation
9068 +obj-y := int-handler.o
9070 +ifdef CONFIG_REMOTE_DEBUG