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); */
	}
}
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);
	}
}
Esempio n. 3
0
/******************************************************************************

 Function Name: sysparm_init

 Description:   Start system parameter driver initialise

 Notes:

******************************************************************************/
static int sysparm_init(void)
{
	int sysparm_ready_count = 0;

	audio_parm_table = NULL;
	ind_mmaudio_parm_table = NULL;
	mmaudio_parm_table = NULL;

	if (is_ap_only_boot()) {
		pr_info("[sysparm]: AP only boot, return error\n");
		return 1;
	}

	pr_info
	    ("[sysparm]: sysparm driver start (PARM_DEP_RAM_ADDR=%x"
	     " PARM_DEP_SIZE=%x)\n",
	     (int)PARM_DEP_RAM_ADDR, (int)PARM_DEP_SIZE);

	if (fuse_sysparm_initialised) {
		pr_info("[sysparm]: init already done\n");
		return 0;
	}

	sys_data_dep = ioremap_nocache(PARM_DEP_RAM_ADDR, PARM_DEP_SIZE);
	if (!sys_data_dep) {
		pr_err("[sysparm]: PARM_DEP_RAM_ADDR ioremap failed\n");
		BUG();
	}

	sysparm_ready_ind_ptr = (UInt32 *)(sys_data_dep + 0x4000);

	while (SYSPARM_INDEX_READY_INDICATOR != *sysparm_ready_ind_ptr) {
		if (sysparm_ready_count >= 5) {
			pr_err("[sysparm]: sys_data_dep+0x0: %x %x %x %x\n",
			       (int)(*(unsigned long *)(sys_data_dep + 0x0)),
			       (int)(*(unsigned long *)(sys_data_dep + 0x4)),
			       (int)(*(unsigned long *)(sys_data_dep + 0x8)),
			       (int)(*(unsigned long *)(sys_data_dep + 0xc)));

			pr_err("[sysparm]: sysparm_ind_ready_ind: %x\n",
			       (int)(*sysparm_ready_ind_ptr));

			pr_err
			    ("[sysparm]: timeout waiting for ready indicator\n");

			BUG();
		}

		mdelay(25);
		sysparm_ready_count++;
	}

	total_index_ptr = (UInt32 *)((UInt32)sysparm_ready_ind_ptr
				     + sizeof(sysparm_ready_ind_ptr));
	sysparm_index = (SysparmIndex_t *) ((UInt32)total_index_ptr
					    + sizeof(total_index_ptr));

	pr_info("[sysparm]: sysparm_init ok\n");
	fuse_sysparm_initialised = 1;

	return 0;
}