Skip to content

Commit

Permalink
pinmux: Add stm32mp157c_dk2 board support
Browse files Browse the repository at this point in the history
Implementation of pinmux for the stm32mp157c_dk2 board.
Some UART pin mux definition has been added (mainly for
UART console and UART/SPI Arduino shield support).
This can be completed with pin mux for other stm32mp157c
UART.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
  • Loading branch information
yboutreux authored and nashif committed May 3, 2019
1 parent 287f067 commit eba3f49
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions boards/arm/stm32mp157c_dk2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: Apache-2.0

zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
2 changes: 2 additions & 0 deletions boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ features:
| UART | on-chip | serial port-polling; |
| | | serial port-interrupt |
+-----------+------------+-------------------------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+-------------------------------------+

The default configuration can be found in the defconfig file:
``boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig``
Expand Down
38 changes: 38 additions & 0 deletions boards/arm/stm32mp157c_dk2/pinmux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <kernel.h>
#include <device.h>
#include <init.h>
#include <pinmux.h>
#include <sys_io.h>

#include <pinmux/stm32/pinmux_stm32.h>

/* pin assignments for STM32MP157c_dk2 board */
static const struct pin_config pinconf[] = {
#ifdef CONFIG_UART_3
{ STM32_PIN_PB10, STM32MP1X_PINMUX_FUNC_PB10_USART3_TX },
{ STM32_PIN_PB12, STM32MP1X_PINMUX_FUNC_PB12_USART3_RX },
#endif /* CONFIG_UART_3 */
#ifdef CONFIG_UART_7
{ STM32_PIN_PE7, STM32MP1X_PINMUX_FUNC_PE7_UART7_RX },
{ STM32_PIN_PE8, STM32MP1X_PINMUX_FUNC_PE8_UART7_TX },
#endif /* CONFIG_UART_7 */

};

static int pinmux_stm32_init(struct device *port)
{
ARG_UNUSED(port);

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

return 0;
}

SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
3 changes: 3 additions & 0 deletions boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# pin mux configuration
CONFIG_PINMUX=y

# clock configuration
CONFIG_CLOCK_CONTROL=y

Expand Down
5 changes: 5 additions & 0 deletions drivers/pinmux/stm32/pinmux_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@

#include "pinmux.h"

#ifdef CONFIG_SOC_SERIES_STM32MP1X
#define GPIO_REG_SIZE 0x1000
/* 0x1000 between each port, 0x400 gpio registry 0xC00 reserved */
#else
#define GPIO_REG_SIZE 0x400
#endif /* CONFIG_SOC_SERIES_STM32MP1X */
/* base address for where GPIO registers start */
#define GPIO_PORTS_BASE (GPIOA_BASE)

Expand Down
2 changes: 2 additions & 0 deletions drivers/pinmux/stm32/pinmux_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void stm32_setup_pins(const struct pin_config *pinconf,
#include "pinmux_stm32l1x.h"
#elif CONFIG_SOC_SERIES_STM32L4X
#include "pinmux_stm32l4x.h"
#elif CONFIG_SOC_SERIES_STM32MP1X
#include "pinmux_stm32mp1x.h"
#elif CONFIG_SOC_SERIES_STM32WBX
#include "pinmux_stm32wbx.h"
#endif
Expand Down
26 changes: 26 additions & 0 deletions drivers/pinmux/stm32/pinmux_stm32mp1x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_DRIVERS_PINMUX_STM32_PINMUX_STM32MP1X_H_
#define ZEPHYR_DRIVERS_PINMUX_STM32_PINMUX_STM32MP1X_H_

/**
* @file Header for STM32MP1X pin multiplexing helper
*/

/* Port B */
#define STM32MP1X_PINMUX_FUNC_PB10_USART3_TX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)
#define STM32MP1X_PINMUX_FUNC_PB12_USART3_RX \
(STM32_PINMUX_ALT_FUNC_8 | STM32_PUPDR_PULL_DOWN)

/* Port E */
#define STM32MP1X_PINMUX_FUNC_PE7_UART7_RX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUPDR_PULL_DOWN)
#define STM32MP1X_PINMUX_FUNC_PE8_UART7_TX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)

#endif /* ZEPHYR_DRIVERS_PINMUX_STM32_PINMUX_STM32MP1X_H_ */
34 changes: 34 additions & 0 deletions dts/arm/st/mp1/stm32mp1-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2019 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <dt-bindings/pinctrl/stm32-pinctrl.h>

/ {
soc {
pinctrl: pin-controller@50002000 {
usart3_pins_a: usart3_a {
rx_tx {
rx = <STM32_PIN_PB12
(STM32_PINMUX_ALT_FUNC_8 |
STM32_PUPDR_PULL_DOWN)>;
tx = <STM32_PIN_PB10
(STM32_PINMUX_ALT_FUNC_7 |
STM32_PUSHPULL_PULLUP)>;
};
};
uart7_pins_a: uart7_a {
rx_tx {
rx = <STM32_PIN_PE7
(STM32_PINMUX_ALT_FUNC_7 |
STM32_PUPDR_PULL_DOWN)>;
tx = <STM32_PIN_PE8
(STM32_PINMUX_ALT_FUNC_7 |
STM32_PUSHPULL_PULLUP)>;
};
};
};
};
};
1 change: 1 addition & 0 deletions dts/arm/st/mp1/stm32mp157.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <st/mp1/stm32mp1-pinctrl.dtsi>
#include <mem.h>
#include <arm/armv7-m.dtsi>
#include <dt-bindings/gpio/gpio.h>
Expand Down

0 comments on commit eba3f49

Please sign in to comment.