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 * SPDX-License-Identifier: GPL-2.0+
15 #include "mergerbox.h"
18 Altera_CYC2_Passive_Serial_fns altera_fns = {
28 Altera_desc cyclone2 = {
37 DECLARE_GLOBAL_DATA_PTR;
39 int mergerbox_init_fpga(void)
41 debug("Initialize FPGA interface\n");
43 fpga_add(fpga_altera, &cyclone2);
48 int fpga_null_fn(int cookie)
53 int fpga_config_fn(int assert, int flush, int cookie)
55 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
56 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
68 int fpga_done_fn(int cookie)
70 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
71 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
75 debug("CONF_DONE check ... ");
76 if (gpio->dat & FPGA_CONF_DONE) {
85 int fpga_status_fn(int cookie)
87 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
88 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
91 debug("STATUS check ... ");
92 if (gpio->dat & FPGA_STATUS) {
101 int fpga_clk_fn(int assert_clk, int flush, int cookie)
103 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
104 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
107 debug("CLOCK %s\n", assert_clk ? "high" : "low");
119 static inline int _write_fpga(u8 val, int dump)
121 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
122 volatile gpio83xx_t *gpio = (gpio83xx_t *)&im->gpio[0];
127 debug(" %02x -> ", val);
128 for (i = 0; i < 8; i++) {
147 int fpga_wr_fn(const void *buf, size_t len, int flush, int cookie)
149 unsigned char *data = (unsigned char *) buf;
152 debug("fpga_wr: buf %p / size %d\n", buf, len);
153 for (i = 0; i < len; i++)
154 _write_fpga(data[i], 0);