1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Aic94xx SAS/SATA driver hardware interface header file.
4  *
5  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
6  * Copyright (C) 2005 Gilbert Wu <gilbert_wu@adaptec.com>
7  */
8 #ifndef _AIC94XX_SDS_H_
9 #define _AIC94XX_SDS_H_
10 
11 enum {
12 	FLASH_METHOD_UNKNOWN,
13 	FLASH_METHOD_A,
14 	FLASH_METHOD_B
15 };
16 
17 #define FLASH_MANUF_ID_AMD              0x01
18 #define FLASH_MANUF_ID_ST               0x20
19 #define FLASH_MANUF_ID_FUJITSU          0x04
20 #define FLASH_MANUF_ID_MACRONIX         0xC2
21 #define FLASH_MANUF_ID_INTEL            0x89
22 #define FLASH_MANUF_ID_UNKNOWN          0xFF
23 
24 #define FLASH_DEV_ID_AM29LV008BT        0x3E
25 #define FLASH_DEV_ID_AM29LV800DT        0xDA
26 #define FLASH_DEV_ID_STM29W800DT        0xD7
27 #define FLASH_DEV_ID_STM29LV640         0xDE
28 #define FLASH_DEV_ID_STM29008           0xEA
29 #define FLASH_DEV_ID_MBM29LV800TE       0xDA
30 #define FLASH_DEV_ID_MBM29DL800TA       0x4A
31 #define FLASH_DEV_ID_MBM29LV008TA       0x3E
32 #define FLASH_DEV_ID_AM29LV640MT        0x7E
33 #define FLASH_DEV_ID_AM29F800B          0xD6
34 #define FLASH_DEV_ID_MX29LV800BT        0xDA
35 #define FLASH_DEV_ID_MX29LV008CT        0xDA
36 #define FLASH_DEV_ID_I28LV00TAT         0x3E
37 #define FLASH_DEV_ID_UNKNOWN            0xFF
38 
39 /* status bit mask values */
40 #define FLASH_STATUS_BIT_MASK_DQ6       0x40
41 #define FLASH_STATUS_BIT_MASK_DQ5       0x20
42 #define FLASH_STATUS_BIT_MASK_DQ2       0x04
43 
44 /* minimum value in micro seconds needed for checking status */
45 #define FLASH_STATUS_ERASE_DELAY_COUNT  50
46 #define FLASH_STATUS_WRITE_DELAY_COUNT  25
47 
48 #define FLASH_SECTOR_SIZE               0x010000
49 #define FLASH_SECTOR_SIZE_MASK          0xffff0000
50 
51 #define FLASH_OK                        0x000000
52 #define FAIL_OPEN_BIOS_FILE             0x000100
53 #define FAIL_CHECK_PCI_ID               0x000200
54 #define FAIL_CHECK_SUM                  0x000300
55 #define FAIL_UNKNOWN                    0x000400
56 #define FAIL_VERIFY                     0x000500
57 #define FAIL_RESET_FLASH                0x000600
58 #define FAIL_FIND_FLASH_ID              0x000700
59 #define FAIL_ERASE_FLASH                0x000800
60 #define FAIL_WRITE_FLASH                0x000900
61 #define FAIL_FILE_SIZE                  0x000a00
62 #define FAIL_PARAMETERS                 0x000b00
63 #define FAIL_OUT_MEMORY                 0x000c00
64 #define FLASH_IN_PROGRESS               0x001000
65 
66 struct controller_id {
67 	u32 vendor;     /* PCI Vendor ID */
68 	u32 device;     /* PCI Device ID */
69 	u32 sub_vendor; /* PCI Subvendor ID */
70 	u32 sub_device; /* PCI Subdevice ID */
71 };
72 
73 struct image_info {
74 	u32 ImageId;       /* Identifies the image */
75 	u32 ImageOffset;   /* Offset the beginning of the file */
76 	u32 ImageLength;   /* length of the image */
77 	u32 ImageChecksum; /* Image checksum */
78 	u32 ImageVersion;  /* Version of the image, could be build number */
79 };
80 
81 struct bios_file_header {
82 	u8 signature[32]; /* Signature/Cookie to identify the file */
83 	u32 checksum;	  /*Entire file checksum with this field zero */
84 	u32 antidote;	  /* Entire file checksum with this field 0xFFFFFFFF */
85 	struct controller_id contrl_id; /*PCI id to identify the controller */
86 	u32 filelen;      /*Length of the entire file*/
87 	u32 chunk_num;	  /*The chunk/part number for multiple Image files */
88 	u32 total_chunks; /*Total number of chunks/parts in the image file */
89 	u32 num_images;   /* Number of images in the file */
90 	u32 build_num;    /* Build number of this image */
91 	struct image_info image_header;
92 };
93 
94 int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
95 		const void *src, u32 dest_offset, u32 bytes_to_verify);
96 int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
97 		const void *src, u32 dest_offset, u32 bytes_to_write);
98 int asd_chk_write_status(struct asd_ha_struct *asd_ha,
99 		u32 sector_addr, u8 erase_flag);
100 int asd_check_flash_type(struct asd_ha_struct *asd_ha);
101 int asd_erase_nv_sector(struct asd_ha_struct *asd_ha,
102 		u32 flash_addr, u32 size);
103 #endif
104