summaryrefslogtreecommitdiff
path: root/include/cros_board_info.h
Commit message (Collapse)AuthorAgeFilesLines
* CBI: Allow board to compose data from other sourcesDaisuke Nojiri2019-04-191-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the source of CBI data is only EEPROM. This patch allows CBI data to be composed from other sources such as ADC or some chip register. cbi_board_override is called by CBI library when data is being requested. Boards can implement this callback to add additional bits or bytes to the data. A board itself may need to get CBI data first to manipulate data properly. For such a case, a board can return EC_ERROR_BUSY to inform the callers that the data is not fully ready while a board itself can accept EC_ERROR_BUSY as an expected value. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/129569858 BRANCH=none TEST=Read LCM_ID properly Change-Id: Ie1f962c64c8d1461a6c171bc6c6d0c855c82e945 Reviewed-on: https://chromium-review.googlesource.com/1572439 Commit-Ready: YH Lin <yueherngl@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cbi: Add a new API for cbi_set_stringFurquan Shaikh2019-03-081-0/+16
| | | | | | | | | | | | | | | | | | | | This change introduces cbi_set_string that can be used by callers to add string data to CBI. Internally, this function ensures that the data is not NULL and call cbi_set_data for the string with a size of strlen + 1. It is added so that callers don't have to repeat the same operations for string data. BUG=b:124282048 BRANCH=None TEST=None Change-Id: Iad9da206c5e87735eac3adee6fce151fd1f0a53a Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1506440 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* CBI: Add MODEL_ID fieldDaisuke Nojiri2018-11-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MODEL_ID is an optional field containing a numeric value identifying models. Model IDs are unique within each OEM and <OEM_ID, MODEL_ID> should form a unique ID within the family. $ cbi-util create --file ~/cbi_image --board_version 0 --oem_id 6 --sku_id 255 --dram_part_num "012345679abcdef" --model_id 127 --size 256 $ hexdump -C /tmp/cbi.bin 0000 43 42 49 fa 00 00 26 00 00 01 00 01 01 06 02 01 |CBI...&.........| 0010 ff 05 01 7f 03 10 30 31 32 33 34 35 36 37 39 61 |......012345679a| 0020 62 63 64 65 66 00 ff ff ff ff ff ff ff ff ff ff |bcdef...........| $ cbi-util show --file /tmp/cbi.bin CBI image: /tmp/cbi.bin TOTAL_SIZE: 38 Data Field: name: value (hex, tag, size) BOARD_VERSION: 0 (0x0, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) MODEL_ID: 127 (0x7f, 5, 1) DRAM_PART_NUM: 012345679abcdef (3, 16) Data validated successfully localhost # ectool cbi set 5 127 1 localhost # ectool cbi get 5 As integer: 127 (0x7f) As binary: 7f > cbi [1289.860454 CBI Reading board info] CBI_VERSION: 0x0000 TOTAL_SIZE: 22 BOARD_VERSION: 513 (0x201) OEM_ID: 3 (0x3) MODEL_ID: 127 (0x7f) SKU_ID: 14951 (0x3a67) 43 42 49 b0 00 00 16 00 00 02 01 02 01 01 03 02 02 67 3a 05 01 7f ff ff ff ff ff ff ff ff ff ff Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:119522898,b:120105950 BRANCH=none TEST=See above. Change-Id: Ifd6f3087f5422bcf4c36d3d981b262653d0c89dc Reviewed-on: https://chromium-review.googlesource.com/1341099 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* cbi-util: Allow field size to be specifiedDaisuke Nojiri2018-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, field sizes are automatically set to the smallest size which can fit a given value. This patch makes cbi-util allow field sizes to be specified. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:79514391 BRANCH=none TEST=Tested as follows: 1. Create CBI image: $ cbi-util create --file cbi.bin --board_version 0x202 \ --oem_id 0xabcd:2 --sku_id 0xff:4 --size 256 2. Verify the image: $ cbi-util show --file cbi.bin CBI image: /home/dnojiri/tmp/nami/tmp/cbi.new.bin TOTAL_SIZE: 22 Data Field: name: value (hex, tag, size) BOARD_VERSION: 514 (0x202, 0, 2) OEM_ID: 43981 (0xabcd, 1, 2) SKU_ID: 255 (0xff, 2, 4) 3. Verify the output matches with the previous output if field sizes are not specified. Change-Id: Ic7149274d6e4a118ea12bbf03199b548b7089a3e Reviewed-on: https://chromium-review.googlesource.com/1056201 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* CBI: Share common code between host tool and firmwareDaisuke Nojiri2018-02-231-0/+35
| | | | | | | | | | | | | | 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 data offset and size variableDaisuke Nojiri2018-02-161-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* CBI: Read board info from EEPROMDaisuke Nojiri2018-01-181-0/+60
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>