comparison packages/devs/flash/amd/am29xxxxxv2/current/doc/am29xxxxx.sgml @ 1767:2ca70385b0f4

Bring driver docs up to date
author bartv
date Wed, 23 Feb 2005 23:11:03 +0000
parents a15c7003d1da
children
comparison
equal deleted inserted replaced
1766:5783e8dbedf5 1767:2ca70385b0f4
10 <!-- --> 10 <!-- -->
11 <!-- =============================================================== --> 11 <!-- =============================================================== -->
12 <!-- ####ECOSPRODOCCOPYRIGHTBEGIN#### --> 12 <!-- ####ECOSPRODOCCOPYRIGHTBEGIN#### -->
13 <!-- --> 13 <!-- -->
14 <!-- This file is part of eCosPro(tm) --> 14 <!-- This file is part of eCosPro(tm) -->
15 <!-- Copyright (C) 2004 eCosCentric Limited --> 15 <!-- Copyright (C) 2004, 2005 eCosCentric Limited -->
16 <!-- Distribution of the work or derivative of the work in any --> 16 <!-- Distribution of the work or derivative of the work in any -->
17 <!-- form is prohibited unless prior permission obtained from the --> 17 <!-- form is prohibited unless prior permission obtained from the -->
18 <!-- copyright holder --> 18 <!-- copyright holder -->
19 <!-- --> 19 <!-- -->
20 <!-- ####ECOSPRODOCCOPYRIGHTEND#### --> 20 <!-- ####ECOSPRODOCCOPYRIGHTEND#### -->
42 42
43 <refsect1 id="am29xxxxx-description"><title>Description</title> 43 <refsect1 id="am29xxxxx-description"><title>Description</title>
44 <para> 44 <para>
45 The <varname>CYGPKG_DEVS_FLASH_AMD_AM29XXXXX_V2</varname> AMD 45 The <varname>CYGPKG_DEVS_FLASH_AMD_AM29XXXXX_V2</varname> AMD
46 AM29xxxxx V2 flash driver package implements support for the AM29xxxxx 46 AM29xxxxx V2 flash driver package implements support for the AM29xxxxx
47 family of flash devices and compatibles. The driver is not normally 47 family of flash devices and compatibles. Normally the driver is not
48 accessed directly. Instead application code will use the API provided 48 accessed directly. Instead application code will use the API provided
49 by the generic flash driver package 49 by the generic flash driver package
50 <varname>CYGPKG_IO_FLASH</varname>, for example by calling functions 50 <varname>CYGPKG_IO_FLASH</varname>, for example by calling functions
51 like <function>cyg_flash_program</function>. 51 like <function>cyg_flash_program</function>.
52 </para> 52 </para>
109 <refsynopsisdiv> 109 <refsynopsisdiv>
110 <funcsynopsis> 110 <funcsynopsis>
111 <funcsynopsisinfo> 111 <funcsynopsisinfo>
112 #include &lt;cyg/io/am29xxxxx_dev.h&gt; 112 #include &lt;cyg/io/am29xxxxx_dev.h&gt;
113 </funcsynopsisinfo> 113 </funcsynopsisinfo>
114 <funcprototype>
115 <funcdef>int <function>cyg_am29xxxxx_init_nop</function></funcdef>
116 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
117 </funcprototype>
118 <funcprototype> 114 <funcprototype>
119 <funcdef>int <function>cyg_am29xxxxx_init_check_devid_XX</function></funcdef> 115 <funcdef>int <function>cyg_am29xxxxx_init_check_devid_XX</function></funcdef>
120 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef> 116 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
121 </funcprototype> 117 </funcprototype>
122 <funcprototype> 118 <funcprototype>
134 <paramdef>cyg_flashaddr_t <parameter>addr</parameter></paramdef> 130 <paramdef>cyg_flashaddr_t <parameter>addr</parameter></paramdef>
135 <paramdef>const void* <parameter>data</parameter></paramdef> 131 <paramdef>const void* <parameter>data</parameter></paramdef>
136 <paramdef>size_t <parameter>len</parameter></paramdef> 132 <paramdef>size_t <parameter>len</parameter></paramdef>
137 </funcprototype> 133 </funcprototype>
138 <funcprototype> 134 <funcprototype>
139 <funcdef>int <function>cyg_am29xxxxx_query_nop</function></funcdef>
140 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
141 <paramdef>void* <parameter>data</parameter></paramdef>
142 <paramdef>const size_t <parameter>len</parameter></paramdef>
143 </funcprototype>
144 <funcprototype>
145 <funcdef>int <function>cyg_am29xxxxx_hwr_map_error_nop</function></funcdef>
146 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
147 <paramdef>int <parameter>err</parameter></paramdef>
148 </funcprototype>
149 <funcprototype>
150 <funcdef>int <function>cyg_am29xxxxx_lock_nop</function></funcdef>
151 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
152 <paramdef>const cyg_flashaddr_t <parameter>addr</parameter></paramdef>
153 </funcprototype>
154 <funcprototype>
155 <funcdef>int <function>cyg_am29xxxxx_unlock_nop</function></funcdef>
156 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
157 <paramdef>const cyg_flashaddr_t <parameter>addr</parameter></paramdef>
158 </funcprototype>
159 <funcprototype>
160 <funcdef>int <function>cyg_am29xxxxx_read_devid_XX</function></funcdef> 135 <funcdef>int <function>cyg_am29xxxxx_read_devid_XX</function></funcdef>
161 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef> 136 <paramdef>struct cyg_flash_dev* <parameter>device</parameter></paramdef>
162 </funcprototype> 137 </funcprototype>
163 </funcsynopsis> 138 </funcsynopsis>
164 </refsynopsisdiv> 139 </refsynopsisdiv>
165 140
166 <refsect1 id="am29xxxxx-instance-description"><title>Description</title> 141 <refsect1 id="am29xxxxx-instance-description"><title>Description</title>
167 <para> 142 <para>
168 The AM29xxxxx family contains some hundreds of different flash 143 The AM29xxxxx family contains some hundreds of different flash
169 devices, all supporting the same basic set of operations, with various 144 devices, all supporting the same basic set of operations but with
170 common or uncommon extensions. The devices vary in capacity, 145 various common or uncommon extensions. The devices vary in capacity,
171 performance, boot block layout, and width. There are also 146 performance, boot block layout, and width. There are also
172 platform-specific issues such as how many devices are actually present 147 platform-specific issues such as how many devices are actually present
173 on the board and where they are mapped in the address space. The 148 on the board and where they are mapped in the address space. The
174 AM29xxxxx driver package cannot know all this information. Instead it 149 AM29xxxxx driver package cannot know the details of every chip and
175 is the responsibility of another package, usually the platform HAL, to 150 every platform. Instead it is the responsibility of another package,
176 instantiate some flash device structures. Two pieces of information 151 usually the platform HAL, to supply the necessary information by
177 are especially important: the bus configuration and the boot block 152 instantiating some data structures. Two pieces of information are
178 layout. 153 especially important: the bus configuration and the boot block layout.
179 </para> 154 </para>
180 <para> 155 <para>
181 Flash devices are typically 8-bits, 16-bits, or 32-bits wide (64-bit 156 Flash devices are typically 8-bits, 16-bits, or 32-bits wide (64-bit
182 devices are not yet in common use). Most 16-bit devices will also 157 devices are not yet in common use). Most 16-bit devices will also
183 support 8-bit accesses, but not all. Similarly 32-bit devices can be 158 support 8-bit accesses, but not all. Similarly 32-bit devices can be
184 accessed 16-bits at a time or 8-bits at a time. A board will have one 159 accessed 16-bits at a time or 8-bits at a time. A board will have one
185 or more of these devices on the bus. For example there may be a single 160 or more of these devices on the bus. For example there may be a single
186 16-bit device on a 16-bit bus, or two 16-bit devices on a 32-bit bus. 161 16-bit device on a 16-bit bus, or two 16-bit devices on a 32-bit bus.
187 The processor's bus logic determines which combinations are possible, 162 The processor's bus logic determines which combinations are possible,
188 and usually there will be a trade off between cost and performance. 163 and there will be a trade off between cost and performance: two 16-bit
189 For example two 16-bit devices in parallel can provide twice the 164 devices in parallel can provide twice the memory bandwidth of a single
190 memory bandwidth of a single device. The driver supports the following 165 device. The driver supports the following combinations:
191 combinations:
192 </para> 166 </para>
193 <variablelist> 167 <variablelist>
194 <varlistentry> 168 <varlistentry>
195 <term>8</term> 169 <term>8</term>
196 <listitem><para> 170 <listitem><para>
224 <varlistentry> 198 <varlistentry>
225 <term>1616</term> 199 <term>1616</term>
226 <listitem><para> 200 <listitem><para>
227 Two parallel 16-bit devices on a 32-bit bus, with one device providing 201 Two parallel 16-bit devices on a 32-bit bus, with one device providing
228 the bottom two bytes of each 32-bit datum and the other device 202 the bottom two bytes of each 32-bit datum and the other device
229 providing the upper two bytes. 203 providing the top two bytes.
230 </para></listitem> 204 </para></listitem>
231 </varlistentry> 205 </varlistentry>
232 <varlistentry> 206 <varlistentry>
233 <term>16as8</term> 207 <term>16as8</term>
234 <listitem><para> 208 <listitem><para>
246 <caution><para> 220 <caution><para>
247 At the time of writing not all the configurations have been tested. 221 At the time of writing not all the configurations have been tested.
248 </para></caution> 222 </para></caution>
249 <para> 223 <para>
250 The second piece of information is the boot block layout. Flash 224 The second piece of information is the boot block layout. Flash
251 devices are subdivided into blocks (also known as sectors, both terms 225 devices are subdivided into blocks (also known as sectors - both terms
252 are in common use). Some operations such as erase work on a whole 226 are in common use). Some operations such as erase work on a whole
253 block at a time, and for most applications a block is the smallest 227 block at a time, and for most applications a block is the smallest
254 unit that gets updated. A typical block size is 64K. It is inefficient 228 unit that gets updated. A typical block size is 64K. It is inefficient
255 to use an entire 64K block for small bits of configuration data and 229 to use an entire 64K block for small bits of configuration data and
256 similar information, so many flash devices also support a number of 230 similar information, so many flash devices also support a number of
264 </para> 238 </para>
265 </refsect1> 239 </refsect1>
266 240
267 <refsect1 id="am29xxxxx-instance-example"><title>Example</title> 241 <refsect1 id="am29xxxxx-instance-example"><title>Example</title>
268 <para> 242 <para>
269 Flash support is usually specific to each platform. Even if two 243 In most cases flash support is specific to a platform. Even if two
270 platforms happen to use the same flash device there are likely to be 244 platforms happen to use the same flash device there are likely to be
271 differences such as the location in the address map. Hence there is 245 differences such as the location in the address map. Hence there is
272 little possibility of re-using the platform-specific code, and this 246 little possibility of re-using the platform-specific code, and this
273 code is generally placed in the platform HAL rather than in a separate 247 code should be placed in the platform HAL rather than in a separate
274 package. Typically this involves a separate file and a corresponding 248 package. Typically this involves a separate file and a corresponding
275 compile property in the platform HAL's CDL: 249 compile property in the platform HAL's CDL:
276 </para> 250 </para>
277 <programlisting width=72> 251 <programlisting width=72>
278 cdl_package CYGPKG_HAL_M68K_ALAIA { 252 cdl_package CYGPKG_HAL_M68K_ALAIA {
293 <programlisting> 267 <programlisting>
294 #include &lt;pkgconf/system.h&gt; 268 #include &lt;pkgconf/system.h&gt;
295 #ifdef CYGPKG_DEVS_FLASH_AMD_AM29XXXXX_V2 269 #ifdef CYGPKG_DEVS_FLASH_AMD_AM29XXXXX_V2
296 270
297 #include &lt;cyg/io/flash.h&gt; 271 #include &lt;cyg/io/flash.h&gt;
298 #include &lt;cyg/io/flash_priv.h&gt; 272 #include &lt;cyg/io/flash_dev.h&gt;
299 #include &lt;cyg/io/am29xxxxx_dev.h&gt; 273 #include &lt;cyg/io/am29xxxxx_dev.h&gt;
300 274
301 static const CYG_FLASH_FUNS(hal_alaia_flash_amd_funs, 275 static const CYG_FLASH_FUNS(hal_alaia_flash_amd_funs,
302 &amp;cyg_am29xxxxx_init_check_devid_16, 276 &amp;cyg_am29xxxxx_init_check_devid_16,
303 &amp;cyg_am29xxxxx_query_nop, 277 &amp;cyg_flash_devfn_query_nop,
304 &amp;cyg_am29xxxxx_erase_16, 278 &amp;cyg_am29xxxxx_erase_16,
305 &amp;cyg_am29xxxxx_program_16, 279 &amp;cyg_am29xxxxx_program_16,
306 (int (*)(struct cyg_flash_dev*, const cyg_flashaddr_t, void*, size_t))0, 280 (int (*)(struct cyg_flash_dev*, const cyg_flashaddr_t, void*, size_t))0,
307 &amp;cyg_am29xxxxx_hwr_map_error_nop, 281 &amp;cyg_flash_devfn_lock_nop,
308 &amp;cyg_am29xxxxx_lock_nop, 282 &amp;cyg_flash_devfn_unlock_nop);
309 &amp;cyg_am29xxxxx_unlock_nop);
310 283
311 static const cyg_am29xxxxx_dev hal_alaia_flash_priv = { 284 static const cyg_am29xxxxx_dev hal_alaia_flash_priv = {
312 .devid = 0x45, 285 .devid = 0x45,
313 .block_info = { 286 .block_info = {
314 { 0x00004000, 1 }, 287 { 0x00004000, 1 },
319 }; 292 };
320 293
321 CYG_FLASH_DRIVER(hal_alaia_flash, 294 CYG_FLASH_DRIVER(hal_alaia_flash,
322 &amp;hal_alaia_flash_amd_funs, 295 &amp;hal_alaia_flash_amd_funs,
323 0, 296 0,
324 0xFFE00000, 297 0xFFC00000,
325 0xFFFFFFFF, 298 0xFFFFFFFF,
326 4, 299 4,
327 hal_alaia_flash_priv.block_info, 300 hal_alaia_flash_priv.block_info,
328 &amp;hal_alaia_flash_priv 301 &amp;hal_alaia_flash_priv
329 ); 302 );
330 #endif 303 #endif
331 </programlisting> 304 </programlisting>
332 <para> 305 <para>
333 The bulk of the file is protected by an ifdef for the AM29xxxxx flash 306 The bulk of the file is protected by an <literal>#ifdef</literal> for
334 driver. That driver will only be active if the generic flash support 307 the AM29xxxxx flash driver. That driver will only be active if the
335 is enabled. Without that support there will be no way of accessing 308 generic flash support is enabled. Without that support there will be
336 the device so there is no point in instantiating the device. The rest 309 no way of accessing the device so instantiating the data structures
337 of the file is split into three definitions. The first supplies the 310 would serve no purpose. The rest of the file is split into three
338 functions which will be used to perform the actual flash accesses, 311 structure definitions. The first supplies the functions which will be
339 using a macro provided by the generic flash code in <filename 312 used to perform the actual flash accesses, using a macro provided by
340 class="headerfile">cyg/io/flash_priv.h</filename>. The 313 the generic flash code in <filename
341 relevant ones have an <literal>_16</literal> suffix, indicating that 314 class="headerfile">cyg/io/flash_dev.h</filename>. The relevant ones
342 on this board there is a single 16-bit flash device on a 16-bit 315 have an <literal>_16</literal> suffix, indicating that on this board
343 bus. The second definition provides information specific to AM29xxxxx 316 there is a single 16-bit flash device on a 16-bit bus. The second
344 flash devices. The third provides the 317 provides information specific to AM29xxxxx flash devices.
345 <structname>cyg_flash_dev</structname> structure needed by the generic 318 The third provides the <structname>cyg_flash_dev</structname>
346 flash code, which contains pointers to the previous two. 319 structure needed by the generic flash code, which contains pointers to
320 the previous two.
347 </para> 321 </para>
348 </refsect1> 322 </refsect1>
349 323
350 <refsect1 id="am29xxxxx-instance-functions"><title>Functions</title> 324 <refsect1 id="am29xxxxx-instance-functions"><title>Functions</title>
351 <para> 325 <para>
352 All eCos flash device drivers must implement a standard interface, 326 All eCos flash device drivers must implement a standard interface,
353 defined by the generic flash code <varname>CYGPKG_IO_FLASH</varname>. 327 defined by the generic flash code <varname>CYGPKG_IO_FLASH</varname>.
354 This interface includes a table of 8 function pointers for various 328 This interface includes a table of seven function pointers for various
355 operations: initialization, query, erase, program, read, error code 329 operations: initialization, query, erase, program, read, locking and
356 handling, locking and unlocking. The query operation is optional and 330 unlocking. The query operation is optional and the generic flash
357 the AM29xxxxx driver only provides a dummy implementation 331 support provides a dummy implementation
358 <function>cyg_am29xxxxx_query_nop</function>. AM29xxxxx flash devices 332 <function>cyg_flash_devfn_query_nop</function>. AM29xxxxx flash
359 are always directly accessible so there is no need for a separate read 333 devices are always directly accessible so there is no need for a
360 function. Standard flash error codes are used so only a dummy 334 separate read function. The remaining functions are more complicated.
361 <function>cyg_am29xxxxx_hwr_map_error_nop</function> function is
362 needed. The remaining functions are more complicated.
363 </para> 335 </para>
364 <para> 336 <para>
365 Usually the table can be declared <literal>const</literal>. In a ROM 337 Usually the table can be declared <literal>const</literal>. In a ROM
366 startup application this avoids both ROM and RAM copies of the table, 338 startup application this avoids both ROM and RAM copies of the table,
367 saving a small amount of memory. <literal>const</literal> should not 339 saving a small amount of memory. <literal>const</literal> should not
370 </para> 342 </para>
371 343
372 <refsect2 id="am29xxxxx-instance-functions-init"><title>Initialization</title> 344 <refsect2 id="am29xxxxx-instance-functions-init"><title>Initialization</title>
373 <para> 345 <para>
374 There is a choice of three main initialization functions. The simplest 346 There is a choice of three main initialization functions. The simplest
375 is <function>cyg_am29xxxxx_init_nop</function>, which does nothing. It 347 is <function>cyg_flash_devfn_init_nop</function>, which does nothing.
376 can be used if the <structname>cyg_am29xxxxx_dev</structname> and 348 It can be used if the <structname>cyg_am29xxxxx_dev</structname> and
377 <structname>cyg_flash_dev</structname> structures are fully 349 <structname>cyg_flash_dev</structname> structures are fully
378 initialized statically and the flash will just work without special 350 initialized statically and the flash will just work without special
379 effort. This is useful if it is guaranteed that the board will always 351 effort. This is useful if it is guaranteed that the board will always
380 be manufactured using the same flash chip, since the nop function 352 be manufactured using the same flash chip, since the nop function
381 involves the smallest code size and run-time overheads. 353 involves the smallest code size and run-time overheads.
382 </para> 354 </para>
383 <para> 355 <para>
384 The next step up is 356 The next step up is
385 <function>cyg_am29xxxxx_init_check_devid_XX</function>, where 357 <function>cyg_am29xxxxx_init_check_devid_XX</function>, where
386 <literal>XX</literal> will be replaced by the suffix appropriate for the 358 <literal>XX</literal> will be replaced by the suffix appropriate for
387 bus configuration. It is still necessary to provide all the device 359 the bus configuration. It is still necessary to provide all the device
388 information statically, including the <structfield>devid</structfield> 360 information statically, including the <structfield>devid</structfield>
389 field in the <structname>cyg_am29xxxxx_dev</structname> structure. 361 field in the <structname>cyg_am29xxxxx_dev</structname> structure.
390 However this initialization function will attempt to query the flash 362 This initialization function will attempt to query the flash device
391 device and check that the provided device id matches the actual 363 and check that the provided device id matches the actual hardware. If
392 hardware. If there is a mismatch the device will be marked 364 there is a mismatch the device will be marked uninitialized and
393 uninitialized and subsequent attempts to manipulate the flash will 365 subsequent attempts to manipulate the flash will fail.
394 fail.
395 </para> 366 </para>
396 <para> 367 <para>
397 If the board may end up being manufactured with any of a number of 368 If the board may end up being manufactured with any of a number of
398 different flash chips then the driver can perform run-time 369 different flash chips then the driver can perform run-time
399 initialization, using a <function>cyg_am29xxxxx_init_cfi_XX</function> 370 initialization, using a <function>cyg_am29xxxxx_init_cfi_XX</function>
406 <structfield>num_block_infos</structfield> fields in the 377 <structfield>num_block_infos</structfield> fields in the
407 <structname>cyg_flash_dev</structname> structure will be filled in. 378 <structname>cyg_flash_dev</structname> structure will be filled in.
408 It is still necessary to supply the <structfield>start</structfield> 379 It is still necessary to supply the <structfield>start</structfield>
409 field statically since otherwise the driver will not know how to 380 field statically since otherwise the driver will not know how to
410 access the flash device. The main disadvantage of using CFI is that it 381 access the flash device. The main disadvantage of using CFI is that it
411 will increase the code size. 382 increases the code size.
412 </para> 383 </para>
384 <caution><para>
385 If CFI is used then the <structname>cyg_am29xxxxx_dev</structname>
386 structure must not be declared <literal>const</literal>. The CFI code
387 will attempt to update the structure and will fail if the structure is
388 held in read-only memory. This would leave the flash driver
389 non-functional.
390 </para></caution>
413 <para> 391 <para>
414 A final option is to use a platform-specific initialization function. 392 A final option is to use a platform-specific initialization function.
415 This may be useful if the board may be manufactured with one of a 393 This may be useful if the board may be manufactured with one of a
416 small number of different flash devices and the platform HAL needs to 394 small number of different flash devices and the platform HAL needs to
417 adapt to this. The AM29xxxxx driver provides a utility function to 395 adapt to this. The AM29xxxxx driver provides a utility function to
434 </programlisting> 412 </programlisting>
435 <para> 413 <para>
436 There are many other possible uses for a platform-specific 414 There are many other possible uses for a platform-specific
437 initialization function. For example initial prototype boards might 415 initialization function. For example initial prototype boards might
438 have only supported 8-bit access to a 16-bit flash device rather than 416 have only supported 8-bit access to a 16-bit flash device rather than
439 16-bit access, but this was fixed in the next revision. The 417 16-bit access, but this problem was fixed in the next revision. The
440 platform-specific initialization function could figure out which model 418 platform-specific initialization function can figure out which model
441 board it is running on and replace the default 419 board it is running on and replace the default
442 <literal>16as8</literal> functions with <literal>16</literal> ones. 420 <literal>16as8</literal> functions with faster <literal>16</literal>
421 ones.
443 </para> 422 </para>
444 </refsect2> 423 </refsect2>
445 424
446 <refsect2 id="am29xxxxx-instance-functions-erase-program"><title>Erase and Program</title> 425 <refsect2 id="am29xxxxx-instance-functions-erase-program"><title>Erase and Program</title>
447 <para> 426 <para>
450 directly. On some targets it may be necessary to do some extra work 429 directly. On some targets it may be necessary to do some extra work
451 before and after the erase and program operations. For example if the 430 before and after the erase and program operations. For example if the
452 hardware has an MMU then the part of the address map containing the 431 hardware has an MMU then the part of the address map containing the
453 flash may have been set to read-only, in an attempt to catch spurious 432 flash may have been set to read-only, in an attempt to catch spurious
454 memory accesses. Erasing or programming the flash requires 433 memory accesses. Erasing or programming the flash requires
455 write-access, so the MMU settings have to be changed temporarily. For 434 write-access, so the MMU settings have to be changed temporarily. As
456 another example some flash device may require a higher voltage to be 435 another example some flash device may require a higher voltage to be
457 applied during an erase or program operation. or a higher voltage may 436 applied during an erase or program operation. or a higher voltage may
458 be desirable to make the operation proceed faster. A typical 437 be desirable to make the operation proceed faster. A typical
459 platform-specific erase function would look like this: 438 platform-specific erase function would look like this:
460 </para> 439 </para>
476 and 455 and
477 <varname>CYGNUM_DEVS_FLASH_AMD_AM29XXXXX_V2_PROGRAM_TIMEOUT</varname>. 456 <varname>CYGNUM_DEVS_FLASH_AMD_AM29XXXXX_V2_PROGRAM_TIMEOUT</varname>.
478 The erase and program operations both involve polling for completion, 457 The erase and program operations both involve polling for completion,
479 and these timeout impose an upper bound on the polling loop. Normally 458 and these timeout impose an upper bound on the polling loop. Normally
480 these operations should never take anywhere close to the timeout 459 these operations should never take anywhere close to the timeout
481 period, and hence a timeout probably indicates a catastrophic failure 460 period, so a timeout indicates a catastrophic failure that should
482 that should really be handled by a watchdog reset. A reset is 461 really be handled by a watchdog reset. A reset is particularly
483 particularly appropriate because there will be no clean way of 462 appropriate because there will be no clean way of aborting the flash
484 aborting the flash operation. The main reason for the timeouts is 463 operation. The main reason for the timeouts is to help with debugging
485 to help with debugging when porting to new hardware. If there is a 464 when porting to new hardware. If there is a valid reason why a
486 valid reason why a particular platform needs different timeouts then 465 particular platform needs different timeouts then the platform HAL's
487 the platform HAL's CDL can require appropriate values for these 466 CDL can require appropriate values for these options.
488 options.
489 </para> 467 </para>
490 </refsect2> 468 </refsect2>
491 469
492 <refsect2 id="am29xxxxx-instance-functions-locking"><title>Locking</title> 470 <refsect2 id="am29xxxxx-instance-functions-locking"><title>Locking</title>
493 <para> 471 <para>
494 There is no single way of implementing the block lock and unlock 472 There is no single way of implementing the block lock and unlock
495 operations on AM29xxxxx devices. If these operations are supported at 473 operations on all AM29xxxxx devices. If these operations are supported
496 all then usually they involve manipulating the voltages on certain 474 at all then usually they involve manipulating the voltages on certain
497 pins. This cannot be handled by generic driver code since it requires 475 pins. This cannot be handled by generic driver code since it requires
498 knowing exactly how these pins can be manipulated via the processor's 476 knowing how these voltages can be manipulated via the processor's GPIO
499 GPIO pins. Therefore the AM29xxxxx driver does not provide functional 477 lines. Therefore the AM29xxxxx driver does not provide lock and unlock
500 lock and unlock functions, only dummy functions 478 functions, and instead the generic dummy functions
501 <function>cyg_am29xxxxx_lock_nop</function> and 479 <function>cyg_flash_devfn_lock_nop</function> and
502 <function>cyg_am29xxxxx_unlock_nop</function>. If there is a way of 480 <function>cyg_flash_devfn_unlock_nop</function> should be used. If a
503 implementing the locking then this can be handled by platform-specific 481 platform does provide a way of implementing the locking then this can
504 functions. 482 be handled by platform-specific functions.
505 </para> 483 </para>
506 <programlisting width=72> 484 <programlisting width=72>
507 static int 485 static int
508 alaia_lock(struct cyg_flash_dev* dev, const cyg_flashaddr_t addr) 486 alaia_lock(struct cyg_flash_dev* dev, const cyg_flashaddr_t addr)
509 { 487 {
567 each block. The table can be initialized in one of three ways: 545 each block. The table can be initialized in one of three ways:
568 </para> 546 </para>
569 <orderedlist> 547 <orderedlist>
570 <listitem><para> 548 <listitem><para>
571 If the driver initialization function is set to 549 If the driver initialization function is set to
572 <function>cyg_am29xxxxx_init_nop</function> or 550 <function>cyg_flash_devfn_init_nop</function> or
573 <function>cyg_am29xxxxx_init_check_devid_XX</function> then the block 551 <function>cyg_am29xxxxx_init_check_devid_XX</function> then the block
574 information should be provided statically. This is appropriate if the 552 information should be provided statically. This is appropriate if the
575 board will also be manufactured using the same flash chip. 553 board will also be manufactured using the same flash chip.
576 </para></listitem> 554 </para></listitem>
577 <listitem><para> 555 <listitem><para>
595 </para> 573 </para>
596 <para> 574 <para>
597 If the <structname>cyg_am29xxxxx_dev</structname> structure is 575 If the <structname>cyg_am29xxxxx_dev</structname> structure is
598 statically initialized then it can be <literal>const</literal>. This 576 statically initialized then it can be <literal>const</literal>. This
599 saves a small amount of memory in ROM startup applications. If the 577 saves a small amount of memory in ROM startup applications. If the
600 structure may be updated at run-time, either by 578 structure is updated at run-time, either by
601 <function>cyg_am29xxxxx_init_cfi_XX</function> or by a 579 <function>cyg_am29xxxxx_init_cfi_XX</function> or by a
602 platform-specific initialization routine, then it cannot be 580 platform-specific initialization routine, then it cannot be
603 <literal>const</literal>. 581 <literal>const</literal>.
604 </para> 582 </para>
605 </refsect1> 583 </refsect1>
606 584
607 <refsect1 id="am29xxxxx-instance-flash"><title>Flash Structure</title> 585 <refsect1 id="am29xxxxx-instance-flash"><title>Flash Structure</title>
608 <para> 586 <para>
609 Internally the flash code works in terms of 587 Internally the generic flash code works in terms of
610 <structname>cyg_flash_dev</structname> structures, and the platform 588 <structname>cyg_flash_dev</structname> structures, and the platform
611 HAL should define one of these. The structure should be placed in the 589 HAL should define one of these. The structure should be placed in the
612 <literal>cyg_flashdev</literal> table. The following fields need to be 590 <literal>cyg_flashdev</literal> table. The following fields need to be
613 provided: 591 provided:
614 </para> 592 </para>