INT32 mtk_wcn_hif_sdio_query_chipid(INT32 waitFlag) { UINT32 timeSlotMs = 200; UINT32 maxTimeSlot = 15; UINT32 counter = 0; //gComboChipId = 0x6628; if (0 == waitFlag) { return gComboChipId; } if (0 <= hif_sdio_is_chipid_valid(gComboChipId)) { return gComboChipId; } wmt_plat_pwr_ctrl(FUNC_ON); wmt_plat_sdio_ctrl(WMT_SDIO_SLOT_SDIO1, FUNC_ON); while (counter < maxTimeSlot) { if (0 <= hif_sdio_is_chipid_valid(gComboChipId)) { break; } msleep(timeSlotMs); counter++; } wmt_plat_sdio_ctrl(WMT_SDIO_SLOT_SDIO1, FUNC_OFF); wmt_plat_pwr_ctrl(FUNC_OFF); return gComboChipId; }
int sdio_detect_query_chipid(int waitFlag) { unsigned int timeSlotMs = 200; unsigned int maxTimeSlot = 15; unsigned int counter = 0; //gComboChipId = 0x6628; if (0 == waitFlag) return gComboChipId; if (0 <= hif_sdio_is_chipid_valid(gComboChipId)) return gComboChipId; while (counter < maxTimeSlot) { if (0 <= hif_sdio_is_chipid_valid(gComboChipId)) break; msleep(timeSlotMs); counter++; } return gComboChipId; }
int wmt_detect_ext_chip_detect(void) { int iRet = -1; unsigned int chipId = -1; /*if there is no external combo chip, return -1*/ int bgfEintStatus = -1; WMT_DETECT_INFO_FUNC("++\n"); /*wait for a stable time*/ msleep (10); /*read BGF_EINT_PIN status*/ bgfEintStatus = wmt_detect_read_ext_cmb_status();; /*EINT status is not important for detect chipid,So ingnore it */ #ifdef WMT_NO_EINT_VALUE bgfEintStatus = 1 ; #endif if (0 == bgfEintStatus) { /*external chip does not exist*/ WMT_DETECT_INFO_FUNC("external combo chip not detected\n"); } else if (1 == bgfEintStatus) { /*combo chip exists*/ WMT_DETECT_INFO_FUNC("external combo chip detected\n"); /*detect chipid by sdio_detect module*/ chipId = sdio_detect_query_chipid(1); if (0 <= hif_sdio_is_chipid_valid(chipId)) { WMT_DETECT_INFO_FUNC("valid external combo chip id (0x%x)\n", chipId); } else { WMT_DETECT_INFO_FUNC("invalid_external combo chip id (0x%x)\n", chipId); } iRet = 0; } else { /*Error exists*/ WMT_DETECT_ERR_FUNC("error happens when detecting combo chip\n"); } WMT_DETECT_INFO_FUNC("--\n"); /*return 0*/ return iRet; /*todo: if there is external combo chip, power on chip return 0*/ }