Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 |
| 3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Stefano Babic | 8627111 | 2011-03-14 15:43:56 +0100 | [diff] [blame] | 9 | #include <asm/arch/clock.h> |
| 10 | #include <asm/arch/imx-regs.h> |
Stefano Babic | 9400f59 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 12 | #include <fpga.h> |
| 13 | #include <lattice.h> |
| 14 | #include "qong_fpga.h" |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | #if defined(CONFIG_FPGA) |
| 19 | |
| 20 | static void qong_jtag_init(void) |
| 21 | { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | static void qong_fpga_jtag_set_tdi(int value) |
| 26 | { |
Stefano Babic | 9400f59 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 27 | gpio_set_value(QONG_FPGA_TDI_PIN, value); |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static void qong_fpga_jtag_set_tms(int value) |
| 31 | { |
Stefano Babic | 9400f59 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 32 | gpio_set_value(QONG_FPGA_TMS_PIN, value); |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | static void qong_fpga_jtag_set_tck(int value) |
| 36 | { |
Stefano Babic | 9400f59 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 37 | gpio_set_value(QONG_FPGA_TCK_PIN, value); |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | static int qong_fpga_jtag_get_tdo(void) |
| 41 | { |
Stefano Babic | 9400f59 | 2011-08-21 10:52:58 +0200 | [diff] [blame] | 42 | return gpio_get_value(QONG_FPGA_TDO_PIN); |
Stefano Babic | b9eb3fd | 2010-06-29 11:48:24 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | lattice_board_specific_func qong_fpga_fns = { |
| 46 | qong_jtag_init, |
| 47 | qong_fpga_jtag_set_tdi, |
| 48 | qong_fpga_jtag_set_tms, |
| 49 | qong_fpga_jtag_set_tck, |
| 50 | qong_fpga_jtag_get_tdo |
| 51 | }; |
| 52 | |
| 53 | Lattice_desc qong_fpga[CONFIG_FPGA_COUNT] = { |
| 54 | { |
| 55 | Lattice_XP2, |
| 56 | lattice_jtag_mode, |
| 57 | 356519, |
| 58 | (void *) &qong_fpga_fns, |
| 59 | NULL, |
| 60 | 0, |
| 61 | "lfxp2_5e_ftbga256" |
| 62 | }, |
| 63 | }; |
| 64 | |
| 65 | int qong_fpga_init(void) |
| 66 | { |
| 67 | int i; |
| 68 | |
| 69 | fpga_init(); |
| 70 | |
| 71 | for (i = 0; i < CONFIG_FPGA_COUNT; i++) { |
| 72 | fpga_add(fpga_lattice, &qong_fpga[i]); |
| 73 | } |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | #endif |