linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct
@ 2023-07-17  8:59 Alexander Stein
  2023-07-17  8:59 ` [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Alexander Stein
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Stein @ 2023-07-17  8:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Alexander Stein, linux-spi

This is only used during probe() call, so there is no need to store it
longer than that.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down
  2023-07-17  8:59 [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Alexander Stein
@ 2023-07-17  8:59 ` Alexander Stein
  2023-07-17  8:59 ` [PATCH v2 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93 Alexander Stein
  2023-07-18 11:47 ` [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2023-07-17  8:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Alexander Stein, linux-spi

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 <alexander.stein@ew.tq-group.com>
---
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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93
  2023-07-17  8:59 [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Alexander Stein
  2023-07-17  8:59 ` [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Alexander Stein
@ 2023-07-17  8:59 ` Alexander Stein
  2023-07-18 11:47 ` [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2023-07-17  8:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Alexander Stein, linux-spi

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 <alexander.stein@ew.tq-group.com>
---
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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct
  2023-07-17  8:59 [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Alexander Stein
  2023-07-17  8:59 ` [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Alexander Stein
  2023-07-17  8:59 ` [PATCH v2 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93 Alexander Stein
@ 2023-07-18 11:47 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-07-18 11:47 UTC (permalink / raw)
  To: Alexander Stein; +Cc: linux-spi

On Mon, 17 Jul 2023 10:59:32 +0200, Alexander Stein wrote:
> This is only used during probe() call, so there is no need to store it
> longer than that.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct
      commit: a55265eeedafee12d9743196ce5bb43266509c31
[2/3] spi: spi-fsl-lpspi: Move controller initialization further down
      (no commit info)
[3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93
      (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-18 11:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17  8:59 [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Alexander Stein
2023-07-17  8:59 ` [PATCH v2 2/3] spi: spi-fsl-lpspi: Move controller initialization further down Alexander Stein
2023-07-17  8:59 ` [PATCH v2 3/3] spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93 Alexander Stein
2023-07-18 11:47 ` [PATCH v2 1/3] spi: spi-fsl-lpspi: Remove num_cs from device struct Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).