nios2-epcs.h 2.5 KB

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