#include <linux/module.h>
#include <linux/mfd/cros_ec.h>
#include <linux/mfd/cros_ec_commands.h>
#include <linux/platform_device.h>
struct cros_ec_pwm_device {
struct cros_ec_device *ec;
static inline struct cros_ec_pwm_device *pwm_to_cros_ec_pwm(struct pwm_chip *c)
return container_of(c, struct cros_ec_pwm_device, chip);
static int cros_ec_pwm_set_duty(struct cros_ec_device *ec, u8 index, u16 duty)
struct cros_ec_command msg;
struct ec_params_pwm_set_duty params;
struct ec_params_pwm_set_duty *params = &buf.params;
struct cros_ec_command *msg = &buf.msg;
memset(&buf, 0, sizeof(buf));
msg->command = EC_CMD_PWM_SET_DUTY;
msg->outsize = sizeof(*params);
params->pwm_type = EC_PWM_TYPE_GENERIC;
return cros_ec_cmd_xfer_status(ec, msg);
static int __cros_ec_pwm_get_duty(struct cros_ec_device *ec, u8 index,
struct cros_ec_command msg;
struct ec_params_pwm_get_duty params;
struct ec_response_pwm_get_duty resp;