3 * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
4 * Keith Outwater, keith_outwater@mvis.com.
7 * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
36 #define fpga_debug(fmt, args...) printf("%s: "fmt, __func__, ##args)
38 #define fpga_debug(fmt, args...)
41 Altera_CYC2_Passive_Serial_fns altera_fns
= {
51 Altera_desc cyclone2
= {
60 DECLARE_GLOBAL_DATA_PTR
;
62 int mvblm7_init_fpga(void)
64 fpga_debug("Initialize FPGA interface\n");
66 fpga_add(fpga_altera
, &cyclone2
);
67 fpga_config_fn(0, 1, 0);
73 int fpga_null_fn(int cookie
)
78 int fpga_config_fn(int assert, int flush
, int cookie
)
80 volatile immap_t
*im
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
81 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
84 fpga_debug("SET config : %s\n", assert ? "low" : "high");
96 int fpga_done_fn(int cookie
)
98 volatile immap_t
*im
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
99 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
103 fpga_debug("CONF_DONE check ... ");
104 if (gpio
->dat
& FPGA_CONF_DONE
) {
105 fpga_debug("high\n");
113 int fpga_status_fn(int cookie
)
115 volatile immap_t
*im
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
116 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
119 fpga_debug("STATUS check ... ");
120 if (gpio
->dat
& FPGA_STATUS
) {
121 fpga_debug("high\n");
129 int fpga_clk_fn(int assert_clk
, int flush
, int cookie
)
131 volatile immap_t
*im
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
132 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
135 fpga_debug("CLOCK %s\n", assert_clk
? "high" : "low");
147 static inline int _write_fpga(u8 val
, int dump
)
149 volatile immap_t
*im
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
150 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
155 fpga_debug(" %02x -> ", val
);
156 for (i
= 0; i
< 8; i
++) {
161 fpga_debug("%d ", val
&1);
175 int fpga_wr_fn(const void *buf
, size_t len
, int flush
, int cookie
)
177 unsigned char *data
= (unsigned char *) buf
;
180 fpga_debug("fpga_wr: buf %p / size %d\n", buf
, len
);
181 for (i
= 0; i
< len
; i
++)
182 _write_fpga(data
[i
], 0);