1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <common.h>
30#include <pci.h>
31#include <net.h>
32#include "srom.h"
33
34extern int eepro100_write_eeprom (struct eth_device *dev,
35 int location, int addr_len,
36 unsigned short data);
37
38
39
40unsigned short eepro100_srom_checksum (unsigned short *sromdata)
41{
42 unsigned short sum = 0;
43 unsigned int i;
44
45 for (i = 0; i < (EE_SIZE - 1); i++) {
46 sum += sromdata[i];
47 }
48 return (EE_CHECKSUM - sum);
49}
50
51
52
53int eepro100_srom_store (unsigned short *source)
54{
55 int count;
56 struct eth_device onboard_dev;
57
58
59 pci_read_config_dword (PCI_BDF (0, 0x10, 0), PCI_BASE_ADDRESS_0,
60 (unsigned int *) &onboard_dev.iobase);
61 onboard_dev.iobase &= ~0xf;
62
63 source[63] = eepro100_srom_checksum (source);
64
65 for (count = 0; count < EE_SIZE; count++) {
66 if (eepro100_write_eeprom ((struct eth_device *) &onboard_dev,
67 count, EE_ADDR_BITS,
68 SROM_SHORT (source)) == -1) {
69 return -1;
70 }
71 source++;
72 }
73 return 0;
74}
75
76
77
78#ifdef EEPRO100_SROM_CHECK
79
80extern int read_eeprom (struct eth_device *dev, int location, int addr_len);
81
82void eepro100_srom_load (unsigned short *destination)
83{
84 int count;
85 struct eth_device onboard_dev;
86
87#ifdef DEBUG
88 int lr = 0;
89
90 printf ("eepro100_srom_download:\n");
91#endif
92
93
94 pci_read_config_dword (PCI_BDF (0, 0x10, 0), PCI_BASE_ADDRESS_0,
95 &onboard_dev.iobase);
96 onboard_dev.iobase &= ~0xf;
97
98 memset (destination, 0x65, 128);
99
100 for (count = 0; count < 0x40; count++) {
101 *destination++ = read_eeprom ((struct eth_device *) &onboard_dev,
102 count, EE_ADDR_BITS);
103#ifdef DEBUG
104 printf ("%04x ", *(destination - 1));
105 if (lr++ == 7) {
106 printf ("\n");
107 lr = 0;
108 }
109#endif
110 }
111}
112#endif
113
114
115