1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <common.h>
26#include <mpc8260.h>
27#include <common.h>
28#include "../common/fpga.h"
29
30fpga_t fpga_list[] = {
31 {"FIOX", CONFIG_SYS_FIOX_BASE,
32 CONFIG_SYS_PD_FIOX_INIT, CONFIG_SYS_PD_FIOX_PROG, CONFIG_SYS_PD_FIOX_DONE}
33 ,
34 {"FDOHM", CONFIG_SYS_FDOHM_BASE,
35 CONFIG_SYS_PD_FDOHM_INIT, CONFIG_SYS_PD_FDOHM_PROG, CONFIG_SYS_PD_FDOHM_DONE}
36};
37int fpga_count = sizeof (fpga_list) / sizeof (fpga_t);
38
39
40ulong fpga_control (fpga_t * fpga, int cmd)
41{
42 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
43
44 switch (cmd) {
45 case FPGA_INIT_IS_HIGH:
46 immr->im_ioport.iop_pdird &= ~fpga->init_mask;
47 return (immr->im_ioport.iop_pdatd & fpga->init_mask) ? 1 : 0;
48
49 case FPGA_INIT_SET_LOW:
50 immr->im_ioport.iop_pdird |= fpga->init_mask;
51 immr->im_ioport.iop_pdatd &= ~fpga->init_mask;
52 break;
53
54 case FPGA_INIT_SET_HIGH:
55 immr->im_ioport.iop_pdird |= fpga->init_mask;
56 immr->im_ioport.iop_pdatd |= fpga->init_mask;
57 break;
58
59 case FPGA_PROG_SET_LOW:
60 immr->im_ioport.iop_pdatd &= ~fpga->prog_mask;
61 break;
62
63 case FPGA_PROG_SET_HIGH:
64 immr->im_ioport.iop_pdatd |= fpga->prog_mask;
65 break;
66
67 case FPGA_DONE_IS_HIGH:
68 return (immr->im_ioport.iop_pdatd & fpga->done_mask) ? 1 : 0;
69
70 case FPGA_READ_MODE:
71 break;
72
73 case FPGA_LOAD_MODE:
74 break;
75
76 case FPGA_GET_ID:
77 if (fpga->conf_base == CONFIG_SYS_FIOX_BASE) {
78 ulong ver =
79 *(volatile ulong *) (fpga->conf_base + 0x10);
80 return ((ver >> 10) & 0xf) + ((ver >> 2) & 0xf0);
81 } else if (fpga->conf_base == CONFIG_SYS_FDOHM_BASE) {
82 return (*(volatile ushort *) fpga->conf_base) & 0xff;
83 } else {
84 return *(volatile ulong *) fpga->conf_base;
85 }
86
87 case FPGA_INIT_PORTS:
88 immr->im_ioport.iop_ppard &= ~fpga->init_mask;
89 immr->im_ioport.iop_psord &= ~fpga->init_mask;
90 immr->im_ioport.iop_pdird &= ~fpga->init_mask;
91
92 immr->im_ioport.iop_ppard &= ~fpga->prog_mask;
93 immr->im_ioport.iop_psord &= ~fpga->prog_mask;
94 immr->im_ioport.iop_pdird |= fpga->prog_mask;
95
96 immr->im_ioport.iop_ppard &= ~fpga->done_mask;
97 immr->im_ioport.iop_psord &= ~fpga->done_mask;
98 immr->im_ioport.iop_pdird &= ~fpga->done_mask;
99
100 break;
101
102 }
103 return 0;
104}
105