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 mvbc_p_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 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
83 u32 dvo = gpio->simple_dvo;
85 fpga_debug("SET config : %s\n", assert ? "low" : "high");
92 gpio->simple_dvo = dvo;
97 int fpga_done_fn(int cookie)
99 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
103 fpga_debug("CONF_DONE check ... ");
104 if (gpio->simple_ival & FPGA_CONF_DONE) {
105 fpga_debug("high\n");
113 int fpga_status_fn(int cookie)
115 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
118 fpga_debug("STATUS check ... ");
119 if (gpio->sint_ival & FPGA_STATUS) {
120 fpga_debug("high\n");
128 int fpga_clk_fn(int assert_clk, int flush, int cookie)
130 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
131 u32 dvo = gpio->simple_dvo;
133 fpga_debug("CLOCK %s\n", assert_clk ? "high" : "low");
140 gpio->simple_dvo = dvo;
145 static inline int _write_fpga(u8 val)
148 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
149 u32 dvo = gpio->simple_dvo;
151 for (i=0; i<8; i++) {
153 gpio->simple_dvo = dvo;
157 gpio->simple_dvo = dvo;
159 gpio->simple_dvo = dvo;
166 int fpga_wr_fn(void *buf, size_t len, int flush, int cookie)
168 unsigned char *data = (unsigned char *) buf;
171 fpga_debug("fpga_wr: buf %p / size %d\n", buf, len);
172 for (i = 0; i < len; i++)
173 _write_fpga(data[i]);