blob: 325cf71f67159a526a3c412903ac7b2ca0050fd1 [file] [log] [blame]
wdenk0c1c117c2005-03-30 23:28:18 +00001/*
2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*************************************************************************
25 * Altera Nios-II EPCS Controller Core interfaces
26 ************************************************************************/
27
28#ifndef __NIOS2_EPCS_H__
29#define __NIOS2_EPCS_H__
30
31typedef struct epcs_devinfo_t {
Wolfgang Denk53677ef2008-05-20 16:00:29 +020032 const char *name; /* Device name */
wdenk0c1c117c2005-03-30 23:28:18 +000033 unsigned char id; /* Device silicon id */
34 unsigned char size; /* Total size log2(bytes)*/
35 unsigned char num_sects; /* Number of sectors */
36 unsigned char sz_sect; /* Sector size log2(bytes) */
37 unsigned char sz_page; /* Page size log2(bytes) */
38 unsigned char prot_mask; /* Protection mask */
39}epcs_devinfo_t;
40
Scott McNutt1f6ce8f2006-06-08 12:08:12 -040041/* Resets the epcs controller -- to prevent (potential) soft-reset
42 * problems when booting from the epcs controller
43 */
44extern int epcs_reset (void);
45
wdenk0c1c117c2005-03-30 23:28:18 +000046/* Returns the devinfo struct if EPCS device is found;
47 * NULL otherwise.
48 */
49extern epcs_devinfo_t *epcs_dev_find (void);
50
51/* Returns the number of bytes used by config data.
52 * Negative on error.
53 */
54extern int epcs_cfgsz (void);
55
56/* Erase sectors 'start' to 'end' - return zero on success
57 */
58extern int epcs_erase (unsigned start, unsigned end);
59
60/* Read 'cnt' bytes from device offset 'off' into buf at 'addr'
61 * Zero return on success
62 */
63extern int epcs_read (ulong addr, ulong off, ulong cnt);
64
65/* Write 'cnt' bytes to device offset 'off' from buf at 'addr'.
66 * Zero return on success
67 */
68extern int epcs_write (ulong addr, ulong off, ulong cnt);
69
70/* Verify 'cnt' bytes at device offset 'off' comparing with buf
71 * at 'addr'. On failure, write first invalid offset to *err.
72 * Zero return on success
73 */
74extern int epcs_verify (ulong addr, ulong off, ulong cnt, ulong *err);
75
76#endif /* __NIOS2_EPCS_H__ */