cmd: add missing usage vars
[fw/openocd] / src / flash / nand / at91sam9.c
1 /*
2  * Copyright (C) 2009 by Dean Glazeski
3  * dnglaze@gmail.com
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  */
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <target/arm.h>
25 #include <helper/log.h>
26 #include "imp.h"
27 #include "arm_io.h"
28
29 #define AT91C_PIOx_SODR (0x30) /**< Offset to PIO SODR. */
30 #define AT91C_PIOx_CODR (0x34) /**< Offset to PIO CODR. */
31 #define AT91C_PIOx_PDSR (0x3C) /**< Offset to PIO PDSR. */
32 #define AT91C_ECCx_CR (0x00) /**< Offset to ECC CR. */
33 #define AT91C_ECCx_SR (0x08) /**< Offset to ECC SR. */
34 #define AT91C_ECCx_PR (0x0C) /**< Offset to ECC PR. */
35 #define AT91C_ECCx_NPR (0x10) /**< Offset to ECC NPR. */
36
37 /**
38  * Representation of a pin on an AT91SAM9 chip.
39  */
40 struct at91sam9_pin {
41         /** Address of the PIO controller. */
42         uint32_t pioc;
43
44         /** Pin number. */
45         uint32_t num;
46 };
47
48 /**
49  * Private data for the controller that is stored in the NAND device structure.
50  */
51 struct at91sam9_nand {
52         /** Address of the ECC controller for NAND. */
53         uint32_t ecc;
54
55         /** Address data is written to. */
56         uint32_t data;
57
58         /** Address commands are written to. */
59         uint32_t cmd;
60
61         /** Address addresses are written to. */
62         uint32_t addr;
63
64         /** I/O structure for hosted reads/writes. */
65         struct arm_nand_data io;
66
67         /** Pin representing the ready/~busy line. */
68         struct at91sam9_pin busy;
69
70         /** Pin representing the chip enable. */
71         struct at91sam9_pin ce;
72 };
73
74 /**
75  * Checks if the target is halted and prints an error message if it isn't.
76  *
77  * @param target Target to be checked.
78  * @param label String label for where function is called from.
79  * @return True if the target is halted.
80  */
81 static int at91sam9_halted(struct target *target, const char *label)
82 {
83         if (target->state == TARGET_HALTED)
84                 return true;
85
86         LOG_ERROR("Target must be halted to use NAND controller (%s)", label);
87         return false;
88 }
89
90 /**
91  * Initialize the AT91SAM9 NAND controller.
92  *
93  * @param nand NAND device the controller is attached to.
94  * @return Success or failure of initialization.
95  */
96 static int at91sam9_init(struct nand_device *nand)
97 {
98         struct target *target = nand->target;
99
100         if (!at91sam9_halted(target, "init")) {
101                 return ERROR_NAND_OPERATION_FAILED;
102         }
103
104         return ERROR_OK;
105 }
106
107 /**
108  * Enable NAND device attached to a controller.
109  *
110  * @param info NAND controller information for controlling NAND device.
111  * @return Success or failure of the enabling.
112  */
113 static int at91sam9_enable(struct nand_device *nand)
114 {
115         struct at91sam9_nand *info = nand->controller_priv;
116         struct target *target = nand->target;
117
118         return target_write_u32(target, info->ce.pioc + AT91C_PIOx_CODR, 1 << info->ce.num);
119 }
120
121 /**
122  * Disable NAND device attached to a controller.
123  *
124  * @param info NAND controller information for controlling NAND device.
125  * @return Success or failure of the disabling.
126  */
127 static int at91sam9_disable(struct nand_device *nand)
128 {
129         struct at91sam9_nand *info = nand->controller_priv;
130         struct target *target = nand->target;
131
132         return target_write_u32(target, info->ce.pioc + AT91C_PIOx_SODR, 1 << info->ce.num);
133 }
134
135 /**
136  * Send a command to the NAND device.
137  *
138  * @param nand NAND device to write the command to.
139  * @param command Command to be written.
140  * @return Success or failure of writing the command.
141  */
142 static int at91sam9_command(struct nand_device *nand, uint8_t command)
143 {
144         struct at91sam9_nand *info = nand->controller_priv;
145         struct target *target = nand->target;
146
147         if (!at91sam9_halted(target, "command")) {
148                 return ERROR_NAND_OPERATION_FAILED;
149         }
150
151         at91sam9_enable(nand);
152
153         return target_write_u8(target, info->cmd, command);
154 }
155
156 /**
157  * Reset the AT91SAM9 NAND controller.
158  *
159  * @param nand NAND device to be reset.
160  * @return Success or failure of reset.
161  */
162 static int at91sam9_reset(struct nand_device *nand)
163 {
164         if (!at91sam9_halted(nand->target, "reset")) {
165                 return ERROR_NAND_OPERATION_FAILED;
166         }
167
168         return at91sam9_disable(nand);
169 }
170
171 /**
172  * Send an address to the NAND device attached to an AT91SAM9 NAND controller.
173  *
174  * @param nand NAND device to send the address to.
175  * @param address Address to be sent.
176  * @return Success or failure of sending the address.
177  */
178 static int at91sam9_address(struct nand_device *nand, uint8_t address)
179 {
180         struct at91sam9_nand *info = nand->controller_priv;
181         struct target *target = nand->target;
182
183         if (!at91sam9_halted(nand->target, "address")) {
184                 return ERROR_NAND_OPERATION_FAILED;
185         }
186
187         return target_write_u8(target, info->addr, address);
188 }
189
190 /**
191  * Read data directly from the NAND device attached to an AT91SAM9 NAND
192  * controller.
193  *
194  * @param nand NAND device to read from.
195  * @param data Pointer to where the data should be put.
196  * @return Success or failure of reading the data.
197  */
198 static int at91sam9_read_data(struct nand_device *nand, void *data)
199 {
200         struct at91sam9_nand *info = nand->controller_priv;
201         struct target *target = nand->target;
202
203         if (!at91sam9_halted(nand->target, "read data")) {
204                 return ERROR_NAND_OPERATION_FAILED;
205         }
206
207         return target_read_u8(target, info->data, data);
208 }
209
210 /**
211  * Write data directly to the NAND device attached to an AT91SAM9 NAND
212  * controller.
213  *
214  * @param nand NAND device to be written to.
215  * @param data Data to be written.
216  * @return Success or failure of the data write.
217  */
218 static int at91sam9_write_data(struct nand_device *nand, uint16_t data)
219 {
220         struct at91sam9_nand *info = nand->controller_priv;
221         struct target *target = nand->target;
222
223         if (!at91sam9_halted(target, "write data")) {
224                 return ERROR_NAND_OPERATION_FAILED;
225         }
226
227         return target_write_u8(target, info->data, data);
228 }
229
230 /**
231  * Determine if the NAND device is ready by looking at the ready/~busy pin.
232  *
233  * @param nand NAND device to check.
234  * @param timeout Time in milliseconds to wait for NAND to be ready.
235  * @return True if the NAND is ready in the timeout period.
236  */
237 static int at91sam9_nand_ready(struct nand_device *nand, int timeout)
238 {
239         struct at91sam9_nand *info = nand->controller_priv;
240         struct target *target = nand->target;
241         uint32_t status;
242
243         if (!at91sam9_halted(target, "nand ready")) {
244                 return 0;
245         }
246
247         do {
248                 target_read_u32(target, info->busy.pioc + AT91C_PIOx_PDSR, &status);
249
250                 if (status & (1 << info->busy.num)) {
251                         return 1;
252                 }
253
254                 alive_sleep(1);
255         } while (timeout-- > 0);
256
257         return 0;
258 }
259
260 /**
261  * Read a block of data from the NAND device attached to an AT91SAM9.  This
262  * utilizes the ARM hosted NAND read function.
263  *
264  * @param nand NAND device to read from.
265  * @param data Pointer to where the read data should be placed.
266  * @param size Size of the data being read.
267  * @return Success or failure of the hosted read.
268  */
269 static int at91sam9_read_block_data(struct nand_device *nand, uint8_t *data, int size)
270 {
271         struct at91sam9_nand *info = nand->controller_priv;
272         struct arm_nand_data *io = &info->io;
273         int status;
274
275         if (!at91sam9_halted(nand->target, "read block")) {
276                 return ERROR_NAND_OPERATION_FAILED;
277         }
278
279         io->chunk_size = nand->page_size;
280         status = arm_nandread(io, data, size);
281
282         return status;
283 }
284
285 /**
286  * Write a block of data to a NAND device attached to an AT91SAM9.  This uses
287  * the ARM hosted write function to write the data.
288  *
289  * @param nand NAND device to write to.
290  * @param data Data to be written to device.
291  * @param size Size of the data being written.
292  * @return Success or failure of the hosted write.
293  */
294 static int at91sam9_write_block_data(struct nand_device *nand, uint8_t *data, int size)
295 {
296         struct at91sam9_nand *info = nand->controller_priv;
297         struct arm_nand_data *io = &info->io;
298         int status;
299
300         if (!at91sam9_halted(nand->target, "write block")) {
301                 return ERROR_NAND_OPERATION_FAILED;
302         }
303
304         io->chunk_size = nand->page_size;
305         status = arm_nandwrite(io, data, size);
306
307         return status;
308 }
309
310 /**
311  * Initialize the ECC controller on the AT91SAM9.
312  *
313  * @param target Target to configure ECC on.
314  * @param info NAND controller information for where the ECC is.
315  * @return Success or failure of initialization.
316  */
317 static int at91sam9_ecc_init(struct target *target, struct at91sam9_nand *info)
318 {
319         if (!info->ecc) {
320                 LOG_ERROR("ECC controller address must be set when not reading raw NAND data");
321                 return ERROR_NAND_OPERATION_FAILED;
322         }
323
324         // reset ECC parity registers
325         return target_write_u32(target, info->ecc + AT91C_ECCx_CR, 1);
326 }
327
328 /**
329  * Initialize an area for the OOB based on whether a user is requesting the OOB
330  * data.  This determines the size of the OOB and allocates the space in case
331  * the user has not requested the OOB data.
332  *
333  * @param nand NAND device we are creating an OOB for.
334  * @param oob Pointer to the user supplied OOB area.
335  * @param size Size of the OOB.
336  * @return Pointer to an area to store OOB data.
337  */
338 static uint8_t * at91sam9_oob_init(struct nand_device *nand, uint8_t *oob, uint32_t *size)
339 {
340         if (!oob) {
341                 // user doesn't want OOB, allocate it
342                 if (nand->page_size == 512) {
343                         *size = 16;
344                 } else if (nand->page_size == 2048) {
345                         *size = 64;
346                 }
347
348                 oob = malloc(*size);
349                 if (!oob) {
350                         LOG_ERROR("Unable to allocate space for OOB");
351                         return NULL;
352                 }
353
354                 memset(oob, 0xFF, *size);
355         }
356
357         return oob;
358 }
359
360 /**
361  * Reads a page from an AT91SAM9 NAND controller and verifies using 1-bit ECC
362  * controller on chip.  This makes an attempt to correct any errors that are
363  * encountered while reading the page of data.
364  *
365  * @param nand NAND device to read from
366  * @param page Page to be read.
367  * @param data Pointer to where data should be read to.
368  * @param data_size Size of the data to be read.
369  * @param oob Pointer to where OOB data should be read to.
370  * @param oob_size Size of the OOB data to be read.
371  * @return Success or failure of reading the NAND page.
372  */
373 static int at91sam9_read_page(struct nand_device *nand, uint32_t page,
374                 uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
375 {
376         int retval;
377         struct at91sam9_nand *info = nand->controller_priv;
378         struct target *target = nand->target;
379         uint8_t *oob_data;
380         uint32_t status;
381
382         retval = at91sam9_ecc_init(target, info);
383         if (ERROR_OK != retval) {
384                 return retval;
385         }
386
387         retval = nand_page_command(nand, page, NAND_CMD_READ0, !data);
388         if (ERROR_OK != retval) {
389                 return retval;
390         }
391
392         if (data) {
393                 retval = nand_read_data_page(nand, data, data_size);
394                 if (ERROR_OK != retval) {
395                         return retval;
396                 }
397         }
398
399         oob_data = at91sam9_oob_init(nand, oob, &oob_size);
400         retval = nand_read_data_page(nand, oob_data, oob_size);
401         if (ERROR_OK == retval && data) {
402                 target_read_u32(target, info->ecc + AT91C_ECCx_SR, &status);
403                 if (status & 1) {
404                         LOG_ERROR("Error detected!");
405                         if (status & 4) {
406                                 LOG_ERROR("Multiple errors encountered; unrecoverable!");
407                         } else {
408                                 // attempt recovery
409                                 uint32_t parity;
410
411                                 target_read_u32(target,
412                                                 info->ecc + AT91C_ECCx_PR,
413                                                 &parity);
414                                 uint32_t word = (parity & 0x0000FFF0) >> 4;
415                                 uint32_t bit = parity & 0x0F;
416
417                                 data[word] ^= (0x1) << bit;
418                                 LOG_INFO("Data word %d, bit %d corrected.",
419                                                 (unsigned) word,
420                                                 (unsigned) bit);
421                         }
422                 }
423
424                 if (status & 2) {
425                         // we could write back correct ECC data
426                         LOG_ERROR("Error in ECC bytes detected");
427                 }
428         }
429
430         if (!oob) {
431                 // if it wasn't asked for, free it
432                 free(oob_data);
433         }
434
435         return retval;
436 }
437
438 /**
439  * Write a page of data including 1-bit ECC information to a NAND device
440  * attached to an AT91SAM9 controller.  If there is OOB data to be written,
441  * this will ignore the computed ECC from the ECC controller.
442  *
443  * @param nand NAND device to write to.
444  * @param page Page to write.
445  * @param data Pointer to data being written.
446  * @param data_size Size of the data being written.
447  * @param oob Pointer to OOB data being written.
448  * @param oob_size Size of the OOB data.
449  * @return Success or failure of the page write.
450  */
451 static int at91sam9_write_page(struct nand_device *nand, uint32_t page,
452                 uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
453 {
454         struct at91sam9_nand *info = nand->controller_priv;
455         struct target *target = nand->target;
456         int retval;
457         uint8_t *oob_data = oob;
458         uint32_t parity, nparity;
459
460         retval = at91sam9_ecc_init(target, info);
461         if (ERROR_OK != retval) {
462                 return retval;
463         }
464
465         retval = nand_page_command(nand, page, NAND_CMD_SEQIN, !data);
466         if (ERROR_OK != retval) {
467                 return retval;
468         }
469
470         if (data) {
471                 retval = nand_write_data_page(nand, data, data_size);
472                 if (ERROR_OK != retval) {
473                         LOG_ERROR("Unable to write data to NAND device");
474                         return retval;
475                 }
476         }
477
478         oob_data = at91sam9_oob_init(nand, oob, &oob_size);
479
480         if (!oob) {
481                 // no OOB given, so read in the ECC parity from the ECC controller
482                 target_read_u32(target, info->ecc + AT91C_ECCx_PR, &parity);
483                 target_read_u32(target, info->ecc + AT91C_ECCx_NPR, &nparity);
484
485                 oob_data[0] = (uint8_t) parity;
486                 oob_data[1] = (uint8_t) (parity >> 8);
487                 oob_data[2] = (uint8_t) nparity;
488                 oob_data[3] = (uint8_t) (nparity >> 8);
489         }
490
491         retval = nand_write_data_page(nand, oob_data, oob_size);
492
493         if (!oob) {
494                 free(oob_data);
495         }
496
497         if (ERROR_OK != retval) {
498                 LOG_ERROR("Unable to write OOB data to NAND");
499                 return retval;
500         }
501
502         retval = nand_write_finish(nand);
503
504         return retval;
505 }
506
507 /**
508  * Handle the initial NAND device command for AT91SAM9 controllers.  This
509  * initializes much of the controller information struct to be ready for future
510  * reads and writes.
511  */
512 NAND_DEVICE_COMMAND_HANDLER(at91sam9_nand_device_command)
513 {
514         unsigned long chip = 0, ecc = 0;
515         struct at91sam9_nand *info = NULL;
516
517         LOG_DEBUG("AT91SAM9 NAND Device Command");
518
519         if (CMD_ARGC < 3 || CMD_ARGC > 4) {
520                 LOG_ERROR("parameters: %s target chip_addr", CMD_ARGV[0]);
521                 return ERROR_NAND_OPERATION_FAILED;
522         }
523
524         COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip);
525         if (chip == 0) {
526                 LOG_ERROR("invalid NAND chip address: %s", CMD_ARGV[2]);
527                 return ERROR_NAND_OPERATION_FAILED;
528         }
529
530         if (CMD_ARGC == 4) {
531                 COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[3], ecc);
532                 if (ecc == 0) {
533                         LOG_ERROR("invalid ECC controller address: %s", CMD_ARGV[3]);
534                         return ERROR_NAND_OPERATION_FAILED;
535                 }
536         }
537
538         info = calloc(1, sizeof(*info));
539         if (!info) {
540                 LOG_ERROR("unable to allocate space for controller private data");
541                 return ERROR_NAND_OPERATION_FAILED;
542         }
543
544         info->data = chip;
545         info->cmd = chip | (1 << 22);
546         info->addr = chip | (1 << 21);
547         info->ecc = ecc;
548
549         nand->controller_priv = info;
550         info->io.target = nand->target;
551         info->io.data = info->data;
552         info->io.op = ARM_NAND_NONE;
553
554         return ERROR_OK;
555 }
556
557 /**
558  * Handle the AT91SAM9 CLE command for specifying the address line to use for
559  * writing commands to a NAND device.
560  */
561 COMMAND_HANDLER(handle_at91sam9_cle_command)
562 {
563         struct nand_device *nand = NULL;
564         struct at91sam9_nand *info = NULL;
565         unsigned num, address_line;
566
567         if (CMD_ARGC != 2) {
568                 command_print(CMD_CTX, "incorrect number of arguments for 'at91sam9 cle' command");
569                 return ERROR_OK;
570         }
571
572         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
573         nand = get_nand_device_by_num(num);
574         if (!nand) {
575                 command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
576                 return ERROR_OK;
577         }
578
579         info = nand->controller_priv;
580
581         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], address_line);
582         info->cmd = info->data | (1 << address_line);
583
584         return ERROR_OK;
585 }
586
587 /**
588  * Handle the AT91SAM9 ALE command for specifying the address line to use for
589  * writing addresses to the NAND device.
590  */
591 COMMAND_HANDLER(handle_at91sam9_ale_command)
592 {
593         struct nand_device *nand = NULL;
594         struct at91sam9_nand *info = NULL;
595         unsigned num, address_line;
596
597         if (CMD_ARGC != 2) {
598                 return ERROR_COMMAND_SYNTAX_ERROR;
599         }
600
601         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
602         nand = get_nand_device_by_num(num);
603         if (!nand) {
604                 command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
605                 return ERROR_COMMAND_ARGUMENT_INVALID;
606         }
607
608         info = nand->controller_priv;
609
610         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], address_line);
611         info->addr = info->data | (1 << address_line);
612
613         return ERROR_OK;
614 }
615
616 /**
617  * Handle the AT91SAM9 RDY/~BUSY command for specifying the pin that watches the
618  * RDY/~BUSY line from the NAND device.
619  */
620 COMMAND_HANDLER(handle_at91sam9_rdy_busy_command)
621 {
622         struct nand_device *nand = NULL;
623         struct at91sam9_nand *info = NULL;
624         unsigned num, base_pioc, pin_num;
625
626         if (CMD_ARGC != 3) {
627                 return ERROR_COMMAND_SYNTAX_ERROR;
628         }
629
630         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
631         nand = get_nand_device_by_num(num);
632         if (!nand) {
633                 command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
634                 return ERROR_COMMAND_ARGUMENT_INVALID;
635         }
636
637         info = nand->controller_priv;
638
639         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], base_pioc);
640         info->busy.pioc = base_pioc;
641
642         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], pin_num);
643         info->busy.num = pin_num;
644
645         return ERROR_OK;
646 }
647
648 /**
649  * Handle the AT91SAM9 CE command for specifying the pin that is used to enable
650  * or disable the NAND device.
651  */
652 COMMAND_HANDLER(handle_at91sam9_ce_command)
653 {
654         struct nand_device *nand = NULL;
655         struct at91sam9_nand *info = NULL;
656         unsigned num, base_pioc, pin_num;
657
658         if (CMD_ARGC != 3) {
659                 return ERROR_COMMAND_SYNTAX_ERROR;
660         }
661
662         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
663         nand = get_nand_device_by_num(num);
664         if (!nand) {
665                 command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
666                 return ERROR_COMMAND_ARGUMENT_INVALID;
667         }
668
669         info = nand->controller_priv;
670
671         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], base_pioc);
672         info->ce.pioc = base_pioc;
673
674         COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], pin_num);
675         info->ce.num = pin_num;
676
677         return ERROR_OK;
678 }
679
680 static const struct command_registration at91sam9_sub_command_handlers[] = {
681         {
682                 .name = "cle",
683                 .handler = handle_at91sam9_cle_command,
684                 .mode = COMMAND_CONFIG,
685                 .help = "set command latch enable address line (default is 22)",
686                 .usage = "bank_id address_line",
687         },
688         {
689                 .name = "ale",
690                 .handler = handle_at91sam9_ale_command,
691                 .mode = COMMAND_CONFIG,
692                 .help = "set address latch enable address line (default is 21)",
693                 .usage = "bank_id address_line",
694         },
695         {
696                 .name = "rdy_busy",
697                 .handler = handle_at91sam9_rdy_busy_command,
698                 .mode = COMMAND_CONFIG,
699                 .help = "set the GPIO input pin connected to "
700                         "the RDY/~BUSY signal (no default)",
701                 .usage = "bank_id pio_base_addr pin_num",
702         },
703         {
704                 .name = "ce",
705                 .handler = handle_at91sam9_ce_command,
706                 .mode = COMMAND_CONFIG,
707                 .help = "set the GPIO output pin connected to "
708                         "the chip enable signal (no default)",
709                 .usage = "bank_id pio_base_addr pin_num",
710         },
711         COMMAND_REGISTRATION_DONE
712 };
713
714 static const struct command_registration at91sam9_command_handler[] = {
715         {
716                 .name = "at91sam9",
717                 .mode = COMMAND_ANY,
718                 .help = "AT91SAM9 NAND flash controller commands",
719                 .usage = "",
720                 .chain = at91sam9_sub_command_handlers,
721         },
722         COMMAND_REGISTRATION_DONE
723 };
724
725 /**
726  * Structure representing the AT91SAM9 NAND controller.
727  */
728 struct nand_flash_controller at91sam9_nand_controller = {
729         .name = "at91sam9",
730         .nand_device_command = at91sam9_nand_device_command,
731         .commands = at91sam9_command_handler,
732         .init = at91sam9_init,
733         .command = at91sam9_command,
734         .reset = at91sam9_reset,
735         .address = at91sam9_address,
736         .read_data = at91sam9_read_data,
737         .write_data = at91sam9_write_data,
738         .nand_ready = at91sam9_nand_ready,
739         .read_block_data = at91sam9_read_block_data,
740         .write_block_data = at91sam9_write_block_data,
741         .read_page = at91sam9_read_page,
742         .write_page = at91sam9_write_page,
743 };