From patchwork Fri Aug 16 00:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11096665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D167912 for ; Fri, 16 Aug 2019 00:45:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F47721C9A for ; Fri, 16 Aug 2019 00:45:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 131AA286E6; Fri, 16 Aug 2019 00:45:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADC8421C9A for ; Fri, 16 Aug 2019 00:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbfHPAp2 (ORCPT ); Thu, 15 Aug 2019 20:45:28 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38527 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbfHPApK (ORCPT ); Thu, 15 Aug 2019 20:45:10 -0400 Received: by mail-wm1-f65.google.com with SMTP id m125so2705564wmm.3; Thu, 15 Aug 2019 17:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ImqyZJDmKPvgOe4k0V4FFzBk+8qBwZGqcDGc3TcKBm4=; b=DpqBbb9LSiCWuDGtMy63+9AFhO05ymfOJQyKegMfoWatYBvl23hnSK0JaA9bPlusNj VwL1lPiOTcsTLCaAMijXLX5pQJzISM/GJsy9vuGVBCLfDDLef90MEq5J6sZjr096RGnr 1JqyB/S4Li3WMMqwX8cjDIdiy/P6Z/qijmirUsBIWN20DoPnLazzg754k3koKuSAKpP7 T2UnmxqKCQeuz3HMafQOCNz8kGZoFGbdbfUY0dbcxh4WSV5/H7vpoH/QHfukYNedd3iL ZkENPOtFeimcOCbASj2I0ZIwOu71HDBbMXi028QrNArro5aC5b1wGG2dKJvCcKFwb1Cg 9KVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ImqyZJDmKPvgOe4k0V4FFzBk+8qBwZGqcDGc3TcKBm4=; b=dMyMtXCsLvFsmWj9H1liLg3QeFTt4pypPM3EWvzAeDxH8anUE4YipXh1IcYyu4W+UE 3Nyy2oOu/4D/kGSLICNKCrRnaV2aTAPMT57JhqKxWBP9AZNuJk8nXEAanKkNaNqLvf64 ebPpGMG84IPJvUh6EqwtAJGJUstcoFWpvKk/MZrir/DuC0DMsvpTlUHvZnW6FTzBT62l o4A7Jj6bc98d24HK2JkzeyBsIA6M09dXkNxK2XPrW80TDeSgsi1ElQSl+X3c4rrYwUdo KzZ8Xy9t96ou4iL06iqA8M8+FnvRvCEWlmELM9Hqyle/zyVIkrzv++Rqb8aFCh+oTjhA fycw== X-Gm-Message-State: APjAAAUMBaMMHhBPWJjmC/ZWKwqEO51V39hcUUZS2hc0zXs6iWZWZ9bA tsQylue0L4ySuFby1MSgH1U= X-Google-Smtp-Source: APXvYqwqYR8mIqlcj16RMrSY+eK8fzNxogZdvPaGEHisWmxRieq+yTXkHqb9tUTif5bu0f4XvrXwVg== X-Received: by 2002:a7b:cc0f:: with SMTP id f15mr501389wmh.39.1565916308462; Thu, 15 Aug 2019 17:45:08 -0700 (PDT) Received: from localhost.localdomain ([188.25.91.80]) by smtp.gmail.com with ESMTPSA id k124sm6451204wmk.47.2019.08.15.17.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 17:45:08 -0700 (PDT) From: Vladimir Oltean To: h.feurstein@gmail.com, mlichvar@redhat.com, richardcochran@gmail.com, andrew@lunn.ch, f.fainelli@gmail.com, broonie@kernel.org Cc: linux-spi@vger.kernel.org, netdev@vger.kernel.org, Vladimir Oltean Subject: [RFC PATCH net-next 06/11] spi: spi-fsl-dspi: Implement the PTP system timestamping Date: Fri, 16 Aug 2019 03:44:44 +0300 Message-Id: <20190816004449.10100-7-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190816004449.10100-1-olteanv@gmail.com> References: <20190816004449.10100-1-olteanv@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a snapshotting software feature for TCFQ and EOQ modes of operation. Due to my lack of proper understanding of the DMA mode, the latter mode is left as an exercise for future developers. Signed-off-by: Vladimir Oltean --- drivers/spi/spi-fsl-dspi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 41c45ee2bb2d..3fc266d8263a 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -184,6 +184,9 @@ struct fsl_dspi { int irq; struct clk *clk; + struct ptp_system_timestamp *ptp_sts; + const void *ptp_sts_word; + bool take_snapshot; struct spi_transfer *cur_transfer; struct spi_message *cur_msg; struct chip_data *cur_chip; @@ -658,6 +661,9 @@ static int dspi_rxtx(struct fsl_dspi *dspi) u16 spi_tcnt; u32 spi_tcr; + if (dspi->take_snapshot) + ptp_read_system_postts(dspi->ptp_sts); + /* Get transfer counter (in number of SPI transfers). It was * reset to 0 when transfer(s) were started. */ @@ -675,6 +681,11 @@ static int dspi_rxtx(struct fsl_dspi *dspi) /* Success! */ return 0; + dspi->take_snapshot = (dspi->tx == dspi->ptp_sts_word); + + if (dspi->take_snapshot) + ptp_read_system_prets(dspi->ptp_sts); + if (dspi->devtype_data->trans_mode == DSPI_EOQ_MODE) dspi_eoq_write(dspi); else @@ -764,6 +775,8 @@ static int dspi_transfer_one_message(struct spi_master *master, dspi->rx = transfer->rx_buf; dspi->rx_end = dspi->rx + transfer->len; dspi->len = transfer->len; + dspi->ptp_sts = transfer->ptp_sts; + dspi->ptp_sts_word = dspi->tx + transfer->ptp_sts_word_offset; /* Validated transfer specific frame size (defaults applied) */ dspi->bits_per_word = transfer->bits_per_word; if (transfer->bits_per_word <= 8) @@ -784,6 +797,11 @@ static int dspi_transfer_one_message(struct spi_master *master, SPI_FRAME_EBITS(transfer->bits_per_word) | SPI_CTARE_DTCP(1)); + dspi->take_snapshot = (dspi->tx == dspi->ptp_sts_word); + + if (dspi->take_snapshot) + ptp_read_system_prets(dspi->ptp_sts); + trans_mode = dspi->devtype_data->trans_mode; switch (trans_mode) { case DSPI_EOQ_MODE: