From patchwork Mon May 28 12:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Shamray X-Patchwork-Id: 10432241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E786F601C7 for ; Mon, 28 May 2018 12:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D922E289DC for ; Mon, 28 May 2018 12:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDDEE28A6C; Mon, 28 May 2018 12:28:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33C45289DC for ; Mon, 28 May 2018 12:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=nbsmnJ1pPL1IK056PSQNOiXtQ4wb6dwQaEdgMLPvRas=; b=jInJFfzUSBdZEX5MPRz7EaRHvE Uc8MhtCprA799hZDrE6UxucA/ptR4gt8kci9Hm8xHKiu5p/PNpyWHipNXuxb4rSapVV3OMQtt5cMG zvxzFnhSd1VeLtmAoJPvUsS76uzfjvKHtmP6KzYxRpw6+fx5HNiU2sXb7jCnIhPbv6dT0+otv+Z2D li4CkL7SjTDE8yO6ebK5yWGqS7mUe1KcqzTDu7TOeK5lv/aq3dfTnxF4+Jv7WXQ3HVKpDbsP1Jz+N V8lOXBk8Jjt7YkKLrYgzTcyvnEy8tBcV/hi7w1LHQkkwBVQyGnMGj74YUlGPwA39clFZxxRdNYk0I SVVyd68A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNHGO-0000iA-Er; Mon, 28 May 2018 12:28:36 +0000 Received: from mail-il-dmz.mellanox.com ([193.47.165.129] helo=mellanox.co.il) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNHEk-000881-8l for linux-arm-kernel@lists.infradead.org; Mon, 28 May 2018 12:27:15 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from oleksandrs@mellanox.com) with ESMTPS (AES256-SHA encrypted); 28 May 2018 15:02:35 +0300 Received: from r-vnc16.mtr.labs.mlnx (r-vnc16.mtr.labs.mlnx [10.208.0.16]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w4SC0SdV023011; Mon, 28 May 2018 15:00:29 +0300 From: Oleksandr Shamray To: gregkh@linuxfoundation.org, arnd@arndb.de Subject: [patch v22 4/4] Documentation: jtag: Add ABI documentation Date: Mon, 28 May 2018 15:00:27 +0300 Message-Id: <1527508827-30724-5-git-send-email-oleksandrs@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1527508827-30724-1-git-send-email-oleksandrs@mellanox.com> References: <1527508827-30724-1-git-send-email-oleksandrs@mellanox.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180528_052654_762805_3E4B0E90 X-CRM114-Status: GOOD ( 15.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jiri@resnulli.us, system-sw-low-level@mellanox.com, linux-api@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, openocd-devel-owner@lists.sourceforge.net, robh+dt@kernel.org, joel@jms.id.au, linux-serial@vger.kernel.org, Oleksandr Shamray , tklauser@distanz.ch, mchehab@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Added document that describe the ABI for JTAG class drivrer Signed-off-by: Oleksandr Shamray Acked-by: Arnd Bergmann --- v21->v22 Comments pointed by Randy Dunlap - fix spell in ABI doccumentation v20->v21 Comments pointed by Randy Dunlap - Fix JTAG dirver help in Kconfig v19->v20 Comments pointed by Randy Dunlap - Fix JTAG doccumentation v18->v19 Pavel Machek - Added JTAG doccumentation to Documentation/jtag v17->v18 v16->v17 v15->v16 v14->v15 v13->v14 v12->v13 v11->v12 Tobias Klauser Comments pointed by - rename /Documentation/ABI/testing/jatg-dev -> jtag-dev - Typo: s/interfase/interface v10->v11 v9->v10 Fixes added by Oleksandr: - change jtag-cdev to jtag-dev in documentation - update KernelVersion and Date in jtag-dev documentation; v8->v9 v7->v8 v6->v7 Comments pointed by Pavel Machek - Added jtag-cdev documentation to Documentation/ABI/testing folder --- Documentation/ABI/testing/jtag-dev | 27 +++++++++ Documentation/jtag/overview | 28 +++++++++ Documentation/jtag/transactions | 109 ++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 4 files changed, 165 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/ABI/testing/jtag-dev b/Documentation/ABI/testing/jtag-dev new file mode 100644 index 0000000..4325316 --- /dev/null +++ b/Documentation/ABI/testing/jtag-dev @@ -0,0 +1,27 @@ +What: /dev/jtag[0-9]+ +Date: May 2018 +KernelVersion: 4.18 +Contact: oleksandrs@mellanox.com +Description: + The misc device files /dev/jtag* are the interface + between JTAG master interface and userspace. + + The ioctl(2)-based ABI is defined and documented in + [include/uapi]. + + The following file operations are supported: + + open(2) + The argument flag currently support only one access + mode O_RDWR. + + ioctl(2) + Initiate various actions. + See the inline documentation in [include/uapi] + for descriptions of all ioctls. + + close(2) + Stops and free up the I/O contexts that was associated + with the file descriptor. + +Users: TBD diff --git a/Documentation/jtag/overview b/Documentation/jtag/overview new file mode 100644 index 0000000..42b487a --- /dev/null +++ b/Documentation/jtag/overview @@ -0,0 +1,28 @@ +Linux kernel JTAG support +========================= + +The 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 hardware specific driver +User: close -> /dev/jatgX diff --git a/Documentation/jtag/transactions b/Documentation/jtag/transactions new file mode 100644 index 0000000..2abf833 --- /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. + +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. + +Open/Close device: +- jtag_fd = open("/dev/jtag0", O_RDWR); +- close(jtag_fd); + +ioctl() +------- +All access operations to JTAG devices performed through ioctl interface. +The IOCTL interface supports 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 hardware driver can support different running modes you can change it. + +Example: + unsigned int mode; + mode = JTAG_XFER_HW_MODE; + ioctl(jtag_fd, JTAG_SIOCMODE, &mode); diff --git a/MAINTAINERS b/MAINTAINERS index a5e5f75..e067eda 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7618,6 +7618,7 @@ F: include/linux/jtag.h F: include/uapi/linux/jtag.h F: drivers/jtag/ F: Documentation/devicetree/bindings/jtag/ +F: Documentation/ABI/testing/jtag-dev K10TEMP HARDWARE MONITORING DRIVER M: Clemens Ladisch