void WaitForCpIpc(void *pSmBase)
{
	int k = 0, ret = 0;

	cp_running = 0;


	IPC_DEBUG(DBG_WARN, "Waiting for CP IPC to init ...\n");

	/* Debug info to show is_ap_only_boot() status */
	if (is_ap_only_boot())
		IPC_DEBUG(DBG_WARN, "AP ONLY BOOT\n");
	else
		IPC_DEBUG(DBG_WARN, "NORMAL BOOT\n");

	if (!is_ap_only_boot()) { /* Check for AP_BOOT or NORMAL_BOOT */
	    ret = IPC_IsCpIpcInit(pSmBase, IPC_AP_CPU);
		IPC_DEBUG(DBG_WARN, "back from IPC_IsCpIpcInit\n");
	    while (ret == 0) {
		/* Wait up to 2s for CP to init */
		if (k++ > 200)
			break;
		else
			msleep(10);
		ret = IPC_IsCpIpcInit(pSmBase, IPC_AP_CPU);
		}
	}

	if (ret == 1) {
		IPC_DEBUG(DBG_WARN, "CP IPC initialized\n");
		spin_lock_bh(&cp_state_notifier_lock);
		cp_running = 1;	/* TRUE; */


			


		raw_notifier_call_chain(&cp_state_notifier_list, IPC_CPSTATE_RUNNING, NULL);
		spin_unlock_bh(&cp_state_notifier_lock);
	} else if (ret == 0) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*       CP IPC NOT INITIALIZED - SYSTEM BOOTS WITH AP ONLY!!!      *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		/* SKIP reset is_ap_only_boot() non zero */
		if (!is_ap_only_boot())
			BUG_ON(ret == 0);
	} else if (ret == -1) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                             CP CRASHED !!!                       *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		BUG_ON(ret);
	} else if (ret == -2) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                     AP/CP IPC VERSION NOT MATCH !!!               *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		//BUG_ON(ret);
	}
}
예제 #2
0
void WaitForCpIpc(void *pSmBase)
{
	int k = 0, ret = 0;
	void __iomem *cp_boot_base;
	u32 reg_val;

	cp_running = 0;


	IPC_DEBUG(DBG_WARN, "Waiting for CP IPC to init 0x%x\n",
		  (unsigned int)pSmBase);

	/* Debug info to show is_ap_only_boot() status */
	if (is_ap_only_boot())
		IPC_DEBUG(DBG_WARN, "AP ONLY BOOT\n");
	else
		IPC_DEBUG(DBG_WARN, "NORMAL BOOT\n");

	if (!is_ap_only_boot()) { /* Check for AP_BOOT or NORMAL_BOOT */
	    ret = IPC_IsCpIpcInit(pSmBase, IPC_AP_CPU);
		IPC_DEBUG(DBG_WARN, "back from IPC_IsCpIpcInit\n");
	    while (ret == 0) {
		/* Wait up to 2s for CP to init */
		if (k++ > 200)
			break;
		else
			msleep(10);
		ret = IPC_IsCpIpcInit(pSmBase, IPC_AP_CPU);
		}
	}

	if (ret == 1) {
		IPC_DEBUG(DBG_WARN, "CP IPC initialized\n");
		spin_lock_bh(&cp_state_notifier_lock);
		cp_running = 1;	/* TRUE; */


			


		raw_notifier_call_chain(&cp_state_notifier_list, IPC_CPSTATE_RUNNING, NULL);
		spin_unlock_bh(&cp_state_notifier_lock);
	} else if (ret == 0) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*       CP IPC NOT INITIALIZED - SYSTEM BOOTS WITH AP ONLY!!!      *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		cp_boot_base = ioremap_nocache(MODEM_ITCM_ADDRESS, 0x20);
		if (!cp_boot_base) {
			IPC_DEBUG(DBG_ERROR,
				  "ITCM Addr=0x%x, length=0x%x",
				  MODEM_ITCM_ADDRESS, 0x20);
			IPC_DEBUG(DBG_ERROR, "ioremap cp_boot_base error\n");
			return;
		}
		reg_val = readl(cp_boot_base);
		IPC_DEBUG(DBG_ERROR, "reset vector value is 0x%x\n", reg_val);

		reg_val = readl(cp_boot_base + 0x20);
		IPC_DEBUG(DBG_ERROR, "CP Boot flag 0x%x\n", reg_val);

		iounmap(cp_boot_base);

		/* SKIP reset is_ap_only_boot() non zero */
		if (!is_ap_only_boot())
			BUG_ON(ret == 0);
	} else if (ret == -1) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                             CP CRASHED !!!                       *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		BUG_ON(ret);
	} else if (ret == -2) {
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                     AP/CP IPC VERSION NOT MATCH !!!               *\n");
		IPC_DEBUG(DBG_ERROR,
			  "*                                                                  *\n");
		IPC_DEBUG(DBG_ERROR,
			  "********************************************************************\n");
		/* BUG_ON(ret); */
	}
}