aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd
diff options
context:
space:
mode:
authorStephen Barber <smbarber@chromium.org>2015-06-09 07:04:43 -0400
committerLee Jones <lee.jones@linaro.org>2015-06-15 08:18:20 -0400
commit256ab950bdaa8797b7bac8fc11a567030d486304 (patch)
tree531850d4278f72142af56221ac79471b6acc4295 /include/linux/mfd
parenta841178445bb72a3d566b4e6ab9d19e9b002eb47 (diff)
mfd: cros_ec: rev cros_ec_commands.h
Update cros_ec_commands.h to the latest version in the EC firmware sources and add power domain and passthru commands. Also, update lightbar to use new command names. Signed-off-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Tested-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Olof Johansson <olof@lixom.net> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r--include/linux/mfd/cros_ec_commands.h277
1 files changed, 255 insertions, 22 deletions
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index a49cd41feea7..13b630c10d4c 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -515,7 +515,7 @@ struct ec_host_response {
515/* 515/*
516 * Notes on commands: 516 * Notes on commands:
517 * 517 *
518 * Each command is an 8-byte command value. Commands which take params or 518 * Each command is an 16-bit command value. Commands which take params or
519 * return response data specify structs for that data. If no struct is 519 * return response data specify structs for that data. If no struct is
520 * specified, the command does not input or output data, respectively. 520 * specified, the command does not input or output data, respectively.
521 * Parameter/response length is implicit in the structs. Some underlying 521 * Parameter/response length is implicit in the structs. Some underlying
@@ -966,7 +966,7 @@ struct rgb_s {
966/* List of tweakable parameters. NOTE: It's __packed so it can be sent in a 966/* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
967 * host command, but the alignment is the same regardless. Keep it that way. 967 * host command, but the alignment is the same regardless. Keep it that way.
968 */ 968 */
969struct lightbar_params { 969struct lightbar_params_v0 {
970 /* Timing */ 970 /* Timing */
971 int32_t google_ramp_up; 971 int32_t google_ramp_up;
972 int32_t google_ramp_down; 972 int32_t google_ramp_down;
@@ -1000,32 +1000,81 @@ struct lightbar_params {
1000 struct rgb_s color[8]; /* 0-3 are Google colors */ 1000 struct rgb_s color[8]; /* 0-3 are Google colors */
1001} __packed; 1001} __packed;
1002 1002
1003struct lightbar_params_v1 {
1004 /* Timing */
1005 int32_t google_ramp_up;
1006 int32_t google_ramp_down;
1007 int32_t s3s0_ramp_up;
1008 int32_t s0_tick_delay[2]; /* AC=0/1 */
1009 int32_t s0a_tick_delay[2]; /* AC=0/1 */
1010 int32_t s0s3_ramp_down;
1011 int32_t s3_sleep_for;
1012 int32_t s3_ramp_up;
1013 int32_t s3_ramp_down;
1014 int32_t tap_tick_delay;
1015 int32_t tap_display_time;
1016
1017 /* Tap-for-battery params */
1018 uint8_t tap_pct_red;
1019 uint8_t tap_pct_green;
1020 uint8_t tap_seg_min_on;
1021 uint8_t tap_seg_max_on;
1022 uint8_t tap_seg_osc;
1023 uint8_t tap_idx[3];
1024
1025 /* Oscillation */
1026 uint8_t osc_min[2]; /* AC=0/1 */
1027 uint8_t osc_max[2]; /* AC=0/1 */
1028 uint8_t w_ofs[2]; /* AC=0/1 */
1029
1030 /* Brightness limits based on the backlight and AC. */
1031 uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
1032 uint8_t bright_bl_on_min[2]; /* AC=0/1 */
1033 uint8_t bright_bl_on_max[2]; /* AC=0/1 */
1034
1035 /* Battery level thresholds */
1036 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1037
1038 /* Map [AC][battery_level] to color index */
1039 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1040 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1041
1042 /* Color palette */
1043 struct rgb_s color[8]; /* 0-3 are Google colors */
1044} __packed;
1045
1003struct ec_params_lightbar { 1046struct ec_params_lightbar {
1004 uint8_t cmd; /* Command (see enum lightbar_command) */ 1047 uint8_t cmd; /* Command (see enum lightbar_command) */
1005 union { 1048 union {
1006 struct { 1049 struct {
1007 /* no args */ 1050 /* no args */
1008 } dump, off, on, init, get_seq, get_params, version; 1051 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
1052 version, get_brightness, get_demo;
1009 1053
1010 struct num { 1054 struct {
1011 uint8_t num; 1055 uint8_t num;
1012 } brightness, seq, demo; 1056 } set_brightness, seq, demo;
1013 1057
1014 struct reg { 1058 struct {
1015 uint8_t ctrl, reg, value; 1059 uint8_t ctrl, reg, value;
1016 } reg; 1060 } reg;
1017 1061
1018 struct rgb { 1062 struct {
1019 uint8_t led, red, green, blue; 1063 uint8_t led, red, green, blue;
1020 } rgb; 1064 } set_rgb;
1065
1066 struct {
1067 uint8_t led;
1068 } get_rgb;
1021 1069
1022 struct lightbar_params set_params; 1070 struct lightbar_params_v0 set_params_v0;
1071 struct lightbar_params_v1 set_params_v1;
1023 }; 1072 };
1024} __packed; 1073} __packed;
1025 1074
1026struct ec_response_lightbar { 1075struct ec_response_lightbar {
1027 union { 1076 union {
1028 struct dump { 1077 struct {
1029 struct { 1078 struct {
1030 uint8_t reg; 1079 uint8_t reg;
1031 uint8_t ic0; 1080 uint8_t ic0;
@@ -1033,20 +1082,26 @@ struct ec_response_lightbar {
1033 } vals[23]; 1082 } vals[23];
1034 } dump; 1083 } dump;
1035 1084
1036 struct get_seq { 1085 struct {
1037 uint8_t num; 1086 uint8_t num;
1038 } get_seq; 1087 } get_seq, get_brightness, get_demo;
1039 1088
1040 struct lightbar_params get_params; 1089 struct lightbar_params_v0 get_params_v0;
1090 struct lightbar_params_v1 get_params_v1;
1041 1091
1042 struct version { 1092 struct {
1043 uint32_t num; 1093 uint32_t num;
1044 uint32_t flags; 1094 uint32_t flags;
1045 } version; 1095 } version;
1046 1096
1047 struct { 1097 struct {
1098 uint8_t red, green, blue;
1099 } get_rgb;
1100
1101 struct {
1048 /* no return params */ 1102 /* no return params */
1049 } off, on, init, brightness, seq, reg, rgb, demo, set_params; 1103 } off, on, init, set_brightness, seq, reg, set_rgb,
1104 demo, set_params_v0, set_params_v1;
1050 }; 1105 };
1051} __packed; 1106} __packed;
1052 1107
@@ -1056,15 +1111,20 @@ enum lightbar_command {
1056 LIGHTBAR_CMD_OFF = 1, 1111 LIGHTBAR_CMD_OFF = 1,
1057 LIGHTBAR_CMD_ON = 2, 1112 LIGHTBAR_CMD_ON = 2,
1058 LIGHTBAR_CMD_INIT = 3, 1113 LIGHTBAR_CMD_INIT = 3,
1059 LIGHTBAR_CMD_BRIGHTNESS = 4, 1114 LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
1060 LIGHTBAR_CMD_SEQ = 5, 1115 LIGHTBAR_CMD_SEQ = 5,
1061 LIGHTBAR_CMD_REG = 6, 1116 LIGHTBAR_CMD_REG = 6,
1062 LIGHTBAR_CMD_RGB = 7, 1117 LIGHTBAR_CMD_SET_RGB = 7,
1063 LIGHTBAR_CMD_GET_SEQ = 8, 1118 LIGHTBAR_CMD_GET_SEQ = 8,
1064 LIGHTBAR_CMD_DEMO = 9, 1119 LIGHTBAR_CMD_DEMO = 9,
1065 LIGHTBAR_CMD_GET_PARAMS = 10, 1120 LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
1066 LIGHTBAR_CMD_SET_PARAMS = 11, 1121 LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
1067 LIGHTBAR_CMD_VERSION = 12, 1122 LIGHTBAR_CMD_VERSION = 12,
1123 LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
1124 LIGHTBAR_CMD_GET_RGB = 14,
1125 LIGHTBAR_CMD_GET_DEMO = 15,
1126 LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
1127 LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
1068 LIGHTBAR_NUM_CMDS 1128 LIGHTBAR_NUM_CMDS
1069}; 1129};
1070 1130
@@ -1421,8 +1481,40 @@ struct ec_response_rtc {
1421/*****************************************************************************/ 1481/*****************************************************************************/
1422/* Port80 log access */ 1482/* Port80 log access */
1423 1483
1484/* Maximum entries that can be read/written in a single command */
1485#define EC_PORT80_SIZE_MAX 32
1486
1424/* Get last port80 code from previous boot */ 1487/* Get last port80 code from previous boot */
1425#define EC_CMD_PORT80_LAST_BOOT 0x48 1488#define EC_CMD_PORT80_LAST_BOOT 0x48
1489#define EC_CMD_PORT80_READ 0x48
1490
1491enum ec_port80_subcmd {
1492 EC_PORT80_GET_INFO = 0,
1493 EC_PORT80_READ_BUFFER,
1494};
1495
1496struct ec_params_port80_read {
1497 uint16_t subcmd;
1498 union {
1499 struct {
1500 uint32_t offset;
1501 uint32_t num_entries;
1502 } read_buffer;
1503 };
1504} __packed;
1505
1506struct ec_response_port80_read {
1507 union {
1508 struct {
1509 uint32_t writes;
1510 uint32_t history_size;
1511 uint32_t last_boot;
1512 } get_info;
1513 struct {
1514 uint16_t codes[EC_PORT80_SIZE_MAX];
1515 } data;
1516 };
1517} __packed;
1426 1518
1427struct ec_response_port80_last_boot { 1519struct ec_response_port80_last_boot {
1428 uint16_t code; 1520 uint16_t code;
@@ -1782,6 +1874,7 @@ struct ec_params_gpio_set {
1782/* Get GPIO value */ 1874/* Get GPIO value */
1783#define EC_CMD_GPIO_GET 0x93 1875#define EC_CMD_GPIO_GET 0x93
1784 1876
1877/* Version 0 of input params and response */
1785struct ec_params_gpio_get { 1878struct ec_params_gpio_get {
1786 char name[32]; 1879 char name[32];
1787} __packed; 1880} __packed;
@@ -1789,6 +1882,38 @@ struct ec_response_gpio_get {
1789 uint8_t val; 1882 uint8_t val;
1790} __packed; 1883} __packed;
1791 1884
1885/* Version 1 of input params and response */
1886struct ec_params_gpio_get_v1 {
1887 uint8_t subcmd;
1888 union {
1889 struct {
1890 char name[32];
1891 } get_value_by_name;
1892 struct {
1893 uint8_t index;
1894 } get_info;
1895 };
1896} __packed;
1897
1898struct ec_response_gpio_get_v1 {
1899 union {
1900 struct {
1901 uint8_t val;
1902 } get_value_by_name, get_count;
1903 struct {
1904 uint8_t val;
1905 char name[32];
1906 uint32_t flags;
1907 } get_info;
1908 };
1909} __packed;
1910
1911enum gpio_get_subcmd {
1912 EC_GPIO_GET_BY_NAME = 0,
1913 EC_GPIO_GET_COUNT = 1,
1914 EC_GPIO_GET_INFO = 2,
1915};
1916
1792/*****************************************************************************/ 1917/*****************************************************************************/
1793/* I2C commands. Only available when flash write protect is unlocked. */ 1918/* I2C commands. Only available when flash write protect is unlocked. */
1794 1919
@@ -1857,13 +1982,21 @@ struct ec_params_charge_control {
1857/*****************************************************************************/ 1982/*****************************************************************************/
1858 1983
1859/* 1984/*
1860 * Cut off battery power output if the battery supports. 1985 * Cut off battery power immediately or after the host has shut down.
1861 * 1986 *
1862 * For unsupported battery, just don't implement this command and lets EC 1987 * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
1863 * return EC_RES_INVALID_COMMAND. 1988 * EC_RES_SUCCESS if the command was successful.
1989 * EC_RES_ERROR if the cut off command failed.
1864 */ 1990 */
1991
1865#define EC_CMD_BATTERY_CUT_OFF 0x99 1992#define EC_CMD_BATTERY_CUT_OFF 0x99
1866 1993
1994#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
1995
1996struct ec_params_battery_cutoff {
1997 uint8_t flags;
1998} __packed;
1999
1867/*****************************************************************************/ 2000/*****************************************************************************/
1868/* USB port mux control. */ 2001/* USB port mux control. */
1869 2002
@@ -2142,6 +2275,32 @@ struct ec_params_sb_wr_block {
2142} __packed; 2275} __packed;
2143 2276
2144/*****************************************************************************/ 2277/*****************************************************************************/
2278/* Battery vendor parameters
2279 *
2280 * Get or set vendor-specific parameters in the battery. Implementations may
2281 * differ between boards or batteries. On a set operation, the response
2282 * contains the actual value set, which may be rounded or clipped from the
2283 * requested value.
2284 */
2285
2286#define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
2287
2288enum ec_battery_vendor_param_mode {
2289 BATTERY_VENDOR_PARAM_MODE_GET = 0,
2290 BATTERY_VENDOR_PARAM_MODE_SET,
2291};
2292
2293struct ec_params_battery_vendor_param {
2294 uint32_t param;
2295 uint32_t value;
2296 uint8_t mode;
2297} __packed;
2298
2299struct ec_response_battery_vendor_param {
2300 uint32_t value;
2301} __packed;
2302
2303/*****************************************************************************/
2145/* System commands */ 2304/* System commands */
2146 2305
2147/* 2306/*
@@ -2338,6 +2497,80 @@ struct ec_params_reboot_ec {
2338 2497
2339/*****************************************************************************/ 2498/*****************************************************************************/
2340/* 2499/*
2500 * PD commands
2501 *
2502 * These commands are for PD MCU communication.
2503 */
2504
2505/* EC to PD MCU exchange status command */
2506#define EC_CMD_PD_EXCHANGE_STATUS 0x100
2507
2508/* Status of EC being sent to PD */
2509struct ec_params_pd_status {
2510 int8_t batt_soc; /* battery state of charge */
2511} __packed;
2512
2513/* Status of PD being sent back to EC */
2514struct ec_response_pd_status {
2515 int8_t status; /* PD MCU status */
2516 uint32_t curr_lim_ma; /* input current limit */
2517} __packed;
2518
2519/* Set USB type-C port role and muxes */
2520#define EC_CMD_USB_PD_CONTROL 0x101
2521
2522enum usb_pd_control_role {
2523 USB_PD_CTRL_ROLE_NO_CHANGE = 0,
2524 USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
2525 USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
2526 USB_PD_CTRL_ROLE_FORCE_SINK = 3,
2527 USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
2528};
2529
2530enum usb_pd_control_mux {
2531 USB_PD_CTRL_MUX_NO_CHANGE = 0,
2532 USB_PD_CTRL_MUX_NONE = 1,
2533 USB_PD_CTRL_MUX_USB = 2,
2534 USB_PD_CTRL_MUX_DP = 3,
2535 USB_PD_CTRL_MUX_DOCK = 4,
2536 USB_PD_CTRL_MUX_AUTO = 5,
2537};
2538
2539struct ec_params_usb_pd_control {
2540 uint8_t port;
2541 uint8_t role;
2542 uint8_t mux;
2543} __packed;
2544
2545/*****************************************************************************/
2546/*
2547 * Passthru commands
2548 *
2549 * Some platforms have sub-processors chained to each other. For example.
2550 *
2551 * AP <--> EC <--> PD MCU
2552 *
2553 * The top 2 bits of the command number are used to indicate which device the
2554 * command is intended for. Device 0 is always the device receiving the
2555 * command; other device mapping is board-specific.
2556 *
2557 * When a device receives a command to be passed to a sub-processor, it passes
2558 * it on with the device number set back to 0. This allows the sub-processor
2559 * to remain blissfully unaware of whether the command originated on the next
2560 * device up the chain, or was passed through from the AP.
2561 *
2562 * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
2563 * AP sends command 0x4002 to the EC
2564 * EC sends command 0x0002 to the PD MCU
2565 * EC forwards PD MCU response back to the AP
2566 */
2567
2568/* Offset and max command number for sub-device n */
2569#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
2570#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
2571
2572/*****************************************************************************/
2573/*
2341 * Deprecated constants. These constants have been renamed for clarity. The 2574 * Deprecated constants. These constants have been renamed for clarity. The
2342 * meaning and size has not changed. Programs that use the old names should 2575 * meaning and size has not changed. Programs that use the old names should
2343 * switch to the new names soon, as the old names may not be carried forward 2576 * switch to the new names soon, as the old names may not be carried forward