]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'for-4.8/mfd' into for-next
authorThierry Reding <thierry.reding@gmail.com>
Mon, 25 Jul 2016 14:23:38 +0000 (16:23 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Mon, 25 Jul 2016 14:23:38 +0000 (16:23 +0200)
drivers/platform/chrome/cros_ec_proto.c
include/linux/mfd/cros_ec.h
include/linux/mfd/cros_ec_commands.h

index b6e161f71b26af834b2366b2d2f9f0e32f61ac0c..6c084b26665113ca0698cf24d0cc7436a974b6ec 100644 (file)
@@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
        return ret;
 }
 EXPORT_SYMBOL(cros_ec_cmd_xfer);
+
+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
+                           struct cros_ec_command *msg)
+{
+       int ret;
+
+       ret = cros_ec_cmd_xfer(ec_dev, msg);
+       if (ret < 0) {
+               dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
+       } else if (msg->result != EC_RES_SUCCESS) {
+               dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
+               return -EPROTO;
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
index 64184d27e3cd38cb7c2f47a3392df8518581e7b3..d641a18abacb9f1d15b65b1ff5420929a6bd9e92 100644 (file)
@@ -225,6 +225,21 @@ int cros_ec_check_result(struct cros_ec_device *ec_dev,
 int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
                     struct cros_ec_command *msg);
 
+/**
+ * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC
+ *
+ * This function is identical to cros_ec_cmd_xfer, except it returns success
+ * status only if both the command was transmitted successfully and the EC
+ * replied with success status. It's not necessary to check msg->result when
+ * using this function.
+ *
+ * @ec_dev: EC device
+ * @msg: Message to write
+ * @return: Num. of bytes transferred on success, <0 on failure
+ */
+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
+                           struct cros_ec_command *msg);
+
 /**
  * cros_ec_remove - Remove a ChromeOS EC
  *
index 13b630c10d4c07d16e958bff61f1c6f3787142dd..7e7a8d4b4551149c48007b95a2840fdaf0f0719f 100644 (file)
@@ -949,6 +949,37 @@ struct ec_params_pwm_set_fan_duty {
        uint32_t percent;
 } __packed;
 
+#define EC_CMD_PWM_SET_DUTY 0x25
+/* 16 bit duty cycle, 0xffff = 100% */
+#define EC_PWM_MAX_DUTY 0xffff
+
+enum ec_pwm_type {
+       /* All types, indexed by board-specific enum pwm_channel */
+       EC_PWM_TYPE_GENERIC = 0,
+       /* Keyboard backlight */
+       EC_PWM_TYPE_KB_LIGHT,
+       /* Display backlight */
+       EC_PWM_TYPE_DISPLAY_LIGHT,
+       EC_PWM_TYPE_COUNT,
+};
+
+struct ec_params_pwm_set_duty {
+       uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+       uint8_t pwm_type;  /* ec_pwm_type */
+       uint8_t index;     /* Type-specific index, or 0 if unique */
+} __packed;
+
+#define EC_CMD_PWM_GET_DUTY 0x26
+
+struct ec_params_pwm_get_duty {
+       uint8_t pwm_type;  /* ec_pwm_type */
+       uint8_t index;     /* Type-specific index, or 0 if unique */
+} __packed;
+
+struct ec_response_pwm_get_duty {
+       uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+} __packed;
+
 /*****************************************************************************/
 /*
  * Lightbar commands. This looks worse than it is. Since we only use one HOST