3 * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
30 #include "../common/fpga.h"
32 fpga_t fpga_list
[] = {
33 { "PUMA" , PUMA_CONF_BASE
,
34 CFG_PC_PUMA_INIT
, CFG_PC_PUMA_PROG
, CFG_PC_PUMA_DONE
}
36 int fpga_count
= sizeof(fpga_list
) / sizeof(fpga_t
);
38 void can_driver_enable (void);
39 void can_driver_disable (void);
41 #define _NOT_USED_ 0xFFFFFFFF
44 * PUMA access using UPM B
46 const uint puma_table
[] =
49 * Single Read. (Offset 0 in UPM RAM)
51 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
56 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
58 * Burst Read. (Offset 8 in UPM RAM)
60 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
61 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
62 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
63 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
65 * Single Write. (Offset 18 in UPM RAM)
67 0x0FFCF804, 0x0FFCF400, 0x3FFDFC47, /* last */
69 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
71 * Burst Write. (Offset 20 in UPM RAM)
73 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
74 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
75 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
76 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
78 * Refresh (Offset 30 in UPM RAM)
80 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
81 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
82 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
84 * Exception. (Offset 3c in UPM RAM)
86 0x7FFFFC07, /* last */
87 _NOT_USED_
, _NOT_USED_
, _NOT_USED_
,
91 ulong
fpga_control (fpga_t
* fpga
, int cmd
)
93 volatile immap_t
*immr
= (immap_t
*)CFG_IMMR
;
94 volatile memctl8xx_t
*memctl
= &immr
->im_memctl
;
97 case FPGA_INIT_IS_HIGH
:
98 immr
->im_ioport
.iop_pcdir
&= ~fpga
->init_mask
; /* input */
99 return (immr
->im_ioport
.iop_pcdat
& fpga
->init_mask
) ? 1:0;
101 case FPGA_INIT_SET_LOW
:
102 immr
->im_ioport
.iop_pcdir
|= fpga
->init_mask
; /* output */
103 immr
->im_ioport
.iop_pcdat
&= ~fpga
->init_mask
;
106 case FPGA_INIT_SET_HIGH
:
107 immr
->im_ioport
.iop_pcdir
|= fpga
->init_mask
; /* output */
108 immr
->im_ioport
.iop_pcdat
|= fpga
->init_mask
;
111 case FPGA_PROG_SET_LOW
:
112 immr
->im_ioport
.iop_pcdat
&= ~fpga
->prog_mask
;
115 case FPGA_PROG_SET_HIGH
:
116 immr
->im_ioport
.iop_pcdat
|= fpga
->prog_mask
;
119 case FPGA_DONE_IS_HIGH
:
120 return (immr
->im_ioport
.iop_pcdat
& fpga
->done_mask
) ? 1:0;
123 /* disable FPGA in memory controller */
124 memctl
->memc_br4
= 0;
125 memctl
->memc_or4
= PUMA_CONF_OR_READ
;
126 memctl
->memc_br4
= PUMA_CONF_BR_READ
;
128 /* (re-) enable CAN drivers */
129 can_driver_enable ();
134 /* disable FPGA in memory controller */
135 memctl
->memc_br4
= 0;
137 * We must disable the CAN drivers first because
138 * they use UPM B, too.
140 can_driver_disable ();
142 * Configure UPMB for FPGA
144 upmconfig(UPMB
,(uint
*)puma_table
,sizeof(puma_table
)/sizeof(uint
));
145 memctl
->memc_or4
= PUMA_CONF_OR_LOAD
;
146 memctl
->memc_br4
= PUMA_CONF_BR_LOAD
;
150 return *(volatile ulong
*)fpga
->conf_base
;
152 case FPGA_INIT_PORTS
:
153 immr
->im_ioport
.iop_pcpar
&= ~fpga
->init_mask
; /* INIT I/O */
154 immr
->im_ioport
.iop_pcso
&= ~fpga
->init_mask
;
155 immr
->im_ioport
.iop_pcdir
&= ~fpga
->init_mask
;
157 immr
->im_ioport
.iop_pcpar
&= ~fpga
->prog_mask
; /* PROG Output */
158 immr
->im_ioport
.iop_pcso
&= ~fpga
->prog_mask
;
159 immr
->im_ioport
.iop_pcdir
|= fpga
->prog_mask
;
161 immr
->im_ioport
.iop_pcpar
&= ~fpga
->done_mask
; /* DONE Input */
162 immr
->im_ioport
.iop_pcso
&= ~fpga
->done_mask
;
163 immr
->im_ioport
.iop_pcdir
&= ~fpga
->done_mask
;