OpenOCD
s3c2410.c
Go to the documentation of this file.
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 {
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 
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");
52  }
53 
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");
65  }
66 
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");
79  }
80 
81  do {
83 
85  return 1;
86 
87  alive_sleep(1);
88  } while (timeout-- > 0);
89 
90  return 0;
91 }
92 
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 };
void alive_sleep(uint64_t ms)
Definition: log.c:460
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define ERROR_OK
Definition: log.h:155
#define ERROR_NAND_OPERATION_FAILED
Definition: nand/core.h:214
static int s3c2410_read_data(struct nand_device *nand, void *data)
Definition: s3c2410.c:58
NAND_DEVICE_COMMAND_HANDLER(s3c2410_nand_device_command)
Definition: s3c2410.c:20
static int s3c2410_nand_ready(struct nand_device *nand, int timeout)
Definition: s3c2410.c:71
static int s3c2410_write_data(struct nand_device *nand, uint16_t data)
Definition: s3c2410.c:45
struct nand_flash_controller s3c2410_nand_controller
Definition: s3c2410.c:93
static int s3c2410_init(struct nand_device *nand)
Definition: s3c2410.c:34
int s3c24xx_reset(struct nand_device *nand)
Definition: s3c24xx.c:37
int s3c24xx_address(struct nand_device *nand, uint8_t address)
Definition: s3c24xx.c:66
int s3c24xx_command(struct nand_device *nand, uint8_t command)
Definition: s3c24xx.c:52
#define CALL_S3C24XX_DEVICE_COMMAND(d, i)
Definition: s3c24xx.h:40
#define s3c24xx_read_page
Definition: s3c24xx.h:56
#define s3c24xx_write_page
Definition: s3c24xx.h:55
#define S3C2410_NFCONF
Definition: s3c24xx_regs.h:18
#define S3C2410_NFADDR
Definition: s3c24xx_regs.h:20
#define S3C2410_NFDATA
Definition: s3c24xx_regs.h:21
#define S3C2410_NFCONF_TACLS(x)
Definition: s3c24xx_regs.h:55
#define S3C2410_NFCMD
Definition: s3c24xx_regs.h:19
#define S3C2410_NFCONF_EN
Definition: s3c24xx_regs.h:50
#define S3C2410_NFCONF_TWRPH1(x)
Definition: s3c24xx_regs.h:57
#define S3C2410_NFSTAT
Definition: s3c24xx_regs.h:22
#define S3C2410_NFSTAT_BUSY
Definition: s3c24xx_regs.h:59
#define S3C2410_NFCONF_TWRPH0(x)
Definition: s3c24xx_regs.h:56
struct target * target
Definition: nand/core.h:49
Interface for NAND flash controllers.
Definition: nand/driver.h:23
const char * name
Driver name that is used to select it from configuration files.
Definition: nand/driver.h:25
Definition: target.h:120
enum target_state state
Definition: target.h:162
Definition: psoc6.c:84
int target_read_u8(struct target *target, target_addr_t address, uint8_t *value)
Definition: target.c:2664
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2707
@ TARGET_HALTED
Definition: target.h:55
static struct ublast_lowlevel_priv info
uint8_t status[4]
Definition: vdebug.c:17