blob: 0bf35a5063bc6a00497d5ab38d420ac2311f26f5 [file] [log] [blame]
Juan Castillofacdd1c2015-08-12 12:53:02 +01001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __NORFLASH_H_
32#define __NORFLASH_H_
33
34#include <stdint.h>
35
36/* First bus cycle */
37#define NOR_CMD_READ_ARRAY 0xFF
38#define NOR_CMD_READ_ID_CODE 0x90
39#define NOR_CMD_READ_QUERY 0x98
40#define NOR_CMD_READ_STATUS_REG 0x70
41#define NOR_CMD_CLEAR_STATUS_REG 0x50
42#define NOR_CMD_WRITE_TO_BUFFER 0xE8
43#define NOR_CMD_WORD_PROGRAM 0x40
44#define NOR_CMD_BLOCK_ERASE 0x20
45#define NOR_CMD_LOCK_UNLOCK 0x60
46
47/* Second bus cycle */
48#define NOR_LOCK_BLOCK 0x01
49#define NOR_UNLOCK_BLOCK 0xD0
50
51/* Status register bits */
52#define NOR_DWS (1 << 7)
53#define NOR_ESS (1 << 6)
54#define NOR_ES (1 << 5)
55#define NOR_PS (1 << 4)
56#define NOR_VPPS (1 << 3)
57#define NOR_PSS (1 << 2)
58#define NOR_BLS (1 << 1)
59#define NOR_BWS (1 << 0)
60
61/* Public API */
62void nor_send_cmd(uintptr_t base_addr, unsigned long cmd);
63int nor_word_program(uintptr_t base_addr, unsigned long data);
64void nor_lock(uintptr_t base_addr);
65void nor_unlock(uintptr_t base_addr);
66
67#endif /* __NORFLASH_H_ */
68