summaryrefslogtreecommitdiff
path: root/drivers/misc/cros_ec.c
AgeCommit message (Collapse)AuthorFilesLines
2021-09-30WS cleanup: remove SPACE(s) followed by TABWolfgang Denk1-1/+1
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-25treewide: Use OF_REAL instead of !OF_PLATDATASimon Glass1-1/+1
Now that we have a 'positive' Kconfig option, use this instead of the negative one, which is harder to understand. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21cros_ec: Drop cros_ec_entering_mode()Simon Glass1-11/+0
This function is not needed anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21cros_ec: Allow reading the battery-charge stateSimon Glass1-0/+17
Add a function to read this information from the EC. It is useful for determining whether the battery has enough charge to boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-10pwm: Add a driver for Chrome OS EC PWMAlper Nebi Yasak1-0/+17
This PWM is used in rk3399-gru-bob and rk3399-gru-kevin to control the display brightness. We can only change the duty cycle, so on set_config() we just try to match the duty cycle that dividing duty_ns by period_ns gives us. To disable, we set the duty cycle to zero while keeping the old value for when we want to re-enable it. The cros_ec_set_pwm_duty() function is taken from Depthcharge's cros_ec_set_bl_pwm_duty() but modified to use the generic pwm type. The driver itself is very loosely based on rk_pwm.c for the general pwm driver structure. The devicetree binding file is from Linux, before it was converted to YAML at 5df5a577a6b4 ("dt-bindings: pwm: Convert google,cros-ec-pwm.txt to YAML format") in their repo. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Add vstore supportSimon Glass1-0/+71
The EC can store small amounts of data for the benefit of the verified boot process. Since the EC is seldom reset, this can allow the AP to store data that survives a reboot or a suspend/resume cycle. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Allow use with of-platdataSimon Glass1-0/+2
Avoid reading the device tree when of-platdata is in use. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Add support for switchesSimon Glass1-0/+16
On x86 platforms the EC provides a way to read 'switches', which are on/off values determined by the EC. Add a new driver method for this and implement it for LPC. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Support reading EC featuresSimon Glass1-6/+20
The EC can support a variety of features and provides a way to find out what is available. Add support for this. Also update the feature list to the lastest available while we are here. This is at: https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/include/ec_commands.h Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Add support for reading the SKU IDSimon Glass1-0/+13
This allows reading strapping pins attached to the EC. Add an implementation for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Add run-time check for input buffer overflowSimon Glass1-0/+2
This should not happen in normal operation, but the EC might have a bug, so add a run-time check just in case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Tidy up a few delaysSimon Glass1-7/+17
Allow a longer time for the EC to reboot. Also use a constant for the hash delay time, so it is clear what it is for. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31cros_ec: Add a function for the hello messageSimon Glass1-15/+31
This is used several times in this file. Put it in a function to avoid code duplication. Also add a test for this function. There are no cros_ec tests at present, so it is time to update the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass1-1/+1
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-15cros_ec: Correct collection of EC hashSimon Glass1-6/+10
The EC now requires that the offset field be set correctly when checking on hash status. Update the code to handle this. Use the same message struct in both functions to reduce stack space. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-05cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENTAlper Nebi Yasak1-0/+15
The cros_ec_keyb driver currently uses EC_CMD_MKBP_STATE to scan the keyboard, but this host command was superseded by EC_CMD_GET_NEXT_EVENT and unavailable on more recent devices (including gru-kevin), as it was removed in cros-ec commit 87a071941b89 ("mkbp: Add support for buttons and switches.") dated 2016-07-06. The EC_CMD_GET_NEXT_EVENT has been available since cros-ec commit d1ed75815efe ("MKBP event signalling implementation") dated 2014-10-20, but it looks like it isn't included in firmware-* branches for at least link, nyan-big, samus, snow, spring, panther and peach-pit which have defconfigs in U-Boot. So this patch falls back to the old method if the EC doesn't recognize the newer command. The implementation is mostly adapted from Depthcharge commit f88af26b44fc ("cros_ec: Change keyboard scanning method."). On a gru-kevin, the current driver before this patch fails to read the pressed keys with: out: cmd=0x60: 03 9d 60 00 00 00 00 00 in-header: 03 fc 01 00 00 00 00 00 in-data: ec_command_inptr: len=-1, din=0000000000000000 check_for_keys: keyboard scan failed However the keyboard works fine with the newer command: out: cmd=0x67: 03 96 67 00 00 00 00 00 in-header: 03 ef 00 00 0e 00 00 00 in-data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ec_command_inptr: len=14, din=00000000f412df30 key_matrix_decode: num_keys = 0 0 valid keycodes found out: cmd=0x67: 03 96 67 00 00 00 00 00 in-header: 03 df 00 00 0e 00 00 00 in-data: 00 00 00 00 00 00 00 00 00 00 00 00 10 00 ec_command_inptr: len=14, din=00000000f412df30 key_matrix_decode: num_keys = 1 valid=1, row=4, col=11 keycode=28 1 valid keycodes found {0d} Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop linux/delay.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop flash.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Fix up some style problems in flash.h while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-12-11cros_ec: use uint instead of uint8_t for cmd paramMichael Auchter1-1/+1
Chromium EC commands can be up to 16-bits, so using a uint8_t here can cause truncation. Update to use a uint instead. It looks like this should likely have been done as a part of 9fea76f5d30264dc08ac591a7a89427b8441555b, but this function was skipped for some reason. Signed-off-by: Michael Auchter <michael.auchter@ni.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-05-08cros_ec: Use a hyphen in the uclass nameSimon Glass1-1/+1
Device-tree rules require that aliases use a hyphen rather than a underscore. Update the uclass name to fit with this. This allows device-tree aliases to be used to refer to cros-ec devices, for example: aliases { cros-ec0 = &ec; cros-ec1 = &pd; }; Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2018-12-05cros: Correct a printf() string and commentSimon Glass1-2/+2
Correct a warning that occurs on sandbox. Also fix the comment style in cros_ec_set_lid_shutdown_mask(). Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-21cros_ec: Add new features for events and powerSimon Glass1-6/+339
This adds new commands to the EC related to setting and clearing events as well as controlling power-related settings. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-21cros_ec: Align uclass data to a cache boundarySimon Glass1-0/+1
The LPC driver expects its buffer to be word-aligned. Add the required flag to the uclass driver to ensure this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-21cros_ec: Fail if we cannot determine the flash burst sizeSimon Glass1-0/+3
This value is required for flashing to work correctly. Add a check for it. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-21cros_ec: Add error logging on a few commandsSimon Glass1-2/+9
Add some more logging to provide more information on failures. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-21cros_ec: Use uint instead of u8 for parametersSimon Glass1-6/+4
There is no advantage to using a u8 for function parameters. It forces the compiler to mask values and can increase code size. Also the command enum has been extended to 16 bits. Update the functions to use uint instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09cros_ec: Update cros_ec_read_hash() to specify the imageSimon Glass1-3/+4
Allow selection of which EC image to hash. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09cros: Update ec_commands to latest versionSimon Glass1-3/+4
This file has changed quite a bit in the last 5 years as the capabilities of the ECs have grown. Sync it up with the copy in coreboot commit b9141f2215. The only change is the addition of EC_VBNV_BLOCK_SIZE_V2. This is needed because U-Boot uses the new v2 vboot API and this is not currently fully supported by Chromium OS firmware. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09cros: Update cros_ec code to use struct udeviceSimon Glass1-73/+74
At present we pass around a private pointer to specify the cros_ec device. With driver model it makes more sense to pass the device. Update the code to do this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09dm: core: Update ofnode to read binman-style flash entrySimon Glass1-16/+17
At present ofnode_read_fmap_entry() reads a flash map entry in a format which is not supported by binman. To allow use to use binman-format descriptions, update this function. Also add a simple test. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Update of_read_fmap_entry() for livetreeSimon Glass1-2/+2
Update this function to take an ofnode so that it can work with livetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-27Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini1-2/+0
We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-09-12dm: core: Add ofnode_for_each_subnode()Simon Glass1-2/+1
Add a convenience macro to iterate over subnodes of a node. Make use of this where appropriate in the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01cros_ec: Convert to support live treeSimon Glass1-19/+14
Convert this driver to support the live device tree and remove the old fdtdec support. The keyboard is not yet converted. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01cros_ec: Fix debug() statement in ec_command_inptr()Simon Glass1-2/+1
This prints out the wrong pointers. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-02-08dm: core: Replace of_offset with accessorSimon Glass1-1/+1
At present devices use a simple integer offset to record the device tree node associated with the device. In preparation for supporting a live device tree, which uses a node pointer instead, refactor existing code to access this field through an inline function. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-12-03cmd: crosec: Move cros_ec_decode_region helper to cmd/cros_ec.cMoritz Fischer1-16/+0
The cros_ec_decode_region() function is only used in combination with the crosec cmds. Move the function to the correct place. Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: u-boot@lists.denx.de Acked-by: Simon Glass <sjg@chromium.org>
2016-10-11cmd: cros_ec: Move crosec commands to cmd subdirectoryMoritz Fischer1-351/+0
Move crosec commands from drivers/misc/cros_ec.c to cmd/cros_ec.c Acked-by: Simon Glass <sjg@chromium.org> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: Heiko Schocher <hs@denx.de> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Miao Yan <yanmiaobest@gmail.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Stefan Roese <sr@denx.de> Cc: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Nishanth Menon <nm@ti.com> Cc: u-boot@lists.denx.de
2016-10-09cros_ec: Fix issue with cros_ec_flash_write commandMoritz Fischer1-7/+16
This commit fixes an issue where data is written to an invalid memory location. The issue has been introduced in commit (88364387 cros: add cros_ec_driver) Cc: Simon Glass <sjg@chromium.org> Cc: u-boot@lists.denx.de Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-10-09cros_ec: Add crosec flashinfo commandMoritz Fischer1-0/+10
Add command to print out the flash info as reported by the ec. The data read back includes size, write block size, erase block size. Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: u-boot@lists.denx.de Acked-by: Simon Glass <sjg@chromium.org>
2016-10-09cros_ec: Add function to read back flash parametersMoritz Fischer1-0/+21
Add support for reading back flash parameters as reported by the ec. Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: u-boot@lists.denx.de Acked-by: Simon Glass <sjg@chromium.org>
2016-10-08cros_ec: Honor the google,remote-bus dt propertyMoritz Fischer1-2/+3
Boards where ECs that use a I2C port != 0 specify this in the devicetree file via the google,remote-bus property. Previously this was ignored and hardcoded to port 0. Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: Heiko Schocher <hs@denx.de> Cc: u-boot@lists.denx.de Acked-by: Simon Glass <sjg@chromium.org>
2016-09-24treewide: replace #include <asm/errno.h> with <linux/errno.h>Masahiro Yamada1-1/+1
Now, arch/${ARCH}/include/asm/errno.h and include/linux/errno.h have the same content. (both just wrap <asm-generic/errno.h>) Replace all include directives for <asm/errno.h> with <linux/errno.h>. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> [trini: Fixup include/clk.] Signed-off-by: Tom Rini <trini@konsulko.com>
2016-07-27dm: Use dm_scan_fdt_dev() directly where possibleSimon Glass1-7/+1
Quite a few places have a bind() method which just calls dm_scan_fdt_dev(). We may as well call dm_scan_fdt_dev() directly. Update the code to do this. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-07-27dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()Simon Glass1-2/+1
This new function is more convenient for callers, and handles pre-relocation situations automatically. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-11-20cros_ec: Use udevice instead of cros_ec_dev for keyboard functionsSimon Glass1-5/+9
In preparation for converting the cros_ec keyboard driver to driver model, adjust the cros_ec functions it will use to use a normal struct udevice. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06cros_ec: Remove the old tunnel codeSimon Glass1-267/+1
This is not needed with driver mode. Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06cros_ec: Support the LDO access method used by springSimon Glass1-10/+11
Add a driver to support the special LDO access used by spring. This is a custom method in the cros_ec protocol - it does not use an I2C pass-through. There are two implementation choices: 1. Write a special LDO driver which can talk across the EC. Duplicate all the logic from TPS65090 for retrying when the LDO fails to come up. 2. Write a special I2C bus driver which pretends to be a TPS65090 and transfers reads and writes using the LDO message. Either is distasteful. The latter method is chosen since it results in less code duplication and a fairly simple (30-line) implementation of the core logic. The crosec 'ldo' subcommand could be removed (since i2c md/mw will work instead) but is retained as a convenience. Signed-off-by: Simon Glass <sjg@chromium.org>