nios2-epcs.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. * Altera Nios-II EPCS Controller Core interfaces
  9. ************************************************************************/
  10. #ifndef __NIOS2_EPCS_H__
  11. #define __NIOS2_EPCS_H__
  12. typedef struct epcs_devinfo_t {
  13. const char *name; /* Device name */
  14. unsigned char id; /* Device silicon id */
  15. unsigned char size; /* Total size log2(bytes)*/
  16. unsigned char num_sects; /* Number of sectors */
  17. unsigned char sz_sect; /* Sector size log2(bytes) */
  18. unsigned char sz_page; /* Page size log2(bytes) */
  19. unsigned char prot_mask; /* Protection mask */
  20. }epcs_devinfo_t;
  21. /* Resets the epcs controller -- to prevent (potential) soft-reset
  22. * problems when booting from the epcs controller
  23. */
  24. extern int epcs_reset (void);
  25. /* Returns the devinfo struct if EPCS device is found;
  26. * NULL otherwise.
  27. */
  28. extern epcs_devinfo_t *epcs_dev_find (void);
  29. /* Returns the number of bytes used by config data.
  30. * Negative on error.
  31. */
  32. extern int epcs_cfgsz (void);
  33. /* Erase sectors 'start' to 'end' - return zero on success
  34. */
  35. extern int epcs_erase (unsigned start, unsigned end);
  36. /* Read 'cnt' bytes from device offset 'off' into buf at 'addr'
  37. * Zero return on success
  38. */
  39. extern int epcs_read (ulong addr, ulong off, ulong cnt);
  40. /* Write 'cnt' bytes to device offset 'off' from buf at 'addr'.
  41. * Zero return on success
  42. */
  43. extern int epcs_write (ulong addr, ulong off, ulong cnt);
  44. /* Verify 'cnt' bytes at device offset 'off' comparing with buf
  45. * at 'addr'. On failure, write first invalid offset to *err.
  46. * Zero return on success
  47. */
  48. extern int epcs_verify (ulong addr, ulong off, ulong cnt, ulong *err);
  49. #endif /* __NIOS2_EPCS_H__ */