blob: 53dd3fc5d0e31f14bed50dd7ba9723603531c552 [file] [log] [blame]
Karl Palsson79b15e32019-10-01 23:12:31 +00001/*
2 * Copyright (c) 2019 eTactica ehf
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <kernel.h>
8#include <device.h>
9#include <init.h>
10#include <drivers/pinmux.h>
11#include <sys/sys_io.h>
12
13#include <pinmux/stm32/pinmux_stm32.h>
14
15static const struct pin_config pinconf[] = {
Erwan Gouriou1a7bccc2020-05-13 08:32:27 +020016#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
Karl Palsson79b15e32019-10-01 23:12:31 +000017#ifdef CONFIG_SPI_STM32_USE_HW_SS
18 {STM32_PIN_PA4, STM32L1X_PINMUX_FUNC_PA4_SPI1_NSS},
19#endif /* CONFIG_SPI_STM32_USE_HW_SS */
20 {STM32_PIN_PA5, STM32L1X_PINMUX_FUNC_PA5_SPI1_SCK},
21 {STM32_PIN_PA6, STM32L1X_PINMUX_FUNC_PA6_SPI1_MISO},
22 {STM32_PIN_PA7, STM32L1X_PINMUX_FUNC_PA7_SPI1_MOSI},
Erwan Gourioubfaa1092020-04-16 20:52:22 +020023#endif
Erwan Gouriou1a7bccc2020-05-13 08:32:27 +020024#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI
Karl Palsson79b15e32019-10-01 23:12:31 +000025#ifdef CONFIG_SPI_STM32_USE_HW_SS
26 {STM32_PIN_PB12, STM32L1X_PINMUX_FUNC_PB12_SPI2_NSS},
27#endif /* CONFIG_SPI_STM32_USE_HW_SS */
28 {STM32_PIN_PB13, STM32L1X_PINMUX_FUNC_PB13_SPI2_SCK},
29 {STM32_PIN_PB14, STM32L1X_PINMUX_FUNC_PB14_SPI2_MISO},
30 {STM32_PIN_PB15, STM32L1X_PINMUX_FUNC_PB15_SPI2_MOSI},
Erwan Gourioubfaa1092020-04-16 20:52:22 +020031#endif
Karl Palsson79b15e32019-10-01 23:12:31 +000032};
33
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020034static int pinmux_stm32_init(const struct device *port)
Karl Palsson79b15e32019-10-01 23:12:31 +000035{
36 ARG_UNUSED(port);
37
38 stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
39
40 return 0;
41}
42
43SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
44 CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);