drivers/platform/x86/asus-tf103c-dock.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/asus-tf103c-dock.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/asus-tf103c-dock.c
Extension
.c
Size
27626 bytes
Lines
944
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

struct tf103c_dock_data {
	struct delayed_work hpd_work;
	struct irq_chip tp_irqchip;
	struct irq_domain *tp_irq_domain;
	struct i2c_client *ec_client;
	struct i2c_client *intr_client;
	struct i2c_client *kbd_client;
	struct i2c_client *tp_client;
	struct gpio_desc *pwr_en;
	struct gpio_desc *irq_gpio;
	struct gpio_desc *hpd_gpio;
	struct input_dev *input;
	struct hid_device *hid;
	unsigned long flags;
	int board_rev;
	int irq;
	int hpd_irq;
	int tp_irq;
	int last_press_0x13;
	int last_press_0x14;
	bool enabled;
	bool tp_enabled;
	bool altgr_pressed;
	bool esc_pressed;
	bool filter_esc;
	u8 kbd_buf[TF103C_DOCK_KBD_DATA_MAX_LENGTH];
};

static struct gpiod_lookup_table tf103c_dock_gpios = {
	.dev_id = "i2c-" TF103C_DOCK_DEV_NAME,
	.table = {
		GPIO_LOOKUP("INT33FC:00",      55, "dock_pwr_en", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("INT33FC:02",       1, "dock_irq", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("INT33FC:02",      29, "dock_hpd", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio_crystalcove", 2, "board_rev", GPIO_ACTIVE_HIGH),
		{}
	},
};

/* Byte 0 is the length of the rest of the packet */
static const u8 tf103c_dock_enable_cmd[9] = { 8, 0x20, 0, 0, 0, 0, 0x20, 0, 0 };
static const u8 tf103c_dock_usb_enable_cmd[9] = { 8, 0, 0, 0, 0, 0, 0, 0x40, 0 };
static const u8 tf103c_dock_suspend_cmd[9] = { 8, 0, 0x20, 0, 0, 0x22, 0, 0, 0 };

/*** keyboard related code ***/

static u8 tf103c_dock_kbd_hid_desc[] = {
	0x05, 0x01,         /*  Usage Page (Desktop),               */
	0x09, 0x06,         /*  Usage (Keyboard),                   */
	0xA1, 0x01,         /*  Collection (Application),           */
	0x85, 0x11,         /*      Report ID (17),                 */
	0x95, 0x08,         /*      Report Count (8),               */
	0x75, 0x01,         /*      Report Size (1),                */
	0x15, 0x00,         /*      Logical Minimum (0),            */
	0x25, 0x01,         /*      Logical Maximum (1),            */
	0x05, 0x07,         /*      Usage Page (Keyboard),          */
	0x19, 0xE0,         /*      Usage Minimum (KB Leftcontrol), */
	0x29, 0xE7,         /*      Usage Maximum (KB Right GUI),   */
	0x81, 0x02,         /*      Input (Variable),               */
	0x95, 0x01,         /*      Report Count (1),               */
	0x75, 0x08,         /*      Report Size (8),                */
	0x81, 0x01,         /*      Input (Constant),               */
	0x95, 0x06,         /*      Report Count (6),               */
	0x75, 0x08,         /*      Report Size (8),                */
	0x15, 0x00,         /*      Logical Minimum (0),            */
	0x26, 0xFF, 0x00,   /*      Logical Maximum (255),          */
	0x05, 0x07,         /*      Usage Page (Keyboard),          */
	0x19, 0x00,         /*      Usage Minimum (None),           */
	0x2A, 0xFF, 0x00,   /*      Usage Maximum (FFh),            */
	0x81, 0x00,         /*      Input,                          */
	0xC0                /*  End Collection                      */
};

static int tf103c_dock_kbd_read(struct tf103c_dock_data *dock)
{
	struct i2c_client *client = dock->kbd_client;
	struct device *dev = &dock->ec_client->dev;
	struct i2c_msg msgs[2];
	u8 reg[2];
	int ret;

	reg[0] = TF103C_DOCK_KBD_DATA_REG & 0xff;
	reg[1] = TF103C_DOCK_KBD_DATA_REG >> 8;

	msgs[0].addr = client->addr;
	msgs[0].flags = 0;
	msgs[0].len = sizeof(reg);
	msgs[0].buf = reg;

	msgs[1].addr = client->addr;

Annotation

Implementation Notes