Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 2 | /* |
| 3 | Copyright (C) 2004 - 2006 rt2x00 SourceForge Project |
| 4 | <http://rt2x00.serialmonkey.com> |
| 5 | |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | Module: eeprom_93cx6 |
| 10 | Abstract: EEPROM reader datastructures for 93cx6 chipsets. |
Magnus Damm | 89e536a | 2007-09-28 22:42:16 -0700 | [diff] [blame] | 11 | Supported chipsets: 93c46, 93c56 and 93c66. |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * EEPROM operation defines. |
| 16 | */ |
| 17 | #define PCI_EEPROM_WIDTH_93C46 6 |
Magnus Damm | 89e536a | 2007-09-28 22:42:16 -0700 | [diff] [blame] | 18 | #define PCI_EEPROM_WIDTH_93C56 8 |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 19 | #define PCI_EEPROM_WIDTH_93C66 8 |
Gertjan van Wingerde | afd2a5c | 2010-06-29 21:43:44 +0200 | [diff] [blame] | 20 | #define PCI_EEPROM_WIDTH_93C86 8 |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 21 | #define PCI_EEPROM_WIDTH_OPCODE 3 |
| 22 | #define PCI_EEPROM_WRITE_OPCODE 0x05 |
Ben Dooks | 072bc80 | 2011-11-21 08:57:57 +0000 | [diff] [blame] | 23 | #define PCI_EEPROM_ERASE_OPCODE 0x07 |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 24 | #define PCI_EEPROM_READ_OPCODE 0x06 |
| 25 | #define PCI_EEPROM_EWDS_OPCODE 0x10 |
| 26 | #define PCI_EEPROM_EWEN_OPCODE 0x13 |
| 27 | |
| 28 | /** |
| 29 | * struct eeprom_93cx6 - control structure for setting the commands |
| 30 | * for reading the eeprom data. |
| 31 | * @data: private pointer for the driver. |
| 32 | * @register_read(struct eeprom_93cx6 *eeprom): handler to |
| 33 | * read the eeprom register, this function should set all reg_* fields. |
| 34 | * @register_write(struct eeprom_93cx6 *eeprom): handler to |
| 35 | * write to the eeprom register by using all reg_* fields. |
| 36 | * @width: eeprom width, should be one of the PCI_EEPROM_WIDTH_* defines |
Ben Dooks | b30f8bd | 2011-11-21 08:57:56 +0000 | [diff] [blame] | 37 | * @drive_data: Set if we're driving the data line. |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 38 | * @reg_data_in: register field to indicate data input |
| 39 | * @reg_data_out: register field to indicate data output |
| 40 | * @reg_data_clock: register field to set the data clock |
| 41 | * @reg_chip_select: register field to set the chip select |
| 42 | * |
| 43 | * This structure is used for the communication between the driver |
| 44 | * and the eeprom_93cx6 handlers for reading the eeprom. |
| 45 | */ |
| 46 | struct eeprom_93cx6 { |
| 47 | void *data; |
| 48 | |
| 49 | void (*register_read)(struct eeprom_93cx6 *eeprom); |
| 50 | void (*register_write)(struct eeprom_93cx6 *eeprom); |
| 51 | |
| 52 | int width; |
| 53 | |
Ben Dooks | b30f8bd | 2011-11-21 08:57:56 +0000 | [diff] [blame] | 54 | char drive_data; |
Ivo van Doorn | 9467d64 | 2007-05-11 15:59:40 -0400 | [diff] [blame] | 55 | char reg_data_in; |
| 56 | char reg_data_out; |
| 57 | char reg_data_clock; |
| 58 | char reg_chip_select; |
| 59 | }; |
| 60 | |
| 61 | extern void eeprom_93cx6_read(struct eeprom_93cx6 *eeprom, |
| 62 | const u8 word, u16 *data); |
| 63 | extern void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, |
| 64 | const u8 word, __le16 *data, const u16 words); |
Ondrej Zary | 7ff28ae | 2014-11-24 23:24:40 +0100 | [diff] [blame] | 65 | extern void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, |
| 66 | const u8 byte, u8 *data); |
| 67 | extern void eeprom_93cx6_multireadb(struct eeprom_93cx6 *eeprom, |
| 68 | const u8 byte, u8 *data, const u16 bytes); |
Ben Dooks | 072bc80 | 2011-11-21 08:57:57 +0000 | [diff] [blame] | 69 | |
| 70 | extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable); |
| 71 | |
| 72 | extern void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, |
| 73 | u8 addr, u16 data); |