Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1143064ybl; Fri, 16 Aug 2019 09:33:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4jjQMcIgeiEcVGClKdW2yA5P2noASai5hbD+GBw6kdkj2nRMtlFqmFk8UpqiZOWuKSwmw X-Received: by 2002:a17:90a:f0c9:: with SMTP id fa9mr7188925pjb.137.1565973228775; Fri, 16 Aug 2019 09:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565973228; cv=none; d=google.com; s=arc-20160816; b=NWIdqaDrnnhhURf+pIN2YD4gFUXIJ93t4Bg8xI3b+nj5Bk0y9RuxxJaT7QXA3jrgrb 2ln4JlyHmlfLsfZ6hstnYIO3aA7+0jsjKyjYUbz3u3kKplyyNP/9ufmUvcejsIj3jtmB opGrmpGOsLuQWBewRa66v18BVogCYk0H3xJmy9vL3B90Jm+LCzFki+bC5lp6X8pvxhU6 8A7x5TYLFuCuUIB9PWOMXnEVMvIOkhY6zd9z5sMaiND0jc3UbNgHkAPOWgPTgXH0D3ip S8Z7Mx2uExzyH/K8l9WCu65tdNcUyV7doT6MQZYtZeNe2hf9L05myae0SmqvVJeeIo9s icUg== 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=24BWbn8DqPjln73B50K/6VPAlju0pIkRFKeVKAz9CKM=; b=prr3uN4Jus3nbCwwVTQTvM7CxPUrCXy4bci6LHTThhrGmFZxKxdlU12Im3/SDIXRCu RUVC3cFPJz3Jx7Oi5O4i3g3hZ22fV7uwG/9KklKPEnMBS1Q9UV/pYNWK5iQ3uKtnPwZ6 7/jpz47G9jFuvxsntBD2CpqIQz5rY8WS+aRlCYjL2Ak+sZwT23eFq9qHt/EVotB+bNG8 SOfNv8z6fhMM3IESR1qFbEswffPYHrugYSBe/XOzfvU75J2xnJ0+7jFHet79cb5IBnjn /vY8xvg2tRsZ+fP85BN5hHRM0PHPolvQ5w/kL2KUu+9oRpp3XwIqssDdhXLlMO5XO6rJ LzWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vX4d2umd; 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 d11si4424290pla.243.2019.08.16.09.33.33; Fri, 16 Aug 2019 09:33:48 -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=vX4d2umd; 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 S1727491AbfHPQc3 (ORCPT + 99 others); Fri, 16 Aug 2019 12:32:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46357 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727416AbfHPQc2 (ORCPT ); Fri, 16 Aug 2019 12:32:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id z1so2085812wru.13; Fri, 16 Aug 2019 09:32:26 -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=24BWbn8DqPjln73B50K/6VPAlju0pIkRFKeVKAz9CKM=; b=vX4d2umdOGrV+OmmupQOlzqpgTb/UHWiJKunbrTiNhBOHM6lFZ2jaMlbj1NKwWp+m8 cry1XXFBFJjwbOXKUrypnt/Zy5WAKLTGZ9+TLaIXpAfwfg+geIhtG3KryqoQwo+AY9KK iQdgkvJhsPM6harsWshTu6sbR5Nm7pyuDvAZZmPvAoM1mw/sz4/a6sZSwZkd809GXwVt ePfr44VXjy5ycW3Z5Z8kcvZuOAyYNnW+lo24C2SA0PN8q6YOyto0sw5QixQyjNTo4Kse Q6TGCHs/EwTGmVNI5J0AOwFIEtxi6S/ht98XnMYVnf7h6SeaC5yZKkA+L5kFT3W0K7N9 za1A== 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=24BWbn8DqPjln73B50K/6VPAlju0pIkRFKeVKAz9CKM=; b=IHgXLOhEi86hA1moIrh8ZUJpJdO6ySEX94u8sriVhYHHwb+L3BCHqueJu0UbPVLsYm yLEx6/gbOSgeFsLYL56mmtt8FSg4v0KxkmIwh44ouvO+vpmGjElMGgcbxcQDyQHW7y7d OBxHZ/04pBw1ImVLrwejeYP2j6qAJi/oPZncx5MAHqgoFPt3qIrJNIc/oKL3V56gg9Ie 2BRU/ey3wdJrwhMZvgBEi4pcN1/xYNmlWcxfnga4b/r3O7EmbF3/Wn4Aoq4GlWDP/vqv l6HZfUBXzB3NcPdP97cdQutWw0a74u2+GH7s4DVrB0dZuVhnIzVca2QnSkrbvGeemZx7 0cxg== X-Gm-Message-State: APjAAAUJuZ/7hjQk3qwoX8A8QEOi+jIZXAoz/3PxUypPnY8Mj2T7qvdb 5y9YDXsrBupQz8A6EoQmqwOoS3qhZQs= X-Received: by 2002:a5d:5591:: with SMTP id i17mr12014753wrv.280.1565973145937; Fri, 16 Aug 2019 09:32:25 -0700 (PDT) Received: from vd-lxpc-hfe.ad.vahle.at ([80.110.31.209]) by smtp.gmail.com with ESMTPSA id d19sm11031677wrb.7.2019.08.16.09.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 09:32:25 -0700 (PDT) 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 2/3] net: dsa: mv88e6xxx: extend PTP gettime function to read system clock Date: Fri, 16 Aug 2019 18:31:56 +0200 Message-Id: <20190816163157.25314-3-h.feurstein@gmail.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190816163157.25314-1-h.feurstein@gmail.com> References: <20190816163157.25314-1-h.feurstein@gmail.com> 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 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 01963ee94c50..9e14dc406415 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -277,6 +277,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 5fc78a063843..e3b0096a9d94 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