drivers/platform/x86/x86-android-tablets/lenovo.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/x86-android-tablets/lenovo.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/x86-android-tablets/lenovo.c
Extension
.c
Size
33709 bytes
Lines
1080
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Board info for Lenovo X86 tablets which ship with Android as the factory image
 * and which have broken DSDT tables. The factory kernels shipped on these
 * devices typically have a bunch of things hardcoded, rather than specified
 * in their DSDT.
 *
 * Copyright (C) 2021-2023 Hans de Goede <hansg@kernel.org>
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/efi.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
#include <linux/input-event-codes.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
#include <linux/mfd/intel_soc_pmic.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_data/lp855x.h>
#include <linux/platform_device.h>
#include <linux/power/bq24190_charger.h>
#include <linux/reboot.h>
#include <linux/rmi.h>
#include <linux/spi/spi.h>

#include "shared-psy-info.h"
#include "x86-android-tablets.h"

/*
 * Various Lenovo models use a TI LP8557 LED backlight controller with its PWM
 * input connected to a PWM output coming from the LCD panel's controller.
 * The Android kernels have a hack in the i915 driver to write a non-standard
 * panel specific DSI register to set the duty-cycle of the LCD's PWM output.
 *
 * To avoid having to have a similar hack in the mainline kernel program the
 * LP8557 to directly set the level and use the lp855x_bl driver for control.
 *
 * The LP8557 can either be configured to multiply its PWM input and
 * the I2C register set level (requiring both to be at 100% for 100% output);
 * or to only take the I2C register set level into account.
 *
 * Multiplying the 2 levels is useful because this will turn off the backlight
 * when the panel goes off and turns off its PWM output.
 *
 * But on some models the panel's PWM output defaults to a duty-cycle of
 * much less then 100%, severely limiting max brightness. In this case
 * the LP8557 should be configured to only take the I2C register into
 * account and the i915 driver must turn off the panel and the backlight
 * separately using e.g. VBT MIPI sequences to turn off the backlight.
 */
static struct lp855x_platform_data lenovo_lp8557_pwm_and_reg_pdata = {
	.device_control = 0x86,
	.initial_brightness = 128,
};

static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
	.device_control = 0x85,
	.initial_brightness = 128,
};

static const struct software_node arizona_gpiochip_node = {
	.name = "arizona",
};

static const struct software_node crystalcove_gpiochip_node = {
	.name = "gpio_crystalcove",
};

/* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */

static const struct property_entry lenovo_yb1_x90_goodix_props[] = {
	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[1], 53, GPIO_ACTIVE_HIGH),
	PROPERTY_ENTRY_GPIO("irq-gpios", &cherryview_gpiochip_nodes[1], 56, GPIO_ACTIVE_HIGH),
	{ }
};

static const struct software_node lenovo_yb1_x90_goodix_node = {
	.properties = lenovo_yb1_x90_goodix_props,
};

static const struct property_entry lenovo_yb1_x90_wacom_props[] = {
	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0001),
	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 150),
	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 82, GPIO_ACTIVE_LOW),
	{ }
};

Annotation

Implementation Notes