static ssize_t wdt3_store(struct device *dev, struct device_attribute *attr,
						const char *buf, size_t n)
{
	u32 wdt3;
	struct DEV_OBJECT *dev_object;
	struct WMD_DEV_CONTEXT *dev_ctxt;

	if (sscanf(buf, "%d", &wdt3) != 1)
		return -EINVAL;

	dev_object = DEV_GetFirst();
	if (dev_object == NULL)
		goto func_end;
	DEV_GetWMDContext(dev_object, &dev_ctxt);
	if (dev_ctxt == NULL)
		goto func_end;

	/* enable WDT */
	if (wdt3 == 1) {
		if (dsp_wdt_get_enable())
			goto func_end;
		dsp_wdt_set_enable(true);
		if (!CLK_Get_UseCnt(SERVICESCLK_wdt3_fck) &&
				dev_ctxt->dwBrdState != BRD_DSP_HIBERNATION)
			dsp_wdt_enable(true);
	} else if (wdt3 == 0) {
		if (!dsp_wdt_get_enable())
			goto func_end;
		if (CLK_Get_UseCnt(SERVICESCLK_wdt3_fck))
			dsp_wdt_enable(false);
		dsp_wdt_set_enable(false);
	}
func_end:
	return n;
}
Exemplo n.º 2
0
/*
 *  ======== CLK_Disable ========
 *  Purpose:
 *      Disable the clock.
 *
*/
DSP_STATUS CLK_Disable(IN enum SERVICES_ClkId clk_id)
{
	DSP_STATUS status = DSP_SOK;
	struct clk *pClk;
	s32 clkUseCnt;

	DBC_Require(clk_id < SERVICESCLK_NOT_DEFINED);
	GT_2trace(CLK_debugMask, GT_6CLASS, "CLK_Disable: CLK %s, "
		 "CLK dev id = %d\n", SERVICES_Clks[clk_id].clk_name,
		 SERVICES_Clks[clk_id].id);

	pClk = SERVICES_Clks[clk_id].clk_handle;

	clkUseCnt = CLK_Get_UseCnt(clk_id);
	if (clkUseCnt == -1) {
		GT_2trace(CLK_debugMask, GT_7CLASS, "CLK_Disable: failed to "
			 "get CLK Use count for CLK %s, CLK dev id = %d\n",
			 SERVICES_Clks[clk_id].clk_name,
			 SERVICES_Clks[clk_id].id);
	} else if (clkUseCnt == 0) {
		GT_2trace(CLK_debugMask, GT_7CLASS, "CLK_Disable: CLK %s, "
			 "CLK dev id= %d is already disabled\n",
			 SERVICES_Clks[clk_id].clk_name,
			 SERVICES_Clks[clk_id].id);
		 return status;
	}
	if (clk_id == SERVICESCLK_ssi_ick)
		SSI_Clk_Prepare(false);

		if (pClk) {
			clk_disable(pClk);
		} else {
			GT_2trace(CLK_debugMask, GT_7CLASS, "CLK_Disable: "
				 "failed to get CLK %s, CLK dev id = %d\n",
				 SERVICES_Clks[clk_id].clk_name,
				 SERVICES_Clks[clk_id].id);
			status = DSP_EFAIL;
		}
	return status;
}