1 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c
2 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_flash.c 2006-08-03 16:36:58.000000000 +0200
7 + Copyright 2002 Broadcom Corp. All Rights Reserved.
9 + This program is free software; you can distribute it and/or modify it
10 + under the terms of the GNU General Public License (Version 2) as
11 + published by the Free Software Foundation.
13 + This program is distributed in the hope it will be useful, but WITHOUT
14 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 + You should have received a copy of the GNU General Public License along
19 + with this program; if not, write to the Free Software Foundation, Inc.,
20 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 + ***************************************************************************
25 + * File Name : bcm63xx_flash.c
27 + * Description: This file contains the flash device driver APIs for bcm63xx board.
29 + * Created on : 8/10/2002 seanl: use cfiflash.c, cfliflash.h (AMD specific)
31 + ***************************************************************************/
35 +#include <linux/fs.h>
36 +#include <linux/capability.h>
37 +#include <linux/slab.h>
38 +#include <linux/errno.h>
39 +#include <linux/module.h>
40 +#include <asm/uaccess.h>
42 +#include <bcm_map_part.h>
44 +#define BCMTAG_EXE_USE
46 +#include "cfiflash.h"
47 +#include "boardparms.h"
49 +//#define DEBUG_FLASH
51 +static FLASH_ADDR_INFO fInfo;
52 +static int flashInitialized = 0;
54 +void *retriedKmalloc(size_t size)
59 + // try 1000 times before quit
60 + while (((pBuf = kmalloc(size, GFP_KERNEL)) == NULL) && (tryCount++ < 1000))
62 + current->state = TASK_INTERRUPTIBLE;
63 + schedule_timeout(HZ/10);
65 + if (tryCount >= 1000)
68 + memset(pBuf, 0, size);
73 +void retriedKfree(void *pBuf)
78 +/***************************************************************************
79 +// Function Name: getCrc32
80 +// Description : caculate the CRC 32 of the given data.
81 +// Parameters : pdata - array of data.
82 +// size - number of input data bytes.
83 +// crc - either CRC32_INIT_VALUE or previous return value.
85 +****************************************************************************/
86 +UINT32 getCrc32(byte *pdata, UINT32 size, UINT32 crc)
89 + crc = (crc >> 8) ^ Crc32_table[(crc ^ *pdata++) & 0xff];
94 +// get the nvram start addr
96 +unsigned long get_nvram_start_addr(void)
98 + return ((unsigned long)
99 + (flash_get_memptr(fInfo.flash_nvram_start_blk) + fInfo.flash_nvram_blk_offset));
102 +// get the scratch_pad start addr
104 +unsigned long get_scratch_pad_start_addr(void)
106 + return ((unsigned long)
107 + (flash_get_memptr(fInfo.flash_scratch_pad_start_blk) + fInfo.flash_scratch_pad_blk_offset));
112 +/* *********************************************************************
113 + * kerSysImageTagGet()
114 + * Get the image tag
115 + * Input parameters:
118 + * point to tag -- Found
120 + ********************************************************************* */
121 +PFILE_TAG kerSysImageTagGet(void)
124 + int totalBlks = flash_get_numsectors();
126 + unsigned char *sectAddr;
129 +#if defined(DEBUG_FLASH)
130 + printk("totalblks in tagGet=%d\n", totalBlks);
133 + // start from 2nd blk, assume 1st one is always CFE
134 + for (i = 1; i < totalBlks; i++)
136 + sectAddr = flash_get_memptr((byte) i);
137 + crc = CRC32_INIT_VALUE;
138 + crc = getCrc32(sectAddr, (UINT32)TAG_LEN-TOKEN_LEN, crc);
139 + pTag = (PFILE_TAG) sectAddr;
141 +#if defined(DEBUG_FLASH)
142 + printk("Check Tag crc on blk [%d]\n", i);
145 + if (crc == (UINT32)(*(UINT32*)(pTag->tagValidationToken)))
149 + return (PFILE_TAG) NULL;
152 +// Initialize the flash and fill out the fInfo structure
153 +void kerSysFlashInit( void )
159 + int usedBlkSize = 0;
160 + NVRAM_DATA nvramData;
161 + UINT32 crc = CRC32_INIT_VALUE, savedCrc;
162 + PFILE_TAG pTag = NULL;
163 + unsigned long kernelEndAddr = 0;
164 + unsigned long spAddr = 0;
166 + if (flashInitialized)
169 + flashInitialized = 1;
172 + totalBlks = flash_get_numsectors();
173 + totalSize = flash_get_total_size();
175 + printk("Total Flash size: %dK with %d sectors\n", totalSize/1024, totalBlks);
177 + /* nvram is always at the end of flash */
178 + fInfo.flash_nvram_length = FLASH45_LENGTH_NVRAM;
179 + fInfo.flash_nvram_start_blk = 0; /* always the first block */
180 + fInfo.flash_nvram_number_blk = 1; /*always fits in the first block */
181 + fInfo.flash_nvram_blk_offset = NVRAM_DATA_OFFSET;
184 + memcpy((char *)&nvramData, (char *)get_nvram_start_addr(), sizeof(NVRAM_DATA));
185 + savedCrc = nvramData.ulCheckSum;
186 + nvramData.ulCheckSum = 0;
187 + crc = getCrc32((char *)&nvramData, (UINT32) sizeof(NVRAM_DATA), crc);
189 + BpSetBoardId( nvramData.szBoardId );
191 + fInfo.flash_persistent_length = NVRAM_PSI_DEFAULT;
192 + if (savedCrc != crc)
194 + printk("***Board is not initialized****: Using the default PSI size: %d\n",
195 + fInfo.flash_persistent_length);
199 + unsigned long ulPsiSize;
200 + if( BpGetPsiSize( &ulPsiSize ) == BP_SUCCESS )
201 + fInfo.flash_persistent_length = ulPsiSize;
204 + printk("***Board id is not set****: Using the default PSI size: %d\n",
205 + fInfo.flash_persistent_length);
209 + fInfo.flash_persistent_length *= ONEK;
210 + startAddr = totalSize - fInfo.flash_persistent_length;
211 + fInfo.flash_persistent_start_blk = flash_get_blk(startAddr+FLASH_BASE_ADDR_REG);
212 + fInfo.flash_persistent_number_blk = totalBlks - fInfo.flash_persistent_start_blk;
213 + // save abs SP address (Scratch Pad). it is before PSI
214 + spAddr = startAddr - SP_MAX_LEN ;
215 + // find out the offset in the start_blk
217 + for (i = fInfo.flash_persistent_start_blk;
218 + i < (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk); i++)
220 + usedBlkSize += flash_get_sector_size((byte) i);
222 + fInfo.flash_persistent_blk_offset = usedBlkSize - fInfo.flash_persistent_length;
224 + // get the info for sp
225 + if (!(pTag = kerSysImageTagGet()))
227 + printk("Failed to read image tag from flash\n");
230 + kernelEndAddr = (unsigned long) simple_strtoul(pTag->kernelAddress, NULL, 10) + \
231 + (unsigned long) simple_strtoul(pTag->kernelLen, NULL, 10);
233 + // make suer sp does not share kernel block
234 + fInfo.flash_scratch_pad_start_blk = flash_get_blk(spAddr+FLASH_BASE_ADDR_REG);
235 + if (fInfo.flash_scratch_pad_start_blk != flash_get_blk(kernelEndAddr))
237 + fInfo.flash_scratch_pad_length = SP_MAX_LEN;
238 + if (fInfo.flash_persistent_start_blk == fInfo.flash_scratch_pad_start_blk) // share blk
240 +#if 1 /* do not used scratch pad unless it's in its own sector */
241 + printk("Scratch pad is not used for this flash part.\n");
242 + fInfo.flash_scratch_pad_length = 0; // no sp
243 +#else /* allow scratch pad to share a sector with another section such as PSI */
244 + fInfo.flash_scratch_pad_number_blk = 1;
245 + fInfo.flash_scratch_pad_blk_offset = fInfo.flash_persistent_blk_offset - fInfo.flash_scratch_pad_length;
248 + else // on different blk
250 + fInfo.flash_scratch_pad_number_blk = fInfo.flash_persistent_start_blk\
251 + - fInfo.flash_scratch_pad_start_blk;
252 + // find out the offset in the start_blk
254 + for (i = fInfo.flash_scratch_pad_start_blk;
255 + i < (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk); i++)
256 + usedBlkSize += flash_get_sector_size((byte) i);
257 + fInfo.flash_scratch_pad_blk_offset = usedBlkSize - fInfo.flash_scratch_pad_length;
262 + printk("No flash for scratch pad!\n");
263 + fInfo.flash_scratch_pad_length = 0; // no sp
266 +#if defined(DEBUG_FLASH)
267 + printk("fInfo.flash_scratch_pad_start_blk = %d\n", fInfo.flash_scratch_pad_start_blk);
268 + printk("fInfo.flash_scratch_pad_number_blk = %d\n", fInfo.flash_scratch_pad_number_blk);
269 + printk("fInfo.flash_scratch_pad_length = 0x%x\n", fInfo.flash_scratch_pad_length);
270 + printk("fInfo.flash_scratch_pad_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_scratch_pad_blk_offset);
272 + printk("fInfo.flash_nvram_start_blk = %d\n", fInfo.flash_nvram_start_blk);
273 + printk("fInfo.flash_nvram_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_nvram_blk_offset);
274 + printk("fInfo.flash_nvram_number_blk = %d\n", fInfo.flash_nvram_number_blk);
276 + printk("psi startAddr = %x\n", startAddr+FLASH_BASE_ADDR_REG);
277 + printk("fInfo.flash_persistent_start_blk = %d\n", fInfo.flash_persistent_start_blk);
278 + printk("fInfo.flash_persistent_blk_offset = 0x%x\n", (unsigned int)fInfo.flash_persistent_blk_offset);
279 + printk("fInfo.flash_persistent_number_blk = %d\n", fInfo.flash_persistent_number_blk);
286 +/***********************************************************************
287 + * Function Name: kerSysFlashAddrInfoGet
288 + * Description : Fills in a structure with information about the NVRAM
289 + * and persistent storage sections of flash memory.
290 + * Fro physmap.c to mount the fs vol.
292 + ***********************************************************************/
293 +void kerSysFlashAddrInfoGet(PFLASH_ADDR_INFO pflash_addr_info)
295 + pflash_addr_info->flash_nvram_blk_offset = fInfo.flash_nvram_blk_offset;
296 + pflash_addr_info->flash_nvram_length = fInfo.flash_nvram_length;
297 + pflash_addr_info->flash_nvram_number_blk = fInfo.flash_nvram_number_blk;
298 + pflash_addr_info->flash_nvram_start_blk = fInfo.flash_nvram_start_blk;
299 + pflash_addr_info->flash_persistent_blk_offset = fInfo.flash_persistent_blk_offset;
300 + pflash_addr_info->flash_persistent_length = fInfo.flash_persistent_length;
301 + pflash_addr_info->flash_persistent_number_blk = fInfo.flash_persistent_number_blk;
302 + pflash_addr_info->flash_persistent_start_blk = fInfo.flash_persistent_start_blk;
306 +// get shared blks into *** pTempBuf *** which has to be released bye the caller!
307 +// return: if pTempBuf != NULL, poits to the data with the dataSize of the buffer
310 +static char *getSharedBlks(int start_blk, int end_blk)
313 + int usedBlkSize = 0;
315 + char *pTempBuf = NULL;
318 + for (i = start_blk; i < end_blk; i++)
319 + usedBlkSize += flash_get_sector_size((byte) i);
321 +#if defined(DEBUG_FLASH)
322 + printk("usedBlkSize = %d\n", usedBlkSize);
325 + if ((pTempBuf = (char *) retriedKmalloc(usedBlkSize)) == NULL)
327 + printk("failed to allocate memory with size: %d\n", usedBlkSize);
332 + for (i = start_blk; i < end_blk; i++)
334 + sect_size = flash_get_sector_size((byte) i);
336 +#if defined(DEBUG_FLASH)
337 + printk("i = %d, sect_size = %d, end_blk = %d\n", i, sect_size, end_blk);
339 + flash_read_buf((byte)i, 0, pBuf, sect_size);
348 +// Set the pTempBuf to flash from start_blk to end_blk
352 +static int setSharedBlks(int start_blk, int end_blk, char *pTempBuf)
357 + char *pBuf = pTempBuf;
359 + for (i = start_blk; i < end_blk; i++)
361 + sect_size = flash_get_sector_size((byte) i);
362 + flash_sector_erase_int(i);
363 + if (flash_write_buf(i, 0, pBuf, sect_size) != sect_size)
365 + printk("Error writing flash sector %d.", i);
377 +/*******************************************************************************
379 + *******************************************************************************/
385 +int kerSysNvRamGet(char *string, int strLen, int offset)
389 + if (!flashInitialized)
392 + if (strLen > FLASH45_LENGTH_NVRAM)
395 + if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
396 + (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
399 + // get string off the memory buffer
400 + memcpy(string, (pBuf + fInfo.flash_nvram_blk_offset + offset), strLen);
402 + retriedKfree(pBuf);
412 +int kerSysNvRamSet(char *string, int strLen, int offset)
417 + if (strLen > FLASH45_LENGTH_NVRAM)
420 + if ((pBuf = getSharedBlks(fInfo.flash_nvram_start_blk,
421 + (fInfo.flash_nvram_start_blk + fInfo.flash_nvram_number_blk))) == NULL)
424 + // set string to the memory buffer
425 + memcpy((pBuf + fInfo.flash_nvram_blk_offset + offset), string, strLen);
427 + if (setSharedBlks(fInfo.flash_nvram_start_blk,
428 + (fInfo.flash_nvram_number_blk + fInfo.flash_nvram_start_blk), pBuf) != 0)
431 + retriedKfree(pBuf);
437 +/***********************************************************************
438 + * Function Name: kerSysEraseNvRam
439 + * Description : Erase the NVRAM storage section of flash memory.
440 + * Returns : 1 -- ok, 0 -- fail
441 + ***********************************************************************/
442 +int kerSysEraseNvRam(void)
445 + char *tempStorage = retriedKmalloc(FLASH45_LENGTH_NVRAM);
447 + // just write the whole buf with '0xff' to the flash
452 + memset(tempStorage, 0xff, FLASH45_LENGTH_NVRAM);
453 + if (kerSysNvRamSet(tempStorage, FLASH45_LENGTH_NVRAM, 0) != 0)
455 + retriedKfree(tempStorage);
462 +/*******************************************************************************
464 + *******************************************************************************/
469 +int kerSysPersistentGet(char *string, int strLen, int offset)
473 + if (strLen > fInfo.flash_persistent_length)
476 + if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
477 + (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
480 + // get string off the memory buffer
481 + memcpy(string, (pBuf + fInfo.flash_persistent_blk_offset + offset), strLen);
483 + retriedKfree(pBuf);
493 +int kerSysPersistentSet(char *string, int strLen, int offset)
498 + if (strLen > fInfo.flash_persistent_length)
501 + if ((pBuf = getSharedBlks(fInfo.flash_persistent_start_blk,
502 + (fInfo.flash_persistent_start_blk + fInfo.flash_persistent_number_blk))) == NULL)
505 + // set string to the memory buffer
506 + memcpy((pBuf + fInfo.flash_persistent_blk_offset + offset), string, strLen);
508 + if (setSharedBlks(fInfo.flash_persistent_start_blk,
509 + (fInfo.flash_persistent_number_blk + fInfo.flash_persistent_start_blk), pBuf) != 0)
512 + retriedKfree(pBuf);
521 +// !0 - the sector number fail to be flashed (should not be 0)
522 +int kerSysBcmImageSet( int flash_start_addr, char *string, int size)
528 + char *pTempBuf = NULL;
529 + int whole_image = 0;
531 + blk_start = flash_get_blk(flash_start_addr);
532 + if( blk_start < 0 )
535 + if (flash_start_addr == FLASH_BASE && size > FLASH45_LENGTH_BOOT_ROM)
538 + /* write image to flash memory */
541 + sect_size = flash_get_sector_size(blk_start);
542 +// NOTE: for memory problem in multiple PVC configuration, temporary get rid of kmalloc this 64K for now.
543 +// if ((pTempBuf = (char *)retriedKmalloc(sect_size)) == NULL)
545 +// printk("Failed to allocate memory with size: %d. Reset the router...\n", sect_size);
546 +// kerSysMipsSoftReset(); // reset the board right away.
548 + // for whole image, no check on psi
549 + if (!whole_image && blk_start == fInfo.flash_persistent_start_blk) // share the blk with psi
551 + if (size > (sect_size - fInfo.flash_persistent_length))
553 + printk("Image is too big\n");
554 + break; // image is too big. Can not overwrite to nvram
556 + if ((pTempBuf = (char *)retriedKmalloc(sect_size)) == NULL)
558 + printk("Failed to allocate memory with size: %d. Reset the router...\n", sect_size);
559 + kerSysMipsSoftReset(); // reset the board right away.
561 + flash_read_buf((byte)blk_start, 0, pTempBuf, sect_size);
562 + if (copy_from_user((void *)pTempBuf,(void *)string, size) != 0)
564 + flash_sector_erase_int(blk_start); // erase blk before flash
565 + if (flash_write_buf(blk_start, 0, pTempBuf, sect_size) == sect_size)
566 + size = 0; // break out and say all is ok
567 + retriedKfree(pTempBuf);
571 + flash_sector_erase_int(blk_start); // erase blk before flash
573 + if (sect_size > size)
580 + if ((i = flash_write_buf(blk_start, 0, string, sect_size)) != sect_size) {
584 + string += sect_size;
586 + } while (size > 0);
590 + // If flashing a whole image, erase to end of flash.
591 + int total_blks = flash_get_numsectors();
592 + while( blk_start < total_blks )
594 + flash_sector_erase_int(blk_start);
599 + retriedKfree(pTempBuf);
604 + sts = blk_start; // failed to flash this sector
609 +/*******************************************************************************
611 + *******************************************************************************/
612 +// get sp data. NOTE: memcpy work here -- not using copy_from/to_user
616 +int kerSysScratchPadGet(char *tokenId, char *tokBuf, int bufLen)
618 + PSP_HEADER pHead = NULL;
619 + PSP_TOKEN pToken = NULL;
621 + char *pShareBuf = NULL;
622 + char *startPtr = NULL;
623 + char *endPtr = NULL;
624 + char *spEndPtr = NULL;
627 + if (fInfo.flash_scratch_pad_length == 0)
630 + if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN)))
632 + printk("Exceed scratch pad space by %d\n", bufLen - fInfo.flash_scratch_pad_length \
633 + - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
637 + if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
638 + (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
641 + // pBuf points to SP buf
642 + pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;
644 + pHead = (PSP_HEADER) pBuf;
645 + if (memcmp(pHead->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0)
647 + printk("Scrap pad is not initialized.\n");
651 + // search up to SPUsedLen for the token
652 + startPtr = pBuf + sizeof(SP_HEADER);
653 + endPtr = pBuf + pHead->SPUsedLen;
654 + spEndPtr = pBuf + SP_MAX_LEN;
655 + while (startPtr < endPtr && startPtr < spEndPtr)
657 + pToken = (PSP_TOKEN) startPtr;
658 + if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
660 + memcpy(tokBuf, startPtr + sizeof(SP_TOKEN), bufLen);
665 + startPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
668 + retriedKfree(pShareBuf);
674 +// set sp. NOTE: memcpy work here -- not using copy_from/to_user
678 +int kerSysScratchPadSet(char *tokenId, char *tokBuf, int bufLen)
680 + PSP_TOKEN pToken = NULL;
681 + PSP_HEADER pHead = NULL;
682 + char *pShareBuf = NULL;
689 + if (fInfo.flash_scratch_pad_length == 0)
692 + if (bufLen >= (fInfo.flash_scratch_pad_length - sizeof(SP_HEADER) - sizeof(SP_TOKEN)))
694 + printk("Exceed scratch pad space by %d\n", bufLen - fInfo.flash_scratch_pad_length \
695 + - sizeof(SP_HEADER) - sizeof(SP_TOKEN));
699 + if ((pShareBuf = getSharedBlks(fInfo.flash_scratch_pad_start_blk,
700 + (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk))) == NULL)
703 + // pBuf points to SP buf
704 + pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;
705 + pHead = (PSP_HEADER) pBuf;
707 + // form header info. SPUsedLen later on...
708 + memset((char *)&SPHead, 0, sizeof(SP_HEADER));
709 + memcpy(SPHead.SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN);
710 + SPHead.SPVersion = SP_VERSION;
712 + // form token info.
713 + memset((char*)&SPToken, 0, sizeof(SP_TOKEN));
714 + strncpy(SPToken.tokenName, tokenId, TOKEN_NAME_LEN - 1);
715 + SPToken.tokenLen = bufLen;
716 + if (memcmp(pHead->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0)
718 + // new sp, so just flash the token
719 + printk("No Scrap pad found. Initialize scratch pad...\n");
720 + SPHead.SPUsedLen = sizeof(SP_HEADER) + sizeof(SP_TOKEN) + bufLen;
721 + memcpy(pBuf, (char *)&SPHead, sizeof(SP_HEADER));
722 + curPtr = pBuf + sizeof(SP_HEADER);
723 + memcpy(curPtr, (char *)&SPToken, sizeof(SP_TOKEN));
724 + curPtr += sizeof(SP_TOKEN);
725 + memcpy(curPtr, tokBuf, bufLen);
729 + // need search for the token, if exist with same size overwrite it. if sizes differ,
730 + // move over the later token data over and put the new one at the end
731 + char *endPtr = pBuf + pHead->SPUsedLen;
732 + char *spEndPtr = pBuf + SP_MAX_LEN;
733 + curPtr = pBuf + sizeof(SP_HEADER);
734 + while (curPtr < endPtr && curPtr < spEndPtr)
736 + pToken = (PSP_TOKEN) curPtr;
737 + if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
739 + if (pToken->tokenLen == bufLen) // overwirte it
741 + memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen);
744 + else // move later data over and put the new token at the end
746 + memcpy((curPtr+sizeof(SP_TOKEN)), tokBuf, bufLen); // ~~~
750 + else // not same token ~~~
754 + curPtr += sizeof(SP_TOKEN) + pToken->tokenLen;
756 + SPHead.SPUsedLen = sizeof(SP_HEADER) + sizeof(SP_TOKEN) + bufLen; // ~~~
757 + if (SPHead.SPUsedLen > SP_MAX_LEN)
759 + printk("No more Scratch pad space left! Over limit by %d bytes\n", SPHead.SPUsedLen - SP_MAX_LEN);
763 + } // else if not new sp
765 + sts = setSharedBlks(fInfo.flash_scratch_pad_start_blk,
766 + (fInfo.flash_scratch_pad_number_blk + fInfo.flash_scratch_pad_start_blk), pShareBuf);
768 + retriedKfree(pShareBuf);
775 +int kerSysFlashSizeGet(void)
777 + return flash_get_total_size();
780 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c
781 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 1970-01-01 01:00:00.000000000 +0100
782 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/bcm63xx_led.c 2006-08-03 16:36:58.000000000 +0200
786 + Copyright 2002 Broadcom Corp. All Rights Reserved.
788 + This program is free software; you can distribute it and/or modify it
789 + under the terms of the GNU General Public License (Version 2) as
790 + published by the Free Software Foundation.
792 + This program is distributed in the hope it will be useful, but WITHOUT
793 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
794 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
797 + You should have received a copy of the GNU General Public License along
798 + with this program; if not, write to the Free Software Foundation, Inc.,
799 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
802 +/***************************************************************************
803 + * File Name : bcm63xx_led.c
807 + * This file contains bcm963xx board led control API functions.
809 + * To use it, do the following
811 + * 1). define in the board.c the following led mappping (this is for 6345GW board):
812 + * const LED_MAP_PAIR cLedMapping45GW[] =
813 + * { // led name Initial state physical pin (ledMask)
814 + * {kLedUsb, kLedStateOff, GPIO_LED_PIN_7},
815 + * {kLedAdsl, kLedStateOff, GPIO_LED_PIN_8},
816 + * {kLedPPP, kLedStateOff, GPIO_LED_PIN_9}, // PPP and WanData share PIN_9
817 + * {kLedWanData, kLedStateOff, GPIO_LED_PIN_9},
818 + * {kLedWireless, kLedStateOff, GPIO_LED_PIN_10},
819 + * {kLedEnd, kLedStateOff, 0 } // NOTE: kLedEnd has to be at the end.
821 + * 2). };To initialize led API and initial state of the leds, call the following function with the mapping
822 + * pointer from the above struct
824 + * boardLedInit((PLED_MAP_PAIR) &cLedMapping45R);
826 + * 3). Sample call for kernel mode:
828 + * kerSysLedCtrl(kLedAdsl, kLedStateBlinkOnce); // kLedxxx defines in board.h
830 + * 4). Sample call for user mode
832 + * sysLedCtrl(kLedAdsl, kLedStateBlinkOnce); // kLedxxx defines in board_api.h
835 + * Created on : 10/28/2002 seanl
837 + ***************************************************************************/
840 +#include <linux/init.h>
841 +#include <linux/fs.h>
842 +#include <linux/capability.h>
843 +#include <linux/slab.h>
844 +#include <linux/errno.h>
845 +#include <linux/module.h>
846 +#include <linux/netdevice.h>
847 +#include <asm/uaccess.h>
849 +#include <bcm_map_part.h>
852 +#define k100ms (HZ / 10) // ~100 ms
853 +#define kFastBlinkCount 0 // ~100ms
854 +#define kSlowBlinkCount 5 // ~600ms
856 +#define MAX_VIRT_LEDS 12
858 +// uncomment // for debug led
861 +// global variables:
862 +struct timer_list gLedTimer;
863 +int gTimerOn = FALSE;
866 +typedef struct ledinfo
868 + unsigned short ledMask; // mask for led: ie. giop 10 = 0x0400
869 + unsigned short ledActiveLow; // GPIO bit reset to turn on LED
870 + unsigned short ledMaskFail; // mask for led: ie. giop 10 = 0x0400
871 + unsigned short ledActiveLowFail;// GPIO bit reset to turn on LED
872 + BOARD_LED_STATE ledState; // current led state
873 + BOARD_LED_STATE savedLedState; // used in blink once for restore to the orignal ledState
874 + int blinkCountDown; // if == 0, do blink (toggle). Is assgined value and dec by 1 at each timer.
875 +} LED_INFO, *PLED_INFO;
877 +static PLED_INFO gLed = NULL;
878 +static PLED_INFO gpVirtLeds[MAX_VIRT_LEDS];
879 +static HANDLE_LED_FUNC gLedHwFunc[MAX_VIRT_LEDS];
880 +static HANDLE_LED_FUNC gLedHwFailFunc[MAX_VIRT_LEDS];
883 +#if defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
884 +static int gLedOffInBridgeMode = 1;
885 +#elif defined(CONFIG_BCM96345)
886 +static int gLedOffInBridgeMode = 0;
890 +void ledTimerExpire(void);
891 +int initLedInfo( PLED_MAP_PAIR pCurMap, PLED_INFO pCurLed );
893 +//**************************************************************************************
895 +//**************************************************************************************
897 +// turn led on and set the ledState
898 +void ledOn(PLED_INFO pLed)
900 + if( pLed->ledMask )
902 + GPIO->GPIODir |= pLed->ledMask; // turn on the direction bit in case was turned off by some one
903 + if( pLed->ledActiveLow )
904 + GPIO->GPIOio &= ~pLed->ledMask; // turn on the led
906 + GPIO->GPIOio |= pLed->ledMask; // turn on the led
907 + pLed->ledState = pLed->savedLedState = kLedStateOn;
912 +// turn led off and set the ledState
913 +void ledOff(PLED_INFO pLed)
915 + if( pLed->ledMask )
917 + GPIO->GPIODir |= pLed->ledMask; // turn on the direction bit in case was turned off by some one
918 + if( pLed->ledActiveLow )
919 + GPIO->GPIOio |= pLed->ledMask; // turn off the led
921 + GPIO->GPIOio &= ~pLed->ledMask; // turn off the led
922 + pLed->ledState = pLed->savedLedState = kLedStateOff;
926 +// turn led on and set the ledState
927 +void ledOnFail(PLED_INFO pLed)
929 + if( pLed->ledMaskFail )
931 + GPIO->GPIODir |= pLed->ledMaskFail; // turn on the direction bit in case was turned off by some one
932 + if( pLed->ledActiveLowFail )
933 + GPIO->GPIOio &= ~pLed->ledMaskFail;// turn on the led
935 + GPIO->GPIOio |= pLed->ledMaskFail; // turn on the led
936 + pLed->ledState = pLed->savedLedState = kLedStateFail;
941 +// turn led off and set the ledState
942 +void ledOffFail(PLED_INFO pLed)
944 + if( pLed->ledMaskFail )
946 + GPIO->GPIODir |= pLed->ledMaskFail; // turn on the direction bit in case was turned off by some one
947 + if( pLed->ledActiveLowFail )
948 + GPIO->GPIOio |= pLed->ledMaskFail; // turn off the led
950 + GPIO->GPIOio &= ~pLed->ledMaskFail;// turn off the led
951 + pLed->ledState = pLed->savedLedState = kLedStateOff;
956 +// toggle the led and return the current ledState
957 +BOARD_LED_STATE ledToggle(PLED_INFO pLed)
959 + GPIO->GPIODir |= pLed->ledMask; // turn on the direction bit in case was turned off by some one
960 + if (GPIO->GPIOio & pLed->ledMask)
962 + GPIO->GPIOio &= ~(pLed->ledMask);
963 + return( (pLed->ledActiveLow) ? kLedStateOn : kLedStateOff );
967 + GPIO->GPIOio |= pLed->ledMask;
968 + return( (pLed->ledActiveLow) ? kLedStateOff : kLedStateOn );
973 +// led timer. Will return if timer is already on
974 +void ledTimerStart(void)
979 +#if defined(DEBUG_LED)
980 + printk("led: add_timer\n");
983 + init_timer(&gLedTimer);
984 + gLedTimer.function = (void*)ledTimerExpire;
985 + gLedTimer.expires = jiffies + k100ms; // timer expires in ~100ms
986 + add_timer (&gLedTimer);
991 +// led timer expire kicks in about ~100ms and perform the led operation according to the ledState and
992 +// restart the timer according to ledState
993 +void ledTimerExpire(void)
1000 + for (i = 0, pCurLed = gLed; i < gLedCount; i++, pCurLed++)
1002 +#if defined(DEBUG_LED)
1003 + printk("led[%d]: Mask=0x%04x, State = %d, blcd=%d\n", i, pCurLed->ledMask, pCurLed->ledState, pCurLed->blinkCountDown);
1005 + switch (pCurLed->ledState)
1008 + case kLedStateOff:
1009 + case kLedStateFail:
1010 + pCurLed->blinkCountDown = 0; // reset the blink count down
1013 + case kLedStateBlinkOnce:
1014 + ledToggle(pCurLed);
1015 + pCurLed->blinkCountDown = 0; // reset to 0
1016 + pCurLed->ledState = pCurLed->savedLedState;
1017 + if (pCurLed->ledState == kLedStateSlowBlinkContinues ||
1018 + pCurLed->ledState == kLedStateFastBlinkContinues)
1019 + ledTimerStart(); // start timer if in blinkContinues stats
1022 + case kLedStateSlowBlinkContinues:
1023 + if (pCurLed->blinkCountDown-- == 0)
1025 + pCurLed->blinkCountDown = kSlowBlinkCount;
1026 + ledToggle(pCurLed);
1031 + case kLedStateFastBlinkContinues:
1032 + if (pCurLed->blinkCountDown-- == 0)
1034 + pCurLed->blinkCountDown = kFastBlinkCount;
1035 + ledToggle(pCurLed);
1041 + printk("Invalid state = %d\n", pCurLed->ledState);
1046 +// initialize the gLedCount and allocate and fill gLed struct
1047 +void __init boardLedInit(PLED_MAP_PAIR cLedMapping)
1049 + PLED_MAP_PAIR p1, p2;
1050 + PLED_INFO pCurLed;
1051 + int needTimer = FALSE;
1052 + int alreadyUsed = 0;
1054 +#if defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
1055 + /* Set blink rate for BCM6348/BCM6338 hardware LEDs. */
1056 + GPIO->LEDCtrl &= ~LED_INTERVAL_SET_MASK;
1057 + GPIO->LEDCtrl |= LED_INTERVAL_SET_80MS;
1060 + memset( gpVirtLeds, 0x00, sizeof(gpVirtLeds) );
1061 + memset( gLedHwFunc, 0x00, sizeof(gLedHwFunc) );
1062 + memset( gLedHwFailFunc, 0x00, sizeof(gLedHwFailFunc) );
1066 + // Check for multiple LED names and multiple LED GPIO pins that share the
1067 + // same physical board LED.
1068 + for( p1 = cLedMapping; p1->ledName != kLedEnd; p1++ )
1071 + for( p2 = cLedMapping; p2 != p1; p2++ )
1073 + if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1074 + (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1081 + if( alreadyUsed == 0 )
1085 + gLed = (PLED_INFO) kmalloc((gLedCount * sizeof(LED_INFO)), GFP_KERNEL);
1086 + if( gLed == NULL )
1088 + printk( "LED memory allocation error.\n" );
1092 + memset( gLed, 0x00, gLedCount * sizeof(LED_INFO) );
1094 + // initial the gLed with unique ledMask and initial state. If more than 1 ledNames share the physical led
1095 + // (ledMask) the first defined led's ledInitState will be used.
1097 + for( p1 = cLedMapping; p1->ledName != kLedEnd; p1++ )
1099 + if( (int) p1->ledName > MAX_VIRT_LEDS )
1103 + for( p2 = cLedMapping; p2 != p1; p2++ )
1105 + if( (p1->ledMask && p1->ledMask == p2->ledMask) ||
1106 + (p1->ledMaskFail && p1->ledMaskFail == p2->ledMaskFail) )
1113 + if( alreadyUsed == 0 )
1115 + // Initialize the board LED for the first time.
1116 + needTimer = initLedInfo( p1, pCurLed );
1117 + gpVirtLeds[(int) p1->ledName] = pCurLed;
1123 + for( pLed = gLed; pLed != pCurLed; pLed++ )
1125 + // Find the LED_INFO structure that has already been initialized.
1126 + if((pLed->ledMask && pLed->ledMask == p1->ledMask) ||
1127 + (pLed->ledMaskFail && pLed->ledMaskFail==p1->ledMaskFail))
1129 + // The board LED has already been initialized but possibly
1130 + // not completely initialized.
1133 + pLed->ledMask = p1->ledMask;
1134 + pLed->ledActiveLow = p1->ledActiveLow;
1136 + if( p1->ledMaskFail )
1138 + pLed->ledMaskFail = p1->ledMaskFail;
1139 + pLed->ledActiveLowFail = p1->ledActiveLowFail;
1141 + gpVirtLeds[(int) p1->ledName] = pLed;
1151 +#if defined(DEBUG_LED)
1153 + for (i=0; i < gLedCount; i++)
1154 + printk("initLed: led[%d]: mask=0x%04x, state=%d\n", i,(gLed+i)->ledMask, (gLed+i)->ledState);
1159 +// Initialize a structure that contains information about a physical board LED
1160 +// control. The board LED may contain more than one GPIO pin to control a
1161 +// normal condition (green) or a failure condition (red).
1162 +int initLedInfo( PLED_MAP_PAIR pCurMap, PLED_INFO pCurLed )
1164 + int needTimer = FALSE;
1165 + pCurLed->ledState = pCurLed->savedLedState = pCurMap->ledInitState;
1166 + pCurLed->ledMask = pCurMap->ledMask;
1167 + pCurLed->ledActiveLow = pCurMap->ledActiveLow;
1168 + pCurLed->ledMaskFail = pCurMap->ledMaskFail;
1169 + pCurLed->ledActiveLowFail = pCurMap->ledActiveLowFail;
1171 + switch (pCurLed->ledState)
1174 + pCurLed->blinkCountDown = 0; // reset the blink count down
1177 + case kLedStateOff:
1178 + pCurLed->blinkCountDown = 0; // reset the blink count down
1181 + case kLedStateFail:
1182 + pCurLed->blinkCountDown = 0; // reset the blink count down
1183 + ledOnFail(pCurLed);
1185 + case kLedStateBlinkOnce:
1186 + pCurLed->blinkCountDown = 1;
1189 + case kLedStateSlowBlinkContinues:
1190 + pCurLed->blinkCountDown = kSlowBlinkCount;
1193 + case kLedStateFastBlinkContinues:
1194 + pCurLed->blinkCountDown = kFastBlinkCount;
1198 + printk("Invalid state = %d\n", pCurLed->ledState);
1201 + return( needTimer );
1205 +// Determines if there is at least one interface in bridge mode. Bridge mode
1206 +// is determined by the cfm convention of naming bridge interfaces nas17
1208 +static int isBridgedProtocol(void)
1210 + extern int dev_get(const char *name);
1211 + const int firstBridgeId = 17;
1212 + const int lastBridgeId = 24;
1217 + for( i = firstBridgeId; i <= lastBridgeId; i++ )
1219 + sprintf( name, "nas%d", i );
1221 + if( dev_get(name) )
1232 +// led ctrl. Maps the ledName to the corresponding ledInfoPtr and perform the led operation
1233 +void boardLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
1235 + PLED_INFO ledInfoPtr;
1237 + // do the mapping from virtual to physical led
1238 + if( (int) ledName < MAX_VIRT_LEDS )
1239 + ledInfoPtr = gpVirtLeds[(int) ledName];
1241 + ledInfoPtr = NULL;
1243 + if (ledInfoPtr == NULL)
1246 + if( ledState != kLedStateFail && gLedHwFunc[(int) ledName] )
1248 + (*gLedHwFunc[(int) ledName]) (ledName, ledState);
1249 + ledOffFail(ledInfoPtr);
1253 + if( ledState == kLedStateFail && gLedHwFailFunc[(int) ledName] )
1255 + (*gLedHwFailFunc[(int) ledName]) (ledName, ledState);
1256 + ledOff(ledInfoPtr);
1261 + // Do not blink the WAN Data LED if at least one interface is in bridge mode.
1262 + if(gLedOffInBridgeMode == 1 && (ledName == kLedWanData || ledName == kLedPPP))
1264 + static int BridgedProtocol = -1;
1266 + if( BridgedProtocol == -1 )
1267 + BridgedProtocol = isBridgedProtocol();
1269 + if( BridgedProtocol == TRUE )
1274 + // If the state is kLedStateFail and there is not a failure LED defined
1275 + // in the board parameters, change the state to kLedStateFastBlinkContinues.
1276 + if( ledState == kLedStateFail && ledInfoPtr->ledMaskFail == 0 )
1277 + ledState = kLedStateFastBlinkContinues;
1282 + // First, turn off the complimentary (failure) LED GPIO.
1283 + if( ledInfoPtr->ledMaskFail )
1284 + ledOffFail(ledInfoPtr);
1286 + if( gLedHwFailFunc[(int) ledName] )
1287 + (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1289 + // Next, turn on the specified LED GPIO.
1290 + ledOn(ledInfoPtr);
1293 + case kLedStateOff:
1294 + // First, turn off the complimentary (failure) LED GPIO.
1295 + if( ledInfoPtr->ledMaskFail )
1296 + ledOffFail(ledInfoPtr);
1298 + if( gLedHwFailFunc[(int) ledName] )
1299 + (*gLedHwFailFunc[(int) ledName]) (ledName, kLedStateOff);
1301 + // Next, turn off the specified LED GPIO.
1302 + ledOff(ledInfoPtr);
1305 + case kLedStateFail:
1306 + // First, turn off the complimentary (normal) LED GPIO.
1307 + if( ledInfoPtr->ledMask )
1308 + ledOff(ledInfoPtr);
1310 + if( gLedHwFunc[(int) ledName] )
1311 + (*gLedHwFunc[(int) ledName]) (ledName, kLedStateOff);
1313 + // Next, turn on (red) the specified LED GPIO.
1314 + ledOnFail(ledInfoPtr);
1317 + case kLedStateBlinkOnce:
1318 + // skip blinkOnce if it is already in Slow/Fast blink continues state
1319 + if (ledInfoPtr->savedLedState == kLedStateSlowBlinkContinues ||
1320 + ledInfoPtr->savedLedState == kLedStateFastBlinkContinues)
1324 + if (ledInfoPtr->blinkCountDown == 0) // skip the call if it is 1
1326 + ledToggle(ledInfoPtr);
1327 + ledInfoPtr->blinkCountDown = 1; // it will be reset to 0 when timer expires
1328 + ledInfoPtr->ledState = kLedStateBlinkOnce;
1334 + case kLedStateSlowBlinkContinues:
1335 + ledInfoPtr->blinkCountDown = kSlowBlinkCount;
1336 + ledInfoPtr->ledState = kLedStateSlowBlinkContinues;
1337 + ledInfoPtr->savedLedState = kLedStateSlowBlinkContinues;
1341 + case kLedStateFastBlinkContinues:
1342 + ledInfoPtr->blinkCountDown = kFastBlinkCount;
1343 + ledInfoPtr->ledState = kLedStateFastBlinkContinues;
1344 + ledInfoPtr->savedLedState = kLedStateFastBlinkContinues;
1349 + printk("Invalid led state\n");
1353 +// This function is called for an LED that is controlled by hardware.
1354 +void kerSysLedRegisterHwHandler( BOARD_LED_NAME ledName,
1355 + HANDLE_LED_FUNC ledHwFunc, int ledFailType )
1357 + if( (int) ledName < MAX_VIRT_LEDS )
1359 + if( ledFailType == 1 )
1360 + gLedHwFailFunc[(int) ledName] = ledHwFunc;
1362 + gLedHwFunc[(int) ledName] = ledHwFunc;
1366 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c
1367 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/board.c 1970-01-01 01:00:00.000000000 +0100
1368 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/board.c 2006-08-03 16:37:21.000000000 +0200
1372 + Copyright 2002 Broadcom Corp. All Rights Reserved.
1374 + This program is free software; you can distribute it and/or modify it
1375 + under the terms of the GNU General Public License (Version 2) as
1376 + published by the Free Software Foundation.
1378 + This program is distributed in the hope it will be useful, but WITHOUT
1379 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1380 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1383 + You should have received a copy of the GNU General Public License along
1384 + with this program; if not, write to the Free Software Foundation, Inc.,
1385 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
1388 +/***************************************************************************
1389 + * File Name : board.c
1391 + * Description: This file contains Linux character device driver entry
1392 + * for the board related ioctl calls: flash, get free kernel
1393 + * page and dump kernel memory, etc.
1395 + * Created on : 2/20/2002 seanl: use cfiflash.c, cfliflash.h (AMD specific)
1397 + ***************************************************************************/
1401 +#include <linux/version.h>
1402 +#include <linux/init.h>
1403 +#include <linux/fs.h>
1404 +#include <linux/interrupt.h>
1405 +#include <linux/capability.h>
1406 +#include <linux/slab.h>
1407 +#include <linux/errno.h>
1408 +#include <linux/module.h>
1409 +#include <linux/pagemap.h>
1410 +#include <asm/uaccess.h>
1411 +#include <linux/wait.h>
1412 +#include <linux/poll.h>
1413 +#include <linux/sched.h>
1414 +#include <linux/list.h>
1415 +#include <linux/if.h>
1416 +#include <linux/spinlock.h>
1418 +#include <bcm_map_part.h>
1420 +#include <bcmTag.h>
1421 +#include "boardparms.h"
1422 +#include "cfiflash.h"
1423 +#include "bcm_intr.h"
1425 +#include "bcm_map_part.h"
1427 +static DEFINE_SPINLOCK(board_lock);
1430 +#if defined (NON_CONSECUTIVE_MAC)
1431 +// used to be the last octet. Now changed to the first 5 bits of the the forth octet
1432 +// to reduced the duplicated MAC addresses.
1433 +#define CHANGED_OCTET 3
1434 +#define SHIFT_BITS 3
1436 +#define CHANGED_OCTET 1
1437 +#define SHIFT_BITS 0
1440 +#if defined (WIRELESS)
1441 +#define SES_BTN_PRESSED 0x00000001
1442 +#define SES_EVENTS SES_BTN_PRESSED /*OR all values if any*/
1443 +#define SES_LED_OFF 0
1444 +#define SES_LED_ON 1
1445 +#define SES_LED_BLINK 2
1450 + unsigned long ulId;
1452 + char chReserved[3];
1453 +} MAC_ADDR_INFO, *PMAC_ADDR_INFO;
1457 + unsigned long ulSdramSize;
1458 + unsigned long ulPsiSize;
1459 + unsigned long ulNumMacAddrs;
1460 + unsigned long ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN];
1461 + MAC_ADDR_INFO MacAddrs[1];
1462 +} NVRAM_INFO, *PNVRAM_INFO;
1466 + unsigned long eventmask;
1467 +} BOARD_IOC, *PBOARD_IOC;
1470 +/*Dyinggasp callback*/
1471 +typedef void (*cb_dgasp_t)(void *arg);
1472 +typedef struct _CB_DGASP__LIST
1474 + struct list_head list;
1475 + char name[IFNAMSIZ];
1476 + cb_dgasp_t cb_dgasp_fn;
1478 +}CB_DGASP_LIST , *PCB_DGASP_LIST;
1481 +static LED_MAP_PAIR LedMapping[] =
1482 +{ // led name Initial state physical pin (ledMask)
1483 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1484 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1485 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1486 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1487 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1488 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1489 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1490 + {kLedEnd, kLedStateOff, 0, 0, 0, 0},
1491 + {kLedEnd, kLedStateOff, 0, 0, 0, 0} // NOTE: kLedEnd has to be at the end.
1495 +extern struct file fastcall *fget_light(unsigned int fd, int *fput_needed);
1496 +extern unsigned int nr_free_pages (void);
1497 +extern const char *get_system_type(void);
1498 +extern void kerSysFlashInit(void);
1499 +extern unsigned long get_nvram_start_addr(void);
1500 +extern unsigned long get_scratch_pad_start_addr(void);
1501 +extern unsigned long getMemorySize(void);
1502 +extern void __init boardLedInit(PLED_MAP_PAIR);
1503 +extern void boardLedCtrl(BOARD_LED_NAME, BOARD_LED_STATE);
1504 +extern void kerSysLedRegisterHandler( BOARD_LED_NAME ledName,
1505 + HANDLE_LED_FUNC ledHwFunc, int ledFailType );
1508 +void __init InitNvramInfo( void );
1509 +static int board_open( struct inode *inode, struct file *filp );
1510 +static int board_ioctl( struct inode *inode, struct file *flip, unsigned int command, unsigned long arg );
1511 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos);
1512 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait);
1513 +static int board_release(struct inode *inode, struct file *filp);
1515 +static BOARD_IOC* borad_ioc_alloc(void);
1516 +static void borad_ioc_free(BOARD_IOC* board_ioc);
1518 +/* DyingGasp function prototype */
1519 +static void __init kerSysDyingGaspMapIntr(void);
1520 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
1521 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs);
1523 +static unsigned int kerSysDyingGaspIsr(void);
1525 +static void __init kerSysInitDyingGaspHandler( void );
1526 +static void __exit kerSysDeinitDyingGaspHandler( void );
1527 +/* -DyingGasp function prototype - */
1530 +#if defined (WIRELESS)
1531 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs);
1532 +static void __init sesBtn_mapGpio(void);
1533 +static void __init sesBtn_mapIntr(int context);
1534 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait);
1535 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos);
1536 +static void __init sesLed_mapGpio(void);
1537 +static void sesLed_ctrl(int action);
1538 +static void __init ses_board_init(void);
1539 +static void __exit ses_board_deinit(void);
1542 +static PNVRAM_INFO g_pNvramInfo = NULL;
1543 +static int g_ledInitialized = 0;
1544 +static wait_queue_head_t g_board_wait_queue;
1545 +static CB_DGASP_LIST *g_cb_dgasp_list_head = NULL;
1547 +static int g_wakeup_monitor = 0;
1548 +static struct file *g_monitor_file = NULL;
1549 +static struct task_struct *g_monitor_task = NULL;
1550 +static unsigned int (*g_orig_fop_poll)
1551 + (struct file *, struct poll_table_struct *) = NULL;
1553 +static struct file_operations board_fops =
1556 + ioctl: board_ioctl,
1559 + release: board_release,
1562 +uint32 board_major = 0;
1564 +#if defined (WIRELESS)
1565 +static unsigned short sesBtn_irq = BP_NOT_DEFINED;
1566 +static unsigned short sesBtn_gpio = BP_NOT_DEFINED;
1567 +static unsigned short sesLed_gpio = BP_NOT_DEFINED;
1570 +#if defined(MODULE)
1571 +int init_module(void)
1573 + return( brcm_board_init() );
1576 +void cleanup_module(void)
1579 + printk("brcm flash: cleanup_module failed because module is in use\n");
1581 + brcm_board_cleanup();
1587 +static int __init brcm_board_init( void )
1589 + typedef int (*BP_LED_FUNC) (unsigned short *);
1590 + static struct BpLedInformation
1592 + BOARD_LED_NAME ledName;
1593 + BP_LED_FUNC bpFunc;
1594 + BP_LED_FUNC bpFuncFail;
1596 + {{kLedAdsl, BpGetAdslLedGpio, BpGetAdslFailLedGpio},
1597 + {kLedWireless, BpGetWirelessLedGpio, NULL},
1598 + {kLedUsb, BpGetUsbLedGpio, NULL},
1599 + {kLedHpna, BpGetHpnaLedGpio, NULL},
1600 + {kLedWanData, BpGetWanDataLedGpio, NULL},
1601 + {kLedPPP, BpGetPppLedGpio, BpGetPppFailLedGpio},
1602 + {kLedVoip, BpGetVoipLedGpio, NULL},
1603 + {kLedSes, BpGetWirelessSesLedGpio, NULL},
1604 + {kLedEnd, NULL, NULL}
1609 + ret = register_chrdev(BOARD_DRV_MAJOR, "bcrmboard", &board_fops );
1611 + printk( "brcm_board_init(major %d): fail to register device.\n",BOARD_DRV_MAJOR);
1614 + PLED_MAP_PAIR pLedMap = LedMapping;
1615 + unsigned short gpio;
1616 + struct BpLedInformation *pInfo;
1618 + printk("brcmboard: brcm_board_init entry\n");
1619 + board_major = BOARD_DRV_MAJOR;
1620 + if (boot_loader_type == BOOT_CFE)
1623 +#if !defined(CONFIG_BCM96338)
1624 + GPIO->GPIOMode &= ~(0x000F0000);
1627 + pLedMap[0].ledName = kLedSelfTest ;
1628 + pLedMap[0].ledMask = GPIO_NUM_TO_MASK(0);
1629 + pLedMap[0].ledActiveLow = 0;
1631 + pLedMap[1].ledName = kLedAdsl;
1632 + pLedMap[1].ledMask = GPIO_NUM_TO_MASK(1);
1633 + pLedMap[1].ledActiveLow = 0;
1635 + pLedMap[2].ledName = kLedLan ;
1636 + pLedMap[2].ledMask = GPIO_NUM_TO_MASK(2);
1637 + pLedMap[2].ledActiveLow = 0;
1639 + pLedMap[3].ledName = kLedVoip ;
1640 + pLedMap[3].ledMask = GPIO_NUM_TO_MASK(3);
1641 + pLedMap[3].ledActiveLow = 0;
1643 + pLedMap[4].ledName = kLedWireless ;
1644 + pLedMap[4].ledMask = GPIO_NUM_TO_MASK(4);
1645 + pLedMap[4].ledActiveLow = 0;
1647 + pLedMap[5].ledName = kLedEnd;
1650 + for( pInfo = bpLedInfo; pInfo->ledName != kLedEnd; pInfo++ )
1652 + if( pInfo->bpFunc && (*pInfo->bpFunc) (&gpio) == BP_SUCCESS )
1654 + pLedMap->ledName = pInfo->ledName;
1655 + pLedMap->ledMask = GPIO_NUM_TO_MASK(gpio);
1656 + pLedMap->ledActiveLow = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1658 + if( pInfo->bpFuncFail && (*pInfo->bpFuncFail) (&gpio) == BP_SUCCESS )
1660 + pLedMap->ledName = pInfo->ledName;
1661 + pLedMap->ledMaskFail = GPIO_NUM_TO_MASK(gpio);
1662 + pLedMap->ledActiveLowFail = (gpio & BP_ACTIVE_LOW) ? 1 : 0;
1664 + if( pLedMap->ledName != kLedEnd )
1668 + init_waitqueue_head(&g_board_wait_queue);
1669 +#if defined (WIRELESS)
1672 + kerSysInitDyingGaspHandler();
1673 + kerSysDyingGaspMapIntr();
1675 + boardLedInit(LedMapping);
1676 + g_ledInitialized = 1;
1682 +void __init InitNvramInfo( void )
1684 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
1685 + unsigned long ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1687 + if( ulNumMacAddrs > 0 && ulNumMacAddrs <= NVRAM_MAC_COUNT_MAX )
1689 + unsigned long ulNvramInfoSize =
1690 + sizeof(NVRAM_INFO) + ((sizeof(MAC_ADDR_INFO) - 1) * ulNumMacAddrs);
1692 + g_pNvramInfo = (PNVRAM_INFO) kmalloc( ulNvramInfoSize, GFP_KERNEL );
1694 + if( g_pNvramInfo )
1696 + unsigned long ulPsiSize;
1697 + if( BpGetPsiSize( &ulPsiSize ) != BP_SUCCESS )
1698 + ulPsiSize = NVRAM_PSI_DEFAULT;
1699 + memset( g_pNvramInfo, 0x00, ulNvramInfoSize );
1700 + g_pNvramInfo->ulPsiSize = ulPsiSize * 1024;
1701 + g_pNvramInfo->ulNumMacAddrs = pNvramData->ulNumMacAddrs;
1702 + memcpy( g_pNvramInfo->ucaBaseMacAddr, pNvramData->ucaBaseMacAddr,
1703 + NVRAM_MAC_ADDRESS_LEN );
1704 + g_pNvramInfo->ulSdramSize = getMemorySize();
1707 + printk("ERROR - Could not allocate memory for NVRAM data\n");
1710 + printk("ERROR - Invalid number of MAC addresses (%ld) is configured.\n",
1714 +void __exit brcm_board_cleanup( void )
1716 + printk("brcm_board_cleanup()\n");
1718 + if (board_major != -1)
1720 +#if defined (WIRELESS)
1721 + ses_board_deinit();
1723 + kerSysDeinitDyingGaspHandler();
1724 + unregister_chrdev(board_major, "board_ioctl");
1728 +static BOARD_IOC* borad_ioc_alloc(void)
1730 + BOARD_IOC *board_ioc =NULL;
1731 + board_ioc = (BOARD_IOC*) kmalloc( sizeof(BOARD_IOC) , GFP_KERNEL );
1734 + memset(board_ioc, 0, sizeof(BOARD_IOC));
1739 +static void borad_ioc_free(BOARD_IOC* board_ioc)
1748 +static int board_open( struct inode *inode, struct file *filp )
1750 + filp->private_data = borad_ioc_alloc();
1752 + if (filp->private_data == NULL)
1758 +static int board_release(struct inode *inode, struct file *filp)
1760 + BOARD_IOC *board_ioc = filp->private_data;
1762 + wait_event_interruptible(g_board_wait_queue, 1);
1763 + borad_ioc_free(board_ioc);
1769 +static unsigned int board_poll(struct file *filp, struct poll_table_struct *wait)
1771 + unsigned int mask = 0;
1772 +#if defined (WIRELESS)
1773 + BOARD_IOC *board_ioc = filp->private_data;
1776 + poll_wait(filp, &g_board_wait_queue, wait);
1777 +#if defined (WIRELESS)
1778 + if(board_ioc->eventmask & SES_EVENTS){
1779 + mask |= sesBtn_poll(filp, wait);
1787 +static ssize_t board_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
1789 +#if defined (WIRELESS)
1790 + BOARD_IOC *board_ioc = filp->private_data;
1791 + if(board_ioc->eventmask & SES_EVENTS){
1792 + return sesBtn_read(filp, buffer, count, ppos);
1798 +//**************************************************************************************
1799 +// Utitlities for dump memory, free kernel pages, mips soft reset, etc.
1800 +//**************************************************************************************
1802 +/***********************************************************************
1803 + * Function Name: dumpaddr
1804 + * Description : Display a hex dump of the specified address.
1805 + ***********************************************************************/
1806 +void dumpaddr( unsigned char *pAddr, int nLen )
1808 + static char szHexChars[] = "0123456789abcdef";
1811 + unsigned char ch, *q;
1817 + sprintf( szLine, "%8.8lx: ", (unsigned long) pAddr );
1818 + p = szLine + strlen(szLine);
1820 + for(i = 0; i < 16 && nLen > 0; i += sizeof(long), nLen -= sizeof(long))
1822 + ul = *(unsigned long *) &pAddr[i];
1823 + q = (unsigned char *) &ul;
1824 + for( j = 0; j < sizeof(long); j++ )
1826 + *p++ = szHexChars[q[j] >> 4];
1827 + *p++ = szHexChars[q[j] & 0x0f];
1832 + for( j = 0; j < 16 - i; j++ )
1833 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1835 + *p++ = ' ', *p++ = ' ', *p++ = ' ';
1837 + for( j = 0; j < i; j++ )
1840 + *p++ = (ch > ' ' && ch < '~') ? ch : '.';
1844 + printk( "%s\r\n", szLine );
1852 +void kerSysMipsSoftReset(void)
1854 +#if defined(CONFIG_BCM96348)
1855 + if (PERF->RevID == 0x634800A1) {
1856 + typedef void (*FNPTR) (void);
1857 + FNPTR bootaddr = (FNPTR) FLASH_BASE;
1860 + /* Disable interrupts. */
1862 + spin_lock_irq(&board_lock);
1864 + /* Reset all blocks. */
1865 + PERF->BlockSoftReset &= ~BSR_ALL_BLOCKS;
1866 + for( i = 0; i < 1000000; i++ )
1868 + PERF->BlockSoftReset |= BSR_ALL_BLOCKS;
1869 + /* Jump to the power on address. */
1873 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1875 + PERF->pll_control |= SOFT_RESET; // soft reset mips
1880 +int kerSysGetMacAddress( unsigned char *pucaMacAddr, unsigned long ulId )
1883 + PMAC_ADDR_INFO pMai = NULL;
1884 + PMAC_ADDR_INFO pMaiFreeNoId = NULL;
1885 + PMAC_ADDR_INFO pMaiFreeId = NULL;
1886 + unsigned long i = 0, ulIdxNoId = 0, ulIdxId = 0, shiftedIdx = 0;
1888 + /* CMO -- Fix le problème avec les adresses mac que l'on n'arrive pas
1889 + * * Ã relire plusieurs fois */
1891 + if (boot_loader_type == BOOT_CFE)
1892 + memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1893 + NVRAM_MAC_ADDRESS_LEN );
1895 + pucaMacAddr[0] = 0x00;
1896 + pucaMacAddr[1] = 0x07;
1897 + pucaMacAddr[2] = 0x3A;
1898 + pucaMacAddr[3] = 0xFF;
1899 + pucaMacAddr[4] = 0xFF;
1900 + pucaMacAddr[5] = 0xFF;
1905 + for( i = 0, pMai = g_pNvramInfo->MacAddrs; i < g_pNvramInfo->ulNumMacAddrs;
1908 + if( ulId == pMai->ulId || ulId == MAC_ADDRESS_ANY )
1910 + /* This MAC address has been used by the caller in the past. */
1911 + memcpy( pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,
1912 + NVRAM_MAC_ADDRESS_LEN );
1914 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1915 + pMai->chInUse = 1;
1916 + pMaiFreeNoId = pMaiFreeId = NULL;
1920 + if( pMai->chInUse == 0 )
1922 + if( pMai->ulId == 0 && pMaiFreeNoId == NULL )
1924 + /* This is an available MAC address that has never been
1927 + pMaiFreeNoId = pMai;
1931 + if( pMai->ulId != 0 && pMaiFreeId == NULL )
1933 + /* This is an available MAC address that has been used
1934 + * before. Use addresses that have never been used
1935 + * first, before using this one.
1937 + pMaiFreeId = pMai;
1943 + if( pMaiFreeNoId || pMaiFreeId )
1945 + /* An available MAC address was found. */
1946 + memcpy(pucaMacAddr, g_pNvramInfo->ucaBaseMacAddr,NVRAM_MAC_ADDRESS_LEN);
1947 + if( pMaiFreeNoId )
1949 + shiftedIdx = ulIdxNoId;
1950 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1951 + pMaiFreeNoId->ulId = ulId;
1952 + pMaiFreeNoId->chInUse = 1;
1956 + shiftedIdx = ulIdxId;
1957 + pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] += (shiftedIdx << SHIFT_BITS);
1958 + pMaiFreeId->ulId = ulId;
1959 + pMaiFreeId->chInUse = 1;
1963 + if( i == g_pNvramInfo->ulNumMacAddrs )
1964 + nRet = -EADDRNOTAVAIL;
1968 +} /* kerSysGetMacAddr */
1970 +int kerSysReleaseMacAddress( unsigned char *pucaMacAddr )
1972 + int nRet = -EINVAL;
1973 + unsigned long ulIdx = 0;
1974 + int idx = (pucaMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET] -
1975 + g_pNvramInfo->ucaBaseMacAddr[NVRAM_MAC_ADDRESS_LEN - CHANGED_OCTET]);
1977 + // if overflow 255 (negitive), add 256 to have the correct index
1980 + ulIdx = (unsigned long) (idx >> SHIFT_BITS);
1982 + if( ulIdx < g_pNvramInfo->ulNumMacAddrs )
1984 + PMAC_ADDR_INFO pMai = &g_pNvramInfo->MacAddrs[ulIdx];
1985 + if( pMai->chInUse == 1 )
1987 + pMai->chInUse = 0;
1993 +} /* kerSysReleaseMacAddr */
1995 +int kerSysGetSdramSize( void )
1997 + if (boot_loader_type == BOOT_CFE) {
1998 + return( (int) g_pNvramInfo->ulSdramSize );
2001 + printk("kerSysGetSdramSize : 0x%08X\n", (int)getMemorySize() + 0x00040000);
2002 + return((int)getMemorySize() + 0x00040000);
2004 +} /* kerSysGetSdramSize */
2007 +void kerSysLedCtrl(BOARD_LED_NAME ledName, BOARD_LED_STATE ledState)
2009 + if (g_ledInitialized)
2010 + boardLedCtrl(ledName, ledState);
2013 +unsigned int kerSysMonitorPollHook( struct file *f, struct poll_table_struct *t)
2015 + int mask = (*g_orig_fop_poll) (f, t);
2017 + if( g_wakeup_monitor == 1 && g_monitor_file == f )
2019 + /* If g_wakeup_monitor is non-0, the user mode application needs to
2020 + * return from a blocking select function. Return POLLPRI which will
2021 + * cause the select to return with the exception descriptor set.
2024 + g_wakeup_monitor = 0;
2030 +/* Put the user mode application that monitors link state on a run queue. */
2031 +void kerSysWakeupMonitorTask( void )
2033 + g_wakeup_monitor = 1;
2034 + if( g_monitor_task )
2035 + wake_up_process( g_monitor_task );
2038 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2039 +int kerSysGetResetHold(void)
2041 + unsigned short gpio;
2043 + if( BpGetPressAndHoldResetGpio( &gpio ) == BP_SUCCESS )
2045 +#if defined(CONFIG_BCM96338)
2046 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
2047 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2049 +#if defined(CONFIG_BCM96345)
2050 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(gpio);
2051 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2053 +#if defined(CONFIG_BCM96348)
2054 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(gpio);
2055 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2057 + if( (gpio & ~BP_ACTIVE_MASK) >= 32 )
2059 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(gpio);
2060 + gpio_reg = &GPIO->GPIOio_high;
2063 + //printk("gpio=%04x,gpio_mask=%04x,gpio_reg=%04x\n",gpio,gpio_mask,*gpio_reg);
2064 + if(*gpio_reg & gpio_mask) //press down
2065 + return RESET_BUTTON_UP;
2067 + return RESET_BUTTON_PRESSDOWN;
2069 +//<<JUNHON, 2004/09/15
2071 +//********************************************************************************************
2072 +// misc. ioctl calls come to here. (flash, led, reset, kernel memory access, etc.)
2073 +//********************************************************************************************
2074 +static int board_ioctl( struct inode *inode, struct file *flip,
2075 + unsigned int command, unsigned long arg )
2078 + BOARD_IOCTL_PARMS ctrlParms;
2079 + unsigned char ucaMacAddr[NVRAM_MAC_ADDRESS_LEN];
2084 + case BOARD_IOCTL_FLASH_INIT:
2085 + // not used for now. kerSysBcmImageInit();
2089 + case BOARD_IOCTL_FLASH_WRITE:
2090 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2092 + NVRAM_DATA SaveNvramData;
2093 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
2095 + switch (ctrlParms.action)
2098 + if (boot_loader_type == BOOT_CFE) {
2099 + ret = kerSysScratchPadSet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2102 + printk("RedBoot : not supported\n");
2108 + if (boot_loader_type == BOOT_CFE) {
2109 + ret = kerSysPersistentSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2112 + printk("RedBoot : not supported\n");
2118 + if (boot_loader_type == BOOT_CFE) {
2119 + ret = kerSysNvRamSet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2122 + printk("RedBoot : not supported\n");
2127 + case BCM_IMAGE_CFE:
2128 + if (boot_loader_type == BOOT_CFE) {
2129 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > FLASH45_LENGTH_BOOT_ROM )
2131 + printk("Illegal CFE size [%d]. Size allowed: [%d]\n",
2132 + ctrlParms.strLen, FLASH45_LENGTH_BOOT_ROM);
2137 + // save NVRAM data into a local structure
2138 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2140 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2142 + // if nvram is not valid, restore the current nvram settings
2143 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2144 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2146 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2150 + printk("RedBoot : not supported\n");
2154 + case BCM_IMAGE_FS:
2155 + if (boot_loader_type == BOOT_CFE) {
2156 + allowedSize = (int) flash_get_total_size() - FLASH_RESERVED_AT_END - TAG_LEN - FLASH45_LENGTH_BOOT_ROM;
2157 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize)
2159 + printk("Illegal root file system size [%d]. Size allowed: [%d]\n",
2160 + ctrlParms.strLen, ctrlParms.offset - allowedSize);
2164 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2165 + kerSysMipsSoftReset();
2168 + printk("RedBoot : not supported\n");
2173 + case BCM_IMAGE_KERNEL: // not used for now.
2174 + if (boot_loader_type == BOOT_CFE) {
2175 + allowedSize = (int) flash_get_total_size() - FLASH_RESERVED_AT_END - TAG_LEN - ctrlParms.offset;
2177 + printk("kernel size = [%d]. Allowed size = [%d]\n", ctrlParms.strLen, allowedSize);
2179 + if( ctrlParms.strLen <= 0 || ctrlParms.strLen > allowedSize )
2181 + printk("Kernel size is over the limit by [%d] bytes\n",
2182 + ctrlParms.strLen - allowedSize);
2186 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2189 + printk("RedBoot : not supported\n");
2193 + case BCM_IMAGE_WHOLE:
2194 + if (boot_loader_type == BOOT_CFE) {
2195 + if(ctrlParms.strLen <= 0)
2197 + printk("Illegal flash image size [%d].\n", ctrlParms.strLen);
2202 + // save NVRAM data into a local structure
2203 + memcpy( &SaveNvramData, pNvramData, sizeof(NVRAM_DATA) );
2205 + ret = kerSysBcmImageSet(ctrlParms.offset, ctrlParms.string, ctrlParms.strLen);
2207 + // if nvram is not valid, restore the current nvram settings
2208 + if( BpSetBoardId( pNvramData->szBoardId ) != BP_SUCCESS &&
2209 + *(unsigned long *) pNvramData == NVRAM_DATA_ID )
2211 + kerSysNvRamSet((char *) &SaveNvramData, sizeof(SaveNvramData), 0);
2214 + kerSysMipsSoftReset();
2217 + printk("RedBoot : not supported\n");
2224 + printk("flash_ioctl_command: invalid command %d\n", ctrlParms.action);
2227 + ctrlParms.result = ret;
2228 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2234 + case BOARD_IOCTL_FLASH_READ:
2235 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2237 + switch (ctrlParms.action)
2240 + if (boot_loader_type == BOOT_CFE) {
2241 + ret = kerSysScratchPadGet(ctrlParms.string, ctrlParms.buf, ctrlParms.offset);
2244 + printk("RedBoot : not supported\n");
2250 + if (boot_loader_type == BOOT_CFE) {
2251 + ret = kerSysPersistentGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2254 + printk("RedBoot : not supported\n");
2260 + if (boot_loader_type == BOOT_CFE) {
2261 + ret = kerSysNvRamGet(ctrlParms.string, ctrlParms.strLen, ctrlParms.offset);
2264 + printk("RedBoot : not supported\n");
2270 + if (boot_loader_type == BOOT_CFE) {
2271 + ret = kerSysFlashSizeGet();
2274 + printk("RedBoot : not supported\n");
2281 + printk("Not supported. invalid command %d\n", ctrlParms.action);
2284 + ctrlParms.result = ret;
2285 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2291 + case BOARD_IOCTL_GET_NR_PAGES:
2292 + ctrlParms.result = nr_free_pages() + get_page_cache_size();
2293 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2297 + case BOARD_IOCTL_DUMP_ADDR:
2298 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2300 + dumpaddr( (unsigned char *) ctrlParms.string, ctrlParms.strLen );
2301 + ctrlParms.result = 0;
2302 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2309 + case BOARD_IOCTL_SET_MEMORY:
2310 + if (boot_loader_type == BOOT_CFE) {
2311 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2313 + unsigned long *pul = (unsigned long *) ctrlParms.string;
2314 + unsigned short *pus = (unsigned short *) ctrlParms.string;
2315 + unsigned char *puc = (unsigned char *) ctrlParms.string;
2316 + switch( ctrlParms.strLen )
2319 + *pul = (unsigned long) ctrlParms.offset;
2322 + *pus = (unsigned short) ctrlParms.offset;
2325 + *puc = (unsigned char) ctrlParms.offset;
2328 + dumpaddr( (unsigned char *) ctrlParms.string, sizeof(long) );
2329 + ctrlParms.result = 0;
2330 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2337 + printk("RedBoot : not supported\n");
2343 + case BOARD_IOCTL_MIPS_SOFT_RESET:
2344 + kerSysMipsSoftReset();
2347 + case BOARD_IOCTL_LED_CTRL:
2348 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2350 + kerSysLedCtrl((BOARD_LED_NAME)ctrlParms.strLen, (BOARD_LED_STATE)ctrlParms.offset);
2355 + case BOARD_IOCTL_GET_ID:
2356 + if (boot_loader_type == BOOT_CFE) {
2357 + if (copy_from_user((void*)&ctrlParms, (void*)arg,
2358 + sizeof(ctrlParms)) == 0)
2360 + if( ctrlParms.string )
2362 + char *p = (char *) get_system_type();
2363 + if( strlen(p) + 1 < ctrlParms.strLen )
2364 + ctrlParms.strLen = strlen(p) + 1;
2365 + __copy_to_user(ctrlParms.string, p, ctrlParms.strLen);
2368 + ctrlParms.result = 0;
2369 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2370 + sizeof(BOARD_IOCTL_PARMS));
2374 + printk("RedBoot : not supported\n");
2379 + case BOARD_IOCTL_GET_MAC_ADDRESS:
2380 + if (boot_loader_type == BOOT_CFE) {
2381 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2383 + ctrlParms.result = kerSysGetMacAddress( ucaMacAddr,
2384 + ctrlParms.offset );
2386 + if( ctrlParms.result == 0 )
2388 + __copy_to_user(ctrlParms.string, ucaMacAddr,
2389 + sizeof(ucaMacAddr));
2392 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2393 + sizeof(BOARD_IOCTL_PARMS));
2400 + printk("RedBoot : not supported\n");
2405 + case BOARD_IOCTL_RELEASE_MAC_ADDRESS:
2406 + if (boot_loader_type == BOOT_CFE) {
2407 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2409 + if (copy_from_user((void*)ucaMacAddr, (void*)ctrlParms.string, \
2410 + NVRAM_MAC_ADDRESS_LEN) == 0)
2412 + ctrlParms.result = kerSysReleaseMacAddress( ucaMacAddr );
2416 + ctrlParms.result = -EACCES;
2419 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2420 + sizeof(BOARD_IOCTL_PARMS));
2427 + printk("RedBoot : not supported\n");
2432 + case BOARD_IOCTL_GET_PSI_SIZE:
2433 + if (boot_loader_type == BOOT_CFE) {
2434 + ctrlParms.result = (int) g_pNvramInfo->ulPsiSize;
2435 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2439 + printk("RedBoot : not supported\n");
2444 + case BOARD_IOCTL_GET_SDRAM_SIZE:
2445 + if (boot_loader_type == BOOT_CFE) {
2446 + ctrlParms.result = (int) g_pNvramInfo->ulSdramSize;
2447 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2451 + printk("RedBoot : not supported\n");
2456 + case BOARD_IOCTL_GET_BASE_MAC_ADDRESS:
2457 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0)
2459 + __copy_to_user(ctrlParms.string, g_pNvramInfo->ucaBaseMacAddr, NVRAM_MAC_ADDRESS_LEN);
2460 + ctrlParms.result = 0;
2462 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms,
2463 + sizeof(BOARD_IOCTL_PARMS));
2470 + case BOARD_IOCTL_GET_CHIP_ID:
2471 + ctrlParms.result = (int) (PERF->RevID & 0xFFFF0000) >> 16;
2472 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2476 + case BOARD_IOCTL_GET_NUM_ENET: {
2477 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2478 + int i, numeth = 0;
2479 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2480 + for( i = 0; i < BP_MAX_ENET_MACS; i++) {
2481 + if (EnetInfos[i].ucPhyType != BP_ENET_NO_PHY) {
2485 + ctrlParms.result = numeth;
2486 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2495 + case BOARD_IOCTL_GET_CFE_VER:
2496 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2497 + char *vertag = (char *)(FLASH_BASE + CFE_VERSION_OFFSET);
2498 + if (ctrlParms.strLen < CFE_VERSION_SIZE) {
2499 + ctrlParms.result = 0;
2500 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2503 + else if (strncmp(vertag, "cfe-v", 5)) { // no tag info in flash
2504 + ctrlParms.result = 0;
2505 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2509 + ctrlParms.result = 1;
2510 + __copy_to_user(ctrlParms.string, vertag+CFE_VERSION_MARK_SIZE, CFE_VERSION_SIZE);
2511 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2520 + case BOARD_IOCTL_GET_ENET_CFG:
2521 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2522 + ETHERNET_MAC_INFO EnetInfos[BP_MAX_ENET_MACS];
2523 + if (BpGetEthernetMacInfo(EnetInfos, BP_MAX_ENET_MACS) == BP_SUCCESS) {
2524 + if (ctrlParms.strLen == sizeof(EnetInfos)) {
2525 + __copy_to_user(ctrlParms.string, EnetInfos, sizeof(EnetInfos));
2526 + ctrlParms.result = 0;
2527 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2541 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
2542 + case BOARD_IOCTL_GET_RESETHOLD:
2543 + ctrlParms.result = kerSysGetResetHold();
2544 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2547 +//>>JUNHON, 2004/09/15
2550 +#if defined (WIRELESS)
2551 + case BOARD_IOCTL_GET_WLAN_ANT_INUSE:
2552 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2553 + unsigned short antInUse = 0;
2554 + if (BpGetWirelessAntInUse(&antInUse) == BP_SUCCESS) {
2555 + if (ctrlParms.strLen == sizeof(antInUse)) {
2556 + __copy_to_user(ctrlParms.string, &antInUse, sizeof(antInUse));
2557 + ctrlParms.result = 0;
2558 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2573 + case BOARD_IOCTL_SET_TRIGGER_EVENT:
2574 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2575 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2576 + ctrlParms.result = -EFAULT;
2578 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2579 + board_ioc->eventmask |= *((int*)ctrlParms.string);
2580 +#if defined (WIRELESS)
2581 + if((board_ioc->eventmask & SES_EVENTS)) {
2582 + if(sesBtn_irq != BP_NOT_DEFINED) {
2583 + BcmHalInterruptEnable(sesBtn_irq);
2584 + ctrlParms.result = 0;
2589 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2598 + case BOARD_IOCTL_GET_TRIGGER_EVENT:
2599 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2600 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2601 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2602 + __copy_to_user(ctrlParms.string, &board_ioc->eventmask, sizeof(unsigned long));
2603 + ctrlParms.result = 0;
2604 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2616 + case BOARD_IOCTL_UNSET_TRIGGER_EVENT:
2617 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2618 + if (ctrlParms.strLen == sizeof(unsigned long)) {
2619 + BOARD_IOC *board_ioc = (BOARD_IOC *)flip->private_data;
2620 + board_ioc->eventmask &= (~(*((int*)ctrlParms.string)));
2621 + ctrlParms.result = 0;
2622 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2633 +#if defined (WIRELESS)
2634 + case BOARD_IOCTL_SET_SES_LED:
2635 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2636 + if (ctrlParms.strLen == sizeof(int)) {
2637 + sesLed_ctrl(*(int*)ctrlParms.string);
2638 + ctrlParms.result = 0;
2639 + __copy_to_user((BOARD_IOCTL_PARMS*)arg, &ctrlParms, sizeof(BOARD_IOCTL_PARMS));
2652 + case BOARD_IOCTL_SET_MONITOR_FD:
2653 + if (copy_from_user((void*)&ctrlParms, (void*)arg, sizeof(ctrlParms)) == 0) {
2654 + int fput_needed = 0;
2656 + g_monitor_file = fget_light( ctrlParms.offset, &fput_needed );
2657 + if( g_monitor_file ) {
2658 + /* Hook this file descriptor's poll function in order to set
2659 + * the exception descriptor when there is a change in link
2662 + g_monitor_task = current;
2663 + g_orig_fop_poll = kerSysMonitorPollHook;
2664 + /*g_orig_fop_poll = g_monitor_file->f_op->poll;
2665 + g_monitor_file->f_op->poll = kerSysMonitorPollHook;*/
2670 + case BOARD_IOCTL_WAKEUP_MONITOR_TASK:
2671 + kerSysWakeupMonitorTask();
2676 + ctrlParms.result = 0;
2677 + printk("board_ioctl: invalid command %x, cmd %d .\n",command,_IOC_NR(command));
2684 +} /* board_ioctl */
2686 +/***************************************************************************
2687 + * SES Button ISR/GPIO/LED functions.
2688 + ***************************************************************************/
2689 +#if defined (WIRELESS)
2690 +static irqreturn_t sesBtn_isr(int irq, void *dev_id, struct pt_regs *ptregs)
2692 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2693 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2694 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2696 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2697 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2698 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2700 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2701 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2702 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2704 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2706 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2707 + gpio_reg = &GPIO->GPIOio_high;
2711 + if (!(*gpio_reg & gpio_mask)){
2712 + wake_up_interruptible(&g_board_wait_queue);
2713 + return IRQ_RETVAL(1);
2715 + return IRQ_RETVAL(0);
2719 +static void __init sesBtn_mapGpio()
2721 + if( BpGetWirelessSesBtnGpio(&sesBtn_gpio) == BP_SUCCESS )
2723 + printk("SES: Button GPIO 0x%x is enabled\n", sesBtn_gpio);
2727 +static void __init sesBtn_mapIntr(int context)
2729 + if( BpGetWirelessSesExtIntr(&sesBtn_irq) == BP_SUCCESS )
2731 + printk("SES: Button Interrupt 0x%x is enabled\n", sesBtn_irq);
2736 + sesBtn_irq += INTERRUPT_ID_EXTERNAL_0;
2738 + if (BcmHalMapInterrupt((FN_HANDLER)sesBtn_isr, context, sesBtn_irq)) {
2739 + printk("SES: Interrupt mapping failed\n");
2741 + BcmHalInterruptEnable(sesBtn_irq);
2745 +static unsigned int sesBtn_poll(struct file *file, struct poll_table_struct *wait)
2747 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
2748 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2749 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2751 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
2752 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2753 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2755 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2756 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2757 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2759 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2761 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2762 + gpio_reg = &GPIO->GPIOio_high;
2766 + if (!(*gpio_reg & gpio_mask)){
2772 +static ssize_t sesBtn_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
2774 + volatile unsigned int event=0;
2777 +#if defined(_BCM96338_) || defined (CONFIG_BCM96338)
2778 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2779 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2781 +#if defined(_BCM96345_) || defined (CONFIG_BCM96345)
2782 + unsigned short gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2783 + volatile unsigned short *gpio_reg = &GPIO->GPIOio;
2785 +#if defined(_BCM96348_) || defined (CONFIG_BCM96348)
2786 + unsigned long gpio_mask = GPIO_NUM_TO_MASK(sesBtn_gpio);
2787 + volatile unsigned long *gpio_reg = &GPIO->GPIOio;
2789 + if( (sesBtn_gpio & ~BP_ACTIVE_MASK) >= 32 )
2791 + gpio_mask = GPIO_NUM_TO_MASK_HIGH(sesBtn_gpio);
2792 + gpio_reg = &GPIO->GPIOio_high;
2796 + if(*gpio_reg & gpio_mask){
2797 + BcmHalInterruptEnable(sesBtn_irq);
2800 + event = SES_EVENTS;
2801 + __copy_to_user((char*)buffer, (char*)&event, sizeof(event));
2802 + BcmHalInterruptEnable(sesBtn_irq);
2803 + count -= sizeof(event);
2804 + buffer += sizeof(event);
2805 + ret += sizeof(event);
2809 +static void __init sesLed_mapGpio()
2811 + if( BpGetWirelessSesBtnGpio(&sesLed_gpio) == BP_SUCCESS )
2813 + printk("SES: LED GPIO 0x%x is enabled\n", sesBtn_gpio);
2817 +static void sesLed_ctrl(int action)
2820 + //char status = ((action >> 8) & 0xff); /* extract status */
2821 + //char event = ((action >> 16) & 0xff); /* extract event */
2822 + //char blinktype = ((action >> 24) & 0xff); /* extract blink type for SES_LED_BLINK */
2824 + BOARD_LED_STATE led;
2826 + if(sesLed_gpio == BP_NOT_DEFINED)
2829 + action &= 0xff; /* extract led */
2831 + //printk("blinktype=%d, event=%d, status=%d\n",(int)blinktype, (int)event, (int)status);
2836 + //printk("SES: led on\n");
2837 + led = kLedStateOn;
2839 + case SES_LED_BLINK:
2840 + //printk("SES: led blink\n");
2841 + led = kLedStateSlowBlinkContinues;
2845 + //printk("SES: led off\n");
2846 + led = kLedStateOff;
2849 + kerSysLedCtrl(kLedSes, led);
2852 +static void __init ses_board_init()
2855 + sesBtn_mapIntr(0);
2858 +static void __exit ses_board_deinit()
2861 + BcmHalInterruptDisable(sesBtn_irq);
2865 +/***************************************************************************
2866 + * Dying gasp ISR and functions.
2867 + ***************************************************************************/
2868 +#define KERSYS_DBG printk
2870 +#if defined(CONFIG_BCM96345)
2871 +#define CYCLE_PER_US 70
2872 +#elif defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)
2873 +/* The BCM6348 cycles per microsecond is really variable since the BCM6348
2874 + * MIPS speed can vary depending on the PLL settings. However, an appoximate
2875 + * value of 120 will still work OK for the test being done.
2877 +#define CYCLE_PER_US 120
2879 +#define DG_GLITCH_TO (100*CYCLE_PER_US)
2881 +static void __init kerSysDyingGaspMapIntr()
2883 + unsigned long ulIntr;
2885 +#if defined(CONFIG_BCM96348) || defined(_BCM96348_) || defined(CONFIG_BCM96338) || defined(_BCM96338_)
2886 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2887 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, INTERRUPT_ID_DG);
2888 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2890 +#elif defined(CONFIG_BCM96345) || defined(_BCM96345_)
2891 + if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) {
2892 + ulIntr += INTERRUPT_ID_EXTERNAL_0;
2893 + BcmHalMapInterrupt((FN_HANDLER)kerSysDyingGaspIsr, 0, ulIntr);
2894 + BcmHalInterruptEnable( ulIntr );
2900 +void kerSysSetWdTimer(ulong timeUs)
2902 + TIMER->WatchDogDefCount = timeUs * (FPERIPH/1000000);
2903 + TIMER->WatchDogCtl = 0xFF00;
2904 + TIMER->WatchDogCtl = 0x00FF;
2907 +ulong kerSysGetCycleCount(void)
2913 + __asm volatile("mfc0 %0, $9":"=d"(cnt));
2918 +static Bool kerSysDyingGaspCheckPowerLoss(void)
2924 + clk0 = kerSysGetCycleCount();
2930 +#if defined(CONFIG_BCM96345)
2931 + BpGetAdslDyingGaspExtIntr( &ulIntr );
2936 + clk1 = kerSysGetCycleCount(); /* time cleared */
2937 + /* wait a little to get new reading */
2938 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2940 + } while ((0 == (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT)))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2942 + if (PERF->ExtIrqCfg & (1 << (ulIntr + EI_STATUS_SHFT))) { /* power glitch */
2943 + BcmHalInterruptEnable( ulIntr + INTERRUPT_ID_EXTERNAL_0);
2944 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2947 +#elif (defined(CONFIG_BCM96348) || defined(CONFIG_BCM96338)) && !defined(VXWORKS)
2951 + clk1 = kerSysGetCycleCount(); /* time cleared */
2952 + /* wait a little to get new reading */
2953 + while ((kerSysGetCycleCount()-clk1) < CYCLE_PER_US*2)
2955 + } while ((PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET))) && ((kerSysGetCycleCount() - clk0) < DG_GLITCH_TO));
2957 + if (!(PERF->IrqStatus & (1 << (INTERRUPT_ID_DG - INTERNAL_ISR_TABLE_OFFSET)))) {
2958 + BcmHalInterruptEnable( INTERRUPT_ID_DG );
2959 + KERSYS_DBG(" - Power glitch detected. Duration: %ld us\n", (kerSysGetCycleCount() - clk0)/CYCLE_PER_US);
2966 +static void kerSysDyingGaspShutdown( void )
2968 + kerSysSetWdTimer(1000000);
2969 +#if defined(CONFIG_BCM96345)
2970 + PERF->blkEnables &= ~(EMAC_CLK_EN | USB_CLK_EN | CPU_CLK_EN);
2971 +#elif defined(CONFIG_BCM96348)
2972 + PERF->blkEnables &= ~(EMAC_CLK_EN | USBS_CLK_EN | USBH_CLK_EN | SAR_CLK_EN);
2976 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
2977 +static irqreturn_t kerSysDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs)
2979 +static unsigned int kerSysDyingGaspIsr(void)
2982 + struct list_head *pos;
2983 + CB_DGASP_LIST *tmp, *dsl = NULL;
2985 + if (kerSysDyingGaspCheckPowerLoss()) {
2987 + /* first to turn off everything other than dsl */
2988 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
2989 + tmp = list_entry(pos, CB_DGASP_LIST, list);
2990 + if(strncmp(tmp->name, "dsl", 3)) {
2991 + (tmp->cb_dgasp_fn)(tmp->context);
2997 + /* now send dgasp */
2999 + (dsl->cb_dgasp_fn)(dsl->context);
3001 + /* reset and shutdown system */
3002 + kerSysDyingGaspShutdown();
3004 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
3005 +return( IRQ_HANDLED );
3011 +static void __init kerSysInitDyingGaspHandler( void )
3013 + CB_DGASP_LIST *new_node;
3015 + if( g_cb_dgasp_list_head != NULL) {
3016 + printk("Error: kerSysInitDyingGaspHandler: list head is not null\n");
3019 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
3020 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
3021 + INIT_LIST_HEAD(&new_node->list);
3022 + g_cb_dgasp_list_head = new_node;
3024 +} /* kerSysInitDyingGaspHandler */
3026 +static void __exit kerSysDeinitDyingGaspHandler( void )
3028 + struct list_head *pos;
3029 + CB_DGASP_LIST *tmp;
3031 + if(g_cb_dgasp_list_head == NULL)
3034 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
3035 + tmp = list_entry(pos, CB_DGASP_LIST, list);
3040 + kfree(g_cb_dgasp_list_head);
3041 + g_cb_dgasp_list_head = NULL;
3043 +} /* kerSysDeinitDyingGaspHandler */
3045 +void kerSysRegisterDyingGaspHandler(char *devname, void *cbfn, void *context)
3047 + CB_DGASP_LIST *new_node;
3049 + if( g_cb_dgasp_list_head == NULL) {
3050 + printk("Error: kerSysRegisterDyingGaspHandler: list head is null\n");
3054 + if( devname == NULL || cbfn == NULL ) {
3055 + printk("Error: kerSysRegisterDyingGaspHandler: register info not enough (%s,%x,%x)\n", devname, (unsigned int)cbfn, (unsigned int)context);
3059 + new_node= (CB_DGASP_LIST *)kmalloc(sizeof(CB_DGASP_LIST), GFP_KERNEL);
3060 + memset(new_node, 0x00, sizeof(CB_DGASP_LIST));
3061 + INIT_LIST_HEAD(&new_node->list);
3062 + strncpy(new_node->name, devname, IFNAMSIZ);
3063 + new_node->cb_dgasp_fn = (cb_dgasp_t)cbfn;
3064 + new_node->context = context;
3065 + list_add(&new_node->list, &g_cb_dgasp_list_head->list);
3067 + printk("dgasp: kerSysRegisterDyingGaspHandler: %s registered \n", devname);
3069 +} /* kerSysRegisterDyingGaspHandler */
3071 +void kerSysDeregisterDyingGaspHandler(char *devname)
3073 + struct list_head *pos;
3074 + CB_DGASP_LIST *tmp;
3076 + if(g_cb_dgasp_list_head == NULL) {
3077 + printk("Error: kerSysDeregisterDyingGaspHandler: list head is null\n");
3081 + if(devname == NULL) {
3082 + printk("Error: kerSysDeregisterDyingGaspHandler: devname is null\n");
3086 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistering\n", devname);
3088 + list_for_each(pos, &g_cb_dgasp_list_head->list) {
3089 + tmp = list_entry(pos, CB_DGASP_LIST, list);
3090 + if(!strcmp(tmp->name, devname)) {
3093 + printk("kerSysDeregisterDyingGaspHandler: %s is deregistered\n", devname);
3097 + printk("kerSysDeregisterDyingGaspHandler: %s not (de)registered\n", devname);
3099 +} /* kerSysDeregisterDyingGaspHandler */
3101 +/***************************************************************************
3102 + * MACRO to call driver initialization and cleanup functions.
3103 + ***************************************************************************/
3104 +module_init( brcm_board_init );
3105 +module_exit( brcm_board_cleanup );
3107 +EXPORT_SYMBOL(kerSysNvRamGet);
3108 +EXPORT_SYMBOL(dumpaddr);
3109 +EXPORT_SYMBOL(kerSysGetMacAddress);
3110 +EXPORT_SYMBOL(kerSysReleaseMacAddress);
3111 +EXPORT_SYMBOL(kerSysGetSdramSize);
3112 +EXPORT_SYMBOL(kerSysLedCtrl);
3113 +//<<JUNHON, 2004/09/15, get reset button status , tim hou , 05/04/12
3114 +EXPORT_SYMBOL(kerSysGetResetHold);
3115 +//>>JUNHON, 2004/09/15
3116 +EXPORT_SYMBOL(kerSysLedRegisterHwHandler);
3117 +EXPORT_SYMBOL(BpGetBoardIds);
3118 +EXPORT_SYMBOL(BpGetSdramSize);
3119 +EXPORT_SYMBOL(BpGetPsiSize);
3120 +EXPORT_SYMBOL(BpGetEthernetMacInfo);
3121 +EXPORT_SYMBOL(BpGetRj11InnerOuterPairGpios);
3122 +EXPORT_SYMBOL(BpGetPressAndHoldResetGpio);
3123 +EXPORT_SYMBOL(BpGetVoipResetGpio);
3124 +EXPORT_SYMBOL(BpGetVoipIntrGpio);
3125 +EXPORT_SYMBOL(BpGetPcmciaResetGpio);
3126 +EXPORT_SYMBOL(BpGetRtsCtsUartGpios);
3127 +EXPORT_SYMBOL(BpGetAdslLedGpio);
3128 +EXPORT_SYMBOL(BpGetAdslFailLedGpio);
3129 +EXPORT_SYMBOL(BpGetWirelessLedGpio);
3130 +EXPORT_SYMBOL(BpGetUsbLedGpio);
3131 +EXPORT_SYMBOL(BpGetHpnaLedGpio);
3132 +EXPORT_SYMBOL(BpGetWanDataLedGpio);
3133 +EXPORT_SYMBOL(BpGetPppLedGpio);
3134 +EXPORT_SYMBOL(BpGetPppFailLedGpio);
3135 +EXPORT_SYMBOL(BpGetVoipLedGpio);
3136 +EXPORT_SYMBOL(BpGetWirelessExtIntr);
3137 +EXPORT_SYMBOL(BpGetAdslDyingGaspExtIntr);
3138 +EXPORT_SYMBOL(BpGetVoipExtIntr);
3139 +EXPORT_SYMBOL(BpGetHpnaExtIntr);
3140 +EXPORT_SYMBOL(BpGetHpnaChipSelect);
3141 +EXPORT_SYMBOL(BpGetVoipChipSelect);
3142 +EXPORT_SYMBOL(BpGetWirelessSesBtnGpio);
3143 +EXPORT_SYMBOL(BpGetWirelessSesExtIntr);
3144 +EXPORT_SYMBOL(BpGetWirelessSesLedGpio);
3145 +EXPORT_SYMBOL(kerSysRegisterDyingGaspHandler);
3146 +EXPORT_SYMBOL(kerSysDeregisterDyingGaspHandler);
3147 +EXPORT_SYMBOL(kerSysGetCycleCount);
3148 +EXPORT_SYMBOL(kerSysSetWdTimer);
3149 +EXPORT_SYMBOL(kerSysWakeupMonitorTask);
3151 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c
3152 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.c 1970-01-01 01:00:00.000000000 +0100
3153 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.c 2006-08-03 16:36:58.000000000 +0200
3158 + Copyright 2003 Broadcom Corp. All Rights Reserved.
3160 + This program is free software; you can distribute it and/or modify it
3161 + under the terms of the GNU General Public License (Version 2) as
3162 + published by the Free Software Foundation.
3164 + This program is distributed in the hope it will be useful, but WITHOUT
3165 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3166 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3169 + You should have received a copy of the GNU General Public License along
3170 + with this program; if not, write to the Free Software Foundation, Inc.,
3171 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
3175 +/**************************************************************************
3176 + * File Name : boardparms.c
3178 + * Description: This file contains the implementation for the BCM63xx board
3179 + * parameter access functions.
3181 + * Updates : 07/14/2003 Created.
3182 + ***************************************************************************/
3185 +#include "boardparms.h"
3189 +/* Default psi size in K bytes */
3190 +#define BP_PSI_DEFAULT_SIZE 24
3193 +typedef struct boardparameters
3195 + char szBoardId[BP_BOARD_ID_LEN]; /* board id string */
3196 + ETHERNET_MAC_INFO EnetMacInfos[BP_MAX_ENET_MACS];
3197 + VOIP_DSP_INFO VoIPDspInfo[BP_MAX_VOIP_DSP];
3198 + unsigned short usSdramSize; /* SDRAM size and type */
3199 + unsigned short usPsiSize; /* persistent storage in K bytes */
3200 + unsigned short usGpioRj11InnerPair; /* GPIO pin or not defined */
3201 + unsigned short usGpioRj11OuterPair; /* GPIO pin or not defined */
3202 + unsigned short usGpioPressAndHoldReset; /* GPIO pin or not defined */
3203 + unsigned short usGpioPcmciaReset; /* GPIO pin or not defined */
3204 + unsigned short usGpioUartRts; /* GPIO pin or not defined */
3205 + unsigned short usGpioUartCts; /* GPIO pin or not defined */
3206 + unsigned short usGpioLedAdsl; /* GPIO pin or not defined */
3207 + unsigned short usGpioLedAdslFail; /* GPIO pin or not defined */
3208 + unsigned short usGpioLedWireless; /* GPIO pin or not defined */
3209 + unsigned short usGpioLedUsb; /* GPIO pin or not defined */
3210 + unsigned short usGpioLedHpna; /* GPIO pin or not defined */
3211 + unsigned short usGpioLedWanData; /* GPIO pin or not defined */
3212 + unsigned short usGpioLedPpp; /* GPIO pin or not defined */
3213 + unsigned short usGpioLedPppFail; /* GPIO pin or not defined */
3214 + unsigned short usGpioLedBlPowerOn; /* GPIO pin or not defined */
3215 + unsigned short usGpioLedBlAlarm; /* GPIO pin or not defined */
3216 + unsigned short usGpioLedBlResetCfg; /* GPIO pin or not defined */
3217 + unsigned short usGpioLedBlStop; /* GPIO pin or not defined */
3218 + unsigned short usExtIntrWireless; /* ext intr or not defined */
3219 + unsigned short usExtIntrAdslDyingGasp; /* ext intr or not defined */
3220 + unsigned short usExtIntrHpna; /* ext intr or not defined */
3221 + unsigned short usCsHpna; /* chip select not defined */
3222 + unsigned short usAntInUseWireless; /* antenna in use or not defined */
3223 + unsigned short usGpioSesBtnWireless; /* GPIO pin or not defined */
3224 + unsigned short usExtIntrSesBtnWireless; /* ext intr or not defined */
3225 + unsigned short usGpioLedSesWireless; /* GPIO pin or not defined */
3226 +} BOARD_PARAMETERS, *PBOARD_PARAMETERS;
3229 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
3230 +static BOARD_PARAMETERS g_bcm96338sv =
3232 + "96338SV", /* szBoardId */
3233 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3234 + 0x01, /* ucPhyAddress */
3235 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3236 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3237 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3238 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3239 + BP_NOT_DEFINED, /* usGpioPhyReset */
3240 + 0x01, /* numSwitchPorts */
3241 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3242 + BP_NOT_DEFINED}, /* usReverseMii */
3243 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3244 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3245 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3246 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3247 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3248 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3249 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3250 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3251 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3252 + BP_NOT_DEFINED, /* usGpioUartRts */
3253 + BP_NOT_DEFINED, /* usGpioUartCts */
3254 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3255 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3256 + BP_NOT_DEFINED, /* usGpioLedWireless */
3257 + BP_NOT_DEFINED, /* usGpioLedUsb */
3258 + BP_NOT_DEFINED, /* usGpioLedHpna */
3259 + BP_NOT_DEFINED, /* usGpioLedWanData */
3260 + BP_NOT_DEFINED, /* usGpioLedPpp */
3261 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3262 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3263 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3264 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3265 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3266 + BP_NOT_DEFINED, /* usExtIntrWireless */
3267 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3268 + BP_NOT_DEFINED, /* usExtIntrHpna */
3269 + BP_NOT_DEFINED, /* usCsHpna */
3270 + BP_NOT_DEFINED, /* usAntInUseWireless */
3271 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3272 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3273 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3275 +static BOARD_PARAMETERS g_bcm96338l2m8m =
3277 + "96338L-2M-8M", /* szBoardId */
3278 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3279 + 0x01, /* ucPhyAddress */
3280 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3281 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3282 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3283 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3284 + BP_NOT_DEFINED, /* usGpioPhyReset */
3285 + 0x01, /* numSwitchPorts */
3286 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3287 + BP_NOT_DEFINED}, /* usReverseMii */
3288 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3289 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3290 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3291 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3292 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3293 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3294 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3295 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3296 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3297 + BP_NOT_DEFINED, /* usGpioUartRts */
3298 + BP_NOT_DEFINED, /* usGpioUartCts */
3299 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3300 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3301 + BP_NOT_DEFINED, /* usGpioLedWireless */
3302 + BP_NOT_DEFINED, /* usGpioLedUsb */
3303 + BP_NOT_DEFINED, /* usGpioLedHpna */
3304 + BP_GPIO_3_AL, /* usGpioLedWanData */
3305 + BP_GPIO_3_AL, /* usGpioLedPpp */
3306 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3307 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3308 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3309 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3310 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3311 + BP_NOT_DEFINED, /* usExtIntrWireless */
3312 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3313 + BP_NOT_DEFINED, /* usExtIntrHpna */
3314 + BP_NOT_DEFINED, /* usCsHpna */
3315 + BP_NOT_DEFINED, /* usAntInUseWireless */
3316 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3317 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3318 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3320 +static PBOARD_PARAMETERS g_BoardParms[] =
3321 + {&g_bcm96338sv, &g_bcm96338l2m8m, 0};
3324 +#if defined(_BCM96345_) || defined(CONFIG_BCM96345)
3325 +static BOARD_PARAMETERS g_bcm96345r =
3327 + "96345R", /* szBoardId */
3328 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3329 + 0x01, /* ucPhyAddress */
3330 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3331 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3332 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3333 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3334 + BP_NOT_DEFINED, /* usGpioPhyReset */
3335 + 0x01, /* numSwitchPorts */
3336 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3337 + BP_NOT_DEFINED}, /* usReverseMii */
3338 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3339 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3340 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3341 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3342 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3343 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3344 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3345 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3346 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3347 + BP_NOT_DEFINED, /* usGpioUartRts */
3348 + BP_NOT_DEFINED, /* usGpioUartCts */
3349 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3350 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3351 + BP_NOT_DEFINED, /* usGpioLedWireless */
3352 + BP_NOT_DEFINED, /* usGpioLedUsb */
3353 + BP_NOT_DEFINED, /* usGpioLedHpna */
3354 + BP_GPIO_8_AH, /* usGpioLedWanData */
3355 + BP_GPIO_9_AH, /* usGpioLedPpp */
3356 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3357 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3358 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3359 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3360 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3361 + BP_NOT_DEFINED, /* usExtIntrWireless */
3362 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3363 + BP_NOT_DEFINED, /* usExtIntrHpna */
3364 + BP_NOT_DEFINED, /* usCsHpna */
3365 + BP_NOT_DEFINED, /* usAntInUseWireless */
3366 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3367 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3368 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3371 +static BOARD_PARAMETERS g_bcm96345gw2 =
3373 + /* A hardware jumper determines whether GPIO 13 is used for Press and Hold
3376 + "96345GW2", /* szBoardId */
3377 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3378 + 0x00, /* ucPhyAddress */
3379 + BP_GPIO_0_AH, /* usGpioPhySpiSck */
3380 + BP_GPIO_4_AH, /* usGpioPhySpiSs */
3381 + BP_GPIO_12_AH, /* usGpioPhySpiMosi */
3382 + BP_GPIO_11_AH, /* usGpioPhySpiMiso */
3383 + BP_NOT_DEFINED, /* usGpioPhyReset */
3384 + 0x04, /* numSwitchPorts */
3385 + BP_ENET_CONFIG_GPIO, /* usConfigType */
3386 + BP_ENET_REVERSE_MII}, /* usReverseMii */
3387 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3388 + {{BP_VOIP_DSP, /* ucDspType */
3389 + 0x00, /* ucDspAddress */
3390 + BP_EXT_INTR_1, /* usExtIntrVoip */
3391 + BP_GPIO_6_AH, /* usGpioVoipReset */
3392 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3393 + BP_NOT_DEFINED, /* usGpioLedVoip */
3394 + BP_CS_2}, /* usCsVoip */
3395 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3396 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3397 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3398 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3399 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3400 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3401 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3402 + BP_GPIO_13_AH, /* usGpioUartRts */
3403 + BP_GPIO_9_AH, /* usGpioUartCts */
3404 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3405 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3406 + BP_NOT_DEFINED, /* usGpioLedWireless */
3407 + BP_GPIO_7_AH, /* usGpioLedUsb */
3408 + BP_NOT_DEFINED, /* usGpioLedHpna */
3409 + BP_GPIO_8_AH, /* usGpioLedWanData */
3410 + BP_NOT_DEFINED, /* usGpioLedPpp */
3411 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3412 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3413 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3414 + BP_GPIO_7_AH, /* usGpioLedBlResetCfg */
3415 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3416 + BP_EXT_INTR_2, /* usExtIntrWireless */
3417 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3418 + BP_NOT_DEFINED, /* usExtIntrHpna */
3419 + BP_NOT_DEFINED, /* usCsHpna */
3420 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3421 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3422 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3423 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3426 +static BOARD_PARAMETERS g_bcm96345gw =
3428 + "96345GW", /* szBoardId */
3429 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3430 + 0x00, /* ucPhyAddress */
3431 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3432 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3433 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3434 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3435 + BP_NOT_DEFINED, /* usGpioPhyReset */
3436 + 0x04, /* numSwitchPorts */
3437 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3438 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3439 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3440 + {{BP_VOIP_DSP, /* ucDspType */
3441 + 0x00, /* ucDspAddress */
3442 + BP_EXT_INTR_1, /* usExtIntrVoip */
3443 + BP_GPIO_6_AH, /* usGpioVoipReset */
3444 + BP_GPIO_15_AH, /* usGpioVoipIntr */
3445 + BP_NOT_DEFINED, /* usGpioLedVoip */
3446 + BP_CS_2}, /* usCsVoip */
3447 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3448 + BP_MEMORY_16MB_1_CHIP, /* usSdramSize */
3449 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3450 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3451 + BP_GPIO_1_AH, /* usGpioRj11OuterPair */
3452 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3453 + BP_GPIO_2_AH, /* usGpioPcmciaReset */
3454 + BP_NOT_DEFINED, /* usGpioUartRts */
3455 + BP_NOT_DEFINED, /* usGpioUartCts */
3456 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3457 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3458 + BP_GPIO_10_AH, /* usGpioLedWireless */
3459 + BP_GPIO_7_AH, /* usGpioLedUsb */
3460 + BP_NOT_DEFINED, /* usGpioLedHpna */
3461 + BP_GPIO_8_AH, /* usGpioLedWanData */
3462 + BP_NOT_DEFINED, /* usGpioLedPpp */
3463 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3464 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3465 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3466 + BP_GPIO_10_AH, /* usGpioLedBlResetCfg */
3467 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3468 + BP_EXT_INTR_2, /* usExtIntrWireless */
3469 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3470 + BP_EXT_INTR_3, /* usExtIntrHpna */
3471 + BP_CS_1, /* usCsHpna */
3472 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3473 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3474 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3475 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3478 +static BOARD_PARAMETERS g_bcm96335r =
3480 + "96335R", /* szBoardId */
3481 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3482 + 0x01, /* ucPhyAddress */
3483 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3484 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3485 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3486 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3487 + BP_NOT_DEFINED, /* usGpioPhyReset */
3488 + 0x01, /* numSwitchPorts */
3489 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3490 + BP_NOT_DEFINED}, /* usReverseMii */
3491 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3492 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3493 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3494 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3495 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3496 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3497 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3498 + BP_GPIO_14_AH, /* usGpioPressAndHoldReset */
3499 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3500 + BP_NOT_DEFINED, /* usGpioUartRts */
3501 + BP_NOT_DEFINED, /* usGpioUartCts */
3502 + BP_GPIO_9_AH, /* usGpioLedAdsl */
3503 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3504 + BP_NOT_DEFINED, /* usGpioLedWireless */
3505 + BP_NOT_DEFINED, /* usGpioLedUsb */
3506 + BP_NOT_DEFINED, /* usGpioLedHpna */
3507 + BP_GPIO_9_AH, /* usGpioLedWanData */
3508 + BP_GPIO_8_AH, /* usGpioLedPpp */
3509 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3510 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3511 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3512 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3513 + BP_GPIO_9_AH, /* usGpioLedBlStop */
3514 + BP_NOT_DEFINED, /* usExtIntrWireless */
3515 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3516 + BP_NOT_DEFINED, /* usExtIntrHpna */
3517 + BP_NOT_DEFINED, /* usCsHpna */
3518 + BP_NOT_DEFINED, /* usAntInUseWireless */
3519 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3520 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3521 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3524 +static BOARD_PARAMETERS g_bcm96345r0 =
3526 + "96345R0", /* szBoardId */
3527 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3528 + 0x01, /* ucPhyAddress */
3529 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3530 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3531 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3532 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3533 + BP_NOT_DEFINED, /* usGpioPhyReset */
3534 + 0x01, /* numSwitchPorts */
3535 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3536 + BP_NOT_DEFINED}, /* usReverseMii */
3537 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3538 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3539 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3540 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3541 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3542 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3543 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3544 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3545 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3546 + BP_NOT_DEFINED, /* usGpioUartRts */
3547 + BP_NOT_DEFINED, /* usGpioUartCts */
3548 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3549 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3550 + BP_NOT_DEFINED, /* usGpioLedWireless */
3551 + BP_NOT_DEFINED, /* usGpioLedUsb */
3552 + BP_NOT_DEFINED, /* usGpioLedHpna */
3553 + BP_GPIO_9_AH, /* usGpioLedWanData */
3554 + BP_GPIO_9_AH, /* usGpioLedPpp */
3555 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3556 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3557 + BP_GPIO_9_AH, /* usGpioLedBlAlarm */
3558 + BP_GPIO_8_AH, /* usGpioLedBlResetCfg */
3559 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3560 + BP_NOT_DEFINED, /* usExtIntrWireless */
3561 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3562 + BP_NOT_DEFINED, /* usExtIntrHpna */
3563 + BP_NOT_DEFINED, /* usCsHpna */
3564 + BP_NOT_DEFINED, /* usAntInUseWireless */
3565 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3566 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3567 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3570 +static BOARD_PARAMETERS g_bcm96345rs =
3572 + "96345RS", /* szBoardId */
3573 + {{BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3574 + 0x00, /* ucPhyAddress */
3575 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3576 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3577 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3578 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3579 + BP_NOT_DEFINED, /* usGpioPhyReset */
3580 + 0x01, /* numSwitchPorts */
3581 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3582 + BP_ENET_NO_REVERSE_MII}, /* usReverseMii */
3583 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3584 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3585 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3586 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3587 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3588 + BP_GPIO_11_AH, /* usGpioRj11InnerPair */
3589 + BP_GPIO_12_AH, /* usGpioRj11OuterPair */
3590 + BP_GPIO_13_AH, /* usGpioPressAndHoldReset */
3591 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3592 + BP_NOT_DEFINED, /* usGpioUartRts */
3593 + BP_NOT_DEFINED, /* usGpioUartCts */
3594 + BP_GPIO_8_AH, /* usGpioLedAdsl */
3595 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3596 + BP_NOT_DEFINED, /* usGpioLedWireless */
3597 + BP_NOT_DEFINED, /* usGpioLedUsb */
3598 + BP_NOT_DEFINED, /* usGpioLedHpna */
3599 + BP_GPIO_8_AH, /* usGpioLedWanData */
3600 + BP_GPIO_9_AH, /* usGpioLedPpp */
3601 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3602 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3603 + BP_GPIO_10_AH, /* usGpioLedBlAlarm */
3604 + BP_GPIO_9_AH, /* usGpioLedBlResetCfg */
3605 + BP_GPIO_8_AH, /* usGpioLedBlStop */
3606 + BP_NOT_DEFINED, /* usExtIntrWireless */
3607 + BP_EXT_INTR_0, /* usExtIntrAdslDyingGasp */
3608 + BP_NOT_DEFINED, /* usExtIntrHpna */
3609 + BP_NOT_DEFINED, /* usCsHpna */
3610 + BP_NOT_DEFINED, /* usAntInUseWireless */
3611 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3612 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3613 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3616 +static PBOARD_PARAMETERS g_BoardParms[] =
3617 + {&g_bcm96345r, &g_bcm96345gw2, &g_bcm96345gw, &g_bcm96335r, &g_bcm96345r0,
3618 + &g_bcm96345rs, 0};
3621 +#if defined(_BCM96348_) || defined(CONFIG_BCM96348)
3623 +static BOARD_PARAMETERS g_bcm96348r =
3625 + "96348R", /* szBoardId */
3626 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3627 + 0x01, /* ucPhyAddress */
3628 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3629 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3630 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3631 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3632 + BP_NOT_DEFINED, /* usGpioPhyReset */
3633 + 0x01, /* numSwitchPorts */
3634 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3635 + BP_NOT_DEFINED}, /* usReverseMii */
3636 + {BP_ENET_NO_PHY}}, /* ucPhyType */
3637 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3638 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3639 + BP_MEMORY_8MB_1_CHIP, /* usSdramSize */
3640 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3641 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3642 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3643 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3644 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3645 + BP_NOT_DEFINED, /* usGpioUartRts */
3646 + BP_NOT_DEFINED, /* usGpioUartCts */
3647 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3648 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3649 + BP_NOT_DEFINED, /* usGpioLedWireless */
3650 + BP_NOT_DEFINED, /* usGpioLedUsb */
3651 + BP_NOT_DEFINED, /* usGpioLedHpna */
3652 + BP_GPIO_3_AL, /* usGpioLedWanData */
3653 + BP_GPIO_3_AL, /* usGpioLedPpp */
3654 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3655 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3656 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3657 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3658 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3659 + BP_NOT_DEFINED, /* usExtIntrWireless */
3660 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3661 + BP_NOT_DEFINED, /* usExtIntrHpna */
3662 + BP_NOT_DEFINED, /* usCsHpna */
3663 + BP_NOT_DEFINED, /* usAntInUseWireless */
3664 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3665 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3666 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3669 +static BOARD_PARAMETERS g_bcm96348lv =
3671 + "96348LV", /* szBoardId */
3672 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3673 + 0x01, /* ucPhyAddress */
3674 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3675 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3676 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3677 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3678 + BP_NOT_DEFINED, /* usGpioPhyReset */
3679 + 0x01, /* numSwitchPorts */
3680 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3681 + BP_NOT_DEFINED}, /* usReverseMii */
3682 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3683 + 0x02, /* ucPhyAddress */
3684 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3685 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3686 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3687 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3688 + BP_GPIO_5_AL, /* usGpioPhyReset */
3689 + 0x01, /* numSwitchPorts */
3690 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3691 + BP_NOT_DEFINED}}, /* usReverseMii */
3692 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3693 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3694 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3695 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3696 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3697 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3698 + BP_GPIO_7_AH, /* usGpioPressAndHoldReset */
3699 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3700 + BP_NOT_DEFINED, /* usGpioUartRts */
3701 + BP_NOT_DEFINED, /* usGpioUartCts */
3702 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3703 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3704 + BP_NOT_DEFINED, /* usGpioLedWireless */
3705 + BP_NOT_DEFINED, /* usGpioLedUsb */
3706 + BP_NOT_DEFINED, /* usGpioLedHpna */
3707 + BP_GPIO_3_AL, /* usGpioLedWanData */
3708 + BP_GPIO_3_AL, /* usGpioLedPpp */
3709 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3710 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3711 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3712 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3713 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3714 + BP_NOT_DEFINED, /* usExtIntrWireless */
3715 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
3716 + BP_NOT_DEFINED, /* usExtIntrHpna */
3717 + BP_NOT_DEFINED, /* usCsHpna */
3718 + BP_NOT_DEFINED, /* usAntInUseWireless */
3719 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3720 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3721 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3724 +static BOARD_PARAMETERS g_bcm96348gw =
3726 + "96348GW", /* szBoardId */
3727 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3728 + 0x01, /* ucPhyAddress */
3729 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3730 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3731 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3732 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3733 + BP_NOT_DEFINED, /* usGpioPhyReset */
3734 + 0x01, /* numSwitchPorts */
3735 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3736 + BP_NOT_DEFINED}, /* usReverseMii */
3737 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3738 + 0x00, /* ucPhyAddress */
3739 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3740 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3741 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3742 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3743 + BP_NOT_DEFINED, /* usGpioPhyReset */
3744 + 0x03, /* numSwitchPorts */
3745 + BP_ENET_CONFIG_SPI_SSB_0, /* usConfigType */
3746 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3747 + {{BP_VOIP_DSP, /* ucDspType */
3748 + 0x00, /* ucDspAddress */
3749 + BP_EXT_INTR_2, /* usExtIntrVoip */
3750 + BP_GPIO_6_AH, /* usGpioVoipReset */
3751 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3752 + BP_NOT_DEFINED, /* usGpioLedVoip */
3753 + BP_CS_2}, /* usCsVoip */
3754 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3755 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3756 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3757 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3758 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3759 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3760 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3761 + BP_NOT_DEFINED, /* usGpioUartRts */
3762 + BP_NOT_DEFINED, /* usGpioUartCts */
3763 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3764 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3765 + BP_NOT_DEFINED, /* usGpioLedWireless */
3766 + BP_NOT_DEFINED, /* usGpioLedUsb */
3767 + BP_NOT_DEFINED, /* usGpioLedHpna */
3768 + BP_GPIO_3_AL, /* usGpioLedWanData */
3769 + BP_GPIO_3_AL, /* usGpioLedPpp */
3770 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3771 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3772 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3773 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3774 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3775 + BP_NOT_DEFINED, /* usExtIntrWireless */
3776 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3777 + BP_NOT_DEFINED, /* usExtIntrHpna */
3778 + BP_NOT_DEFINED, /* usCsHpna */
3779 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3780 + BP_NOT_DEFINED, /* BP_GPIO_35_AH, */ /* usGpioSesBtnWireless */
3781 + BP_NOT_DEFINED, /* BP_EXT_INTR_3, */ /* usExtIntrSesBtnWireless */
3782 + BP_NOT_DEFINED /* BP_GPIO_0_AL */ /* usGpioLedSesWireless */
3786 +static BOARD_PARAMETERS g_bcm96348gw_10 =
3788 + "96348GW-10", /* szBoardId */
3789 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3790 + 0x01, /* ucPhyAddress */
3791 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3792 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3793 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3794 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3795 + BP_NOT_DEFINED, /* usGpioPhyReset */
3796 + 0x01, /* numSwitchPorts */
3797 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3798 + BP_NOT_DEFINED}, /* usReverseMii */
3799 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3800 + 0x00, /* ucPhyAddress */
3801 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3802 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3803 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3804 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3805 + BP_NOT_DEFINED, /* usGpioPhyReset */
3806 + 0x03, /* numSwitchPorts */
3807 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3808 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3809 + {{BP_VOIP_DSP, /* ucDspType */
3810 + 0x00, /* ucDspAddress */
3811 + BP_EXT_INTR_2, /* usExtIntrVoip */
3812 + BP_GPIO_6_AH, /* usGpioVoipReset */
3813 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3814 + BP_NOT_DEFINED, /* usGpioLedVoip */
3815 + BP_CS_2}, /* usCsVoip */
3816 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3817 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3818 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3819 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3820 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3821 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3822 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3823 + BP_NOT_DEFINED, /* usGpioUartRts */
3824 + BP_NOT_DEFINED, /* usGpioUartCts */
3825 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3826 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3827 + BP_NOT_DEFINED, /* usGpioLedWireless */
3828 + BP_NOT_DEFINED, /* usGpioLedUsb */
3829 + BP_NOT_DEFINED, /* usGpioLedHpna */
3830 + BP_GPIO_3_AL, /* usGpioLedWanData */
3831 + BP_GPIO_3_AL, /* usGpioLedPpp */
3832 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3833 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3834 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3835 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3836 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3837 + BP_NOT_DEFINED, /* usExtIntrWireless */
3838 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3839 + BP_NOT_DEFINED, /* usExtIntrHpna */
3840 + BP_NOT_DEFINED, /* usCsHpna */
3841 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
3842 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3843 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3844 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3847 +static BOARD_PARAMETERS g_bcm96348gw_11 =
3849 + "96348GW-11", /* szBoardId */
3850 + {{BP_ENET_NO_PHY}, /* ucPhyType */
3851 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3852 + 0x00, /* ucPhyAddress */
3853 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3854 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3855 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3856 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3857 + BP_NOT_DEFINED, /* usGpioPhyReset */
3858 + 0x04, /* numSwitchPorts */
3859 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3860 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3861 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3862 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3863 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3864 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3865 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3866 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3867 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3868 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3869 + BP_NOT_DEFINED, /* usGpioUartRts */
3870 + BP_NOT_DEFINED, /* usGpioUartCts */
3871 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3872 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3873 + BP_NOT_DEFINED, /* usGpioLedWireless */
3874 + BP_NOT_DEFINED, /* usGpioLedUsb */
3875 + BP_NOT_DEFINED, /* usGpioLedHpna */
3876 + BP_GPIO_3_AL, /* usGpioLedWanData */
3877 + BP_GPIO_3_AL, /* usGpioLedPpp */
3878 + BP_GPIO_4_AL, /* usGpioLedPppFail */
3879 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
3880 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3881 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
3882 + BP_GPIO_1_AL, /* usGpioLedBlStop */
3883 + BP_NOT_DEFINED, /* usExtIntrWireless */
3884 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3885 + BP_NOT_DEFINED, /* usExtIntrHpna */
3886 + BP_NOT_DEFINED, /* usCsHpna */
3887 + BP_NOT_DEFINED, /* usAntInUseWireless */
3888 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3889 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3890 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3893 +static BOARD_PARAMETERS g_bcm96348sv =
3895 + "96348SV", /* szBoardId */
3896 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3897 + 0x01, /* ucPhyAddress */
3898 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3899 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3900 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3901 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3902 + BP_NOT_DEFINED, /* usGpioPhyReset */
3903 + 0x01, /* numSwitchPorts */
3904 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3905 + BP_NOT_DEFINED}, /* usReverseMii */
3906 + {BP_ENET_EXTERNAL_PHY, /* ucPhyType */
3907 + 0x1f, /* ucPhyAddress */
3908 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3909 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3910 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3911 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3912 + BP_NOT_DEFINED, /* usGpioPhyReset */
3913 + 0x01, /* numSwitchPorts */
3914 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3915 + BP_NOT_DEFINED}}, /* usReverseMii */
3916 + {{BP_VOIP_NO_DSP}, /* ucDspType */
3917 + {BP_VOIP_NO_DSP}}, /* ucDspType */
3918 + BP_MEMORY_32MB_2_CHIP, /* usSdramSize */
3919 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3920 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3921 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3922 + BP_NOT_DEFINED, /* usGpioPressAndHoldReset */
3923 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3924 + BP_NOT_DEFINED, /* usGpioUartRts */
3925 + BP_NOT_DEFINED, /* usGpioUartCts */
3926 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3927 + BP_NOT_DEFINED, /* usGpioLedAdslFail */
3928 + BP_NOT_DEFINED, /* usGpioLedWireless */
3929 + BP_NOT_DEFINED, /* usGpioLedUsb */
3930 + BP_NOT_DEFINED, /* usGpioLedHpna */
3931 + BP_NOT_DEFINED, /* usGpioLedWanData */
3932 + BP_NOT_DEFINED, /* usGpioLedPpp */
3933 + BP_NOT_DEFINED, /* usGpioLedPppFail */
3934 + BP_NOT_DEFINED, /* usGpioLedBlPowerOn */
3935 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
3936 + BP_NOT_DEFINED, /* usGpioLedBlResetCfg */
3937 + BP_NOT_DEFINED, /* usGpioLedBlStop */
3938 + BP_NOT_DEFINED, /* usExtIntrWireless */
3939 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
3940 + BP_NOT_DEFINED, /* usExtIntrHpna */
3941 + BP_NOT_DEFINED, /* usCsHpna */
3942 + BP_NOT_DEFINED, /* usAntInUseWireless */
3943 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
3944 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
3945 + BP_NOT_DEFINED /* usGpioLedSesWireless */
3949 +static BOARD_PARAMETERS g_bcm96348gw_dualDsp =
3951 + "96348GW-DualDSP", /* szBoardId */
3952 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
3953 + 0x01, /* ucPhyAddress */
3954 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3955 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3956 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3957 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3958 + BP_NOT_DEFINED, /* usGpioPhyReset */
3959 + 0x01, /* numSwitchPorts */
3960 + BP_ENET_CONFIG_MDIO, /* usConfigType */
3961 + BP_NOT_DEFINED}, /* usReverseMii */
3962 + {BP_ENET_EXTERNAL_SWITCH, /* ucPhyType */
3963 + 0x00, /* ucPhyAddress */
3964 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
3965 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
3966 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
3967 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
3968 + BP_NOT_DEFINED, /* usGpioPhyReset */
3969 + 0x03, /* numSwitchPorts */
3970 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
3971 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
3972 + {{BP_VOIP_DSP, /* ucDspType */
3973 + 0x00, /* ucDspAddress */
3974 + BP_EXT_INTR_2, /* usExtIntrVoip */
3975 + BP_UNEQUIPPED, /* usGpioVoipReset */
3976 + BP_GPIO_34_AH, /* usGpioVoipIntr */
3977 + BP_NOT_DEFINED, /* usGpioLedVoip */
3978 + BP_CS_2}, /* usCsVoip */
3979 + {BP_VOIP_DSP, /* ucDspType */
3980 + 0x01, /* ucDspAddress */
3981 + BP_EXT_INTR_3, /* usExtIntrVoip */
3982 + BP_UNEQUIPPED , /* usGpioVoipReset */
3983 + BP_GPIO_35_AH, /* usGpioVoipIntr */
3984 + BP_NOT_DEFINED, /* usGpioLedVoip */
3985 + BP_CS_3}}, /* usCsVoip */
3986 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
3987 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
3988 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
3989 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
3990 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
3991 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
3992 + BP_NOT_DEFINED, /* usGpioUartRts */
3993 + BP_NOT_DEFINED, /* usGpioUartCts */
3994 + BP_NOT_DEFINED, /* usGpioLedAdsl */
3995 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
3996 + BP_NOT_DEFINED, /* usGpioLedWireless */
3997 + BP_NOT_DEFINED, /* usGpioLedUsb */
3998 + BP_NOT_DEFINED, /* usGpioLedHpna */
3999 + BP_GPIO_3_AL, /* usGpioLedWanData */
4000 + BP_GPIO_3_AL, /* usGpioLedPpp */
4001 + BP_GPIO_4_AL, /* usGpioLedPppFail */
4002 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
4003 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
4004 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
4005 + BP_GPIO_1_AL, /* usGpioLedBlStop */
4006 + BP_NOT_DEFINED, /* usExtIntrWireless */
4007 + BP_HW_DEFINED, /* usExtIntrAdslDyingGasp */
4008 + BP_NOT_DEFINED, /* usExtIntrHpna */
4009 + BP_NOT_DEFINED, /* usCsHpna */
4010 + BP_WLAN_ANT_MAIN, /* usAntInUseWireless */
4011 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
4012 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
4013 + BP_NOT_DEFINED /* usGpioLedSesWireless */
4017 +static BOARD_PARAMETERS g_bcmCustom_01 =
4019 + "BCMCUST_01", /* szBoardId */
4020 + {{BP_ENET_INTERNAL_PHY, /* ucPhyType */
4021 + 0x01, /* ucPhyAddress */
4022 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
4023 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
4024 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
4025 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
4026 + BP_NOT_DEFINED, /* usGpioPhyReset */
4027 + 0x01, /* numSwitchPorts */
4028 + BP_ENET_CONFIG_MDIO, /* usConfigType */
4029 + BP_NOT_DEFINED}, /* usReverseMii */
4030 + {BP_ENET_NO_PHY, /* ucPhyType */
4031 + 0x00, /* ucPhyAddress */
4032 + BP_NOT_DEFINED, /* usGpioPhySpiSck */
4033 + BP_NOT_DEFINED, /* usGpioPhySpiSs */
4034 + BP_NOT_DEFINED, /* usGpioPhySpiMosi */
4035 + BP_NOT_DEFINED, /* usGpioPhySpiMiso */
4036 + BP_NOT_DEFINED, /* usGpioPhyReset */
4037 + 0x01, /* numSwitchPorts */
4038 + BP_ENET_CONFIG_SPI_SSB_1, /* usConfigType */
4039 + BP_ENET_REVERSE_MII}}, /* usReverseMii */
4040 + {{BP_VOIP_DSP, /* ucDspType */
4041 + 0x00, /* ucDspAddress */
4042 + BP_EXT_INTR_2, /* usExtIntrVoip */
4043 + BP_GPIO_36_AH, /* usGpioVoipReset */
4044 + BP_GPIO_34_AL, /* usGpioVoipIntr */
4045 + BP_NOT_DEFINED, /* usGpioLedVoip */
4046 + BP_CS_2}, /* usCsVoip */
4047 + {BP_VOIP_NO_DSP}}, /* ucDspType */
4048 + BP_MEMORY_16MB_2_CHIP, /* usSdramSize */
4049 + BP_PSI_DEFAULT_SIZE, /* usPsiSize */
4050 + BP_NOT_DEFINED, /* usGpioRj11InnerPair */
4051 + BP_NOT_DEFINED, /* usGpioRj11OuterPair */
4052 + BP_GPIO_33_AL, /* usGpioPressAndHoldReset */
4053 + BP_NOT_DEFINED, /* usGpioPcmciaReset */
4054 + BP_NOT_DEFINED, /* usGpioUartRts */
4055 + BP_NOT_DEFINED, /* usGpioUartCts */
4056 + BP_NOT_DEFINED, /* usGpioLedAdsl */
4057 + BP_GPIO_2_AL, /* usGpioLedAdslFail */
4058 + BP_NOT_DEFINED, /* usGpioLedWireless */
4059 + BP_NOT_DEFINED, /* usGpioLedUsb */
4060 + BP_NOT_DEFINED, /* usGpioLedHpna */
4061 + BP_GPIO_3_AL, /* usGpioLedWanData */
4062 + BP_GPIO_3_AL, /* usGpioLedPpp */
4063 + BP_GPIO_4_AL, /* usGpioLedPppFail */
4064 + BP_GPIO_0_AL, /* usGpioLedBlPowerOn */
4065 + BP_NOT_DEFINED, /* usGpioLedBlAlarm */
4066 + BP_GPIO_3_AL, /* usGpioLedBlResetCfg */
4067 + BP_GPIO_1_AL, /* usGpioLedBlStop */
4068 + BP_NOT_DEFINED, /* usExtIntrWireless */
4069 + BP_NOT_DEFINED, /* usExtIntrAdslDyingGasp */
4070 + BP_NOT_DEFINED, /* usExtIntrHpna */
4071 + BP_NOT_DEFINED, /* usCsHpna */
4072 + BP_NOT_DEFINED, /* usAntInUseWireless */
4073 + BP_NOT_DEFINED, /* usGpioSesBtnWireless */
4074 + BP_NOT_DEFINED, /* usExtIntrSesBtnWireless */
4075 + BP_NOT_DEFINED /* usGpioLedSesWireless */
4078 +static PBOARD_PARAMETERS g_BoardParms[] =
4079 + {&g_bcm96348r, &g_bcm96348lv, &g_bcm96348gw, &g_bcm96348gw_10,
4080 + &g_bcm96348gw_11, &g_bcm96348sv, &g_bcm96348gw_dualDsp,
4081 + &g_bcmCustom_01, 0};
4084 +static PBOARD_PARAMETERS g_pCurrentBp = 0;
4086 +/**************************************************************************
4089 + * Description: String compare for this file so it does not depend on an OS.
4090 + * (Linux kernel and CFE share this source file.)
4092 + * Parameters : [IN] dest - destination string
4093 + * [IN] src - source string
4095 + * Returns : -1 - dest < src, 1 - dest > src, 0 dest == src
4096 + ***************************************************************************/
4097 +static int bpstrcmp(const char *dest,const char *src);
4098 +static int bpstrcmp(const char *dest,const char *src)
4100 + while (*src && *dest)
4102 + if (*dest < *src) return -1;
4103 + if (*dest > *src) return 1;
4108 + if (*dest && !*src) return 1;
4109 + if (!*dest && *src) return -1;
4113 +/**************************************************************************
4114 + * Name : BpGetVoipDspConfig
4116 + * Description: Gets the DSP configuration from the board parameter
4117 + * structure for a given DSP index.
4119 + * Parameters : [IN] dspNum - DSP index (number)
4121 + * Returns : Pointer to DSP configuration block if found/valid, NULL
4123 + ***************************************************************************/
4124 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum );
4125 +VOIP_DSP_INFO *BpGetVoipDspConfig( unsigned char dspNum )
4127 + VOIP_DSP_INFO *pDspConfig = 0;
4130 + if( g_pCurrentBp )
4132 + for( i = 0 ; i < BP_MAX_VOIP_DSP ; i++ )
4134 + if( g_pCurrentBp->VoIPDspInfo[i].ucDspType != BP_VOIP_NO_DSP &&
4135 + g_pCurrentBp->VoIPDspInfo[i].ucDspAddress == dspNum )
4137 + pDspConfig = &g_pCurrentBp->VoIPDspInfo[i];
4143 + return pDspConfig;
4147 +/**************************************************************************
4148 + * Name : BpSetBoardId
4150 + * Description: This function find the BOARD_PARAMETERS structure for the
4151 + * specified board id string and assigns it to a global, static
4154 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
4156 + * Returns : BP_SUCCESS - Success, value is returned.
4157 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
4158 + * have a board parameters configuration record.
4159 + ***************************************************************************/
4160 +int BpSetBoardId( char *pszBoardId )
4162 + int nRet = BP_BOARD_ID_NOT_FOUND;
4163 + PBOARD_PARAMETERS *ppBp;
4165 + for( ppBp = g_BoardParms; *ppBp; ppBp++ )
4167 + if( !bpstrcmp((*ppBp)->szBoardId, pszBoardId) )
4169 + g_pCurrentBp = *ppBp;
4170 + nRet = BP_SUCCESS;
4176 +} /* BpSetBoardId */
4178 +/**************************************************************************
4179 + * Name : BpGetBoardIds
4181 + * Description: This function returns all of the supported board id strings.
4183 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
4184 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
4186 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
4187 + * were allocated in pszBoardIds.
4189 + * Returns : Number of board id strings returned.
4190 + ***************************************************************************/
4191 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize )
4193 + PBOARD_PARAMETERS *ppBp;
4198 + for( i = 0, ppBp = g_BoardParms; *ppBp && nBoardIdsSize;
4199 + i++, ppBp++, nBoardIdsSize--, pszBoardIds += BP_BOARD_ID_LEN )
4201 + dest = pszBoardIds;
4202 + src = (*ppBp)->szBoardId;
4209 +} /* BpGetBoardIds */
4211 +/**************************************************************************
4212 + * Name : BpGetEthernetMacInfo
4214 + * Description: This function returns all of the supported board id strings.
4216 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
4218 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
4219 + * are pointed to by pEnetInfos.
4221 + * Returns : BP_SUCCESS - Success, value is returned.
4222 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4223 + ***************************************************************************/
4224 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos )
4228 + if( g_pCurrentBp )
4230 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4232 + if( i < BP_MAX_ENET_MACS )
4234 + unsigned char *src = (unsigned char *)
4235 + &g_pCurrentBp->EnetMacInfos[i];
4236 + unsigned char *dest = (unsigned char *) pEnetInfos;
4237 + int len = sizeof(ETHERNET_MAC_INFO);
4242 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4245 + nRet = BP_SUCCESS;
4249 + for( i = 0; i < nNumEnetInfos; i++, pEnetInfos++ )
4250 + pEnetInfos->ucPhyType = BP_ENET_NO_PHY;
4252 + nRet = BP_BOARD_ID_NOT_SET;
4256 +} /* BpGetEthernetMacInfo */
4258 +/**************************************************************************
4259 + * Name : BpGetSdramSize
4261 + * Description: This function returns a constant that describees the board's
4262 + * SDRAM type and size.
4264 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
4267 + * Returns : BP_SUCCESS - Success, value is returned.
4268 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4269 + ***************************************************************************/
4270 +int BpGetSdramSize( unsigned long *pulSdramSize )
4274 + if( g_pCurrentBp )
4276 + *pulSdramSize = g_pCurrentBp->usSdramSize;
4277 + nRet = BP_SUCCESS;
4281 + *pulSdramSize = BP_NOT_DEFINED;
4282 + nRet = BP_BOARD_ID_NOT_SET;
4286 +} /* BpGetSdramSize */
4288 +/**************************************************************************
4289 + * Name : BpGetPsiSize
4291 + * Description: This function returns the persistent storage size in K bytes.
4293 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
4294 + * storage size is returned in.
4296 + * Returns : BP_SUCCESS - Success, value is returned.
4297 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4298 + ***************************************************************************/
4299 +int BpGetPsiSize( unsigned long *pulPsiSize )
4303 + if( g_pCurrentBp )
4305 + *pulPsiSize = g_pCurrentBp->usPsiSize;
4306 + nRet = BP_SUCCESS;
4310 + *pulPsiSize = BP_NOT_DEFINED;
4311 + nRet = BP_BOARD_ID_NOT_SET;
4315 +} /* BpGetPsiSize */
4317 +/**************************************************************************
4318 + * Name : BpGetRj11InnerOuterPairGpios
4320 + * Description: This function returns the GPIO pin assignments for changing
4321 + * between the RJ11 inner pair and RJ11 outer pair.
4323 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
4324 + * GPIO pin is returned in.
4325 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
4326 + * GPIO pin is returned in.
4328 + * Returns : BP_SUCCESS - Success, values are returned.
4329 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4330 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4332 + ***************************************************************************/
4333 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
4334 + unsigned short *pusOuter )
4338 + if( g_pCurrentBp )
4340 + *pusInner = g_pCurrentBp->usGpioRj11InnerPair;
4341 + *pusOuter = g_pCurrentBp->usGpioRj11OuterPair;
4343 + if( g_pCurrentBp->usGpioRj11InnerPair != BP_NOT_DEFINED &&
4344 + g_pCurrentBp->usGpioRj11OuterPair != BP_NOT_DEFINED )
4346 + nRet = BP_SUCCESS;
4350 + nRet = BP_VALUE_NOT_DEFINED;
4355 + *pusInner = *pusOuter = BP_NOT_DEFINED;
4356 + nRet = BP_BOARD_ID_NOT_SET;
4360 +} /* BpGetRj11InnerOuterPairGpios */
4362 +/**************************************************************************
4363 + * Name : BpGetPressAndHoldResetGpio
4365 + * Description: This function returns the GPIO pin assignment for the press
4366 + * and hold reset button.
4368 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
4369 + * reset button GPIO pin is returned in.
4371 + * Returns : BP_SUCCESS - Success, value is returned.
4372 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4373 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4375 + ***************************************************************************/
4376 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue )
4380 + if( g_pCurrentBp )
4382 + *pusValue = g_pCurrentBp->usGpioPressAndHoldReset;
4384 + if( g_pCurrentBp->usGpioPressAndHoldReset != BP_NOT_DEFINED )
4386 + nRet = BP_SUCCESS;
4390 + nRet = BP_VALUE_NOT_DEFINED;
4395 + *pusValue = BP_NOT_DEFINED;
4396 + nRet = BP_BOARD_ID_NOT_SET;
4400 +} /* BpGetPressAndHoldResetGpio */
4402 +/**************************************************************************
4403 + * Name : BpGetVoipResetGpio
4405 + * Description: This function returns the GPIO pin assignment for the VOIP
4406 + * Reset operation.
4408 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
4409 + * GPIO pin is returned in.
4410 + * [IN] dspNum - Address of the DSP to query.
4412 + * Returns : BP_SUCCESS - Success, value is returned.
4413 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4414 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4416 + ***************************************************************************/
4417 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue )
4421 + if( g_pCurrentBp )
4423 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4427 + *pusValue = pDspInfo->usGpioVoipReset;
4429 + if( *pusValue != BP_NOT_DEFINED ||
4430 + *pusValue == BP_UNEQUIPPED )
4432 + nRet = BP_SUCCESS;
4436 + nRet = BP_VALUE_NOT_DEFINED;
4441 + *pusValue = BP_NOT_DEFINED;
4442 + nRet = BP_BOARD_ID_NOT_FOUND;
4447 + *pusValue = BP_NOT_DEFINED;
4448 + nRet = BP_BOARD_ID_NOT_SET;
4452 +} /* BpGetVoipResetGpio */
4454 +/**************************************************************************
4455 + * Name : BpGetVoipIntrGpio
4457 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
4459 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
4460 + * GPIO pin is returned in.
4461 + * [IN] dspNum - Address of the DSP to query.
4463 + * Returns : BP_SUCCESS - Success, value is returned.
4464 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4465 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4467 + ***************************************************************************/
4468 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue )
4472 + if( g_pCurrentBp )
4474 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
4478 + *pusValue = pDspInfo->usGpioVoipIntr;
4480 + if( *pusValue != BP_NOT_DEFINED )
4482 + nRet = BP_SUCCESS;
4486 + nRet = BP_VALUE_NOT_DEFINED;
4491 + *pusValue = BP_NOT_DEFINED;
4492 + nRet = BP_BOARD_ID_NOT_FOUND;
4497 + *pusValue = BP_NOT_DEFINED;
4498 + nRet = BP_BOARD_ID_NOT_SET;
4502 +} /* BpGetVoipIntrGpio */
4504 +/**************************************************************************
4505 + * Name : BpGetPcmciaResetGpio
4507 + * Description: This function returns the GPIO pin assignment for the PCMCIA
4508 + * Reset operation.
4510 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
4511 + * GPIO pin is returned in.
4513 + * Returns : BP_SUCCESS - Success, value is returned.
4514 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4515 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4517 + ***************************************************************************/
4518 +int BpGetPcmciaResetGpio( unsigned short *pusValue )
4522 + if( g_pCurrentBp )
4524 + *pusValue = g_pCurrentBp->usGpioPcmciaReset;
4526 + if( g_pCurrentBp->usGpioPcmciaReset != BP_NOT_DEFINED )
4528 + nRet = BP_SUCCESS;
4532 + nRet = BP_VALUE_NOT_DEFINED;
4537 + *pusValue = BP_NOT_DEFINED;
4538 + nRet = BP_BOARD_ID_NOT_SET;
4542 +} /* BpGetPcmciaResetGpio */
4544 +/**************************************************************************
4545 + * Name : BpGetUartRtsCtsGpios
4547 + * Description: This function returns the GPIO pin assignments for RTS and CTS
4550 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
4551 + * pin is returned in.
4552 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
4553 + * pin is returned in.
4555 + * Returns : BP_SUCCESS - Success, values are returned.
4556 + * BP_BOARD_ID_NOT_SET - Error, board id input string does not
4557 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4559 + ***************************************************************************/
4560 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts )
4564 + if( g_pCurrentBp )
4566 + *pusRts = g_pCurrentBp->usGpioUartRts;
4567 + *pusCts = g_pCurrentBp->usGpioUartCts;
4569 + if( g_pCurrentBp->usGpioUartRts != BP_NOT_DEFINED &&
4570 + g_pCurrentBp->usGpioUartCts != BP_NOT_DEFINED )
4572 + nRet = BP_SUCCESS;
4576 + nRet = BP_VALUE_NOT_DEFINED;
4581 + *pusRts = *pusCts = BP_NOT_DEFINED;
4582 + nRet = BP_BOARD_ID_NOT_SET;
4586 +} /* BpGetUartRtsCtsGpios */
4588 +/**************************************************************************
4589 + * Name : BpGetAdslLedGpio
4591 + * Description: This function returns the GPIO pin assignment for the ADSL
4594 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4595 + * GPIO pin is returned in.
4597 + * Returns : BP_SUCCESS - Success, value is returned.
4598 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4599 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4601 + ***************************************************************************/
4602 +int BpGetAdslLedGpio( unsigned short *pusValue )
4606 + if( g_pCurrentBp )
4608 + *pusValue = g_pCurrentBp->usGpioLedAdsl;
4610 + if( g_pCurrentBp->usGpioLedAdsl != BP_NOT_DEFINED )
4612 + nRet = BP_SUCCESS;
4616 + nRet = BP_VALUE_NOT_DEFINED;
4621 + *pusValue = BP_NOT_DEFINED;
4622 + nRet = BP_BOARD_ID_NOT_SET;
4626 +} /* BpGetAdslLedGpio */
4628 +/**************************************************************************
4629 + * Name : BpGetAdslFailLedGpio
4631 + * Description: This function returns the GPIO pin assignment for the ADSL
4632 + * LED that is used when there is a DSL connection failure.
4634 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
4635 + * GPIO pin is returned in.
4637 + * Returns : BP_SUCCESS - Success, value is returned.
4638 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4639 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4641 + ***************************************************************************/
4642 +int BpGetAdslFailLedGpio( unsigned short *pusValue )
4646 + if( g_pCurrentBp )
4648 + *pusValue = g_pCurrentBp->usGpioLedAdslFail;
4650 + if( g_pCurrentBp->usGpioLedAdslFail != BP_NOT_DEFINED )
4652 + nRet = BP_SUCCESS;
4656 + nRet = BP_VALUE_NOT_DEFINED;
4661 + *pusValue = BP_NOT_DEFINED;
4662 + nRet = BP_BOARD_ID_NOT_SET;
4666 +} /* BpGetAdslFailLedGpio */
4668 +/**************************************************************************
4669 + * Name : BpGetWirelessLedGpio
4671 + * Description: This function returns the GPIO pin assignment for the Wireless
4674 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4675 + * GPIO pin is returned in.
4677 + * Returns : BP_SUCCESS - Success, value is returned.
4678 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4679 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4681 + ***************************************************************************/
4682 +int BpGetWirelessLedGpio( unsigned short *pusValue )
4686 + if( g_pCurrentBp )
4688 + *pusValue = g_pCurrentBp->usGpioLedWireless;
4690 + if( g_pCurrentBp->usGpioLedWireless != BP_NOT_DEFINED )
4692 + nRet = BP_SUCCESS;
4696 + nRet = BP_VALUE_NOT_DEFINED;
4701 + *pusValue = BP_NOT_DEFINED;
4702 + nRet = BP_BOARD_ID_NOT_SET;
4706 +} /* BpGetWirelessLedGpio */
4708 +/**************************************************************************
4709 + * Name : BpGetWirelessAntInUse
4711 + * Description: This function returns the antennas in use for wireless
4713 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
4716 + * Returns : BP_SUCCESS - Success, value is returned.
4717 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4718 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4720 + ***************************************************************************/
4721 +int BpGetWirelessAntInUse( unsigned short *pusValue )
4725 + if( g_pCurrentBp )
4727 + *pusValue = g_pCurrentBp->usAntInUseWireless;
4729 + if( g_pCurrentBp->usAntInUseWireless != BP_NOT_DEFINED )
4731 + nRet = BP_SUCCESS;
4735 + nRet = BP_VALUE_NOT_DEFINED;
4740 + *pusValue = BP_NOT_DEFINED;
4741 + nRet = BP_BOARD_ID_NOT_SET;
4745 +} /* BpGetWirelessAntInUse */
4747 +/**************************************************************************
4748 + * Name : BpGetWirelessSesBtnGpio
4750 + * Description: This function returns the GPIO pin assignment for the Wireless
4753 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
4754 + * GPIO pin is returned in.
4756 + * Returns : BP_SUCCESS - Success, value is returned.
4757 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4758 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4760 + ***************************************************************************/
4761 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue )
4765 + if( g_pCurrentBp )
4767 + *pusValue = g_pCurrentBp->usGpioSesBtnWireless;
4769 + if( g_pCurrentBp->usGpioSesBtnWireless != BP_NOT_DEFINED )
4771 + nRet = BP_SUCCESS;
4775 + nRet = BP_VALUE_NOT_DEFINED;
4780 + *pusValue = BP_NOT_DEFINED;
4781 + nRet = BP_BOARD_ID_NOT_SET;
4785 +} /* BpGetWirelessSesBtnGpio */
4787 +/**************************************************************************
4788 + * Name : BpGetWirelessSesExtIntr
4790 + * Description: This function returns the external interrupt number for the
4791 + * Wireless Ses Button.
4793 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4794 + * external interrup is returned in.
4796 + * Returns : BP_SUCCESS - Success, value is returned.
4797 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4798 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4800 + ***************************************************************************/
4801 +int BpGetWirelessSesExtIntr( unsigned short *pusValue )
4805 + if( g_pCurrentBp )
4807 + *pusValue = g_pCurrentBp->usExtIntrSesBtnWireless;
4809 + if( g_pCurrentBp->usExtIntrSesBtnWireless != BP_NOT_DEFINED )
4811 + nRet = BP_SUCCESS;
4815 + nRet = BP_VALUE_NOT_DEFINED;
4820 + *pusValue = BP_NOT_DEFINED;
4821 + nRet = BP_BOARD_ID_NOT_SET;
4826 +} /* BpGetWirelessSesExtIntr */
4828 +/**************************************************************************
4829 + * Name : BpGetWirelessSesLedGpio
4831 + * Description: This function returns the GPIO pin assignment for the Wireless
4834 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
4835 + * Led GPIO pin is returned in.
4837 + * Returns : BP_SUCCESS - Success, value is returned.
4838 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4839 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4841 + ***************************************************************************/
4842 +int BpGetWirelessSesLedGpio( unsigned short *pusValue )
4846 + if( g_pCurrentBp )
4848 + *pusValue = g_pCurrentBp->usGpioLedSesWireless;
4850 + if( g_pCurrentBp->usGpioLedSesWireless != BP_NOT_DEFINED )
4852 + nRet = BP_SUCCESS;
4856 + nRet = BP_VALUE_NOT_DEFINED;
4861 + *pusValue = BP_NOT_DEFINED;
4862 + nRet = BP_BOARD_ID_NOT_SET;
4867 +} /* BpGetWirelessSesLedGpio */
4869 +/**************************************************************************
4870 + * Name : BpGetUsbLedGpio
4872 + * Description: This function returns the GPIO pin assignment for the USB
4875 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
4876 + * GPIO pin is returned in.
4878 + * Returns : BP_SUCCESS - Success, value is returned.
4879 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4880 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4882 + ***************************************************************************/
4883 +int BpGetUsbLedGpio( unsigned short *pusValue )
4887 + if( g_pCurrentBp )
4889 + *pusValue = g_pCurrentBp->usGpioLedUsb;
4891 + if( g_pCurrentBp->usGpioLedUsb != BP_NOT_DEFINED )
4893 + nRet = BP_SUCCESS;
4897 + nRet = BP_VALUE_NOT_DEFINED;
4902 + *pusValue = BP_NOT_DEFINED;
4903 + nRet = BP_BOARD_ID_NOT_SET;
4907 +} /* BpGetUsbLedGpio */
4909 +/**************************************************************************
4910 + * Name : BpGetHpnaLedGpio
4912 + * Description: This function returns the GPIO pin assignment for the HPNA
4915 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
4916 + * GPIO pin is returned in.
4918 + * Returns : BP_SUCCESS - Success, value is returned.
4919 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4920 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4922 + ***************************************************************************/
4923 +int BpGetHpnaLedGpio( unsigned short *pusValue )
4927 + if( g_pCurrentBp )
4929 + *pusValue = g_pCurrentBp->usGpioLedHpna;
4931 + if( g_pCurrentBp->usGpioLedHpna != BP_NOT_DEFINED )
4933 + nRet = BP_SUCCESS;
4937 + nRet = BP_VALUE_NOT_DEFINED;
4942 + *pusValue = BP_NOT_DEFINED;
4943 + nRet = BP_BOARD_ID_NOT_SET;
4947 +} /* BpGetHpnaLedGpio */
4949 +/**************************************************************************
4950 + * Name : BpGetWanDataLedGpio
4952 + * Description: This function returns the GPIO pin assignment for the WAN Data
4955 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
4956 + * GPIO pin is returned in.
4958 + * Returns : BP_SUCCESS - Success, value is returned.
4959 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
4960 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
4962 + ***************************************************************************/
4963 +int BpGetWanDataLedGpio( unsigned short *pusValue )
4967 + if( g_pCurrentBp )
4969 + *pusValue = g_pCurrentBp->usGpioLedWanData;
4971 + if( g_pCurrentBp->usGpioLedWanData != BP_NOT_DEFINED )
4973 + nRet = BP_SUCCESS;
4977 + nRet = BP_VALUE_NOT_DEFINED;
4982 + *pusValue = BP_NOT_DEFINED;
4983 + nRet = BP_BOARD_ID_NOT_SET;
4987 +} /* BpGetWanDataLedGpio */
4989 +/**************************************************************************
4990 + * Name : BpGetPppLedGpio
4992 + * Description: This function returns the GPIO pin assignment for the PPP
4995 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
4996 + * GPIO pin is returned in.
4998 + * Returns : BP_SUCCESS - Success, value is returned.
4999 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5000 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5002 + ***************************************************************************/
5003 +int BpGetPppLedGpio( unsigned short *pusValue )
5007 + if( g_pCurrentBp )
5009 + *pusValue = g_pCurrentBp->usGpioLedPpp;
5011 + if( g_pCurrentBp->usGpioLedPpp != BP_NOT_DEFINED )
5013 + nRet = BP_SUCCESS;
5017 + nRet = BP_VALUE_NOT_DEFINED;
5022 + *pusValue = BP_NOT_DEFINED;
5023 + nRet = BP_BOARD_ID_NOT_SET;
5027 +} /* BpGetPppLedGpio */
5029 +/**************************************************************************
5030 + * Name : BpGetPppFailLedGpio
5032 + * Description: This function returns the GPIO pin assignment for the PPP
5033 + * LED that is used when there is a PPP connection failure.
5035 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
5036 + * GPIO pin is returned in.
5038 + * Returns : BP_SUCCESS - Success, value is returned.
5039 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5040 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5042 + ***************************************************************************/
5043 +int BpGetPppFailLedGpio( unsigned short *pusValue )
5047 + if( g_pCurrentBp )
5049 + *pusValue = g_pCurrentBp->usGpioLedPppFail;
5051 + if( g_pCurrentBp->usGpioLedPppFail != BP_NOT_DEFINED )
5053 + nRet = BP_SUCCESS;
5057 + nRet = BP_VALUE_NOT_DEFINED;
5062 + *pusValue = BP_NOT_DEFINED;
5063 + nRet = BP_BOARD_ID_NOT_SET;
5067 +} /* BpGetPppFailLedGpio */
5069 +/**************************************************************************
5070 + * Name : BpGetBootloaderPowerOnLedGpio
5072 + * Description: This function returns the GPIO pin assignment for the power
5073 + * on LED that is set by the bootloader.
5075 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5076 + * GPIO pin is returned in.
5078 + * Returns : BP_SUCCESS - Success, value is returned.
5079 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5080 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5082 + ***************************************************************************/
5083 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue )
5087 + if( g_pCurrentBp )
5089 + *pusValue = g_pCurrentBp->usGpioLedBlPowerOn;
5091 + if( g_pCurrentBp->usGpioLedBlPowerOn != BP_NOT_DEFINED )
5093 + nRet = BP_SUCCESS;
5097 + nRet = BP_VALUE_NOT_DEFINED;
5102 + *pusValue = BP_NOT_DEFINED;
5103 + nRet = BP_BOARD_ID_NOT_SET;
5107 +} /* BpGetBootloaderPowerOn */
5109 +/**************************************************************************
5110 + * Name : BpGetBootloaderAlarmLedGpio
5112 + * Description: This function returns the GPIO pin assignment for the alarm
5113 + * LED that is set by the bootloader.
5115 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
5116 + * GPIO pin is returned in.
5118 + * Returns : BP_SUCCESS - Success, value is returned.
5119 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5120 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5122 + ***************************************************************************/
5123 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue )
5127 + if( g_pCurrentBp )
5129 + *pusValue = g_pCurrentBp->usGpioLedBlAlarm;
5131 + if( g_pCurrentBp->usGpioLedBlAlarm != BP_NOT_DEFINED )
5133 + nRet = BP_SUCCESS;
5137 + nRet = BP_VALUE_NOT_DEFINED;
5142 + *pusValue = BP_NOT_DEFINED;
5143 + nRet = BP_BOARD_ID_NOT_SET;
5147 +} /* BpGetBootloaderAlarmLedGpio */
5149 +/**************************************************************************
5150 + * Name : BpGetBootloaderResetCfgLedGpio
5152 + * Description: This function returns the GPIO pin assignment for the reset
5153 + * configuration LED that is set by the bootloader.
5155 + * Parameters : [OUT] pusValue - Address of short word that the reset
5156 + * configuration LED GPIO pin is returned in.
5158 + * Returns : BP_SUCCESS - Success, value is returned.
5159 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5160 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5162 + ***************************************************************************/
5163 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue )
5167 + if( g_pCurrentBp )
5169 + *pusValue = g_pCurrentBp->usGpioLedBlResetCfg;
5171 + if( g_pCurrentBp->usGpioLedBlResetCfg != BP_NOT_DEFINED )
5173 + nRet = BP_SUCCESS;
5177 + nRet = BP_VALUE_NOT_DEFINED;
5182 + *pusValue = BP_NOT_DEFINED;
5183 + nRet = BP_BOARD_ID_NOT_SET;
5187 +} /* BpGetBootloaderResetCfgLedGpio */
5189 +/**************************************************************************
5190 + * Name : BpGetBootloaderStopLedGpio
5192 + * Description: This function returns the GPIO pin assignment for the break
5193 + * into bootloader LED that is set by the bootloader.
5195 + * Parameters : [OUT] pusValue - Address of short word that the break into
5196 + * bootloader LED GPIO pin is returned in.
5198 + * Returns : BP_SUCCESS - Success, value is returned.
5199 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5200 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5202 + ***************************************************************************/
5203 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue )
5207 + if( g_pCurrentBp )
5209 + *pusValue = g_pCurrentBp->usGpioLedBlStop;
5211 + if( g_pCurrentBp->usGpioLedBlStop != BP_NOT_DEFINED )
5213 + nRet = BP_SUCCESS;
5217 + nRet = BP_VALUE_NOT_DEFINED;
5222 + *pusValue = BP_NOT_DEFINED;
5223 + nRet = BP_BOARD_ID_NOT_SET;
5227 +} /* BpGetBootloaderStopLedGpio */
5229 +/**************************************************************************
5230 + * Name : BpGetVoipLedGpio
5232 + * Description: This function returns the GPIO pin assignment for the VOIP
5235 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
5236 + * GPIO pin is returned in.
5238 + * Returns : BP_SUCCESS - Success, value is returned.
5239 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5240 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5243 + * Note : The VoIP structure would allow for having one LED per DSP
5244 + * however, the board initialization function assumes only one
5245 + * LED per functionality (ie one LED for VoIP). Therefore in
5246 + * order to keep this tidy and simple we do not make usage of the
5247 + * one-LED-per-DSP function. Instead, we assume that the LED for
5248 + * VoIP is unique and associated with DSP 0 (always present on
5249 + * any VoIP platform). If changing this to a LED-per-DSP function
5250 + * then one need to update the board initialization driver in
5251 + * bcmdrivers\opensource\char\board\bcm963xx\impl1
5252 + ***************************************************************************/
5253 +int BpGetVoipLedGpio( unsigned short *pusValue )
5257 + if( g_pCurrentBp )
5259 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( 0 );
5263 + *pusValue = pDspInfo->usGpioLedVoip;
5265 + if( *pusValue != BP_NOT_DEFINED )
5267 + nRet = BP_SUCCESS;
5271 + nRet = BP_VALUE_NOT_DEFINED;
5276 + *pusValue = BP_NOT_DEFINED;
5277 + nRet = BP_BOARD_ID_NOT_FOUND;
5282 + *pusValue = BP_NOT_DEFINED;
5283 + nRet = BP_BOARD_ID_NOT_SET;
5287 +} /* BpGetVoipLedGpio */
5289 +/**************************************************************************
5290 + * Name : BpGetWirelessExtIntr
5292 + * Description: This function returns the Wireless external interrupt number.
5294 + * Parameters : [OUT] pulValue - Address of short word that the wireless
5295 + * external interrupt number is returned in.
5297 + * Returns : BP_SUCCESS - Success, value is returned.
5298 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5299 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5301 + ***************************************************************************/
5302 +int BpGetWirelessExtIntr( unsigned long *pulValue )
5306 + if( g_pCurrentBp )
5308 + *pulValue = g_pCurrentBp->usExtIntrWireless;
5310 + if( g_pCurrentBp->usExtIntrWireless != BP_NOT_DEFINED )
5312 + nRet = BP_SUCCESS;
5316 + nRet = BP_VALUE_NOT_DEFINED;
5321 + *pulValue = BP_NOT_DEFINED;
5322 + nRet = BP_BOARD_ID_NOT_SET;
5326 +} /* BpGetWirelessExtIntr */
5328 +/**************************************************************************
5329 + * Name : BpGetAdslDyingGaspExtIntr
5331 + * Description: This function returns the ADSL Dying Gasp external interrupt
5334 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
5335 + * external interrupt number is returned in.
5337 + * Returns : BP_SUCCESS - Success, value is returned.
5338 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5339 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5341 + ***************************************************************************/
5342 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue )
5346 + if( g_pCurrentBp )
5348 + *pulValue = g_pCurrentBp->usExtIntrAdslDyingGasp;
5350 + if( g_pCurrentBp->usExtIntrAdslDyingGasp != BP_NOT_DEFINED )
5352 + nRet = BP_SUCCESS;
5356 + nRet = BP_VALUE_NOT_DEFINED;
5361 + *pulValue = BP_NOT_DEFINED;
5362 + nRet = BP_BOARD_ID_NOT_SET;
5366 +} /* BpGetAdslDyingGaspExtIntr */
5368 +/**************************************************************************
5369 + * Name : BpGetVoipExtIntr
5371 + * Description: This function returns the VOIP external interrupt number.
5373 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5374 + * external interrupt number is returned in.
5375 + * [IN] dspNum - Address of the DSP to query.
5377 + * Returns : BP_SUCCESS - Success, value is returned.
5378 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5379 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5381 + ***************************************************************************/
5382 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue )
5386 + if( g_pCurrentBp )
5388 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5392 + *pulValue = pDspInfo->usExtIntrVoip;
5394 + if( *pulValue != BP_NOT_DEFINED )
5396 + nRet = BP_SUCCESS;
5400 + nRet = BP_VALUE_NOT_DEFINED;
5405 + *pulValue = BP_NOT_DEFINED;
5406 + nRet = BP_BOARD_ID_NOT_FOUND;
5411 + *pulValue = BP_NOT_DEFINED;
5412 + nRet = BP_BOARD_ID_NOT_SET;
5416 +} /* BpGetVoipExtIntr */
5418 +/**************************************************************************
5419 + * Name : BpGetHpnaExtIntr
5421 + * Description: This function returns the HPNA external interrupt number.
5423 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5424 + * external interrupt number is returned in.
5426 + * Returns : BP_SUCCESS - Success, value is returned.
5427 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5428 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5430 + ***************************************************************************/
5431 +int BpGetHpnaExtIntr( unsigned long *pulValue )
5435 + if( g_pCurrentBp )
5437 + *pulValue = g_pCurrentBp->usExtIntrHpna;
5439 + if( g_pCurrentBp->usExtIntrHpna != BP_NOT_DEFINED )
5441 + nRet = BP_SUCCESS;
5445 + nRet = BP_VALUE_NOT_DEFINED;
5450 + *pulValue = BP_NOT_DEFINED;
5451 + nRet = BP_BOARD_ID_NOT_SET;
5455 +} /* BpGetHpnaExtIntr */
5457 +/**************************************************************************
5458 + * Name : BpGetHpnaChipSelect
5460 + * Description: This function returns the HPNA chip select number.
5462 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
5463 + * chip select number is returned in.
5465 + * Returns : BP_SUCCESS - Success, value is returned.
5466 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5467 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5469 + ***************************************************************************/
5470 +int BpGetHpnaChipSelect( unsigned long *pulValue )
5474 + if( g_pCurrentBp )
5476 + *pulValue = g_pCurrentBp->usCsHpna;
5478 + if( g_pCurrentBp->usCsHpna != BP_NOT_DEFINED )
5480 + nRet = BP_SUCCESS;
5484 + nRet = BP_VALUE_NOT_DEFINED;
5489 + *pulValue = BP_NOT_DEFINED;
5490 + nRet = BP_BOARD_ID_NOT_SET;
5494 +} /* BpGetHpnaChipSelect */
5496 +/**************************************************************************
5497 + * Name : BpGetVoipChipSelect
5499 + * Description: This function returns the VOIP chip select number.
5501 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
5502 + * chip select number is returned in.
5503 + * [IN] dspNum - Address of the DSP to query.
5505 + * Returns : BP_SUCCESS - Success, value is returned.
5506 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5507 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5509 + ***************************************************************************/
5510 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue )
5514 + if( g_pCurrentBp )
5516 + VOIP_DSP_INFO *pDspInfo = BpGetVoipDspConfig( dspNum );
5520 + *pulValue = pDspInfo->usCsVoip;
5522 + if( *pulValue != BP_NOT_DEFINED )
5524 + nRet = BP_SUCCESS;
5528 + nRet = BP_VALUE_NOT_DEFINED;
5533 + *pulValue = BP_NOT_DEFINED;
5534 + nRet = BP_BOARD_ID_NOT_FOUND;
5539 + *pulValue = BP_NOT_DEFINED;
5540 + nRet = BP_BOARD_ID_NOT_SET;
5544 +} /* BpGetVoipChipSelect */
5546 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h
5547 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/boardparms.h 1970-01-01 01:00:00.000000000 +0100
5548 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/boardparms.h 2006-08-03 16:36:58.000000000 +0200
5553 + Copyright 2003 Broadcom Corp. All Rights Reserved.
5555 + This program is free software; you can distribute it and/or modify it
5556 + under the terms of the GNU General Public License (Version 2) as
5557 + published by the Free Software Foundation.
5559 + This program is distributed in the hope it will be useful, but WITHOUT
5560 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5561 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5564 + You should have received a copy of the GNU General Public License along
5565 + with this program; if not, write to the Free Software Foundation, Inc.,
5566 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
5570 +/**************************************************************************
5571 + * File Name : boardparms.h
5573 + * Description: This file contains definitions and function prototypes for
5574 + * the BCM63xx board parameter access functions.
5576 + * Updates : 07/14/2003 Created.
5577 + ***************************************************************************/
5579 +#if !defined(_BOARDPARMS_H)
5580 +#define _BOARDPARMS_H
5582 +/* Return codes. */
5583 +#define BP_SUCCESS 0
5584 +#define BP_BOARD_ID_NOT_FOUND 1
5585 +#define BP_VALUE_NOT_DEFINED 2
5586 +#define BP_BOARD_ID_NOT_SET 3
5588 +/* Values for BpGetSdramSize. */
5589 +#define BP_MEMORY_8MB_1_CHIP 0
5590 +#define BP_MEMORY_16MB_1_CHIP 1
5591 +#define BP_MEMORY_32MB_1_CHIP 2
5592 +#define BP_MEMORY_64MB_2_CHIP 3
5593 +#define BP_MEMORY_32MB_2_CHIP 4
5594 +#define BP_MEMORY_16MB_2_CHIP 5
5596 +/* Values for EthernetMacInfo PhyType. */
5597 +#define BP_ENET_NO_PHY 0
5598 +#define BP_ENET_INTERNAL_PHY 1
5599 +#define BP_ENET_EXTERNAL_PHY 2
5600 +#define BP_ENET_EXTERNAL_SWITCH 3
5602 +/* Values for EthernetMacInfo Configuration type. */
5603 +#define BP_ENET_CONFIG_MDIO 0 /* Internal PHY, External PHY, Switch+(no GPIO, no SPI, no MDIO Pseudo phy */
5604 +#define BP_ENET_CONFIG_GPIO 1 /* Bcm96345GW board + Bcm5325M/E */
5605 +#define BP_ENET_CONFIG_MDIO_PSEUDO_PHY 2 /* Bcm96348GW board + Bcm5325E */
5606 +#define BP_ENET_CONFIG_SPI_SSB_0 3 /* Bcm96348GW board + Bcm5325M/E */
5607 +#define BP_ENET_CONFIG_SPI_SSB_1 4 /* Bcm96348GW board + Bcm5325M/E */
5608 +#define BP_ENET_CONFIG_SPI_SSB_2 5 /* Bcm96348GW board + Bcm5325M/E */
5609 +#define BP_ENET_CONFIG_SPI_SSB_3 6 /* Bcm96348GW board + Bcm5325M/E */
5611 +/* Values for EthernetMacInfo Reverse MII. */
5612 +#define BP_ENET_NO_REVERSE_MII 0
5613 +#define BP_ENET_REVERSE_MII 1
5615 +/* Values for VoIPDSPInfo DSPType. */
5616 +#define BP_VOIP_NO_DSP 0
5617 +#define BP_VOIP_DSP 1
5620 +/* Values for GPIO pin assignments (AH = Active High, AL = Active Low). */
5621 +#define BP_ACTIVE_MASK 0x8000
5622 +#define BP_ACTIVE_HIGH 0x0000
5623 +#define BP_ACTIVE_LOW 0x8000
5624 +#define BP_GPIO_0_AH (0 | BP_ACTIVE_HIGH)
5625 +#define BP_GPIO_0_AL (0 | BP_ACTIVE_LOW)
5626 +#define BP_GPIO_1_AH (1 | BP_ACTIVE_HIGH)
5627 +#define BP_GPIO_1_AL (1 | BP_ACTIVE_LOW)
5628 +#define BP_GPIO_2_AH (2 | BP_ACTIVE_HIGH)
5629 +#define BP_GPIO_2_AL (2 | BP_ACTIVE_LOW)
5630 +#define BP_GPIO_3_AH (3 | BP_ACTIVE_HIGH)
5631 +#define BP_GPIO_3_AL (3 | BP_ACTIVE_LOW)
5632 +#define BP_GPIO_4_AH (4 | BP_ACTIVE_HIGH)
5633 +#define BP_GPIO_4_AL (4 | BP_ACTIVE_LOW)
5634 +#define BP_GPIO_5_AH (5 | BP_ACTIVE_HIGH)
5635 +#define BP_GPIO_5_AL (5 | BP_ACTIVE_LOW)
5636 +#define BP_GPIO_6_AH (6 | BP_ACTIVE_HIGH)
5637 +#define BP_GPIO_6_AL (6 | BP_ACTIVE_LOW)
5638 +#define BP_GPIO_7_AH (7 | BP_ACTIVE_HIGH)
5639 +#define BP_GPIO_7_AL (7 | BP_ACTIVE_LOW)
5640 +#define BP_GPIO_8_AH (8 | BP_ACTIVE_HIGH)
5641 +#define BP_GPIO_8_AL (8 | BP_ACTIVE_LOW)
5642 +#define BP_GPIO_9_AH (9 | BP_ACTIVE_HIGH)
5643 +#define BP_GPIO_9_AL (9 | BP_ACTIVE_LOW)
5644 +#define BP_GPIO_10_AH (10 | BP_ACTIVE_HIGH)
5645 +#define BP_GPIO_10_AL (10 | BP_ACTIVE_LOW)
5646 +#define BP_GPIO_11_AH (11 | BP_ACTIVE_HIGH)
5647 +#define BP_GPIO_11_AL (11 | BP_ACTIVE_LOW)
5648 +#define BP_GPIO_12_AH (12 | BP_ACTIVE_HIGH)
5649 +#define BP_GPIO_12_AL (12 | BP_ACTIVE_LOW)
5650 +#define BP_GPIO_13_AH (13 | BP_ACTIVE_HIGH)
5651 +#define BP_GPIO_13_AL (13 | BP_ACTIVE_LOW)
5652 +#define BP_GPIO_14_AH (14 | BP_ACTIVE_HIGH)
5653 +#define BP_GPIO_14_AL (14 | BP_ACTIVE_LOW)
5654 +#define BP_GPIO_15_AH (15 | BP_ACTIVE_HIGH)
5655 +#define BP_GPIO_15_AL (15 | BP_ACTIVE_LOW)
5656 +#define BP_GPIO_16_AH (16 | BP_ACTIVE_HIGH)
5657 +#define BP_GPIO_16_AL (16 | BP_ACTIVE_LOW)
5658 +#define BP_GPIO_17_AH (17 | BP_ACTIVE_HIGH)
5659 +#define BP_GPIO_17_AL (17 | BP_ACTIVE_LOW)
5660 +#define BP_GPIO_18_AH (18 | BP_ACTIVE_HIGH)
5661 +#define BP_GPIO_18_AL (18 | BP_ACTIVE_LOW)
5662 +#define BP_GPIO_19_AH (19 | BP_ACTIVE_HIGH)
5663 +#define BP_GPIO_19_AL (19 | BP_ACTIVE_LOW)
5664 +#define BP_GPIO_20_AH (20 | BP_ACTIVE_HIGH)
5665 +#define BP_GPIO_20_AL (20 | BP_ACTIVE_LOW)
5666 +#define BP_GPIO_21_AH (21 | BP_ACTIVE_HIGH)
5667 +#define BP_GPIO_21_AL (21 | BP_ACTIVE_LOW)
5668 +#define BP_GPIO_22_AH (22 | BP_ACTIVE_HIGH)
5669 +#define BP_GPIO_22_AL (22 | BP_ACTIVE_LOW)
5670 +#define BP_GPIO_23_AH (23 | BP_ACTIVE_HIGH)
5671 +#define BP_GPIO_23_AL (23 | BP_ACTIVE_LOW)
5672 +#define BP_GPIO_24_AH (24 | BP_ACTIVE_HIGH)
5673 +#define BP_GPIO_24_AL (24 | BP_ACTIVE_LOW)
5674 +#define BP_GPIO_25_AH (25 | BP_ACTIVE_HIGH)
5675 +#define BP_GPIO_25_AL (25 | BP_ACTIVE_LOW)
5676 +#define BP_GPIO_26_AH (26 | BP_ACTIVE_HIGH)
5677 +#define BP_GPIO_26_AL (26 | BP_ACTIVE_LOW)
5678 +#define BP_GPIO_27_AH (27 | BP_ACTIVE_HIGH)
5679 +#define BP_GPIO_27_AL (27 | BP_ACTIVE_LOW)
5680 +#define BP_GPIO_28_AH (28 | BP_ACTIVE_HIGH)
5681 +#define BP_GPIO_28_AL (28 | BP_ACTIVE_LOW)
5682 +#define BP_GPIO_29_AH (29 | BP_ACTIVE_HIGH)
5683 +#define BP_GPIO_29_AL (29 | BP_ACTIVE_LOW)
5684 +#define BP_GPIO_30_AH (30 | BP_ACTIVE_HIGH)
5685 +#define BP_GPIO_30_AL (30 | BP_ACTIVE_LOW)
5686 +#define BP_GPIO_31_AH (31 | BP_ACTIVE_HIGH)
5687 +#define BP_GPIO_31_AL (31 | BP_ACTIVE_LOW)
5688 +#define BP_GPIO_32_AH (32 | BP_ACTIVE_HIGH)
5689 +#define BP_GPIO_32_AL (32 | BP_ACTIVE_LOW)
5690 +#define BP_GPIO_33_AH (33 | BP_ACTIVE_HIGH)
5691 +#define BP_GPIO_33_AL (33 | BP_ACTIVE_LOW)
5692 +#define BP_GPIO_34_AH (34 | BP_ACTIVE_HIGH)
5693 +#define BP_GPIO_34_AL (34 | BP_ACTIVE_LOW)
5694 +#define BP_GPIO_35_AH (35 | BP_ACTIVE_HIGH)
5695 +#define BP_GPIO_35_AL (35 | BP_ACTIVE_LOW)
5696 +#define BP_GPIO_36_AH (36 | BP_ACTIVE_HIGH)
5697 +#define BP_GPIO_36_AL (36 | BP_ACTIVE_LOW)
5699 +/* Values for external interrupt assignments. */
5700 +#define BP_EXT_INTR_0 0
5701 +#define BP_EXT_INTR_1 1
5702 +#define BP_EXT_INTR_2 2
5703 +#define BP_EXT_INTR_3 3
5705 +/* Values for chip select assignments. */
5711 +/* Value for GPIO and external interrupt fields that are not used. */
5712 +#define BP_NOT_DEFINED 0xffff
5713 +#define BP_HW_DEFINED 0xfff0
5714 +#define BP_UNEQUIPPED 0xfff1
5716 +/* Maximum size of the board id string. */
5717 +#define BP_BOARD_ID_LEN 16
5719 +/* Maximum number of Ethernet MACs. */
5720 +#define BP_MAX_ENET_MACS 2
5722 +/* Maximum number of VoIP DSPs. */
5723 +#define BP_MAX_VOIP_DSP 2
5725 +/* Wireless Antenna Settings. */
5726 +#define BP_WLAN_ANT_MAIN 0
5727 +#define BP_WLAN_ANT_AUX 1
5728 +#define BP_WLAN_ANT_BOTH 3
5730 +#if !defined(__ASSEMBLER__)
5732 +/* Information about an Ethernet MAC. If ucPhyType is BP_ENET_NO_PHY,
5733 + * then the other fields are not valid.
5735 +typedef struct EthernetMacInfo
5737 + unsigned char ucPhyType; /* BP_ENET_xxx */
5738 + unsigned char ucPhyAddress; /* 0 to 31 */
5739 + unsigned short usGpioPhySpiSck; /* GPIO pin or not defined */
5740 + unsigned short usGpioPhySpiSs; /* GPIO pin or not defined */
5741 + unsigned short usGpioPhySpiMosi; /* GPIO pin or not defined */
5742 + unsigned short usGpioPhySpiMiso; /* GPIO pin or not defined */
5743 + unsigned short usGpioPhyReset; /* GPIO pin or not defined (96348LV) */
5744 + unsigned short numSwitchPorts; /* Number of PHY ports */
5745 + unsigned short usConfigType; /* Configuration type */
5746 + unsigned short usReverseMii; /* Reverse MII */
5747 +} ETHERNET_MAC_INFO, *PETHERNET_MAC_INFO;
5750 +/* Information about VoIP DSPs. If ucDspType is BP_VOIP_NO_DSP,
5751 + * then the other fields are not valid.
5753 +typedef struct VoIPDspInfo
5755 + unsigned char ucDspType;
5756 + unsigned char ucDspAddress;
5757 + unsigned short usExtIntrVoip;
5758 + unsigned short usGpioVoipReset;
5759 + unsigned short usGpioVoipIntr;
5760 + unsigned short usGpioLedVoip;
5761 + unsigned short usCsVoip;
5766 +/**************************************************************************
5767 + * Name : BpSetBoardId
5769 + * Description: This function find the BOARD_PARAMETERS structure for the
5770 + * specified board id string and assigns it to a global, static
5773 + * Parameters : [IN] pszBoardId - Board id string that is saved into NVRAM.
5775 + * Returns : BP_SUCCESS - Success, value is returned.
5776 + * BP_BOARD_ID_NOT_FOUND - Error, board id input string does not
5777 + * have a board parameters configuration record.
5778 + ***************************************************************************/
5779 +int BpSetBoardId( char *pszBoardId );
5781 +/**************************************************************************
5782 + * Name : BpGetBoardIds
5784 + * Description: This function returns all of the supported board id strings.
5786 + * Parameters : [OUT] pszBoardIds - Address of a buffer that the board id
5787 + * strings are returned in. Each id starts at BP_BOARD_ID_LEN
5789 + * [IN] nBoardIdsSize - Number of BP_BOARD_ID_LEN elements that
5790 + * were allocated in pszBoardIds.
5792 + * Returns : Number of board id strings returned.
5793 + ***************************************************************************/
5794 +int BpGetBoardIds( char *pszBoardIds, int nBoardIdsSize );
5796 +/**************************************************************************
5797 + * Name : BpGetEthernetMacInfo
5799 + * Description: This function returns all of the supported board id strings.
5801 + * Parameters : [OUT] pEnetInfos - Address of an array of ETHERNET_MAC_INFO
5803 + * [IN] nNumEnetInfos - Number of ETHERNET_MAC_INFO elements that
5804 + * are pointed to by pEnetInfos.
5806 + * Returns : BP_SUCCESS - Success, value is returned.
5807 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5808 + ***************************************************************************/
5809 +int BpGetEthernetMacInfo( PETHERNET_MAC_INFO pEnetInfos, int nNumEnetInfos );
5811 +/**************************************************************************
5812 + * Name : BpGetSdramSize
5814 + * Description: This function returns a constant that describees the board's
5815 + * SDRAM type and size.
5817 + * Parameters : [OUT] pulSdramSize - Address of short word that the SDRAM size
5820 + * Returns : BP_SUCCESS - Success, value is returned.
5821 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5822 + ***************************************************************************/
5823 +int BpGetSdramSize( unsigned long *pulSdramSize );
5825 +/**************************************************************************
5826 + * Name : BpGetPsiSize
5828 + * Description: This function returns the persistent storage size in K bytes.
5830 + * Parameters : [OUT] pulPsiSize - Address of short word that the persistent
5831 + * storage size is returned in.
5833 + * Returns : BP_SUCCESS - Success, value is returned.
5834 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5835 + ***************************************************************************/
5836 +int BpGetPsiSize( unsigned long *pulPsiSize );
5838 +/**************************************************************************
5839 + * Name : BpGetRj11InnerOuterPairGpios
5841 + * Description: This function returns the GPIO pin assignments for changing
5842 + * between the RJ11 inner pair and RJ11 outer pair.
5844 + * Parameters : [OUT] pusInner - Address of short word that the RJ11 inner pair
5845 + * GPIO pin is returned in.
5846 + * [OUT] pusOuter - Address of short word that the RJ11 outer pair
5847 + * GPIO pin is returned in.
5849 + * Returns : BP_SUCCESS - Success, values are returned.
5850 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5851 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5853 + ***************************************************************************/
5854 +int BpGetRj11InnerOuterPairGpios( unsigned short *pusInner,
5855 + unsigned short *pusOuter );
5857 +/**************************************************************************
5858 + * Name : BpGetPressAndHoldResetGpio
5860 + * Description: This function returns the GPIO pin assignment for the press
5861 + * and hold reset button.
5863 + * Parameters : [OUT] pusValue - Address of short word that the press and hold
5864 + * reset button GPIO pin is returned in.
5866 + * Returns : BP_SUCCESS - Success, value is returned.
5867 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5868 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5870 + ***************************************************************************/
5871 +int BpGetPressAndHoldResetGpio( unsigned short *pusValue );
5873 +/**************************************************************************
5874 + * Name : BpGetVoipResetGpio
5876 + * Description: This function returns the GPIO pin assignment for the VOIP
5877 + * Reset operation.
5879 + * Parameters : [OUT] pusValue - Address of short word that the VOIP reset
5880 + * GPIO pin is returned in.
5881 + * [IN] dspNum - Address of the DSP to query.
5883 + * Returns : BP_SUCCESS - Success, value is returned.
5884 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5885 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5887 + ***************************************************************************/
5888 +int BpGetVoipResetGpio( unsigned char dspNum, unsigned short *pusValue );
5890 +/**************************************************************************
5891 + * Name : BpGetVoipIntrGpio
5893 + * Description: This function returns the GPIO pin assignment for VoIP interrupt.
5895 + * Parameters : [OUT] pusValue - Address of short word that the VOIP interrupt
5896 + * GPIO pin is returned in.
5897 + * [IN] dspNum - Address of the DSP to query.
5899 + * Returns : BP_SUCCESS - Success, value is returned.
5900 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5901 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5903 + ***************************************************************************/
5904 +int BpGetVoipIntrGpio( unsigned char dspNum, unsigned short *pusValue );
5906 +/**************************************************************************
5907 + * Name : BpGetPcmciaResetGpio
5909 + * Description: This function returns the GPIO pin assignment for the PCMCIA
5910 + * Reset operation.
5912 + * Parameters : [OUT] pusValue - Address of short word that the PCMCIA reset
5913 + * GPIO pin is returned in.
5915 + * Returns : BP_SUCCESS - Success, value is returned.
5916 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5917 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5919 + ***************************************************************************/
5920 +int BpGetPcmciaResetGpio( unsigned short *pusValue );
5922 +/**************************************************************************
5923 + * Name : BpGetUartRtsCtsGpios
5925 + * Description: This function returns the GPIO pin assignments for RTS and CTS
5928 + * Parameters : [OUT] pusRts - Address of short word that the UART RTS GPIO
5929 + * pin is returned in.
5930 + * [OUT] pusCts - Address of short word that the UART CTS GPIO
5931 + * pin is returned in.
5933 + * Returns : BP_SUCCESS - Success, values are returned.
5934 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5935 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5937 + ***************************************************************************/
5938 +int BpGetRtsCtsUartGpios( unsigned short *pusRts, unsigned short *pusCts );
5940 +/**************************************************************************
5941 + * Name : BpGetAdslLedGpio
5943 + * Description: This function returns the GPIO pin assignment for the ADSL
5946 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5947 + * GPIO pin is returned in.
5949 + * Returns : BP_SUCCESS - Success, value is returned.
5950 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5951 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5953 + ***************************************************************************/
5954 +int BpGetAdslLedGpio( unsigned short *pusValue );
5956 +/**************************************************************************
5957 + * Name : BpGetAdslFailLedGpio
5959 + * Description: This function returns the GPIO pin assignment for the ADSL
5960 + * LED that is used when there is a DSL connection failure.
5962 + * Parameters : [OUT] pusValue - Address of short word that the ADSL LED
5963 + * GPIO pin is returned in.
5965 + * Returns : BP_SUCCESS - Success, value is returned.
5966 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5967 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5969 + ***************************************************************************/
5970 +int BpGetAdslFailLedGpio( unsigned short *pusValue );
5972 +/**************************************************************************
5973 + * Name : BpGetWirelessLedGpio
5975 + * Description: This function returns the GPIO pin assignment for the Wireless
5978 + * Parameters : [OUT] pusValue - Address of short word that the Wireless LED
5979 + * GPIO pin is returned in.
5981 + * Returns : BP_SUCCESS - Success, value is returned.
5982 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5983 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
5985 + ***************************************************************************/
5986 +int BpGetWirelessLedGpio( unsigned short *pusValue );
5988 +/**************************************************************************
5989 + * Name : BpGetWirelessAntInUse
5991 + * Description: This function returns the antennas in use for wireless
5993 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Antenna
5996 + * Returns : BP_SUCCESS - Success, value is returned.
5997 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
5998 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6000 + ***************************************************************************/
6001 +int BpGetWirelessAntInUse( unsigned short *pusValue );
6003 +/**************************************************************************
6004 + * Name : BpGetWirelessSesBtnGpio
6006 + * Description: This function returns the GPIO pin assignment for the Wireless
6009 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6010 + * Button GPIO pin is returned in.
6012 + * Returns : BP_SUCCESS - Success, value is returned.
6013 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6014 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6016 + ***************************************************************************/
6017 +int BpGetWirelessSesBtnGpio( unsigned short *pusValue );
6019 +/**************************************************************************
6020 + * Name : BpGetWirelessSesExtIntr
6022 + * Description: This function returns the external interrupt number for the
6023 + * Wireless Ses Button.
6025 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6026 + * external interrup is returned in.
6028 + * Returns : BP_SUCCESS - Success, value is returned.
6029 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6030 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6032 + ***************************************************************************/
6033 +int BpGetWirelessSesExtIntr( unsigned short *pusValue );
6035 +/**************************************************************************
6036 + * Name : BpGetWirelessSesLedGpio
6038 + * Description: This function returns the GPIO pin assignment for the Wireless
6041 + * Parameters : [OUT] pusValue - Address of short word that the Wireless Ses
6042 + * Led GPIO pin is returned in.
6044 + * Returns : BP_SUCCESS - Success, value is returned.
6045 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6046 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6048 + ***************************************************************************/
6049 +int BpGetWirelessSesLedGpio( unsigned short *pusValue );
6051 +/**************************************************************************
6052 + * Name : BpGetUsbLedGpio
6054 + * Description: This function returns the GPIO pin assignment for the USB
6057 + * Parameters : [OUT] pusValue - Address of short word that the USB LED
6058 + * GPIO pin is returned in.
6060 + * Returns : BP_SUCCESS - Success, value is returned.
6061 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6062 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6064 + ***************************************************************************/
6065 +int BpGetUsbLedGpio( unsigned short *pusValue );
6067 +/**************************************************************************
6068 + * Name : BpGetHpnaLedGpio
6070 + * Description: This function returns the GPIO pin assignment for the HPNA
6073 + * Parameters : [OUT] pusValue - Address of short word that the HPNA LED
6074 + * GPIO pin is returned in.
6076 + * Returns : BP_SUCCESS - Success, value is returned.
6077 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6078 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6080 + ***************************************************************************/
6081 +int BpGetHpnaLedGpio( unsigned short *pusValue );
6083 +/**************************************************************************
6084 + * Name : BpGetWanDataLedGpio
6086 + * Description: This function returns the GPIO pin assignment for the WAN Data
6089 + * Parameters : [OUT] pusValue - Address of short word that the WAN Data LED
6090 + * GPIO pin is returned in.
6092 + * Returns : BP_SUCCESS - Success, value is returned.
6093 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6094 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6096 + ***************************************************************************/
6097 +int BpGetWanDataLedGpio( unsigned short *pusValue );
6099 +/**************************************************************************
6100 + * Name : BpGetPppLedGpio
6102 + * Description: This function returns the GPIO pin assignment for the PPP
6105 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
6106 + * GPIO pin is returned in.
6108 + * Returns : BP_SUCCESS - Success, value is returned.
6109 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6110 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6112 + ***************************************************************************/
6113 +int BpGetPppLedGpio( unsigned short *pusValue );
6115 +/**************************************************************************
6116 + * Name : BpGetPppFailLedGpio
6118 + * Description: This function returns the GPIO pin assignment for the PPP
6119 + * LED that is used when there is a PPP connection failure.
6121 + * Parameters : [OUT] pusValue - Address of short word that the PPP LED
6122 + * GPIO pin is returned in.
6124 + * Returns : BP_SUCCESS - Success, value is returned.
6125 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6126 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6128 + ***************************************************************************/
6129 +int BpGetPppFailLedGpio( unsigned short *pusValue );
6131 +/**************************************************************************
6132 + * Name : BpGetVoipLedGpio
6134 + * Description: This function returns the GPIO pin assignment for the VOIP
6137 + * Parameters : [OUT] pusValue - Address of short word that the VOIP LED
6138 + * GPIO pin is returned in.
6140 + * Returns : BP_SUCCESS - Success, value is returned.
6141 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6142 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6144 + ***************************************************************************/
6145 +int BpGetVoipLedGpio( unsigned short *pusValue );
6147 +/**************************************************************************
6148 + * Name : BpGetBootloaderPowerOnLedGpio
6150 + * Description: This function returns the GPIO pin assignment for the power
6151 + * on LED that is set by the bootloader.
6153 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6154 + * GPIO pin is returned in.
6156 + * Returns : BP_SUCCESS - Success, value is returned.
6157 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6158 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6160 + ***************************************************************************/
6161 +int BpGetBootloaderPowerOnLedGpio( unsigned short *pusValue );
6163 +/**************************************************************************
6164 + * Name : BpGetBootloaderAlarmLedGpio
6166 + * Description: This function returns the GPIO pin assignment for the alarm
6167 + * LED that is set by the bootloader.
6169 + * Parameters : [OUT] pusValue - Address of short word that the alarm LED
6170 + * GPIO pin is returned in.
6172 + * Returns : BP_SUCCESS - Success, value is returned.
6173 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6174 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6176 + ***************************************************************************/
6177 +int BpGetBootloaderAlarmLedGpio( unsigned short *pusValue );
6179 +/**************************************************************************
6180 + * Name : BpGetBootloaderResetCfgLedGpio
6182 + * Description: This function returns the GPIO pin assignment for the reset
6183 + * configuration LED that is set by the bootloader.
6185 + * Parameters : [OUT] pusValue - Address of short word that the reset
6186 + * configuration LED GPIO pin is returned in.
6188 + * Returns : BP_SUCCESS - Success, value is returned.
6189 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6190 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6192 + ***************************************************************************/
6193 +int BpGetBootloaderResetCfgLedGpio( unsigned short *pusValue );
6195 +/**************************************************************************
6196 + * Name : BpGetBootloaderStopLedGpio
6198 + * Description: This function returns the GPIO pin assignment for the break
6199 + * into bootloader LED that is set by the bootloader.
6201 + * Parameters : [OUT] pusValue - Address of short word that the break into
6202 + * bootloader LED GPIO pin is returned in.
6204 + * Returns : BP_SUCCESS - Success, value is returned.
6205 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6206 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6208 + ***************************************************************************/
6209 +int BpGetBootloaderStopLedGpio( unsigned short *pusValue );
6211 +/**************************************************************************
6212 + * Name : BpGetWirelessExtIntr
6214 + * Description: This function returns the Wireless external interrupt number.
6216 + * Parameters : [OUT] pulValue - Address of short word that the wireless
6217 + * external interrupt number is returned in.
6219 + * Returns : BP_SUCCESS - Success, value is returned.
6220 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6221 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6223 + ***************************************************************************/
6224 +int BpGetWirelessExtIntr( unsigned long *pulValue );
6226 +/**************************************************************************
6227 + * Name : BpGetAdslDyingGaspExtIntr
6229 + * Description: This function returns the ADSL Dying Gasp external interrupt
6232 + * Parameters : [OUT] pulValue - Address of short word that the ADSL Dying Gasp
6233 + * external interrupt number is returned in.
6235 + * Returns : BP_SUCCESS - Success, value is returned.
6236 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6237 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6239 + ***************************************************************************/
6240 +int BpGetAdslDyingGaspExtIntr( unsigned long *pulValue );
6242 +/**************************************************************************
6243 + * Name : BpGetVoipExtIntr
6245 + * Description: This function returns the VOIP external interrupt number.
6247 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6248 + * external interrupt number is returned in.
6249 + * [IN] dspNum - Address of the DSP to query.
6251 + * Returns : BP_SUCCESS - Success, value is returned.
6252 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6253 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6255 + ***************************************************************************/
6256 +int BpGetVoipExtIntr( unsigned char dspNum, unsigned long *pulValue );
6258 +/**************************************************************************
6259 + * Name : BpGetHpnaExtIntr
6261 + * Description: This function returns the HPNA external interrupt number.
6263 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6264 + * external interrupt number is returned in.
6266 + * Returns : BP_SUCCESS - Success, value is returned.
6267 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6268 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6270 + ***************************************************************************/
6271 +int BpGetHpnaExtIntr( unsigned long *pulValue );
6273 +/**************************************************************************
6274 + * Name : BpGetHpnaChipSelect
6276 + * Description: This function returns the HPNA chip select number.
6278 + * Parameters : [OUT] pulValue - Address of short word that the HPNA
6279 + * chip select number is returned in.
6281 + * Returns : BP_SUCCESS - Success, value is returned.
6282 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6283 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6285 + ***************************************************************************/
6286 +int BpGetHpnaChipSelect( unsigned long *pulValue );
6288 +/**************************************************************************
6289 + * Name : BpGetVoipChipSelect
6291 + * Description: This function returns the VOIP chip select number.
6293 + * Parameters : [OUT] pulValue - Address of short word that the VOIP
6294 + * chip select number is returned in.
6295 + * [IN] dspNum - Address of the DSP to query.
6297 + * Returns : BP_SUCCESS - Success, value is returned.
6298 + * BP_BOARD_ID_NOT_SET - Error, BpSetBoardId has not been called.
6299 + * BP_VALUE_NOT_DEFINED - At least one return value is not defined
6301 + ***************************************************************************/
6302 +int BpGetVoipChipSelect( unsigned char dspNum, unsigned long *pulValue );
6304 +#endif /* __ASSEMBLER__ */
6306 +#endif /* _BOARDPARMS_H */
6308 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c
6309 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.c 1970-01-01 01:00:00.000000000 +0100
6310 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.c 2006-08-03 16:36:58.000000000 +0200
6312 +/************************************************************************/
6314 +/* AMD CFI Enabled Flash Memory Drivers */
6315 +/* File name: CFIFLASH.C */
6316 +/* Revision: 1.0 5/07/98 */
6318 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
6319 +/* This software is unpublished and contains the trade secrets and */
6320 +/* confidential proprietary information of AMD. Unless otherwise */
6321 +/* provided in the Software Agreement associated herewith, it is */
6322 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
6323 +/* or part by any means except for backup. Use, duplication, or */
6324 +/* disclosure by the Government is subject to the restrictions in */
6325 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
6326 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
6327 +/* Software owned by */
6328 +/* Advanced Micro Devices, Inc., */
6329 +/* One AMD Place, */
6330 +/* P.O. Box 3453 */
6331 +/* Sunnyvale, CA 94088-3453. */
6332 +/************************************************************************/
6333 +/* This software constitutes a basic shell of source code for */
6334 +/* programming all AMD Flash components. AMD */
6335 +/* will not be responsible for misuse or illegal use of this */
6336 +/* software for devices not supported herein. AMD is providing */
6337 +/* this source code "AS IS" and will not be responsible for */
6338 +/* issues arising from incorrect user implementation of the */
6339 +/* source code herein. It is the user's responsibility to */
6340 +/* properly design-in this source code. */
6342 +/************************************************************************/
6344 +#include "lib_types.h"
6345 +#include "lib_printf.h"
6346 +#include "lib_string.h"
6347 +#include "cfe_timer.h"
6348 +#define printk printf
6350 +#include <linux/param.h>
6351 +#include <linux/sched.h>
6352 +#include <linux/timer.h>
6355 +#include "cfiflash.h"
6357 +static int flash_wait(WORD sector, int offset, UINT16 data);
6358 +static UINT16 flash_get_device_id(void);
6359 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily);
6360 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes);
6361 +static void flash_command(int command, WORD sector, int offset, UINT16 data);
6363 +/*********************************************************************/
6364 +/* 'meminfo' should be a pointer, but most C compilers will not */
6365 +/* allocate static storage for a pointer without calling */
6366 +/* non-portable functions such as 'new'. We also want to avoid */
6367 +/* the overhead of passing this pointer for every driver call. */
6368 +/* Systems with limited heap space will need to do this. */
6369 +/*********************************************************************/
6370 +struct flashinfo meminfo; /* Flash information structure */
6371 +static int flashFamily = FLASH_UNDEFINED;
6372 +static int totalSize = 0;
6373 +static struct cfi_query query;
6375 +static UINT16 cfi_data_struct_29W160[] = {
6376 + 0x0020, 0x0049, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6377 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6378 + 0x0051, 0x0052, 0x0059, 0x0002, 0x0000, 0x0040, 0x0000, 0x0000,
6379 + 0x0000, 0x0000, 0x0000, 0x0027, 0x0036, 0x0000, 0x0000, 0x0004,
6380 + 0x0000, 0x000a, 0x0000, 0x0004, 0x0000, 0x0003, 0x0000, 0x0015,
6381 + 0x0002, 0x0000, 0x0000, 0x0000, 0x0004, 0x0000, 0x0000, 0x0040,
6382 + 0x0000, 0x0001, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0080,
6383 + 0x0000, 0x001e, 0x0000, 0x0000, 0x0001, 0xffff, 0xffff, 0xffff,
6384 + 0x0050, 0x0052, 0x0049, 0x0031, 0x0030, 0x0000, 0x0002, 0x0001,
6385 + 0x0001, 0x0004, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0002,
6386 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6387 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6388 + 0xffff, 0x0888, 0x252b, 0x8c84, 0x7dbc, 0xffff, 0xffff, 0xffff,
6389 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6390 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
6391 + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
6395 +/*********************************************************************/
6396 +/* Init_flash is used to build a sector table from the information */
6397 +/* provided through the CFI query. This information is translated */
6398 +/* from erase_block information to base:offset information for each */
6399 +/* individual sector. This information is then stored in the meminfo */
6400 +/* structure, and used throughout the driver to access sector */
6403 +/* This is more efficient than deriving the sector base:offset */
6404 +/* information every time the memory map switches (since on the */
6405 +/* development platform can only map 64k at a time). If the entire */
6406 +/* flash memory array can be mapped in, then the addition static */
6407 +/* allocation for the meminfo structure can be eliminated, but the */
6408 +/* drivers will have to be re-written. */
6410 +/* The meminfo struct occupies 653 bytes of heap space, depending */
6411 +/* on the value of the define MAXSECTORS. Adjust to suit */
6413 +/*********************************************************************/
6414 +byte flash_init(void)
6416 + int i=0, j=0, count=0;
6419 + int flipCFIGeometry = FALSE;
6422 + * a single 8k sector for sector 0. This is to allow
6423 + * the system to perform memory mapping to the device,
6424 + * even though the actual physical layout is unknown.
6425 + * Once mapped in, the CFI query will produce all
6426 + * relevant information.
6428 + meminfo.addr = 0L;
6430 + meminfo.nsect = 1;
6431 + meminfo.bank1start = 0;
6432 + meminfo.bank2start = 0;
6434 + meminfo.sec[0].size = 8192;
6435 + meminfo.sec[0].base = 0x00000;
6436 + meminfo.sec[0].bank = 1;
6438 + flash_command(FLASH_RESET, 0, 0, 0);
6440 + device_id = flash_get_device_id();
6442 + switch (device_id) {
6443 + case ID_I28F160C3B:
6444 + case ID_I28F320C3B:
6445 + case ID_I28F160C3T:
6446 + case ID_I28F320C3T:
6447 + flashFamily = FLASH_INTEL;
6449 + case ID_AM29DL800B:
6450 + case ID_AM29LV800B:
6451 + case ID_AM29LV400B:
6452 + case ID_AM29LV160B:
6453 + case ID_AM29LV320B:
6454 + case ID_MX29LV320AB:
6455 + case ID_AM29LV320MB:
6456 + case ID_AM29DL800T:
6457 + case ID_AM29LV800T:
6458 + case ID_AM29LV160T:
6459 + case ID_AM29LV320T:
6460 + case ID_MX29LV320AT:
6461 + case ID_AM29LV320MT:
6462 + flashFamily = FLASH_AMD;
6464 + case ID_SST39VF1601:
6465 + case ID_SST39VF3201:
6466 + flashFamily = FLASH_SST;
6469 + printk("Flash memory not supported! Device id = %x\n", device_id);
6473 + if (flash_get_cfi(&query, 0, flashFamily) == -1) {
6474 + switch(device_id) {
6475 + case ID_AM29LV160T:
6476 + case ID_AM29LV160B:
6477 + flash_get_cfi(&query, cfi_data_struct_29W160, flashFamily);
6480 + printk("CFI data structure not found. Device id = %x\n", device_id);
6485 + // need to determine if it top or bottom boot here
6486 + switch (device_id)
6488 + case ID_AM29DL800B:
6489 + case ID_AM29LV800B:
6490 + case ID_AM29LV400B:
6491 + case ID_AM29LV160B:
6492 + case ID_AM29LV320B:
6493 + case ID_MX29LV320AB:
6494 + case ID_AM29LV320MB:
6495 + case ID_I28F160C3B:
6496 + case ID_I28F320C3B:
6497 + case ID_I28F160C3T:
6498 + case ID_I28F320C3T:
6499 + case ID_SST39VF1601:
6500 + case ID_SST39VF3201:
6501 + flipCFIGeometry = FALSE;
6503 + case ID_AM29DL800T:
6504 + case ID_AM29LV800T:
6505 + case ID_AM29LV160T:
6506 + case ID_AM29LV320T:
6507 + case ID_MX29LV320AT:
6508 + case ID_AM29LV320MT:
6509 + flipCFIGeometry = TRUE;
6512 + printk("Flash memory not supported! Device id = %x\n", device_id);
6516 + count=0;basecount=0L;
6518 + if (!flipCFIGeometry)
6520 + for (i=0; i<query.num_erase_blocks; i++) {
6521 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6522 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6523 + meminfo.sec[count].base = (int) basecount;
6524 + basecount += (int) query.erase_block[i].sector_size;
6531 + for (i = (query.num_erase_blocks - 1); i >= 0; i--) {
6532 + for(j=0; j<query.erase_block[i].num_sectors; j++) {
6533 + meminfo.sec[count].size = (int) query.erase_block[i].sector_size;
6534 + meminfo.sec[count].base = (int) basecount;
6535 + basecount += (int) query.erase_block[i].sector_size;
6541 + meminfo.nsect = count;
6542 + totalSize = meminfo.sec[count-1].base + meminfo.sec[count-1].size;
6546 +/*********************************************************************/
6547 +/* Flash_sector_erase_int() is identical to flash_sector_erase(), */
6548 +/* except it will wait until the erase is completed before returning */
6549 +/* control to the calling function. This can be used in cases which */
6550 +/* require the program to hold until a sector is erased, without */
6551 +/* adding the wait check external to this function. */
6552 +/*********************************************************************/
6553 +byte flash_sector_erase_int(WORD sector)
6557 + for( i = 0; i < 3; i++ ) {
6558 + flash_command(FLASH_SERASE, sector, 0, 0);
6559 + if (flash_wait(sector, 0, 0xffff) == STATUS_READY)
6566 +/*********************************************************************/
6567 +/* flash_read_buf() reads buffer of data from the specified */
6568 +/* offset from the sector parameter. */
6569 +/*********************************************************************/
6570 +int flash_read_buf(WORD sector, int offset,
6571 + byte *buffer, int numbytes)
6575 + fwp = (byte *)flash_get_memptr(sector);
6577 + while (numbytes) {
6578 + *buffer++ = *(fwp + offset);
6586 +/*********************************************************************/
6587 +/* flash_write_buf() utilizes */
6588 +/* the unlock bypass mode of the flash device. This can remove */
6589 +/* significant overhead from the bulk programming operation, and */
6590 +/* when programming bulk data a sizeable performance increase can be */
6592 +/*********************************************************************/
6593 +int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes)
6597 + unsigned char *p = flash_get_memptr(sector) + offset;
6599 + /* After writing the flash block, compare the contents to the source
6600 + * buffer. Try to write the sector successfully up to three times.
6602 + for( i = 0; i < 3; i++ ) {
6603 + ret = flash_write(sector, offset, buffer, numbytes);
6604 + if( !memcmp( p, buffer, numbytes ) )
6606 + /* Erase and try again */
6607 + flash_sector_erase_int(sector);
6612 + printk( "Flash write error. Verify failed\n" );
6617 +/*********************************************************************/
6618 +/* Usefull funtion to return the number of sectors in the device. */
6619 +/* Can be used for functions which need to loop among all the */
6620 +/* sectors, or wish to know the number of the last sector. */
6621 +/*********************************************************************/
6622 +int flash_get_numsectors(void)
6624 + return meminfo.nsect;
6627 +/*********************************************************************/
6628 +/* flash_get_sector_size() is provided for cases in which the size */
6629 +/* of a sector is required by a host application. The sector size */
6630 +/* (in bytes) is returned in the data location pointed to by the */
6631 +/* 'size' parameter. */
6632 +/*********************************************************************/
6633 +int flash_get_sector_size(WORD sector)
6635 + return meminfo.sec[sector].size;
6638 +/*********************************************************************/
6639 +/* The purpose of flash_get_memptr() is to return a memory pointer */
6640 +/* which points to the beginning of memory space allocated for the */
6641 +/* flash. All function pointers are then referenced from this */
6644 +/* Different systems will implement this in different ways: */
6645 +/* possibilities include: */
6646 +/* - A direct memory pointer */
6647 +/* - A pointer to a memory map */
6648 +/* - A pointer to a hardware port from which the linear */
6649 +/* address is translated */
6650 +/* - Output of an MMU function / service */
6652 +/* Also note that this function expects the pointer to a specific */
6653 +/* sector of the device. This can be provided by dereferencing */
6654 +/* the pointer from a translated offset of the sector from a */
6655 +/* global base pointer (e.g. flashptr = base_pointer + sector_offset)*/
6657 +/* Important: Many AMD flash devices need both bank and or sector */
6658 +/* address bits to be correctly set (bank address bits are A18-A16, */
6659 +/* and sector address bits are A18-A12, or A12-A15). Flash parts */
6660 +/* which do not need these bits will ignore them, so it is safe to */
6661 +/* assume that every part will require these bits to be set. */
6662 +/*********************************************************************/
6663 +unsigned char *flash_get_memptr(WORD sector)
6665 + unsigned char *memptr = (unsigned char*)(FLASH_BASE_ADDR_REG + meminfo.sec[sector].base);
6670 +/*********************************************************************/
6671 +/* The purpose of flash_get_blk() is to return a the block number */
6672 +/* for a given memory address. */
6673 +/*********************************************************************/
6674 +int flash_get_blk(int addr)
6677 + int last_blk = flash_get_numsectors();
6678 + int relative_addr = addr - (int) FLASH_BASE_ADDR_REG;
6680 + for(blk_start=0, i=0; i < relative_addr && blk_start < last_blk; blk_start++)
6681 + i += flash_get_sector_size(blk_start);
6683 + if( i > relative_addr )
6685 + blk_start--; // last blk, dec by 1
6688 + if( blk_start == last_blk )
6690 + printk("Address is too big.\n");
6694 + return( blk_start );
6697 +/************************************************************************/
6698 +/* The purpose of flash_get_total_size() is to return the total size of */
6700 +/************************************************************************/
6701 +int flash_get_total_size()
6706 +/*********************************************************************/
6707 +/* Flash_command() is the main driver function. It performs */
6708 +/* every possible command available to AMD B revision */
6709 +/* flash parts. Note that this command is not used directly, but */
6710 +/* rather called through the API wrapper functions provided below. */
6711 +/*********************************************************************/
6712 +static void flash_command(int command, WORD sector, int offset, UINT16 data)
6714 + volatile UINT16 *flashptr;
6715 + volatile UINT16 *flashbase;
6717 + flashptr = (UINT16 *) flash_get_memptr(sector);
6718 + flashbase = (UINT16 *) flash_get_memptr(0);
6720 + switch (flashFamily) {
6721 + case FLASH_UNDEFINED:
6722 + /* These commands should work for AMD, Intel and SST flashes */
6723 + switch (command) {
6725 + flashptr[0] = 0xF0;
6726 + flashptr[0] = 0xFF;
6728 + case FLASH_READ_ID:
6729 + flashptr[0x5555] = 0xAA; /* unlock 1 */
6730 + flashptr[0x2AAA] = 0x55; /* unlock 2 */
6731 + flashptr[0x5555] = 0x90;
6738 + switch (command) {
6740 + flashptr[0] = 0xF0;
6742 + case FLASH_READ_ID:
6743 + flashptr[0x555] = 0xAA; /* unlock 1 */
6744 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6745 + flashptr[0x555] = 0x90;
6747 + case FLASH_CFIQUERY:
6748 + flashptr[0x55] = 0x98;
6751 + flashptr[0x555] = 0xAA; /* unlock 1 */
6752 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6753 + flashptr[0x555] = 0x20;
6756 + flashptr[0] = 0xA0;
6757 + flashptr[offset/2] = data;
6759 + case FLASH_UBRESET:
6760 + flashptr[0] = 0x90;
6761 + flashptr[0] = 0x00;
6763 + case FLASH_SERASE:
6764 + flashptr[0x555] = 0xAA; /* unlock 1 */
6765 + flashptr[0x2AA] = 0x55; /* unlock 2 */
6766 + flashptr[0x555] = 0x80;
6767 + flashptr[0x555] = 0xAA;
6768 + flashptr[0x2AA] = 0x55;
6769 + flashptr[0] = 0x30;
6776 + switch (command) {
6778 + flashptr[0] = 0xFF;
6780 + case FLASH_READ_ID:
6781 + flashptr[0] = 0x90;
6783 + case FLASH_CFIQUERY:
6784 + flashptr[0] = 0x98;
6787 + flashptr[0] = 0x40;
6788 + flashptr[offset/2] = data;
6790 + case FLASH_SERASE:
6791 + flashptr[0] = 0x60;
6792 + flashptr[0] = 0xD0;
6793 + flashptr[0] = 0x20;
6794 + flashptr[0] = 0xD0;
6801 + switch (command) {
6803 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6804 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6805 + flashbase[0x5555] = 0xf0;
6807 + case FLASH_READ_ID:
6808 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6809 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6810 + flashbase[0x5555] = 0x90;
6812 + case FLASH_CFIQUERY:
6813 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6814 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6815 + flashbase[0x5555] = 0x98;
6820 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6821 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6822 + flashbase[0x5555] = 0xa0;
6823 + flashptr[offset/2] = data;
6825 + case FLASH_UBRESET:
6827 + case FLASH_SERASE:
6828 + flashbase[0x5555] = 0xAA; /* unlock 1 */
6829 + flashbase[0x2AAA] = 0x55; /* unlock 2 */
6830 + flashbase[0x5555] = 0x80;
6831 + flashbase[0x5555] = 0xAA;
6832 + flashbase[0x2AAA] = 0x55;
6833 + flashptr[0] = 0x30;
6844 +/*********************************************************************/
6845 +/* flash_write extends the functionality of flash_program() by */
6846 +/* providing an faster way to program multiple data words, without */
6847 +/* needing the function overhead of looping algorithms which */
6848 +/* program word by word. This function utilizes fast pointers */
6849 +/* to quickly loop through bulk data. */
6850 +/*********************************************************************/
6851 +static int flash_write(WORD sector, int offset, byte *buf, int nbytes)
6854 + src = (UINT16 *)buf;
6856 + if ((nbytes | offset) & 1) {
6860 + flash_command(FLASH_UB, 0, 0, 0);
6861 + while (nbytes > 0) {
6862 + flash_command(FLASH_PROG, sector, offset, *src);
6863 + if (flash_wait(sector, offset, *src) != STATUS_READY)
6869 + flash_command(FLASH_UBRESET, 0, 0, 0);
6871 + return (byte*)src - buf;
6874 +/*********************************************************************/
6875 +/* flash_wait utilizes the DQ6, DQ5, and DQ2 polling algorithms */
6876 +/* described in the flash data book. It can quickly ascertain the */
6877 +/* operational status of the flash device, and return an */
6878 +/* appropriate status code (defined in flash.h) */
6879 +/*********************************************************************/
6880 +static int flash_wait(WORD sector, int offset, UINT16 data)
6882 + volatile UINT16 *flashptr; /* flash window */
6885 + flashptr = (UINT16 *) flash_get_memptr(sector);
6887 + if (flashFamily == FLASH_AMD || flashFamily == FLASH_SST) {
6888 +#if defined(_BCM96338_) || defined(CONFIG_BCM96338)
6890 + d1 = flashptr[offset/2];
6892 + return STATUS_READY;
6893 + } while (!(d1 & 0x20));
6895 + d1 = flashptr[offset/2];
6898 + flash_command(FLASH_RESET, 0, 0, 0);
6899 + return STATUS_TIMEOUT;
6903 + d1 = *flashptr; /* read data */
6904 + d1 ^= *flashptr; /* read it again and see what toggled */
6905 + if (d1 == 0) /* no toggles, nothing's happening */
6906 + return STATUS_READY;
6907 + } while (!(d1 & 0x20));
6909 + d1 = *flashptr; /* read data */
6910 + d1 ^= *flashptr; /* read it again and see what toggled */
6913 + flash_command(FLASH_RESET, 0, 0, 0);
6914 + return STATUS_TIMEOUT;
6917 + } else if (flashFamily == FLASH_INTEL) {
6918 + flashptr[0] = 0x70;
6919 + /* Wait for completion */
6920 + while(!(*flashptr & 0x80));
6921 + if (*flashptr & 0x30) {
6922 + flashptr[0] = 0x50;
6923 + flash_command(FLASH_RESET, 0, 0, 0);
6924 + return STATUS_TIMEOUT;
6926 + flashptr[0] = 0x50;
6927 + flash_command(FLASH_RESET, 0, 0, 0);
6930 + return STATUS_READY;
6933 +/*********************************************************************/
6934 +/* flash_get_device_id() will perform an autoselect sequence on the */
6935 +/* flash device, and return the device id of the component. */
6936 +/* This function automatically resets to read mode. */
6937 +/*********************************************************************/
6938 +static UINT16 flash_get_device_id()
6940 + volatile UINT16 *fwp; /* flash window */
6943 + fwp = (UINT16 *)flash_get_memptr(0);
6945 + flash_command(FLASH_READ_ID, 0, 0, 0);
6946 + answer = *(fwp + 1);
6947 + if (answer == ID_AM29LV320M) {
6948 + answer = *(fwp + 0xe);
6949 + answer = *(fwp + 0xf);
6952 + flash_command(FLASH_RESET, 0, 0, 0);
6953 + return( (UINT16) answer );
6956 +/*********************************************************************/
6957 +/* flash_get_cfi() is the main CFI workhorse function. Due to it's */
6958 +/* complexity and size it need only be called once upon */
6959 +/* initializing the flash system. Once it is called, all operations */
6960 +/* are performed by looking at the meminfo structure. */
6961 +/* All possible care was made to make this algorithm as efficient as */
6962 +/* possible. 90% of all operations are memory reads, and all */
6963 +/* calculations are done using bit-shifts when possible */
6964 +/*********************************************************************/
6965 +static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily)
6967 + volatile UINT16 *fwp; /* flash window */
6970 + flash_command(FLASH_CFIQUERY, 0, 0, 0);
6972 + if (cfi_struct == 0)
6973 + fwp = (UINT16 *)flash_get_memptr(0);
6977 + /* Initial house-cleaning */
6978 + for(i=0; i < 8; i++) {
6979 + query->erase_block[i].sector_size = 0;
6980 + query->erase_block[i].num_sectors = 0;
6983 + /* If not 'QRY', then we dont have a CFI enabled device in the socket */
6984 + if( fwp[0x10] != 'Q' &&
6985 + fwp[0x11] != 'R' &&
6986 + fwp[0x12] != 'Y') {
6987 + flash_command(FLASH_RESET, 0, 0, 0);
6991 + query->num_erase_blocks = fwp[0x2C];
6992 + if(flashFamily == FLASH_SST)
6993 + query->num_erase_blocks = 1;
6995 + for(i=0; i < query->num_erase_blocks; i++) {
6996 + query->erase_block[i].num_sectors = fwp[(0x2D+(4*i))] + (fwp[0x2E + (4*i)] << 8);
6997 + query->erase_block[i].num_sectors++;
6998 + query->erase_block[i].sector_size = 256 * (256 * fwp[(0x30+(4*i))] + fwp[(0x2F+(4*i))]);
7001 + flash_command(FLASH_RESET, 0, 0, 0);
7004 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h
7005 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/cfiflash.h 1970-01-01 01:00:00.000000000 +0100
7006 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/cfiflash.h 2006-08-03 16:36:58.000000000 +0200
7008 +/************************************************************************/
7010 +/* AMD CFI Enabled Flash Memory Drivers */
7011 +/* File name: CFIFLASH.H */
7012 +/* Revision: 1.0 5/07/98 */
7014 +/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
7015 +/* This software is unpublished and contains the trade secrets and */
7016 +/* confidential proprietary information of AMD. Unless otherwise */
7017 +/* provided in the Software Agreement associated herewith, it is */
7018 +/* licensed in confidence "AS IS" and is not to be reproduced in whole */
7019 +/* or part by any means except for backup. Use, duplication, or */
7020 +/* disclosure by the Government is subject to the restrictions in */
7021 +/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
7022 +/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
7023 +/* Software owned by */
7024 +/* Advanced Micro Devices, Inc., */
7025 +/* One AMD Place, */
7026 +/* P.O. Box 3453 */
7027 +/* Sunnyvale, CA 94088-3453. */
7028 +/************************************************************************/
7029 +/* This software constitutes a basic shell of source code for */
7030 +/* programming all AMD Flash components. AMD */
7031 +/* will not be responsible for misuse or illegal use of this */
7032 +/* software for devices not supported herein. AMD is providing */
7033 +/* this source code "AS IS" and will not be responsible for */
7034 +/* issues arising from incorrect user implementation of the */
7035 +/* source code herein. It is the user's responsibility to */
7036 +/* properly design-in this source code. */
7038 +/************************************************************************/
7039 +#ifndef _CFIFLASH_H
7040 +#define _CFIFLASH_H
7042 +/* include board/CPU specific definitions */
7043 +#include "bcmtypes.h"
7046 +#define FLASH_BASE_ADDR_REG FLASH_BASE
7052 +#define MAXSECTORS 1024 /* maximum number of sectors supported */
7054 +/* A structure for identifying a flash part. There is one for each
7055 + * of the flash part definitions. We need to keep track of the
7056 + * sector organization, the address register used, and the size
7060 + char *name; /* "Am29DL800T", etc. */
7061 + unsigned long addr; /* physical address, once translated */
7062 + int areg; /* Can be set to zero for all parts */
7063 + int nsect; /* # of sectors -- 19 in LV, 22 in DL */
7064 + int bank1start; /* first sector # in bank 1 */
7065 + int bank2start; /* first sector # in bank 2, if DL part */
7067 + long size; /* # of bytes in this sector */
7068 + long base; /* offset from beginning of device */
7069 + int bank; /* 1 or 2 for DL; 1 for LV */
7070 + } sec[MAXSECTORS]; /* per-sector info */
7074 + * This structure holds all CFI query information as defined
7075 + * in the JEDEC standard. All information up to
7076 + * primary_extended_query is standard among all manufactures
7077 + * with CFI enabled devices.
7081 + int num_erase_blocks; /* Number of sector defs. */
7083 + unsigned long sector_size; /* byte size of sector */
7084 + int num_sectors; /* Num sectors of this size */
7085 + } erase_block[8]; /* Max of 256, but 8 is good */
7088 +/* Standard Boolean declarations */
7092 +/* Define different type of flash */
7093 +#define FLASH_UNDEFINED 0
7094 +#define FLASH_AMD 1
7095 +#define FLASH_INTEL 2
7096 +#define FLASH_SST 3
7098 +/* Command codes for the flash_command routine */
7099 +#define FLASH_RESET 0 /* reset to read mode */
7100 +#define FLASH_READ_ID 1 /* read device ID */
7101 +#define FLASH_CFIQUERY 2 /* CFI query */
7102 +#define FLASH_UB 3 /* go into unlock bypass mode */
7103 +#define FLASH_PROG 4 /* program a word */
7104 +#define FLASH_UBRESET 5 /* reset to read mode from unlock bypass mode */
7105 +#define FLASH_SERASE 6 /* sector erase */
7107 +/* Return codes from flash_status */
7108 +#define STATUS_READY 0 /* ready for action */
7109 +#define STATUS_TIMEOUT 1 /* operation timed out */
7111 +/* A list of AMD compatible device ID's - add others as needed */
7112 +#define ID_AM29DL800T 0x224A
7113 +#define ID_AM29DL800B 0x22CB
7114 +#define ID_AM29LV800T 0x22DA
7115 +#define ID_AM29LV800B 0x225B
7116 +#define ID_AM29LV400B 0x22BA
7118 +#define ID_AM29LV160B 0x2249
7119 +#define ID_AM29LV160T 0x22C4
7121 +#define ID_AM29LV320T 0x22F6
7122 +#define ID_MX29LV320AT 0x22A7
7123 +#define ID_AM29LV320B 0x22F9
7124 +#define ID_MX29LV320AB 0x22A8
7126 +#define ID_AM29LV320M 0x227E
7127 +#define ID_AM29LV320MB 0x2200
7128 +#define ID_AM29LV320MT 0x2201
7130 +#define ID_SST39VF1601 0x234B
7131 +#define ID_SST39VF3201 0x235B
7133 +/* A list of Intel compatible device ID's - add others as needed */
7134 +#define ID_I28F160C3T 0x88C2
7135 +#define ID_I28F160C3B 0x88C3
7136 +#define ID_I28F320C3T 0x88C4
7137 +#define ID_I28F320C3B 0x88C5
7139 +extern byte flash_init(void);
7140 +extern int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes);
7141 +extern int flash_read_buf(WORD sector, int offset, byte *buffer, int numbytes);
7142 +extern byte flash_sector_erase_int(WORD sector);
7143 +extern int flash_get_numsectors(void);
7144 +extern int flash_get_sector_size(WORD sector);
7145 +extern int flash_get_total_size(void);
7146 +extern unsigned char *flash_get_memptr(WORD sector);
7147 +extern int flash_get_blk(int addr);
7150 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c
7151 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/irq.c 1970-01-01 01:00:00.000000000 +0100
7152 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/irq.c 2006-08-03 16:36:58.000000000 +0200
7156 + Copyright 2002 Broadcom Corp. All Rights Reserved.
7158 + This program is free software; you can distribute it and/or modify it
7159 + under the terms of the GNU General Public License (Version 2) as
7160 + published by the Free Software Foundation.
7162 + This program is distributed in the hope it will be useful, but WITHOUT
7163 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7164 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7167 + You should have received a copy of the GNU General Public License along
7168 + with this program; if not, write to the Free Software Foundation, Inc.,
7169 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7173 + * Interrupt control functions for Broadcom 963xx MIPS boards
7176 +#include <asm/atomic.h>
7178 +#include <linux/delay.h>
7179 +#include <linux/init.h>
7180 +#include <linux/ioport.h>
7181 +#include <linux/irq.h>
7182 +#include <linux/interrupt.h>
7183 +#include <linux/kernel.h>
7184 +#include <linux/slab.h>
7185 +#include <linux/module.h>
7186 +#include <linux/spinlock.h>
7188 +#include <asm/irq.h>
7189 +#include <asm/mipsregs.h>
7190 +#include <asm/addrspace.h>
7191 +#include <asm/signal.h>
7192 +#include <bcm_map_part.h>
7193 +#include <bcm_intr.h>
7195 +static DEFINE_SPINLOCK(irq_lock);
7197 +static void irq_dispatch_int(struct pt_regs *regs)
7199 + unsigned int pendingIrqs;
7200 + static unsigned int irqBit;
7201 + static unsigned int isrNumber = 31;
7203 + pendingIrqs = PERF->IrqStatus & PERF->IrqMask;
7204 + if (!pendingIrqs) {
7211 + if (isrNumber == 32) {
7215 + if (pendingIrqs & irqBit) {
7216 + PERF->IrqMask &= ~irqBit; // mask
7217 + do_IRQ(isrNumber + INTERNAL_ISR_TABLE_OFFSET, regs);
7223 +static void irq_dispatch_ext(uint32 irq, struct pt_regs *regs)
7225 + if (!(PERF->ExtIrqCfg & (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)))) {
7226 + printk("**** Ext IRQ mask. Should not dispatch ****\n");
7228 + /* disable and clear interrupt in the controller */
7229 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7230 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7231 + do_IRQ(irq, regs);
7234 +void brcm_irq_dispatch(struct pt_regs *regs)
7237 + while((cause = (read_c0_cause()& CAUSEF_IP))) {
7238 + if (cause & CAUSEF_IP7)
7239 + do_IRQ(MIPS_TIMER_INT, regs);
7240 + else if (cause & CAUSEF_IP2)
7241 + irq_dispatch_int(regs);
7242 + else if (cause & CAUSEF_IP3)
7243 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7244 + else if (cause & CAUSEF_IP4)
7245 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7246 + else if (cause & CAUSEF_IP5)
7247 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7248 + else if (cause & CAUSEF_IP6)
7249 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7251 + spin_lock_irq(&irq_lock);
7255 +void plat_irq_dispatch(struct pt_regs *regs)
7258 + while((cause = (read_c0_cause()& CAUSEF_IP))) {
7259 + if (cause & CAUSEF_IP7)
7260 + do_IRQ(MIPS_TIMER_INT, regs);
7261 + else if (cause & CAUSEF_IP2)
7262 + irq_dispatch_int(regs);
7263 + else if (cause & CAUSEF_IP3)
7264 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_0, regs);
7265 + else if (cause & CAUSEF_IP4)
7266 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_1, regs);
7267 + else if (cause & CAUSEF_IP5)
7268 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_2, regs);
7269 + else if (cause & CAUSEF_IP6)
7270 + irq_dispatch_ext(INTERRUPT_ID_EXTERNAL_3, regs);
7272 + spin_lock_irq(&irq_lock);
7277 +void enable_brcm_irq(unsigned int irq)
7279 + unsigned long flags;
7281 + local_irq_save(flags);
7282 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7283 + PERF->IrqMask |= (1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7285 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7286 + /* enable and clear interrupt in the controller */
7287 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT));
7288 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7290 + local_irq_restore(flags);
7293 +void disable_brcm_irq(unsigned int irq)
7295 + unsigned long flags;
7297 + local_irq_save(flags);
7298 + if( irq >= INTERNAL_ISR_TABLE_OFFSET ) {
7299 + PERF->IrqMask &= ~(1 << (irq - INTERNAL_ISR_TABLE_OFFSET));
7301 + else if (irq >= INTERRUPT_ID_EXTERNAL_0 && irq <= INTERRUPT_ID_EXTERNAL_3) {
7302 + /* disable interrupt in the controller */
7303 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT));
7305 + local_irq_restore(flags);
7308 +void ack_brcm_irq(unsigned int irq)
7310 + /* Already done in brcm_irq_dispatch */
7313 +unsigned int startup_brcm_irq(unsigned int irq)
7315 + enable_brcm_irq(irq);
7317 + return 0; /* never anything pending */
7320 +unsigned int startup_brcm_none(unsigned int irq)
7325 +void end_brcm_irq(unsigned int irq)
7327 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
7328 + enable_brcm_irq(irq);
7331 +void end_brcm_none(unsigned int irq)
7335 +#define ALLINTS_NOTIMER (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
7337 +static void __init brcm_irq_setup(void)
7339 + extern asmlinkage void brcmIRQ(void);
7341 + clear_c0_status(ST0_BEV);
7342 + set_except_vector(0, brcmIRQ);
7343 + change_c0_status(ST0_IM, ALLINTS_NOTIMER);
7345 +#ifdef CONFIG_REMOTE_DEBUG
7350 +static struct hw_interrupt_type brcm_irq_type = {
7351 + .typename = "MIPS",
7352 + .startup = startup_brcm_irq,
7353 + .shutdown = disable_brcm_irq,
7354 + .enable = enable_brcm_irq,
7355 + .disable = disable_brcm_irq,
7356 + .ack = ack_brcm_irq,
7357 + .end = end_brcm_irq,
7358 + .set_affinity = NULL
7361 +static struct hw_interrupt_type brcm_irq_no_end_type = {
7362 + .typename = "MIPS",
7363 + .startup = startup_brcm_none,
7364 + .shutdown = disable_brcm_irq,
7365 + .enable = enable_brcm_irq,
7366 + .disable = disable_brcm_irq,
7367 + .ack = ack_brcm_irq,
7368 + .end = end_brcm_none,
7369 + .set_affinity = NULL
7372 +void __init arch_init_irq(void)
7376 + for (i = 0; i < NR_IRQS; i++) {
7377 + irq_desc[i].status = IRQ_DISABLED;
7378 + irq_desc[i].action = 0;
7379 + irq_desc[i].depth = 1;
7380 + irq_desc[i].handler = &brcm_irq_type;
7386 +int request_external_irq(unsigned int irq,
7387 + FN_HANDLER handler,
7388 + unsigned long irqflags,
7389 + const char * devname,
7392 + unsigned long flags;
7394 + local_irq_save(flags);
7396 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_CLEAR_SHFT)); // Clear
7397 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_MASK_SHFT)); // Mask
7398 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_INSENS_SHFT)); // Edge insesnsitive
7399 + PERF->ExtIrqCfg |= (1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_LEVEL_SHFT)); // Level triggered
7400 + PERF->ExtIrqCfg &= ~(1 << (irq - INTERRUPT_ID_EXTERNAL_0 + EI_SENSE_SHFT)); // Low level
7402 + local_irq_restore(flags);
7404 + return( request_irq(irq, handler, irqflags, devname, dev_id) );
7407 +/* VxWorks compatibility function(s). */
7409 +unsigned int BcmHalMapInterrupt(FN_HANDLER pfunc, unsigned int param,
7410 + unsigned int interruptId)
7415 + devname = kmalloc(16, GFP_KERNEL);
7417 + sprintf( devname, "brcm_%d", interruptId );
7419 + /* Set the IRQ description to not automatically enable the interrupt at
7420 + * the end of an ISR. The driver that handles the interrupt must
7421 + * explicitly call BcmHalInterruptEnable or enable_brcm_irq. This behavior
7422 + * is consistent with interrupt handling on VxWorks.
7424 + irq_desc[interruptId].handler = &brcm_irq_no_end_type;
7426 + if( interruptId >= INTERNAL_ISR_TABLE_OFFSET )
7428 + nRet = request_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7429 + devname, (void *) param );
7431 + else if (interruptId >= INTERRUPT_ID_EXTERNAL_0 && interruptId <= INTERRUPT_ID_EXTERNAL_3)
7433 + nRet = request_external_irq( interruptId, pfunc, SA_SAMPLE_RANDOM | SA_INTERRUPT,
7434 + devname, (void *) param );
7441 +/* Debug function. */
7443 +void dump_intr_regs(void)
7445 + printk("PERF->ExtIrqCfg [%08x]\n", *(&(PERF->ExtIrqCfg)));
7448 +EXPORT_SYMBOL(enable_brcm_irq);
7449 +EXPORT_SYMBOL(disable_brcm_irq);
7450 +EXPORT_SYMBOL(request_external_irq);
7451 +EXPORT_SYMBOL(BcmHalMapInterrupt);
7453 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig
7454 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
7455 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Kconfig 2006-08-03 16:36:58.000000000 +0200
7457 +# Kernel and Driver configuration for Broadcom Commengine ADSL board
7459 + prompt "Broadcom Commengine ADSL board"
7460 + depends on MIPS_BRCM
7463 + Select different Broadcom ADSL board
7466 + bool "96338 ADSL board"
7467 + select DMA_NONCOHERENT
7471 + bool "96345 ADSL board"
7472 + select DMA_NONCOHERENT
7476 + bool "96348 ADSL board"
7477 + select DMA_NONCOHERENT
7483 + bool "Support for Broadcom Board"
7484 + depends on BCM96338 || BCM96345 || BCM96348
7487 + bool "Support for Serial Port"
7488 + depends on BCM96338 || BCM96345 || BCM96348
7491 + tristate "Support for Ethernet"
7492 + depends on BCM96338 || BCM96345 || BCM96348
7495 + tristate "Support for USB"
7496 + depends on BCM96338 || BCM96345 || BCM96348
7499 + tristate "Support for Wireless"
7500 + depends on BCM96338 || BCM96345 || BCM96348
7503 + bool "Support for PCI"
7504 + depends on BCM96338 || BCM96345 || BCM96348
7508 + tristate "Support for ATM"
7509 + depends on BCM96338 || BCM96345 || BCM96348
7512 + tristate "Support for ATM Diagnostic"
7513 + depends on BCM96338 || BCM96345 || BCM96348
7516 + tristate "Support for ADSL"
7517 + depends on BCM96338 || BCM96345 || BCM96348
7519 +config BCM_ENDPOINT
7520 + tristate "Support for VOICE"
7521 + depends on BCM96338 || BCM96345 || BCM96348
7524 + tristate "Support for PROCFS"
7525 + depends on BCM96338 || BCM96345 || BCM96348
7528 + tristate "Support for VDSL"
7529 + depends on BCM96338 || BCM96345 || BCM96348
7531 +config BCM_SECURITY
7532 + tristate "Support for SECURITY"
7533 + depends on BCM96338 || BCM96345 || BCM96348
7536 + tristate "Support for HPNA"
7537 + depends on BCM96338 || BCM96345 || BCM96348
7539 +config BCM_BOARD_IMPL
7540 + int "Implementation index for ADSL Board"
7541 + depends on BCM96338 || BCM96345 || BCM96348
7543 +config BCM_SERIAL_IMPL
7544 + int "Implementation index for Serial"
7545 + depends on BCM96338 || BCM96345 || BCM96348
7547 +config BCM_ENET_IMPL
7548 + int "Implementation index for Ethernet"
7549 + depends on BCM96338 || BCM96345 || BCM96348
7551 +config BCM_USB_IMPL
7552 + int "Implementation index for USB"
7553 + depends on BCM96338 || BCM96345 || BCM96348
7555 +config BCM_WLAN_IMPL
7556 + int "Implementation index for WIRELESS"
7557 + depends on BCM96338 || BCM96345 || BCM96348
7559 +config BCM_ATMAPI_IMPL
7560 + int "Implementation index for ATM"
7561 + depends on BCM96338 || BCM96345 || BCM96348
7563 +config BCM_ATMTEST_IMPL
7564 + int "Implementation index for ATM Diagnostic"
7565 + depends on BCM96338 || BCM96345 || BCM96348
7567 +config BCM_BLAA_IMPL
7568 + int "Implementation index for BLAA"
7569 + depends on BCM96338 || BCM96345 || BCM96348
7571 +config BCM_ADSL_IMPL
7572 + int "Implementation index for ADSL"
7573 + depends on BCM96338 || BCM96345 || BCM96348
7575 +config BCM_ENDPOINT_IMPL
7576 + int "Implementation index for VOICE"
7577 + depends on BCM96338 || BCM96345 || BCM96348
7579 +config BCM_PROCFS_IMPL
7580 + int "Implementation index for PROCFS"
7581 + depends on BCM96338 || BCM96345 || BCM96348
7583 +config BCM_VDSL_IMPL
7584 + int "Implementation index for VDSL"
7585 + depends on BCM96338 || BCM96345 || BCM96348
7587 +config BCM_SECURITY_IMPL
7588 + int "Implementation index for SECURITY"
7589 + depends on BCM96338 || BCM96345 || BCM96348
7591 +config BCM_HPNA_IMPL
7592 + int "Implementation index for HPNA"
7593 + depends on BCM96338 || BCM96345 || BCM96348
7596 + prompt "Root File System"
7597 + depends on MIPS_BRCM
7598 + default ROOTFS_SQUASHFS
7600 + Select root file system on the board flash.
7602 +config ROOTFS_SQUASHFS
7604 +config ROOTFS_CRAMFS
7606 +config ROOTFS_JFFS2
7613 +config ROOT_FLASHFS
7614 + string "flash partition"
7615 + depends on ROOTFS_SQUASHFS || ROOTFS_CRAMFS || ROOTFS_JFFS2
7616 + default "root=31:0 ro noinitrd" if ROOTFS_SQUASHFS = y || ROOTFS_CRAMFS = y
7617 + default "root=31:2 ro noinitrd" if ROOTFS_JFFS2 = y
7619 + This is the root file system partition on flash memory
7621 +config ROOT_NFS_DIR
7622 + string "NFS server path"
7623 + depends on ROOTFS_NFS
7624 + default "/opt/bcm96338/targets/96338R/fs" if BCM96338 = y
7625 + default "/opt/bcm96345/targets/96345R/fs" if BCM96345 = y
7626 + default "/opt/bcm96348/targets/96348R/fs" if BCM96348 = y
7628 + This is the path of NFS server (host system)
7629 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile
7630 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/Makefile 1970-01-01 01:00:00.000000000 +0100
7631 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/Makefile 2006-08-03 16:36:58.000000000 +0200
7634 +# Makefile for generic Broadcom MIPS boards
7636 +# Copyright (C) 2004 Broadcom Corporation
7638 +obj-y := irq.o prom.o setup.o time.o ser_init.o bcm63xx_flash.o bcm63xx_led.o board.o boardparms.o cfiflash.o
7640 +SRCBASE := $(TOPDIR)
7641 +EXTRA_CFLAGS += -I$(SRCBASE)/include
7642 +#EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH) -DDBG
7643 +EXTRA_CFLAGS += -I$(INC_ADSLDRV_PATH)
7646 +ifeq "$(ADSL)" "ANNEX_B"
7647 +EXTRA_CFLAGS += -DADSL_ANNEXB
7649 +ifeq "$(ADSL)" "SADSL"
7650 +EXTRA_CFLAGS += -DADSL_SADSL
7652 +ifeq "$(ADSL)" "ANNEX_C"
7653 +EXTRA_CFLAGS += -DADSL_ANNEXC
7656 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c
7657 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/prom.c 1970-01-01 01:00:00.000000000 +0100
7658 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/prom.c 2006-08-03 16:40:27.000000000 +0200
7662 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7664 + This program is free software; you can distribute it and/or modify it
7665 + under the terms of the GNU General Public License (Version 2) as
7666 + published by the Free Software Foundation.
7668 + This program is distributed in the hope it will be useful, but WITHOUT
7669 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7670 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7673 + You should have received a copy of the GNU General Public License along
7674 + with this program; if not, write to the Free Software Foundation, Inc.,
7675 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7679 + * prom.c: PROM library initialization code.
7682 +#include <linux/init.h>
7683 +#include <linux/mm.h>
7684 +#include <linux/sched.h>
7685 +#include <linux/bootmem.h>
7686 +#include <linux/blkdev.h>
7687 +#include <asm/addrspace.h>
7688 +#include <asm/bootinfo.h>
7689 +#include <asm/cpu.h>
7690 +#include <asm/time.h>
7692 +#include <bcm_map_part.h>
7694 +#include "boardparms.h"
7695 +#include "softdsl/AdslCoreDefs.h"
7698 +//char arcs_cmdline[CL_SIZE] __initdata = {0};
7700 +int boot_loader_type;
7702 +extern int do_syslog(int, char *, int);
7703 +extern void serial_init(void);
7704 +extern void __init InitNvramInfo( void );
7705 +extern void kerSysFlashInit( void );
7706 +extern unsigned long get_nvram_start_addr(void);
7707 +void __init create_root_nfs_cmdline( char *cmdline );
7709 +#if defined(CONFIG_BCM96338)
7710 +#define CPU_CLOCK 240000000
7711 +#define MACH_BCM MACH_BCM96338
7713 +#if defined(CONFIG_BCM96345)
7714 +#define CPU_CLOCK 140000000
7715 +#define MACH_BCM MACH_BCM96345
7717 +#if defined(CONFIG_BCM96348)
7718 +void __init calculateCpuSpeed(void);
7719 +static unsigned long cpu_speed;
7720 +#define CPU_CLOCK cpu_speed
7721 +#define MACH_BCM MACH_BCM96348
7724 +const char *get_system_type(void)
7726 + /*PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7728 + return( pNvramData->szBoardId );*/
7729 + return "brcm63xx";
7732 +unsigned long getMemorySize(void)
7734 + unsigned long ulSdramType = BOARD_SDRAM_TYPE;
7736 + unsigned long ulSdramSize;
7738 + switch( ulSdramType )
7740 + case BP_MEMORY_16MB_1_CHIP:
7741 + case BP_MEMORY_16MB_2_CHIP:
7742 + ulSdramSize = 16 * 1024 * 1024;
7744 + case BP_MEMORY_32MB_1_CHIP:
7745 + case BP_MEMORY_32MB_2_CHIP:
7746 + ulSdramSize = 32 * 1024 * 1024;
7748 + case BP_MEMORY_64MB_2_CHIP:
7749 + ulSdramSize = 64 * 1024 * 1024;
7752 + ulSdramSize = 8 * 1024 * 1024;
7755 + if (boot_loader_type == BOOT_CFE)
7756 + return ulSdramSize;
7758 + // assume that there is one contiguous memory map
7759 + return boot_mem_map.map[0].size;
7762 +/* --------------------------------------------------------------------------
7764 + -------------------------------------------------------------------------- */
7765 +void __init prom_init(void)
7767 + extern ulong r4k_interval;
7771 + /* Need to fixup boot loader detection code
7772 + * whithout changing prom_init prototype
7775 + if (boot_loader_type == BOOT_CFE)
7776 + kerSysFlashInit();
7778 + do_syslog(8, NULL, 8);
7780 + printk( "%s prom init\n", get_system_type() );
7782 + PERF->IrqMask = 0;
7784 + arcs_cmdline[0] = '\0';
7785 +#if defined(CONFIG_ROOT_NFS)
7786 + create_root_nfs_cmdline( arcs_cmdline );
7787 +#elif defined(CONFIG_ROOT_FLASHFS)
7788 + strcpy(arcs_cmdline, CONFIG_ROOT_FLASHFS);
7790 +//#define ADSL_SDRAM_IMAGE_SIZE 0x40000
7792 + //add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7793 + if (boot_loader_type == BOOT_CFE)
7794 + add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7796 + add_memory_region(0, (0x01000000 - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
7797 +#if defined(CONFIG_BCM96348)
7798 + calculateCpuSpeed();
7800 + /* Count register increments every other clock */
7801 + r4k_interval = CPU_CLOCK / HZ / 2;
7802 + mips_hpt_frequency = CPU_CLOCK / 2;
7804 + mips_machgroup = MACH_GROUP_BRCM;
7805 + mips_machtype = MACH_BCM;
7808 +/* --------------------------------------------------------------------------
7809 + Name: prom_free_prom_memory
7811 + -------------------------------------------------------------------------- */
7812 +void __init prom_free_prom_memory(void)
7818 +#if defined(CONFIG_ROOT_NFS)
7819 +/* This function reads in a line that looks something like this:
7822 + * CFE bootline=bcmEnet(0,0)host:vmlinux e=192.169.0.100:ffffff00 h=192.169.0.1
7825 + * and retuns in the cmdline parameter some that looks like this:
7827 + * CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/opt/targets/96345R/fs
7828 + * ip=192.168.0.100:192.168.0.1::255.255.255.0::eth0:off rw"
7830 +#define BOOT_LINE_ADDR 0x0
7831 +#define HEXDIGIT(d) ((d >= '0' && d <= '9') ? (d - '0') : ((d | 0x20) - 'W'))
7832 +#define HEXBYTE(b) (HEXDIGIT((b)[0]) << 4) + HEXDIGIT((b)[1])
7833 +extern unsigned long get_nvram_start_addr(void);
7835 +void __init create_root_nfs_cmdline( char *cmdline )
7837 + char root_nfs_cl[] = "root=/dev/nfs nfsroot=%s:" CONFIG_ROOT_NFS_DIR
7838 + " ip=%s:%s::%s::eth0:off rw";
7840 + char *localip = NULL;
7841 + char *hostip = NULL;
7842 + char mask[16] = "";
7843 + PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
7844 + char bootline[128] = "";
7845 + char *p = bootline;
7847 + memcpy(bootline, pNvramData->szBootline, sizeof(bootline));
7850 + if( p[0] == 'e' && p[1] == '=' )
7852 + /* Found local ip address */
7855 + while( *p && *p != ' ' && *p != ':' )
7859 + /* Found network mask (eg FFFFFF00 */
7861 + sprintf( mask, "%u.%u.%u.%u", HEXBYTE(p), HEXBYTE(p + 2),
7862 + HEXBYTE(p + 4), HEXBYTE(p + 6) );
7865 + else if( *p == ' ' )
7868 + else if( p[0] == 'h' && p[1] == '=' )
7870 + /* Found host ip address */
7873 + while( *p && *p != ' ' )
7882 + if( localip && hostip )
7883 + sprintf( cmdline, root_nfs_cl, hostip, localip, hostip, mask );
7888 +#if defined(CONFIG_BCM96348)
7889 +/* *********************************************************************
7890 + * calculateCpuSpeed()
7891 + * Calculate the BCM6348 CPU speed by reading the PLL strap register
7892 + * and applying the following formula:
7893 + * cpu_clk = (.25 * 64MHz freq) * (N1 + 1) * (N2 + 2) / (M1_CPU + 1)
7894 + * Input parameters:
7898 + ********************************************************************* */
7899 +void __init calculateCpuSpeed(void)
7901 + UINT32 pllStrap = PERF->PllStrap;
7902 + int n1 = (pllStrap & PLL_N1_MASK) >> PLL_N1_SHFT;
7903 + int n2 = (pllStrap & PLL_N2_MASK) >> PLL_N2_SHFT;
7904 + int m1cpu = (pllStrap & PLL_M1_CPU_MASK) >> PLL_M1_CPU_SHFT;
7906 + cpu_speed = (16 * (n1 + 1) * (n2 + 2) / (m1cpu + 1)) * 1000000;
7910 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c
7911 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/ser_init.c 1970-01-01 01:00:00.000000000 +0100
7912 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/ser_init.c 2006-08-03 16:36:58.000000000 +0200
7916 + Copyright 2004 Broadcom Corp. All Rights Reserved.
7918 + This program is free software; you can distribute it and/or modify it
7919 + under the terms of the GNU General Public License (Version 2) as
7920 + published by the Free Software Foundation.
7922 + This program is distributed in the hope it will be useful, but WITHOUT
7923 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7924 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7927 + You should have received a copy of the GNU General Public License along
7928 + with this program; if not, write to the Free Software Foundation, Inc.,
7929 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
7933 + * Broadcom bcm63xx serial port initialization, also prepare for printk
7934 + * by registering with console_init
7938 +#include <linux/config.h>
7939 +#include <linux/init.h>
7940 +#include <linux/interrupt.h>
7941 +#include <linux/kernel.h>
7942 +#include <linux/types.h>
7943 +#include <linux/console.h>
7944 +#include <linux/sched.h>
7946 +#include <asm/addrspace.h>
7947 +#include <asm/irq.h>
7948 +#include <asm/reboot.h>
7949 +#include <asm/gdb-stub.h>
7950 +#include <asm/mc146818rtc.h>
7952 +#include <bcm_map_part.h>
7955 +#define SER63XX_DEFAULT_BAUD 115200
7956 +#define BD_BCM63XX_TIMER_CLOCK_INPUT (FPERIPH)
7957 +#define stUart ((volatile Uart * const) UART_BASE)
7959 +// Transmit interrupts
7960 +#define TXINT (TXFIFOEMT | TXUNDERR | TXOVFERR)
7961 +// Receive interrupts
7962 +#define RXINT (RXFIFONE | RXOVFERR)
7964 +/* --------------------------------------------------------------------------
7966 + Purpose: Initalize the UART
7967 +-------------------------------------------------------------------------- */
7968 +void __init serial_init(void)
7970 + UINT32 tmpVal = SER63XX_DEFAULT_BAUD;
7971 + ULONG clockFreqHz;
7973 +#if defined(CONFIG_BCM96345)
7974 + // Make sure clock is ticking
7975 + PERF->blkEnables |= UART_CLK_EN;
7978 + /* Dissable channel's receiver and transmitter. */
7979 + stUart->control &= ~(BRGEN|TXEN|RXEN);
7981 + /*--------------------------------------------------------------------*/
7982 + /* Write the table value to the clock select register. */
7983 + /* DPullen - this is the equation to use: */
7984 + /* value = clockFreqHz / baud / 32-1; */
7985 + /* (snmod) Actually you should also take into account any necessary */
7986 + /* rounding. Divide by 16, look at lsb, if 0, divide by 2 */
7987 + /* and subtract 1. If 1, just divide by 2 */
7988 + /*--------------------------------------------------------------------*/
7989 + clockFreqHz = BD_BCM63XX_TIMER_CLOCK_INPUT;
7990 + tmpVal = (clockFreqHz / tmpVal) / 16;
7991 + if( tmpVal & 0x01 )
7992 + tmpVal /= 2; //Rounding up, so sub is already accounted for
7994 + tmpVal = (tmpVal / 2) - 1; // Rounding down so we must sub 1
7995 + stUart->baudword = tmpVal;
7997 + /* Finally, re-enable the transmitter and receiver. */
7998 + stUart->control |= (BRGEN|TXEN|RXEN);
8000 + stUart->config = (BITS8SYM | ONESTOP);
8001 + // Set the FIFO interrupt depth ... stUart->fifocfg = 0xAA;
8002 + stUart->fifoctl = RSTTXFIFOS | RSTRXFIFOS;
8003 + stUart->intMask = 0;
8004 + stUart->intMask = RXINT | TXINT;
8009 + * Output a character to the UART
8011 +void prom_putc(char c)
8013 + /* Wait for Tx uffer to empty */
8014 + while (! (READ16(stUart->intStatus) & TXFIFOEMT));
8015 + /* Send character */
8020 + * Write a string to the UART
8022 +void prom_puts(const char *s)
8033 +/* prom_getc_nowait()
8034 + * Returns a character from the UART
8035 + * Returns -1 if no characters available or corrupted
8037 +int prom_getc_nowait(void)
8042 + uStatus = READ16(stUart->intStatus);
8044 + if (uStatus & RXFIFONE) { /* Do we have a character? */
8045 + cData = READ16(stUart->Data) & 0xff; /* Read character */
8046 + if (uStatus & (RXFRAMERR | RXPARERR)) { /* If we got an error, throw it away */
8055 + * Returns a charcter from the serial port
8056 + * Will block until it receives a valid character
8058 +char prom_getc(void)
8062 + /* Loop until we get a valid character */
8063 + while(cData == -1) {
8064 + cData = prom_getc_nowait();
8066 + return (char) cData;
8070 + * Returns 0 if no characters available
8072 +int prom_testc(void)
8076 + uStatus = READ16(stUart->intStatus);
8078 + return (uStatus & RXFIFONE);
8081 +#if defined (CONFIG_REMOTE_DEBUG)
8082 +/* Prevent other code from writing to the serial port */
8083 +void _putc(char c) { }
8084 +void _puts(const char *ptr) { }
8086 +/* Low level outputs call prom routines */
8087 +void _putc(char c) {
8090 +void _puts(const char *ptr) {
8094 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c
8095 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/setup.c 1970-01-01 01:00:00.000000000 +0100
8096 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/setup.c 2006-08-03 16:36:58.000000000 +0200
8100 + Copyright 2002 Broadcom Corp. All Rights Reserved.
8102 + This program is free software; you can distribute it and/or modify it
8103 + under the terms of the GNU General Public License (Version 2) as
8104 + published by the Free Software Foundation.
8106 + This program is distributed in the hope it will be useful, but WITHOUT
8107 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8108 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8111 + You should have received a copy of the GNU General Public License along
8112 + with this program; if not, write to the Free Software Foundation, Inc.,
8113 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8117 + * Generic setup routines for Broadcom 963xx MIPS boards
8120 +#include <linux/config.h>
8121 +#include <linux/init.h>
8122 +#include <linux/interrupt.h>
8123 +#include <linux/kernel.h>
8124 +#include <linux/kdev_t.h>
8125 +#include <linux/types.h>
8126 +#include <linux/console.h>
8127 +#include <linux/sched.h>
8128 +#include <linux/mm.h>
8129 +#include <linux/slab.h>
8130 +#include <linux/module.h>
8131 +#include <linux/pm.h>
8133 +#include <asm/addrspace.h>
8134 +#include <asm/bcache.h>
8135 +#include <asm/irq.h>
8136 +#include <asm/time.h>
8137 +#include <asm/reboot.h>
8138 +#include <asm/gdb-stub.h>
8140 +extern void brcm_timer_setup(struct irqaction *irq);
8141 +extern unsigned long getMemorySize(void);
8143 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8144 +#include <linux/pci.h>
8145 +#include <linux/delay.h>
8146 +#include <bcm_map_part.h>
8147 +#include <bcmpci.h>
8149 +static volatile MpiRegisters * mpi = (MpiRegisters *)(MPI_BASE);
8152 +/* This function should be in a board specific directory. For now,
8153 + * assume that all boards that include this file use a Broadcom chip
8154 + * with a soft reset bit in the PLL control register.
8156 +static void brcm_machine_restart(char *command)
8158 + const unsigned long ulSoftReset = 0x00000001;
8159 + unsigned long *pulPllCtrl = (unsigned long *) 0xfffe0008;
8160 + *pulPllCtrl |= ulSoftReset;
8163 +static void brcm_machine_halt(void)
8165 + printk("System halted\n");
8169 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8171 +static void mpi_SetLocalPciConfigReg(uint32 reg, uint32 value)
8173 + /* write index then value */
8174 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
8175 + mpi->pcicfgdata = value;
8178 +static uint32 mpi_GetLocalPciConfigReg(uint32 reg)
8180 + /* write index then get value */
8181 + mpi->pcicfgcntrl = PCI_CFG_REG_WRITE_EN + reg;;
8182 + return mpi->pcicfgdata;
8186 + * mpi_ResetPcCard: Set/Reset the PcCard
8188 +static void mpi_ResetPcCard(int cardtype, BOOL bReset)
8190 + if (cardtype == MPI_CARDTYPE_NONE) {
8194 + if (cardtype == MPI_CARDTYPE_CARDBUS) {
8195 + bReset = ! bReset;
8199 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8201 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 | PCCARD_CARD_RESET);
8206 + * mpi_ConfigCs: Configure an MPI/EBI chip select
8208 +static void mpi_ConfigCs(uint32 cs, uint32 base, uint32 size, uint32 flags)
8210 + mpi->cs[cs].base = ((base & 0x1FFFFFFF) | size);
8211 + mpi->cs[cs].config = flags;
8215 + * mpi_InitPcmciaSpace
8217 +static void mpi_InitPcmciaSpace(void)
8219 + // ChipSelect 4 controls PCMCIA Memory accesses
8220 + mpi_ConfigCs(PCMCIA_COMMON_BASE, pcmciaMem, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8221 + // ChipSelect 5 controls PCMCIA Attribute accesses
8222 + mpi_ConfigCs(PCMCIA_ATTRIBUTE_BASE, pcmciaAttr, EBI_SIZE_1M, (EBI_WORD_WIDE|EBI_ENABLE));
8223 + // ChipSelect 6 controls PCMCIA I/O accesses
8224 + mpi_ConfigCs(PCMCIA_IO_BASE, pcmciaIo, EBI_SIZE_64K, (EBI_WORD_WIDE|EBI_ENABLE));
8226 + mpi->pcmcia_cntl2 = ((PCMCIA_ATTR_ACTIVE << RW_ACTIVE_CNT_BIT) |
8227 + (PCMCIA_ATTR_INACTIVE << INACTIVE_CNT_BIT) |
8228 + (PCMCIA_ATTR_CE_SETUP << CE_SETUP_CNT_BIT) |
8229 + (PCMCIA_ATTR_CE_HOLD << CE_HOLD_CNT_BIT));
8231 + mpi->pcmcia_cntl2 |= (PCMCIA_HALFWORD_EN | PCMCIA_BYTESWAP_DIS);
8235 + * cardtype_vcc_detect: PC Card's card detect and voltage sense connection
8237 + * CD1#/ CD2#/ VS1#/ VS2#/ Card Initial Vcc
8238 + * CCD1# CCD2# CVS1 CVS2 Type
8240 + * GND GND open open 16-bit 5 vdc
8242 + * GND GND GND open 16-bit 3.3 vdc
8244 + * GND GND open GND 16-bit x.x vdc
8246 + * GND GND GND GND 16-bit 3.3 & x.x vdc
8248 + *====================================================================
8250 + * CVS1 GND CCD1# open CardBus 3.3 vdc
8252 + * GND CVS2 open CCD2# CardBus x.x vdc
8254 + * GND CVS1 CCD2# open CardBus y.y vdc
8256 + * GND CVS2 GND CCD2# CardBus 3.3 & x.x vdc
8258 + * CVS2 GND open CCD1# CardBus x.x & y.y vdc
8260 + * GND CVS1 CCD2# open CardBus 3.3, x.x & y.y vdc
8263 +static int cardtype_vcc_detect(void)
8268 + cardtype = MPI_CARDTYPE_NONE;
8269 + mpi->pcmcia_cntl1 = 0x0000A000; // Turn on the output enables and drive
8270 + // the CVS pins to 0.
8271 + data32 = mpi->pcmcia_cntl1;
8272 + switch (data32 & 0x00000003) // Test CD1# and CD2#, see if card is plugged in.
8274 + case 0x00000003: // No Card is in the slot.
8275 + printk("mpi: No Card is in the PCMCIA slot\n");
8278 + case 0x00000002: // Partial insertion, No CD2#.
8279 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD2 signal\n");
8282 + case 0x00000001: // Partial insertion, No CD1#.
8283 + printk("mpi: Card in the PCMCIA slot partial insertion, no CD1 signal\n");
8287 + mpi->pcmcia_cntl1 = 0x0000A0C0; // Turn off the CVS output enables and
8288 + // float the CVS pins.
8290 + data32 = mpi->pcmcia_cntl1;
8291 + // Read the Register.
8292 + switch (data32 & 0x0000000C) // See what is on the CVS pins.
8294 + case 0x00000000: // CVS1 and CVS2 are tied to ground, only 1 option.
8295 + printk("mpi: Detected 3.3 & x.x 16-bit PCMCIA card\n");
8296 + cardtype = MPI_CARDTYPE_PCMCIA;
8299 + case 0x00000004: // CVS1 is open or tied to CCD1/CCD2 and CVS2 is tied to ground.
8300 + // 2 valid voltage options.
8301 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8303 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8304 + // This is not a valid combination.
8305 + printk("mpi: Unknown card plugged into slot\n");
8308 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8309 + mpi->pcmcia_cntl1 = 0x0000A080; // Drive CVS1 to a 0.
8311 + data32 = mpi->pcmcia_cntl1;
8312 + if (data32 & 0x00000002) { // CCD2 is tied to CVS2, not valid.
8313 + printk("mpi: Unknown card plugged into slot\n");
8314 + } else { // CCD2 is tied to CVS1.
8315 + printk("mpi: Detected 3.3, x.x and y.y Cardbus card\n");
8316 + cardtype = MPI_CARDTYPE_CARDBUS;
8320 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8321 + // This is not a valid combination.
8322 + printk("mpi: Unknown card plugged into slot\n");
8325 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8326 + printk("mpi: Detected x.x vdc 16-bit PCMCIA card\n");
8327 + cardtype = MPI_CARDTYPE_PCMCIA;
8332 + case 0x00000008: // CVS2 is open or tied to CCD1/CCD2 and CVS1 is tied to ground.
8333 + // 2 valid voltage options.
8334 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8336 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8337 + // This is not a valid combination.
8338 + printk("mpi: Unknown card plugged into slot\n");
8341 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8342 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8344 + data32 = mpi->pcmcia_cntl1;
8345 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1, not valid.
8346 + printk("mpi: Unknown card plugged into slot\n");
8347 + } else {// CCD2 is tied to CVS2.
8348 + printk("mpi: Detected 3.3 and x.x Cardbus card\n");
8349 + cardtype = MPI_CARDTYPE_CARDBUS;
8353 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8354 + // This is not a valid combination.
8355 + printk("mpi: Unknown card plugged into slot\n");
8358 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8359 + cardtype = MPI_CARDTYPE_PCMCIA;
8360 + printk("mpi: Detected 3.3 vdc 16-bit PCMCIA card\n");
8365 + case 0x0000000C: // CVS1 and CVS2 are open or tied to CCD1/CCD2.
8366 + // 5 valid voltage options.
8368 + switch (data32 & 0x00000003) // Test the values of CCD1 and CCD2.
8370 + case 0x00000003: // CCD1 and CCD2 are tied to 1 of the CVS pins.
8371 + // This is not a valid combination.
8372 + printk("mpi: Unknown card plugged into slot\n");
8375 + case 0x00000002: // CCD2 is tied to either CVS1 or CVS2.
8376 + // CCD1 is tied to ground.
8377 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8379 + data32 = mpi->pcmcia_cntl1;
8380 + if (data32 & 0x00000002) { // CCD2 is tied to CVS1.
8381 + printk("mpi: Detected y.y vdc Cardbus card\n");
8382 + } else { // CCD2 is tied to CVS2.
8383 + printk("mpi: Detected x.x vdc Cardbus card\n");
8385 + cardtype = MPI_CARDTYPE_CARDBUS;
8388 + case 0x00000001: // CCD1 is tied to either CVS1 or CVS2.
8389 + // CCD2 is tied to ground.
8391 + mpi->pcmcia_cntl1 = 0x0000A040; // Drive CVS2 to a 0.
8393 + data32 = mpi->pcmcia_cntl1;
8394 + if (data32 & 0x00000001) {// CCD1 is tied to CVS1.
8395 + printk("mpi: Detected 3.3 vdc Cardbus card\n");
8396 + } else { // CCD1 is tied to CVS2.
8397 + printk("mpi: Detected x.x and y.y Cardbus card\n");
8399 + cardtype = MPI_CARDTYPE_CARDBUS;
8402 + case 0x00000000: // CCD1 and CCD2 are tied to ground.
8403 + cardtype = MPI_CARDTYPE_PCMCIA;
8404 + printk("mpi: Detected 5 vdc 16-bit PCMCIA card\n");
8410 + printk("mpi: Unknown card plugged into slot\n");
8419 + * mpi_DetectPcCard: Detect the plugged in PC-Card
8420 + * Return: < 0 => Unknown card detected
8421 + * 0 => No card detected
8422 + * 1 => 16-bit card detected
8423 + * 2 => 32-bit CardBus card detected
8425 +static int mpi_DetectPcCard(void)
8429 + cardtype = cardtype_vcc_detect();
8430 + switch(cardtype) {
8431 + case MPI_CARDTYPE_PCMCIA:
8432 + mpi->pcmcia_cntl1 &= ~0x0000e000; // disable enable bits
8433 + //mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & ~PCCARD_CARD_RESET);
8434 + mpi->pcmcia_cntl1 |= (PCMCIA_ENABLE | PCMCIA_GPIO_ENABLE);
8435 + mpi_InitPcmciaSpace();
8436 + mpi_ResetPcCard(cardtype, FALSE);
8437 + // Hold card in reset for 10ms
8439 + mpi_ResetPcCard(cardtype, TRUE);
8440 + // Let card come out of reset
8443 + case MPI_CARDTYPE_CARDBUS:
8444 + // 8 => CardBus Enable
8445 + // 1 => PCI Slot Number
8446 + // C => Float VS1 & VS2
8447 + mpi->pcmcia_cntl1 = (mpi->pcmcia_cntl1 & 0xFFFF0000) |
8449 + (CARDBUS_SLOT << 8)|
8452 + /* access to this memory window will be to/from CardBus */
8453 + mpi->l2pmremap1 |= CARDBUS_MEM;
8455 + // Need to reset the Cardbus Card. There's no CardManager to do this,
8456 + // and we need to be ready for PCI configuration.
8457 + mpi_ResetPcCard(cardtype, FALSE);
8458 + // Hold card in reset for 10ms
8460 + mpi_ResetPcCard(cardtype, TRUE);
8461 + // Let card come out of reset
8470 +static int mpi_init(void)
8472 + unsigned long data;
8473 + unsigned int chipid;
8474 + unsigned int chiprev;
8475 + unsigned int sdramsize;
8477 + chipid = (PERF->RevID & 0xFFFF0000) >> 16;
8478 + chiprev = (PERF->RevID & 0xFF);
8479 + sdramsize = getMemorySize();
8481 + * Init the pci interface
8483 + data = GPIO->GPIOMode; // GPIO mode register
8484 + data |= GROUP2_PCI | GROUP1_MII_PCCARD; // PCI internal arbiter + Cardbus
8485 + GPIO->GPIOMode = data; // PCI internal arbiter
8488 + * In the BCM6348 CardBus support is defaulted to Slot 0
8489 + * because there is no external IDSEL for CardBus. To disable
8490 + * the CardBus and allow a standard PCI card in Slot 0
8491 + * set the cbus_idsel field to 0x1f.
8494 + uData = mpi->pcmcia_cntl1;
8495 + uData |= CARDBUS_IDSEL;
8496 + mpi->pcmcia_cntl1 = uData;
8498 + // Setup PCI I/O Window range. Give 64K to PCI I/O
8499 + mpi->l2piorange = ~(BCM_PCI_IO_SIZE_64KB-1);
8500 + // UBUS to PCI I/O base address
8501 + mpi->l2piobase = BCM_PCI_IO_BASE & BCM_PCI_ADDR_MASK;
8502 + // UBUS to PCI I/O Window remap
8503 + mpi->l2pioremap = (BCM_PCI_IO_BASE | MEM_WINDOW_EN);
8505 + // enable PCI related GPIO pins and data swap between system and PCI bus
8506 + mpi->locbuscntrl = (EN_PCI_GPIO | DIR_U2P_NOSWAP);
8508 + /* Enable 6348 BusMaster and Memory access mode */
8509 + data = mpi_GetLocalPciConfigReg(PCI_COMMAND);
8510 + data |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
8511 + mpi_SetLocalPciConfigReg(PCI_COMMAND, data);
8513 + /* Configure two 16 MByte PCI to System memory regions. */
8514 + /* These memory regions are used when PCI device is a bus master */
8515 + /* Accesses to the SDRAM from PCI bus will be "byte swapped" for this region */
8516 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_3, BCM_HOST_MEM_SPACE1);
8517 + mpi->sp0remap = 0x0;
8519 + /* Accesses to the SDRAM from PCI bus will not be "byte swapped" for this region */
8520 + mpi_SetLocalPciConfigReg(PCI_BASE_ADDRESS_4, BCM_HOST_MEM_SPACE2);
8521 + mpi->sp1remap = 0x0;
8522 + mpi->pcimodesel |= (PCI_BAR2_NOSWAP | 0x40);
8524 + if ((chipid == 0x6348) && (chiprev == 0xb0)) {
8525 + mpi->sp0range = ~(sdramsize-1);
8526 + mpi->sp1range = ~(sdramsize-1);
8529 + * Change 6348 PCI Cfg Reg. offset 0x40 to PCI memory read retry count infinity
8530 + * by set 0 in bit 8~15. This resolve read Bcm4306 srom return 0xffff in
8533 + data = mpi_GetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER);
8534 + data &= ~BRCM_PCI_CONFIG_TIMER_RETRY_MASK;
8535 + data |= 0x00000080;
8536 + mpi_SetLocalPciConfigReg(BRCM_PCI_CONFIG_TIMER, data);
8538 + /* enable pci interrupt */
8539 + mpi->locintstat |= (EXT_PCI_INT << 16);
8541 + mpi_DetectPcCard();
8543 + ioport_resource.start = BCM_PCI_IO_BASE;
8544 + ioport_resource.end = BCM_PCI_IO_BASE + BCM_PCI_IO_SIZE_64KB;
8546 +#if defined(CONFIG_USB)
8547 + PERF->blkEnables |= USBH_CLK_EN;
8549 + *USBH_NON_OHCI = NON_OHCI_BYTE_SWAP;
8556 +static int __init brcm63xx_setup(void)
8558 + extern int panic_timeout;
8560 + _machine_restart = brcm_machine_restart;
8561 + _machine_halt = brcm_machine_halt;
8562 + pm_power_off = brcm_machine_halt;
8564 + board_timer_setup = brcm_timer_setup;
8566 + panic_timeout = 5;
8568 +#if defined(CONFIG_BCM96348) && defined(CONFIG_PCI)
8569 + /* mpi initialization */
8575 +void plat_setup(void)
8580 +/***************************************************************************
8581 + * C++ New and delete operator functions
8582 + ***************************************************************************/
8584 +/* void *operator new(unsigned int sz) */
8585 +void *_Znwj(unsigned int sz)
8587 + return( kmalloc(sz, GFP_KERNEL) );
8590 +/* void *operator new[](unsigned int sz)*/
8591 +void *_Znaj(unsigned int sz)
8593 + return( kmalloc(sz, GFP_KERNEL) );
8596 +/* placement new operator */
8597 +/* void *operator new (unsigned int size, void *ptr) */
8598 +void *ZnwjPv(unsigned int size, void *ptr)
8603 +/* void operator delete(void *m) */
8604 +void _ZdlPv(void *m)
8609 +/* void operator delete[](void *m) */
8610 +void _ZdaPv(void *m)
8615 +EXPORT_SYMBOL(_Znwj);
8616 +EXPORT_SYMBOL(_Znaj);
8617 +EXPORT_SYMBOL(ZnwjPv);
8618 +EXPORT_SYMBOL(_ZdlPv);
8619 +EXPORT_SYMBOL(_ZdaPv);
8621 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h
8622 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 1970-01-01 01:00:00.000000000 +0100
8623 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/softdsl/AdslCoreDefs.h 2006-08-03 16:36:58.000000000 +0200
8625 +#define ADSL_SDRAM_IMAGE_SIZE (384*1024)
8627 diff -urN linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c
8628 --- linux-2.6.17/arch/mips/brcm-boards/bcm963xx/time.c 1970-01-01 01:00:00.000000000 +0100
8629 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/bcm963xx/time.c 2006-08-03 16:36:58.000000000 +0200
8633 + Copyright 2004 Broadcom Corp. All Rights Reserved.
8635 + This program is free software; you can distribute it and/or modify it
8636 + under the terms of the GNU General Public License (Version 2) as
8637 + published by the Free Software Foundation.
8639 + This program is distributed in the hope it will be useful, but WITHOUT
8640 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8641 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8644 + You should have received a copy of the GNU General Public License along
8645 + with this program; if not, write to the Free Software Foundation, Inc.,
8646 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8650 + * Setup time for Broadcom 963xx MIPS boards
8653 +#include <linux/config.h>
8654 +#include <linux/init.h>
8655 +#include <linux/kernel_stat.h>
8656 +#include <linux/sched.h>
8657 +#include <linux/spinlock.h>
8658 +#include <linux/interrupt.h>
8659 +#include <linux/module.h>
8660 +#include <linux/time.h>
8661 +#include <linux/timex.h>
8663 +#include <asm/mipsregs.h>
8664 +#include <asm/ptrace.h>
8665 +#include <asm/div64.h>
8666 +#include <asm/time.h>
8668 +#include <bcm_map_part.h>
8669 +#include <bcm_intr.h>
8671 +unsigned long r4k_interval; /* Amount to increment compare reg each time */
8672 +static unsigned long r4k_cur; /* What counter should be at next timer irq */
8674 +/* Cycle counter value at the previous timer interrupt.. */
8675 +static unsigned int timerhi = 0, timerlo = 0;
8677 +extern volatile unsigned long wall_jiffies;
8679 +/* Optional board-specific timer routine */
8680 +void (*board_timer_interrupt)(int irq, void *dev_id, struct pt_regs * regs);
8682 +static inline void ack_r4ktimer(unsigned long newval)
8684 + write_c0_compare(newval);
8688 + * There are a lot of conceptually broken versions of the MIPS timer interrupt
8689 + * handler floating around. This one is rather different, but the algorithm
8690 + * is provably more robust.
8692 +static irqreturn_t brcm_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
8694 + unsigned int count;
8696 + if (r4k_interval == 0)
8702 + if (board_timer_interrupt)
8703 + board_timer_interrupt(irq, dev_id, regs);
8705 + r4k_cur += r4k_interval;
8706 + ack_r4ktimer(r4k_cur);
8708 + } while (((count = (unsigned long)read_c0_count())
8709 + - r4k_cur) < 0x7fffffff);
8713 + * If jiffies has overflowed in this timer_interrupt we must
8714 + * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
8715 + * quotient calc still valid. -arca
8717 + timerhi = timerlo = 0;
8720 + * The cycle counter is only 32 bit which is good for about
8721 + * a minute at current count rates of upto 150MHz or so.
8723 + timerhi += (count < timerlo); /* Wrap around */
8727 + return IRQ_HANDLED;
8734 +static struct irqaction brcm_timer_action = {
8735 + .handler = brcm_timer_interrupt,
8736 + .flags = SA_INTERRUPT,
8737 + .mask = CPU_MASK_NONE,
8740 + .dev_id = brcm_timer_interrupt,
8744 +void __init brcm_timer_setup(struct irqaction *irq)
8746 + r4k_cur = (read_c0_count() + r4k_interval);
8747 + write_c0_compare(r4k_cur);
8749 + /* we are using the cpu counter for timer interrupts */
8750 + irq->handler = no_action; /* we use our own handler */
8751 + setup_irq(MIPS_TIMER_INT, &brcm_timer_action);
8752 + set_c0_status(IE_IRQ5);
8756 +/* This is for machines which generate the exact clock. */
8757 +#define USECS_PER_JIFFY (1000000/HZ)
8758 +#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
8760 +static void call_do_div64_32( unsigned long *res, unsigned int high,
8761 + unsigned int low, unsigned long base )
8763 + do_div64_32(*res, high, low, base);
8767 + * FIXME: Does playing with the RP bit in c0_status interfere with this code?
8769 +static unsigned long do_fast_gettimeoffset(void)
8772 + unsigned long res, tmp;
8774 + /* Last jiffy when do_fast_gettimeoffset() was called. */
8775 + static unsigned long last_jiffies=0;
8776 + unsigned long quotient;
8779 + * Cached "1/(clocks per usec)*2^32" value.
8780 + * It has to be recalculated once each jiffy.
8782 + static unsigned long cached_quotient=0;
8786 + quotient = cached_quotient;
8788 + if (tmp && last_jiffies != tmp) {
8789 + last_jiffies = tmp;
8790 +#ifdef CONFIG_CPU_MIPS32
8791 + if (last_jiffies != 0) {
8794 + /* gcc 3.0.1 gets an internal compiler error if there are two
8795 + * do_div64_32 inline macros. To work around this problem,
8796 + * do_div64_32 is called as a function.
8798 + call_do_div64_32(&r0, timerhi, timerlo, tmp);
8799 + call_do_div64_32("ient, USECS_PER_JIFFY,
8800 + USECS_PER_JIFFY_FRAC, r0);
8802 + cached_quotient = quotient;
8806 + __asm__(".set\tnoreorder\n\t"
8810 + "dsll32\t$1,%1,0\n\t"
8811 + "or\t$1,$1,%0\n\t"
8812 + "ddivu\t$0,$1,%3\n\t"
8814 + "dsll32\t%0,%4,0\n\t"
8816 + "ddivu\t$0,%0,$1\n\t"
8825 + "r" (USECS_PER_JIFFY)
8827 + cached_quotient = quotient;
8831 + /* Get last timer tick in absolute kernel time */
8832 + count = read_c0_count();
8834 + /* .. relative to previous jiffy (32 bits is enough) */
8837 + __asm__("multu\t%1,%2\n\t"
8844 + * Due to possible jiffies inconsistencies, we need to check
8845 + * the result so that we'll get a timer that is monotonic.
8847 + if (res >= USECS_PER_JIFFY)
8848 + res = USECS_PER_JIFFY-1;
8853 +void do_gettimeofday(struct timeval *tv)
8855 + unsigned int flags;
8857 + read_lock_irqsave (&xtime_lock, flags);
8858 + tv->tv_sec = xtime.tv_sec;
8859 + tv->tv_usec = xtime.tv_nsec/1000;
8860 + tv->tv_usec += do_fast_gettimeoffset();
8863 + * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
8864 + * is nonzero if the timer bottom half hasnt executed yet.
8866 + if (jiffies - wall_jiffies)
8867 + tv->tv_usec += USECS_PER_JIFFY;
8869 + read_unlock_irqrestore (&xtime_lock, flags);
8871 + if (tv->tv_usec >= 1000000) {
8872 + tv->tv_usec -= 1000000;
8877 +EXPORT_SYMBOL(do_gettimeofday);
8879 +int do_settimeofday(struct timespec *tv)
8881 + write_lock_irq (&xtime_lock);
8883 + /* This is revolting. We need to set the xtime.tv_usec correctly.
8884 + * However, the value in this location is is value at the last tick.
8885 + * Discover what correction gettimeofday would have done, and then
8888 + tv->tv_nsec -= do_fast_gettimeoffset()*NSEC_PER_USEC;
8890 + if (tv->tv_nsec < 0) {
8891 + tv->tv_nsec += 1000000*NSEC_PER_USEC;
8895 + xtime.tv_sec = tv->tv_sec;
8896 + xtime.tv_nsec = tv->tv_nsec;
8897 + time_adjust = 0; /* stop active adjtime() */
8898 + time_status |= STA_UNSYNC;
8899 + time_maxerror = NTP_PHASE_LIMIT;
8900 + time_esterror = NTP_PHASE_LIMIT;
8902 + write_unlock_irq (&xtime_lock);
8905 +EXPORT_SYMBOL(do_settimeofday);
8908 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c
8909 --- linux-2.6.17/arch/mips/brcm-boards/generic/dbg_io.c 1970-01-01 01:00:00.000000000 +0100
8910 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/dbg_io.c 2006-08-03 16:36:58.000000000 +0200
8914 + Copyright 2003 Broadcom Corp. All Rights Reserved.
8916 + This program is free software; you can distribute it and/or modify it
8917 + under the terms of the GNU General Public License (Version 2) as
8918 + published by the Free Software Foundation.
8920 + This program is distributed in the hope it will be useful, but WITHOUT
8921 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8922 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8925 + You should have received a copy of the GNU General Public License along
8926 + with this program; if not, write to the Free Software Foundation, Inc.,
8927 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
8931 +#include <linux/config.h>
8932 +#include <linux/tty.h>
8933 +#include <linux/major.h>
8934 +#include <linux/init.h>
8935 +#include <linux/console.h>
8936 +#include <linux/fs.h>
8937 +#include <linux/interrupt.h>
8938 +#include <linux/kernel.h>
8939 +#include <linux/types.h>
8940 +#include <linux/sched.h>
8942 +#include <bcm_map_part.h>
8944 +#undef PRNT /* define for debug printing */
8946 +#define UART16550_BAUD_2400 2400
8947 +#define UART16550_BAUD_4800 4800
8948 +#define UART16550_BAUD_9600 9600
8949 +#define UART16550_BAUD_19200 19200
8950 +#define UART16550_BAUD_38400 38400
8951 +#define UART16550_BAUD_57600 57600
8952 +#define UART16550_BAUD_115200 115200
8954 +#define UART16550_PARITY_NONE 0
8955 +#define UART16550_PARITY_ODD 0x08
8956 +#define UART16550_PARITY_EVEN 0x18
8957 +#define UART16550_PARITY_MARK 0x28
8958 +#define UART16550_PARITY_SPACE 0x38
8960 +#define UART16550_DATA_5BIT 0x0
8961 +#define UART16550_DATA_6BIT 0x1
8962 +#define UART16550_DATA_7BIT 0x2
8963 +#define UART16550_DATA_8BIT 0x3
8965 +#define UART16550_STOP_1BIT 0x0
8966 +#define UART16550_STOP_2BIT 0x4
8968 +volatile Uart * stUart = UART_BASE;
8970 +#define WRITE16(addr, value) ((*(volatile UINT16 *)((ULONG)&addr)) = value)
8972 +/* Low level UART routines from promcon.c */
8973 +extern void prom_putc(char c);
8974 +extern char prom_getc(void);
8975 +extern int prom_getc_nowait(void);
8976 +extern int prom_testc(void);
8978 +extern void set_debug_traps(void);
8979 +extern void breakpoint(void);
8980 +extern void enable_brcm_irq(unsigned int);
8981 +extern void set_async_breakpoint(unsigned int epc);
8983 +#ifdef CONFIG_GDB_CONSOLE
8984 +extern void register_gdb_console(void);
8987 +int gdb_initialized = 0;
8989 +#define GDB_BUF_SIZE 512 /* power of 2, please */
8991 +static char gdb_buf[GDB_BUF_SIZE] ;
8992 +static int gdb_buf_in_inx ;
8993 +static atomic_t gdb_buf_in_cnt ;
8994 +static int gdb_buf_out_inx ;
8996 +void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
8998 + /* Do nothing, assume boot loader has already set up serial port */
8999 + printk("debugInit called\n");
9003 + * Get a char if available, return -1 if nothing available.
9004 + * Empty the receive buffer first, then look at the interface hardware.
9006 +static int read_char(void)
9008 + if (atomic_read(&gdb_buf_in_cnt) != 0) /* intr routine has q'd chars */
9012 + chr = gdb_buf[gdb_buf_out_inx++] ;
9013 + gdb_buf_out_inx &= (GDB_BUF_SIZE - 1) ;
9014 + atomic_dec(&gdb_buf_in_cnt) ;
9017 + return(prom_getc_nowait()) ; /* read from hardware */
9021 + * This is the receiver interrupt routine for the GDB stub.
9022 + * It will receive a limited number of characters of input
9023 + * from the gdb host machine and save them up in a buffer.
9025 + * When the gdb stub routine getDebugChar() is called it
9026 + * draws characters out of the buffer until it is empty and
9027 + * then reads directly from the serial port.
9029 + * We do not attempt to write chars from the interrupt routine
9030 + * since the stubs do all of that via putDebugChar() which
9031 + * writes one byte after waiting for the interface to become
9034 + * The debug stubs like to run with interrupts disabled since,
9035 + * after all, they run as a consequence of a breakpoint in
9038 + * Perhaps someone who knows more about the tty driver than I
9039 + * care to learn can make this work for any low level serial
9042 +static void gdb_interrupt(int irq, void *dev_id, struct pt_regs * regs)
9048 + chr = prom_getc_nowait() ;
9049 + more = prom_testc();
9050 + if (chr < 0) continue ;
9052 + /* If we receive a Ctrl-C then this is GDB trying to break in */
9055 + /* Replace current instruction with breakpoint */
9056 + set_async_breakpoint(regs->cp0_epc);
9061 + printk("gdb_interrupt: chr=%02x '%c', more = %x\n",
9062 + chr, chr > ' ' && chr < 0x7F ? chr : ' ', more) ;
9065 + if (atomic_read(&gdb_buf_in_cnt) >= GDB_BUF_SIZE)
9066 + { /* buffer overflow, clear it */
9067 + gdb_buf_in_inx = 0 ;
9068 + atomic_set(&gdb_buf_in_cnt, 0) ;
9069 + gdb_buf_out_inx = 0 ;
9073 + gdb_buf[gdb_buf_in_inx++] = chr ;
9074 + gdb_buf_in_inx &= (GDB_BUF_SIZE - 1) ;
9075 + atomic_inc(&gdb_buf_in_cnt) ;
9079 +} /* gdb_interrupt */
9084 + * This is a GDB stub routine. It waits for a character from the
9085 + * serial interface and then returns it. If there is no serial
9086 + * interface connection then it returns a bogus value which will
9087 + * almost certainly cause the system to hang.
9089 +int getDebugChar(void)
9091 + volatile int chr ;
9094 + printk("getDebugChar: ") ;
9097 + while ( (chr = read_char()) < 0 ) ;
9100 + printk("%c\n", chr > ' ' && chr < 0x7F ? chr : ' ') ;
9104 +} /* getDebugChar */
9109 + * This is a GDB stub routine. It waits until the interface is ready
9110 + * to transmit a char and then sends it. If there is no serial
9111 + * interface connection then it simply returns to its caller, having
9112 + * pretended to send the char.
9114 +int putDebugChar(unsigned char chr)
9117 + printk("putDebugChar: chr=%02x '%c'\n", chr,
9118 + chr > ' ' && chr < 0x7F ? chr : ' ') ;
9121 + prom_putc(chr) ; /* this routine will wait */
9124 +} /* putDebugChar */
9126 +/* Just a NULL routine for testing. */
9127 +void gdb_null(void)
9131 +void rs_kgdb_hook(int tty_no)
9133 + printk("rs_kgdb_hook: tty %d\n", tty_no);
9135 + /* Call GDB routine to setup the exception vectors for the debugger */
9136 + set_debug_traps();
9138 + printk("Breaking into debugger...\n");
9141 + printk("Connected.\n");
9143 + gdb_initialized = 1;
9145 +#ifdef CONFIG_GDB_CONSOLE
9146 + register_gdb_console();
9150 +void kgdb_hook_irq()
9155 + printk("GDB: Hooking UART interrupt\n");
9157 + retval = request_irq(INTERRUPT_ID_UART,
9160 + "GDB-stub", NULL);
9163 + printk("gdb_hook: request_irq(irq=%d) failed: %d\n", INTERRUPT_ID_UART, retval);
9165 + // Enable UART config Rx not empty IRQ
9166 + uMask = READ16(stUart->intMask) ;
9167 + // printk("intMask: 0x%x\n", uMask);
9168 + WRITE16(stUart->intMask, uMask | RXFIFONE);
9172 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S
9173 --- linux-2.6.17/arch/mips/brcm-boards/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
9174 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/int-handler.S 2006-08-03 16:36:58.000000000 +0200
9178 + Copyright 2002 Broadcom Corp. All Rights Reserved.
9180 + This program is free software; you can distribute it and/or modify it
9181 + under the terms of the GNU General Public License (Version 2) as
9182 + published by the Free Software Foundation.
9184 + This program is distributed in the hope it will be useful, but WITHOUT
9185 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9186 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9189 + You should have received a copy of the GNU General Public License along
9190 + with this program; if not, write to the Free Software Foundation, Inc.,
9191 + 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
9195 + * Generic interrupt handler for Broadcom MIPS boards
9198 +#include <linux/config.h>
9200 +#include <asm/asm.h>
9201 +#include <asm/mipsregs.h>
9202 +#include <asm/regdef.h>
9203 +#include <asm/stackframe.h>
9208 + * 0 Software (ignored)
9209 + * 1 Software (ignored)
9210 + * 2 Combined hardware interrupt (hw0)
9222 + NESTED(brcmIRQ, PT_SIZE, sp)
9228 + jal brcm_irq_dispatch
9235 diff -urN linux-2.6.17/arch/mips/brcm-boards/generic/Makefile linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile
9236 --- linux-2.6.17/arch/mips/brcm-boards/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
9237 +++ linux-2.6.17-brcm63xx/arch/mips/brcm-boards/generic/Makefile 2006-08-03 16:36:58.000000000 +0200
9240 +# Makefile for generic Broadcom MIPS boards
9242 +# Copyright (C) 2001 Broadcom Corporation
9244 +obj-y := int-handler.o
9246 +ifdef CONFIG_REMOTE_DEBUG