Lines Matching refs:asd_ha

116 static int asd_read_ocm_seg(struct asd_ha_struct *asd_ha, void *buffer,  in asd_read_ocm_seg()  argument
120 if (unlikely(asd_ha->iospace)) in asd_read_ocm_seg()
121 asd_read_reg_string(asd_ha, buffer, offs+OCM_BASE_ADDR, size); in asd_read_ocm_seg()
124 *p = asd_read_ocm_byte(asd_ha, offs); in asd_read_ocm_seg()
129 static int asd_read_ocm_dir(struct asd_ha_struct *asd_ha, in asd_read_ocm_dir() argument
132 int err = asd_read_ocm_seg(asd_ha, dir, offs, sizeof(*dir)); in asd_read_ocm_dir()
161 static void asd_write_ocm_seg(struct asd_ha_struct *asd_ha, void *buffer, in asd_write_ocm_seg() argument
165 if (unlikely(asd_ha->iospace)) in asd_write_ocm_seg()
166 asd_write_reg_string(asd_ha, buffer, offs+OCM_BASE_ADDR, size); in asd_write_ocm_seg()
169 asd_write_ocm_byte(asd_ha, offs, *p); in asd_write_ocm_seg()
197 static int asd_get_bios_chim(struct asd_ha_struct *asd_ha, in asd_get_bios_chim() argument
215 err = asd_read_ocm_seg(asd_ha, (void *)bc_struct, offs, 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()
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()
272 asd_hwi_initialize_ocm_dir (struct asd_ha_struct *asd_ha) in asd_hwi_initialize_ocm_dir() argument
278 asd_write_ocm_dword(asd_ha, i, 0); in asd_hwi_initialize_ocm_dir()
281 asd_write_ocm_seg(asd_ha, &OCMDirInit, 0, in asd_hwi_initialize_ocm_dir()
286 asd_write_ocm_seg(asd_ha, &OCMDirEntriesInit[i], in asd_hwi_initialize_ocm_dir()
294 asd_hwi_check_ocm_access (struct asd_ha_struct *asd_ha) in asd_hwi_check_ocm_access() argument
296 struct pci_dev *pcidev = asd_ha->pcidev; in asd_hwi_check_ocm_access()
302 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); in asd_hwi_check_ocm_access()
325 asd_hwi_initialize_ocm_dir(asd_ha); in asd_hwi_check_ocm_access()
336 int asd_read_ocm(struct asd_ha_struct *asd_ha) in asd_read_ocm() argument
341 if (asd_hwi_check_ocm_access(asd_ha)) 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()
550 static int asd_poll_flash(struct asd_ha_struct *asd_ha) in asd_poll_flash() argument
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()
565 static int asd_reset_flash(struct asd_ha_struct *asd_ha) in asd_reset_flash() argument
569 err = asd_poll_flash(asd_ha); in asd_reset_flash()
572 asd_write_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar, FLASH_RESET); in asd_reset_flash()
573 err = asd_poll_flash(asd_ha); in asd_reset_flash()
578 static int asd_read_flash_seg(struct asd_ha_struct *asd_ha, in asd_read_flash_seg() argument
581 asd_read_reg_string(asd_ha, buffer, asd_ha->hw_prof.flash.bar+offs, in asd_read_flash_seg()
594 static int asd_find_flash_dir(struct asd_ha_struct *asd_ha, in asd_find_flash_dir() argument
599 asd_read_flash_seg(asd_ha, flash_dir, v, in asd_find_flash_dir()
603 asd_ha->hw_prof.flash.dir_offs = v; in asd_find_flash_dir()
604 asd_read_flash_seg(asd_ha, flash_dir, v, in asd_find_flash_dir()
612 static int asd_flash_getid(struct asd_ha_struct *asd_ha) in asd_flash_getid() argument
617 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); in asd_flash_getid()
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()
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()
627 err = asd_reset_flash(asd_ha); in asd_flash_getid()
690 static int asd_ms_get_sas_addr(struct asd_ha_struct *asd_ha, in asd_ms_get_sas_addr() argument
693 memcpy(asd_ha->hw_prof.sas_addr, ms->sas_addr, SAS_ADDR_SIZE); in asd_ms_get_sas_addr()
697 static int asd_ms_get_pcba_sn(struct asd_ha_struct *asd_ha, in asd_ms_get_pcba_sn() argument
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()
756 static int asd_ms_get_phy_params(struct asd_ha_struct *asd_ha, in asd_ms_get_phy_params() argument
795 asd_ha->hw_prof.enabled_phys = 0; 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()
826 static int asd_ms_get_connector_map(struct asd_ha_struct *asd_ha, in asd_ms_get_connector_map() argument
854 static int asd_process_ms(struct asd_ha_struct *asd_ha, in asd_process_ms() argument
877 err = asd_read_flash_seg(asd_ha, (void *)manuf_sec, offs, size); in asd_process_ms()
890 err = asd_ms_get_sas_addr(asd_ha, manuf_sec); in asd_process_ms()
896 SAS_ADDR(asd_ha->hw_prof.sas_addr)); in asd_process_ms()
898 err = asd_ms_get_pcba_sn(asd_ha, manuf_sec); in asd_process_ms()
903 ASD_DPRINTK("manuf sect PCBA SN %s\n", asd_ha->hw_prof.pcba_sn); in asd_process_ms()
905 err = asd_ms_get_phy_params(asd_ha, manuf_sec); in asd_process_ms()
911 err = asd_ms_get_connector_map(asd_ha, manuf_sec); in asd_process_ms()
923 static int asd_process_ctrla_phy_settings(struct asd_ha_struct *asd_ha, in asd_process_ctrla_phy_settings() argument
930 if (!PHY_ENABLED(asd_ha, i)) 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()
941 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_process_ctrla_phy_settings()
943 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_process_ctrla_phy_settings()
945 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_process_ctrla_phy_settings()
947 asd_ha->hw_prof.phy_desc[i].flags = pe->flags; 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()
967 static int asd_process_ctrl_a_user(struct asd_ha_struct *asd_ha, in asd_process_ctrl_a_user() argument
985 asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE); in asd_process_ctrl_a_user()
1006 err = asd_read_flash_seg(asd_ha, (void *)el, offs, size); in asd_process_ctrl_a_user()
1019 err = asd_process_ctrla_phy_settings(asd_ha, ps); in asd_process_ctrl_a_user()
1034 int asd_read_flash(struct asd_ha_struct *asd_ha) in asd_read_flash() argument
1039 err = asd_flash_getid(asd_ha); in asd_read_flash()
1048 if (!asd_find_flash_dir(asd_ha, flash_dir)) { in asd_read_flash()
1059 err = asd_process_ms(asd_ha, flash_dir); in asd_read_flash()
1065 err = asd_process_ctrl_a_user(asd_ha, flash_dir); in asd_read_flash()
1083 int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, in asd_verify_flash_seg() argument
1091 reg = asd_ha->hw_prof.flash.bar; in asd_verify_flash_seg()
1098 flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i); in asd_verify_flash_seg()
1114 int asd_write_flash_seg(struct asd_ha_struct *asd_ha, in asd_write_flash_seg() argument
1121 reg = asd_ha->hw_prof.flash.bar; in asd_write_flash_seg()
1124 err = asd_check_flash_type(asd_ha); in asd_write_flash_seg()
1131 err = asd_erase_nv_sector(asd_ha, nv_offset, bytes_to_write); in asd_write_flash_seg()
1138 err = asd_reset_flash(asd_ha); in asd_write_flash_seg()
1147 switch (asd_ha->hw_prof.flash.method) { in asd_write_flash_seg()
1150 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1152 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1154 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1156 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1163 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1165 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1167 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1169 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1177 if (asd_chk_write_status(asd_ha, in asd_write_flash_seg()
1185 err = asd_reset_flash(asd_ha); in asd_write_flash_seg()
1193 int asd_chk_write_status(struct asd_ha_struct *asd_ha, in asd_chk_write_status() argument
1205 reg = asd_ha->hw_prof.flash.bar; in asd_chk_write_status()
1208 nv_data1 = asd_read_reg_byte(asd_ha, reg); in asd_chk_write_status()
1209 nv_data2 = asd_read_reg_byte(asd_ha, reg); in asd_chk_write_status()
1218 nv_data1 = asd_read_reg_byte(asd_ha, in asd_chk_write_status()
1220 nv_data2 = asd_read_reg_byte(asd_ha, in asd_chk_write_status()
1256 int asd_erase_nv_sector(struct asd_ha_struct *asd_ha, u32 flash_addr, u32 size) in asd_erase_nv_sector() argument
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()
1273 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA); in asd_erase_nv_sector()
1274 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55); in asd_erase_nv_sector()
1275 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0x80); in asd_erase_nv_sector()
1276 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA); in asd_erase_nv_sector()
1277 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55); in asd_erase_nv_sector()
1278 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30); in asd_erase_nv_sector()
1281 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_erase_nv_sector()
1282 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_erase_nv_sector()
1283 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x80); in asd_erase_nv_sector()
1284 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_erase_nv_sector()
1285 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_erase_nv_sector()
1286 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30); in asd_erase_nv_sector()
1292 if (asd_chk_write_status(asd_ha, sector_addr, 1) != 0) in asd_erase_nv_sector()
1301 int asd_check_flash_type(struct asd_ha_struct *asd_ha) in asd_check_flash_type() argument
1311 reg = asd_ha->hw_prof.flash.bar; in asd_check_flash_type()
1314 err = asd_reset_flash(asd_ha); 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()
1329 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0xAA); in asd_check_flash_type()
1330 asd_write_reg_byte(asd_ha, reg + 0x555, 0x55); in asd_check_flash_type()
1331 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0x90); in asd_check_flash_type()
1332 manuf_id = asd_read_reg_byte(asd_ha, reg); in asd_check_flash_type()
1333 dev_id = asd_read_reg_byte(asd_ha, reg + inc); in asd_check_flash_type()
1334 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc); in asd_check_flash_type()
1336 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1343 err = asd_reset_flash(asd_ha); 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()
1387 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1394 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_check_flash_type()
1395 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_check_flash_type()
1396 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x90); in asd_check_flash_type()
1397 manuf_id = asd_read_reg_byte(asd_ha, reg); in asd_check_flash_type()
1398 dev_id = asd_read_reg_byte(asd_ha, reg + inc); in asd_check_flash_type()
1399 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc); in asd_check_flash_type()
1404 err = asd_reset_flash(asd_ha); 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()