diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/amp.h | 29 | ||||
-rwxr-xr-x | include/android_avb/avb_ab_flow.h | 555 | ||||
-rw-r--r-- | include/android_avb/rk_avb_ops_user.h | 39 | ||||
-rw-r--r-- | include/bidram.h | 81 | ||||
-rw-r--r-- | include/boot_rkimg.h | 3 | ||||
-rw-r--r-- | include/configs/evb_px5.h | 1 | ||||
-rw-r--r-- | include/configs/rk3368_common.h | 5 | ||||
-rw-r--r-- | include/configs/rv1108_common.h | 2 | ||||
-rw-r--r-- | include/console.h | 2 | ||||
-rw-r--r-- | include/dm/uclass-id.h | 1 | ||||
-rw-r--r-- | include/dt-bindings/clock/rk1808-cru.h | 1 | ||||
-rw-r--r-- | include/image.h | 2 | ||||
-rw-r--r-- | include/irq-platform.h | 3 | ||||
-rw-r--r-- | include/key.h | 26 | ||||
-rw-r--r-- | include/lmb.h | 2 | ||||
-rw-r--r-- | include/memblk.h | 63 | ||||
-rw-r--r-- | include/optee_include/OpteeClientInterface.h | 2 | ||||
-rw-r--r-- | include/optee_include/OpteeClientMem.h | 2 | ||||
-rw-r--r-- | include/optee_include/OpteeClientRkFs-v2.h | 3 | ||||
-rw-r--r-- | include/optee_include/OpteeClientRkFs.h | 4 | ||||
-rw-r--r-- | include/power/rk8xx_pmic.h | 1 | ||||
-rw-r--r-- | include/rk_timer_irq.h | 9 | ||||
-rw-r--r-- | include/sysmem.h | 120 |
23 files changed, 585 insertions, 371 deletions
diff --git a/include/amp.h b/include/amp.h new file mode 100644 index 0000000000..629dcdcd04 --- /dev/null +++ b/include/amp.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2019 Rockchip Electronics Co., Ltd + */ + +#ifndef _AMP_H_ +#define _AMP_H_ + +#include <dm.h> + +struct dm_amp_ops { + int (*cpu_on)(struct udevice *dev); +}; + +struct dm_amp_uclass_platdata { + const char *desc; + const char *partition; + u32 cpu; /* cpu mpidr */ + u32 aarch; + u32 load; + u32 entry; + u32 reserved_mem[2]; /* [0]: start, [1]: size */ +}; + +int amp_bind_children(struct udevice *dev, const char *drv_name); +int amp_cpus_on(void); +int amp_cpu_on(u32 cpu); + +#endif /* _AMP_H_ */ diff --git a/include/android_avb/avb_ab_flow.h b/include/android_avb/avb_ab_flow.h index 0ba5ccd47c..152901b7c7 100755 --- a/include/android_avb/avb_ab_flow.h +++ b/include/android_avb/avb_ab_flow.h @@ -1,277 +1,278 @@ -/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*
-#if !defined(AVB_INSIDE_LIBAVB_AB_H) && !defined(AVB_COMPILATION)
-#error \
- "Never include this file directly, include libavb_ab/libavb_ab.h instead."
-#endif
-*/
-
-#ifndef AVB_AB_FLOW_H_
-#define AVB_AB_FLOW_H_
-
-#include <android_avb/avb_ab_ops.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Magic for the A/B struct when serialized. */
-#define AVB_AB_MAGIC "\0AB0"
-#define AVB_AB_MAGIC_LEN 4
-
-/* Versioning for the on-disk A/B metadata - keep in sync with avbtool. */
-#define AVB_AB_MAJOR_VERSION 1
-#define AVB_AB_MINOR_VERSION 0
-
-/* Size of AvbABData struct. */
-#define AVB_AB_DATA_SIZE 32
-
-/* Maximum values for slot data */
-#define AVB_AB_MAX_PRIORITY 15
-#define AVB_AB_MAX_TRIES_REMAINING 7
-
-/* Struct used for recording per-slot metadata.
- *
- * When serialized, data is stored in network byte-order.
- */
-typedef struct AvbABSlotData {
- /* Slot priority. Valid values range from 0 to AVB_AB_MAX_PRIORITY,
- * both inclusive with 1 being the lowest and AVB_AB_MAX_PRIORITY
- * being the highest. The special value 0 is used to indicate the
- * slot is unbootable.
- */
- uint8_t priority;
-
- /* Number of times left attempting to boot this slot ranging from 0
- * to AVB_AB_MAX_TRIES_REMAINING.
- */
- uint8_t tries_remaining;
-
- /* Non-zero if this slot has booted successfully, 0 otherwise. */
- uint8_t successful_boot;
-
- /* Reserved for future use. */
- uint8_t reserved[1];
-} AVB_ATTR_PACKED AvbABSlotData;
-
-/* Struct used for recording A/B metadata.
- *
- * When serialized, data is stored in network byte-order.
- */
-typedef struct AvbABData {
- /* Magic number used for identification - see AVB_AB_MAGIC. */
- uint8_t magic[AVB_AB_MAGIC_LEN];
-
- /* Version of on-disk struct - see AVB_AB_{MAJOR,MINOR}_VERSION. */
- uint8_t version_major;
- uint8_t version_minor;
-
- /* Padding to ensure |slots| field start eight bytes in. */
- uint8_t reserved1[2];
-
- /* Per-slot metadata. */
- AvbABSlotData slots[2];
-
- /* Reserved for future use. */
- uint8_t reserved2[12];
-
- /* CRC32 of all 28 bytes preceding this field. */
- uint32_t crc32;
-} AVB_ATTR_PACKED AvbABData;
-
-/* Copies |src| to |dest|, byte-swapping fields in the
- * process. Returns false if the data is invalid (e.g. wrong magic,
- * wrong CRC32 etc.), true otherwise.
- */
-bool avb_ab_data_verify_and_byteswap(const AvbABData* src, AvbABData* dest);
-
-/* Copies |src| to |dest|, byte-swapping fields in the process. Also
- * updates the |crc32| field in |dest|.
- */
-void avb_ab_data_update_crc_and_byteswap(const AvbABData* src, AvbABData* dest);
-
-/* Initializes |data| such that it has two slots and both slots have
- * maximum tries remaining. The CRC is not set.
- */
-void avb_ab_data_init(AvbABData* data);
-
-/* Reads A/B metadata from the 'misc' partition using |ops|. Returned
- * data is properly byteswapped. Returns AVB_IO_RESULT_OK on
- * success, error code otherwise.
- *
- * If the data read from disk is invalid (e.g. wrong magic or CRC
- * checksum failure), the metadata will be reset using
- * avb_ab_data_init() and then written to disk.
- */
-AvbIOResult avb_ab_data_read(AvbABOps* ab_ops, AvbABData* data);
-
-/* Writes A/B metadata to the 'misc' partition using |ops|. This will
- * byteswap and update the CRC as needed. Returns AVB_IO_RESULT_OK on
- * success, error code otherwise.
- */
-AvbIOResult avb_ab_data_write(AvbABOps* ab_ops, const AvbABData* data);
-
-/* Return codes used in avb_ab_flow(), see that function for
- * documentation of each value.
- */
-typedef enum {
- AVB_AB_FLOW_RESULT_OK,
- AVB_AB_FLOW_RESULT_OK_WITH_VERIFICATION_ERROR,
- AVB_AB_FLOW_RESULT_ERROR_OOM,
- AVB_AB_FLOW_RESULT_ERROR_IO,
- AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS,
- AVB_AB_FLOW_RESULT_ERROR_INVALID_ARGUMENT
-} AvbABFlowResult;
-
-/* Get a textual representation of |result|. */
-const char* avb_ab_flow_result_to_string(AvbABFlowResult result);
-
-/* High-level function to select a slot to boot. The following
- * algorithm is used:
- *
- * 1. A/B metadata is loaded and validated using the
- * read_ab_metadata() operation. Typically this means it's read from
- * the 'misc' partition and if it's invalid then it's reset using
- * avb_ab_data_init() and this reset metadata is returned.
- *
- * 2. All bootable slots listed in the A/B metadata are verified using
- * avb_slot_verify(). If a slot is invalid or if it fails verification
- * (and AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is not set, see
- * below), it will be marked as unbootable in the A/B metadata and the
- * metadata will be saved to disk before returning.
- *
- * 3. If there are no bootable slots, the value
- * AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS is returned.
- *
- * 4. For each bootable slot, the Stored Rollback Indexes are updated
- * such that for each rollback index location, the Stored Rollback
- * Index is the largest number smaller than or equal to the Rollback
- * Index of each slot.
- *
- * 5. The bootable slot with the highest priority is selected and
- * returned in |out_data|. If this slot is already marked as
- * successful, the A/B metadata is not modified. However, if the slot
- * is not marked as bootable its |tries_remaining| count is
- * decremented and the A/B metadata is saved to disk before returning.
- * In either case the value AVB_AB_FLOW_RESULT_OK is returning.
- *
- * The partitions to load is given in |requested_partitions| as a
- * NULL-terminated array of NUL-terminated strings. Typically the
- * |requested_partitions| array only contains a single item for the
- * boot partition, 'boot'.
- *
- * If the device is unlocked (and _only_ if it's unlocked), the
- * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR flag should be set
- * in the |flags| parameter. This will allow considering slots as
- * verified even when avb_slot_verify() returns
- * AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED,
- * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION, or
- * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX for the slot in
- * question.
- *
- * Note that neither androidboot.slot_suffix nor androidboot.slot are
- * set in the |cmdline| field in |AvbSlotVerifyData| - you will have
- * to pass these yourself.
- *
- * If a slot was selected and it verified then AVB_AB_FLOW_RESULT_OK
- * is returned.
- *
- * If a slot was selected but it didn't verify then
- * AVB_AB_FLOW_RESULT_OK_WITH_VERIFICATION_ERROR is returned. This can
- * only happen when the AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR
- * flag is set.
- *
- * If an I/O operation - such as loading/saving metadata or checking
- * rollback indexes - fail, the value AVB_AB_FLOW_RESULT_ERROR_IO is
- * returned.
- *
- * If memory allocation fails, AVB_AB_FLOW_RESULT_ERROR_OOM is
- * returned.
- *
- * If invalid arguments are passed,
- * AVB_AB_FLOW_RESULT_ERROR_INVALID_ARGUMENT is returned. For example
- * this can happen if using AVB_HASHTREE_ERROR_MODE_LOGGING without
- * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR.
- *
- * Reasonable behavior for handling AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS
- * is to initiate device repair (which is device-dependent).
- */
-AvbABFlowResult avb_ab_flow(AvbABOps* ab_ops,
- const char* const* requested_partitions,
- AvbSlotVerifyFlags flags,
- AvbHashtreeErrorMode hashtree_error_mode,
- AvbSlotVerifyData** out_data);
-
-/* Marks the slot with the given slot number as active. Returns
- * AVB_IO_RESULT_OK on success, error code otherwise.
- *
- * This function is typically used by the OS updater when completing
- * an update. It can also used by the firmware for implementing the
- * "set_active" command.
- */
-AvbIOResult avb_ab_mark_slot_active(AvbABOps* ab_ops, unsigned int slot_number);
-
-/* Marks the slot with the given slot number as unbootable. Returns
- * AVB_IO_RESULT_OK on success, error code otherwise.
- *
- * This function is typically used by the OS updater before writing to
- * a slot.
- */
-AvbIOResult avb_ab_mark_slot_unbootable(AvbABOps* ab_ops,
- unsigned int slot_number);
-
-/* Marks the slot with the given slot number as having booted
- * successfully. Returns AVB_IO_RESULT_OK on success, error code
- * otherwise.
- *
- * Calling this on an unbootable slot is an error - AVB_IO_RESULT_OK
- * will be returned yet the function will have no side-effects.
- *
- * This function is typically used by the OS updater after having
- * confirmed that the slot works as intended.
- */
-AvbIOResult avb_ab_mark_slot_successful(AvbABOps* ab_ops,
- unsigned int slot_number);
-
-/*
- * Load metadata.
- */
-AvbIOResult load_metadata(AvbABOps* ab_ops,
- AvbABData* ab_data,
- AvbABData* ab_data_orig);
-
-/* Writes A/B metadata to disk only if it has changed - returns
- * AVB_IO_RESULT_OK on success, error code otherwise.
- */
-AvbIOResult save_metadata_if_changed(AvbABOps* ab_ops,
- AvbABData* ab_data,
- AvbABData* ab_data_orig);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AVB_AB_FLOW_H_ */
+/* + * Copyright (C) 2016 The Android Open Source Project + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* +#if !defined(AVB_INSIDE_LIBAVB_AB_H) && !defined(AVB_COMPILATION) +#error \ + "Never include this file directly, include libavb_ab/libavb_ab.h instead." +#endif +*/ + +#ifndef AVB_AB_FLOW_H_ +#define AVB_AB_FLOW_H_ + +#include <android_avb/avb_ab_ops.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Magic for the A/B struct when serialized. */ +#define AVB_AB_MAGIC "\0AB0" +#define AVB_AB_MAGIC_LEN 4 + +/* Versioning for the on-disk A/B metadata - keep in sync with avbtool. */ +#define AVB_AB_MAJOR_VERSION 1 +#define AVB_AB_MINOR_VERSION 0 + +/* Size of AvbABData struct. */ +#define AVB_AB_DATA_SIZE 32 + +/* Maximum values for slot data */ +#define AVB_AB_MAX_PRIORITY 15 +#define AVB_AB_MAX_TRIES_REMAINING 7 + +/* Struct used for recording per-slot metadata. + * + * When serialized, data is stored in network byte-order. + */ +typedef struct AvbABSlotData { + /* Slot priority. Valid values range from 0 to AVB_AB_MAX_PRIORITY, + * both inclusive with 1 being the lowest and AVB_AB_MAX_PRIORITY + * being the highest. The special value 0 is used to indicate the + * slot is unbootable. + */ + uint8_t priority; + + /* Number of times left attempting to boot this slot ranging from 0 + * to AVB_AB_MAX_TRIES_REMAINING. + */ + uint8_t tries_remaining; + + /* Non-zero if this slot has booted successfully, 0 otherwise. */ + uint8_t successful_boot; + + /* Reserved for future use. */ + uint8_t reserved[1]; +} AVB_ATTR_PACKED AvbABSlotData; + +/* Struct used for recording A/B metadata. + * + * When serialized, data is stored in network byte-order. + */ +typedef struct AvbABData { + /* Magic number used for identification - see AVB_AB_MAGIC. */ + uint8_t magic[AVB_AB_MAGIC_LEN]; + + /* Version of on-disk struct - see AVB_AB_{MAJOR,MINOR}_VERSION. */ + uint8_t version_major; + uint8_t version_minor; + + /* Padding to ensure |slots| field start eight bytes in. */ + uint8_t reserved1[2]; + + /* Per-slot metadata. */ + AvbABSlotData slots[2]; + + /* Reserved for future use. */ + uint8_t last_boot; + uint8_t reserved2[11]; + + /* CRC32 of all 28 bytes preceding this field. */ + uint32_t crc32; +} AVB_ATTR_PACKED AvbABData; + +/* Copies |src| to |dest|, byte-swapping fields in the + * process. Returns false if the data is invalid (e.g. wrong magic, + * wrong CRC32 etc.), true otherwise. + */ +bool avb_ab_data_verify_and_byteswap(const AvbABData* src, AvbABData* dest); + +/* Copies |src| to |dest|, byte-swapping fields in the process. Also + * updates the |crc32| field in |dest|. + */ +void avb_ab_data_update_crc_and_byteswap(const AvbABData* src, AvbABData* dest); + +/* Initializes |data| such that it has two slots and both slots have + * maximum tries remaining. The CRC is not set. + */ +void avb_ab_data_init(AvbABData* data); + +/* Reads A/B metadata from the 'misc' partition using |ops|. Returned + * data is properly byteswapped. Returns AVB_IO_RESULT_OK on + * success, error code otherwise. + * + * If the data read from disk is invalid (e.g. wrong magic or CRC + * checksum failure), the metadata will be reset using + * avb_ab_data_init() and then written to disk. + */ +AvbIOResult avb_ab_data_read(AvbABOps* ab_ops, AvbABData* data); + +/* Writes A/B metadata to the 'misc' partition using |ops|. This will + * byteswap and update the CRC as needed. Returns AVB_IO_RESULT_OK on + * success, error code otherwise. + */ +AvbIOResult avb_ab_data_write(AvbABOps* ab_ops, const AvbABData* data); + +/* Return codes used in avb_ab_flow(), see that function for + * documentation of each value. + */ +typedef enum { + AVB_AB_FLOW_RESULT_OK, + AVB_AB_FLOW_RESULT_OK_WITH_VERIFICATION_ERROR, + AVB_AB_FLOW_RESULT_ERROR_OOM, + AVB_AB_FLOW_RESULT_ERROR_IO, + AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS, + AVB_AB_FLOW_RESULT_ERROR_INVALID_ARGUMENT +} AvbABFlowResult; + +/* Get a textual representation of |result|. */ +const char* avb_ab_flow_result_to_string(AvbABFlowResult result); + +/* High-level function to select a slot to boot. The following + * algorithm is used: + * + * 1. A/B metadata is loaded and validated using the + * read_ab_metadata() operation. Typically this means it's read from + * the 'misc' partition and if it's invalid then it's reset using + * avb_ab_data_init() and this reset metadata is returned. + * + * 2. All bootable slots listed in the A/B metadata are verified using + * avb_slot_verify(). If a slot is invalid or if it fails verification + * (and AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is not set, see + * below), it will be marked as unbootable in the A/B metadata and the + * metadata will be saved to disk before returning. + * + * 3. If there are no bootable slots, the value + * AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS is returned. + * + * 4. For each bootable slot, the Stored Rollback Indexes are updated + * such that for each rollback index location, the Stored Rollback + * Index is the largest number smaller than or equal to the Rollback + * Index of each slot. + * + * 5. The bootable slot with the highest priority is selected and + * returned in |out_data|. If this slot is already marked as + * successful, the A/B metadata is not modified. However, if the slot + * is not marked as bootable its |tries_remaining| count is + * decremented and the A/B metadata is saved to disk before returning. + * In either case the value AVB_AB_FLOW_RESULT_OK is returning. + * + * The partitions to load is given in |requested_partitions| as a + * NULL-terminated array of NUL-terminated strings. Typically the + * |requested_partitions| array only contains a single item for the + * boot partition, 'boot'. + * + * If the device is unlocked (and _only_ if it's unlocked), the + * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR flag should be set + * in the |flags| parameter. This will allow considering slots as + * verified even when avb_slot_verify() returns + * AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED, + * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION, or + * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX for the slot in + * question. + * + * Note that neither androidboot.slot_suffix nor androidboot.slot are + * set in the |cmdline| field in |AvbSlotVerifyData| - you will have + * to pass these yourself. + * + * If a slot was selected and it verified then AVB_AB_FLOW_RESULT_OK + * is returned. + * + * If a slot was selected but it didn't verify then + * AVB_AB_FLOW_RESULT_OK_WITH_VERIFICATION_ERROR is returned. This can + * only happen when the AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR + * flag is set. + * + * If an I/O operation - such as loading/saving metadata or checking + * rollback indexes - fail, the value AVB_AB_FLOW_RESULT_ERROR_IO is + * returned. + * + * If memory allocation fails, AVB_AB_FLOW_RESULT_ERROR_OOM is + * returned. + * + * If invalid arguments are passed, + * AVB_AB_FLOW_RESULT_ERROR_INVALID_ARGUMENT is returned. For example + * this can happen if using AVB_HASHTREE_ERROR_MODE_LOGGING without + * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR. + * + * Reasonable behavior for handling AVB_AB_FLOW_RESULT_ERROR_NO_BOOTABLE_SLOTS + * is to initiate device repair (which is device-dependent). + */ +AvbABFlowResult avb_ab_flow(AvbABOps* ab_ops, + const char* const* requested_partitions, + AvbSlotVerifyFlags flags, + AvbHashtreeErrorMode hashtree_error_mode, + AvbSlotVerifyData** out_data); + +/* Marks the slot with the given slot number as active. Returns + * AVB_IO_RESULT_OK on success, error code otherwise. + * + * This function is typically used by the OS updater when completing + * an update. It can also used by the firmware for implementing the + * "set_active" command. + */ +AvbIOResult avb_ab_mark_slot_active(AvbABOps* ab_ops, unsigned int slot_number); + +/* Marks the slot with the given slot number as unbootable. Returns + * AVB_IO_RESULT_OK on success, error code otherwise. + * + * This function is typically used by the OS updater before writing to + * a slot. + */ +AvbIOResult avb_ab_mark_slot_unbootable(AvbABOps* ab_ops, + unsigned int slot_number); + +/* Marks the slot with the given slot number as having booted + * successfully. Returns AVB_IO_RESULT_OK on success, error code + * otherwise. + * + * Calling this on an unbootable slot is an error - AVB_IO_RESULT_OK + * will be returned yet the function will have no side-effects. + * + * This function is typically used by the OS updater after having + * confirmed that the slot works as intended. + */ +AvbIOResult avb_ab_mark_slot_successful(AvbABOps* ab_ops, + unsigned int slot_number); + +/* + * Load metadata. + */ +AvbIOResult load_metadata(AvbABOps* ab_ops, + AvbABData* ab_data, + AvbABData* ab_data_orig); + +/* Writes A/B metadata to disk only if it has changed - returns + * AVB_IO_RESULT_OK on success, error code otherwise. + */ +AvbIOResult save_metadata_if_changed(AvbABOps* ab_ops, + AvbABData* ab_data, + AvbABData* ab_data_orig); + +#ifdef __cplusplus +} +#endif + +#endif /* AVB_AB_FLOW_H_ */ diff --git a/include/android_avb/rk_avb_ops_user.h b/include/android_avb/rk_avb_ops_user.h index 0a70e7096b..441856c33c 100644 --- a/include/android_avb/rk_avb_ops_user.h +++ b/include/android_avb/rk_avb_ops_user.h @@ -30,6 +30,13 @@ extern "C" { #define RPMB_BASE_ADDR (64*1024/256) #define UBOOT_RB_INDEX_OFFSET 24 #define TRUST_RB_INDEX_OFFSET 28 +#define ROCHCHIP_RSA_PARAMETER_SIZE 64 + +struct rk_pub_key { + u_int32_t rsa_n[ROCHCHIP_RSA_PARAMETER_SIZE]; + u_int32_t rsa_e[ROCHCHIP_RSA_PARAMETER_SIZE]; + u_int32_t rsa_c[ROCHCHIP_RSA_PARAMETER_SIZE]; +}; /** * Provided to fastboot to read how many slot in this system. @@ -267,6 +274,38 @@ int rk_auth_unlock(void *buffer, char *out_is_trusted); */ int rk_generate_unlock_challenge(void *buffer, uint32_t *challenge_len); +/** + * Get last boot slot + * + * @return 0 is slot A; 1 is slot B; -1 is error + */ +int rk_get_lastboot(void); + +/** + * Get permanent attribute certificate + * + * @param cer: certificate data + * + * @param size: certificate size + */ +int rk_avb_get_perm_attr_cer(uint8_t *cer, uint32_t size); + +/** + * Set permanent attribute certificate + * + * @param cer: certificate data + * + * @param size: certificate size + */ +int rk_avb_set_perm_attr_cer(uint8_t *cer, uint32_t size); + +/** + * Get public key + * + * @param pub_key: public key data + */ +int rk_avb_get_pub_key(struct rk_pub_key *pub_key); + #ifdef __cplusplus } #endif diff --git a/include/bidram.h b/include/bidram.h new file mode 100644 index 0000000000..3b39d442fd --- /dev/null +++ b/include/bidram.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2019 Rockchip Electronics Co., Ltd + */ + +#ifndef _BIDRAM_H +#define _BIDRAM_H + +#include <memblk.h> + +typedef struct memblock *(*parse_fn_t)(int *); + +struct bidram { + struct lmb lmb; + struct list_head reserved_head; + bool has_init; +}; + +/** + * bidram_initr() - Initial bidram after relocation. + * + * @return 0 on success, otherwise error + */ +int bidram_initr(void); + +/** + * bidram_get_ram_size() - Initial bidram and get ram size. + * + * @parse_fn: function to parse ddr memory regions + * + * @return ram size, 0 on success, otherwise the effect ram size. + */ +phys_size_t bidram_get_ram_size(void); + +/** + * bidram_gen_gd_bi_dram() - Update gd->bd->bi_dram[] according to bidram state. + */ +void bidram_gen_gd_bi_dram(void); + +/** + * bidram_reserve() - Reserve bidram region + * + * @id: memblk id + * @base: region base address + * @size: region size + * + * @return 0 on success, otherwise error + */ +int bidram_reserve(enum memblk_id id, phys_addr_t base, phys_size_t size); + +/** + * bidram_reserve_by_name() - Reserve bidram region by name + * + * @name: region name + * @base: region base address + * @size: region size + * + * @return 0 on success, otherwise error + */ +int bidram_reserve_by_name(const char *name, phys_addr_t base, phys_size_t size); + +/** + * bidram_dump_all() - Dump all bidram stat + */ +void bidram_dump(void); + +/** + * board_bidram_parse_fn() - Weak function for board to implement + */ +parse_fn_t board_bidram_parse_fn(void); + +/** + * board_bidram_reserve() - Weak function for board to implement + * + * @bidram: global bidram point, ignored + * + * @return 0 on success, otherwise error + */ +int board_bidram_reserve(struct bidram *bidram); + +#endif /* _BIDRAM_H */ diff --git a/include/boot_rkimg.h b/include/boot_rkimg.h index e88375159f..795ad62901 100644 --- a/include/boot_rkimg.h +++ b/include/boot_rkimg.h @@ -29,6 +29,9 @@ enum _boot_mode { int rockchip_get_boot_mode(void); int boot_rockchip_image(struct blk_desc *dev, disk_partition_t *boot_part); +int read_rockchip_image(struct blk_desc *dev_desc, + disk_partition_t *part_info, void *dst); + struct blk_desc *rockchip_get_bootdev(void); /* diff --git a/include/configs/evb_px5.h b/include/configs/evb_px5.h index 4160187d50..b6866b5f0d 100644 --- a/include/configs/evb_px5.h +++ b/include/configs/evb_px5.h @@ -10,5 +10,6 @@ #include <configs/rk3368_common.h> #define CONFIG_CONSOLE_SCROLL_LINES 10 +#define CONFIG_SYS_MMC_ENV_DEV 0 #endif diff --git a/include/configs/rk3368_common.h b/include/configs/rk3368_common.h index e7f4178f0c..5ef4a3b9f2 100644 --- a/include/configs/rk3368_common.h +++ b/include/configs/rk3368_common.h @@ -15,7 +15,7 @@ #include <linux/sizes.h> #define CONFIG_SYS_SDRAM_BASE 0 -#define SDRAM_MAX_SIZE 0xff000000 +#define SDRAM_MAX_SIZE 0xfe000000 #define CONFIG_BAUDRATE 115200 #define CONFIG_SYS_MALLOC_LEN (192 << 20) #define CONFIG_SYS_CBSIZE 1024 @@ -28,9 +28,10 @@ #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x00000000 -#define CONFIG_SPL_MAX_SIZE 0x40000 +#define CONFIG_SPL_MAX_SIZE 0x60000 #define CONFIG_SPL_BSS_START_ADDR 0x400000 #define CONFIG_SPL_BSS_MAX_SIZE 0x20000 +#define CONFIG_SPL_STACK 0x00188000 #define GICD_BASE 0xffB71000 #define GICC_BASE 0xffB72000 diff --git a/include/configs/rv1108_common.h b/include/configs/rv1108_common.h index 44cd4e3f6f..0463f236b8 100644 --- a/include/configs/rv1108_common.h +++ b/include/configs/rv1108_common.h @@ -22,7 +22,7 @@ /* SPL support */ #define CONFIG_SPL_STACK 0x10080700 #define CONFIG_SPL_TEXT_BASE 0x10080800 -#define CONFIG_SPL_MAX_SIZE 0x1700 +#define CONFIG_SPL_MAX_SIZE 0x4000 /* BSS setup */ #define CONFIG_SPL_BSS_MAX_SIZE 0x100 diff --git a/include/console.h b/include/console.h index d72c8cdf35..3af98a622a 100644 --- a/include/console.h +++ b/include/console.h @@ -12,6 +12,8 @@ extern char console_buffer[]; #define CONSOLE_EVT_CTRL_B 0x02 #define CONSOLE_EVT_CTRL_D 0x04 +#define CONSOLE_EVT_CTRL_F 0x06 +#define CONSOLE_EVT_CTRL_M 0x0D /* common/console.c */ int console_init_f(void); /* Before relocation; uses the serial stuff */ diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 70910f319e..b51b9873f2 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -31,6 +31,7 @@ enum uclass_id { UCLASS_BLK, /* Block device */ UCLASS_CLK, /* Clock source, e.g. used by peripherals */ UCLASS_CPU, /* CPU, typically part of an SoC */ + UCLASS_AMP, /* Asymmetric Multi-Processing */ UCLASS_CODEC, /* audio codec */ UCLASS_CROS_EC, /* Chrome OS EC */ UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */ diff --git a/include/dt-bindings/clock/rk1808-cru.h b/include/dt-bindings/clock/rk1808-cru.h index 3dd5c76d52..994896d111 100644 --- a/include/dt-bindings/clock/rk1808-cru.h +++ b/include/dt-bindings/clock/rk1808-cru.h @@ -111,6 +111,7 @@ #define SCLK_MIPIDSIPHY_REF 110 #define SCLK_PCIEPHY_REF 111 #define SCLK_RTC32K_FRAC 112 +#define SCLK_32K_IOE 113 /* aclk gates */ #define ACLK_GIC_PRE 145 diff --git a/include/image.h b/include/image.h index 8daffcceee..11c65292ba 100644 --- a/include/image.h +++ b/include/image.h @@ -693,6 +693,8 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob); #ifdef CONFIG_SYSMEM int boot_fdt_add_sysmem_rsv_regions(void *fdt_blob); +#else +static inline int boot_fdt_add_sysmem_rsv_regions(void *fdt_blob) { return 0; } #endif int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size); diff --git a/include/irq-platform.h b/include/irq-platform.h index b07d576057..5ae9e973b1 100644 --- a/include/irq-platform.h +++ b/include/irq-platform.h @@ -104,7 +104,8 @@ #define GPIO_BANK_NUM 4 #define GPIO_BANK_PINS 32 -#define IRQ_TIMER1 79 +#define IRQ_TIMER0 98 +#define IRQ_TIMER1 99 #define IRQ_PWM 110 #define IRQ_GPIO0 113 #define IRQ_GPIO1 114 diff --git a/include/key.h b/include/key.h index f85e1f3164..c9e11bd874 100644 --- a/include/key.h +++ b/include/key.h @@ -18,49 +18,43 @@ enum { GPIO_KEY = 0x2, }; -enum key_state { +enum key_event { KEY_PRESS_NONE, /* press without release */ KEY_PRESS_DOWN, /* press -> release */ KEY_PRESS_LONG_DOWN, KEY_NOT_EXIST, }; -struct input_key { - struct udevice *parent; - struct list_head link; +struct dm_key_uclass_platdata { const char *name; bool pre_reloc; u32 code; u8 type; /* ADC key */ - u32 adcval; - u32 vref; u8 channel; + u32 adcval; + u32 min; + u32 max; /* GPIO key */ u32 irq; + u32 gpios[2]; struct gpio_desc gpio; - /* Event */ - u64 up_t; - u64 down_t; -}; - -struct dm_key_ops { - const char *name; + u64 rise_ms; + u64 fall_ms; }; /* Use it instead of get_timer() in key interrupt handler */ uint64_t key_timer(uint64_t base); -/* Reister you key to dm key framework */ -void key_add(struct input_key *key); - /* Confirm if your key value is a press event */ int key_is_pressed(int keyval); /* Read key */ int key_read(int code); +int key_bind_children(struct udevice *dev, const char *drv_name); + #endif diff --git a/include/lmb.h b/include/lmb.h index 6b6959fd86..ece2a54e5b 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -11,7 +11,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#define MAX_LMB_REGIONS 8 +#define MAX_LMB_REGIONS 16 struct lmb_property { phys_addr_t base; diff --git a/include/memblk.h b/include/memblk.h new file mode 100644 index 0000000000..bba5de000e --- /dev/null +++ b/include/memblk.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2019 Rockchip Electronics Co., Ltd + */ + +#ifndef _MEMBLK_H +#define _MEMBLK_H + +enum memblk_id { + MEMBLK_ID_UNK, + + /* Preloader */ + MEMBLK_ID_ATF, + MEMBLK_ID_OPTEE, + MEMBLK_ID_SHM, + + /* U-Boot self */ + MEMBLK_ID_UBOOT, + MEMBLK_ID_STACK, + MEMBLK_ID_FASTBOOT, + + /* Image */ + MEMBLK_ID_RAMDISK, + MEMBLK_ID_FDT, + MEMBLK_ID_FDT_DTBO, + MEMBLK_ID_FDT_AOSP, + MEMBLK_ID_KERNEL, + MEMBLK_ID_ANDROID, + + /* Other */ + MEMBLK_ID_BY_NAME, + MEMBLK_ID_FDT_RESV, + MEMBLK_ID_DEMO, + MEMBLK_ID_MAX, +}; + +struct memblk_attr { + const char *name; + const char *alias[2]; + u32 flags; +}; + +struct memblock { + phys_addr_t base; + phys_size_t size; + struct memblk_attr attr; + struct list_head node; +}; + +extern const struct memblk_attr *mem_attr; + +#define SIZE_MB(len) ((len) >> 20) +#define SIZE_KB(len) (((len) % (1 << 20)) >> 10) + +#define M_ATTR_NONE 0 +/* Over-Flow-Check for region tail */ +#define M_ATTR_OFC (1 << 0) +/* Over-Flow-Check for region Head, only for U-Boot stack */ +#define M_ATTR_HOFC (1 << 1) +/* Memory can be overlap by fdt reserved memory */ +#define M_ATTR_OVERLAP (1 << 2) + +#endif /* _MEMBLK_H */ diff --git a/include/optee_include/OpteeClientInterface.h b/include/optee_include/OpteeClientInterface.h index c2e6f90c8f..b99229ee90 100644 --- a/include/optee_include/OpteeClientInterface.h +++ b/include/optee_include/OpteeClientInterface.h @@ -14,7 +14,7 @@ #define ATTEST_UUID_SIZE (ATAP_HEX_UUID_LEN+1) #define ATTEST_CA_OUT_SIZE 256 -void test_optee(void); +uint32_t test_optee(void); uint32_t trusty_read_rollback_index(uint32_t slot, uint64_t *value); uint32_t trusty_write_rollback_index(uint32_t slot, uint64_t value); uint32_t trusty_read_permanent_attributes(uint8_t *attributes, uint32_t size); diff --git a/include/optee_include/OpteeClientMem.h b/include/optee_include/OpteeClientMem.h index ba85f829c3..1b9affbf36 100644 --- a/include/optee_include/OpteeClientMem.h +++ b/include/optee_include/OpteeClientMem.h @@ -9,7 +9,7 @@ #include <linux/types.h> -void OpteeClientMemInit(void); +int OpteeClientMemInit(void); void *OpteeClientMemAlloc(uint32_t length); diff --git a/include/optee_include/OpteeClientRkFs-v2.h b/include/optee_include/OpteeClientRkFs-v2.h index a8ee4d6c5b..57138a07dd 100644 --- a/include/optee_include/OpteeClientRkFs-v2.h +++ b/include/optee_include/OpteeClientRkFs-v2.h @@ -70,6 +70,7 @@ int tee_supp_rk_fs_init(void); int tee_supp_rk_fs_process(size_t num_params, struct tee_ioctl_param *params); -void OpteeClientRkFsInit(void); +int OpteeClientRkFsInit(void); +int check_security_exist(int print_flag); #endif diff --git a/include/optee_include/OpteeClientRkFs.h b/include/optee_include/OpteeClientRkFs.h index d7f68bc277..d70c118c75 100644 --- a/include/optee_include/OpteeClientRkFs.h +++ b/include/optee_include/OpteeClientRkFs.h @@ -33,6 +33,8 @@ int tee_supp_rk_fs_init(void); int tee_supp_rk_fs_process(void *cmd, uint32_t cmd_size); -void OpteeClientRkFsInit(void); +int OpteeClientRkFsInit(void); + +int check_security_exist(int print_flag); #endif diff --git a/include/power/rk8xx_pmic.h b/include/power/rk8xx_pmic.h index daeebb9665..80bf923732 100644 --- a/include/power/rk8xx_pmic.h +++ b/include/power/rk8xx_pmic.h @@ -211,6 +211,7 @@ enum { #define RK8XX_ON_SOURCE 0xae #define RK8XX_OFF_SOURCE 0xaf +#define RK817_BUCK4_CMIN 0xc6 #define RK817_ON_SOURCE 0xf5 #define RK817_OFF_SOURCE 0xf6 diff --git a/include/rk_timer_irq.h b/include/rk_timer_irq.h index 46133016b3..6de549e281 100644 --- a/include/rk_timer_irq.h +++ b/include/rk_timer_irq.h @@ -36,8 +36,13 @@ #define TIMER_BASE (0xFF1C0000 + 0x20) /* TIMER 1 */ #define TIMER_IRQ IRQ_TIMER1 #elif defined(CONFIG_ROCKCHIP_RK3368) -#define TIMER_BASE (0xFF810000 + 0x20) /* TIMER 1 */ -#define TIMER_IRQ IRQ_TIMER1 +/* + * Use timer0 and never change, because timer0 will be used in charge animation + * driver to support auto wakeup when system suspend. If core poweroff, PMU only + * support timer0(not all timer) as wakeup source. + */ +#define TIMER_BASE (0xFF810000 + 0x00) /* TIMER 0 */ +#define TIMER_IRQ IRQ_TIMER0 #elif defined(CONFIG_ROCKCHIP_RK3399) #define TIMER_BASE (0xFF850000 + 0x20) /* TIMER 1 */ #define TIMER_IRQ IRQ_TIMER1 diff --git a/include/sysmem.h b/include/sysmem.h index 58de824968..0a5d807f82 100644 --- a/include/sysmem.h +++ b/include/sysmem.h @@ -6,12 +6,7 @@ #ifndef _SYSMEM_H #define _SYSMEM_H -#include <asm/types.h> - -#define MAX_SYSMEM_REGIONS 64 - -#undef MAX_LMB_REGIONS -#define MAX_LMB_REGIONS MAX_SYSMEM_REGIONS +#include <memblk.h> /* * CONFIG_SYS_FDT_PAD default value is sync with bootm framework in: @@ -21,96 +16,84 @@ #define CONFIG_SYS_FDT_PAD 0x3000 #endif -struct sysmem_property { - const char *name; - phys_addr_t base; - phys_size_t size; - struct list_head node; -}; - struct sysmem { struct lmb lmb; struct list_head allocated_head; - struct list_head reserved_head; ulong allocated_cnt; - bool has_init; + bool has_initf; + bool has_initr; }; +#ifdef CONFIG_SYSMEM /** - * sysmem_init() - Sysmem initialization + * sysmem_has_init() - Is sysmem initialized * - * @return 0 on success, otherwise error + * @return true or false */ -int sysmem_init(void); +bool sysmem_has_init(void); /** - * sysmem_add() - Add sysmem region - * - * @base: region base address - * @size: region size + * sysmem_init() - Sysmem initialization * * @return 0 on success, otherwise error */ -int sysmem_add(phys_addr_t base, phys_size_t size); +int sysmem_init(void); /** - * sysmem_reserve() - Reserve sysmem region - * - * @name: region name - * @base: region base address - * @size: region size + * sysmem_initr() - Sysmem initialization after relocation * * @return 0 on success, otherwise error */ -int sysmem_reserve(const char *name, phys_addr_t base, phys_size_t size); +int sysmem_initr(void); /** * sysmem_alloc() - Alloc sysmem region at anywhere * - * @name: region name + * @id: memblk id * @size: region size * * @return NULL on error, otherwise the allocated region address ptr */ -void *sysmem_alloc(const char *name, phys_size_t size); +void *sysmem_alloc(enum memblk_id id, phys_size_t size); /** - * sysmem_alloc_align() - Alloc sysmem region at anywhere with addr align down + * sysmem_alloc_base() - Alloc sysmem region at the expect addr * - * @name: region name + * @id: memblk id + * @base: region base * @size: region size - * @align: region base address align (down) * * @return NULL on error, otherwise the allocated region address ptr */ -void *sysmem_alloc_align(const char *name, phys_size_t size, ulong align); +void *sysmem_alloc_base(enum memblk_id id, phys_addr_t base, phys_size_t size); /** - * sysmem_alloc_base() - Alloc sysmem region at the expect addr + * sysmem_alloc_base_by_name() - Alloc sysmem region at the expect addr by name * - * @name: region name + * @name: memblk name * @base: region base * @size: region size * * @return NULL on error, otherwise the allocated region address ptr */ -void *sysmem_alloc_base(const char *name, phys_addr_t base, phys_size_t size); +void *sysmem_alloc_base_by_name(const char *name, + phys_addr_t base, phys_size_t size); /** - * sysmem_alloc_align_base() - Alloc sysmem region at the expect addr with align down + * sysmem_fdt_reserve_alloc_base() - Alloc sysmem region at the expect addr by name, + * called only for reserve memory from fdt. * - * @name: region name + * @name: memblk name * @base: region base * @size: region size - * @align: region base address align (down) * * @return NULL on error, otherwise the allocated region address ptr */ -void *sysmem_alloc_align_base(const char *name, phys_addr_t base, - phys_size_t size, ulong align); +void *sysmem_fdt_reserve_alloc_base(const char *name, + phys_addr_t base, phys_size_t size); /** - * sysmem_free() - Free sysmem region + * sysmem_free() - Free allocated sysmem region * * @base: region base * @@ -119,23 +102,11 @@ void *sysmem_alloc_align_base(const char *name, phys_addr_t base, int sysmem_free(phys_addr_t base); /** - * sysmem_check() - Check sysmem regions - * - * @return 0 on okay, otherwise something wrong - */ -int sysmem_check(void); - -/** - * sysmem_dump_all() - Dump all sysmem stat + * sysmem_dump() - Dump all sysmem region state and check overflow */ void sysmem_dump(void); /** - * sysmem_dump_check() - Dump all sysmem stat and check overflow - */ -int sysmem_dump_check(void); - -/** * board_sysmem_reserve() - Weak function for board to implement * * @sysmem: global sysmem point, ignored @@ -143,14 +114,29 @@ int sysmem_dump_check(void); * @return 0 on success, otherwise error */ int board_sysmem_reserve(struct sysmem *sysmem); - -/** - * arch_sysmem_reserve() - Weak function for arch to implement - * - * @sysmem: global sysmem point, ignored - * - * @return 0 on success, otherwise error - */ -int arch_sysmem_reserve(struct sysmem *sysmem); - +#else +static inline bool sysmem_has_init(void) { return false; } +static inline int sysmem_init(void) { return 0; } +static inline int sysmem_initr(void) { return 0; } +static inline int sysmem_free(phys_addr_t base) { return 0; } +static inline void sysmem_dump(void) {} +__weak int board_sysmem_reserve(struct sysmem *sysmem) { return 0; } +static inline void *sysmem_alloc_base(enum memblk_id id, + phys_addr_t base, phys_size_t size) +{ + return (void *)base; +} +static inline void *sysmem_alloc_base_by_name(const char *name, + phys_addr_t base, + phys_size_t size) +{ + return (void *)base; +} +static inline void *sysmem_fdt_reserve_alloc_base(const char *name, + phys_addr_t base, + phys_size_t size) +{ + return (void *)base; +} +#endif /* CONFIG_SYSMEM */ #endif /* _SYSMEM_H */ |