* [PATCH 1/2] spi: stm32: disable device mode with st,stm32f4-spi compatible
2023-06-21 11:55 [PATCH 0/2] spi: stm32: disable spi device mode for stm32f4-f7 Valentin Caron
@ 2023-06-21 11:55 ` Valentin Caron
2023-06-21 12:25 ` Krzysztof Kozlowski
2023-06-21 11:55 ` [PATCH 2/2] spi: dt-bindings: stm32: do not disable spi-slave property for stm32f4-f7 Valentin Caron
2023-06-23 0:32 ` (subset) [PATCH 0/2] spi: stm32: disable spi device mode " Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Valentin Caron @ 2023-06-21 11:55 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Alexandre Torgue, Alain Volmat, linux-spi, devicetree,
linux-stm32, linux-arm-kernel, linux-kernel, Valentin Caron
STM32 SPI driver is not capable to handle device mode with stm32f4/f7 soc.
Stop probing if this case happens.
Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
---
drivers/spi/spi-stm32.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 6d10fa4ab783..f71712af43d4 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -238,6 +238,7 @@ struct stm32_spi;
* @baud_rate_div_min: minimum baud rate divisor
* @baud_rate_div_max: maximum baud rate divisor
* @has_fifo: boolean to know if fifo is used for driver
+ * @has_device_mode: is this compatible capable to switch on device mode
* @flags: compatible specific SPI controller flags used at registration time
*/
struct stm32_spi_cfg {
@@ -259,6 +260,7 @@ struct stm32_spi_cfg {
unsigned int baud_rate_div_min;
unsigned int baud_rate_div_max;
bool has_fifo;
+ bool has_device_mode;
u16 flags;
};
@@ -1750,6 +1752,7 @@ static const struct stm32_spi_cfg stm32f4_spi_cfg = {
.baud_rate_div_min = STM32F4_SPI_BR_DIV_MIN,
.baud_rate_div_max = STM32F4_SPI_BR_DIV_MAX,
.has_fifo = false,
+ .has_device_mode = false,
.flags = SPI_MASTER_MUST_TX,
};
@@ -1774,6 +1777,7 @@ static const struct stm32_spi_cfg stm32h7_spi_cfg = {
.baud_rate_div_min = STM32H7_SPI_MBR_DIV_MIN,
.baud_rate_div_max = STM32H7_SPI_MBR_DIV_MAX,
.has_fifo = true,
+ .has_device_mode = true,
};
static const struct of_device_id stm32_spi_of_match[] = {
@@ -1798,8 +1802,15 @@ static int stm32_spi_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
bool device_mode;
int ret;
+ const struct of_device_id *of_match =
+ of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
+ const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)of_match->data;
device_mode = of_property_read_bool(np, "spi-slave");
+ if (!cfg->has_device_mode && device_mode) {
+ dev_err(&pdev->dev, "spi-slave not yet supported with %s\n", of_match->compatible);
+ return -EPERM;
+ }
if (device_mode)
ctrl = devm_spi_alloc_slave(&pdev->dev, sizeof(struct stm32_spi));
@@ -1817,9 +1828,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
spi->device_mode = device_mode;
spin_lock_init(&spi->lock);
- spi->cfg = (const struct stm32_spi_cfg *)
- of_match_device(pdev->dev.driver->of_match_table,
- &pdev->dev)->data;
+ spi->cfg = cfg;
spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(spi->base))
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] spi: dt-bindings: stm32: do not disable spi-slave property for stm32f4-f7
2023-06-21 11:55 [PATCH 0/2] spi: stm32: disable spi device mode for stm32f4-f7 Valentin Caron
2023-06-21 11:55 ` [PATCH 1/2] spi: stm32: disable device mode with st,stm32f4-spi compatible Valentin Caron
@ 2023-06-21 11:55 ` Valentin Caron
2023-06-21 12:23 ` Krzysztof Kozlowski
2023-06-23 0:32 ` (subset) [PATCH 0/2] spi: stm32: disable spi device mode " Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Valentin Caron @ 2023-06-21 11:55 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Alexandre Torgue, Alain Volmat, linux-spi, devicetree,
linux-stm32, linux-arm-kernel, linux-kernel, Valentin Caron
STM32F4-F7 are, from hardware point of view, capable to handle device mode.
So this property should not be forced at false in dt-bindings.
Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
---
Documentation/devicetree/bindings/spi/st,stm32-spi.yaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/spi/st,stm32-spi.yaml b/Documentation/devicetree/bindings/spi/st,stm32-spi.yaml
index f1c86e694af1..9ca1a843c820 100644
--- a/Documentation/devicetree/bindings/spi/st,stm32-spi.yaml
+++ b/Documentation/devicetree/bindings/spi/st,stm32-spi.yaml
@@ -27,7 +27,6 @@ allOf:
then:
properties:
st,spi-midi-ns: false
- spi-slave: false
properties:
compatible:
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: (subset) [PATCH 0/2] spi: stm32: disable spi device mode for stm32f4-f7
2023-06-21 11:55 [PATCH 0/2] spi: stm32: disable spi device mode for stm32f4-f7 Valentin Caron
2023-06-21 11:55 ` [PATCH 1/2] spi: stm32: disable device mode with st,stm32f4-spi compatible Valentin Caron
2023-06-21 11:55 ` [PATCH 2/2] spi: dt-bindings: stm32: do not disable spi-slave property for stm32f4-f7 Valentin Caron
@ 2023-06-23 0:32 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2023-06-23 0:32 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Valentin Caron
Cc: Alexandre Torgue, Alain Volmat, linux-spi, devicetree,
linux-stm32, linux-arm-kernel, linux-kernel
On Wed, 21 Jun 2023 13:55:21 +0200, Valentin Caron wrote:
> This series follows this thread:
> https://lore.kernel.org/all/20230615075815.310261-1-valentin.caron@foss.st.com/
>
> As STM32F4-F7 hardware can handle device mode and stm32 spi kernel
> driver can't, a restriction should be put in the kernel driver and
> not in the device-tree bindings. This series fixes that.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[2/2] spi: dt-bindings: stm32: do not disable spi-slave property for stm32f4-f7
commit: 01fa9edd8bcf1c4fe330ea000c3da9ecf76c76a0
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] 6+ messages in thread