From patchwork Mon Jun 13 12:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12879530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 065B6CCA47B for ; Mon, 13 Jun 2022 13:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ub9X7us/Zo/05dZAcbyBgvZQYe761j3TgLMs/ncKjME=; b=yAAwR1IAX5LquN 7a6c2Nt/u85of2/UjJvXcKutBNGouOqIsnQTbGTbsaIaoayzvf6TtrenGYCASi600+SOjHWVlVHwt +5Kh0bSWD5dAF40TJQ1sO8EfGLLKtjlyPX0FDK9/EPdaiapQukYpHzWX/zhTtcrHNnJD4cOioTuXO CyVgICM0e1lRn2ppsxgEvK4C0rShX0vRyuA6kTL53HV89Nk184bw/FtF5pnF/0Q9IkzFzNYj3g7KM 9tG7ZwIVmx3npr6nEdSwiGp8yApPk1TOIyQ/TxM+tCvK4FJEDI00zymQzCWhOEEzICHJF5+J6GSYe b37kmULpLP/K09LytGPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jeo-003hTR-Ha; Mon, 13 Jun 2022 12:59:02 +0000 Received: from mail-dm6nam10on20626.outbound.protection.outlook.com ([2a01:111:f400:7e88::626] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jek-003hPr-MW for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2022 12:58:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZYhHLNSqQpbGxJoHzJXqWRSOUvxnoYg8bSGP554IV/UiuU9pSMrKJy96zHpG4E9NZBJIj9QfR1D+lWewk0iWjXhuxGlANTOJuaCk4VPuHTHTmSoQcuVRXAUuk3rTR72wwMRRuTd6eGciSeIkioWXQAazVlPQH3HzsGaz+4QrJNr95tkUi5JTS/KvrI0XfDeoKrVzAyH1BQQmpJbFOxiLglBDzpHbpwtIblpJ76RososX63VlXD1slRNroswsAbhLLUmFvNLiMKld45xGGWz6c+4zJV29dp15snWll/n1zQ6mG2mol7nSE6dRo8ARcXx/26q/q5vQkR5MoiusaIWlSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9M9XYx+1ZYRNmofc9ryGKkuwenpDUaE0ciZSljby7EE=; b=GdybdHgZyCio30EsYcQBuH97M0dtdUoRjKvkfFs6ZpY8tP3q4RuUxTxeVsZz5e87zEVcRDuessbYSdN3Iaj3/y2S0uF0tNYp3Ps1nXeu8WiAXwVaL14+k/URG89+ImjHgxkMvuCC1SX5CwUTv3hyGUCGR/Ho5npaIJ/qSOWhPjB9WCFyYxRlk3kokBZ+Fitw4en21lAhMsuedFx3VBuPkto/tRKZ5I/1dDB7OXTP0QB7TzfYxWVNqnsqfPX7Txz3dATknWt6n60aHB23z4H8pK5QIq7AmrPAfOUacVuOrTrJEoHZpYQGJEBYlsghfi6Ke+bFI5DLqphp1khHaEu4kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=towertech.it smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9M9XYx+1ZYRNmofc9ryGKkuwenpDUaE0ciZSljby7EE=; b=XcKEs7GDJac7mxFx9rcIx1Y5EGrRR8in+A9hSm2SMhoBWgaGo8XK6txiwlsyHCuYvfzo5Rcnj127loPoXPgdHlhJBThZRg4DWxeY1JzVRXKXXMI0qwQ4IFmZ+SVdoiwJFA6ODZWeMtYK8LybpyP2gIPQpqBQZzu3voAIH6kQZaY= Received: from SN7PR18CA0016.namprd18.prod.outlook.com (2603:10b6:806:f3::20) by CY4PR02MB2631.namprd02.prod.outlook.com (2603:10b6:903:70::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.16; Mon, 13 Jun 2022 12:58:49 +0000 Received: from SN1NAM02FT0063.eop-nam02.prod.protection.outlook.com (2603:10b6:806:f3:cafe::2f) by SN7PR18CA0016.outlook.office365.com (2603:10b6:806:f3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.20 via Frontend Transport; Mon, 13 Jun 2022 12:58:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0063.mail.protection.outlook.com (10.97.5.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5332.12 via Frontend Transport; Mon, 13 Jun 2022 12:58:49 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 13 Jun 2022 05:58:48 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 13 Jun 2022 05:58:48 -0700 Received: from [10.140.6.39] (port=42756 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o0jeZ-000DQD-DM; Mon, 13 Jun 2022 05:58:47 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , Srinivas Neeli Subject: [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information Date: Mon, 13 Jun 2022 18:28:34 +0530 Message-ID: <20220613125836.523449-1-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 999bab69-6414-43d2-a0d4-08da4d3c75ac X-MS-TrafficTypeDiagnostic: CY4PR02MB2631:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pWvZhUusqYupujCTjCjJT9leB4rLSftq3wR8/CCWqYdsicZ+T/D6BNul/LlTYagMqwRFGE9lfrp5NIDd5B9miJzywOS6z/i4UwZ0DO1MdqqNpwMJqnEd024xKRoEbd1ubmS8ye7CzgGG+mmiNqWyStBaZNACErU7Qx285Vs9Vynx2QtJOPYliFHYSNThtzBU8h+w8fsZmsPhQt1+s6LToG4KX+q+fbpkI46CPauQOixZqO57vTBcRZ3lqkYUE6x0dM3q7Ih9GYtbaMASGM13MtMdk2IIkreINASodS/dYavNobudrjMvrFSOg2JytXX8UUhj9bDzWbHLunadEGaggFUItjZOGhx0Tn0eKjnn7LBW1axw5kH+Qq8nuroyRjkzC3L8ArqF22CgwPoHBoH40BXaoj4PhYl+OtWF/EF6tL7Kr0rjYhL+OlBcQrd2+VBbv33KE5hj8VM/IKeiKyx2xjKJiMXzf6i0IvYRDGBptkn1wWKkxlS0EVyahrbVaLEuL4IeBZYCSEX54DMbobO0rba1gq97X8NiLmPh0KeczNdpHhDCbHpr9i4FXicnMe3JsWAyesgPk0zUllXz2V/MhNtiODvl2S915o+whvOtlgyJU65pPO6xjk1S81I6OeRsavCW/6g+YLuImqVUGqqofq9bM1mAHVvpx73/gTB5qv/DiA9TX/PoiosWHQAB5Bn5yGvBX2fkhAGsErJj6OsXQ/6kABQSQp3J6HpYpYCw//Y= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230016)(4636009)(46966006)(36840700001)(40470700004)(2906002)(8676002)(508600001)(4326008)(82310400005)(36860700001)(40460700003)(54906003)(316002)(110136005)(6666004)(70206006)(7696005)(70586007)(26005)(36756003)(2616005)(83380400001)(186003)(1076003)(426003)(47076005)(107886003)(336012)(9786002)(8936002)(356005)(7416002)(5660300002)(44832011)(7636003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2022 12:58:49.3189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 999bab69-6414-43d2-a0d4-08da4d3c75ac X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0063.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR02MB2631 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220613_055858_776281_7CF8A4A6 X-CRM114-Status: UNSURE ( 8.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Added clock information and deprecated calibration support. Signed-off-by: Srinivas Neeli Reviewed-by: Rob Herring --- Changes in V8: -None Changes in V7: -None Changes in V6: -Removed dtc warnings. Changes in V5: -Removed quotes and _clk suffix from clocknames. Changes in V4: - Deprecated calibrtion support Changes in V3: - New patch --- .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml index bdb72d3ddf2a..638dd1d8bb26 100644 --- a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml @@ -23,8 +23,15 @@ properties: reg: maxItems: 1 + clocks: + items: + - description: rtc_clk is the operating frequency of crystal. + + clock-names: + maxItems: 1 + interrupts: - minItems: 2 + maxItems: 2 interrupt-names: items: @@ -39,6 +46,7 @@ properties: minimum: 0x1 maximum: 0x1FFFFF default: 0x198233 + deprecated: true required: - compatible @@ -61,5 +69,7 @@ examples: interrupts = <0 26 4>, <0 27 4>; interrupt-names = "alarm", "sec"; calibration = <0x198233>; + clock-names = "rtc_clk"; + clocks = <&rtc_clk>; }; }; From patchwork Mon Jun 13 12:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12879532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53424C433EF for ; Mon, 13 Jun 2022 13:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WEjRRF45urhnEMlRHZ50OtlrMPzHVrIInALvCUNLIOQ=; b=QTKZgbWD7P6v5t t3W553E/P8hxT33+tpeZg6hi52MEP2Ylmc6GArtHPcZPwhjj2ffYezlh6mDHO6YCs0E/6L8cwx9rT 7Nu7b+GslXiP8RUjoAwhnCgfdBXQ2J7Yc5wY7OZckHGafbHdDB43BPoj/Pbgn/TyKOfhMqnDMUr9d WFHWW08y4Ap9y6RjvA0FwixlFjEUeJLbT9eOZfjuIx3mX8sAPqn7vHfCYvD8hVoAwhpu+m8Eoji7g ikgO4QtN8jg7q4RzHmJWK0czKuFE+7hMlumpxE3USr8CDhcSFvvRpwobptPH09T1buaFa2h7Trz5O zjcaDBwnQTwLnaZKxP0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jey-003hWz-3Y; Mon, 13 Jun 2022 12:59:12 +0000 Received: from mail-dm6nam11on20624.outbound.protection.outlook.com ([2a01:111:f400:7eaa::624] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jel-003hRo-5F for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2022 12:59:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1CTk+Ju0NGf5KXtoZtJSnFZm3paKSuvLMk+oIH7xyiOF7Fr9U/c2WRcscBn+BYycLmykAlodECfe/0xfUkEZQILlWt2kLHKSQKwtG9dCC0dFrPscVPGZ44hVRip+08ENz0gL7V4+zwHhZEOD20lNL8WSFoIMH/HiLY3K7fpqFGBMsOM+PBxsaDTmjxfIbdO3dRoUTNIf4YX5bbS73N5VU5mxIADilTeVYiFmZi4EwkRT9Egg4dZwENkIIyJhK0FeFQekM8e20Vu29XBI8jcfGBqoXt43+tzkJs7dgPI/HBXU3A8VDBHN+SEG2yRCCm/HdXHfFgfbYQ95gtKWtfSmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oTlqzVvSct2hAKYXLgvPTI5RDN0nVEvfBmEXKI7LaXI=; b=RR7k6cCaBYkicHUYGjEEz20HjaEJ6RBtWtw6IsGdliihM4AZZiMEWdhYeK7VApelNs6ZLkmc5npSlneC7v7sGyPGF02EufnutNZU1OJ9D0WqodfvxzirTqMor02xa140e6Yci+07U8wrfi5mtjJ59x2IuJPDzu1ruBBToCSGjYVuKzru2tt/2wWb0up8XI5GKP40uSEeGidslXbO1r0GVc5ySfO19sIfoR60Xkh7NZw6St19rJ+2Whlr6T4BHxGIMMyEgLRrKsnzSxsl6Qz0vBRvp+l2gz7GnIMDsq9v+G/WKUSxvTjnp3JhlfnhjQ01nV62BD1hmOztQ1PEGdrBvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=towertech.it smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oTlqzVvSct2hAKYXLgvPTI5RDN0nVEvfBmEXKI7LaXI=; b=ijlSLSwxJCQWqQemiFK8P0ZV4iAA/PP00GBzlpU3+7OhtMImDn34+im5+vSCo5QtdFIeI4j2x0dvVseIQsyAIa7AUsayymeEPwEzcxjAkJJqjF4QrsvFtrqsmm7RCHGhmgLBfkx/O7qT23cCyY4NaoqnJMQ9QoddMusMcihubnk= Received: from SA9PR13CA0043.namprd13.prod.outlook.com (2603:10b6:806:22::18) by BL3PR02MB9036.namprd02.prod.outlook.com (2603:10b6:208:3bf::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.20; Mon, 13 Jun 2022 12:58:53 +0000 Received: from SN1NAM02FT0022.eop-nam02.prod.protection.outlook.com (2603:10b6:806:22:cafe::26) by SA9PR13CA0043.outlook.office365.com (2603:10b6:806:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.5 via Frontend Transport; Mon, 13 Jun 2022 12:58:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0022.mail.protection.outlook.com (10.97.5.0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5332.12 via Frontend Transport; Mon, 13 Jun 2022 12:58:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 13 Jun 2022 05:58:52 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 13 Jun 2022 05:58:52 -0700 Received: from [10.140.6.39] (port=42756 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o0jed-000DQD-EH; Mon, 13 Jun 2022 05:58:51 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , Srinivas Neeli Subject: [PATCH V8 2/3] rtc: zynqmp: Updated calibration value Date: Mon, 13 Jun 2022 18:28:35 +0530 Message-ID: <20220613125836.523449-2-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613125836.523449-1-srinivas.neeli@xilinx.com> References: <20220613125836.523449-1-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8e132a4-3f1e-464c-8f2c-08da4d3c7827 X-MS-TrafficTypeDiagnostic: BL3PR02MB9036:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ejfQlDC8XFf8jl1pWfq9FvWEblfJagod/mdBXoiv1whR1sL3AGfZQioiU3e3Dho6JWn1Q29yZoTAdfOXGmCkjvd1PSVJ0MeZ2JCZ+iAZCuvE5brOfzabohTI3bLUMHM9iS2GYbF1E5tlBiz/eXE5fYAirqHn4Cj7Wh9CuS/Z7nBU2+/NvA8MYBnEHY86tihNJYQ9lAl25nkuevQVfAObuNKqDTDxKn6toD7AeTzB8xPj6wNP7+v4/YVhjnSjPCyrjusC2azJUbqc5nqv258jY+Cu7Za3kHwD3Ct/ZdGbL2Qf06jMZh1UmsZwA2JO6UVY8Gk0fRzvCt64G5uEMFgg5eM0rlx12FKAZQIZUkEMFWljzLay5wEsJ5UxLNrfvuUIOQCxo7Wn9Wt70b7fYHQYMq1f4uwPmIUe/lY71UchdPZW/gLkQlPI8kOVmEa73B5vjW0RyH36YAYt5l3RsNKRd1knamlJPqgkCITuQ83s9F5kmp+Oj3GXE5RK6I0gUJ8P/tOekvIxY3ihMHpv0T4Y4vx4iW6DfAn763osh4fhG9/yrfogAlikOixhVmwkN/jBvmEUi5Ff9J6lHxQp5qqIGP4kixCuFjt5dRgdAajAfstagCGLMDAfC1dIzgGJjIg4OkFpwdk5t5nTj/GjsvdB23sqU078BvWMmS1j2DZhS/guGzHTCFBFNhAxfl24U4qXty3eJyYyQnjlNElTeUx7AiGaMGwjylc9y/geSdGjNvc= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230016)(4636009)(40470700004)(46966006)(36840700001)(110136005)(82310400005)(54906003)(508600001)(6666004)(4744005)(2906002)(7416002)(15650500001)(44832011)(9786002)(316002)(8936002)(70586007)(5660300002)(8676002)(4326008)(70206006)(7636003)(36756003)(40460700003)(356005)(7696005)(336012)(1076003)(107886003)(426003)(83380400001)(2616005)(47076005)(186003)(36860700001)(26005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2022 12:58:53.4800 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8e132a4-3f1e-464c-8f2c-08da4d3c7827 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0022.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB9036 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220613_055859_238951_60A2A021 X-CRM114-Status: UNSURE ( 8.37 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As per RTC spec default calibration value is 0x7FFF. Signed-off-by: Srinivas Neeli Acked-by: Peter Korsgaard --- Changes in V8 -None, just swapped 2/3 and 3/3 patches from V7. Changes in V7: -New patch -TRM not updated yet, Internal design document contains 0x7FFF as default value. TRM Will update in next release. --- drivers/rtc/rtc-zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index f440bb52be92..5da33d760419 100644 --- a/drivers/rtc/rtc-zynqmp.c +++ b/drivers/rtc/rtc-zynqmp.c @@ -36,7 +36,7 @@ #define RTC_OSC_EN BIT(24) #define RTC_BATT_EN BIT(31) -#define RTC_CALIB_DEF 0x198233 +#define RTC_CALIB_DEF 0x7FFF #define RTC_CALIB_MASK 0x1FFFFF #define RTC_ALRM_MASK BIT(1) #define RTC_MSEC 1000 From patchwork Mon Jun 13 12:58:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12879531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D376C43334 for ; Mon, 13 Jun 2022 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H1+a8JUfc5VQZ4Jd9G1Uya1E9YtuJYnJ8j4/elv3EZI=; b=MyBm4qjA8zx1p4 I9cYQ7xNHY6FjtXL9PVO0A7JvUe3StrC/58Dlw4Lomc5kz6sawlf3yo9EiDk/IjVx5duK8Se9rKL1 M2vhV8Xh/+2CUgFHURVbERutRDKstLkx1sAbx+Nrq5F9qzb/8YyuhLauMBXZBW3fgVBp9LGDFmTB8 NL59zUbAws55MMi97LDQtHdO+DEiXw9G/lMYqyGE2DHaKqjgIRUgQ6tAV90km/hjOGzWvDTs6aJ8k 4+AIguia3zuf2rF2GKnNt979BUMsbXUHOsswMrOL2z7FQsI1nGozZqMSEBTljLnAFXGeTjvD4kPmi mVg7Bf5yXuhxqMXs14fQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jf7-003hZY-OT; Mon, 13 Jun 2022 12:59:21 +0000 Received: from mail-dm6nam04on2062a.outbound.protection.outlook.com ([2a01:111:f400:7e8b::62a] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0jer-003hTh-4d for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2022 12:59:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UEDajzxOe6Mfd7kcAxOajq17WUlXjR52h9VqdNGQKFLyGNp5othdgvSvwVnsClHGPbEs4rAdr6qRf6vXDqb73trI8yx/ANcnAT5eHdoDWtJ36fwUofRwXQADdr9h2QixVgBnxkrpVrIoLD249BO32MC0kZ+8NvpGGdR5tRne9uAxGHCOg9agc1Ti8DhMCvtxeDJnHwvp6wrLOELOEy43P2lczXN1L9oLLOtWbtj2sbRJTYQEQAUs8t8g/zVtIV82+CDK4jabccdg0Di8vlGZosUYSb8tQ/lDDZjZCH/WfJ8Pe8LHDHP7Pyb4COv4+nXWeAvBIOT9E63OWlpa+q7nEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Cg+w8PwkOw7z7uBhPOsgvtIn1Cknp9Y+Ab+78xHNqNw=; b=XueDRmuM0gwBvd89H8jEMso4xgVCY/AZLk6vpFM4NqDfZexzc2QfaeyQzlLs+u4cMcabjak8uwxB4FvC3IALRSvBQ2VWJjUk/cuwKJxUj8DuAAkRrt/+fk+wy5OQxfrDy/wxUyR9UhVkUdUP1f9XRB5Tg6c6CcTH4R1tt9vE3PcIEyfiBbx5jlIHudN6o1UGVzOloUiS9in08pSFj7/AkrxWnBdgCem7DIB/XxSbXfg9xni1uI7p/wZGS3fer9HGWtJe9EvXRUixa+Hzkopvtc/dbZzadahbm+I+YP5SL1tSYexk0LXqF7YWXj1WZENrr74YbQsfZkVOS0g/MXxidw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=towertech.it smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cg+w8PwkOw7z7uBhPOsgvtIn1Cknp9Y+Ab+78xHNqNw=; b=sewWxInpCEQwHXWqNsIo6X+szeOhMhjAuT1H8E1sVd5X3DwIw0PmJXOHM+jJKruq7zrSp1H7QMQZaOJCQkEa4Wxcn8nHwGLe20JP+RoOoKwzNwgQVNb9FSe5b0M29oUZ3nsaBAvRVqPEf7BW/L3sP5i5PRXXslpl1Fy9zDdMzqY= Received: from SA1P222CA0038.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::19) by BYAPR02MB5031.namprd02.prod.outlook.com (2603:10b6:a03:6f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Mon, 13 Jun 2022 12:59:00 +0000 Received: from SN1NAM02FT0055.eop-nam02.prod.protection.outlook.com (2603:10b6:806:2d0:cafe::44) by SA1P222CA0038.outlook.office365.com (2603:10b6:806:2d0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13 via Frontend Transport; Mon, 13 Jun 2022 12:59:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0055.mail.protection.outlook.com (10.97.5.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5332.12 via Frontend Transport; Mon, 13 Jun 2022 12:59:00 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 13 Jun 2022 05:58:56 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 13 Jun 2022 05:58:56 -0700 Received: from [10.140.6.39] (port=42756 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o0jeh-000DQD-FG; Mon, 13 Jun 2022 05:58:55 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , Srinivas Neeli Subject: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support Date: Mon, 13 Jun 2022 18:28:36 +0530 Message-ID: <20220613125836.523449-3-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613125836.523449-1-srinivas.neeli@xilinx.com> References: <20220613125836.523449-1-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8205b8f2-5e87-4129-eef3-08da4d3c7c3e X-MS-TrafficTypeDiagnostic: BYAPR02MB5031:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X3iqHZOvPSuAPWZ+HMbNCnr9IaXHp8uk0Kc7Az08auKXqPhRXuHrPENiFqxv3VmXYP0eCMkJY5qbRd0OyhtA7Of0n9arRYc+90OAlxvrILWUkkmRrA5FJwyPhjAGniGxlBOfG+ixAG3ynDCkrELypIE8DI/Qqz+NbkNS7sTBik9tY6+yQgwccqArWPv9Jn7lt7kQ4g97uXpYQF6o68mKJijL83yd1Onxx2+ppywgiVhDNBHAvzb8j2dFKbu1w3w+Wf6j2gG1jxA77S49h/bg7iSPdNQX0KzfsManAuUi97p5Oe6Vd8iPIrje6rl0Ek/muia5xNdgiINhE7RAundMHo/0s5ZK2J3mfqWOUhAvr17Kvo19XnyY5GGIOynRUsMAVbFWCSJy/46ae3wJKIRF71ZzfusvRoXIjBmC/9Vbw2Q06UOHYGcoIYS2dYn23zxwnXilr8ha7rxV7+OG9rpai1IXIOem3cGrYv9Ip1H2X7YpN4AXQnZr5rlhKHgqLGoSc42dQLc4Ww2I70p2Hpvc5+1TKHH/QG19gmrwsNKwNgKLjKB3Q5lpjoBiPUCfQZaQNXDRuD/2r+pwLFa3PguoGsmO0pWDWFS60bTih9WfyGa22gtHKleIuAUnAp5RRRjr2/nsY7q7yQJZ7eXPc9QOQrwPr/4hV+P2AJ+NucAdBiusybjI32P0RUEnpu2I48PPI0517FK5VUPqPO5hcua8jkYFWhHIzOQFzWRaNnBJ+3I= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230016)(4636009)(40470700004)(46966006)(36840700001)(44832011)(110136005)(186003)(82310400005)(26005)(6666004)(54906003)(1076003)(426003)(7696005)(2616005)(316002)(7416002)(40460700003)(47076005)(336012)(107886003)(508600001)(5660300002)(2906002)(70586007)(8936002)(70206006)(8676002)(4326008)(9786002)(83380400001)(36756003)(7636003)(36860700001)(356005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2022 12:59:00.3284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8205b8f2-5e87-4129-eef3-08da4d3c7c3e X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0055.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5031 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220613_055905_235299_32AB2D87 X-CRM114-Status: GOOD ( 21.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Zynqmp RTC controller has a calibration feature to compensate time deviation due to input clock inaccuracy. Set and get calibration API's are used for setting and getting calibration value from the controller calibration register. Signed-off-by: Srinivas Neeli --- Changes in V7: -Removed calibration default value update from this patch. Changes in V6: -None Changes in V5: -None Changes in V4: -Updated MIN and MAX calibration values. Changes in V3: -Calculated tick_mult using crystal frequency. -Calibration register updating based on crystal frequency in probe. -Supressed MIN an MAX calibration values,Will send separate patch in future. Changes in V2: -Removed unused macro. -Updated code with review comments. --- drivers/rtc/rtc-zynqmp.c | 113 ++++++++++++++++++++++++++++++++------- 1 file changed, 94 insertions(+), 19 deletions(-) diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index 5da33d760419..1dd389b891fe 100644 --- a/drivers/rtc/rtc-zynqmp.c +++ b/drivers/rtc/rtc-zynqmp.c @@ -6,6 +6,7 @@ * */ +#include #include #include #include @@ -40,13 +41,19 @@ #define RTC_CALIB_MASK 0x1FFFFF #define RTC_ALRM_MASK BIT(1) #define RTC_MSEC 1000 +#define RTC_FR_MASK 0xF0000 +#define RTC_FR_MAX_TICKS 16 +#define RTC_PPB 1000000000LL +#define RTC_MIN_OFFSET -32768000 +#define RTC_MAX_OFFSET 32767000 struct xlnx_rtc_dev { struct rtc_device *rtc; void __iomem *reg_base; int alarm_irq; int sec_irq; - unsigned int calibval; + struct clk *rtc_clk; + unsigned int freq; }; static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm) @@ -61,13 +68,6 @@ static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm) */ new_time = rtc_tm_to_time64(tm) + 1; - /* - * Writing into calibration register will clear the Tick Counter and - * force the next second to be signaled exactly in 1 second period - */ - xrtcdev->calibval &= RTC_CALIB_MASK; - writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR)); - writel(new_time, xrtcdev->reg_base + RTC_SET_TM_WR); /* @@ -173,15 +173,76 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev) rtc_ctrl = readl(xrtcdev->reg_base + RTC_CTRL); rtc_ctrl |= RTC_BATT_EN; writel(rtc_ctrl, xrtcdev->reg_base + RTC_CTRL); +} - /* - * Based on crystal freq of 33.330 KHz - * set the seconds counter and enable, set fractions counter - * to default value suggested as per design spec - * to correct RTC delay in frequency over period of time. +static int xlnx_rtc_read_offset(struct device *dev, long *offset) +{ + struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev); + unsigned long long rtc_ppb = RTC_PPB; + unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq); + unsigned int calibval; + long offset_val; + + calibval = readl(xrtcdev->reg_base + RTC_CALIB_RD); + /* Offset with seconds ticks */ + offset_val = calibval & RTC_TICK_MASK; + offset_val = offset_val - RTC_CALIB_DEF; + offset_val = offset_val * tick_mult; + + /* Offset with fractional ticks */ + if (calibval & RTC_FR_EN) + offset_val += ((calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT) + * (tick_mult / RTC_FR_MAX_TICKS); + *offset = offset_val; + + return 0; +} + +static int xlnx_rtc_set_offset(struct device *dev, long offset) +{ + struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev); + unsigned long long rtc_ppb = RTC_PPB; + unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq); + unsigned char fract_tick; + unsigned int calibval; + short int max_tick; + int fract_offset; + + if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET) + return -ERANGE; + + /* Number ticks for given offset */ + max_tick = div_s64_rem(offset, tick_mult, &fract_offset); + + /* Number fractional ticks for given offset */ + if (fract_offset) { + if (fract_offset < 0) { + fract_offset = fract_offset + tick_mult; + max_tick--; + } + if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) { + for (fract_tick = 1; fract_tick < 16; fract_tick++) { + if (fract_offset <= + (fract_tick * + (tick_mult / RTC_FR_MAX_TICKS))) + break; + } + } + } + + /* Zynqmp RTC uses second and fractional tick + * counters for compensation */ - xrtcdev->calibval &= RTC_CALIB_MASK; - writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR)); + calibval = max_tick + RTC_CALIB_DEF; + + if (fract_tick) + calibval |= RTC_FR_EN; + + calibval |= (fract_tick << RTC_FR_DATSHIFT); + + writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR)); + + return 0; } static const struct rtc_class_ops xlnx_rtc_ops = { @@ -190,6 +251,8 @@ static const struct rtc_class_ops xlnx_rtc_ops = { .read_alarm = xlnx_rtc_read_alarm, .set_alarm = xlnx_rtc_set_alarm, .alarm_irq_enable = xlnx_rtc_alarm_irq_enable, + .read_offset = xlnx_rtc_read_offset, + .set_offset = xlnx_rtc_set_offset, }; static irqreturn_t xlnx_rtc_interrupt(int irq, void *id) @@ -255,10 +318,22 @@ static int xlnx_rtc_probe(struct platform_device *pdev) return ret; } - ret = of_property_read_u32(pdev->dev.of_node, "calibration", - &xrtcdev->calibval); - if (ret) - xrtcdev->calibval = RTC_CALIB_DEF; + /* Getting the rtc_clk info */ + xrtcdev->rtc_clk = devm_clk_get_optional(&pdev->dev, "rtc_clk"); + if (IS_ERR(xrtcdev->rtc_clk)) { + if (PTR_ERR(xrtcdev->rtc_clk) != -EPROBE_DEFER) + dev_warn(&pdev->dev, "Device clock not found.\n"); + } + xrtcdev->freq = clk_get_rate(xrtcdev->rtc_clk); + if (!xrtcdev->freq) { + ret = of_property_read_u32(pdev->dev.of_node, "calibration", + &xrtcdev->freq); + if (ret) + xrtcdev->freq = RTC_CALIB_DEF; + } + ret = readl(xrtcdev->reg_base + RTC_CALIB_RD); + if (!ret) + writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR)); xlnx_init_rtc(xrtcdev);