diff options
author | Mike Lee <mike5@huaqin.corp-partner.google.com> | 2020-09-16 20:06:56 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-24 04:34:49 +0000 |
commit | f4fbd68a2664e8d830fb00222023b841f6debac0 (patch) | |
tree | 8e0a48fc20bf7c3c2ea84e8cff9e59670d69cdd5 /driver/ioexpander | |
parent | 48509706db2ab4e3987a600ea6676f581317e5fb (diff) | |
download | chrome-ec-f4fbd68a2664e8d830fb00222023b841f6debac0.tar.gz |
Fennel: Modify it8801 keyboard backlight driver and Enable keyboard backlight
1.Modify it8801 keyboard backlight driver code
2.Enable keyboard backlight setting with it8801 keyboard backlight driver
BUG=b:162902808
BRANCH=firmware-kukui-12573.B
TEST=Manual.
Build and flash BIOS&EC on fennel board.
Verify the keyboard backlight function.
Signed-off-by: Mike Lee <mike5@huaqin.corp-partner.google.com>
Change-Id: I73dd7ffc7b6ee80ed7ca39ac4d05afe65f666181
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2413675
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Diffstat (limited to 'driver/ioexpander')
-rw-r--r-- | driver/ioexpander/it8801.c | 62 | ||||
-rw-r--r-- | driver/ioexpander/it8801.h | 4 |
2 files changed, 57 insertions, 9 deletions
diff --git a/driver/ioexpander/it8801.c b/driver/ioexpander/it8801.c index 2f560a4468..df6ea3e76e 100644 --- a/driver/ioexpander/it8801.c +++ b/driver/ioexpander/it8801.c @@ -14,6 +14,7 @@ #include "registers.h" #include "task.h" #include "util.h" +#include "keyboard_backlight.h" #define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ## args) @@ -430,16 +431,17 @@ DECLARE_CONSOLE_COMMAND(it8801_dump, it8801_dump, "NULL", struct it8801_pwm_gpio_map { int port; int mask; + int pushpull_en; }; const static struct it8801_pwm_gpio_map it8801_pwm_gpio_map[] = { - [1] = {.port = 1, .mask = BIT(2)}, - [2] = {.port = 1, .mask = BIT(3)}, - [3] = {.port = 1, .mask = BIT(4)}, - [4] = {.port = 1, .mask = BIT(5)}, - [7] = {.port = 2, .mask = BIT(0)}, - [8] = {.port = 2, .mask = BIT(3)}, - [9] = {.port = 2, .mask = BIT(2)}, + [1] = {.port = 1, .mask = BIT(2), .pushpull_en = BIT(0)}, + [2] = {.port = 1, .mask = BIT(3), .pushpull_en = BIT(1)}, + [3] = {.port = 1, .mask = BIT(4), .pushpull_en = BIT(2)}, + [4] = {.port = 1, .mask = BIT(5), .pushpull_en = BIT(3)}, + [7] = {.port = 2, .mask = BIT(0), .pushpull_en = BIT(4)}, + [8] = {.port = 2, .mask = BIT(3), .pushpull_en = BIT(5)}, + [9] = {.port = 2, .mask = BIT(2), .pushpull_en = BIT(6)}, }; void it8801_pwm_enable(enum pwm_channel ch, int enabled) @@ -470,9 +472,19 @@ void it8801_pwm_enable(enum pwm_channel ch, int enabled) if (enabled) val |= IT8801_PWMMCR_MCR_BLINKING; it8801_write(IT8801_REG_PWMMCR(it8801_pwm_channels[ch].index), val); + + /* + * 1: enable push pull function + */ + it8801_read(IT8801_REG_PWMODDSR, &val); + val &= ~it8801_pwm_gpio_map[index].pushpull_en; + if (enabled) + val |= it8801_pwm_gpio_map[index].pushpull_en; + it8801_write(IT8801_REG_PWMODDSR, val); + } -int it88801_pwm_get_enabled(enum pwm_channel ch) +int it8801_pwm_get_enabled(enum pwm_channel ch) { int val; @@ -507,4 +519,38 @@ int it8801_pwm_get_duty(enum pwm_channel ch) return 100 - it8801_pwm_get_raw_duty(ch) * 100 / 255; } +#if defined(SECTION_IS_RW) && defined(CONFIG_KEYBOARD_BACKLIGHT) +const enum pwm_channel it8801_kblight_pwm_ch = IT8801_PWM_CH_KBLIGHT; + +static int it8801_kblight_enable(int enable) +{ + it8801_pwm_enable(it8801_kblight_pwm_ch, enable); + return EC_SUCCESS; +} + +static int it8801_kblight_set_brightness(int percent) +{ + it8801_pwm_set_duty(it8801_kblight_pwm_ch, percent); + return EC_SUCCESS; +} + +static int it8801_kblight_get_brightness(void) +{ + return it8801_pwm_get_duty(it8801_kblight_pwm_ch); +} + +static int it8801_kblight_init(void) +{ + it8801_pwm_set_duty(it8801_kblight_pwm_ch, 0); + it8801_pwm_enable(it8801_kblight_pwm_ch, 1); + return EC_SUCCESS; +} + +const struct kblight_drv kblight_it8801 = { + .init = it8801_kblight_init, + .set = it8801_kblight_set_brightness, + .get = it8801_kblight_get_brightness, + .enable = it8801_kblight_enable, +}; +#endif #endif /* CONFIG_IO_EXPANDER_IT8801_PWM */ diff --git a/driver/ioexpander/it8801.h b/driver/ioexpander/it8801.h index 016412ca22..25a82fe617 100644 --- a/driver/ioexpander/it8801.h +++ b/driver/ioexpander/it8801.h @@ -95,15 +95,17 @@ struct it8801_pwm_t { }; extern const struct it8801_pwm_t it8801_pwm_channels[]; +extern const struct kblight_drv kblight_it8801; /* standard pwm interface as defined in pwm.h */ void it8801_pwm_enable(enum pwm_channel ch, int enabled); -int it88801_pwm_get_enabled(enum pwm_channel ch); +int it8801_pwm_get_enabled(enum pwm_channel ch); void it8801_pwm_set_raw_duty(enum pwm_channel ch, uint16_t duty); uint16_t it8801_pwm_get_raw_duty(enum pwm_channel ch); void it8801_pwm_set_duty(enum pwm_channel ch, int percent); int it8801_pwm_get_duty(enum pwm_channel ch); +#define IT8801_REG_PWMODDSR 0x5F #define IT8801_REG_PWMMCR(n) (0x60 + ((n) - 1) * 8) #define IT8801_REG_PWMDCR(n) (0x64 + ((n) - 1) * 8) #define IT8801_REG_PWMPRSL(n) (0x66 + ((n) - 1) * 8) |