1 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c
2 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 2006-07-07 22:16:32.000000000 +0200
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.16.7/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c
781 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 1970-01-01 01:00:00.000000000 +0100
782 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 2006-07-07 22:16:32.000000000 +0200
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.16.7/arch/mips/brcm-boards/bcm963xx/board.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c
1367 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/board.c 1970-01-01 01:00:00.000000000 +0100
1368 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c 2006-07-07 22:16:43.000000000 +0200
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>
1417 +#include <bcm_map_part.h>
1419 +#include <bcmTag.h>
1420 +#include "boardparms.h"
1421 +#include "cfiflash.h"
1422 +#include "bcm_intr.h"
1424 +#include "bcm_map_part.h"
1427 +#if defined (NON_CONSECUTIVE_MAC)
1428 +// used to be the last octet. Now changed to the first 5 bits of the the forth octet
1429 +// to reduced the duplicated MAC addresses.
1430 +#define CHANGED_OCTET 3
1431 +#define SHIFT_BITS 3
1433 +#define CHANGED_OCTET 1
1434 +#define SHIFT_BITS 0
1437 +#if defined (WIRELESS)
1438 +#define SES_BTN_PRESSED 0x00000001
1439 +#define SES_EVENTS SES_BTN_PRESSED /*OR all values if any*/
1440 +#define SES_LED_OFF 0
1441 +#define SES_LED_ON 1
1442 +#define SES_LED_BLINK 2
1447 + unsigned long ulId;
1449 + char chReserved[3];
1450 +} MAC_ADDR_INFO, *PMAC_ADDR_INFO;
1454 + unsigned long ulSdramSize;
1455 + unsigned long ulPsiSize;
1456 + unsigned long ulNumMacAddrs;
1457 + unsigned long ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN];
1458 + MAC_ADDR_INFO MacAddrs[1];
1459 +} NVRAM_INFO, *PNVRAM_INFO;
1463 + unsigned long eventmask;
1464 +} BOARD_IOC, *PBOARD_IOC;
1467 +/*Dyinggasp callback*/
1468 +typedef void (*cb_dgasp_t)(void *arg);
1469 +typedef struct _CB_DGASP__LIST
1471 + struct list_head list;
1472 + char name[IFNAMSIZ];
1473 + cb_dgasp_t cb_dgasp_fn;
1475 +}CB_DGASP_LIST , *PCB_DGASP_LIST;
1478 +static LED_MAP_PAIR LedMapping[] =
1479 +{ // led name Initial state physical pin (ledMask)
1480 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1481 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1482 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1483 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1484 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1485 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1486 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1487 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1488 + {kLedEnd, kLedStateOff, 0, 0, 0, 0} // NOTE: kLedEnd has to be at the end.
1492 +extern struct file fastcall *fget_light(unsigned int fd, int *fput_needed);
1493 +extern unsigned int nr_free_pages (void);
1494 +extern const char *get_system_type(void);
1495 +extern void kerSysFlashInit(void);
1496 +extern unsigned long get_nvram_start_addr(void);
1497 +extern unsigned long get_scratch_pad_start_addr(void);
1498 +extern unsigned long getMemorySize(void);
1499 +extern void __init boardLedInit(PLED_MAP_PAIR);
1500 +extern void boardLedCtrl(BOARD_LED_NAME, BOARD_LED_STATE);
1501 +extern void kerSysLedRegisterHandler( BOARD_LED_NAME ledName,
1502 + HANDLE_LED_FUNC ledHwFunc, int ledFailType );
1505 +void __init InitNvramInfo( void );
1506 +static int board_open( struct inode *inode, struct file *filp );
1507 +static int board_ioctl( struct inode *inode, struct file *flip, unsigned int command, unsigned long arg );
1508 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos);
1509 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait);
1510 +static int board_release(struct inode *inode, struct file *filp);
1512 +static BOARD_IOC* borad_ioc_alloc(void);
1513 +static void borad_ioc_free(BOARD_IOC* board_ioc);
1515 +/* DyingGasp function prototype */
1516 +static void __init kerSysDyingGaspMapIntr(void);
1517 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
1518 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs);
1520 +static unsigned int kerSysDyingGaspIsr(void);
1522 +static void __init kerSysInitDyingGaspHandler( void );
1523 +static void __exit kerSysDeinitDyingGaspHandler( void );
1524 +/* -DyingGasp function prototype - */
1527 +#if defined (WIRELESS)
1528 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs);
1529 +static void __init sesBtn_mapGpio(void);
1530 +static void __init sesBtn_mapIntr(int context);
1531 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait);
1532 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos);
1533 +static void __init sesLed_mapGpio(void);
1534 +static void sesLed_ctrl(int action);
1535 +static void __init ses_board_init(void);
1536 +static void __exit ses_board_deinit(void);
1539 +static PNVRAM_INFO g_pNvramInfo = NULL;
1540 +static int g_ledInitialized = 0;
1541 +static wait_queue_head_t g_board_wait_queue;
1542 +static CB_DGASP_LIST *g_cb_dgasp_list_head = NULL;
1544 +static int g_wakeup_monitor = 0;
1545 +static struct file *g_monitor_file = NULL;
1546 +static struct task_struct *g_monitor_task = NULL;
1547 +static unsigned int (*g_orig_fop_poll)
1548 + (struct file *, struct poll_table_struct *) = NULL;
1550 +static struct file_operations board_fops =
1553 + ioctl: board_ioctl,
1556 + release: board_release,
1559 +uint32 board_major = 0;
1561 +#if defined (WIRELESS)
1562 +static unsigned short sesBtn_irq = BP_NOT_DEFINED;
1563 +static unsigned short sesBtn_gpio = BP_NOT_DEFINED;
1564 +static unsigned short sesLed_gpio = BP_NOT_DEFINED;
1567 +#if defined(MODULE)
1568 +int init_module(void)
1570 + return( brcm_board_init() );
1573 +void cleanup_module(void)
1576 + printk("brcm flash: cleanup_module failed because module is in use\n");
1578 + brcm_board_cleanup();
1584 +static int __init brcm_board_init( void )
1586 + typedef int (*BP_LED_FUNC) (unsigned short *);
1587 + static struct BpLedInformation
1589 + BOARD_LED_NAME ledName;
1590 + BP_LED_FUNC bpFunc;
1591 + BP_LED_FUNC bpFuncFail;
1593 + {{kLedAdsl, BpGetAdslLedGpio, BpGetAdslFailLedGpio},
1594 + {kLedWireless, BpGetWirelessLedGpio, NULL},
1595 + {kLedUsb, BpGetUsbLedGpio, NULL},
1596 + {kLedHpna, BpGetHpnaLedGpio, NULL},
1597 + {kLedWanData, BpGetWanDataLedGpio, NULL},
1598 + {kLedPPP, BpGetPppLedGpio, BpGetPppFailLedGpio},
1599 + {kLedVoip, BpGetVoipLedGpio, NULL},
1600 + {kLedSes, BpGetWirelessSesLedGpio, NULL},
1601 + {kLedEnd, NULL, NULL}
1606 + ret = register_chrdev(BOARD_DRV_MAJOR, "bcrmboard", &board_fops );
1608 + printk( "brcm_board_init(major %d): fail to register device.\n",BOARD_DRV_MAJOR);
1611 + PLED_MAP_PAIR pLedMap = LedMapping;
1612 + unsigned short gpio;
1613 + struct BpLedInformation *pInfo;
1615 + printk("brcmboard: brcm_board_init entry\n");
1616 + board_major = BOARD_DRV_MAJOR;
1619 + for( pInfo = bpLedInfo; pInfo->ledName != kLedEnd; pInfo++ )
1621 + if( pInfo->bpFunc && (*pInfo->bpFunc) (&gpio) == BP_SUCCESS )
1623 + pLedMap->ledName = pInfo->ledName;
1624 + pLedMap->ledMask = GPIO_NUM_TO_MASK(gpio);
1625 + pLedMap->ledActiveLow = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1627 + if( pInfo->bpFuncFail && (*pInfo->bpFuncFail) (&gpio) == BP_SUCCESS )
1629 + pLedMap->ledName = pInfo->ledName;
1630 + pLedMap->ledMaskFail = GPIO_NUM_TO_MASK(gpio);
1631 + pLedMap->ledActiveLowFail = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1633 + if( pLedMap->ledName != kLedEnd )
1637 + init_waitqueue_head(&g_board_wait_queue);
1638 +#if defined (WIRELESS)
1641 + kerSysInitDyingGaspHandler();
1642 + kerSysDyingGaspMapIntr();
1644 + boardLedInit(LedMapping);
1645 + g_ledInitialized = 1;
1651 +void __init InitNvramInfo( void )
1653 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
1654 + unsigned long ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1656 + if( ulNumMacAddrs > 0 && ulNumMacAddrs <= NVRAM_MAC_COUNT_MAX )
1658 + unsigned long ulNvramInfoSize =
1659 + sizeof(NVRAM_INFO) + ((sizeof(MAC_ADDR_INFO) - 1) * ulNumMacAddrs);
1661 + g_pNvramInfo = (PNVRAM_INFO) kmalloc( ulNvramInfoSize, GFP_KERNEL );
1663 + if( g_pNvramInfo )
1665 + unsigned long ulPsiSize;
1666 + if( BpGetPsiSize( &ulPsiSize ) != BP_SUCCESS )
1667 + ulPsiSize = NVRAM_PSI_DEFAULT;
1668 + memset( g_pNvramInfo, 0x00, ulNvramInfoSize );
1669 + g_pNvramInfo->ulPsiSize = ulPsiSize * 1024;
1670 + g_pNvramInfo->ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1671 + memcpy( g_pNvramInfo->ucaBaseMacAddr, pNvramData->ucaBaseMacAddr,
1672 + NVRAM_MAC_ADDRESS_LEN );
1673 + g_pNvramInfo->ulSdramSize = getMemorySize();
1676 + printk("ERROR - Could not allocate memory for NVRAM data\n");
1679 + printk("ERROR - Invalid number of MAC addresses (%ld) is configured.\n",
1683 +void __exit brcm_board_cleanup( void )
1685 + printk("brcm_board_cleanup()\n");
1687 + if (board_major != -1)
1689 +#if defined (WIRELESS)
1690 + ses_board_deinit();
1692 + kerSysDeinitDyingGaspHandler();
1693 + unregister_chrdev(board_major, "board_ioctl");
1697 +static BOARD_IOC* borad_ioc_alloc(void)
1699 + BOARD_IOC *board_ioc =NULL;
1700 + board_ioc = (BOARD_IOC*) kmalloc( sizeof(BOARD_IOC) , GFP_KERNEL );
1703 + memset(board_ioc, 0, sizeof(BOARD_IOC));
1708 +static void borad_ioc_free(BOARD_IOC* board_ioc)
1717 +static int board_open( struct inode *inode, struct file *filp )
1719 + filp->private_data = borad_ioc_alloc();
1721 + if (filp->private_data == NULL)
1727 +static int board_release(struct inode *inode, struct file *filp)
1729 + BOARD_IOC *board_ioc = filp->private_data;
1731 + wait_event_interruptible(g_board_wait_queue, 1);
1732 + borad_ioc_free(board_ioc);
1738 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait)
1740 + unsigned int mask = 0;
1741 +#if defined (WIRELESS)
1742 + BOARD_IOC *board_ioc = filp->private_data;
1745 + poll_wait(filp, &g_board_wait_queue, wait);
1746 +#if defined (WIRELESS)
1747 + if(board_ioc->eventmask & SES_EVENTS){
1748 + mask |= sesBtn_poll(filp, wait);
1756 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
1758 +#if defined (WIRELESS)
1759 + BOARD_IOC *board_ioc = filp->private_data;
1760 + if(board_ioc->eventmask & SES_EVENTS){
1761 + return sesBtn_read(filp, buffer, count, ppos);
1767 +//**************************************************************************************
1768 +// Utitlities for dump memory, free kernel pages, mips soft reset, etc.
1769 +//**************************************************************************************
1771 +/***********************************************************************
1772 + * Function Name: dumpaddr
1773 + * Description : Display a hex dump of the specified address.
1774 + ***********************************************************************/
1775 +void dumpaddr( unsigned char *pAddr, int nLen )
1777 + static char szHexChars[] = "0123456789abcdef";
1780 + unsigned char ch, *q;
1786 + sprintf( szLine, "%8.8lx: ", (unsigned long) pAddr );
1787 + p = szLine + strlen(szLine);
1789 + for(i = 0; i < 16 && nLen > 0; i += sizeof(long), nLen -= sizeof(long))
1791 + ul = *(unsigned long *) &pAddr[i];
1792 + q = (unsigned char *) &ul;
1793 + for( j = 0; j < sizeof(long); j++ )
1795 + *p++ = szHexChars[q[j] >> 4];
1796 + *p++ = szHexChars[q[j] & 0x0f];
1801 + for( j = 0; j < 16 - i; j++ )
1802 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1804 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1806 + for( j = 0; j < i; j++ )
1809 + *p++ = (ch > ' ' && ch < '~') ? ch : '.';
1813 + printk( "%s\r\n", szLine );
1821 +void kerSysMipsSoftReset(void)
1823 +#if defined(CONFIG_BCM96348)
1824 + if (PERF->RevID == 0x634800A1) {
1825 + typedef void (*FNPTR) (void);
1826 + FNPTR bootaddr = (FNPTR) FLASH_BASE;
1829 + /* Disable interrupts. */
1832 + /* Reset all blocks. */
1833 + PERF->BlockSoftReset &= ~BSR_ALL_BLOCKS;
1834 + for( i = 0; i < 1000000; i++ )
1836 + PERF->BlockSoftReset |= BSR_ALL_BLOCKS;
1837 + /* Jump to the power on address. */
1841 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1843 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1848 +int kerSysGetMacAddress( unsigned char *pucaMacAddr, unsigned long ulId )
1851 + PMAC_ADDR_INFO pMai = NULL;
1852 + PMAC_ADDR_INFO pMaiFreeNoId = NULL;
1853 + PMAC_ADDR_INFO pMaiFreeId = NULL;
1854 + unsigned long i = 0, ulIdxNoId = 0, ulIdxId = 0, shiftedIdx = 0;
1856 + for( i = 0, pMai = g_pNvramInfo->MacAddrs; i < g_pNvramInfo->ulNumMacAddrs;
1859 + if( ulId == pMai->ulId || ulId == MAC_ADDRESS_ANY )
1861 + /* This MAC address has been used by the caller in the past. */
1862 + memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1863 + NVRAM_MAC_ADDRESS_LEN );
1865 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1866 + pMai->chInUse = 1;
1867 + pMaiFreeNoId = pMaiFreeId = NULL;
1871 + if( pMai->chInUse == 0 )
1873 + if( pMai->ulId == 0 && pMaiFreeNoId == NULL )
1875 + /* This is an available MAC address that has never been
1878 + pMaiFreeNoId = pMai;
1882 + if( pMai->ulId != 0 && pMaiFreeId == NULL )
1884 + /* This is an available MAC address that has been used
1885 + * before. Use addresses that have never been used
1886 + * first, before using this one.
1888 + pMaiFreeId = pMai;
1894 + if( pMaiFreeNoId || pMaiFreeId )
1896 + /* An available MAC address was found. */
1897 + memcpy(pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,NVRAM_MAC_ADDRESS_LEN);
1898 + if( pMaiFreeNoId )
1900 + shiftedIdx = ulIdxNoId;
1901 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1902 + pMaiFreeNoId->ulId = ulId;
1903 + pMaiFreeNoId->chInUse = 1;
1907 + shiftedIdx = ulIdxId;
1908 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1909 + pMaiFreeId->ulId = ulId;
1910 + pMaiFreeId->chInUse = 1;
1914 + if( i == g_pNvramInfo->ulNumMacAddrs )
1915 + nRet = -EADDRNOTAVAIL;
1918 +} /* kerSysGetMacAddr */
1920 +int kerSysReleaseMacAddress( unsigned char *pucaMacAddr )
1922 + int nRet = -EINVAL;
1923 + unsigned long ulIdx = 0;
1924 + int idx = (pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] -
1925 + g_pNvramInfo->ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET]);
1927 + // if overflow 255 (negitive), add 256 to have the correct index
1930 + ulIdx = (unsigned long) (idx >> SHIFT_BITS);
1932 + if( ulIdx < g_pNvramInfo->ulNumMacAddrs )
1934 + PMAC_ADDR_INFO pMai = &g_pNvramInfo->MacAddrs[ulIdx];
1935 + if( pMai->chInUse == 1 )
1937 + pMai->chInUse = 0;
1943 +} /* kerSysReleaseMacAddr */
1945 +int kerSysGetSdramSize( void )
1947 + return( (int) g_pNvramInfo->ulSdramSize );
1948 +} /* kerSysGetSdramSize */
1951 +void kerSysLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
1953 + if (g_ledInitialized)
1954 + boardLedCtrl(ledName, ledState);
1957 +unsigned int kerSysMonitorPollHook( struct file *f, struct poll_table_struct *t)
1959 + int mask = (*g_orig_fop_poll) (f, t);
1961 + if( g_wakeup_monitor == 1 && g_monitor_file == f )
1963 + /* If g_wakeup_monitor is non-0, the user mode application needs to
1964 + * return from a blocking select function. Return POLLPRI which will
1965 + * cause the select to return with the exception descriptor set.
1968 + g_wakeup_monitor = 0;
1974 +/* Put the user mode application that monitors link state on a run queue. */
1975 +void kerSysWakeupMonitorTask( void )
1977 + g_wakeup_monitor = 1;
1978 + if( g_monitor_task )
1979 + wake_up_process( g_monitor_task );
1982 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
1983 +int kerSysGetResetHold(void)
1985 + unsigned short gpio;
1987 + if( BpGetPressAndHoldResetGpio( &gpio ) == BP_SUCCESS )
1989 +#if defined(CONFIG_BCM96338)
1990 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
1991 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
1993 +#if defined(CONFIG_BCM96345)
1994 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(gpio);
1995 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
1997 +#if defined(CONFIG_BCM96348)
1998 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
1999 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2001 + if( (gpio & ~BP_ACTIVE_MASK) >= 32 )
2003 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(gpio);
2004 + gpio_reg = &GPIO->GPIOio_high;
2007 + //printk("gpio=%04x,gpio_mask=%04x,gpio_reg=%04x\n",gpio,gpio_mask,*gpio_reg);
2008 + if(*gpio_reg & gpio_mask) //press down
2009 + return RESET_BUTTON_UP;
2011 + return RESET_BUTTON_PRESSDOWN;
2013 +//<<JUNHON, 2004/09/15
2015 +//********************************************************************************************
2016 +// misc. ioctl calls come to here. (flash, led, reset, kernel memory access, etc.)
2017 +//********************************************************************************************
2018 +static int board_ioctl( struct inode *inode, struct file *flip,
2019 + unsigned int command, unsigned long arg )
2022 + BOARD_IOCTL_PARMS ctrlParms;
2023 + unsigned char ucaMacAddr[NVRAM_MAC_ADDRESS_LEN];
2028 + case BOARD_IOCTL_FLASH_INIT:
2029 + // not used for now. kerSysBcmImageInit();
2033 + case BOARD_IOCTL_FLASH_WRITE:
2034 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2036 + NVRAM_DATA SaveNvramData;
2037 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
2039 + switch (ctrlParms.action)
2042 + ret = kerSysScratchPadSet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2046 + ret = kerSysPersistentSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2050 + ret = kerSysNvRamSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2053 + case BCM_IMAGE_CFE:
2054 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > FLASH45_LENGTH_BOOT_ROM )
2056 + printk("Illegal CFE size [%d]. Size allowed: [%d]\n",
2057 + ctrlParms.strLen, FLASH45_LENGTH_BOOT_ROM);
2062 + // save NVRAM data into a local structure
2063 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2065 + // set memory type field
2066 + BpGetSdramSize( (unsigned long *) &ctrlParms.string[SDRAM_TYPE_ADDRESS_OFFSET] );
2068 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2070 + // if nvram is not valid, restore the current nvram settings
2071 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2072 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2074 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2078 + case BCM_IMAGE_FS:
2079 + allowedSize = (int) flash_get_total_size() - \
2080 + FLASH_RESERVED_AT_END - TAG_LEN - FLASH45_LENGTH_BOOT_ROM;
2081 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize)
2083 + printk("Illegal root file system size [%d]. Size allowed: [%d]\n",
2084 + ctrlParms.strLen, allowedSize);
2088 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2089 + kerSysMipsSoftReset();
2092 + case BCM_IMAGE_KERNEL: // not used for now.
2094 + case BCM_IMAGE_WHOLE:
2095 + if(ctrlParms.strLen <= 0)
2097 + printk("Illegal flash image size [%d].\n", ctrlParms.strLen);
2102 + // save NVRAM data into a local structure
2103 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2105 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2107 + // if nvram is not valid, restore the current nvram settings
2108 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2109 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2111 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2114 + kerSysMipsSoftReset();
2119 + printk("flash_ioctl_command: invalid command %d\n", ctrlParms.action);
2122 + ctrlParms.result = ret;
2123 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2129 + case BOARD_IOCTL_FLASH_READ:
2130 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2132 + switch (ctrlParms.action)
2135 + ret = kerSysScratchPadGet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2139 + ret = kerSysPersistentGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2143 + ret = kerSysNvRamGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2147 + ret = kerSysFlashSizeGet();
2152 + printk("Not supported. invalid command %d\n", ctrlParms.action);
2155 + ctrlParms.result = ret;
2156 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2162 + case BOARD_IOCTL_GET_NR_PAGES:
2163 + ctrlParms.result = nr_free_pages() + get_page_cache_size();
2164 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2168 + case BOARD_IOCTL_DUMP_ADDR:
2169 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2171 + dumpaddr( (unsigned char *) ctrlParms.string, ctrlParms.strLen );
2172 + ctrlParms.result = 0;
2173 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2180 + case BOARD_IOCTL_SET_MEMORY:
2181 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2183 + unsigned long *pul = (unsigned long *) ctrlParms.string;
2184 + unsigned short *pus = (unsigned short *) ctrlParms.string;
2185 + unsigned char *puc = (unsigned char *) ctrlParms.string;
2186 + switch( ctrlParms.strLen )
2189 + *pul = (unsigned long) ctrlParms.offset;
2192 + *pus = (unsigned short) ctrlParms.offset;
2195 + *puc = (unsigned char) ctrlParms.offset;
2198 + dumpaddr( (unsigned char *) ctrlParms.string, sizeof(long) );
2199 + ctrlParms.result = 0;
2200 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2207 + case BOARD_IOCTL_MIPS_SOFT_RESET:
2208 + kerSysMipsSoftReset();
2211 + case BOARD_IOCTL_LED_CTRL:
2212 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2214 + kerSysLedCtrl((BOARD_LED_NAME)ctrlParms.strLen, (BOARD_LED_STATE)ctrlParms.offset);
2219 + case BOARD_IOCTL_GET_ID:
2220 + if (copy_from_user((void*)&ctrlParms, (void*)arg,
2221 + sizeof(ctrlParms)) == 0)
2223 + if( ctrlParms.string )
2225 + char *p = (char *) get_system_type();
2226 + if( strlen(p) + 1 < ctrlParms.strLen )
2227 + ctrlParms.strLen = strlen(p) + 1;
2228 + __copy_to_user(ctrlParms.string, p, ctrlParms.strLen);
2231 + ctrlParms.result = 0;
2232 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2233 + sizeof(BOARD_IOCTL_PARMS));
2237 + case BOARD_IOCTL_GET_MAC_ADDRESS:
2238 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2240 + ctrlParms.result = kerSysGetMacAddress( ucaMacAddr,
2241 + ctrlParms.offset );
2243 + if( ctrlParms.result == 0 )
2245 + __copy_to_user(ctrlParms.string, ucaMacAddr,
2246 + sizeof(ucaMacAddr));
2249 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2250 + sizeof(BOARD_IOCTL_PARMS));
2257 + case BOARD_IOCTL_RELEASE_MAC_ADDRESS:
2258 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2260 + if (copy_from_user((void*)ucaMacAddr, (void*)ctrlParms.string, \
2261 + NVRAM_MAC_ADDRESS_LEN) == 0)
2263 + ctrlParms.result = kerSysReleaseMacAddress( ucaMacAddr );
2267 + ctrlParms.result = -EACCES;
2270 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2271 + sizeof(BOARD_IOCTL_PARMS));
2278 + case BOARD_IOCTL_GET_PSI_SIZE:
2279 + ctrlParms.result = (int) g_pNvramInfo->ulPsiSize;
2280 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2284 + case BOARD_IOCTL_GET_SDRAM_SIZE:
2285 + ctrlParms.result = (int) g_pNvramInfo->ulSdramSize;
2286 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2290 + case BOARD_IOCTL_GET_BASE_MAC_ADDRESS:
2291 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2293 + __copy_to_user(ctrlParms.string, g_pNvramInfo->ucaBaseMacAddr, NVRAM_MAC_ADDRESS_LEN);
2294 + ctrlParms.result = 0;
2296 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2297 + sizeof(BOARD_IOCTL_PARMS));
2304 + case BOARD_IOCTL_GET_CHIP_ID:
2305 + ctrlParms.result = (int) (PERF->RevID & 0xFFFF0000) >> 16;
2306 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2310 + case BOARD_IOCTL_GET_NUM_ENET: {
2311 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2312 + int i, numeth = 0;
2313 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2314 + for( i = 0; i < BP_MAX_ENET_MACS; i++) {
2315 + if (EnetInfos[i].ucPhyType != BP_ENET_NO_PHY) {
2319 + ctrlParms.result = numeth;
2320 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2329 + case BOARD_IOCTL_GET_CFE_VER:
2330 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2331 + char *vertag = (char *)(FLASH_BASE + CFE_VERSION_OFFSET);
2332 + if (ctrlParms.strLen < CFE_VERSION_SIZE) {
2333 + ctrlParms.result = 0;
2334 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2337 + else if (strncmp(vertag, "cfe-v", 5)) { // no tag info in flash
2338 + ctrlParms.result = 0;
2339 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2343 + ctrlParms.result = 1;
2344 + __copy_to_user(ctrlParms.string, vertag+CFE_VERSION_MARK_SIZE, CFE_VERSION_SIZE);
2345 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2354 + case BOARD_IOCTL_GET_ENET_CFG:
2355 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2356 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2357 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2358 + if (ctrlParms.strLen == sizeof(EnetInfos)) {
2359 + __copy_to_user(ctrlParms.string, EnetInfos, sizeof(EnetInfos));
2360 + ctrlParms.result = 0;
2361 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2375 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2376 + case BOARD_IOCTL_GET_RESETHOLD:
2377 + ctrlParms.result = kerSysGetResetHold();
2378 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2381 +//>>JUNHON, 2004/09/15
2384 +#if defined (WIRELESS)
2385 + case BOARD_IOCTL_GET_WLAN_ANT_INUSE:
2386 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2387 + unsigned short antInUse = 0;
2388 + if (BpGetWirelessAntInUse(&antInUse) == BP_SUCCESS) {
2389 + if (ctrlParms.strLen == sizeof(antInUse)) {
2390 + __copy_to_user(ctrlParms.string, &antInUse, sizeof(antInUse));
2391 + ctrlParms.result = 0;
2392 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2407 + case BOARD_IOCTL_SET_TRIGGER_EVENT:
2408 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2409 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2410 + ctrlParms.result = -EFAULT;
2412 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2413 + board_ioc->eventmask |= *((int*)ctrlParms.string);
2414 +#if defined (WIRELESS)
2415 + if((board_ioc->eventmask & SES_EVENTS)) {
2416 + if(sesBtn_irq != BP_NOT_DEFINED) {
2417 + BcmHalInterruptEnable(sesBtn_irq);
2418 + ctrlParms.result = 0;
2423 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2432 + case BOARD_IOCTL_GET_TRIGGER_EVENT:
2433 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2434 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2435 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2436 + __copy_to_user(ctrlParms.string, &board_ioc->eventmask, sizeof(unsigned long));
2437 + ctrlParms.result = 0;
2438 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2450 + case BOARD_IOCTL_UNSET_TRIGGER_EVENT:
2451 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2452 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2453 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2454 + board_ioc->eventmask &= (~(*((int*)ctrlParms.string)));
2455 + ctrlParms.result = 0;
2456 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2467 +#if defined (WIRELESS)
2468 + case BOARD_IOCTL_SET_SES_LED:
2469 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2470 + if (ctrlParms.strLen == sizeof(int)) {
2471 + sesLed_ctrl(*(int*)ctrlParms.string);
2472 + ctrlParms.result = 0;
2473 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2486 + case BOARD_IOCTL_SET_MONITOR_FD:
2487 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2488 + int fput_needed = 0;
2490 + g_monitor_file = fget_light( ctrlParms.offset, &fput_needed );
2491 + if( g_monitor_file ) {
2492 + /* Hook this file descriptor's poll function in order to set
2493 + * the exception descriptor when there is a change in link
2496 + g_monitor_task = current;
2497 + g_orig_fop_poll = g_monitor_file->f_op->poll;
2498 + g_monitor_file->f_op->poll = kerSysMonitorPollHook;
2503 + case BOARD_IOCTL_WAKEUP_MONITOR_TASK:
2504 + kerSysWakeupMonitorTask();
2509 + ctrlParms.result = 0;
2510 + printk("board_ioctl: invalid command %x, cmd %d .\n",command,_IOC_NR(command));
2517 +} /* board_ioctl */
2519 +/***************************************************************************
2520 + * SES Button ISR/GPIO/LED functions.
2521 + ***************************************************************************/
2522 +#if defined (WIRELESS)
2523 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs)
2525 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2526 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2527 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2529 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2530 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2531 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2533 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2534 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2535 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2537 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2539 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2540 + gpio_reg = &GPIO->GPIOio_high;
2544 + if (!(*gpio_reg & gpio_mask)){
2545 + wake_up_interruptible(&g_board_wait_queue);
2546 + return IRQ_RETVAL(1);
2548 + return IRQ_RETVAL(0);
2552 +static void __init sesBtn_mapGpio()
2554 + if( BpGetWirelessSesBtnGpio(&sesBtn_gpio) == BP_SUCCESS )
2556 + printk("SES: Button GPIO 0x%x is enabled\n", sesBtn_gpio);
2560 +static void __init sesBtn_mapIntr(int context)
2562 + if( BpGetWirelessSesExtIntr(&sesBtn_irq) == BP_SUCCESS )
2564 + printk("SES: Button Interrupt 0x%x is enabled\n", sesBtn_irq);
2569 + sesBtn_irq += INTERRUPT_ID_EXTERNAL_0;
2571 + if (BcmHalMapInterrupt((FN_HANDLER)sesBtn_isr, context, sesBtn_irq)) {
2572 + printk("SES: Interrupt mapping failed\n");
2574 + BcmHalInterruptEnable(sesBtn_irq);
2578 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait)
2580 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2581 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2582 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2584 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2585 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2586 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2588 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2589 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2590 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2592 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2594 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2595 + gpio_reg = &GPIO->GPIOio_high;
2599 + if (!(*gpio_reg & gpio_mask)){
2605 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
2607 + volatile unsigned int event=0;
2610 +#if defined(_BCM96338_) || defined (CONFIG_BCM96338)
2611 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2612 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2614 +#if defined(_BCM96345_) || defined (CONFIG_BCM96345)
2615 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2616 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2618 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2619 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2620 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2622 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2624 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2625 + gpio_reg = &GPIO->GPIOio_high;
2629 + if(*gpio_reg & gpio_mask){
2630 + BcmHalInterruptEnable(sesBtn_irq);
2633 + event = SES_EVENTS;
2634 + __copy_to_user((char*)buffer, (char*)&event, sizeof(event));
2635 + BcmHalInterruptEnable(sesBtn_irq);
2636 + count -= sizeof(event);
2637 + buffer += sizeof(event);
2638 + ret += sizeof(event);
2642 +static void __init sesLed_mapGpio()
2644 + if( BpGetWirelessSesBtnGpio(&sesLed_gpio) == BP_SUCCESS )
2646 + printk("SES: LED GPIO 0x%x is enabled\n", sesBtn_gpio);
2650 +static void sesLed_ctrl(int action)
2653 + //char status = ((action >> 8) & 0xff); /* extract status */
2654 + //char event = ((action >> 16) & 0xff); /* extract event */
2655 + //char blinktype = ((action >> 24) & 0xff); /* extract blink type for SES_LED_BLINK */
2657 + BOARD_LED_STATE led;
2659 + if(sesLed_gpio == BP_NOT_DEFINED)
2662 + action &= 0xff; /* extract led */
2664 + //printk("blinktype=%d, event=%d, status=%d\n",(int)blinktype, (int)event, (int)status);
2669 + //printk("SES: led on\n");
2670 + led = kLedStateOn;
2672 + case SES_LED_BLINK:
2673 + //printk("SES: led blink\n");
2674 + led = kLedStateSlowBlinkContinues;
2678 + //printk("SES: led off\n");
2679 + led = kLedStateOff;
2682 + kerSysLedCtrl(kLedSes, led);
2685 +static void __init ses_board_init()
2688 + sesBtn_mapIntr(0);
2691 +static void __exit ses_board_deinit()
2694 + BcmHalInterruptDisable(sesBtn_irq);
2698 +/***************************************************************************
2699 + * Dying gasp ISR and functions.
2700 + ***************************************************************************/
2701 +#define KERSYS_DBG printk
2703 +#if defined(CONFIG_BCM96345)
2704 +#define CYCLE_PER_US 70
2705 +#elif defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
2706 +/* The BCM6348 cycles per microsecond is really variable since the BCM6348
2707 + * MIPS speed can vary depending on the PLL settings. However, an appoximate
2708 + * value of 120 will still work OK for the test being done.
2710 +#define CYCLE_PER_US 120
2712 +#define DG_GLITCH_TO (100*CYCLE_PER_US)
2714 +static void __init kerSysDyingGaspMapIntr()
2716 + unsigned long ulIntr;
2718 +#if defined(CONFIG_BCM96348) || defined(_BCM96348_) || defined(CONFIG_BCM96338) || defined(_BCM96338_)
2719 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2720 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, INTERRUPT_ID_DG);
2721 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2723 +#elif defined(CONFIG_BCM96345) || defined(_BCM96345_)
2724 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2725 + ulIntr += INTERRUPT_ID_EXTERNAL_0;
2726 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, ulIntr);
2727 + BcmHalInterruptEnable( ulIntr );
2733 +void kerSysSetWdTimer(ulong timeUs)
2735 + TIMER->WatchDogDefCount = timeUs * (FPERIPH/1000000);
2736 + TIMER->WatchDogCtl = 0xFF00;
2737 + TIMER->WatchDogCtl = 0x00FF;
2740 +ulong kerSysGetCycleCount(void)
2746 + __asm volatile("mfc0 %0, $9":"=d"(cnt));
2751 +static Bool kerSysDyingGaspCheckPowerLoss(void)
2757 + clk0 = kerSysGetCycleCount();
2763 +#if defined(CONFIG_BCM96345)
2764 + BpGetAdslDyingGaspExtIntr( &ulIntr );
2769 + clk1 = kerSysGetCycleCount(); /* time cleared */
2770 + /* wait a little to get new reading */
2771 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2773 + } while ((0 == (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT)))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2775 + if (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT))) { /* power glitch */
2776 + BcmHalInterruptEnable( ulIntr + INTERRUPT_ID_EXTERNAL_0);
2777 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2780 +#elif (defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)) && !defined(VXWORKS)
2784 + clk1 = kerSysGetCycleCount(); /* time cleared */
2785 + /* wait a little to get new reading */
2786 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2788 + } while ((PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2790 + if (!(PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET)))) {
2791 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2792 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2799 +static void kerSysDyingGaspShutdown( void )
2801 + kerSysSetWdTimer(1000000);
2802 +#if defined(CONFIG_BCM96345)
2803 + PERF->blkEnables &= ~(EMAC_CLK_EN | USB_CLK_EN | CPU_CLK_EN);
2804 +#elif defined(CONFIG_BCM96348)
2805 + PERF->blkEnables &= ~(EMAC_CLK_EN | USBS_CLK_EN | USBH_CLK_EN | SAR_CLK_EN);
2809 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2810 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs)
2812 +static unsigned int kerSysDyingGaspIsr(void)
2815 + struct list_head *pos;
2816 + CB_DGASP_LIST *tmp, *dsl = NULL;
2818 + if (kerSysDyingGaspCheckPowerLoss()) {
2820 + /* first to turn off everything other than dsl */
2821 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2822 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2823 + if(strncmp(tmp->name, "dsl", 3)) {
2824 + (tmp->cb_dgasp_fn)(tmp->context);
2830 + /* now send dgasp */
2832 + (dsl->cb_dgasp_fn)(dsl->context);
2834 + /* reset and shutdown system */
2835 + kerSysDyingGaspShutdown();
2837 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2838 +return( IRQ_HANDLED );
2844 +static void __init kerSysInitDyingGaspHandler( void )
2846 + CB_DGASP_LIST *new_node;
2848 + if( g_cb_dgasp_list_head != NULL) {
2849 + printk("Error: kerSysInitDyingGaspHandler: list head is not null\n");
2852 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
2853 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
2854 + INIT_LIST_HEAD(&new_node->list);
2855 + g_cb_dgasp_list_head = new_node;
2857 +} /* kerSysInitDyingGaspHandler */
2859 +static void __exit kerSysDeinitDyingGaspHandler( void )
2861 + struct list_head *pos;
2862 + CB_DGASP_LIST *tmp;
2864 + if(g_cb_dgasp_list_head == NULL)
2867 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2868 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2873 + kfree(g_cb_dgasp_list_head);
2874 + g_cb_dgasp_list_head = NULL;
2876 +} /* kerSysDeinitDyingGaspHandler */
2878 +void kerSysRegisterDyingGaspHandler(char *devname, void *cbfn, void *context)
2880 + CB_DGASP_LIST *new_node;
2882 + if( g_cb_dgasp_list_head == NULL) {
2883 + printk("Error: kerSysRegisterDyingGaspHandler: list head is null\n");
2887 + if( devname == NULL || cbfn == NULL ) {
2888 + printk("Error: kerSysRegisterDyingGaspHandler: register info not enough (%s,%x,%x)\n", devname, (unsigned int)cbfn, (unsigned int)context);
2892 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
2893 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
2894 + INIT_LIST_HEAD(&new_node->list);
2895 + strncpy(new_node->name, devname, IFNAMSIZ);
2896 + new_node->cb_dgasp_fn = (cb_dgasp_t)cbfn;
2897 + new_node->context = context;
2898 + list_add(&new_node->list, &g_cb_dgasp_list_head->list);
2900 + printk("dgasp: kerSysRegisterDyingGaspHandler: %s registered \n", devname);
2902 +} /* kerSysRegisterDyingGaspHandler */
2904 +void kerSysDeregisterDyingGaspHandler(char *devname)
2906 + struct list_head *pos;
2907 + CB_DGASP_LIST *tmp;
2909 + if(g_cb_dgasp_list_head == NULL) {
2910 + printk("Error: kerSysDeregisterDyingGaspHandler: list head is null\n");
2914 + if(devname == NULL) {
2915 + printk("Error: kerSysDeregisterDyingGaspHandler: devname is null\n");
2919 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistering\n", devname);
2921 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2922 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2923 + if(!strcmp(tmp->name, devname)) {
2926 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistered\n", devname);
2930 + printk("kerSysDeregisterDyingGaspHandler: %s not (de)registered\n", devname);
2932 +} /* kerSysDeregisterDyingGaspHandler */
2934 +/***************************************************************************
2935 + * MACRO to call driver initialization and cleanup functions.
2936 + ***************************************************************************/
2937 +module_init( brcm_board_init );
2938 +module_exit( brcm_board_cleanup );
2940 +EXPORT_SYMBOL(kerSysNvRamGet);
2941 +EXPORT_SYMBOL(dumpaddr);
2942 +EXPORT_SYMBOL(kerSysGetMacAddress);
2943 +EXPORT_SYMBOL(kerSysReleaseMacAddress);
2944 +EXPORT_SYMBOL(kerSysGetSdramSize);
2945 +EXPORT_SYMBOL(kerSysLedCtrl);
2946 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2947 +EXPORT_SYMBOL(kerSysGetResetHold);
2948 +//>>JUNHON, 2004/09/15
2949 +EXPORT_SYMBOL(kerSysLedRegisterHwHandler);
2950 +EXPORT_SYMBOL(BpGetBoardIds);
2951 +EXPORT_SYMBOL(BpGetSdramSize);
2952 +EXPORT_SYMBOL(BpGetPsiSize);
2953 +EXPORT_SYMBOL(BpGetEthernetMacInfo);
2954 +EXPORT_SYMBOL(BpGetRj11InnerOuterPairGpios);
2955 +EXPORT_SYMBOL(BpGetPressAndHoldResetGpio);
2956 +EXPORT_SYMBOL(BpGetVoipResetGpio);
2957 +EXPORT_SYMBOL(BpGetVoipIntrGpio);
2958 +EXPORT_SYMBOL(BpGetPcmciaResetGpio);
2959 +EXPORT_SYMBOL(BpGetRtsCtsUartGpios);
2960 +EXPORT_SYMBOL(BpGetAdslLedGpio);
2961 +EXPORT_SYMBOL(BpGetAdslFailLedGpio);
2962 +EXPORT_SYMBOL(BpGetWirelessLedGpio);
2963 +EXPORT_SYMBOL(BpGetUsbLedGpio);
2964 +EXPORT_SYMBOL(BpGetHpnaLedGpio);
2965 +EXPORT_SYMBOL(BpGetWanDataLedGpio);
2966 +EXPORT_SYMBOL(BpGetPppLedGpio);
2967 +EXPORT_SYMBOL(BpGetPppFailLedGpio);
2968 +EXPORT_SYMBOL(BpGetVoipLedGpio);
2969 +EXPORT_SYMBOL(BpGetWirelessExtIntr);
2970 +EXPORT_SYMBOL(BpGetAdslDyingGaspExtIntr);
2971 +EXPORT_SYMBOL(BpGetVoipExtIntr);
2972 +EXPORT_SYMBOL(BpGetHpnaExtIntr);
2973 +EXPORT_SYMBOL(BpGetHpnaChipSelect);
2974 +EXPORT_SYMBOL(BpGetVoipChipSelect);
2975 +EXPORT_SYMBOL(BpGetWirelessSesBtnGpio);
2976 +EXPORT_SYMBOL(BpGetWirelessSesExtIntr);
2977 +EXPORT_SYMBOL(BpGetWirelessSesLedGpio);
2978 +EXPORT_SYMBOL(kerSysRegisterDyingGaspHandler);
2979 +EXPORT_SYMBOL(kerSysDeregisterDyingGaspHandler);
2980 +EXPORT_SYMBOL(kerSysGetCycleCount);
2981 +EXPORT_SYMBOL(kerSysSetWdTimer);
2982 +EXPORT_SYMBOL(kerSysWakeupMonitorTask);
2984 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/boardparms.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c
2985 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/boardparms.c 1970-01-01 01:00:00.000000000 +0100
2986 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c 2006-07-07 22:16:11.000000000 +0200
2991 + Copyright 2003 Broadcom Corp. All Rights Reserved.
2993 + This program is free software; you can distribute it and/or modify it
2994 + under the terms of the GNU General Public License (Version 2) as
2995 + published by the Free Software Foundation.
2997 + This program is distributed in the hope it will be useful, but WITHOUT
2998 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2999 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3002 + You should have received a copy of the GNU General Public License along
3003 + with this program; if not, write to the Free Software Foundation, Inc.,
3004 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
3008 +/**************************************************************************
3009 + * File Name : boardparms.c
3011 + * Description: This file contains the implementation for the BCM63xx board
3012 + * parameter access functions.
3014 + * Updates : 07/14/2003 Created.
3015 + ***************************************************************************/
3018 +#include "boardparms.h"
3022 +/* Default psi size in K bytes */
3023 +#define BP_PSI_DEFAULT_SIZE 24
3026 +typedef struct boardparameters
3028 + char szBoardId[BP_BOARD_ID_LEN]; /* board id string */
3029 + ETHERNET_MAC_INFO EnetMacInfos[BP_MAX_ENET_MACS];
3030 + VOIP_DSP_INFO VoIPDspInfo[BP_MAX_VOIP_DSP];
3031 + unsigned short usSdramSize; /* SDRAM size and type */
3032 + unsigned short usPsiSize; /* persistent storage in K bytes */
3033 + unsigned short usGpioRj11InnerPair; /* GPIO pin or not defined */
3034 + unsigned short usGpioRj11OuterPair; /* GPIO pin or not defined */
3035 + unsigned short usGpioPressAndHoldReset; /* GPIO pin or not defined */
3036 + unsigned short usGpioPcmciaReset; /* GPIO pin or not defined */
3037 + unsigned short usGpioUartRts; /* GPIO pin or not defined */
3038 + unsigned short usGpioUartCts; /* GPIO pin or not defined */
3039 + unsigned short usGpioLedAdsl; /* GPIO pin or not defined */
3040 + unsigned short usGpioLedAdslFail; /* GPIO pin or not defined */
3041 + unsigned short usGpioLedWireless; /* GPIO pin or not defined */
3042 + unsigned short usGpioLedUsb; /* GPIO pin or not defined */
3043 + unsigned short usGpioLedHpna; /* GPIO pin or not defined */
3044 + unsigned short usGpioLedWanData; /* GPIO pin or not defined */
3045 + unsigned short usGpioLedPpp; /* GPIO pin or not defined */
3046 + unsigned short usGpioLedPppFail; /* GPIO pin or not defined */
3047 + unsigned short usGpioLedBlPowerOn; /* GPIO pin or not defined */
3048 + unsigned short usGpioLedBlAlarm; /* GPIO pin or not defined */
3049 + unsigned short usGpioLedBlResetCfg; /* GPIO pin or not defined */
3050 + unsigned short usGpioLedBlStop; /* GPIO pin or not defined */
3051 + unsigned short usExtIntrWireless; /* ext intr or not defined */
3052 + unsigned short usExtIntrAdslDyingGasp; /* ext intr or not defined */
3053 + unsigned short usExtIntrHpna; /* ext intr or not defined */
3054 + unsigned short usCsHpna; /* chip select not defined */
3055 + unsigned short usAntInUseWireless; /* antenna in use or not defined */
3056 + unsigned short usGpioSesBtnWireless; /* GPIO pin or not defined */
3057 + unsigned short usExtIntrSesBtnWireless; /* ext intr or not defined */
3058 + unsigned short usGpioLedSesWireless; /* GPIO pin or not defined */
3059 +} BOARD_PARAMETERS, *PBOARD_PARAMETERS;
3062 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
3063 +static BOARD_PARAMETERS g_bcm96338sv =
3065 + "96338SV", /* szBoardId */
3066 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3067 + 0x01, /* ucPhyAddress */
3068 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3069 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3070 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3071 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3072 + BP_NOT_DEFINED, /* usGpioPhyReset */
3073 + 0x01, /* numSwitchPorts */
3074 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3075 + BP_NOT_DEFINED}, /* usReverseMii */
3076 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3077 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3078 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3079 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3080 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3081 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3082 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3083 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3084 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3085 + BP_NOT_DEFINED, /* usGpioUartRts */
3086 + BP_NOT_DEFINED, /* usGpioUartCts */
3087 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3088 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3089 + BP_NOT_DEFINED, /* usGpioLedWireless */
3090 + BP_NOT_DEFINED, /* usGpioLedUsb */
3091 + BP_NOT_DEFINED, /* usGpioLedHpna */
3092 + BP_NOT_DEFINED, /* usGpioLedWanData */
3093 + BP_NOT_DEFINED, /* usGpioLedPpp */
3094 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3095 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3096 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3097 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3098 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3099 + BP_NOT_DEFINED, /* usExtIntrWireless */
3100 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3101 + BP_NOT_DEFINED, /* usExtIntrHpna */
3102 + BP_NOT_DEFINED, /* usCsHpna */
3103 + BP_NOT_DEFINED, /* usAntInUseWireless */
3104 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3105 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3106 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3108 +static BOARD_PARAMETERS g_bcm96338l2m8m =
3110 + "96338L-2M-8M", /* szBoardId */
3111 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3112 + 0x01, /* ucPhyAddress */
3113 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3114 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3115 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3116 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3117 + BP_NOT_DEFINED, /* usGpioPhyReset */
3118 + 0x01, /* numSwitchPorts */
3119 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3120 + BP_NOT_DEFINED}, /* usReverseMii */
3121 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3122 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3123 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3124 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3125 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3126 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3127 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3128 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3129 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3130 + BP_NOT_DEFINED, /* usGpioUartRts */
3131 + BP_NOT_DEFINED, /* usGpioUartCts */
3132 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3133 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3134 + BP_NOT_DEFINED, /* usGpioLedWireless */
3135 + BP_NOT_DEFINED, /* usGpioLedUsb */
3136 + BP_NOT_DEFINED, /* usGpioLedHpna */
3137 + BP_GPIO_3_AL, /* usGpioLedWanData */
3138 + BP_GPIO_3_AL, /* usGpioLedPpp */
3139 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3140 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3141 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3142 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3143 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3144 + BP_NOT_DEFINED, /* usExtIntrWireless */
3145 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3146 + BP_NOT_DEFINED, /* usExtIntrHpna */
3147 + BP_NOT_DEFINED, /* usCsHpna */
3148 + BP_NOT_DEFINED, /* usAntInUseWireless */
3149 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3150 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3151 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3153 +static PBOARD_PARAMETERS g_BoardParms[] =
3154 + {&g_bcm96338sv, &g_bcm96338l2m8m, 0};
3157 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
3158 +static BOARD_PARAMETERS g_bcm96345r =
3160 + "96345R", /* szBoardId */
3161 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3162 + 0x01, /* ucPhyAddress */
3163 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3164 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3165 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3166 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3167 + BP_NOT_DEFINED, /* usGpioPhyReset */
3168 + 0x01, /* numSwitchPorts */
3169 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3170 + BP_NOT_DEFINED}, /* usReverseMii */
3171 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3172 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3173 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3174 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3175 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3176 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3177 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3178 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3179 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3180 + BP_NOT_DEFINED, /* usGpioUartRts */
3181 + BP_NOT_DEFINED, /* usGpioUartCts */
3182 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3183 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3184 + BP_NOT_DEFINED, /* usGpioLedWireless */
3185 + BP_NOT_DEFINED, /* usGpioLedUsb */
3186 + BP_NOT_DEFINED, /* usGpioLedHpna */
3187 + BP_GPIO_8_AH, /* usGpioLedWanData */
3188 + BP_GPIO_9_AH, /* usGpioLedPpp */
3189 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3190 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3191 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3192 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3193 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3194 + BP_NOT_DEFINED, /* usExtIntrWireless */
3195 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3196 + BP_NOT_DEFINED, /* usExtIntrHpna */
3197 + BP_NOT_DEFINED, /* usCsHpna */
3198 + BP_NOT_DEFINED, /* usAntInUseWireless */
3199 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3200 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3201 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3204 +static BOARD_PARAMETERS g_bcm96345gw2 =
3206 + /* A hardware jumper determines whether GPIO 13 is used for Press and Hold
3209 + "96345GW2", /* szBoardId */
3210 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3211 + 0x00, /* ucPhyAddress */
3212 + BP_GPIO_0_AH, /* usGpioPhySpiSck */
3213 + BP_GPIO_4_AH, /* usGpioPhySpiSs */
3214 + BP_GPIO_12_AH, /* usGpioPhySpiMosi */
3215 + BP_GPIO_11_AH, /* usGpioPhySpiMiso */
3216 + BP_NOT_DEFINED, /* usGpioPhyReset */
3217 + 0x04, /* numSwitchPorts */
3218 + BP_ENET_CONFIG_GPIO, /* usConfigType */
3219 + BP_ENET_REVERSE_MII}, /* usReverseMii */
3220 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3221 + {{BP_VOIP_DSP, /* ucDspType */
3222 + 0x00, /* ucDspAddress */
3223 + BP_EXT_INTR_1, /* usExtIntrVoip */
3224 + BP_GPIO_6_AH, /* usGpioVoipReset */
3225 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3226 + BP_NOT_DEFINED, /* usGpioLedVoip */
3227 + BP_CS_2}, /* usCsVoip */
3228 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3229 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3230 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3231 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3232 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3233 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3234 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3235 + BP_GPIO_13_AH, /* usGpioUartRts */
3236 + BP_GPIO_9_AH, /* usGpioUartCts */
3237 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3238 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3239 + BP_NOT_DEFINED, /* usGpioLedWireless */
3240 + BP_GPIO_7_AH, /* usGpioLedUsb */
3241 + BP_NOT_DEFINED, /* usGpioLedHpna */
3242 + BP_GPIO_8_AH, /* usGpioLedWanData */
3243 + BP_NOT_DEFINED, /* usGpioLedPpp */
3244 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3245 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3246 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3247 + BP_GPIO_7_AH, /* usGpioLedBlResetCfg */
3248 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3249 + BP_EXT_INTR_2, /* usExtIntrWireless */
3250 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3251 + BP_NOT_DEFINED, /* usExtIntrHpna */
3252 + BP_NOT_DEFINED, /* usCsHpna */
3253 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3254 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3255 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3256 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3259 +static BOARD_PARAMETERS g_bcm96345gw =
3261 + "96345GW", /* szBoardId */
3262 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3263 + 0x00, /* ucPhyAddress */
3264 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3265 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3266 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3267 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3268 + BP_NOT_DEFINED, /* usGpioPhyReset */
3269 + 0x04, /* numSwitchPorts */
3270 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3271 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3272 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3273 + {{BP_VOIP_DSP, /* ucDspType */
3274 + 0x00, /* ucDspAddress */
3275 + BP_EXT_INTR_1, /* usExtIntrVoip */
3276 + BP_GPIO_6_AH, /* usGpioVoipReset */
3277 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3278 + BP_NOT_DEFINED, /* usGpioLedVoip */
3279 + BP_CS_2}, /* usCsVoip */
3280 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3281 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3282 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3283 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3284 + BP_GPIO_1_AH, /* usGpioRj11OuterPair */
3285 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3286 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3287 + BP_NOT_DEFINED, /* usGpioUartRts */
3288 + BP_NOT_DEFINED, /* usGpioUartCts */
3289 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3290 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3291 + BP_GPIO_10_AH, /* usGpioLedWireless */
3292 + BP_GPIO_7_AH, /* usGpioLedUsb */
3293 + BP_NOT_DEFINED, /* usGpioLedHpna */
3294 + BP_GPIO_8_AH, /* usGpioLedWanData */
3295 + BP_NOT_DEFINED, /* usGpioLedPpp */
3296 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3297 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3298 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3299 + BP_GPIO_10_AH, /* usGpioLedBlResetCfg */
3300 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3301 + BP_EXT_INTR_2, /* usExtIntrWireless */
3302 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3303 + BP_EXT_INTR_3, /* usExtIntrHpna */
3304 + BP_CS_1, /* usCsHpna */
3305 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3306 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3307 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3308 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3311 +static BOARD_PARAMETERS g_bcm96335r =
3313 + "96335R", /* szBoardId */
3314 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3315 + 0x01, /* ucPhyAddress */
3316 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3317 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3318 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3319 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3320 + BP_NOT_DEFINED, /* usGpioPhyReset */
3321 + 0x01, /* numSwitchPorts */
3322 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3323 + BP_NOT_DEFINED}, /* usReverseMii */
3324 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3325 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3326 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3327 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3328 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3329 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3330 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3331 + BP_GPIO_14_AH, /* usGpioPressAndHoldReset */
3332 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3333 + BP_NOT_DEFINED, /* usGpioUartRts */
3334 + BP_NOT_DEFINED, /* usGpioUartCts */
3335 + BP_GPIO_9_AH, /* usGpioLedAdsl */
3336 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3337 + BP_NOT_DEFINED, /* usGpioLedWireless */
3338 + BP_NOT_DEFINED, /* usGpioLedUsb */
3339 + BP_NOT_DEFINED, /* usGpioLedHpna */
3340 + BP_GPIO_9_AH, /* usGpioLedWanData */
3341 + BP_GPIO_8_AH, /* usGpioLedPpp */
3342 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3343 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3344 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3345 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3346 + BP_GPIO_9_AH, /* usGpioLedBlStop */
3347 + BP_NOT_DEFINED, /* usExtIntrWireless */
3348 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3349 + BP_NOT_DEFINED, /* usExtIntrHpna */
3350 + BP_NOT_DEFINED, /* usCsHpna */
3351 + BP_NOT_DEFINED, /* usAntInUseWireless */
3352 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3353 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3354 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3357 +static BOARD_PARAMETERS g_bcm96345r0 =
3359 + "96345R0", /* szBoardId */
3360 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3361 + 0x01, /* ucPhyAddress */
3362 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3363 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3364 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3365 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3366 + BP_NOT_DEFINED, /* usGpioPhyReset */
3367 + 0x01, /* numSwitchPorts */
3368 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3369 + BP_NOT_DEFINED}, /* usReverseMii */
3370 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3371 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3372 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3373 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3374 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3375 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3376 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3377 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3378 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3379 + BP_NOT_DEFINED, /* usGpioUartRts */
3380 + BP_NOT_DEFINED, /* usGpioUartCts */
3381 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3382 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3383 + BP_NOT_DEFINED, /* usGpioLedWireless */
3384 + BP_NOT_DEFINED, /* usGpioLedUsb */
3385 + BP_NOT_DEFINED, /* usGpioLedHpna */
3386 + BP_GPIO_9_AH, /* usGpioLedWanData */
3387 + BP_GPIO_9_AH, /* usGpioLedPpp */
3388 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3389 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3390 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3391 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3392 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3393 + BP_NOT_DEFINED, /* usExtIntrWireless */
3394 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3395 + BP_NOT_DEFINED, /* usExtIntrHpna */
3396 + BP_NOT_DEFINED, /* usCsHpna */
3397 + BP_NOT_DEFINED, /* usAntInUseWireless */
3398 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3399 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3400 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3403 +static BOARD_PARAMETERS g_bcm96345rs =
3405 + "96345RS", /* szBoardId */
3406 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3407 + 0x00, /* ucPhyAddress */
3408 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3409 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3410 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3411 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3412 + BP_NOT_DEFINED, /* usGpioPhyReset */
3413 + 0x01, /* numSwitchPorts */
3414 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3415 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3416 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3417 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3418 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3419 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3420 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3421 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3422 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3423 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3424 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3425 + BP_NOT_DEFINED, /* usGpioUartRts */
3426 + BP_NOT_DEFINED, /* usGpioUartCts */
3427 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3428 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3429 + BP_NOT_DEFINED, /* usGpioLedWireless */
3430 + BP_NOT_DEFINED, /* usGpioLedUsb */
3431 + BP_NOT_DEFINED, /* usGpioLedHpna */
3432 + BP_GPIO_8_AH, /* usGpioLedWanData */
3433 + BP_GPIO_9_AH, /* usGpioLedPpp */
3434 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3435 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3436 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3437 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3438 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3439 + BP_NOT_DEFINED, /* usExtIntrWireless */
3440 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3441 + BP_NOT_DEFINED, /* usExtIntrHpna */
3442 + BP_NOT_DEFINED, /* usCsHpna */
3443 + BP_NOT_DEFINED, /* usAntInUseWireless */
3444 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3445 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3446 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3449 +static PBOARD_PARAMETERS g_BoardParms[] =
3450 + {&g_bcm96345r, &g_bcm96345gw2, &g_bcm96345gw, &g_bcm96335r, &g_bcm96345r0,
3451 + &g_bcm96345rs, 0};
3454 +#if defined(_BCM96348_) || defined(CONFIG_BCM96348)
3456 +static BOARD_PARAMETERS g_bcm96348r =
3458 + "96348R", /* szBoardId */
3459 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3460 + 0x01, /* ucPhyAddress */
3461 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3462 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3463 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3464 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3465 + BP_NOT_DEFINED, /* usGpioPhyReset */
3466 + 0x01, /* numSwitchPorts */
3467 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3468 + BP_NOT_DEFINED}, /* usReverseMii */
3469 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3470 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3471 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3472 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3473 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3474 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3475 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3476 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3477 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3478 + BP_NOT_DEFINED, /* usGpioUartRts */
3479 + BP_NOT_DEFINED, /* usGpioUartCts */
3480 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3481 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3482 + BP_NOT_DEFINED, /* usGpioLedWireless */
3483 + BP_NOT_DEFINED, /* usGpioLedUsb */
3484 + BP_NOT_DEFINED, /* usGpioLedHpna */
3485 + BP_GPIO_3_AL, /* usGpioLedWanData */
3486 + BP_GPIO_3_AL, /* usGpioLedPpp */
3487 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3488 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3489 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3490 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3491 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3492 + BP_NOT_DEFINED, /* usExtIntrWireless */
3493 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3494 + BP_NOT_DEFINED, /* usExtIntrHpna */
3495 + BP_NOT_DEFINED, /* usCsHpna */
3496 + BP_NOT_DEFINED, /* usAntInUseWireless */
3497 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3498 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3499 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3502 +static BOARD_PARAMETERS g_bcm96348lv =
3504 + "96348LV", /* szBoardId */
3505 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3506 + 0x01, /* ucPhyAddress */
3507 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3508 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3509 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3510 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3511 + BP_NOT_DEFINED, /* usGpioPhyReset */
3512 + 0x01, /* numSwitchPorts */
3513 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3514 + BP_NOT_DEFINED}, /* usReverseMii */
3515 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3516 + 0x02, /* ucPhyAddress */
3517 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3518 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3519 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3520 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3521 + BP_GPIO_5_AL, /* usGpioPhyReset */
3522 + 0x01, /* numSwitchPorts */
3523 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3524 + BP_NOT_DEFINED}}, /* usReverseMii */
3525 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3526 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3527 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3528 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3529 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3530 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3531 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3532 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3533 + BP_NOT_DEFINED, /* usGpioUartRts */
3534 + BP_NOT_DEFINED, /* usGpioUartCts */
3535 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3536 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3537 + BP_NOT_DEFINED, /* usGpioLedWireless */
3538 + BP_NOT_DEFINED, /* usGpioLedUsb */
3539 + BP_NOT_DEFINED, /* usGpioLedHpna */
3540 + BP_GPIO_3_AL, /* usGpioLedWanData */
3541 + BP_GPIO_3_AL, /* usGpioLedPpp */
3542 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3543 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3544 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3545 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3546 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3547 + BP_NOT_DEFINED, /* usExtIntrWireless */
3548 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3549 + BP_NOT_DEFINED, /* usExtIntrHpna */
3550 + BP_NOT_DEFINED, /* usCsHpna */
3551 + BP_NOT_DEFINED, /* usAntInUseWireless */
3552 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3553 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3554 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3557 +static BOARD_PARAMETERS g_bcm96348gw =
3559 + "96348GW", /* szBoardId */
3560 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3561 + 0x01, /* ucPhyAddress */
3562 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3563 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3564 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3565 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3566 + BP_NOT_DEFINED, /* usGpioPhyReset */
3567 + 0x01, /* numSwitchPorts */
3568 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3569 + BP_NOT_DEFINED}, /* usReverseMii */
3570 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3571 + 0x00, /* ucPhyAddress */
3572 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3573 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3574 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3575 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3576 + BP_NOT_DEFINED, /* usGpioPhyReset */
3577 + 0x03, /* numSwitchPorts */
3578 + BP_ENET_CONFIG_SPI_SSB_0, /* usConfigType */
3579 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3580 + {{BP_VOIP_DSP, /* ucDspType */
3581 + 0x00, /* ucDspAddress */
3582 + BP_EXT_INTR_2, /* usExtIntrVoip */
3583 + BP_GPIO_6_AH, /* usGpioVoipReset */
3584 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3585 + BP_NOT_DEFINED, /* usGpioLedVoip */
3586 + BP_CS_2}, /* usCsVoip */
3587 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3588 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3589 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3590 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3591 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3592 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3593 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3594 + BP_NOT_DEFINED, /* usGpioUartRts */
3595 + BP_NOT_DEFINED, /* usGpioUartCts */
3596 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3597 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3598 + BP_NOT_DEFINED, /* usGpioLedWireless */
3599 + BP_NOT_DEFINED, /* usGpioLedUsb */
3600 + BP_NOT_DEFINED, /* usGpioLedHpna */
3601 + BP_GPIO_3_AL, /* usGpioLedWanData */
3602 + BP_GPIO_3_AL, /* usGpioLedPpp */
3603 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3604 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3605 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3606 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3607 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3608 + BP_NOT_DEFINED, /* usExtIntrWireless */
3609 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3610 + BP_NOT_DEFINED, /* usExtIntrHpna */
3611 + BP_NOT_DEFINED, /* usCsHpna */
3612 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3613 + BP_NOT_DEFINED, /* BP_GPIO_35_AH, */ /* usGpioSesBtnWireless */
3614 + BP_NOT_DEFINED, /* BP_EXT_INTR_3, */ /* usExtIntrSesBtnWireless */
3615 + BP_NOT_DEFINED /* BP_GPIO_0_AL */ /* usGpioLedSesWireless */
3619 +static BOARD_PARAMETERS g_bcm96348gw_10 =
3621 + "96348GW-10", /* szBoardId */
3622 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3623 + 0x01, /* ucPhyAddress */
3624 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3625 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3626 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3627 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3628 + BP_NOT_DEFINED, /* usGpioPhyReset */
3629 + 0x01, /* numSwitchPorts */
3630 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3631 + BP_NOT_DEFINED}, /* usReverseMii */
3632 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3633 + 0x00, /* ucPhyAddress */
3634 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3635 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3636 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3637 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3638 + BP_NOT_DEFINED, /* usGpioPhyReset */
3639 + 0x03, /* numSwitchPorts */
3640 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3641 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3642 + {{BP_VOIP_DSP, /* ucDspType */
3643 + 0x00, /* ucDspAddress */
3644 + BP_EXT_INTR_2, /* usExtIntrVoip */
3645 + BP_GPIO_6_AH, /* usGpioVoipReset */
3646 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3647 + BP_NOT_DEFINED, /* usGpioLedVoip */
3648 + BP_CS_2}, /* usCsVoip */
3649 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3650 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3651 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3652 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3653 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3654 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3655 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3656 + BP_NOT_DEFINED, /* usGpioUartRts */
3657 + BP_NOT_DEFINED, /* usGpioUartCts */
3658 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3659 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3660 + BP_NOT_DEFINED, /* usGpioLedWireless */
3661 + BP_NOT_DEFINED, /* usGpioLedUsb */
3662 + BP_NOT_DEFINED, /* usGpioLedHpna */
3663 + BP_GPIO_3_AL, /* usGpioLedWanData */
3664 + BP_GPIO_3_AL, /* usGpioLedPpp */
3665 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3666 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3667 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3668 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3669 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3670 + BP_NOT_DEFINED, /* usExtIntrWireless */
3671 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3672 + BP_NOT_DEFINED, /* usExtIntrHpna */
3673 + BP_NOT_DEFINED, /* usCsHpna */
3674 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3675 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3676 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3677 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3680 +static BOARD_PARAMETERS g_bcm96348gw_11 =
3682 + "96348GW-11", /* szBoardId */
3683 + {{BP_ENET_NO_PHY}, /* ucPhyType */
3684 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3685 + 0x00, /* ucPhyAddress */
3686 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3687 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3688 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3689 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3690 + BP_NOT_DEFINED, /* usGpioPhyReset */
3691 + 0x04, /* numSwitchPorts */
3692 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3693 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3694 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3695 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3696 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3697 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3698 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3699 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3700 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3701 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3702 + BP_NOT_DEFINED, /* usGpioUartRts */
3703 + BP_NOT_DEFINED, /* usGpioUartCts */
3704 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3705 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3706 + BP_NOT_DEFINED, /* usGpioLedWireless */
3707 + BP_NOT_DEFINED, /* usGpioLedUsb */
3708 + BP_NOT_DEFINED, /* usGpioLedHpna */
3709 + BP_GPIO_3_AL, /* usGpioLedWanData */
3710 + BP_GPIO_3_AL, /* usGpioLedPpp */
3711 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3712 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3713 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3714 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3715 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3716 + BP_NOT_DEFINED, /* usExtIntrWireless */
3717 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3718 + BP_NOT_DEFINED, /* usExtIntrHpna */
3719 + BP_NOT_DEFINED, /* usCsHpna */
3720 + BP_NOT_DEFINED, /* usAntInUseWireless */
3721 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3722 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3723 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3726 +static BOARD_PARAMETERS g_bcm96348sv =
3728 + "96348SV", /* szBoardId */
3729 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3730 + 0x01, /* ucPhyAddress */
3731 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3732 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3733 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3734 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3735 + BP_NOT_DEFINED, /* usGpioPhyReset */
3736 + 0x01, /* numSwitchPorts */
3737 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3738 + BP_NOT_DEFINED}, /* usReverseMii */
3739 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3740 + 0x1f, /* ucPhyAddress */
3741 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3742 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3743 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3744 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3745 + BP_NOT_DEFINED, /* usGpioPhyReset */
3746 + 0x01, /* numSwitchPorts */
3747 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3748 + BP_NOT_DEFINED}}, /* usReverseMii */
3749 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3750 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3751 + BP_MEMORY_32MB_2_CHIP, /* usSdramSize */
3752 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3753 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3754 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3755 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3756 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3757 + BP_NOT_DEFINED, /* usGpioUartRts */
3758 + BP_NOT_DEFINED, /* usGpioUartCts */
3759 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3760 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3761 + BP_NOT_DEFINED, /* usGpioLedWireless */
3762 + BP_NOT_DEFINED, /* usGpioLedUsb */
3763 + BP_NOT_DEFINED, /* usGpioLedHpna */
3764 + BP_NOT_DEFINED, /* usGpioLedWanData */
3765 + BP_NOT_DEFINED, /* usGpioLedPpp */
3766 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3767 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3768 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3769 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3770 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3771 + BP_NOT_DEFINED, /* usExtIntrWireless */
3772 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3773 + BP_NOT_DEFINED, /* usExtIntrHpna */
3774 + BP_NOT_DEFINED, /* usCsHpna */
3775 + BP_NOT_DEFINED, /* usAntInUseWireless */
3776 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3777 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3778 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3782 +static BOARD_PARAMETERS g_bcm96348gw_dualDsp =
3784 + "96348GW-DualDSP", /* szBoardId */
3785 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3786 + 0x01, /* ucPhyAddress */
3787 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3788 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3789 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3790 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3791 + BP_NOT_DEFINED, /* usGpioPhyReset */
3792 + 0x01, /* numSwitchPorts */
3793 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3794 + BP_NOT_DEFINED}, /* usReverseMii */
3795 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3796 + 0x00, /* ucPhyAddress */
3797 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3798 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3799 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3800 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3801 + BP_NOT_DEFINED, /* usGpioPhyReset */
3802 + 0x03, /* numSwitchPorts */
3803 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3804 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3805 + {{BP_VOIP_DSP, /* ucDspType */
3806 + 0x00, /* ucDspAddress */
3807 + BP_EXT_INTR_2, /* usExtIntrVoip */
3808 + BP_UNEQUIPPED, /* usGpioVoipReset */
3809 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3810 + BP_NOT_DEFINED, /* usGpioLedVoip */
3811 + BP_CS_2}, /* usCsVoip */
3812 + {BP_VOIP_DSP, /* ucDspType */
3813 + 0x01, /* ucDspAddress */
3814 + BP_EXT_INTR_3, /* usExtIntrVoip */
3815 + BP_UNEQUIPPED , /* usGpioVoipReset */
3816 + BP_GPIO_35_AH, /* usGpioVoipIntr */
3817 + BP_NOT_DEFINED, /* usGpioLedVoip */
3818 + BP_CS_3}}, /* usCsVoip */
3819 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3820 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3821 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3822 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3823 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3824 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3825 + BP_NOT_DEFINED, /* usGpioUartRts */
3826 + BP_NOT_DEFINED, /* usGpioUartCts */
3827 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3828 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3829 + BP_NOT_DEFINED, /* usGpioLedWireless */
3830 + BP_NOT_DEFINED, /* usGpioLedUsb */
3831 + BP_NOT_DEFINED, /* usGpioLedHpna */
3832 + BP_GPIO_3_AL, /* usGpioLedWanData */
3833 + BP_GPIO_3_AL, /* usGpioLedPpp */
3834 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3835 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3836 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3837 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3838 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3839 + BP_NOT_DEFINED, /* usExtIntrWireless */
3840 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3841 + BP_NOT_DEFINED, /* usExtIntrHpna */
3842 + BP_NOT_DEFINED, /* usCsHpna */
3843 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3844 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3845 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3846 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3850 +static BOARD_PARAMETERS g_bcmCustom_01 =
3852 + "BCMCUST_01", /* szBoardId */
3853 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3854 + 0x01, /* ucPhyAddress */
3855 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3856 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3857 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3858 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3859 + BP_NOT_DEFINED, /* usGpioPhyReset */
3860 + 0x01, /* numSwitchPorts */
3861 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3862 + BP_NOT_DEFINED}, /* usReverseMii */
3863 + {BP_ENET_NO_PHY, /* ucPhyType */
3864 + 0x00, /* ucPhyAddress */
3865 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3866 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3867 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3868 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3869 + BP_NOT_DEFINED, /* usGpioPhyReset */
3870 + 0x01, /* numSwitchPorts */
3871 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3872 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3873 + {{BP_VOIP_DSP, /* ucDspType */
3874 + 0x00, /* ucDspAddress */
3875 + BP_EXT_INTR_2, /* usExtIntrVoip */
3876 + BP_GPIO_36_AH, /* usGpioVoipReset */
3877 + BP_GPIO_34_AL, /* usGpioVoipIntr */
3878 + BP_NOT_DEFINED, /* usGpioLedVoip */
3879 + BP_CS_2}, /* usCsVoip */
3880 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3881 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3882 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3883 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3884 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3885 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3886 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3887 + BP_NOT_DEFINED, /* usGpioUartRts */
3888 + BP_NOT_DEFINED, /* usGpioUartCts */
3889 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3890 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3891 + BP_NOT_DEFINED, /* usGpioLedWireless */
3892 + BP_NOT_DEFINED, /* usGpioLedUsb */
3893 + BP_NOT_DEFINED, /* usGpioLedHpna */
3894 + BP_GPIO_3_AL, /* usGpioLedWanData */
3895 + BP_GPIO_3_AL, /* usGpioLedPpp */
3896 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3897 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3898 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3899 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3900 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3901 + BP_NOT_DEFINED, /* usExtIntrWireless */
3902 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3903 + BP_NOT_DEFINED, /* usExtIntrHpna */
3904 + BP_NOT_DEFINED, /* usCsHpna */
3905 + BP_NOT_DEFINED, /* usAntInUseWireless */
3906 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3907 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3908 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3911 +static PBOARD_PARAMETERS g_BoardParms[] =
3912 + {&g_bcm96348r, &g_bcm96348lv, &g_bcm96348gw, &g_bcm96348gw_10,
3913 + &g_bcm96348gw_11, &g_bcm96348sv, &g_bcm96348gw_dualDsp,
3914 + &g_bcmCustom_01, 0};
3917 +static PBOARD_PARAMETERS g_pCurrentBp = 0;
3919 +/**************************************************************************
3922 + * Description: String compare for this file so it does not depend on an OS.
3923 + * (Linux kernel and CFE share this source file.)
3925 + * Parameters : [IN] dest - destination string
3926 + * [IN] src - source string
3928 + * Returns : -1 - dest < src, 1 - dest > src, 0 dest == src
3929 + ***************************************************************************/
3930 +static int bpstrcmp(const char *dest,const char *src);
3931 +static int bpstrcmp(const char *dest,const char *src)
3933 + while (*src && *dest)
3935 + if (*dest < *src) return -1;
3936 + if (*dest > *src) return 1;
3941 + if (*dest && !*src) return 1;
3942 + if (!*dest && *src) return -1;
3946 +/**************************************************************************
3947 + * Name : BpGetVoipDspConfig
3949 + * Description: Gets the DSP configuration from the board parameter
3950 + * structure for a given DSP index.
3952 + * Parameters : [IN] dspNum - DSP index (number)
3954 + * Returns : Pointer to DSP configuration block if found/valid, NULL
3956 + ***************************************************************************/
3957 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum );
3958 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum )
3960 + VOIP_DSP_INFO *pDspConfig = 0;
3963 + if( g_pCurrentBp )
3965 + for( i = 0 ; i < BP_MAX_VOIP_DSP ; i++ )
3967 + if( g_pCurrentBp->VoIPDspInfo[i].ucDspType != BP_VOIP_NO_DSP &&
3968 + g_pCurrentBp->VoIPDspInfo[i].ucDspAddress == dspNum )
3970 + pDspConfig = &g_pCurrentBp->VoIPDspInfo[i];
3976 + return pDspConfig;
3980 +/**************************************************************************
3981 + * Name : BpSetBoardId
3983 + * Description: This function find the BOARD_PARAMETERS structure for the
3984 + * specified board id string and assigns it to a global, static
3987 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
3989 + * Returns : BP_SUCCESS - Success, value is returned.
3990 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
3991 + * have a board parameters configuration record.
3992 + ***************************************************************************/
3993 +int BpSetBoardId( char *pszBoardId )
3995 + int nRet = BP_BOARD_ID_NOT_FOUND;
3996 + PBOARD_PARAMETERS *ppBp;
3998 + for( ppBp = g_BoardParms; *ppBp; ppBp++ )
4000 + if( !bpstrcmp((*ppBp)->szBoardId, pszBoardId) )
4002 + g_pCurrentBp = *ppBp;
4003 + nRet = BP_SUCCESS;
4009 +} /* BpSetBoardId */
4011 +/**************************************************************************
4012 + * Name : BpGetBoardIds
4014 + * Description: This function returns all of the supported board id strings.
4016 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
4017 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
4019 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
4020 + * were allocated in pszBoardIds.
4022 + * Returns : Number of board id strings returned.
4023 + ***************************************************************************/
4024 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize )
4026 + PBOARD_PARAMETERS *ppBp;
4031 + for( i = 0, ppBp = g_BoardParms; *ppBp && nBoardIdsSize;
4032 + i++, ppBp++, nBoardIdsSize--, pszBoardIds += BP_BOARD_ID_LEN )
4034 + dest = pszBoardIds;
4035 + src = (*ppBp)->szBoardId;
4042 +} /* BpGetBoardIds */
4044 +/**************************************************************************
4045 + * Name : BpGetEthernetMacInfo
4047 + * Description: This function returns all of the supported board id strings.
4049 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
4051 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
4052 + * are pointed to by pEnetInfos.
4054 + * Returns : BP_SUCCESS - Success, value is returned.
4055 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4056 + ***************************************************************************/
4057 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos )
4061 + if( g_pCurrentBp )
4063 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4065 + if( i < BP_MAX_ENET_MACS )
4067 + unsigned char *src = (unsigned char *)
4068 + &g_pCurrentBp->EnetMacInfos[i];
4069 + unsigned char *dest = (unsigned char *) pEnetInfos;
4070 + int len = sizeof(ETHERNET_MAC_INFO);
4075 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4078 + nRet = BP_SUCCESS;
4082 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4083 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4085 + nRet = BP_BOARD_ID_NOT_SET;
4089 +} /* BpGetEthernetMacInfo */
4091 +/**************************************************************************
4092 + * Name : BpGetSdramSize
4094 + * Description: This function returns a constant that describees the board's
4095 + * SDRAM type and size.
4097 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
4100 + * Returns : BP_SUCCESS - Success, value is returned.
4101 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4102 + ***************************************************************************/
4103 +int BpGetSdramSize( unsigned long *pulSdramSize )
4107 + if( g_pCurrentBp )
4109 + *pulSdramSize = g_pCurrentBp->usSdramSize;
4110 + nRet = BP_SUCCESS;
4114 + *pulSdramSize = BP_NOT_DEFINED;
4115 + nRet = BP_BOARD_ID_NOT_SET;
4119 +} /* BpGetSdramSize */
4121 +/**************************************************************************
4122 + * Name : BpGetPsiSize
4124 + * Description: This function returns the persistent storage size in K bytes.
4126 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
4127 + * storage size is returned in.
4129 + * Returns : BP_SUCCESS - Success, value is returned.
4130 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4131 + ***************************************************************************/
4132 +int BpGetPsiSize( unsigned long *pulPsiSize )
4136 + if( g_pCurrentBp )
4138 + *pulPsiSize = g_pCurrentBp->usPsiSize;
4139 + nRet = BP_SUCCESS;
4143 + *pulPsiSize = BP_NOT_DEFINED;
4144 + nRet = BP_BOARD_ID_NOT_SET;
4148 +} /* BpGetPsiSize */
4150 +/**************************************************************************
4151 + * Name : BpGetRj11InnerOuterPairGpios
4153 + * Description: This function returns the GPIO pin assignments for changing
4154 + * between the RJ11 inner pair and RJ11 outer pair.
4156 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
4157 + * GPIO pin is returned in.
4158 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
4159 + * GPIO pin is returned in.
4161 + * Returns : BP_SUCCESS - Success, values are returned.
4162 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4163 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4165 + ***************************************************************************/
4166 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
4167 + unsigned short *pusOuter )
4171 + if( g_pCurrentBp )
4173 + *pusInner = g_pCurrentBp->usGpioRj11InnerPair;
4174 + *pusOuter = g_pCurrentBp->usGpioRj11OuterPair;
4176 + if( g_pCurrentBp->usGpioRj11InnerPair != BP_NOT_DEFINED &&
4177 + g_pCurrentBp->usGpioRj11OuterPair != BP_NOT_DEFINED )
4179 + nRet = BP_SUCCESS;
4183 + nRet = BP_VALUE_NOT_DEFINED;
4188 + *pusInner = *pusOuter = BP_NOT_DEFINED;
4189 + nRet = BP_BOARD_ID_NOT_SET;
4193 +} /* BpGetRj11InnerOuterPairGpios */
4195 +/**************************************************************************
4196 + * Name : BpGetPressAndHoldResetGpio
4198 + * Description: This function returns the GPIO pin assignment for the press
4199 + * and hold reset button.
4201 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
4202 + * reset button GPIO pin is returned in.
4204 + * Returns : BP_SUCCESS - Success, value is returned.
4205 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4206 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4208 + ***************************************************************************/
4209 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue )
4213 + if( g_pCurrentBp )
4215 + *pusValue = g_pCurrentBp->usGpioPressAndHoldReset;
4217 + if( g_pCurrentBp->usGpioPressAndHoldReset != BP_NOT_DEFINED )
4219 + nRet = BP_SUCCESS;
4223 + nRet = BP_VALUE_NOT_DEFINED;
4228 + *pusValue = BP_NOT_DEFINED;
4229 + nRet = BP_BOARD_ID_NOT_SET;
4233 +} /* BpGetPressAndHoldResetGpio */
4235 +/**************************************************************************
4236 + * Name : BpGetVoipResetGpio
4238 + * Description: This function returns the GPIO pin assignment for the VOIP
4239 + * Reset operation.
4241 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
4242 + * GPIO pin is returned in.
4243 + * [IN] dspNum - Address of the DSP to query.
4245 + * Returns : BP_SUCCESS - Success, value is returned.
4246 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4247 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4249 + ***************************************************************************/
4250 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue )
4254 + if( g_pCurrentBp )
4256 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4260 + *pusValue = pDspInfo->usGpioVoipReset;
4262 + if( *pusValue != BP_NOT_DEFINED ||
4263 + *pusValue == BP_UNEQUIPPED )
4265 + nRet = BP_SUCCESS;
4269 + nRet = BP_VALUE_NOT_DEFINED;
4274 + *pusValue = BP_NOT_DEFINED;
4275 + nRet = BP_BOARD_ID_NOT_FOUND;
4280 + *pusValue = BP_NOT_DEFINED;
4281 + nRet = BP_BOARD_ID_NOT_SET;
4285 +} /* BpGetVoipResetGpio */
4287 +/**************************************************************************
4288 + * Name : BpGetVoipIntrGpio
4290 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
4292 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
4293 + * GPIO pin is returned in.
4294 + * [IN] dspNum - Address of the DSP to query.
4296 + * Returns : BP_SUCCESS - Success, value is returned.
4297 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4298 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4300 + ***************************************************************************/
4301 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue )
4305 + if( g_pCurrentBp )
4307 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4311 + *pusValue = pDspInfo->usGpioVoipIntr;
4313 + if( *pusValue != BP_NOT_DEFINED )
4315 + nRet = BP_SUCCESS;
4319 + nRet = BP_VALUE_NOT_DEFINED;
4324 + *pusValue = BP_NOT_DEFINED;
4325 + nRet = BP_BOARD_ID_NOT_FOUND;
4330 + *pusValue = BP_NOT_DEFINED;
4331 + nRet = BP_BOARD_ID_NOT_SET;
4335 +} /* BpGetVoipIntrGpio */
4337 +/**************************************************************************
4338 + * Name : BpGetPcmciaResetGpio
4340 + * Description: This function returns the GPIO pin assignment for the PCMCIA
4341 + * Reset operation.
4343 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
4344 + * GPIO pin is returned in.
4346 + * Returns : BP_SUCCESS - Success, value is returned.
4347 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4348 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4350 + ***************************************************************************/
4351 +int BpGetPcmciaResetGpio( unsigned short *pusValue )
4355 + if( g_pCurrentBp )
4357 + *pusValue = g_pCurrentBp->usGpioPcmciaReset;
4359 + if( g_pCurrentBp->usGpioPcmciaReset != BP_NOT_DEFINED )
4361 + nRet = BP_SUCCESS;
4365 + nRet = BP_VALUE_NOT_DEFINED;
4370 + *pusValue = BP_NOT_DEFINED;
4371 + nRet = BP_BOARD_ID_NOT_SET;
4375 +} /* BpGetPcmciaResetGpio */
4377 +/**************************************************************************
4378 + * Name : BpGetUartRtsCtsGpios
4380 + * Description: This function returns the GPIO pin assignments for RTS and CTS
4383 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
4384 + * pin is returned in.
4385 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
4386 + * pin is returned in.
4388 + * Returns : BP_SUCCESS - Success, values are returned.
4389 + * BP_BOARD_ID_NOT_SET - Error, board id input string does not
4390 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4392 + ***************************************************************************/
4393 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts )
4397 + if( g_pCurrentBp )
4399 + *pusRts = g_pCurrentBp->usGpioUartRts;
4400 + *pusCts = g_pCurrentBp->usGpioUartCts;
4402 + if( g_pCurrentBp->usGpioUartRts != BP_NOT_DEFINED &&
4403 + g_pCurrentBp->usGpioUartCts != BP_NOT_DEFINED )
4405 + nRet = BP_SUCCESS;
4409 + nRet = BP_VALUE_NOT_DEFINED;
4414 + *pusRts = *pusCts = BP_NOT_DEFINED;
4415 + nRet = BP_BOARD_ID_NOT_SET;
4419 +} /* BpGetUartRtsCtsGpios */
4421 +/**************************************************************************
4422 + * Name : BpGetAdslLedGpio
4424 + * Description: This function returns the GPIO pin assignment for the ADSL
4427 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4428 + * GPIO pin is returned in.
4430 + * Returns : BP_SUCCESS - Success, value is returned.
4431 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4432 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4434 + ***************************************************************************/
4435 +int BpGetAdslLedGpio( unsigned short *pusValue )
4439 + if( g_pCurrentBp )
4441 + *pusValue = g_pCurrentBp->usGpioLedAdsl;
4443 + if( g_pCurrentBp->usGpioLedAdsl != BP_NOT_DEFINED )
4445 + nRet = BP_SUCCESS;
4449 + nRet = BP_VALUE_NOT_DEFINED;
4454 + *pusValue = BP_NOT_DEFINED;
4455 + nRet = BP_BOARD_ID_NOT_SET;
4459 +} /* BpGetAdslLedGpio */
4461 +/**************************************************************************
4462 + * Name : BpGetAdslFailLedGpio
4464 + * Description: This function returns the GPIO pin assignment for the ADSL
4465 + * LED that is used when there is a DSL connection failure.
4467 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4468 + * GPIO pin is returned in.
4470 + * Returns : BP_SUCCESS - Success, value is returned.
4471 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4472 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4474 + ***************************************************************************/
4475 +int BpGetAdslFailLedGpio( unsigned short *pusValue )
4479 + if( g_pCurrentBp )
4481 + *pusValue = g_pCurrentBp->usGpioLedAdslFail;
4483 + if( g_pCurrentBp->usGpioLedAdslFail != BP_NOT_DEFINED )
4485 + nRet = BP_SUCCESS;
4489 + nRet = BP_VALUE_NOT_DEFINED;
4494 + *pusValue = BP_NOT_DEFINED;
4495 + nRet = BP_BOARD_ID_NOT_SET;
4499 +} /* BpGetAdslFailLedGpio */
4501 +/**************************************************************************
4502 + * Name : BpGetWirelessLedGpio
4504 + * Description: This function returns the GPIO pin assignment for the Wireless
4507 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4508 + * GPIO pin is returned in.
4510 + * Returns : BP_SUCCESS - Success, value is returned.
4511 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4512 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4514 + ***************************************************************************/
4515 +int BpGetWirelessLedGpio( unsigned short *pusValue )
4519 + if( g_pCurrentBp )
4521 + *pusValue = g_pCurrentBp->usGpioLedWireless;
4523 + if( g_pCurrentBp->usGpioLedWireless != BP_NOT_DEFINED )
4525 + nRet = BP_SUCCESS;
4529 + nRet = BP_VALUE_NOT_DEFINED;
4534 + *pusValue = BP_NOT_DEFINED;
4535 + nRet = BP_BOARD_ID_NOT_SET;
4539 +} /* BpGetWirelessLedGpio */
4541 +/**************************************************************************
4542 + * Name : BpGetWirelessAntInUse
4544 + * Description: This function returns the antennas in use for wireless
4546 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
4549 + * Returns : BP_SUCCESS - Success, value is returned.
4550 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4551 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4553 + ***************************************************************************/
4554 +int BpGetWirelessAntInUse( unsigned short *pusValue )
4558 + if( g_pCurrentBp )
4560 + *pusValue = g_pCurrentBp->usAntInUseWireless;
4562 + if( g_pCurrentBp->usAntInUseWireless != BP_NOT_DEFINED )
4564 + nRet = BP_SUCCESS;
4568 + nRet = BP_VALUE_NOT_DEFINED;
4573 + *pusValue = BP_NOT_DEFINED;
4574 + nRet = BP_BOARD_ID_NOT_SET;
4578 +} /* BpGetWirelessAntInUse */
4580 +/**************************************************************************
4581 + * Name : BpGetWirelessSesBtnGpio
4583 + * Description: This function returns the GPIO pin assignment for the Wireless
4586 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4587 + * GPIO pin is returned in.
4589 + * Returns : BP_SUCCESS - Success, value is returned.
4590 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4591 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4593 + ***************************************************************************/
4594 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue )
4598 + if( g_pCurrentBp )
4600 + *pusValue = g_pCurrentBp->usGpioSesBtnWireless;
4602 + if( g_pCurrentBp->usGpioSesBtnWireless != BP_NOT_DEFINED )
4604 + nRet = BP_SUCCESS;
4608 + nRet = BP_VALUE_NOT_DEFINED;
4613 + *pusValue = BP_NOT_DEFINED;
4614 + nRet = BP_BOARD_ID_NOT_SET;
4618 +} /* BpGetWirelessSesBtnGpio */
4620 +/**************************************************************************
4621 + * Name : BpGetWirelessSesExtIntr
4623 + * Description: This function returns the external interrupt number for the
4624 + * Wireless Ses Button.
4626 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4627 + * external interrup is returned in.
4629 + * Returns : BP_SUCCESS - Success, value is returned.
4630 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4631 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4633 + ***************************************************************************/
4634 +int BpGetWirelessSesExtIntr( unsigned short *pusValue )
4638 + if( g_pCurrentBp )
4640 + *pusValue = g_pCurrentBp->usExtIntrSesBtnWireless;
4642 + if( g_pCurrentBp->usExtIntrSesBtnWireless != BP_NOT_DEFINED )
4644 + nRet = BP_SUCCESS;
4648 + nRet = BP_VALUE_NOT_DEFINED;
4653 + *pusValue = BP_NOT_DEFINED;
4654 + nRet = BP_BOARD_ID_NOT_SET;
4659 +} /* BpGetWirelessSesExtIntr */
4661 +/**************************************************************************
4662 + * Name : BpGetWirelessSesLedGpio
4664 + * Description: This function returns the GPIO pin assignment for the Wireless
4667 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4668 + * Led GPIO pin is returned in.
4670 + * Returns : BP_SUCCESS - Success, value is returned.
4671 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4672 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4674 + ***************************************************************************/
4675 +int BpGetWirelessSesLedGpio( unsigned short *pusValue )
4679 + if( g_pCurrentBp )
4681 + *pusValue = g_pCurrentBp->usGpioLedSesWireless;
4683 + if( g_pCurrentBp->usGpioLedSesWireless != BP_NOT_DEFINED )
4685 + nRet = BP_SUCCESS;
4689 + nRet = BP_VALUE_NOT_DEFINED;
4694 + *pusValue = BP_NOT_DEFINED;
4695 + nRet = BP_BOARD_ID_NOT_SET;
4700 +} /* BpGetWirelessSesLedGpio */
4702 +/**************************************************************************
4703 + * Name : BpGetUsbLedGpio
4705 + * Description: This function returns the GPIO pin assignment for the USB
4708 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
4709 + * GPIO pin is returned in.
4711 + * Returns : BP_SUCCESS - Success, value is returned.
4712 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4713 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4715 + ***************************************************************************/
4716 +int BpGetUsbLedGpio( unsigned short *pusValue )
4720 + if( g_pCurrentBp )
4722 + *pusValue = g_pCurrentBp->usGpioLedUsb;
4724 + if( g_pCurrentBp->usGpioLedUsb != BP_NOT_DEFINED )
4726 + nRet = BP_SUCCESS;
4730 + nRet = BP_VALUE_NOT_DEFINED;
4735 + *pusValue = BP_NOT_DEFINED;
4736 + nRet = BP_BOARD_ID_NOT_SET;
4740 +} /* BpGetUsbLedGpio */
4742 +/**************************************************************************
4743 + * Name : BpGetHpnaLedGpio
4745 + * Description: This function returns the GPIO pin assignment for the HPNA
4748 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
4749 + * GPIO pin is returned in.
4751 + * Returns : BP_SUCCESS - Success, value is returned.
4752 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4753 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4755 + ***************************************************************************/
4756 +int BpGetHpnaLedGpio( unsigned short *pusValue )
4760 + if( g_pCurrentBp )
4762 + *pusValue = g_pCurrentBp->usGpioLedHpna;
4764 + if( g_pCurrentBp->usGpioLedHpna != BP_NOT_DEFINED )
4766 + nRet = BP_SUCCESS;
4770 + nRet = BP_VALUE_NOT_DEFINED;
4775 + *pusValue = BP_NOT_DEFINED;
4776 + nRet = BP_BOARD_ID_NOT_SET;
4780 +} /* BpGetHpnaLedGpio */
4782 +/**************************************************************************
4783 + * Name : BpGetWanDataLedGpio
4785 + * Description: This function returns the GPIO pin assignment for the WAN Data
4788 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
4789 + * GPIO pin is returned in.
4791 + * Returns : BP_SUCCESS - Success, value is returned.
4792 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4793 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4795 + ***************************************************************************/
4796 +int BpGetWanDataLedGpio( unsigned short *pusValue )
4800 + if( g_pCurrentBp )
4802 + *pusValue = g_pCurrentBp->usGpioLedWanData;
4804 + if( g_pCurrentBp->usGpioLedWanData != BP_NOT_DEFINED )
4806 + nRet = BP_SUCCESS;
4810 + nRet = BP_VALUE_NOT_DEFINED;
4815 + *pusValue = BP_NOT_DEFINED;
4816 + nRet = BP_BOARD_ID_NOT_SET;
4820 +} /* BpGetWanDataLedGpio */
4822 +/**************************************************************************
4823 + * Name : BpGetPppLedGpio
4825 + * Description: This function returns the GPIO pin assignment for the PPP
4828 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4829 + * GPIO pin is returned in.
4831 + * Returns : BP_SUCCESS - Success, value is returned.
4832 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4833 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4835 + ***************************************************************************/
4836 +int BpGetPppLedGpio( unsigned short *pusValue )
4840 + if( g_pCurrentBp )
4842 + *pusValue = g_pCurrentBp->usGpioLedPpp;
4844 + if( g_pCurrentBp->usGpioLedPpp != BP_NOT_DEFINED )
4846 + nRet = BP_SUCCESS;
4850 + nRet = BP_VALUE_NOT_DEFINED;
4855 + *pusValue = BP_NOT_DEFINED;
4856 + nRet = BP_BOARD_ID_NOT_SET;
4860 +} /* BpGetPppLedGpio */
4862 +/**************************************************************************
4863 + * Name : BpGetPppFailLedGpio
4865 + * Description: This function returns the GPIO pin assignment for the PPP
4866 + * LED that is used when there is a PPP connection failure.
4868 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4869 + * GPIO pin is returned in.
4871 + * Returns : BP_SUCCESS - Success, value is returned.
4872 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4873 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4875 + ***************************************************************************/
4876 +int BpGetPppFailLedGpio( unsigned short *pusValue )
4880 + if( g_pCurrentBp )
4882 + *pusValue = g_pCurrentBp->usGpioLedPppFail;
4884 + if( g_pCurrentBp->usGpioLedPppFail != BP_NOT_DEFINED )
4886 + nRet = BP_SUCCESS;
4890 + nRet = BP_VALUE_NOT_DEFINED;
4895 + *pusValue = BP_NOT_DEFINED;
4896 + nRet = BP_BOARD_ID_NOT_SET;
4900 +} /* BpGetPppFailLedGpio */
4902 +/**************************************************************************
4903 + * Name : BpGetBootloaderPowerOnLedGpio
4905 + * Description: This function returns the GPIO pin assignment for the power
4906 + * on LED that is set by the bootloader.
4908 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
4909 + * GPIO pin is returned in.
4911 + * Returns : BP_SUCCESS - Success, value is returned.
4912 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4913 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4915 + ***************************************************************************/
4916 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue )
4920 + if( g_pCurrentBp )
4922 + *pusValue = g_pCurrentBp->usGpioLedBlPowerOn;
4924 + if( g_pCurrentBp->usGpioLedBlPowerOn != BP_NOT_DEFINED )
4926 + nRet = BP_SUCCESS;
4930 + nRet = BP_VALUE_NOT_DEFINED;
4935 + *pusValue = BP_NOT_DEFINED;
4936 + nRet = BP_BOARD_ID_NOT_SET;
4940 +} /* BpGetBootloaderPowerOn */
4942 +/**************************************************************************
4943 + * Name : BpGetBootloaderAlarmLedGpio
4945 + * Description: This function returns the GPIO pin assignment for the alarm
4946 + * LED that is set by the bootloader.
4948 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
4949 + * GPIO pin is returned in.
4951 + * Returns : BP_SUCCESS - Success, value is returned.
4952 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4953 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4955 + ***************************************************************************/
4956 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue )
4960 + if( g_pCurrentBp )
4962 + *pusValue = g_pCurrentBp->usGpioLedBlAlarm;
4964 + if( g_pCurrentBp->usGpioLedBlAlarm != BP_NOT_DEFINED )
4966 + nRet = BP_SUCCESS;
4970 + nRet = BP_VALUE_NOT_DEFINED;
4975 + *pusValue = BP_NOT_DEFINED;
4976 + nRet = BP_BOARD_ID_NOT_SET;
4980 +} /* BpGetBootloaderAlarmLedGpio */
4982 +/**************************************************************************
4983 + * Name : BpGetBootloaderResetCfgLedGpio
4985 + * Description: This function returns the GPIO pin assignment for the reset
4986 + * configuration LED that is set by the bootloader.
4988 + * Parameters : [OUT] pusValue - Address of short word that the reset
4989 + * configuration LED GPIO pin is returned in.
4991 + * Returns : BP_SUCCESS - Success, value is returned.
4992 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4993 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4995 + ***************************************************************************/
4996 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue )
5000 + if( g_pCurrentBp )
5002 + *pusValue = g_pCurrentBp->usGpioLedBlResetCfg;
5004 + if( g_pCurrentBp->usGpioLedBlResetCfg != BP_NOT_DEFINED )
5006 + nRet = BP_SUCCESS;
5010 + nRet = BP_VALUE_NOT_DEFINED;
5015 + *pusValue = BP_NOT_DEFINED;
5016 + nRet = BP_BOARD_ID_NOT_SET;
5020 +} /* BpGetBootloaderResetCfgLedGpio */
5022 +/**************************************************************************
5023 + * Name : BpGetBootloaderStopLedGpio
5025 + * Description: This function returns the GPIO pin assignment for the break
5026 + * into bootloader LED that is set by the bootloader.
5028 + * Parameters : [OUT] pusValue - Address of short word that the break into
5029 + * bootloader LED GPIO pin is returned in.
5031 + * Returns : BP_SUCCESS - Success, value is returned.
5032 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5033 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5035 + ***************************************************************************/
5036 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue )
5040 + if( g_pCurrentBp )
5042 + *pusValue = g_pCurrentBp->usGpioLedBlStop;
5044 + if( g_pCurrentBp->usGpioLedBlStop != BP_NOT_DEFINED )
5046 + nRet = BP_SUCCESS;
5050 + nRet = BP_VALUE_NOT_DEFINED;
5055 + *pusValue = BP_NOT_DEFINED;
5056 + nRet = BP_BOARD_ID_NOT_SET;
5060 +} /* BpGetBootloaderStopLedGpio */
5062 +/**************************************************************************
5063 + * Name : BpGetVoipLedGpio
5065 + * Description: This function returns the GPIO pin assignment for the VOIP
5068 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5069 + * GPIO pin is returned in.
5071 + * Returns : BP_SUCCESS - Success, value is returned.
5072 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5073 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5076 + * Note : The VoIP structure would allow for having one LED per DSP
5077 + * however, the board initialization function assumes only one
5078 + * LED per functionality (ie one LED for VoIP). Therefore in
5079 + * order to keep this tidy and simple we do not make usage of the
5080 + * one-LED-per-DSP function. Instead, we assume that the LED for
5081 + * VoIP is unique and associated with DSP 0 (always present on
5082 + * any VoIP platform). If changing this to a LED-per-DSP function
5083 + * then one need to update the board initialization driver in
5084 + * bcmdrivers\opensource\char\board\bcm963xx\impl1
5085 + ***************************************************************************/
5086 +int BpGetVoipLedGpio( unsigned short *pusValue )
5090 + if( g_pCurrentBp )
5092 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( 0 );
5096 + *pusValue = pDspInfo->usGpioLedVoip;
5098 + if( *pusValue != BP_NOT_DEFINED )
5100 + nRet = BP_SUCCESS;
5104 + nRet = BP_VALUE_NOT_DEFINED;
5109 + *pusValue = BP_NOT_DEFINED;
5110 + nRet = BP_BOARD_ID_NOT_FOUND;
5115 + *pusValue = BP_NOT_DEFINED;
5116 + nRet = BP_BOARD_ID_NOT_SET;
5120 +} /* BpGetVoipLedGpio */
5122 +/**************************************************************************
5123 + * Name : BpGetWirelessExtIntr
5125 + * Description: This function returns the Wireless external interrupt number.
5127 + * Parameters : [OUT] pulValue - Address of short word that the wireless
5128 + * external interrupt number is returned in.
5130 + * Returns : BP_SUCCESS - Success, value is returned.
5131 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5132 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5134 + ***************************************************************************/
5135 +int BpGetWirelessExtIntr( unsigned long *pulValue )
5139 + if( g_pCurrentBp )
5141 + *pulValue = g_pCurrentBp->usExtIntrWireless;
5143 + if( g_pCurrentBp->usExtIntrWireless != BP_NOT_DEFINED )
5145 + nRet = BP_SUCCESS;
5149 + nRet = BP_VALUE_NOT_DEFINED;
5154 + *pulValue = BP_NOT_DEFINED;
5155 + nRet = BP_BOARD_ID_NOT_SET;
5159 +} /* BpGetWirelessExtIntr */
5161 +/**************************************************************************
5162 + * Name : BpGetAdslDyingGaspExtIntr
5164 + * Description: This function returns the ADSL Dying Gasp external interrupt
5167 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
5168 + * external interrupt number is returned in.
5170 + * Returns : BP_SUCCESS - Success, value is returned.
5171 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5172 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5174 + ***************************************************************************/
5175 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue )
5179 + if( g_pCurrentBp )
5181 + *pulValue = g_pCurrentBp->usExtIntrAdslDyingGasp;
5183 + if( g_pCurrentBp->usExtIntrAdslDyingGasp != BP_NOT_DEFINED )
5185 + nRet = BP_SUCCESS;
5189 + nRet = BP_VALUE_NOT_DEFINED;
5194 + *pulValue = BP_NOT_DEFINED;
5195 + nRet = BP_BOARD_ID_NOT_SET;
5199 +} /* BpGetAdslDyingGaspExtIntr */
5201 +/**************************************************************************
5202 + * Name : BpGetVoipExtIntr
5204 + * Description: This function returns the VOIP external interrupt number.
5206 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5207 + * external interrupt number is returned in.
5208 + * [IN] dspNum - Address of the DSP to query.
5210 + * Returns : BP_SUCCESS - Success, value is returned.
5211 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5212 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5214 + ***************************************************************************/
5215 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue )
5219 + if( g_pCurrentBp )
5221 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5225 + *pulValue = pDspInfo->usExtIntrVoip;
5227 + if( *pulValue != BP_NOT_DEFINED )
5229 + nRet = BP_SUCCESS;
5233 + nRet = BP_VALUE_NOT_DEFINED;
5238 + *pulValue = BP_NOT_DEFINED;
5239 + nRet = BP_BOARD_ID_NOT_FOUND;
5244 + *pulValue = BP_NOT_DEFINED;
5245 + nRet = BP_BOARD_ID_NOT_SET;
5249 +} /* BpGetVoipExtIntr */
5251 +/**************************************************************************
5252 + * Name : BpGetHpnaExtIntr
5254 + * Description: This function returns the HPNA external interrupt number.
5256 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5257 + * external interrupt number is returned in.
5259 + * Returns : BP_SUCCESS - Success, value is returned.
5260 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5261 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5263 + ***************************************************************************/
5264 +int BpGetHpnaExtIntr( unsigned long *pulValue )
5268 + if( g_pCurrentBp )
5270 + *pulValue = g_pCurrentBp->usExtIntrHpna;
5272 + if( g_pCurrentBp->usExtIntrHpna != BP_NOT_DEFINED )
5274 + nRet = BP_SUCCESS;
5278 + nRet = BP_VALUE_NOT_DEFINED;
5283 + *pulValue = BP_NOT_DEFINED;
5284 + nRet = BP_BOARD_ID_NOT_SET;
5288 +} /* BpGetHpnaExtIntr */
5290 +/**************************************************************************
5291 + * Name : BpGetHpnaChipSelect
5293 + * Description: This function returns the HPNA chip select number.
5295 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5296 + * chip select number is returned in.
5298 + * Returns : BP_SUCCESS - Success, value is returned.
5299 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5300 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5302 + ***************************************************************************/
5303 +int BpGetHpnaChipSelect( unsigned long *pulValue )
5307 + if( g_pCurrentBp )
5309 + *pulValue = g_pCurrentBp->usCsHpna;
5311 + if( g_pCurrentBp->usCsHpna != BP_NOT_DEFINED )
5313 + nRet = BP_SUCCESS;
5317 + nRet = BP_VALUE_NOT_DEFINED;
5322 + *pulValue = BP_NOT_DEFINED;
5323 + nRet = BP_BOARD_ID_NOT_SET;
5327 +} /* BpGetHpnaChipSelect */
5329 +/**************************************************************************
5330 + * Name : BpGetVoipChipSelect
5332 + * Description: This function returns the VOIP chip select number.
5334 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5335 + * chip select number is returned in.
5336 + * [IN] dspNum - Address of the DSP to query.
5338 + * Returns : BP_SUCCESS - Success, value is returned.
5339 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5340 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5342 + ***************************************************************************/
5343 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue )
5347 + if( g_pCurrentBp )
5349 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5353 + *pulValue = pDspInfo->usCsVoip;
5355 + if( *pulValue != BP_NOT_DEFINED )
5357 + nRet = BP_SUCCESS;
5361 + nRet = BP_VALUE_NOT_DEFINED;
5366 + *pulValue = BP_NOT_DEFINED;
5367 + nRet = BP_BOARD_ID_NOT_FOUND;
5372 + *pulValue = BP_NOT_DEFINED;
5373 + nRet = BP_BOARD_ID_NOT_SET;
5377 +} /* BpGetVoipChipSelect */
5379 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/boardparms.h linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h
5380 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/boardparms.h 1970-01-01 01:00:00.000000000 +0100
5381 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h 2006-07-07 22:16:11.000000000 +0200
5386 + Copyright 2003 Broadcom Corp. All Rights Reserved.
5388 + This program is free software; you can distribute it and/or modify it
5389 + under the terms of the GNU General Public License (Version 2) as
5390 + published by the Free Software Foundation.
5392 + This program is distributed in the hope it will be useful, but WITHOUT
5393 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5394 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5397 + You should have received a copy of the GNU General Public License along
5398 + with this program; if not, write to the Free Software Foundation, Inc.,
5399 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
5403 +/**************************************************************************
5404 + * File Name : boardparms.h
5406 + * Description: This file contains definitions and function prototypes for
5407 + * the BCM63xx board parameter access functions.
5409 + * Updates : 07/14/2003 Created.
5410 + ***************************************************************************/
5412 +#if !defined(_BOARDPARMS_H)
5413 +#define _BOARDPARMS_H
5419 +/* Return codes. */
5420 +#define BP_SUCCESS 0
5421 +#define BP_BOARD_ID_NOT_FOUND 1
5422 +#define BP_VALUE_NOT_DEFINED 2
5423 +#define BP_BOARD_ID_NOT_SET 3
5425 +/* Values for BpGetSdramSize. */
5426 +#define BP_MEMORY_8MB_1_CHIP 0
5427 +#define BP_MEMORY_16MB_1_CHIP 1
5428 +#define BP_MEMORY_32MB_1_CHIP 2
5429 +#define BP_MEMORY_64MB_2_CHIP 3
5430 +#define BP_MEMORY_32MB_2_CHIP 4
5431 +#define BP_MEMORY_16MB_2_CHIP 5
5433 +/* Values for EthernetMacInfo PhyType. */
5434 +#define BP_ENET_NO_PHY 0
5435 +#define BP_ENET_INTERNAL_PHY 1
5436 +#define BP_ENET_EXTERNAL_PHY 2
5437 +#define BP_ENET_EXTERNAL_SWITCH 3
5439 +/* Values for EthernetMacInfo Configuration type. */
5440 +#define BP_ENET_CONFIG_MDIO 0 /* Internal PHY, External PHY, Switch+(no GPIO, no SPI, no MDIO Pseudo phy */
5441 +#define BP_ENET_CONFIG_GPIO 1 /* Bcm96345GW board + Bcm5325M/E */
5442 +#define BP_ENET_CONFIG_MDIO_PSEUDO_PHY 2 /* Bcm96348GW board + Bcm5325E */
5443 +#define BP_ENET_CONFIG_SPI_SSB_0 3 /* Bcm96348GW board + Bcm5325M/E */
5444 +#define BP_ENET_CONFIG_SPI_SSB_1 4 /* Bcm96348GW board + Bcm5325M/E */
5445 +#define BP_ENET_CONFIG_SPI_SSB_2 5 /* Bcm96348GW board + Bcm5325M/E */
5446 +#define BP_ENET_CONFIG_SPI_SSB_3 6 /* Bcm96348GW board + Bcm5325M/E */
5448 +/* Values for EthernetMacInfo Reverse MII. */
5449 +#define BP_ENET_NO_REVERSE_MII 0
5450 +#define BP_ENET_REVERSE_MII 1
5452 +/* Values for VoIPDSPInfo DSPType. */
5453 +#define BP_VOIP_NO_DSP 0
5454 +#define BP_VOIP_DSP 1
5457 +/* Values for GPIO pin assignments (AH = Active High, AL = Active Low). */
5458 +#define BP_ACTIVE_MASK 0x8000
5459 +#define BP_ACTIVE_HIGH 0x0000
5460 +#define BP_ACTIVE_LOW 0x8000
5461 +#define BP_GPIO_0_AH (0 | BP_ACTIVE_HIGH)
5462 +#define BP_GPIO_0_AL (0 | BP_ACTIVE_LOW)
5463 +#define BP_GPIO_1_AH (1 | BP_ACTIVE_HIGH)
5464 +#define BP_GPIO_1_AL (1 | BP_ACTIVE_LOW)
5465 +#define BP_GPIO_2_AH (2 | BP_ACTIVE_HIGH)
5466 +#define BP_GPIO_2_AL (2 | BP_ACTIVE_LOW)
5467 +#define BP_GPIO_3_AH (3 | BP_ACTIVE_HIGH)
5468 +#define BP_GPIO_3_AL (3 | BP_ACTIVE_LOW)
5469 +#define BP_GPIO_4_AH (4 | BP_ACTIVE_HIGH)
5470 +#define BP_GPIO_4_AL (4 | BP_ACTIVE_LOW)
5471 +#define BP_GPIO_5_AH (5 | BP_ACTIVE_HIGH)
5472 +#define BP_GPIO_5_AL (5 | BP_ACTIVE_LOW)
5473 +#define BP_GPIO_6_AH (6 | BP_ACTIVE_HIGH)
5474 +#define BP_GPIO_6_AL (6 | BP_ACTIVE_LOW)
5475 +#define BP_GPIO_7_AH (7 | BP_ACTIVE_HIGH)
5476 +#define BP_GPIO_7_AL (7 | BP_ACTIVE_LOW)
5477 +#define BP_GPIO_8_AH (8 | BP_ACTIVE_HIGH)
5478 +#define BP_GPIO_8_AL (8 | BP_ACTIVE_LOW)
5479 +#define BP_GPIO_9_AH (9 | BP_ACTIVE_HIGH)
5480 +#define BP_GPIO_9_AL (9 | BP_ACTIVE_LOW)
5481 +#define BP_GPIO_10_AH (10 | BP_ACTIVE_HIGH)
5482 +#define BP_GPIO_10_AL (10 | BP_ACTIVE_LOW)
5483 +#define BP_GPIO_11_AH (11 | BP_ACTIVE_HIGH)
5484 +#define BP_GPIO_11_AL (11 | BP_ACTIVE_LOW)
5485 +#define BP_GPIO_12_AH (12 | BP_ACTIVE_HIGH)
5486 +#define BP_GPIO_12_AL (12 | BP_ACTIVE_LOW)
5487 +#define BP_GPIO_13_AH (13 | BP_ACTIVE_HIGH)
5488 +#define BP_GPIO_13_AL (13 | BP_ACTIVE_LOW)
5489 +#define BP_GPIO_14_AH (14 | BP_ACTIVE_HIGH)
5490 +#define BP_GPIO_14_AL (14 | BP_ACTIVE_LOW)
5491 +#define BP_GPIO_15_AH (15 | BP_ACTIVE_HIGH)
5492 +#define BP_GPIO_15_AL (15 | BP_ACTIVE_LOW)
5493 +#define BP_GPIO_16_AH (16 | BP_ACTIVE_HIGH)
5494 +#define BP_GPIO_16_AL (16 | BP_ACTIVE_LOW)
5495 +#define BP_GPIO_17_AH (17 | BP_ACTIVE_HIGH)
5496 +#define BP_GPIO_17_AL (17 | BP_ACTIVE_LOW)
5497 +#define BP_GPIO_18_AH (18 | BP_ACTIVE_HIGH)
5498 +#define BP_GPIO_18_AL (18 | BP_ACTIVE_LOW)
5499 +#define BP_GPIO_19_AH (19 | BP_ACTIVE_HIGH)
5500 +#define BP_GPIO_19_AL (19 | BP_ACTIVE_LOW)
5501 +#define BP_GPIO_20_AH (20 | BP_ACTIVE_HIGH)
5502 +#define BP_GPIO_20_AL (20 | BP_ACTIVE_LOW)
5503 +#define BP_GPIO_21_AH (21 | BP_ACTIVE_HIGH)
5504 +#define BP_GPIO_21_AL (21 | BP_ACTIVE_LOW)
5505 +#define BP_GPIO_22_AH (22 | BP_ACTIVE_HIGH)
5506 +#define BP_GPIO_22_AL (22 | BP_ACTIVE_LOW)
5507 +#define BP_GPIO_23_AH (23 | BP_ACTIVE_HIGH)
5508 +#define BP_GPIO_23_AL (23 | BP_ACTIVE_LOW)
5509 +#define BP_GPIO_24_AH (24 | BP_ACTIVE_HIGH)
5510 +#define BP_GPIO_24_AL (24 | BP_ACTIVE_LOW)
5511 +#define BP_GPIO_25_AH (25 | BP_ACTIVE_HIGH)
5512 +#define BP_GPIO_25_AL (25 | BP_ACTIVE_LOW)
5513 +#define BP_GPIO_26_AH (26 | BP_ACTIVE_HIGH)
5514 +#define BP_GPIO_26_AL (26 | BP_ACTIVE_LOW)
5515 +#define BP_GPIO_27_AH (27 | BP_ACTIVE_HIGH)
5516 +#define BP_GPIO_27_AL (27 | BP_ACTIVE_LOW)
5517 +#define BP_GPIO_28_AH (28 | BP_ACTIVE_HIGH)
5518 +#define BP_GPIO_28_AL (28 | BP_ACTIVE_LOW)
5519 +#define BP_GPIO_29_AH (29 | BP_ACTIVE_HIGH)
5520 +#define BP_GPIO_29_AL (29 | BP_ACTIVE_LOW)
5521 +#define BP_GPIO_30_AH (30 | BP_ACTIVE_HIGH)
5522 +#define BP_GPIO_30_AL (30 | BP_ACTIVE_LOW)
5523 +#define BP_GPIO_31_AH (31 | BP_ACTIVE_HIGH)
5524 +#define BP_GPIO_31_AL (31 | BP_ACTIVE_LOW)
5525 +#define BP_GPIO_32_AH (32 | BP_ACTIVE_HIGH)
5526 +#define BP_GPIO_32_AL (32 | BP_ACTIVE_LOW)
5527 +#define BP_GPIO_33_AH (33 | BP_ACTIVE_HIGH)
5528 +#define BP_GPIO_33_AL (33 | BP_ACTIVE_LOW)
5529 +#define BP_GPIO_34_AH (34 | BP_ACTIVE_HIGH)
5530 +#define BP_GPIO_34_AL (34 | BP_ACTIVE_LOW)
5531 +#define BP_GPIO_35_AH (35 | BP_ACTIVE_HIGH)
5532 +#define BP_GPIO_35_AL (35 | BP_ACTIVE_LOW)
5533 +#define BP_GPIO_36_AH (36 | BP_ACTIVE_HIGH)
5534 +#define BP_GPIO_36_AL (36 | BP_ACTIVE_LOW)
5536 +/* Values for external interrupt assignments. */
5537 +#define BP_EXT_INTR_0 0
5538 +#define BP_EXT_INTR_1 1
5539 +#define BP_EXT_INTR_2 2
5540 +#define BP_EXT_INTR_3 3
5542 +/* Values for chip select assignments. */
5548 +/* Value for GPIO and external interrupt fields that are not used. */
5549 +#define BP_NOT_DEFINED 0xffff
5550 +#define BP_HW_DEFINED 0xfff0
5551 +#define BP_UNEQUIPPED 0xfff1
5553 +/* Maximum size of the board id string. */
5554 +#define BP_BOARD_ID_LEN 16
5556 +/* Maximum number of Ethernet MACs. */
5557 +#define BP_MAX_ENET_MACS 2
5559 +/* Maximum number of VoIP DSPs. */
5560 +#define BP_MAX_VOIP_DSP 2
5562 +/* Wireless Antenna Settings. */
5563 +#define BP_WLAN_ANT_MAIN 0
5564 +#define BP_WLAN_ANT_AUX 1
5565 +#define BP_WLAN_ANT_BOTH 3
5567 +#if !defined(__ASSEMBLER__)
5569 +/* Information about an Ethernet MAC. If ucPhyType is BP_ENET_NO_PHY,
5570 + * then the other fields are not valid.
5572 +typedef struct EthernetMacInfo
5574 + unsigned char ucPhyType; /* BP_ENET_xxx */
5575 + unsigned char ucPhyAddress; /* 0 to 31 */
5576 + unsigned short usGpioPhySpiSck; /* GPIO pin or not defined */
5577 + unsigned short usGpioPhySpiSs; /* GPIO pin or not defined */
5578 + unsigned short usGpioPhySpiMosi; /* GPIO pin or not defined */
5579 + unsigned short usGpioPhySpiMiso; /* GPIO pin or not defined */
5580 + unsigned short usGpioPhyReset; /* GPIO pin or not defined (96348LV) */
5581 + unsigned short numSwitchPorts; /* Number of PHY ports */
5582 + unsigned short usConfigType; /* Configuration type */
5583 + unsigned short usReverseMii; /* Reverse MII */
5584 +} ETHERNET_MAC_INFO, *PETHERNET_MAC_INFO;
5587 +/* Information about VoIP DSPs. If ucDspType is BP_VOIP_NO_DSP,
5588 + * then the other fields are not valid.
5590 +typedef struct VoIPDspInfo
5592 + unsigned char ucDspType;
5593 + unsigned char ucDspAddress;
5594 + unsigned short usExtIntrVoip;
5595 + unsigned short usGpioVoipReset;
5596 + unsigned short usGpioVoipIntr;
5597 + unsigned short usGpioLedVoip;
5598 + unsigned short usCsVoip;
5603 +/**************************************************************************
5604 + * Name : BpSetBoardId
5606 + * Description: This function find the BOARD_PARAMETERS structure for the
5607 + * specified board id string and assigns it to a global, static
5610 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
5612 + * Returns : BP_SUCCESS - Success, value is returned.
5613 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
5614 + * have a board parameters configuration record.
5615 + ***************************************************************************/
5616 +int BpSetBoardId( char *pszBoardId );
5618 +/**************************************************************************
5619 + * Name : BpGetBoardIds
5621 + * Description: This function returns all of the supported board id strings.
5623 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
5624 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
5626 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
5627 + * were allocated in pszBoardIds.
5629 + * Returns : Number of board id strings returned.
5630 + ***************************************************************************/
5631 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize );
5633 +/**************************************************************************
5634 + * Name : BpGetEthernetMacInfo
5636 + * Description: This function returns all of the supported board id strings.
5638 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
5640 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
5641 + * are pointed to by pEnetInfos.
5643 + * Returns : BP_SUCCESS - Success, value is returned.
5644 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5645 + ***************************************************************************/
5646 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos );
5648 +/**************************************************************************
5649 + * Name : BpGetSdramSize
5651 + * Description: This function returns a constant that describees the board's
5652 + * SDRAM type and size.
5654 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
5657 + * Returns : BP_SUCCESS - Success, value is returned.
5658 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5659 + ***************************************************************************/
5660 +int BpGetSdramSize( unsigned long *pulSdramSize );
5662 +/**************************************************************************
5663 + * Name : BpGetPsiSize
5665 + * Description: This function returns the persistent storage size in K bytes.
5667 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
5668 + * storage size is returned in.
5670 + * Returns : BP_SUCCESS - Success, value is returned.
5671 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5672 + ***************************************************************************/
5673 +int BpGetPsiSize( unsigned long *pulPsiSize );
5675 +/**************************************************************************
5676 + * Name : BpGetRj11InnerOuterPairGpios
5678 + * Description: This function returns the GPIO pin assignments for changing
5679 + * between the RJ11 inner pair and RJ11 outer pair.
5681 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
5682 + * GPIO pin is returned in.
5683 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
5684 + * GPIO pin is returned in.
5686 + * Returns : BP_SUCCESS - Success, values are returned.
5687 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5688 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5690 + ***************************************************************************/
5691 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
5692 + unsigned short *pusOuter );
5694 +/**************************************************************************
5695 + * Name : BpGetPressAndHoldResetGpio
5697 + * Description: This function returns the GPIO pin assignment for the press
5698 + * and hold reset button.
5700 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
5701 + * reset button GPIO pin is returned in.
5703 + * Returns : BP_SUCCESS - Success, value is returned.
5704 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5705 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5707 + ***************************************************************************/
5708 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue );
5710 +/**************************************************************************
5711 + * Name : BpGetVoipResetGpio
5713 + * Description: This function returns the GPIO pin assignment for the VOIP
5714 + * Reset operation.
5716 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
5717 + * GPIO pin is returned in.
5718 + * [IN] dspNum - Address of the DSP to query.
5720 + * Returns : BP_SUCCESS - Success, value is returned.
5721 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5722 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5724 + ***************************************************************************/
5725 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue );
5727 +/**************************************************************************
5728 + * Name : BpGetVoipIntrGpio
5730 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
5732 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
5733 + * GPIO pin is returned in.
5734 + * [IN] dspNum - Address of the DSP to query.
5736 + * Returns : BP_SUCCESS - Success, value is returned.
5737 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5738 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5740 + ***************************************************************************/
5741 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue );
5743 +/**************************************************************************
5744 + * Name : BpGetPcmciaResetGpio
5746 + * Description: This function returns the GPIO pin assignment for the PCMCIA
5747 + * Reset operation.
5749 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
5750 + * GPIO pin is returned in.
5752 + * Returns : BP_SUCCESS - Success, value is returned.
5753 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5754 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5756 + ***************************************************************************/
5757 +int BpGetPcmciaResetGpio( unsigned short *pusValue );
5759 +/**************************************************************************
5760 + * Name : BpGetUartRtsCtsGpios
5762 + * Description: This function returns the GPIO pin assignments for RTS and CTS
5765 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
5766 + * pin is returned in.
5767 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
5768 + * pin is returned in.
5770 + * Returns : BP_SUCCESS - Success, values are returned.
5771 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5772 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5774 + ***************************************************************************/
5775 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts );
5777 +/**************************************************************************
5778 + * Name : BpGetAdslLedGpio
5780 + * Description: This function returns the GPIO pin assignment for the ADSL
5783 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5784 + * GPIO pin is returned in.
5786 + * Returns : BP_SUCCESS - Success, value is returned.
5787 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5788 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5790 + ***************************************************************************/
5791 +int BpGetAdslLedGpio( unsigned short *pusValue );
5793 +/**************************************************************************
5794 + * Name : BpGetAdslFailLedGpio
5796 + * Description: This function returns the GPIO pin assignment for the ADSL
5797 + * LED that is used when there is a DSL connection failure.
5799 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5800 + * GPIO pin is returned in.
5802 + * Returns : BP_SUCCESS - Success, value is returned.
5803 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5804 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5806 + ***************************************************************************/
5807 +int BpGetAdslFailLedGpio( unsigned short *pusValue );
5809 +/**************************************************************************
5810 + * Name : BpGetWirelessLedGpio
5812 + * Description: This function returns the GPIO pin assignment for the Wireless
5815 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
5816 + * GPIO pin is returned in.
5818 + * Returns : BP_SUCCESS - Success, value is returned.
5819 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5820 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5822 + ***************************************************************************/
5823 +int BpGetWirelessLedGpio( unsigned short *pusValue );
5825 +/**************************************************************************
5826 + * Name : BpGetWirelessAntInUse
5828 + * Description: This function returns the antennas in use for wireless
5830 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
5833 + * Returns : BP_SUCCESS - Success, value is returned.
5834 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5835 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5837 + ***************************************************************************/
5838 +int BpGetWirelessAntInUse( unsigned short *pusValue );
5840 +/**************************************************************************
5841 + * Name : BpGetWirelessSesBtnGpio
5843 + * Description: This function returns the GPIO pin assignment for the Wireless
5846 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5847 + * Button GPIO pin is returned in.
5849 + * Returns : BP_SUCCESS - Success, value is returned.
5850 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5851 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5853 + ***************************************************************************/
5854 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue );
5856 +/**************************************************************************
5857 + * Name : BpGetWirelessSesExtIntr
5859 + * Description: This function returns the external interrupt number for the
5860 + * Wireless Ses Button.
5862 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5863 + * external interrup is returned in.
5865 + * Returns : BP_SUCCESS - Success, value is returned.
5866 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5867 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5869 + ***************************************************************************/
5870 +int BpGetWirelessSesExtIntr( unsigned short *pusValue );
5872 +/**************************************************************************
5873 + * Name : BpGetWirelessSesLedGpio
5875 + * Description: This function returns the GPIO pin assignment for the Wireless
5878 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
5879 + * Led GPIO pin is returned in.
5881 + * Returns : BP_SUCCESS - Success, value is returned.
5882 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5883 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5885 + ***************************************************************************/
5886 +int BpGetWirelessSesLedGpio( unsigned short *pusValue );
5888 +/**************************************************************************
5889 + * Name : BpGetUsbLedGpio
5891 + * Description: This function returns the GPIO pin assignment for the USB
5894 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
5895 + * GPIO pin is returned in.
5897 + * Returns : BP_SUCCESS - Success, value is returned.
5898 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5899 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5901 + ***************************************************************************/
5902 +int BpGetUsbLedGpio( unsigned short *pusValue );
5904 +/**************************************************************************
5905 + * Name : BpGetHpnaLedGpio
5907 + * Description: This function returns the GPIO pin assignment for the HPNA
5910 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
5911 + * GPIO pin is returned in.
5913 + * Returns : BP_SUCCESS - Success, value is returned.
5914 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5915 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5917 + ***************************************************************************/
5918 +int BpGetHpnaLedGpio( unsigned short *pusValue );
5920 +/**************************************************************************
5921 + * Name : BpGetWanDataLedGpio
5923 + * Description: This function returns the GPIO pin assignment for the WAN Data
5926 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
5927 + * GPIO pin is returned in.
5929 + * Returns : BP_SUCCESS - Success, value is returned.
5930 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5931 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5933 + ***************************************************************************/
5934 +int BpGetWanDataLedGpio( unsigned short *pusValue );
5936 +/**************************************************************************
5937 + * Name : BpGetPppLedGpio
5939 + * Description: This function returns the GPIO pin assignment for the PPP
5942 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5943 + * GPIO pin is returned in.
5945 + * Returns : BP_SUCCESS - Success, value is returned.
5946 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5947 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5949 + ***************************************************************************/
5950 +int BpGetPppLedGpio( unsigned short *pusValue );
5952 +/**************************************************************************
5953 + * Name : BpGetPppFailLedGpio
5955 + * Description: This function returns the GPIO pin assignment for the PPP
5956 + * LED that is used when there is a PPP connection failure.
5958 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5959 + * GPIO pin is returned in.
5961 + * Returns : BP_SUCCESS - Success, value is returned.
5962 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5963 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5965 + ***************************************************************************/
5966 +int BpGetPppFailLedGpio( unsigned short *pusValue );
5968 +/**************************************************************************
5969 + * Name : BpGetVoipLedGpio
5971 + * Description: This function returns the GPIO pin assignment for the VOIP
5974 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5975 + * GPIO pin is returned in.
5977 + * Returns : BP_SUCCESS - Success, value is returned.
5978 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5979 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5981 + ***************************************************************************/
5982 +int BpGetVoipLedGpio( unsigned short *pusValue );
5984 +/**************************************************************************
5985 + * Name : BpGetBootloaderPowerOnLedGpio
5987 + * Description: This function returns the GPIO pin assignment for the power
5988 + * on LED that is set by the bootloader.
5990 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5991 + * GPIO pin is returned in.
5993 + * Returns : BP_SUCCESS - Success, value is returned.
5994 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5995 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5997 + ***************************************************************************/
5998 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue );
6000 +/**************************************************************************
6001 + * Name : BpGetBootloaderAlarmLedGpio
6003 + * Description: This function returns the GPIO pin assignment for the alarm
6004 + * LED that is set by the bootloader.
6006 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6007 + * GPIO pin is returned in.
6009 + * Returns : BP_SUCCESS - Success, value is returned.
6010 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6011 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6013 + ***************************************************************************/
6014 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue );
6016 +/**************************************************************************
6017 + * Name : BpGetBootloaderResetCfgLedGpio
6019 + * Description: This function returns the GPIO pin assignment for the reset
6020 + * configuration LED that is set by the bootloader.
6022 + * Parameters : [OUT] pusValue - Address of short word that the reset
6023 + * configuration LED GPIO pin is returned in.
6025 + * Returns : BP_SUCCESS - Success, value is returned.
6026 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6027 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6029 + ***************************************************************************/
6030 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue );
6032 +/**************************************************************************
6033 + * Name : BpGetBootloaderStopLedGpio
6035 + * Description: This function returns the GPIO pin assignment for the break
6036 + * into bootloader LED that is set by the bootloader.
6038 + * Parameters : [OUT] pusValue - Address of short word that the break into
6039 + * bootloader LED GPIO pin is returned in.
6041 + * Returns : BP_SUCCESS - Success, value is returned.
6042 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6043 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6045 + ***************************************************************************/
6046 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue );
6048 +/**************************************************************************
6049 + * Name : BpGetWirelessExtIntr
6051 + * Description: This function returns the Wireless external interrupt number.
6053 + * Parameters : [OUT] pulValue - Address of short word that the wireless
6054 + * external interrupt number is returned in.
6056 + * Returns : BP_SUCCESS - Success, value is returned.
6057 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6058 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6060 + ***************************************************************************/
6061 +int BpGetWirelessExtIntr( unsigned long *pulValue );
6063 +/**************************************************************************
6064 + * Name : BpGetAdslDyingGaspExtIntr
6066 + * Description: This function returns the ADSL Dying Gasp external interrupt
6069 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
6070 + * external interrupt number is returned in.
6072 + * Returns : BP_SUCCESS - Success, value is returned.
6073 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6074 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6076 + ***************************************************************************/
6077 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue );
6079 +/**************************************************************************
6080 + * Name : BpGetVoipExtIntr
6082 + * Description: This function returns the VOIP external interrupt number.
6084 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6085 + * external interrupt number is returned in.
6086 + * [IN] dspNum - Address of the DSP to query.
6088 + * Returns : BP_SUCCESS - Success, value is returned.
6089 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6090 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6092 + ***************************************************************************/
6093 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue );
6095 +/**************************************************************************
6096 + * Name : BpGetHpnaExtIntr
6098 + * Description: This function returns the HPNA external interrupt number.
6100 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6101 + * external interrupt number is returned in.
6103 + * Returns : BP_SUCCESS - Success, value is returned.
6104 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6105 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6107 + ***************************************************************************/
6108 +int BpGetHpnaExtIntr( unsigned long *pulValue );
6110 +/**************************************************************************
6111 + * Name : BpGetHpnaChipSelect
6113 + * Description: This function returns the HPNA chip select number.
6115 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6116 + * chip select number is returned in.
6118 + * Returns : BP_SUCCESS - Success, value is returned.
6119 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6120 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6122 + ***************************************************************************/
6123 +int BpGetHpnaChipSelect( unsigned long *pulValue );
6125 +/**************************************************************************
6126 + * Name : BpGetVoipChipSelect
6128 + * Description: This function returns the VOIP chip select number.
6130 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6131 + * chip select number is returned in.
6132 + * [IN] dspNum - Address of the DSP to query.
6134 + * Returns : BP_SUCCESS - Success, value is returned.
6135 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6136 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6138 + ***************************************************************************/
6139 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue );
6141 +#endif /* __ASSEMBLER__ */
6147 +#endif /* _BOARDPARMS_H */
6149 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/cfiflash.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c
6150 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/cfiflash.c 1970-01-01 01:00:00.000000000 +0100
6151 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c 2006-07-07 22:17:24.000000000 +0200
6153 +/************************************************************************/
6155 +/* AMD CFI Enabled Flash Memory Drivers */
6156 +/* File name: CFIFLASH.C */
6157 +/* Revision: 1.0 5/07/98 */
6159 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6160 +/* This software is unpublished and contains the trade secrets and */
6161 +/* confidential proprietary information of AMD. Unless otherwise */
6162 +/* provided in the Software Agreement associated herewith, it is */
6163 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
6164 +/* or part by any means except for backup. Use, duplication, or */
6165 +/* disclosure by the Government is subject to the restrictions in */
6166 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
6167 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
6168 +/* Software owned by */
6169 +/* Advanced Micro Devices, Inc., */
6170 +/* One AMD Place, */
6171 +/* P.O. Box 3453 */
6172 +/* Sunnyvale, CA 94088-3453. */
6173 +/************************************************************************/
6174 +/* This software constitutes a basic shell of source code for */
6175 +/* programming all AMD Flash components. AMD */
6176 +/* will not be responsible for misuse or illegal use of this */
6177 +/* software for devices not supported herein. AMD is providing */
6178 +/* this source code "AS IS" and will not be responsible for */
6179 +/* issues arising from incorrect user implementation of the */
6180 +/* source code herein. It is the user's responsibility to */
6181 +/* properly design-in this source code. */
6183 +/************************************************************************/
6185 +#include "lib_types.h"
6186 +#include "lib_printf.h"
6187 +#include "lib_string.h"
6188 +#include "cfe_timer.h"
6189 +#define printk printf
6191 +#include <linux/param.h>
6192 +#include <linux/sched.h>
6193 +#include <linux/timer.h>
6196 +#include "cfiflash.h"
6198 +static int flash_wait(WORD sector, int offset, UINT16 data);
6199 +static UINT16 flash_get_device_id(void);
6200 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily);
6201 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes);
6202 +static void flash_command(int command, WORD sector, int offset, UINT16 data);
6204 +/*********************************************************************/
6205 +/* 'meminfo' should be a pointer, but most C compilers will not */
6206 +/* allocate static storage for a pointer without calling */
6207 +/* non-portable functions such as 'new'. We also want to avoid */
6208 +/* the overhead of passing this pointer for every driver call. */
6209 +/* Systems with limited heap space will need to do this. */
6210 +/*********************************************************************/
6211 +struct flashinfo meminfo; /* Flash information structure */
6212 +static int flashFamily = FLASH_UNDEFINED;
6213 +static int totalSize = 0;
6214 +static struct cfi_query query;
6216 +static UINT16 cfi_data_struct_29W160[] = {
6217 + 0x0020, 0x0049, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6218 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6219 + 0x0051, 0x0052, 0x0059, 0x0002, 0x0000, 0x0040, 0x0000, 0x0000,
6220 + 0x0000, 0x0000, 0x0000, 0x0027, 0x0036, 0x0000, 0x0000, 0x0004,
6221 + 0x0000, 0x000a, 0x0000, 0x0004, 0x0000, 0x0003, 0x0000, 0x0015,
6222 + 0x0002, 0x0000, 0x0000, 0x0000, 0x0004, 0x0000, 0x0000, 0x0040,
6223 + 0x0000, 0x0001, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0080,
6224 + 0x0000, 0x001e, 0x0000, 0x0000, 0x0001, 0xffff, 0xffff, 0xffff,
6225 + 0x0050, 0x0052, 0x0049, 0x0031, 0x0030, 0x0000, 0x0002, 0x0001,
6226 + 0x0001, 0x0004, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0002,
6227 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6228 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6229 + 0xffff, 0x0888, 0x252b, 0x8c84, 0x7dbc, 0xffff, 0xffff, 0xffff,
6230 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6231 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6232 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
6236 +/*********************************************************************/
6237 +/* Init_flash is used to build a sector table from the information */
6238 +/* provided through the CFI query. This information is translated */
6239 +/* from erase_block information to base:offset information for each */
6240 +/* individual sector. This information is then stored in the meminfo */
6241 +/* structure, and used throughout the driver to access sector */
6244 +/* This is more efficient than deriving the sector base:offset */
6245 +/* information every time the memory map switches (since on the */
6246 +/* development platform can only map 64k at a time). If the entire */
6247 +/* flash memory array can be mapped in, then the addition static */
6248 +/* allocation for the meminfo structure can be eliminated, but the */
6249 +/* drivers will have to be re-written. */
6251 +/* The meminfo struct occupies 653 bytes of heap space, depending */
6252 +/* on the value of the define MAXSECTORS. Adjust to suit */
6254 +/*********************************************************************/
6255 +byte flash_init(void)
6257 + int i=0, j=0, count=0;
6260 + int flipCFIGeometry = FALSE;
6263 + * a single 8k sector for sector 0. This is to allow
6264 + * the system to perform memory mapping to the device,
6265 + * even though the actual physical layout is unknown.
6266 + * Once mapped in, the CFI query will produce all
6267 + * relevant information.
6269 + meminfo.addr = 0L;
6271 + meminfo.nsect = 1;
6272 + meminfo.bank1start = 0;
6273 + meminfo.bank2start = 0;
6275 + meminfo.sec[0].size = 8192;
6276 + meminfo.sec[0].base = 0x00000;
6277 + meminfo.sec[0].bank = 1;
6279 + flash_command(FLASH_RESET, 0, 0, 0);
6281 + device_id = flash_get_device_id();
6283 + switch (device_id) {
6284 + case ID_I28F160C3B:
6285 + case ID_I28F320C3B:
6286 + case ID_I28F160C3T:
6287 + case ID_I28F320C3T:
6288 + flashFamily = FLASH_INTEL;
6290 + case ID_AM29DL800B:
6291 + case ID_AM29LV800B:
6292 + case ID_AM29LV400B:
6293 + case ID_AM29LV160B:
6294 + case ID_AM29LV320B:
6295 + case ID_MX29LV320AB:
6296 + case ID_AM29LV320MB:
6297 + case ID_AM29DL800T:
6298 + case ID_AM29LV800T:
6299 + case ID_AM29LV160T:
6300 + case ID_AM29LV320T:
6301 + case ID_MX29LV320AT:
6302 + case ID_AM29LV320MT:
6303 + flashFamily = FLASH_AMD;
6305 + case ID_SST39VF1601:
6306 + case ID_SST39VF3201:
6307 + flashFamily = FLASH_SST;
6310 + printk("Flash memory not supported! Device id = %x\n", device_id);
6314 + if (flash_get_cfi(&query, 0, flashFamily) == -1) {
6315 + switch(device_id) {
6316 + case ID_AM29LV160T:
6317 + case ID_AM29LV160B:
6318 + flash_get_cfi(&query, cfi_data_struct_29W160, flashFamily);
6321 + printk("CFI data structure not found. Device id = %x\n", device_id);
6326 + // need to determine if it top or bottom boot here
6327 + switch (device_id)
6329 + case ID_AM29DL800B:
6330 + case ID_AM29LV800B:
6331 + case ID_AM29LV400B:
6332 + case ID_AM29LV160B:
6333 + case ID_AM29LV320B:
6334 + case ID_MX29LV320AB:
6335 + case ID_AM29LV320MB:
6336 + case ID_I28F160C3B:
6337 + case ID_I28F320C3B:
6338 + case ID_I28F160C3T:
6339 + case ID_I28F320C3T:
6340 + case ID_SST39VF1601:
6341 + case ID_SST39VF3201:
6342 + flipCFIGeometry = FALSE;
6344 + case ID_AM29DL800T:
6345 + case ID_AM29LV800T:
6346 + case ID_AM29LV160T:
6347 + case ID_AM29LV320T:
6348 + case ID_MX29LV320AT:
6349 + case ID_AM29LV320MT:
6350 + flipCFIGeometry = TRUE;
6353 + printk("Flash memory not supported! Device id = %x\n", device_id);
6357 + count=0;basecount=0L;
6359 + if (!flipCFIGeometry)
6361 + for (i=0; i<query.num_erase_blocks; i++) {
6362 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6363 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6364 + meminfo.sec[count].base = (int) basecount;
6365 + basecount += (int) query.erase_block[i].sector_size;
6372 + for (i = (query.num_erase_blocks - 1); i >= 0; i--) {
6373 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6374 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6375 + meminfo.sec[count].base = (int) basecount;
6376 + basecount += (int) query.erase_block[i].sector_size;
6382 + meminfo.nsect = count;
6383 + totalSize = meminfo.sec[count-1].base + meminfo.sec[count-1].size;
6387 +/*********************************************************************/
6388 +/* Flash_sector_erase_int() is identical to flash_sector_erase(), */
6389 +/* except it will wait until the erase is completed before returning */
6390 +/* control to the calling function. This can be used in cases which */
6391 +/* require the program to hold until a sector is erased, without */
6392 +/* adding the wait check external to this function. */
6393 +/*********************************************************************/
6394 +byte flash_sector_erase_int(WORD sector)
6398 + for( i = 0; i < 3; i++ ) {
6399 + flash_command(FLASH_SERASE, sector, 0, 0);
6400 + if (flash_wait(sector, 0, 0xffff) == STATUS_READY)
6407 +/*********************************************************************/
6408 +/* flash_read_buf() reads buffer of data from the specified */
6409 +/* offset from the sector parameter. */
6410 +/*********************************************************************/
6411 +int flash_read_buf(WORD sector, int offset,
6412 + byte *buffer, int numbytes)
6416 + fwp = (byte *)flash_get_memptr(sector);
6418 + while (numbytes) {
6419 + *buffer++ = *(fwp + offset);
6427 +/*********************************************************************/
6428 +/* flash_write_buf() utilizes */
6429 +/* the unlock bypass mode of the flash device. This can remove */
6430 +/* significant overhead from the bulk programming operation, and */
6431 +/* when programming bulk data a sizeable performance increase can be */
6433 +/*********************************************************************/
6434 +int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes)
6438 + unsigned char *p = flash_get_memptr(sector) + offset;
6440 + /* After writing the flash block, compare the contents to the source
6441 + * buffer. Try to write the sector successfully up to three times.
6443 + for( i = 0; i < 3; i++ ) {
6444 + ret = flash_write(sector, offset, buffer, numbytes);
6445 + if( !memcmp( p, buffer, numbytes ) )
6447 + /* Erase and try again */
6448 + flash_sector_erase_int(sector);
6453 + printk( "Flash write error. Verify failed\n" );
6458 +/*********************************************************************/
6459 +/* Usefull funtion to return the number of sectors in the device. */
6460 +/* Can be used for functions which need to loop among all the */
6461 +/* sectors, or wish to know the number of the last sector. */
6462 +/*********************************************************************/
6463 +int flash_get_numsectors(void)
6465 + return meminfo.nsect;
6468 +/*********************************************************************/
6469 +/* flash_get_sector_size() is provided for cases in which the size */
6470 +/* of a sector is required by a host application. The sector size */
6471 +/* (in bytes) is returned in the data location pointed to by the */
6472 +/* 'size' parameter. */
6473 +/*********************************************************************/
6474 +int flash_get_sector_size(WORD sector)
6476 + return meminfo.sec[sector].size;
6479 +/*********************************************************************/
6480 +/* The purpose of flash_get_memptr() is to return a memory pointer */
6481 +/* which points to the beginning of memory space allocated for the */
6482 +/* flash. All function pointers are then referenced from this */
6485 +/* Different systems will implement this in different ways: */
6486 +/* possibilities include: */
6487 +/* - A direct memory pointer */
6488 +/* - A pointer to a memory map */
6489 +/* - A pointer to a hardware port from which the linear */
6490 +/* address is translated */
6491 +/* - Output of an MMU function / service */
6493 +/* Also note that this function expects the pointer to a specific */
6494 +/* sector of the device. This can be provided by dereferencing */
6495 +/* the pointer from a translated offset of the sector from a */
6496 +/* global base pointer (e.g. flashptr = base_pointer + sector_offset)*/
6498 +/* Important: Many AMD flash devices need both bank and or sector */
6499 +/* address bits to be correctly set (bank address bits are A18-A16, */
6500 +/* and sector address bits are A18-A12, or A12-A15). Flash parts */
6501 +/* which do not need these bits will ignore them, so it is safe to */
6502 +/* assume that every part will require these bits to be set. */
6503 +/*********************************************************************/
6504 +unsigned char *flash_get_memptr(WORD sector)
6506 + unsigned char *memptr = (unsigned char*)(FLASH_BASE_ADDR_REG + meminfo.sec[sector].base);
6511 +/*********************************************************************/
6512 +/* The purpose of flash_get_blk() is to return a the block number */
6513 +/* for a given memory address. */
6514 +/*********************************************************************/
6515 +int flash_get_blk(int addr)
6518 + int last_blk = flash_get_numsectors();
6519 + int relative_addr = addr - (int) FLASH_BASE_ADDR_REG;
6521 + for(blk_start=0, i=0; i < relative_addr && blk_start < last_blk; blk_start++)
6522 + i += flash_get_sector_size(blk_start);
6524 + if( i > relative_addr )
6526 + blk_start--; // last blk, dec by 1
6529 + if( blk_start == last_blk )
6531 + printk("Address is too big.\n");
6535 + return( blk_start );
6538 +/************************************************************************/
6539 +/* The purpose of flash_get_total_size() is to return the total size of */
6541 +/************************************************************************/
6542 +int flash_get_total_size()
6547 +/*********************************************************************/
6548 +/* Flash_command() is the main driver function. It performs */
6549 +/* every possible command available to AMD B revision */
6550 +/* flash parts. Note that this command is not used directly, but */
6551 +/* rather called through the API wrapper functions provided below. */
6552 +/*********************************************************************/
6553 +static void flash_command(int command, WORD sector, int offset, UINT16 data)
6555 + volatile UINT16 *flashptr;
6556 + volatile UINT16 *flashbase;
6558 + flashptr = (UINT16 *) flash_get_memptr(sector);
6559 + flashbase = (UINT16 *) flash_get_memptr(0);
6561 + switch (flashFamily) {
6562 + case FLASH_UNDEFINED:
6563 + /* These commands should work for AMD, Intel and SST flashes */
6564 + switch (command) {
6566 + flashptr[0] = 0xF0;
6567 + flashptr[0] = 0xFF;
6569 + case FLASH_READ_ID:
6570 + flashptr[0x5555] = 0xAA; /* unlock 1 */
6571 + flashptr[0x2AAA] = 0x55; /* unlock 2 */
6572 + flashptr[0x5555] = 0x90;
6579 + switch (command) {
6581 + flashptr[0] = 0xF0;
6583 + case FLASH_READ_ID:
6584 + flashptr[0x555] = 0xAA; /* unlock 1 */
6585 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6586 + flashptr[0x555] = 0x90;
6588 + case FLASH_CFIQUERY:
6589 + flashptr[0x55] = 0x98;
6592 + flashptr[0x555] = 0xAA; /* unlock 1 */
6593 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6594 + flashptr[0x555] = 0x20;
6597 + flashptr[0] = 0xA0;
6598 + flashptr[offset/2] = data;
6600 + case FLASH_UBRESET:
6601 + flashptr[0] = 0x90;
6602 + flashptr[0] = 0x00;
6604 + case FLASH_SERASE:
6605 + flashptr[0x555] = 0xAA; /* unlock 1 */
6606 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6607 + flashptr[0x555] = 0x80;
6608 + flashptr[0x555] = 0xAA;
6609 + flashptr[0x2AA] = 0x55;
6610 + flashptr[0] = 0x30;
6617 + switch (command) {
6619 + flashptr[0] = 0xFF;
6621 + case FLASH_READ_ID:
6622 + flashptr[0] = 0x90;
6624 + case FLASH_CFIQUERY:
6625 + flashptr[0] = 0x98;
6628 + flashptr[0] = 0x40;
6629 + flashptr[offset/2] = data;
6631 + case FLASH_SERASE:
6632 + flashptr[0] = 0x60;
6633 + flashptr[0] = 0xD0;
6634 + flashptr[0] = 0x20;
6635 + flashptr[0] = 0xD0;
6642 + switch (command) {
6644 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6645 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6646 + flashbase[0x5555] = 0xf0;
6648 + case FLASH_READ_ID:
6649 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6650 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6651 + flashbase[0x5555] = 0x90;
6653 + case FLASH_CFIQUERY:
6654 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6655 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6656 + flashbase[0x5555] = 0x98;
6661 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6662 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6663 + flashbase[0x5555] = 0xa0;
6664 + flashptr[offset/2] = data;
6666 + case FLASH_UBRESET:
6668 + case FLASH_SERASE:
6669 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6670 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6671 + flashbase[0x5555] = 0x80;
6672 + flashbase[0x5555] = 0xAA;
6673 + flashbase[0x2AAA] = 0x55;
6674 + flashptr[0] = 0x30;
6685 +/*********************************************************************/
6686 +/* flash_write extends the functionality of flash_program() by */
6687 +/* providing an faster way to program multiple data words, without */
6688 +/* needing the function overhead of looping algorithms which */
6689 +/* program word by word. This function utilizes fast pointers */
6690 +/* to quickly loop through bulk data. */
6691 +/*********************************************************************/
6692 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes)
6695 + src = (UINT16 *)buf;
6697 + if ((nbytes | offset) & 1) {
6701 + flash_command(FLASH_UB, 0, 0, 0);
6702 + while (nbytes > 0) {
6703 + flash_command(FLASH_PROG, sector, offset, *src);
6704 + if (flash_wait(sector, offset, *src) != STATUS_READY)
6710 + flash_command(FLASH_UBRESET, 0, 0, 0);
6712 + return (byte*)src - buf;
6715 +/*********************************************************************/
6716 +/* flash_wait utilizes the DQ6, DQ5, and DQ2 polling algorithms */
6717 +/* described in the flash data book. It can quickly ascertain the */
6718 +/* operational status of the flash device, and return an */
6719 +/* appropriate status code (defined in flash.h) */
6720 +/*********************************************************************/
6721 +static int flash_wait(WORD sector, int offset, UINT16 data)
6723 + volatile UINT16 *flashptr; /* flash window */
6726 + flashptr = (UINT16 *) flash_get_memptr(sector);
6728 + if (flashFamily == FLASH_AMD || flashFamily == FLASH_SST) {
6729 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
6731 + d1 = flashptr[offset/2];
6733 + return STATUS_READY;
6734 + } while (!(d1 & 0x20));
6736 + d1 = flashptr[offset/2];
6739 + flash_command(FLASH_RESET, 0, 0, 0);
6740 + return STATUS_TIMEOUT;
6744 + d1 = *flashptr; /* read data */
6745 + d1 ^= *flashptr; /* read it again and see what toggled */
6746 + if (d1 == 0) /* no toggles, nothing's happening */
6747 + return STATUS_READY;
6748 + } while (!(d1 & 0x20));
6750 + d1 = *flashptr; /* read data */
6751 + d1 ^= *flashptr; /* read it again and see what toggled */
6754 + flash_command(FLASH_RESET, 0, 0, 0);
6755 + return STATUS_TIMEOUT;
6758 + } else if (flashFamily == FLASH_INTEL) {
6759 + flashptr[0] = 0x70;
6760 + /* Wait for completion */
6761 + while(!(*flashptr & 0x80));
6762 + if (*flashptr & 0x30) {
6763 + flashptr[0] = 0x50;
6764 + flash_command(FLASH_RESET, 0, 0, 0);
6765 + return STATUS_TIMEOUT;
6767 + flashptr[0] = 0x50;
6768 + flash_command(FLASH_RESET, 0, 0, 0);
6771 + return STATUS_READY;
6774 +/*********************************************************************/
6775 +/* flash_get_device_id() will perform an autoselect sequence on the */
6776 +/* flash device, and return the device id of the component. */
6777 +/* This function automatically resets to read mode. */
6778 +/*********************************************************************/
6779 +static UINT16 flash_get_device_id()
6781 + volatile UINT16 *fwp; /* flash window */
6784 + fwp = (UINT16 *)flash_get_memptr(0);
6786 + flash_command(FLASH_READ_ID, 0, 0, 0);
6787 + answer = *(fwp + 1);
6788 + if (answer == ID_AM29LV320M) {
6789 + answer = *(fwp + 0xe);
6790 + answer = *(fwp + 0xf);
6793 + flash_command(FLASH_RESET, 0, 0, 0);
6794 + return( (UINT16) answer );
6797 +/*********************************************************************/
6798 +/* flash_get_cfi() is the main CFI workhorse function. Due to it's */
6799 +/* complexity and size it need only be called once upon */
6800 +/* initializing the flash system. Once it is called, all operations */
6801 +/* are performed by looking at the meminfo structure. */
6802 +/* All possible care was made to make this algorithm as efficient as */
6803 +/* possible. 90% of all operations are memory reads, and all */
6804 +/* calculations are done using bit-shifts when possible */
6805 +/*********************************************************************/
6806 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily)
6808 + volatile UINT16 *fwp; /* flash window */
6811 + flash_command(FLASH_CFIQUERY, 0, 0, 0);
6813 + if (cfi_struct == 0)
6814 + fwp = (UINT16 *)flash_get_memptr(0);
6818 + /* Initial house-cleaning */
6819 + for(i=0; i < 8; i++) {
6820 + query->erase_block[i].sector_size = 0;
6821 + query->erase_block[i].num_sectors = 0;
6824 + /* If not 'QRY', then we dont have a CFI enabled device in the socket */
6825 + if( fwp[0x10] != 'Q' &&
6826 + fwp[0x11] != 'R' &&
6827 + fwp[0x12] != 'Y') {
6828 + flash_command(FLASH_RESET, 0, 0, 0);
6832 + query->num_erase_blocks = fwp[0x2C];
6833 + if(flashFamily == FLASH_SST)
6834 + query->num_erase_blocks = 1;
6836 + for(i=0; i < query->num_erase_blocks; i++) {
6837 + query->erase_block[i].num_sectors = fwp[(0x2D+(4*i))] + (fwp[0x2E + (4*i)] << 8);
6838 + query->erase_block[i].num_sectors++;
6839 + query->erase_block[i].sector_size = 256 * (256 * fwp[(0x30+(4*i))] + fwp[(0x2F+(4*i))]);
6842 + flash_command(FLASH_RESET, 0, 0, 0);
6845 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/cfiflash.h linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h
6846 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/cfiflash.h 1970-01-01 01:00:00.000000000 +0100
6847 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h 2006-07-07 22:17:24.000000000 +0200
6849 +/************************************************************************/
6851 +/* AMD CFI Enabled Flash Memory Drivers */
6852 +/* File name: CFIFLASH.H */
6853 +/* Revision: 1.0 5/07/98 */
6855 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6856 +/* This software is unpublished and contains the trade secrets and */
6857 +/* confidential proprietary information of AMD. Unless otherwise */
6858 +/* provided in the Software Agreement associated herewith, it is */
6859 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
6860 +/* or part by any means except for backup. Use, duplication, or */
6861 +/* disclosure by the Government is subject to the restrictions in */
6862 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
6863 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
6864 +/* Software owned by */
6865 +/* Advanced Micro Devices, Inc., */
6866 +/* One AMD Place, */
6867 +/* P.O. Box 3453 */
6868 +/* Sunnyvale, CA 94088-3453. */
6869 +/************************************************************************/
6870 +/* This software constitutes a basic shell of source code for */
6871 +/* programming all AMD Flash components. AMD */
6872 +/* will not be responsible for misuse or illegal use of this */
6873 +/* software for devices not supported herein. AMD is providing */
6874 +/* this source code "AS IS" and will not be responsible for */
6875 +/* issues arising from incorrect user implementation of the */
6876 +/* source code herein. It is the user's responsibility to */
6877 +/* properly design-in this source code. */
6879 +/************************************************************************/
6880 +#ifndef _CFIFLASH_H
6881 +#define _CFIFLASH_H
6883 +#if defined __cplusplus
6887 +/* include board/CPU specific definitions */
6888 +#include "bcmtypes.h"
6891 +#define FLASH_BASE_ADDR_REG FLASH_BASE
6897 +#define MAXSECTORS 1024 /* maximum number of sectors supported */
6899 +/* A structure for identifying a flash part. There is one for each
6900 + * of the flash part definitions. We need to keep track of the
6901 + * sector organization, the address register used, and the size
6905 + char *name; /* "Am29DL800T", etc. */
6906 + unsigned long addr; /* physical address, once translated */
6907 + int areg; /* Can be set to zero for all parts */
6908 + int nsect; /* # of sectors -- 19 in LV, 22 in DL */
6909 + int bank1start; /* first sector # in bank 1 */
6910 + int bank2start; /* first sector # in bank 2, if DL part */
6912 + long size; /* # of bytes in this sector */
6913 + long base; /* offset from beginning of device */
6914 + int bank; /* 1 or 2 for DL; 1 for LV */
6915 + } sec[MAXSECTORS]; /* per-sector info */
6919 + * This structure holds all CFI query information as defined
6920 + * in the JEDEC standard. All information up to
6921 + * primary_extended_query is standard among all manufactures
6922 + * with CFI enabled devices.
6926 + int num_erase_blocks; /* Number of sector defs. */
6928 + unsigned long sector_size; /* byte size of sector */
6929 + int num_sectors; /* Num sectors of this size */
6930 + } erase_block[8]; /* Max of 256, but 8 is good */
6933 +/* Standard Boolean declarations */
6937 +/* Define different type of flash */
6938 +#define FLASH_UNDEFINED 0
6939 +#define FLASH_AMD 1
6940 +#define FLASH_INTEL 2
6941 +#define FLASH_SST 3
6943 +/* Command codes for the flash_command routine */
6944 +#define FLASH_RESET 0 /* reset to read mode */
6945 +#define FLASH_READ_ID 1 /* read device ID */
6946 +#define FLASH_CFIQUERY 2 /* CFI query */
6947 +#define FLASH_UB 3 /* go into unlock bypass mode */
6948 +#define FLASH_PROG 4 /* program a word */
6949 +#define FLASH_UBRESET 5 /* reset to read mode from unlock bypass mode */
6950 +#define FLASH_SERASE 6 /* sector erase */
6952 +/* Return codes from flash_status */
6953 +#define STATUS_READY 0 /* ready for action */
6954 +#define STATUS_TIMEOUT 1 /* operation timed out */
6956 +/* A list of AMD compatible device ID's - add others as needed */
6957 +#define ID_AM29DL800T 0x224A
6958 +#define ID_AM29DL800B 0x22CB
6959 +#define ID_AM29LV800T 0x22DA
6960 +#define ID_AM29LV800B 0x225B
6961 +#define ID_AM29LV400B 0x22BA
6963 +#define ID_AM29LV160B 0x2249
6964 +#define ID_AM29LV160T 0x22C4
6966 +#define ID_AM29LV320T 0x22F6
6967 +#define ID_MX29LV320AT 0x22A7
6968 +#define ID_AM29LV320B 0x22F9
6969 +#define ID_MX29LV320AB 0x22A8
6971 +#define ID_AM29LV320M 0x227E
6972 +#define ID_AM29LV320MB 0x2200
6973 +#define ID_AM29LV320MT 0x2201
6975 +#define ID_SST39VF1601 0x234B
6976 +#define ID_SST39VF3201 0x235B
6978 +/* A list of Intel compatible device ID's - add others as needed */
6979 +#define ID_I28F160C3T 0x88C2
6980 +#define ID_I28F160C3B 0x88C3
6981 +#define ID_I28F320C3T 0x88C4
6982 +#define ID_I28F320C3B 0x88C5
6984 +extern byte flash_init(void);
6985 +extern int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes);
6986 +extern int flash_read_buf(WORD sector, int offset, byte *buffer, int numbytes);
6987 +extern byte flash_sector_erase_int(WORD sector);
6988 +extern int flash_get_numsectors(void);
6989 +extern int flash_get_sector_size(WORD sector);
6990 +extern int flash_get_total_size(void);
6991 +extern unsigned char *flash_get_memptr(WORD sector);
6992 +extern int flash_get_blk(int addr);
6994 +#if defined __cplusplus
6999 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/irq.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c
7000 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/irq.c 1970-01-01 01:00:00.000000000 +0100
7001 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c 2006-07-07 22:15:18.000000000 +0200
7005 + Copyright 2002 Broadcom Corp. All Rights Reserved.
7007 + This program is free software; you can distribute it and/or modify it
7008 + under the terms of the GNU General Public License (Version 2) as
7009 + published by the Free Software Foundation.
7011 + This program is distributed in the hope it will be useful, but WITHOUT
7012 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7013 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7016 + You should have received a copy of the GNU General Public License along
7017 + with this program; if not, write to the Free Software Foundation, Inc.,
7018 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7022 + * Interrupt control functions for Broadcom 963xx MIPS boards
7025 +#include <asm/atomic.h>
7027 +#include <linux/delay.h>
7028 +#include <linux/init.h>
7029 +#include <linux/ioport.h>
7030 +#include <linux/irq.h>
7031 +#include <linux/interrupt.h>
7032 +#include <linux/kernel.h>
7033 +#include <linux/slab.h>
7034 +#include <linux/module.h>
7036 +#include <asm/irq.h>
7037 +#include <asm/mipsregs.h>
7038 +#include <asm/addrspace.h>
7039 +#include <asm/signal.h>
7040 +#include <bcm_map_part.h>
7041 +#include <bcm_intr.h>
7043 +static void irq_dispatch_int(struct pt_regs *regs)
7045 + unsigned int pendingIrqs;
7046 + static unsigned int irqBit;
7047 + static unsigned int isrNumber = 31;
7049 + pendingIrqs = PERF->IrqStatus & PERF->IrqMask;
7050 + if (!pendingIrqs) {
7057 + if (isrNumber == 32) {
7061 + if (pendingIrqs & irqBit) {
7062 + PERF->IrqMask &= ~irqBit; // mask
7063 + do_IRQ(isrNumber + INTERNAL_ISR_TABLE_OFFSET, regs);
7069 +static void irq_dispatch_ext(uint32 irq, struct pt_regs *regs)
7071 + if (!(PERF->ExtIrqCfg & (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)))) {
7072 + printk("**** Ext IRQ mask. Should not dispatch ****\n");
7074 + /* disable and clear interrupt in the controller */
7075 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7076 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7077 + do_IRQ(irq, regs);
7080 +void brcm_irq_dispatch(struct pt_regs *regs)
7083 + while((cause = (read_c0_cause()& CAUSEF_IP))) {
7084 + if (cause & CAUSEF_IP7)
7085 + do_IRQ(MIPS_TIMER_INT, regs);
7086 + else if (cause & CAUSEF_IP2)
7087 + irq_dispatch_int(regs);
7088 + else if (cause & CAUSEF_IP3)
7089 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7090 + else if (cause & CAUSEF_IP4)
7091 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7092 + else if (cause & CAUSEF_IP5)
7093 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7094 + else if (cause & CAUSEF_IP6)
7095 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7101 +void enable_brcm_irq(unsigned int irq)
7103 + unsigned long flags;
7105 + local_irq_save(flags);
7106 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7107 + PERF->IrqMask |= (1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7109 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7110 + /* enable and clear interrupt in the controller */
7111 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7112 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7114 + local_irq_restore(flags);
7117 +void disable_brcm_irq(unsigned int irq)
7119 + unsigned long flags;
7121 + local_irq_save(flags);
7122 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7123 + PERF->IrqMask &= ~(1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7125 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7126 + /* disable interrupt in the controller */
7127 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7129 + local_irq_restore(flags);
7132 +void ack_brcm_irq(unsigned int irq)
7134 + /* Already done in brcm_irq_dispatch */
7137 +unsigned int startup_brcm_irq(unsigned int irq)
7139 + enable_brcm_irq(irq);
7141 + return 0; /* never anything pending */
7144 +unsigned int startup_brcm_none(unsigned int irq)
7149 +void end_brcm_irq(unsigned int irq)
7151 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
7152 + enable_brcm_irq(irq);
7155 +void end_brcm_none(unsigned int irq)
7159 +#define ALLINTS_NOTIMER (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
7161 +static void __init brcm_irq_setup(void)
7163 + extern asmlinkage void brcmIRQ(void);
7165 + clear_c0_status(ST0_BEV);
7166 + set_except_vector(0, brcmIRQ);
7167 + change_c0_status(ST0_IM, ALLINTS_NOTIMER);
7169 +#ifdef CONFIG_REMOTE_DEBUG
7174 +static struct hw_interrupt_type brcm_irq_type = {
7175 + .typename = "MIPS",
7176 + .startup = startup_brcm_irq,
7177 + .shutdown = disable_brcm_irq,
7178 + .enable = enable_brcm_irq,
7179 + .disable = disable_brcm_irq,
7180 + .ack = ack_brcm_irq,
7181 + .end = end_brcm_irq,
7182 + .set_affinity = NULL
7185 +static struct hw_interrupt_type brcm_irq_no_end_type = {
7186 + .typename = "MIPS",
7187 + .startup = startup_brcm_none,
7188 + .shutdown = disable_brcm_irq,
7189 + .enable = enable_brcm_irq,
7190 + .disable = disable_brcm_irq,
7191 + .ack = ack_brcm_irq,
7192 + .end = end_brcm_none,
7193 + .set_affinity = NULL
7196 +void __init arch_init_irq(void)
7200 + for (i = 0; i < NR_IRQS; i++) {
7201 + irq_desc[i].status = IRQ_DISABLED;
7202 + irq_desc[i].action = 0;
7203 + irq_desc[i].depth = 1;
7204 + irq_desc[i].handler = &brcm_irq_type;
7210 +int request_external_irq(unsigned int irq,
7211 + FN_HANDLER handler,
7212 + unsigned long irqflags,
7213 + const char * devname,
7216 + unsigned long flags;
7218 + local_irq_save(flags);
7220 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT)); // Clear
7221 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)); // Mask
7222 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_INSENS_SHFT)); // Edge insesnsitive
7223 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_LEVEL_SHFT)); // Level triggered
7224 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_SENSE_SHFT)); // Low level
7226 + local_irq_restore(flags);
7228 + return( request_irq(irq, handler, irqflags, devname, dev_id) );
7231 +/* VxWorks compatibility function(s). */
7233 +unsigned int BcmHalMapInterrupt(FN_HANDLER pfunc, unsigned int param,
7234 + unsigned int interruptId)
7239 + devname = kmalloc(16, GFP_KERNEL);
7241 + sprintf( devname, "brcm_%d", interruptId );
7243 + /* Set the IRQ description to not automatically enable the interrupt at
7244 + * the end of an ISR. The driver that handles the interrupt must
7245 + * explicitly call BcmHalInterruptEnable or enable_brcm_irq. This behavior
7246 + * is consistent with interrupt handling on VxWorks.
7248 + irq_desc[interruptId].handler = &brcm_irq_no_end_type;
7250 + if( interruptId >= INTERNAL_ISR_TABLE_OFFSET )
7252 + nRet = request_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7253 + devname, (void *) param );
7255 + else if (interruptId >= INTERRUPT_ID_EXTERNAL_0 && interruptId <= INTERRUPT_ID_EXTERNAL_3)
7257 + nRet = request_external_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7258 + devname, (void *) param );
7265 +/* Debug function. */
7267 +void dump_intr_regs(void)
7269 + printk("PERF->ExtIrqCfg [%08x]\n", *(&(PERF->ExtIrqCfg)));
7272 +EXPORT_SYMBOL(enable_brcm_irq);
7273 +EXPORT_SYMBOL(disable_brcm_irq);
7274 +EXPORT_SYMBOL(request_external_irq);
7275 +EXPORT_SYMBOL(BcmHalMapInterrupt);
7277 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/Kconfig linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig
7278 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
7279 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig 2006-07-07 22:15:18.000000000 +0200
7281 +# Kernel and Driver configuration for Broadcom Commengine ADSL board
7283 + prompt "Broadcom Commengine ADSL board"
7284 + depends on MIPS_BRCM
7287 + Select different Broadcom ADSL board
7290 + bool "96338 ADSL board"
7291 + select DMA_NONCOHERENT
7295 + bool "96345 ADSL board"
7296 + select DMA_NONCOHERENT
7300 + bool "96348 ADSL board"
7301 + select DMA_NONCOHERENT
7307 + bool "Support for Broadcom Board"
7308 + depends on BCM96338 || BCM96345 || BCM96348
7311 + bool "Support for Serial Port"
7312 + depends on BCM96338 || BCM96345 || BCM96348
7315 + tristate "Support for Ethernet"
7316 + depends on BCM96338 || BCM96345 || BCM96348
7319 + tristate "Support for USB"
7320 + depends on BCM96338 || BCM96345 || BCM96348
7323 + tristate "Support for Wireless"
7324 + depends on BCM96338 || BCM96345 || BCM96348
7327 + bool "Support for PCI"
7328 + depends on BCM96338 || BCM96345 || BCM96348
7332 + tristate "Support for ATM"
7333 + depends on BCM96338 || BCM96345 || BCM96348
7336 + tristate "Support for ATM Diagnostic"
7337 + depends on BCM96338 || BCM96345 || BCM96348
7340 + tristate "Support for ADSL"
7341 + depends on BCM96338 || BCM96345 || BCM96348
7343 +config BCM_ENDPOINT
7344 + tristate "Support for VOICE"
7345 + depends on BCM96338 || BCM96345 || BCM96348
7348 + tristate "Support for PROCFS"
7349 + depends on BCM96338 || BCM96345 || BCM96348
7352 + tristate "Support for VDSL"
7353 + depends on BCM96338 || BCM96345 || BCM96348
7355 +config BCM_SECURITY
7356 + tristate "Support for SECURITY"
7357 + depends on BCM96338 || BCM96345 || BCM96348
7360 + tristate "Support for HPNA"
7361 + depends on BCM96338 || BCM96345 || BCM96348
7363 +config BCM_BOARD_IMPL
7364 + int "Implementation index for ADSL Board"
7365 + depends on BCM96338 || BCM96345 || BCM96348
7367 +config BCM_SERIAL_IMPL
7368 + int "Implementation index for Serial"
7369 + depends on BCM96338 || BCM96345 || BCM96348
7371 +config BCM_ENET_IMPL
7372 + int "Implementation index for Ethernet"
7373 + depends on BCM96338 || BCM96345 || BCM96348
7375 +config BCM_USB_IMPL
7376 + int "Implementation index for USB"
7377 + depends on BCM96338 || BCM96345 || BCM96348
7379 +config BCM_WLAN_IMPL
7380 + int "Implementation index for WIRELESS"
7381 + depends on BCM96338 || BCM96345 || BCM96348
7383 +config BCM_ATMAPI_IMPL
7384 + int "Implementation index for ATM"
7385 + depends on BCM96338 || BCM96345 || BCM96348
7387 +config BCM_ATMTEST_IMPL
7388 + int "Implementation index for ATM Diagnostic"
7389 + depends on BCM96338 || BCM96345 || BCM96348
7391 +config BCM_BLAA_IMPL
7392 + int "Implementation index for BLAA"
7393 + depends on BCM96338 || BCM96345 || BCM96348
7395 +config BCM_ADSL_IMPL
7396 + int "Implementation index for ADSL"
7397 + depends on BCM96338 || BCM96345 || BCM96348
7399 +config BCM_ENDPOINT_IMPL
7400 + int "Implementation index for VOICE"
7401 + depends on BCM96338 || BCM96345 || BCM96348
7403 +config BCM_PROCFS_IMPL
7404 + int "Implementation index for PROCFS"
7405 + depends on BCM96338 || BCM96345 || BCM96348
7407 +config BCM_VDSL_IMPL
7408 + int "Implementation index for VDSL"
7409 + depends on BCM96338 || BCM96345 || BCM96348
7411 +config BCM_SECURITY_IMPL
7412 + int "Implementation index for SECURITY"
7413 + depends on BCM96338 || BCM96345 || BCM96348
7415 +config BCM_HPNA_IMPL
7416 + int "Implementation index for HPNA"
7417 + depends on BCM96338 || BCM96345 || BCM96348
7420 + prompt "Root File System"
7421 + depends on MIPS_BRCM
7422 + default ROOTFS_SQUASHFS
7424 + Select root file system on the board flash.
7426 +config ROOTFS_SQUASHFS
7428 +config ROOTFS_CRAMFS
7430 +config ROOTFS_JFFS2
7437 +config ROOT_FLASHFS
7438 + string "flash partition"
7439 + depends on ROOTFS_SQUASHFS || ROOTFS_CRAMFS || ROOTFS_JFFS2
7440 + default "root=31:0 ro noinitrd" if ROOTFS_SQUASHFS = y || ROOTFS_CRAMFS = y
7441 + default "root=31:2 ro noinitrd" if ROOTFS_JFFS2 = y
7443 + This is the root file system partition on flash memory
7445 +config ROOT_NFS_DIR
7446 + string "NFS server path"
7447 + depends on ROOTFS_NFS
7448 + default "/opt/bcm96338/targets/96338R/fs" if BCM96338 = y
7449 + default "/opt/bcm96345/targets/96345R/fs" if BCM96345 = y
7450 + default "/opt/bcm96348/targets/96348R/fs" if BCM96348 = y
7452 + This is the path of NFS server (host system)
7453 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/Makefile linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile
7454 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/Makefile 1970-01-01 01:00:00.000000000 +0100
7455 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile 2006-07-07 22:18:20.000000000 +0200
7458 +# Makefile for generic Broadcom MIPS boards
7460 +# Copyright (C) 2004 Broadcom Corporation
7462 +obj-y := irq.o prom.o setup.o time.o ser_init.o bcm63xx_flash.o bcm63xx_led.o board.o boardparms.o cfiflash.o
7464 +SRCBASE := $(TOPDIR)
7465 +EXTRA_CFLAGS += -I$(SRCBASE)/include
7466 +#EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH) -DDBG
7467 +EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH)
7470 +ifeq "$(ADSL)" "ANNEX_B"
7471 +EXTRA_CFLAGS += -DADSL_ANNEXB
7473 +ifeq "$(ADSL)" "SADSL"
7474 +EXTRA_CFLAGS += -DADSL_SADSL
7476 +ifeq "$(ADSL)" "ANNEX_C"
7477 +EXTRA_CFLAGS += -DADSL_ANNEXC
7480 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/prom.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c
7481 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/prom.c 1970-01-01 01:00:00.000000000 +0100
7482 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c 2006-07-07 22:15:18.000000000 +0200
7486 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7488 + This program is free software; you can distribute it and/or modify it
7489 + under the terms of the GNU General Public License (Version 2) as
7490 + published by the Free Software Foundation.
7492 + This program is distributed in the hope it will be useful, but WITHOUT
7493 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7494 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7497 + You should have received a copy of the GNU General Public License along
7498 + with this program; if not, write to the Free Software Foundation, Inc.,
7499 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7503 + * prom.c: PROM library initialization code.
7506 +#include <linux/init.h>
7507 +#include <linux/mm.h>
7508 +#include <linux/sched.h>
7509 +#include <linux/bootmem.h>
7510 +#include <linux/blkdev.h>
7511 +#include <asm/addrspace.h>
7512 +#include <asm/bootinfo.h>
7513 +#include <asm/cpu.h>
7514 +#include <asm/time.h>
7516 +#include <bcm_map_part.h>
7518 +#include "boardparms.h"
7519 +#include "softdsl/AdslCoreDefs.h"
7522 +extern int do_syslog(int, char *, int);
7523 +extern void serial_init(void);
7524 +extern void __init InitNvramInfo( void );
7525 +/*extern void kerSysFlashInit( void );*/
7526 +/*extern unsigned long get_nvram_start_addr(void);*/
7527 +void __init create_root_nfs_cmdline( char *cmdline );
7529 +#if defined(CONFIG_BCM96338)
7530 +#define CPU_CLOCK 240000000
7531 +#define MACH_BCM MACH_BCM96338
7533 +#if defined(CONFIG_BCM96345)
7534 +#define CPU_CLOCK 140000000
7535 +#define MACH_BCM MACH_BCM96345
7537 +#if defined(CONFIG_BCM96348)
7538 +void __init calculateCpuSpeed(void);
7539 +static unsigned long cpu_speed;
7540 +#define CPU_CLOCK cpu_speed
7541 +#define MACH_BCM MACH_BCM96348
7544 +const char *get_system_type(void)
7546 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7548 + return( pNvramData->szBoardId );*/
7549 + return "brcm63xx";
7552 +unsigned long getMemorySize(void)
7554 + unsigned long ulSdramType = BOARD_SDRAM_TYPE;
7556 + unsigned long ulSdramSize;
7558 + switch( ulSdramType )
7560 + case BP_MEMORY_16MB_1_CHIP:
7561 + case BP_MEMORY_16MB_2_CHIP:
7562 + ulSdramSize = 16 * 1024 * 1024;
7564 + case BP_MEMORY_32MB_1_CHIP:
7565 + case BP_MEMORY_32MB_2_CHIP:
7566 + ulSdramSize = 32 * 1024 * 1024;
7568 + case BP_MEMORY_64MB_2_CHIP:
7569 + ulSdramSize = 64 * 1024 * 1024;
7572 + ulSdramSize = 8 * 1024 * 1024;
7576 + return ulSdramSize;
7579 +/* --------------------------------------------------------------------------
7581 + -------------------------------------------------------------------------- */
7582 +void __init prom_init(void)
7584 + extern ulong r4k_interval;
7588 + /*kerSysFlashInit();*/
7590 + do_syslog(8, NULL, 8);
7592 + printk( "%s prom init\n", get_system_type() );
7594 + PERF->IrqMask = 0;
7596 + arcs_cmdline[0] = '\0';
7598 +#if defined(CONFIG_ROOT_NFS)
7599 + create_root_nfs_cmdline( arcs_cmdline );
7601 +#elif defined(CONFIG_ROOT_FLASHFS)
7602 + strcpy(arcs_cmdline, CONFIG_ROOT_FLASHFS);
7605 + add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7607 +#if defined(CONFIG_BCM96348)
7608 + calculateCpuSpeed();
7610 + /* Count register increments every other clock */
7611 + r4k_interval = CPU_CLOCK / HZ / 2;
7612 + mips_hpt_frequency = CPU_CLOCK / 2;
7614 + mips_machgroup = MACH_GROUP_BRCM;
7615 + mips_machtype = MACH_BCM;
7618 +/* --------------------------------------------------------------------------
7619 + Name: prom_free_prom_memory
7621 + -------------------------------------------------------------------------- */
7622 +void __init prom_free_prom_memory(void)
7628 +#if defined(CONFIG_ROOT_NFS)
7629 +/* This function reads in a line that looks something like this:
7632 + * CFE bootline=bcmEnet(0,0)host:vmlinux e=192.169.0.100:ffffff00 h=192.169.0.1
7635 + * and retuns in the cmdline parameter some that looks like this:
7637 + * CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/opt/targets/96345R/fs
7638 + * ip=192.168.0.100:192.168.0.1::255.255.255.0::eth0:off rw"
7640 +#define BOOT_LINE_ADDR 0x0
7641 +#define HEXDIGIT(d) ((d >= '0' && d <= '9') ? (d - '0') : ((d | 0x20) - 'W'))
7642 +#define HEXBYTE(b) (HEXDIGIT((b)[0]) << 4) + HEXDIGIT((b)[1])
7643 +extern unsigned long get_nvram_start_addr(void);
7645 +void __init create_root_nfs_cmdline( char *cmdline )
7647 + char root_nfs_cl[] = "root=/dev/nfs nfsroot=%s:" CONFIG_ROOT_NFS_DIR
7648 + " ip=%s:%s::%s::eth0:off rw";
7650 + char *localip = NULL;
7651 + char *hostip = NULL;
7652 + char mask[16] = "";
7653 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7654 + char bootline[128] = "";
7655 + char *p = bootline;
7657 + memcpy(bootline, pNvramData->szBootline, sizeof(bootline));
7660 + if( p[0] == 'e' && p[1] == '=' )
7662 + /* Found local ip address */
7665 + while( *p && *p != ' ' && *p != ':' )
7669 + /* Found network mask (eg FFFFFF00 */
7671 + sprintf( mask, "%u.%u.%u.%u", HEXBYTE(p), HEXBYTE(p + 2),
7672 + HEXBYTE(p + 4), HEXBYTE(p + 6) );
7675 + else if( *p == ' ' )
7678 + else if( p[0] == 'h' && p[1] == '=' )
7680 + /* Found host ip address */
7683 + while( *p && *p != ' ' )
7692 + if( localip && hostip )
7693 + sprintf( cmdline, root_nfs_cl, hostip, localip, hostip, mask );
7698 +#if defined(CONFIG_BCM96348)
7699 +/* *********************************************************************
7700 + * calculateCpuSpeed()
7701 + * Calculate the BCM6348 CPU speed by reading the PLL strap register
7702 + * and applying the following formula:
7703 + * cpu_clk = (.25 * 64MHz freq) * (N1 + 1) * (N2 + 2) / (M1_CPU + 1)
7704 + * Input parameters:
7708 + ********************************************************************* */
7709 +void __init calculateCpuSpeed(void)
7711 + UINT32 pllStrap = PERF->PllStrap;
7712 + int n1 = (pllStrap & PLL_N1_MASK) >> PLL_N1_SHFT;
7713 + int n2 = (pllStrap & PLL_N2_MASK) >> PLL_N2_SHFT;
7714 + int m1cpu = (pllStrap & PLL_M1_CPU_MASK) >> PLL_M1_CPU_SHFT;
7716 + cpu_speed = (16 * (n1 + 1) * (n2 + 2) / (m1cpu + 1)) * 1000000;
7720 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/ser_init.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c
7721 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/ser_init.c 1970-01-01 01:00:00.000000000 +0100
7722 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c 2006-07-07 22:15:18.000000000 +0200
7726 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7728 + This program is free software; you can distribute it and/or modify it
7729 + under the terms of the GNU General Public License (Version 2) as
7730 + published by the Free Software Foundation.
7732 + This program is distributed in the hope it will be useful, but WITHOUT
7733 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7734 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7737 + You should have received a copy of the GNU General Public License along
7738 + with this program; if not, write to the Free Software Foundation, Inc.,
7739 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7743 + * Broadcom bcm63xx serial port initialization, also prepare for printk
7744 + * by registering with console_init
7748 +#include <linux/config.h>
7749 +#include <linux/init.h>
7750 +#include <linux/interrupt.h>
7751 +#include <linux/kernel.h>
7752 +#include <linux/types.h>
7753 +#include <linux/console.h>
7754 +#include <linux/sched.h>
7756 +#include <asm/addrspace.h>
7757 +#include <asm/irq.h>
7758 +#include <asm/reboot.h>
7759 +#include <asm/gdb-stub.h>
7760 +#include <asm/mc146818rtc.h>
7762 +#include <bcm_map_part.h>
7765 +#define SER63XX_DEFAULT_BAUD 115200
7766 +#define BD_BCM63XX_TIMER_CLOCK_INPUT (FPERIPH)
7767 +#define stUart ((volatile Uart * const) UART_BASE)
7769 +// Transmit interrupts
7770 +#define TXINT (TXFIFOEMT | TXUNDERR | TXOVFERR)
7771 +// Receive interrupts
7772 +#define RXINT (RXFIFONE | RXOVFERR)
7774 +/* --------------------------------------------------------------------------
7776 + Purpose: Initalize the UART
7777 +-------------------------------------------------------------------------- */
7778 +void __init serial_init(void)
7780 + UINT32 tmpVal = SER63XX_DEFAULT_BAUD;
7781 + ULONG clockFreqHz;
7783 +#if defined(CONFIG_BCM96345)
7784 + // Make sure clock is ticking
7785 + PERF->blkEnables |= UART_CLK_EN;
7788 + /* Dissable channel's receiver and transmitter. */
7789 + stUart->control &= ~(BRGEN|TXEN|RXEN);
7791 + /*--------------------------------------------------------------------*/
7792 + /* Write the table value to the clock select register. */
7793 + /* DPullen - this is the equation to use: */
7794 + /* value = clockFreqHz / baud / 32-1; */
7795 + /* (snmod) Actually you should also take into account any necessary */
7796 + /* rounding. Divide by 16, look at lsb, if 0, divide by 2 */
7797 + /* and subtract 1. If 1, just divide by 2 */
7798 + /*--------------------------------------------------------------------*/
7799 + clockFreqHz = BD_BCM63XX_TIMER_CLOCK_INPUT;
7800 + tmpVal = (clockFreqHz / tmpVal) / 16;
7801 + if( tmpVal & 0x01 )
7802 + tmpVal /= 2; //Rounding up, so sub is already accounted for
7804 + tmpVal = (tmpVal / 2) - 1; // Rounding down so we must sub 1
7805 + stUart->baudword = tmpVal;
7807 + /* Finally, re-enable the transmitter and receiver. */
7808 + stUart->control |= (BRGEN|TXEN|RXEN);
7810 + stUart->config = (BITS8SYM | ONESTOP);
7811 + // Set the FIFO interrupt depth ... stUart->fifocfg = 0xAA;
7812 + stUart->fifoctl = RSTTXFIFOS | RSTRXFIFOS;
7813 + stUart->intMask = 0;
7814 + stUart->intMask = RXINT | TXINT;
7819 + * Output a character to the UART
7821 +void prom_putc(char c)
7823 + /* Wait for Tx uffer to empty */
7824 + while (! (READ16(stUart->intStatus) & TXFIFOEMT));
7825 + /* Send character */
7830 + * Write a string to the UART
7832 +void prom_puts(const char *s)
7843 +/* prom_getc_nowait()
7844 + * Returns a character from the UART
7845 + * Returns -1 if no characters available or corrupted
7847 +int prom_getc_nowait(void)
7852 + uStatus = READ16(stUart->intStatus);
7854 + if (uStatus & RXFIFONE) { /* Do we have a character? */
7855 + cData = READ16(stUart->Data) & 0xff; /* Read character */
7856 + if (uStatus & (RXFRAMERR | RXPARERR)) { /* If we got an error, throw it away */
7865 + * Returns a charcter from the serial port
7866 + * Will block until it receives a valid character
7868 +char prom_getc(void)
7872 + /* Loop until we get a valid character */
7873 + while(cData == -1) {
7874 + cData = prom_getc_nowait();
7876 + return (char) cData;
7880 + * Returns 0 if no characters available
7882 +int prom_testc(void)
7886 + uStatus = READ16(stUart->intStatus);
7888 + return (uStatus & RXFIFONE);
7891 +#if CONFIG_REMOTE_DEBUG
7892 +/* Prevent other code from writing to the serial port */
7893 +void _putc(char c) { }
7894 +void _puts(const char *ptr) { }
7896 +/* Low level outputs call prom routines */
7897 +void _putc(char c) {
7900 +void _puts(const char *ptr) {
7904 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/setup.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c
7905 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/setup.c 1970-01-01 01:00:00.000000000 +0100
7906 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c 2006-07-07 22:15:18.000000000 +0200
7910 + Copyright 2002 Broadcom Corp. All Rights Reserved.
7912 + This program is free software; you can distribute it and/or modify it
7913 + under the terms of the GNU General Public License (Version 2) as
7914 + published by the Free Software Foundation.
7916 + This program is distributed in the hope it will be useful, but WITHOUT
7917 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7918 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7921 + You should have received a copy of the GNU General Public License along
7922 + with this program; if not, write to the Free Software Foundation, Inc.,
7923 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7927 + * Generic setup routines for Broadcom 963xx MIPS boards
7930 +#include <linux/config.h>
7931 +#include <linux/init.h>
7932 +#include <linux/interrupt.h>
7933 +#include <linux/kernel.h>
7934 +#include <linux/kdev_t.h>
7935 +#include <linux/types.h>
7936 +#include <linux/console.h>
7937 +#include <linux/sched.h>
7938 +#include <linux/mm.h>
7939 +#include <linux/slab.h>
7940 +#include <linux/module.h>
7941 +#include <linux/pm.h>
7943 +#include <asm/addrspace.h>
7944 +#include <asm/bcache.h>
7945 +#include <asm/irq.h>
7946 +#include <asm/time.h>
7947 +#include <asm/reboot.h>
7948 +#include <asm/gdb-stub.h>
7950 +extern void brcm_timer_setup(struct irqaction *irq);
7951 +extern unsigned long getMemorySize(void);
7953 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
7954 +#include <linux/pci.h>
7955 +#include <linux/delay.h>
7956 +#include <bcm_map_part.h>
7957 +#include <bcmpci.h>
7959 +static volatile MpiRegisters * mpi = (MpiRegisters *)(MPI_BASE);
7962 +/* This function should be in a board specific directory. For now,
7963 + * assume that all boards that include this file use a Broadcom chip
7964 + * with a soft reset bit in the PLL control register.
7966 +static void brcm_machine_restart(char *command)
7968 + const unsigned long ulSoftReset = 0x00000001;
7969 + unsigned long *pulPllCtrl = (unsigned long *) 0xfffe0008;
7970 + *pulPllCtrl |= ulSoftReset;
7973 +static void brcm_machine_halt(void)
7975 + printk("System halted\n");
7979 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
7981 +static void mpi_SetLocalPciConfigReg(uint32 reg, uint32 value)
7983 + /* write index then value */
7984 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
7985 + mpi->pcicfgdata = value;
7988 +static uint32 mpi_GetLocalPciConfigReg(uint32 reg)
7990 + /* write index then get value */
7991 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
7992 + return mpi->pcicfgdata;
7996 + * mpi_ResetPcCard: Set/Reset the PcCard
7998 +static void mpi_ResetPcCard(int cardtype, BOOL bReset)
8000 + if (cardtype == MPI_CARDTYPE_NONE) {
8004 + if (cardtype == MPI_CARDTYPE_CARDBUS) {
8005 + bReset = ! bReset;
8009 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8011 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 | PCCARD_CARD_RESET);
8016 + * mpi_ConfigCs: Configure an MPI/EBI chip select
8018 +static void mpi_ConfigCs(uint32 cs, uint32 base, uint32 size, uint32 flags)
8020 + mpi->cs[cs].base = ((base & 0x1FFFFFFF) | size);
8021 + mpi->cs[cs].config = flags;
8025 + * mpi_InitPcmciaSpace
8027 +static void mpi_InitPcmciaSpace(void)
8029 + // ChipSelect 4 controls PCMCIA Memory accesses
8030 + mpi_ConfigCs(PCMCIA_COMMON_BASE, pcmciaMem, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8031 + // ChipSelect 5 controls PCMCIA Attribute accesses
8032 + mpi_ConfigCs(PCMCIA_ATTRIBUTE_BASE, pcmciaAttr, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8033 + // ChipSelect 6 controls PCMCIA I/O accesses
8034 + mpi_ConfigCs(PCMCIA_IO_BASE, pcmciaIo, EBI_SIZE_64K, (EBI_WORD_WIDE|EBI_ENABLE));
8036 + mpi->pcmcia_cntl2 = ((PCMCIA_ATTR_ACTIVE << RW_ACTIVE_CNT_BIT) |
8037 + (PCMCIA_ATTR_INACTIVE << INACTIVE_CNT_BIT) |
8038 + (PCMCIA_ATTR_CE_SETUP << CE_SETUP_CNT_BIT) |
8039 + (PCMCIA_ATTR_CE_HOLD << CE_HOLD_CNT_BIT));
8041 + mpi->pcmcia_cntl2 |= (PCMCIA_HALFWORD_EN | PCMCIA_BYTESWAP_DIS);
8045 + * cardtype_vcc_detect: PC Card's card detect and voltage sense connection
8047 + * CD1#/ CD2#/ VS1#/ VS2#/ Card Initial Vcc
8048 + * CCD1# CCD2# CVS1 CVS2 Type
8050 + * GND GND open open 16-bit 5 vdc
8052 + * GND GND GND open 16-bit 3.3 vdc
8054 + * GND GND open GND 16-bit x.x vdc
8056 + * GND GND GND GND 16-bit 3.3 & x.x vdc
8058 + *====================================================================
8060 + * CVS1 GND CCD1# open CardBus 3.3 vdc
8062 + * GND CVS2 open CCD2# CardBus x.x vdc
8064 + * GND CVS1 CCD2# open CardBus y.y vdc
8066 + * GND CVS2 GND CCD2# CardBus 3.3 & x.x vdc
8068 + * CVS2 GND open CCD1# CardBus x.x & y.y vdc
8070 + * GND CVS1 CCD2# open CardBus 3.3, x.x & y.y vdc
8073 +static int cardtype_vcc_detect(void)
8078 + cardtype = MPI_CARDTYPE_NONE;
8079 + mpi->pcmcia_cntl1 = 0x0000A000; // Turn on the output enables and drive
8080 + // the CVS pins to 0.
8081 + data32 = mpi->pcmcia_cntl1;
8082 + switch (data32 & 0x00000003) // Test CD1# and CD2#, see if card is plugged in.
8084 + case 0x00000003: // No Card is in the slot.
8085 + printk("mpi: No Card is in the PCMCIA slot\n");
8088 + case 0x00000002: // Partial insertion, No CD2#.
8089 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD2 signal\n");
8092 + case 0x00000001: // Partial insertion, No CD1#.
8093 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD1 signal\n");
8097 + mpi->pcmcia_cntl1 = 0x0000A0C0; // Turn off the CVS output enables and
8098 + // float the CVS pins.
8100 + data32 = mpi->pcmcia_cntl1;
8101 + // Read the Register.
8102 + switch (data32 & 0x0000000C) // See what is on the CVS pins.
8104 + case 0x00000000: // CVS1 and CVS2 are tied to ground, only 1 option.
8105 + printk("mpi: Detected 3.3 & x.x 16-bit PCMCIA card\n");
8106 + cardtype = MPI_CARDTYPE_PCMCIA;
8109 + case 0x00000004: // CVS1 is open or tied to CCD1/CCD2 and CVS2 is tied to ground.
8110 + // 2 valid voltage options.
8111 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8113 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8114 + // This is not a valid combination.
8115 + printk("mpi: Unknown card plugged into slot\n");
8118 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8119 + mpi->pcmcia_cntl1 = 0x0000A080; // Drive CVS1 to a 0.
8121 + data32 = mpi->pcmcia_cntl1;
8122 + if (data32 & 0x00000002) { // CCD2 is tied to CVS2, not valid.
8123 + printk("mpi: Unknown card plugged into slot\n");
8124 + } else { // CCD2 is tied to CVS1.
8125 + printk("mpi: Detected 3.3, x.x and y.y Cardbus card\n");
8126 + cardtype = MPI_CARDTYPE_CARDBUS;
8130 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8131 + // This is not a valid combination.
8132 + printk("mpi: Unknown card plugged into slot\n");
8135 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8136 + printk("mpi: Detected x.x vdc 16-bit PCMCIA card\n");
8137 + cardtype = MPI_CARDTYPE_PCMCIA;
8142 + case 0x00000008: // CVS2 is open or tied to CCD1/CCD2 and CVS1 is tied to ground.
8143 + // 2 valid voltage options.
8144 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8146 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8147 + // This is not a valid combination.
8148 + printk("mpi: Unknown card plugged into slot\n");
8151 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8152 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8154 + data32 = mpi->pcmcia_cntl1;
8155 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1, not valid.
8156 + printk("mpi: Unknown card plugged into slot\n");
8157 + } else {// CCD2 is tied to CVS2.
8158 + printk("mpi: Detected 3.3 and x.x Cardbus card\n");
8159 + cardtype = MPI_CARDTYPE_CARDBUS;
8163 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8164 + // This is not a valid combination.
8165 + printk("mpi: Unknown card plugged into slot\n");
8168 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8169 + cardtype = MPI_CARDTYPE_PCMCIA;
8170 + printk("mpi: Detected 3.3 vdc 16-bit PCMCIA card\n");
8175 + case 0x0000000C: // CVS1 and CVS2 are open or tied to CCD1/CCD2.
8176 + // 5 valid voltage options.
8178 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8180 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8181 + // This is not a valid combination.
8182 + printk("mpi: Unknown card plugged into slot\n");
8185 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8186 + // CCD1 is tied to ground.
8187 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8189 + data32 = mpi->pcmcia_cntl1;
8190 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1.
8191 + printk("mpi: Detected y.y vdc Cardbus card\n");
8192 + } else { // CCD2 is tied to CVS2.
8193 + printk("mpi: Detected x.x vdc Cardbus card\n");
8195 + cardtype = MPI_CARDTYPE_CARDBUS;
8198 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8199 + // CCD2 is tied to ground.
8201 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8203 + data32 = mpi->pcmcia_cntl1;
8204 + if (data32 & 0x00000001) {// CCD1 is tied to CVS1.
8205 + printk("mpi: Detected 3.3 vdc Cardbus card\n");
8206 + } else { // CCD1 is tied to CVS2.
8207 + printk("mpi: Detected x.x and y.y Cardbus card\n");
8209 + cardtype = MPI_CARDTYPE_CARDBUS;
8212 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8213 + cardtype = MPI_CARDTYPE_PCMCIA;
8214 + printk("mpi: Detected 5 vdc 16-bit PCMCIA card\n");
8220 + printk("mpi: Unknown card plugged into slot\n");
8229 + * mpi_DetectPcCard: Detect the plugged in PC-Card
8230 + * Return: < 0 => Unknown card detected
8231 + * 0 => No card detected
8232 + * 1 => 16-bit card detected
8233 + * 2 => 32-bit CardBus card detected
8235 +static int mpi_DetectPcCard(void)
8239 + cardtype = cardtype_vcc_detect();
8240 + switch(cardtype) {
8241 + case MPI_CARDTYPE_PCMCIA:
8242 + mpi->pcmcia_cntl1 &= ~0x0000e000; // disable enable bits
8243 + //mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8244 + mpi->pcmcia_cntl1 |= (PCMCIA_ENABLE | PCMCIA_GPIO_ENABLE);
8245 + mpi_InitPcmciaSpace();
8246 + mpi_ResetPcCard(cardtype, FALSE);
8247 + // Hold card in reset for 10ms
8249 + mpi_ResetPcCard(cardtype, TRUE);
8250 + // Let card come out of reset
8253 + case MPI_CARDTYPE_CARDBUS:
8254 + // 8 => CardBus Enable
8255 + // 1 => PCI Slot Number
8256 + // C => Float VS1 & VS2
8257 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & 0xFFFF0000) |
8259 + (CARDBUS_SLOT << 8)|
8262 + /* access to this memory window will be to/from CardBus */
8263 + mpi->l2pmremap1 |= CARDBUS_MEM;
8265 + // Need to reset the Cardbus Card. There's no CardManager to do this,
8266 + // and we need to be ready for PCI configuration.
8267 + mpi_ResetPcCard(cardtype, FALSE);
8268 + // Hold card in reset for 10ms
8270 + mpi_ResetPcCard(cardtype, TRUE);
8271 + // Let card come out of reset
8280 +static int mpi_init(void)
8282 + unsigned long data;
8283 + unsigned int chipid;
8284 + unsigned int chiprev;
8285 + unsigned int sdramsize;
8287 + chipid = (PERF->RevID & 0xFFFF0000) >> 16;
8288 + chiprev = (PERF->RevID & 0xFF);
8289 + sdramsize = getMemorySize();
8291 + * Init the pci interface
8293 + data = GPIO->GPIOMode; // GPIO mode register
8294 + data |= GROUP2_PCI | GROUP1_MII_PCCARD; // PCI internal arbiter + Cardbus
8295 + GPIO->GPIOMode = data; // PCI internal arbiter
8298 + * In the BCM6348 CardBus support is defaulted to Slot 0
8299 + * because there is no external IDSEL for CardBus. To disable
8300 + * the CardBus and allow a standard PCI card in Slot 0
8301 + * set the cbus_idsel field to 0x1f.
8304 + uData = mpi->pcmcia_cntl1;
8305 + uData |= CARDBUS_IDSEL;
8306 + mpi->pcmcia_cntl1 = uData;
8308 + // Setup PCI I/O Window range. Give 64K to PCI I/O
8309 + mpi->l2piorange = ~(BCM_PCI_IO_SIZE_64KB-1);
8310 + // UBUS to PCI I/O base address
8311 + mpi->l2piobase = BCM_PCI_IO_BASE & BCM_PCI_ADDR_MASK;
8312 + // UBUS to PCI I/O Window remap
8313 + mpi->l2pioremap = (BCM_PCI_IO_BASE | MEM_WINDOW_EN);
8315 + // enable PCI related GPIO pins and data swap between system and PCI bus
8316 + mpi->locbuscntrl = (EN_PCI_GPIO | DIR_U2P_NOSWAP);
8318 + /* Enable 6348 BusMaster and Memory access mode */
8319 + data = mpi_GetLocalPciConfigReg(PCI_COMMAND);
8320 + data |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
8321 + mpi_SetLocalPciConfigReg(PCI_COMMAND, data);
8323 + /* Configure two 16 MByte PCI to System memory regions. */
8324 + /* These memory regions are used when PCI device is a bus master */
8325 + /* Accesses to the SDRAM from PCI bus will be "byte swapped" for this region */
8326 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_3, BCM_HOST_MEM_SPACE1);
8327 + mpi->sp0remap = 0x0;
8329 + /* Accesses to the SDRAM from PCI bus will not be "byte swapped" for this region */
8330 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_4, BCM_HOST_MEM_SPACE2);
8331 + mpi->sp1remap = 0x0;
8332 + mpi->pcimodesel |= (PCI_BAR2_NOSWAP | 0x40);
8334 + if ((chipid == 0x6348) && (chiprev == 0xb0)) {
8335 + mpi->sp0range = ~(sdramsize-1);
8336 + mpi->sp1range = ~(sdramsize-1);
8339 + * Change 6348 PCI Cfg Reg. offset 0x40 to PCI memory read retry count infinity
8340 + * by set 0 in bit 8~15. This resolve read Bcm4306 srom return 0xffff in
8343 + data = mpi_GetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER);
8344 + data &= ~BRCM_PCI_CONFIG_TIMER_RETRY_MASK;
8345 + data |= 0x00000080;
8346 + mpi_SetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER, data);
8348 + /* enable pci interrupt */
8349 + mpi->locintstat |= (EXT_PCI_INT << 16);
8351 + mpi_DetectPcCard();
8353 + ioport_resource.start = BCM_PCI_IO_BASE;
8354 + ioport_resource.end = BCM_PCI_IO_BASE + BCM_PCI_IO_SIZE_64KB;
8356 +#if defined(CONFIG_USB)
8357 + PERF->blkEnables |= USBH_CLK_EN;
8359 + *USBH_NON_OHCI = NON_OHCI_BYTE_SWAP;
8366 +static int __init brcm63xx_setup(void)
8368 + extern int panic_timeout;
8370 + _machine_restart = brcm_machine_restart;
8371 + _machine_halt = brcm_machine_halt;
8372 + pm_power_off = brcm_machine_halt;
8374 + board_timer_setup = brcm_timer_setup;
8376 + panic_timeout = 5;
8378 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8379 + /* mpi initialization */
8385 +void plat_setup(void)
8390 +/***************************************************************************
8391 + * C++ New and delete operator functions
8392 + ***************************************************************************/
8394 +/* void *operator new(unsigned int sz) */
8395 +void *_Znwj(unsigned int sz)
8397 + return( kmalloc(sz, GFP_KERNEL) );
8400 +/* void *operator new[](unsigned int sz)*/
8401 +void *_Znaj(unsigned int sz)
8403 + return( kmalloc(sz, GFP_KERNEL) );
8406 +/* placement new operator */
8407 +/* void *operator new (unsigned int size, void *ptr) */
8408 +void *ZnwjPv(unsigned int size, void *ptr)
8413 +/* void operator delete(void *m) */
8414 +void _ZdlPv(void *m)
8419 +/* void operator delete[](void *m) */
8420 +void _ZdaPv(void *m)
8425 +EXPORT_SYMBOL(_Znwj);
8426 +EXPORT_SYMBOL(_Znaj);
8427 +EXPORT_SYMBOL(ZnwjPv);
8428 +EXPORT_SYMBOL(_ZdlPv);
8429 +EXPORT_SYMBOL(_ZdaPv);
8431 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h
8432 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 1970-01-01 01:00:00.000000000 +0100
8433 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 2006-07-07 22:15:18.000000000 +0200
8435 +#define ADSL_SDRAM_IMAGE_SIZE (384*1024)
8437 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/time.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c
8438 --- linux-2.6.16.7/arch/mips/brcm-boards/bcm963xx/time.c 1970-01-01 01:00:00.000000000 +0100
8439 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c 2006-07-07 22:15:18.000000000 +0200
8443 + Copyright 2004 Broadcom Corp. All Rights Reserved.
8445 + This program is free software; you can distribute it and/or modify it
8446 + under the terms of the GNU General Public License (Version 2) as
8447 + published by the Free Software Foundation.
8449 + This program is distributed in the hope it will be useful, but WITHOUT
8450 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8451 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8454 + You should have received a copy of the GNU General Public License along
8455 + with this program; if not, write to the Free Software Foundation, Inc.,
8456 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8460 + * Setup time for Broadcom 963xx MIPS boards
8463 +#include <linux/config.h>
8464 +#include <linux/init.h>
8465 +#include <linux/kernel_stat.h>
8466 +#include <linux/sched.h>
8467 +#include <linux/spinlock.h>
8468 +#include <linux/interrupt.h>
8469 +#include <linux/module.h>
8470 +#include <linux/time.h>
8471 +#include <linux/timex.h>
8473 +#include <asm/mipsregs.h>
8474 +#include <asm/ptrace.h>
8475 +#include <asm/div64.h>
8476 +#include <asm/time.h>
8478 +#include <bcm_map_part.h>
8479 +#include <bcm_intr.h>
8481 +unsigned long r4k_interval; /* Amount to increment compare reg each time */
8482 +static unsigned long r4k_cur; /* What counter should be at next timer irq */
8484 +/* Cycle counter value at the previous timer interrupt.. */
8485 +static unsigned int timerhi = 0, timerlo = 0;
8487 +extern volatile unsigned long wall_jiffies;
8489 +/* Optional board-specific timer routine */
8490 +void (*board_timer_interrupt)(int irq, void *dev_id, struct pt_regs * regs);
8492 +static inline void ack_r4ktimer(unsigned long newval)
8494 + write_c0_compare(newval);
8498 + * There are a lot of conceptually broken versions of the MIPS timer interrupt
8499 + * handler floating around. This one is rather different, but the algorithm
8500 + * is provably more robust.
8502 +static irqreturn_t brcm_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
8504 + unsigned int count;
8506 + if (r4k_interval == 0)
8512 + if (board_timer_interrupt)
8513 + board_timer_interrupt(irq, dev_id, regs);
8515 + r4k_cur += r4k_interval;
8516 + ack_r4ktimer(r4k_cur);
8518 + } while (((count = (unsigned long)read_c0_count())
8519 + - r4k_cur) < 0x7fffffff);
8523 + * If jiffies has overflowed in this timer_interrupt we must
8524 + * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
8525 + * quotient calc still valid. -arca
8527 + timerhi = timerlo = 0;
8530 + * The cycle counter is only 32 bit which is good for about
8531 + * a minute at current count rates of upto 150MHz or so.
8533 + timerhi += (count < timerlo); /* Wrap around */
8537 + return IRQ_HANDLED;
8544 +static struct irqaction brcm_timer_action = {
8545 + .handler = brcm_timer_interrupt,
8546 + .flags = SA_INTERRUPT,
8547 + .mask = CPU_MASK_NONE,
8550 + .dev_id = brcm_timer_interrupt,
8554 +void __init brcm_timer_setup(struct irqaction *irq)
8556 + r4k_cur = (read_c0_count() + r4k_interval);
8557 + write_c0_compare(r4k_cur);
8559 + /* we are using the cpu counter for timer interrupts */
8560 + irq->handler = no_action; /* we use our own handler */
8561 + setup_irq(MIPS_TIMER_INT, &brcm_timer_action);
8562 + set_c0_status(IE_IRQ5);
8566 +/* This is for machines which generate the exact clock. */
8567 +#define USECS_PER_JIFFY (1000000/HZ)
8568 +#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
8570 +static void call_do_div64_32( unsigned long *res, unsigned int high,
8571 + unsigned int low, unsigned long base )
8573 + do_div64_32(*res, high, low, base);
8577 + * FIXME: Does playing with the RP bit in c0_status interfere with this code?
8579 +static unsigned long do_fast_gettimeoffset(void)
8582 + unsigned long res, tmp;
8584 + /* Last jiffy when do_fast_gettimeoffset() was called. */
8585 + static unsigned long last_jiffies=0;
8586 + unsigned long quotient;
8589 + * Cached "1/(clocks per usec)*2^32" value.
8590 + * It has to be recalculated once each jiffy.
8592 + static unsigned long cached_quotient=0;
8596 + quotient = cached_quotient;
8598 + if (tmp && last_jiffies != tmp) {
8599 + last_jiffies = tmp;
8600 +#ifdef CONFIG_CPU_MIPS32
8601 + if (last_jiffies != 0) {
8604 + /* gcc 3.0.1 gets an internal compiler error if there are two
8605 + * do_div64_32 inline macros. To work around this problem,
8606 + * do_div64_32 is called as a function.
8608 + call_do_div64_32(&r0, timerhi, timerlo, tmp);
8609 + call_do_div64_32("ient, USECS_PER_JIFFY,
8610 + USECS_PER_JIFFY_FRAC, r0);
8612 + cached_quotient = quotient;
8616 + __asm__(".set\tnoreorder\n\t"
8620 + "dsll32\t$1,%1,0\n\t"
8621 + "or\t$1,$1,%0\n\t"
8622 + "ddivu\t$0,$1,%3\n\t"
8624 + "dsll32\t%0,%4,0\n\t"
8626 + "ddivu\t$0,%0,$1\n\t"
8635 + "r" (USECS_PER_JIFFY)
8637 + cached_quotient = quotient;
8641 + /* Get last timer tick in absolute kernel time */
8642 + count = read_c0_count();
8644 + /* .. relative to previous jiffy (32 bits is enough) */
8647 + __asm__("multu\t%1,%2\n\t"
8654 + * Due to possible jiffies inconsistencies, we need to check
8655 + * the result so that we'll get a timer that is monotonic.
8657 + if (res >= USECS_PER_JIFFY)
8658 + res = USECS_PER_JIFFY-1;
8663 +void do_gettimeofday(struct timeval *tv)
8665 + unsigned int flags;
8667 + read_lock_irqsave (&xtime_lock, flags);
8668 + tv->tv_sec = xtime.tv_sec;
8669 + tv->tv_usec = xtime.tv_nsec/1000;
8670 + tv->tv_usec += do_fast_gettimeoffset();
8673 + * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
8674 + * is nonzero if the timer bottom half hasnt executed yet.
8676 + if (jiffies - wall_jiffies)
8677 + tv->tv_usec += USECS_PER_JIFFY;
8679 + read_unlock_irqrestore (&xtime_lock, flags);
8681 + if (tv->tv_usec >= 1000000) {
8682 + tv->tv_usec -= 1000000;
8687 +EXPORT_SYMBOL(do_gettimeofday);
8689 +int do_settimeofday(struct timespec *tv)
8691 + write_lock_irq (&xtime_lock);
8693 + /* This is revolting. We need to set the xtime.tv_usec correctly.
8694 + * However, the value in this location is is value at the last tick.
8695 + * Discover what correction gettimeofday would have done, and then
8698 + tv->tv_nsec -= do_fast_gettimeoffset()*NSEC_PER_USEC;
8700 + if (tv->tv_nsec < 0) {
8701 + tv->tv_nsec += 1000000*NSEC_PER_USEC;
8705 + xtime.tv_sec = tv->tv_sec;
8706 + xtime.tv_nsec = tv->tv_nsec;
8707 + time_adjust = 0; /* stop active adjtime() */
8708 + time_status |= STA_UNSYNC;
8709 + time_maxerror = NTP_PHASE_LIMIT;
8710 + time_esterror = NTP_PHASE_LIMIT;
8712 + write_unlock_irq (&xtime_lock);
8715 +EXPORT_SYMBOL(do_settimeofday);
8718 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/generic/dbg_io.c linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c
8719 --- linux-2.6.16.7/arch/mips/brcm-boards/generic/dbg_io.c 1970-01-01 01:00:00.000000000 +0100
8720 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c 2006-07-07 22:15:18.000000000 +0200
8724 + Copyright 2003 Broadcom Corp. All Rights Reserved.
8726 + This program is free software; you can distribute it and/or modify it
8727 + under the terms of the GNU General Public License (Version 2) as
8728 + published by the Free Software Foundation.
8730 + This program is distributed in the hope it will be useful, but WITHOUT
8731 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8732 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8735 + You should have received a copy of the GNU General Public License along
8736 + with this program; if not, write to the Free Software Foundation, Inc.,
8737 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8741 +#include <linux/config.h>
8742 +#include <linux/tty.h>
8743 +#include <linux/major.h>
8744 +#include <linux/init.h>
8745 +#include <linux/console.h>
8746 +#include <linux/fs.h>
8747 +#include <linux/interrupt.h>
8748 +#include <linux/kernel.h>
8749 +#include <linux/types.h>
8750 +#include <linux/sched.h>
8752 +#include <bcm_map_part.h>
8754 +#undef PRNT /* define for debug printing */
8756 +#define UART16550_BAUD_2400 2400
8757 +#define UART16550_BAUD_4800 4800
8758 +#define UART16550_BAUD_9600 9600
8759 +#define UART16550_BAUD_19200 19200
8760 +#define UART16550_BAUD_38400 38400
8761 +#define UART16550_BAUD_57600 57600
8762 +#define UART16550_BAUD_115200 115200
8764 +#define UART16550_PARITY_NONE 0
8765 +#define UART16550_PARITY_ODD 0x08
8766 +#define UART16550_PARITY_EVEN 0x18
8767 +#define UART16550_PARITY_MARK 0x28
8768 +#define UART16550_PARITY_SPACE 0x38
8770 +#define UART16550_DATA_5BIT 0x0
8771 +#define UART16550_DATA_6BIT 0x1
8772 +#define UART16550_DATA_7BIT 0x2
8773 +#define UART16550_DATA_8BIT 0x3
8775 +#define UART16550_STOP_1BIT 0x0
8776 +#define UART16550_STOP_2BIT 0x4
8778 +volatile Uart * stUart = UART_BASE;
8780 +#define WRITE16(addr, value) ((*(volatile UINT16 *)((ULONG)&addr)) = value)
8782 +/* Low level UART routines from promcon.c */
8783 +extern void prom_putc(char c);
8784 +extern char prom_getc(void);
8785 +extern int prom_getc_nowait(void);
8786 +extern int prom_testc(void);
8788 +extern void set_debug_traps(void);
8789 +extern void breakpoint(void);
8790 +extern void enable_brcm_irq(unsigned int);
8791 +extern void set_async_breakpoint(unsigned int epc);
8793 +#ifdef CONFIG_GDB_CONSOLE
8794 +extern void register_gdb_console(void);
8797 +int gdb_initialized = 0;
8799 +#define GDB_BUF_SIZE 512 /* power of 2, please */
8801 +static char gdb_buf[GDB_BUF_SIZE] ;
8802 +static int gdb_buf_in_inx ;
8803 +static atomic_t gdb_buf_in_cnt ;
8804 +static int gdb_buf_out_inx ;
8806 +void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
8808 + /* Do nothing, assume boot loader has already set up serial port */
8809 + printk("debugInit called\n");
8813 + * Get a char if available, return -1 if nothing available.
8814 + * Empty the receive buffer first, then look at the interface hardware.
8816 +static int read_char(void)
8818 + if (atomic_read(&gdb_buf_in_cnt) != 0) /* intr routine has q'd chars */
8822 + chr = gdb_buf[gdb_buf_out_inx++] ;
8823 + gdb_buf_out_inx &= (GDB_BUF_SIZE - 1) ;
8824 + atomic_dec(&gdb_buf_in_cnt) ;
8827 + return(prom_getc_nowait()) ; /* read from hardware */
8831 + * This is the receiver interrupt routine for the GDB stub.
8832 + * It will receive a limited number of characters of input
8833 + * from the gdb host machine and save them up in a buffer.
8835 + * When the gdb stub routine getDebugChar() is called it
8836 + * draws characters out of the buffer until it is empty and
8837 + * then reads directly from the serial port.
8839 + * We do not attempt to write chars from the interrupt routine
8840 + * since the stubs do all of that via putDebugChar() which
8841 + * writes one byte after waiting for the interface to become
8844 + * The debug stubs like to run with interrupts disabled since,
8845 + * after all, they run as a consequence of a breakpoint in
8848 + * Perhaps someone who knows more about the tty driver than I
8849 + * care to learn can make this work for any low level serial
8852 +static void gdb_interrupt(int irq, void *dev_id, struct pt_regs * regs)
8858 + chr = prom_getc_nowait() ;
8859 + more = prom_testc();
8860 + if (chr < 0) continue ;
8862 + /* If we receive a Ctrl-C then this is GDB trying to break in */
8865 + /* Replace current instruction with breakpoint */
8866 + set_async_breakpoint(regs->cp0_epc);
8871 + printk("gdb_interrupt: chr=%02x '%c', more = %x\n",
8872 + chr, chr > ' ' && chr < 0x7F ? chr : ' ', more) ;
8875 + if (atomic_read(&gdb_buf_in_cnt) >= GDB_BUF_SIZE)
8876 + { /* buffer overflow, clear it */
8877 + gdb_buf_in_inx = 0 ;
8878 + atomic_set(&gdb_buf_in_cnt, 0) ;
8879 + gdb_buf_out_inx = 0 ;
8883 + gdb_buf[gdb_buf_in_inx++] = chr ;
8884 + gdb_buf_in_inx &= (GDB_BUF_SIZE - 1) ;
8885 + atomic_inc(&gdb_buf_in_cnt) ;
8889 +} /* gdb_interrupt */
8894 + * This is a GDB stub routine. It waits for a character from the
8895 + * serial interface and then returns it. If there is no serial
8896 + * interface connection then it returns a bogus value which will
8897 + * almost certainly cause the system to hang.
8899 +int getDebugChar(void)
8901 + volatile int chr ;
8904 + printk("getDebugChar: ") ;
8907 + while ( (chr = read_char()) < 0 ) ;
8910 + printk("%c\n", chr > ' ' && chr < 0x7F ? chr : ' ') ;
8914 +} /* getDebugChar */
8919 + * This is a GDB stub routine. It waits until the interface is ready
8920 + * to transmit a char and then sends it. If there is no serial
8921 + * interface connection then it simply returns to its caller, having
8922 + * pretended to send the char.
8924 +int putDebugChar(unsigned char chr)
8927 + printk("putDebugChar: chr=%02x '%c'\n", chr,
8928 + chr > ' ' && chr < 0x7F ? chr : ' ') ;
8931 + prom_putc(chr) ; /* this routine will wait */
8934 +} /* putDebugChar */
8936 +/* Just a NULL routine for testing. */
8937 +void gdb_null(void)
8941 +void rs_kgdb_hook(int tty_no)
8943 + printk("rs_kgdb_hook: tty %d\n", tty_no);
8945 + /* Call GDB routine to setup the exception vectors for the debugger */
8946 + set_debug_traps();
8948 + printk("Breaking into debugger...\n");
8951 + printk("Connected.\n");
8953 + gdb_initialized = 1;
8955 +#ifdef CONFIG_GDB_CONSOLE
8956 + register_gdb_console();
8960 +void kgdb_hook_irq()
8965 + printk("GDB: Hooking UART interrupt\n");
8967 + retval = request_irq(INTERRUPT_ID_UART,
8970 + "GDB-stub", NULL);
8973 + printk("gdb_hook: request_irq(irq=%d) failed: %d\n", INTERRUPT_ID_UART, retval);
8975 + // Enable UART config Rx not empty IRQ
8976 + uMask = READ16(stUart->intMask) ;
8977 + // printk("intMask: 0x%x\n", uMask);
8978 + WRITE16(stUart->intMask, uMask | RXFIFONE);
8982 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/generic/int-handler.S linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S
8983 --- linux-2.6.16.7/arch/mips/brcm-boards/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
8984 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S 2006-07-07 22:15:18.000000000 +0200
8988 + Copyright 2002 Broadcom Corp. All Rights Reserved.
8990 + This program is free software; you can distribute it and/or modify it
8991 + under the terms of the GNU General Public License (Version 2) as
8992 + published by the Free Software Foundation.
8994 + This program is distributed in the hope it will be useful, but WITHOUT
8995 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8996 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8999 + You should have received a copy of the GNU General Public License along
9000 + with this program; if not, write to the Free Software Foundation, Inc.,
9001 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
9005 + * Generic interrupt handler for Broadcom MIPS boards
9008 +#include <linux/config.h>
9010 +#include <asm/asm.h>
9011 +#include <asm/mipsregs.h>
9012 +#include <asm/regdef.h>
9013 +#include <asm/stackframe.h>
9018 + * 0 Software (ignored)
9019 + * 1 Software (ignored)
9020 + * 2 Combined hardware interrupt (hw0)
9032 + NESTED(brcmIRQ, PT_SIZE, sp)
9038 + jal brcm_irq_dispatch
9045 diff -urN linux-2.6.16.7/arch/mips/brcm-boards/generic/Makefile linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/Makefile
9046 --- linux-2.6.16.7/arch/mips/brcm-boards/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
9047 +++ linux-2.6.16.7-brcm63xx/arch/mips/brcm-boards/generic/Makefile 2006-07-07 22:15:18.000000000 +0200
9050 +# Makefile for generic Broadcom MIPS boards
9052 +# Copyright (C) 2001 Broadcom Corporation
9054 +obj-y := int-handler.o
9056 +ifdef CONFIG_REMOTE_DEBUG