From patchwork Wed Jul 5 09:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13301851 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 5F067C0015E for ; Wed, 5 Jul 2023 09:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbjGEJCM (ORCPT ); Wed, 5 Jul 2023 05:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232334AbjGEJCD (ORCPT ); Wed, 5 Jul 2023 05:02:03 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C68A199A for ; Wed, 5 Jul 2023 02:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1688547715; x=1720083715; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2St3MLrk2aG2ULQGB2nTNOi3wjOqaquFdKHHdlBbA7s=; b=cRumMkSjAmZQFbOfEJNjQJaNmMO6z+kdQ3eHp/haWhSNhoB8CMl/AVKT vhK92awKkI7eLTTEZOsd0yEvIw82H5Y99Z36fUSIICsvyDZhqd0SbDdrE x8xqb0oJxN2qt9L6G14ZiTxcLwUBRKmssvMzKHA6DRGJPO2ZumCEzywZ9 p3ZF8ucUYZHetYb3avMsSbc3sGdtW3ziUT8XWjeljEsXLSmkPIEjKpNWF fOewsoaAquAWaYENHmKSiusf9dFvaAK+6sTbhB2jUwEIiBJf4IJtgIMx6 e7aL2V98ebExXHeizoI/DELZlilamOB3fJTuXQGnipFTIpZFrt2dJq26V w==; X-IronPort-AV: E=Sophos;i="6.01,182,1684792800"; d="scan'208";a="31764883" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 05 Jul 2023 11:01:53 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 33B7E280087; Wed, 5 Jul 2023 11:01:53 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Date: Wed, 5 Jul 2023 11:01:43 +0200 Message-Id: <20230705090145.1354663-1-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This is only used during probe() call, so there is no need to store it longer than that. Signed-off-by: Alexander Stein --- drivers/spi/spi-fsl-lpspi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index fb68c72df171..486f4bc488fd 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -98,7 +98,6 @@ struct fsl_lpspi_data { struct clk *clk_ipg; struct clk *clk_per; bool is_slave; - u32 num_cs; bool is_only_cs1; bool is_first_byte; @@ -826,6 +825,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) struct spi_controller *controller; struct resource *res; int ret, irq; + u32 num_cs; u32 temp; bool is_slave; @@ -848,8 +848,8 @@ static int fsl_lpspi_probe(struct platform_device *pdev) fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node, "fsl,spi-only-use-cs1-sel"); if (of_property_read_u32((&pdev->dev)->of_node, "num-cs", - &fsl_lpspi->num_cs)) - fsl_lpspi->num_cs = 1; + &num_cs)) + num_cs = 1; controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); controller->transfer_one = fsl_lpspi_transfer_one; @@ -859,7 +859,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; controller->dev.of_node = pdev->dev.of_node; controller->bus_num = pdev->id; - controller->num_chipselect = fsl_lpspi->num_cs; + controller->num_chipselect = num_cs; controller->slave_abort = fsl_lpspi_slave_abort; if (!fsl_lpspi->is_slave) controller->use_gpio_descriptors = true; From patchwork Wed Jul 5 09:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13301852 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 6D912C0015E for ; Wed, 5 Jul 2023 09:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232280AbjGEJCZ (ORCPT ); Wed, 5 Jul 2023 05:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbjGEJCS (ORCPT ); Wed, 5 Jul 2023 05:02:18 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C658E1BCC for ; Wed, 5 Jul 2023 02:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1688547721; x=1720083721; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QHWl1ZsYAtZFfHeU+QNzJosNvCJ8GCAn6dXN91Pu4p8=; b=bVQC7y33fPpGYVB5/Zg5ZaeCKYX9Zs8PBxToIpAWclQRMeH3HgFH2pXR s96Wk6fN1A3eSXYyuG1F7H9I4VJqcEpN+SIYlbuUAgJcprqUhfxH7Yiih mBpQcS4gIEAw9YYDw+FQLsAdQyf7JgtQxDZHnbDnqAM4bXZU66HI30b7r bOJpMY5TUivozUl0hayD3Sz1I/qhpiWN1UxARUXH1mx/fkfDdtXmYyZvC o5ALDLPVBkpm+xBQblU8iMXGZwij4DF0r5k0WHl+3Y3btyv4xfitxGRYo KB+gCbC7dSB/vMrBrz4bpaO9dVR4WrRjcciWvjM7VtLx2m0vT1An9Q1Hp g==; X-IronPort-AV: E=Sophos;i="6.01,182,1684792800"; d="scan'208";a="31764884" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 05 Jul 2023 11:01:53 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 4C9D7280088; Wed, 5 Jul 2023 11:01:53 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Date: Wed, 5 Jul 2023 11:01:44 +0200 Message-Id: <20230705090145.1354663-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230705090145.1354663-1-alexander.stein@ew.tq-group.com> References: <20230705090145.1354663-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This is a preparation for reading number of chip-selects from hardware. This needs IO resources mapped and peripheral clocking enabled. No functional changes intended. Signed-off-by: Alexander Stein --- I opted to keep the controller assignments together for readability, although not strictly necessary. drivers/spi/spi-fsl-lpspi.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 486f4bc488fd..4b4d25e13ca4 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -847,22 +847,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev) fsl_lpspi->is_slave = is_slave; fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node, "fsl,spi-only-use-cs1-sel"); - if (of_property_read_u32((&pdev->dev)->of_node, "num-cs", - &num_cs)) - num_cs = 1; - - controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); - controller->transfer_one = fsl_lpspi_transfer_one; - controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware; - controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware; - controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; - controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; - controller->dev.of_node = pdev->dev.of_node; - controller->bus_num = pdev->id; - controller->num_chipselect = num_cs; - controller->slave_abort = fsl_lpspi_slave_abort; - if (!fsl_lpspi->is_slave) - controller->use_gpio_descriptors = true; init_completion(&fsl_lpspi->xfer_done); @@ -912,6 +896,22 @@ static int fsl_lpspi_probe(struct platform_device *pdev) temp = readl(fsl_lpspi->base + IMX7ULP_PARAM); fsl_lpspi->txfifosize = 1 << (temp & 0x0f); fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f); + if (of_property_read_u32((&pdev->dev)->of_node, "num-cs", + &num_cs)) + num_cs = 1; + + controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); + controller->transfer_one = fsl_lpspi_transfer_one; + controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware; + controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware; + controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; + controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; + controller->dev.of_node = pdev->dev.of_node; + controller->bus_num = pdev->id; + controller->num_chipselect = num_cs; + controller->slave_abort = fsl_lpspi_slave_abort; + if (!fsl_lpspi->is_slave) + controller->use_gpio_descriptors = true; ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller); if (ret == -EPROBE_DEFER) From patchwork Wed Jul 5 09:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13301853 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 2C826EB64DA for ; Wed, 5 Jul 2023 09:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjGEJC2 (ORCPT ); Wed, 5 Jul 2023 05:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbjGEJCX (ORCPT ); Wed, 5 Jul 2023 05:02:23 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B271727 for ; Wed, 5 Jul 2023 02:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1688547722; x=1720083722; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CCiU6JSUONVV+wche7PFnEEtldA36zBzDsC0Qvocb2Q=; b=LaNdklw0QFYY1vnmX2a7WhvzsO5T58t20TX46F1xT0pSEhEZXNJO4u3d 5qdQU9nEhrLUYIwccvKqNdn1WBAvBugjfcGXS5c/+YnPVUvlqxRB+gpdU lnvJ8LCs4jdoBUyQU5dIu4vtgHlL/JLft4+pP3gvUPB7NBp3hSjSdyhSd wAI60jr388JA8Cr+m/wYO4wWylcScDe69XwDbq4zR1Qymiqu4c9OrMl44 L6AJc2BWOW1ezVTSur8d3cv03X9eN/qFtTW+hSkmE3ZucJC0vCFQp7xe4 /3Q9Fc8dD9vxnqT6X5MSzOKQQiNdJXatHPXNTKxMKfXIE+TDRyNEFapWI A==; X-IronPort-AV: E=Sophos;i="6.01,182,1684792800"; d="scan'208";a="31764885" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 05 Jul 2023 11:01:53 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 64E6028008A; Wed, 5 Jul 2023 11:01:53 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93 Date: Wed, 5 Jul 2023 11:01:45 +0200 Message-Id: <20230705090145.1354663-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230705090145.1354663-1-alexander.stein@ew.tq-group.com> References: <20230705090145.1354663-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org PARAM.PCSNUM register on i.MX93 indicates the number of supported (hw) chip-selects. LPSPI4 has 3 while others have only 2. Still allow overwriting from DT. Signed-off-by: Alexander Stein --- I've checked i.MX7ULP and i.MX8QM reference manuals and only i.MX93 has these PCSNUM bits defined in PARAM register. drivers/spi/spi-fsl-lpspi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 4b4d25e13ca4..540495dc4bc9 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -897,8 +897,12 @@ static int fsl_lpspi_probe(struct platform_device *pdev) fsl_lpspi->txfifosize = 1 << (temp & 0x0f); fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f); if (of_property_read_u32((&pdev->dev)->of_node, "num-cs", - &num_cs)) - num_cs = 1; + &num_cs)) { + if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx93-spi")) + num_cs = ((temp >> 16) & 0xf); + else + num_cs = 1; + } controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); controller->transfer_one = fsl_lpspi_transfer_one;