zephyr/boards/arm/atsamd21_xpro/pinmux.c
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00

73 lines
1.9 KiB
C

/*
* Copyright (c) 2018 Bryan O'Donoghue
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <pinmux.h>
static int board_pinmux_init(struct device *dev)
{
struct device *muxa = device_get_binding(DT_PINMUX_SAM0_A_LABEL);
struct device *muxb = device_get_binding(DT_PINMUX_SAM0_B_LABEL);
ARG_UNUSED(dev);
#if DT_UART_SAM0_SERCOM0_BASE_ADDRESS
/* SERCOM0 on RX=PA11, TX=PA10 */
pinmux_pin_set(muxa, 11, PINMUX_FUNC_C);
pinmux_pin_set(muxa, 10, PINMUX_FUNC_C);
#endif
#if DT_UART_SAM0_SERCOM1_BASE_ADDRESS
/* SERCOM3 ON RX=PA19, TX=PA16 */
pinmux_pin_set(muxa, 19, PINMUX_FUNC_C);
pinmux_pin_set(muxa, 16, PINMUX_FUNC_C);
#endif
#if DT_UART_SAM0_SERCOM2_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_UART_SAM0_SERCOM3_BASE_ADDRESS
/* SERCOM3 ON RX=PA23, TX=PA22 */
pinmux_pin_set(muxa, 23, PINMUX_FUNC_C);
pinmux_pin_set(muxa, 22, PINMUX_FUNC_C);
#endif
#if DT_UART_SAM0_SERCOM4_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_UART_SAM0_SERCOM5_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM0_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM1_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM2_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM3_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM4_BASE_ADDRESS
#error Pin mapping is not configured
#endif
#if DT_SPI_SAM0_SERCOM5_BASE_ADDRESS
/* SPI SERCOM5 on MISO=PB16/pad 0, MOSI=PB22/pad 2, SCK=PB23/pad 3 */
pinmux_pin_set(muxb, 16, PINMUX_FUNC_C);
pinmux_pin_set(muxb, 22, PINMUX_FUNC_D);
pinmux_pin_set(muxb, 23, PINMUX_FUNC_D);
#endif
#ifdef CONFIG_USB_DC_SAM0
/* USB DP on PA25, USB DM on PA24 */
pinmux_pin_set(muxa, 25, PINMUX_FUNC_G);
pinmux_pin_set(muxa, 24, PINMUX_FUNC_G);
#endif
return 0;
}
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);