xref: /linux/include/linux/bcm963xx_tag.h (revision 3528f8ec)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28fce60b8SSimon Arlott #ifndef __LINUX_BCM963XX_TAG_H__
38fce60b8SSimon Arlott #define __LINUX_BCM963XX_TAG_H__
48fce60b8SSimon Arlott 
58fce60b8SSimon Arlott #include <linux/types.h>
68fce60b8SSimon Arlott 
78fce60b8SSimon Arlott #define TAGVER_LEN		4	/* Length of Tag Version */
88fce60b8SSimon Arlott #define TAGLAYOUT_LEN		4	/* Length of FlashLayoutVer */
98fce60b8SSimon Arlott #define SIG1_LEN		20	/* Company Signature 1 Length */
108fce60b8SSimon Arlott #define SIG2_LEN		14	/* Company Signature 2 Length */
118fce60b8SSimon Arlott #define BOARDID_LEN		16	/* Length of BoardId */
128fce60b8SSimon Arlott #define ENDIANFLAG_LEN		2	/* Endian Flag Length */
138fce60b8SSimon Arlott #define CHIPID_LEN		6	/* Chip Id Length */
148fce60b8SSimon Arlott #define IMAGE_LEN		10	/* Length of Length Field */
158fce60b8SSimon Arlott #define ADDRESS_LEN		12	/* Length of Address field */
16696569f7SSimon Arlott #define IMAGE_SEQUENCE_LEN	4	/* Image sequence Length */
178fce60b8SSimon Arlott #define RSASIG_LEN		20	/* Length of RSA Signature in tag */
188fce60b8SSimon Arlott #define TAGINFO1_LEN		30	/* Length of vendor information field1 in tag */
198fce60b8SSimon Arlott #define FLASHLAYOUTVER_LEN	4	/* Length of Flash Layout Version String tag */
208fce60b8SSimon Arlott #define TAGINFO2_LEN		16	/* Length of vendor information field2 in tag */
218fce60b8SSimon Arlott #define ALTTAGINFO_LEN		54	/* Alternate length for vendor information; Pirelli */
228fce60b8SSimon Arlott 
238fce60b8SSimon Arlott #define NUM_PIRELLI		2
248fce60b8SSimon Arlott #define IMAGETAG_CRC_START	0xFFFFFFFF
258fce60b8SSimon Arlott 
268fce60b8SSimon Arlott #define PIRELLI_BOARDS { \
278fce60b8SSimon Arlott 	"AGPF-S0", \
288fce60b8SSimon Arlott 	"DWV-S0", \
298fce60b8SSimon Arlott }
308fce60b8SSimon Arlott 
311f29cb19SSimon Arlott /* Extended flash address, needs to be subtracted
321f29cb19SSimon Arlott  * from bcm_tag flash image offsets.
331f29cb19SSimon Arlott  */
341f29cb19SSimon Arlott #define BCM963XX_EXTENDED_SIZE	0xBFC00000
351f29cb19SSimon Arlott 
368fce60b8SSimon Arlott /*
378fce60b8SSimon Arlott  * The broadcom firmware assumes the rootfs starts the image,
388fce60b8SSimon Arlott  * therefore uses the rootfs start (flash_image_address)
398fce60b8SSimon Arlott  * to determine where to flash the image.  Since we have the kernel first
408fce60b8SSimon Arlott  * we have to give it the kernel address, but the crc uses the length
418fce60b8SSimon Arlott  * associated with this address (root_length), which is added to the kernel
428fce60b8SSimon Arlott  * length (kernel_length) to determine the length of image to flash and thus
438fce60b8SSimon Arlott  * needs to be rootfs + deadcode (jffs2 EOF marker)
448fce60b8SSimon Arlott */
458fce60b8SSimon Arlott 
468fce60b8SSimon Arlott struct bcm_tag {
478fce60b8SSimon Arlott 	/* 0-3: Version of the image tag */
488fce60b8SSimon Arlott 	char tag_version[TAGVER_LEN];
498fce60b8SSimon Arlott 	/* 4-23: Company Line 1 */
508fce60b8SSimon Arlott 	char sig_1[SIG1_LEN];
518fce60b8SSimon Arlott 	/*  24-37: Company Line 2 */
528fce60b8SSimon Arlott 	char sig_2[SIG2_LEN];
538fce60b8SSimon Arlott 	/* 38-43: Chip this image is for */
548fce60b8SSimon Arlott 	char chip_id[CHIPID_LEN];
558fce60b8SSimon Arlott 	/* 44-59: Board name */
568fce60b8SSimon Arlott 	char board_id[BOARDID_LEN];
578fce60b8SSimon Arlott 	/* 60-61: Map endianness -- 1 BE 0 LE */
588fce60b8SSimon Arlott 	char big_endian[ENDIANFLAG_LEN];
598fce60b8SSimon Arlott 	/* 62-71: Total length of image */
608fce60b8SSimon Arlott 	char total_length[IMAGE_LEN];
618fce60b8SSimon Arlott 	/* 72-83: Address in memory of CFE */
628fce60b8SSimon Arlott 	char cfe__address[ADDRESS_LEN];
638fce60b8SSimon Arlott 	/* 84-93: Size of CFE */
648fce60b8SSimon Arlott 	char cfe_length[IMAGE_LEN];
658fce60b8SSimon Arlott 	/* 94-105: Address in memory of image start
668fce60b8SSimon Arlott 	 * (kernel for OpenWRT, rootfs for stock firmware)
678fce60b8SSimon Arlott 	 */
688fce60b8SSimon Arlott 	char flash_image_start[ADDRESS_LEN];
698fce60b8SSimon Arlott 	/* 106-115: Size of rootfs */
708fce60b8SSimon Arlott 	char root_length[IMAGE_LEN];
718fce60b8SSimon Arlott 	/* 116-127: Address in memory of kernel */
728fce60b8SSimon Arlott 	char kernel_address[ADDRESS_LEN];
738fce60b8SSimon Arlott 	/* 128-137: Size of kernel */
748fce60b8SSimon Arlott 	char kernel_length[IMAGE_LEN];
75696569f7SSimon Arlott 	/* 138-141: Image sequence number
76696569f7SSimon Arlott 	 * (to be incremented when flashed with a new image)
77696569f7SSimon Arlott 	 */
78696569f7SSimon Arlott 	char image_sequence[IMAGE_SEQUENCE_LEN];
798fce60b8SSimon Arlott 	/* 142-161: RSA Signature (not used; some vendors may use this) */
808fce60b8SSimon Arlott 	char rsa_signature[RSASIG_LEN];
818fce60b8SSimon Arlott 	/* 162-191: Compilation and related information (not used in OpenWrt) */
828fce60b8SSimon Arlott 	char information1[TAGINFO1_LEN];
838fce60b8SSimon Arlott 	/* 192-195: Version flash layout */
848fce60b8SSimon Arlott 	char flash_layout_ver[FLASHLAYOUTVER_LEN];
858fce60b8SSimon Arlott 	/* 196-199: kernel+rootfs CRC32 */
868fce60b8SSimon Arlott 	__u32 fskernel_crc;
87*3528f8ecSRandy Dunlap 	/* 200-215: Unused except on Alice Gate where it is information */
888fce60b8SSimon Arlott 	char information2[TAGINFO2_LEN];
898fce60b8SSimon Arlott 	/* 216-219: CRC32 of image less imagetag (kernel for Alice Gate) */
908fce60b8SSimon Arlott 	__u32 image_crc;
918fce60b8SSimon Arlott 	/* 220-223: CRC32 of rootfs partition */
928fce60b8SSimon Arlott 	__u32 rootfs_crc;
938fce60b8SSimon Arlott 	/* 224-227: CRC32 of kernel partition */
948fce60b8SSimon Arlott 	__u32 kernel_crc;
958fce60b8SSimon Arlott 	/* 228-235: Unused at present */
968fce60b8SSimon Arlott 	char reserved1[8];
978fce60b8SSimon Arlott 	/* 236-239: CRC32 of header excluding last 20 bytes */
988fce60b8SSimon Arlott 	__u32 header_crc;
998fce60b8SSimon Arlott 	/* 240-255: Unused at present */
1008fce60b8SSimon Arlott 	char reserved2[16];
1018fce60b8SSimon Arlott };
1028fce60b8SSimon Arlott 
1038fce60b8SSimon Arlott #endif /* __LINUX_BCM63XX_TAG_H__ */
104