aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/chrome (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-07-21platform/chrome: cros_kunit_util: add default value for `msg->result`Tzung-Bi Shih2-1/+6
Add default value for `msg->result` so that it won't be garbage bytes when the mock list is empty. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220720044754.4026295-3-tzungbi@kernel.org
2022-07-21platform/chrome: merge Kunit utils and test casesTzung-Bi Shih3-24/+5
Merge CROS_KUNIT and CROS_EC_PROTO_KUNIT_TEST so that when they're built as modules cros_kunit_util doesn't need to export the symbols. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220720044754.4026295-2-tzungbi@kernel.org
2022-07-20platform/chrome: cros_kbd_led_backlight: fix build warningTzung-Bi Shih1-5/+5
drivers/platform/chrome/cros_kbd_led_backlight.c got a new build warning when using the randconfig in [1]: >>> warning: unused variable 'keyboard_led_drvdata_ec_pwm' The warning happens when CONFIG_CROS_EC is set but CONFIG_OF is not set. Reproduce: - mkdir build_dir - wget [1] -O build_dir/.config - COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 \ O=build_dir ARCH=s390 SHELL=/bin/bash drivers/platform/chrome/ Fix the warning by using __maybe_unused. Also use IS_ENABLED() because CROS_EC is a tristate. [1]: https://download.01.org/0day-ci/archive/20220717/202207170538.MR39dw8m-lkp@intel.com/config Fixes: 40f58143745e ("platform/chrome: cros_kbd_led_backlight: support EC PWM backend") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718105047.2356542-1-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit test for cros_ec_cmd()Tzung-Bi Shih1-0/+48
cros_ec_cmd() is a wrapper of cros_ec_cmd_xfer_status(). Add Kunit test for cros_ec_cmd(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-8-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for get_sensor_countTzung-Bi Shih3-0/+182
cros_ec_get_sensor_count() gets number of MEMS sensors. Add Kunit tests for cros_ec_get_sensor_count(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-7-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for check_featuresTzung-Bi Shih1-0/+77
cros_ec_check_features() gets EC features if it hasn't had cache, and checks whether the given EC_FEATURE_* is supported or not. Add Kunit tests for cros_ec_check_features(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-6-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for get_host_eventTzung-Bi Shih1-0/+59
cros_ec_get_host_event() performs some sanity checks, parses `ec_dev->event_data.data.host_event`, and returns bitmap of EC_HOST_EVENT_*. Add Kunit tests for cros_ec_get_host_event(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-5-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for get_next_eventTzung-Bi Shih1-0/+266
cros_ec_get_next_event() gets events from EC. It consists of 3 versions of event retrieval: 1. No MKBP event. 2. MKBP event version 0. 3. MKBP event version >0. Add Kunit tests for cros_ec_get_next_event(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-4-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit test for cros_ec_map_error()Tzung-Bi Shih1-0/+49
cros_ec_cmd_xfer_status() is the only exported function that calls static function cros_ec_map_error(). Add Kunit test for cros_ec_map_error() through calling cros_ec_cmd_xfer_status(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-3-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for cmd_xfer_statusTzung-Bi Shih1-0/+42
cros_ec_cmd_xfer_status() calls cros_ec_cmd_xfer() and cros_ec_map_error(). Given that there are already test cases for cros_ec_cmd_xfer(), only add basic Kunit tests for cros_ec_cmd_xfer_status(). Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220622041040.202737-2-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: return -EPROTO if empty payloadTzung-Bi Shih1-0/+5
cros_ec_wait_until_complete() sends EC_CMD_GET_COMMS_STATUS which expects to receive sizeof(struct ec_response_get_comms_status) from cros_ec_xfer_command(). Return -EPROTO if cros_ec_xfer_command() returns 0. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-11-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit test for empty payloadTzung-Bi Shih1-0/+31
cros_ec_wait_until_complete() sends EC_CMD_GET_COMMS_STATUS which expects to receive sizeof(struct ec_response_get_comms_status) from cros_ec_xfer_command(). Add Kunit test and expect to receive an error code when cros_ec_xfer_command() returns 0. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718050914.2267370-10-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: return -EAGAIN when retries timed outTzung-Bi Shih1-0/+3
While EC_COMMS_STATUS_PROCESSING flag is still on after it tries EC_COMMAND_RETRIES times for sending EC_CMD_GET_COMMS_STATUS, cros_ec_wait_until_complete() doesn't return an error code. Return -EAGAIN in the case instead. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718050914.2267370-9-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: change Kunit expectation when timed outTzung-Bi Shih1-3/+1
While EC_COMMS_STATUS_PROCESSING flag is still on after it tries EC_COMMAND_RETRIES times for sending EC_CMD_GET_COMMS_STATUS, cros_ec_wait_until_complete() doesn't return an error code. Change the expectation to an error code. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-8-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: separate cros_ec_wait_until_complete()Tzung-Bi Shih1-39/+35
EC returns EC_RES_IN_PROGRESS if the host command needs more time to complete. Whenever receives the return code, cros_ec_send_command() sends EC_CMD_GET_COMMS_STATUS to query the command status. Separate cros_ec_wait_until_complete() from cros_ec_send_command(). It sends EC_CMD_GET_COMMS_STATUS and waits until the previous command was completed, or encountered error, or timed out. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718050914.2267370-7-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: separate cros_ec_xfer_command()Tzung-Bi Shih1-3/+10
cros_ec_send_command() has extra logic to handle EC_RES_IN_PROGRESS. Separate the command transfer part into cros_ec_xfer_command() so that other functions can re-use it. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-6-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_send_command()Tzung-Bi Shih3-0/+289
cros_ec_cmd_xfer() is the only exported function that calls static function cros_ec_send_command(). Add Kunit tests for cros_ec_send_command() through calling cros_ec_cmd_xfer(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-5-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_cmd_xfer()Tzung-Bi Shih1-0/+149
cros_ec_cmd_xfer() transfers the given command and data if any. It performs some sanity checks and calls cros_ec_send_command(). Add Kunit tests for cros_ec_cmd_xfer(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-4-tzungbi@kernel.org
2022-07-20platform/chrome: cros_ec_proto: add "cros_ec_" prefix to send_command()Tzung-Bi Shih1-8/+7
To be neat, add "cros_ec_" prefix to static function send_command(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-3-tzungbi@kernel.org
2022-07-18platform/chrome: cros_ec_typec: Register port altmodesPrashant Malani1-11/+40
Instead of using manually managed altmode structs, register the port's altmodes with the Type-C framework. This facilitates matching them to partner altmodes later. Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Prashant Malani <pmalani@chromium.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20220712210318.2671292-2-pmalani@chromium.org
2022-07-18platform/chrome: cros_ec_typec: Rename port altmode arrayPrashant Malani1-8/+7
Rename "p_altmode" to "port_altmode" which is a less ambiguous name for the port_altmode struct array. Signed-off-by: Prashant Malani <pmalani@chromium.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20220712210318.2671292-1-pmalani@chromium.org
2022-07-13platform/chrome: cros_ec_typec: Use dev_err_probe on port register failNĂ­colas F. R. A. Prado1-1/+1
The typec_register_port() can fail with EPROBE_DEFER if the endpoint node hasn't probed yet. In order to avoid spamming the log with errors in that case, log using dev_err_probe(). Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Guenter Roeck <groeck@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20220712214554.545035-1-nfraprado@collabora.com Signed-off-by: Prashant Malani <pmalani@chromium.org>
2022-06-24platform/chrome: wilco_ec: event: Fix typo in commentJiang Jian1-1/+1
Drop the redundant word 'the'. Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220622061442.18242-1-jiangjian@cdjrlc.com
2022-06-14platform/chrome: cros_ec: Always expose last resume resultStephen Boyd1-4/+4
The last resume result exposing logic in cros_ec_sleep_event() incorrectly requires S0ix support, which doesn't work on ARM based systems where S0ix doesn't exist. That's because cros_ec_sleep_event() only reports the last resume result when the EC indicates the last sleep event was an S0ix resume. On ARM systems, the last sleep event is always S3 resume, but the EC can still detect sleep hang events in case some other part of the AP is blocking sleep. Always expose the last resume result if the EC supports it so that this works on all devices regardless of S0ix support. This fixes sleep hang detection on ARM based chromebooks like Trogdor. Cc: Rajat Jain <rajatja@chromium.org> Cc: Matthias Kaehlcke <mka@chromium.org> Cc: Hsin-Yi Wang <hsinyi@chromium.org> Cc: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Reviewed-by: Evan Green <evgreen@chromium.org> Fixes: 7235560ac77a ("platform/chrome: Add support for v1 of host sleep event") Signed-off-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220614075726.2729987-1-swboyd@chromium.org
2022-06-14platform/chrome: cros_ec_proto: Fix spelling mistake "unknwon" -> "unknown"Colin Ian King1-1/+1
There is a spelling mistake in a dev_dbg message. Fix it. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220614064909.47804-1-colin.i.king@gmail.com
2022-06-10platform/chrome: cros_ec_proto: handle empty payload in getting wake maskTzung-Bi Shih1-10/+14
cros_ec_get_host_event_wake_mask() expects to receive sizeof(struct ec_response_host_event_mask) from send_command(). The payload is valid only if the return value is positive. Return -EPROTO if send_command() returns 0 in cros_ec_get_host_event_wake_mask(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-22-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit test for getting wake maskTzung-Bi Shih1-0/+128
cros_ec_get_host_event_wake_mask() expects to receive sizeof(struct ec_response_host_event_mask) from send_command(). The payload is valid only if the return value is positive. Add Kunit tests for returning 0 from send_command() in cros_ec_get_host_event_wake_mask(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-21-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: return 0 on getting wake mask successTzung-Bi Shih1-1/+2
cros_ec_get_host_event_wake_mask() used to return value from send_command() which is number of bytes for input payload on success (i.e. sizeof(struct ec_response_host_event_mask)). However, the callers don't need to know how many bytes are available. Don't return number of available bytes. Instead, return 0 on success; otherwise, negative integers on error. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-20-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: handle empty payload in getting cmd maskTzung-Bi Shih1-0/+5
cros_ec_get_host_command_version_mask() expects to receive sizeof(struct ec_response_get_cmd_versions) from send_command(). The payload is valid only if the return value is positive. Return -EPROTO if send_command() returns 0 in cros_ec_get_host_command_version_mask(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-19-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit tests for getting cmd maskTzung-Bi Shih1-0/+197
cros_ec_get_host_command_version_mask() expects to receive sizeof(struct ec_response_get_cmd_versions) from send_command(). The payload is valid only if the return value is positive. Add Kunit tests for returning 0 from send_command() in cros_ec_get_host_command_version_mask(). Note that because the 2 cros_ec_get_host_command_version_mask() use the same `ver_mask`. cros_ec_proto_test_query_all_no_host_sleep_return0() polluates the `ver_mask` and returns 0 on the second send_command() to make sure the second cros_ec_get_host_command_version_mask() doesn't take the garbage from the previous call. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-18-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: check `msg->result` in getting cmd maskTzung-Bi Shih1-8/+13
cros_ec_get_host_command_version_mask() should check if EC wasn't happy by checking `msg->result`. Use cros_ec_map_error() and return the error code if any. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-17-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit test for getting cmd mask errorTzung-Bi Shih1-0/+89
cros_ec_query_all() uses cros_ec_get_host_command_version_mask() to query the supported MKBP version; cros_ec_get_host_command_version_mask() uses send_command() for transferring the host command. Returning >=0 from send_command() only denotes the transfer was success. cros_ec_get_host_command_version_mask() should check if EC wasn't happy by checking `msg->result`. Add a Kunit test for returning error in `msg->result` in cros_ec_get_host_command_version_mask(). For the case, cros_ec_query_all() should find the EC device doesn't support MKBP. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-16-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: return 0 on getting cmd mask successTzung-Bi Shih1-8/+5
cros_ec_get_host_command_version_mask() used to return value from send_command() which is number of available bytes for input payload on success (i.e. sizeof(struct ec_response_get_cmd_versions)). However, the callers don't need to know how many bytes are available. Don't return number of available bytes. Instead, return 0 on success; otherwise, negative integers on error. Also remove the unneeded `ver_mask` initialization as the callers should take it only if cros_ec_get_host_command_version_mask() returns 0. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-15-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: don't show MKBP version if unsupportedTzung-Bi Shih1-4/+4
It wrongly showed the following message when it doesn't support MKBP: "MKBP support version 4294967295". Fix it. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-14-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: handle empty payload in getting info legacyTzung-Bi Shih1-3/+9
cros_ec_get_proto_info_legacy() expects to receive sizeof(struct ec_response_hello) from send_command(). The payload is valid only if the return value is positive. Return -EPROTO if send_command() returns 0 in cros_ec_get_proto_info_legacy(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-13-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit test for getting legacy infoTzung-Bi Shih1-0/+49
cros_ec_get_proto_info_legacy() expects to receive sizeof(struct ec_response_hello) from send_command(). The payload is valid only if the return value is positive. Add a Kunit test for returning 0 from send_command() in cros_ec_get_proto_info_legacy(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-12-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info_legacy()Tzung-Bi Shih2-50/+44
Rename cros_ec_host_command_proto_query_v2() to cros_ec_get_proto_info_legacy() and make it responsible for setting `ec_dev` fields for EC protocol v2. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-11-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: handle empty payload in getting proto infoTzung-Bi Shih1-0/+5
cros_ec_get_proto_info() expects to receive sizeof(struct ec_response_get_protocol_info) from send_command(). The payload is valid only if the return value is positive. Return -EPROTO if send_command() returns 0 in cros_ec_get_proto_info(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-10-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit tests for getting proto infoTzung-Bi Shih1-0/+132
cros_ec_get_proto_info() expects to receive sizeof(struct ec_response_get_protocol_info) from send_command(). The payload is valid only if the return value is positive. Add Kunit tests for returning 0 from send_command() in cros_ec_get_proto_info(). Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-9-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info()Tzung-Bi Shih2-97/+93
Rename cros_ec_host_command_proto_query() to cros_ec_get_proto_info() and make it responsible for setting `ec_dev` fields according to the response protocol info. Also make cros_ec_get_host_event_wake_mask() allocate its own message buffer. It was lucky that size of `struct ec_response_host_event_mask` is less than `struct ec_response_get_protocol_info`. Thus, the buffer wasn't overflow. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-8-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: use cros_ec_map_error()Tzung-Bi Shih1-5/+4
Use cros_ec_map_error() in cros_ec_get_host_event_wake_mask(). The behavior of cros_ec_get_host_event_wake_mask() slightly changed. It is acceptable because the caller only needs it returns negative integers for indicating errors. Especially, the EC_RES_INVALID_COMMAND still maps to -EOPNOTSUPP. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-7-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: remove redundant NULL checkTzung-Bi Shih1-3/+0
send_command() already checks if `ec_dev->pkt_xfer` is NULL. Remove the redundant check. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-6-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: assign buffer size from protocol infoTzung-Bi Shih1-6/+2
`din_size` is calculated from `ec_dev->max_response`. `ec_dev->max_response` is further calculated from the protocol info. To make it clear, assign `din_size` and `dout_size` from protocol info directly. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-5-tzungbi@kernel.org
2022-06-10platform/chrome: use macros for passthru indexesTzung-Bi Shih4-15/+17
Move passthru indexes for EC and PD devices to common header. Also use them instead of literal constants. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-4-tzungbi@kernel.org
2022-06-10platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_query_all()Tzung-Bi Shih5-0/+943
cros_ec_query_all() sends multiple host commands to EC for querying supported protocols and settings. Add required mock for interacting with cros_ec_query_all() and Kunit tests. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-3-tzungbi@kernel.org
2022-06-10platform/chrome: cros_kbd_led_backlight: support EC PWM backendTzung-Bi Shih2-16/+99
EC PWM backend uses EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT and EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT for setting and getting the brightness respectively. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Tested-by: Matthias Kaehlcke <mka@chromium.org> Link: https://lore.kernel.org/r/20220523090822.3035189-6-tzungbi@kernel.org
2022-06-10platform/chrome: cros_kbd_led_backlight: support OF matchTzung-Bi Shih1-1/+14
For letting device tree based machines to use the driver, support OF match. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Link: https://lore.kernel.org/r/20220523090822.3035189-5-tzungbi@kernel.org
2022-06-10platform/chrome: cros_kbd_led_backlight: separate ACPI backendTzung-Bi Shih1-13/+69
cros_kbd_led_backlight uses ACPI_KEYBOARD_BACKLIGHT_WRITE and ACPI_KEYBOARD_BACKLIGHT_READ for setting and getting the brightness respectively. Separate ACPI operations for preparing the driver to support other backends. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220523090822.3035189-3-tzungbi@kernel.org
2022-06-10platform/chrome: cros_kbd_led_backlight: sort headers alphabeticallyTzung-Bi Shih1-2/+2
To be neat and reduce conflict possibility, sort the headers alphabetically. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220523090822.3035189-2-tzungbi@kernel.org
2022-06-08platform/chrome: cros_ec_proto: Update size arg typesPrashant Malani1-2/+2
cros_ec_cmd() takes 2 size arguments. Update them to be of the more appropriate type size_t. Suggested-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220606201825.763788-4-pmalani@chromium.org