Is there a way to setup device tree to use a pin for UART and as GPIO?

I am interfacing with a part that uses the same pin, P0.6, for two purposes:

1) The pin is used for UART communication.  MCU RX input.

2) The pin is used as a GPIO.  MCU GPIO output.

I am using runtime power management.  What I would like is that when the UART driver is in the default state then the pin is connected to the UART.  When the UART driver is in the sleep state then the pin is used as a GPIO.  Is this possible?

What I have right now in my dts as a (incorrect) starting point is:

arduino_serial: &uart0 {
  pinctrl-0 = <&uart0_default>;
  pinctrl-1 = <&uart0_sleep>;
  pinctrl-names = "default", "sleep";
...
};
 
uart0_default: uart0_default {
  group1 {
    psels = <NRF_PSEL(UART_RX, 0, 6)>;
    bias-pull-up;
  };
  group2 {
    psels = <NRF_PSEL(UART_TX, 0, 20)>;
  };
};
uart0_sleep: uart0_sleep {
  group1 {
    psels = <NRF_PSEL(UART_RX, 0, 6)>, <NRF_PSEL(UART_TX, 0, 20)>;
    low-power-enable;
  };
};
interface_ctl {
  compatible = "gpio-leds";
  uart_log_txd: uart_log_txd {
    gpios = <&gpio0 6 GPIO_PULL_UP>;
    label = "UART LOG TXD";
  };
};
Parents Reply
  • Won't putting the uart to sleep, with the dts above, still retain control of P0.6?

    Is there a way, via the dts, to have the uart not retain control of P0.6 when to goes to sleep?  Some dts NRF constant for no connection?

    Seems like the pin control API is meant to do this kind of thing in a portable manner.  I read through the docs online, but still a bit unclear to me how the pin control API is intended to be used for this specific type of situation.

Children
Related