]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/flash/arm/mxc/v2_0/include/imx_spi_nor.h
Initial revision
[karo-tx-redboot.git] / packages / devs / flash / arm / mxc / v2_0 / include / imx_spi_nor.h
1 #ifndef _IMX_SPI_NOR_H_
2 #define _IMX_SPI_NOR_H_
3 //==========================================================================
4 //
5 //      imx_nfc.h
6 //
7 //      Flash programming to support NAND flash on Freescale MXC platforms
8 //
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 //
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //==========================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):    Kevin Zhang <k.zhang@freescale.com>
46 // Contributors: Kevin Zhang <k.zhang@freescale.com>
47 // Date:         2008-11-14
48 // Purpose:
49 // Description:
50 //
51 //####DESCRIPTIONEND####
52 //
53 //==========================================================================
54
55 // dummy defines - not used
56 #define CYGNUM_FLASH_INTERLEAVE         1
57 #define CYGNUM_FLASH_SERIES             1
58 #define CYGNUM_FLASH_WIDTH              8
59 #define CYGNUM_FLASH_BASE               0
60 #define CYGNUM_FLASH_BLANK              1
61
62 #define READ        0x03    // tx: 1 byte cmd + 3 byte addr; rx: variable bytes
63 #define READ_HS     0x0B    // tx: 1 byte cmd + 3 byte addr + 1 byte dummy; rx: variable bytes
64 #define RDSR        0x05    // read status register 1 byte tx cmd + 1 byte rx status
65     #define RDSR_BUSY       (1 << 0)    // 1=write-in-progress (default 0)
66     #define RDSR_WEL        (1 << 1)    // 1=write enable (default 0)
67     #define RDSR_BP0        (1 << 2)    // block write prot level (default 1)
68     #define RDSR_BP1        (1 << 3)    // block write prot level (default 1)
69     #define RDSR_BP2        (1 << 4)    // block write prot level (default 1)
70     #define RDSR_BP3        (1 << 5)    // block write prot level (default 1)
71     #define RDSR_AAI        (1 << 6)    // 1=AAI prog mode; 0=byte prog (default 0)
72     #define RDSR_BPL        (1 << 7)    // 1=BP3,BP2,BP1,BP0 RO; 0=R/W (default 0)    
73 #define WREN        0x06    // write enable. 1 byte tx cmd
74 #define WRDI        0x04    // write disable. 1 byte tx cmd
75 #define EWSR        0x50    // Enable write status. 1 byte tx cmd
76 #define WRSR        0x01    // Write status register. 1 byte tx cmd + 1 byte tx value
77 #define ERASE_4K    0x20    // sector erase. 1 byte cmd + 3 byte addr
78 #define ERASE_32K   0x52    // 32K block erase. 1 byte cmd + 3 byte addr
79 #define ERASE_64K   0xD8    // 64K block erase. 1 byte cmd + 3 byte addr
80 #define ERASE_CHIP  0x60    // whole chip erase
81 #define BYTE_PROG   0x02    // all tx: 1 cmd + 3 addr + 1 data
82 #define AAI_PROG    0xAD    // all tx: [1 cmd + 3 addr + 2 data] + RDSR
83                             //   + [1cmd + 2 data] + .. + [WRDI] + [RDSR]
84 #define JEDEC_ID    0x9F    // read JEDEC ID. tx: 1 byte cmd; rx: 3 byte ID
85
86 #define SZ_64K      0x10000
87 #define SZ_32K      0x8000
88 #define SZ_4K       0x1000
89
90 extern imx_spi_init_func_t *spi_nor_init;
91 extern imx_spi_xfer_func_t *spi_nor_xfer;
92 extern struct imx_spi_dev imx_spi_nor;
93 static int spi_nor_status(void);
94 static int spi_nor_cmd_1byte(unsigned char cmd);
95 int spi_nor_erase_block(void* block_addr, unsigned int block_size);
96 static int spi_nor_write_status(unsigned char val);
97 int spi_nor_program_buf(void *addr, void *data, int len);
98
99 #endif // _IMX_SPI_NOR_H_