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,
32 #include "mergerbox.h"
35 Altera_CYC2_Passive_Serial_fns altera_fns = {
45 Altera_desc cyclone2 = {
54 DECLARE_GLOBAL_DATA_PTR;
56 int mergerbox_init_fpga(void)
58 debug("Initialize FPGA interface\n");
60 fpga_add(fpga_altera, &cyclone2);
65 int fpga_null_fn(int cookie)
70 int fpga_config_fn(int assert, int flush, int cookie)
72 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
73 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
85 int fpga_done_fn(int cookie)
87 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
88 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
92 debug("CONF_DONE check ... ");
93 if (gpio->dat & FPGA_CONF_DONE) {
102 int fpga_status_fn(int cookie)
104 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
105 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
108 debug("STATUS check ... ");
109 if (gpio->dat & FPGA_STATUS) {
118 int fpga_clk_fn(int assert_clk, int flush, int cookie)
120 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
121 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
124 debug("CLOCK %s\n", assert_clk ? "high" : "low");
136 static inline int _write_fpga(u8 val, int dump)
138 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
139 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
144 debug(" %02x -> ", val);
145 for (i = 0; i < 8; i++) {
164 int fpga_wr_fn(const void *buf, size_t len, int flush, int cookie)
166 unsigned char *data = (unsigned char *) buf;
169 debug("fpga_wr: buf %p / size %d\n", buf, len);
170 for (i = 0; i < len; i++)
171 _write_fpga(data[i], 0);