Linux Drivers for Masterclock PCIe Cards

Click to Download

After downloading, edit the line in the makefile to indicate where the program should expect to find its .conf configuration file. Edit the log filespec line in the .conf file to indicate where you want the log file to go.

Linux manages serial configuration through device files located in the filesystem under /dev.  Normally, you might see:


Note that your flavor of Linux/Un*x may use slightly different nomenclature to refer to serial devices.  Consult your operating system documentation.

From this point, instructions will refer to installing the PCIe-GPS/MCR (hereinafter PCIe) in a Linux 2.6 kernel operating system.  Procedures may vary for other PC-based Un*x distributions.

By default Linux will detect, initialize, and establish serial devices for the first four physical serial ports that it finds. This presents a configuration challenge because the PCIe-GPS/MCR (hereinafter PCIe) itself contains four independent serial ports. It is possible for Linux to find other serial ports in the system first resulting in only some (or even none) of the PCIe serial ports being detected.  Some manual configuration will be required to resolve this.

One method to deal with this situation is to disable all hardware serial interfaces other than the PCie card.  This may involve disabling all on-motherboard serial ports in the computer's BIOS, removing add-in serial interface boards, or both.  This may not be desirable if there is an expectation that these serial port(s) may be used in the future.

A better method to deal this situation is to increase the number of serial ports that the Linux operating system will recognize by default.  
This can be done by providing configuration changes to the kernel module at boot time (usually via 'grub' or 'lilo').  To the bootloader add kernel option '8250.nr_uarts=X", where X is the desired new maximum to support.  (In cases where the serial driver is compiled directly into the kernel, the option is 'nr_uarts=X').

Theoretically, 'X' would be set to the total number of physical serial ports currently installed in the system including the four associated with the PCIe card.  When is doubt, '8' would be a good starting point.  

Note that the PCIe software will have to examine each of these serial ports to auto-detect the location of the card and its features.  
Therefore, avoid setting this number unnecessarily high.

After making the configuration changes and rebooting the system you should see at least four, and usually more, ttySx devices in /dev.

IMPORTANT: There is an additional run-time configuration change to make to the PCIe serial ports.  The crystal (clock) on the PCIe board is not the default frequency used for most serial UARTs but Linux's serial drivers are unaware of this.  To accommodate this, a change to the serial driver's 'baud_base' parameter is needed for each PCIe port.


Identify the serial devices (/dev/ttySx) associated with the PCIe

Use the 'lspci' tool to determine the BIOS-assigned configuration for the PCIe.  We are specifically concerned with the IRQ and I/O port address space assigned and will examine  these values to determine which /dev/ttySx (if any) are assigned to our card.
Dump the output of 'lspci -v' to a file.  Examine the contents looking for the "Pericom Semiconductor Device 7954."  The data below this PCI item will identify the IRQ (interrupt) assigned, and also the beginning of the I/O address space (example 0xd000) and the address space length
which will be 64 bytes for the 4-port Pericom chip.   All Pericom ports
will share the assigned IRQ (example 17).

Now we will examine the configuration for the existing serial devices.  
For example, in /dev we may have:


For each device, use the 'setserial' tool to view the device's assigned configuration.  For example 'setserial /dev/ttyS0' might produce the following output:

/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4

We can tell that the IRQ shown above (4) is not the same IRQ assigned to our Pericom device (17).  The I/O port address space is also not within the I/O port space mapped to the PCIe card. Therefore, we know that this serial port is physically located elsewhere in the computer - most probably on the computer's motherboard.

Continue the 'setserial' procedure for each serial device in /dev until we have identified which (if any) serial devices have been initialized on the PCIe board.  For example, a 'setserial' examination of ttyS1, ttyS2, ttyS3, and ttyS4 might produce the following results:

/dev/ttyS1, Line 1, UART: 16650, Port: 0xd000, IRQ: 17

/dev/ttyS2, Line 2, UART: 16650, Port: 0xd008, IRQ: 17

/dev/ttyS3, Line 3, UART: 16650, Port: 0xd010, IRQ: 17

/dev/ttyS4, Line 4, UART: 16650, Port: 0xd018, IRQ: 17

Examining the IRQ and I/O port address space information above shows that all of these devices are referring to resources assigned to the PCIe card.

Using the 'setserial' tool, change the 'base_baud' configuration on each serial device associated with the PCIe card.  

Referencing the above example:

setserial /dev/ttyS1 baud_base 921600

setserial /dev/ttyS2 baud_base 921600

setserial /dev/ttyS3 baud_base 921600

setserial /dev/ttyS4 baud_base 921600

The serial ports should now be configured properly and ready for use.  

GPSMCR application will auto-detect the PCIe card at run-time.

Note:  Debugging build is enabled by default.  You will get a lot of messages, and also to stdout. You can take the -D_DEBUG out of the makefile, or you can just close the terminal window you used to fire off the 'gpsmcr' instance.  You can also tone down the volume of debugging messages with -debug=1, -debug=0, etc.... (default level of debugging output for debug build is 3) 

You can shut the daemon down gracefully by sending it a SIGTERM.