summaryrefslogtreecommitdiff
path: root/board/fennel
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2020-09-25 16:58:53 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-28 07:27:47 +0000
commita74cf86153a9450fc3cda52ccab932038a141f50 (patch)
treec57076eccc148714b9bd2a122f5ceec0f96f0866 /board/fennel
parent769ec0c4a84342b393d536b938b5c96e50242247 (diff)
downloadchrome-ec-a74cf86153a9450fc3cda52ccab932038a141f50.tar.gz
fennel: add host command for the ioexpander pwm
In order to support the kernel driver to use the ioexpander pwm driver, we add two host command EC_CMD_PWM_SET_DUTY and EC_CMD_PWM_GET_DUTY to the board layer to support it. Besides, to avoid the RO rom size overflow, we remove the ioexpander pwm function and keyboard backlight function from the RO rom. BUG=b:162902808 BRANCH=firmware-kukui-12573.B TEST=build pass Change-Id: Ibbd66164c19cd792a865f471c0c32ecb595f75e7 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2430904 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/fennel')
-rw-r--r--board/fennel/board.c56
-rw-r--r--board/fennel/board.h2
2 files changed, 58 insertions, 0 deletions
diff --git a/board/fennel/board.c b/board/fennel/board.c
index 43d3e30bad..799255712d 100644
--- a/board/fennel/board.c
+++ b/board/fennel/board.c
@@ -488,3 +488,59 @@ int board_get_battery_i2c(void)
{
return board_get_version() >= 1 ? 2 : 1;
}
+
+#ifdef SECTION_IS_RW
+static int it8801_get_target_channel(enum pwm_channel *channel,
+ int type, int index)
+{
+ switch (type) {
+ case EC_PWM_TYPE_GENERIC:
+ *channel = index;
+ break;
+ default:
+ return -1;
+ }
+
+ return *channel >= 1;
+}
+
+static enum ec_status
+host_command_pwm_set_duty(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_pwm_set_duty *p = args->params;
+ enum pwm_channel channel;
+ uint16_t duty;
+
+ if (it8801_get_target_channel(&channel, p->pwm_type, p->index))
+ return EC_RES_INVALID_PARAM;
+
+ duty = (uint32_t) p->duty * 255 / 65535;
+ it8801_pwm_set_raw_duty(channel, duty);
+ it8801_pwm_enable(channel, p->duty > 0);
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_DUTY,
+ host_command_pwm_set_duty,
+ EC_VER_MASK(0));
+
+static enum ec_status
+host_command_pwm_get_duty(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_pwm_get_duty *p = args->params;
+ struct ec_response_pwm_get_duty *r = args->response;
+
+ enum pwm_channel channel;
+
+ if (it8801_get_target_channel(&channel, p->pwm_type, p->index))
+ return EC_RES_INVALID_PARAM;
+
+ r->duty = (uint32_t) it8801_pwm_get_raw_duty(channel) * 65535 / 255;
+ args->response_size = sizeof(*r);
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_PWM_GET_DUTY,
+ host_command_pwm_get_duty,
+ EC_VER_MASK(0));
+#endif
diff --git a/board/fennel/board.h b/board/fennel/board.h
index 8e366c8b73..5dee11b489 100644
--- a/board/fennel/board.h
+++ b/board/fennel/board.h
@@ -73,8 +73,10 @@
#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL)
+#ifdef SECTION_IS_RW
#define CONFIG_IO_EXPANDER_IT8801_PWM
#define CONFIG_KEYBOARD_BACKLIGHT
+#endif
#endif /* VARIANT_KUKUI_NO_SENSORS */