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 = {
59 DECLARE_GLOBAL_DATA_PTR;
61 int mvbc_p_init_fpga(void)
63 fpga_debug("Initialize FPGA interface\n");
65 fpga_add(fpga_altera, &cyclone2);
66 fpga_config_fn(0, 1, 0);
72 int fpga_null_fn(int cookie)
77 int fpga_config_fn(int assert, int flush, int cookie)
79 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
80 u32 dvo = gpio->simple_dvo;
82 fpga_debug("SET config : %s\n", assert ? "low" : "high");
89 gpio->simple_dvo = dvo;
94 int fpga_done_fn(int cookie)
96 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
100 fpga_debug("CONF_DONE check ... ");
101 if (gpio->simple_ival & FPGA_CONF_DONE) {
102 fpga_debug("high\n");
110 int fpga_status_fn(int cookie)
112 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
115 fpga_debug("STATUS check ... ");
116 if (gpio->sint_ival & FPGA_STATUS) {
117 fpga_debug("high\n");
125 int fpga_clk_fn(int assert_clk, int flush, int cookie)
127 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
128 u32 dvo = gpio->simple_dvo;
130 fpga_debug("CLOCK %s\n", assert_clk ? "high" : "low");
137 gpio->simple_dvo = dvo;
142 static inline int _write_fpga(u8 val)
145 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
146 u32 dvo = gpio->simple_dvo;
148 for (i=0; i<8; i++) {
150 gpio->simple_dvo = dvo;
154 gpio->simple_dvo = dvo;
156 gpio->simple_dvo = dvo;
163 int fpga_wr_fn(void *buf, size_t len, int flush, int cookie)
165 unsigned char *data = (unsigned char *) buf;
168 fpga_debug("fpga_wr: buf %p / size %d\n", buf, len);
169 for (i = 0; i < len; i++)
170 _write_fpga(data[i]);