Lines Matching +full:flash +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
18 /* ---------- OCM stuff ---------- */
108 * asd_read_ocm_seg - read an on chip memory (OCM) segment
120 if (unlikely(asd_ha->iospace)) in asd_read_ocm_seg()
123 for ( ; size > 0; size--, offs++, p++) in asd_read_ocm_seg()
138 if (dir->sig[0] != 'M' || dir->sig[1] != 'O') { in asd_read_ocm_dir()
140 dir->sig[0], dir->sig[1]); in asd_read_ocm_dir()
141 return -ENOENT; in asd_read_ocm_dir()
143 if (dir->major != 0) { in asd_read_ocm_dir()
145 dir->major); in asd_read_ocm_dir()
146 return -ENOENT; in asd_read_ocm_dir()
148 dir->num_de &= 0xf; in asd_read_ocm_dir()
153 * asd_write_ocm_seg - write an on chip memory (OCM) segment
165 if (unlikely(asd_ha->iospace)) in asd_write_ocm_seg()
168 for ( ; size > 0; size--, offs++, p++) in asd_write_ocm_seg()
182 for (i = 0; i < dir->num_de; i++) { in asd_find_dir_entry()
183 if (dir->entry[i].type == type) in asd_find_dir_entry()
186 if (i >= dir->num_de) in asd_find_dir_entry()
187 return -ENOENT; in asd_find_dir_entry()
188 ent = &dir->entry[i]; in asd_find_dir_entry()
189 *offs = (u32) THREE_TO_NUM(ent->offs); in asd_find_dir_entry()
190 *size = (u32) THREE_TO_NUM(ent->size); in asd_find_dir_entry()
209 err = -ENOMEM; in asd_get_bios_chim()
221 if (strncmp(bc_struct->sig, "SOIB", 4) in asd_get_bios_chim()
222 && strncmp(bc_struct->sig, "IPSA", 4)) { in asd_get_bios_chim()
224 bc_struct->sig[0], bc_struct->sig[1], in asd_get_bios_chim()
225 bc_struct->sig[2], bc_struct->sig[3]); in asd_get_bios_chim()
226 err = -ENOENT; in asd_get_bios_chim()
229 if (bc_struct->major != 1) { in asd_get_bios_chim()
231 bc_struct->major); in asd_get_bios_chim()
232 err = -ENOENT; in asd_get_bios_chim()
235 if (bc_struct->flags & BC_BIOS_PRESENT) { in asd_get_bios_chim()
236 asd_ha->hw_prof.bios.present = 1; in asd_get_bios_chim()
237 asd_ha->hw_prof.bios.maj = bc_struct->bios_major; in asd_get_bios_chim()
238 asd_ha->hw_prof.bios.min = bc_struct->bios_minor; in asd_get_bios_chim()
239 asd_ha->hw_prof.bios.bld = le32_to_cpu(bc_struct->bios_build); in asd_get_bios_chim()
241 asd_ha->hw_prof.bios.maj, in asd_get_bios_chim()
242 asd_ha->hw_prof.bios.min, in asd_get_bios_chim()
243 asd_ha->hw_prof.bios.bld); in asd_get_bios_chim()
245 asd_ha->hw_prof.ue.num = le16_to_cpu(bc_struct->ue_num); in asd_get_bios_chim()
246 asd_ha->hw_prof.ue.size= le16_to_cpu(bc_struct->ue_size); in asd_get_bios_chim()
247 ASD_DPRINTK("ue num:%d, ue size:%d\n", asd_ha->hw_prof.ue.num, in asd_get_bios_chim()
248 asd_ha->hw_prof.ue.size); in asd_get_bios_chim()
249 size = asd_ha->hw_prof.ue.num * asd_ha->hw_prof.ue.size; in asd_get_bios_chim()
251 err = -ENOMEM; in asd_get_bios_chim()
252 asd_ha->hw_prof.ue.area = kmalloc(size, GFP_KERNEL); in asd_get_bios_chim()
253 if (!asd_ha->hw_prof.ue.area) in asd_get_bios_chim()
255 err = asd_read_ocm_seg(asd_ha, (void *)asd_ha->hw_prof.ue.area, in asd_get_bios_chim()
258 kfree(asd_ha->hw_prof.ue.area); in asd_get_bios_chim()
259 asd_ha->hw_prof.ue.area = NULL; in asd_get_bios_chim()
260 asd_ha->hw_prof.ue.num = 0; in asd_get_bios_chim()
261 asd_ha->hw_prof.ue.size = 0; in asd_get_bios_chim()
296 struct pci_dev *pcidev = asd_ha->pcidev; in asd_hwi_check_ocm_access()
333 * asd_read_ocm - read on chip memory (OCM)
342 return -1; in asd_read_ocm()
347 return -ENOMEM; in asd_read_ocm()
360 /* ---------- FLASH stuff ---------- */
365 #define FLASH_DIR_COOKIE "*** ADAPTEC FLASH DIRECTORY *** "
419 u8 phy_control_0; /* mode 5 reg 0x160 */
420 u8 phy_control_1; /* mode 5 reg 0x161 */
421 u8 phy_control_2; /* mode 5 reg 0x162 */
422 u8 phy_control_3; /* mode 5 reg 0x163 */
555 for (c = 5000; c > 0; c--) { in asd_poll_flash()
556 d = asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar); in asd_poll_flash()
557 d ^= asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar); in asd_poll_flash()
562 return -ENOENT; in asd_poll_flash()
572 asd_write_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar, FLASH_RESET); in asd_reset_flash()
581 asd_read_reg_string(asd_ha, buffer, asd_ha->hw_prof.flash.bar+offs, in asd_read_flash_seg()
587 * asd_find_flash_dir - finds and reads the flash directory
589 * @flash_dir: pointer to flash directory structure
591 * If found, the flash directory segment will be copied to
600 sizeof(FLASH_DIR_COOKIE)-1); in asd_find_flash_dir()
601 if (memcmp(flash_dir->cookie, FLASH_DIR_COOKIE, in asd_find_flash_dir()
602 sizeof(FLASH_DIR_COOKIE)-1) == 0) { in asd_find_flash_dir()
603 asd_ha->hw_prof.flash.dir_offs = v; in asd_find_flash_dir()
619 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR, in asd_flash_getid()
620 &asd_ha->hw_prof.flash.bar)) { in asd_flash_getid()
622 pci_name(asd_ha->pcidev)); in asd_flash_getid()
623 return -ENOENT; in asd_flash_getid()
625 asd_ha->hw_prof.flash.present = 1; in asd_flash_getid()
626 asd_ha->hw_prof.flash.wide = reg & FLASHW ? 1 : 0; in asd_flash_getid()
629 ASD_DPRINTK("couldn't reset flash(%d)\n", err); in asd_flash_getid()
639 while (size-- > 0) in asd_calc_flash_chksum()
653 u32 type = le32_to_cpu(flash_dir->dir_entry[i].type); in asd_find_flash_de()
660 return -ENOENT; in asd_find_flash_de()
661 de = &flash_dir->dir_entry[i]; in asd_find_flash_de()
662 *offs = le32_to_cpu(de->offs); in asd_find_flash_de()
663 *size = le32_to_cpu(de->pad_size); in asd_find_flash_de()
669 if (ms->sig[0] != 'S' || ms->sig[1] != 'M') { in asd_validate_ms()
671 ms->sig[0], ms->sig[1]); in asd_validate_ms()
672 return -ENOENT; in asd_validate_ms()
674 if (ms->maj != 0) { in asd_validate_ms()
676 ms->maj); in asd_validate_ms()
677 return -ENOENT; in asd_validate_ms()
679 ms->offs_next = le16_to_cpu((__force __le16) ms->offs_next); in asd_validate_ms()
680 ms->chksum = le16_to_cpu((__force __le16) ms->chksum); in asd_validate_ms()
681 ms->size = le16_to_cpu((__force __le16) ms->size); in asd_validate_ms()
683 if (asd_calc_flash_chksum((u16 *)ms, ms->size/2)) { in asd_validate_ms()
693 memcpy(asd_ha->hw_prof.sas_addr, ms->sas_addr, SAS_ADDR_SIZE); in asd_ms_get_sas_addr()
700 memcpy(asd_ha->hw_prof.pcba_sn, ms->pcba_sn, ASD_PCBA_SN_SIZE); in asd_ms_get_pcba_sn()
701 asd_ha->hw_prof.pcba_sn[ASD_PCBA_SN_SIZE] = '\0'; in asd_ms_get_pcba_sn()
706 * asd_find_ll_by_id - find a linked list entry by its id
723 if (el->id1 == id1) { in asd_find_ll_by_id()
726 if (el->id0 == id0) in asd_find_ll_by_id()
730 el = start + le16_to_cpu(el->next); in asd_find_ll_by_id()
737 * asd_ms_get_phy_params - get phy parameters from the manufacturing sector
741 * The manufacturing sector contans also the linked list of sub-segments,
742 * since when it was read, its size was taken from the flash directory,
748 * The absolute total phy number is ASD_MAX_PHYS. hw_prof->num_phys
752 * In this case ASD_MAX_PHYS is 8, hw_prof->num_phys is 5, and only 2
788 if (phy_param->maj != 0) { in asd_ms_get_phy_params()
790 phy_param->maj); in asd_ms_get_phy_params()
791 return -ENOENT; in asd_ms_get_phy_params()
794 ASD_DPRINTK("ms: num_phy_desc: %d\n", phy_param->num_phy_desc); in asd_ms_get_phy_params()
795 asd_ha->hw_prof.enabled_phys = 0; in asd_ms_get_phy_params()
796 for (i = 0; i < phy_param->num_phy_desc; i++) { in asd_ms_get_phy_params()
797 struct asd_manuf_phy_desc *pd = &phy_param->phy_desc[i]; in asd_ms_get_phy_params()
798 switch (pd->state & 0xF) { in asd_ms_get_phy_params()
804 asd_ha->hw_prof.enabled_phys &= ~(1 << i); in asd_ms_get_phy_params()
809 asd_ha->hw_prof.enabled_phys |= (1 << i); in asd_ms_get_phy_params()
813 asd_ha->hw_prof.phy_desc[i].phy_control_0 = pd->phy_control_0; in asd_ms_get_phy_params()
814 asd_ha->hw_prof.phy_desc[i].phy_control_1 = pd->phy_control_1; in asd_ms_get_phy_params()
815 asd_ha->hw_prof.phy_desc[i].phy_control_2 = pd->phy_control_2; in asd_ms_get_phy_params()
816 asd_ha->hw_prof.phy_desc[i].phy_control_3 = pd->phy_control_3; in asd_ms_get_phy_params()
818 asd_ha->hw_prof.max_phys = rep_phys + en_phys; in asd_ms_get_phy_params()
819 asd_ha->hw_prof.num_phys = en_phys; in asd_ms_get_phy_params()
821 asd_ha->hw_prof.max_phys, asd_ha->hw_prof.num_phys); in asd_ms_get_phy_params()
822 ASD_DPRINTK("ms: enabled_phys:0x%x\n", asd_ha->hw_prof.enabled_phys); in asd_ms_get_phy_params()
837 if (cm->maj != 0) { in asd_ms_get_connector_map()
839 "\n", cm->maj); in asd_ms_get_connector_map()
840 return -ENOENT; in asd_ms_get_connector_map()
850 * asd_process_ms - find and extract information from the manufacturing sector
852 * @flash_dir: pointer to the flash directory
870 err = -ENOMEM; in asd_process_ms()
896 SAS_ADDR(asd_ha->hw_prof.sas_addr)); in asd_process_ms()
903 ASD_DPRINTK("manuf sect PCBA SN %s\n", asd_ha->hw_prof.pcba_sn); in asd_process_ms()
927 for (i = 0; i < ps->num_phys; i++) { in asd_process_ctrla_phy_settings()
928 struct asd_ctrla_phy_entry *pe = &ps->phy_ent[i]; in asd_process_ctrla_phy_settings()
932 if (*(u64 *)pe->sas_addr == 0) { in asd_process_ctrla_phy_settings()
933 asd_ha->hw_prof.enabled_phys &= ~(1 << i); in asd_process_ctrla_phy_settings()
937 memcpy(asd_ha->hw_prof.phy_desc[i].sas_addr, pe->sas_addr, in asd_process_ctrla_phy_settings()
939 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_process_ctrla_phy_settings()
940 (pe->sas_link_rates & 0xF0) >> 4; in asd_process_ctrla_phy_settings()
941 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_process_ctrla_phy_settings()
942 (pe->sas_link_rates & 0x0F); in asd_process_ctrla_phy_settings()
943 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_process_ctrla_phy_settings()
944 (pe->sata_link_rates & 0xF0) >> 4; in asd_process_ctrla_phy_settings()
945 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_process_ctrla_phy_settings()
946 (pe->sata_link_rates & 0x0F); in asd_process_ctrla_phy_settings()
947 asd_ha->hw_prof.phy_desc[i].flags = pe->flags; in asd_process_ctrla_phy_settings()
948 ASD_DPRINTK("ctrla: phy%d: sas_addr: %llx, sas rate:0x%x-0x%x," in asd_process_ctrla_phy_settings()
949 " sata rate:0x%x-0x%x, flags:0x%x\n", in asd_process_ctrla_phy_settings()
951 SAS_ADDR(asd_ha->hw_prof.phy_desc[i].sas_addr), in asd_process_ctrla_phy_settings()
952 asd_ha->hw_prof.phy_desc[i].max_sas_lrate, in asd_process_ctrla_phy_settings()
953 asd_ha->hw_prof.phy_desc[i].min_sas_lrate, in asd_process_ctrla_phy_settings()
954 asd_ha->hw_prof.phy_desc[i].max_sata_lrate, in asd_process_ctrla_phy_settings()
955 asd_ha->hw_prof.phy_desc[i].min_sata_lrate, in asd_process_ctrla_phy_settings()
956 asd_ha->hw_prof.phy_desc[i].flags); in asd_process_ctrla_phy_settings()
963 * asd_process_ctrl_a_user - process CTRL-A user settings
965 * @flash_dir: pointer to the flash directory
978 ASD_DPRINTK("couldn't find CTRL-A user settings section\n"); in asd_process_ctrl_a_user()
979 ASD_DPRINTK("Creating default CTRL-A user settings section\n"); in asd_process_ctrl_a_user()
985 asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE); in asd_process_ctrl_a_user()
999 err = -ENOMEM; in asd_process_ctrl_a_user()
1012 err = -ENOENT; in asd_process_ctrl_a_user()
1031 * asd_read_flash - read flash memory
1045 return -ENOMEM; in asd_read_flash()
1047 err = -ENOENT; in asd_read_flash()
1049 ASD_DPRINTK("couldn't find flash directory\n"); in asd_read_flash()
1053 if (le32_to_cpu(flash_dir->rev) != 2) { in asd_read_flash()
1054 asd_printk("unsupported flash dir version:0x%x\n", in asd_read_flash()
1055 le32_to_cpu(flash_dir->rev)); in asd_read_flash()
1067 ASD_DPRINTK("couldn't process CTRL-A user settings\n"); in asd_read_flash()
1077 * asd_verify_flash_seg - verify data with flash memory
1080 * @dest_offset: offset from flash memory
1091 reg = asd_ha->hw_prof.flash.bar; in asd_verify_flash_seg()
1108 * asd_write_flash_seg - write data into flash memory
1111 * @dest_offset: offset from flash memory
1121 reg = asd_ha->hw_prof.flash.bar; in asd_write_flash_seg()
1126 ASD_DPRINTK("couldn't find the type of flash. err=%d\n", err); in asd_write_flash_seg()
1140 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_write_flash_seg()
1147 switch (asd_ha->hw_prof.flash.method) { in asd_write_flash_seg()
1187 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_write_flash_seg()
1205 reg = asd_ha->hw_prof.flash.bar; in asd_chk_write_status()
1232 * ERASE is a sector-by-sector operation and requires in asd_chk_write_status()
1233 * more time to finish while WRITE is byte-byte-byte in asd_chk_write_status()
1247 return -1; in asd_chk_write_status()
1251 * asd_erase_nv_sector - Erase the flash memory sectors.
1253 * @flash_addr: pointer to offset from flash memory
1261 reg = asd_ha->hw_prof.flash.bar; in asd_erase_nv_sector()
1267 * Erasing an flash sector needs to be done in six consecutive in asd_erase_nv_sector()
1271 switch (asd_ha->hw_prof.flash.method) { in asd_erase_nv_sector()
1310 /* get Flash memory base address */ in asd_check_flash_type()
1311 reg = asd_ha->hw_prof.flash.bar; in asd_check_flash_type()
1313 /* Determine flash info */ in asd_check_flash_type()
1316 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_check_flash_type()
1320 asd_ha->hw_prof.flash.method = FLASH_METHOD_UNKNOWN; in asd_check_flash_type()
1321 asd_ha->hw_prof.flash.manuf = FLASH_MANUF_ID_UNKNOWN; in asd_check_flash_type()
1322 asd_ha->hw_prof.flash.dev_id = FLASH_DEV_ID_UNKNOWN; in asd_check_flash_type()
1324 /* Get flash info. This would most likely be AMD Am29LV family flash. in asd_check_flash_type()
1325 * First try the sequence for word mode. It is the same as for in asd_check_flash_type()
1326 * 008B (byte mode only), 160B (word mode) and 800D (word mode). in asd_check_flash_type()
1328 inc = asd_ha->hw_prof.flash.wide ? 2 : 1; in asd_check_flash_type()
1335 /* Get out of autoselect mode. */ in asd_check_flash_type()
1338 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_check_flash_type()
1341 ASD_DPRINTK("Flash MethodA manuf_id(0x%x) dev_id(0x%x) " in asd_check_flash_type()
1353 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1363 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1373 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1380 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1386 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) { in asd_check_flash_type()
1389 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_check_flash_type()
1401 ASD_DPRINTK("Flash MethodB manuf_id(0x%x) dev_id(0x%x) sec_prot" in asd_check_flash_type()
1406 ASD_DPRINTK("couldn't reset flash. err=%d\n", err); in asd_check_flash_type()
1414 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1423 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1432 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1439 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1446 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1455 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) in asd_check_flash_type()
1458 asd_ha->hw_prof.flash.manuf = manuf_id; in asd_check_flash_type()
1459 asd_ha->hw_prof.flash.dev_id = dev_id; in asd_check_flash_type()
1460 asd_ha->hw_prof.flash.sec_prot = sec_prot; in asd_check_flash_type()