summaryrefslogtreecommitdiff
path: root/board/spherion
diff options
context:
space:
mode:
authorBen Chen <ben.chen2@quanta.corp-partner.google.com>2021-03-05 10:09:54 +0800
committerCommit Bot <commit-bot@chromium.org>2021-03-19 06:44:33 +0000
commit029571ba02454d4f6f0691170c2ba3b5214a71da (patch)
treee31622715a7711fd364351c47bcf14e2a83ecfa5 /board/spherion
parent1720f734983ab6452884573e3a7c8e184d28cef7 (diff)
downloadchrome-ec-029571ba02454d4f6f0691170c2ba3b5214a71da.tar.gz
spherion: config PWM KB backlight control
Move asurada baseboard PWM channels definition to board control. Config gpio keyboard backlight en pin, and enable/disable in power on/off sequence BUG=b:181799718 BRANCH=none TEST=make buildall TEST=run 'kblight' EC console command to verify keyboard backight TEST=run 'ectool verify pwmsetkblight' to verify keyboard backlight Change-Id: If7afbd4f21dd6b0500525d08ec7786071c3523c1 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738494 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Yilin Yang (kerker) <kerker@chromium.org>
Diffstat (limited to 'board/spherion')
-rw-r--r--board/spherion/board.c31
-rw-r--r--board/spherion/board.h9
-rw-r--r--board/spherion/gpio.inc2
3 files changed, 41 insertions, 1 deletions
diff --git a/board/spherion/board.c b/board/spherion/board.c
index eccd0a21c6..1e7e90b7c3 100644
--- a/board/spherion/board.c
+++ b/board/spherion/board.c
@@ -166,3 +166,34 @@ struct motion_sensor_t motion_sensors[] = {
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+/* PWM */
+
+/*
+ * PWM channels. Must be in the exactly same order as in enum pwm_channel.
+ * There total three 16 bits clock prescaler registers for all pwm channels,
+ * so use the same frequency and prescaler register setting is required if
+ * number of pwm channel greater than three.
+ */
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_KBLIGHT] = {
+ .channel = 2,
+ .flags = 0,
+ .freq_hz = 10000,
+ .pcfsr_sel = PWM_PRESCALER_C4
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+
+
+static void kb_backlight_enable(void)
+{
+ gpio_set_level(GPIO_EC_KB_BL_EN, 1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, kb_backlight_enable, HOOK_PRIO_DEFAULT);
+
+static void kb_backlight_disable(void)
+{
+ gpio_set_level(GPIO_EC_KB_BL_EN, 0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, kb_backlight_disable, HOOK_PRIO_DEFAULT);
diff --git a/board/spherion/board.h b/board/spherion/board.h
index 135be0d6a6..8bce87a17a 100644
--- a/board/spherion/board.h
+++ b/board/spherion/board.h
@@ -25,6 +25,10 @@
/* LED */
#define CONFIG_LED_ONOFF_STATES
+/* Keyboard features */
+/* Keyboard backliht */
+#define CONFIG_PWM_KBLIGHT
+
/* PD / USB-C / PPC */
#define CONFIG_USB_PD_DEBUG_LEVEL 3
@@ -77,5 +81,10 @@ enum sensor_id {
SENSOR_COUNT,
};
+enum pwm_channel {
+ PWM_CH_KBLIGHT,
+ PWM_CH_COUNT,
+};
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/spherion/gpio.inc b/board/spherion/gpio.inc
index 5b07faf43d..89abf26d37 100644
--- a/board/spherion/gpio.inc
+++ b/board/spherion/gpio.inc
@@ -83,6 +83,7 @@ GPIO(BC12_DET_EN, PIN(J, 5), GPIO_OUT_LOW) /* EN_USB_C0_BC12_DET */
GPIO(EN_EC_ID_ODL, PIN(H, 5), GPIO_ODR_LOW)
GPIO(ENTERING_RW, PIN(C, 5), GPIO_OUT_LOW) /* EC_ENTERING_RW */
GPIO(EC_USB_C0_MUX_RESET_L, PIN(D, 7), GPIO_OUT_HIGH)
+GPIO(EC_KB_BL_EN, PIN(I, 7), GPIO_OUT_LOW) /* Keyboard backlight enable */
/* I2C pins - Alternate function below configures I2C module on these pins */
GPIO(I2C_A_SCL, PIN(B, 3), GPIO_INPUT) /* I2C_CHG_BATT_SCL */
@@ -140,7 +141,6 @@ GPIO(CCD_MODE_ODL, PIN(C, 4), GPIO_INPUT)
* so we set them as output low.
*/
GPIO(NC_GPI5, PIN(I, 5), GPIO_OUT_LOW)
-GPIO(NC_GPI7, PIN(I, 7), GPIO_OUT_LOW)
/* NC pins, enable internal pull-up/down to avoid floating state. */
GPIO(NC_GPM2, PIN(M, 2), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(NC_GPM3, PIN(M, 3), GPIO_INPUT | GPIO_PULL_DOWN)