1 |
/* |
2 |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot. |
4 |
* |
5 |
* NMC93C46/NMC93C56 Serial EEPROM. |
6 |
*/ |
7 |
|
8 |
#ifndef __NMC93CX6_H__ |
9 |
#define __NMC93CX6_H__ |
10 |
|
11 |
#include <sys/types.h> |
12 |
#include "utils.h" |
13 |
#include "cisco_eeprom.h" |
14 |
|
15 |
/* EEPROM types */ |
16 |
enum { |
17 |
EEPROM_TYPE_NMC93C46, |
18 |
EEPROM_TYPE_NMC93C56, |
19 |
}; |
20 |
|
21 |
/* 8 groups with 4 differents bits (clock,select,data_in,data_out) */ |
22 |
#define NMC93CX6_MAX_EEPROM_PER_GROUP 8 |
23 |
|
24 |
/* NMC93C46 EEPROM command bit length */ |
25 |
#define NMC93C46_CMD_BITLEN 9 |
26 |
|
27 |
/* NMC93C56 EEPROM command bit length */ |
28 |
#define NMC93C56_CMD_BITLEN 11 |
29 |
|
30 |
/* NMC93C46 EEPROM data bit length */ |
31 |
#define NMC93CX6_CMD_DATALEN 16 |
32 |
|
33 |
/* NMC93C46 EEPROM commands: SB (1) OP(2) Address(6/9) */ |
34 |
#define NMC93CX6_CMD_CONTROL (0x1 | 0x0) |
35 |
#define NMC93CX6_CMD_WRDS (0x1 | 0x0 | 0x00) |
36 |
#define NMC93CX6_CMD_ERASE_ALL (0x1 | 0x0 | 0x08) |
37 |
#define NMC93CX6_CMD_WRITE_ALL (0x1 | 0x0 | 0x10) |
38 |
#define NMC93CX6_CMD_WREN (0x1 | 0x0 | 0x18) |
39 |
#define NMC93CX6_CMD_READ (0x1 | 0x2) |
40 |
#define NMC93CX6_CMD_WRITE (0x1 | 0x4) |
41 |
#define NMC93CX6_CMD_ERASE (0x1 | 0x6) |
42 |
|
43 |
struct nmc93cX6_eeprom_def { |
44 |
u_int clock_bit; |
45 |
u_int select_bit; |
46 |
u_int din_bit; |
47 |
u_int dout_bit; |
48 |
}; |
49 |
|
50 |
struct nmc93cX6_eeprom_state { |
51 |
u_int cmd_len; |
52 |
u_int cmd_val; |
53 |
u_int state; |
54 |
u_int dataout_pos; |
55 |
u_int dataout_val; |
56 |
}; |
57 |
|
58 |
struct nmc93cX6_group { |
59 |
u_int eeprom_type; |
60 |
u_int nr_eeprom; |
61 |
u_int eeprom_reg; |
62 |
char *description; |
63 |
int debug; |
64 |
const struct nmc93cX6_eeprom_def *def[NMC93CX6_MAX_EEPROM_PER_GROUP]; |
65 |
struct nmc93cX6_eeprom_state state[NMC93CX6_MAX_EEPROM_PER_GROUP]; |
66 |
struct cisco_eeprom *eeprom[NMC93CX6_MAX_EEPROM_PER_GROUP]; |
67 |
}; |
68 |
|
69 |
/* Handle write */ |
70 |
void nmc93cX6_write(struct nmc93cX6_group *g,u_int data); |
71 |
|
72 |
/* Handle read */ |
73 |
u_int nmc93cX6_read(struct nmc93cX6_group *p); |
74 |
|
75 |
#endif /* __NMC93CX6_H__ */ |