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()
548 static int asd_poll_flash(struct asd_ha_struct *asd_ha) in asd_poll_flash() argument
554 d = asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar); in asd_poll_flash()
555 d ^= asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar); in asd_poll_flash()
563 static int asd_reset_flash(struct asd_ha_struct *asd_ha) in asd_reset_flash() argument
567 err = asd_poll_flash(asd_ha); in asd_reset_flash()
570 asd_write_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar, FLASH_RESET); in asd_reset_flash()
571 err = asd_poll_flash(asd_ha); in asd_reset_flash()
576 static int asd_read_flash_seg(struct asd_ha_struct *asd_ha, in asd_read_flash_seg() argument
579 asd_read_reg_string(asd_ha, buffer, asd_ha->hw_prof.flash.bar+offs, in asd_read_flash_seg()
592 static int asd_find_flash_dir(struct asd_ha_struct *asd_ha, in asd_find_flash_dir() argument
597 asd_read_flash_seg(asd_ha, flash_dir, v, in asd_find_flash_dir()
601 asd_ha->hw_prof.flash.dir_offs = v; in asd_find_flash_dir()
602 asd_read_flash_seg(asd_ha, flash_dir, v, in asd_find_flash_dir()
610 static int asd_flash_getid(struct asd_ha_struct *asd_ha) in asd_flash_getid() argument
615 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); in asd_flash_getid()
617 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR, in asd_flash_getid()
618 &asd_ha->hw_prof.flash.bar)) { in asd_flash_getid()
620 pci_name(asd_ha->pcidev)); in asd_flash_getid()
623 asd_ha->hw_prof.flash.present = 1; in asd_flash_getid()
624 asd_ha->hw_prof.flash.wide = reg & FLASHW ? 1 : 0; in asd_flash_getid()
625 err = asd_reset_flash(asd_ha); in asd_flash_getid()
688 static int asd_ms_get_sas_addr(struct asd_ha_struct *asd_ha, in asd_ms_get_sas_addr() argument
691 memcpy(asd_ha->hw_prof.sas_addr, ms->sas_addr, SAS_ADDR_SIZE); in asd_ms_get_sas_addr()
695 static int asd_ms_get_pcba_sn(struct asd_ha_struct *asd_ha, in asd_ms_get_pcba_sn() argument
698 memcpy(asd_ha->hw_prof.pcba_sn, ms->pcba_sn, ASD_PCBA_SN_SIZE); in asd_ms_get_pcba_sn()
699 asd_ha->hw_prof.pcba_sn[ASD_PCBA_SN_SIZE] = '\0'; in asd_ms_get_pcba_sn()
752 static int asd_ms_get_phy_params(struct asd_ha_struct *asd_ha, in asd_ms_get_phy_params() argument
791 asd_ha->hw_prof.enabled_phys = 0; in asd_ms_get_phy_params()
800 asd_ha->hw_prof.enabled_phys &= ~(1 << i); in asd_ms_get_phy_params()
805 asd_ha->hw_prof.enabled_phys |= (1 << i); in asd_ms_get_phy_params()
809 asd_ha->hw_prof.phy_desc[i].phy_control_0 = pd->phy_control_0; in asd_ms_get_phy_params()
810 asd_ha->hw_prof.phy_desc[i].phy_control_1 = pd->phy_control_1; in asd_ms_get_phy_params()
811 asd_ha->hw_prof.phy_desc[i].phy_control_2 = pd->phy_control_2; in asd_ms_get_phy_params()
812 asd_ha->hw_prof.phy_desc[i].phy_control_3 = pd->phy_control_3; in asd_ms_get_phy_params()
814 asd_ha->hw_prof.max_phys = rep_phys + en_phys; in asd_ms_get_phy_params()
815 asd_ha->hw_prof.num_phys = en_phys; in asd_ms_get_phy_params()
817 asd_ha->hw_prof.max_phys, asd_ha->hw_prof.num_phys); in asd_ms_get_phy_params()
818 ASD_DPRINTK("ms: enabled_phys:0x%x\n", asd_ha->hw_prof.enabled_phys); in asd_ms_get_phy_params()
822 static int asd_ms_get_connector_map(struct asd_ha_struct *asd_ha, in asd_ms_get_connector_map() argument
850 static int asd_process_ms(struct asd_ha_struct *asd_ha, in asd_process_ms() argument
873 err = asd_read_flash_seg(asd_ha, (void *)manuf_sec, offs, size); in asd_process_ms()
886 err = asd_ms_get_sas_addr(asd_ha, manuf_sec); in asd_process_ms()
892 SAS_ADDR(asd_ha->hw_prof.sas_addr)); in asd_process_ms()
894 err = asd_ms_get_pcba_sn(asd_ha, manuf_sec); in asd_process_ms()
899 ASD_DPRINTK("manuf sect PCBA SN %s\n", asd_ha->hw_prof.pcba_sn); in asd_process_ms()
901 err = asd_ms_get_phy_params(asd_ha, manuf_sec); in asd_process_ms()
907 err = asd_ms_get_connector_map(asd_ha, manuf_sec); in asd_process_ms()
919 static int asd_process_ctrla_phy_settings(struct asd_ha_struct *asd_ha, in asd_process_ctrla_phy_settings() argument
926 if (!PHY_ENABLED(asd_ha, i)) in asd_process_ctrla_phy_settings()
929 asd_ha->hw_prof.enabled_phys &= ~(1 << i); in asd_process_ctrla_phy_settings()
933 memcpy(asd_ha->hw_prof.phy_desc[i].sas_addr, pe->sas_addr, in asd_process_ctrla_phy_settings()
935 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_process_ctrla_phy_settings()
937 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_process_ctrla_phy_settings()
939 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_process_ctrla_phy_settings()
941 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_process_ctrla_phy_settings()
943 asd_ha->hw_prof.phy_desc[i].flags = pe->flags; in asd_process_ctrla_phy_settings()
947 SAS_ADDR(asd_ha->hw_prof.phy_desc[i].sas_addr), in asd_process_ctrla_phy_settings()
948 asd_ha->hw_prof.phy_desc[i].max_sas_lrate, in asd_process_ctrla_phy_settings()
949 asd_ha->hw_prof.phy_desc[i].min_sas_lrate, in asd_process_ctrla_phy_settings()
950 asd_ha->hw_prof.phy_desc[i].max_sata_lrate, in asd_process_ctrla_phy_settings()
951 asd_ha->hw_prof.phy_desc[i].min_sata_lrate, in asd_process_ctrla_phy_settings()
952 asd_ha->hw_prof.phy_desc[i].flags); in asd_process_ctrla_phy_settings()
963 static int asd_process_ctrl_a_user(struct asd_ha_struct *asd_ha, in asd_process_ctrl_a_user() argument
981 asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE); in asd_process_ctrl_a_user()
1002 err = asd_read_flash_seg(asd_ha, (void *)el, offs, size); in asd_process_ctrl_a_user()
1015 err = asd_process_ctrla_phy_settings(asd_ha, ps); in asd_process_ctrl_a_user()
1030 int asd_read_flash(struct asd_ha_struct *asd_ha) in asd_read_flash() argument
1035 err = asd_flash_getid(asd_ha); in asd_read_flash()
1044 if (!asd_find_flash_dir(asd_ha, flash_dir)) { in asd_read_flash()
1055 err = asd_process_ms(asd_ha, flash_dir); in asd_read_flash()
1061 err = asd_process_ctrl_a_user(asd_ha, flash_dir); in asd_read_flash()
1079 int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, in asd_verify_flash_seg() argument
1087 reg = asd_ha->hw_prof.flash.bar; in asd_verify_flash_seg()
1094 flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i); in asd_verify_flash_seg()
1110 int asd_write_flash_seg(struct asd_ha_struct *asd_ha, in asd_write_flash_seg() argument
1117 reg = asd_ha->hw_prof.flash.bar; in asd_write_flash_seg()
1120 err = asd_check_flash_type(asd_ha); in asd_write_flash_seg()
1127 err = asd_erase_nv_sector(asd_ha, nv_offset, bytes_to_write); in asd_write_flash_seg()
1134 err = asd_reset_flash(asd_ha); in asd_write_flash_seg()
1143 switch (asd_ha->hw_prof.flash.method) { in asd_write_flash_seg()
1146 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1148 asd_write_reg_byte(asd_ha, 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()
1159 asd_write_reg_byte(asd_ha, in asd_write_flash_seg()
1161 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()
1173 if (asd_chk_write_status(asd_ha, in asd_write_flash_seg()
1181 err = asd_reset_flash(asd_ha); in asd_write_flash_seg()
1189 int asd_chk_write_status(struct asd_ha_struct *asd_ha, in asd_chk_write_status() argument
1201 reg = asd_ha->hw_prof.flash.bar; in asd_chk_write_status()
1204 nv_data1 = asd_read_reg_byte(asd_ha, reg); in asd_chk_write_status()
1205 nv_data2 = asd_read_reg_byte(asd_ha, reg); in asd_chk_write_status()
1214 nv_data1 = asd_read_reg_byte(asd_ha, in asd_chk_write_status()
1216 nv_data2 = asd_read_reg_byte(asd_ha, in asd_chk_write_status()
1252 int asd_erase_nv_sector(struct asd_ha_struct *asd_ha, u32 flash_addr, u32 size) in asd_erase_nv_sector() argument
1257 reg = asd_ha->hw_prof.flash.bar; in asd_erase_nv_sector()
1267 switch (asd_ha->hw_prof.flash.method) { in asd_erase_nv_sector()
1269 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA); in asd_erase_nv_sector()
1270 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55); in asd_erase_nv_sector()
1271 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0x80); in asd_erase_nv_sector()
1272 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA); in asd_erase_nv_sector()
1273 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55); in asd_erase_nv_sector()
1274 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30); in asd_erase_nv_sector()
1277 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_erase_nv_sector()
1278 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_erase_nv_sector()
1279 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x80); in asd_erase_nv_sector()
1280 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_erase_nv_sector()
1281 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_erase_nv_sector()
1282 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30); in asd_erase_nv_sector()
1288 if (asd_chk_write_status(asd_ha, sector_addr, 1) != 0) in asd_erase_nv_sector()
1297 int asd_check_flash_type(struct asd_ha_struct *asd_ha) in asd_check_flash_type() argument
1307 reg = asd_ha->hw_prof.flash.bar; in asd_check_flash_type()
1310 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1316 asd_ha->hw_prof.flash.method = FLASH_METHOD_UNKNOWN; in asd_check_flash_type()
1317 asd_ha->hw_prof.flash.manuf = FLASH_MANUF_ID_UNKNOWN; in asd_check_flash_type()
1318 asd_ha->hw_prof.flash.dev_id = FLASH_DEV_ID_UNKNOWN; in asd_check_flash_type()
1324 inc = asd_ha->hw_prof.flash.wide ? 2 : 1; in asd_check_flash_type()
1325 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0xAA); in asd_check_flash_type()
1326 asd_write_reg_byte(asd_ha, reg + 0x555, 0x55); in asd_check_flash_type()
1327 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0x90); in asd_check_flash_type()
1328 manuf_id = asd_read_reg_byte(asd_ha, reg); in asd_check_flash_type()
1329 dev_id = asd_read_reg_byte(asd_ha, reg + inc); in asd_check_flash_type()
1330 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc); in asd_check_flash_type()
1332 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1339 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1349 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1359 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1369 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1376 asd_ha->hw_prof.flash.method = FLASH_METHOD_A; in asd_check_flash_type()
1382 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) { in asd_check_flash_type()
1383 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1390 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA); in asd_check_flash_type()
1391 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55); in asd_check_flash_type()
1392 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x90); in asd_check_flash_type()
1393 manuf_id = asd_read_reg_byte(asd_ha, reg); in asd_check_flash_type()
1394 dev_id = asd_read_reg_byte(asd_ha, reg + inc); in asd_check_flash_type()
1395 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc); in asd_check_flash_type()
1400 err = asd_reset_flash(asd_ha); in asd_check_flash_type()
1410 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1419 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1428 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1435 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1442 asd_ha->hw_prof.flash.method = FLASH_METHOD_B; in asd_check_flash_type()
1451 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) in asd_check_flash_type()
1454 asd_ha->hw_prof.flash.manuf = manuf_id; in asd_check_flash_type()
1455 asd_ha->hw_prof.flash.dev_id = dev_id; in asd_check_flash_type()
1456 asd_ha->hw_prof.flash.sec_prot = sec_prot; in asd_check_flash_type()