blob: 2ab8842abdc3c00f344df8b1952e302db0d58080 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#ifndef _CFI_FLASH_H
#define _CFI_FLASH_H
#include <stdint.h>
#define CFI_FLASH_MAX_ERASE_REGIONS 4
/* structure of erase region descriptor */
struct cfi_region {
uint16_t b_count;
uint16_t b_size;
} __attribute__((packed));
/* structure of cfi query response */
struct cfi_query {
uint8_t qry[3];
uint16_t p_id;
uint16_t p_adr;
uint16_t a_id;
uint16_t a_adr;
uint8_t vcc_min;
uint8_t vcc_max;
uint8_t vpp_min;
uint8_t vpp_max;
uint8_t word_write_timeout_typ;
uint8_t buf_write_timeout_typ;
uint8_t block_erase_timeout_typ;
uint8_t chip_erase_timeout_typ;
uint8_t word_write_timeout_max;
uint8_t buf_write_timeout_max;
uint8_t block_erase_timeout_max;
uint8_t chip_erase_timeout_max;
uint8_t dev_size;
uint16_t interface_desc;
uint16_t max_buf_write_size;
uint8_t num_erase_regions;
struct cfi_region erase_regions[CFI_FLASH_MAX_ERASE_REGIONS];
} __attribute__((packed));
typedef struct {
void *f_base;
uint32_t f_size;
uint16_t f_manuf_id;
uint16_t f_dev_id;
struct cfi_query f_query;
} cfi_flash_t;
typedef uint8_t flash_lock;
void flash_init(cfi_flash_t *flash, void *base_addr);
void flash_dump_info(cfi_flash_t *flash);
flash_lock flash_block_getlock(cfi_flash_t *base_addr, uint32_t block_offset);
void flash_block_unlock(cfi_flash_t *base_addr, uint32_t block_offset);
void flash_block_lock(cfi_flash_t *base_addr, uint32_t block_offset);
void flash_block_lockdown(cfi_flash_t *base_addr, uint32_t block_offset);
void flash_block_erase(cfi_flash_t *base_addr, uint32_t block_addr);
#endif
|