diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/staging/altera-stapl/altera-lpt.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/staging/altera-stapl/altera-lpt.c')
-rw-r--r-- | drivers/staging/altera-stapl/altera-lpt.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/staging/altera-stapl/altera-lpt.c b/drivers/staging/altera-stapl/altera-lpt.c new file mode 100644 index 00000000000..91456a03612 --- /dev/null +++ b/drivers/staging/altera-stapl/altera-lpt.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * altera-lpt.c | ||
3 | * | ||
4 | * altera FPGA driver | ||
5 | * | ||
6 | * Copyright (C) Altera Corporation 1998-2001 | ||
7 | * Copyright (C) 2010 NetUP Inc. | ||
8 | * Copyright (C) 2010 Abylay Ospan <aospan@netup.ru> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | */ | ||
25 | |||
26 | #include <linux/io.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include "altera-exprt.h" | ||
29 | |||
30 | static int lpt_hardware_initialized; | ||
31 | |||
32 | static void byteblaster_write(int port, int data) | ||
33 | { | ||
34 | outb((u8)data, (u16)(port + 0x378)); | ||
35 | }; | ||
36 | |||
37 | static int byteblaster_read(int port) | ||
38 | { | ||
39 | int data = 0; | ||
40 | data = inb((u16)(port + 0x378)); | ||
41 | return data & 0xff; | ||
42 | }; | ||
43 | |||
44 | int netup_jtag_io_lpt(void *device, int tms, int tdi, int read_tdo) | ||
45 | { | ||
46 | int data = 0; | ||
47 | int tdo = 0; | ||
48 | int initial_lpt_ctrl = 0; | ||
49 | |||
50 | if (!lpt_hardware_initialized) { | ||
51 | initial_lpt_ctrl = byteblaster_read(2); | ||
52 | byteblaster_write(2, (initial_lpt_ctrl | 0x02) & 0xdf); | ||
53 | lpt_hardware_initialized = 1; | ||
54 | } | ||
55 | |||
56 | data = ((tdi ? 0x40 : 0) | (tms ? 0x02 : 0)); | ||
57 | |||
58 | byteblaster_write(0, data); | ||
59 | |||
60 | if (read_tdo) { | ||
61 | tdo = byteblaster_read(1); | ||
62 | tdo = ((tdo & 0x80) ? 0 : 1); | ||
63 | } | ||
64 | |||
65 | byteblaster_write(0, data | 0x01); | ||
66 | |||
67 | byteblaster_write(0, data); | ||
68 | |||
69 | return tdo; | ||
70 | } | ||