1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef _FLASHVAR_H_
20 #define _FLASHVAR_H_
21
22 #ifdef _KERNEL
23
24
25 struct flash_ctl_tag {
26 u_int8_t (*reg8_read)(void *, int);
27 int (*regx_read_page)(void *, caddr_t, caddr_t);
28 void (*reg8_write)(void *, int, u_int8_t);
29 int (*regx_write_page)(void *, caddr_t, caddr_t);
30 void (*default_disklabel)(void *, dev_t, struct disklabel *);
31 int (*safe_strategy)(void *, struct buf *);
32 };
33
34
35
36
37
38
39
40 #define FLASH_REG_DATA 0x00
41 #define FLASH_REG_COL 0x01
42 #define FLASH_REG_ROW 0x02
43 #define FLASH_REG_CMD 0x03
44 #define FLASH_REG_ALE 0x04
45 #define FLASH_REG_CLE 0x05
46 #define FLASH_REG_CE 0x06
47 #define FLASH_REG_WP 0x07
48 #define FLASH_REG_READY 0x0f
49
50
51 struct flashdev {
52 u_int16_t id;
53 const char *longname;
54 u_long pagesize;
55 u_long oobsize;
56 u_long blkpages;
57 u_long capacity;
58 };
59
60 #define FLASH_DEVICE(v,d) ((FLASH_VENDOR_##v << 8) | (d))
61
62
63 #define FLASH_VENDOR_SAMSUNG 0xec
64
65
66 #define FLASH_DEVICE_SAMSUNG_K9F2808U0C FLASH_DEVICE(SAMSUNG, 0x73)
67 #define FLASH_DEVICE_SAMSUNG_K9F1G08U0A FLASH_DEVICE(SAMSUNG, 0xf1)
68
69
70 #define FLASH_MAXPAGESIZE 2048
71 #define FLASH_MAXOOBSIZE 64
72
73
74
75
76 struct flash_softc {
77 struct device sc_dev;
78
79 struct disk sc_dk;
80 struct buf sc_q;
81 struct buf *sc_bp;
82 int sc_flags;
83
84 struct flash_ctl_tag *sc_tag;
85 void *sc_cookie;
86
87 const struct flashdev *sc_flashdev;
88 int sc_maxwaitready;
89 int sc_maxwaitcomplete;
90 };
91
92
93 #define FDK_LOADED 0x00000001
94 #define FDK_SAFE 0x00000002
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 #define flashsafe(x) (minor(x) & 0x800)
112 #define flashunit(x) DISKUNIT(makedev(major(x), minor(x) & 0x7ff))
113 #define flashpart(x) DISKPART(makedev(major(x), minor(x) & 0x7ff))
114 #define flashlabeldev(x) (MAKEDISKDEV(major(x), flashunit(x), RAW_PART)\
115 |flashsafe(x))
116
117 void flashattach(struct flash_softc *, struct flash_ctl_tag *, void *);
118 int flashdetach(struct device *, int);
119 int flashactivate(struct device *, enum devact);
120
121 u_int8_t flash_reg8_read(struct flash_softc *, int);
122 void flash_reg8_read_page(struct flash_softc *, caddr_t, caddr_t);
123 void flash_reg8_write(struct flash_softc *, int, u_int8_t);
124 void flash_reg8_write_page(struct flash_softc *, caddr_t, caddr_t);
125 void flash_chip_enable(struct flash_softc *);
126 void flash_chip_disable(struct flash_softc *);
127 int flash_chip_reset(struct flash_softc *);
128 int flash_chip_identify(struct flash_softc *, u_int8_t *, u_int8_t *);
129 int flash_chip_erase_block(struct flash_softc *, long);
130 int flash_chip_read_block(struct flash_softc *, long, caddr_t);
131 int flash_chip_read_page(struct flash_softc *, long, caddr_t, caddr_t);
132 int flash_chip_read_oob(struct flash_softc *, long, caddr_t);
133 int flash_chip_write_block(struct flash_softc *, long, caddr_t, caddr_t);
134 int flash_chip_write_page(struct flash_softc *, long, caddr_t, caddr_t);
135 int flash_chip_verify_block(struct flash_softc *, long, caddr_t, caddr_t);
136 int flash_chip_verify_page(struct flash_softc *, long, caddr_t, caddr_t);
137
138 #endif
139
140
141
142 #endif