jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / flash / nand / s3c2410.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /***************************************************************************
4 * Copyright (C) 2007, 2008 by Ben Dooks *
5 * ben@fluff.org *
6 ***************************************************************************/
7
8 /*
9 * S3C2410 OpenOCD NAND Flash controller support.
10 *
11 * Many thanks to Simtec Electronics for sponsoring this work.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
17
18 #include "s3c24xx.h"
19
20 NAND_DEVICE_COMMAND_HANDLER(s3c2410_nand_device_command)
21 {
22 struct s3c24xx_nand_controller *info;
23 CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
24
25 /* fill in the address fields for the core device */
26 info->cmd = S3C2410_NFCMD;
27 info->addr = S3C2410_NFADDR;
28 info->data = S3C2410_NFDATA;
29 info->nfstat = S3C2410_NFSTAT;
30
31 return ERROR_OK;
32 }
33
34 static int s3c2410_init(struct nand_device *nand)
35 {
36 struct target *target = nand->target;
37
38 target_write_u32(target, S3C2410_NFCONF,
39 S3C2410_NFCONF_EN | S3C2410_NFCONF_TACLS(3) |
40 S3C2410_NFCONF_TWRPH0(5) | S3C2410_NFCONF_TWRPH1(3));
41
42 return ERROR_OK;
43 }
44
45 static int s3c2410_write_data(struct nand_device *nand, uint16_t data)
46 {
47 struct target *target = nand->target;
48
49 if (target->state != TARGET_HALTED) {
50 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
51 return ERROR_NAND_OPERATION_FAILED;
52 }
53
54 target_write_u32(target, S3C2410_NFDATA, data);
55 return ERROR_OK;
56 }
57
58 static int s3c2410_read_data(struct nand_device *nand, void *data)
59 {
60 struct target *target = nand->target;
61
62 if (target->state != TARGET_HALTED) {
63 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
64 return ERROR_NAND_OPERATION_FAILED;
65 }
66
67 target_read_u8(target, S3C2410_NFDATA, data);
68 return ERROR_OK;
69 }
70
71 static int s3c2410_nand_ready(struct nand_device *nand, int timeout)
72 {
73 struct target *target = nand->target;
74 uint8_t status;
75
76 if (target->state != TARGET_HALTED) {
77 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
78 return ERROR_NAND_OPERATION_FAILED;
79 }
80
81 do {
82 target_read_u8(target, S3C2410_NFSTAT, &status);
83
84 if (status & S3C2410_NFSTAT_BUSY)
85 return 1;
86
87 alive_sleep(1);
88 } while (timeout-- > 0);
89
90 return 0;
91 }
92
93 struct nand_flash_controller s3c2410_nand_controller = {
94 .name = "s3c2410",
95 .nand_device_command = &s3c2410_nand_device_command,
96 .init = &s3c2410_init,
97 .reset = &s3c24xx_reset,
98 .command = &s3c24xx_command,
99 .address = &s3c24xx_address,
100 .write_data = &s3c2410_write_data,
101 .read_data = &s3c2410_read_data,
102 .write_page = s3c24xx_write_page,
103 .read_page = s3c24xx_read_page,
104 .nand_ready = &s3c2410_nand_ready,
105 };

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)