1 //=============================================================================
3 // i557_eep.h - Cyclone Diagnostics
5 //=============================================================================
6 //####ECOSGPLCOPYRIGHTBEGIN####
7 // -------------------------------------------
8 // This file is part of eCos, the Embedded Configurable Operating System.
9 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
11 // eCos is free software; you can redistribute it and/or modify it under
12 // the terms of the GNU General Public License as published by the Free
13 // Software Foundation; either version 2 or (at your option) any later version.
15 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // You should have received a copy of the GNU General Public License along
21 // with eCos; if not, write to the Free Software Foundation, Inc.,
22 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 // As a special exception, if other files instantiate templates or use macros
25 // or inline functions from this file, or you compile this file and link it
26 // with other works to produce a work based on this file, this file does not
27 // by itself cause the resulting work to be covered by the GNU General Public
28 // License. However the source code for this file must still be made available
29 // in accordance with section (3) of the GNU General Public License.
31 // This exception does not invalidate any other reasons why a work based on
32 // this file might be covered by the GNU General Public License.
34 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35 // at http://sources.redhat.com/ecos/ecos-license/
36 // -------------------------------------------
37 //####ECOSGPLCOPYRIGHTEND####
38 //=============================================================================
39 //#####DESCRIPTIONBEGIN####
41 // Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
47 //####DESCRIPTIONEND####
49 //===========================================================================*/
51 /* Public define's and function prototypes */
52 #define EEPROM_SIZE 128 /* Maximum # bytes in serial eeprom */
53 #define EEPROM_WORD_SIZE 64 /* Maximum # shorts in serial eeprom */
55 /* result codes for the functions below */
56 #define OK 0 /* Operation completed successfully */
57 #define EEPROM_ERROR 1 /* generic error */
58 #define EEPROM_NOT_RESPONDING 2 /* eeprom not resp/not installed */
59 #define EEPROM_TO_SMALL 3 /* req write/read past end of eeprom */
60 #define EEPROM_INVALID_CMD 4 /* op code not supported */
62 /* layout of the Serial EEPROM register */
63 #define I557_EESK (1 << 0)
64 #define I557_EECS (1 << 1)
65 #define I557_EEDI (1 << 2)
66 #define I557_EEDO (1 << 3)
69 #define EEPROM_WRITE 1
71 #define EEPROM_ERASE 3
74 #define EEPROM_EWEN_OP 0x30
75 #define EEPROM_EWDS_OP 0x00
77 /* EEPROM Chip Select */
78 #define SELECT_557_EEP(n) (*(unsigned char *)(n+0x0e) |= I557_EECS)
79 #define DESELECT_557_EEP(n) (*(unsigned char *)(n+0x0e) &= ~I557_EECS)
81 /* EEPROM Serial Clock */
82 #define SK_HIGH_557_EEP(n) (*(unsigned char *)(n+0x0e) |= I557_EESK)
83 #define SK_LOW_557_EEP(n) (*(unsigned char *)(n+0x0e) &= ~I557_EESK)
85 /* EEPROM Serial Data In -> out to eeprom */
86 #define EEDI_HIGH_557_EEP(n) (*(unsigned char *)(n+0x0e) |= I557_EEDI)
87 #define EEDI_LOW_557_EEP(n) (*(unsigned char *)(n+0x0e) &= ~I557_EEDI)
89 /* EEPROM Serial Data Out -> in from eeprom */
90 #define EEDO_557_EEP(n) ((*(unsigned char *)(n+0x0e) & I557_EEDO) >> 3)
92 /* global functions declared in serial_eep.c */
94 int eeprom_read (unsigned long pci_addr,
95 int eeprom_addr, /* word offset from start of eeprom */
96 unsigned short *p_data,/* buffer pointer */
97 int nwords /* number of bytes to read */