diff options
-rw-r--r-- | include/led_pwm.h | 4 | ||||
-rw-r--r-- | zephyr/CMakeLists.txt | 3 | ||||
-rw-r--r-- | zephyr/Kconfig | 1 | ||||
-rw-r--r-- | zephyr/Kconfig.led | 57 | ||||
-rw-r--r-- | zephyr/projects/volteer/include/pwm_map.h | 24 | ||||
-rw-r--r-- | zephyr/shim/include/board.h | 4 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 20 | ||||
-rw-r--r-- | zephyr/shim/include/pwm/pwm.h | 2 |
8 files changed, 115 insertions, 0 deletions
diff --git a/include/led_pwm.h b/include/led_pwm.h index 42f2f5caad..e372f02aab 100644 --- a/include/led_pwm.h +++ b/include/led_pwm.h @@ -8,6 +8,10 @@ #include "ec_commands.h" +#ifdef CONFIG_ZEPHYR +#include "pwm/pwm.h" +#endif + #define PWM_LED_NO_CHANNEL -1 struct pwm_led { diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 978009573f..edcfd769b4 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -126,6 +126,9 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD zephyr_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 "${PLATFORM_EC}/common/keyboard_8042.c" "${PLATFORM_EC}/common/keyboard_8042_sharedlib.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON + "${PLATFORM_EC}/common/led_common.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM "${PLATFORM_EC}/common/led_pwm.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_LID_ANGLE "${PLATFORM_EC}/common/motion_lid.c" "${PLATFORM_EC}/common/math_util.c") diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 8076041e63..5c0ef4fcd2 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -32,6 +32,7 @@ menuconfig PLATFORM_EC if PLATFORM_EC rsource "Kconfig.battery" +rsource "Kconfig.led" rsource "Kconfig.powerseq" rsource "Kconfig.motionsense" rsource "Kconfig.tasks" diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led new file mode 100644 index 0000000000..f57d03d3a5 --- /dev/null +++ b/zephyr/Kconfig.led @@ -0,0 +1,57 @@ +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +menuconfig PLATFORM_EC_LED_COMMON + bool "LED Support" + help + Enable the common LED module supporting automatic control of the + battery and power LEDs. + +if PLATFORM_EC_LED_COMMON + +# TODO: Add other choices +# CONFIG_LED_POLICY_STD +# CONFIG_LED_PWM_CHARGE_STATE_ONLY +# CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY +# CONFIG_LED_ONOFF_STATES + +config PLATFORM_EC_LED_PWM + bool "PWM (Pulse Width Modulation) LEDs" + depends on PLATFORM_EC_PWM + help + Enable PWM (Pulse Width Modulation) controlled LEDs that conform to + the Chromium OS LED behavior specification. + + Your board files must implement the led_get_brightness_range() and + led_set_brightness() which are used by the LED PWM module to set the + board LEDs in response to power and charging events. + +if PLATFORM_EC_LED_PWM + +config PLATFORM_EC_LED_PWM_COUNT + int "Number of PWM LEDs" + default 1 + help + This sets the number of PWM LEDs that are controlled by the common + PWM LED policy. The maximum number of PWM LEDs is currently 2. + + TODO(b/177452529): Set this parameter from the device tree. + +config PLATFORM_EC_CMD_LEDTEST + bool "Console command: ledtest" + default y + help + Enable the "ledtest" command. This command lets you override the + automatic control of the platform LEDs. For example: + + ledtest 0 enable red + + disables automatic control of the first PWM LED and forces the LED + color to red. Set the 2nd parameter to "disable" to return back + to automatic control: + + ledtest 0 disable + +endif # PLATFORM_EC_LED_PWM +endif # PLATFORM_EC_LED_COMMON diff --git a/zephyr/projects/volteer/include/pwm_map.h b/zephyr/projects/volteer/include/pwm_map.h new file mode 100644 index 0000000000..e3f0715b68 --- /dev/null +++ b/zephyr/projects/volteer/include/pwm_map.h @@ -0,0 +1,24 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __ZEPHYR_CHROME_PWM_MAP_H +#define __ZEPHYR_CHROME_PWM_MAP_H + +#include <devicetree.h> + +#include "config.h" + +#include "pwm/pwm.h" + +/* + * TODO(b/177452529): eliminate the dependency on enum pwm_channel + * and configure this information directly from the device tree. + */ +#define PWM_CH_LED1_BLUE NAMED_PWM(led1_blue) +#define PWM_CH_LED2_GREEN NAMED_PWM(led2_green) +#define PWM_CH_LED3_RED NAMED_PWM(led3_red) +#define PWM_CH_LED4_SIDESEL NAMED_PWM(led3_sidesel) + +#endif /* __ZEPHYR_CHROME_PWM_MAP_H */ diff --git a/zephyr/shim/include/board.h b/zephyr/shim/include/board.h index 87ec7ed33a..4c94ac0a0e 100644 --- a/zephyr/shim/include/board.h +++ b/zephyr/shim/include/board.h @@ -21,6 +21,10 @@ #include "i2c_map.h" #endif +#ifdef CONFIG_PWM +#include "pwm_map.h" +#endif + /* Include board specific sensor configuration if motionsense is enabled */ #ifdef CONFIG_MOTIONSENSE #include "sensor_map.h" diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index eb5d294490..168aeb87ee 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -220,6 +220,26 @@ enum battery_type { #define CONFIG_KEYBOARD_COL2_INVERTED #endif /* CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED */ +#undef CONFIG_LED_COMMON +#ifdef CONFIG_PLATFORM_EC_LED_COMMON +#define CONFIG_LED_COMMON +#endif + +#undef CONFIG_LED_PWM +#ifdef CONFIG_PLATFORM_EC_LED_PWM +#define CONFIG_LED_PWM +#endif + +#undef CONFIG_LED_PWM_COUNT +#ifdef CONFIG_PLATFORM_EC_LED_PWM_COUNT +#define CONFIG_LED_PWM_COUNT CONFIG_PLATFORM_EC_LED_PWM_COUNT +#endif + +#undef CONFIG_CMD_LEDTEST +#ifdef CONFIG_PLATFORM_EC_CMD_LEDTEST +#define CONFIG_CMD_LEDTEST +#endif + #ifdef CONFIG_PLATFORM_EC_POWERSEQ_CPU_PROCHOT_ACTIVE_LOW #define CONFIG_CHIPSET_CPU_PROCHOT_ACTIVE_LOW #endif diff --git a/zephyr/shim/include/pwm/pwm.h b/zephyr/shim/include/pwm/pwm.h index 38720abb39..1bf4685837 100644 --- a/zephyr/shim/include/pwm/pwm.h +++ b/zephyr/shim/include/pwm/pwm.h @@ -19,6 +19,8 @@ enum pwm_channel { PWM_CH_COUNT, }; +#define NAMED_PWM(name) PWM_CHANNEL(DT_PATH(named_pwms, name)) + #endif /* named_pwms */ #endif /* ZEPHYR_SHIM_INCLUDE_PWM_PWM_H_ */ |