From 90a9901764d71308192c96ecd7d735531fe9cc30 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Nov 2020 14:15:35 -0700 Subject: test: Add some tests for setexpr This command currently has no tests. Add some for basic assignment and the integer operations. Note that the default size for setexpr is ulong, which varies depending on the build machine. So for sandbox on a 64-bit host, this means that the default size is 64 bits. Signed-off-by: Simon Glass --- include/test/suites.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index ab7b3bd9cad..5c97846e7f5 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -38,6 +38,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_time(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, -- cgit v1.2.3 From 7526deec7e52da92dee25aaf3a47514e639c2bb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Nov 2020 14:15:36 -0700 Subject: command: Add constants for cmd_get_data_size string / error At present these values are open-coded in a few places. Add constants so the meaning is clear. Also add a comment to cmd_get_data_size() Signed-off-by: Simon Glass --- include/command.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/command.h b/include/command.h index b9b5ec1afa0..e900f97df33 100644 --- a/include/command.h +++ b/include/command.h @@ -117,7 +117,31 @@ int cmd_process_error(struct cmd_tbl *cmdtp, int err); defined(CONFIG_CMD_PCI) || \ defined(CONFIG_CMD_SETEXPR) #define CMD_DATA_SIZE -extern int cmd_get_data_size(char* arg, int default_size); +#define CMD_DATA_SIZE_ERR (-1) +#define CMD_DATA_SIZE_STR (-2) + +/** + * cmd_get_data_size() - Get the data-size specifier from a command + * + * This reads a '.x' size specifier appended to a command. For example 'md.b' + * is the 'md' command with a '.b' specifier, meaning that the command should + * use bytes. + * + * Valid characters are: + * + * b - byte + * w - word (16 bits) + * l - long (32 bits) + * q - quad (64 bits) + * s - string + * + * @arg: Pointers to the command to check. If a valid specifier is present it + * will be the last character of the string, following a '.' + * @default_size: Default size to return if there is no specifier + * @return data size in bytes (1, 2, 4, 8) or CMD_DATA_SIZE_ERR for an invalid + * character, or CMD_DATA_SIZE_STR for a string + */ +int cmd_get_data_size(char *arg, int default_size); #endif #ifdef CONFIG_CMD_BOOTD -- cgit v1.2.3 From d422c77ae8e0cb1211b34eb4af442600b0da8d5b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Nov 2020 14:15:40 -0700 Subject: setexpr: Add some tests for buffer overflow and backref Add tests to check for buffer overflow using simple replacement as well as back references. At present these don't fully pass. Signed-off-by: Simon Glass --- include/command.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/command.h b/include/command.h index e900f97df33..e229bf2825c 100644 --- a/include/command.h +++ b/include/command.h @@ -183,6 +183,23 @@ extern int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif +/** + * setexpr_regex_sub() - Replace a regex pattern with a string + * + * @data: Buffer containing the string to update + * @data_size: Size of buffer (must be large enough for the new string) + * @nbuf: Back-reference buffer + * @nbuf_size: Size of back-reference buffer (must be larger enough for @s plus + * all back-reference expansions) + * @r: Regular expression to find + * @s: String to replace with + * @global: true to replace all matches in @data, false to replace just the + * first + * @return 0 if OK, 1 on error + */ +int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size, + const char *r, const char *s, bool global); + /* * Error codes that commands return to cmd_process(). We use the standard 0 * and 1 for success and failure, but add one more case - failure with a -- cgit v1.2.3 From 310f285e788dbc77fe804261ff5d016cd56ad523 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 26 Oct 2020 09:31:41 +0100 Subject: hush: Remove default CONFIG_SYS_PROMPT_HUSH_PS2 setting from board files There is no reason to define default option for this macro which is already done in common/cli_hush.c. 87 #ifndef CONFIG_SYS_PROMPT_HUSH_PS2 88 #define CONFIG_SYS_PROMPT_HUSH_PS2 "> " 89 #endif Signed-off-by: Patrick Delaunay Acked-by: Oleksandr Andrushchenko --- include/configs/apalis-imx8.h | 1 - include/configs/colibri-imx8x.h | 1 - include/configs/imx8mm_beacon.h | 1 - include/configs/imx8mm_evk.h | 1 - include/configs/imx8mn_evk.h | 1 - include/configs/imx8mp_evk.h | 1 - include/configs/imx8mq_evk.h | 1 - include/configs/imx8mq_phanbell.h | 1 - include/configs/s5p4418_nanopi2.h | 4 ---- include/configs/verdin-imx8mm.h | 1 - include/configs/xenguest_arm64.h | 1 - 11 files changed, 14 deletions(-) (limited to 'include') diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h index db4e9011c0b..b474b2f5226 100644 --- a/include/configs/apalis-imx8.h +++ b/include/configs/apalis-imx8.h @@ -98,7 +98,6 @@ #define PHYS_SDRAM_2_SIZE SZ_2G /* 2 GB */ /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h index 29a37ed44fd..fc2c1915942 100644 --- a/include/configs/colibri-imx8x.h +++ b/include/configs/colibri-imx8x.h @@ -132,7 +132,6 @@ #define PHYS_SDRAM_2_SIZE 0x00000000 /* 0 GB */ /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mm_beacon.h b/include/configs/imx8mm_beacon.h index 3c9541187f8..9a93dba1c59 100644 --- a/include/configs/imx8mm_beacon.h +++ b/include/configs/imx8mm_beacon.h @@ -119,7 +119,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h index 83521ad401d..92eb85553e5 100644 --- a/include/configs/imx8mm_evk.h +++ b/include/configs/imx8mm_evk.h @@ -120,7 +120,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h index a6333085fe2..cda8fc2ef76 100644 --- a/include/configs/imx8mn_evk.h +++ b/include/configs/imx8mn_evk.h @@ -124,7 +124,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h index 8253c6aa2f3..92091dfd6ba 100644 --- a/include/configs/imx8mp_evk.h +++ b/include/configs/imx8mp_evk.h @@ -135,7 +135,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mq_evk.h b/include/configs/imx8mq_evk.h index 3f9a3bc100b..96bfff749cf 100644 --- a/include/configs/imx8mq_evk.h +++ b/include/configs/imx8mq_evk.h @@ -175,7 +175,6 @@ /* Monitor Command Prompt */ #undef CONFIG_SYS_PROMPT #define CONFIG_SYS_PROMPT "u-boot=> " -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mq_phanbell.h b/include/configs/imx8mq_phanbell.h index e8b65a4ba5c..66c2c3a8d87 100644 --- a/include/configs/imx8mq_phanbell.h +++ b/include/configs/imx8mq_phanbell.h @@ -169,7 +169,6 @@ #define CONFIG_MXC_UART_BASE UART1_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/s5p4418_nanopi2.h b/include/configs/s5p4418_nanopi2.h index 6dd1f3bc049..1e2180b970d 100644 --- a/include/configs/s5p4418_nanopi2.h +++ b/include/configs/s5p4418_nanopi2.h @@ -102,10 +102,6 @@ /* Boot Argument Buffer Size */ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE -#ifdef CONFIG_HUSH_PARSER -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " -#endif - /*----------------------------------------------------------------------- * Etc Command definition */ diff --git a/include/configs/verdin-imx8mm.h b/include/configs/verdin-imx8mm.h index fd8405433dd..4751bf5a5af 100644 --- a/include/configs/verdin-imx8mm.h +++ b/include/configs/verdin-imx8mm.h @@ -98,7 +98,6 @@ #define CONFIG_MXC_UART_BASE UART1_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/xenguest_arm64.h b/include/configs/xenguest_arm64.h index c44381e966c..d76ce13d14e 100644 --- a/include/configs/xenguest_arm64.h +++ b/include/configs/xenguest_arm64.h @@ -27,7 +27,6 @@ #define CONFIG_SYS_MALLOC_LEN (32 * 1024 * 1024) /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE -- cgit v1.2.3 From 7292a18256252e41970eceacd5ccd3ed79ea64f0 Mon Sep 17 00:00:00 2001 From: Holger Brunck Date: Fri, 30 Oct 2020 12:45:49 +0100 Subject: km/arm: coding style clean up Address most of the checkpatch issues we found in km_arm and common km code. CC: Stefan Roese CC: Valentin Longchamp Signed-off-by: Holger Brunck Reviewed-by: Stefan Roese --- include/configs/km/keymile-common.h | 4 ++-- include/configs/km/km_arm.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index 851b13e063d..e0848625181 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -184,9 +184,9 @@ "cramfsloadfdt=" \ "cramfsload ${fdt_addr_r} " \ "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb\0" \ - "fdt_addr_r="__stringify(CONFIG_KM_FDT_ADDR) "\0" \ + "fdt_addr_r=" __stringify(CONFIG_KM_FDT_ADDR) "\0" \ "init=/sbin/init-overlay.sh\0" \ - "load_addr_r="__stringify(CONFIG_KM_KERNEL_ADDR) "\0" \ + "load_addr_r=" __stringify(CONFIG_KM_KERNEL_ADDR) "\0" \ "load=tftpboot ${load_addr_r} ${u-boot}\0" \ "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \ "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \ diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 98e0ce1c240..29060fa96b3 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -48,7 +48,7 @@ " boardid=0x${IVM_BoardId} hwkey=0x${IVM_HWKey}" #define CONFIG_KM_DEF_ENV_CPU \ - "u-boot="CONFIG_HOSTNAME "/u-boot.kwb\0" \ + "u-boot=" CONFIG_HOSTNAME "/u-boot.kwb\0" \ CONFIG_KM_UPDATE_UBOOT \ "set_fdthigh=setenv fdt_high ${kernelmem}\0" \ "checkfdt=" \ -- cgit v1.2.3 From e926136bb29cb9dda00f1b8960db963b6e97124b Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 26 Nov 2020 23:07:22 +0200 Subject: tpm: use more than sha256 on pcr_extend The current tpm2_pcr_extend is hardcoded using SHA256. Let's make the actual command to the TPM2 configurable so we can support a wider range of algorithms and keep the current command line as-is i.e limited to SHA256 only Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- include/tpm-v2.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/tpm-v2.h b/include/tpm-v2.h index 74c14fe7c51..f1826ff3858 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -309,11 +309,14 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw, * * @dev TPM device * @index Index of the PCR + * @algorithm Algorithm used, defined in 'enum tpm2_algorithms' * @digest Value representing the event to be recorded + * @digest_len len of the hash * * @return code of the operation */ -u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest); +u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, + const u8 *digest, u32 digest_len); /** * Issue a TPM2_PCR_Read command. -- cgit v1.2.3 From 8e0b0871b82db0511440208b101ecf488858e915 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Mon, 30 Nov 2020 11:47:39 +0200 Subject: tpm: Add tpm2 headers for TCG2 eventlog support A following patch introduces support for the EFI_TCG2_PROTOCOL eventlog management. Introduce the necessary tpm related headers Signed-off-by: Ilias Apalodimas --- include/tpm-v2.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'include') diff --git a/include/tpm-v2.h b/include/tpm-v2.h index f1826ff3858..fab6b86ca2f 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -18,6 +18,12 @@ #define TPM2_DIGEST_LEN 32 +#define TPM2_SHA1_DIGEST_SIZE 20 +#define TPM2_SHA256_DIGEST_SIZE 32 +#define TPM2_SHA384_DIGEST_SIZE 48 +#define TPM2_SHA512_DIGEST_SIZE 64 +#define TPM2_SM3_256_DIGEST_SIZE 32 + #define TPM2_MAX_PCRS 32 #define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8) #define TPM2_MAX_CAP_BUFFER 1024 @@ -45,6 +51,15 @@ #define TPM2_PT_MAX_COMMAND_SIZE (u32)(TPM2_PT_FIXED + 30) #define TPM2_PT_MAX_RESPONSE_SIZE (u32)(TPM2_PT_FIXED + 31) +/* event types */ +#define EV_POST_CODE ((u32)0x00000001) +#define EV_NO_ACTION ((u32)0x00000003) +#define EV_SEPARATOR ((u32)0x00000004) +#define EV_S_CRTM_CONTENTS ((u32)0x00000007) +#define EV_S_CRTM_VERSION ((u32)0x00000008) +#define EV_CPU_MICROCODE ((u32)0x00000009) +#define EV_TABLE_OF_DEVICES ((u32)0x0000000B) + /* TPMS_TAGGED_PROPERTY Structure */ struct tpms_tagged_property { u32 property; @@ -86,6 +101,73 @@ struct tpms_capability_data { union tpmu_capabilities data; } __packed; +/** + * SHA1 Event Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event (see EFI specs) + * @digest: Value extended into PCR index + * @event_size: Size of event + * @event: Event data + */ +struct tcg_pcr_event { + u32 pcr_index; + u32 event_type; + u8 digest[TPM2_SHA1_DIGEST_SIZE]; + u32 event_size; + u8 event[]; +} __packed; + +/** + * Definition of TPMU_HA Union + */ +union tmpu_ha { + u8 sha1[TPM2_SHA1_DIGEST_SIZE]; + u8 sha256[TPM2_SHA256_DIGEST_SIZE]; + u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE]; + u8 sha384[TPM2_SHA384_DIGEST_SIZE]; + u8 sha512[TPM2_SHA512_DIGEST_SIZE]; +} __packed; + +/** + * Definition of TPMT_HA Structure + * + * @hash_alg: Hash algorithm defined in enum tpm2_algorithms + * @digest: Digest value for a given algorithm + */ +struct tpmt_ha { + u16 hash_alg; + union tmpu_ha digest; +} __packed; + +/** + * Definition of TPML_DIGEST_VALUES Structure + * + * @count: Number of algorithms supported by hardware + * @digests: struct for algorithm id and hash value + */ +struct tpml_digest_values { + u32 count; + struct tpmt_ha digests[TPM2_NUM_PCR_BANKS]; +} __packed; + +/** + * Crypto Agile Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event + * @digests: List of digestsextended to PCR index + * @event_size: Size of the event data + * @event: Event data + */ +struct tcg_pcr_event2 { + u32 pcr_index; + u32 event_type; + struct tpml_digest_values digests; + u32 event_size; + u8 event[]; +} __packed; + /** * TPM2 Structure Tags for command/response buffers. * -- cgit v1.2.3 From c8d0fd582576ff7cc67d0053282430476201fd33 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Mon, 30 Nov 2020 11:47:40 +0200 Subject: efi_loader: Introduce eventlog support for TCG2_PROTOCOL In the previous patches we only introduced a minimal subset of the EFI_TCG2_PROTOCOL protocol implementing GetCapability(). So let's continue adding features to it, introducing the GetEventLog() and HashLogExtendEvent() functions. In order to do that we first need to construct the eventlog in memory, specifically in EFI_BOOT_SERVICES_DATA memory and a configuration table from EFI_ACPI_MEMORY_NVS. U-Boot won't currently add any events to the log or measure any components, but will expose the necessary EFI APIs for applications to do so. Signed-off-by: Ilias Apalodimas --- include/efi_api.h | 4 +++ include/efi_tcg2.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 5744f6aed86..364c578a3b1 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -356,6 +356,10 @@ struct efi_runtime_services { EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \ 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d) +#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \ + EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \ + 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) + struct efi_configuration_table { efi_guid_t guid; void *table; diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h index 86b8fe4c01a..40e241ce315 100644 --- a/include/efi_tcg2.h +++ b/include/efi_tcg2.h @@ -17,6 +17,8 @@ /* TPMV2 only */ #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 +#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001 +#define PE_COFF_IMAGE 0x0000000000000010 /* Algorithm Registry */ #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001 @@ -25,6 +27,10 @@ #define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010 +#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1 + +#define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE + typedef u32 efi_tcg_event_log_bitmap; typedef u32 efi_tcg_event_log_format; typedef u32 efi_tcg_event_algorithm_bitmap; @@ -65,6 +71,68 @@ struct efi_tcg2_boot_service_capability { sizeof(struct efi_tcg2_boot_service_capability) - \ offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks) +#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03" +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2 +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0 +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2 + +/** + * struct TCG_EfiSpecIdEventAlgorithmSize + * + * @algorithm_id: algorithm defined in enum tpm2_algorithms + * @digest_size: size of the algorithm + */ +struct tcg_efi_spec_id_event_algorithm_size { + u16 algorithm_id; + u16 digest_size; +} __packed; + +/** + * struct TCG_EfiSpecIDEventStruct + * + * @signature: signature, set to Spec ID Event03 + * @platform_class: class defined in TCG ACPI Specification + * Client Common Header. + * @spec_version_minor: minor version + * @spec_version_major: major version + * @spec_version_errata: major version + * @uintn_size: size of the efi_uintn_t fields used in various + * data structures used in this specification. + * 0x01 indicates u32 and 0x02 indicates u64 + * @number_of_algorithms: hashing algorithms used in this event log + * @digest_sizes: array of number_of_algorithms pairs + * 1st member defines the algorithm id + * 2nd member defines the algorithm size + * @vendor_info_size: size in bytes for vendor specific info + * @vendor_info: vendor specific info + */ +struct tcg_efi_spec_id_event { + u8 signature[16]; + u32 platform_class; + u8 spec_version_minor; + u8 spec_version_major; + u8 spec_errata; + u8 uintn_size; + u32 number_of_algorithms; + struct tcg_efi_spec_id_event_algorithm_size digest_sizes[TPM2_NUM_PCR_BANKS]; + u8 vendor_info_size; + /* U-Boot does not provide any vendor info */ + u8 vendor_info[]; +} __packed; + +/** + * struct tdEFI_TCG2_FINAL_EVENTS_TABLE + * @version: version number for this structure + * @number_of_events: number of events recorded after invocation of + * GetEventLog() + * @event: List of events of type tcg_pcr_event2 + */ +struct efi_tcg2_final_events_table { + u64 version; + u64 number_of_events; + struct tcg_pcr_event2 event[]; +}; + struct efi_tcg2_protocol { efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this, struct efi_tcg2_boot_service_capability *capability); @@ -73,7 +141,8 @@ struct efi_tcg2_protocol { u64 *event_log_location, u64 *event_log_last_entry, bool *event_log_truncated); efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this, - u64 flags, u64 data_to_hash, + u64 flags, + efi_physical_addr_t data_to_hash, u64 data_to_hash_len, struct efi_tcg2_event *efi_tcg_event); efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this, -- cgit v1.2.3 From 2bc27ca8a04aea89c82b5fc4412e889d1ac9f756 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 17 Nov 2020 09:27:55 +0900 Subject: efi_loader: define UpdateCapsule api In this commit, skeleton functions for capsule-related API's are added under CONFIG_EFI_UPDATE_CAPSULE configuration. Detailed implementation for a specific capsule type will be added in the succeeding patches. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 12 ++++++++++++ include/efi_loader.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 364c578a3b1..a466e2c9e61 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -217,6 +217,10 @@ enum efi_reset_type { #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 +#define EFI_CAPSULE_REPORT_GUID \ + EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \ + 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3) + struct efi_capsule_header { efi_guid_t capsule_guid; u32 header_size; @@ -224,6 +228,14 @@ struct efi_capsule_header { u32 capsule_image_size; } __packed; +struct efi_capsule_result_variable_header { + u32 variable_total_size; + u32 reserved; + efi_guid_t capsule_guid; + struct efi_time capsule_processed; + efi_status_t capsule_status; +} __packed; + #define EFI_RT_SUPPORTED_GET_TIME 0x0001 #define EFI_RT_SUPPORTED_SET_TIME 0x0002 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 diff --git a/include/efi_loader.h b/include/efi_loader.h index 3c68b85b68e..abd6856b3d5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -210,6 +210,8 @@ extern const efi_guid_t efi_guid_cert_type_pkcs7; /* GUID of RNG protocol */ extern const efi_guid_t efi_guid_rng_protocol; +/* GUID of capsule update result */ +extern const efi_guid_t efi_guid_capsule_report; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; @@ -812,6 +814,17 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t n); /* commonly used helper function */ u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index); +/* Capsule update */ +efi_status_t EFIAPI efi_update_capsule( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 scatter_gather_list); +efi_status_t EFIAPI efi_query_capsule_caps( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 *maximum_capsule_size, + u32 *reset_type); + #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ -- cgit v1.2.3 From c74cd8bd08d1bbff366a1bfb0cc82a2413fdf106 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 17 Nov 2020 09:27:56 +0900 Subject: efi_loader: capsule: add capsule_on_disk support Capsule data can be loaded into the system either via UpdateCapsule runtime service or files on a file system (of boot device). The latter case is called "capsules on disk", and actual updates will take place at the next boot time. In this commit, we will support capsule on disk mechanism. Please note that U-Boot itself has no notion of "boot device" and all the capsule files to be executed will be detected only if they are located in a specific directory, \EFI\UpdateCapsule, on a device that is identified as a boot device by "BootXXXX" variables. Signed-off-by: AKASHI Takahiro --- include/efi_loader.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index abd6856b3d5..de1d24b3334 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -825,6 +825,11 @@ efi_status_t EFIAPI efi_query_capsule_caps( u64 *maximum_capsule_size, u32 *reset_type); +#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" + +/* Hook at initialization */ +efi_status_t efi_launch_capsules(void); + #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ @@ -841,6 +846,10 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { } static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } static inline void efi_print_image_infos(void *pc) { } +static inline efi_status_t efi_launch_capsules(void) +{ + return EFI_SUCCESS; +} #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ -- cgit v1.2.3 From ed9349c697711bd2d1b69b0877bc3d96fc664a37 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 17 Nov 2020 09:27:57 +0900 Subject: efi_loader: capsule: add memory range capsule definitions Memory range capsule gives us a way to notify that some memory regions should be left untouched across the next reset. See UEFI specification, section 8.5.3. Since how we should handle this kind of capsule is totally up to the system, no implementation will be added in this commit. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index a466e2c9e61..fadf40e8ff3 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -221,6 +221,10 @@ enum efi_reset_type { EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \ 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3) +#define EFI_MEMORY_RANGE_CAPSULE_GUID \ + EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \ + 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72) + struct efi_capsule_header { efi_guid_t capsule_guid; u32 header_size; @@ -236,6 +240,19 @@ struct efi_capsule_result_variable_header { efi_status_t capsule_status; } __packed; +struct efi_memory_range { + efi_physical_addr_t address; + u64 length; +}; + +struct efi_memory_range_capsule { + struct efi_capsule_header *header; + /* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */ + enum efi_mem_type os_requested_memory_type; + u64 number_of_memory_ranges; + struct efi_memory_range memory_ranges[]; +} __packed; + #define EFI_RT_SUPPORTED_GET_TIME 0x0001 #define EFI_RT_SUPPORTED_SET_TIME 0x0002 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 -- cgit v1.2.3 From 8d99026f06978ddf2ed72ccaed6cd3ad0887e4e5 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Mon, 30 Nov 2020 18:12:11 +0900 Subject: efi_loader: capsule: support firmware update A capsule tagged with the guid, EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID, is handled as a firmware update object. What efi_update_capsule() basically does is to load any firmware management protocol (or fmp) drivers contained in a capsule, find out an appropriate fmp driver and then invoke its set_image() interface against each binary in a capsule. In this commit, however, loading drivers is not supported. The result of applying a capsule is set to be stored in "CapsuleXXXX" variable, but its implementation is deferred to a fmp driver. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/efi_loader.h | 2 + 2 files changed, 131 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index fadf40e8ff3..5d2f7bbbe32 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -217,6 +217,9 @@ enum efi_reset_type { #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 +#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001 +#define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002 + #define EFI_CAPSULE_REPORT_GUID \ EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \ 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3) @@ -225,6 +228,10 @@ enum efi_reset_type { EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \ 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72) +#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \ + EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ + 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a) + struct efi_capsule_header { efi_guid_t capsule_guid; u32 header_size; @@ -253,6 +260,33 @@ struct efi_memory_range_capsule { struct efi_memory_range memory_ranges[]; } __packed; +struct efi_firmware_management_capsule_header { + u32 version; + u16 embedded_driver_count; + u16 payload_item_count; + u64 item_offset_list[]; +} __packed; + +struct efi_firmware_management_capsule_image_header { + u32 version; + efi_guid_t update_image_type_id; + u8 update_image_index; + u8 reserved[3]; + u32 update_image_size; + u32 update_vendor_code_size; + u64 update_hardware_instance; + u64 image_capsule_support; +} __packed; + +struct efi_capsule_result_variable_fmp { + u16 version; + u8 payload_index; + u8 update_image_index; + efi_guid_t update_image_type_id; + // u16 capsule_file_name[]; + // u16 capsule_target[]; +} __packed; + #define EFI_RT_SUPPORTED_GET_TIME 0x0001 #define EFI_RT_SUPPORTED_SET_TIME 0x0002 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 @@ -1812,4 +1846,99 @@ struct efi_signature_list { /* struct efi_signature_data signatures[...][signature_size]; */ } __attribute__((__packed__)); +/* + * Firmware management protocol + */ +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \ + EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ + 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7) + +#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 +#define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 +#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 +#define IMAGE_ATTRIBUTE_IN_USE 0x0000000000000008 +#define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0000000000000010 +#define IMAGE_ATTRIBUTE_DEPENDENCY 0x0000000000000020 + +#define IMAGE_COMPATIBILITY_CHECK_SUPPORTED 0x0000000000000001 + +#define IMAGE_UPDATABLE_VALID 0x0000000000000001 +#define IMAGE_UPDATABLE_INVALID 0x0000000000000002 +#define IMAGE_UPDATABLE_INVALID_TYPE 0x0000000000000004 +#define IMAGE_UPDATABLE_INVALID_OLLD 0x0000000000000008 +#define IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE 0x0000000000000010 + +#define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE 0x0000000000000001 +#define PACKAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 +#define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 + +#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 4 + +typedef struct efi_firmware_image_dependencies { + u8 dependencies[0]; +} efi_firmware_image_dep_t; + +struct efi_firmware_image_descriptor { + u8 image_index; + efi_guid_t image_type_id; + u64 image_id; + u16 *image_id_name; + u32 version; + u16 *version_name; + efi_uintn_t size; + u64 attributes_supported; + u64 attributes_setting; + u64 compatibilities; + u32 lowest_supported_image_version; + u32 last_attempt_version; + u32 last_attempt_status; + u64 hardware_instance; + efi_firmware_image_dep_t *dependencies; +}; + +struct efi_firmware_management_protocol { + efi_status_t (EFIAPI *get_image_info)( + struct efi_firmware_management_protocol *this, + efi_uintn_t *image_info_size, + struct efi_firmware_image_descriptor *image_info, + u32 *descriptor_version, + u8 *descriptor_count, + efi_uintn_t *descriptor_size, + u32 *package_version, + u16 **package_version_name); + efi_status_t (EFIAPI *get_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + void *image, + efi_uintn_t *image_size); + efi_status_t (EFIAPI *set_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t image_size, + const void *vendor_code, + efi_status_t (*progress)(efi_uintn_t completion), + u16 **abort_reason); + efi_status_t (EFIAPI *check_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t *image_size, + u32 *image_updatable); + efi_status_t (EFIAPI *get_package_info)( + struct efi_firmware_management_protocol *this, + u32 *package_version, + u16 **package_version_name, + u32 *package_version_name_maxlen, + u64 *attributes_supported, + u64 *attributes_setting); + efi_status_t (EFIAPI *set_package_info)( + struct efi_firmware_management_protocol *this, + const void *image, + efi_uintn_t *image_size, + const void *vendor_code, + u32 package_version, + const u16 *package_version_name); +}; + #endif diff --git a/include/efi_loader.h b/include/efi_loader.h index de1d24b3334..ed5a49b520d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -212,6 +212,8 @@ extern const efi_guid_t efi_guid_cert_type_pkcs7; extern const efi_guid_t efi_guid_rng_protocol; /* GUID of capsule update result */ extern const efi_guid_t efi_guid_capsule_report; +/* GUID of firmware management protocol */ +extern const efi_guid_t efi_guid_firmware_management_protocol; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; -- cgit v1.2.3 From f27c20148511b476b688bddf7c2322c98d9e0be2 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Mon, 30 Nov 2020 18:12:12 +0900 Subject: efi_loader: add firmware management protocol for FIT image In this commit, a very simple firmware management protocol driver is implemented. It will take a common FIT image firmware in a capsule file and apply the data using dfu backend storage drivers via update_fit() interface. So "dfu_alt_info" variable should be properly set to specify a device and location to be updated. Please read README.dfu. Fit image is a common file format for firmware update on U-Boot, and this protocol works neatly just as a wrapper for one. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 4 ++++ include/efi_loader.h | 2 ++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 5d2f7bbbe32..d6751f6ad2c 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1853,6 +1853,10 @@ struct efi_signature_list { EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7) +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \ + EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \ + 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47) + #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 diff --git a/include/efi_loader.h b/include/efi_loader.h index ed5a49b520d..d592a0e680c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -816,6 +816,8 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t n); /* commonly used helper function */ u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index); +extern const struct efi_firmware_management_protocol efi_fmp_fit; + /* Capsule update */ efi_status_t EFIAPI efi_update_capsule( struct efi_capsule_header **capsule_header_array, -- cgit v1.2.3 From bb7e71d33c3ebde6e6aa2c266374cb51be14505c Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 17 Nov 2020 09:28:00 +0900 Subject: efi_loader: add firmware management protocol for raw image In this commit, a very simple firmware management protocol driver is implemented. It will take a binary image in a capsule file and apply the data using dfu backend storage drivers via dfu_write_by_alt() interface. So "dfu_alt_info" variable should be properly set to specify a device and location to be updated. Please read README.dfu. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 4 ++++ include/efi_loader.h | 1 + 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index d6751f6ad2c..e82d4ca9ff4 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1857,6 +1857,10 @@ struct efi_signature_list { EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \ 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47) +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \ + EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \ + 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f) + #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 diff --git a/include/efi_loader.h b/include/efi_loader.h index d592a0e680c..76cd2b36f2b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -817,6 +817,7 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t n); u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index); extern const struct efi_firmware_management_protocol efi_fmp_fit; +extern const struct efi_firmware_management_protocol efi_fmp_raw; /* Capsule update */ efi_status_t EFIAPI efi_update_capsule( -- cgit v1.2.3 From d2cb0c8f759ddc9cbc063816454d5f0d18d7fcb1 Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Wed, 18 Nov 2020 17:45:56 +0100 Subject: spl: atf: provide a bl2_plat_get_bl31_params_default() Move the actual implementation of the bl2_plat_get_bl31_params() to its own function. The weak function will just call the default implementation. This has the advantage that board code can still call the original implementation if it just want to modify minor things. Signed-off-by: Michael Walle --- include/spl.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/spl.h b/include/spl.h index b72dfc7e3d4..fd928377f07 100644 --- a/include/spl.h +++ b/include/spl.h @@ -526,25 +526,44 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image, void spl_invoke_atf(struct spl_image_info *spl_image); /** - * bl2_plat_get_bl31_params() - prepare params for bl31. - * @bl32_entry address of BL32 executable (secure) - * @bl33_entry address of BL33 executable (non secure) - * @fdt_addr address of Flat Device Tree + * bl2_plat_get_bl31_params() - return params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree * - * This function assigns a pointer to the memory that the platform has kept - * aside to pass platform specific and trusted firmware related information - * to BL31. This memory is allocated by allocating memory to - * bl2_to_bl31_params_mem structure which is a superset of all the - * structure whose information is passed to BL31 - * NOTE: This function should be called only once and should be done - * before generating params to BL31 + * This is a weak function which might be overridden by the board code. By + * default it will just call bl2_plat_get_bl31_params_default(). * - * @return bl31 params structure pointer + * If you just want to manipulate or add some parameters, you can override + * this function, call bl2_plat_get_bl31_params_default and operate on the + * returned bl31 params. + * + * Return: bl31 params structure pointer */ struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, uintptr_t bl33_entry, uintptr_t fdt_addr); +/** + * bl2_plat_get_bl31_params_default() - prepare params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This is the default implementation of bl2_plat_get_bl31_params(). It assigns + * a pointer to the memory that the platform has kept aside to pass platform + * specific and trusted firmware related information to BL31. This memory is + * allocated by allocating memory to bl2_to_bl31_params_mem structure which is + * a superset of all the structure whose information is passed to BL31 + * + * NOTE: The memory is statically allocated, thus this function should be + * called only once. All subsequent calls will overwrite any changes. + * + * Return: bl31 params structure pointer + */ +struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); /** * spl_optee_entry - entry function for optee * -- cgit v1.2.3 From 553825c1090c9f6968e81a0d40d0a3f42202fc6b Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Wed, 18 Nov 2020 17:45:57 +0100 Subject: spl: atf: remove helper structure from common header bl2_to_bl31_params_mem is just an implementation detail of the SPL ATF support and is not needed anywhere else. Move it from the header to the actual module. Signed-off-by: Michael Walle Acked-by: Michal Simek --- include/atf_common.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'include') diff --git a/include/atf_common.h b/include/atf_common.h index fd5454c55b4..e173a10ca9d 100644 --- a/include/atf_common.h +++ b/include/atf_common.h @@ -162,20 +162,6 @@ struct bl31_params { struct atf_image_info *bl33_image_info; }; -/******************************************************************************* - * This structure represents the superset of information that is passed to - * BL31, e.g. while passing control to it from BL2, bl31_params - * and other platform specific params - ******************************************************************************/ -struct bl2_to_bl31_params_mem { - struct bl31_params bl31_params; - struct atf_image_info bl31_image_info; - struct atf_image_info bl32_image_info; - struct atf_image_info bl33_image_info; - struct entry_point_info bl33_ep_info; - struct entry_point_info bl32_ep_info; - struct entry_point_info bl31_ep_info; -}; #endif /*__ASSEMBLY__ */ -- cgit v1.2.3 From 7b866825cd354a358eff8f62207701771e0511bd Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Wed, 18 Nov 2020 17:45:58 +0100 Subject: spl: atf: add support for LOAD_IMAGE_V2 Newer platforms use the LOAD_IMAGE_V2 parameter passing method. Add support for it. Signed-off-by: Michael Walle --- include/atf_common.h | 30 ++++++++++++++++++++++++++++++ include/spl.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) (limited to 'include') diff --git a/include/atf_common.h b/include/atf_common.h index e173a10ca9d..d69892fac6c 100644 --- a/include/atf_common.h +++ b/include/atf_common.h @@ -14,8 +14,14 @@ #define ATF_PARAM_EP 0x01 #define ATF_PARAM_IMAGE_BINARY 0x02 #define ATF_PARAM_BL31 0x03 +#define ATF_PARAM_BL_PARAMS 0x05 #define ATF_VERSION_1 0x01 +#define ATF_VERSION_2 0x02 + +#define ATF_BL31_IMAGE_ID 0x03 +#define ATF_BL32_IMAGE_ID 0x04 +#define ATF_BL33_IMAGE_ID 0x05 #define ATF_EP_SECURE 0x0 #define ATF_EP_NON_SECURE 0x1 @@ -121,6 +127,9 @@ struct atf_image_info { struct param_header h; uintptr_t image_base; /* physical address of base of image */ uint32_t image_size; /* bytes read from image file */ +#if CONFIG_IS_ENABLED(ATF_LOAD_IMAGE_V2) + uint32_t image_max_size; +#endif }; /***************************************************************************** @@ -162,6 +171,27 @@ struct bl31_params { struct atf_image_info *bl33_image_info; }; +/* BL image node in the BL image execution sequence */ +struct bl_params_node { + unsigned int image_id; + struct atf_image_info *image_info; + struct entry_point_info *ep_info; + struct bl_params_node *next_params_info; +}; + +/* + * BL image head node in the BL image execution sequence + * It is also used to pass information to next BL image. + */ +struct bl_params { + struct param_header h; + struct bl_params_node *head; +}; + +#define for_each_bl_params_node(bl_params, node) \ + for ((node) = (bl_params)->head; \ + (node); \ + (node) = (node)->next_params_info) #endif /*__ASSEMBLY__ */ diff --git a/include/spl.h b/include/spl.h index fd928377f07..374a295fa36 100644 --- a/include/spl.h +++ b/include/spl.h @@ -564,6 +564,41 @@ struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry, uintptr_t bl33_entry, uintptr_t fdt_addr); + +/** + * bl2_plat_get_bl31_params_v2() - return params for bl31 + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This function does the same as bl2_plat_get_bl31_params() except that is is + * used for the new LOAD_IMAGE_V2 option, which uses a slightly different + * method to pass the parameters. + * + * Return: bl31 params structure pointer + */ +struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); + +/** + * bl2_plat_get_bl31_params_v2_default() - prepare params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This is the default implementation of bl2_plat_get_bl31_params_v2(). It + * prepares the linked list of the bl31 params, populates the image types and + * set the entry points for bl32 and bl33 (if available). + * + * NOTE: The memory is statically allocated, thus this function should be + * called only once. All subsequent calls will overwrite any changes. + * + * Return: bl31 params structure pointer + */ +struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); /** * spl_optee_entry - entry function for optee * -- cgit v1.2.3 From 96434a76fd254248ded19e95dc967d28e65a5edf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:37 -0700 Subject: env: Allow returning errors from hdelete_r() At present this function returns 1 on success and 0 on failure. But in the latter case it provides no indication of what went wrong. If an attempt is made to delete a non-existent variable, the caller may want to ignore this error. This happens when setting a non-existent variable to "", for example. Update the function to return 0 on success and a useful error code on failure. Add a function comment too. Make sure that env_set() does not return an error if it is deleting a variable that doesn't exist. We could update env_set() to return useful error numbers also, but that is beyond the scope of this change. Signed-off-by: Simon Glass wip --- include/search.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/search.h b/include/search.h index e56843c26fd..d0bb44388e1 100644 --- a/include/search.h +++ b/include/search.h @@ -80,7 +80,16 @@ int hsearch_r(struct env_entry item, enum env_action action, int hmatch_r(const char *match, int last_idx, struct env_entry **retval, struct hsearch_data *htab); -/* Search and delete entry matching "key" in internal hash table. */ +/** + * hdelete_r() - Search and delete entry in internal hash table + * + * @key: Name of entry to delete + * @htab: Hash table + * @flag: Flags to use (H_...) + * @return 0 on success, -ENOENT if not found, -EPERM if the hash table callback + * rejected changing the variable, -EINVAL if the hash table refused to + * delete the variable + */ int hdelete_r(const char *key, struct hsearch_data *htab, int flag); ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, -- cgit v1.2.3 From f158ba15ee0f9f756193b60420adfdc0a9c1eb96 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:38 -0700 Subject: bootm: Add tests for fixup_silent_linux() This function currently has no tests. Export it so that we can implement a simple test on sandbox. Use IS_ENABLED() to remove the unused code, instead #ifdef. Signed-off-by: Simon Glass --- include/bootm.h | 3 +++ include/test/suites.h | 1 + 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index a812a6bf24f..6d675e64559 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -85,4 +85,7 @@ void arch_preboot_os(void); */ void board_preboot_os(void); +/* Adjust the 'bootargs' to ensure that Linux boots silently, if required */ +void fixup_silent_linux(void); + #endif diff --git a/include/test/suites.h b/include/test/suites.h index 5c97846e7f5..52e8fc8155a 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -26,6 +26,7 @@ int cmd_ut_category(const char *name, const char *prefix, struct unit_test *tests, int n_ents, int argc, char *const argv[]); +int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, -- cgit v1.2.3 From 4ae42643d0d71dbb5af45d19fa05b7a6807150c0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:39 -0700 Subject: bootm: Update fixup_silent_linux() to return an error At present this function fails silently on error. Update it to produce an error code. Report this error to the user and abort the boot, since it likely will prevent a successful start. No tests are added at this stage, since additional refactoring is taking place in subsequent patches. Signed-off-by: Simon Glass --- include/bootm.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index 6d675e64559..438829af0fe 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -85,7 +85,14 @@ void arch_preboot_os(void); */ void board_preboot_os(void); -/* Adjust the 'bootargs' to ensure that Linux boots silently, if required */ -void fixup_silent_linux(void); +/* + * fixup_silent_linux() - Process fix-ups for the command line + * + * Updates the 'bootargs' envvar as required. This handles making Linux boot + * silently if requested ('silent_linux' envvar) + * + * @return 0 if OK, -ENOMEM if out of memory + */ +int fixup_silent_linux(void); #endif -- cgit v1.2.3 From 4dcb81545ab09b6cb4ee1f3c870fb3131984cf6f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:40 -0700 Subject: bootm: Rename fixup_silent_linux() We want to add more processing to this function. Before doing so, rename it to bootm_process_cmdline_env(), which is more generic. Signed-off-by: Simon Glass --- include/bootm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index 438829af0fe..35c27ab9609 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -86,13 +86,13 @@ void arch_preboot_os(void); void board_preboot_os(void); /* - * fixup_silent_linux() - Process fix-ups for the command line + * bootm_process_cmdline_env() - Process fix-ups for the command line * * Updates the 'bootargs' envvar as required. This handles making Linux boot * silently if requested ('silent_linux' envvar) * * @return 0 if OK, -ENOMEM if out of memory */ -int fixup_silent_linux(void); +int bootm_process_cmdline_env(void); #endif -- cgit v1.2.3 From d9477a0a4d4c4561941007a8b3db588385aaad07 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:41 -0700 Subject: bootm: Add a bool parameter to bootm_process_cmdline_env() This function will soon do more than just handle the 'silent linux' feature. As a first step, update it to take a boolean parameter, indicating whether or not the processing is required. Signed-off-by: Simon Glass --- include/bootm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index 35c27ab9609..f12ee2b3cb3 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -91,8 +91,9 @@ void board_preboot_os(void); * Updates the 'bootargs' envvar as required. This handles making Linux boot * silently if requested ('silent_linux' envvar) * + * @do_silent: Process bootargs for silent console * @return 0 if OK, -ENOMEM if out of memory */ -int bootm_process_cmdline_env(void); +int bootm_process_cmdline_env(bool do_silent); #endif -- cgit v1.2.3 From b3c01678fdb15c63b231743481b9b77c7c4f8549 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:44 -0700 Subject: bootm: Update bootm_process_cmdline_env() to use flags At present only one transformation is supported: making the Linux console silent. To prepare for adding more, convert the boolean parameter into a flag value. Signed-off-by: Simon Glass --- include/bootm.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index f12ee2b3cb3..4876d7b2882 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -75,6 +75,13 @@ void board_quiesce_devices(void); */ void switch_to_non_secure_mode(void); +/* Flags to control bootm_process_cmdline() */ +enum bootm_cmdline_t { + BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ + + BOOTM_CL_ALL = 1, /* All substitutions */ +}; + /** * arch_preboot_os() - arch specific configuration before booting */ @@ -91,9 +98,9 @@ void board_preboot_os(void); * Updates the 'bootargs' envvar as required. This handles making Linux boot * silently if requested ('silent_linux' envvar) * - * @do_silent: Process bootargs for silent console + * @flags: Flags to control what happens (see bootm_cmdline_t) * @return 0 if OK, -ENOMEM if out of memory */ -int bootm_process_cmdline_env(bool do_silent); +int bootm_process_cmdline_env(int flags); #endif -- cgit v1.2.3 From 4448fe8e4e7cc4dc5336a2d27fa6048057eaf1a6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:45 -0700 Subject: bootm: Allow updating the bootargs in a buffer At present we only support updating the 'bootargs' environment variable. Add another function to update a buffer instead. This will allow zimage to use this feature. Also add a lot more tests to cover various cases. Signed-off-by: Simon Glass --- include/bootm.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index 4876d7b2882..8d95fb2a90a 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -93,6 +93,22 @@ void arch_preboot_os(void); void board_preboot_os(void); /* + * bootm_process_cmdline() - Process fix-ups for the command line + * + * This handles: making Linux boot silently if requested ('silent_linux' envvar) + * + * @maxlen must provide enough space for the string being processed plus the + * resulting string + * + * @buf: buffer holding commandline string to adjust + * @maxlen: Maximum length of buffer at @buf (including \0) + * @flags: Flags to control what happens (see bootm_cmdline_t) + * @return 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too + * long + */ +int bootm_process_cmdline(char *buf, int maxlen, int flags); + +/** * bootm_process_cmdline_env() - Process fix-ups for the command line * * Updates the 'bootargs' envvar as required. This handles making Linux boot -- cgit v1.2.3 From 1a62d64c7de7e7de3facf221eb8408ddfb675cb8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:47 -0700 Subject: cli: Support macro processing with a fixed-size buffer At present cli_simple_process_macros() requires that the caller provide an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This makes sense since it is designed to be used from the command line. But we also want to use it for bootargs substitution. Update the function to allow the caller to specify the buffer size. Also return an error if the buffer is exhausted. The caller can ignore that if preferred. Signed-off-by: Simon Glass --- include/cli.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/cli.h b/include/cli.h index 39b913743b5..3449fa6ae72 100644 --- a/include/cli.h +++ b/include/cli.h @@ -34,8 +34,10 @@ int cli_simple_run_command(const char *cmd, int flag); * * @param input Input string possible containing $() / ${} vars * @param output Output string with $() / ${} vars expanded + * @param max_size Maximum size of @output (including terminator) + * @return 0 if OK, -ENOSPC if we ran out of space in @output */ -void cli_simple_process_macros(const char *input, char *output); +int cli_simple_process_macros(const char *input, char *output, int max_size); /** * cli_simple_run_command_list() - Execute a list of command -- cgit v1.2.3 From 51bb33846ad2b045799d2c43ca773fafa36e6ec8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:48 -0700 Subject: bootm: Support string substitution in bootargs In some cases it is necessary to pass parameters to Linux so that it will boot correctly. For example, the rootdev parameter is often used to specify the root device. However the root device may change depending on whence U-Boot loads the kernel. At present it is necessary to build up the command line by adding device strings to it one by one. It is often more convenient to provide a template for bootargs, with U-Boot doing the substitution from other environment variables. Add a way to substitute strings in the bootargs variable. This allows things like "rootdev=${rootdev}" to be used in bootargs, with the ${rootdev} substitution providing the UUID of the root device. For example, to substitute the GUID of the kernel partition: setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1 kern_guid=${uuid}" part uuid mmc 2:2 uuid bootm This is particularly useful when the command line from another place. For example, Chrome OS stores the command line next to the kernel itself. It depends on the kernel version being used as well as the hardware features, so it is extremely difficult to devise a U-Boot script that works on all boards and kernel versions. With this feature, the command line can be read from disk and used directly, with a few substitutions set up. Signed-off-by: Simon Glass --- include/bootm.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/bootm.h b/include/bootm.h index 8d95fb2a90a..7f88ec718b8 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -78,8 +78,9 @@ void switch_to_non_secure_mode(void); /* Flags to control bootm_process_cmdline() */ enum bootm_cmdline_t { BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ + BOOTM_CL_SUBST = 1 << 1, /* Do substitution */ - BOOTM_CL_ALL = 1, /* All substitutions */ + BOOTM_CL_ALL = 3, /* All substitutions */ }; /** @@ -95,7 +96,10 @@ void board_preboot_os(void); /* * bootm_process_cmdline() - Process fix-ups for the command line * - * This handles: making Linux boot silently if requested ('silent_linux' envvar) + * This handles: + * + * - making Linux boot silently if requested ('silent_linux' envvar) + * - performing substitutions in the command line ('bootargs_subst' envvar) * * @maxlen must provide enough space for the string being processed plus the * resulting string @@ -111,8 +115,10 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags); /** * bootm_process_cmdline_env() - Process fix-ups for the command line * - * Updates the 'bootargs' envvar as required. This handles making Linux boot - * silently if requested ('silent_linux' envvar) + * Updates the 'bootargs' envvar as required. This handles: + * + * - making Linux boot silently if requested ('silent_linux' envvar) + * - performing substitutions in the command line ('bootargs_subst' envvar) * * @flags: Flags to control what happens (see bootm_cmdline_t) * @return 0 if OK, -ENOMEM if out of memory -- cgit v1.2.3 From d236e825a214a5684598fa7a7b919af332c43390 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 22 Nov 2020 09:19:52 +0100 Subject: fs: fat: export fat_next_cluster() Rename function next_cluster() to fat_next_cluster() and export it. When creating a new directory entries we should reuse deleted entries. This requires re-scanning the directory. Signed-off-by: Heinrich Schuchardt --- include/fat.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/fat.h b/include/fat.h index 02742f92a5c..3c29a4484d4 100644 --- a/include/fat.h +++ b/include/fat.h @@ -9,8 +9,9 @@ #ifndef _FAT_H_ #define _FAT_H_ -#include #include +#include +#include struct disk_partition; @@ -179,6 +180,9 @@ typedef struct { int fats; /* Number of FATs */ } fsdata; +struct fat_itr; +typedef struct fat_itr fat_itr; + static inline u32 clust_to_sect(fsdata *fsdata, u32 clust) { return fsdata->data_begin + clust * fsdata->clust_size; @@ -208,4 +212,5 @@ void fat_closedir(struct fs_dir_stream *dirs); int fat_unlink(const char *filename); int fat_mkdir(const char *dirname); void fat_close(void); +void *fat_next_cluster(fat_itr *itr, unsigned int *nbytes); #endif /* _FAT_H_ */ -- cgit v1.2.3 From b6f11098c9a619f480582b26edd26c5b195c69f4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 4 Dec 2020 03:33:41 +0100 Subject: efi_loader: move EFI_LOAD_FILE2_PROTOCOL_GUID The EFI_LOAD_FILE_PROTOCOL_GUID and EFI_LOAD_FILE2_PROTOCOL_GUID are needed to complement the implementation of the LoadFile() boot service. Remove a duplicate declaration of a variable for the EFI_LOAD_FILE2_PROTOCOL_GUID. Move the remaining declaration to efi_boottime.c. Add a variable for the EFI_LOAD_FILE_PROTOCOL_GUID. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 76cd2b36f2b..4c6eb8616d5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -195,6 +195,9 @@ extern const efi_guid_t efi_file_system_info_guid; extern const efi_guid_t efi_guid_device_path_utilities_protocol; /* GUID of the deprecated Unicode collation protocol */ extern const efi_guid_t efi_guid_unicode_collation_protocol; +/* GUIDs of the Load File and Load File2 protocol */ +extern const efi_guid_t efi_guid_load_file_protocol; +extern const efi_guid_t efi_guid_load_file2_protocol; /* GUID of the Unicode collation protocol */ extern const efi_guid_t efi_guid_unicode_collation_protocol2; extern const efi_guid_t efi_guid_hii_config_routing_protocol; -- cgit v1.2.3 From f9ad240e65ac2f45d7b0acd770b5d79e50c3d92f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Jan 2020 12:33:59 +0100 Subject: efi_loader: make efi_protocol_open() non-static Provide efi_protocol_open() as library function. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 4c6eb8616d5..365f3d01dc7 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -500,6 +500,11 @@ efi_status_t efi_search_protocol(const efi_handle_t handle, efi_status_t efi_add_protocol(const efi_handle_t handle, const efi_guid_t *protocol, void *protocol_interface); +/* Open protocol */ +efi_status_t efi_protocol_open(struct efi_handler *handler, + void **protocol_interface, void *agent_handle, + void *controller_handle, uint32_t attributes); + /* Delete protocol from a handle */ efi_status_t efi_remove_protocol(const efi_handle_t handle, const efi_guid_t *protocol, -- cgit v1.2.3 From b46f30a378673a5c789d145c1d8d0d76312714d8 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 12 Nov 2020 00:29:56 +0100 Subject: sandbox: add handler for exceptions Add a handler for SIGILL, SIGBUS, SIGSEGV. When an exception occurs print the program counter and the loaded UEFI binaries and reset the system if CONFIG_SANDBOX_CRASH_RESET=y or exit to the OS otherwise. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/os.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index 1fe44f35105..0913b47b3a8 100644 --- a/include/os.h +++ b/include/os.h @@ -407,4 +407,21 @@ void *os_find_text_base(void); */ void os_relaunch(char *argv[]); +/** + * os_setup_signal_handlers() - setup signal handlers + * + * Install signal handlers for SIGBUS and SIGSEGV. + * + * Return: 0 for success + */ +int os_setup_signal_handlers(void); + +/** + * os_signal_action() - handle a signal + * + * @sig: signal + * @pc: program counter + */ +void os_signal_action(int sig, unsigned long pc); + #endif -- cgit v1.2.3 From e12052b3227bb0d77125970dc9f731e052b1c730 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:00 -0700 Subject: dm: core: Rename device_bind() to device_bind_offset() This function is not necessary anymore, since device_bind_ofnode() does the same thing and works with both flattree and livetree. Rename it to indicate that it is special. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 8 ++++---- include/power/regulator.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index c5d7ec0650f..59d3be09a1e 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -16,7 +16,7 @@ struct device_node; struct udevice; /** - * device_bind() - Create a device and bind it to a driver + * device_bind_offset() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either * have platdata, or a device tree node which can be used to create the @@ -36,9 +36,9 @@ struct udevice; * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ -int device_bind(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, int of_offset, - struct udevice **devp); +int device_bind_offset(struct udevice *parent, const struct driver *drv, + const char *name, void *platdata, int of_offset, + struct udevice **devp); int device_bind_ofnode(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, ofnode node, diff --git a/include/power/regulator.h b/include/power/regulator.h index 7f278e8c7dc..4d58a436fea 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -48,7 +48,7 @@ * If regulator-name property is not provided, node name will be chosen. * * Regulator bind: - * For each regulator device, the device_bind() should be called with passed + * For each regulator device, the device_bind_offset() should be called with passed * device tree offset. This is required for this uclass's '.post_bind' method, * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function: -- cgit v1.2.3 From 734206dda14b328bfb946eea1e343f06a5fcceea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:01 -0700 Subject: dm: core: Rename device_bind_ofnode() to device_bind() This is the standard function to use when binding devices. Drop the '_ofnode' suffix to make this clear. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 59d3be09a1e..636210f73ed 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -40,9 +40,9 @@ int device_bind_offset(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, int of_offset, struct udevice **devp); -int device_bind_ofnode(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, ofnode node, - struct udevice **devp); +int device_bind(struct udevice *parent, const struct driver *drv, + const char *name, void *platdata, ofnode node, + struct udevice **devp); /** * device_bind_with_driver_data() - Create a device and bind it to a driver -- cgit v1.2.3 From 0de1b07406d709c3951dbb1a69ca196d80bd516d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:02 -0700 Subject: dm: core: Add a livetree function to check node status Add a way to find out if a node is enabled or not, based on its 'status' property. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index ced7f6ffb25..ee8c44a71ec 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -345,6 +345,17 @@ const char *ofnode_read_string(ofnode node, const char *propname); */ int ofnode_read_u32_array(ofnode node, const char *propname, u32 *out_values, size_t sz); +/** + * ofnode_is_enabled() - Checks whether a node is enabled. + * This looks for a 'status' property. If this exists, then returns true if + * the status is 'okay' and false otherwise. If there is no status property, + * it returns true on the assumption that anything mentioned should be enabled + * by default. + * + * @node: node to examine + * @return false (not enabled) or true (enabled) + */ +bool ofnode_is_enabled(ofnode node); /** * ofnode_read_bool() - read a boolean value from a property -- cgit v1.2.3 From a2703ce10cfcbe6a82ec8ed9ec10df2aeea08e64 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:03 -0700 Subject: dm: Remove uses of device_bind_offset() This function is not needed since the standard device_bind() can be used instead. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 636210f73ed..6f4f8510f7e 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -37,8 +37,8 @@ struct udevice; * @return 0 if OK, -ve on error */ int device_bind_offset(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, int of_offset, - struct udevice **devp); + const char *name, void *platdata, int of_offset, + struct udevice **devp); int device_bind(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, ofnode node, diff --git a/include/power/regulator.h b/include/power/regulator.h index 4d58a436fea..7f278e8c7dc 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -48,7 +48,7 @@ * If regulator-name property is not provided, node name will be chosen. * * Regulator bind: - * For each regulator device, the device_bind_offset() should be called with passed + * For each regulator device, the device_bind() should be called with passed * device tree offset. This is required for this uclass's '.post_bind' method, * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function: -- cgit v1.2.3 From 0d56fba3c4156ba305053b5f8f317e2974f50eeb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:05 -0700 Subject: dm: core: Drop dev_set_of_offset() This pre-livetree function is not needed anymore. Drop it. Signed-off-by: Simon Glass --- include/dm/device.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 5bef4842470..25a77d08b9d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -177,11 +177,6 @@ static inline int dev_of_offset(const struct udevice *dev) return ofnode_to_offset(dev->node); } -static inline void dev_set_of_offset(struct udevice *dev, int of_offset) -{ - dev->node = offset_to_ofnode(of_offset); -} - static inline bool dev_has_of_node(struct udevice *dev) { return ofnode_valid(dev->node); -- cgit v1.2.3 From e80be7493412e0facbbf81f709dc44740e975dea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:06 -0700 Subject: dm: core: Drop device_bind_offset() This function is not needed since the standard device_bind() can be used instead. Drop it. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 6f4f8510f7e..578a483497e 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -16,7 +16,7 @@ struct device_node; struct udevice; /** - * device_bind_offset() - Create a device and bind it to a driver + * device_bind() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either * have platdata, or a device tree node which can be used to create the @@ -31,15 +31,11 @@ struct udevice; * @platdata: Pointer to data for this device - the structure is device- * specific but may include the device's I/O address, etc.. This is NULL for * devices which use device tree. - * @of_offset: Offset of device tree node for this device. This is -1 for - * devices which don't use device tree. + * @ofnode: Devicetree node for this device. This is ofnode_null() for + * devices which don't use devicetree or don't have a node. * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ -int device_bind_offset(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, int of_offset, - struct udevice **devp); - int device_bind(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, ofnode node, struct udevice **devp); -- cgit v1.2.3 From d0c20ce6bcb9af3d70ed6ada618607ca1099e811 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:07 -0700 Subject: dm: core: Add an ofnode function to get the devicetree root This is needed in at least one place. Avoid the conditional code in root.c by adding this inline function. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index ee8c44a71ec..53f04ac91d0 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -218,6 +218,18 @@ static inline ofnode ofnode_null(void) return node; } +static inline ofnode ofnode_root(void) +{ + ofnode node; + + if (of_live_active()) + node.np = gd_of_root(); + else + node.of_offset = 0; + + return node; +} + /** * ofnode_read_u32() - Read a 32-bit integer from a property * -- cgit v1.2.3 From 725e4fce61e5b8339fdc975b01ce7bb3dd9fa5f4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:09 -0700 Subject: dm: core: Drop unused parameter from dm_scan_fdt() This doesn't need to be passed the devicetree anymore. Drop it. Signed-off-by: Simon Glass --- include/dm/root.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/root.h b/include/dm/root.h index c8d629ba9bf..e277ebb9523 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -47,12 +47,11 @@ int dm_scan_platdata(bool pre_reloc_only); * This scans the device tree and creates a driver for each node. Only * the top-level subnodes are examined. * - * @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_fdt(const void *blob, bool pre_reloc_only); +int dm_scan_fdt(bool pre_reloc_only); /** * dm_extended_scan_fdt() - Scan the device tree and bind drivers -- cgit v1.2.3 From 8ee05b5f903bdfb0c4c2d578fd0172ecb900e3e2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Nov 2020 17:50:10 -0700 Subject: dm: core: Drop unused parameter from dm_extended_scan_fdt() This doesn't need to be passed the devicetree anymore. Drop it. Also rename the function to drop the _fdt suffix. Signed-off-by: Simon Glass --- include/dm/root.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dm/root.h b/include/dm/root.h index e277ebb9523..830e31312df 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -54,18 +54,17 @@ int dm_scan_platdata(bool pre_reloc_only); int dm_scan_fdt(bool pre_reloc_only); /** - * dm_extended_scan_fdt() - Scan the device tree and bind drivers + * dm_extended_scan() - Scan the device tree and bind drivers * * This calls dm_scna_dft() which scans the device tree and creates a driver * for each node. the top-level subnodes are examined and also all sub-nodes * of "clocks" node. * - * @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only); +int dm_extended_scan(bool pre_reloc_only); /** * dm_scan_other() - Scan for other devices -- cgit v1.2.3 From 41575d8e4c334df148c4cdd7c40cc825dc0fcaa1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:17 -0700 Subject: dm: treewide: Rename auto_alloc_size members to be shorter 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 --- include/dm/device.h | 18 +++++++++--------- include/dm/uclass.h | 20 ++++++++++---------- include/dwmmc.h | 2 +- include/sdhci.h | 2 +- include/spi.h | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 25a77d08b9d..f4c2b9b246e 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -111,7 +111,7 @@ enum { * probe method if the device has a device tree node. * * All three of platdata, priv and uclass_priv can be allocated by the - * driver, or you can use the auto_alloc_size members of struct driver and + * driver, or you can use the 'auto' members of struct driver and * struct uclass_driver to have driver model do this automatically. * * @driver: The driver used by this device @@ -225,18 +225,18 @@ struct udevice_id { * memory allocated but it has not yet been probed. * @child_post_remove: Called after a child device is removed. The device * has memory allocated but its device_remove() method has been called. - * @priv_auto_alloc_size: If non-zero this is the size of the private data + * @priv_auto: If non-zero this is the size of the private data * to be allocated in the device's ->priv pointer. If zero, then the driver * is responsible for allocating any data required. - * @platdata_auto_alloc_size: If non-zero this is the size of the + * @platdata_auto: If non-zero this is the size of the * platform data to be allocated in the device's ->platdata pointer. * This is typically only useful for device-tree-aware drivers (those with * an of_match), since drivers which use platdata will have the data * provided in the U_BOOT_DEVICE() instantiation. - * @per_child_auto_alloc_size: Each device can hold private data owned by + * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. - * @per_child_platdata_auto_alloc_size: A bus likes to store information about + * @per_child_platdata_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated * in the child's parent_platdata pointer. * @ops: Driver-specific operations. This is typically a list of function @@ -258,10 +258,10 @@ struct driver { int (*child_post_bind)(struct udevice *dev); int (*child_pre_probe)(struct udevice *dev); int (*child_post_remove)(struct udevice *dev); - int priv_auto_alloc_size; - int platdata_auto_alloc_size; - int per_child_auto_alloc_size; - int per_child_platdata_auto_alloc_size; + int priv_auto; + int platdata_auto; + int per_child_auto; + int per_child_platdata_auto; const void *ops; /* driver-specific operations */ uint32_t flags; #if CONFIG_IS_ENABLED(ACPIGEN) diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 71883043046..e74082fbdf7 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -65,19 +65,19 @@ struct udevice; * @child_post_probe: Called after a child in this uclass is probed * @init: Called to set up the uclass * @destroy: Called to destroy the uclass - * @priv_auto_alloc_size: If non-zero this is the size of the private data + * @priv_auto: If non-zero this is the size of the private data * to be allocated in the uclass's ->priv pointer. If zero, then the uclass * driver is responsible for allocating any data required. - * @per_device_auto_alloc_size: Each device can hold private data owned + * @per_device_auto: Each device can hold private data owned * by the uclass. If required this will be automatically allocated if this * value is non-zero. - * @per_device_platdata_auto_alloc_size: Each device can hold platform data + * @per_device_platdata_auto: Each device can hold platform data * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero, * then this will be automatically allocated. - * @per_child_auto_alloc_size: Each child device (of a parent in this + * @per_child_auto: Each child device (of a parent in this * uclass) can hold parent data for the device/uclass. This value is only * used as a fallback if this member is 0 in the driver. - * @per_child_platdata_auto_alloc_size: A bus likes to store information about + * @per_child_platdata_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated * in the child device's parent_platdata pointer. This value is only used as * a fallback if this member is 0 in the driver. @@ -98,11 +98,11 @@ struct uclass_driver { int (*child_post_probe)(struct udevice *dev); int (*init)(struct uclass *class); int (*destroy)(struct uclass *class); - int priv_auto_alloc_size; - int per_device_auto_alloc_size; - int per_device_platdata_auto_alloc_size; - int per_child_auto_alloc_size; - int per_child_platdata_auto_alloc_size; + int priv_auto; + int per_device_auto; + int per_device_platdata_auto; + int per_child_auto; + int per_child_platdata_auto; const void *ops; uint32_t flags; }; diff --git a/include/dwmmc.h b/include/dwmmc.h index d8a8355a0ad..c53694654ed 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -256,7 +256,7 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), + * .platdata_auto = sizeof(struct rockchip_mmc_plat), * * To access platform data: * struct rockchip_mmc_plat *plat = dev_get_platdata(dev); diff --git a/include/sdhci.h b/include/sdhci.h index 1fd20ec0860..d04afd53b16 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -440,7 +440,7 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat), + * .platdata_auto = sizeof(struct msm_sdhc_plat), * * To access platform data: * struct msm_sdhc_plat *plat = dev_get_platdata(dev); diff --git a/include/spi.h b/include/spi.h index ef8c1f6692e..f69c08d287f 100644 --- a/include/spi.h +++ b/include/spi.h @@ -102,7 +102,7 @@ enum spi_polarity { * * For driver model this is the per-child data used by the SPI bus. It can * be accessed using dev_get_parent_priv() on the slave device. The SPI uclass - * sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the + * sets up per_child_auto to sizeof(struct spi_slave), and the * driver should not override it. Two platform data fields (max_hz and mode) * are copied into this structure to provide an initial value. This allows * them to be changed, since we should never change platform data in drivers. -- cgit v1.2.3 From caa4daa2ae3dc0a3e516addea5772c9af76abcb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:18 -0700 Subject: dm: treewide: Rename 'platdata' variables to just 'plat' We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass --- include/adc.h | 4 ++-- include/blk.h | 2 +- include/cpu.h | 2 +- include/dm/device-internal.h | 10 ++++---- include/dm/device.h | 56 ++++++++++++++++++++++---------------------- include/dm/lists.h | 2 +- include/dm/pci.h | 2 +- include/dm/platdata.h | 6 ++--- include/dm/root.h | 2 +- include/dm/uclass.h | 12 +++++----- include/dwmmc.h | 2 +- include/i2c.h | 2 +- include/net.h | 2 +- include/pci.h | 2 +- include/power/regulator.h | 26 ++++++++++---------- include/remoteproc.h | 2 +- include/sdhci.h | 2 +- include/spi.h | 10 ++++---- include/usb.h | 4 ++-- include/video.h | 4 ++-- 20 files changed, 77 insertions(+), 77 deletions(-) (limited to 'include') diff --git a/include/adc.h b/include/adc.h index 5841dfb54b9..0d1a666908f 100644 --- a/include/adc.h +++ b/include/adc.h @@ -40,7 +40,7 @@ struct adc_channel { }; /** - * struct adc_uclass_platdata - basic ADC info + * struct adc_uclass_plat - basic ADC info * * Note: The positive/negative reference Voltage is only a name and it doesn't * provide an information about the value polarity. It is possible, for both @@ -71,7 +71,7 @@ struct adc_channel { * @vdd_microvolts - positive reference Voltage value * @vss_microvolts - negative reference Voltage value */ -struct adc_uclass_platdata { +struct adc_uclass_plat { int data_format; unsigned int data_mask; unsigned int data_timeout_us; diff --git a/include/blk.h b/include/blk.h index 9ee10fb80e7..c4401b00253 100644 --- a/include/blk.h +++ b/include/blk.h @@ -56,7 +56,7 @@ enum sig_type { /* * With driver model (CONFIG_BLK) this is uclass platform data, accessible - * with dev_get_uclass_platdata(dev) + * with dev_get_uclass_plat(dev) */ struct blk_desc { /* diff --git a/include/cpu.h b/include/cpu.h index 78e88b9ed09..1d53308f7a4 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -17,7 +17,7 @@ * @timebase_freq: the current frequency at which the cpu timer timebase * registers are updated (in Hz) * - * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU + * This can be accessed with dev_get_parent_plat() for any UCLASS_CPU * device. */ struct cpu_platdata { diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 578a483497e..2e9c1d5ef9c 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -19,8 +19,8 @@ struct udevice; * device_bind() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either - * have platdata, or a device tree node which can be used to create the - * platdata. + * have plat, or a device tree node which can be used to create the + * plat. * * Once bound a device exists but is not yet active until device_probe() is * called. @@ -28,7 +28,7 @@ struct udevice; * @parent: Pointer to device's parent, under which this driver will exist * @drv: Device's driver * @name: Name of device (e.g. device tree node name) - * @platdata: Pointer to data for this device - the structure is device- + * @plat: Pointer to data for this device - the structure is device- * specific but may include the device's I/O address, etc.. This is NULL for * devices which use device tree. * @ofnode: Devicetree node for this device. This is ofnode_null() for @@ -37,7 +37,7 @@ struct udevice; * @return 0 if OK, -ve on error */ int device_bind(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, ofnode node, + const char *name, void *plat, ofnode node, struct udevice **devp); /** @@ -72,7 +72,7 @@ int device_bind_with_driver_data(struct udevice *parent, * @parent: Pointer to device's parent * @pre_reloc_only: If true, bind the driver only if its DM_FLAG_PRE_RELOC flag * is set. If false bind the driver always. - * @info: Name and platdata for this device + * @info: Name and plat for this device * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ diff --git a/include/dm/device.h b/include/dm/device.h index f4c2b9b246e..5d31a2c7154 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -23,16 +23,16 @@ struct driver_info; /* Driver is active (probed). Cleared when it is removed */ #define DM_FLAG_ACTIVATED (1 << 0) -/* DM is responsible for allocating and freeing platdata */ +/* DM is responsible for allocating and freeing plat */ #define DM_FLAG_ALLOC_PDATA (1 << 1) /* DM should init this device prior to relocation */ #define DM_FLAG_PRE_RELOC (1 << 2) -/* DM is responsible for allocating and freeing parent_platdata */ +/* DM is responsible for allocating and freeing parent_plat */ #define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3) -/* DM is responsible for allocating and freeing uclass_platdata */ +/* DM is responsible for allocating and freeing uclass_plat */ #define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4) /* Allocate driver private data on a DMA boundary */ @@ -64,7 +64,7 @@ struct driver_info; /* DM does not enable/disable the power domains corresponding to this device */ #define DM_FLAG_DEFAULT_PD_CTRL_OFF (1 << 11) -/* Driver platdata has been read. Cleared when the device is removed */ +/* Driver plat has been read. Cleared when the device is removed */ #define DM_FLAG_PLATDATA_VALID (1 << 12) /* @@ -104,21 +104,21 @@ enum { * particular port or peripheral (essentially a driver instance). * * A device will come into existence through a 'bind' call, either due to - * a U_BOOT_DEVICE() macro (in which case platdata is non-NULL) or a node + * a U_BOOT_DEVICE() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case - * we translate the device tree information into platdata in a function + * we translate the device tree information into plat in a function * implemented by the driver ofdata_to_platdata method (called just before the * probe method if the device has a device tree node. * - * All three of platdata, priv and uclass_priv can be allocated by the - * driver, or you can use the 'auto' members of struct driver and + * All three of plat, priv and uclass_priv can be allocated by the + * driver, or you can use the auto_alloc_size members of struct driver and * struct uclass_driver to have driver model do this automatically. * * @driver: The driver used by this device * @name: Name of device, typically the FDT node name - * @platdata: Configuration data for this device - * @parent_platdata: The parent bus's configuration data for this device - * @uclass_platdata: The uclass's configuration data for this device + * @plat: Configuration data for this device + * @parent_plat: The parent bus's configuration data for this device + * @uclass_plat: The uclass's configuration data for this device * @node: Reference to device tree node for this device * @driver_data: Driver data word for the entry that matched this device with * its driver @@ -142,9 +142,9 @@ enum { struct udevice { const struct driver *driver; const char *name; - void *platdata; - void *parent_platdata; - void *uclass_platdata; + void *plat; + void *parent_plat; + void *uclass_plat; ofnode node; ulong driver_data; struct udevice *parent; @@ -203,7 +203,7 @@ struct udevice_id { * * This holds methods for setting up a new device, and also removing it. * The device needs information to set itself up - this is provided either - * by platdata or a device tree node (which we find by looking up + * by plat or a device tree node (which we find by looking up * matching compatible strings with of_match). * * Drivers all belong to a uclass, representing a class of devices of the @@ -228,17 +228,17 @@ struct udevice_id { * @priv_auto: If non-zero this is the size of the private data * to be allocated in the device's ->priv pointer. If zero, then the driver * is responsible for allocating any data required. - * @platdata_auto: If non-zero this is the size of the - * platform data to be allocated in the device's ->platdata pointer. + * @plat_auto: If non-zero this is the size of the + * platform data to be allocated in the device's ->plat pointer. * This is typically only useful for device-tree-aware drivers (those with - * an of_match), since drivers which use platdata will have the data + * an of_match), since drivers which use plat will have the data * provided in the U_BOOT_DEVICE() instantiation. * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. - * @per_child_platdata_auto: A bus likes to store information about + * @per_child_plat_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated - * in the child's parent_platdata pointer. + * in the child's parent_plat pointer. * @ops: Driver-specific operations. This is typically a list of function * pointers defined by the driver, to implement driver functions required by * the uclass. @@ -259,9 +259,9 @@ struct driver { int (*child_pre_probe)(struct udevice *dev); int (*child_post_remove)(struct udevice *dev); int priv_auto; - int platdata_auto; + int plat_auto; int per_child_auto; - int per_child_platdata_auto; + int per_child_plat_auto; const void *ops; /* driver-specific operations */ uint32_t flags; #if CONFIG_IS_ENABLED(ACPIGEN) @@ -295,24 +295,24 @@ struct driver { void *dev_get_platdata(const struct udevice *dev); /** - * dev_get_parent_platdata() - Get the parent platform data for a device + * dev_get_parent_plat() - Get the parent platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return parent's platform data, or NULL if none */ -void *dev_get_parent_platdata(const struct udevice *dev); +void *dev_get_parent_plat(const struct udevice *dev); /** - * dev_get_uclass_platdata() - Get the uclass platform data for a device + * dev_get_uclass_plat() - Get the uclass platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return uclass's platform data, or NULL if none */ -void *dev_get_uclass_platdata(const struct udevice *dev); +void *dev_get_uclass_plat(const struct udevice *dev); /** * dev_get_priv() - Get the private data for a device @@ -622,7 +622,7 @@ int device_find_child_by_name(const struct udevice *parent, const char *name, struct udevice **devp); /** - * device_first_child_ofdata_err() - Find the first child and reads its platdata + * device_first_child_ofdata_err() - Find the first child and reads its plat * * The ofdata_to_platdata() method is called on the child before it is returned, * but the child is not probed. @@ -635,7 +635,7 @@ int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp); /* - * device_next_child_ofdata_err() - Find the next child and read its platdata + * device_next_child_ofdata_err() - Find the next child and read its plat * * The ofdata_to_platdata() method is called on the child before it is returned, * but the child is not probed. diff --git a/include/dm/lists.h b/include/dm/lists.h index 810e244d9ef..070bc9c19f6 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -16,7 +16,7 @@ * lists_driver_lookup_name() - Return u_boot_driver corresponding to name * * This function returns a pointer to a driver given its name. This is used - * for binding a driver given its name and platdata. + * for binding a driver given its name and plat. * * @name: Name of driver to look up * @return pointer to driver, or NULL if not found diff --git a/include/dm/pci.h b/include/dm/pci.h index 10f9fd9e378..bddacbf5997 100644 --- a/include/dm/pci.h +++ b/include/dm/pci.h @@ -30,7 +30,7 @@ int pci_get_devfn(struct udevice *dev); * * This returns an int to avoid a dependency on pci.h * - * @reg: reg value from dt-platdata.c array (first member). This is not a + * @reg: reg value from dt-plat.c array (first member). This is not a * pointer type, since the caller may use fdt32_t or fdt64_t depending on * the address sizes. * @return device/function for that device (pci_dev_t format) diff --git a/include/dm/platdata.h b/include/dm/platdata.h index 216efa8ef77..6094b663f8b 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -20,13 +20,13 @@ * available). U-Boot's driver model uses device tree for configuration. * * @name: Driver name - * @platdata: Driver-specific platform data + * @plat: Driver-specific platform data * @platdata_size: Size of platform data structure * @parent_idx: Index of the parent driver_info structure */ struct driver_info { const char *name; - const void *platdata; + const void *plat; #if CONFIG_IS_ENABLED(OF_PLATDATA) unsigned short platdata_size; short parent_idx; @@ -57,7 +57,7 @@ struct driver_rt { * available). U-Boot's driver model uses device tree for configuration. * * When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the - * dt-platdata.c file created by dtoc + * dt-plat.c file created by dtoc */ #if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLATDATA_C) #define U_BOOT_DEVICE(__name) _Static_assert(false, \ diff --git a/include/dm/root.h b/include/dm/root.h index 830e31312df..113e92ec783 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -33,7 +33,7 @@ void dm_fixup_for_gd_move(struct global_data *new_gd); /** * dm_scan_platdata() - Scan all platform data and bind drivers * - * This scans all available platdata and creates drivers for each + * This scans all available plat and creates drivers for each * * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC * flag. If false bind all drivers. diff --git a/include/dm/uclass.h b/include/dm/uclass.h index e74082fbdf7..068e8ea8bf7 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -71,15 +71,15 @@ struct udevice; * @per_device_auto: Each device can hold private data owned * by the uclass. If required this will be automatically allocated if this * value is non-zero. - * @per_device_platdata_auto: Each device can hold platform data - * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero, + * @per_device_plat_auto: Each device can hold platform data + * owned by the uclass as 'dev->uclass_plat'. If the value is non-zero, * then this will be automatically allocated. * @per_child_auto: Each child device (of a parent in this * uclass) can hold parent data for the device/uclass. This value is only * used as a fallback if this member is 0 in the driver. - * @per_child_platdata_auto: A bus likes to store information about + * @per_child_plat_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated - * in the child device's parent_platdata pointer. This value is only used as + * in the child device's parent_plat pointer. This value is only used as * a fallback if this member is 0 in the driver. * @ops: Uclass operations, providing the consistent interface to devices * within the uclass. @@ -100,9 +100,9 @@ struct uclass_driver { int (*destroy)(struct uclass *class); int priv_auto; int per_device_auto; - int per_device_platdata_auto; + int per_device_plat_auto; int per_child_auto; - int per_child_platdata_auto; + int per_child_plat_auto; const void *ops; uint32_t flags; }; diff --git a/include/dwmmc.h b/include/dwmmc.h index c53694654ed..4515a44dc27 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -256,7 +256,7 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto = sizeof(struct rockchip_mmc_plat), + * .plat_auto = sizeof(struct rockchip_mmc_plat), * * To access platform data: * struct rockchip_mmc_plat *plat = dev_get_platdata(dev); diff --git a/include/i2c.h b/include/i2c.h index 880aa8032b7..d0a390141b8 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -71,7 +71,7 @@ struct udevice; * An I2C chip is a device on the I2C bus. It sits at a particular address * and normally supports 7-bit or 10-bit addressing. * - * To obtain this structure, use dev_get_parent_platdata(dev) where dev is + * To obtain this structure, use dev_get_parent_plat(dev) where dev is * the chip to examine. * * @chip_addr: Chip address on bus diff --git a/include/net.h b/include/net.h index aff6674bb3e..13da69b7c14 100644 --- a/include/net.h +++ b/include/net.h @@ -115,7 +115,7 @@ enum eth_state_t { * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... * @max_speed: Maximum speed of Ethernet connection supported by MAC - * @priv_pdata: device specific platdata + * @priv_pdata: device specific plat */ struct eth_pdata { phys_addr_t iobase; diff --git a/include/pci.h b/include/pci.h index d1ccf6c9636..a8472dd2683 100644 --- a/include/pci.h +++ b/include/pci.h @@ -903,7 +903,7 @@ struct udevice; * * Every device on a PCI bus has this per-child data. * - * It can be accessed using dev_get_parent_platdata(dev) if dev->parent is a + * It can be accessed using dev_get_parent_plat(dev) if dev->parent is a * PCI bus (i.e. UCLASS_PCI) * * @devfn: Encoded device and function index - see PCI_DEVFN() diff --git a/include/power/regulator.h b/include/power/regulator.h index 7f278e8c7dc..19a3b7b502a 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -16,15 +16,15 @@ * 'UCLASS_REGULATOR' and the regulator driver API. * * The regulator uclass - is based on uclass platform data which is allocated, - * automatically for each regulator device on bind and 'dev->uclass_platdata' - * points to it. The data type is: 'struct dm_regulator_uclass_platdata'. + * automatically for each regulator device on bind and 'dev->uclass_plat' + * points to it. The data type is: 'struct dm_regulator_uclass_plat'. * The uclass file: 'drivers/power/regulator/regulator-uclass.c' * * The regulator device - is based on driver's model 'struct udevice'. * The API can use regulator name in two meanings: * - devname - the regulator device's name: 'dev->name' - * - platname - the device's platdata's name. So in the code it looks like: - * 'uc_pdata = dev->uclass_platdata'; 'name = uc_pdata->name'. + * - platname - the device's plat's name. So in the code it looks like: + * 'uc_pdata = dev->uclass_plat'; 'name = uc_pdata->name'. * * The regulator device driver - provide an implementation of uclass operations * pointed by 'dev->driver->ops' as a struct of type 'struct dm_regulator_ops'. @@ -135,7 +135,7 @@ enum regulator_flag { }; /** - * struct dm_regulator_uclass_platdata - pointed by dev->uclass_platdata, and + * struct dm_regulator_uclass_plat - pointed by dev->uclass_plat, and * allocated on each regulator bind. This structure holds an information * about each regulator's constraints and supported operation modes. * There is no "step" voltage value - so driver should take care of this. @@ -162,7 +162,7 @@ enum regulator_flag { * The constraints: type, mode, mode_count, can be set by device driver, e.g. * by the driver '.probe' method. */ -struct dm_regulator_uclass_platdata { +struct dm_regulator_uclass_plat { enum regulator_type type; struct dm_regulator_mode *mode; int mode_count; @@ -422,7 +422,7 @@ int regulators_enable_boot_on(bool verbose); * regulator_autoset: setup the voltage/current on a regulator * * The setup depends on constraints found in device's uclass's platform data - * (struct dm_regulator_uclass_platdata): + * (struct dm_regulator_uclass_plat): * * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, * or if both are unset, then the function returns @@ -431,7 +431,7 @@ int regulators_enable_boot_on(bool verbose); * * The function returns on the first-encountered error. * - * @platname - expected string for dm_regulator_uclass_platdata .name field + * @platname - expected string for dm_regulator_uclass_plat .name field * @devp - returned pointer to the regulator device - if non-NULL passed * @return: 0 on success or negative value of errno. */ @@ -440,7 +440,7 @@ int regulator_autoset(struct udevice *dev); /** * regulator_autoset_by_name: setup the regulator given by its uclass's * platform data name field. The setup depends on constraints found in device's - * uclass's platform data (struct dm_regulator_uclass_platdata): + * uclass's platform data (struct dm_regulator_uclass_plat): * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, * or if both are unset, then the function returns * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal @@ -448,7 +448,7 @@ int regulator_autoset(struct udevice *dev); * * The function returns on first encountered error. * - * @platname - expected string for dm_regulator_uclass_platdata .name field + * @platname - expected string for dm_regulator_uclass_plat .name field * @devp - returned pointer to the regulator device - if non-NULL passed * @return: 0 on success or negative value of errno. * @@ -464,7 +464,7 @@ int regulator_autoset_by_name(const char *platname, struct udevice **devp); * regulator_autoset_by_name() for each name from the list. * * @list_platname - an array of expected strings for .name field of each - * regulator's uclass platdata + * regulator's uclass plat * @list_devp - an array of returned pointers to the successfully setup * regulator devices if non-NULL passed * @verbose - (true/false) print each regulator setup info, or be quiet @@ -499,9 +499,9 @@ int regulator_get_by_devname(const char *devname, struct udevice **devp); /** * regulator_get_by_platname: returns the pointer to the pmic regulator device. - * Search by name, found in regulator uclass platdata. + * Search by name, found in regulator uclass plat. * - * @platname - expected string for uc_pdata->name of regulator uclass platdata + * @platname - expected string for uc_pdata->name of regulator uclass plat * @devp - returns pointer to the regulator device or NULL on error * @return 0 on success or negative value of errno. * diff --git a/include/remoteproc.h b/include/remoteproc.h index 74d01723f6a..089131f65fd 100644 --- a/include/remoteproc.h +++ b/include/remoteproc.h @@ -34,7 +34,7 @@ enum rproc_mem_type { * @mem_type: one of 'enum rproc_mem_type' * @driver_plat_data: driver specific platform data that may be needed. * - * This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC + * This can be accessed with dev_get_uclass_plat() for any UCLASS_REMOTEPROC * device. * */ diff --git a/include/sdhci.h b/include/sdhci.h index d04afd53b16..69c2087c10c 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -440,7 +440,7 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto = sizeof(struct msm_sdhc_plat), + * .plat_auto = sizeof(struct msm_sdhc_plat), * * To access platform data: * struct msm_sdhc_plat *plat = dev_get_platdata(dev); diff --git a/include/spi.h b/include/spi.h index f69c08d287f..176a42cb13a 100644 --- a/include/spi.h +++ b/include/spi.h @@ -48,8 +48,8 @@ struct dm_spi_bus { * struct dm_spi_platdata - platform data for all SPI slaves * * This describes a SPI slave, a child device of the SPI bus. To obtain this - * struct from a spi_slave, use dev_get_parent_platdata(dev) or - * dev_get_parent_platdata(slave->dev). + * struct from a spi_slave, use dev_get_parent_plat(dev) or + * dev_get_parent_plat(slave->dev). * * This data is immuatable. Each time the device is probed, @max_hz and @mode * will be copied to struct spi_slave. @@ -566,12 +566,12 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp, * is automatically bound on this chip select with requested speed and mode. * * Ths new slave device is probed ready for use with the speed and mode - * from platdata when available or the requested values. + * from plat when available or the requested values. * * @busnum: SPI bus number * @cs: Chip select to look for - * @speed: SPI speed to use for this slave when not available in platdata - * @mode: SPI mode to use for this slave when not available in platdata + * @speed: SPI speed to use for this slave when not available in plat + * @mode: SPI mode to use for this slave when not available in plat * @drv_name: Name of driver to attach to this chip select * @dev_name: Name of the new device thus created * @busp: Returns bus device diff --git a/include/usb.h b/include/usb.h index 5a7af882fb6..a3323f58018 100644 --- a/include/usb.h +++ b/include/usb.h @@ -608,7 +608,7 @@ struct usb_platdata { /** * struct usb_dev_platdata - Platform data about a USB device * - * Given a USB device dev this structure is dev_get_parent_platdata(dev). + * Given a USB device dev this structure is dev_get_parent_plat(dev). * This is used by sandbox to provide emulation data also. * * @id: ID used to match this device @@ -662,7 +662,7 @@ struct usb_bus_priv { * struct usb_emul_platdata - platform data about the USB emulator * * Given a USB emulator (UCLASS_USB_EMUL) 'dev', this is - * dev_get_uclass_platdata(dev). + * dev_get_uclass_plat(dev). * * @port1: USB emulator device port number on the parent hub */ diff --git a/include/video.h b/include/video.h index 9d09d2409af..31a12bd7996 100644 --- a/include/video.h +++ b/include/video.h @@ -21,7 +21,7 @@ struct udevice; * struct video_uc_platdata - uclass platform data for a video device * * This holds information that the uclass needs to know about each device. It - * is accessed using dev_get_uclass_platdata(dev). See 'Theory of operation' at + * is accessed using dev_get_uclass_plat(dev). See 'Theory of operation' at * the top of video-uclass.c for details on how this information is set. * * @align: Frame-buffer alignment, indicating the memory boundary the frame @@ -125,7 +125,7 @@ struct video_ops { * * Note: This function is for internal use. * - * This uses the uclass platdata's @size and @align members to figure out + * This uses the uclass plat's @size and @align members to figure out * a size and position for each frame buffer as part of the pre-relocation * process of determining the post-relocation memory layout. * -- cgit v1.2.3 From 4f50086ad6d69c355a07389fb436c64c92ec614a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:19 -0700 Subject: dm: Rename 'platdata_size' to 'plat_size' Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass --- include/dm/platdata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/platdata.h b/include/dm/platdata.h index 6094b663f8b..d650fb39190 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -21,14 +21,14 @@ * * @name: Driver name * @plat: Driver-specific platform data - * @platdata_size: Size of platform data structure + * @plat_size: Size of platform data structure * @parent_idx: Index of the parent driver_info structure */ struct driver_info { const char *name; const void *plat; #if CONFIG_IS_ENABLED(OF_PLATDATA) - unsigned short platdata_size; + unsigned short plat_size; short parent_idx; #endif }; -- cgit v1.2.3 From c69cda25c9b59e53a6bc8969ada58942549f5b5d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:20 -0700 Subject: dm: treewide: Rename dev_get_platdata() to dev_get_plat() Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass --- include/dm/device.h | 4 ++-- include/dwmmc.h | 2 +- include/linux/clk-provider.h | 2 +- include/sdhci.h | 2 +- include/usb.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 5d31a2c7154..491542c5804 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -285,14 +285,14 @@ struct driver { #define U_BOOT_DRIVER_ALIAS(__name, __alias) /** - * dev_get_platdata() - Get the platform data for a device + * dev_get_plat() - Get the platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return platform data, or NULL if none */ -void *dev_get_platdata(const struct udevice *dev); +void *dev_get_plat(const struct udevice *dev); /** * dev_get_parent_plat() - Get the parent platform data for a device diff --git a/include/dwmmc.h b/include/dwmmc.h index 4515a44dc27..51ab74ead35 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -259,7 +259,7 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) * .plat_auto = sizeof(struct rockchip_mmc_plat), * * To access platform data: - * struct rockchip_mmc_plat *plat = dev_get_platdata(dev); + * struct rockchip_mmc_plat *plat = dev_get_plat(dev); * * See rockchip_dw_mmc.c for an example. * diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 79dce8f0ad6..75b16353dad 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -144,7 +144,7 @@ struct clk_fixed_rate { unsigned long fixed_rate; }; -#define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_platdata(dev)) +#define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_plat(dev)) struct clk_composite { struct clk clk; diff --git a/include/sdhci.h b/include/sdhci.h index 69c2087c10c..3e5a6498185 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -443,7 +443,7 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg) * .plat_auto = sizeof(struct msm_sdhc_plat), * * To access platform data: - * struct msm_sdhc_plat *plat = dev_get_platdata(dev); + * struct msm_sdhc_plat *plat = dev_get_plat(dev); * * See msm_sdhci.c for an example. * diff --git a/include/usb.h b/include/usb.h index a3323f58018..9e1ec534eca 100644 --- a/include/usb.h +++ b/include/usb.h @@ -599,7 +599,7 @@ struct usb_hub_device { /** * struct usb_platdata - Platform data about a USB controller * - * Given a USB controller (UCLASS_USB) dev this is dev_get_platdata(dev) + * Given a USB controller (UCLASS_USB) dev this is dev_get_plat(dev) */ struct usb_platdata { enum usb_init_type init_type; -- cgit v1.2.3 From d1998a9fde0a917d6496299f6a97b6bccfdc6724 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:21 -0700 Subject: dm: treewide: Rename ofdata_to_platdata() to of_to_plat() This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 4 ++-- include/dm/device.h | 16 ++++++++-------- include/dm/platform_data/spi_pl022.h | 2 +- include/i2c.h | 10 +++++----- include/ns16550.h | 4 ++-- include/spi.h | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 2e9c1d5ef9c..af3b6b2b054 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -89,7 +89,7 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, int device_reparent(struct udevice *dev, struct udevice *new_parent); /** - * device_ofdata_to_platdata() - Read platform data for a device + * device_of_to_plat() - Read platform data for a device * * Read platform data for a device (typically from the device tree) so that * the information needed to probe the device is present. @@ -102,7 +102,7 @@ int device_reparent(struct udevice *dev, struct udevice *new_parent); * @dev: Pointer to device to process * @return 0 if OK, -ve on error */ -int device_ofdata_to_platdata(struct udevice *dev); +int device_of_to_plat(struct udevice *dev); /** * device_probe() - Probe a device, activating it diff --git a/include/dm/device.h b/include/dm/device.h index 491542c5804..ed80ae44940 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -107,7 +107,7 @@ enum { * a U_BOOT_DEVICE() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case * we translate the device tree information into plat in a function - * implemented by the driver ofdata_to_platdata method (called just before the + * implemented by the driver of_to_plat method (called just before the * probe method if the device has a device tree node. * * All three of plat, priv and uclass_priv can be allocated by the @@ -219,7 +219,7 @@ struct udevice_id { * @probe: Called to probe a device, i.e. activate it * @remove: Called to remove a device, i.e. de-activate it * @unbind: Called to unbind a device from its driver - * @ofdata_to_platdata: Called before probe to decode device tree data + * @of_to_plat: Called before probe to decode device tree data * @child_post_bind: Called after a new child has been bound * @child_pre_probe: Called before a child device is probed. The device has * memory allocated but it has not yet been probed. @@ -254,7 +254,7 @@ struct driver { int (*probe)(struct udevice *dev); int (*remove)(struct udevice *dev); int (*unbind)(struct udevice *dev); - int (*ofdata_to_platdata)(struct udevice *dev); + int (*of_to_plat)(struct udevice *dev); int (*child_post_bind)(struct udevice *dev); int (*child_pre_probe)(struct udevice *dev); int (*child_post_remove)(struct udevice *dev); @@ -624,7 +624,7 @@ int device_find_child_by_name(const struct udevice *parent, const char *name, /** * device_first_child_ofdata_err() - Find the first child and reads its plat * - * The ofdata_to_platdata() method is called on the child before it is returned, + * The of_to_plat() method is called on the child before it is returned, * but the child is not probed. * * @parent: Parent to check @@ -637,7 +637,7 @@ int device_first_child_ofdata_err(struct udevice *parent, /* * device_next_child_ofdata_err() - Find the next child and read its plat * - * The ofdata_to_platdata() method is called on the child before it is returned, + * The of_to_plat() method is called on the child before it is returned, * but the child is not probed. * * @devp: On entry, points to the previous child; on exit returns the child that @@ -798,19 +798,19 @@ static inline bool device_is_on_pci_bus(const struct udevice *dev) list_for_each_entry(pos, &parent->child_head, sibling_node) /** - * device_foreach_child_ofdata_to_platdata() - iterate through children + * device_foreach_child_of_to_plat() - iterate through children * * This stops when it gets an error, with @pos set to the device that failed to * read ofdata. * This creates a for() loop which works through the available children of * a device in order from start to end. Device ofdata is read by calling - * device_ofdata_to_platdata() on each one. The devices are not probed. + * device_of_to_plat() on each one. The devices are not probed. * * @pos: struct udevice * for the current device * @parent: parent device to scan */ -#define device_foreach_child_ofdata_to_platdata(pos, parent) \ +#define device_foreach_child_of_to_plat(pos, parent) \ for (int _ret = device_first_child_ofdata_err(parent, &dev); !_ret; \ _ret = device_next_child_ofdata_err(&dev)) diff --git a/include/dm/platform_data/spi_pl022.h b/include/dm/platform_data/spi_pl022.h index 63a58ee4535..c5aa3212915 100644 --- a/include/dm/platform_data/spi_pl022.h +++ b/include/dm/platform_data/spi_pl022.h @@ -4,7 +4,7 @@ * Quentin Schulz, Bootlin, quentin.schulz@bootlin.com * * Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use - * in ofdata_to_platdata. + * in of_to_plat. */ #ifndef __spi_pl022_h diff --git a/include/i2c.h b/include/i2c.h index d0a390141b8..e45e33f5037 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -521,17 +521,17 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, struct udevice **devp); /** - * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data + * i2c_chip_of_to_plat() - Decode standard I2C platform data * * This decodes the chip address from a device tree node and puts it into * its dm_i2c_chip structure. This should be called in your driver's - * ofdata_to_platdata() method. + * of_to_plat() method. * * @blob: Device tree blob * @node: Node offset to read from * @spi: Place to put the decoded information */ -int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip); +int i2c_chip_of_to_plat(struct udevice *dev, struct dm_i2c_chip *chip); /** * i2c_dump_msgs() - Dump a list of I2C messages @@ -568,7 +568,7 @@ struct udevice *i2c_emul_get_device(struct udevice *emul); extern struct acpi_ops i2c_acpi_ops; /** - * acpi_i2c_ofdata_to_platdata() - Read properties intended for ACPI + * acpi_i2c_of_to_plat() - Read properties intended for ACPI * * This reads the generic I2C properties from the device tree, so that these * can be used to create ACPI information for the device. @@ -579,7 +579,7 @@ extern struct acpi_ops i2c_acpi_ops; * @dev: I2C device to process * @return 0 if OK, -EINVAL if acpi,hid is not present */ -int acpi_i2c_ofdata_to_platdata(struct udevice *dev); +int acpi_i2c_of_to_plat(struct udevice *dev); #ifndef CONFIG_DM_I2C diff --git a/include/ns16550.h b/include/ns16550.h index 18c9077755b..08e933ffe79 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -241,7 +241,7 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor); int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); /** - * ns16550_serial_ofdata_to_platdata() - convert DT to platform data + * ns16550_serial_of_to_plat() - convert DT to platform data * * Decode a device tree node for an ns16550 device. This includes the * register base address and register shift properties. The caller must set @@ -250,7 +250,7 @@ int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); * @dev: dev to decode platform data for * @return: 0 if OK, -EINVAL on error */ -int ns16550_serial_ofdata_to_platdata(struct udevice *dev); +int ns16550_serial_of_to_plat(struct udevice *dev); /** * ns16550_serial_probe() - probe a serial port diff --git a/include/spi.h b/include/spi.h index 176a42cb13a..85a785e8339 100644 --- a/include/spi.h +++ b/include/spi.h @@ -601,7 +601,7 @@ int spi_chip_select(struct udevice *slave); int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); /** - * spi_slave_ofdata_to_platdata() - decode standard SPI platform data + * spi_slave_of_to_plat() - decode standard SPI platform data * * This decodes the speed and mode for a slave from a device tree node * @@ -609,8 +609,8 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); * @node: Node offset to read from * @plat: Place to put the decoded information */ -int spi_slave_ofdata_to_platdata(struct udevice *dev, - struct dm_spi_slave_platdata *plat); +int spi_slave_of_to_plat(struct udevice *dev, + struct dm_spi_slave_platdata *plat); /** * spi_cs_info() - Check information on a chip select -- cgit v1.2.3 From 8a8d24bdf174851ebb8607f359d54b72e3283b97 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:23 -0700 Subject: dm: treewide: Rename ..._platdata variables to just ..._plat Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass --- include/atmel_lcd.h | 4 ++-- include/cpu.h | 4 ++-- include/dm/platform_data/fsl_espi.h | 2 +- include/dm/platform_data/lpc32xx_hsuart.h | 4 ++-- include/dm/platform_data/pxa_mmc_gen.h | 2 +- include/dm/platform_data/serial_bcm283x_mu.h | 2 +- include/dm/platform_data/serial_coldfire.h | 4 ++-- include/dm/platform_data/serial_mxc.h | 2 +- include/dm/platform_data/serial_pl01x.h | 2 +- include/dm/platform_data/serial_pxa.h | 4 ++-- include/dm/platform_data/serial_sh.h | 2 +- include/dm/platform_data/spi_coldfire.h | 4 ++-- include/dm/platform_data/spi_davinci.h | 2 +- include/dm/root.h | 4 ++-- include/fs_loader.h | 2 +- include/ns16550.h | 6 +++--- include/p2sb.h | 4 ++-- include/pci.h | 4 ++-- include/power/acpi_pmc.h | 2 +- include/regmap.h | 6 +++--- include/scsi.h | 4 ++-- include/spi.h | 7 +++---- include/syscon.h | 2 +- include/usb.h | 12 ++++++------ include/vbe.h | 4 ++-- include/video.h | 6 +++--- 26 files changed, 50 insertions(+), 51 deletions(-) (limited to 'include') diff --git a/include/atmel_lcd.h b/include/atmel_lcd.h index 4aa955b6b2d..66436b9b277 100644 --- a/include/atmel_lcd.h +++ b/include/atmel_lcd.h @@ -10,11 +10,11 @@ #define _ATMEL_LCD_H_ /** - * struct atmel_lcd_platdata - platform data for Atmel LCDs with driver model + * struct atmel_lcd_plat - platform data for Atmel LCDs with driver model * * @timing_index: Index of LCD timing to use in device tree node */ -struct atmel_lcd_platdata { +struct atmel_lcd_plat { int timing_index; }; diff --git a/include/cpu.h b/include/cpu.h index 1d53308f7a4..5831bfa7421 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -8,7 +8,7 @@ #define __CPU_H /** - * struct cpu_platdata - platform data for a CPU + * struct cpu_plat - platform data for a CPU * @cpu_id: Platform-specific way of identifying the CPU. * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set * @device_id: Driver-defined device identifier @@ -20,7 +20,7 @@ * This can be accessed with dev_get_parent_plat() for any UCLASS_CPU * device. */ -struct cpu_platdata { +struct cpu_plat { int cpu_id; int ucode_version; ulong device_id; diff --git a/include/dm/platform_data/fsl_espi.h b/include/dm/platform_data/fsl_espi.h index 812933f51cd..de2307f7fb5 100644 --- a/include/dm/platform_data/fsl_espi.h +++ b/include/dm/platform_data/fsl_espi.h @@ -6,7 +6,7 @@ #ifndef __fsl_espi_h #define __fsl_espi_h -struct fsl_espi_platdata { +struct fsl_espi_plat { uint flags; uint speed_hz; uint num_chipselect; diff --git a/include/dm/platform_data/lpc32xx_hsuart.h b/include/dm/platform_data/lpc32xx_hsuart.h index 9bfd62833cd..6f41e0e734a 100644 --- a/include/dm/platform_data/lpc32xx_hsuart.h +++ b/include/dm/platform_data/lpc32xx_hsuart.h @@ -7,11 +7,11 @@ #define _LPC32XX_HSUART_PLAT_H /** - * struct lpc32xx_hsuart_platdata - NXP LPC32xx HSUART platform data + * struct lpc32xx_hsuart_plat - NXP LPC32xx HSUART platform data * * @base: Base register address */ -struct lpc32xx_hsuart_platdata { +struct lpc32xx_hsuart_plat { unsigned long base; }; diff --git a/include/dm/platform_data/pxa_mmc_gen.h b/include/dm/platform_data/pxa_mmc_gen.h index 9875bab2cf4..d15c1551f46 100644 --- a/include/dm/platform_data/pxa_mmc_gen.h +++ b/include/dm/platform_data/pxa_mmc_gen.h @@ -9,7 +9,7 @@ #include /* - * struct pxa_mmc_platdata - information about a PXA MMC controller + * struct pxa_mmc_plat - information about a PXA MMC controller * * @base: MMC controller base register address */ diff --git a/include/dm/platform_data/serial_bcm283x_mu.h b/include/dm/platform_data/serial_bcm283x_mu.h index 37f5174dbf2..6c77272e804 100644 --- a/include/dm/platform_data/serial_bcm283x_mu.h +++ b/include/dm/platform_data/serial_bcm283x_mu.h @@ -14,7 +14,7 @@ * * @base: Register base address */ -struct bcm283x_mu_serial_platdata { +struct bcm283x_mu_serial_plat { unsigned long base; unsigned int clock; bool skip_init; diff --git a/include/dm/platform_data/serial_coldfire.h b/include/dm/platform_data/serial_coldfire.h index ba916fece3d..5e265e9087d 100644 --- a/include/dm/platform_data/serial_coldfire.h +++ b/include/dm/platform_data/serial_coldfire.h @@ -7,13 +7,13 @@ #define __serial_coldfire_h /* - * struct coldfire_serial_platdata - information about a coldfire port + * struct coldfire_serial_plat - information about a coldfire port * * @base: Uart port base register address * @port: Uart port index, for cpu with pinmux for uart / gpio * baudrtatre: Uart port baudrate */ -struct coldfire_serial_platdata { +struct coldfire_serial_plat { unsigned long base; int port; int baudrate; diff --git a/include/dm/platform_data/serial_mxc.h b/include/dm/platform_data/serial_mxc.h index 86cd3bcf628..cc59eeb1dd1 100644 --- a/include/dm/platform_data/serial_mxc.h +++ b/include/dm/platform_data/serial_mxc.h @@ -7,7 +7,7 @@ #define __serial_mxc_h /* Information about a serial port */ -struct mxc_serial_platdata { +struct mxc_serial_plat { struct mxc_uart *reg; /* address of registers in physical memory */ bool use_dte; }; diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h index 77d96c49f03..e3d4e308a14 100644 --- a/include/dm/platform_data/serial_pl01x.h +++ b/include/dm/platform_data/serial_pl01x.h @@ -20,7 +20,7 @@ enum pl01x_type { * @skip_init: Don't attempt to change port configuration (also means @clock * is ignored) */ -struct pl01x_serial_platdata { +struct pl01x_serial_plat { unsigned long base; enum pl01x_type type; unsigned int clock; diff --git a/include/dm/platform_data/serial_pxa.h b/include/dm/platform_data/serial_pxa.h index b78bdb64094..0d7dc4c462d 100644 --- a/include/dm/platform_data/serial_pxa.h +++ b/include/dm/platform_data/serial_pxa.h @@ -40,13 +40,13 @@ #endif /* - * struct pxa_serial_platdata - information about a PXA port + * struct pxa_serial_plat - information about a PXA port * * @base: Uart port base register address * @port: Uart port index, for cpu with pinmux for uart / gpio * baudrtatre: Uart port baudrate */ -struct pxa_serial_platdata { +struct pxa_serial_plat { struct pxa_uart_regs *base; int port; int baudrate; diff --git a/include/dm/platform_data/serial_sh.h b/include/dm/platform_data/serial_sh.h index 711435d8f6e..69cd012fc5a 100644 --- a/include/dm/platform_data/serial_sh.h +++ b/include/dm/platform_data/serial_sh.h @@ -27,7 +27,7 @@ enum sh_serial_type { * @clk_mode: Clock mode, set internal (INT) or external (EXT) * @type: Type of SCIF */ -struct sh_serial_platdata { +struct sh_serial_plat { unsigned long base; unsigned int clk; enum sh_clk_mode clk_mode; diff --git a/include/dm/platform_data/spi_coldfire.h b/include/dm/platform_data/spi_coldfire.h index 8ad8eaedfde..da514bad0d3 100644 --- a/include/dm/platform_data/spi_coldfire.h +++ b/include/dm/platform_data/spi_coldfire.h @@ -10,14 +10,14 @@ #define MAX_CTAR_FIELDS 8 /* - * struct coldfire_spi_platdata - information about a coldfire spi module + * struct coldfire_spi_plat - information about a coldfire spi module * * @regs_addr: base address for module registers * @speed_hz: default SCK frequency * @mode: default SPI mode * @num_cs: number of DSPI chipselect signals */ -struct coldfire_spi_platdata { +struct coldfire_spi_plat { fdt_addr_t regs_addr; uint speed_hz; uint mode; diff --git a/include/dm/platform_data/spi_davinci.h b/include/dm/platform_data/spi_davinci.h index fbc62c262ab..42a467e40b2 100644 --- a/include/dm/platform_data/spi_davinci.h +++ b/include/dm/platform_data/spi_davinci.h @@ -7,7 +7,7 @@ #ifndef __spi_davinci_h #define __spi_davinci_h -struct davinci_spi_platdata { +struct davinci_spi_plat { struct davinci_spi_regs *regs; u8 num_cs; /* total no. of CS available */ }; diff --git a/include/dm/root.h b/include/dm/root.h index 113e92ec783..89afbee6196 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -31,7 +31,7 @@ struct global_data; void dm_fixup_for_gd_move(struct global_data *new_gd); /** - * dm_scan_platdata() - Scan all platform data and bind drivers + * dm_scan_plat() - Scan all platform data and bind drivers * * This scans all available plat and creates drivers for each * @@ -39,7 +39,7 @@ void dm_fixup_for_gd_move(struct global_data *new_gd); * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_platdata(bool pre_reloc_only); +int dm_scan_plat(bool pre_reloc_only); /** * dm_scan_fdt() - Scan the device tree and bind drivers diff --git a/include/fs_loader.h b/include/fs_loader.h index 1b3c58086f5..8de7cb18dc7 100644 --- a/include/fs_loader.h +++ b/include/fs_loader.h @@ -31,7 +31,7 @@ struct phandle_part { * @mtdpart: MTD partition for ubi partition. * @ubivol: UBI volume-name for ubifsmount. */ -struct device_platdata { +struct device_plat { struct phandle_part phandlepart; char *mtdpart; char *ubivol; diff --git a/include/ns16550.h b/include/ns16550.h index 08e933ffe79..bef29610325 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -56,7 +56,7 @@ enum ns16550_flags { }; /** - * struct ns16550_platdata - information about a NS16550 port + * struct ns16550_plat - information about a NS16550 port * * @base: Base register address * @reg_width: IO accesses size of registers (in bytes, 1 or 4) @@ -67,7 +67,7 @@ enum ns16550_flags { * @flags: A few flags (enum ns16550_flags) * @bdf: PCI slot/function (pci_dev_t) */ -struct ns16550_platdata { +struct ns16550_plat { unsigned long base; int reg_width; int reg_shift; @@ -111,7 +111,7 @@ struct NS16550 { UART_REG(ssr); /* 11*/ #endif #ifdef CONFIG_DM_SERIAL - struct ns16550_platdata *plat; + struct ns16550_plat *plat; #endif }; diff --git a/include/p2sb.h b/include/p2sb.h index a25170e3d11..ddbc8d5e14d 100644 --- a/include/p2sb.h +++ b/include/p2sb.h @@ -17,11 +17,11 @@ #define PCH_P2SB_HBDF 0x70 /** - * struct p2sb_child_platdata - Information about each child of a p2sb device + * struct p2sb_child_plat - Information about each child of a p2sb device * * @pid: Port ID for this child */ -struct p2sb_child_platdata { +struct p2sb_child_plat { uint pid; }; diff --git a/include/pci.h b/include/pci.h index a8472dd2683..d5b42cee83c 100644 --- a/include/pci.h +++ b/include/pci.h @@ -899,7 +899,7 @@ struct udevice; #ifdef CONFIG_DM_PCI /** - * struct pci_child_platdata - information stored about each PCI device + * struct pci_child_plat - information stored about each PCI device * * Every device on a PCI bus has this per-child data. * @@ -914,7 +914,7 @@ struct udevice; * @pfdev: Handle to Physical Function device * @virtid: Virtual Function Index */ -struct pci_child_platdata { +struct pci_child_plat { int devfn; unsigned short vendor; unsigned short device; diff --git a/include/power/acpi_pmc.h b/include/power/acpi_pmc.h index 222288b71a4..64176d79bc6 100644 --- a/include/power/acpi_pmc.h +++ b/include/power/acpi_pmc.h @@ -180,7 +180,7 @@ int pmc_disable_tco(struct udevice *dev); */ int pmc_global_reset_set_enable(struct udevice *dev, bool enable); -int pmc_ofdata_to_uc_platdata(struct udevice *dev); +int pmc_ofdata_to_uc_plat(struct udevice *dev); int pmc_disable_tco_base(ulong tco_base); diff --git a/include/regmap.h b/include/regmap.h index c6258face30..8216de015dd 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -373,7 +373,7 @@ int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val); int regmap_init_mem(ofnode node, struct regmap **mapp); /** - * regmap_init_mem_platdata() - Set up a new memory register map for + * regmap_init_mem_plat() - Set up a new memory register map for * of-platdata * * @dev: Device that uses this map @@ -388,8 +388,8 @@ int regmap_init_mem(ofnode node, struct regmap **mapp); * Use regmap_uninit() to free it. * */ -int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count, - struct regmap **mapp); +int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count, + struct regmap **mapp); int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index); diff --git a/include/scsi.h b/include/scsi.h index 96cb7266762..90cec99e322 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -162,14 +162,14 @@ struct scsi_cmd { #define SCSI_WRITE_SAME 0x41 /* Write Same (O) */ /** - * struct scsi_platdata - stores information about SCSI controller + * struct scsi_plat - stores information about SCSI controller * * @base: Controller base address * @max_lun: Maximum number of logical units * @max_id: Maximum number of target ids * @max_bytes_per_req: Maximum number of bytes per read/write request */ -struct scsi_platdata { +struct scsi_plat { unsigned long base; unsigned long max_lun; unsigned long max_id; diff --git a/include/spi.h b/include/spi.h index 85a785e8339..6b42b3e36ac 100644 --- a/include/spi.h +++ b/include/spi.h @@ -45,7 +45,7 @@ struct dm_spi_bus { }; /** - * struct dm_spi_platdata - platform data for all SPI slaves + * struct dm_spi_plat - platform data for all SPI slaves * * This describes a SPI slave, a child device of the SPI bus. To obtain this * struct from a spi_slave, use dev_get_parent_plat(dev) or @@ -58,7 +58,7 @@ struct dm_spi_bus { * @max_hz: Maximum bus speed that this slave can tolerate * @mode: SPI mode to use for this device (see SPI mode flags) */ -struct dm_spi_slave_platdata { +struct dm_spi_slave_plat { unsigned int cs; uint max_hz; uint mode; @@ -609,8 +609,7 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); * @node: Node offset to read from * @plat: Place to put the decoded information */ -int spi_slave_of_to_plat(struct udevice *dev, - struct dm_spi_slave_platdata *plat); +int spi_slave_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat); /** * spi_cs_info() - Check information on a chip select diff --git a/include/syscon.h b/include/syscon.h index 3df96e32764..2e02199c051 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -33,7 +33,7 @@ struct syscon_ops { * * Update: 64-bit is now supported and we have an education crisis. */ -struct syscon_base_platdata { +struct syscon_base_plat { fdt_val_t reg[2]; }; #endif diff --git a/include/usb.h b/include/usb.h index 9e1ec534eca..b3851fdb4f9 100644 --- a/include/usb.h +++ b/include/usb.h @@ -597,16 +597,16 @@ struct usb_hub_device { #if CONFIG_IS_ENABLED(DM_USB) /** - * struct usb_platdata - Platform data about a USB controller + * struct usb_plat - Platform data about a USB controller * * Given a USB controller (UCLASS_USB) dev this is dev_get_plat(dev) */ -struct usb_platdata { +struct usb_plat { enum usb_init_type init_type; }; /** - * struct usb_dev_platdata - Platform data about a USB device + * struct usb_dev_plat - Platform data about a USB device * * Given a USB device dev this structure is dev_get_parent_plat(dev). * This is used by sandbox to provide emulation data also. @@ -617,7 +617,7 @@ struct usb_platdata { * @strings: List of descriptor strings (for sandbox emulation purposes) * @desc_list: List of descriptors (for sandbox emulation purposes) */ -struct usb_dev_platdata { +struct usb_dev_plat { struct usb_device_id id; int devnum; /* @@ -659,14 +659,14 @@ struct usb_bus_priv { }; /** - * struct usb_emul_platdata - platform data about the USB emulator + * struct usb_emul_plat - platform data about the USB emulator * * Given a USB emulator (UCLASS_USB_EMUL) 'dev', this is * dev_get_uclass_plat(dev). * * @port1: USB emulator device port number on the parent hub */ -struct usb_emul_platdata { +struct usb_emul_plat { int port1; /* Port number (numbered from 1) */ }; diff --git a/include/vbe.h b/include/vbe.h index f420f493ee1..1631260eb73 100644 --- a/include/vbe.h +++ b/include/vbe.h @@ -104,10 +104,10 @@ struct vbe_ddc_info { extern struct vbe_mode_info mode_info; struct video_priv; -struct video_uc_platdata; +struct video_uc_plat; int vbe_setup_video_priv(struct vesa_mode_info *vesa, struct video_priv *uc_priv, - struct video_uc_platdata *plat); + struct video_uc_plat *plat); int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)); #endif diff --git a/include/video.h b/include/video.h index 31a12bd7996..7b7f62a8277 100644 --- a/include/video.h +++ b/include/video.h @@ -18,7 +18,7 @@ struct udevice; /** - * struct video_uc_platdata - uclass platform data for a video device + * struct video_uc_plat - uclass platform data for a video device * * This holds information that the uclass needs to know about each device. It * is accessed using dev_get_uclass_plat(dev). See 'Theory of operation' at @@ -31,7 +31,7 @@ struct udevice; * @copy_base: Base address of a hardware copy of the frame buffer. See * CONFIG_VIDEO_COPY. */ -struct video_uc_platdata { +struct video_uc_plat { uint align; uint size; ulong base; @@ -77,7 +77,7 @@ enum video_log2_bpp { * @fb: Frame buffer * @fb_size: Frame buffer size * @copy_fb: Copy of the frame buffer to keep up to date; see struct - * video_uc_platdata + * video_uc_plat * @line_length: Length of each frame buffer line, in bytes. This can be * set by the driver, but if not, the uclass will set it after * probing -- cgit v1.2.3 From 0b2fa98aa5e5dbdac4f5e2b2f67a34cc34dcc6b8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:06 -0700 Subject: linker_lists: Fix alignment issue The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary. For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset 0x18 from the start of the linker_list section. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset. With sandbox on x86_64, a reference to a linker list item using ll_entry_get() can force alignment of that particular linker_list item, if it is in the same file as the linker_list item is declared. Consider this example, where struct driver is 0x80 bytes: ll_entry_declare(struct driver, fred, driver) ... void *p = ll_entry_get(struct driver, fred, driver) If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the linker_list item. In the first case, an 8-byte 'fill' region is added: .u_boot_list_2_driver_2_testbus_drv 0x0000000000270018 0x80 test/built-in.o 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv .u_boot_list_2_driver_2_testfdt1_drv 0x0000000000270098 0x80 test/built-in.o 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv *fill* 0x0000000000270118 0x8 .u_boot_list_2_driver_2_testfdt_drv 0x0000000000270120 0x80 test/built-in.o 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv .u_boot_list_2_driver_2_testprobe_drv 0x00000000002701a0 0x80 test/built-in.o 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drv With this, the linker_list no-longer works since items after testfdt1_drv are not at the expected address. Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the linker_list feature. One possible fix is to force each separate linker_list to start on the largest possible boundary that can be required by the compiler. However that does not seem to work on x86_64, which uses 16-byte alignment in this case but needs 32-byte alignment. So add a Kconfig option to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it. Update the ll_entry_start() accordingly. Signed-off-by: Simon Glass --- include/linker_lists.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linker_lists.h b/include/linker_lists.h index d775d041e04..fd98ecd297c 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -124,7 +124,8 @@ */ #define ll_entry_start(_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ }) -- cgit v1.2.3 From 8b85dfc675f12de8d04126c07f3c796965b990c2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:07 -0700 Subject: dm: Avoid accessing seq directly At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass --- include/dm/device.h | 5 +++++ include/pci.h | 2 +- include/spi.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index ed80ae44940..7ada7200e3d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -182,6 +182,11 @@ static inline bool dev_has_of_node(struct udevice *dev) return ofnode_valid(dev->node); } +static inline int dev_seq(const struct udevice *dev) +{ + return dev->seq; +} + /** * struct udevice_id - Lists the compatible strings supported by a driver * @compatible: Compatible string diff --git a/include/pci.h b/include/pci.h index d5b42cee83c..5f36537b725 100644 --- a/include/pci.h +++ b/include/pci.h @@ -934,7 +934,7 @@ struct dm_pci_ops { * PCI buses must support reading and writing configuration values * so that the bus can be scanned and its devices configured. * - * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always. + * Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always. * If bridges exist it is possible to use the top-level bus to * access a sub-bus. In that case @bus will be the top-level bus * and PCI_BUS(bdf) will be a different (higher) value diff --git a/include/spi.h b/include/spi.h index 6b42b3e36ac..a0342e31695 100644 --- a/include/spi.h +++ b/include/spi.h @@ -116,7 +116,7 @@ enum spi_polarity { * claimed. * @bus: ID of the bus that the slave is attached to. For * driver model this is the sequence number of the SPI - * bus (bus->seq) so does not need to be stored + * bus (dev_seq(bus)) so does not need to be stored * @cs: ID of the chip select connected to the slave. * @mode: SPI mode to use for this slave (see SPI mode flags) * @wordlen: Size of SPI word in number of bits -- cgit v1.2.3 From d03adb4a78d18b5506350b3ac72ab2f18f1ed160 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:08 -0700 Subject: dm: core: Update uclass_find_next_free_req_seq() args At present this is passed a uclass ID and it has to do a lookup. The callers all have the uclass pointer, except for the I2C uclass where the code will soon be deleted. Update the argument to a uclass * instead of an ID since it is more efficient. Signed-off-by: Simon Glass --- include/dm/uclass-internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 6e3f15c2b08..2c21871e0fd 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -19,10 +19,10 @@ * maximum req_seq of the uclass + 1. * This allows assiging req_seq number in the binding order. * - * @id: Id number of the uclass + * @uc: uclass to check * @return The next free req_seq number */ -int uclass_find_next_free_req_seq(enum uclass_id id); +int uclass_find_next_free_req_seq(struct uclass *uc); /** * uclass_get_device_tail() - handle the end of a get_device call -- cgit v1.2.3 From cd53e5bf4bba421d98eb42ec71af31b521a90c2a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:09 -0700 Subject: dm: core: Add a new sequence number for devices At present each device has two sequence numbers, with 'req_seq' being set up at bind time and 'seq' at probe time. The idea is that devices can 'request' a sequence number and then the conflicts are resolved when the device is probed. This makes things complicated in a few cases, since we don't really know what the sequence number will end up being. We want to honour the bind-time requests if at all possible, but in fact the only source of these at present is the devicetree aliases. Since we have the devicetree available at bind time, we may as well just use it, in the hope that the required processing will turn out to be useful later (i.e. the device actually gets used). Add a new 'sqq' member, the bind-time sequence number. It operates in parallel to the old values for now. All devices get a valid sqq value, i.e. it is never -1. Drop an #ifdef while we are here. Signed-off-by: Simon Glass --- include/dm/device.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 7ada7200e3d..725e313eacd 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -131,6 +131,13 @@ enum { * @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... + * @sqq: Allocated sequence number for this device (-1 = none). This is set up + * when the device is bound and is unique within the device's uclass. If the + * device has an alias in the devicetree then that is used to set the sequence + * number. Otherwise, the next available number is used. Sequence numbers are + * used by certain commands that need device to be numbered (e.g. 'mmc dev') + * + * The following two fields are deprecated: * @req_seq: Requested sequence number for this device (-1 = any) * @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is probed and will be unique within the device's uclass. @@ -156,6 +163,7 @@ struct udevice { struct list_head child_head; struct list_head sibling_node; uint32_t flags; + int sqq; int req_seq; int seq; #ifdef CONFIG_DEVRES -- cgit v1.2.3 From 15a1196be81c6bfc847a58dc65151ce439630f7d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:17 -0700 Subject: dm: core: Allow manual sequence numbering Some buses have their own rules which require assigning sequence numbers with a bus-specific algorithm. For example, PCI requires that sub-buses are numbered higher than their parent buses, meaning effectively that parent buses must be numbered only after all of their child buses have been numbered. Add a uclass flag to indicate that driver model should not assign sequence numbers. In this case, the uclass must do it. Signed-off-by: Simon Glass --- include/dm/uclass.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 068e8ea8bf7..c4cd58349ed 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -44,6 +44,9 @@ struct udevice; /* Members of this uclass sequence themselves with aliases */ #define DM_UC_FLAG_SEQ_ALIAS (1 << 0) +/* Members of this uclass without aliases don't get a sequence number */ +#define DM_UC_FLAG_NO_AUTO_SEQ (1 << 1) + /* Same as DM_FLAG_ALLOC_PRIV_DMA */ #define DM_UC_FLAG_ALLOC_PRIV_DMA (1 << 5) -- cgit v1.2.3 From 981426e350801f2de93f385a371270f27dfeeb14 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:26 -0700 Subject: dm: Switch over to use new sequence number for dev_seq() Update this function to use the new sequence number and fix up the test that deals with this. Signed-off-by: Simon Glass --- include/dm/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 725e313eacd..15731d6c270 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -192,7 +192,7 @@ static inline bool dev_has_of_node(struct udevice *dev) static inline int dev_seq(const struct udevice *dev) { - return dev->seq; + return dev->sqq; } /** -- cgit v1.2.3 From 93f44e8a8c8c7878c76d3415f1d425d4fa418287 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:27 -0700 Subject: dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Check that this flag operates as expected. This patch is not earlier in this series since is uses the new behaviour of dev_seq(). Signed-off-by: Simon Glass --- include/dm/uclass-id.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index e952a9967c2..ae4425d7a57 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -16,6 +16,7 @@ enum uclass_id { UCLASS_DEMO, UCLASS_TEST, UCLASS_TEST_FDT, + UCLASS_TEST_FDT_MANUAL, UCLASS_TEST_BUS, UCLASS_TEST_PROBE, UCLASS_TEST_DUMMY, -- cgit v1.2.3 From b5b11558bc2d7088dfbb67253d8b094782334dea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:28 -0700 Subject: dm: Drop uclass_resolve_seq() This function is not needed anymore. Drop it. Signed-off-by: Simon Glass --- include/dm/uclass.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'include') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index c4cd58349ed..91edbfb47d4 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -368,21 +368,6 @@ int uclass_next_device_check(struct udevice **devp); int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data, struct udevice **devp); -/** - * uclass_resolve_seq() - Resolve a device's sequence number - * - * On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a - * sequence number automatically, or >= 0 to select a particular number. - * If the requested sequence number is in use, then this device will - * be allocated another one. - * - * Note that the device's seq value is not changed by this function. - * - * @dev: Device for which to allocate sequence number - * @return sequence number allocated, or -ve on error - */ -int uclass_resolve_seq(struct udevice *dev); - /** * uclass_id_foreach_dev() - Helper function to iteration through devices * -- cgit v1.2.3 From 991759196faa74b2e7df1cb8e87820f4ec7285f8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:29 -0700 Subject: dm: Drop the unused arg in uclass_find_device_by_seq() Now that there is only one sequence number (rather than both requested and assigned ones) we can simplify this function. Also update its caller to simplify the logic. Signed-off-by: Simon Glass --- include/dm/device.h | 18 +++++------------- include/dm/uclass-internal.h | 18 +++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 15731d6c270..75f75497c5f 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -452,24 +452,16 @@ int device_get_child_count(const struct udevice *parent); /** * device_find_child_by_seq() - Find a child device based on a sequence * - * This searches for a device with the given seq or req_seq. - * - * For seq, if an active device has this sequence it will be returned. - * If there is no such device then this will return -ENODEV. - * - * For req_seq, if a device (whether activated or not) has this req_seq - * value, that device will be returned. This is a strong indication that - * the device will receive that sequence when activated. + * This searches for a device with the given seq. * * @parent: Parent device - * @seq_or_req_seq: Sequence number to find (0=first) - * @find_req_seq: true to find req_seq, false to find seq + * @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq). * Set to NULL if none is found - * @return 0 if OK, -ve on error + * @return 0 if OK, -ENODEV if not found */ -int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int device_find_child_by_seq(const struct udevice *parent, int seq, + struct udevice **devp); /** * device_get_child_by_seq() - Get a child device based on a sequence diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 2c21871e0fd..9c23d3f223e 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -103,25 +103,17 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, /** * uclass_find_device_by_seq() - Find uclass device based on ID and sequence * - * This searches for a device with the given seq or req_seq. - * - * For seq, if an active device has this sequence it will be returned. - * If there is no such device then this will return -ENODEV. - * - * For req_seq, if a device (whether activated or not) has this req_seq - * value, that device will be returned. This is a strong indication that - * the device will receive that sequence when activated. + * This searches for a device with the given seq. * * The device is NOT probed, it is merely returned. * * @id: ID to look up - * @seq_or_req_seq: Sequence number to find (0=first) - * @find_req_seq: true to find req_seq, false to find seq + * @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq) - * @return 0 if OK, -ve on error + * @return 0 if OK, -ENODEV if not found */ -int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int uclass_find_device_by_seq(enum uclass_id id, int seq, + struct udevice **devp); /** * uclass_find_device_by_of_offset() - Find a uclass device by device tree node -- cgit v1.2.3 From a133e2179a729036e7750b497c1c38f9f6a3a835 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:30 -0700 Subject: dm: core: Update uclass_find_next_free_req_seq() for new scheme This function current deals with req_seq which is deprecated. Update it to use the new sequence numbers, putting them above existing aliases. Rename the function to make this clear. Signed-off-by: Simon Glass --- include/dm/uclass-internal.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 9c23d3f223e..3e052f95d32 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -12,17 +12,20 @@ #include /** - * uclass_find_next_free_req_seq() - Get the next free req_seq number + * uclass_find_next_free_seq() - Get the next free sequence number * - * This returns the next free req_seq number. This is useful only if - * OF_CONTROL is not used. The next free req_seq number is simply the - * maximum req_seq of the uclass + 1. - * This allows assiging req_seq number in the binding order. + * This returns the next free sequence number. This is useful only if + * OF_CONTROL is not used. The next free sequence number is simply the + * maximum sequence number used by all devices in the uclass + 1. The value + * returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled + * and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag. + * + * This allows assigning the sequence number in the binding order. * * @uc: uclass to check - * @return The next free req_seq number + * @return The next free sequence number */ -int uclass_find_next_free_req_seq(struct uclass *uc); +int uclass_find_next_free_seq(struct uclass *uc); /** * uclass_get_device_tail() - handle the end of a get_device call -- cgit v1.2.3 From 7f20d1d24989fedaad28689c0454f91d44453e80 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 21:20:32 -0700 Subject: dm: core: Drop seq and req_seq Now that migration to the new sequence numbers is complete, drop the old fields. Add a test that covers the new behaviour. Also drop the check for OF_PRIOR_STAGE since we always assign sequence numbers now. Signed-off-by: Simon Glass --- include/dm/device.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 75f75497c5f..30fc98dc345 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -131,16 +131,11 @@ enum { * @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... - * @sqq: Allocated sequence number for this device (-1 = none). This is set up + * @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is bound and is unique within the device's uclass. If the * device has an alias in the devicetree then that is used to set the sequence * number. Otherwise, the next available number is used. Sequence numbers are * used by certain commands that need device to be numbered (e.g. 'mmc dev') - * - * The following two fields are deprecated: - * @req_seq: Requested sequence number for this device (-1 = any) - * @seq: Allocated sequence number for this device (-1 = none). This is set up - * when the device is probed and will be unique within the device's uclass. * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -164,8 +159,6 @@ struct udevice { struct list_head sibling_node; uint32_t flags; int sqq; - int req_seq; - int seq; #ifdef CONFIG_DEVRES struct list_head devres_head; #endif -- cgit v1.2.3 From 741280e9accd3da20650a04f716538944d878482 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 14 Dec 2020 19:06:50 +0200 Subject: spi: spi-uclass: Fix spi_claim_bus() speed/mode setup logic Currently, when different spi slaves claim the bus consecutively using spi_claim_bus(), spi_set_speed_mode() will only be executed on the first two calls, leaving the bus in a bad state starting with the third call. This patch drops spi_slave->speed member and adds caching of bus speed/mode in dm_spi_bus struct. It also updates spi_claim_bus() to call spi_set_speed_mode() if either speed or mode is different from what the bus is currently configured for. Current behavior is to only take into account the speed, but not the mode, which seems wrong. Fixes: 60e2809a848 ("dm: spi: Avoid setting the speed with every transfer") Reviewed-by: Simon Glass Reported-by: Rasmus Villemoes Reported-by: Moshe, Yaniv Signed-off-by: Ovidiu Panait --- include/spi.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/spi.h b/include/spi.h index a0342e31695..e81f7996500 100644 --- a/include/spi.h +++ b/include/spi.h @@ -39,9 +39,22 @@ #define SPI_DEFAULT_WORDLEN 8 -/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */ +/** + * struct dm_spi_bus - SPI bus info + * + * This contains information about a SPI bus. To obtain this structure, use + * dev_get_uclass_priv(bus) where bus is the SPI bus udevice. + * + * @max_hz: Maximum speed that the bus can tolerate. + * @speed: Current bus speed. This is 0 until the bus is first claimed. + * @mode: Current bus mode. This is 0 until the bus is first claimed. + * + * TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave. + */ struct dm_spi_bus { uint max_hz; + uint speed; + uint mode; }; /** @@ -112,8 +125,6 @@ enum spi_polarity { * * @dev: SPI slave device * @max_hz: Maximum speed for this slave - * @speed: Current bus speed. This is 0 until the bus is first - * claimed. * @bus: ID of the bus that the slave is attached to. For * driver model this is the sequence number of the SPI * bus (dev_seq(bus)) so does not need to be stored @@ -131,7 +142,6 @@ struct spi_slave { #if CONFIG_IS_ENABLED(DM_SPI) struct udevice *dev; /* struct spi_slave is dev->parentdata */ uint max_hz; - uint speed; #else unsigned int bus; unsigned int cs; -- cgit v1.2.3 From ec1add1e51affd4aacc308dc37439ea13dc1b70e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 16 Dec 2020 17:25:06 -0700 Subject: dm: core: Inline a few ofnode functions in SPL A recent change to unify the flattree/livetree code introduced a small size increase in SPL on some boards. For example SPL code size for px30-core-ctouch2-px30 increased by 40 bytes. To address this we can take advantage of the fact that some of the ofnode functions are only called a few times in SPL, so it is worth inlining them. Add new Kconfig options to control this. These functions are not inlined for U-Boot proper, since this increases code size. Fixes: 2ebea5eaebf ("dm: core: Combine the flattree and livetree binding code") Signed-off-by: Simon Glass --- include/dm/ofnode.h | 56 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 53f04ac91d0..5b088650d3b 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -10,6 +10,7 @@ /* TODO(sjg@chromium.org): Drop fdtdec.h include */ #include #include +#include #include /* Enable checks to protect against invalid calls */ @@ -357,17 +358,6 @@ const char *ofnode_read_string(ofnode node, const char *propname); */ int ofnode_read_u32_array(ofnode node, const char *propname, u32 *out_values, size_t sz); -/** - * ofnode_is_enabled() - Checks whether a node is enabled. - * This looks for a 'status' property. If this exists, then returns true if - * the status is 'okay' and false otherwise. If there is no status property, - * it returns true on the assumption that anything mentioned should be enabled - * by default. - * - * @node: node to examine - * @return false (not enabled) or true (enabled) - */ -bool ofnode_is_enabled(ofnode node); /** * ofnode_read_bool() - read a boolean value from a property @@ -388,6 +378,49 @@ bool ofnode_read_bool(ofnode node, const char *propname); */ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name); +#if CONFIG_IS_ENABLED(DM_INLINE_OFNODE) +static inline bool ofnode_is_enabled(ofnode node) +{ + if (ofnode_is_np(node)) { + return of_device_is_available(ofnode_to_np(node)); + } else { + return fdtdec_get_is_enabled(gd->fdt_blob, + ofnode_to_offset(node)); + } +} + +static inline ofnode ofnode_first_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->child); + + return offset_to_ofnode( + fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} + +static inline ofnode ofnode_next_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->sibling); + + return offset_to_ofnode( + fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} +#else +/** + * ofnode_is_enabled() - Checks whether a node is enabled. + * This looks for a 'status' property. If this exists, then returns true if + * the status is 'okay' and false otherwise. If there is no status property, + * it returns true on the assumption that anything mentioned should be enabled + * by default. + * + * @node: node to examine + * @return false (not enabled) or true (enabled) + */ +bool ofnode_is_enabled(ofnode node); + /** * ofnode_first_subnode() - find the first subnode of a parent node * @@ -405,6 +438,7 @@ ofnode ofnode_first_subnode(ofnode node); * has no more siblings) */ ofnode ofnode_next_subnode(ofnode node); +#endif /* DM_INLINE_OFNODE */ /** * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode) -- cgit v1.2.3 From c0c21d67f0654f9d3641b9dd3bdfd635110c2bc1 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 20 Dec 2020 11:05:38 +0100 Subject: efi_loader: make variable store size customizable Currently the size of the buffer to keep UEFI variables in memory is fixed at 16384 bytes. This size has proven to be too small for some use cases. Make the size of the memory buffer for UEFI variables customizable. Reported-by: Paulo Alcantara (SUSE) Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- include/efi_variable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_variable.h b/include/efi_variable.h index 4704a3c16e6..bf5076233e4 100644 --- a/include/efi_variable.h +++ b/include/efi_variable.h @@ -91,7 +91,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes, #define EFI_VAR_FILE_NAME "ubootefi.var" -#define EFI_VAR_BUF_SIZE 0x4000 +#define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE /* * This constant identifies the file format for storing UEFI variables in -- cgit v1.2.3 From d0be67657d64523b4499d385390c08c2bafab1bc Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 25 Dec 2020 14:30:04 +0100 Subject: fs: fat: eliminate DIRENTSPERBLOCK() macro The FAT filesystem implementation uses several marcros referring to a magic variable name mydata which renders the code less readable. Eliminate one of them which is only used for a debug() statement. Use log_debug() instead of debug(). Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/fat.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/fat.h b/include/fat.h index 3c29a4484d4..8cae283030f 100644 --- a/include/fat.h +++ b/include/fat.h @@ -22,7 +22,6 @@ struct disk_partition; #define MAX_CLUSTSIZE CONFIG_FS_FAT_MAX_CLUSTSIZE -#define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry)) #define DIRENTSPERCLUST ((mydata->clust_size * mydata->sect_size) / \ sizeof(dir_entry)) -- cgit v1.2.3 From c0029e4e25c10d627f4bff62cdb4074bb2c7eaf7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 31 Dec 2020 00:38:13 +0100 Subject: fs/fat: implement fsuuid command The FAT file system does not have a UUID but a 4 byte volume ID. Let the fsuuid command show it in XXXX-XXXX format. Signed-off-by: Heinrich Schuchardt --- include/fat.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/fat.h b/include/fat.h index 8cae283030f..b9f273f381f 100644 --- a/include/fat.h +++ b/include/fat.h @@ -212,4 +212,16 @@ int fat_unlink(const char *filename); int fat_mkdir(const char *dirname); void fat_close(void); void *fat_next_cluster(fat_itr *itr, unsigned int *nbytes); + +/** + * fat_uuid() - get FAT volume ID + * + * The FAT volume ID returned in @uuid_str as hexadecimal number in XXXX-XXXX + * format. + * + * @uuid_str: caller allocated buffer of at least 10 bytes for the volume ID + * Return: 0 on success + */ +int fat_uuid(char *uuid_str); + #endif /* _FAT_H_ */ -- cgit v1.2.3 From 0ce3fb55e0be286f1f7686aeb452ee77100a2493 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 28 Dec 2020 22:42:51 +0100 Subject: efi_loader: describe struct efi_loaded_image_obj Add the missing description of some fields of struct efi_loaded_image_obj. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 365f3d01dc7..280225a7c15 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -304,8 +304,10 @@ enum efi_image_auth_status { * @exit_status: exit status passed to Exit() * @exit_data_size: exit data size passed to Exit() * @exit_data: exit data passed to Exit() - * @exit_jmp: long jump buffer for returning form started image + * @exit_jmp: long jump buffer for returning from started image * @entry: entry address of the relocated image + * @image_type: indicates if the image is an applicition or a driver + * @auth_status: indicates if the image is authenticated */ struct efi_loaded_image_obj { struct efi_object header; -- cgit v1.2.3 From f8212f09702f802ffab42769133e3114bd6e5e77 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 28 Dec 2020 23:24:40 +0100 Subject: efi_loader: use after free in efi_exit() Do not use data from the loaded image object after deleting it. Fixes: 126a43f15b36 ("efi_loader: unload applications upon Exit()") Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 280225a7c15..62a6c3de5a0 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -311,10 +311,10 @@ enum efi_image_auth_status { */ struct efi_loaded_image_obj { struct efi_object header; - efi_status_t exit_status; + efi_status_t *exit_status; efi_uintn_t *exit_data_size; u16 **exit_data; - struct jmp_buf_data exit_jmp; + struct jmp_buf_data *exit_jmp; EFIAPI efi_status_t (*entry)(efi_handle_t image_handle, struct efi_system_table *st); u16 image_type; -- cgit v1.2.3 From fe179d7fb5c10d8a4e299af06c766f47f2c8d51a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 31 Dec 2020 12:26:46 +0200 Subject: efi_loader: Add size checks to efi_create_indexed_name() Although the function description states the caller must provide a sufficient buffer, it's better to have in function checks that the destination buffer can hold the intended value. So let's add an extra argument with the buffer size and check that before doing any copying. Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 62a6c3de5a0..790d4bf64c9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -824,7 +824,8 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, void efi_memcpy_runtime(void *dest, const void *src, size_t n); /* commonly used helper function */ -u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index); +u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name, + unsigned int index); extern const struct efi_firmware_management_protocol efi_fmp_fit; extern const struct efi_firmware_management_protocol efi_fmp_raw; -- cgit v1.2.3 From ab201a116f1e825b1728a0133718427885381efd Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Wed, 30 Dec 2020 19:27:04 +0530 Subject: fsp: Move and rename fsp_types.h file The fsp_types.h header file contains macros for building signatures of different widths. These signature macros are architecture agnostic, and can be used in all places which use signatures in a data structure. Move and rename the fsp_types.h under the common include header. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- include/signatures.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 include/signatures.h (limited to 'include') diff --git a/include/signatures.h b/include/signatures.h new file mode 100644 index 00000000000..4042db1e00b --- /dev/null +++ b/include/signatures.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: Intel */ +/* + * Copyright (C) 2013, Intel Corporation + * Copyright (C) 2014, Bin Meng + */ + +#ifndef __SIGNATURES_H__ +#define __SIGNATURES_H__ + +/** + * Returns a 16-bit signature built from 2 ASCII characters. + * + * This macro returns a 16-bit value built from the two ASCII characters + * specified by A and B. + * + * @A: The first ASCII character. + * @B: The second ASCII character. + * + * @return: A 16-bit value built from the two ASCII characters specified by + * A and B. + */ +#define SIGNATURE_16(A, B) ((A) | (B << 8)) + +/** + * Returns a 32-bit signature built from 4 ASCII characters. + * + * This macro returns a 32-bit value built from the four ASCII characters + * specified by A, B, C, and D. + * + * @A: The first ASCII character. + * @B: The second ASCII character. + * @C: The third ASCII character. + * @D: The fourth ASCII character. + * + * @return: A 32-bit value built from the two ASCII characters specified by + * A, B, C and D. + */ +#define SIGNATURE_32(A, B, C, D) \ + (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16)) + +/** + * Returns a 64-bit signature built from 8 ASCII characters. + * + * This macro returns a 64-bit value built from the eight ASCII characters + * specified by A, B, C, D, E, F, G,and H. + * + * @A: The first ASCII character. + * @B: The second ASCII character. + * @C: The third ASCII character. + * @D: The fourth ASCII character. + * @E: The fifth ASCII character. + * @F: The sixth ASCII character. + * @G: The seventh ASCII character. + * @H: The eighth ASCII character. + * + * @return: A 64-bit value built from the two ASCII characters specified by + * A, B, C, D, E, F, G and H. + */ +#define SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (SIGNATURE_32(A, B, C, D) | ((u64)(SIGNATURE_32(E, F, G, H)) << 32)) + +#endif /* __SIGNATURES_H__ */ -- cgit v1.2.3 From 201b8068f35385c1c7794f24d0a3ac427210f241 Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Wed, 30 Dec 2020 19:27:07 +0530 Subject: efi_loader: Make the pkcs7 header parsing function an extern The pkcs7 header parsing functionality is pretty generic, and can be used by other features like capsule authentication. Make the function an extern, also changing it's name to efi_parse_pkcs7_header Signed-off-by: Sughosh Ganu --- include/efi_loader.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 790d4bf64c9..f1dfb1d33fd 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -820,6 +820,10 @@ bool efi_secure_boot_enabled(void); bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, WIN_CERTIFICATE **auth, size_t *auth_len); +struct pkcs7_message *efi_parse_pkcs7_header(const void *buf, + size_t buflen, + u8 **tmpbuf); + /* runtime implementation of memcpy() */ void efi_memcpy_runtime(void *dest, const void *src, size_t n); -- cgit v1.2.3 From b4f20a5d83f0b8a5c30128966eabe68748631e66 Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Wed, 30 Dec 2020 19:27:08 +0530 Subject: efi_loader: Re-factor code to build the signature store from efi signature list The efi_sigstore_parse_sigdb function reads the uefi authenticated variable, stored in the signature database format and builds the signature store structure. Factor out the code for building the signature store. This can then be used by the capsule authentication routine to build the signature store even when the signature database is not stored as an uefi authenticated variable Signed-off-by: Sughosh Ganu --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index f1dfb1d33fd..7fd65eeb8db 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -813,6 +813,8 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, int nocheck); void efi_sigstore_free(struct efi_signature_store *sigstore); +struct efi_signature_store *efi_build_signature_store(void *sig_list, + efi_uintn_t size); struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name); bool efi_secure_boot_enabled(void); -- cgit v1.2.3 From 04be98bd6bcfccf3ab028fda0ca962dd00f61260 Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Wed, 30 Dec 2020 19:27:09 +0530 Subject: efi: capsule: Add support for uefi capsule authentication Add support for authenticating uefi capsules. Most of the signature verification functionality is shared with the uefi secure boot feature. The root certificate containing the public key used for the signature verification is stored as part of the device tree blob. The root certificate is stored as an efi signature list(esl) file -- this file contains the x509 certificate which is the root certificate. Signed-off-by: Sughosh Ganu --- include/efi_api.h | 18 ++++++++++++++++++ include/efi_loader.h | 6 ++++++ 2 files changed, 24 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index e82d4ca9ff4..ecb43a06070 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1812,6 +1812,24 @@ struct efi_variable_authentication_2 { struct win_certificate_uefi_guid auth_info; } __attribute__((__packed__)); +/** + * efi_firmware_image_authentication - Capsule authentication method + * descriptor + * + * This structure describes an authentication information for + * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set + * and should be included as part of the capsule. + * Only EFI_CERT_TYPE_PKCS7_GUID is accepted. + * + * @monotonic_count: Count to prevent replay + * @auth_info: Authentication info + */ +struct efi_firmware_image_authentication { + uint64_t monotonic_count; + struct win_certificate_uefi_guid auth_info; +} __attribute__((__packed__)); + + /** * efi_signature_data - A format of signature * diff --git a/include/efi_loader.h b/include/efi_loader.h index 7fd65eeb8db..4719fa93f06 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -819,6 +819,8 @@ struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name); bool efi_secure_boot_enabled(void); +bool efi_capsule_auth_enabled(void); + bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, WIN_CERTIFICATE **auth, size_t *auth_len); @@ -847,6 +849,10 @@ efi_status_t EFIAPI efi_query_capsule_caps( u64 *maximum_capsule_size, u32 *reset_type); +efi_status_t efi_capsule_authenticate(const void *capsule, + efi_uintn_t capsule_size, + void **image, efi_uintn_t *image_size); + #define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" /* Hook at initialization */ -- cgit v1.2.3 From 6b80de790cf95c5e2e3fab57b33a9db1004e4ccb Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Thu, 17 Dec 2020 03:15:56 -0700 Subject: microblaze: Add nor device to distro boot Add parallel nor device to distroboot for microblaze. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- include/configs/microblaze-generic.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index bc0bf049737..59b20cf116a 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -81,6 +81,20 @@ # define BOOT_TARGET_DEVICES_QSPI(func) #endif +#if defined(CONFIG_MTD_NOR_FLASH) +# define BOOT_TARGET_DEVICES_NOR(func) func(NOR, nor, na) +#else +# define BOOT_TARGET_DEVICES_NOR(func) +#endif + +#define BOOTENV_DEV_NOR(devtypeu, devtypel, instance) \ + "bootcmd_nor=cp.b ${script_offset_nor} ${scriptaddr} ${script_size_f} && " \ + "echo NOR: Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; echo NOR: SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_NOR(devtypeu, devtypel, instance) \ + "nor " + #define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \ "bootcmd_qspi=sf probe 0 0 0 && " \ "sf read ${scriptaddr} ${script_offset_f} ${script_size_f} && " \ @@ -101,7 +115,8 @@ #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_JTAG(func) \ - BOOT_TARGET_DEVICES_QSPI(func) \ + BOOT_TARGET_DEVICES_QSPI(func) \ + BOOT_TARGET_DEVICES_NOR(func) \ BOOT_TARGET_DEVICES_DHCP(func) \ BOOT_TARGET_DEVICES_PXE(func) -- cgit v1.2.3 From 17da310ac41424f056af3a88a0ff081925a027ff Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 14 Dec 2020 09:14:03 +0100 Subject: video: Fix video sync kernel-doc format Place description below function parameters to make kernel-doc stript happy. Also rename dev to vid to be aligned with function parameters. Fixes: 1acafc73bfc7 ("dm: video: Add a video uclass") Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/video.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/video.h b/include/video.h index 9d09d2409af..7313b17f7ce 100644 --- a/include/video.h +++ b/include/video.h @@ -151,13 +151,13 @@ int video_clear(struct udevice *dev); /** * video_sync() - Sync a device's frame buffer with its hardware * + * @vid: Device to sync + * @force: True to force a sync even if there was one recently (this is + * very expensive on sandbox) + * * Some frame buffers are cached or have a secondary frame buffer. This * function syncs these up so that the current contents of the U-Boot frame * buffer are displayed to the user. - * - * @dev: Device to sync - * @force: True to force a sync even if there was one recently (this is - * very expensive on sandbox) */ void video_sync(struct udevice *vid, bool force); -- cgit v1.2.3 From 9de731f295c5f1aa0f55f30b076b94f9cb72428e Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 14 Dec 2020 08:47:52 +0100 Subject: video: Let video_sync to return error value This patch is preparation for follow up one to support cases where synchronization can fail. Suggested-by: Simon Glass Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/video.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/video.h b/include/video.h index 7313b17f7ce..1bfe6843a80 100644 --- a/include/video.h +++ b/include/video.h @@ -155,11 +155,13 @@ int video_clear(struct udevice *dev); * @force: True to force a sync even if there was one recently (this is * very expensive on sandbox) * + * @return: 0 always + * * Some frame buffers are cached or have a secondary frame buffer. This * function syncs these up so that the current contents of the U-Boot frame * buffer are displayed to the user. */ -void video_sync(struct udevice *vid, bool force); +int video_sync(struct udevice *vid, bool force); /** * video_sync_all() - Sync all devices' frame buffers with there hardware -- cgit v1.2.3 From 9d69c2d9a8eb27bfa2ac0ac1a0fc779f5eccb49b Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 3 Dec 2020 09:30:00 +0100 Subject: video: Introduce video_sync operation Some drivers like LCD connected via SPI requires explicit sync function which copy framebuffer content over SPI to controller to display. This hook doesn't exist yet that's why introduce it via video operations. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/video.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/video.h b/include/video.h index 1bfe6843a80..12fc525ab4e 100644 --- a/include/video.h +++ b/include/video.h @@ -114,8 +114,16 @@ struct video_priv { u8 bg_col_idx; }; -/* Placeholder - there are no video operations at present */ +/** + * struct video_ops - structure for keeping video operations + * @video_sync: Synchronize FB with device. Some device like SPI based LCD + * displays needs synchronization when data in an FB is available. + * For these devices implement video_sync hook to call a sync + * function. vid is pointer to video device udevice. Function + * should return 0 on success video_sync and error code otherwise + */ struct video_ops { + int (*video_sync)(struct udevice *vid); }; #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops) @@ -155,7 +163,7 @@ int video_clear(struct udevice *dev); * @force: True to force a sync even if there was one recently (this is * very expensive on sandbox) * - * @return: 0 always + * @return: 0 on success, error code otherwise * * Some frame buffers are cached or have a secondary frame buffer. This * function syncs these up so that the current contents of the U-Boot frame -- cgit v1.2.3 From d30c7209dfb4c6e4f38f8b42354e44885b53f301 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:18 -0700 Subject: serial: Update NS16550_t and struct NS16550 Typedefs should not be used in U-Boot and structs should be lower case. Update the code to use struct ns16550 consistently. Put a header guard on the file while we are here. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/ns16550.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/ns16550.h b/include/ns16550.h index bef29610325..75c5bf61fd3 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -21,6 +21,9 @@ * will not allocate storage for arrays of size 0 */ +#ifndef __ns16550_h +#define __ns16550_h + #include #ifdef CONFIG_DM_SERIAL @@ -82,7 +85,7 @@ struct ns16550_plat { struct udevice; -struct NS16550 { +struct ns16550 { UART_REG(rbr); /* 0 */ UART_REG(ier); /* 1 */ UART_REG(fcr); /* 2 */ @@ -120,8 +123,6 @@ struct NS16550 { #define dll rbr #define dlm ier -typedef struct NS16550 *NS16550_t; - /* * These are the definitions for the FIFO Control Register */ @@ -221,11 +222,11 @@ typedef struct NS16550 *NS16550_t; /* useful defaults for LCR */ #define UART_LCR_8N1 0x03 -void NS16550_init(NS16550_t com_port, int baud_divisor); -void NS16550_putc(NS16550_t com_port, char c); -char NS16550_getc(NS16550_t com_port); -int NS16550_tstc(NS16550_t com_port); -void NS16550_reinit(NS16550_t com_port, int baud_divisor); +void NS16550_init(struct ns16550 *com_port, int baud_divisor); +void NS16550_putc(struct ns16550 *com_port, char c); +char NS16550_getc(struct ns16550 *com_port); +int NS16550_tstc(struct ns16550 *com_port); +void NS16550_reinit(struct ns16550 *com_port, int baud_divisor); /** * ns16550_calc_divisor() - calculate the divisor given clock and baud rate @@ -238,7 +239,7 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor); * @baudrate: Required baud rate * @return baud rate divisor that should be used */ -int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); +int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate); /** * ns16550_serial_of_to_plat() - convert DT to platform data @@ -266,3 +267,5 @@ int ns16550_serial_probe(struct udevice *dev); * These should be used by the client driver for the driver's 'ops' member */ extern const struct dm_serial_ops ns16550_serial_ops; + +#endif /* __ns16550_h */ -- cgit v1.2.3 From 2d6bf754ced8fc66cb945d026b66865da4fede85 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:19 -0700 Subject: serial: Rename ns16550 functions to lower case Lower case should be used for function names. Update this driver and its callers accordingly. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/ns16550.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/ns16550.h b/include/ns16550.h index 75c5bf61fd3..bef20719980 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -222,11 +222,11 @@ struct ns16550 { /* useful defaults for LCR */ #define UART_LCR_8N1 0x03 -void NS16550_init(struct ns16550 *com_port, int baud_divisor); -void NS16550_putc(struct ns16550 *com_port, char c); -char NS16550_getc(struct ns16550 *com_port); -int NS16550_tstc(struct ns16550 *com_port); -void NS16550_reinit(struct ns16550 *com_port, int baud_divisor); +void ns16550_init(struct ns16550 *com_port, int baud_divisor); +void ns16550_putc(struct ns16550 *com_port, char c); +char ns16550_getc(struct ns16550 *com_port); +int ns16550_tstc(struct ns16550 *com_port); +void ns16550_reinit(struct ns16550 *com_port, int baud_divisor); /** * ns16550_calc_divisor() - calculate the divisor given clock and baud rate -- cgit v1.2.3 From 38d6b7ebdaee3e0e8426ef1b9df88bdce8ae2e75 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:21 -0700 Subject: spl: Drop bd_info in the data section This uses up space in the SPL binary but it always starts as zero. Also some boards cannot support data in TPL (e.g. Intel Apollo Lake). Use malloc() to allocate this structure instead, by moving the init a little later, after malloc() is inited. Make this function optional since it pulls in malloc(). This reduces the TPL binary size on coral by about 64 bytes Signed-off-by: Simon Glass --- include/spl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/spl.h b/include/spl.h index 374a295fa36..a7648787b74 100644 --- a/include/spl.h +++ b/include/spl.h @@ -285,7 +285,15 @@ u32 spl_mmc_boot_mode(const u32 boot_device); * If not overridden, it is weakly defined in common/spl/spl_mmc.c. */ int spl_mmc_boot_partition(const u32 boot_device); -void spl_set_bd(void); + +/** + * spl_alloc_bd() - Allocate space for bd_info + * + * This sets up the gd->bd pointer by allocating memory for it + * + * @return 0 if OK, -ENOMEM if out of memory + */ +int spl_alloc_bd(void); /** * spl_set_header_raw_uboot() - Set up a standard SPL image structure -- cgit v1.2.3 From 9c503137b73534c3b5abb90691b4d9675b1cdead Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:23 -0700 Subject: dm: core: Use 'uclass_driver' for the uclass linker_list At present the name 'uclass_driver' is used for the uclass linker list. This does not follow the convention of using the struct name. Fix it. Signed-off-by: Simon Glass --- include/dm/uclass.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 91edbfb47d4..fde08fe157a 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -112,7 +112,7 @@ struct uclass_driver { /* Declare a new uclass_driver */ #define UCLASS_DRIVER(__name) \ - ll_entry_declare(struct uclass_driver, __name, uclass) + ll_entry_declare(struct uclass_driver, __name, uclass_driver) /** * uclass_get() - Get a uclass based on an ID, creating it if needed -- cgit v1.2.3 From 806473933adf52740864ab6cdab8c90a84c0b1f3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:26 -0700 Subject: dm: core: Add function to access uclass priv Add functions so this information is not accessed directly. This will be needed for of-platdata which stores it in a different place. Signed-off-by: Simon Glass --- include/dm/uclass-internal.h | 14 ++++++++++++++ include/dm/uclass.h | 8 ++++++++ 2 files changed, 22 insertions(+) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 3e052f95d32..c5a464be7c4 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -11,6 +11,20 @@ #include +/** + * uclass_set_priv() - Set the private data for a uclass + * + * This is normally handled by driver model, which automatically allocates + * private data when an 'auto' size if provided by the uclass driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @uc Uclass to update + * @priv New private-data pointer + */ +void uclass_set_priv(struct uclass *uc, void *priv); + /** * uclass_find_next_free_seq() - Get the next free sequence number * diff --git a/include/dm/uclass.h b/include/dm/uclass.h index fde08fe157a..20d4b9e6832 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -114,6 +114,14 @@ struct uclass_driver { #define UCLASS_DRIVER(__name) \ ll_entry_declare(struct uclass_driver, __name, uclass_driver) +/** + * uclass_get_priv() - Get the private data for a uclass + * + * @uc Uclass to check + * @return private data, or NULL if none + */ +void *uclass_get_priv(const struct uclass *uc); + /** * uclass_get() - Get a uclass based on an ID, creating it if needed * -- cgit v1.2.3 From 12559f5bab3e43b603dccfa6c354ffd7da03249c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:27 -0700 Subject: dm: core: Add functions to set priv/plat This should not normally be needed in drivers, but add accessors for the few cases that exist. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index af3b6b2b054..03b092bdf7d 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -189,6 +189,90 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv, } #endif +/** + * dev_set_priv() - Set the private data for a device + * + * This is normally handled by driver model, which automatically allocates + * private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @priv New private-data pointer + */ +void dev_set_priv(struct udevice *dev, void *priv); + +/** + * dev_set_parent_priv() - Set the parent-private data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_priv: New parent-private data + */ +void dev_set_parent_priv(struct udevice *dev, void *parent_priv); + +/** + * dev_set_uclass_priv() - Set the uclass private data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_priv: New uclass private data + */ +void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv); + +/** + * dev_set_plat() - Set the platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @plat New platform-data pointer + */ +void dev_set_plat(struct udevice *dev, void *priv); + +/** + * dev_set_parent_plat() - Set the parent platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_plat: New parent platform data + */ +void dev_set_parent_plat(struct udevice *dev, void *parent_plat); + +/** + * dev_set_uclass_plat() - Set the uclass platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_plat: New uclass platform data + */ +void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat); + /** * simple_bus_translate() - translate a bus address to a system address * -- cgit v1.2.3 From fb8c9fb3fa422314d53516ba30f280be1e7216f9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:30 -0700 Subject: dm: core: Rename the priv/plat members These are supposed to be private to driver model, not accessed by any code outside. Add a trailing underscore to indicate this. Signed-off-by: Simon Glass --- include/dm/device.h | 29 +++++++++++++++++------------ include/dm/uclass.h | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 30fc98dc345..daebd6eb68d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -116,17 +116,22 @@ enum { * * @driver: The driver used by this device * @name: Name of device, typically the FDT node name - * @plat: Configuration data for this device - * @parent_plat: The parent bus's configuration data for this device - * @uclass_plat: The uclass's configuration data for this device + * @plat_: Configuration data for this device (do not access outside driver + * model) + * @parent_plat_: The parent bus's configuration data for this device (do not + * access outside driver model) + * @uclass_plat_: The uclass's configuration data for this device (do not access + * outside driver model) * @node: Reference to device tree node for this device * @driver_data: Driver data word for the entry that matched this device with * its driver * @parent: Parent of this device, or NULL for the top level device - * @priv: Private data for this device + * @priv_: Private data for this device (do not access outside driver model) * @uclass: Pointer to uclass for this device - * @uclass_priv: The uclass's private data for this device - * @parent_priv: The parent's private data for this device + * @uclass_priv_: The uclass's private data for this device (do not access + * outside driver model) + * @parent_priv_: The parent's private data for this device (do not access + * outside driver model) * @uclass_node: Used by uclass to link its devices * @child_head: List of children of this device * @sibling_node: Next device in list of all devices @@ -144,16 +149,16 @@ enum { struct udevice { const struct driver *driver; const char *name; - void *plat; - void *parent_plat; - void *uclass_plat; + void *plat_; + void *parent_plat_; + void *uclass_plat_; ofnode node; ulong driver_data; struct udevice *parent; - void *priv; + void *priv_; struct uclass *uclass; - void *uclass_priv; - void *parent_priv; + void *uclass_priv_; + void *parent_priv_; struct list_head uclass_node; struct list_head child_head; struct list_head sibling_node; diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 20d4b9e6832..f06339e4d69 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -24,7 +24,7 @@ * There may be drivers for on-chip SoC GPIO banks, I2C GPIO expanders and * PMIC IO lines, all made available in a unified way through the uclass. * - * @priv: Private data for this uclass + * @priv_: Private data for this uclass (do not access outside driver model) * @uc_drv: The driver for the uclass itself, not to be confused with a * 'struct driver' * @dev_head: List of devices in this uclass (devices are attached to their @@ -32,7 +32,7 @@ * @sibling_node: Next uclass in the linked list of uclasses */ struct uclass { - void *priv; + void *priv_; struct uclass_driver *uc_drv; struct list_head dev_head; struct list_head sibling_node; -- cgit v1.2.3 From 3f8760824e028f5710e3d8ec029c8cc9fade1729 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 23 Dec 2020 08:11:17 -0700 Subject: test: Use a simple variable to record removed device At present the entire test state is effective passed into a test driver just to record which device was removed. This is unnecessary and makes it harder to track what is going on. Use a simple boolean instead. Also drop the unused 'removed' member while we are here. Signed-off-by: Simon Glass --- include/dm/test.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/dm/test.h b/include/dm/test.h index b2adce730ad..cbe1b57d95f 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -134,14 +134,12 @@ extern struct unit_test_state global_dm_test_state; * @testdev: Test device * @force_fail_alloc: Force all memory allocs to fail * @skip_post_probe: Skip uclass post-probe processing - * @removed: Used to keep track of a device that was removed */ struct dm_test_state { struct udevice *root; struct udevice *testdev; int force_fail_alloc; int skip_post_probe; - struct udevice *removed; }; /* Declare a new driver model test */ -- cgit v1.2.3 From 079ac59586fa1e0c69020e74e4f16cbfdf82232d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 23 Dec 2020 08:11:18 -0700 Subject: test: Move some test drivers into their own file At present several test drivers are part of the test file itself. Some of these are useful for of-platdata tests. Separate them out so we can use them for other things also. A few adjustments are needed so this driver can build for sandbox_spl as well. Signed-off-by: Simon Glass --- include/dm/test.h | 18 ++++++++++++++++++ include/test/test.h | 9 +++++++++ 2 files changed, 27 insertions(+) (limited to 'include') diff --git a/include/dm/test.h b/include/dm/test.h index cbe1b57d95f..6ac6672cd6f 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -167,6 +167,24 @@ struct sandbox_sdl_plat { int font_size; }; +/** + * struct dm_test_parent_plat - Used to track state in bus tests + * + * @count: + * @bind_flag: Indicates that the child post-bind method was called + * @uclass_bind_flag: Also indicates that the child post-bind method was called + */ +struct dm_test_parent_plat { + int count; + int bind_flag; + int uclass_bind_flag; +}; + +enum { + TEST_FLAG_CHILD_PROBED = 10, + TEST_FLAG_CHILD_REMOVED = -7, +}; + /* Declare ping methods for the drivers */ int test_ping(struct udevice *dev, int pingval, int *pingret); int testfdt_ping(struct udevice *dev, int pingval, int *pingret); diff --git a/include/test/test.h b/include/test/test.h index 03e29290bf4..3fdaa2b5e51 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -94,6 +94,15 @@ enum { TEST_DEVRES_SIZE3 = 37, }; +/** + * testbus_get_clear_removed() - Test function to obtain removed device + * + * This is used in testbus to find out which device was removed. Calling this + * function returns a pointer to the device and then clears it back to NULL, so + * that a future test can check it. + */ +struct udevice *testbus_get_clear_removed(void); + /** * dm_test_main() - Run driver model tests * -- cgit v1.2.3 From e2a7cfe9d5fce65789972a31ff50fb1d8d509848 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:00 -0700 Subject: spi: Tidy up get/set of device node This code is a bit odd in that it only reads and updates the livetree version of the device ofnode. This means it won't work with flattree. Update the code to work as it was presumably intended. Signed-off-by: Simon Glass --- include/linux/mtd/mtd.h | 9 ++++----- include/linux/mtd/nand.h | 14 ++++++++++++++ include/linux/mtd/spi-nor.h | 2 ++ include/linux/mtd/spinand.h | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 1b9151714c0..54d03d02402 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -332,15 +332,14 @@ struct mtd_info { }; #if IS_ENABLED(CONFIG_DM) -static inline void mtd_set_of_node(struct mtd_info *mtd, - const struct device_node *np) +static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node) { - mtd->dev->node.np = np; + mtd->dev->node = node; } -static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) +static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd) { - return mtd->dev->node.np; + return mtd->dev->node; } #else struct device_node; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 13e8dd11035..7774c17ad5d 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -389,6 +389,7 @@ static inline int nanddev_unregister(struct nand_device *nand) return mtd_device_unregister(nand->mtd); } +#ifndef __UBOOT__ /** * nanddev_set_of_node() - Attach a DT node to a NAND device * @nand: NAND device @@ -412,6 +413,19 @@ static inline const struct device_node *nanddev_get_of_node(struct nand_device * { return mtd_get_of_node(nand->mtd); } +#else +/** + * nanddev_set_of_node() - Attach a DT node to a NAND device + * @nand: NAND device + * @node: ofnode + * + * Attach a DT node to a NAND device. + */ +static inline void nanddev_set_ofnode(struct nand_device *nand, ofnode node) +{ + mtd_set_ofnode(nand->mtd, node); +} +#endif /* __UBOOT__ */ /** * nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 233fdc341a7..2642bf91d00 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -352,6 +352,7 @@ struct spi_nor { u32 erase_size; }; +#ifndef __UBOOT__ static inline void spi_nor_set_flash_node(struct spi_nor *nor, const struct device_node *np) { @@ -363,6 +364,7 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor) { return mtd_get_of_node(&nor->mtd); } +#endif /* __UBOOT__ */ /** * struct spi_nor_hwcaps - Structure for describing the hardware capabilies diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 88bacde91e5..15bcd59f341 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -412,6 +412,7 @@ spinand_to_nand(struct spinand_device *spinand) return &spinand->base; } +#ifndef __UBOOT__ /** * spinand_set_of_node - Attach a DT node to a SPI NAND device * @spinand: SPI NAND device @@ -424,6 +425,20 @@ static inline void spinand_set_of_node(struct spinand_device *spinand, { nanddev_set_of_node(&spinand->base, np); } +#else +/** + * spinand_set_of_node - Attach a DT node to a SPI NAND device + * @spinand: SPI NAND device + * @node: ofnode + * + * Attach a DT node to a SPI NAND device. + */ +static inline void spinand_set_ofnode(struct spinand_device *spinand, + ofnode node) +{ + nanddev_set_ofnode(&spinand->base, node); +} +#endif /* __UBOOT__ */ int spinand_match_and_init(struct spinand_device *dev, const struct spinand_info *table, -- cgit v1.2.3 From a1a8a633859ce6ecfe298e3b40eb97c49248f8a0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:01 -0700 Subject: spi: Tweak a few strange SPI NOR features for of-platdata The #define of one struct to another has been around for a while. It confuses dtoc and makes it think that struct spi_flash does not exist. Make a few changes to improve things while we wait for migration to be completed: - Move the 'struct spi_flash' to column 1 so dtoc scans it - Remove the #define when compiling dt-platdata.c - Update the strange mtd_get/set_of_node() functions - Use struct spi_nor in the drivers, so dtoc sees the correct struct Signed-off-by: Simon Glass --- include/linux/mtd/spi-nor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 2642bf91d00..363f2749d7d 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -258,11 +258,13 @@ struct flash_info; /* * TODO: Remove, once all users of spi_flash interface are moved to MTD * - * struct spi_flash { +struct spi_flash { * Defined below (keep this text to enable searching for spi_flash decl) * } */ +#ifndef DT_PLATDATA_C #define spi_flash spi_nor +#endif /** * struct spi_nor - Structure for defining a the SPI NOR layer -- cgit v1.2.3 From 6563b205eb65653e8fe0d3f92106ec37d28a4af7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:03 -0700 Subject: dm: core: Move priv/plat structs for simple_bus to headers With the new of-platdata, these need to be available to dt_platdata.c so must be in header files. Move them. Signed-off-by: Simon Glass --- include/dm/simple_bus.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 include/dm/simple_bus.h (limited to 'include') diff --git a/include/dm/simple_bus.h b/include/dm/simple_bus.h new file mode 100644 index 00000000000..4ad4cc4051d --- /dev/null +++ b/include/dm/simple_bus.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ + +#ifndef __DM_SIMPLE_BUS_H +#define __DM_SIMPLE_BUS_H + +struct simple_bus_plat { + u32 base; + u32 size; + u32 target; +}; + +#endif -- cgit v1.2.3 From 2462139fdd4f1f5eb50427e287a802b9c9eef097 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:09 -0700 Subject: dm: core: Rename sqq to seq_ Now that the sequence-numbering migration is complete, rename this member back to seq_, adding an underscore to indicate it is internal to driver model. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/dm/device.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index daebd6eb68d..a063bbaa176 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -136,11 +136,12 @@ enum { * @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... - * @seq: Allocated sequence number for this device (-1 = none). This is set up + * @seq_: Allocated sequence number for this device (-1 = none). This is set up * when the device is bound and is unique within the device's uclass. If the * device has an alias in the devicetree then that is used to set the sequence * number. Otherwise, the next available number is used. Sequence numbers are - * used by certain commands that need device to be numbered (e.g. 'mmc dev') + * used by certain commands that need device to be numbered (e.g. 'mmc dev'). + * (do not access outside driver model) * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -163,7 +164,7 @@ struct udevice { struct list_head child_head; struct list_head sibling_node; uint32_t flags; - int sqq; + int seq_; #ifdef CONFIG_DEVRES struct list_head devres_head; #endif @@ -190,7 +191,7 @@ static inline bool dev_has_of_node(struct udevice *dev) static inline int dev_seq(const struct udevice *dev) { - return dev->sqq; + return dev->seq_; } /** -- cgit v1.2.3 From 73466df3e214f6ff1966e69df351f273eec1a029 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:10 -0700 Subject: dm: core: Access device flags through functions At present flags are stored as part of the device. In preparation for storing them separately, change the access to go through inline functions. Signed-off-by: Simon Glass --- include/dm/device.h | 15 +++++++++++++++ include/virtio.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index a063bbaa176..4ec423e9618 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -179,6 +179,21 @@ struct udevice { /* Returns non-zero if the device is active (probed and not removed) */ #define device_active(dev) ((dev)->flags & DM_FLAG_ACTIVATED) +static inline u32 dev_get_flags(const struct udevice *dev) +{ + return dev->flags; +} + +static inline void dev_or_flags(struct udevice *dev, u32 or) +{ + dev->flags |= or; +} + +static inline void dev_bic_flags(struct udevice *dev, u32 bic) +{ + dev->flags &= ~bic; +} + static inline int dev_of_offset(const struct udevice *dev) { return ofnode_to_offset(dev->node); diff --git a/include/virtio.h b/include/virtio.h index 10a9c073ba1..a42bdad6b87 100644 --- a/include/virtio.h +++ b/include/virtio.h @@ -492,7 +492,7 @@ static inline void __virtio_clear_bit(struct udevice *udev, unsigned int fbit) */ static inline bool virtio_has_feature(struct udevice *vdev, unsigned int fbit) { - if (!(vdev->flags & DM_FLAG_BOUND)) + if (!(dev_get_flags(vdev) & DM_FLAG_BOUND)) WARN_ON(true); return __virtio_test_bit(vdev->parent, fbit); -- cgit v1.2.3 From 156004f863c06ed985ed089450977827e11cb451 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:11 -0700 Subject: dm: core: Rename device flags to indicate it is private To avoid having people accidentally access this member, add a trailing underscore. Signed-off-by: Simon Glass --- include/dm/device.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 4ec423e9618..a0c1752cddc 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -135,7 +135,8 @@ enum { * @uclass_node: Used by uclass to link its devices * @child_head: List of children of this device * @sibling_node: Next device in list of all devices - * @flags: Flags for this device DM_FLAG_... + * @flags_: Flags for this device DM_FLAG_... (do not access outside driver + * model) * @seq_: Allocated sequence number for this device (-1 = none). This is set up * when the device is bound and is unique within the device's uclass. If the * device has an alias in the devicetree then that is used to set the sequence @@ -163,7 +164,7 @@ struct udevice { struct list_head uclass_node; struct list_head child_head; struct list_head sibling_node; - uint32_t flags; + u32 flags_; int seq_; #ifdef CONFIG_DEVRES struct list_head devres_head; @@ -176,24 +177,24 @@ struct udevice { /* Returns the operations for a device */ #define device_get_ops(dev) (dev->driver->ops) -/* Returns non-zero if the device is active (probed and not removed) */ -#define device_active(dev) ((dev)->flags & DM_FLAG_ACTIVATED) - static inline u32 dev_get_flags(const struct udevice *dev) { - return dev->flags; + return dev->flags_; } static inline void dev_or_flags(struct udevice *dev, u32 or) { - dev->flags |= or; + dev->flags_ |= or; } static inline void dev_bic_flags(struct udevice *dev, u32 bic) { - dev->flags &= ~bic; + dev->flags_ &= ~bic; } +/* Returns non-zero if the device is active (probed and not removed) */ +#define device_active(dev) (dev_get_flags(dev) & DM_FLAG_ACTIVATED) + static inline int dev_of_offset(const struct udevice *dev) { return ofnode_to_offset(dev->node); -- cgit v1.2.3 From c23405f8176c8d32d36ad992eb203ec87c4f5507 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:12 -0700 Subject: dm: core: Rename dev_has_of_node() to dev_has_ofnode() We use 'ofnode' rather than 'of_node' in U-Boot. Rename this function to fit. Signed-off-by: Simon Glass --- include/dm/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index a0c1752cddc..b15a14ec330 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -200,7 +200,7 @@ static inline int dev_of_offset(const struct udevice *dev) return ofnode_to_offset(dev->node); } -static inline bool dev_has_of_node(struct udevice *dev) +static inline bool dev_has_ofnode(struct udevice *dev) { return ofnode_valid(dev->node); } -- cgit v1.2.3 From 7d14ee443ca674314e0fe5c3e25f48e52a8fd5ee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:13 -0700 Subject: dm: core: Use dev_has_ofnode() instead of dev_of_valid() We have two functions which do the same thing. Standardise on dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in normal operation: it is either null or missing. Also move the functions into one place. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- include/dm/device.h | 13 ++++++++++++- include/dm/read.h | 16 ---------------- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index b15a14ec330..4a1224bcc26 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -192,6 +192,17 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic) dev->flags_ &= ~bic; } +/** + * dev_ofnode() - get the DT node reference associated with a udevice + * + * @dev: device to check + * @return reference of the the device's DT node + */ +static inline ofnode dev_ofnode(const struct udevice *dev) +{ + return dev->node; +} + /* Returns non-zero if the device is active (probed and not removed) */ #define device_active(dev) (dev_get_flags(dev) & DM_FLAG_ACTIVATED) @@ -200,7 +211,7 @@ static inline int dev_of_offset(const struct udevice *dev) return ofnode_to_offset(dev->node); } -static inline bool dev_has_ofnode(struct udevice *dev) +static inline bool dev_has_ofnode(const struct udevice *dev) { return ofnode_valid(dev->node); } diff --git a/include/dm/read.h b/include/dm/read.h index 0585eb12281..d5cdd87911d 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -30,22 +30,6 @@ static inline const struct device_node *dev_np(const struct udevice *dev) } #endif -/** - * dev_ofnode() - get the DT node reference associated with a udevice - * - * @dev: device to check - * @return reference of the the device's DT node - */ -static inline ofnode dev_ofnode(const struct udevice *dev) -{ - return dev->node; -} - -static inline bool dev_of_valid(const struct udevice *dev) -{ - return ofnode_valid(dev_ofnode(dev)); -} - #ifndef CONFIG_DM_DEV_READ_INLINE /** -- cgit v1.2.3 From f10643cf8a4ca006d1ad194e930cd292fd869d17 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:14 -0700 Subject: dm: core: Access device ofnode through functions At present ofnode is present in the device even if it is never used. With of-platdata this field is not used, so can be removed. In preparation for this, change the access to go through inline functions. Signed-off-by: Simon Glass --- include/dm/device.h | 23 +++++++++++++++++++++-- include/dm/read.h | 2 +- include/linux/mtd/mtd.h | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 4a1224bcc26..1b274206ea3 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic) */ static inline ofnode dev_ofnode(const struct udevice *dev) { +#if !CONFIG_IS_ENABLED(OF_PLATDATA) return dev->node; +#else + return ofnode_null(); +#endif } /* Returns non-zero if the device is active (probed and not removed) */ @@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev) static inline int dev_of_offset(const struct udevice *dev) { - return ofnode_to_offset(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_to_offset(dev_ofnode(dev)); +#else + return -1; +#endif } static inline bool dev_has_ofnode(const struct udevice *dev) { - return ofnode_valid(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_valid(dev_ofnode(dev)); +#else + return false; +#endif +} + +static inline void dev_set_ofnode(struct udevice *dev, ofnode node) +{ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + dev->node = node; +#endif } static inline int dev_seq(const struct udevice *dev) diff --git a/include/dm/read.h b/include/dm/read.h index d5cdd87911d..fc987f77598 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -21,7 +21,7 @@ struct resource; #if CONFIG_IS_ENABLED(OF_LIVE) static inline const struct device_node *dev_np(const struct udevice *dev) { - return ofnode_to_np(dev->node); + return ofnode_to_np(dev_ofnode(dev)); } #else static inline const struct device_node *dev_np(const struct udevice *dev) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 54d03d02402..927854950a0 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -334,12 +334,12 @@ struct mtd_info { #if IS_ENABLED(CONFIG_DM) static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node) { - mtd->dev->node = node; + dev_set_ofnode(mtd->dev, node); } static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd) { - return mtd->dev->node; + return dev_ofnode(mtd->dev); } #else struct device_node; -- cgit v1.2.3 From 84a42ae3668313e72b5056940f4f8e6f5c78e399 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:15 -0700 Subject: dm: core: Rename device node to indicate it is private To avoid having people accidentally access this member, add a trailing underscore. Also remove it when of-platdata is enabled, since it is not used. Signed-off-by: Simon Glass --- include/dm/device.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 1b274206ea3..4469804a00e 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -122,7 +122,6 @@ enum { * access outside driver model) * @uclass_plat_: The uclass's configuration data for this device (do not access * outside driver model) - * @node: Reference to device tree node for this device * @driver_data: Driver data word for the entry that matched this device with * its driver * @parent: Parent of this device, or NULL for the top level device @@ -143,6 +142,8 @@ enum { * number. Otherwise, the next available number is used. Sequence numbers are * used by certain commands that need device to be numbered (e.g. 'mmc dev'). * (do not access outside driver model) + * @node_: Reference to device tree node for this device (do not access outside + * driver model) * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -154,7 +155,6 @@ struct udevice { void *plat_; void *parent_plat_; void *uclass_plat_; - ofnode node; ulong driver_data; struct udevice *parent; void *priv_; @@ -166,6 +166,9 @@ struct udevice { struct list_head sibling_node; u32 flags_; int seq_; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + ofnode node_; +#endif #ifdef CONFIG_DEVRES struct list_head devres_head; #endif @@ -201,7 +204,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic) static inline ofnode dev_ofnode(const struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - return dev->node; + return dev->node_; #else return ofnode_null(); #endif @@ -231,7 +234,7 @@ static inline bool dev_has_ofnode(const struct udevice *dev) static inline void dev_set_ofnode(struct udevice *dev, ofnode node) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - dev->node = node; + dev->node_ = node; #endif } -- cgit v1.2.3 From 8a715530bb1f9522030757379415b174f3109951 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:17 -0700 Subject: dm: core: Allow the uclass list to move At present the uclass list head is in global_data. This is convenient but with the new of-platdata we need the list head to be declared by the generated code. Change this over to be a pointer. Provide a 'static' version in global_data to retain the current behaviour. Signed-off-by: Simon Glass --- include/asm-generic/global_data.h | 8 +++++++- include/dm/device-internal.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 87d827d0f43..b63575919f0 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -194,7 +194,13 @@ struct global_data { /** * @uclass_root: head of core tree */ - struct list_head uclass_root; + struct list_head uclass_root_s; + /** + * @uclass_root: pointer to head of core tree, if uclasses are in + * read-only memory and cannot be adjusted to use @uclass_root as a + * list head. + */ + struct list_head *uclass_root; # if CONFIG_IS_ENABLED(OF_PLATDATA) /** Dynamic info about the driver */ struct driver_rt *dm_driver_rt; diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 03b092bdf7d..639bbd293d9 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -288,6 +288,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr); /* Cast away any volatile pointer */ #define DM_ROOT_NON_CONST (((gd_t *)gd)->dm_root) #define DM_UCLASS_ROOT_NON_CONST (((gd_t *)gd)->uclass_root) +#define DM_UCLASS_ROOT_S_NON_CONST (((gd_t *)gd)->uclass_root_s) /* device resource management */ #ifdef CONFIG_DEVRES -- cgit v1.2.3 From 20e442ab2df355450006574fff178c746d254a18 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:54 -0700 Subject: dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO() The current macro is a misnomer since it does not declare a device directly. Instead, it declares driver_info record which U-Boot uses at runtime to create a device. The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?) It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices. Rename it to U_BOOT_DRVINFO(), which indicates clearly that this is declaring a new driver_info record, not a device. Signed-off-by: Simon Glass --- include/dm/device.h | 4 ++-- include/dm/lists.h | 2 +- include/dm/platdata.h | 16 ++++++++-------- include/dm/platform_data/spi_pl022.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 4469804a00e..e16ba2405f9 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -104,7 +104,7 @@ enum { * particular port or peripheral (essentially a driver instance). * * A device will come into existence through a 'bind' call, either due to - * a U_BOOT_DEVICE() macro (in which case plat is non-NULL) or a node + * a U_BOOT_DRVINFO() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case * we translate the device tree information into plat in a function * implemented by the driver of_to_plat method (called just before the @@ -293,7 +293,7 @@ struct udevice_id { * platform data to be allocated in the device's ->plat pointer. * This is typically only useful for device-tree-aware drivers (those with * an of_match), since drivers which use plat will have the data - * provided in the U_BOOT_DEVICE() instantiation. + * provided in the U_BOOT_DRVINFO() instantiation. * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. diff --git a/include/dm/lists.h b/include/dm/lists.h index 070bc9c19f6..1a865525461 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -35,7 +35,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id); /** * lists_bind_drivers() - search for and bind all drivers to parent * - * This searches the U_BOOT_DEVICE() structures and creates new devices for + * This searches the U_BOOT_DRVINFO() structures and creates new devices for * each one. The devices will have @parent as their parent. * * @parent: parent device (root) diff --git a/include/dm/platdata.h b/include/dm/platdata.h index d650fb39190..e2b16ce6e4e 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -56,31 +56,31 @@ struct driver_rt { * is not feasible (e.g. serial driver in SPL where <8KB of SRAM is * available). U-Boot's driver model uses device tree for configuration. * - * When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the + * When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the * dt-plat.c file created by dtoc */ #if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLATDATA_C) -#define U_BOOT_DEVICE(__name) _Static_assert(false, \ - "Cannot use U_BOOT_DEVICE with of-platdata. Please use devicetree instead") +#define U_BOOT_DRVINFO(__name) _Static_assert(false, \ + "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead") #else -#define U_BOOT_DEVICE(__name) \ +#define U_BOOT_DRVINFO(__name) \ ll_entry_declare(struct driver_info, __name, driver_info) #endif /* Declare a list of devices. The argument is a driver_info[] array */ -#define U_BOOT_DEVICES(__name) \ +#define U_BOOT_DRVINFOS(__name) \ ll_entry_declare_list(struct driver_info, __name, driver_info) /** * Get a pointer to a given device info given its name * - * With the declaration U_BOOT_DEVICE(name), DM_GET_DEVICE(name) will return a + * With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * - * TODO(sjg@chromium.org): U_BOOT_DEVICE() tells U-Boot to create a device, so + * TODO(sjg@chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so * the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it * finds the driver_info record, not the device. * @@ -93,7 +93,7 @@ struct driver_rt { /** * dm_populate_phandle_data() - Populates phandle data in platda * - * This populates phandle data with an U_BOOT_DEVICE entry get by + * This populates phandle data with an U_BOOT_DRVINFO entry get by * DM_GET_DEVICE. The implementation of this function will be done * by dtoc when parsing dtb. */ diff --git a/include/dm/platform_data/spi_pl022.h b/include/dm/platform_data/spi_pl022.h index c5aa3212915..7f74b3cbc5c 100644 --- a/include/dm/platform_data/spi_pl022.h +++ b/include/dm/platform_data/spi_pl022.h @@ -3,7 +3,7 @@ * (C) Copyright 2018 * Quentin Schulz, Bootlin, quentin.schulz@bootlin.com * - * Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use + * Structure for use with U_BOOT_DRVINFO for pl022 SPI devices or to use * in of_to_plat. */ -- cgit v1.2.3 From 8629d30a32e7b4ff8323292364116c08033bd57b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:55 -0700 Subject: dm: Rename DM_GET_DEVICE() to DM_DRVINFO_GET() This does not get a device (struct udevice *) but a struct driver_info * so the name is confusing. Rename it accordingly. Since we plan to have several various of these macros, put GET at the end instead of the middle, so it is easier to spot the related macros. Signed-off-by: Simon Glass --- include/dm/platdata.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/dm/platdata.h b/include/dm/platdata.h index e2b16ce6e4e..df1f6abcc7e 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -74,27 +74,23 @@ struct driver_rt { /** * Get a pointer to a given device info given its name * - * With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a + * With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * - * TODO(sjg@chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so - * the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it - * finds the driver_info record, not the device. - * * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000) * @return struct driver_info * to the driver that created the device */ -#define DM_GET_DEVICE(__name) \ +#define DM_DRVINFO_GET(__name) \ ll_entry_get(struct driver_info, __name, driver_info) /** * dm_populate_phandle_data() - Populates phandle data in platda * * This populates phandle data with an U_BOOT_DRVINFO entry get by - * DM_GET_DEVICE. The implementation of this function will be done + * DM_DRVINFO_GET. The implementation of this function will be done * by dtoc when parsing dtb. */ void dm_populate_phandle_data(void); -- cgit v1.2.3 From 65e25bea597ccaaea756c593318bea1e574d8df1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:56 -0700 Subject: dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET() In the spirit of using the same base name for all of these related macros, rename this to have the operation at the end. This is not widely used so the impact is fairly small. Signed-off-by: Simon Glass --- include/dm/device.h | 2 +- include/dm/uclass.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index e16ba2405f9..68990301051 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -335,7 +335,7 @@ struct driver { ll_entry_declare(struct driver, __name, driver) /* Get a pointer to a given driver */ -#define DM_GET_DRIVER(__name) \ +#define DM_DRIVER_GET(__name) \ ll_entry_get(struct driver, __name, driver) /** diff --git a/include/dm/uclass.h b/include/dm/uclass.h index f06339e4d69..b5f066dbf48 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -264,7 +264,7 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, * uclass_get_device_by_driver() - Get a uclass device for a driver * * This searches the devices in the uclass for one that uses the given - * driver. Use DM_GET_DRIVER(name) for the @drv argument, where 'name' is + * driver. Use DM_DRIVER_GET(name) for the @drv argument, where 'name' is * the driver name - as used in U_BOOT_DRIVER(name). * * The device is probed to activate it ready for use. -- cgit v1.2.3 From bdf8fd76c0184373bbd31e6ee9a3a9430dcfc485 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:57 -0700 Subject: dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS We use the U_BOOT_ prefix (i.e. U_BOOT_DRIVER) to declare a driver but in every other case we just use DM_. Update the alias macros to use the DM_ prefix. We could perhaps rename U_BOOT_DRIVER() to DM_DRIVER(), but this macro is widely used and there is at least some benefit to indicating it us a U-Boot driver, particularly for code ported from Linux. So for now, let's keep that name. Signed-off-by: Simon Glass --- include/dm/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 68990301051..f5b4cd6876e 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -343,7 +343,7 @@ struct driver { * produce no code but its information will be parsed by tools like * dtoc */ -#define U_BOOT_DRIVER_ALIAS(__name, __alias) +#define DM_DRIVER_ALIAS(__name, __alias) /** * dev_get_plat() - Get the platform data for a device -- cgit v1.2.3 From f31fa99a9ed92c223fbf56e07eae57e7bdea19ae Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:01 -0700 Subject: dtoc: Rename dt-platdata.c to dt-plat.c Use this new name to be consistent with the rest of U-Boot, which talks about 'plat' for the platform data, which is what this file holds. Signed-off-by: Simon Glass --- include/dm/platdata.h | 2 +- include/linux/mtd/spi-nor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/platdata.h b/include/dm/platdata.h index df1f6abcc7e..dc3cbfcbc7f 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -59,7 +59,7 @@ struct driver_rt { * When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the * dt-plat.c file created by dtoc */ -#if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLATDATA_C) +#if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLAT_C) #define U_BOOT_DRVINFO(__name) _Static_assert(false, \ "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead") #else diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 363f2749d7d..4a8e19ee4f9 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -262,7 +262,7 @@ struct spi_flash { * Defined below (keep this text to enable searching for spi_flash decl) * } */ -#ifndef DT_PLATDATA_C +#ifndef DT_PLAT_C #define spi_flash spi_nor #endif -- cgit v1.2.3 From d960f0db289144a80553e4d226d5dd145d63926a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:05 -0700 Subject: dtoc: Drop dm_populate_phandle_data() This has not been needed since parent information was added and we started using indicies for references to other drivers instead of pointers. It was kept around in the expectation that it might be needed later. However with the latest updates, it doesn't seem likely that we'll need this in the foreseeable future. Drop dm_populate_phandle_data() from dtoc and driver model. Signed-off-by: Simon Glass --- include/dm/platdata.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/dm/platdata.h b/include/dm/platdata.h index dc3cbfcbc7f..3821a56f2ca 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -86,12 +86,4 @@ struct driver_rt { #define DM_DRVINFO_GET(__name) \ ll_entry_get(struct driver_info, __name, driver_info) -/** - * dm_populate_phandle_data() - Populates phandle data in platda - * - * This populates phandle data with an U_BOOT_DRVINFO entry get by - * DM_DRVINFO_GET. The implementation of this function will be done - * by dtoc when parsing dtb. - */ -void dm_populate_phandle_data(void); #endif -- cgit v1.2.3