From patchwork Wed Feb 15 13:32:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 1742862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-xilinx-onmicrosoft-com header.b=hGYLKkHL; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PGzXh5lYJz23yb for ; Thu, 16 Feb 2023 00:32:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229923AbjBONcv (ORCPT ); Wed, 15 Feb 2023 08:32:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjBONct (ORCPT ); Wed, 15 Feb 2023 08:32:49 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2122D5BAC; Wed, 15 Feb 2023 05:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JxO3w4jwRnI0NNynXEEcVR6uEzA/0nPYZj8L7/F1JclYa4a93CJK/2ZrbZdeWDLL7GxFHItBbvY+i3JUwpm3oiS9f5uHFXU8FMdngQzVrGYC0VQwC5uThYnJi7/GhJx6hYmZwjpOSFMFA6nlkpJm9Cq+IbB8k6tVfGltBkkIy0/eGyRlc3+rsSfxcQ0+cBbC4K8XJ45czBeF1tmGkUNlTO56INnAUnpH5ka8ZF35Oi2oFwHCaT51z/AXwu5fPy55fEpM0jyoD0QhNjFp9IOPQj8L+04NdGQy7yboFQ7pYdcULVH9ifpqYIbx8JTitFCi5dxPPFUC6PBKXuD1MsDa7w== 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=eWc+fmJe88k/Ztjkc4W5AFUYJKWD/hgKU5yH09ZaZ9M=; b=F1cxP4z06YcJnoDAJhKMOlewmJyvtz8pJptPygPa7ytgXMhr29fAj9zPvEWPjridBQ5ViPdm/dDqDy8OZzLVshJEZkPQRP5x01KWO9BhO6Au56rbK7JwSiDt2MbPZH0yU/qCdxsaWYI+0pdkQmiQXXY17k8onMHtUO6+y+rZs4x9RXEQqp5F+Rvlh2YwumWziISicbnQ5E6uZ3Mcu2QLzG2/eUpNkpOwMEevvCrn/HaMTvE97rV2tYBwTEE2Tckf5i/8bytVf7wrN2gS+141Rd1C2L0y+4t7ZKR5M4mwqR50uyucNAh56jFTGTYU368v181km3TpBBai8sVyLlx7dQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.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=eWc+fmJe88k/Ztjkc4W5AFUYJKWD/hgKU5yH09ZaZ9M=; b=hGYLKkHLt7jQV4QycZKSKl0a8t/XKdePVWE3wUr7+faL7fVtsXNLS9ikyqyh7yjyN57X1hJix+TuJ2F1dHKwyskW++vF7rOp/klL2oHpBawt0TQyu3jXMHg0viGChmMWPrjcs+GUDx4+Do4pSJpOsK7QkdyA7zx9Hb6Hqb6jlk4= Received: from SA9PR13CA0083.namprd13.prod.outlook.com (2603:10b6:806:23::28) by MW4PR02MB7410.namprd02.prod.outlook.com (2603:10b6:303:7f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.27; Wed, 15 Feb 2023 13:32:43 +0000 Received: from SN1NAM02FT0026.eop-nam02.prod.protection.outlook.com (2603:10b6:806:23:cafe::e) by SA9PR13CA0083.outlook.office365.com (2603:10b6:806:23::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 13:32: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=fail action=quarantine header.from=amd.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 SN1NAM02FT0026.mail.protection.outlook.com (10.97.5.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 13:32:43 +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.2507.16; Wed, 15 Feb 2023 05:32:41 -0800 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.2507.16 via Frontend Transport; Wed, 15 Feb 2023 05:32:41 -0800 Envelope-to: git@amd.com, manikanta.guntupalli@amd.com, michal.simek@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, manion05gk@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, andrew@lunn.ch, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.3] (port=42318 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pSHto-0005FE-Om; Wed, 15 Feb 2023 05:32:41 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id B60B11055BA; Wed, 15 Feb 2023 19:02:27 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V6 1/3] dt-bindings: i2c: xiic: Add 'xlnx,axi-iic-2.1' to compatible Date: Wed, 15 Feb 2023 19:02:22 +0530 Message-ID: <1676467944-17426-2-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> References: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0026:EE_|MW4PR02MB7410:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c200d63-2901-4147-3535-08db0f591df5 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ty/Gva0ejqQehFf3F70j+xaee7E+jmRLYjwJsp7Bwv61NtwUboamAQMEAjkNAjwpmeyciXGXJigjD1CT6PtaICzn7Pf3AHDg16JrT6TSaGhY78zv8mrMHWcZ/nNS3gIeL+KT/9ByLA6vN+JKbliLV7i+utW09vFjaPOi4ORbDN3a6VXTC7MVTOoFnp/5YSP+Pb3Ve5Z7IIAGy1msIuqM26+EQXJ89Gp8E1GBYFYltrPIlBVhoQ9nm2J5fJFEtGcdqSusXBvm9hdsFkHeEyJ7F52h2Z7hjAE2P0sKo8R/W3RV3OFS8jdT8NrAlMbFmW40scz9yKEwyMP6MVNIldHHJOBQ/rWoa5Uk6iuiCoK9hLnubboJyIrTpf84eq7R+48kgnIS69Gj8UGtJEdbsCYAdEW6aDWKEKDgCXQhmcV/0LkSEUW+O3WmQjceJGBgLpLTZpsoZ05pGKZPHkb1WY+RZcKPzHCnUBpdc4M7oLe80LWJOMDQSm0yMP97TDLTC6uo9HadwmUT5eClCJDJ+u1EeE2cgDHOTSBy4lCCOz6U5XsPSeMbyTKZ0ryQnvmWSlzXVSzCGjGRN4wH4E94wZ28SfIc80w2StdgBzxVEu2abSBGqswgibwCHH/W1O2YCEhK4mEXaxbxNVYsbyTcnfs4I5eMMxBTusFtR95Qd38/m8y9Gr0I0e3UC7Wc/eYkfXGq9CZv6fv6XNHZo5E8w6G4Wo6Cy0qfuY/g3NTm9GvF7j6C9uW6riSSC8BYR6wMbGpI 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:(13230025)(376002)(396003)(346002)(39860400002)(136003)(451199018)(40470700004)(36840700001)(46966006)(2906002)(44832011)(7416002)(5660300002)(83380400001)(8936002)(41300700001)(356005)(7636003)(36860700001)(36756003)(70206006)(70586007)(8676002)(4326008)(316002)(40460700003)(110136005)(42186006)(54906003)(83170400001)(186003)(82310400005)(478600001)(6266002)(40480700001)(336012)(47076005)(42882007)(82740400003)(107886003)(26005)(2616005)(6666004)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 13:32:43.0922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c200d63-2901-4147-3535-08db0f591df5 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: SN1NAM02FT0026.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7410 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam Add xilinx I2C new version 'xlnx,axi-iic-2.1' string to compatible. Add clock-frequency as optional property. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek Reviewed-by: Krzysztof Kozlowski --- Changes for v6: Add enum for clock-frequency in xlnx,xps-iic-2.00.a.yaml Changes for v5: Update description and add default value details for clock-frequency in xlnx,xps-iic-2.00.a.yaml Changes for v4: Add description for clock-frequency in xlnx,xps-iic-2.00.a.yaml Changes since v3: none --- .../devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml index 8d241a703d85..1b598638d457 100644 --- a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml +++ b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml @@ -14,7 +14,9 @@ allOf: properties: compatible: - const: xlnx,xps-iic-2.00.a + enum: + - xlnx,axi-iic-2.1 + - xlnx,xps-iic-2.00.a reg: maxItems: 1 @@ -30,6 +32,13 @@ properties: description: | Input clock name. + clock-frequency: + description: + Optional I2C SCL clock frequency. If not specified, do not configure + in software, rely only on hardware design value. + default: 100000 + enum: [ 100000, 400000, 1000000 ] + required: - compatible - reg From patchwork Wed Feb 15 13:32:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 1742864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-xilinx-onmicrosoft-com header.b=FWfAlA3R; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PGzYB1kp1z23hX for ; Thu, 16 Feb 2023 00:33:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjBONdQ (ORCPT ); Wed, 15 Feb 2023 08:33:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjBONdO (ORCPT ); Wed, 15 Feb 2023 08:33:14 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74BB5358D; Wed, 15 Feb 2023 05:33:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eeIjioxoUTQPE4ZVT76rF+/RbHBozV6eZy/JhrXFMkZrgVtd+Gkurca4tJImbXBvHEfZZPlUyMMBN8Ji1hrlxzMxGazICXG6sahPLJH5erAXK5aBspY2Npxz2LFYqQQSrUlMtQ0tDZz/VciuQeSwjtkGINVUfczqV1nR0Pqredfrj8ed303ROBkuC4HrxvsOkTJxt64TyvKxhxI6FbE6zxzZWPQFTCM8v02j45hKMBdX972Zqt1SdE9arD7oevqIHNNxrPQ89QUWnfAAGEb+M2+3FL4RWogwTl9fXBsdq7svQOj0vXnlDN5aojyjxEibfBbaqil+7ctO380ju7YITQ== 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=6NntkIq1M06a9B+y/OJna6QefVd/HKbYhpe1gAyG6RY=; b=LiINGttGqQ5JeMFSALPYWtTssVSKv3aM+6j0LNopbqT7MTOE7TDOssc4CKCgmRGD1RnSHUjkuwqFbPVqKKMImED40ABKH2KuLD2da4P+QYL7hj40YiyRyi8MOjsU6q/WSR7o5P2T8w3lRqLrc+3vY3YICs2Y7M3nXuKJTBnpmlL94npBgfxAGQIwj6Ge/Nuz7udL3Mpv3XVEd1BRUsI2oZbEcx68YSVeIYSlov109JjmmCPvQ+0Th8IdbtA3hwHAp1OnIFuHUdtlsEimzU4PnBRPqNtfAVuCSBRH89bqk1MHT5Zo0nIzs5UD33NYEvLS89rshaFvdcaYwo/cZ5hpwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.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=6NntkIq1M06a9B+y/OJna6QefVd/HKbYhpe1gAyG6RY=; b=FWfAlA3RHmsrffjnDzqkyA8JrklUmVSwEIpKCrc7IUwK3pPYh37leM05r8veFcLo9R/Yg3qQ9usVRcR3HLzBjQ45t+CyVHCnWnF1OLwNHXyNkG5brjuYs2PCbVI0GEToUwtQaxnm7CPx4/WDklv7fbAOxCxWe5+PETelHrf4IvI= Received: from BN7PR06CA0049.namprd06.prod.outlook.com (2603:10b6:408:34::26) by CO6PR02MB7748.namprd02.prod.outlook.com (2603:10b6:303:a6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 13:33:10 +0000 Received: from BN1NAM02FT055.eop-nam02.prod.protection.outlook.com (2603:10b6:408:34:cafe::97) by BN7PR06CA0049.outlook.office365.com (2603:10b6:408:34::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Wed, 15 Feb 2023 13:33:09 +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=fail action=quarantine header.from=amd.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 BN1NAM02FT055.mail.protection.outlook.com (10.13.2.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 13:33:09 +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.2375.28; Wed, 15 Feb 2023 05:32:54 -0800 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.2507.16 via Frontend Transport; Wed, 15 Feb 2023 05:32:54 -0800 Envelope-to: git@amd.com, manikanta.guntupalli@amd.com, michal.simek@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, manion05gk@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, andrew@lunn.ch, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.3] (port=42320 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pSHu1-0002ig-Ue; Wed, 15 Feb 2023 05:32:54 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 022B61055BB; Wed, 15 Feb 2023 19:02:28 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V6 2/3] i2c: xiic: Update compatible with new IP version Date: Wed, 15 Feb 2023 19:02:23 +0530 Message-ID: <1676467944-17426-3-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> References: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT055:EE_|CO6PR02MB7748:EE_ X-MS-Office365-Filtering-Correlation-Id: e48e83d1-2416-4eb8-759b-08db0f592dcb X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uEeHQAg5GSyjYBzthvU+Xn6i/hZxaRgB9xj8WRoLDT8AD1dDTNwkYGsmg+IHkViwoZd3veS8kHA5d/3hEiXIq0qA/0Vl0CZKzISxDgr2nqqSDa8kvC9YdYNkVLD5u2Sa4aPcL1L3AuaUxUbhp/vCj88NMW6CG1hIHB3sgBR1aJlnV7yPrTSdP/BUyaw56iPjOEoTSkXFb+1SneNE/csGIBuyLZ3JPw/WtZnUhyiyOLXFjAqCVo7eL4UXDqI8nJRG61IoiKJpkSknRFMM8TlSZKHL0F2ETmQ2+/7Qw0TV2GydB6tE+ytOLWX+fLA9lEJ0R18bjlqGU6eLTyDCCW4pjfY4FehQxLHB1VP2SlSQ8NHOvnujja2muYluj97uLou0OacyLpXz1RIQIMc8Uz9uCuHd4fxo0DnBjo33TSeQwAeT9bSR6Zk2vOila/pxpGBRlxtmX1eitEV+zQwOS6+7fQ6j5ZUh76TFXQyTdsNCKMx71R9pMnaGjCjS9ewaC8GHNPVpFiLRlIiTYk2BfSkDBL8uGu6vbIu/9eeMvIUfQC86QXu2s1qLPIBMY6pjJlXIMjxmKf2zLhTGj8vI3tg7rK7vx8eM59D+H3O0eG2er6HMAm8Nqn7OtpGEh76KHIQD1yUMr+Ho76tGL3/RaIhVKYKxV691zNu2WhbDG/m2UC00Ls6RpHxPcx8jyNAwmmJ29hheUdEAIbUpHEt3djQ0nnM63kPZecYPF9IWY5bCamVYZoz7iA99F69kP9Kvx95X 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:(13230025)(376002)(136003)(396003)(346002)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(2906002)(15650500001)(5660300002)(8936002)(7416002)(70586007)(70206006)(8676002)(4326008)(41300700001)(44832011)(316002)(54906003)(42186006)(110136005)(478600001)(36756003)(36860700001)(6666004)(107886003)(336012)(6266002)(26005)(186003)(42882007)(2616005)(83170400001)(7636003)(40480700001)(356005)(47076005)(82310400005)(83380400001)(40460700003)(82740400003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 13:33:09.6465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e48e83d1-2416-4eb8-759b-08db0f592dcb 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: BN1NAM02FT055.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR02MB7748 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam Xilinx AXI I2C IP is updated with a bug fix for dynamic mode reads. Older IPs are handled with a workaround in which they are using xiic standard mode for all these effected use cases. Add the new IP version to compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- Changes since v1: none --- drivers/i2c/busses/i2c-xiic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 8503b5016aaf..682b3567e83e 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -1074,6 +1074,7 @@ static const struct xiic_version_data xiic_2_00 = { #if defined(CONFIG_OF) static const struct of_device_id xiic_of_match[] = { { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, + { .compatible = "xlnx,axi-iic-2.1", }, {}, }; MODULE_DEVICE_TABLE(of, xiic_of_match); From patchwork Wed Feb 15 13:32:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 1742865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-xilinx-onmicrosoft-com header.b=cFXyXst4; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PGzYF4srgz23yb for ; Thu, 16 Feb 2023 00:33:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbjBONdU (ORCPT ); Wed, 15 Feb 2023 08:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjBONdS (ORCPT ); Wed, 15 Feb 2023 08:33:18 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB3ED4492; Wed, 15 Feb 2023 05:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sk+qXGwsWflKAsVIRBDNNQJTRVuLfRge2MIoqLD+TYIy7tppIkz7iISr3q1vyyCsqAlPqRPJ80YKlPTQMzXAgd+G7Lo9c8hNdRkHA0IwB5/IZTrErPdLaAh77zleEmSzRx8L7jhrnXNQCmwV41kRQgQ73XPVYfUcf8Ks4kohwQHyNU3vPsGgsEo7lTyNJ+ZDrUoxNi4U7evsX7h+FdEHPAL6y/ZIZsezSrppK6wzFV/Ee8EeewMfuxbgLLU2rRwi2+zCYosbRQcJ3cG69NyZPeoFGIOYCGzl8LWMVwHLBjXnk1jVcFbcysckZVlQvlud/gAx4scbM+XcX1wcjvxfcA== 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=bkFQFhPEhbNHgoFvcD+RjSqYj5J6yFkMBsYk4+w1lbk=; b=D/waJyvpKNQMQfBHOt2vszzXV7Ef3R34WG2Os477PBJMR1HeIWjt7xijPbn83KL9TweZWXLOuVezd3Dkzscf4bfMDwaObjvUZIQrWuWW6yZ+Fc+qv2WKqmlD0SzYOAxtCQVT1JAPqWaBjDd0dFpmgjdTVCYKglUWrtft0/8afFqguKFTCKxjrI5muZ33zONcuR3ioZPp+2ib1r8cFr5/YnMJkB3fbFjNGNFTmlnqTMlSdy7DypujxKZDD89lH/lJ09BgQdF61zRgHYsmFnw9oEhuH9STue4uJB0MzxrHpWK9vvKUwAfk+XlX4+ZIv/wgCs/HiA/ZJF4EnCjMPzzXsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.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=bkFQFhPEhbNHgoFvcD+RjSqYj5J6yFkMBsYk4+w1lbk=; b=cFXyXst4DkOOwIIpD6WwFkbMHl6JWcaHo/lk2kNeLjNkX1K3UYXrGDSE/jGKf0mfY0zUc3mMMT04EXVfN7x6ubFAmf6GaVYU30zp28gB/QLlG3LFFd0qRhsEuVZd3jAqZydaxlOWG0CTpQHzaBE6nAQWkC9QlOf1P8YA8yRZrpY= Received: from SN4PR0501CA0129.namprd05.prod.outlook.com (2603:10b6:803:42::46) by DM8PR02MB8139.namprd02.prod.outlook.com (2603:10b6:8:1c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 13:33:14 +0000 Received: from SN1NAM02FT0046.eop-nam02.prod.protection.outlook.com (2603:10b6:803:42:cafe::de) by SN4PR0501CA0129.outlook.office365.com (2603:10b6:803:42::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 13:33:14 +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=fail action=quarantine header.from=amd.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 SN1NAM02FT0046.mail.protection.outlook.com (10.97.5.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.12 via Frontend Transport; Wed, 15 Feb 2023 13:33:14 +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.2507.16; Wed, 15 Feb 2023 05:33:07 -0800 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.2507.16 via Frontend Transport; Wed, 15 Feb 2023 05:33:07 -0800 Envelope-to: git@amd.com, manikanta.guntupalli@amd.com, michal.simek@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, manion05gk@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, andrew@lunn.ch, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.3] (port=42322 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pSHuF-0002p2-3v; Wed, 15 Feb 2023 05:33:07 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id E47A81055BC; Wed, 15 Feb 2023 19:02:29 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V6 3/3] i2c: xiic: Add SCL frequency configuration support Date: Wed, 15 Feb 2023 19:02:24 +0530 Message-ID: <1676467944-17426-4-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> References: <1676467944-17426-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0046:EE_|DM8PR02MB8139:EE_ X-MS-Office365-Filtering-Correlation-Id: f512936d-7fda-4f1d-8b56-08db0f5930a7 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WNS3UdzDB7R3F0ZMZ9ZASjXaQxbhPaXCaIZq3wI3QMBQokA2BT+JzzNfPAtwUkl+psWpXFBuOL1BbXEXzPl9SDIPYoDIVCinD7fNyVkgD7qWy0N+p3ptzy65NrZJi5REnoDZgC/uYWSkjVHkqK07XcHyvtrixw2WslH/GqRvLpiH1qXx6Lw6w2WwOGkHYsoYEKZ0Jy82VEYVmJKVuTBsrtxdSbMffhdrro6bHJNhfzYKi74KjKVWIhqbxz5beANoD7LG34W36NAsEczlXPdas1waLYegjBbr+tUu2Vhz4fLJrc8QaHLWgoWlj5yVrFnSYaPxPGVI3iBBoI7DY3yMBJLzGxwFS501m0L6gUvMDIugDbA8c/ob2EMxYLLZv+G1EMMIQFilch+T2cE2U7GiajYKih6YJSiZdzF+Rgex7QYKV8yAaewM328CzxQDXLxXcL7xxXEUjOTI2kJoXndD5MSjhSKDXMPsPW/bpkhzEBSCTbqo3nVITfe51mYh2f0eplFTEqmXHGFsfk4KBsbVoqbmXEFZt9oczuAZ4tskmnmKoGQbjm28JbMJHHL50j75DmcffT22VikAziSHvIsvBjRfTrL0tJqEvr0oQGN/knFDJVuk/XcfRUGZ9G3/BA2FYIyn2T38BWRMmEp/iJdpaNMJUllNk383fiygaSjLVkXuo2XmGUKaE07rXBf6MSCUFr7xmefR2hAJrB2Z+TpitDv3DkFySMAJPyhNhyeEI8Nvq8oV4NginMwpCBphV7Y0 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:(13230025)(396003)(136003)(39860400002)(346002)(376002)(451199018)(40470700004)(36840700001)(46966006)(40480700001)(83380400001)(36860700001)(47076005)(40140700001)(83170400001)(356005)(82310400005)(7636003)(82740400003)(42882007)(478600001)(6666004)(107886003)(6266002)(186003)(26005)(2616005)(336012)(36756003)(40460700003)(41300700001)(8676002)(2906002)(70586007)(70206006)(4326008)(5660300002)(8936002)(7416002)(44832011)(54906003)(110136005)(42186006)(316002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 13:33:14.5068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f512936d-7fda-4f1d-8b56-08db0f5930a7 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: SN1NAM02FT0046.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR02MB8139 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam From 'clock-frequency' device tree property, configure I2C SCL frequency by calculating the timing register values according to input clock. After soft reset in reinit function, the timing registers are set to default values (configured in design tool). So, setting SCL frequency is done inside reinit function after the soft reset. This allows configuration of SCL frequency exclusively through software via device tree property, overriding the design. If the clock-frequency parameter is not specified in DT, driver doesn't configure frequency, making it backward compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- Changes since v1: none --- drivers/i2c/busses/i2c-xiic.c | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 682b3567e83e..1e89e8270749 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -46,6 +46,12 @@ enum xiic_endian { BIG }; +enum i2c_scl_freq { + REG_VALUES_100KHZ = 0, + REG_VALUES_400KHZ = 1, + REG_VALUES_1MHZ = 2 +}; + /** * struct xiic_i2c - Internal representation of the XIIC I2C bus * @dev: Pointer to device structure @@ -66,6 +72,8 @@ enum xiic_endian { * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info * @smbus_block_read: Flag to handle block read + * @input_clk: Input clock to I2C controller + * @i2c_clk: I2C SCL frequency */ struct xiic_i2c { struct device *dev; @@ -86,12 +94,37 @@ struct xiic_i2c { bool prev_msg_tx; u32 quirks; bool smbus_block_read; + unsigned long input_clk; + unsigned int i2c_clk; }; struct xiic_version_data { u32 quirks; }; +/** + * struct timing_regs - AXI I2C timing registers that depend on I2C spec + * @tsusta: setup time for a repeated START condition + * @tsusto: setup time for a STOP condition + * @thdsta: hold time for a repeated START condition + * @tsudat: setup time for data + * @tbuf: bus free time between STOP and START + */ +struct timing_regs { + unsigned int tsusta; + unsigned int tsusto; + unsigned int thdsta; + unsigned int tsudat; + unsigned int tbuf; +}; + +/* Reg values in ns derived from I2C spec and AXI I2C PG for different frequencies */ +static const struct timing_regs timing_reg_values[] = { + { 5700, 5000, 4300, 550, 5000 }, /* Reg values for 100KHz */ + { 900, 900, 900, 400, 1600 }, /* Reg values for 400KHz */ + { 380, 380, 380, 170, 620 }, /* Reg values for 1MHz */ +}; + #define XIIC_MSB_OFFSET 0 #define XIIC_REG_OFFSET (0x100 + XIIC_MSB_OFFSET) @@ -110,6 +143,19 @@ struct xiic_version_data { #define XIIC_RFD_REG_OFFSET (0x20 + XIIC_REG_OFFSET) /* Rx FIFO Depth reg */ #define XIIC_GPO_REG_OFFSET (0x24 + XIIC_REG_OFFSET) /* Output Register */ +/* + * Timing register offsets from RegisterBase. These are used only for + * setting i2c clock frequency for the line. + */ +#define XIIC_TSUSTA_REG_OFFSET (0x28 + XIIC_REG_OFFSET) /* TSUSTA Register */ +#define XIIC_TSUSTO_REG_OFFSET (0x2C + XIIC_REG_OFFSET) /* TSUSTO Register */ +#define XIIC_THDSTA_REG_OFFSET (0x30 + XIIC_REG_OFFSET) /* THDSTA Register */ +#define XIIC_TSUDAT_REG_OFFSET (0x34 + XIIC_REG_OFFSET) /* TSUDAT Register */ +#define XIIC_TBUF_REG_OFFSET (0x38 + XIIC_REG_OFFSET) /* TBUF Register */ +#define XIIC_THIGH_REG_OFFSET (0x3C + XIIC_REG_OFFSET) /* THIGH Register */ +#define XIIC_TLOW_REG_OFFSET (0x40 + XIIC_REG_OFFSET) /* TLOW Register */ +#define XIIC_THDDAT_REG_OFFSET (0x44 + XIIC_REG_OFFSET) /* THDDAT Register */ + /* Control Register masks */ #define XIIC_CR_ENABLE_DEVICE_MASK 0x01 /* Device enable = 1 */ #define XIIC_CR_TX_FIFO_RESET_MASK 0x02 /* Transmit FIFO reset=1 */ @@ -310,12 +356,102 @@ static int xiic_wait_tx_empty(struct xiic_i2c *i2c) return 0; } +/** + * xiic_setclk - Sets the configured clock rate + * @i2c: Pointer to the xiic device structure + * + * The timing register values are calculated according to the input clock + * frequency and configured scl frequency. For details, please refer the + * AXI I2C PG and NXP I2C Spec. + * Supported frequencies are 100KHz, 400KHz and 1MHz. + * + * Return: 0 on success (Supported frequency selected or not configurable in SW) + * -EINVAL on failure (scl frequency not supported or THIGH is 0) + */ +static int xiic_setclk(struct xiic_i2c *i2c) +{ + unsigned int clk_in_mhz; + unsigned int index = 0; + u32 reg_val; + + dev_dbg(i2c->adap.dev.parent, + "%s entry, i2c->input_clk: %ld, i2c->i2c_clk: %d\n", + __func__, i2c->input_clk, i2c->i2c_clk); + + /* If not specified in DT, do not configure in SW. Rely only on Vivado design */ + if (!i2c->i2c_clk || !i2c->input_clk) + return 0; + + clk_in_mhz = DIV_ROUND_UP(i2c->input_clk, 1000000); + + switch (i2c->i2c_clk) { + case I2C_MAX_FAST_MODE_PLUS_FREQ: + index = REG_VALUES_1MHZ; + break; + case I2C_MAX_FAST_MODE_FREQ: + index = REG_VALUES_400KHZ; + break; + case I2C_MAX_STANDARD_MODE_FREQ: + index = REG_VALUES_100KHZ; + break; + default: + dev_warn(i2c->adap.dev.parent, "Unsupported scl frequency\n"); + return -EINVAL; + } + + /* + * Value to be stored in a register is the number of clock cycles required + * for the time duration. So the time is divided by the input clock time + * period to get the number of clock cycles required. Refer Xilinx AXI I2C + * PG document and I2C specification for further details. + */ + + /* THIGH - Depends on SCL clock frequency(i2c_clk) as below */ + reg_val = (DIV_ROUND_UP(i2c->input_clk, 2 * i2c->i2c_clk)) - 7; + if (reg_val == 0) + return -EINVAL; + + xiic_setreg32(i2c, XIIC_THIGH_REG_OFFSET, reg_val - 1); + + /* TLOW - Value same as THIGH */ + xiic_setreg32(i2c, XIIC_TLOW_REG_OFFSET, reg_val - 1); + + /* TSUSTA */ + reg_val = (timing_reg_values[index].tsusta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTA_REG_OFFSET, reg_val - 1); + + /* TSUSTO */ + reg_val = (timing_reg_values[index].tsusto * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTO_REG_OFFSET, reg_val - 1); + + /* THDSTA */ + reg_val = (timing_reg_values[index].thdsta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_THDSTA_REG_OFFSET, reg_val - 1); + + /* TSUDAT */ + reg_val = (timing_reg_values[index].tsudat * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUDAT_REG_OFFSET, reg_val - 1); + + /* TBUF */ + reg_val = (timing_reg_values[index].tbuf * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TBUF_REG_OFFSET, reg_val - 1); + + /* THDDAT */ + xiic_setreg32(i2c, XIIC_THDDAT_REG_OFFSET, 1); + + return 0; +} + static int xiic_reinit(struct xiic_i2c *i2c) { int ret; xiic_setreg32(i2c, XIIC_RESETR_OFFSET, XIIC_RESET_MASK); + ret = xiic_setclk(i2c); + if (ret) + return ret; + /* Set receive Fifo depth to maximum (zero based). */ xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, IIC_RX_FIFO_DEPTH - 1); @@ -1138,6 +1274,15 @@ static int xiic_i2c_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(i2c->dev); pm_runtime_set_active(i2c->dev); pm_runtime_enable(i2c->dev); + + /* SCL frequency configuration */ + i2c->input_clk = clk_get_rate(i2c->clk); + ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &i2c->i2c_clk); + /* If clock-frequency not specified in DT, do not configure in SW */ + if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ) + i2c->i2c_clk = 0; + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, xiic_process, IRQF_ONESHOT, pdev->name, i2c); @@ -1181,6 +1326,9 @@ static int xiic_i2c_probe(struct platform_device *pdev) i2c_new_client_device(&i2c->adap, pdata->devices + i); } + dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", + (unsigned long)res->start, irq, i2c->i2c_clk); + return 0; err_clk_dis: