1 /* src/flash/s3c2440_nand.c
3 * S3C2440 OpenOCD NAND Flash controller support.
5 * Copyright 2007,2008 Ben Dooks <ben@fluff.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Many thanks to Simtec Electronics for sponsoring this work.
19 #include "replacements.h"
26 #include "s3c24xx_nand.h"
29 int s3c2440_nand_device_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct nand_device_s
*device
);
30 int s3c2440_init(struct nand_device_s
*device
);
31 int s3c2440_nand_ready(struct nand_device_s
*device
, int timeout
);
33 nand_flash_controller_t s3c2440_nand_controller
=
36 .nand_device_command
= s3c2440_nand_device_command
,
37 .register_commands
= s3c24xx_register_commands
,
39 .reset
= s3c24xx_reset
,
40 .command
= s3c24xx_command
,
41 .address
= s3c24xx_address
,
42 .write_data
= s3c24xx_write_data
,
43 .read_data
= s3c24xx_read_data
,
44 .write_page
= s3c24xx_write_page
,
45 .read_page
= s3c24xx_read_page
,
46 .write_block_data
= s3c2440_write_block_data
,
47 .read_block_data
= s3c2440_read_block_data
,
48 .controller_ready
= s3c24xx_controller_ready
,
49 .nand_ready
= s3c2440_nand_ready
,
52 int s3c2440_nand_device_command(struct command_context_s
*cmd_ctx
, char *cmd
,
53 char **args
, int argc
,
54 struct nand_device_s
*device
)
56 s3c24xx_nand_controller_t
*info
;
58 info
= s3c24xx_nand_device_command(cmd_ctx
, cmd
, args
, argc
, device
);
60 return ERROR_NAND_DEVICE_INVALID
;
63 /* fill in the address fields for the core device */
64 info
->cmd
= S3C2440_NFCMD
;
65 info
->addr
= S3C2440_NFADDR
;
66 info
->data
= S3C2440_NFDATA
;
67 info
->nfstat
= S3C2440_NFSTAT
;
72 int s3c2440_init(struct nand_device_s
*device
)
74 s3c24xx_nand_controller_t
*s3c24xx_info
= device
->controller_priv
;
75 target_t
*target
= s3c24xx_info
->target
;
77 target_write_u32(target
, S3C2410_NFCONF
,
78 S3C2440_NFCONF_TACLS(3) |
79 S3C2440_NFCONF_TWRPH0(7) |
80 S3C2440_NFCONF_TWRPH1(7));
82 target_write_u32(target
, S3C2440_NFCONT
,
83 S3C2440_NFCONT_INITECC
| S3C2440_NFCONT_ENABLE
);
88 int s3c2440_nand_ready(struct nand_device_s
*device
, int timeout
)
90 s3c24xx_nand_controller_t
*s3c24xx_info
= device
->controller_priv
;
91 target_t
*target
= s3c24xx_info
->target
;
94 if (target
->state
!= TARGET_HALTED
) {
95 ERROR("target must be halted to use S3C24XX NAND flash controller");
96 return ERROR_NAND_OPERATION_FAILED
;
100 target_read_u8(target
, s3c24xx_info
->nfstat
, &status
);
102 if (status
& S3C2440_NFSTAT_READY
)
106 } while (timeout
-- > 0);
112 /* use the fact we can read/write 4 bytes in one go via a single 32bit op */
114 int s3c2440_read_block_data(struct nand_device_s
*device
, u8
*data
, int data_size
)
116 s3c24xx_nand_controller_t
*s3c24xx_info
= device
->controller_priv
;
117 target_t
*target
= s3c24xx_info
->target
;
118 u32 nfdata
= s3c24xx_info
->data
;
121 INFO("%s: reading data: %p, %p, %d\n", __func__
, device
, data
, data_size
);
123 if (target
->state
!= TARGET_HALTED
) {
124 ERROR("target must be halted to use S3C24XX NAND flash controller");
125 return ERROR_NAND_OPERATION_FAILED
;
128 while (data_size
>= 4) {
129 target_read_u32(target
, nfdata
, &tmp
);
140 while (data_size
> 0) {
141 target_read_u8(target
, nfdata
, data
);
150 int s3c2440_write_block_data(struct nand_device_s
*device
, u8
*data
, int data_size
)
152 s3c24xx_nand_controller_t
*s3c24xx_info
= device
->controller_priv
;
153 target_t
*target
= s3c24xx_info
->target
;
154 u32 nfdata
= s3c24xx_info
->data
;
157 if (target
->state
!= TARGET_HALTED
) {
158 ERROR("target must be halted to use S3C24XX NAND flash controller");
159 return ERROR_NAND_OPERATION_FAILED
;
162 while (data_size
>= 4) {
163 tmp
= le_to_h_u32(data
);
164 target_write_u32(target
, nfdata
, tmp
);
170 while (data_size
> 0) {
171 target_write_u8(target
, nfdata
, *data
);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)