Beispiel #1
0
int mt8193_power_on(void)
{
    MT8193_DRV_FUNC();
    #if defined(CONFIG_HAS_EARLYSUSPEND)
    if(mt8193_hdmiearlysuspend==0) return 0;
    #endif	
	mt8193_hotinit = 0;
	mt_set_gpio_mode(GPIO_HDMI_POWER_CONTROL, GPIO_MODE_00);  
    mt_set_gpio_dir(GPIO_HDMI_POWER_CONTROL, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_HDMI_POWER_CONTROL, GPIO_OUT_ONE);

	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_power_turnon, hdmi_power_turnon);
	vWriteHdmiSYSMsk(HDMI_SYS_PWR_RST_B, hdmi_pwr_sys_sw_unreset, hdmi_pwr_sys_sw_unreset);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_iso_dis, hdmi_iso_en);
    vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_clock_on, hdmi_clock_off);
	
	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, ANLG_ON|HDMI_ON, ANLG_ON|HDMI_ON);
	
    mt8193_i2c_write(0x1500, 0x20);
    vHotPlugPinInit();
    vInitHdcpKeyGetMethod(NON_HOST_ACCESS_FROM_EEPROM);


	vWriteHdmiIntMask(0xFF);
	
    return 0;
}
void vResetHDMIPLL(void)
{
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2, 0, POW_PLL_L);
	udelay(2);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2, POW_PLL_L, POW_PLL_L);
	udelay(2);
}
void vEnableDeepColor(u8 ui1Mode)
{
  u32 u4Data;
  MT8193_DRV_FUNC();
  if(ui1Mode == HDMI_DEEP_COLOR_10_BIT)
  {
  	u4Data = COLOR_10BIT_MODE;
  }
  else if(ui1Mode == HDMI_DEEP_COLOR_12_BIT)
  {
  	u4Data = COLOR_12BIT_MODE;
  }	
  else if(ui1Mode == HDMI_DEEP_COLOR_16_BIT)
  {
  	u4Data = COLOR_16BIT_MODE;
  }	
  else 
  {
  	u4Data = COLOR_8BIT_MODE;
  }	
 	
  if(u4Data == COLOR_8BIT_MODE)	
  {
  	vWriteHdmiSYSMsk(HDMI_SYS_CFG20, u4Data, DEEP_COLOR_MODE_MASK| DEEP_COLOR_EN);	
  }
  else
  {
  	vWriteHdmiSYSMsk(HDMI_SYS_CFG20, u4Data|DEEP_COLOR_EN, DEEP_COLOR_MODE_MASK| DEEP_COLOR_EN);		
  }		
  
}	
void vTxSignalOnOff(u8 bOn)
{
  u8 bData1;
  
  MT8193_PLL_FUNC();

  bData1=bReadByteHdmiGRL(GRL_INT)&INT_MDI;
 
  if(bOn)
  {
	vWriteHdmiSYSMsk(HDMI_SYS_AMPCTRL,RG_SET_DTXST,RG_SET_DTXST);
	//the 5ms delay time after pll setting , resolve CTS 7-6 can't find trigger and result fail
	mdelay(5);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL7,TX_DRV_ENABLE,TX_DRV_ENABLE_MSK);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6,0,ABIST_MODE_SET_MSK);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6,0,ABIST_MODE_EN|ABIST_LV_EN);
  }
  else
  {
	vWriteHdmiSYSMsk(HDMI_SYS_AMPCTRL,0,RG_SET_DTXST);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL1,0,RG_ENCKST);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6,ABIST_MODE_SET,ABIST_MODE_SET_MSK);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6,ABIST_MODE_EN|ABIST_LV_EN,ABIST_MODE_EN|ABIST_LV_EN);
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL7,0,TX_DRV_ENABLE_MSK);
  }
  if((bData1!=INT_MDI))
  bClearGRLInt(INT_MDI);
}
void vResetHDMI(BYTE bRst)
{
	MT8193_DRV_FUNC();
	if (bRst) {
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, HDMI_RST, HDMI_RST);
	} else {
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, 0, HDMI_RST);
		vWriteHdmiGRLMsk(GRL_CFG3, 0, CFG3_CONTROL_PACKET_DELAY);	/* Designer suggest adjust Control packet deliver time */
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, ANLG_ON, ANLG_ON);
	}
}
void vWriteAksvKeyMask(u8 *PrData)
{
	u8 bData;
	/* - write wIdx into 92. */
	MT8193_HDCP_FUNC();
	bData = (*(PrData + 2) & 0x0f) | ((*(PrData + 3) & 0x0f) << 4);

	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, (bData << 16), SYS_KEYMASK2);
	bData = (*(PrData + 0) & 0x0f) | ((*(PrData + 1) & 0x0f) << 4);

	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, (bData << 8), SYS_KEYMASK1);
}
void vInitHdcpKeyGetMethod(u8 bMethod)
{
	MT8193_HDCP_FUNC();
	if (bMethod == NON_HOST_ACCESS_FROM_EEPROM) {
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, (I2CM_ON | EXT_E2PROM_ON),
				 (I2CM_ON | EXT_E2PROM_ON));
	} else if (bMethod == NON_HOST_ACCESS_FROM_MCM) {
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, (I2CM_ON | MCM_E2PROM_ON),
				 (I2CM_ON | MCM_E2PROM_ON));
	} else if (bMethod == NON_HOST_ACCESS_FROM_GCPU) {
		vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, AES_EFUSE_ENABLE,
				 (AES_EFUSE_ENABLE | I2CM_ON | EXT_E2PROM_ON | MCM_E2PROM_ON));
	}
}
void vSetHDMITxPLL(u8 bResIndex, u8 bdeepmode)
{
	u8 u4Feq = 0;
	MT8193_PLL_FUNC();

	vWriteHdmiDGIMsk(dgi0_anaif_ctrl1, dgi1_pad_clk_en,
			 anaif_dig1_clk_sel | dgi1_pad_clk_en | clk_sel_tv_mode | data_in_tv_mode |
			 dgi1_clk_pad_sel_tv_mode | tv_mode_clk_en);

	if ((bResIndex == HDMI_VIDEO_720x480p_60Hz) || (bResIndex == HDMI_VIDEO_720x576p_50Hz))
		u4Feq = 0;	/* 27M */
	else if ((bResIndex == HDMI_VIDEO_1920x1080p_60Hz)
		 || (bResIndex == HDMI_VIDEO_1920x1080p_50Hz))
		u4Feq = 2;	/* 148M */
	else
		u4Feq = 1;	/* 74M */

	if (((bResIndex == HDMI_VIDEO_1920x1080p_60Hz) || (bResIndex == HDMI_VIDEO_1920x1080p_50Hz))
	    && (bdeepmode == HDMI_DEEP_COLOR_12_BIT))
		vVideoPLLInit_1080P_36BIT();
	else
		vVideoPLLInit();

	udelay(10);
	if (bdeepmode == HDMI_NO_DEEP_COLOR) {
		vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2, (HDMI_PLL_SETTING[u4Feq][0]), 0xFF);
		vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,
			      (HDMI_PLL_SETTING[u4Feq][1]) | (HDMI_PLL_SETTING[u4Feq][2] << 8) |
			      (HDMI_PLL_SETTING[u4Feq][3] << 16) | (HDMI_PLL_SETTING[u4Feq][4] <<
								    24));
	} else if (bdeepmode == HDMI_DEEP_COLOR_10_BIT) {
		vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2, (HDMI_PLL_SETTING_X_1_25[u4Feq][0]), 0xFF);
		vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,
			      (HDMI_PLL_SETTING_X_1_25[u4Feq][1]) |
			      (HDMI_PLL_SETTING_X_1_25[u4Feq][2] << 8) |
			      (HDMI_PLL_SETTING_X_1_25[u4Feq][3] << 16) |
			      (HDMI_PLL_SETTING_X_1_25[u4Feq][4] << 24));
	} else if (bdeepmode == HDMI_DEEP_COLOR_12_BIT) {
		vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2, (HDMI_PLL_SETTING_X_1_5[u4Feq][0]), 0xFF);
		vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,
			      (HDMI_PLL_SETTING_X_1_5[u4Feq][1]) | (HDMI_PLL_SETTING_X_1_5[u4Feq][2]
								    << 8) |
			      (HDMI_PLL_SETTING_X_1_5[u4Feq][3] << 16) |
			      (HDMI_PLL_SETTING_X_1_5[u4Feq][4] << 24));
	}
	vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6, RG_CK148M_EN, RG_CK148M_EN);


}
int mt8193_power_on(void)
{
	struct device_node *dn;
	int bus_switch_pin;

	HDMI_DEF_LOG("[hdmi]mt8193_power_on_\n");

	if (hdmi_powerenable == 1) {
		HDMI_DEF_LOG("[hdmi]already power on, return\n");
		return 0;
	}
	hdmi_powerenable = 1;

#if defined(CONFIG_HAS_EARLYSUSPEND)
	if (mt8193_hdmiearlysuspend == 0)
		return 0;
#endif
	mt8193_hotinit = 0;
	mt8193_hotplugstate = HDMI_STATE_HOT_PLUG_OUT;
	is_hdmi_plug_out_flag = 0;
#ifdef GPIO_HDMI_POWER_CONTROL
	mt_set_gpio_mode(GPIO_HDMI_POWER_CONTROL, GPIO_MODE_00);
	mt_set_gpio_dir(GPIO_HDMI_POWER_CONTROL, GPIO_DIR_OUT);
	mt_set_gpio_out(GPIO_HDMI_POWER_CONTROL, GPIO_OUT_ONE);
	HDMI_DEF_LOG("[hdmi]hdmi_5v_on\n");
#endif

	dn = of_find_compatible_node(NULL, NULL, "mediatek,mt8193-hdmi");
	bus_switch_pin = of_get_named_gpio(dn, "hdmi_power_gpios", 0);
	gpio_direction_output(bus_switch_pin, 1);

	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_power_turnon, hdmi_power_turnon);
	vWriteHdmiSYSMsk(HDMI_SYS_PWR_RST_B, hdmi_pwr_sys_sw_unreset, hdmi_pwr_sys_sw_unreset);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_iso_dis, hdmi_iso_en);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_clock_on, hdmi_clock_off);

	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, ANLG_ON | HDMI_ON, ANLG_ON | HDMI_ON);

	mt8193_i2c_write(0x1500, 0x20);
	vHotPlugPinInit();
	vInitHdcpKeyGetMethod(NON_HOST_ACCESS_FROM_EEPROM);

	vWriteHdmiIntMask(0xFF);

	mod_timer(&r_hdmi_timer, jiffies + gHDMI_CHK_INTERVAL / (1000 / HZ));
	mod_timer(&r_cec_timer, jiffies + gCEC_CHK_INTERVAL / (1000 / HZ));

	return 0;
}
Beispiel #10
0
void mt8193_power_off(void)
{
    MT8193_DRV_FUNC();
	
	mt8193_hotinit = 1;
	mt8193_hotplugstate = HDMI_STATE_HOT_PLUG_OUT;
	vSetSharedInfo(SI_HDMI_RECEIVER_STATUS, HDMI_PLUG_OUT);
    vWriteHdmiIntMask(0xFF);
	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, 0, ANLG_ON|HDMI_ON);
	
	mt_set_gpio_mode(GPIO_HDMI_POWER_CONTROL, GPIO_MODE_00);  
    mt_set_gpio_dir(GPIO_HDMI_POWER_CONTROL, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_HDMI_POWER_CONTROL, GPIO_OUT_ZERO);

    vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_clock_off, hdmi_clock_off);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_iso_en, hdmi_iso_en);
	vWriteHdmiSYSMsk(HDMI_SYS_PWR_RST_B, hdmi_pwr_sys_sw_reset, hdmi_pwr_sys_sw_unreset);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_power_turnoff, hdmi_power_turnon);
}
void mt8193_power_off(void)
{
	struct device_node *dn;
	int bus_switch_pin;

	HDMI_DEF_LOG("[hdmi]mt8193_power_off\n");
	if (hdmi_powerenable == 0) {
		HDMI_DEF_LOG("[hdmi]already power off, return\n");
		return;
	}
	hdmi_powerenable = 0;
	is_hdmi_plug_out_flag = 1;

	mt8193_hotinit = 1;
	mt8193_hotplugstate = HDMI_STATE_HOT_PLUG_OUT;
#if defined(CONFIG_HAS_EARLYSUSPEND)
	if (mt8193_hdmiearlysuspend == 1)
		is_hdmi_plug_out_flag = 1;
	else
		is_hdmi_plug_out_flag = 0;
#endif

	vSetSharedInfo(SI_HDMI_RECEIVER_STATUS, HDMI_PLUG_OUT);
	vWriteHdmiIntMask(0xFF);
	vWriteHdmiSYSMsk(HDMI_SYS_CFG1C, 0, ANLG_ON | HDMI_ON);
#ifdef GPIO_HDMI_POWER_CONTROL
	mt_set_gpio_mode(GPIO_HDMI_POWER_CONTROL, GPIO_MODE_00);
	mt_set_gpio_dir(GPIO_HDMI_POWER_CONTROL, GPIO_DIR_OUT);
	mt_set_gpio_out(GPIO_HDMI_POWER_CONTROL, GPIO_OUT_ZERO);
	HDMI_DEF_LOG("[hdmi]hdmi_5v_off\n");
#endif

	dn = of_find_compatible_node(NULL, NULL, "mediatek,mt8193-hdmi");
	bus_switch_pin = of_get_named_gpio(dn, "hdmi_power_gpios", 0);
	gpio_direction_output(bus_switch_pin, 0);

	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_clock_off, hdmi_clock_off);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_iso_en, hdmi_iso_en);
	vWriteHdmiSYSMsk(HDMI_SYS_PWR_RST_B, hdmi_pwr_sys_sw_reset, hdmi_pwr_sys_sw_unreset);
	vWriteHdmiSYSMsk(HDMI_PWR_CTRL, hdmi_power_turnoff, hdmi_power_turnon);

}
void vSetHDMITxPLL(u8 bResIndex, u8 bdeepmode)
{
  u8 u4Feq=0;
  MT8193_PLL_FUNC();
  
  if((bResIndex==HDMI_VIDEO_720x480p_60Hz)||(bResIndex==HDMI_VIDEO_720x576p_50Hz))
   u4Feq = 0; //27M
  else if((bResIndex==HDMI_VIDEO_1920x1080p_60Hz)||(bResIndex==HDMI_VIDEO_1920x1080p_50Hz))
   u4Feq = 2; //148M
  else
   u4Feq = 1; //74M
		
  if(((bResIndex==HDMI_VIDEO_1920x1080p_60Hz)||(bResIndex==HDMI_VIDEO_1920x1080p_50Hz))&&(bdeepmode==HDMI_DEEP_COLOR_12_BIT))
   vVideoPLLInit_1080P_36BIT();
  else
   vVideoPLLInit();	

  udelay(10);		
  if(bdeepmode==HDMI_NO_DEEP_COLOR)  
  {
   vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2,(HDMI_PLL_SETTING[u4Feq][0]), 0xFF);	
   vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,(HDMI_PLL_SETTING[u4Feq][1])|(HDMI_PLL_SETTING[u4Feq][2]<<8)|(HDMI_PLL_SETTING[u4Feq][3]<<16)|(HDMI_PLL_SETTING[u4Feq][4]<<24));      
  }
  else if(bdeepmode==HDMI_DEEP_COLOR_10_BIT)  
  {
   vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2,(HDMI_PLL_SETTING_X_1_25[u4Feq][0]), 0xFF);	
   vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,(HDMI_PLL_SETTING_X_1_25[u4Feq][1])|(HDMI_PLL_SETTING_X_1_25[u4Feq][2]<<8)|(HDMI_PLL_SETTING_X_1_25[u4Feq][3]<<16)|(HDMI_PLL_SETTING_X_1_25[u4Feq][4]<<24));      
  }
  else if(bdeepmode==HDMI_DEEP_COLOR_12_BIT)  
  {
   vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2,(HDMI_PLL_SETTING_X_1_5[u4Feq][0]), 0xFF);	
   vWriteHdmiSYS(HDMI_SYS_PLLCTRL3,(HDMI_PLL_SETTING_X_1_5[u4Feq][1])|(HDMI_PLL_SETTING_X_1_5[u4Feq][2]<<8)|(HDMI_PLL_SETTING_X_1_5[u4Feq][3]<<16)|(HDMI_PLL_SETTING_X_1_5[u4Feq][4]<<24));      
  }
  vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL6, RG_CK148M_EN, RG_CK148M_EN);
  
  vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2,POW_HDMITX, POW_HDMITX|POW_PLL_L);	
  udelay(20);
  vWriteHdmiSYSMsk(HDMI_SYS_PLLCTRL2,POW_HDMITX|POW_PLL_L, POW_HDMITX|POW_PLL_L);	

}