annotate packages/devs/flash/powerpc/moab/current/src/moab_nand_flash.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents 7fbd87364c15
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
1 //==========================================================================
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
2 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
3 // moab_nand_flash.c
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
4 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
5 // Flash programming for Toshiba NAND FLASH device on MOAB board
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
6 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
16 // version.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
21 // for more details.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
33 // General Public License v2.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1517
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
39 //==========================================================================
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
41 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
42 // Author(s): Gary Thomas <gary@mlbassoc.com>
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
43 // Contributors:
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
44 // Date: 2003-09-02
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
45 // Purpose:
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
46 // Description:
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
47 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
48 //####DESCRIPTIONEND####
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
49 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
50 //==========================================================================
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
51
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
52 #include <cyg/infra/cyg_type.h>
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
53 #define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
54 #include <cyg/hal/ppc_regs.h> // Platform registers
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
55 #include <cyg/hal/hal_io.h> // I/O macros
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
56 #include <cyg/hal/hal_if.h> // Virtual vector interfaces
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
57
1517
7fbd87364c15 Add support for newer part TC58DVG02 (128MB)
gthomas
parents: 1223
diff changeset
58 // There's a single TC58256 or TC58DVG02 on the MOAB board.
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
59
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
60 #define CYGHWR_DEVS_FLASH_TOSHIBA_TC58256
1517
7fbd87364c15 Add support for newer part TC58DVG02 (128MB)
gthomas
parents: 1223
diff changeset
61 #define CYGHWR_DEVS_FLASH_TOSHIBA_TC58DVG02
7fbd87364c15 Add support for newer part TC58DVG02 (128MB)
gthomas
parents: 1223
diff changeset
62 #define CYGNUM_FLASH_BLANK (1)
1223
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
63 #define CYGNUM_FLASH_INTERLEAVE (1)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
64 #define CYGNUM_FLASH_WIDTH (8)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
65 #define CYGNUM_FLASH_SERIES (1)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
66 #define CYGNUM_FLASH_BASE (_MOAB_NAND)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
67
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
68 #define CYGHWR_FLASH_TC58XXX_CE moab_CE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
69 #define CYGHWR_FLASH_TC58XXX_CLE moab_CLE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
70 #define CYGHWR_FLASH_TC58XXX_ALE moab_ALE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
71 #define CYGHWR_FLASH_TC58XXX_RDY moab_RDY
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
72
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
73 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
74 // Select the NAND device - this will be held until the
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
75 // entire command/data sequence has completed (which is
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
76 // necessary for read sequential)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
77 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
78 static void __inline__
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
79 moab_CE(int state)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
80 {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
81 cyg_uint32 gpio_or;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
82 HAL_READ_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
83 if (state) {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
84 // Assert CE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
85 gpio_or &= ~_MOAB_CE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
86 } else {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
87 // De-assert CE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
88 gpio_or |= _MOAB_CE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
89 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
90 HAL_WRITE_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
91 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
92
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
93 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
94 // Prepare to send a command byte to the NAND interface
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
95 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
96 static void __inline__
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
97 moab_CLE(int state)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
98 {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
99 cyg_uint32 gpio_or;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
100 HAL_READ_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
101 if (state) {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
102 // Assert CLE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
103 gpio_or |= _MOAB_CLE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
104 } else {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
105 // De-assert CLE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
106 gpio_or &= ~_MOAB_CLE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
107 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
108 HAL_WRITE_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
109 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
110
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
111 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
112 // Prepare to send address byte(s) to the NAND interface
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
113 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
114 static void __inline__
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
115 moab_ALE(int state)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
116 {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
117 cyg_uint32 gpio_or;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
118
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
119 HAL_READ_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
120 if (state) {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
121 // Assert ALE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
122 gpio_or |= _MOAB_ALE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
123 } else {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
124 // De-assert ALE
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
125 gpio_or &= ~_MOAB_ALE;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
126 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
127 HAL_WRITE_UINT32(GPIO_OR, gpio_or);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
128 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
129
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
130 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
131 // Wait until the NAND device is ready (after a long operation)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
132 //
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
133 static bool __inline__
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
134 moab_RDY(void)
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
135 {
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
136 cyg_uint32 gpio_ir;
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
137
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
138 HAL_READ_UINT32(GPIO_IR, gpio_ir);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
139 return ((gpio_ir & _MOAB_RDY) != 0);
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
140 }
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
141
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
142 #include <cyg/io/flash_tc58xxx.inl>
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
143
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
144
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
145 // ------------------------------------------------------------------------
dbcfe4e0dbd2 New platform - TAMS MOAB - and generic changes to support it
gthomas
parents:
diff changeset
146 // EOF moab_nand_flash.c