summaryrefslogtreecommitdiffstats
path: root/src/occ_gpe0/firdata/norflash.h
blob: c4c9cdcdb1dc96920d26410a096c4f7e6328a2d3 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/firdata/norflash.h $                              */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2017                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef __PNOR_NORFLASH_H
#define __PNOR_NORFLASH_H

#include <native.h>
#include <pnor_mboxdd.h>

/** @file norflash.H
 *  @brief Contains constants related to specific types of
 *    of NOR flash chips
 */

/**
 * @brief Supported NOR Chip IDs
 */
enum NorChipIDs
{
    UNKNOWN_NOR_ID    = 0x12345600, /**< Initial value before read */

    MICRON_MFG_ID     = 0x20000000, /**< Micron Mfg ID */
    MICRON_NOR_ID     = 0x20ba2000, /**< Micron NOR */

    MACRONIX_MFG_ID   = 0xC2000000, /**< Macronix Mfg ID */
    MACRONIX32_NOR_ID = 0xC2201A00, /**< Macronix NOR MXxxL51235F */
    MACRONIX64_NOR_ID = 0xC2201900, /**< Macronix NOR MXxxL25635F */

    /* Note: Simics currently models Micron NOR  */
    VPO_NOR_ID        = 0x20201800, /**< VPO NOR chip ID */
    FAKE_NOR_ID       = 0xBADBAD00, /**< ID used during fake pnor */

    ID_MASK           = 0xFFFFFF00, /**< Only look at 3 bytes */
    MFGID_MASK        = 0xFF000000, /**< Manufacturer ID is the first byte */
};

/**
 * @brief SPI Config Info
 *    OP Codes and other MISC info for configuring SFC
 */
typedef enum
{
    SPI_NO_OPCODE       = 0x00, /**< Undefined value */

    /*
     * Micron Flash Commands
     */
    SPI_MICRON_FLAG_STAT    = 0x70, /**< Check write/erase complete */
    SPI_MICRON_CLRFLAG_STAT = 0x50, /**< Clear write/erase Status reg */

    /*
     * Macronix Flash Commands
     */
    SPI_MACRONIX_EN4B        = 0xB7, /**< Enable Macronix 4-Byte addressing */

    /* SPI protocol commands */
    SPI_JEDEC_WRITE_STATUS   = 0x01, /*WRSR */
    SPI_JEDEC_PAGE_PROGRAM   = 0x02, /*PP */
    SPI_JEDEC_READ           = 0x03, /*READ */
    SPI_JEDEC_WRITE_DISABLE  = 0x04, /*WRDI */
    SPI_JEDEC_READ_STATUS    = 0x05, /*RDSR */
    SPI_JEDEC_WRITE_ENABLE   = 0x06, /*WREN */
    SPI_JEDEC_FAST_READ      = 0x0B, /*FAST_READ */
    SPI_JEDEC_SECTOR_ERASE   = 0x20, /*SE */
    SPI_JEDEC_READ_SFDP      = 0x5A, /*RDSFDP */
    SPI_JEDEC_CHIPID         = 0x9F, /*RDID */
    SPI_JEDEC_BLOCK_ERASE    = 0xD8, /*BE */

} SpiConfigInfo;

/**
 * @brief General Constants related to flash
 */
enum
{
    PAGE_PROGRAM_BYTES = 256, /***< 256 bytes per PP command */
};


/**
 * Common format of Status Register
 */
typedef union
{
    uint8_t data8;
    struct
    {
        uint8_t writeProtect    : 1; /*0 */
        uint8_t rsvd            : 5; /*1:5 */
        uint8_t writeEnable     : 1; /*6 */
        uint8_t writeInProgress : 1; /*7 */
    };
} NorStatusReg_t;

/**
 * Flags used to trigger Hardware workarounds
 */
enum
{
    /* No workarounds present */
    HWWK_NO_WORKAROUNDS = 0x00000000,

    /* Must perform 'read flag status' commands after */
    /*  any write or erase */
    HWWK_MICRON_WRT_ERASE = 0x00000001,

    /* Must do a read of a low flash address before issuing read */
    /*  commands that return more than 1 word of data */
    HWWK_MICRON_EXT_READ = 0x00000002,
};


/*
 * Vendor-specific interfaces
 */

/**
 * @brief Check flag status bit on Micron NOR chips
 *        The current version of Micron parts require the Flag
 *        Status register be read after a read or erase operation,
 *        otherwise all future operations won't work..
 *
 * @parm i_pnorMbox  Pnor Mbox Struct to operate on
 *
 * @return Error from operation
 */
errorHndl_t micronFlagStatus( pnorMbox_t* i_pnorMbox );




#endif
OpenPOWER on IntegriCloud