1/* 2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com> 3 * Scott McNutt <smcnutt@psyent.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 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 { 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 */ 23}epcs_devinfo_t; 24 25/* Resets the epcs controller -- to prevent (potential) soft-reset 26 * problems when booting from the epcs controller 27 */ 28extern int epcs_reset (void); 29 30/* 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__ */ 61