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
= {
52 Altera_desc cyclone2
= {
61 DECLARE_GLOBAL_DATA_PTR
;
63 int mvblm7_init_fpga(void)
65 fpga_debug("Initialize FPGA interface (reloc 0x%.8lx)\n",
67 fpga_init(gd
->reloc_off
);
68 fpga_add(fpga_altera
, &cyclone2
);
69 fpga_config_fn(0, 1, 0);
75 int fpga_null_fn(int cookie
)
80 int fpga_config_fn(int assert, int flush
, int cookie
)
82 volatile immap_t
*im
= (volatile immap_t
*)CFG_IMMR
;
83 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
86 fpga_debug("SET config : %s\n", assert ? "low" : "high");
98 int fpga_done_fn(int cookie
)
100 volatile immap_t
*im
= (volatile immap_t
*)CFG_IMMR
;
101 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
105 fpga_debug("CONF_DONE check ... ");
106 if (gpio
->dat
& FPGA_CONF_DONE
) {
107 fpga_debug("high\n");
115 int fpga_status_fn(int cookie
)
117 volatile immap_t
*im
= (volatile immap_t
*)CFG_IMMR
;
118 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
121 fpga_debug("STATUS check ... ");
122 if (gpio
->dat
& FPGA_STATUS
) {
123 fpga_debug("high\n");
131 int fpga_clk_fn(int assert_clk
, int flush
, int cookie
)
133 volatile immap_t
*im
= (volatile immap_t
*)CFG_IMMR
;
134 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
137 fpga_debug("CLOCK %s\n", assert_clk
? "high" : "low");
149 static inline int _write_fpga(u8 val
, int dump
)
151 volatile immap_t
*im
= (volatile immap_t
*)CFG_IMMR
;
152 volatile gpio83xx_t
*gpio
= (volatile gpio83xx_t
*)&im
->gpio
[0];
157 fpga_debug(" %02x -> ", val
);
158 for (i
= 0; i
< 8; i
++) {
163 fpga_debug("%d ", val
&1);
177 int fpga_wr_fn(void *buf
, size_t len
, int flush
, int cookie
)
179 unsigned char *data
= (unsigned char *) buf
;
182 fpga_debug("fpga_wr: buf %p / size %d\n", buf
, len
);
183 for (i
= 0; i
< len
; i
++)
184 _write_fpga(data
[i
], 0);