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