drivers/platform/olpc/olpc-xo175-ec.c
Source file repositories/reference/linux-study-clean/drivers/platform/olpc/olpc-xo175-ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/olpc/olpc-xo175-ec.c- Extension
.c- Size
- 20917 bytes
- Lines
- 759
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/completion.hlinux/ctype.hlinux/delay.hlinux/gpio/consumer.hlinux/input.hlinux/kfifo.hlinux/module.hlinux/olpc-ec.hlinux/platform_device.hlinux/power_supply.hlinux/reboot.hlinux/slab.hlinux/spinlock.hlinux/spi/spi.h
Detected Declarations
struct ec_cmd_tstruct olpc_xo175_ec_cmdstruct olpc_xo175_ec_respstruct olpc_xo175_ecenum ec_chan_tenum ec_state_tfunction olpc_xo175_ec_resp_lenfunction olpc_xo175_ec_flush_logbuffunction olpc_xo175_ec_send_commandfunction olpc_xo175_ec_read_packetfunction olpc_xo175_ec_completefunction requestsfunction msecs_to_jiffiesfunction olpc_xo175_ec_set_event_maskfunction olpc_xo175_ec_power_offfunction olpc_xo175_ec_suspendfunction olpc_xo175_ec_resume_noirqfunction olpc_xo175_ec_resumefunction olpc_xo175_ec_removefunction olpc_xo175_ec_probe
Annotated Snippet
struct ec_cmd_t {
u8 cmd;
u8 bytes_returned;
};
enum ec_chan_t {
CHAN_NONE = 0,
CHAN_SWITCH,
CHAN_CMD_RESP,
CHAN_KEYBOARD,
CHAN_TOUCHPAD,
CHAN_EVENT,
CHAN_DEBUG,
CHAN_CMD_ERROR,
};
/*
* EC events
*/
#define EVENT_AC_CHANGE 1 /* AC plugged/unplugged */
#define EVENT_BATTERY_STATUS 2 /* Battery low/full/error/gone */
#define EVENT_BATTERY_CRITICAL 3 /* Battery critical voltage */
#define EVENT_BATTERY_SOC_CHANGE 4 /* 1% SOC Change */
#define EVENT_BATTERY_ERROR 5 /* Abnormal error, query for cause */
#define EVENT_POWER_PRESSED 6 /* Power button was pressed */
#define EVENT_POWER_PRESS_WAKE 7 /* Woken up with a power button */
#define EVENT_TIMED_HOST_WAKE 8 /* Host wake timer */
#define EVENT_OLS_HIGH_LIMIT 9 /* OLS crossed dark threshold */
#define EVENT_OLS_LOW_LIMIT 10 /* OLS crossed light threshold */
/*
* EC commands
* (from http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ec_cmd.h)
*/
#define CMD_GET_API_VERSION 0x08 /* out: u8 */
#define CMD_READ_VOLTAGE 0x10 /* out: u16, *9.76/32, mV */
#define CMD_READ_CURRENT 0x11 /* out: s16, *15.625/120, mA */
#define CMD_READ_ACR 0x12 /* out: s16, *6250/15, uAh */
#define CMD_READ_BATT_TEMPERATURE 0x13 /* out: u16, *100/256, deg C */
#define CMD_READ_AMBIENT_TEMPERATURE 0x14 /* unimplemented, no hardware */
#define CMD_READ_BATTERY_STATUS 0x15 /* out: u8, bitmask */
#define CMD_READ_SOC 0x16 /* out: u8, percentage */
#define CMD_READ_GAUGE_ID 0x17 /* out: u8 * 8 */
#define CMD_READ_GAUGE_DATA 0x18 /* in: u8 addr, out: u8 data */
#define CMD_READ_BOARD_ID 0x19 /* out: u16 (platform id) */
#define CMD_READ_BATT_ERR_CODE 0x1f /* out: u8, error bitmask */
#define CMD_SET_DCON_POWER 0x26 /* in: u8 */
#define CMD_RESET_EC 0x28 /* none */
#define CMD_READ_BATTERY_TYPE 0x2c /* out: u8 */
#define CMD_SET_AUTOWAK 0x33 /* out: u8 */
#define CMD_SET_EC_WAKEUP_TIMER 0x36 /* in: u32, out: ? */
#define CMD_READ_EXT_SCI_MASK 0x37 /* ? */
#define CMD_WRITE_EXT_SCI_MASK 0x38 /* ? */
#define CMD_CLEAR_EC_WAKEUP_TIMER 0x39 /* none */
#define CMD_ENABLE_RUNIN_DISCHARGE 0x3B /* none */
#define CMD_DISABLE_RUNIN_DISCHARGE 0x3C /* none */
#define CMD_READ_MPPT_ACTIVE 0x3d /* out: u8 */
#define CMD_READ_MPPT_LIMIT 0x3e /* out: u8 */
#define CMD_SET_MPPT_LIMIT 0x3f /* in: u8 */
#define CMD_DISABLE_MPPT 0x40 /* none */
#define CMD_ENABLE_MPPT 0x41 /* none */
#define CMD_READ_VIN 0x42 /* out: u16 */
#define CMD_EXT_SCI_QUERY 0x43 /* ? */
#define RSP_KEYBOARD_DATA 0x48 /* ? */
#define RSP_TOUCHPAD_DATA 0x49 /* ? */
#define CMD_GET_FW_VERSION 0x4a /* out: u8 * 16 */
#define CMD_POWER_CYCLE 0x4b /* none */
#define CMD_POWER_OFF 0x4c /* none */
#define CMD_RESET_EC_SOFT 0x4d /* none */
#define CMD_READ_GAUGE_U16 0x4e /* ? */
#define CMD_ENABLE_MOUSE 0x4f /* ? */
#define CMD_ECHO 0x52 /* in: u8 * 5, out: u8 * 5 */
#define CMD_GET_FW_DATE 0x53 /* out: u8 * 16 */
#define CMD_GET_FW_USER 0x54 /* out: u8 * 16 */
#define CMD_TURN_OFF_POWER 0x55 /* none (same as 0x4c) */
#define CMD_READ_OLS 0x56 /* out: u16 */
#define CMD_OLS_SMT_LEDON 0x57 /* none */
#define CMD_OLS_SMT_LEDOFF 0x58 /* none */
#define CMD_START_OLS_ASSY 0x59 /* none */
#define CMD_STOP_OLS_ASSY 0x5a /* none */
#define CMD_OLS_SMTTEST_STOP 0x5b /* none */
#define CMD_READ_VIN_SCALED 0x5c /* out: u16 */
#define CMD_READ_BAT_MIN_W 0x5d /* out: u16 */
#define CMD_READ_BAR_MAX_W 0x5e /* out: u16 */
#define CMD_RESET_BAT_MINMAX_W 0x5f /* none */
#define CMD_READ_LOCATION 0x60 /* in: u16 addr, out: u8 data */
#define CMD_WRITE_LOCATION 0x61 /* in: u16 addr, u8 data */
#define CMD_KEYBOARD_CMD 0x62 /* in: u8, out: ? */
#define CMD_TOUCHPAD_CMD 0x63 /* in: u8, out: ? */
#define CMD_GET_FW_HASH 0x64 /* out: u8 * 16 */
Annotation
- Immediate include surface: `linux/completion.h`, `linux/ctype.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/input.h`, `linux/kfifo.h`, `linux/module.h`, `linux/olpc-ec.h`.
- Detected declarations: `struct ec_cmd_t`, `struct olpc_xo175_ec_cmd`, `struct olpc_xo175_ec_resp`, `struct olpc_xo175_ec`, `enum ec_chan_t`, `enum ec_state_t`, `function olpc_xo175_ec_resp_len`, `function olpc_xo175_ec_flush_logbuf`, `function olpc_xo175_ec_send_command`, `function olpc_xo175_ec_read_packet`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.