Skip to content

Commit 1e5cdb1

Browse files
AlessandroLuohenrikbrixandersen
authored andcommitted
drivers: spi: Add SPI device support for Apollo3 SoCs
This commit adds spi device support for Apollo3 SoCs. Signed-off-by: Hao Luo <[email protected]>
1 parent c2b6bcc commit 1e5cdb1

File tree

10 files changed

+506
-14
lines changed

10 files changed

+506
-14
lines changed

boards/ambiq/apollo3_evb/apollo3_evb-pinctrl.dtsi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
bias-pull-up;
6666
};
6767
};
68-
68+
spid0_default: spid0_default {
69+
group1 {
70+
pinmux = <SLSCK_P0>, <SLMISO_P2>, <SLMOSI_P1>, <SLNCE_P3>;
71+
};
72+
};
6973
spi0_default: spi0_default {
7074
group1 {
7175
pinmux = <M0SCK_P5>, <M0MISO_P6>, <M0MOSI_P7>;

boards/ambiq/apollo3p_evb/apollo3p_evb-pinctrl.dtsi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
bias-pull-up;
6666
};
6767
};
68-
68+
spid0_default: spid0_default {
69+
group1 {
70+
pinmux = <SLSCK_P0>, <SLMISO_P2>, <SLMOSI_P1>, <SLNCE_P3>;
71+
};
72+
};
6973
spi0_default: spi0_default {
7074
group1 {
7175
pinmux = <M0SCK_P5>, <M0MISO_P6>, <M0MOSI_P7>;

drivers/spi/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ zephyr_library_sources_ifdef(CONFIG_SPI_PW spi_pw.c)
4646
zephyr_library_sources_ifdef(CONFIG_SPI_SMARTBOND spi_smartbond.c)
4747
zephyr_library_sources_ifdef(CONFIG_SPI_OPENTITAN spi_opentitan.c)
4848
zephyr_library_sources_ifdef(CONFIG_SPI_NUMAKER spi_numaker.c)
49-
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ spi_ambiq.c)
49+
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_SPIC spi_ambiq_spic.c)
50+
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_SPID spi_ambiq_spid.c)
5051
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_BLEIF spi_ambiq_bleif.c)
5152
zephyr_library_sources_ifdef(CONFIG_SPI_RPI_PICO_PIO spi_rpi_pico_pio.c)
5253
zephyr_library_sources_ifdef(CONFIG_SPI_MCHP_MSS spi_mchp_mss.c)

drivers/spi/Kconfig.ambiq

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
# SPDX-License-Identifier: Apache-2.0
77
#
88

9-
menuconfig SPI_AMBIQ
10-
bool "AMBIQ SPI driver"
9+
menuconfig SPI_AMBIQ_SPIC
10+
bool "AMBIQ SPI Controller driver"
1111
default y
1212
depends on DT_HAS_AMBIQ_SPI_ENABLED
1313
select GPIO
1414
select AMBIQ_HAL
15-
select AMBIQ_HAL_USE_SPI
15+
select AMBIQ_HAL_USE_SPIC
1616
help
17-
Enable driver for Ambiq SPI.
17+
Enable driver for Ambiq SPI in Controller mode.
1818

19-
if SPI_AMBIQ
19+
if SPI_AMBIQ_SPIC
2020

2121
config SPI_AMBIQ_DMA
2222
bool "AMBIQ APOLLO SPI DMA Support"
23-
depends on SPI_AMBIQ
23+
depends on SPI_AMBIQ_SPIC
2424
help
2525
Enable DMA for Ambiq SPI.
2626

@@ -31,7 +31,17 @@ config SPI_DMA_TCB_BUFFER_SIZE
3131
help
3232
DMA Transfer Control Buffer size in words
3333

34-
endif # SPI_AMBIQ
34+
endif # SPI_AMBIQ_SPIC
35+
36+
config SPI_AMBIQ_SPID
37+
bool "AMBIQ SPI Device driver"
38+
default y
39+
depends on DT_HAS_AMBIQ_SPID_ENABLED
40+
select GPIO
41+
select AMBIQ_HAL
42+
select AMBIQ_HAL_USE_SPID
43+
help
44+
Enable driver for Ambiq SPI in Device mode.
3545

3646
config SPI_AMBIQ_BLEIF
3747
bool "AMBIQ SPI-BLEIF driver"

drivers/spi/spi_ambiq.c renamed to drivers/spi/spi_ambiq_spic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int spi_config(const struct device *dev, const struct spi_config *config)
170170
}
171171

172172
if (config->operation & SPI_OP_MODE_SLAVE) {
173-
LOG_ERR("Slave mode not supported");
173+
LOG_ERR("Device mode not supported");
174174
return -ENOTSUP;
175175
}
176176
if (config->operation & SPI_MODE_LOOP) {
@@ -183,7 +183,8 @@ static int spi_config(const struct device *dev, const struct spi_config *config)
183183
return -ENOTSUP;
184184
}
185185

186-
/* Select slower of two: SPI bus frequency for SPI device or SPI master clock frequency */
186+
/* Select slower of two: SPI bus frequency for SPI device or SPI controller clock frequency
187+
*/
187188
data->iom_cfg.ui32ClockFreq =
188189
(config->frequency ? MIN(config->frequency, cfg->clock_freq) : cfg->clock_freq);
189190
ctx->config = config;

0 commit comments

Comments
 (0)