summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/flash.c
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: Eliminate pointer from SYS_INIT functionsKeith Short2023-04-171-3/+1
| | | | | | | | | | | | | | | | | | | | The upstream change https://github.com/zephyrproject-rtos/zephyr/pull/51217 modified the function signature for the SYS_INIT call, eliminating the unused device pointer. Run the Zephyr provided script ./zephyr/scripts/utils/migrate_sys_init.py to update all callers. BUG=b:278595739 BRANCH=none TEST=zmake build -a Cq-Depend: chromium:4422804 Change-Id: I881bc536cef43a7c3ac4bc5eb3ce1893237bbd1f Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4437049 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* cbi: flash: Implement CBI flash storage driver interfaceMadhurima Paruchuri2023-03-091-2/+3
| | | | | | | | | | | BUG=b:267628657 BRANCH=None TEST=./twister -s drivers/drivers.cbi_flash -c --coverage Change-Id: Ia1be34baf79774dc550bd70493ce5d2de31f2f28 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4284566 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* flash: allow zero num_banks_desc in flash_info requestTing Shen2023-01-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | Some external tools (e.g. flashrom) sends EC_CMD_FLASH_INFO with num_banks_desc=0 to get the total number of banks. EC should allow this type of request. Also add a test to cover this use case. BUG=b:265472751 TEST=1) `flashrom -p ec -w <ec.bin>` on tentacruel 2) ./twister -T zephyr/test/drivers/ \ --sub-test drivers.flash.page_layout 3) ./twister -T zephyr/test/drivers/ --sub-test drivers.flash BRANCH=none Change-Id: Iab97ac754bac87067f949cf9435156be91b07ebc Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4167539 Tested-by: Chen-Tsung Hsieh <chentsung@chromium.org> Reviewed-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Patryk Duda <patrykd@google.com>
* shim/src/flash: Add functions for providing flash sectors infoPatryk Duda2023-01-111-0/+182
| | | | | | | | | | | | | | | | | | | | | Introduce Zephyr counterparts of functions that provide information about flash sectors, total number of sectors, size of array to describe sector types, etc. These functions use Zephyr flash pages API. To use functions, enable PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT config. BUG=b:239712345 BRANCH=none TEST=zmake build -a --clobber Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I9ee9a8f36401e4643adfa150c745ba502b72c36a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030378 Tested-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* zephyr/shim: Sort header filesJeremy Bettis2022-11-161-5/+6
| | | | | | | | | | | | | | | | | | Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I5fefbad560d33e2e8be1b02d0db618a19fdd403d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024019 Reviewed-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Tomasz Michalec <tmichalec@google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr/shim/src/flash.c: Format with clang-formatJack Rosenthal2022-06-301-12/+7
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I68679356bb874a4c9a3af10c9e4889d31d6a2c0b Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730909 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: add a zephyr/ prefix to all zephyr includesFabio Baltieri2022-05-091-3/+3
| | | | | | | | | | | | | | | | | | | This adds a zephyr/ prefix to all #include path pointing to Zephyr header files, so that we could drop LEGACY_INCLUD_PATH once all upstream code has been converted. Generated using something similar to the script in: c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I5ba2c859fe10a34ea8d3a49a612132ea4d02f2cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3634345 Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: mchp: Add shim flashmartin yan2022-03-291-0/+8
| | | | | | | | | | | | | Add shim layer flash code BUG=b:226599277 BRANCH=main TEST=zmake testall Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: I509d27ec06922a0f51759fbf8c100f43e2ce08e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3546981 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: Fix comment referencing functionAndrew McRae2022-02-141-1/+1
| | | | | | | | | | | | | | | Reference the Zephyr GPIO API instead of the legacy API. BUG=b:216466985 TEST=zmake testall BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: Ifd6bb8e0974ead5f99b3bf3c49a35683dc2bb043 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3459582 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: flash: Rename cros-ec,flash to cros-ec,flash-controllerWealian Liao2022-01-281-3/+3
| | | | | | | | | | | | | | | Rename cros-ec,flash to cros-ec,flash-controller. So we can distinguish the flash and flash-controller node. BUG=b:216385443 BRANCH=none TEST=zmake testall Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ibd892a903f6efab2729961681267c6c98eb5762d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3419434 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: flash: clean up the shim layerDawid Niedzwiecki2022-01-181-16/+43
| | | | | | | | | | | | | | | | | | | | | | | Investigate if there is a possibility to call Zephyr flash drivers directly in the shim layer, not via CrosEC drivers. Unfortunately, it is possible only for the read operation. Other operations require additional actions depending on the chip type e.g. splitting into smaller parts or refreshing watchdog. Also, move locking of physical flash operations to the CrosEC drivers from the shim layer. BUG=b:205175314 TEST=zmake testall && make sure SoftwareSync works to verify flash operations BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I9c947d46244a255573ebde9a5cd7432a3ee9389c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3389268 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: use a chosen node to detect internal flashPeter Marheine2021-11-301-7/+7
| | | | | | | | | | | | | | | | | | | This change defines a well-known chosen node to bind the crec_flash_* shim functions to an actual flash device. Prior to this change, the shim required the internal flash be named 'fiu0' in order to function and this would only be checked at runtime. It is now checked at compile-time, saving a pointer in RAM and failing at build-time if not correctly configured. BUG=b:205615358 TEST=zmake testall BRANCH=none Change-Id: Ie713176960150a7ebeae8d2dcfc10c48260b264c Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3305647 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: flash: npcx: move the flash operations to upstreamJun Lin2021-11-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | In PR:39644, the SPI (FIU/UMA) driver is added to the Zephyr upstream. The flash access now can be via the flash APIs in spi_nor driver, including flash write/read/erase/read_jedec_id. Note that because there is no API in the flash driver to read/write the status register, it is implemented here via the spi_transceive API. BRANCH=none BUG=b:202295086 TEST=pass "zmake testall" TEST=enable flash console command on volteer and npcx9_evb, test the following flash related commands: flashread/flashwrite/flasherase/flashwp/flashchip/flashinfo. Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Cq-Depend: chromium:3261416 Change-Id: I012ea359695a22cbb54d39124b4b78ff95cca36d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3261447 Tested-by: CH Lin <chlin56@nuvoton.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: add support for flashchip commandMichał Barnaś2021-10-011-0/+37
| | | | | | | | | | | | | | | | | This commit extends the cros_flash_driver_api by adding pointer to functions that read manufacturer and device ids and status registers. BRANCH=main BUG=b:190224781 TEST=Extending interface shouldn't change EC behavior. Change-Id: I20f75679d7de5ab33432fc4b76bc3bbf7df5b541 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3191590 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(3)Tim Lin2021-07-011-56/+4
| | | | | | | | | | | | | | | | | | | | | Move NPCX specific code crec_flash_physical_get_protect(), crec_flash_physical_get_protect_flags(), crec_flash_physical_protect_at_boot(), and crec_flash_physical_protect_now() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=zmake -lDEBUG configure -b -B zephyr/build_volteer \ zephyr/projects/volteer/volteer/ Cq-Depend: chromium:2994430 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: Id6ed382ad4578969838339c9eb874b323390c485 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2891674 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(2)Tim Lin2021-07-011-29/+0
| | | | | | | | | | | | | | | | | | Move NPCX specific code flash_dev_init(), crec_flash_physical_write() and crec_flash_physical_erase() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=none Cq-Depend: chromium:2994429 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: I094e26c5b670402872a665ba4d24a6594f7ca77e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994430 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(1)Tim Lin2021-07-011-194/+0
| | | | | | | | | | | | | | | | | | | Move the flash protection routines flash_get_status1() through flash_write_prot_reg() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=none Cq-Depend: chromium:2891674 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: Iaca3a32cfb35a77df10b87745bdabc1ed1cd3c40 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994429 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* include/flash: rename the APIsTim Lin2021-06-091-23/+23
| | | | | | | | | | | | | | | | The names conflict when enabling both Zephyr's flash driver and CONFIG_FLASH_CROS option. Rename all the APIs in include/flash.h BUG=b:187192628 BRANCH=none TEST=make buildall -j4 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: If1fd0ea28fa9f5cec1c1daa8f72f63eb7a0e6500 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2931749 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: fix initialization priority to be forward compatibleYuval Peress2021-04-071-1/+5
| | | | | | | | | | | | | | | | | | In upstream Zephyr the initialization of the GPIO module (and most other drivers) was changed. This breaks our gpio and in return also flash initialization. Update both gpio and flash initialization to work with Kconfig and add a compile time validation to be able to catch this sooner in the future. BRANCH=none BUG=none TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I44e5867dbf4cb3d5934bf0d0807dcc1aa6c778e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2808335 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: flash: change flash_lock to use K_MUTEX_DEFINEJack Rosenthal2021-03-231-9/+1
| | | | | | | | | | | | | | Switch this Zephyr-only code to use K_MUTEX_DEFINE, removing the requirement to initialize this mutex at runtime. BUG=b:177677037 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I917f88d4e72d27f23503f58511b6486405631d97 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2782235 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: Add locking to shimmed flash.cYuval Peress2021-02-121-3/+72
| | | | | | | | | | | | | | | | | Add a mutex to the shimmed version of flash.c (see chip/npcx/flash.c for reference). While I haven't run into this as a direct issue yet, this could very possibly be where we were running into the boot hang prior. BRANCH=none BUG=b:180112248, b:179900857, b:167392037 TEST=zmake testall TEST=build volteer, flash, see that it boots. Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I8013eba02545f96406399b8f4966e92bed1e9e9a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686983 Reviewed-by: Simon Glass <sjg@chromium.org>
* Refactor CONFIG_FLASH_SIZE to CONFIG_FLASH_SIZE_BYTESYuval Peress2021-01-151-3/+3
| | | | | | | | | | | | | | | | | | | | | In Zephyr CONFIG_FLASH_SIZE is a Kconfig value that is used throughout. The issue is that the units don't match. In Zephyr the value is in KiB instead of bytes. This refactor simply renames CONFIG_FLASH_SIZE in platform/ec to include the unit (via _BYTES). BRANCH=none BUG=b:174873770 TEST=make buildall be generated by the build instead of per board Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I44bf3c7a20fcf62aaa9ae15715be78db4210f384 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2627638 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim the flash accessJunLin2020-12-291-6/+327
| | | | | | | | | | | | | | | | | Implement the flash_physical* APIs by wrapping the cros_flash device driver APIs in zephyr-chrome BRANCH=none BUG=b:174874876 TEST=pass build with related patches. TEST=combine with related patches, use console commands to test all the implemented flash APIs. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: JunLin <CHLin56@nuvoton.com> Cq-Depend: chromium:2601823, chromium:2598212 Change-Id: I72543fe6290e24b74f7c6bf133599e577c529f08 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600809
* zephyr: Add the beginnings of a shim for flash accessSimon Glass2020-12-291-0/+39
Add myriad Kconfig options to make the flash code compile. This does not yet do anything useful, as we need to connect up to the Zephyr flash device (and need support for this in the npcx too). BUG=b:174873770 BRANCH=none TEST=build for volteer Change-Id: Ib4bed4cdd39cdf33a1d27b39aadb89df491941b3 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2575208