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

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

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/x86-android-tablets/other.c
Extension
.c
Size
26249 bytes
Lines
884
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
/*
 * DMI based code to deal with broken DSDTs on X86 tablets which ship with
 * Android as (part of) the factory image. 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>
 */

#include <linux/acpi.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
#include <linux/input-event-codes.h>
#include <linux/leds.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>

#include <dt-bindings/leds/common.h>

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

/*
 * Advantech MICA-071
 * This is a standard Windows tablet, but it has an extra "quick launch" button
 * which is not described in the ACPI tables in anyway.
 * Use the x86-android-tablets infra to create a gpio-keys device for this.
 */
static const struct software_node advantech_mica_071_gpio_keys_node = {
	.name = "prog1_key",
};

static const struct property_entry advantech_mica_071_prog1_key_props[] = {
	PROPERTY_ENTRY_U32("linux,code", KEY_PROG1),
	PROPERTY_ENTRY_STRING("label", "prog1_key"),
	PROPERTY_ENTRY_GPIO("gpios", &baytrail_gpiochip_nodes[0], 2, GPIO_ACTIVE_LOW),
	PROPERTY_ENTRY_U32("debounce-interval", 50),
	{ }
};

static const struct software_node advantech_mica_071_prog1_key_node = {
	.parent = &advantech_mica_071_gpio_keys_node,
	.properties = advantech_mica_071_prog1_key_props,
};

static const struct software_node *advantech_mica_071_button_swnodes[] = {
	&advantech_mica_071_gpio_keys_node,
	&advantech_mica_071_prog1_key_node,
	NULL
};

const struct x86_dev_info advantech_mica_071_info __initconst = {
	.gpio_button_swnodes = advantech_mica_071_button_swnodes,
	.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};

/*
 * When booted with the BIOS set to Android mode the Chuwi Hi8 (CWI509) DSDT
 * contains a whole bunch of bogus ACPI I2C devices and is missing entries
 * for the touchscreen and the accelerometer.
 */
static const struct property_entry chuwi_hi8_gsl1680_props[] = {
	PROPERTY_ENTRY_U32("touchscreen-size-x", 1665),
	PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
	PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
	PROPERTY_ENTRY_BOOL("silead,home-button"),
	PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-chuwi-hi8.fw"),
	{ }
};

static const struct software_node chuwi_hi8_gsl1680_node = {
	.properties = chuwi_hi8_gsl1680_props,
};

static const char * const chuwi_hi8_mount_matrix[] = {
	"1", "0", "0",
	"0", "-1", "0",
	"0", "0", "1"
};

static const struct property_entry chuwi_hi8_bma250e_props[] = {
	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", chuwi_hi8_mount_matrix),
	{ }
};

static const struct software_node chuwi_hi8_bma250e_node = {
	.properties = chuwi_hi8_bma250e_props,
};

Annotation

Implementation Notes