aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@gmail.com>2016-07-25 04:38:54 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-07-25 04:38:54 -0400
commit38593426ecc7e0e22873dcd7b5d471eb869a0b6e (patch)
treebb676c71f3ddeefd5d906c22ee68e3f90c170cde
parent017bb04e846be82715769799aafa934feab0e443 (diff)
parent2b66bd692c40034d42d905f37f7f20c3540f185e (diff)
Merge branch 'for-4.8/mfd' into for-4.8/drivers
-rw-r--r--drivers/platform/chrome/cros_ec_proto.c17
-rw-r--r--include/linux/mfd/cros_ec.h15
-rw-r--r--include/linux/mfd/cros_ec_commands.h31
3 files changed, 63 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index b6e161f71b26..6c084b266651 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
380 return ret; 380 return ret;
381} 381}
382EXPORT_SYMBOL(cros_ec_cmd_xfer); 382EXPORT_SYMBOL(cros_ec_cmd_xfer);
383
384int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
385 struct cros_ec_command *msg)
386{
387 int ret;
388
389 ret = cros_ec_cmd_xfer(ec_dev, msg);
390 if (ret < 0) {
391 dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
392 } else if (msg->result != EC_RES_SUCCESS) {
393 dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
394 return -EPROTO;
395 }
396
397 return ret;
398}
399EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index 64184d27e3cd..d641a18abacb 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -226,6 +226,21 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
226 struct cros_ec_command *msg); 226 struct cros_ec_command *msg);
227 227
228/** 228/**
229 * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC
230 *
231 * This function is identical to cros_ec_cmd_xfer, except it returns success
232 * status only if both the command was transmitted successfully and the EC
233 * replied with success status. It's not necessary to check msg->result when
234 * using this function.
235 *
236 * @ec_dev: EC device
237 * @msg: Message to write
238 * @return: Num. of bytes transferred on success, <0 on failure
239 */
240int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
241 struct cros_ec_command *msg);
242
243/**
229 * cros_ec_remove - Remove a ChromeOS EC 244 * cros_ec_remove - Remove a ChromeOS EC
230 * 245 *
231 * Call this to deregister a ChromeOS EC, then clean up any private data. 246 * Call this to deregister a ChromeOS EC, then clean up any private data.
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index 13b630c10d4c..7e7a8d4b4551 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -949,6 +949,37 @@ struct ec_params_pwm_set_fan_duty {
949 uint32_t percent; 949 uint32_t percent;
950} __packed; 950} __packed;
951 951
952#define EC_CMD_PWM_SET_DUTY 0x25
953/* 16 bit duty cycle, 0xffff = 100% */
954#define EC_PWM_MAX_DUTY 0xffff
955
956enum ec_pwm_type {
957 /* All types, indexed by board-specific enum pwm_channel */
958 EC_PWM_TYPE_GENERIC = 0,
959 /* Keyboard backlight */
960 EC_PWM_TYPE_KB_LIGHT,
961 /* Display backlight */
962 EC_PWM_TYPE_DISPLAY_LIGHT,
963 EC_PWM_TYPE_COUNT,
964};
965
966struct ec_params_pwm_set_duty {
967 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
968 uint8_t pwm_type; /* ec_pwm_type */
969 uint8_t index; /* Type-specific index, or 0 if unique */
970} __packed;
971
972#define EC_CMD_PWM_GET_DUTY 0x26
973
974struct ec_params_pwm_get_duty {
975 uint8_t pwm_type; /* ec_pwm_type */
976 uint8_t index; /* Type-specific index, or 0 if unique */
977} __packed;
978
979struct ec_response_pwm_get_duty {
980 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
981} __packed;
982
952/*****************************************************************************/ 983/*****************************************************************************/
953/* 984/*
954 * Lightbar commands. This looks worse than it is. Since we only use one HOST 985 * Lightbar commands. This looks worse than it is. Since we only use one HOST