blob: 8c8f2385ee5d1ee0f8f1f45048ec172b9a6cfaee [file] [log] [blame]
wdenk194b8392005-03-30 23:28:18 +00001/*
2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk194b8392005-03-30 23:28:18 +00006 */
7
8/*************************************************************************
9 * Altera Nios-II EPCS Controller Core interfaces
10 ************************************************************************/
11
12#ifndef __NIOS2_EPCS_H__
13#define __NIOS2_EPCS_H__
14
15typedef struct epcs_devinfo_t {
Wolfgang Denka1be4762008-05-20 16:00:29 +020016 const char *name; /* Device name */
wdenk194b8392005-03-30 23:28:18 +000017 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 */
23}epcs_devinfo_t;
24
Scott McNutt4fd37c02006-06-08 12:08:12 -040025/* Resets the epcs controller -- to prevent (potential) soft-reset
26 * problems when booting from the epcs controller
27 */
28extern int epcs_reset (void);
29
wdenk194b8392005-03-30 23:28:18 +000030/* Returns the devinfo struct if EPCS device is found;
31 * NULL otherwise.
32 */
33extern epcs_devinfo_t *epcs_dev_find (void);
34
35/* Returns the number of bytes used by config data.
36 * Negative on error.
37 */
38extern int epcs_cfgsz (void);
39
40/* Erase sectors 'start' to 'end' - return zero on success
41 */
42extern int epcs_erase (unsigned start, unsigned end);
43
44/* Read 'cnt' bytes from device offset 'off' into buf at 'addr'
45 * Zero return on success
46 */
47extern int epcs_read (ulong addr, ulong off, ulong cnt);
48
49/* Write 'cnt' bytes to device offset 'off' from buf at 'addr'.
50 * Zero return on success
51 */
52extern int epcs_write (ulong addr, ulong off, ulong cnt);
53
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
57 */
58extern int epcs_verify (ulong addr, ulong off, ulong cnt, ulong *err);
59
60#endif /* __NIOS2_EPCS_H__ */