2018-03-04 19:42:02 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Sean Nyekjaer
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <init.h>
|
|
|
|
#include <pinmux.h>
|
|
|
|
|
|
|
|
static int board_pinmux_init(struct device *dev)
|
|
|
|
{
|
2018-11-13 22:15:23 +08:00
|
|
|
struct device *muxa = device_get_binding(DT_PINMUX_SAM0_A_LABEL);
|
|
|
|
struct device *muxb = device_get_binding(DT_PINMUX_SAM0_B_LABEL);
|
2018-03-04 19:42:02 +08:00
|
|
|
|
|
|
|
ARG_UNUSED(dev);
|
|
|
|
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM0_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM1_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM2_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM3_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
/* SERCOM3 on RX=PA25, TX=PA24 */
|
|
|
|
pinmux_pin_set(muxa, 24, PINMUX_FUNC_C);
|
|
|
|
pinmux_pin_set(muxa, 25, PINMUX_FUNC_C);
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM4_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
pinmux_pin_set(muxb, 8, PINMUX_FUNC_D);
|
|
|
|
pinmux_pin_set(muxb, 9, PINMUX_FUNC_D);
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_UART_SAM0_SERCOM5_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
|
|
|
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM0_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
/* SPI SERCOM0 on MISO=PA04, MOSI=PA06, SCK=PA07 */
|
|
|
|
pinmux_pin_set(muxa, 4, PINMUX_FUNC_D);
|
|
|
|
pinmux_pin_set(muxa, 6, PINMUX_FUNC_D);
|
|
|
|
pinmux_pin_set(muxa, 7, PINMUX_FUNC_D);
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM1_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM2_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM3_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM4_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
2018-11-13 22:15:23 +08:00
|
|
|
#if DT_SPI_SAM0_SERCOM5_BASE_ADDRESS
|
2018-03-04 19:42:02 +08:00
|
|
|
#error Pin mapping is not configured
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
|