3 * Copyright (C) 2001 By Joachim Martillo, Telford Tools, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
11 /* This file is linked in, but I am
12 not sure there is ever any
13 reason directly to read the
14 serial eprom on the multichannel
17 /* We handle PCI devices */
18 #include <linux/pci.h>
20 /* We need to use ioremap */
23 #include <linux/delay.h>
28 /* read a byte out of the serial eeprom/nvram by means of
29 * 16 short commands */
31 static unsigned int amcc_nvram_breadw(unsigned char *bridge_space,
32 unsigned short address,
38 for(count = 0; count < 20000; ++count)
40 rhr = readl(bridge_space + AMCC_RCR);
41 if((rhr & AMCC_NVRBUSY) == 0)
51 rhr = AMCC_NVRWRLA | ((address & 0x00FF) << 16);
52 writel(rhr, bridge_space + AMCC_RCR);
53 rhr = AMCC_NVRWRHA | ((address & 0xFF00) << 8);
54 writel(rhr, bridge_space + AMCC_RCR);
55 writel(AMCC_NVRRDDB, bridge_space + AMCC_RCR);
56 for(count = 0; count < 20000; ++count)
58 rhr = readl(bridge_space + AMCC_RCR);
59 if((rhr & AMCC_NVRBUSY) == 0)
69 if(rhr & AMCC_NVRACCFAIL)
73 *value = (unsigned char) (rhr >> 16);
77 /* read the whole serial eeprom from the host card */
79 unsigned int amcc_read_nvram(unsigned char* buffer, unsigned length, unsigned char *bridge_space)
82 length <<= 1; /* covert words to bytes */
84 for(count = 0; count < length; ++count)
86 if(amcc_nvram_breadw(bridge_space, count, &buffer[count]) == FALSE)