1 |
/* |
2 |
* Simulates a NMC93C46 Serial EEPROM. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot. |
4 |
*/ |
5 |
|
6 |
#ifndef __NMC93C46_H__ |
7 |
#define __NMC93C46_H__ |
8 |
|
9 |
#include <sys/types.h> |
10 |
#include "utils.h" |
11 |
#include "cisco_eeprom.h" |
12 |
|
13 |
/* 8 groups with 4 differents bits (clock,select,data_in,data_out) */ |
14 |
#define NMC93C46_MAX_EEPROM_PER_GROUP 8 |
15 |
|
16 |
/* NMC93C46 EEPROM command bit length */ |
17 |
#define NMC93C46_CMD_BITLEN 9 |
18 |
|
19 |
/* NMC93C46 EEPROM data bit length */ |
20 |
#define NMC93C46_CMD_DATALEN 16 |
21 |
|
22 |
/* NMC93C46 EEPROM commands: SB (1) OP(2) Address(5) */ |
23 |
#define NMC93C46_CMD_CONTROL (0x1 | 0x0) |
24 |
#define NMC93C46_CMD_WRDS (0x1 | 0x0 | 0x00) |
25 |
#define NMC93C46_CMD_ERASE_ALL (0x1 | 0x0 | 0x08) |
26 |
#define NMC93C46_CMD_WRITE_ALL (0x1 | 0x0 | 0x10) |
27 |
#define NMC93C46_CMD_WREN (0x1 | 0x0 | 0x18) |
28 |
#define NMC93C46_CMD_READ (0x1 | 0x2) |
29 |
#define NMC93C46_CMD_WRITE (0x1 | 0x4) |
30 |
#define NMC93C46_CMD_ERASE (0x1 | 0x6) |
31 |
|
32 |
struct nmc93c46_eeprom_def { |
33 |
u_int clock_bit; |
34 |
u_int select_bit; |
35 |
u_int din_bit; |
36 |
u_int dout_bit; |
37 |
}; |
38 |
|
39 |
struct nmc93c46_eeprom_state { |
40 |
u_int cmd_len; |
41 |
u_int cmd_val; |
42 |
u_int state; |
43 |
u_int dataout_pos; |
44 |
u_int dataout_val; |
45 |
}; |
46 |
|
47 |
struct nmc93c46_group { |
48 |
u_int nr_eeprom; |
49 |
u_int eeprom_reg; |
50 |
char *description; |
51 |
int debug; |
52 |
const struct nmc93c46_eeprom_def *def[NMC93C46_MAX_EEPROM_PER_GROUP]; |
53 |
struct nmc93c46_eeprom_state state[NMC93C46_MAX_EEPROM_PER_GROUP]; |
54 |
struct cisco_eeprom *eeprom[NMC93C46_MAX_EEPROM_PER_GROUP]; |
55 |
}; |
56 |
|
57 |
/* Handle write */ |
58 |
void nmc93c46_write(struct nmc93c46_group *g,u_int data); |
59 |
|
60 |
/* Handle read */ |
61 |
u_int nmc93c46_read(struct nmc93c46_group *p); |
62 |
|
63 |
#endif /* __NMC93C46_H__ */ |