Skip to content

masneyb/nexus-5-upstream

Repository files navigation

This page describes the current development efforts to port the upstream Linux Kernel to the LG Nexus 5 (hammerhead) phone. This work benefits other devices that use the Qualcomm msm8974 System on Chip (SoC) such as the Fairphone 2, OnePlus One, Samsung Galaxy S5, Sony Xperia Z1, Sony Xperia Z2 tablets, and current devices that use some of the same IP blocks within newer Qualcomm SoCs.

The factory kernel image is based on the upstream Linux 3.4 kernel that was released in May 2012, and adds almost 2 million lines of code on top of the upstream kernel. This factory image is abandoned and no longer receives security updates. The goal is to eventually get all of the major components working upstream so that the phone will work with the latest upstream kernel. These patches will eventually appear in the Android kernels as they rebase their kernels onto newer upstream LTS kernel releases.

Hardware status

The following components work upstream without any additional patches: display, backlight, touchscreen, USB, WiFi, charger, gyroscope / accelerometer, magnetometer, temperature / humidity / barometer, proximity / ambient light sensor (ALS), serial console, battery.

My linux tree on GitHub contains work-in-progress patches that adds support for the GPU, modem, bluetooth, and vibrator. See my v5.5 patch series cover letter that gives a high-level overview of the status of those patches.

I have work in progress patches available below to get the external display over HDMI and the IOMMU, where the latter is the last piece that's needed to support the GPU upstream. The hardware isn't fully working yet with these patches.

See the TODO list for information about other components and links to some out-of-tree patches.

Note that the kernel command line arguments msm.allow_vram_carveout msm.vram=48m must be passed used in order for the display to work properly. These options are present in my build-kernel script.

Phone user space

I've been running postmarketOS on the phone. Follow the instructions on their Nexus 5 page that describes how to install it. Here's my pmbootstrap.cfg config file. Once that's installed, see my build-kernel script for how to build and boot a custom kernel into a postmarketOS userspace.

A serial console can be obtained through the headphone jack and requires building a custom cable as described on this page. You will want to make a cable if you plan to do any development work.

External GPIO Example

See the gpio_demoy.py script for the source code to the GTK+ application controlling the external LEDs in the image above. The phone is running XFCE4 and postmarketOS on an upstream Linux kernel. This Tiny OTG USB adapter is used on that video.

Upstream contribution summary

The following is a summary of my upstream Linux kernel contributions as part of this project:

  • Created a new Qualcomm msm8974 interconnect driver that allows setting system bandwidth requirements between various network-on-chip fabrics. This is required in order to support the display, GPU and various other devices upstream. Patches
  • Created a new On Chip Memory (OCMEM) allocator driver that allows various clients to allocate memory from OCMEM based on performance, latency and power requirements. This is typically used by the GPU, camera/video, and audio components on some Snapdragon SoCs. Patches
  • Hierarchical IRQ chip support for all Qualcomm platforms (spmi-gpio and ssbi-gpio) so that device tree consumers can request an IRQ directly from the GPIO block rather than having to request an IRQ from the underlying PMIC. Contributed to the generic implementation in the GPIO core. Patches
  • When attempting to setup up a GPIO hog, device probing would repeatedly fail with -EPROBE_DEFERED errors during system boot due to a circular dependency between the GPIO and Pinctrl frameworks. Patches
  • Corrected issue with the Freedreno DRM/KMS driver not working properly on old command-mode DSI panels, dirty framebuffer helper support, corrected msm8974 gfx3d clock, wired display into msm8974 device tree, corrected issues when running without an IOMMU, and silenced several -EPROBE_DEFER warnings. Patches
  • Created PLL driver and necessary device tree changes for external display over HDMI (work in progress), converted analogix-anx78xx driver to use i2c_new_dummy_device(), added necessary regulator node to device tree, and added support for new variants to the analogix-anx78xx driver. Patches
  • Took over maintainership of the TAOS tsl2772 driver upstream for the proximity detection and ambient light sensing, performed the staging graduation, corrected equations and timings for the 10 hardware variants supported by the driver, got interrupt and proximity functionality working properly, added regulator support, and numerous cleanups to the driver. Patches
  • Added firmware node support to the existing lm3630a driver and corrected an issue updating the brightness level via sysfs. Patches
  • Added extcon support to the existing bq24190_charger driver upstream, and support for USB OTG to device tree. Patches
  • Found and fixed an issue with the qcom-crypto.c driver not waiting for availablity of randomness from the hardware and would return zeros. Patches
  • Work in progress patches to get the vibrator supported upstream. Working with the upstream maintainers to see where this code should go upstream. Patches
  • Work in progress patches to get the IOMMU for the display and GPU working. Patches
  • Cleaned up patches from other people and got them accepted upstream for the following components: various I2C sensors, panel, WiFi / Bluetooth, touchscreen, and sdhci.
  • Bisected bugs found in linux-next with the regulator subsystem and the mmc/sdhci system.
  • I have another page that describes some of my other kernel work that's not related to this Nexus 5 project. A few highlights: 3 staging graduations in the IIO subsystem, runtime power management, and various other driver cleanups.

Display

Patches

Note that the ones with a short git SHA at the beginning are in the mainline kernel, the ones marked Queued are in linux-next, and the others are labeled either Pending or Needs work.

Other resources

Contact

Brian Masney: Email, Linked In, GitHub