Skip to content

Commit

Permalink
drivers: spi: Add SPI device support for Apollo3 SoCs
Browse files Browse the repository at this point in the history
This commit adds spi device support for Apollo3 SoCs.

Signed-off-by: Hao Luo <[email protected]>
  • Loading branch information
AlessandroLuo committed Aug 23, 2024
1 parent fba0a47 commit 792578b
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 15 deletions.
6 changes: 5 additions & 1 deletion boards/ambiq/apollo3_evb/apollo3_evb-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
bias-pull-up;
};
};

spis0_default: spis0_default {
group1 {
pinmux = <SLSCK_P0>, <SLMISO_P2>, <SLMOSI_P1>, <SLNCE_P3>;
};
};
spi0_default: spi0_default {
group1 {
pinmux = <M0SCK_P5>, <M0MISO_P6>, <M0MOSI_P7>;
Expand Down
6 changes: 5 additions & 1 deletion boards/ambiq/apollo3p_evb/apollo3p_evb-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
bias-pull-up;
};
};

spis0_default: spis0_default {
group1 {
pinmux = <SLSCK_P0>, <SLMISO_P2>, <SLMOSI_P1>, <SLNCE_P3>;
};
};
spi0_default: spi0_default {
group1 {
pinmux = <M0SCK_P5>, <M0MISO_P6>, <M0MOSI_P7>;
Expand Down
3 changes: 2 additions & 1 deletion drivers/spi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ zephyr_library_sources_ifdef(CONFIG_SPI_PW spi_pw.c)
zephyr_library_sources_ifdef(CONFIG_SPI_SMARTBOND spi_smartbond.c)
zephyr_library_sources_ifdef(CONFIG_SPI_OPENTITAN spi_opentitan.c)
zephyr_library_sources_ifdef(CONFIG_SPI_NUMAKER spi_numaker.c)
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ spi_ambiq.c)
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_SPIM spi_ambiq_spim.c)
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_SPIS spi_ambiq_spis.c)
zephyr_library_sources_ifdef(CONFIG_SPI_AMBIQ_BLEIF spi_ambiq_bleif.c)
zephyr_library_sources_ifdef(CONFIG_SPI_RPI_PICO_PIO spi_rpi_pico_pio.c)
zephyr_library_sources_ifdef(CONFIG_SPI_MCHP_MSS spi_mchp_mss.c)
Expand Down
24 changes: 17 additions & 7 deletions drivers/spi/Kconfig.ambiq
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
# SPDX-License-Identifier: Apache-2.0
#

menuconfig SPI_AMBIQ
bool "AMBIQ SPI driver"
menuconfig SPI_AMBIQ_SPIM
bool "AMBIQ SPI Master driver"
default y
depends on DT_HAS_AMBIQ_SPI_ENABLED
depends on DT_HAS_AMBIQ_SPIM_ENABLED
select GPIO
select AMBIQ_HAL
select AMBIQ_HAL_USE_SPI
select AMBIQ_HAL_USE_SPIM
help
Enable driver for Ambiq SPI.
Enable driver for Ambiq SPI Master.

if SPI_AMBIQ
if SPI_AMBIQ_SPIM

config SPI_AMBIQ_DMA
bool "AMBIQ APOLLO SPI DMA Support"
Expand All @@ -31,7 +31,17 @@ config SPI_DMA_TCB_BUFFER_SIZE
help
DMA Transfer Control Buffer size in words

endif # SPI_AMBIQ
endif # SPI_AMBIQ_SPIM

config SPI_AMBIQ_SPIS
bool "AMBIQ SPI Slave driver"
default y
depends on DT_HAS_AMBIQ_SPIS_ENABLED
select GPIO
select AMBIQ_HAL
select AMBIQ_HAL_USE_SPIS
help
Enable driver for Ambiq SPI Slave.

config SPI_AMBIQ_BLEIF
bool "AMBIQ SPI-BLEIF driver"
Expand Down
2 changes: 0 additions & 2 deletions drivers/spi/spi_ambiq.c → drivers/spi/spi_ambiq_spim.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ typedef void (*spi_context_update_trx)(struct spi_context *ctx, uint8_t dfs, uin

#define SPI_WORD_SIZE 8

#define SPI_CS_INDEX 3

#ifdef CONFIG_SPI_AMBIQ_DMA
static __aligned(32) struct {
__aligned(32) uint32_t buf[CONFIG_SPI_DMA_TCB_BUFFER_SIZE];
Expand Down
Loading

0 comments on commit 792578b

Please sign in to comment.