From nobody Sat Jul 25 00:56:28 2026 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 443E832BF51; Tue, 21 Jul 2026 13:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640653; cv=none; b=pifwDOKYXnHgW3ajOXtqOLhFR6Y9M2rjKVZvMyFtK6eIBgb5Jpui5iFtsOpexloSEcgRQBnWKlN5qAvFdgkA8GSlkOSIjTOrUbDCqTmFIAXLKBzVxd8hdq2ghhLGSImkh/MO+TMMpIQ//gcxE5bG+M3rMSYMb5jbpuPjU9ntvI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640653; c=relaxed/simple; bh=hdm1z9iMsJlbjV+coDlihMkkeFDS2E0ooPl0hGi03XI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hrivxhZT544I20B4fEpKxIFCpF6pcPPTctlHjhllMdZWAxQdy4XNkd18Cn9504OhLyJwPYykWF3YxHiPm94KZ2as5ywEoP7n+7Hm6guLpKWiaPIQf8wsxtiijoDL/6VgIW0P7p+1NO0MlmmKRvHR1f2rDehIazRHNddBHXSI2bA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=2BtnBFF9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gobeB9h9; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="2BtnBFF9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gobeB9h9" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 64FEEEC01DF; Tue, 21 Jul 2026 09:30:50 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 21 Jul 2026 09:30:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1784640650; x=1784727050; bh=nBYhBomxIJce1ndUEXgHNoen1njZkz83h7XP6tFRSbw=; b= 2BtnBFF9Uvb70zv56W7Dtqi86bh52t0P3i7EQSxoz5oK2sOv3k1ZFU2cLCG91K68 8XEWaPHu7O8/JoW8LVc3mOk00FZNngvoxPa1gZr/6VExvE3hyHeiBm+ArriU9SHP b038ESeeefoKR4+z1nMguitNg6seJHt7eo1THB8ktYSaNjSEehmxxogB9gC80Q3A +gmHVKForyFAWYmpjAjP1Gq+JThNsMoKLnXbK4nqhkBQJi30Boav03exs931hozE 93hn5cNhP8NorXmjMztm4Zong07IGAdG+vJXaEcDCf0whMYhBvkBf7a26A3ro7LZ zV4zwqnwARTuSPLiD01C3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1784640650; x= 1784727050; bh=nBYhBomxIJce1ndUEXgHNoen1njZkz83h7XP6tFRSbw=; b=g obeB9h9IYWz39pabBbBNaZWYxqpiSvA7u2Tsta71lbbywEJuqT7ICgfdBdJZWUDi Om1Bs3c6Ruy5/ocls4kniYEuxFUOoRWG3QxDx+YZnQ//UsuTUCM6P86vVOIAbSpE Baw7VoUblnKF28xyQp/Or8SxJb5qgAK9GzFX+dJ4xdCVpaB7XwHYSCl1s8GqJ0m8 /bB5uEn7bcy8mMlQodw9y2DFSTN9+DlRnpXTer9T7pUpvPQEO+uFN6szIwTRfcb1 Y1lLo67tbjWtReT15OgBC+dnnqy4tHRsxJTEdN3K9uTHAkr8TGsAOJP62kye+Q4P aVc2NsJ7y7UN0HORKrGdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF575ZcECJFrMdyDOFXiBqlpXf0yhJc4wJMGRSk1x6GE76JbdZNoYn99qsG6N3LS7 USpQE+ZKunF24wrYSvawlBt8W4qEMWKfUSJTDnVEopJvF1+Q62r8MvTdfgpHsNvbNGrf1D vKpAOQ4I3FBNejt01hlSCxMBJSb2IVwTag8kF3nu1RLPuqjE5TxSJfHwK+Op9j9S83ygI6 ZgWIzHc6Kx6a/UZvErQchcOraZWT/TwGxDoAThTI3dmc16PbrH4O8objPTsteFmCRfv6rX Q4At1kl+MQqqzqG4Q9/mzL8gQuEkKgewxIcLI85kyIjyMpjV1vFmzivnzrUb7wggFcj9NH AY+NU/NZmKIrmwUJoYgYkgr9c+xX3Jt9iT5GQmaKy/oaalLXlwU/gd7GJmNpk3XkpOrE+r lJ2fQmAk+fQFBCeJ20L5pHGQHHDgcfEdi+d8vWP48uLD8iMiFPRk21jLn6luIGSgDGfKT3 uBl8sLfQ/mgtsz7HkTFCxmacNgD1+TZhQGnMtj+jpl5CGq13E0zdUZ6UyQ9M+l4o12A8ji zjbGZ3Z3yw4xwD7oM2Cz0fDDqaPmSobO/OirM+8y7YnntBrXPgZtLejyx9xtm5PFnp712d zGcngarlvnVt+Sr2piKUrZewrBpj7wSiFOUR5Su8K3QghCBrDhDwMT9ZV61w X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Jul 2026 09:30:49 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Krzysztof Kozlowski Subject: [PATCH net-next v5 1/3] dt-bindings: ptp: renesas,rcar-gen4-gptp: Add R-Car Gen4 Date: Tue, 21 Jul 2026 15:29:34 +0200 Message-ID: <20260721132936.1331318-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> References: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add bindings for the R-Car Gen4 gPTP timer. The timer enables accurate synchronization of the clock in the control system. The timer is system-wide and used by different Ethernet devices on each Gen4 platform. - On R-Car S4 it is shared between RSWITCH and RAVB. - On R-Car V4H it is shared between RTSN and RAVB. - On R-Car V4M it is only used by RAVB. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Krzysztof Kozlowski --- * Changes since v1 - Drop 'binding for' for patch subject. - Drop comment for renesas,rcar-gen4-gptp compatible to match other Renesas bindings. - Drop unused label in example. - Rename node ptp in example. --- .../bindings/ptp/renesas,rcar-gen4-gptp.yaml | 64 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/ptp/renesas,rcar-gen4= -gptp.yaml diff --git a/Documentation/devicetree/bindings/ptp/renesas,rcar-gen4-gptp.y= aml b/Documentation/devicetree/bindings/ptp/renesas,rcar-gen4-gptp.yaml new file mode 100644 index 000000000000..3edd64d40038 --- /dev/null +++ b/Documentation/devicetree/bindings/ptp/renesas,rcar-gen4-gptp.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +# Copyright (C) 2026 Renesas Electronics Corp. +# Copyright (C) 2026 Niklas S=C3=B6derlund +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/renesas,rcar-gen4-gptp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas R-Car Gen4 gPTP timer + +maintainers: + - Niklas S=C3=B6derlund + +description: + The R-Car Gen4 gPTP timer enables accurate synchronization of the clock = in + the control system. The timer is system-wide and used by different Ether= net + devices on each Gen4 platform. + + - On R-Car S4 it is shared between RSWITCH and RAVB. + - On R-Car V4H it is shared between RTSN and RAVB. + - On R-Car V4M it is only used by RAVB. + +properties: + compatible: + items: + - enum: + - renesas,r8a779f0-gptp # S4-8 + - renesas,r8a779g0-gptp # V4H + - renesas,r8a779h0-gptp # V4M + - const: renesas,rcar-gen4-gptp + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + +required: + - compatible + - reg + - clocks + - power-domains + - resets + +additionalProperties: false + +examples: + - | + #include + #include + + ptp@e6449000 { + compatible =3D "renesas,r8a779g0-gptp", "renesas,rcar-gen4-gpt= p"; + reg =3D <0xe6449000 0x500>; + clocks =3D <&cpg CPG_MOD 2723>; + power-domains =3D <&sysc R8A779G0_PD_ALWAYS_ON>; + resets =3D <&cpg 2723>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 6940aa3d498b..4e1c4ed038c5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22914,6 +22914,12 @@ S: Maintained F: Documentation/devicetree/bindings/mtd/renesas-nandc.yaml F: drivers/mtd/nand/raw/renesas-nand-controller.c =20 +RENESAS R-CAR GEN4 GPTP DRIVER +M: Niklas S=C3=B6derlund +L: linux-renesas-soc@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/ptp/renesas,rcar-gen4-gptp.yaml + RENESAS R-CAR GYROADC DRIVER M: Marek Vasut L: linux-iio@vger.kernel.org --=20 2.55.0 From nobody Sat Jul 25 00:56:28 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E35783672BF; Tue, 21 Jul 2026 13:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640656; cv=none; b=ON8WlcWjGrJOxCgjywA3uAG1v0TiKhjXUMIaQwqLMp89IJukcKsfkMD9p9vftxMRd/0Hmt5SfVBZiRYyuvHZweaObUQBfucAHdeWlk1+8y/S0gnBEYX6CI+4Mccq6FgoTfdQZs+BrNnR9YuwRu9NoqRuxha/kPBhk/on8EDY2wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640656; c=relaxed/simple; bh=TzsI65UIv2Q+dXETfAE7YMTPG9tK8D2HBUNEYZtYWC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u0SZ6zRje7CShDWr5toxp38U7A5TCdbRMCPZqqWD6anEwN2mAlL4XXkb+2Jcmih9loXUrrKlHOwa0r0P25ipsLQq0NMdXMuAiWH8MtdwcS/w7Xkjo6cE1ksjsasb3lQ8C3QmcgM3e9UjeleuFsSC1oCmKCdhw6jPV/tnXAFZOWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=lS7RHKOi; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=U5xE98AU; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="lS7RHKOi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="U5xE98AU" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 129D51400138; Tue, 21 Jul 2026 09:30:53 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Tue, 21 Jul 2026 09:30:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1784640653; x=1784727053; bh=ukHffcywcgJVKCTf46tEeRaEOkSD/6rYbBN3ueUycFQ=; b= lS7RHKOiFaKQca23sTVQ7bLcihWhkCgJtGhFdylTaPpHhjHy6iK8ltFCGfGTlghp jh6eHfa9BaES+mBEngBp9XZEWB4Cu0PQaLqL5GXFk3LOlpjZUaD9cRLNB+sREht0 z9Bk+z1l/GIm58VpJk7BlUb/9RL5CrA8evJwFjprT3b7eSGhEkBrk1S3TOlaSw4G YuKGHejxQHSZU66KI9L2CPPLHxB0VvOnRYpHKeyT2LxUq2kLa0m9h9eGDb+YN3eX /XivjJQV589PFZcAEBk8G9Zh2nOfbiehvZCXo2rLiHJfA7Nquf6hF+XRIvQIorWK 5nufMtaVLd70btK+ExPOEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1784640653; x= 1784727053; bh=ukHffcywcgJVKCTf46tEeRaEOkSD/6rYbBN3ueUycFQ=; b=U 5xE98AUz62OpWQK38rDZgAOaM0hUY9SLwazo9IN71UN6XJoCK34kRnwN0lwy1eZB Xo36g6st3+jM2OMXpU85l7VOqxdcgTfn5PESfFgBW7qea10bmrE0dRUX3+rrWL2G PWzOE/k5UpX9rlZMoqBkEl2RrZZM4FKa0KP6UIdtvXdwdoP/eZXbzOX0mPm2PvZx IgPNqJ7m+2L4ZbTnWZNIiUX5EcoNnPEyLUbLHof8DH2+T0HQ+vaD1RNsYKczlPMc MEv7JLuWdRYI9/DPR+vMTfRycai10kYO4LKIiLEjw1NjIEN64NmQKV6xkJ25vqG/ f9QciwGRku6wE4m98wuiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEO3WiW2LIZLndKegBRYU0lkj8LPXXrU7k/eTpMP6MrtWem9XD25WSFWTvj8a4EXg 7oDvcV+vOC3s5C4OOqoJrqtS+o4+j0lhZ8rSj7kzonTXQhMwUs0TJYkHFth4dAgSbspN1k 9hKP3SH9NQiB+80sbUry1B0r14t/x2fF89JheM81FigP81auMM1NND24BmsGmP0B+82Dnm +YIXsuwgIWXyUPB7Kh9Zn1oxdduKxHoFzyut8PXlZ3YPBYeWZ+xjCaPogk5m9/bD2jWCQj Fqoh5JnGuPvCmpzwCPXXaIPX1pdKfxb5AWLzDcBTapyX/R1lpznCzk//xJUVNJmn8jL1ti 2+cnC5syzB8/fuTif9yJ7mce7Y1iolhe1qgfWHEBQuu5CmCD+I2I8TyQ66pXWPCkx3/Q1I 6ak1VAZT2nh77bvrQoRSESWTaiTOM1YCbx4JHJFSPFFgjbDoeOmQdgKvBdMTPn1LU/eDoM Xv2sOCm3QaZCKdGqLevsI8zWnRSidagwcFNTz5skNFUPL7fcD9hMjtQchNeBQFyTehqq2E Uw3oDYOE4nudkbTrzhd841JAN4X5iepnUilyslWumBYq90UrL3nI7gMfHAICjRXrBysXIR UFC4QbXyxyDChhkQFj+Qn8liqa92Kr036o0fTAMeEA/6EK3dpUZlrqlvjxJg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Jul 2026 09:30:51 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 2/3] ptp: Add driver for R-Car Gen4 Date: Tue, 21 Jul 2026 15:29:35 +0200 Message-ID: <20260721132936.1331318-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> References: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add driver for the gPTP timer found on R-Car Gen4 devices. The timer is system-wide and shared by different Ethernet devices on each Gen4 platform. The operation of the timer is however not completely in depended of the systems Ethernet devices. - On R-Car S4 is gated by the RSWITCH Ethernet module clock. - On R-Car V4H is gated by the RTSN Ethernet module clock. - On R-Car V4M is gated by its own module clock, the system have neither RTSN or RSWITCH device. But the module clock is the same as RTSN on V4H and the documentation referees to it as tsn (EtherTSN). The gPTP device do have its own register space on all three platforms. But on S4 and V4H it will share its clock and reset property with RSWITCH or RTSN, respectively. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Vadim Fedorenko --- * Changes since v4 - Drop mod_devicetable.h include. - Remove clap of register value as .max_adj prevents any overflow. * Changes since v3 - Clamp increment calculated to register limitations. - Check return value of clk_get_rate(). - Disable PM if ptp_clock_register() fails. --- MAINTAINERS | 1 + drivers/ptp/Kconfig | 12 ++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_rcar_gen4.c | 225 ++++++++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+) create mode 100644 drivers/ptp/ptp_rcar_gen4.c diff --git a/MAINTAINERS b/MAINTAINERS index 4e1c4ed038c5..ed54ac3cf550 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22919,6 +22919,7 @@ M: Niklas S=C3=B6derlund L: linux-renesas-soc@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/ptp/renesas,rcar-gen4-gptp.yaml +F: drivers/ptp/ptp_rcar_gen4.c =20 RENESAS R-CAR GYROADC DRIVER M: Marek Vasut diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index b93640ca08b7..3593fd9da92a 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -263,4 +263,16 @@ config PTP_NETC_V4_TIMER synchronization. It also supports periodic output signal (e.g. PPS) and external trigger timestamping. =20 +config PTP_RCAR_GEN4 + tristate "Renesas R-Car Gen4 PTP Driver" + depends on ARCH_RENESAS || COMPILE_TEST + depends on PTP_1588_CLOCK + help + This driver adds support for using the Renesas R-Car Gen4 gPTP timer + as a PTP clock, the clock can then be used by Gen4 Ethernet drivers + for PTP time synchronization. + + To compile this driver as a module, choose M here: the module + will be called ptp_rcar_gen4. + endmenu diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile index bdc47e284f14..0464a586bed2 100644 --- a/drivers/ptp/Makefile +++ b/drivers/ptp/Makefile @@ -22,3 +22,4 @@ obj-$(CONFIG_PTP_1588_CLOCK_OCP) +=3D ptp_ocp.o obj-$(CONFIG_PTP_DFL_TOD) +=3D ptp_dfl_tod.o obj-$(CONFIG_PTP_S390) +=3D ptp_s390.o obj-$(CONFIG_PTP_NETC_V4_TIMER) +=3D ptp_netc.o +obj-$(CONFIG_PTP_RCAR_GEN4) +=3D ptp_rcar_gen4.o diff --git a/drivers/ptp/ptp_rcar_gen4.c b/drivers/ptp/ptp_rcar_gen4.c new file mode 100644 index 000000000000..8072d5f2b72d --- /dev/null +++ b/drivers/ptp/ptp_rcar_gen4.c @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Renesas R-Car Gen4 gPTP device driver + * + * Copyright (C) 2026 Renesas Electronics Corporation + * Copyright (C) 2026 Niklas S=C3=B6derlund + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define PTPTMEC_REG 0x0010 +#define PTPTMDC_REG 0x0014 +#define PTPTIVC0_REG 0x0020 +#define PTPTOVC00_REG 0x0030 +#define PTPTOVC10_REG 0x0034 +#define PTPTOVC20_REG 0x0038 +#define PTPGPTPTM00_REG 0x0050 +#define PTPGPTPTM10_REG 0x0054 +#define PTPGPTPTM20_REG 0x0058 + +struct ptp_rcar_gen4_priv { + void __iomem *base; + struct clk *clk; + + struct ptp_clock *clock; + struct ptp_clock_info info; + + spinlock_t lock; /* Registers access. */ + s64 default_addend; +}; + +#define ptp_to_priv(ptp) container_of(ptp, struct ptp_rcar_gen4_priv, info) + +static int ptp_rcar_gen4_adjfine(struct ptp_clock_info *ptp, long scaled_p= pm) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + s64 addend =3D priv->default_addend; + bool neg_adj =3D scaled_ppm < 0; + unsigned long flags; + s64 diff; + + if (neg_adj) + scaled_ppm =3D -scaled_ppm; + diff =3D div_s64(addend * scaled_ppm_to_ppb(scaled_ppm), NSEC_PER_SEC); + addend =3D neg_adj ? addend - diff : addend + diff; + + spin_lock_irqsave(&priv->lock, flags); + iowrite32(addend, priv->base + PTPTIVC0_REG); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static void _ptp_rcar_gen4_gettime(struct ptp_clock_info *ptp, + struct timespec64 *ts) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + + lockdep_assert_held(&priv->lock); + + ts->tv_nsec =3D ioread32(priv->base + PTPGPTPTM00_REG); + ts->tv_sec =3D ioread32(priv->base + PTPGPTPTM10_REG) | + ((s64)ioread32(priv->base + PTPGPTPTM20_REG) << 32); +} + +static int ptp_rcar_gen4_gettime(struct ptp_clock_info *ptp, + struct timespec64 *ts) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + _ptp_rcar_gen4_gettime(ptp, ts); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static void _ptp_rcar_gen4_settime(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + + lockdep_assert_held(&priv->lock); + + iowrite32(1, priv->base + PTPTMDC_REG); + iowrite32(0, priv->base + PTPTOVC20_REG); + iowrite32(0, priv->base + PTPTOVC10_REG); + iowrite32(0, priv->base + PTPTOVC00_REG); + iowrite32(1, priv->base + PTPTMEC_REG); + iowrite32(ts->tv_sec >> 32, priv->base + PTPTOVC20_REG); + iowrite32(ts->tv_sec, priv->base + PTPTOVC10_REG); + iowrite32(ts->tv_nsec, priv->base + PTPTOVC00_REG); +} + +static int ptp_rcar_gen4_settime(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + _ptp_rcar_gen4_settime(ptp, ts); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static int ptp_rcar_gen4_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ + struct ptp_rcar_gen4_priv *priv =3D ptp_to_priv(ptp); + struct timespec64 ts; + unsigned long flags; + s64 now; + + spin_lock_irqsave(&priv->lock, flags); + _ptp_rcar_gen4_gettime(ptp, &ts); + now =3D ktime_to_ns(timespec64_to_ktime(ts)); + ts =3D ns_to_timespec64(now + delta); + _ptp_rcar_gen4_settime(ptp, &ts); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static struct ptp_clock_info ptp_rcar_gen4_info =3D { + .owner =3D THIS_MODULE, + .name =3D "R-Car Gen4 gPTP", + .max_adj =3D 50000000, + .adjfine =3D ptp_rcar_gen4_adjfine, + .adjtime =3D ptp_rcar_gen4_adjtime, + .gettime64 =3D ptp_rcar_gen4_gettime, + .settime64 =3D ptp_rcar_gen4_settime, +}; + +static int ptp_rcar_gen4_probe(struct platform_device *pdev) +{ + struct ptp_rcar_gen4_priv *priv; + struct device *dev =3D &pdev->dev; + unsigned long rate; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, priv); + + priv->base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + priv->clk =3D devm_clk_get(dev, NULL); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); + + rate =3D clk_get_rate(priv->clk); + if (!rate) + return -ENODEV; + + spin_lock_init(&priv->lock); + + priv->info =3D ptp_rcar_gen4_info; + + /* Default timer increment in ns. + * bit[31:27] - integer + * bit[26:0] - decimal + * increment[ns] =3D perid[ns] * 2^27 =3D> (1ns * 2^27) / rate[hz] + */ + + priv->default_addend =3D div_s64(1000000000LL << 27, rate); + + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + + iowrite32(priv->default_addend, priv->base + PTPTIVC0_REG); + iowrite32(1, priv->base + PTPTMEC_REG); + + priv->clock =3D ptp_clock_register(&priv->info, dev); + if (IS_ERR(priv->clock)) { + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); + return PTR_ERR(priv->clock); + } + + return 0; +} + +static void ptp_rcar_gen4_remove(struct platform_device *pdev) +{ + struct ptp_rcar_gen4_priv *priv =3D platform_get_drvdata(pdev); + struct device *dev =3D &pdev->dev; + + ptp_clock_unregister(priv->clock); + + iowrite32(1, priv->base + PTPTMDC_REG); + + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); +} + +static const struct of_device_id ptp_rcar_gen4_of_match[] =3D { + { .compatible =3D "renesas,rcar-gen4-gptp", }, + { /* Sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, ptp_rcar_gen4_of_match); + +static struct platform_driver ptp_rcar_gen4_driver =3D { + .driver =3D { + .name =3D "ptp-rcar-gen4", + .of_match_table =3D ptp_rcar_gen4_of_match, + }, + .probe =3D ptp_rcar_gen4_probe, + .remove =3D ptp_rcar_gen4_remove, +}; +module_platform_driver(ptp_rcar_gen4_driver); + +MODULE_AUTHOR("Niklas S=C3=B6derlund"); +MODULE_DESCRIPTION("Renesas R-Car Gen4 gPTP driver"); +MODULE_LICENSE("GPL"); --=20 2.55.0 From nobody Sat Jul 25 00:56:28 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 454A7368264; Tue, 21 Jul 2026 13:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640657; cv=none; b=lIVLKjiYgeN55cAxSC36rkQR6BUZWQVgSyPDDb/7oC90FxUEDmYi3uFpetycWw0E/Bvk9a7A1P/x6kdEgIvS5EWyhod0W/Yk4j/nbCH6ZkRMs9aJgzcDUVrIP00TUCw19JvXIguC/L67CHdYYlhuEW49JbUxOhcMRYOqEsNZbYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784640657; c=relaxed/simple; bh=PpoJ8mSDeO5J500ag0sun37EeE6AvIqeZEsWDfHGEXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s4r2fmZBJZXLR+4MAedboJcXicGk+0wBHqnA4WChp+/tqSeY/6a6cJRbW0as768EVAvsnooxWPPz0oPIpKQEOhjJd2GNVcXJp7Z+bgQ10e7ju1XeYY5d4cMXkDCTCmtwRkk8DfrVVOOITA3B8CdvdUniwRykS+8/rUW6wSRAHMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=eYDWfoPQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Y4bG8ymx; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="eYDWfoPQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Y4bG8ymx" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5B3641400159; Tue, 21 Jul 2026 09:30:55 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 21 Jul 2026 09:30:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1784640655; x=1784727055; bh=sLmOrxWgSzKesbLl24YL8N9oK1UdIQD9gnT9tarZDw8=; b= eYDWfoPQh9R3Kibc06J7RGhh/IoxSBUWqh0k8XX5EvTvsJEIXPe6sfqcrr7Par2/ JuzlX/O0d1p6Uu8eR2Vs0UtTSVuYmMW2j8RaLvTtIDxPiauWV+DL4tNrtj0NEIee LManzSnd/0vu0i0nTqLyjhKY8rABBByBidBGYB2/sKZ1raevWuF2ZsEFkyId9LRI OMzQ9QdYJB5a84rvC1cdkrzxoQkQheARzj4MBL92asGS2D3MuvAtbyVk3gpm8xr9 LOhcPlV3Nz7d5Qou4PjMCIM2NDCeHQ1l6xb2Ra3E6Rvtld/BuQ/wiIaMug3w7hmJ 4ChDP1tsyYrifzyJwvjE1Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1784640655; x= 1784727055; bh=sLmOrxWgSzKesbLl24YL8N9oK1UdIQD9gnT9tarZDw8=; b=Y 4bG8ymxUVuDF3gD/cpLCsBo6gce8jJ0Ch9Y1+kPP9pFdj+y86xRCnjC3WWDhxbnA ssqCvs2vGpxJu/azdYNhM/JBzOzPUXjrhp+MGmUoh1zXQcxiUX2A1nS3phBLcKSW DAvHPRXHByEDV6vR5KROgUgU8E/YDvQ1cjpwF4xUCeANYu9vXI3mfdOkARUCMK8i En5EXfIMYuSoPzk+TA1RfLhjdqLlU61gZJ7IScz3hio/8zJS6Xb65Me2dlekEz+b 8oK0vpOSgSies6Cg01XzfaCJ51+Orge7FNS7Uhv34FQsXpCi7hPU/ILgP2wKd6My bs5WGAsri8D1P6N8zJnnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTErwjElEy8690l1ycSe3BvSXuBXSR0Jg1HpWthT0P2RPmGLUJJni6PIk9RkTYSob6 G91jjkTE2CSoFyKQK/b6DxQl0FA/SSSzTqZad3ZyC45OwiOumHjl/bWEJCM1isvpNRN/jY dovoY0jrlxkD/9i41qhlwKYMplntd2LQWiwi8wfXVm/OuBrBhY7CIUnKIYxPi+ICcEuDS0 LsH4PxP7uCIBRudSa+aIYl2ComCj/meCak5H/XXeOTop2i9TSM1aGRDpjvPerYIIIAt5L/ qfqQ6FGW7FhxDVq1M28/hpcY1fdPyWUpeiDu1kuxoiJyffvHKnW9Wf11GZ+nZYOfDh89O3 ODCbG36c9UxPTzHxbfOqmPQxs6fGt3nWeyAJoPDgyBImRscLHb8OFHPkXh92PzuTDBymTC SiCA7xWxX9keKHfh1qkeUtSTTWc9ihIAR/WPh9sMRQPf1kcoxjitABu1ra13fjlvti4TX5 ALzmZ1FfwC7nrj3YWXGSO6Pr28vjHP/xRUwt6rYp/bgsMZM0vgqvvU3eSH3zzjFix3rzR6 lDhXI2PjtHSn3P/yEyNFrbI9v+ctbCX7zmM/I2Gr0UmIpPF5DCvsCiIzePikUKL62vVwTd YIC0OjeiWhUPpk0TVWoNRTvh/MGXtBuBz4Fc5QBHwYSwRS/JNr3Ga5nrvgPw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Jul 2026 09:30:54 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 3/3] arm64: dts: renesas: r8a779g0: Add gPTP node Date: Tue, 21 Jul 2026 15:29:36 +0200 Message-ID: <20260721132936.1331318-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> References: <20260721132936.1331318-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The gPTP module is shared between the RAVB and RTSN Ethernet devices on the SoC. Signed-off-by: Niklas S=C3=B6derlund --- * Changes since v2 - Preserve sort order by unit-address. * Changes since v1 - Rename node ptp. --- arch/arm64/boot/dts/renesas/r8a779g0.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/r8a779g0.dtsi b/arch/arm64/boot/dt= s/renesas/r8a779g0.dtsi index 82a7278836e5..b9b860ef7035 100644 --- a/arch/arm64/boot/dts/renesas/r8a779g0.dtsi +++ b/arch/arm64/boot/dts/renesas/r8a779g0.dtsi @@ -589,6 +589,15 @@ tmu4: timer@ffc00000 { status =3D "disabled"; }; =20 + gptp: ptp@e6449000 { + compatible =3D "renesas,r8a779g0-gptp", "renesas,rcar-gen4-gptp"; + reg =3D <0 0xe6449000 0 0x500>; + clocks =3D <&cpg CPG_MOD 2723>; + power-domains =3D <&sysc R8A779G0_PD_ALWAYS_ON>; + resets =3D <&cpg 2723>; + status =3D "disabled"; + }; + tsn0: ethernet@e6460000 { compatible =3D "renesas,r8a779g0-ethertsn", "renesas,rcar-gen4-ethertsn= "; reg =3D <0 0xe6460000 0 0x7000>, --=20 2.55.0