From patchwork Sun Sep 25 18:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kumar Mahapatra X-Patchwork-Id: 609305 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC4F0C04A95 for ; Sun, 25 Sep 2022 18:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbiIYSIC (ORCPT ); Sun, 25 Sep 2022 14:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbiIYSIB (ORCPT ); Sun, 25 Sep 2022 14:08:01 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00DF71F630; Sun, 25 Sep 2022 11:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ghvj1Hn4rXJQ/nBcLvAlEwdVApwtMNURAa9COApLaT/sc9Jw+esAyJ6/64xSCze4f9Zjx8PxMG5nmet/X6YagJFylQylv9HQ4iaqddFdlGaB8WouXpKfX37h6EZXwUK8VzPtQ7bhjDNP7W35ZhloPdOcOl8h8QvDz6EgNvrivFXBoMc3atDTS1IJ6B+q+Jw72oSWYJ9O2gUQvfDW4C11Hd8KfYS5SzhvnCVGF0danmpAWnKvPUqT7wbpNv+XREhdvNTxEa/a0tQ7NSZRyLCo2K8hPAJ105So5zJzPTjT6l6SvcoDeOwvReN7hcRRmy0Zqm8CeZSUhQyC3NdbTLNdTQ== 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=tTVvvZzu8JCMGsL/wzE9d/zHikByTOy/N+nAeETMTpU=; b=gEyAbI5Vny2uKPSUQvOVxX9kqwM+0E/LX8Md0/QxWCEK1TcwDjMCCImX2miDBnupLuJ6FDrgRBDbd53Ku3aVS6GpusID6TUHPemUeewbl4RMbBljxRd+evKy2+Js5lkLTDo8gBEMO5fhQ9DdPwfR+YtBHSuEQIFylV0rJwgr/1Wdk57RdtK6/yk8NrpYvjjTt55BdUyyYD7WfqSAt5Yu4fR3SLhUPA3I0M0A1mFua8iWI+oWVGB+8SnrohRgc98MROjvpSb7zA12ACgWTHsrgrOrTvJqDM5LioY3fF/9klctwByQrwzAmYVBVrWWebXDMs0VJeTdZ0OmdVM5/V3DlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=kernel.org 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=tTVvvZzu8JCMGsL/wzE9d/zHikByTOy/N+nAeETMTpU=; b=gZYvXMxCUjTW+5bq2OI+pseg9mBU4+1NQzRt7aZCE9RRZ0VUTE3rTkp8tZaQlj5D2mQznhjhr3K6cYtPTybmtQU4V7fi0ojW/ZqMUKzT+BD50kmBBk+2LI9NJCAF+2r6wLxo5qvlTkfxOOP8KOZaG0E4czM1obzfg1e1yLR+mjo= Received: from SA0PR11CA0143.namprd11.prod.outlook.com (2603:10b6:806:131::28) by DM6PR02MB6512.namprd02.prod.outlook.com (2603:10b6:5:1b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Sun, 25 Sep 2022 18:07:59 +0000 Received: from SN1NAM02FT0006.eop-nam02.prod.protection.outlook.com (2603:10b6:806:131:cafe::ed) by SA0PR11CA0143.outlook.office365.com (2603:10b6:806:131::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24 via Frontend Transport; Sun, 25 Sep 2022 18:07:59 +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 SN1NAM02FT0006.mail.protection.outlook.com (10.97.5.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Sun, 25 Sep 2022 18:07:59 +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.9; Sun, 25 Sep 2022 11:07:46 -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.2507.9 via Frontend Transport; Sun, 25 Sep 2022 11:07:46 -0700 Envelope-to: broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, akumarma@amd.com, git@amd.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, amit.kumar-mahapatra@amd.com, michal.simek@amd.com Received: from [10.140.6.18] (port=44788 helo=xhdlakshmis40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ocW2c-0001TD-6G; Sun, 25 Sep 2022 11:07:46 -0700 From: Amit Kumar Mahapatra To: , , CC: , , , , , , , , Amit Kumar Mahapatra , Michal Simek Subject: [PATCH v3 1/7] spi: spi-zynqmp-gqspi: Fix kernel-doc warnings Date: Sun, 25 Sep 2022 23:37:33 +0530 Message-ID: <20220925180739.21612-2-amit.kumar-mahapatra@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> References: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0006:EE_|DM6PR02MB6512:EE_ X-MS-Office365-Filtering-Correlation-Id: b8b6fc2e-a3e5-45cd-049a-08da9f20e122 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: 5fAlovJZSvJEm35tQmmNyF2LW7gz95oAFDc2R5U5rsfLYCdtLO+j6NE9CZ7gRn9gSIrasOOCeBfTNABYYvoKW5t0LVK3hRZCv6VqZ+wGdEgn64s04DsF9W5551p0OI4TnBnIAgpbixaKf7n9LOdmcPyviOLJCPDVKqm+1/l1QAyQcRBoGYVFgU5Ari7hsYJv0rn+07rA2KNeENps4KXHPUUa5yQpc33yatVTn1CXQqedBHUGpgY0X3vbC0nqFSXDXFGzaJFgYYho35aetsybL4mc6c3rbBohsvjFyv7Bg2xMlHcUVtoirGUBYdrf50BMI0KamsmBGIXGGUOJrL9/WVcgiJKBLRo/LqtVQQUf5LfTGrxIrclUvWGxLyXQS4S7J+P41/0hPZ5OeHVqqBP7rjFaxF0vpr4irHhSKyQcP4VZcwWilzyS57fCoo3bjgGg6A7WXYJu3MfEJj4v+W5atdtiHXIliG5YrWcSubxoZp7JniJmgkqmaov9QiTKh0ljV28ZbVFWsJundvZC82JL4sCNfnJhx8d0uA9R6pii0ukY9ZO9t5D0tzIEdTRvQiBqLMa56LJSrr6SUZ+nZDutworg2MhwzrlTbqY1IwnWBE9VdsSK1xrF8nCOutjKppFrbFMzCSW8kuxdmqCFG6mkL+sMEf96VBHrb0lSwCe8oJ4Tf09ROQNw8w6hm9XcK4t1p/M4kNYN88KUuN7OiIPN0EmL1+fQTLkLoQ5fmGdBEY+8K7cJUjVBq7gZ2+BVpbtieX/54je4WmjtcQMtOnw8V+y4/VMoIYzkFycG3y47AqQ= 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:(13230022)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(41300700001)(8936002)(5660300002)(7416002)(110136005)(8676002)(54906003)(9786002)(316002)(70586007)(70206006)(4326008)(83380400001)(40480700001)(82740400003)(47076005)(36860700001)(426003)(336012)(6666004)(7696005)(478600001)(26005)(356005)(2616005)(7636003)(186003)(1076003)(40460700003)(82310400005)(36756003)(2906002)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2022 18:07:59.0281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8b6fc2e-a3e5-45cd-049a-08da9f20e122 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: SN1NAM02FT0006.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6512 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Document zynqmp_qspi ctrl and op_lock member description. It also adds return documentation for 'zynqmp_qspi_setuprxdma' and zynqmp_qspi_read_op. Fixes below kernel-doc warnings- spi-zynqmp-gqspi.c:178: warning: Function parameter or member 'ctlr' not described in 'zynqmp_qspi' spi-zynqmp-gqspi.c:178: warning: Function parameter or member 'op_lock' not described in 'zynqmp_qspi' spi-zynqmp-gqspi.c:737: warning: No description found for return value of 'zynqmp_qspi_setuprxdma' spi-zynqmp-gqspi.c:822: warning: No description found for return value of 'zynqmp_qspi_read_op' Signed-off-by: Michal Simek Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index c760aac070e5..973008a30a09 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -141,6 +141,7 @@ enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; /** * struct zynqmp_qspi - Defines qspi driver instance + * @ctlr: Pointer to the spi controller information * @regs: Virtual address of the QSPI controller registers * @refclk: Pointer to the peripheral clock * @pclk: Pointer to the APB clock @@ -157,6 +158,7 @@ enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; * @genfifoentry: Used for storing the genfifoentry instruction. * @mode: Defines the mode in which QSPI is operating * @data_completion: completion structure + * @op_lock: Operational lock */ struct zynqmp_qspi { struct spi_controller *ctlr; @@ -739,6 +741,8 @@ static irqreturn_t zynqmp_qspi_irq(int irq, void *dev_id) /** * zynqmp_qspi_setuprxdma - This function sets up the RX DMA operation * @xqspi: xqspi is a pointer to the GQSPI instance. + * + * Return: 0 on success; error value otherwise. */ static int zynqmp_qspi_setuprxdma(struct zynqmp_qspi *xqspi) { @@ -823,6 +827,8 @@ static void zynqmp_qspi_write_op(struct zynqmp_qspi *xqspi, u8 tx_nbits, * @rx_nbits: Receive buswidth. * @genfifoentry: genfifoentry is pointer to the variable in which * GENFIFO mask is returned to calling function + * + * Return: 0 on success; error value otherwise. */ static int zynqmp_qspi_read_op(struct zynqmp_qspi *xqspi, u8 rx_nbits, u32 genfifoentry) From patchwork Sun Sep 25 18:07:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kumar Mahapatra X-Patchwork-Id: 610030 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E500C54EE9 for ; Sun, 25 Sep 2022 18:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232925AbiIYSIT (ORCPT ); Sun, 25 Sep 2022 14:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbiIYSIS (ORCPT ); Sun, 25 Sep 2022 14:08:18 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 447442A94F; Sun, 25 Sep 2022 11:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bo+2Roe6CF0GvZ0w4hEgja3WPsQplXYOpBDqDKNNWyFvvWFHKFNoWEWPZOUAIuqubS6M9P4v6TBv55IxRY9Qt3tXTQ2t5IoVoC8XVIyOOZ961mkbhXt6NmBlvdMQA/m6s+qUdgJJLOq4cRs4MqpVMipb4qCFe5z9OdvXBFvPkKI6skGhn1EtnD3pSGmHNAyOsDbHyK6QcKwG4F5Eo3XE/N+dbBEeAoFoeNYt/zKWdy6ZUtMUQmj51UVLrmY1dnUnUzE/ZDVqwhANsQLR0OXbTr7aI4U4l+linmdcTRshmhbiaIueXUKp7CPGDgLmoqzNh2wLwOWtjKHTihDTp8x6jw== 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=e0XSmwsYhzBzkLphw6Dkc/Poa9iVIJtLOAXsA3sEI8g=; b=PsnKyhFSQAf9+ka/HGB/HL4bsXZRKGloBL9n1ATLR7bQYv2RvrLKsqXvs3T35u1lkDQpJzy/xpHitWIAErO0FmJfFfCGrqmXX/SlSDpDBmSRT6YsQSCkS40udT3d7YCUT3Bi40aerYsh1ZUMIa+4hwsFUpESVY6UzvNTFQ0+2WJA1eTxLzWoMy9yCNXwDwcapImwSIrnRyIegcNmwRCZ2lPKY9/fj0rTDebQiAq7Zihfmar13ICfIFR8vDsy7tGXM4kbHx6YvMXVJ6g6u2NJ5JPO5vGHt+oRzXgyvn7DNn40yDwS7V5DNbB7bPm0waFTVOh/KZBd6fqbbC1pIJX7KA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=kernel.org 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=e0XSmwsYhzBzkLphw6Dkc/Poa9iVIJtLOAXsA3sEI8g=; b=bE66IjamRSXHpTUZXdJNBa+V2W831TAMD8JzMWWoMFUUP/nDnvZyxYgEoTGpSGqKZGO0uum0xRN4v8FvsvzvQ5OId9a3BhdYyjxtjviglafi2cc6fvvKyZ7QhfbbbGvPFNLeDtZoweCJWM0fw1s1eAFH7QM/8CmJyA99G3W3JdE= Received: from SN7PR04CA0051.namprd04.prod.outlook.com (2603:10b6:806:120::26) by CO6PR02MB7697.namprd02.prod.outlook.com (2603:10b6:303:ad::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Sun, 25 Sep 2022 18:08:14 +0000 Received: from SN1NAM02FT0014.eop-nam02.prod.protection.outlook.com (2603:10b6:806:120:cafe::50) by SN7PR04CA0051.outlook.office365.com (2603:10b6:806:120::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24 via Frontend Transport; Sun, 25 Sep 2022 18:08:13 +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 SN1NAM02FT0014.mail.protection.outlook.com (10.97.4.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Sun, 25 Sep 2022 18:08:13 +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.9; Sun, 25 Sep 2022 11:07:50 -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.2507.9 via Frontend Transport; Sun, 25 Sep 2022 11:07:50 -0700 Envelope-to: broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, akumarma@amd.com, git@amd.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, amit.kumar-mahapatra@amd.com Received: from [10.140.6.18] (port=44788 helo=xhdlakshmis40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ocW2f-0001TD-Id; Sun, 25 Sep 2022 11:07:50 -0700 From: Amit Kumar Mahapatra To: , , CC: , , , , , , , , Amit Kumar Mahapatra Subject: [PATCH v3 2/7] spi: spi-zynqmp-gqspi: Set CPOL and CPHA during hardware init Date: Sun, 25 Sep 2022 23:37:34 +0530 Message-ID: <20220925180739.21612-3-amit.kumar-mahapatra@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> References: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0014:EE_|CO6PR02MB7697:EE_ X-MS-Office365-Filtering-Correlation-Id: e0a629be-bff3-4022-182f-08da9f20e9ec 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: WEu2OI6J1nZ9zjwwSPmKYkQ2JXtuvIQEBXRnERFJgmrkT9W+hJoK7HgBlL0nsG5YQu6t2nzKHoC/pnzYrZgEWtZfydBvS6pMbJDcowKsuuk5xZvSUSeukJGdFQMcCqw8Rf89dPpfIGVAdE8CZm4bIqOwUugDl8bLqe/6BIN7h1j8h5mPYuf7rf07FPgyDtu3L3cI55kiuuLcShIXaUuW9172hEvwe0D+cUT1XQ72omuuQVsLOh10DMKvDCXPntBb8t3Ov5nPOxEtbziUXrfm8h8JJ7GPGVnqwxvyBvhR4/bbKFshCOtYHvEoYQeFiPxn9k9LAJFMROP6ijcdh+BnvPmd6Bakl8PTAHsTDAGhXW0CDtl9Ox/KuAx/Uuu57v98qRXVxUfXT5rqGD+8d5o6T8Eox9fh9m4PX1PX942ul/YJJEOX57Ei7fBhFIfw/mvy3eDen2EGDqT8SIpOTcKfC4+701q8fhcJOH3A3aCQzCEbt7zyVZZkOi4+Xl9d3hS0Z8KsmYE5BXDdFjHcbknDiWgLQo//T7WsvLFWp57CCPno2ZIhdV6Ds6RgeJBBQEMPbnGV3Lx4Djv4fW1ctuyh3hUxCylt9cpafMUUZXtVfqE8IUaZcgTjAmbeWBI70n4CnMJccMZVihurWUEucKteVEUjUTpGkG7C7nS7FhRoQr3KXAk2G/AbUOmnKch4uBOK1VavhW6/JDz/nuOXlY2BG72ClCQnLXlr0VoLWNnIYAs08brStz/5UevaaABJczcWPM30vXkFpURyz3o14vtN27eyoGGEikb/lEsYud7CApo= 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:(13230022)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199015)(46966006)(40470700004)(36840700001)(478600001)(316002)(54906003)(6666004)(41300700001)(70206006)(70586007)(186003)(9786002)(5660300002)(8936002)(7416002)(26005)(2616005)(1076003)(2906002)(336012)(82740400003)(107886003)(7696005)(36860700001)(36756003)(426003)(47076005)(110136005)(4326008)(8676002)(40460700003)(40480700001)(356005)(83380400001)(82310400005)(7636003)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2022 18:08:13.7742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0a629be-bff3-4022-182f-08da9f20e9ec 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: SN1NAM02FT0014.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR02MB7697 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org During every transfer GQSPI driver writes the CPOL & CPHA values to the configuration register. But the CPOL & CPHA values do not change in between multiple transfers, so moved the CPOL & CPHA initialization to hardware init so that the values are written only once. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 973008a30a09..1b56dd29057f 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -266,7 +266,9 @@ static void zynqmp_gqspi_selectslave(struct zynqmp_qspi *instanceptr, * - Enable manual slave select * - Enable manual start * - Deselect all the chip select lines - * - Set the little endian mode of TX FIFO and + * - Set the little endian mode of TX FIFO + * - Set clock phase + * - Set clock polarity and * - Enable the QSPI controller */ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) @@ -305,10 +307,17 @@ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) config_reg |= GQSPI_CFG_WP_HOLD_MASK; /* Clear pre-scalar by default */ config_reg &= ~GQSPI_CFG_BAUD_RATE_DIV_MASK; - /* CPHA 0 */ - config_reg &= ~GQSPI_CFG_CLK_PHA_MASK; - /* CPOL 0 */ - config_reg &= ~GQSPI_CFG_CLK_POL_MASK; + /* Set CPHA */ + if (xqspi->ctlr->mode_bits & SPI_CPHA) + config_reg |= GQSPI_CFG_CLK_PHA_MASK; + else + config_reg &= ~GQSPI_CFG_CLK_PHA_MASK; + /* Set CPOL */ + if (xqspi->ctlr->mode_bits & SPI_CPOL) + config_reg |= GQSPI_CFG_CLK_POL_MASK; + else + config_reg &= ~GQSPI_CFG_CLK_POL_MASK; + zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg); /* Clear the TX and RX FIFO */ @@ -470,14 +479,6 @@ static int zynqmp_qspi_config_op(struct zynqmp_qspi *xqspi, config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST); - /* Set the QSPI clock phase and clock polarity */ - config_reg &= (~GQSPI_CFG_CLK_PHA_MASK) & (~GQSPI_CFG_CLK_POL_MASK); - - if (qspi->mode & SPI_CPHA) - config_reg |= GQSPI_CFG_CLK_PHA_MASK; - if (qspi->mode & SPI_CPOL) - config_reg |= GQSPI_CFG_CLK_POL_MASK; - config_reg &= ~GQSPI_CFG_BAUD_RATE_DIV_MASK; config_reg |= (baud_rate_val << GQSPI_CFG_BAUD_RATE_DIV_SHIFT); zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg); @@ -1170,6 +1171,9 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) goto clk_dis_all; } + ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD | + SPI_TX_DUAL | SPI_TX_QUAD; + /* QSPI controller initializations */ zynqmp_qspi_init_hw(xqspi); @@ -1207,8 +1211,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ctlr->setup = zynqmp_qspi_setup_op; ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2; ctlr->bits_per_word_mask = SPI_BPW_MASK(8); - ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD | - SPI_TX_DUAL | SPI_TX_QUAD; ctlr->dev.of_node = np; ctlr->auto_runtime_pm = true; From patchwork Sun Sep 25 18:07:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kumar Mahapatra X-Patchwork-Id: 609304 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10EE0C04A95 for ; Sun, 25 Sep 2022 18:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232965AbiIYSIX (ORCPT ); Sun, 25 Sep 2022 14:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbiIYSIU (ORCPT ); Sun, 25 Sep 2022 14:08:20 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F135D2A94F; Sun, 25 Sep 2022 11:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=froe8U22lPAsyFYDKb8gz7GeeS/xXvArdu0Xi4i+37PC3J3lDOUMMbBndMK3YP8wZ3tuJv+BBczUUUNDe9AABE5YuZNgvj7OeFBpKEZ/koqAoZ0lc3hxitc9PFBxImCq6eDkTliBA7Hn8pTWxO4Mfpt9Z8ktDngHpGI9ZAm5hf5wXEjExrZNp6kKzHoMCj3dVSX/iMz2qPupggdhrVJETAQmZ+UTDxUEo1MfhxSVKPw2pL64KMh2wMF1YFAVL8XLCeD7V3AY8DKNHK28AcXcIR3ZjjjcQqnWzzeImQDJy8Ad33Gbu0qk4XLwN1JHOfMXjbjT7sNI0fuQxxEE6eDFqQ== 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=n62TMUhbtw7CZp6V4FfxOA4/3OrlBP2cy/grjGanfkM=; b=LReMlCsj915Y0IglZqV9d2aRh1MytXqyko82jsIeeUQV5r7uHkbsEUO3ztCXhFdYspKfQ14cqpLtdUbYHUIlH+eK9SbhMarXT/U/qF0sgKEzAGMkmzgQ3gk2uWumQRU4hcEy8dxxE6Tj9xlvVRMX+xEIC6S1T9syTg0GGExoDVOkky+vL+V7udUzeL0hlQF22km4M9gemLl+JS9V/1fZl5GQSx1DFqvtygcBS9IJw6tCnn6Z11JzH4e0hwB8Bwlf1RSl/fkcFa4+CfgK5xfG3Asj0gmt/ayju80bfhFhNZbCx+iKeVtRYtrSCh3C/ZoDJhgYDw5P4LuMlgyyx0ZUmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=kernel.org 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=n62TMUhbtw7CZp6V4FfxOA4/3OrlBP2cy/grjGanfkM=; b=AsshXKL4D52vuLLXA5Ef00XPel7D9etZ+OFbXfe0J/VDdaHhcpkE+9wf4aujrOGDwJp8J3y8Q22HhsinQ/7vqz/G6KhxZb8qN377BKf2WddPP3T7uGZedRaSpFnY2F0MjwxqWkeC7nU54gWc4huFWV1ousHcf0G6SN+dq3zZsdk= Received: from SN7PR04CA0032.namprd04.prod.outlook.com (2603:10b6:806:120::7) by PH0PR02MB8534.namprd02.prod.outlook.com (2603:10b6:510:10d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Sun, 25 Sep 2022 18:08:17 +0000 Received: from SN1NAM02FT0014.eop-nam02.prod.protection.outlook.com (2603:10b6:806:120:cafe::f6) by SN7PR04CA0032.outlook.office365.com (2603:10b6:806:120::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24 via Frontend Transport; Sun, 25 Sep 2022 18:08:17 +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 SN1NAM02FT0014.mail.protection.outlook.com (10.97.4.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Sun, 25 Sep 2022 18:08:17 +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.9; Sun, 25 Sep 2022 11:07:53 -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.2507.9 via Frontend Transport; Sun, 25 Sep 2022 11:07:53 -0700 Envelope-to: broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, akumarma@amd.com, git@amd.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, amit.kumar-mahapatra@amd.com Received: from [10.140.6.18] (port=44788 helo=xhdlakshmis40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ocW2i-0001TD-V7; Sun, 25 Sep 2022 11:07:53 -0700 From: Amit Kumar Mahapatra To: , , CC: , , , , , , , , Amit Kumar Mahapatra Subject: [PATCH v3 3/7] spi: spi-zynqmp-gqspi: Avoid setting baud rate multiple times for same SPI frequency Date: Sun, 25 Sep 2022 23:37:35 +0530 Message-ID: <20220925180739.21612-4-amit.kumar-mahapatra@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> References: <20220925180739.21612-1-amit.kumar-mahapatra@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0014:EE_|PH0PR02MB8534:EE_ X-MS-Office365-Filtering-Correlation-Id: 6421c1f0-69dc-410b-92ce-08da9f20ebf8 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: RJE1+Ht+gTDdurc+Ilxtuk4LmHAKVWvSfWnVN464uAWagLj8V3qU9TV2wMxm104TOUjPhcMaz+F8q9+Q7k9ATRRgR5bXUMzKrGNRJlgcROknsmTqDVe9JQsRXkRYuTJrwCeKqOtlPirsVydbYFmWRLm9oMRnh1Cwe/7/aD2KMF1l8deTsgTOpYH7iv2OXPM9QAVsnSPB28jjizIJAHvW8EKnRubLhL5a1NGNvsYUr1xnmu0D9hblJI95izWJMNQc5tuGvsm9hjn9knk4NNXwEN/EWorquB/WgIkXBzY407OeFHokuMC3d/VaTaCIKxt0TNHUqVu8wW5oIGRF9IEUDsuGcrDeP2U+vxFv3WCCsJfHcXEC3pfbXqThPohmbBeWUapll1ntWJqb8J7G/B05a6HCfLLiIzGYCtF73rXiUWHCuba3Ee3PJMgdTMVhdBHvrpwAAs8MjA5zhCGZ9BXLn4sF+pNaxRVPacqnddTukJ36GXf8Sv89Um+O8qFsuRh1uqKXdLCb1ezZ5QS+TIjHpfhan6nhNylv4LOEGubQ81l4iXw6DCaTXLzQ/4WxbJhPR8F6OcbxQbTbVEkysaFszI1O7z6vjS35Gv4gxnRggegdMfX5HYJzeTpcm+aF8P5FU0mvozpaXhy6TjC4+LOuQ+jCfvrVxDbToGaYM5yR8thtTw43eiMZDIQEqF0bU4dlnAKDV81TGuaY8SyX/FsmbaIiD/aJmG+zha7fzd4hL3/zz+Ll/iLi6pFkYN+X0x+NMKKgsklk/IrTSrVtd9IQmqSz1z95UMX6lpqR2nVlPsE= 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:(13230022)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199015)(46966006)(40470700004)(36840700001)(4326008)(8676002)(70206006)(70586007)(186003)(1076003)(426003)(47076005)(336012)(26005)(107886003)(6666004)(7696005)(54906003)(110136005)(2616005)(316002)(36756003)(356005)(2906002)(5660300002)(7416002)(82740400003)(7636003)(40460700003)(41300700001)(83380400001)(40480700001)(8936002)(9786002)(36860700001)(82310400005)(478600001)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2022 18:08:17.2115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6421c1f0-69dc-410b-92ce-08da9f20ebf8 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: SN1NAM02FT0014.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8534 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org During every transfer the GQSPI driver configures the baud rate value. But when there is no change in the SPI clock frequency the driver should avoid rewriting the same baud rate value to the configuration register. Update GQSPI driver to rewrite the baud rate value if there is any change in SPI clock frequency. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 49 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 1b56dd29057f..0fecea338027 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -159,6 +159,7 @@ enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; * @mode: Defines the mode in which QSPI is operating * @data_completion: completion structure * @op_lock: Operational lock + * @speed_hz: Current SPI bus clock speed in hz */ struct zynqmp_qspi { struct spi_controller *ctlr; @@ -179,6 +180,7 @@ struct zynqmp_qspi { enum mode_type mode; struct completion data_completion; struct mutex op_lock; + u32 speed_hz; }; /** @@ -273,7 +275,8 @@ static void zynqmp_gqspi_selectslave(struct zynqmp_qspi *instanceptr, */ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) { - u32 config_reg; + u32 config_reg, baud_rate_val = 0; + ulong clk_rate; /* Select the GQSPI mode */ zynqmp_gqspi_write(xqspi, GQSPI_SEL_OFST, GQSPI_SEL_MASK); @@ -318,6 +321,16 @@ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) else config_reg &= ~GQSPI_CFG_CLK_POL_MASK; + /* Set the clock frequency */ + clk_rate = clk_get_rate(xqspi->refclk); + while ((baud_rate_val < GQSPI_BAUD_DIV_MAX) && + (clk_rate / + (GQSPI_BAUD_DIV_SHIFT << baud_rate_val)) > xqspi->speed_hz) + baud_rate_val++; + + config_reg &= ~GQSPI_CFG_BAUD_RATE_DIV_MASK; + config_reg |= (baud_rate_val << GQSPI_CFG_BAUD_RATE_DIV_SHIFT); + zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg); /* Clear the TX and RX FIFO */ @@ -466,22 +479,29 @@ static int zynqmp_qspi_config_op(struct zynqmp_qspi *xqspi, struct spi_device *qspi) { ulong clk_rate; - u32 config_reg, baud_rate_val = 0; + u32 config_reg, req_speed_hz, baud_rate_val = 0; - /* Set the clock frequency */ - /* If req_hz == 0, default to lowest speed */ - clk_rate = clk_get_rate(xqspi->refclk); + req_speed_hz = qspi->max_speed_hz; - while ((baud_rate_val < GQSPI_BAUD_DIV_MAX) && - (clk_rate / - (GQSPI_BAUD_DIV_SHIFT << baud_rate_val)) > qspi->max_speed_hz) - baud_rate_val++; + if (xqspi->speed_hz != req_speed_hz) { + xqspi->speed_hz = req_speed_hz; - config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST); + /* Set the clock frequency */ + /* If req_speed_hz == 0, default to lowest speed */ + clk_rate = clk_get_rate(xqspi->refclk); - config_reg &= ~GQSPI_CFG_BAUD_RATE_DIV_MASK; - config_reg |= (baud_rate_val << GQSPI_CFG_BAUD_RATE_DIV_SHIFT); - zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg); + while ((baud_rate_val < GQSPI_BAUD_DIV_MAX) && + (clk_rate / + (GQSPI_BAUD_DIV_SHIFT << baud_rate_val)) > + req_speed_hz) + baud_rate_val++; + + config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST); + + config_reg &= ~GQSPI_CFG_BAUD_RATE_DIV_MASK; + config_reg |= (baud_rate_val << GQSPI_CFG_BAUD_RATE_DIV_SHIFT); + zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg); + } return 0; } @@ -1173,6 +1193,8 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_DUAL | SPI_TX_QUAD; + ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2; + xqspi->speed_hz = ctlr->max_speed_hz; /* QSPI controller initializations */ zynqmp_qspi_init_hw(xqspi); @@ -1209,7 +1231,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ctlr->bits_per_word_mask = SPI_BPW_MASK(8); ctlr->mem_ops = &zynqmp_qspi_mem_ops; ctlr->setup = zynqmp_qspi_setup_op; - ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2; ctlr->bits_per_word_mask = SPI_BPW_MASK(8); ctlr->dev.of_node = np; ctlr->auto_runtime_pm = true;