summaryrefslogtreecommitdiff
path: root/chip/g/loader/rom_flash.h
blob: 7895d14af2cc5aeebaf823122b7f79d19b0bc259 (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
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __EC_CHIP_G_LOADER_ROM_FLASH_H
#define __EC_CHIP_G_LOADER_ROM_FLASH_H

#include "registers.h"

#define FSH_OP_BULKERASE GC_CONST_FSH_PE_CONTROL_BULKERASE
#define FSH_OP_ENABLE    GC_CONST_FSH_PE_EN
#define FSH_OP_ERASE     GC_CONST_FSH_PE_CONTROL_ERASE
#define FSH_OP_PROGRAM   GC_CONST_FSH_PE_CONTROL_PROGRAM
#define FSH_OP_READ      GC_CONST_FSH_PE_CONTROL_READ

#if 0
#define num_flashes 2
/*
 * FIX ME: words_per_row = m.get_flash_param("FlashWordsPerRow")
 * FIX ME: rows_per_page = m.get_flash_param("FlashRowsPerPage")
 * FIX ME: words_per_page = int(words_per_row)*int(rows_per_page)
 */
#define words_per_page 512
/* This is BAD... This number is based on the TSMC spec Nmp=Tprog/Tsmp */
#define _max_prog_cycles 9
/* This is BAD... This number is based on the TSMC spec Nme=Terase/Tsme */
#define _max_erase_cycles 45
/* This is BAD... This number is based on the TSMC spec Nme=Terase/Tsme */
#define _max_bulkerase_cycles 45
#define _debug_flash 0

/* write words to flash */
int flash_write(uint32_t fidx, uint32_t offset,
		const uint32_t *data, uint32_t size);

/* erase one page */
int flash_erase(uint32_t fidx, uint32_t page);

/* erase entire bank */
int flash_wipe(uint32_t fidx);
#endif

#define E_FL_NOT_AWAKE 1
#define E_FL_TIMEOUT 2
#define E_FL_BAD_MAINB 3
#define E_FL_BAD_SIZE 4
#define E_FL_BAD_PTR 5
#define E_FL_BAD_BANK 6
#define E_FL_WRITE_FAIL 7
#define E_FL_ERASE_FAIL 8
#define E_FL_WIPE_FAIL 9
#define E_FL_ERROR 10

/* read single word from info block */
int flash_info_read(uint32_t offset, uint32_t *dst);


#endif  /* __EC_CHIP_G_LOADER_ROM_FLASH_H */