43 #ifdef SYM_CONF_DEBUG_NVRAM
44 static u_char Tekram_boot_delay[7] = {3, 5, 10, 20, 30, 60, 120};
56 switch (nvram->
type) {
108 tp->
usr_width = (tn->bus_width == 0x8) ? 0 : 1;
111 static const unsigned char Tekram_sync[16] = {
112 25, 31, 37, 43, 50, 62, 75, 125, 12, 15, 18, 21, 6, 7, 9, 10
131 tp->
usr_period = Tekram_sync[tn->sync_index & 0xf];
142 sym_Symbios_setup_target(tp, target, &nvp->
data.
Symbios);
145 sym_Tekram_setup_target(tp, target, &nvp->
data.
Tekram);
152 #ifdef SYM_CONF_DEBUG_NVRAM
161 printf(
"%s: HOST ID=%d%s%s%s%s%s%s\n",
171 for (i = 0 ; i < 15 ; i++) {
173 printf(
"%s-%d:%s%s%s%s WIDTH=%d SYNC=%d TMO=%d\n",
190 int i,
tags, boot_delay;
200 case 0: rem =
"";
break;
201 case 1: rem =
" REMOVABLE=boot device";
break;
202 case 2: rem =
" REMOVABLE=all";
break;
205 printf(
"%s: HOST ID=%d%s%s%s%s%s%s%s%s%s BOOT DELAY=%d tags=%d\n",
215 rem, boot_delay, tags);
218 for (i = 0; i <= 15; i++) {
221 j = tn->sync_index & 0xf;
222 sync = Tekram_sync[
j];
223 printf(
"%s-%d:%s%s%s%s%s%s PERIOD=%d\n",
275 OUTB(np, nc_gpreg, *gpreg);
285 S24C16_set_bit(np, 1, gpreg,
SET_BIT);
286 S24C16_set_bit(np, 0, gpreg,
SET_CLK);
287 S24C16_set_bit(np, 0, gpreg,
CLR_BIT);
288 S24C16_set_bit(np, 0, gpreg,
CLR_CLK);
296 S24C16_set_bit(np, 0, gpreg,
SET_CLK);
297 S24C16_set_bit(np, 1, gpreg,
SET_BIT);
307 S24C16_set_bit(np, write_bit, gpreg,
SET_BIT);
308 S24C16_set_bit(np, 0, gpreg,
SET_CLK);
310 *read_bit =
INB(np, nc_gpreg);
311 S24C16_set_bit(np, 0, gpreg,
CLR_CLK);
312 S24C16_set_bit(np, 0, gpreg,
CLR_BIT);
322 OUTB(np, nc_gpcntl, *gpcntl & 0xfe);
323 S24C16_do_bit(np,
NULL, write_bit, gpreg);
324 OUTB(np, nc_gpcntl, *gpcntl);
334 OUTB(np, nc_gpcntl, *gpcntl | 0x01);
335 S24C16_do_bit(np, read_bit, 1, gpreg);
336 OUTB(np, nc_gpcntl, *gpcntl);
348 for (x = 0; x < 8; x++)
349 S24C16_do_bit(np,
NULL, (write_data >> (7 - x)) & 0x01, gpreg);
351 S24C16_read_ack(np, ack_data, gpreg, gpcntl);
365 for (x = 0; x < 8; x++) {
366 S24C16_do_bit(np, &read_bit, 1, gpreg);
367 *read_data |= ((read_bit & 0x01) << (7 - x));
370 S24C16_write_ack(np, ack_data, gpreg, gpcntl);
373 #ifdef SYM_CONF_NVRAM_WRITE_SUPPORT
381 u_char old_gpcntl, old_gpreg;
386 old_gpreg =
INB(np, nc_gpreg);
387 old_gpcntl =
INB(np, nc_gpcntl);
388 gpcntl = old_gpcntl & 0x1c;
391 OUTB(np, nc_gpreg, old_gpreg);
392 OUTB(np, nc_gpcntl, gpcntl);
396 S24C16_set_bit(np, 0, &gpreg,
CLR_CLK);
397 S24C16_set_bit(np, 0, &gpreg,
CLR_BIT);
400 S24C16_stop(np, &gpreg);
403 for (x = 0; x < len ; x += 16) {
405 S24C16_start(np, &gpreg);
406 S24C16_write_byte(np, &ack_data,
407 0xa0 | (((offset+x) >> 7) & 0x0e),
409 }
while (ack_data & 0x01);
411 S24C16_write_byte(np, &ack_data, (offset+x) & 0xff,
414 for (
y = 0;
y < 16;
y++)
415 S24C16_write_byte(np, &ack_data, data[x+
y],
417 S24C16_stop(np, &gpreg);
421 OUTB(np, nc_gpcntl, old_gpcntl);
422 OUTB(np, nc_gpreg, old_gpreg);
431 static int sym_read_S24C16_nvram(
struct sym_device *np,
int offset,
u_char *data,
int len)
434 u_char old_gpcntl, old_gpreg;
440 old_gpreg =
INB(np, nc_gpreg);
441 old_gpcntl =
INB(np, nc_gpcntl);
442 gpcntl = old_gpcntl & 0x1c;
445 OUTB(np, nc_gpreg, old_gpreg);
446 OUTB(np, nc_gpcntl, gpcntl);
450 S24C16_set_bit(np, 0, &gpreg,
CLR_CLK);
451 S24C16_set_bit(np, 0, &gpreg,
CLR_BIT);
454 S24C16_stop(np, &gpreg);
457 S24C16_start(np, &gpreg);
460 S24C16_write_byte(np, &ack_data,
461 0xa0 | ((offset >> 7) & 0x0e), &gpreg, &gpcntl);
466 S24C16_write_byte(np, &ack_data,
467 offset & 0xff, &gpreg, &gpcntl);
472 S24C16_start(np, &gpreg);
475 S24C16_write_byte(np, &ack_data,
476 0xa1 | ((offset >> 7) & 0x0e), &gpreg, &gpcntl);
482 OUTB(np, nc_gpcntl, gpcntl);
485 for (x = 0; x < len; x++)
486 S24C16_read_byte(np, &data[x], (x == (len-1)), &gpreg, &gpcntl);
490 OUTB(np, nc_gpcntl, gpcntl);
491 S24C16_stop(np, &gpreg);
495 OUTB(np, nc_gpcntl, old_gpcntl);
496 OUTB(np, nc_gpreg, old_gpreg);
512 static u_char Symbios_trailer[6] = {0xfe, 0xfe, 0, 0, 0, 0};
514 int len =
sizeof(*nvram);
523 if (nvram->
type != 0 ||
529 for (x = 6, csum = 0; x < len - 6; x++)
553 OUTB(np, nc_gpreg, *gpreg | 0x04);
556 OUTB(np, nc_gpreg, *gpreg);
565 T93C46_Clk(np, gpreg);
566 *read_bit =
INB(np, nc_gpreg);
574 if (write_bit & 0x01)
581 OUTB(np, nc_gpreg, *gpreg);
585 T93C46_Clk(np, gpreg);
594 OUTB(np, nc_gpreg, *gpreg);
598 T93C46_Clk(np, gpreg);
610 for (x = 0; x < 9; x++)
611 T93C46_Write_Bit(np, (
u_char) (write_data >> (8 - x)), gpreg);
613 *read_bit =
INB(np, nc_gpreg);
619 static void T93C46_Read_Word(
struct sym_device *np,
620 unsigned short *nvram_data,
unsigned char *gpreg)
626 for (x = 0; x < 16; x++) {
627 T93C46_Read_Bit(np, &read_bit, gpreg);
630 *nvram_data |= (0x01 << (15 -
x));
632 *nvram_data &= ~(0x01 << (15 -
x));
639 static int T93C46_Read_Data(
struct sym_device *np,
unsigned short *data,
640 int len,
unsigned char *gpreg)
644 for (x = 0; x < len; x++) {
647 T93C46_Send_Command(np, 0x180 | x, &read_bit, gpreg);
650 T93C46_Read_Word(np, &data[x], gpreg);
651 T93C46_Stop(np, gpreg);
663 u_char old_gpcntl, old_gpreg;
667 old_gpreg =
INB(np, nc_gpreg);
668 old_gpcntl =
INB(np, nc_gpcntl);
672 gpreg = old_gpreg & 0xe9;
673 OUTB(np, nc_gpreg, gpreg);
674 gpcntl = (old_gpcntl & 0xe9) | 0x09;
675 OUTB(np, nc_gpcntl, gpcntl);
678 retv = T93C46_Read_Data(np, (
u_short *) nvram,
679 sizeof(*nvram) /
sizeof(
short), &gpreg);
682 OUTB(np, nc_gpcntl, old_gpcntl);
683 OUTB(np, nc_gpreg, old_gpreg);
695 int len =
sizeof(*nvram);
699 switch (np->
pdev->device) {
712 x = sym_read_T93C46_nvram(np, nvram);
719 for (x = 0, csum = 0; x < len - 1; x += 2)
720 csum += data[x] + (data[x+1] << 8);
743 static inline int sym_read_parisc_pdc(
struct sym_device *np,
755 if (!sym_read_Symbios_nvram(np, &nvp->
data.
Symbios)) {
758 }
else if (!sym_read_Tekram_nvram(np, &nvp->
data.
Tekram)) {
760 sym_display_Tekram_nvram(np, &nvp->
data.
Tekram);
771 return "Symbios NVRAM";
773 return "Tekram NVRAM";
775 return "PA-RISC Firmware";