Linux on the Lenovo Yoga 2 Tablet

Yoga2 This neat tablet/laptop combo sports a nice 1920x1200 IPS display and a detachable Bluetooth keyboard/touchpad unit. Of course you want to run Linux on it (Fedora in my case). Follow Pascal's tutorial to get a basic system set up. However, some problems remain:

  • The Bluetooth keyboard
  • Accelerated X
  • Backlight control (important for suspend)
  • Sound
Here we'll solve at least two of them :)


Bluetooth

The Bluetooth chip is a Broadcom 4324 which is really picky about the devices it pairs with. Pascal's systemd service will apparently enable Bluetooth, but the keyboard will not work. In order to fix that, add the following to the service file to load the correct firmware:
/usr/local/bin/brcm_patchram_plus --no2bytes --baudrate 3000000 --use_baudrate_for_download 
--patchram /etc/firmware/brcm/BCM4324B3_002.004.006.0130.0161.hcd -bd_addr $MAC /dev/ttyS4 
-d >/tmp/btlog 2>&1
brcm_patchram_plus can be found here and the firmware file is here. Then just pair and trust the keyboard and it will work.


Update: Starting with 4.15.x kernels in F27, Fedora changed the way of dealing with bluetooth keyboards which at first didn't work with the Yoga. Hans then fixed it upstream and for F28 you don't need the bluetooth systemd service file any longer. You only need to copy the firmware to /usr/lib/firmware/brcm/BCM4324B3.hcd and the kernel will do the rest!


Accelerated X

Pascal notes that enabling the i915 driver crashes the kernel. This can be fixed by adding the following boot parameters to the kernel (in /etc/default/grub for example):
i915.modeset=1 intel_pstate=disable intel_idle.max_cstate=1 clocksource=tsc
Then create /etc/X11/xorg.conf.d/20-intel.conf:
Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
    Option "DPMS"
    Option "AccelMethod" "sna"
    Option "TearFree" "True"
EndSection
This will prevent the CPU from entering the deep sleep states (> C1), but my measurements indicate that this does not impact battery life too much.


Backlight

Pascal found a way to turn it off and on (most important for suspend), and I later discovered how to set the brightness. It's not the official ACPI way (the hardware is pretty screwed up), but it gets the job done. Create /usr/local/bin/setBacklight:
#!/bin/bash

if [[ "$1" == "off" ]];
then
    /usr/sbin/i2cset -y 9 0x2c 0x00 0
elif [[ "$1" == "on" ]];
then
    /usr/sbin/i2cset -y 9 0x2c 0x00 1
elif [[ "$1" == "read" ]];
then
    i2cget -y 9 0x2c 0x04
else
    /usr/sbin/i2cset -y 9 0x2c 0x00 0
    /usr/sbin/i2cset -y 9 0x2c 0x10 0x85
    /usr/sbin/i2cset -y 9 0x2c 0x04 $1
    /usr/sbin/i2cset -y 9 0x2c 0x00 1
fi
and /lib/systemd/system-sleep/backlight:
!/bin/sh

if [[ "$1" == "pre" ]];
then
    /usr/local/bin/setBacklight read > /var/tmp/brightness
    /usr/local/bin/setBacklight off
else
    /usr/local/bin/setBacklight on
    if [ -f /var/tmp/brightness ]
    then
        /usr/local/bin/setBacklight `cat /var/tmp/brightness`
    fi
    /bin/systemctl restart  bluetooth.service
    /usr/sbin/powertop --auto-tune
fi
and your Yoga will suspend and resume nicely. Use setBacklight 0-255 to set brightness manually.


Update: at some point the kernel got support for the PWM chip used in the Yoga and you can now control display brightness via the generic Gnome shell slider.

all images Creative Commons License - last change: 2018/06/13
a 2024 daduke production. all rights reserved.