Skip to contentSkip to conversation

Writing a Line discpline driver to talk to a stm32 controller

DISCUSSION Oliver Graute 2 participants 2 messages Mar 23, 2018 – Mar 26, 2018

lore
Share & tools
lore
#0 lore raw

Hello list,

I have a imx6ul connected to a stm32 controller via a serial interface. I need to implement a little protocol to talk towards the stm32 controller for send and receive ontop of the serial line. I found out that I have to write my own line discpline driver for doing this. After digging around in drivers/tty/n_* I have a little idea what to do here. I already attached my demo ldisc to a /dev/ttymxc7 via the ldattach command in userspace. This looks fine so far.

Here my first Questions:

Is there a way to permanent attach the ldisc to an serial interface in the Kernel?

I have a reset GPIO to reset the stm32 controller. I would like to toggle this GPIO on opening the device. But the open() method in the ldisc driver seems the wrong place to do this. But in which open() should I do this? the underlying serial imx.c driver do not have any open() and I'am using this driver also for other serial lines?

useful links to the ldisc topic:

https://www.kernel.org/doc/Documentation/serial/tty.txt
http://www.embeddedlinux.org.cn/essentiallinuxdevicedrivers/

Best Regards,

Oliver

#1 lore raw

Hello Oliver,

Am 23.03.2018 um 09:18 schrieb Oliver Graute:

Quoted 9 lines

Hello list,

I have a imx6ul connected to a stm32 controller via a serial interface. I need to implement a little protocol to talk towards the stm32 controller for send and receive ontop of the serial line. I found out that I have to write my own line discpline driver for doing this. After digging around in drivers/tty/n_* I have a little idea what to do here. I already attached my demo ldisc to a /dev/ttymxc7 via the ldattach command in userspace. This looks fine so far.

Quoted 4 lines

Here my first Questions:

Is there a way to permanent attach the ldisc to an serial interface in the Kernel?

take a look at the serial device bus as an alternative for ldisc [1]

Stefan

[1] - https://elinux.org/images/0/0e/Serdev-elce-2017-2.pdf

Quoted 21 lines

I have a reset GPIO to reset the stm32 controller. I would like to toggle this GPIO on opening the device. But the open() method in the ldisc driver seems the wrong place to do this. But in which open() should I do this? the underlying serial imx.c driver do not have any open() and I'am using this driver also for other serial lines?

useful links to the ldisc topic:

https://www.kernel.org/doc/Documentation/serial/tty.txt
http://www.embeddedlinux.org.cn/essentiallinuxdevicedrivers/

Best Regards,

Oliver

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies