Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/arm/disco_l475_iot1/disco_l475_iot1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

&usart1 {
current-speed = <115200>;
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
pinctrl-names = "default";
status = "okay";
};

Expand Down
48 changes: 48 additions & 0 deletions dts/arm/st/l4/stm32l4-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

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

/ {
soc {
pinctrl: pin-controller@48000000 {
/* USART1_TX */
usart1_tx_pa9: usart1_tx_1 {
pinmux = <STM32_PINMUX('A', 9, AF7)>;
drive-push-pull;
bias-pull-up;
};
usart1_tx_pb6: usart1_tx_2 {
pinmux = <STM32_PINMUX('B', 6, AF7)>;
drive-push-pull;
bias-pull-up;
};
/* USART1_RX */
usart1_rx_pa10: usart1_rx_1 {
pinmux = <STM32_PINMUX('A', 10, AF7)>;
bias-disable;
};
usart1_rx_pb7: usart1_rx_2 {
pinmux = <STM32_PINMUX('B', 7, AF7)>;
bias-disable;
};
/* USART2_TX */
usart2_tx_pa2: usart2_tx_1 {
pinmux = <STM32_PINMUX('A', 2, AF7)>;
bias-disable;
};
/* USART2_RX */
usart2_rx_pa3: usart2_rx_1 {
pinmux = <STM32_PINMUX('A', 3, AF7)>;
bias-disable;
};
usart2_rx_pa15: usart2_rx_2 {
pinmux = <STM32_PINMUX('A', 15, AF3)>;
bias-disable;
};
};
};
};
1 change: 1 addition & 0 deletions dts/arm/st/l4/stm32l4.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


#include <arm/armv7-m.dtsi>
#include <st/l4/stm32l4-pinctrl.dtsi>
#include <dt-bindings/clock/stm32_clock.h>
#include <dt-bindings/i2c/i2c.h>
#include <dt-bindings/gpio/gpio.h>
Expand Down
43 changes: 43 additions & 0 deletions dts/arm/st/l4/stm32l471-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

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

/ {
soc {
pinctrl: pin-controller@48000000 {
/* USART3_TX */
usart3_tx_pb10: usart3_tx_1 {
pinmux = <STM32_PINMUX('B', 10, AF7)>;
drive-push-pull;
bias-pull-up;
};
usart3_tx_pc4: usart3_tx_2 {
pinmux = <STM32_PINMUX('C', 5, AF7)>;
drive-push-pull;
bias-pull-up;
};
usart3_tx_pc11: usart3_tx_3 {
pinmux = <STM32_PINMUX('C', 10, AF7)>;
drive-push-pull;
bias-pull-up;
};
/* USART3_RX */
usart3_rx_pb10: usart3_rx_1 {
pinmux = <STM32_PINMUX('B', 11, AF7)>;
bias-pull-up;
};
usart3_rx_pc4: usart3_rx_2 {
pinmux = <STM32_PINMUX('C', 4, AF7)>;
bias-pull-up;
};
usart3_rx_pc11: usart3_rx_3 {
pinmux = <STM32_PINMUX('C', 11, AF7)>;
bias-pull-up;
};
};
};
};
50 changes: 47 additions & 3 deletions dts/bindings/pinctrl/st,stm32-pinmux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,50 @@ properties:
reg:
required: true

pinmux-cells:
- pin
- function
child-binding:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to have a title: and description: too. The contents of child-binding: is parsed like a regular binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ulfalizer
The usage of child-binding did not work out for me with the current edtlib.py.

In #22255 I made a RFC for a different solution using a generic binding for the pinctrl-state nodes (and some other similar node types - dts: edtlib: enable bindings for special nodes without compatibles).

title: STM32 PIN configurations

description: |
This binding gives a base representation of the STM32 pins configration

properties:
pinmux:
required: false
type: int

bias-disable:
required: false
type: boolean

bias-pull-down:
required: false
type: boolean

bias-pull-up:
required: false
type: boolean

drive-push-pull:
required: false
type: boolean

drive-open-drain:
required: false
type: boolean

output-low:
required: false
type: boolean

output-high:
required: false
type: boolean

slew-rate:
type: int
default: 2
enum:
- 0
- 1
- 2
- 3
25 changes: 25 additions & 0 deletions include/dt-bindings/pinctrl/stm32-pinctrl-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@
#ifndef ZEPHYR_STM32_PINCTRL_COMMON_H_
#define ZEPHYR_STM32_PINCTRL_COMMON_H_

/* Extracted from Linux: include/dt-bindings/pinctrl/stm32-pinfunc.h */
/* define PIN modes */
#define GPIO 0x0
#define AF0 0x1
#define AF1 0x2
#define AF2 0x3
#define AF3 0x4
#define AF4 0x5
#define AF5 0x6
#define AF6 0x7
#define AF7 0x8
#define AF8 0x9
#define AF9 0xa
#define AF10 0xb
#define AF11 0xc
#define AF12 0xd
#define AF13 0xe
#define AF14 0xf
#define AF15 0x10
#define ANALOG 0x11

/* define Pins number*/
#define PIN_NO(port, line) (((port) - 'A') * 0x10 + (line))

#define STM32_PINMUX(port, line, mode) (((PIN_NO(port, line)) << 8) | (mode))

/**
* @brief numerical IDs for IO ports
Expand Down