18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Aic94xx SAS/SATA driver hardware interface header file.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
68c2ecf20Sopenharmony_ci * Copyright (C) 2005 Gilbert Wu <gilbert_wu@adaptec.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef _AIC94XX_SDS_H_
98c2ecf20Sopenharmony_ci#define _AIC94XX_SDS_H_
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cienum {
128c2ecf20Sopenharmony_ci	FLASH_METHOD_UNKNOWN,
138c2ecf20Sopenharmony_ci	FLASH_METHOD_A,
148c2ecf20Sopenharmony_ci	FLASH_METHOD_B
158c2ecf20Sopenharmony_ci};
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_AMD              0x01
188c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_ST               0x20
198c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_FUJITSU          0x04
208c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_MACRONIX         0xC2
218c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_INTEL            0x89
228c2ecf20Sopenharmony_ci#define FLASH_MANUF_ID_UNKNOWN          0xFF
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_AM29LV008BT        0x3E
258c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_AM29LV800DT        0xDA
268c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_STM29W800DT        0xD7
278c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_STM29LV640         0xDE
288c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_STM29008           0xEA
298c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_MBM29LV800TE       0xDA
308c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_MBM29DL800TA       0x4A
318c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_MBM29LV008TA       0x3E
328c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_AM29LV640MT        0x7E
338c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_AM29F800B          0xD6
348c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_MX29LV800BT        0xDA
358c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_MX29LV008CT        0xDA
368c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_I28LV00TAT         0x3E
378c2ecf20Sopenharmony_ci#define FLASH_DEV_ID_UNKNOWN            0xFF
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* status bit mask values */
408c2ecf20Sopenharmony_ci#define FLASH_STATUS_BIT_MASK_DQ6       0x40
418c2ecf20Sopenharmony_ci#define FLASH_STATUS_BIT_MASK_DQ5       0x20
428c2ecf20Sopenharmony_ci#define FLASH_STATUS_BIT_MASK_DQ2       0x04
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* minimum value in micro seconds needed for checking status */
458c2ecf20Sopenharmony_ci#define FLASH_STATUS_ERASE_DELAY_COUNT  50
468c2ecf20Sopenharmony_ci#define FLASH_STATUS_WRITE_DELAY_COUNT  25
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define FLASH_SECTOR_SIZE               0x010000
498c2ecf20Sopenharmony_ci#define FLASH_SECTOR_SIZE_MASK          0xffff0000
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define FLASH_OK                        0x000000
528c2ecf20Sopenharmony_ci#define FAIL_OPEN_BIOS_FILE             0x000100
538c2ecf20Sopenharmony_ci#define FAIL_CHECK_PCI_ID               0x000200
548c2ecf20Sopenharmony_ci#define FAIL_CHECK_SUM                  0x000300
558c2ecf20Sopenharmony_ci#define FAIL_UNKNOWN                    0x000400
568c2ecf20Sopenharmony_ci#define FAIL_VERIFY                     0x000500
578c2ecf20Sopenharmony_ci#define FAIL_RESET_FLASH                0x000600
588c2ecf20Sopenharmony_ci#define FAIL_FIND_FLASH_ID              0x000700
598c2ecf20Sopenharmony_ci#define FAIL_ERASE_FLASH                0x000800
608c2ecf20Sopenharmony_ci#define FAIL_WRITE_FLASH                0x000900
618c2ecf20Sopenharmony_ci#define FAIL_FILE_SIZE                  0x000a00
628c2ecf20Sopenharmony_ci#define FAIL_PARAMETERS                 0x000b00
638c2ecf20Sopenharmony_ci#define FAIL_OUT_MEMORY                 0x000c00
648c2ecf20Sopenharmony_ci#define FLASH_IN_PROGRESS               0x001000
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct controller_id {
678c2ecf20Sopenharmony_ci	u32 vendor;     /* PCI Vendor ID */
688c2ecf20Sopenharmony_ci	u32 device;     /* PCI Device ID */
698c2ecf20Sopenharmony_ci	u32 sub_vendor; /* PCI Subvendor ID */
708c2ecf20Sopenharmony_ci	u32 sub_device; /* PCI Subdevice ID */
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistruct image_info {
748c2ecf20Sopenharmony_ci	u32 ImageId;       /* Identifies the image */
758c2ecf20Sopenharmony_ci	u32 ImageOffset;   /* Offset the beginning of the file */
768c2ecf20Sopenharmony_ci	u32 ImageLength;   /* length of the image */
778c2ecf20Sopenharmony_ci	u32 ImageChecksum; /* Image checksum */
788c2ecf20Sopenharmony_ci	u32 ImageVersion;  /* Version of the image, could be build number */
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct bios_file_header {
828c2ecf20Sopenharmony_ci	u8 signature[32]; /* Signature/Cookie to identify the file */
838c2ecf20Sopenharmony_ci	u32 checksum;	  /*Entire file checksum with this field zero */
848c2ecf20Sopenharmony_ci	u32 antidote;	  /* Entire file checksum with this field 0xFFFFFFFF */
858c2ecf20Sopenharmony_ci	struct controller_id contrl_id; /*PCI id to identify the controller */
868c2ecf20Sopenharmony_ci	u32 filelen;      /*Length of the entire file*/
878c2ecf20Sopenharmony_ci	u32 chunk_num;	  /*The chunk/part number for multiple Image files */
888c2ecf20Sopenharmony_ci	u32 total_chunks; /*Total number of chunks/parts in the image file */
898c2ecf20Sopenharmony_ci	u32 num_images;   /* Number of images in the file */
908c2ecf20Sopenharmony_ci	u32 build_num;    /* Build number of this image */
918c2ecf20Sopenharmony_ci	struct image_info image_header;
928c2ecf20Sopenharmony_ci};
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciint asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
958c2ecf20Sopenharmony_ci		const void *src, u32 dest_offset, u32 bytes_to_verify);
968c2ecf20Sopenharmony_ciint asd_write_flash_seg(struct asd_ha_struct *asd_ha,
978c2ecf20Sopenharmony_ci		const void *src, u32 dest_offset, u32 bytes_to_write);
988c2ecf20Sopenharmony_ciint asd_chk_write_status(struct asd_ha_struct *asd_ha,
998c2ecf20Sopenharmony_ci		u32 sector_addr, u8 erase_flag);
1008c2ecf20Sopenharmony_ciint asd_check_flash_type(struct asd_ha_struct *asd_ha);
1018c2ecf20Sopenharmony_ciint asd_erase_nv_sector(struct asd_ha_struct *asd_ha,
1028c2ecf20Sopenharmony_ci		u32 flash_addr, u32 size);
1038c2ecf20Sopenharmony_ci#endif
104