Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2998801ybl; Mon, 19 Aug 2019 10:30:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwP9LHnOFXb4Ru/fGCnsNVdJm+uNJZ3Zhs7YI7qPXaxDKFqcasGLPDkH+m3XWCgOL3JYwoP X-Received: by 2002:a17:902:7448:: with SMTP id e8mr23751657plt.85.1566235812945; Mon, 19 Aug 2019 10:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566235812; cv=none; d=google.com; s=arc-20160816; b=GZik2F0wBI6lybBz3dkweZWmvrGuoiMAPAPhcW4nmISfAIcdF6Z9dYkM6l5E62/MK2 EKEgC2SJBLq24M0BKqThI85aMQqa42i7r62iLpxMe/Sr0Snh5CfxCB7oomcw+PXGPsgG qiqgQbRBH1qfskxnccki4iJTggasndBYq88gmTjG9g4Dh3JMq0eys0vG1YKOJBJtL+P/ ncphlkUcexYqc6DWsdWgNFjkdLAA3ZtPTF3Ib7qPKSe38MuYygBExdr8kl3O1DYCGQZs ePbox0CwMjeUKXsQVGGd8VYxjVagASUEEU7Q053NCsxJsGKznA1SixwhAYyt92HtTcWf Rh1Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N4+pf5d7pVmnBlivGuHqKTTW2Rfxav1QD4GVn+SGku8=; b=C2tpEC6WLCYZQP6V7ZN1rFDEGPK7MQiy+N/1dr5w6iL0vt1HiRlsr0bHSgUKx2JrbA poVva7MA86SJY2lvpcMwzFBTnmfnT8aArIx5Bj39+IQ3WH60QYZmgHksAqLUnG9YV0Qh ISZKp0ZDhB+QBv4VQGgceiCybKTlofOExCjJ0uTz9CHzbA5+mxuZqj/9tggnXOaMqQ6f WuMBfNx7Ki70fZgHtQAovCVTY627oWlckhLd5gQN32kwcmvfom5sQSeCL999rCsh91To 2jNLRfGMgGEJeHZBv4mlqcR4o2MrHaHi/N9SYOLgejFq0JrHAeECBPqPlIHjjDD84TUx zPGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rB+i0qyl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si10218880plb.367.2019.08.19.10.29.58; Mon, 19 Aug 2019 10:30: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=pass header.i=@gmail.com header.s=20161025 header.b=rB+i0qyl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728214AbfHSR27 (ORCPT + 99 others); Mon, 19 Aug 2019 13:28:59 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34042 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfHSR2o (ORCPT ); Mon, 19 Aug 2019 13:28:44 -0400 Received: by mail-wm1-f66.google.com with SMTP id e8so511712wme.1; Mon, 19 Aug 2019 10:28:42 -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 :mime-version:content-transfer-encoding; bh=N4+pf5d7pVmnBlivGuHqKTTW2Rfxav1QD4GVn+SGku8=; b=rB+i0qylgMJQS7W6tIapfGXnwknLUgZSuLbNMFUO5e0mY9mi6LehXLYeQ7C3mPriH4 whXcuu7eAGt49zKShHlAgvFJ1XRBIiVz0kt46A8CXx2vZGTvbHHlfBIqPaPL65RQIyVR oSQhSq1QYb+sCIQht0/6YvF8jFqusSUf9CqGKcmpJkxzuznHJXTz8vKfK93dXq9wtSFa Tla2r5lNdRX9kqJRK8yFbc5WuRQws497J6xZM5QSCo0x61ZY93qkbiUhDOT6IEyeTweh iqFU76VYUaFuhL0tvdGfV6qUh4yuMGiYUcYlgCLseza4NiVq/5mIVi/b15a8oqx/CQiG 5ygw== 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:mime-version:content-transfer-encoding; bh=N4+pf5d7pVmnBlivGuHqKTTW2Rfxav1QD4GVn+SGku8=; b=WmSc7QzqcD9mFCqcmUmhXLYA9ZY9jFrMq+55iRUUGM4Jj6NJHtXaHLYFL2qSvnVz26 ElhXa99gEBVGQDc6xD/j5ZKTsHybNQZpwojyyMbXT8xG7Wtrnr30oR78UWDYVuQnYhoL ILvFiz73gE9DmBlfhPxzD75ZI2K5GY/0d12Nf5j15pkI6oITTDYQpt9NgXaOKsB9NAPL o6wIkTbSlqLO5ZcN4w6oKYrFjiqIp9vkaVaz5/VexIHZF8xmSKPPH4UPDsQTPg4lxUga 1i+kvh7D4jR7+rziuwmU3hIOsgwW2PF9tkgeJ0ScIQXviVPe6s8ROAxNjIDpEoCTDUa7 IkCw== X-Gm-Message-State: APjAAAWP6SH6GmTp27k9I0Zafz1aJlHO5d/26lcjTqAOJSaneFp3Qv/n glYTy65kl+mmgJqd3vVk67kgurMqhzs= X-Received: by 2002:a1c:9ec5:: with SMTP id h188mr21805675wme.176.1566235722008; Mon, 19 Aug 2019 10:28:42 -0700 (PDT) Received: from vd-lxpc-hfe.ad.vahle.at ([80.110.31.209]) by smtp.gmail.com with ESMTPSA id c15sm41983879wrb.80.2019.08.19.10.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 10:28:41 -0700 (PDT) From: Hubert Feurstein X-Google-Original-From: Hubert Feurstein To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hubert Feurstein , Andrew Lunn , Richard Cochran , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" Subject: [PATCH net-next v2 3/4] net: dsa: mv88e6xxx: extend PTP gettime function to read system clock Date: Mon, 19 Aug 2019 19:28:26 +0200 Message-Id: <20190819172827.9550-4-hubert.feurstein@vahle.at> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190819172827.9550-1-hubert.feurstein@vahle.at> References: <20190819172827.9550-1-hubert.feurstein@vahle.at> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hubert Feurstein This adds support for the PTP_SYS_OFFSET_EXTENDED ioctl. Signed-off-by: Hubert Feurstein --- drivers/net/dsa/mv88e6xxx/chip.h | 2 ++ drivers/net/dsa/mv88e6xxx/ptp.c | 11 +++++++---- drivers/net/dsa/mv88e6xxx/smi.c | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index a406be2f5652..1bfde0d8a5a3 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -275,6 +275,8 @@ struct mv88e6xxx_chip { struct ptp_clock_info ptp_clock_info; struct delayed_work tai_event_work; struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO]; + struct ptp_system_timestamp *ptp_sts; + u16 trig_config; u16 evcap_config; u16 enable_count; diff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c index 073cbd0bb91b..cf6e52ee9e0a 100644 --- a/drivers/net/dsa/mv88e6xxx/ptp.c +++ b/drivers/net/dsa/mv88e6xxx/ptp.c @@ -235,14 +235,17 @@ static int mv88e6xxx_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) return 0; } -static int mv88e6xxx_ptp_gettime(struct ptp_clock_info *ptp, - struct timespec64 *ts) +static int mv88e6xxx_ptp_gettimex(struct ptp_clock_info *ptp, + struct timespec64 *ts, + struct ptp_system_timestamp *sts) { struct mv88e6xxx_chip *chip = ptp_to_chip(ptp); u64 ns; mv88e6xxx_reg_lock(chip); + chip->ptp_sts = sts; ns = timecounter_read(&chip->tstamp_tc); + chip->ptp_sts = NULL; mv88e6xxx_reg_unlock(chip); *ts = ns_to_timespec64(ns); @@ -426,7 +429,7 @@ static void mv88e6xxx_ptp_overflow_check(struct work_struct *work) struct mv88e6xxx_chip *chip = dw_overflow_to_chip(dw); struct timespec64 ts; - mv88e6xxx_ptp_gettime(&chip->ptp_clock_info, &ts); + mv88e6xxx_ptp_gettimex(&chip->ptp_clock_info, &ts, NULL); schedule_delayed_work(&chip->overflow_work, MV88E6XXX_TAI_OVERFLOW_PERIOD); @@ -472,7 +475,7 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) chip->ptp_clock_info.max_adj = MV88E6XXX_MAX_ADJ_PPB; chip->ptp_clock_info.adjfine = mv88e6xxx_ptp_adjfine; chip->ptp_clock_info.adjtime = mv88e6xxx_ptp_adjtime; - chip->ptp_clock_info.gettime64 = mv88e6xxx_ptp_gettime; + chip->ptp_clock_info.gettimex64 = mv88e6xxx_ptp_gettimex; chip->ptp_clock_info.settime64 = mv88e6xxx_ptp_settime; chip->ptp_clock_info.enable = ptp_ops->ptp_enable; chip->ptp_clock_info.verify = ptp_ops->ptp_verify; diff --git a/drivers/net/dsa/mv88e6xxx/smi.c b/drivers/net/dsa/mv88e6xxx/smi.c index 282fe08db050..abedd04ff2ae 100644 --- a/drivers/net/dsa/mv88e6xxx/smi.c +++ b/drivers/net/dsa/mv88e6xxx/smi.c @@ -45,7 +45,8 @@ static int mv88e6xxx_smi_direct_write(struct mv88e6xxx_chip *chip, { int ret; - ret = mdiobus_write_nested(chip->bus, dev, reg, data); + ret = mdiobus_write_sts_nested(chip->bus, dev, reg, data, + chip->ptp_sts); if (ret < 0) return ret; -- 2.22.1