From patchwork Wed Sep 25 07:24:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aida Mynzhasova X-Patchwork-Id: 277722 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 45A5F2C040D for ; Wed, 25 Sep 2013 17:24:57 +1000 (EST) Received: from mail.skitlab.ru (mail.skitlab.ru [217.65.220.135]) by ozlabs.org (Postfix) with ESMTP id 4C6F72C00B8 for ; Wed, 25 Sep 2013 17:24:29 +1000 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.skitlab.ru (Postfix) with ESMTP id AE854106008D; Wed, 25 Sep 2013 11:24:25 +0400 (MSK) Received: from mail.skitlab.ru ([127.0.0.1]) by localhost (zimbra.skitlab.int [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id kcNPWzW0UHue; Wed, 25 Sep 2013 11:24:25 +0400 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.skitlab.ru (Postfix) with ESMTP id 05153106009B; Wed, 25 Sep 2013 11:24:25 +0400 (MSK) X-Virus-Scanned: amavisd-new at skitlab.ru Received: from mail.skitlab.ru ([127.0.0.1]) by localhost (zimbra.skitlab.int [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nl79ZBdkIuZp; Wed, 25 Sep 2013 11:24:24 +0400 (MSK) Received: from aida-desktop.skitlab.int (aida-desktop.skitlab.int [192.168.0.114]) by mail.skitlab.ru (Postfix) with ESMTPSA id C9228106008D; Wed, 25 Sep 2013 11:24:24 +0400 (MSK) From: Aida Mynzhasova To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2] powerpc/83xx: gianfar_ptp: select 1588 clock source through dts file Date: Wed, 25 Sep 2013 11:24:23 +0400 Message-Id: <1380093863-5388-1-git-send-email-aida.mynzhasova@skitlab.ru> X-Mailer: git-send-email 1.8.1.2 Cc: devicetree@vger.kernel.org, richardcochran@gmail.com, netdev@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16rc2 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Currently IEEE 1588 timer reference clock source is determined through hard-coded value in gianfar_ptp driver. This patch allows to select ptp clock source by means of device tree file node. For instance: fsl,cksel = <0>; for using external (TSEC_TMR_CLK input) high precision timer reference clock. Other acceptable values: <1> : eTSEC system clock <2> : eTSEC1 transmit clock <3> : RTC clock input When this attribute isn't used, eTSEC system clock will serve as IEEE 1588 timer reference clock. Signed-off-by: Aida Mynzhasova Acked-by: Richard Cochran --- Documentation/devicetree/bindings/net/fsl-tsec-phy.txt | 16 +++++++++++++++- drivers/net/ethernet/freescale/gianfar_ptp.c | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt index 2c6be03..eb06059 100644 --- a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt +++ b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt @@ -86,6 +86,7 @@ General Properties: Clock Properties: + - fsl,cksel Timer reference clock source. - fsl,tclk-period Timer reference clock period in nanoseconds. - fsl,tmr-prsc Prescaler, divides the output clock. - fsl,tmr-add Frequency compensation value. @@ -97,7 +98,7 @@ Clock Properties: clock. You must choose these carefully for the clock to work right. Here is how to figure good values: - TimerOsc = system clock MHz + TimerOsc = selected reference clock MHz tclk_period = desired clock period nanoseconds NominalFreq = 1000 / tclk_period MHz FreqDivRatio = TimerOsc / NominalFreq (must be greater that 1.0) @@ -114,6 +115,18 @@ Clock Properties: Pulse Per Second (PPS) signal, since this will be offered to the PPS subsystem to synchronize the Linux clock. + "fsl,cksel" property allows to select different reference clock + sources: + + <0> - external high precision timer reference clock (TSEC_TMR_CLK + input is used for this purpose); + <1> - eTSEC system clock; + <2> - eTSEC1 transmit clock; + <3> - RTC clock input. + + When this attribute is not used, eTSEC system clock will serve as + IEEE 1588 timer reference clock. + Example: ptp_clock@24E00 { @@ -121,6 +134,7 @@ Example: reg = <0x24E00 0xB0>; interrupts = <12 0x8 13 0x8>; interrupt-parent = < &ipic >; + fsl,cksel = <1>; fsl,tclk-period = <10>; fsl,tmr-prsc = <100>; fsl,tmr-add = <0x999999A4>; diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c index 098f133..e006a09 100644 --- a/drivers/net/ethernet/freescale/gianfar_ptp.c +++ b/drivers/net/ethernet/freescale/gianfar_ptp.c @@ -452,7 +452,9 @@ static int gianfar_ptp_probe(struct platform_device *dev) err = -ENODEV; etsects->caps = ptp_gianfar_caps; - etsects->cksel = DEFAULT_CKSEL; + + if (get_of_u32(node, "fsl,cksel", &etsects->cksel)) + etsects->cksel = DEFAULT_CKSEL; if (get_of_u32(node, "fsl,tclk-period", &etsects->tclk_period) || get_of_u32(node, "fsl,tmr-prsc", &etsects->tmr_prsc) ||