2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
5 * SPDX-License-Identifier: GPL-2.0+
8 /*************************************************************************
9 * Altera Nios-II EPCS Controller Core interfaces
10 ************************************************************************/
12 #ifndef __NIOS2_EPCS_H__
13 #define __NIOS2_EPCS_H__
15 typedef struct epcs_devinfo_t {
16 const char *name; /* Device name */
17 unsigned char id; /* Device silicon id */
18 unsigned char size; /* Total size log2(bytes)*/
19 unsigned char num_sects; /* Number of sectors */
20 unsigned char sz_sect; /* Sector size log2(bytes) */
21 unsigned char sz_page; /* Page size log2(bytes) */
22 unsigned char prot_mask; /* Protection mask */
25 /* Resets the epcs controller -- to prevent (potential) soft-reset
26 * problems when booting from the epcs controller
28 extern int epcs_reset (void);
30 /* Returns the devinfo struct if EPCS device is found;
33 extern epcs_devinfo_t *epcs_dev_find (void);
35 /* Returns the number of bytes used by config data.
38 extern int epcs_cfgsz (void);
40 /* Erase sectors 'start' to 'end' - return zero on success
42 extern int epcs_erase (unsigned start, unsigned end);
44 /* Read 'cnt' bytes from device offset 'off' into buf at 'addr'
45 * Zero return on success
47 extern int epcs_read (ulong addr, ulong off, ulong cnt);
49 /* Write 'cnt' bytes to device offset 'off' from buf at 'addr'.
50 * Zero return on success
52 extern int epcs_write (ulong addr, ulong off, ulong cnt);
54 /* Verify 'cnt' bytes at device offset 'off' comparing with buf
55 * at 'addr'. On failure, write first invalid offset to *err.
56 * Zero return on success
58 extern int epcs_verify (ulong addr, ulong off, ulong cnt, ulong *err);
60 #endif /* __NIOS2_EPCS_H__ */