From patchwork Sun Jun 26 07:08:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12895627 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 15BE7C43334 for ; Sun, 26 Jun 2022 07:10:05 +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=KevBLDqiZ+4eAW4/39Cbc9hvitawGIII6grg3VdVbi0=; b=0bFGRlnbrb7GgK Xuf0aDdq7R5pjmcuroTbr7ivJRm09DMU+EdyDX1bWUrPMX4yXhFUDiJh6AQEWFmGD6wAZIES5TOMz BlW8jyYY3iYOOfr1t+8XrCO4FL1DhZPjhsm8OEmmJypo0IvZsUC3/rrIcguohHt8n0TYdCHkxo5LQ H4obkVbQMetghLwxI6LoAAGkYyNyf1+XfMyjvfdbfJjwAeuVTZGseJSCj59xNpjZp/2UWcIwXMxH8 Od5O8D/VGj2JalSRkyd587Rvqt2ikDBXdOFqfWyZpYtyZlyiUeueYziAo1WSPXSg3mWsCYJK54k2T GcOh8u3UEvs1oi8wXEnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MO7-00AHxa-7c; Sun, 26 Jun 2022 07:08:55 +0000 Received: from mail-dm6nam10on2066.outbound.protection.outlook.com ([40.107.93.66] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MO4-00AHv0-1F for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 07:08:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kP/az+QVpEwR1VcQUZp8FkGsmBx3iafuErM6KQC+JzZyJSU1RQKbO4DNNQT/ogK1zMQ+UBhZzljPD8URKzLg8Ku3xJLkw6Pd/mgoGG9MLY7ygQCmikhCY6nGtWlDrTbsSxfWmIRmLNm1SAS6aOz9BGhzoXxY8rNqANZ4UvvY2NyArwoyi/e8sXDvMXNHe1zNOC5h7lR63kGQ9ssY7s31iyS3Iym0qEy6Z3JVm5EGoceOo15k0q8OLkaqjpwg5fm+pPM3CODnlLWyR3kG/DrO4MkUMdWL8bX3yW+Y9E1WziQhm5FIW+znu8CSK8Iv6y96RkikK/ppGaRoNdJrtsf2Gg== 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=gGmINQICBnsP37Ka+yRHtTffsob9IUkB2e7BORWjNxQ=; b=jE+DxqPIXsHzgDMo68S47r53WHODnR7uTzmTPutVNimQdkLJsUIqrZUxuEt4KKgjQtqvFpc1g9hgr2JG+X25aAu0W6kc4qbP7qvhMmc43Obqo6bQSL8ymqNjPOYFIHpuHsQwdIU9Sm/sZ1tmkSvd0Wz7KtyfmC0jIqkJPulio22NgBAbqJQnEVCtbShbtVGSaV+ilVVC1RL+Bf3qvKrZcv2PLZIUEWleyvAg4h7y80o0fpV2FyOe5TzmaXBbeO3dTp1zJOpMMggl1RXciAYFut/92TMQ1FKP2LYfx+5qblqn1tkqY4oHjvpaEe5NFIBKJjebTL9ceH6K8ojP0hAOpQ== 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=gGmINQICBnsP37Ka+yRHtTffsob9IUkB2e7BORWjNxQ=; b=WWWEaW39qzZci8LgDWGD8pJ6VC6Ug0TsAjSWlYSIXj5EhfguHQ4K8814oPIySXYhP+i2bDlcZ9trTv5D0xmtJapNh43seil9aZnh2y1Nw0Kq6+3AEKbeus0wix2UvzfQTXODnt6Q5bcwdaacHF8Z7untHpPyZoUDEMhA4VnBlD4= Received: from SA9PR13CA0068.namprd13.prod.outlook.com (2603:10b6:806:23::13) by DM6PR02MB6842.namprd02.prod.outlook.com (2603:10b6:5:223::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17; Sun, 26 Jun 2022 07:08:43 +0000 Received: from SN1NAM02FT0017.eop-nam02.prod.protection.outlook.com (2603:10b6:806:23:cafe::a6) by SA9PR13CA0068.outlook.office365.com (2603:10b6:806:23::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.6 via Frontend Transport; Sun, 26 Jun 2022 07:08:43 +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 SN1NAM02FT0017.mail.protection.outlook.com (10.97.4.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5373.15 via Frontend Transport; Sun, 26 Jun 2022 07:08:43 +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; Sun, 26 Jun 2022 00:08:41 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Sun, 26 Jun 2022 00:08:41 -0700 Received: from [10.140.6.39] (port=59232 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o5MNs-00061W-CC; Sun, 26 Jun 2022 00:08:40 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , , Srinivas Neeli , Rob Herring Subject: [PATCH V10 1/3] dt-bindings: rtc: zynqmp: Add clock information Date: Sun, 26 Jun 2022 12:38:15 +0530 Message-ID: <20220626070817.3780977-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: e1b3385b-bf56-46ac-b5f6-08da5742b4a0 X-MS-TrafficTypeDiagnostic: DM6PR02MB6842:EE_ 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: m3hHyJ9fmqhav5MZXjcaYwr/2bzJeRcYra/p4yEc9j77ssYdr9s9pMqz+pp5u5SWc/HhlUIrFbAlxFAWOHBaseRO/jbAttSOzJ21hRlnZv891Flk/+HHHXUqfFoLxQ/c5thRD2UydgUYEHoAhXS+X7oRBhaJhbfXrKmy2hAw6rT2DJmdQ/gJLrphpVOYb0KPpX1NbX6FYY+9xg5BRsw5QPTsGUtp5TOmFr6V/pDlJSNWE77ObJ3P7VNjvTw5waY1E7NdqK9lTpfiRYOSoDwMc82CoHrPpAKtPg4nhMYgjfknhnnTRbTJ6J3vAlOBfe8TvU4cv0abFDjC9E/tXYfRlQy+2ugaYgffYbKkIWLGV03UwiFjyjT43GOnW+fcuulFenMwpxEwoxmR61vrq56KY4No8dteMDdceNIAU9md+PApNbHnLTHkA3R0NCFXsTkDTpnyhnNfmmdRLb9vJqmqrn891XH7Q6InjR3GkSxBMtCXPvpImwmPBRvN+ZVvsWZhSi+n+lcNuHQf/gTul9oNtXdHZ9VJoFTx+ncMnhfCdDXgXZszhWNuH5VY5F0AKKCT1HgJ8+6K/vOX5U5a1CWPs4mb653D7aZZQYKRoBTv+o/UZQyIopbfAiAW2msMngyH0KnRAIQrRIzE1tFsOj4kAKW5xc/nT7xQwrBrCXhZRmFqdM1fzbkgnZ2Zx5lBIfSj1QJ9aw9MhH+spMdUHbaJ/6Xi0dDL5zb5/fBDsNppw2moOMPZ2T/FLv7HglnGLsF2jx0Det/fdGdO6baoKXXAMswX2My4XDPc3QqoDDew4Ukyn40MzjHZXGH/J1BuoxSKAycTBBUOXi5pbZ3Bpia+GRl49pmnPWDJgfDX+7cYIQM= 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)(376002)(136003)(396003)(39860400002)(346002)(36840700001)(46966006)(40470700004)(110136005)(2616005)(5660300002)(36756003)(82740400003)(41300700001)(6636002)(6666004)(2906002)(47076005)(336012)(316002)(54906003)(186003)(426003)(40460700003)(82310400005)(70586007)(70206006)(356005)(83380400001)(4326008)(26005)(8676002)(1076003)(7696005)(44832011)(7636003)(36860700001)(8936002)(9786002)(7416002)(478600001)(40480700001)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2022 07:08:43.5298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1b3385b-bf56-46ac-b5f6-08da5742b4a0 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: SN1NAM02FT0017.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6842 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_000852_120950_6046997F X-CRM114-Status: UNSURE ( 7.95 ) 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 Acked-by: Krzysztof Kozlowski --- Changes in V10: -resolved dt_check error. Changes in V9: -Updated clock information in clock-names. 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..7ed0230f6c67 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: + maxItems: 1 + + clock-names: + items: + - const: rtc + 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"; + clocks = <&rtc_clk>; }; }; From patchwork Sun Jun 26 07:08:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12895626 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 BA5B2C433EF for ; Sun, 26 Jun 2022 07:10:04 +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=STqFiSxMsVliXhGS+UdutVmRJOCqFKb1kfO7p2kJyy4=; b=3aNbRWdpRTFStN FQtbENqEp6ZdemRrL/9VQxCiEB33R6XNLXvZ2j4qMVFnaVZ9VBN7RV2rq7gERwlitr1MMGWcz2bPF x+nRfip88PGqvhSWJ16WftjrQjBWoKE8AU9Qub81yMQmGDFBzkScsEtfXHuis6T0BLq8UtbjKNl4+ l94nB1F/IYLhhFh7U606wroF/h5LU48ONMveNh7zuSzsmepgSkTgV27jHgyqDHqTEWtDJl+KpznBI 2o3pxkrHdsYzGI3u5Lw8w1T33YJeG2IL2CemaLprLYkyof96IqephOFnetEmPBvP90Ph0fEH9z9i5 IsYExTlqon31Fg3JJyCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MOG-00AI10-Lu; Sun, 26 Jun 2022 07:09:04 +0000 Received: from mail-bn8nam12on2043.outbound.protection.outlook.com ([40.107.237.43] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MO8-00AHxk-TU for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 07:08:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ab6lhQzEUXKEQi7c5lBd1uHessbkMQGhX+rRn/dWGaLMvC3BJpM1ytF+QaVDWWghe7yo8cE5gUwgGEWdMDbEuA80t3q7R3qocAZi9gp+RjRV3P8zeQZgKwuss/YPglPuGkc8UoINRxiNDvTf88x6qZPDMxMkzpoma89LmGJjaCHa/Ippah01TUXD0jkcOCzUwnUFw/LiJC7s+rINqMLemB18FDGi44f1lXCZTJHPfgBgl5nZYEQBYkaSJojR7eDalUKkPw0/wFIojSYg6PH3xW6EWJMuHl6/L0EKri8kHvogG68lkNbA0Xdn7hjSlr8jMvvZ5F3clLDtLUgPjlfWug== 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=Hl1ecw6+6UbFuumzQI8ORtbZHlWhzrFkYIEJsA0E0wY=; b=LgLZLdxPdc1mC4vga7fc7kYqEYHrSs5w0H6UXN50Yv8Cn/QULpZOVKlnNfiByH961GYOII6EFUzV8FalK9frvsivbt/720THwIekE2sIQtdJYpONTUSuIan+5hJhdFKGVrK3LAglXLf2u1IgCHF/U+LyZHoAWTGJYZF2yIwrqab4TIK3+4GVBoOGNL9euMYdBHavtdwZApwmkqsfLrSVbUXGdKUHcrw+uZWT376/SqECrSAHyTB9J5E7v0FL1uLrQCf9io3G7I+2hMcdMNjh+eBwfW9rQhBOVZGcnKSvXOBSYSbYqNg4rxKlSrRRKvoIY/qBXGybtgRApIpcVAqOoA== 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=Hl1ecw6+6UbFuumzQI8ORtbZHlWhzrFkYIEJsA0E0wY=; b=NrhqvIto+Ool+GyUcs9b8Z6Cv6DsgAqNAuk5niPJnLz5jORXb78Os9idClcrqq81ZGwvxSeudoevJHeZ0ykQJWb4gXBJkxQJnWNSPHVnc8oOvV+B1YTgDOSF0zPLmM7yMQNRfnRye4sK811dGxP93gzD64Beihy/CVMVb3o+Xl8= Received: from BN6PR1201CA0014.namprd12.prod.outlook.com (2603:10b6:405:4c::24) by MW4PR02MB7236.namprd02.prod.outlook.com (2603:10b6:303:72::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Sun, 26 Jun 2022 07:08:48 +0000 Received: from BN1NAM02FT032.eop-nam02.prod.protection.outlook.com (2603:10b6:405:4c:cafe::27) by BN6PR1201CA0014.outlook.office365.com (2603:10b6:405:4c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17 via Frontend Transport; Sun, 26 Jun 2022 07:08:47 +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 BN1NAM02FT032.mail.protection.outlook.com (10.13.3.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5373.15 via Frontend Transport; Sun, 26 Jun 2022 07:08:47 +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; Sun, 26 Jun 2022 00:08:45 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Sun, 26 Jun 2022 00:08:45 -0700 Received: from [10.140.6.39] (port=59232 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o5MNw-00061W-QO; Sun, 26 Jun 2022 00:08:45 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , , Srinivas Neeli , Peter Korsgaard Subject: [PATCH V10 2/3] rtc: zynqmp: Updated calibration value Date: Sun, 26 Jun 2022 12:38:16 +0530 Message-ID: <20220626070817.3780977-2-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220626070817.3780977-1-srinivas.neeli@xilinx.com> References: <20220626070817.3780977-1-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5b1f77d-61a5-4d5e-f2a7-08da5742b6d2 X-MS-TrafficTypeDiagnostic: MW4PR02MB7236:EE_ 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: +JDjkXEBxdH1rH3fLoc4iP/lq2CenS9qB6mYiuvM0ns37YymaY3WTKWtLUqPkb/Yd1OkfAP1hjdEhkudfwLDe6yeuPJffm+uaiL1D3Q657CT2uqGZc+fbXKtaIDlzk+sK1nRKrhZ6Tok3WXmw29rsiKV1oevr6+ZTfHID2KYMMT/CW30MMgZ/0UjxpmnAK4iPfRBF31nbu/v5vkN1lz7pnqv6K108ILVZu6V4wXkOecFsufzT0X+qjUFCwM/MaQH1xlvb5DbNsMvuU8VD957kf9McBd5ME55XiwPBuQLlNFhnxd9aHxxnCWLte4yCekRbRJtZ8IH21EihmvsN5VNzCWVVldIsZEruiKGgT6T8J/5CoqhSJJLGBHQNeLUe7VFe9MDyleTUT8F5C+z59MdOzldDlVKLD7neqHPMM5yDMrAClHgJ2acNpFY8b1zxBaeOcNxjBRnjrzaEiVEEqEfK6zIUwsFt+6xDR2g92EMhnF9lbOmz8HZOU3SbwESaCXuLEx2Ul/Ci1+Jh6frQd2UohDdeLrldNqdg7nLMTGQB+nO0aLL/SUVmI3+Vti0Ub6Uv9FvtP9XQLvRuSH/K97j/Tgj6uLBQPO118/HfApXvR9siLHaMpGNMTKl+pTfRybybRmlBrcw1ZR7GGW4ZaOB1wA9Q5JxD73lJ5LjYyCeJRk917JEaeS/rXyf0+C3wzn2FtUdFfQRpgL0aAC6kdYmu9JZTlcLz6CtPsHAOhN1VvAu50px4tjkaSGOXKKaWmUOdOZSOmlJHh3f7CCblrkQzPjEtYkgwvFZTIyVUOnrfCW+PNzU2OjFbzYhTRBIYRVG0ijoTRwAeVRcFCV9yq7HVv06ZNsiH1iYipiApEuv5Po= 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)(396003)(39860400002)(376002)(346002)(136003)(40470700004)(36840700001)(46966006)(6636002)(36756003)(36860700001)(7636003)(356005)(316002)(40460700003)(110136005)(82740400003)(54906003)(2906002)(4744005)(40480700001)(6666004)(26005)(7696005)(1076003)(82310400005)(83380400001)(4326008)(70586007)(8676002)(70206006)(5660300002)(15650500001)(186003)(336012)(2616005)(47076005)(426003)(41300700001)(44832011)(478600001)(7416002)(9786002)(8936002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2022 07:08:47.1832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5b1f77d-61a5-4d5e-f2a7-08da5742b6d2 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: BN1NAM02FT032.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7236 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_000857_016078_6A2D1143 X-CRM114-Status: UNSURE ( 9.45 ) 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. We are in process to update the 0x7FFF as default value in the next version of TRM. Signed-off-by: Srinivas Neeli Acked-by: Peter Korsgaard --- Changes in V10: -None Changes in V9: -None 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 Sun Jun 26 07:08:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12895628 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 E6485C433EF for ; Sun, 26 Jun 2022 07:10: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: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=SHHvdgeJeE3CyDrV6bk1efUYvMooFOUlBvJac3CSdfo=; b=d48vUfUTTmn22a OHyqbRxal0rVlzUTl8e/eJ4ySNal7X1EHVaS22MbxGeWVZ93m/Z2weryfrMb5uCQf+QZTIUWMcSTX qQgxJiY5GgQMZ1LjDlsQ5Rz/wWxSoRDlaWvVUv7pZow3lDp3XxhBsA5XoBrzGGebTc15yUFkKidMI gZgUQIDLQ3xXP/23qy/5Pz1FfAbjgsd/btv3ovyIhRswZ2NjTDGX3dDpUxY/O+e8kDwnECgZVOr98 JHE326OqgxuAnaYkHZHha7Zxs45nbAUYBjHo94DH+qxvv2mzxGI5BVVFXKdH04FTrnYkvaHJ26x7g SabQooBjBxQZGS7mO05A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MOP-00AI2M-Ey; Sun, 26 Jun 2022 07:09:13 +0000 Received: from mail-bn7nam10on2059.outbound.protection.outlook.com ([40.107.92.59] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MOA-00AHyE-Pw for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 07:09:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IvwgAT12VIxEC6yXy0HUVqOst6Ef3FDiUNnM0y7cy1uLSgSGKlSBNw/kZRA1RzgXQhv0yX8qabMKyG5DlG/41/tp0paoS5xWf3I5OgqIDG7jZfgp1avYNa+zqKGkHDibUOeUfYOn63bZbFVi2NRUprXcf5FAgp8MfJJhnLeJXgO7hsyrsQnMOhdXg3DGbEltExiW3x6cUfFXPen1mijJ1Wbv2JbplcnU3cRoi/n612eHoS+BvtLSh/FAuvJdBzYsdmVaOgi7o0bigMJSw94yKP4a6kGLq8boZFCCfbIIiKFnd6UA15wrsNwkEar3nn/JYRR3bV13XVHb6zBZAcyutg== 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=PoDfnd+22aIUj7ycGxpVSruq43gsFV8+98RJ/0uK10g=; b=FmgJbeN5SYWvci3Y0Y0AbcrhSv1qs66yk70ztZK8tQP/In02Owsniu8rp9loznqSpXtH879JGNGj7plsfZanprANh2bDcSsJhY6NBc0DxZ1VRvskC6adaYqM1mcpvJN7G6pMkORV9+K69P3CYca+uysUaG4zDvkGmlHf2tpRL9pk5LZ83AvufnIQcjPh4miTsB302WkhUFcRvIyapsV2UC1ve3BjHBE018AjtquDsyhAGlZ1OdLUIoI4+QR8nobUQqyxRrkHMLC1xM/Tfl9ZR6v2RFASfqnUXO97sGkRpLxSXTsfRVfIrOGtCg50u+lfkcOp4nUcQG1BwDBq49Zttw== 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=PoDfnd+22aIUj7ycGxpVSruq43gsFV8+98RJ/0uK10g=; b=aiuyCrHVaj/YWP8ta3WcqvqhbnCwDAgM49GKE0ePpJXWTFluRIJXFXhbyqxInGi0nZIgDwEmRgM312nlzyzIwzMyUXBa+i+oB/SXj5yU6cRZYRHaMGz+fo9B9M9t3lyutIg/cnxWt2x6MDUOBaRApVvx0t5xeF+VppzvPlvJEvI= Received: from BN6PR1201CA0002.namprd12.prod.outlook.com (2603:10b6:405:4c::12) by MWHPR02MB3261.namprd02.prod.outlook.com (2603:10b6:301:63::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Sun, 26 Jun 2022 07:08:53 +0000 Received: from BN1NAM02FT032.eop-nam02.prod.protection.outlook.com (2603:10b6:405:4c:cafe::1f) by BN6PR1201CA0002.outlook.office365.com (2603:10b6:405:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17 via Frontend Transport; Sun, 26 Jun 2022 07:08:52 +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 BN1NAM02FT032.mail.protection.outlook.com (10.13.3.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5373.15 via Frontend Transport; Sun, 26 Jun 2022 07:08:52 +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; Sun, 26 Jun 2022 00:08:49 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Sun, 26 Jun 2022 00:08:49 -0700 Received: from [10.140.6.39] (port=59232 helo=xhdsgoud40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o5MO1-00061W-1m; Sun, 26 Jun 2022 00:08:49 -0700 From: Srinivas Neeli To: , , , , , , , , CC: , , , , , , Srinivas Neeli Subject: [PATCH V10 3/3] rtc: zynqmp: Add calibration set and get support Date: Sun, 26 Jun 2022 12:38:17 +0530 Message-ID: <20220626070817.3780977-3-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220626070817.3780977-1-srinivas.neeli@xilinx.com> References: <20220626070817.3780977-1-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03d0238b-2404-44ca-bfa5-08da5742ba17 X-MS-TrafficTypeDiagnostic: MWHPR02MB3261:EE_ 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: lWhQoCcmO7OBv62R6ndeZtDjJW7PraZoZPAQpSNqNJnPzdjaupm4739WpXAX1pchWK1YkqMpmsbXAQIu/oRs1YYdAkY+3iWlYsDJn0z2kvA6eAGizM9m/1w/1tzm+HrSffc5GebDM5FODyd5WibLhS/DULaZYD5Vrt3QGVUDtTxVe3LiU6XKx9tg2kBgnJHcgVaIhHnEZucWrJ6Y10l7L0NxRhlPVV1pKM+S2CXmcdhTJVut9XSDconTw6Z4135/9yBKqvr9DnBsI8WIv9hibEzOxpvfrzeFD6+KHhjVokbwUAXzk4/CjRAvocYIxtP7TBr7nqJvgLU+oWBHHTUv7z1VDhjqZUtR/jYn+k9mACflRtNq1szidWsUo9Bixd8C/TwA+aLghQvR7S8eB03lReSsGLXkBoANRSVCzRH4xmYA2wFpLoy1gkNiOlVFK76VnosmiNGO71VR01Hf28LDn5Cq2Od8wk6+LIEkfvscf0JTYvXd1DlCUsi3DPQf6h2oHHGeVd5xt0xLckf/1XVTZ4i6kTu66tQso1SjqvYxGLAF5pcuSUo1QbmBv3AnYwSKACSZhr8wNk4VeK9zTKqcpcXU/s57nXfn66XJ7KWD5H+E10gnWIp8oGIk4Wu9QdyHOUYgHP6dWQFQSOCpabbqTNIn8m+AQ2CcCkmQPG++HXg2nFW83/d5oCeZbY6uNSkbPBf/i0vmR54Id1PxHDi5DGRcUaM55FF0buk17hpyhj4Ilp12BG/qeoz2W27DmDmnbbSADooKi6gjvrKxgdEvqo8vql2RqphG3Z8PMv9zAE0Vlqqi/xfZT16M00BvWQ8XZO62atcYYSPykcyADIq2Gpd88z+9faosGZpgIVMXaPo= 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)(376002)(396003)(346002)(136003)(39860400002)(40470700004)(46966006)(36840700001)(186003)(47076005)(70206006)(4326008)(40460700003)(70586007)(6666004)(107886003)(41300700001)(36860700001)(8676002)(83380400001)(356005)(336012)(1076003)(426003)(26005)(36756003)(2616005)(7636003)(478600001)(8936002)(9786002)(82310400005)(7696005)(7416002)(5660300002)(6636002)(110136005)(54906003)(316002)(2906002)(40480700001)(44832011)(82740400003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2022 07:08:52.6673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03d0238b-2404-44ca-bfa5-08da5742ba17 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: BN1NAM02FT032.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB3261 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_000858_898479_B32F1207 X-CRM114-Status: GOOD ( 21.33 ) 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 --- Chanes in V10: -None Changes in V9: -None Changes in V8: -None 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);