From patchwork Mon Jul 17 08:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13315349 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 2DF0AEB64DC for ; Mon, 17 Jul 2023 08:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjGQI7y (ORCPT ); Mon, 17 Jul 2023 04:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjGQI7u (ORCPT ); Mon, 17 Jul 2023 04:59:50 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BACA01BE for ; Mon, 17 Jul 2023 01:59:48 -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=1689584388; x=1721120388; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9gRugZHOgV4c+QqZlYJH19hQNzFjnCXyL1pKBi3wnJc=; b=An/f49AyeUm+nBS/FVY6BABxGz4/S82d6YL+L/dnYTT0XOvyKU2Q2cE+ f20J8Zy60k3GGJ1NcX0dtIJEHJBcLJiwlSWaPi1Six6a0zsfzsW3LseDc iZj24lseA189dkjxnDoOUCsKFTpzg3E7fHl1ZWTAShWUYyjCGcuiP3Wn8 0Rjg3DhnVAIq/alx320jkuXQIxZzass6ibZ4Po6mlMPaJ1Lw27OJ7zKSp yGuWpCM162IXQJyY4Nzfb9Y0qYTyTZW07XfbCFFvfKt0/8dQ/p9i2D/Xe 7yTHgWC41iB8VFTqNxLLp1RypeS3VW+4uDbSQyrX2307VUipYSOdmfhBV A==; X-IronPort-AV: E=Sophos;i="6.01,211,1684792800"; d="scan'208";a="31958423" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 17 Jul 2023 10:59:47 +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 02587280078; Mon, 17 Jul 2023 10:59:46 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Date: Mon, 17 Jul 2023 10:59:32 +0200 Message-Id: <20230717085934.409476-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 --- Changes in v2: * Rebase to next-20230717 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 dfdcb69f66ab..0a0677f11a3d 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -97,7 +97,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; @@ -825,6 +824,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; @@ -847,8 +847,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; @@ -858,7 +858,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) controller->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_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 Mon Jul 17 08:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13315351 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 526F2C001E0 for ; Mon, 17 Jul 2023 08:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbjGQI7z (ORCPT ); Mon, 17 Jul 2023 04:59:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjGQI7v (ORCPT ); Mon, 17 Jul 2023 04:59:51 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7450EE7F for ; Mon, 17 Jul 2023 01:59:50 -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=1689584390; x=1721120390; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Atl7ulgRmZbBVqo6NH76K5Mj40dfQz/WNoIzmN0IuHk=; b=Vgq50qpv9Q6yx05KERGRXBIb4afBmLXdjTnihFZNoQPMfNy11R+GAvDQ 8pgKHpN4SuwU7VwoXuVwdA9dfzfZB53p+pFxDtm7I/N75z5bZSBzgO9IU EilZgIPWN26BRZy6mq2Jdd85HzXhN9KLEUTSEXZBT0ml5E8Xu/laQQNPE x3bblKQlLN5bhGCQXLeVHUXZENE2OFm4PppeRLoRUtdKKgI8jdzHveiie u9qpL5Hj6g30ROBiKzc3t1X1rPYkbICERBzW5M3t4stRb+aBpqOCPwA87 on4NWGueSO5VC3mrAt+PM904+a1nRUGi/7o5ymP1yoaw6o0tlXnS0fIEu Q==; X-IronPort-AV: E=Sophos;i="6.01,211,1684792800"; d="scan'208";a="31958424" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 17 Jul 2023 10:59:47 +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 1CF6E280084; Mon, 17 Jul 2023 10:59:47 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Date: Mon, 17 Jul 2023 10:59:33 +0200 Message-Id: <20230717085934.409476-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717085934.409476-1-alexander.stein@ew.tq-group.com> References: <20230717085934.409476-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 --- Changes in v2: * Rebase to next-20230717 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 0a0677f11a3d..f3b7bb1e52eb 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -846,22 +846,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_CONTROLLER_MUST_RX | SPI_CONTROLLER_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); @@ -911,6 +895,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_CONTROLLER_MUST_RX | SPI_CONTROLLER_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 Mon Jul 17 08:59:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13315350 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 9A444C001B0 for ; Mon, 17 Jul 2023 08:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbjGQI7z (ORCPT ); Mon, 17 Jul 2023 04:59:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjGQI7x (ORCPT ); Mon, 17 Jul 2023 04:59:53 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC7C2E58 for ; Mon, 17 Jul 2023 01:59:51 -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=1689584391; x=1721120391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pe+J8Ph/L1AS+x+SkGE3jMZdvxTA0GLnex7gb2D1+Xc=; b=EIBPagrKj66sKkgdyt2IbrUz2LZUBXFCS3Xjv15RkpzIwOxn//2qfJOF X43OAVx8ymqKq/fCMRu0sKCkiSO62Nzoa5Occ+SrFS/hQYo+MEgA0qb/C 0mhUL5AkRuWofu5KqOV+0/YqZp89ZenLpmmqH0DyyHU85n8xYGXmBvXfo myDUQFm0B9nJ0yl0IH10b5JrhlWXQydobx6aVGj/FQQuTmRO55eNQ3Qjc WCU+v4RDCeQ8v5Nupxaz7fV6rAFJWw87w9X1btlXZf2lhg8VbdJzPgdXx eZkeSYdrbajEbG483C41pALKBbLr592RHIR1U7Dbk9n9MzfGsu9uKWBwJ g==; X-IronPort-AV: E=Sophos;i="6.01,211,1684792800"; d="scan'208";a="31958425" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 17 Jul 2023 10:59:47 +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 37BEE280085; Mon, 17 Jul 2023 10:59:47 +0200 (CEST) From: Alexander Stein To: Mark Brown Cc: Alexander Stein , linux-spi@vger.kernel.org Subject: [PATCH v2 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93 Date: Mon, 17 Jul 2023 10:59:34 +0200 Message-Id: <20230717085934.409476-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717085934.409476-1-alexander.stein@ew.tq-group.com> References: <20230717085934.409476-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 --- Changes in v2: * Rebase to next-20230717 (no change on the diff though) 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 f3b7bb1e52eb..e32e8cab5aa8 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -896,8 +896,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;