openocd: fix SPDX tag format for files .c
[openocd.git] / src / flash / nand / s3c24xx.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 * S3C24XX Series 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 S3C24XX_DEVICE_COMMAND()
21 {
22 *info = NULL;
23
24 struct s3c24xx_nand_controller *s3c24xx_info;
25 s3c24xx_info = malloc(sizeof(struct s3c24xx_nand_controller));
26 if (!s3c24xx_info) {
27 LOG_ERROR("no memory for nand controller");
28 return -ENOMEM;
29 }
30
31 nand->controller_priv = s3c24xx_info;
32 *info = s3c24xx_info;
33
34 return ERROR_OK;
35 }
36
37 int s3c24xx_reset(struct nand_device *nand)
38 {
39 struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
40 struct target *target = nand->target;
41
42 if (target->state != TARGET_HALTED) {
43 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
44 return ERROR_NAND_OPERATION_FAILED;
45 }
46
47 target_write_u32(target, s3c24xx_info->cmd, 0xff);
48
49 return ERROR_OK;
50 }
51
52 int s3c24xx_command(struct nand_device *nand, uint8_t command)
53 {
54 struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
55 struct target *target = nand->target;
56
57 if (target->state != TARGET_HALTED) {
58 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
59 return ERROR_NAND_OPERATION_FAILED;
60 }
61
62 target_write_u16(target, s3c24xx_info->cmd, command);
63 return ERROR_OK;
64 }
65
66 int s3c24xx_address(struct nand_device *nand, uint8_t address)
67 {
68 struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
69 struct target *target = nand->target;
70
71 if (target->state != TARGET_HALTED) {
72 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
73 return ERROR_NAND_OPERATION_FAILED;
74 }
75
76 target_write_u16(target, s3c24xx_info->addr, address);
77 return ERROR_OK;
78 }
79
80 int s3c24xx_write_data(struct nand_device *nand, uint16_t data)
81 {
82 struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
83 struct target *target = nand->target;
84
85 if (target->state != TARGET_HALTED) {
86 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
87 return ERROR_NAND_OPERATION_FAILED;
88 }
89
90 target_write_u8(target, s3c24xx_info->data, data);
91 return ERROR_OK;
92 }
93
94 int s3c24xx_read_data(struct nand_device *nand, void *data)
95 {
96 struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
97 struct target *target = nand->target;
98
99 if (target->state != TARGET_HALTED) {
100 LOG_ERROR("target must be halted to use S3C24XX NAND flash controller");
101 return ERROR_NAND_OPERATION_FAILED;
102 }
103
104 target_read_u8(target, s3c24xx_info->data, data);
105 return ERROR_OK;
106 }

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)