diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2014-11-24 17:24:40 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-25 09:42:53 -0500 |
commit | 7ff28aee40c42676abc3baab122d45826726ea49 (patch) | |
tree | 2593a6522853a06b4fc8da507d6aed5926dfc751 /drivers/misc/eeprom | |
parent | 68b14b8f9482b6c42cec71e06613f5684e89d275 (diff) |
eeprom-93cx6: Add (read-only) support for 8-bit mode
Add read-only support for EEPROMs configured in 8-bit mode (ORG pin connected
to GND).
This will be used by wd719x driver.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/misc/eeprom')
-rw-r--r-- | drivers/misc/eeprom/eeprom_93cx6.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/drivers/misc/eeprom/eeprom_93cx6.c b/drivers/misc/eeprom/eeprom_93cx6.c index 0ff4b02177be..0cf2c9d676be 100644 --- a/drivers/misc/eeprom/eeprom_93cx6.c +++ b/drivers/misc/eeprom/eeprom_93cx6.c | |||
@@ -170,7 +170,7 @@ static void eeprom_93cx6_read_bits(struct eeprom_93cx6 *eeprom, | |||
170 | } | 170 | } |
171 | 171 | ||
172 | /** | 172 | /** |
173 | * eeprom_93cx6_read - Read multiple words from eeprom | 173 | * eeprom_93cx6_read - Read a word from eeprom |
174 | * @eeprom: Pointer to eeprom structure | 174 | * @eeprom: Pointer to eeprom structure |
175 | * @word: Word index from where we should start reading | 175 | * @word: Word index from where we should start reading |
176 | * @data: target pointer where the information will have to be stored | 176 | * @data: target pointer where the information will have to be stored |
@@ -235,6 +235,66 @@ void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, const u8 word, | |||
235 | EXPORT_SYMBOL_GPL(eeprom_93cx6_multiread); | 235 | EXPORT_SYMBOL_GPL(eeprom_93cx6_multiread); |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * eeprom_93cx6_readb - Read a byte from eeprom | ||
239 | * @eeprom: Pointer to eeprom structure | ||
240 | * @word: Byte index from where we should start reading | ||
241 | * @data: target pointer where the information will have to be stored | ||
242 | * | ||
243 | * This function will read a byte of the eeprom data | ||
244 | * into the given data pointer. | ||
245 | */ | ||
246 | void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, const u8 byte, | ||
247 | u8 *data) | ||
248 | { | ||
249 | u16 command; | ||
250 | u16 tmp; | ||
251 | |||
252 | /* | ||
253 | * Initialize the eeprom register | ||
254 | */ | ||
255 | eeprom_93cx6_startup(eeprom); | ||
256 | |||
257 | /* | ||
258 | * Select the read opcode and the byte to be read. | ||
259 | */ | ||
260 | command = (PCI_EEPROM_READ_OPCODE << (eeprom->width + 1)) | byte; | ||
261 | eeprom_93cx6_write_bits(eeprom, command, | ||
262 | PCI_EEPROM_WIDTH_OPCODE + eeprom->width + 1); | ||
263 | |||
264 | /* | ||
265 | * Read the requested 8 bits. | ||
266 | */ | ||
267 | eeprom_93cx6_read_bits(eeprom, &tmp, 8); | ||
268 | *data = tmp & 0xff; | ||
269 | |||
270 | /* | ||
271 | * Cleanup eeprom register. | ||
272 | */ | ||
273 | eeprom_93cx6_cleanup(eeprom); | ||
274 | } | ||
275 | EXPORT_SYMBOL_GPL(eeprom_93cx6_readb); | ||
276 | |||
277 | /** | ||
278 | * eeprom_93cx6_multireadb - Read multiple bytes from eeprom | ||
279 | * @eeprom: Pointer to eeprom structure | ||
280 | * @byte: Index from where we should start reading | ||
281 | * @data: target pointer where the information will have to be stored | ||
282 | * @words: Number of bytes that should be read. | ||
283 | * | ||
284 | * This function will read all requested bytes from the eeprom, | ||
285 | * this is done by calling eeprom_93cx6_readb() multiple times. | ||
286 | */ | ||
287 | void eeprom_93cx6_multireadb(struct eeprom_93cx6 *eeprom, const u8 byte, | ||
288 | u8 *data, const u16 bytes) | ||
289 | { | ||
290 | unsigned int i; | ||
291 | |||
292 | for (i = 0; i < bytes; i++) | ||
293 | eeprom_93cx6_readb(eeprom, byte + i, &data[i]); | ||
294 | } | ||
295 | EXPORT_SYMBOL_GPL(eeprom_93cx6_multireadb); | ||
296 | |||
297 | /** | ||
238 | * eeprom_93cx6_wren - set the write enable state | 298 | * eeprom_93cx6_wren - set the write enable state |
239 | * @eeprom: Pointer to eeprom structure | 299 | * @eeprom: Pointer to eeprom structure |
240 | * @enable: true to enable writes, otherwise disable writes | 300 | * @enable: true to enable writes, otherwise disable writes |