Motorola Droid 4 - WL1285 and GPS
Today I had another look at GPS for Droid 4. In theory it has 3 different chips, that have GPS receivers: WL1285C, MDM6600, WG3LTE. The Cyanogenmod changelog for the Droid 4 contains a hint, that WL1285C’s GPS module is the one actually used:
Don't hold st_wakelock until BT/GPS is used for the first time
Also the stock kernel contains a driver for GPS from WiLink. WiLink based chips come with either SPI or SDIO connection for WLAN and a shared UART for Bluetooth (BT), FM radio, GPS and NFC. Let’s see how sharing the UART for multiple wireless protocols work:
Standard Bluetooth has 4 different packet types and there is a Bluetooth over UART standard (named H4), which defines, that each packet begins with its packet type. It also specifies a header for each of the packet types, that contains the packet’s length. So we can identify any of the Bluetooth packets via their first byte and their packet length.
- 0x01 - HCI_COMMAND_PKT
- 0x02 - HCI_ACLDATA_PKT
- 0x03 - HCI_SCODATA_PKT
- 0x04 - HCI_EVENT_PKT
So basically we can just use the standard H4 bluetooth protocol driver with WiLink devices. There are a few extra packet types, though:
- 0x30 - LL_SLEEP_IND
- 0x31 - LL_SLEEP_ACK
- 0x32 - LL_WAKE_UP_IND
- 0x33 - LL_WAKE_UP_ACK
These types are used for power management of the chip. There is a bluetooth driver for standard H4 protocol + TI power management named hci_ll. This really can be used for WiLink devices, if only the Bluetooth functionality is required.
FM, GPS (and NFC on devices having that) use the following command bytes:
- 0x08 - FM
- 0x09 - GPS
- 0x0c - NFC
The mainline kernel also supports FM radio. For that a driver named ti-st (shared transport) is used, which creates a device named kim exposing some information to sysfs. Like all UART solutions before 2017 ti-st can be attached to the UART as line discipline from userspace. For this TI’s uimd reads the sysfs information and then prepares the line discipline. The ti-st driver itself only handles the power management of the chip. All other functions, like Bluetooth or FM are implemented in their own drivers, that hook into ti-st.
Since 4.11-rc1 we have serdev, so the uimd hack could be avoided. Using serdev ti-st could open and configure the UART without any custom userspace software. The result would be out-of-the-box support for Bluetooth and FM radio. Unfortunately the mainline kernel does not yet have a driver for the chip’s GPS part. Porting the driver from the Droid 4 stock kernel is not much work, but the userspace interface is not very nice. I guess its time to create a proper GPS subsystem in the Linux kernel. This would also be useful for the Nokia N900.
– Sebastian