4

When does the console and UART binding happen in Linux,is it possible to unbind the UART from console and bind it to other module(GPS) at runtime.

My board is having a single UART,can i switch between console and GPS at runtime.if yes how do i do it? if no what is the hack which I need to do?

Abbhi
  • 41
  • 5
  • Actually it happens when you write to some device ttyS0 for example or something different (for userspace). – Alex Hoppus Jul 23 '15 at 05:38
  • During bootup the console will be binded to UART,as soon as GPS is up i need to disconnect console form UART and bind GPS to the UART.Is this run time switching of UART possible. – Abbhi Jul 23 '15 at 06:01

1 Answers1

0

Yes you can. At run time you can unbind/bind any driver. You can find more information here:

https://lwn.net/Articles/143397/

You can find the correct driver for your the UART (and GPS probably, but I'm not sure. Never played with it) here:

cd /sys/class/tty/<your-device>/device/driver/

Then in these directories you have the sysfs files bind and unbind. The device ID to use to unbind the device from the driver is typically show in the driver directory.

The platform_device is not special at all, it behaves like any other driver. Typically the device id of a platform device it's its name (there is not a bus enumeration behind). Here an example with platform_device with my PC:

# ls /sys/bus/platform/devices/
alarmtimer        gpio_ich  iTCO_wdt   platform-framebuffer.0  PNP0800:00  PNP0C14:00
coretemp.0        hp-wmi    microcode  PNP0003:00              PNP0C04:00  serial8250
Fixed MDIO bus.0  i8042     pcspkr     PNP0103:00              PNP0C0C:00
# cd /sys/bus/platform/drivers/serial8250/
# ls
bind  serial8250  uevent  unbind
Federico
  • 3,782
  • 32
  • 46
  • Hi Federico, Console drivers are generally platform drivers,they wont be having this "/sys/class/tty//device/driver/" . Even the GPS and BT HCI uart drivers are platform drivers.Can i bind these GPS/BT HCI drivers at runtime to the same console UART (unbinding the console UART). – Abbhi Jul 23 '15 at 14:24
  • generally they can be everywhere: USB, PCI, VME, platform. It depends on your hardware. I improved my answer with a platform example. The `/sys/class/tty` is only an example. You have to adapt the thing to your particular case – Federico Jul 23 '15 at 16:49