/*
 * $Id: enet_eeprom.h,v 1.5 2001/08/03 18:14:42 thockin Exp $
 *
 * Copyright (C) 2001 Sun Microsystems
 * All Rights Reserved
 *
 */

#ifndef ENET_EEPROM_H__
#define ENET_EEPROM_H__

#define WAKE_ON_PHY     (1<<0)
#define WAKE_ON_UCAST   (1<<1)
#define WAKE_ON_MCAST   (1<<2)
#define WAKE_ON_BCAST   (1<<3)
#define WAKE_ON_ARP     (1<<4)
#define WAKE_ON_MAGIC   (1<<5)
#define WAKE_ON_SOMAGIC (1<<6)

/*
 * A few notes on this driver model:
 * 
 * The only functions that should actually go out to the EEPROM device
 * are the read_eeprom() and write_eeprom() methods, and the 
 * {read,write}{byte,word}() methods.  All other methods operate on an
 * array of unsigned short values, representing the EEPROM data.
 *
 * All methods return integers, negative values indicate a failure.  
 * Driver methods may print an error to stderr if they have detailed 
 * information.
 *
 * Required methods:
 * 	read_eeprom()
 *	read_byte()
 *	read_word()
 *	get_size()
 *
 * If _ANY_ write method is supported, the following must be also:
 *	write_eeprom()
 *	write_byte()
 *	write_word()
 *	update_checksum()
 *
 * If load_default() is supported, the following must be also:
 * 	read_mac()
 * 	write_mac()
 *
 * All other methods are optional, NULL indicates their lack of support.
 */
struct eeprom_driver {
    /* read and write the the entire eeprom */
    int (*read_eeprom)(unsigned short ioaddr, unsigned short *eeprom_data);
    int (*write_eeprom)(unsigned short ioaddr, unsigned short *eeprom_data);

    /* read/write an arbitrary word/byte from eeprom */
    int (*read_byte)(unsigned short ioaddr, unsigned char *data, int offset);
    int (*read_word)(unsigned short ioaddr, unsigned short *data, int offset);
    int (*write_byte)(unsigned short ioaddr, unsigned char data, int offset);
    int (*write_word)(unsigned short ioaddr, unsigned short data, int offset);

    /* get size of eeprom in 16 bit words */
    int (*get_size)(void);

    /* update the checksum of the eeprom data */
    int (*update_checksum)( unsigned short *eeprom_data);

    /* stuff the default values into the eeprom data */
    int (*load_default)(unsigned short *eeprom_data);

    /* read/write the mac address to/from the eeprom data */
    int (*read_mac)(unsigned short *eeprom_data, unsigned char *mac);
    int (*write_mac)(unsigned short *eeprom_data, unsigned char *mac);

    /* read/write wake on lan info to/from the eeprom data */
    int (*read_wol)(unsigned short *eeprom_data, unsigned long *wol);
    int (*write_wol)(unsigned short *eeprom_data, unsigned long wol);

    /* read/write SecureOn passwords to/from the eeprom data */
    int (*read_sopass)(unsigned short *eeprom_data, unsigned char *sopass);
    int (*write_sopass)(unsigned short *eeprom_data, unsigned char *sopass);
};

extern struct eeprom_driver natsemi_driver;
extern struct eeprom_driver eepro100_driver;

#endif /* ENET_EEPROM_H__ */
