Colibri VF50 DeviceTree enable DCD, DTR, DSR

Hey,

reading the documentation on the web I saw that the DCD, DTR and DSR Pins need to be GPIO emulated.

Can this be done like described in:
http://git.toradex.com/cgit/linux-toradex.git/tree/Documentation/devicetree/bindings/serial/serial.txt?h=toradex_4.14-2.3.x-imx

By setting:

dtr-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
dsr-gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
dcd-gpios = <&gpio2 24 GPIO_ACTIVE_LOW>;

in the devicetree?

And when it’s possible how this settings have to be made?

Edit: What i’ve tried so far:

Changing the devicetree file:

&uart0 {
	status = "okay";
	dcd-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
};

But reading the value of DCD signal using termios structure, statserial and picocom showed always zero, when the DCD is raised by the device.

I also decompiled the device tree binary to make that the settings are really in the dtb. And they are.

When I use as GPIO

echo 11 > /sys/class/gpio/export

and

cat /sys/class/gpio/gpio11/value

I can see the value toggling according to the DCD state of the connected modem.

But using it as GPIO doesn’t really help me out. I wanted to use the DCD signal with pppd to detect a broken connection using a LTE modem connected to UART0.

Does anyone has a hint how to get it working that the DCD is usable in the standard linux way?

Thanks in advance

Kind regards,
Sebastian

To complete my monologue…

I found the answer by my self.

With the actual implementation it’s not possible to use the signals. They have to be handled as GPIO.

But it’s possible to use the signals by extending the fsl_lpuart kernel module.

I extended the fsl_lpuart kernel driver to use the GPIO subsystem to provide at least the state of the DCD signal.

Here is the patch with the changes in case somebody needs it.

Using the patch the GPIO for the DCD signal can be defined in the devicetree

&uart0 {
	status = "okay";
	dcd_gpio = <11>;
};

Where 11 is the PTA21 signal, which is tied to Linux GPIO 11.

Too Toradex:

Feel free to use the patch to bring the changes upstream to the kernel.

Kind regards,

Sebastian

Hello @seho85 ,

Glad that you could find the solution and that it works now.
Thank you for the feedback!

Best Regards,
Janani

I found out, that this patch is only half of the solution. When I use the patch together with pppd (modem option enable) the connection isn’t terminated.

There have to be made a call to uart_handle_dcd_change in the kernel module to notify the userspace applications of the state change. The current provided patch fill does that only when state is polled.

I implemented that with an GPIO irq, but thats not very pretty right now. I’ll post back when I finally extended the fsl_lpuart with a timer to poll the GPIOs cyclically.

Perfect, we are glad about the progress!

So here now the final patch file.

This patch extends the fsl_lpuart kernel driver to deal with DCD, DTR, DSR and RI.

The GPIOs used can be defined in the device tree

&uart0 {
	status = "okay";
	dcd_gpio = <11>;
	dcd_gpio_active_value = <0>;
	dtr_gpio = <10>;
	dtr_gpio_active_value = <0>;
	dsr_gpio = <21>;
	dsr_gpio_active_value = <0>;
	ri_gpio = <20>;
	ri_gpio_active_value = <0>;
}

If no signal_gpio_active_value is defined, but the gpio is defined, then zero is used ‘active value’

By default the GPIOs are low active.

The kernel module will also print out the GPIOs used.

[    0.360963] fsl-lpuart 40027000.serial: using interrupt of gpio 11 for dcd
[    0.361138] fsl-lpuart 40027000.serial: dcd_gpio_active_value not defined in devicetree - using as 0 as 'active value' for dcd gpio
[    0.361365] fsl-lpuart 40027000.serial: using gpio 21 for dsr
[    0.361476] fsl-lpuart 40027000.serial: dsr_gpio_active_value not defined in devicetree - using as 0 as 'active value' for dsr gpio
[    0.361666] fsl-lpuart 40027000.serial: using gpio 20 for ri
[    0.361772] fsl-lpuart 40027000.serial: ri_gpio_active_value not defined in devicetree - using as 0 as 'active value' for ri gpio
[    0.361930] fsl-lpuart 40027000.serial: dtr_gpio_active_value not defined in devicetree - using as 0 as 'active value' for dtr gpio
[    0.362112] fsl-lpuart 40027000.serial: using gpio 10 for dtr

Please leave a like if you found it usefull

Kind regards,

Sebastian

Hello @seho85 ,

Thank you for sharing your answer on our platform. I am sure other people having similar applications/issues will be able to take inspiration from your answer.

Best Regards,
Janani