SDM660 UEFI LCD读ID脚兼容

/*--------------------------------------------------------------------------------*/
enum lcd_panel_type {
    PANEL_ST7701S_WVGA = 1,
    PANEL_ST7701S_30TH,
};
/*
add for detect GPIO24 lcd_ID0 and GPIO65 lcd_ID1 
*/
int panel_detect_pin_id(void)
{
    UINT32  lcd_id0 = 0;
    UINT32  lcd_id1 = 0;
    EFI_STATUS status = EFI_SUCCESS;
    UINT32 idconfig,idconfig1;
    EFI_TLMM_PROTOCOL   *TLMMProtocol = NULL;
    //DEBUG((EFI_D_ERROR, "panel_detect_pin_id is start\n")); 
    
if (EFI_SUCCESS != gBS->LocateProtocol(&gEfiTLMMProtocolGuid, NULL, (void**)&TLMMProtocol))
 {
    DEBUG((EFI_D_ERROR, "DisplayDxe: Locate TLMM protocol failed!\n"));
 }
else
 {    
        idconfig =  EFI_GPIO_CFG( LCD_ID0_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA );
        status = TLMMProtocol->ConfigGpio((UINT32)idconfig,TLMM_GPIO_ENABLE);
        if (status != EFI_SUCCESS)
        {
            DEBUG((EFI_D_ERROR, "Faile to Configure MSM GPIO 24 ENABLE !!\n"));
        }    
        
        idconfig1 =  EFI_GPIO_CFG( LCD_ID1_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA );
        status = TLMMProtocol->ConfigGpio((UINT32)idconfig1,TLMM_GPIO_ENABLE);
        if (status != EFI_SUCCESS)
        {
            DEBUG((EFI_D_ERROR, "Faile to Configure MSM GPIO 65 ENABLE !!\n"));
        }    
        /*Read Value*/
            gBS->Stall(20000);//20ms
        status = TLMMProtocol->GpioIn(idconfig, &lcd_id0);
            gBS->Stall(5000); // 5 ms .
        status = TLMMProtocol->GpioIn(idconfig1, &lcd_id1);
            DEBUG((EFI_D_ERROR, "lcd_id0 = %d\t lcd_id1 = %d.\n",lcd_id0,lcd_id1));  
        }
    /*Select TP*/
    if ((lcd_id0 == GPIO_LOW_VALUE) && (lcd_id1 == GPIO_HIGH_VALUE)) {
            DEBUG((EFI_D_ERROR, "PANEL_ST7701S_WVGA\n"));   
        return PANEL_ST7701S_WVGA;
        }
    else if ((lcd_id0 == GPIO_LOW_VALUE) && (lcd_id1 == GPIO_LOW_VALUE)){
            DEBUG((EFI_D_ERROR, "PANEL_ST7701S_30TH\n"));   
        return PANEL_ST7701S_30TH;
        }
        
    return 0;
}

SDM660 UEFI LCD读ID脚兼容_第1张图片

你可能感兴趣的:(Linux,Linux内核)