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.

Dependency Surface

Detected Declarations

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

Implementation Notes