Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / misc / altera-stapl / altera-lpt.c
blob2b7d9cf415569868d8db1a953708cbb08f868602
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * altera-lpt.c
5 * altera FPGA driver
7 * Copyright (C) Altera Corporation 1998-2001
8 * Copyright (C) 2010 NetUP Inc.
9 * Copyright (C) 2010 Abylay Ospan <aospan@netup.ru>
12 #include <linux/io.h>
13 #include <linux/kernel.h>
14 #include "altera-exprt.h"
16 static int lpt_hardware_initialized;
18 static void byteblaster_write(int port, int data)
20 outb((u8)data, (u16)(port + 0x378));
23 static int byteblaster_read(int port)
25 int data = 0;
26 data = inb((u16)(port + 0x378));
27 return data & 0xff;
30 int netup_jtag_io_lpt(void *device, int tms, int tdi, int read_tdo)
32 int data = 0;
33 int tdo = 0;
34 int initial_lpt_ctrl = 0;
36 if (!lpt_hardware_initialized) {
37 initial_lpt_ctrl = byteblaster_read(2);
38 byteblaster_write(2, (initial_lpt_ctrl | 0x02) & 0xdf);
39 lpt_hardware_initialized = 1;
42 data = ((tdi ? 0x40 : 0) | (tms ? 0x02 : 0));
44 byteblaster_write(0, data);
46 if (read_tdo) {
47 tdo = byteblaster_read(1);
48 tdo = ((tdo & 0x80) ? 0 : 1);
51 byteblaster_write(0, data | 0x01);
53 byteblaster_write(0, data);
55 return tdo;