Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2338623imm; Wed, 16 May 2018 11:18:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrQF2J+Sa7TfUYba0Axw6qIbrWqL7G0ndSNFFZHrD/XAWZmO6QZXQu2KQDS56Qca+fn8ypz X-Received: by 2002:a63:bd09:: with SMTP id a9-v6mr1554582pgf.250.1526494693712; Wed, 16 May 2018 11:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526494693; cv=none; d=google.com; s=arc-20160816; b=M4Yp51vAkfA43xYmF98LJKpVEt5/ra5b7rMs1cqZsNyONt2g53UTMzpjVEWIvKOWIb P6SAhz/z4ClFA2QYYxMozVA6EhNW5I5eRvAvgoOYL8RMYyVmGrIV5sT/nWtD22etA6Sw 8A+0fmlZwR6AuI5sremu3r7G53cbyuMYJ8B0UNDdrK0rBG1DO31MMzR5NYBXbp71RW6F LfRb8x8bFZvkhXniG/n/V/xAcM0dYQhzEl6L4WnNAdBaG1V2+FAWFrCv2YWMXtTQC6A/ 05oArcQz5+NpD71GT52ZrAZHlfZ8PTmJn6p/9vKJCnm9AumNA/Z5x2EiHpSEkgftn/ZE wR7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=6Y6c67k9kyU5Q59nxU0aSYRDClWz6O8+lcVVx7dufFY=; b=pYEBcbf67I+LDhrtSclFjMNwwnrydUWvgpTaI5zYUrUGIewVC9magFk5feQLXZSnAs lqpZEVC73bKlrQkDoPZrIFszBnIvsijqvIxG0ddbRvMwc1uVdgudxVOQ5nCX+1KWvhIj NoXnTKo4h86ncZWhIeCAoPxA5ImMzgQ2QnOulh58OEadq9+cnVggrLcCI19hbiIrXOJa sn63UWNefn/TULvsMjg64qxADN50qkHEXOfOEwfrzsq8df3qLt7klWS3EAvg2SkTZUN+ GQ6D7qj4eev2PDoZzPXhxBvcnaKLFWjbVkBSd2dKFyBfolKl6A9NoLAB6Or6IpAEjpWW WAhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=G79USmIY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18-v6si3047626plr.265.2018.05.16.11.17.58; Wed, 16 May 2018 11:18:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=G79USmIY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbeEPSRQ (ORCPT + 99 others); Wed, 16 May 2018 14:17:16 -0400 Received: from merlin.infradead.org ([205.233.59.134]:48180 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533AbeEPSRO (ORCPT ); Wed, 16 May 2018 14:17:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6Y6c67k9kyU5Q59nxU0aSYRDClWz6O8+lcVVx7dufFY=; b=G79USmIYMJvPHEXFUJUX1DesO3 NBV6vqygR5ATW2BZeQwFDAe9eHTV+jKt95A2qL40ODfeb+4vNhtzcGh7AW1kWkAvHrb6R4gb4/vWw FiSgB+EoWPS/+PPGtaRUWsefdJg8+uwnyl8GaEfPjm35lNx86qgjXo9g7Tp7ZvypBl4OqVeQ9IJgR 2a6SqU2qrMhmwoKgB7SNojEU+kFNK6NNikvIUs5qTEV/Xa3TMUmnCah9VKbg9sFU9+rUB1z5t9fL0 44ZsNTp4hf4l4QwLrmlaHDVenqdRmAu4CLnO+mtsnjPerx3ae2bbZUxpa5gwzpt5ZHwpvjHPck7ch xSB88TyQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJ0yy-0002ik-SB; Wed, 16 May 2018 18:17:01 +0000 Subject: Re: [patch v21 4/4] Documentation: jtag: Add ABI documentation To: Oleksandr Shamray , gregkh@linuxfoundation.org, arnd@arndb.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, openbmc@lists.ozlabs.org, joel@jms.id.au, jiri@resnulli.us, tklauser@distanz.ch, linux-serial@vger.kernel.org, vadimp@mellanox.com, system-sw-low-level@mellanox.com, robh+dt@kernel.org, openocd-devel-owner@lists.sourceforge.net, linux-api@vger.kernel.org, davem@davemloft.net, mchehab@kernel.org References: <1526394095-5069-1-git-send-email-oleksandrs@mellanox.com> <1526394095-5069-5-git-send-email-oleksandrs@mellanox.com> From: Randy Dunlap Message-ID: <31c3b10e-7f8a-f997-4942-aed533d8801b@infradead.org> Date: Wed, 16 May 2018 11:16:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1526394095-5069-5-git-send-email-oleksandrs@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/15/2018 07:21 AM, Oleksandr Shamray wrote: > Added document that describe the ABI for JTAG class drivrer > > --- > Documentation/ABI/testing/jtag-dev | 27 +++++++++ > Documentation/jtag/overview | 28 +++++++++ > Documentation/jtag/transactions | 109 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 164 insertions(+), 0 deletions(-) > create mode 100644 Documentation/ABI/testing/jtag-dev > create mode 100644 Documentation/jtag/overview > create mode 100644 Documentation/jtag/transactions > > diff --git a/Documentation/jtag/overview b/Documentation/jtag/overview > new file mode 100644 > index 0000000..a86f188 > --- /dev/null > +++ b/Documentation/jtag/overview > @@ -0,0 +1,28 @@ > +Linux kernel JTAG support > +========================= > + > +The JTAG is an industry standard for verifying hardware JTAG is an industry standard for verifying hardware. > +JTAG provides access to many logic signals of a complex integrated circuit, > +including the device pins. > + > +A JTAG interface is a special interface added to a chip. > +Depending on the version of JTAG, two, four, or five pins are added. > + > +The connector pins are: > + TDI (Test Data In) > + TDO (Test Data Out) > + TCK (Test Clock) > + TMS (Test Mode Select) > + TRST (Test Reset) optional. > + > +JTAG interface is designed to have two parts - basic core driver and > +hardware specific driver. The basic driver introduces a general interface > +which is not dependent of specific hardware. It provides communication > +between user space and hardware specific driver. > +Each JTAG device is represented as a char device from (jtag0, jtag1, ...). > +Access to a JTAG device is performed through IOCTL calls. > + > +Call flow example: > +User: open -> /dev/jatgX > +User: ioctl -> /dev/jtagX -> JTAG core driver -> JTAG hw specific driver JTAG hardware specific driver > +User: close -> /dev/jatgX > diff --git a/Documentation/jtag/transactions b/Documentation/jtag/transactions > new file mode 100644 > index 0000000..6a857c8 > --- /dev/null > +++ b/Documentation/jtag/transactions > @@ -0,0 +1,109 @@ > +The JTAG API > +============= > + > +JTAG master devices can be accessed through a character misc-device. > +Each JTAG master interface can be accessed by using /dev/jtagN /dev/jtagN. > + > +JTAG system calls set: > +- SIR (Scan Instruction Register, IEEE 1149.1 Instruction Register scan); > +- SDR (Scan Data Register, IEEE 1149.1 Data Register scan); > +- RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified > +number of clocks. > + > +open(), close() > +------- > +open() opens JTAG device. Only one open operation per JTAG device > +can be performed. Two or more open for one device will return error will return error. > + > +Open/Close device: > +- open("/dev/jtag0", O_RDWR); > +- close(jtag_fd'); close(jtag_fd); > + > +ioctl() > +------- > +All access operations to JTAG devices performed through ioctl interface. > +The IOCTL interface supports this requests: these requests: > + JTAG_IOCRUNTEST - Force JTAG state machine to RUN_TEST/IDLE state > + JTAG_SIOCFREQ - Set JTAG TCK frequency > + JTAG_GIOCFREQ - Get JTAG TCK frequency > + JTAG_IOCXFER - send JTAG data Xfer > + JTAG_GIOCSTATUS - get current JTAG TAP status > + JTAG_SIOCMODE - set JTAG mode flags. > + > +JTAG_SIOCFREQ, JTAG_GIOCFREQ > +------ > +Set/Get JTAG clock speed: > + > + unsigned int jtag_fd; > + ioctl(jtag_fd, JTAG_SIOCFREQ, &frq); > + ioctl(jtag_fd, JTAG_GIOCFREQ, &frq); > + > +JTAG_IOCRUNTEST > +------ > +Force JTAG state machine to RUN_TEST/IDLE state > + > +struct jtag_run_test_idle { > + __u8 reset; > + __u8 endstate; > + __u8 tck; > +}; > + > +reset: 0 - run IDLE/PAUSE from current state > + 1 - go through TEST_LOGIC/RESET state before IDLE/PAUSE > +endstate: completion flag > +tck: clock counter > + > +Example: > + struct jtag_run_test_idle runtest; > + > + runtest.endstate = JTAG_STATE_IDLE; > + runtest.reset = 0; > + runtest.tck = data_p->tck; > + usleep(25 * 1000); > + ioctl(jtag_fd, JTAG_IOCRUNTEST, &runtest); > + > +JTAG_IOCXFER > +------ > +Send SDR/SIR transaction > + > +struct jtag_xfer { > + __u8 type; > + __u8 direction; > + __u8 endstate; > + __u8 padding; > + __u32 length; > + __u64 tdio; > +}; > + > +type: transfer type - JTAG_SIR_XFER/JTAG_SDR_XFER > +direction: xfer direction - JTAG_SIR_XFER/JTAG_SDR_XFER, > +length: xfer data len in bits > +tdio : xfer data array > +endstate: xfer end state after transaction finish > + can be: JTAG_STATE_IDLE/JTAG_STATE_PAUSEIR/JTAG_STATE_PAUSEDR > + > +Example: > + struct jtag_xfer xfer; > + static char buf[64]; > + static unsigned int buf_len = 0; > + [...] > + xfer.type = JTAG_SDR_XFER; > + xfer.tdio = (__u64)buf; > + xfer.length = buf_len; > + xfer.endstate = JTAG_STATE_IDLE; > + > + if (is_read) > + xfer.direction = JTAG_READ_XFER; > + else > + xfer.direction = JTAG_WRITE_XFER; > + > + ioctl(jtag_fd, JTAG_IOCXFER, &xfer); > + > +JTAG_SIOCMODE > +------ > +If hw driver can support different running modes you can change it. If hardware driver > + > +Example: > + unsigned int mode; > + mode = JTAG_XFER_HW_MODE; > + ioctl(jtag_fd, JTAG_SIOCMODE, &mode); > -- ~Randy