• Home
  • Raw
  • Download

Lines Matching +full:eeprom +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2004 - 2006 rt2x00 SourceForge Project
7 * Abstract: EEPROM reader routines for 93cx6 chipsets.
18 MODULE_DESCRIPTION("EEPROM 93cx6 chip driver");
21 static inline void eeprom_93cx6_pulse_high(struct eeprom_93cx6 *eeprom) in eeprom_93cx6_pulse_high() argument
23 eeprom->reg_data_clock = 1; in eeprom_93cx6_pulse_high()
24 eeprom->register_write(eeprom); in eeprom_93cx6_pulse_high()
34 static inline void eeprom_93cx6_pulse_low(struct eeprom_93cx6 *eeprom) in eeprom_93cx6_pulse_low() argument
36 eeprom->reg_data_clock = 0; in eeprom_93cx6_pulse_low()
37 eeprom->register_write(eeprom); in eeprom_93cx6_pulse_low()
47 static void eeprom_93cx6_startup(struct eeprom_93cx6 *eeprom) in eeprom_93cx6_startup() argument
52 eeprom->register_read(eeprom); in eeprom_93cx6_startup()
53 eeprom->reg_data_in = 0; in eeprom_93cx6_startup()
54 eeprom->reg_data_out = 0; in eeprom_93cx6_startup()
55 eeprom->reg_data_clock = 0; in eeprom_93cx6_startup()
56 eeprom->reg_chip_select = 1; in eeprom_93cx6_startup()
57 eeprom->drive_data = 1; in eeprom_93cx6_startup()
58 eeprom->register_write(eeprom); in eeprom_93cx6_startup()
63 eeprom_93cx6_pulse_high(eeprom); in eeprom_93cx6_startup()
64 eeprom_93cx6_pulse_low(eeprom); in eeprom_93cx6_startup()
67 static void eeprom_93cx6_cleanup(struct eeprom_93cx6 *eeprom) in eeprom_93cx6_cleanup() argument
72 eeprom->register_read(eeprom); in eeprom_93cx6_cleanup()
73 eeprom->reg_data_in = 0; in eeprom_93cx6_cleanup()
74 eeprom->reg_chip_select = 0; in eeprom_93cx6_cleanup()
75 eeprom->register_write(eeprom); in eeprom_93cx6_cleanup()
80 eeprom_93cx6_pulse_high(eeprom); in eeprom_93cx6_cleanup()
81 eeprom_93cx6_pulse_low(eeprom); in eeprom_93cx6_cleanup()
84 static void eeprom_93cx6_write_bits(struct eeprom_93cx6 *eeprom, in eeprom_93cx6_write_bits() argument
85 const u16 data, const u16 count) in eeprom_93cx6_write_bits() argument
89 eeprom->register_read(eeprom); in eeprom_93cx6_write_bits()
92 * Clear data flags. in eeprom_93cx6_write_bits()
94 eeprom->reg_data_in = 0; in eeprom_93cx6_write_bits()
95 eeprom->reg_data_out = 0; in eeprom_93cx6_write_bits()
96 eeprom->drive_data = 1; in eeprom_93cx6_write_bits()
101 for (i = count; i > 0; i--) { in eeprom_93cx6_write_bits()
105 eeprom->reg_data_in = !!(data & (1 << (i - 1))); in eeprom_93cx6_write_bits()
108 * Write the bit to the eeprom register. in eeprom_93cx6_write_bits()
110 eeprom->register_write(eeprom); in eeprom_93cx6_write_bits()
115 eeprom_93cx6_pulse_high(eeprom); in eeprom_93cx6_write_bits()
116 eeprom_93cx6_pulse_low(eeprom); in eeprom_93cx6_write_bits()
119 eeprom->reg_data_in = 0; in eeprom_93cx6_write_bits()
120 eeprom->register_write(eeprom); in eeprom_93cx6_write_bits()
123 static void eeprom_93cx6_read_bits(struct eeprom_93cx6 *eeprom, in eeprom_93cx6_read_bits() argument
124 u16 *data, const u16 count) in eeprom_93cx6_read_bits() argument
129 eeprom->register_read(eeprom); in eeprom_93cx6_read_bits()
132 * Clear data flags. in eeprom_93cx6_read_bits()
134 eeprom->reg_data_in = 0; in eeprom_93cx6_read_bits()
135 eeprom->reg_data_out = 0; in eeprom_93cx6_read_bits()
136 eeprom->drive_data = 0; in eeprom_93cx6_read_bits()
141 for (i = count; i > 0; i--) { in eeprom_93cx6_read_bits()
142 eeprom_93cx6_pulse_high(eeprom); in eeprom_93cx6_read_bits()
144 eeprom->register_read(eeprom); in eeprom_93cx6_read_bits()
149 eeprom->reg_data_in = 0; in eeprom_93cx6_read_bits()
154 if (eeprom->reg_data_out) in eeprom_93cx6_read_bits()
155 buf |= (1 << (i - 1)); in eeprom_93cx6_read_bits()
157 eeprom_93cx6_pulse_low(eeprom); in eeprom_93cx6_read_bits()
160 *data = buf; in eeprom_93cx6_read_bits()
164 * eeprom_93cx6_read - Read a word from eeprom
165 * @eeprom: Pointer to eeprom structure
167 * @data: target pointer where the information will have to be stored
169 * This function will read the eeprom data as host-endian word
170 * into the given data pointer.
172 void eeprom_93cx6_read(struct eeprom_93cx6 *eeprom, const u8 word, in eeprom_93cx6_read() argument
173 u16 *data) in eeprom_93cx6_read() argument
178 * Initialize the eeprom register in eeprom_93cx6_read()
180 eeprom_93cx6_startup(eeprom); in eeprom_93cx6_read()
185 command = (PCI_EEPROM_READ_OPCODE << eeprom->width) | word; in eeprom_93cx6_read()
186 eeprom_93cx6_write_bits(eeprom, command, in eeprom_93cx6_read()
187 PCI_EEPROM_WIDTH_OPCODE + eeprom->width); in eeprom_93cx6_read()
192 eeprom_93cx6_read_bits(eeprom, data, 16); in eeprom_93cx6_read()
195 * Cleanup eeprom register. in eeprom_93cx6_read()
197 eeprom_93cx6_cleanup(eeprom); in eeprom_93cx6_read()
202 * eeprom_93cx6_multiread - Read multiple words from eeprom
203 * @eeprom: Pointer to eeprom structure
205 * @data: target pointer where the information will have to be stored
208 * This function will read all requested words from the eeprom,
214 void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, const u8 word, in eeprom_93cx6_multiread() argument
215 __le16 *data, const u16 words) in eeprom_93cx6_multiread() argument
222 eeprom_93cx6_read(eeprom, word + i, &tmp); in eeprom_93cx6_multiread()
223 data[i] = cpu_to_le16(tmp); in eeprom_93cx6_multiread()
229 * eeprom_93cx6_readb - Read a byte from eeprom
230 * @eeprom: Pointer to eeprom structure
232 * @data: target pointer where the information will have to be stored
234 * This function will read a byte of the eeprom data
235 * into the given data pointer.
237 void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, const u8 byte, in eeprom_93cx6_readb() argument
238 u8 *data) in eeprom_93cx6_readb() argument
244 * Initialize the eeprom register in eeprom_93cx6_readb()
246 eeprom_93cx6_startup(eeprom); in eeprom_93cx6_readb()
251 command = (PCI_EEPROM_READ_OPCODE << (eeprom->width + 1)) | byte; in eeprom_93cx6_readb()
252 eeprom_93cx6_write_bits(eeprom, command, in eeprom_93cx6_readb()
253 PCI_EEPROM_WIDTH_OPCODE + eeprom->width + 1); in eeprom_93cx6_readb()
258 eeprom_93cx6_read_bits(eeprom, &tmp, 8); in eeprom_93cx6_readb()
259 *data = tmp & 0xff; in eeprom_93cx6_readb()
262 * Cleanup eeprom register. in eeprom_93cx6_readb()
264 eeprom_93cx6_cleanup(eeprom); in eeprom_93cx6_readb()
269 * eeprom_93cx6_multireadb - Read multiple bytes from eeprom
270 * @eeprom: Pointer to eeprom structure
272 * @data: target pointer where the information will have to be stored
275 * This function will read all requested bytes from the eeprom,
278 void eeprom_93cx6_multireadb(struct eeprom_93cx6 *eeprom, const u8 byte, in eeprom_93cx6_multireadb() argument
279 u8 *data, const u16 bytes) in eeprom_93cx6_multireadb() argument
284 eeprom_93cx6_readb(eeprom, byte + i, &data[i]); in eeprom_93cx6_multireadb()
289 * eeprom_93cx6_wren - set the write enable state
290 * @eeprom: Pointer to eeprom structure
293 * Set the EEPROM write enable state to either allow or deny
296 void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable) in eeprom_93cx6_wren() argument
301 eeprom_93cx6_startup(eeprom); in eeprom_93cx6_wren()
306 command <<= (eeprom->width - 2); in eeprom_93cx6_wren()
308 eeprom_93cx6_write_bits(eeprom, command, in eeprom_93cx6_wren()
309 PCI_EEPROM_WIDTH_OPCODE + eeprom->width); in eeprom_93cx6_wren()
311 eeprom_93cx6_cleanup(eeprom); in eeprom_93cx6_wren()
316 * eeprom_93cx6_write - write data to the EEPROM
317 * @eeprom: Pointer to eeprom structure
318 * @addr: Address to write data to.
319 * @data: The data to write to address @addr.
321 * Write the @data to the specified @addr in the EEPROM and
328 void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, u8 addr, u16 data) in eeprom_93cx6_write() argument
334 eeprom_93cx6_startup(eeprom); in eeprom_93cx6_write()
336 command = PCI_EEPROM_WRITE_OPCODE << eeprom->width; in eeprom_93cx6_write()
340 eeprom_93cx6_write_bits(eeprom, command, in eeprom_93cx6_write()
341 PCI_EEPROM_WIDTH_OPCODE + eeprom->width); in eeprom_93cx6_write()
343 /* send data */ in eeprom_93cx6_write()
344 eeprom_93cx6_write_bits(eeprom, data, 16); in eeprom_93cx6_write()
347 eeprom->drive_data = 0; in eeprom_93cx6_write()
348 eeprom->reg_chip_select = 1; in eeprom_93cx6_write()
349 eeprom->register_write(eeprom); in eeprom_93cx6_write()
351 /* wait at-least 250ns to get DO to be the busy signal */ in eeprom_93cx6_write()
357 eeprom->register_read(eeprom); in eeprom_93cx6_write()
359 if (eeprom->reg_data_out) in eeprom_93cx6_write()
364 if (--timeout <= 0) { in eeprom_93cx6_write()
370 eeprom_93cx6_cleanup(eeprom); in eeprom_93cx6_write()