Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ondrej Zary and committed by
Christoph Hellwig
7ff28aee 68b14b8f

+65 -1
+61 -1
drivers/misc/eeprom/eeprom_93cx6.c
··· 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 174 * @eeprom: Pointer to eeprom structure 175 175 * @word: Word index from where we should start reading 176 176 * @data: target pointer where the information will have to be stored ··· 233 233 } 234 234 } 235 235 EXPORT_SYMBOL_GPL(eeprom_93cx6_multiread); 236 + 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); 236 296 237 297 /** 238 298 * eeprom_93cx6_wren - set the write enable state
+4
include/linux/eeprom_93cx6.h
··· 75 75 const u8 word, u16 *data); 76 76 extern void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, 77 77 const u8 word, __le16 *data, const u16 words); 78 + extern void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, 79 + const u8 byte, u8 *data); 80 + extern void eeprom_93cx6_multireadb(struct eeprom_93cx6 *eeprom, 81 + const u8 byte, u8 *data, const u16 bytes); 78 82 79 83 extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable); 80 84