-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Introduction
Ability to configure alternate gpios (SPI, UART, I2C) pins at runtime.
Problem description
I have 2 CPU's connected to each other (MCU with Zephyr code to iMX6). They use USART to communicate, but there is leakage current on USART pins which for a consequence has the iMX6 is powered through them (leakage current running from MCU Rx/Tx pins through clamping diodes in iMX6).
Proposed change
A possibility to configure SPI/USART/I2C pins from code, not (only) from the device tree (which is in effect from the very beginning). I.e. pins would be in their reset state until configured from the code. It would also allow to go back and forth between different configurations (i.e. high-Z -> alternate function -> high-Z -> alternate function -> reset state)
Detailed RFC
Correct me if I am wrong, but I currently do not see a possibilty to configure (USART) pins at runtime (if there is such possibility, please bring it to my attention).
I looked at the uart_stm32_pm_constraint_set and uart_stm32_pm_constraint_release function inside of the uart_stm32.c file. All that does is it allows or denies for entire processor to go to sleep (am I right or am I misunderstanding something?).
What I want/need is for the specific USART peripheral to be disabled (disable its clock, set its pins to reset state or high impedance). How can I achieve that?
I am sure these pins are the ones which are problematic. My dts looks like following:
&usart3_tx_pd8 { bias-disable; slew-rate = "high-speed";};
&usart3_rx_pd9 { bias-pull-up; slew-rate = "high-speed";};
&usart3 {
pinctrl-0 = <&usart3_tx_pd8 &usart3_rx_pd9>;
current-speed = <115200>;
status = "okay";
};
When I change the status to "disabled", I no longer see the leakage problem.
I am using the following environment:
OS: Ubuntu 20.04
Toolchain : zephyr-sdk.0.13.1
Commit SHA : 73f4dfb