Lines Matching +full:1 +full:- +full:sd
10 * 1. Redistributions of source code must retain the above copyright
39 * -------------------------------------------------------------------
40 * READ 1 10 A5 - A0 Reads data stored in memory,
42 * EWEN 1 00 11XXXX Write enable must precede
44 * ERASE 1 11 A5 - A0 Erase register A5A4A3A2A1A0
45 * WRITE 1 01 A5 - A0 D15 - D0 Writes register
46 * ERAL 1 00 10XXXX Erase all registers
47 * WRAL 1 00 01XXXX D15 - D0 Writes to all registers
48 * EWDS 1 00 00XXXX Disables all programming
57 * 1 usec, with the clock high and low a minimum of 750 and 250 nsec
61 * requested 16-bit register contents is read from the data out line but
62 * is preceded by an initial zero (leading 0, followed by 16-bits, MSB
81 static const struct seeprom_cmd seeprom_ewen = {9, {1, 0, 0, 1, 1, 0, 0, 0, 0}};
82 static const struct seeprom_cmd seeprom_ewds = {9, {1, 0, 0, 0, 0, 0, 0, 0, 0}};
85 static const struct seeprom_cmd seeprom_long_ewen = {11, {1, 0, 0, 1, 1, 0, 0, 0, 0}};
86 static const struct seeprom_cmd seeprom_long_ewds = {11, {1, 0, 0, 0, 0, 0, 0, 0, 0}};
89 static const struct seeprom_cmd seeprom_write = {3, {1, 0, 1}};
90 static const struct seeprom_cmd seeprom_read = {3, {1, 1, 0}};
95 #define CLOCK_PULSE(sd, rdy) \ argument
96 while ((SEEPROM_STATUS_INB(sd) & rdy) == 0) { \
99 (void)SEEPROM_INB(sd); /* Clear clock */
105 send_seeprom_cmd(struct seeprom_descriptor *sd, const struct seeprom_cmd *cmd) in send_seeprom_cmd() argument
111 temp = sd->sd_MS ^ sd->sd_CS; in send_seeprom_cmd()
112 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in send_seeprom_cmd()
113 CLOCK_PULSE(sd, sd->sd_RDY); in send_seeprom_cmd()
115 for (i = 0; i < cmd->len; i++) { in send_seeprom_cmd()
116 if (cmd->bits[i] != 0) in send_seeprom_cmd()
117 temp ^= sd->sd_DO; in send_seeprom_cmd()
118 SEEPROM_OUTB(sd, temp); in send_seeprom_cmd()
119 CLOCK_PULSE(sd, sd->sd_RDY); in send_seeprom_cmd()
120 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in send_seeprom_cmd()
121 CLOCK_PULSE(sd, sd->sd_RDY); in send_seeprom_cmd()
122 if (cmd->bits[i] != 0) in send_seeprom_cmd()
123 temp ^= sd->sd_DO; in send_seeprom_cmd()
131 reset_seeprom(struct seeprom_descriptor *sd) in reset_seeprom() argument
135 temp = sd->sd_MS; in reset_seeprom()
136 SEEPROM_OUTB(sd, temp); in reset_seeprom()
137 CLOCK_PULSE(sd, sd->sd_RDY); in reset_seeprom()
138 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in reset_seeprom()
139 CLOCK_PULSE(sd, sd->sd_RDY); in reset_seeprom()
140 SEEPROM_OUTB(sd, temp); in reset_seeprom()
141 CLOCK_PULSE(sd, sd->sd_RDY); in reset_seeprom()
145 * Read the serial EEPROM and returns 1 if successful and 0 if
149 ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, in ahc_read_seeprom() argument
159 * will range from 0 to count-1. in ahc_read_seeprom()
164 * address of the 16-bit register we want to read. in ahc_read_seeprom()
166 send_seeprom_cmd(sd, &seeprom_read); in ahc_read_seeprom()
169 temp = sd->sd_MS ^ sd->sd_CS; in ahc_read_seeprom()
170 for (i = (sd->sd_chip - 1); i >= 0; i--) { in ahc_read_seeprom()
171 if ((k & (1 << i)) != 0) in ahc_read_seeprom()
172 temp ^= sd->sd_DO; in ahc_read_seeprom()
173 SEEPROM_OUTB(sd, temp); in ahc_read_seeprom()
174 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_read_seeprom()
175 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in ahc_read_seeprom()
176 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_read_seeprom()
177 if ((k & (1 << i)) != 0) in ahc_read_seeprom()
178 temp ^= sd->sd_DO; in ahc_read_seeprom()
188 for (i = 16; i >= 0; i--) { in ahc_read_seeprom()
189 SEEPROM_OUTB(sd, temp); in ahc_read_seeprom()
190 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_read_seeprom()
191 v <<= 1; in ahc_read_seeprom()
192 if (SEEPROM_DATA_INB(sd) & sd->sd_DI) in ahc_read_seeprom()
193 v |= 1; in ahc_read_seeprom()
194 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in ahc_read_seeprom()
195 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_read_seeprom()
198 buf[k - start_addr] = v; in ahc_read_seeprom()
201 reset_seeprom(sd); in ahc_read_seeprom()
205 for (k = 0; k < count; k = k + 1) { in ahc_read_seeprom()
213 return (1); in ahc_read_seeprom()
217 * Write the serial EEPROM and return 1 if successful and 0 if
221 ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, in ahc_write_seeprom() argument
229 /* Place the chip into write-enable mode */ in ahc_write_seeprom()
230 if (sd->sd_chip == C46) { in ahc_write_seeprom()
233 } else if (sd->sd_chip == C56_66) { in ahc_write_seeprom()
238 sd->sd_chip); in ahc_write_seeprom()
242 send_seeprom_cmd(sd, ewen); in ahc_write_seeprom()
243 reset_seeprom(sd); in ahc_write_seeprom()
246 temp = sd->sd_MS ^ sd->sd_CS; in ahc_write_seeprom()
249 send_seeprom_cmd(sd, &seeprom_write); in ahc_write_seeprom()
252 for (i = (sd->sd_chip - 1); i >= 0; i--) { in ahc_write_seeprom()
253 if ((k & (1 << i)) != 0) in ahc_write_seeprom()
254 temp ^= sd->sd_DO; in ahc_write_seeprom()
255 SEEPROM_OUTB(sd, temp); in ahc_write_seeprom()
256 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
257 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in ahc_write_seeprom()
258 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
259 if ((k & (1 << i)) != 0) in ahc_write_seeprom()
260 temp ^= sd->sd_DO; in ahc_write_seeprom()
264 v = buf[k - start_addr]; in ahc_write_seeprom()
265 for (i = 15; i >= 0; i--) { in ahc_write_seeprom()
266 if ((v & (1 << i)) != 0) in ahc_write_seeprom()
267 temp ^= sd->sd_DO; in ahc_write_seeprom()
268 SEEPROM_OUTB(sd, temp); in ahc_write_seeprom()
269 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
270 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in ahc_write_seeprom()
271 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
272 if ((v & (1 << i)) != 0) in ahc_write_seeprom()
273 temp ^= sd->sd_DO; in ahc_write_seeprom()
277 temp = sd->sd_MS; in ahc_write_seeprom()
278 SEEPROM_OUTB(sd, temp); in ahc_write_seeprom()
279 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
280 temp = sd->sd_MS ^ sd->sd_CS; in ahc_write_seeprom()
282 SEEPROM_OUTB(sd, temp); in ahc_write_seeprom()
283 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
284 SEEPROM_OUTB(sd, temp ^ sd->sd_CK); in ahc_write_seeprom()
285 CLOCK_PULSE(sd, sd->sd_RDY); in ahc_write_seeprom()
286 } while ((SEEPROM_DATA_INB(sd) & sd->sd_DI) == 0); in ahc_write_seeprom()
288 reset_seeprom(sd); in ahc_write_seeprom()
291 /* Put the chip back into write-protect mode */ in ahc_write_seeprom()
292 send_seeprom_cmd(sd, ewds); in ahc_write_seeprom()
293 reset_seeprom(sd); in ahc_write_seeprom()
295 return (1); in ahc_write_seeprom()
306 maxaddr = (sizeof(*sc)/2) - 1; in ahc_verify_cksum()
313 || (checksum & 0xFFFF) != sc->checksum) { in ahc_verify_cksum()
316 return(1); in ahc_verify_cksum()