Please note that the x86 COM Express® EAPI Linux package is only available on request. Please contact support@tq-group.com.
The Linux drivers package tqmx86-dist-1.3.tar.gz is intended to be installed on TQ modules based on the COM Express® standard.
Tested operating systems:
$ sudo apt-get install i2c-tools lm-sensors $ sudo apt-get install dkms linux-headers-$(uname -r) $ sudo dpkg -i tqmx86-drivers_1.3_{i386,amd64}.deb
configs/sensors.tqmx
from tqmx86-dist-1.3.tar.gz to /etc/sensors.d/
$ cp configs/sensors.tqmx /etc/sensors.d/
Note: this configuration file has been tested on TQMxE38x module. For other TQ COMExpress modules, a following change may be required to make CPU-Temp sensor functional:
label temp1 “CPUtemp” should be changed to label temp5 “CPUtemp”
configs/tqmx86.conf
from tqmx86-dist-1.3.tar.gz to /etc/modules-load.d/
$ cp configs/tqmx86.conf /etc/modules-load.d/
/etc/modprobe.d/blacklist.conf
: Comment out 'blacklist i2c_i801'$ nano /etc/modprobe.d/blacklist.conf
/etc/default/grub
: Add 'acpi_enforce_resources=lax' parameter to the 'GRUB_CMDLINE_LINUX_DEFAULT' variable definition $ nano /etc/default/grub
$ update-grub
$ reboot
$ lsmod
Check that the following kernel modules/drivers have been automatically loaded:
tqmx86 tqmx86_wdt gpio_tqmx86 at24 nct7802 i2c_i801 i2c_machxo2 or i2c_wishbone
Note: starting from version R01.02, the package also supports a Lattice Wishbone soft I2C controller which is present on some versions of TQMx86 boards. For such boards, all instances of “i2c-machxo2” should be replaced with “i2c-wishbone” throughout this document.
modprobe
/dev/watchdog /dev/watchdog0 /sys/devices/platform/tqmx86/ /sys/devices/platform/tqmx86/i2c-machxo2/ (or i2c-wishbone) /sys/devices/platform/tqmx86/tqmx86wdt/ /sys/devices/platform/tqmx86/tqmx86gpio/ /sys/devices/pci0000:00/0000:00:1f.*/i2c*/*002c/hwmon/hwmon* /sys/devices/platform/tqmx86/i2c*/i2c*/*0050/
To obtain board and system information, following commands can be used:
$ cat /sys/class/dmi/id/sys_vendor
$ cat /sys/devices/platform/tqmx86/board_id
$ cat /sys/devices/platform/tqmx86/board_version
$ cat /sys/class/dmi/id/bios_version
A standard Watchdog API is provided by the driver. Please refer to official documentation
for further reference:
https://www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt
$ gcc wdtest.c -o wdtest
sudo sh -c "./wdtest -p 20 &"
The above command pings watchdog every 20 seconds - this is short enough for the default timeout period of 32 sec.
WARNING: once the watchdog is first accessed it is started and cannot be stopped by any means - it can only be restarted by wdtest or similar watchdog daemon program or just by writing a character into /dev/watchdog (/dev/watchdog0) file.
$ ps ax | grep wdtest 1686 pts/8 S 0:00 ./wdtest -p 20 $ sudo kill -9 1686 ;sudo ./wdtest i ;sudo sh -c "./wdtest -p 20 &" Options: 8080, Version: 0, Id: TQMx86 Watchdog Status: 0 Timeout: 32
The above command kills the running daemon, requests watchdog info and starts new daemon.
$ ps ax |grep wdtest 1703 pts/8 S 0:00 ./wdtest -p 20 $ sudo kill -9 1703; sudo ./wdtest -t 800 $ sudo sh -c "./wdtest -p 500 &"
The timeout is set to 1024sec
Note: delay between 'kill' and 'start' commands should be short not to allow watchdog to reset the board.
A standard GPIO API is provided by the driver. Please refer to official documentation for
further reference:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
GPIO functionality may be tested by a gpio-test.sh shell script provided in examples directory of the tqmx86-dist-1.3.tar.gz archive. The program requires root privileges to export a 'pin' (once) and to change the output value. With a single 'pin' argument the program reports pin status (direction and value). When the second argument is provided it changes state of (output) pin accordingly:
sudo ./gpio-test.sh 2 Direction: out Value: 0 $ sudo ./gpio-test.sh 5 Direction: in Value: 1 $ sudo ./gpio-test.sh 2 1 $ ./gpio-test.sh 2 Direction: out Value: 1
Note: GPIO[0:3] are hardwired as outputs and GPIO[4:7] as inputs. Direction cannot be changed.
A standard I2C dev API is provided by the driver. Please refer to official documentation for further reference:
https://www.kernel.org/doc/Documentation/i2c/dev-interface
Let's consider several examples how to access devices on I2C bus:
$ sudo hexdump -C /sys/devices/platform/tqmx86/i2c-*/i2c-*/*-0050/eeprom 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000010 54 51 4d 78 45 33 38 4d 0a ff ff ff ff ff ff ff |TQMxE38M........| 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 000002a0 ff a1 ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 000002b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00001000
$ i2cdetect l i2c-0 unknown i915 gmbus ssc N/A i2c-1 unknown i915 gmbus vga N/A i2c-2 unknown i915 gmbus panel N/A i2c-3 unknown i915 gmbus dpc N/A i2c-4 unknown i915 gmbus dpb N/A i2c-5 unknown i915 gmbus dpd N/A i2c-6 unknown DPDDCB N/A i2c-7 unknown DPDDCC N/A i2c-8 unknown i2c-machxo2 N/A i2c-9 unknown SMBus I801 adapter at 3000 N/A
(According to the output above, it's 8.)
$ sudo i2cdump -r 0-3 8 0x70 [part of the output skipped] 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 05 ff 00 ff
All pins are configured as input, pins 0 and 2 are pulled up to 3.3V.
$ sudo i2cset 8 0x70 3 0xf0 $ sudo i2cdump -r 0-3 8 0x70 00: 0f ff 00 f0
$ sudo i2cset 8 0x70 1 0x06 $ sudo i2cdump -r 0-3 8 0x70 00: 06 06 00 f0
Note: setting pin 0 to output value 0 should turn on LED.
Option: PCA9540 I/O multiplexer
$ gcc i2c-rw.c -o i2c-rw
$ sudo ./i2c-rw -s 8 0x57 0 0x40 Time: 6344 usec 0000: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ................ 0010: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ................ 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
$ sudo ./i2c-rw -s 8 0x57 0xa00 0x200 Time: 47233 usec 0a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ [skipped] 0af0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0b00: 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b ................ 0b10: 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b ................ 0b20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ [skipped] 0bf0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
$ echo -n "Hello!" |sudo ./i2c-rw -s -w 8 0x57 0x30 Time: 978 usec $ sudo ./i2c-rw -s 8 0x57 0x20 0x20 Time: 3400 usec 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0030: 48 65 6c 6c 6f 21 ff ff ff ff ff ff ff ff ff ff Hello!..........
Note: the program supports reading/writing up to 8K of data in a single request. However, i2c slave devices may impose different limits for a single operation. In particular:
Refer to datasheet for Microchip 24AA32A EEPROM for further details.
A standard hwmon API is provided by the driver via sysfs. But a high-level wrapper/library libsensors can be used to access sensors as well. Please refer to official documentation for further reference:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
Standard Linux 'sensors' command can be used to obtain NCT7802 and coretemp (MSR registers of CPU) hardware monitor data:
$ sensors coretemp-isa-0000 Adapter: ISA adapter Core 0: +30.0°C (high = +110.0°C, crit = +110.0°C) Core 1: +30.0°C (high = +110.0°C, crit = +110.0°C) Core 2: +31.0°C (high = +110.0°C, crit = +110.0°C) Core 3: +31.0°C (high = +110.0°C, crit = +110.0°C) soc_dts0-virtual0 Adapter: Virtual device temp1: +29.0°C soc_dts1-virtual0 Adapter: Virtual device temp1: +30.0°C nct7802-i2c-9-2c Adapter: SMBus I801 adapter at 3000 3V3: +3.37 V (min = +0.00 V, max = +4.09 V) RTCbat: +3.02 V 5VSB: +5.08 V (min = +0.00 V, max = +6.24 V) COMeinput: +12.38 V (min = +0.00 V, max = +21.99 V) CPUfan: 0 RPM (min = 0 RPM) COMefan: 3936 RPM (min = 0 RPM) CPUtemp: +30.2°C (low = +0.0°C, high = +85.0°C) (crit = +100.0°C) SYStemp: +30.0°C (low = +0.0°C, high = +85.0°C) (crit = +100.0°C)
$ sudo modprobe tqmx86 i2c_speed=50
This parameter may be also added to file in
/etc/modprobe.d/
as:
options tqmx86 i2c_speed=50