2

by checking the serial folder @: \drivers\tty\serial

There are many different serial port drivers there, which one is for x86?

Mark
  • 325
  • 1
  • 16

2 Answers2

2

There is no single UART chip for x86.
The IBM PC originally used the 8250, later it began customary to replace it with the 16550 and later with the 16750.
With the advent of SuperIO chips each manufacturer had their implementation of the UART but all were more or less compatible with the 16550/750 and the 8250.
Today chipsets usually have one ore more 16750 UARTs integrated in the PCH but they don't have an external socket, so a lot of USB/PCI third-party serials are present in the market.
In the end, the driver depends on the UART chip.


If you are interested in the integrated UART (with the socket on the back of your PC), the driver is probably in the 8250 folder unless your chipset uses a different UART chip.

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124
  • the UART function didn't be integrated into x86 CPU? – Mark Jan 24 '19 at 13:48
  • 1
    @Mark No, not that I'm aware of. Some Skylake CPUs has the PCH (the chipset) integrated but that's just a physical layout of the ICs, functionally nothing changed. The UART is a fairly slow device, usually things get integrated in the CPU to speed them up. – Margaret Bloom Jan 24 '19 at 14:09
  • @MargaretBloom: yeah, I don't think that would make sense. You don't want to dedicate 2 extra CPU pins to RS-232 lines, and you'd still need an external chip anyway because you probably don't want a wire from outside the case electrically connected *directly* to a CPU pin. So you might as well make that external chip an actual UART, or bake it into the southbridge, and talk to it over PCIe or DMI, along with the hard-drive LEDs and other misc. stuff that would need extra pins. – Peter Cordes Jan 24 '19 at 17:49
  • I don't understand it. When x86 using superIO, doesn't it mean UART already be integrated? then, there should be a driver for this UART. – Mark Jan 26 '19 at 00:53
  • 2
    @Mark The SuperIO is a chip on its own, it deals with a lot of legacy devices, including the UART. These UARTs have the same interface of the 16550 which is a superset of the 8250. Under Linux it's all under the 8250 folder as stated in the comments in the files themselves. – Margaret Bloom Jan 26 '19 at 09:25
2

@Margaret Bloom has a great answer. An 8250/16550-compatible UART is the base for normal x86 PCs, and is integrated into the northbridge/southbridge ICH/PCH chipsets. As was pointed out, this does not mean the integrated UART is used; there are third-party serial cards that can be added (see below for the Maxim MAX310x serial driver.)

So, how can you tell what's being used? Here's some commands from a QEMU session running debian 10:

q35ek:511> ls -l /dev/ttyS0
crw------- 1 dave tty 4, 64 Feb  2 12:09 /dev/ttyS0

q35ek:512> sudo cat /proc/tty/driver/serial | egrep '^0:'
0: uart:16550A port:000003F8 irq:4 tx:11291 rx:18 RTS|CTS|DTR|DSR|CD

q35ek:513> sudo cat /proc/tty/drivers
/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
ttyprintk            /dev/ttyprintk   5       3 console
max310x              /dev/ttyMAX   204 209-224 serial
serial               /dev/ttyS       4 64-111 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console
q35ek:514> 

The first command finds the major/minor number of the tty you're interested in.

The second finds info about the driver: it's a uart:16550A (the 'A' model has a character fifo), it's on IO port 0x3F8 and uses IRQ 4, tx and rx character counts and lastly the available control options.

The third shows the matching drivers for each device. 4:64 uses the serial driver_name. Some developers are not great about uniquely defining the driver_name so this could be either the 8250/16550-compatible device (under $K/drivers/tty/serial/8250), a DECstation DZ chip or a GRLIB uart. I'm going out on a limb and saying it's an 8250/16550 interface as shown by the following code snippet:

static struct uart_driver serial8250_reg = {
    .owner          = THIS_MODULE,
    .driver_name        = "serial",
    .dev_name       = "ttyS",
    .major          = TTY_MAJOR,
    .minor          = 64,
    .cons           = SERIAL8250_CONSOLE,
};
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
dturvene
  • 2,284
  • 1
  • 20
  • 18
  • 16550 is certainly a good default assumption for a normal PC, but you can put other serial cards into PCI slots. e.g. an old modem server might have a cyclades multi-port serial card (or one from another vendor), and Linux has drivers for that, https://github.com/torvalds/linux/blob/fcadab740480e0e0e9fa9bd272acd409884d431a/drivers/tty/cyclades.c. This would be a better answer if you pointed out that standard IBM-PC compatible machines normally have 16550 built-in, without saying anything over-broad like all x86 machines. – Peter Cordes Feb 02 '21 at 20:03