fpga_scm.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
  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. #include <common.h>
  24. #include <mpc8260.h>
  25. #include <common.h>
  26. #include "../common/fpga.h"
  27. fpga_t fpga_list[] = {
  28. {"FIOX", CFG_FIOX_BASE,
  29. CFG_PD_FIOX_INIT, CFG_PD_FIOX_PROG, CFG_PD_FIOX_DONE}
  30. ,
  31. {"FDOHM", CFG_FDOHM_BASE,
  32. CFG_PD_FDOHM_INIT, CFG_PD_FDOHM_PROG, CFG_PD_FDOHM_DONE}
  33. };
  34. int fpga_count = sizeof (fpga_list) / sizeof (fpga_t);
  35. ulong fpga_control (fpga_t * fpga, int cmd)
  36. {
  37. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  38. switch (cmd) {
  39. case FPGA_INIT_IS_HIGH:
  40. immr->im_ioport.iop_pdird &= ~fpga->init_mask; /* input */
  41. return (immr->im_ioport.iop_pdatd & fpga->init_mask) ? 1 : 0;
  42. case FPGA_INIT_SET_LOW:
  43. immr->im_ioport.iop_pdird |= fpga->init_mask; /* output */
  44. immr->im_ioport.iop_pdatd &= ~fpga->init_mask;
  45. break;
  46. case FPGA_INIT_SET_HIGH:
  47. immr->im_ioport.iop_pdird |= fpga->init_mask; /* output */
  48. immr->im_ioport.iop_pdatd |= fpga->init_mask;
  49. break;
  50. case FPGA_PROG_SET_LOW:
  51. immr->im_ioport.iop_pdatd &= ~fpga->prog_mask;
  52. break;
  53. case FPGA_PROG_SET_HIGH:
  54. immr->im_ioport.iop_pdatd |= fpga->prog_mask;
  55. break;
  56. case FPGA_DONE_IS_HIGH:
  57. return (immr->im_ioport.iop_pdatd & fpga->done_mask) ? 1 : 0;
  58. case FPGA_READ_MODE:
  59. break;
  60. case FPGA_LOAD_MODE:
  61. break;
  62. case FPGA_GET_ID:
  63. if (fpga->conf_base == CFG_FIOX_BASE) {
  64. ulong ver =
  65. *(volatile ulong *) (fpga->conf_base + 0x10);
  66. return ((ver >> 10) & 0xf) + ((ver >> 2) & 0xf0);
  67. } else if (fpga->conf_base == CFG_FDOHM_BASE) {
  68. return (*(volatile ushort *) fpga->conf_base) & 0xff;
  69. } else {
  70. return *(volatile ulong *) fpga->conf_base;
  71. }
  72. case FPGA_INIT_PORTS:
  73. immr->im_ioport.iop_ppard &= ~fpga->init_mask; /* INIT I/O */
  74. immr->im_ioport.iop_psord &= ~fpga->init_mask;
  75. immr->im_ioport.iop_pdird &= ~fpga->init_mask;
  76. immr->im_ioport.iop_ppard &= ~fpga->prog_mask; /* PROG Output */
  77. immr->im_ioport.iop_psord &= ~fpga->prog_mask;
  78. immr->im_ioport.iop_pdird |= fpga->prog_mask;
  79. immr->im_ioport.iop_ppard &= ~fpga->done_mask; /* DONE Input */
  80. immr->im_ioport.iop_psord &= ~fpga->done_mask;
  81. immr->im_ioport.iop_pdird &= ~fpga->done_mask;
  82. break;
  83. }
  84. return 0;
  85. }