1 /***************************************************************************
2 * Copyright (C) 2007, 2008 by Ben Dooks *
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. *
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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
20 * S3C2440 OpenOCD NAND Flash controller support.
22 * Many thanks to Simtec Electronics for sponsoring this work.
31 NAND_DEVICE_COMMAND_HANDLER(s3c2440_nand_device_command
)
33 struct s3c24xx_nand_controller
*info
;
34 CALL_S3C24XX_DEVICE_COMMAND(nand
, &info
);
36 /* fill in the address fields for the core device */
37 info
->cmd
= S3C2440_NFCMD
;
38 info
->addr
= S3C2440_NFADDR
;
39 info
->data
= S3C2440_NFDATA
;
40 info
->nfstat
= S3C2440_NFSTAT
;
45 static int s3c2440_init(struct nand_device
*nand
)
47 struct target
*target
= nand
->target
;
49 target_write_u32(target
, S3C2410_NFCONF
,
50 S3C2440_NFCONF_TACLS(3) |
51 S3C2440_NFCONF_TWRPH0(7) |
52 S3C2440_NFCONF_TWRPH1(7));
54 target_write_u32(target
, S3C2440_NFCONT
,
55 S3C2440_NFCONT_INITECC
| S3C2440_NFCONT_ENABLE
);
60 int s3c2440_nand_ready(struct nand_device
*nand
, int timeout
)
62 struct s3c24xx_nand_controller
*s3c24xx_info
= nand
->controller_priv
;
63 struct target
*target
= nand
->target
;
66 if (target
->state
!= TARGET_HALTED
) {
67 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
68 return ERROR_NAND_OPERATION_FAILED
;
72 target_read_u8(target
, s3c24xx_info
->nfstat
, &status
);
74 if (status
& S3C2440_NFSTAT_READY
)
78 } while (timeout
-- > 0);
84 /* use the fact we can read/write 4 bytes in one go via a single 32bit op */
86 int s3c2440_read_block_data(struct nand_device
*nand
, uint8_t *data
, int data_size
)
88 struct s3c24xx_nand_controller
*s3c24xx_info
= nand
->controller_priv
;
89 struct target
*target
= nand
->target
;
90 uint32_t nfdata
= s3c24xx_info
->data
;
93 LOG_INFO("%s: reading data: %p, %p, %d", __func__
, nand
, data
, data_size
);
95 if (target
->state
!= TARGET_HALTED
) {
96 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
97 return ERROR_NAND_OPERATION_FAILED
;
100 while (data_size
>= 4) {
101 target_read_u32(target
, nfdata
, &tmp
);
112 while (data_size
> 0) {
113 target_read_u8(target
, nfdata
, data
);
122 int s3c2440_write_block_data(struct nand_device
*nand
, uint8_t *data
, int data_size
)
124 struct s3c24xx_nand_controller
*s3c24xx_info
= nand
->controller_priv
;
125 struct target
*target
= nand
->target
;
126 uint32_t nfdata
= s3c24xx_info
->data
;
129 if (target
->state
!= TARGET_HALTED
) {
130 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
131 return ERROR_NAND_OPERATION_FAILED
;
134 while (data_size
>= 4) {
135 tmp
= le_to_h_u32(data
);
136 target_write_u32(target
, nfdata
, tmp
);
142 while (data_size
> 0) {
143 target_write_u8(target
, nfdata
, *data
);
152 struct nand_flash_controller s3c2440_nand_controller
= {
154 .nand_device_command
= &s3c2440_nand_device_command
,
155 .init
= &s3c2440_init
,
156 .reset
= &s3c24xx_reset
,
157 .command
= &s3c24xx_command
,
158 .address
= &s3c24xx_address
,
159 .write_data
= &s3c24xx_write_data
,
160 .read_data
= &s3c24xx_read_data
,
161 .write_page
= s3c24xx_write_page
,
162 .read_page
= s3c24xx_read_page
,
163 .write_block_data
= &s3c2440_write_block_data
,
164 .read_block_data
= &s3c2440_read_block_data
,
165 .nand_ready
= &s3c2440_nand_ready
,
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)