Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmem: u-boot-env: add Broadcom format support

Broadcom uses U-Boot for a lot of their bcmbca familiy chipsets. They
decided to store U-Boot environment data inside U-Boot partition and to
use a custom header (with "uEnv" magic and env data length).

Add support for Broadcom's specific binding and their custom format.

Ref: 6b0584c19d87 ("dt-bindings: nvmem: u-boot,env: add Broadcom's variant binding")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20221118063932.6418-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rafał Miłecki and committed by
Greg Kroah-Hartman
ada84d07 fb817c4e

+14
+14
drivers/nvmem/u-boot-env.c
··· 16 16 enum u_boot_env_format { 17 17 U_BOOT_FORMAT_SINGLE, 18 18 U_BOOT_FORMAT_REDUNDANT, 19 + U_BOOT_FORMAT_BROADCOM, 19 20 }; 20 21 21 22 struct u_boot_env { ··· 39 38 __le32 crc32; 40 39 u8 mark; 41 40 uint8_t data[]; 41 + } __packed; 42 + 43 + struct u_boot_env_image_broadcom { 44 + __le32 magic; 45 + __le32 len; 46 + __le32 crc32; 47 + uint8_t data[0]; 42 48 } __packed; 43 49 44 50 static int u_boot_env_read(void *context, unsigned int offset, void *val, ··· 146 138 crc32_data_offset = offsetof(struct u_boot_env_image_redundant, data); 147 139 data_offset = offsetof(struct u_boot_env_image_redundant, data); 148 140 break; 141 + case U_BOOT_FORMAT_BROADCOM: 142 + crc32_offset = offsetof(struct u_boot_env_image_broadcom, crc32); 143 + crc32_data_offset = offsetof(struct u_boot_env_image_broadcom, data); 144 + data_offset = offsetof(struct u_boot_env_image_broadcom, data); 145 + break; 149 146 } 150 147 crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset)); 151 148 crc32_data_len = priv->mtd->size - crc32_data_offset; ··· 215 202 { .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, }, 216 203 { .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, }, 217 204 { .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, }, 205 + { .compatible = "brcm,env", .data = (void *)U_BOOT_FORMAT_BROADCOM, }, 218 206 {}, 219 207 }; 220 208