at master 2.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 Copyright (C) 2004 - 2006 rt2x00 SourceForge Project 4 <http://rt2x00.serialmonkey.com> 5 6 */ 7 8/* 9 Module: eeprom_93cx6 10 Abstract: EEPROM reader datastructures for 93cx6 chipsets. 11 Supported chipsets: 93c46, 93c56 and 93c66. 12 */ 13 14#include <linux/bits.h> 15 16/* 17 * EEPROM operation defines. 18 */ 19#define PCI_EEPROM_WIDTH_93C46 6 20#define PCI_EEPROM_WIDTH_93C56 8 21#define PCI_EEPROM_WIDTH_93C66 8 22#define PCI_EEPROM_WIDTH_93C86 8 23#define PCI_EEPROM_WIDTH_OPCODE 3 24#define PCI_EEPROM_WRITE_OPCODE 0x05 25#define PCI_EEPROM_ERASE_OPCODE 0x07 26#define PCI_EEPROM_READ_OPCODE 0x06 27#define PCI_EEPROM_EWDS_OPCODE 0x10 28#define PCI_EEPROM_EWEN_OPCODE 0x13 29 30/** 31 * struct eeprom_93cx6 - control structure for setting the commands 32 * for reading the eeprom data. 33 * @data: private pointer for the driver. 34 * @register_read(struct eeprom_93cx6 *eeprom): handler to 35 * read the eeprom register, this function should set all reg_* fields. 36 * @register_write(struct eeprom_93cx6 *eeprom): handler to 37 * write to the eeprom register by using all reg_* fields. 38 * @width: eeprom width, should be one of the PCI_EEPROM_WIDTH_* defines 39 * @quirks: eeprom or controller quirks 40 * @drive_data: Set if we're driving the data line. 41 * @reg_data_in: register field to indicate data input 42 * @reg_data_out: register field to indicate data output 43 * @reg_data_clock: register field to set the data clock 44 * @reg_chip_select: register field to set the chip select 45 * 46 * This structure is used for the communication between the driver 47 * and the eeprom_93cx6 handlers for reading the eeprom. 48 */ 49struct eeprom_93cx6 { 50 void *data; 51 52 void (*register_read)(struct eeprom_93cx6 *eeprom); 53 void (*register_write)(struct eeprom_93cx6 *eeprom); 54 55 int width; 56 unsigned int quirks; 57/* Some EEPROMs require an extra clock cycle before reading */ 58#define PCI_EEPROM_QUIRK_EXTRA_READ_CYCLE BIT(0) 59 60 char drive_data; 61 char reg_data_in; 62 char reg_data_out; 63 char reg_data_clock; 64 char reg_chip_select; 65}; 66 67extern void eeprom_93cx6_read(struct eeprom_93cx6 *eeprom, 68 const u8 word, u16 *data); 69extern void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, 70 const u8 word, __le16 *data, const u16 words); 71extern void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, 72 const u8 byte, u8 *data); 73extern void eeprom_93cx6_multireadb(struct eeprom_93cx6 *eeprom, 74 const u8 byte, u8 *data, const u16 bytes); 75 76extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable); 77 78extern void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, 79 u8 addr, u16 data); 80 81static inline bool has_quirk_extra_read_cycle(struct eeprom_93cx6 *eeprom) 82{ 83 return eeprom->quirks & PCI_EEPROM_QUIRK_EXTRA_READ_CYCLE; 84}