Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 |
| 3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
Stefano Babic | 78129d9 | 2011-03-14 15:43:56 +0100 | [diff] [blame] | 26 | #include <asm/arch/clock.h> |
| 27 | #include <asm/arch/imx-regs.h> |
Stefano Babic | 07184e8 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 28 | #include <asm/gpio.h> |
Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 29 | #include <fpga.h> |
| 30 | #include <lattice.h> |
| 31 | #include "qong_fpga.h" |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | #if defined(CONFIG_FPGA) |
| 36 | |
| 37 | static void qong_jtag_init(void) |
| 38 | { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | static void qong_fpga_jtag_set_tdi(int value) |
| 43 | { |
Stefano Babic | 07184e8 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 44 | gpio_set_value(QONG_FPGA_TDI_PIN, value); |
Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static void qong_fpga_jtag_set_tms(int value) |
| 48 | { |
Stefano Babic | 07184e8 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 49 | gpio_set_value(QONG_FPGA_TMS_PIN, value); |
Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static void qong_fpga_jtag_set_tck(int value) |
| 53 | { |
Stefano Babic | 07184e8 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 54 | gpio_set_value(QONG_FPGA_TCK_PIN, value); |
Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static int qong_fpga_jtag_get_tdo(void) |
| 58 | { |
Stefano Babic | 07184e8 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 59 | return gpio_get_value(QONG_FPGA_TDO_PIN); |
Stefano Babic | fbb1f58 | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | lattice_board_specific_func qong_fpga_fns = { |
| 63 | qong_jtag_init, |
| 64 | qong_fpga_jtag_set_tdi, |
| 65 | qong_fpga_jtag_set_tms, |
| 66 | qong_fpga_jtag_set_tck, |
| 67 | qong_fpga_jtag_get_tdo |
| 68 | }; |
| 69 | |
| 70 | Lattice_desc qong_fpga[CONFIG_FPGA_COUNT] = { |
| 71 | { |
| 72 | Lattice_XP2, |
| 73 | lattice_jtag_mode, |
| 74 | 356519, |
| 75 | (void *) &qong_fpga_fns, |
| 76 | NULL, |
| 77 | 0, |
| 78 | "lfxp2_5e_ftbga256" |
| 79 | }, |
| 80 | }; |
| 81 | |
| 82 | int qong_fpga_init(void) |
| 83 | { |
| 84 | int i; |
| 85 | |
| 86 | fpga_init(); |
| 87 | |
| 88 | for (i = 0; i < CONFIG_FPGA_COUNT; i++) { |
| 89 | fpga_add(fpga_lattice, &qong_fpga[i]); |
| 90 | } |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | #endif |