summaryrefslogtreecommitdiff
path: root/common/cbi.c
Commit message (Collapse)AuthorAgeFilesLines
* cbi: add Second Source Factory Cache (SSFC) CBI fieldMarco Chen2021-09-081-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. BRANCH=none BUG=b:197005105 TEST= make BOARD=rammus TEST= Run command "ectool cbi set 8 0x10 4" TEST= Run command "ectool cbi get 8" Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> (cherry picked from commit 0212d4a3ce01452ddaba46f076f90e9a5e90e589) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3128387 Reviewed-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
* cbi: allow fields to be resizedJett Rink2018-09-201-6/+22
| | | | | | | | | | | | | | | | | Since we now have a dynamically sized CBI field (DRAM), it is more convenient to be able to resize fields. We accomplish this by deleting the old field and adding the field at the end, after copying all of the data forward. BRANCH=none BUG=b:116075074 TEST=Updated various CBI fields and watch them move to the end. tested updating the last field and middle fields Change-Id: Icb9b3cb36445d8e78315f9fd3a74483ff2d52ebf Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1234747 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cbi: fail set command early if WP is assertedJett Rink2018-09-041-5/+12
| | | | | | | | | | | | | | | | We are changing the in-memory version of CBI but cannot write it out to the EEPROM. This causes weird behavior when reading the CBI setting out again because it does not match the EEPROM values BRANCH=none BUG=b:113577856 TEST=Values aren't written to CBI in-memory when WP is asserted. Change-Id: Ie74fd3e47b3fabe6436e2787931b7238a112ec94 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1196846 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* drivers: Refactor to use high-level i2c APIsJonathan Brandmeyer2018-08-091-18/+6
| | | | | | | | | | | | | | | | | | | | | | | | Using the high-level APIs for block transfers eliminates some code duplication and error-prone manual locking sequences. - common/cbi: Block transfers - driver/accel_bma2x2: Block transfers - driver/accel_kionix: Block transfers - driver/accelgyro_bmi160: Block transfers - driver/accelgyro_lsm6ds0: Block transfers - driver/baro_bmp280: Block and byte transfers - driver/charger/rt946x: Block transfers - driver/gyro_l3gd20h: Block transfers - driver/stm_mems_common: Block transfers - driver/tcpm: Block transfers TEST=buildall; motionsense and PD testing on Grunt convertible which exercises the bma160, kionix and tcpcm drivers. BRANCH=none BUG=chromium:871851 Change-Id: I1732253a244c3343459265ce1e1e54488cee65b8 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1167958 Reviewed-by: Jett Rink <jettrink@chromium.org>
* cbi: lock the i2c port before using itZhuohao Lee2018-08-071-1/+9
| | | | | | | | | | | | | | i2c bus is the share resource. We need to lock the port before using it. Otherwise, it will break the other who is using the i2c bus. BUG=b:78538360 BRANCH=master TEST=Use command `ectool cbi get 0 1` without error Change-Id: I0adde0b0e912420813cfdec444ae8e531d90042f Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1163542 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* CBI: Disallow board version and OEM ID to be reprogrammedDaisuke Nojiri2018-05-041-0/+7
| | | | | | | | | | | | | | | | | This patch makes CBI refuse to change board version and OEM ID. When CONFIG_SYSTEM_UNLOCKED is defined, this restriction is removed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:74946347 BRANCH=none TEST=buildall Change-Id: I6ceda5764af56ed18a575f5563eaf294bb2876d0 Reviewed-on: https://chromium-review.googlesource.com/1017225 Commit-Ready: Jett Rink <jettrink@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* system: update board version to return an error if encounteredJett Rink2018-04-191-12/+0
| | | | | | | | | | | | | | | | | | | | Now that board version can come from CBI, we can have a real error reading it. We should pass that error to the console or to the AP on the host command and let the AP firmware (or user) decided how to handle that error case Also update the CONFIG_BOARD_VERSION to be derived instead of needed in most cases. BRANCH=none BUG=b:77972120 TEST=Error reported on EC console and AP console when CBI is invalid on yorp Change-Id: Ib8d80f610ea226265a61e68b61965150cdc9bb04 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1015776 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cbi: always refersh data for cbi ec commandstabilize-meowth-10574.BJett Rink2018-04-121-19/+28
| | | | | | | | | | | | | Also updated the description of the cbi command in help BRANCH=none BUG=none TEST=wrote directly to flash and verified the cbi command updated Change-Id: I54b5d995a0f06b9566622a5079da11ce575fb309 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1008831 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* CBI: Share common code between host tool and firmwareDaisuke Nojiri2018-02-231-25/+49
| | | | | | | | | | | | | | This patch makes EC firmware and cbi-util share the common code. BUG=b:70294260 BRANCH=none TEST=Set fields using ectool. Verify the contents by cbi command. Verify cbi-util creates the same binary as before. Verify emerge ec-utils ec-devutils pass. Change-Id: If5e65e48dd03960e0adf23ef775f67aecf785d85 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/932001
* CBI: Make cbi command dump EEPROM contentsfirmware-kbl-10431.BDaisuke Nojiri2018-02-221-16/+21
| | | | | | | | | | | | | | | | | | | | | | | Currently, cbi console command dumps the buffered contents. This patch will make the command dump the entire EEPROM. BUG=b:70294260 BRANCH=none TEST=Run cbi command on Fizz: CBI_VERSION: 0x0000 TOTAL_SIZE: 18 BOARD_VERSION: 514 (0x202) OEM_ID: 2 (0x2) SKU_ID: 0 (0x0) 43 42 49 5c 00 00 12 00 00 02 02 02 02 01 00 01 01 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ... Change-Id: I39f3335a38eb72c95d53264ddc7386dd0910e946 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/930322 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* CBI: Make data offset and size variableDaisuke Nojiri2018-02-161-101/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently CBI data offset and size are fixed. This patch makes them variable. Each data item consists of <tag><size><value> where <tag> is a numeric value assigned to each data item, <size> is the number of bytes used for <value>. BUG=b:70294260 BRANCH=none TEST=Use 'ectool cbi set' to set board version, oem, sku. Verify the contents by cbi console command and ectool cbi get. 1. ectool cbi set 0 0x202 2 2 (Init CBI and write board ver. of size 2) 2. ectool cbi set 1 1 1 (write oem id of size 1) 3. ectool cbi set 2 2 1 (write sku id of size 1) 4. ectool cbi get 0 514 (0x202) 5. ectool cbi get 1 1 (0x1) 6. ectool cbi get 2 2 (0x2) 7. Run cbi console command: CBI_VERSION: 0x0000 TOTAL_SIZE: 18 BOARD_VERSION: 514 (0x202) OEM_ID: 1 (0x1) SKU_ID: 2 (0x2) 43 42 49 8c 00 00 12 00 00 02 02 02 01 01 01 02 01 02 Change-Id: I5a30a4076e3eb448f4808d2af8ec4ef4c016ae5e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/920905 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* Fizz: Update thermal table by projectRyan Zhang2018-02-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 1. Prochot/Shutdown Point a. Prochot on: >=81C, off: <=77C b. Shutodwn: >=82C 2. custom fan table There are three projects sharing two tables, and use Kench & Teemo's table before getting correct OEM ID because it raises fan speed quicker than the other one. a. Kench & Teemo & default b. Sion BUG=b:70294260 BRANCH=master TEST=EC can get two fan tables with different cbi value. Change-Id: Ie1bffbcf5c353a9aae5806f6c2b41554eed22b7d Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/886121 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* CBI: Return ACCESS_DENIED on write failure due to WPDaisuke Nojiri2018-02-011-2/+5
| | | | | | | | | | | | | | | | This patch makes EC_CMD_SET_CROS_BOARD_INFO return EC_RES_ACCESS_DENIED if the command fails due to write-protect switch. BUG=b:70294260 BRANCH=none TEST=Verify 'ectool cbi set 2 4' prints 'WP enabled?' when WP is enabled. Change-Id: I7c27ee748caf32e57f22ab79edcbff96e42c44ad Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/897683 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* CBI: Allow get command to reload data from EEPROMDaisuke Nojiri2018-01-181-0/+3
| | | | | | | | | | | | | | | | | | This patch adds CBI_GET_RELOAD flag to EC_CMD_GET_CROS_BOARD_INFO command. When the flag is set, the command will be forced to read data from EEPROM even, ignoring the data cached by the previous read. This allows ectool to verify a write was successful without reboot. BUG=b:70294260 BRANCH=none TEST=ectool cbi set 0 0x1234 && ectool cbi get 0 1 Change-Id: I3e7ced5be56a74c605870a4c0622c0a2f47963bb Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/874155 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* CBI: Retry read and cache the resultDaisuke Nojiri2018-01-181-12/+19
| | | | | | | | | | | | | | | This patch makes read_board_info retry to read CBI on error. The successive calls will be immediately returned with the cached result. This will avoid attempting reads doomed to fail. BUG=b:70294260 BRANCH=none TEST=ectool cbi get 0 Change-Id: Iacd9cc38bab814af9188c4557c2ee751c421e3a3 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/872259 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* CBI: Add host command to set board infoDaisuke Nojiri2018-01-181-0/+87
| | | | | | | | | | | | | This patch adds host command to write board information in EERPOM. BUG=b:70294260 BRANCH=none TEST=Run ectool cbi set <type> <value> to write BOARD_VERSION, OEM_ID, and SKU_ID. Enable WP and verify cbi set command fails. Change-Id: I39536d146313408ace666f350a107d89b331bf7a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/865570
* CBI: Add host command to get board infoDaisuke Nojiri2018-01-181-0/+29
| | | | | | | | | | | | | This patch adds host command to get board info from EEPROM. BUG=b:70294260 BRANCH=none TEST=Run ectool cbi get <type> to get board version, OEM, SKU Change-Id: I41a84d3eea6da9d88fa8122db36dcd1df515842d Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/865161 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* CBI: Read board info from EEPROMDaisuke Nojiri2018-01-181-0/+127
This patch adds Cros Board Info APIs. It reads board info from EEPROM. This patch sets CONFIG_CBI for Fizz to make it use CBI. BUG=b:70294260 BRANCH=none TEST=Read data from EEPROM. Change-Id: I7eb4323188817d46b0450f1d65ac34d1b7e4e220 Reviewed-on: https://chromium-review.googlesource.com/707741 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>