Lines Matching +full:sig +full:- +full:dir
1 // SPDX-License-Identifier: GPL-2.0-only
18 /* ---------- OCM stuff ---------- */
28 char sig[2]; member
55 .sig = {0x4D, 0x4F}, /* signature */
92 char sig[4]; member
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()
130 struct asd_ocm_dir *dir, u32 offs) in asd_read_ocm_dir() argument
132 int err = asd_read_ocm_seg(asd_ha, dir, offs, sizeof(*dir)); in asd_read_ocm_dir()
138 if (dir->sig[0] != 'M' || dir->sig[1] != 'O') { in asd_read_ocm_dir()
139 ASD_DPRINTK("no valid dir signature(%c%c) at start of OCM\n", 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()
144 asd_printk("unsupported major version of ocm dir:0x%x\n", 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()
176 static int asd_find_dir_entry(struct asd_ocm_dir *dir, u8 type, in asd_find_dir_entry() argument
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()
198 struct asd_ocm_dir *dir) in asd_get_bios_chim() argument
204 err = asd_find_dir_entry(dir, OCM_BIOS_CHIM_DE, &offs, &size); in asd_get_bios_chim()
206 ASD_DPRINTK("couldn't find BIOS_CHIM dir ent\n"); in asd_get_bios_chim()
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()
223 ASD_DPRINTK("BIOS_CHIM entry has no valid sig(%c%c%c%c)\n", 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()
280 /* Write Dir */ in asd_hwi_initialize_ocm_dir()
284 /* Write Dir Entries */ in asd_hwi_initialize_ocm_dir()
296 struct pci_dev *pcidev = asd_ha->pcidev; in asd_hwi_check_ocm_access()
333 * asd_read_ocm - read on chip memory (OCM)
339 struct asd_ocm_dir *dir; in asd_read_ocm() local
342 return -1; in asd_read_ocm()
344 dir = kmalloc(sizeof(*dir), GFP_KERNEL); in asd_read_ocm()
345 if (!dir) { in asd_read_ocm()
346 asd_printk("no memory for ocm dir\n"); in asd_read_ocm()
347 return -ENOMEM; in asd_read_ocm()
350 err = asd_read_ocm_dir(asd_ha, dir, 0); in asd_read_ocm()
354 err = asd_get_bios_chim(asd_ha, dir); in asd_read_ocm()
356 kfree(dir); in asd_read_ocm()
360 /* ---------- FLASH stuff ---------- */
399 char sig[2]; /* 'S', 'M' */ member
426 char sig[2]; /* 'P', 'M' */ member
510 char sig[2]; /* 'M', 'C' */ member
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
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()
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()
670 ASD_DPRINTK("manuf sec: no valid sig(%c%c)\n", 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,
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
769 dflt_phy_param.sig[0] = 'P'; in asd_ms_get_phy_params()
770 dflt_phy_param.sig[1] = 'M'; in asd_ms_get_phy_params()
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
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
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()
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
1091 reg = asd_ha->hw_prof.flash.bar; in asd_verify_flash_seg()
1108 * asd_write_flash_seg - write data into flash memory
1121 reg = asd_ha->hw_prof.flash.bar; in asd_write_flash_seg()
1147 switch (asd_ha->hw_prof.flash.method) { 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.
1261 reg = asd_ha->hw_prof.flash.bar; in asd_erase_nv_sector()
1271 switch (asd_ha->hw_prof.flash.method) { in asd_erase_nv_sector()
1311 reg = asd_ha->hw_prof.flash.bar; 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()
1328 inc = asd_ha->hw_prof.flash.wide ? 2 : 1; 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()
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()