Skip to content

dts: arm: adi: Enable SPI for MAX32657 #92036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/adi/max32657evkit/max32657evkit_max32657.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ supported:
- dma
- counter
- pwm
- spi
ram: 256
flash: 960
6 changes: 6 additions & 0 deletions boards/adi/max32657evkit/max32657evkit_max32657_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@
&wdt0 {
status = "okay";
};

&spi0 {
status = "okay";
pinctrl-0 = <&spi0_mosi_p0_2 &spi0_miso_p0_4 &spi0_sck_p0_6 &spi0_ss0_p0_3>;
pinctrl-names = "default";
};
1 change: 1 addition & 0 deletions boards/adi/max32657evkit/max32657evkit_max32657_ns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ supported:
- dma
- counter
- pwm
- spi
ram: 192
flash: 576
10 changes: 5 additions & 5 deletions drivers/spi/spi_max32.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static int transceive(const struct device *dev, const struct spi_config *config,
spi_context_cs_control(ctx, true);
} else {
cfg->regs->ctrl0 =
(cfg->regs->ctrl0 & ~MXC_F_SPI_CTRL0_START) | MXC_F_SPI_CTRL0_SS_CTRL;
(cfg->regs->ctrl0 & ~MXC_F_SPI_CTRL0_START) | ADI_MAX32_SPI_CTRL0_SS_CTRL;
}

#ifdef CONFIG_SPI_MAX32_INTERRUPT
Expand Down Expand Up @@ -412,7 +412,7 @@ static int transceive(const struct device *dev, const struct spi_config *config,
if (!hw_cs_ctrl) {
spi_context_cs_control(ctx, false);
} else {
cfg->regs->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | MXC_F_SPI_CTRL0_SS_CTRL |
cfg->regs->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | ADI_MAX32_SPI_CTRL0_SS_CTRL |
ADI_MAX32_SPI_CTRL_EN);
cfg->regs->ctrl0 |= ADI_MAX32_SPI_CTRL_EN;
}
Expand Down Expand Up @@ -571,7 +571,7 @@ static int transceive_dma(const struct device *dev, const struct spi_config *con
if (!hw_cs_ctrl) {
spi_context_cs_control(ctx, true);
} else {
spi->ctrl0 = (spi->ctrl0 & ~MXC_F_SPI_CTRL0_START) | MXC_F_SPI_CTRL0_SS_CTRL;
spi->ctrl0 = (spi->ctrl0 & ~MXC_F_SPI_CTRL0_START) | ADI_MAX32_SPI_CTRL0_SS_CTRL;
}

MXC_SPI_SetSlave(cfg->regs, ctx->config->slave);
Expand Down Expand Up @@ -620,7 +620,7 @@ static int transceive_dma(const struct device *dev, const struct spi_config *con
if (!hw_cs_ctrl) {
spi_context_cs_control(ctx, false);
} else {
spi->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | MXC_F_SPI_CTRL0_SS_CTRL |
spi->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | ADI_MAX32_SPI_CTRL0_SS_CTRL |
ADI_MAX32_SPI_CTRL_EN);
spi->ctrl0 |= ADI_MAX32_SPI_CTRL_EN;
}
Expand Down Expand Up @@ -772,7 +772,7 @@ static void spi_max32_callback(mxc_spi_req_t *req, int error)
if (spi_cs_is_gpio(ctx->config)) {
spi_context_cs_control(ctx, false);
} else {
req->spi->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | MXC_F_SPI_CTRL0_SS_CTRL |
req->spi->ctrl0 &= ~(MXC_F_SPI_CTRL0_START | ADI_MAX32_SPI_CTRL0_SS_CTRL |
ADI_MAX32_SPI_CTRL_EN);
req->spi->ctrl0 |= ADI_MAX32_SPI_CTRL_EN;
}
Expand Down
10 changes: 10 additions & 0 deletions dts/arm/adi/max32/max32657_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@
status = "disabled";
};
};

spi0: spi@46000 {
compatible = "adi,max32-spi";
reg = <0x46000 0x1000>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&gcr ADI_MAX32_CLOCK_BUS0 6>;
interrupts = <12 0>;
status = "disabled";
};
};

&nvic {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# Copyright (c) 2024 Analog Devices, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_SPI_MAX32_INTERRUPT=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Analog Devices, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

&dma1 {
status = "okay";
};

&spi0 {
dmas = <&dma1 1 MAX32_DMA_SLOT_SPI_TX>, <&dma1 2 MAX32_DMA_SLOT_SPI_RX>;
dma-names = "tx", "rx";

slow@1 {
compatible = "test-spi-loopback-slow";
reg = <1>;
spi-max-frequency = <128000>;
};
fast@1 {
compatible = "test-spi-loopback-fast";
reg = <1>;
spi-max-frequency = <500000>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# Copyright (c) 2024 Analog Devices, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_SPI_MAX32_INTERRUPT=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2024 Analog Devices, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

&spi0 {
slow@1 {
compatible = "test-spi-loopback-slow";
reg = <1>;
spi-max-frequency = <128000>;
};
fast@1 {
compatible = "test-spi-loopback-fast";
reg = <1>;
spi-max-frequency = <500000>;
};
};