drivers/platform/arm64/lenovo-thinkpad-t14s.c
Source file repositories/reference/linux-study-clean/drivers/platform/arm64/lenovo-thinkpad-t14s.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/arm64/lenovo-thinkpad-t14s.c- Extension
.c- Size
- 17359 bytes
- Lines
- 663
- 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bits.hlinux/cleanup.hlinux/container_of.hlinux/device.hlinux/delay.hlinux/dev_printk.hlinux/err.hlinux/i2c.hlinux/input.hlinux/input/sparse-keymap.hlinux/interrupt.hlinux/leds.hlinux/lockdep.hlinux/module.hlinux/regmap.hlinux/slab.hlinux/pm.h
Detected Declarations
struct t14s_ec_led_classdevstruct t14s_ecenum t14s_ec_led_status_tfunction t14s_ec_writefunction t14s_ec_readfunction t14s_ec_read_evtfunction t14s_ec_write_sequencefunction t14s_led_set_statusfunction t14s_led_brightness_setfunction t14s_led_blink_setfunction t14s_init_ledfunction t14s_leds_probefunction t14s_kbd_bl_setfunction t14s_kbd_bl_getfunction t14s_kbd_bl_updatefunction t14s_kbd_backlight_probefunction t14s_audio_led_getfunction t14s_audio_led_setfunction t14s_mic_mute_led_getfunction t14s_mic_mute_led_setfunction t14s_spk_mute_led_getfunction t14s_spk_mute_led_setfunction t14s_kbd_audio_led_probefunction t14s_input_probefunction t14s_ec_irq_handlerfunction t14s_ec_probefunction t14s_ec_suspendfunction t14s_ec_resume
Annotated Snippet
struct t14s_ec_led_classdev {
struct led_classdev led_classdev;
int led;
enum t14s_ec_led_status_t cache;
struct t14s_ec *ec;
};
struct t14s_ec {
struct regmap *regmap;
struct device *dev;
struct t14s_ec_led_classdev led_pwr_btn;
struct t14s_ec_led_classdev led_chrg_orange;
struct t14s_ec_led_classdev led_chrg_white;
struct t14s_ec_led_classdev led_lid_logo_dot;
struct led_classdev kbd_backlight;
struct led_classdev led_mic_mute;
struct led_classdev led_spk_mute;
struct input_dev *inputdev;
};
static const struct regmap_config t14s_ec_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0xff,
};
static int t14s_ec_write(void *context, unsigned int reg,
unsigned int val)
{
struct t14s_ec *ec = context;
struct i2c_client *client = to_i2c_client(ec->dev);
u8 buf[5] = {T14S_EC_CMD_ECWR, reg, 0x00, 0x01, val};
int ret;
ret = i2c_master_send(client, buf, sizeof(buf));
if (ret < 0)
return ret;
fsleep(10000);
return 0;
}
static int t14s_ec_read(void *context, unsigned int reg,
unsigned int *val)
{
struct t14s_ec *ec = context;
struct i2c_client *client = to_i2c_client(ec->dev);
u8 buf[4] = {T14S_EC_CMD_ECRD, reg, 0x00, 0x01};
struct i2c_msg request, response;
u8 result;
int ret;
request.addr = client->addr;
request.flags = I2C_M_STOP;
request.len = sizeof(buf);
request.buf = buf;
response.addr = client->addr;
response.flags = I2C_M_RD;
response.len = 1;
response.buf = &result;
i2c_lock_bus(client->adapter, I2C_LOCK_SEGMENT);
ret = __i2c_transfer(client->adapter, &request, 1);
if (ret < 0)
goto out;
ret = __i2c_transfer(client->adapter, &response, 1);
if (ret < 0)
goto out;
*val = result;
ret = 0;
out:
i2c_unlock_bus(client->adapter, I2C_LOCK_SEGMENT);
fsleep(10000);
return ret;
}
static const struct regmap_bus t14s_ec_regmap_bus = {
.reg_write = t14s_ec_write,
.reg_read = t14s_ec_read,
};
static int t14s_ec_read_evt(struct t14s_ec *ec, u8 *val)
{
struct i2c_client *client = to_i2c_client(ec->dev);
u8 buf[4] = {T14S_EC_CMD_EVT, 0x00, 0x00, 0x01};
struct i2c_msg request, response;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/container_of.h`, `linux/device.h`, `linux/delay.h`, `linux/dev_printk.h`, `linux/err.h`.
- Detected declarations: `struct t14s_ec_led_classdev`, `struct t14s_ec`, `enum t14s_ec_led_status_t`, `function t14s_ec_write`, `function t14s_ec_read`, `function t14s_ec_read_evt`, `function t14s_ec_write_sequence`, `function t14s_led_set_status`, `function t14s_led_brightness_set`, `function t14s_led_blink_set`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.