wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004, Psyent Corporation <www.psyent.com> |
| 3 | * Scott McNutt <smcnutt@psyent.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /************************************************************************* |
| 9 | * Altera Nios-II EPCS Controller Core interfaces |
| 10 | ************************************************************************/ |
| 11 | |
| 12 | #ifndef __NIOS2_EPCS_H__ |
| 13 | #define __NIOS2_EPCS_H__ |
| 14 | |
| 15 | typedef struct epcs_devinfo_t { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 16 | const char *name; /* Device name */ |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 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 */ |
| 23 | }epcs_devinfo_t; |
| 24 | |
Scott McNutt | 1f6ce8f | 2006-06-08 12:08:12 -0400 | [diff] [blame] | 25 | /* Resets the epcs controller -- to prevent (potential) soft-reset |
| 26 | * problems when booting from the epcs controller |
| 27 | */ |
| 28 | extern int epcs_reset (void); |
| 29 | |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 30 | /* Returns the devinfo struct if EPCS device is found; |
| 31 | * NULL otherwise. |
| 32 | */ |
| 33 | extern epcs_devinfo_t *epcs_dev_find (void); |
| 34 | |
| 35 | /* Returns the number of bytes used by config data. |
| 36 | * Negative on error. |
| 37 | */ |
| 38 | extern int epcs_cfgsz (void); |
| 39 | |
| 40 | /* Erase sectors 'start' to 'end' - return zero on success |
| 41 | */ |
| 42 | extern 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 | */ |
| 47 | extern 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 | */ |
| 52 | extern 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 | */ |
| 58 | extern int epcs_verify (ulong addr, ulong off, ulong cnt, ulong *err); |
| 59 | |
| 60 | #endif /* __NIOS2_EPCS_H__ */ |