static int mtkts6311_bind(struct thermal_zone_device *thermal,
			struct thermal_cooling_device *cdev)
{
	int table_val=0;

	if(!strcmp(cdev->type, g_bind0))
	{
		table_val = 0;
	}
	else if(!strcmp(cdev->type, g_bind1))
	{
		table_val = 1;
	}
	else if(!strcmp(cdev->type, g_bind2))
	{
		table_val = 2;
	}
	else if(!strcmp(cdev->type, g_bind3))
	{
		table_val = 3;
	}
	else if(!strcmp(cdev->type, g_bind4))
	{
		table_val = 4;
	}
	else if(!strcmp(cdev->type, g_bind5))
	{
		table_val = 5;
	}
	else if(!strcmp(cdev->type, g_bind6))
	{
		table_val = 6;
	}
	else if(!strcmp(cdev->type, g_bind7))
	{
		table_val = 7;
	}
	else if(!strcmp(cdev->type, g_bind8))
	{
		table_val = 8;
	}
	else if(!strcmp(cdev->type, g_bind9))
	{
		table_val = 9;
	}
	else
	{
		return 0;
	}

	if (mtk_thermal_zone_bind_cooling_device(thermal, table_val, cdev)) {
		mtkts6311_dprintk("[mtkts6311_bind] error binding cooling dev\n");
		return -EINVAL;
	} else {
		mtkts6311_dprintk("[mtkts6311_bind] binding OK, %d\n", table_val);
	}

	return 0;
}
static int ts6311_sysrst_get_cur_state(struct thermal_cooling_device *cdev,
				 unsigned long *state)
{
	mtkts6311_dprintk("ts6311_sysrst_get_cur_state = %d \n",cl_dev_sysrst_state);
	*state = cl_dev_sysrst_state;
	return 0;
}
static int ts6311_sysrst_get_max_state(struct thermal_cooling_device *cdev,
				 unsigned long *state)
{
	mtkts6311_dprintk("ts6311_sysrst_get_max_state!!!\n");
	*state = 1;
	return 0;
}
Exemple #4
0
static int ts6311_sysrst_set_cur_state(struct thermal_cooling_device *cdev,
				 unsigned long state)
{
	mtkts6311_dprintk("ts6311_sysrst_set_cur_state = %d \n",cl_dev_sysrst_state);
	cl_dev_sysrst_state = state;
	if(cl_dev_sysrst_state == 1)
	{
		printk("Power/6311_Thermal: reset, reset, reset!!!");
		printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
		printk("*****************************************");
		printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

		BUG();
	}
	return 0;
}
static int ts6311_sysrst_set_cur_state(struct thermal_cooling_device *cdev,
				 unsigned long state)
{
	mtkts6311_dprintk("ts6311_sysrst_set_cur_state = %d \n",cl_dev_sysrst_state);
	cl_dev_sysrst_state = state;
	if(cl_dev_sysrst_state == 1)
	{
		printk("Power/6311_Thermal: reset, reset, reset!!!");
		printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
		printk("*****************************************");
		printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

#ifndef CONFIG_ARM64
        BUG();
#else
        *(unsigned int*) 0x0 = 0xdead; // To trigger data abort to reset the system for thermal protection.
#endif
	}
	return 0;
}
static int mtkts6311_get_temp(struct thermal_zone_device *thermal,
				   unsigned long *t)
{
	mtkts6311_dprintk("[mtkts6311_get_temp]\n");

	*t=50000;//default 50 degree


	if(mt6311_get_pmu_thr_status()==0x0)//T<110
	{
		*t=60000;
		mtkts6331_dprintk("mt6311_get_pmu_thr_status()==0x0\n");
		if(mt6311_get_rg_thr_l_int_status()==1)//receive interrupt
        {

			*t=80000;//60 degree
			printk("[Thermal/PMIC_6331]mt6311_get_thr_l_int_status()==1,6311 T=80 deg\n");
			mt6311_clr_thr_l_int_status();

			mt6311_set_rg_strup_thr_110_clr(1);//Set 0x28 bit 0=1 ;CLR 110 INT
			udelay(10);
			mt6311_set_rg_strup_thr_110_clr(0);

			mt6311_set_rg_strup_thr_110_irq_en(0);//Set 0x28 bit 2=0 ; disable 110 INT
            mt6311_set_rg_strup_thr_125_irq_en(1);//Set 0x28 bit 3=1; EN >125 INT

		}
	}
	else if(mt6311_get_pmu_thr_status()==0x1)//110<T<125
	{
		mtkts6331_dprintk("mt6311_get_pmu_thr_status()==0x1\n");

		*t=115000;//115 degree

		printk("[Thermal/PMIC_6331]6311 pmic temp : 110<T<125 deg\n");
	}
	else if(mt6311_get_pmu_thr_status()==0x3)//125<T<150
	{
		*t=130000;//130 degree
		//printk("[Thermal/PMIC_6331]mt6311_get_pmu_thr_status()==0x3\n");
		printk("[Thermal/PMIC_6331]6311 pmic temp 125<T<150 deg\n");

		if(mt6311_get_rg_thr_h_int_status()==1){//receive interrupt

            *t=135000;//135 degree
			printk("[Thermal/PMIC_6331]6311 pmic temp =140 deg\n");
            //printk("[Thermal/PMIC_6331]mt6311_get_rg_thr_h_int_status()==1,6311 T=135 deg\n");

            mtkts6331_dprintk("mt6311_get_thr_h_int_status()==1\n");
			mt6311_clr_thr_h_int_status();

			mt6311_set_rg_strup_thr_125_clr(1);//Set 0x28 bit 1=1 ;CLR 125 INT
			udelay(10);
	        mt6311_set_rg_strup_thr_125_clr(0);

			mt6311_set_rg_strup_thr_125_irq_en(0);//Set 0x28 bit 3=0 ; disable 125 INT
			mt6311_set_rg_strup_thr_110_irq_en(1);//Set 0x28 bit 2=1; EN <110 INT
		}

	}
	mtkts6331_dprintk("6311 pmic temp =%d\n",*t);
	return 0;
}