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+
19 #define fpga_debug(fmt, args...) printf("%s: "fmt, __func__, ##args)
21 #define fpga_debug(fmt, args...)
24 Altera_CYC2_Passive_Serial_fns altera_fns = {
34 Altera_desc cyclone2 = {
43 DECLARE_GLOBAL_DATA_PTR;
45 int mvblm7_init_fpga(void)
47 fpga_debug("Initialize FPGA interface\n");
49 fpga_add(fpga_altera, &cyclone2);
50 fpga_config_fn(0, 1, 0);
56 int fpga_null_fn(int cookie)
61 int fpga_config_fn(int assert, int flush, int cookie)
63 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
64 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)&im->gpio[0];
67 fpga_debug("SET config : %s\n", assert ? "low" : "high");
79 int fpga_done_fn(int cookie)
81 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
82 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)&im->gpio[0];
86 fpga_debug("CONF_DONE check ... ");
87 if (gpio->dat & FPGA_CONF_DONE) {
96 int fpga_status_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];
102 fpga_debug("STATUS check ... ");
103 if (gpio->dat & FPGA_STATUS) {
104 fpga_debug("high\n");
112 int fpga_clk_fn(int assert_clk, int flush, int cookie)
114 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
115 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)&im->gpio[0];
118 fpga_debug("CLOCK %s\n", assert_clk ? "high" : "low");
130 static inline int _write_fpga(u8 val, int dump)
132 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
133 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)&im->gpio[0];
138 fpga_debug(" %02x -> ", val);
139 for (i = 0; i < 8; i++) {
144 fpga_debug("%d ", val&1);
158 int fpga_wr_fn(const void *buf, size_t len, int flush, int cookie)
160 unsigned char *data = (unsigned char *) buf;
163 fpga_debug("fpga_wr: buf %p / size %d\n", buf, len);
164 for (i = 0; i < len; i++)
165 _write_fpga(data[i], 0);