/*=========================================================================== FUNCTION get_compass_gs_position DESCRIPTION This function probe which G-sensor & Campass status type should be used DEPENDENCIES RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ compass_gs_position_type get_compass_gs_position(void) { compass_gs_position_type compass_gs_position=COMPASS_TOP_GS_TOP; /* modify compass and gs position by board id */ //move C8820\25D define from TOP to BOTTOM if (machine_is_msm7x27a_surf() || machine_is_msm7x27a_ffa() || machine_is_msm7x27a_umts() || machine_is_msm7x27a_cdma() || machine_is_msm7x27a_U8815()) { compass_gs_position=COMPASS_TOP_GS_TOP; } /*< DTS2012022006500 yangbo 20120220 begin */ /*version A and version B has compass, since version C don't have compass*/ else if(machine_is_msm7x27a_C8820() && (HW_VER_SUB_VC <= get_hw_sub_board_id())) { compass_gs_position=COMPASS_NONE_GS_BOTTOM; } /* DTS2012022006500 yangbo 20120220 end > */ /* add U8655_EMMC, use the u8655 configuration */ else if (machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm7x27a_M660() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8820() || machine_is_msm7x27a_C8825D() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { compass_gs_position=COMPASS_BOTTOM_GS_BOTTOM; } else if (machine_is_msm7x27a_U8185()) { compass_gs_position=COMPASS_NONE_GS_TOP; } else if(machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { compass_gs_position=COMPASS_TOP_GS_TOP; } /*< DTS2012022300887 fengwei 20120224 begin */ else if (machine_is_msm7x27a_C8668D() ) { compass_gs_position = COMPASS_BOTTOM_GS_TOP; } /* DTS2012022300887 fengwei 20120224 end >*/ return compass_gs_position; }
/* C8820VC uses PM pwm. */ hw_lcd_ctrl_bl_type get_hw_lcd_ctrl_bl_type(void) { hw_lcd_ctrl_bl_type ctrl_bl_type = CTRL_BL_BY_UNKNOW; /*control backlight by MSM pwm*/ /* C8668D uses PM pwm. */ if (machine_is_msm7x27a_U8815() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_U8185() || machine_is_msm7x27a_U8655() || machine_is_msm7x27a_M660() || machine_is_msm7x27a_H867G() || machine_is_msm7x27a_H868C() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860_92() || (machine_is_msm7x27a_C8820() && (HW_VER_SUB_VC <= get_hw_sub_board_id())) ||machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D() ) { ctrl_bl_type = CTRL_BL_BY_MSM; } /*control backlight by LCD output pwm*/ else { ctrl_bl_type = CTRL_BL_BY_LCD; } return ctrl_bl_type; }
/* FUNCTION get_hw_wifi_device_model * DEPENDENCIES * get wifi device model. * affect app_info. * RETURN VALUE * wifi device model:WIFI_QUALCOMM_6005 or WIFI_BROADCOM_4329 ro WIFI_BROADCOM_4330 */ hw_wifi_device_model get_hw_wifi_device_model(void) { /*< DTS2012042703826 lixin 20120427 begin */ if(machine_is_msm7x27a_U8185()|| machine_is_msm7x27a_U8661()|| machine_is_msm7x27a_C8668D() || (machine_is_msm7x27a_U8815() && (HW_VER_SUB_VC == get_hw_sub_board_id()))) { return WIFI_QUALCOMM_6005; } /* DTS2012042703826 lixin 20120427 end >*/ else if(machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() /* < DTS2012050801712 xiedayong 20120508 begin */ /* add msm8255_u8800_pro proudct,it uses BCM4329 chip */ || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8800_pro()) /* DTS2012050801712 xiedayong 20120508 end > */ { return WIFI_BROADCOM_4329; } else { return WIFI_BROADCOM_4330; } }
/* FUNCTION get_hw_wifi_device_model * DEPENDENCIES * get wifi device model. * affect app_info. * RETURN VALUE * wifi device model:WIFI_QUALCOMM_6005 or WIFI_BROADCOM_4329 ro WIFI_BROADCOM_4330 */ hw_wifi_device_model get_hw_wifi_device_model(void) { if(machine_is_msm7x27a_U8185()|| machine_is_msm7x27a_U8661()|| machine_is_msm7x27a_C8668D() || machine_is_msm8x25_C8825D() || machine_is_msm8x25_U8825D() || machine_is_msm8x25_U8825() || machine_is_msm8x25_C8833D() || machine_is_msm8x25_U8951D() || machine_is_msm8x25_U8951() || machine_is_msm8x25_U8833D() || machine_is_msm8x25_U8833() || machine_is_msm8x25_C8813() || machine_is_msm8x25_C8812P()) { return WIFI_QUALCOMM_6005; } else if(machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { return WIFI_BROADCOM_4329; } else { return WIFI_BROADCOM_4330; } }
/*=========================================================================== FUNCTION get_compass_gs_position DESCRIPTION This function probe which G-sensor & Campass status type should be used DEPENDENCIES RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ compass_gs_position_type get_compass_gs_position(void) { compass_gs_position_type compass_gs_position=COMPASS_TOP_GS_TOP; /* modify compass and gs position by board id */ //move C8820\25D define from TOP to BOTTOM if (machine_is_msm7x27a_surf() || machine_is_msm7x27a_ffa() || machine_is_msm7x27a_U8815() || machine_is_msm8x25_C8950D() || (machine_is_msm8x25_U8950() && (HW_VER_SUB_VB <= get_hw_sub_board_id())) || machine_is_msm8x25_U8950D() ) { compass_gs_position=COMPASS_TOP_GS_TOP; } /*version A and version B has compass, since version C don't have compass*/ else if(machine_is_msm7x27a_C8820() && (HW_VER_SUB_VC <= get_hw_sub_board_id())) { compass_gs_position=COMPASS_NONE_GS_BOTTOM; } /* add U8655_EMMC, use the u8655 configuration */ else if (machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm7x27a_M660() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8820() || machine_is_msm8x25_C8825D() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8x25_U8825() || machine_is_msm8x25_U8825D() || (machine_is_msm8x25_U8950() && (HW_VER_SUB_VA == get_hw_sub_board_id())) || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { compass_gs_position=COMPASS_BOTTOM_GS_BOTTOM; } else if (machine_is_msm7x27a_U8185()) { compass_gs_position=COMPASS_NONE_GS_TOP; } else if(machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { compass_gs_position=COMPASS_TOP_GS_TOP; } else if (machine_is_msm7x27a_C8668D() ) { compass_gs_position = COMPASS_BOTTOM_GS_TOP; } return compass_gs_position; }
/* *brief: get lcd panel resolution */ lcd_type get_hw_lcd_resolution_type(void) { lcd_type lcd_resolution = LCD_IS_HVGA; /*< DTS2012020306500 lijianzhao 20120204 begin */ /* add 8x55 paltform products */ if ( machine_is_msm7x27a_U8815() || machine_is_msm7x27a_C8820() || machine_is_msm7x27a_C8825D() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { lcd_resolution = LCD_IS_WVGA; } else if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { lcd_resolution = LCD_IS_FWVGA; } /* DTS2012020306500 lijianzhao 20120204 end >*/ /*< DTS2012021602342 zhongjinrong 20120224 begin */ /*< DTS2012021007223 lijianzhao 20120211 begin */ /*< DTS2012022300887 fengwei 20120224 begin */ /* C8668D uses HVGA. */ else if ( machine_is_msm7x27a_M660() || machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm8255_u8667() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D()) /* DTS2012022300887 fengwei 20120224 end >*/ /* DTS2012021007223 lijianzhao 20120211 end >*/ /* DTS2012021602342 zhongjinrong 20120224 end >*/ { lcd_resolution = LCD_IS_HVGA; } else if (machine_is_msm7x27a_U8185()) { lcd_resolution = LCD_IS_QVGA; } else { lcd_resolution = LCD_IS_HVGA; } return lcd_resolution; }
/* *brief: get lcd panel resolution */ lcd_type get_hw_lcd_resolution_type(void) { lcd_type lcd_resolution = LCD_IS_HVGA; /* add 8x55 paltform products */ /*delete some lines for changing the lcd resolution of C8950D/U8950*/ if ( machine_is_msm7x27a_U8815() || machine_is_msm8x25_U8825() || machine_is_msm8x25_U8825D() || machine_is_msm7x27a_C8820() || machine_is_msm8x25_C8825D() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { lcd_resolution = LCD_IS_WVGA; } else if (machine_is_msm8x25_C8950D() || machine_is_msm8x25_U8950() || machine_is_msm8x25_U8950D()) { lcd_resolution = LCD_IS_QHD; } else if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { lcd_resolution = LCD_IS_FWVGA; } /* C8668D uses HVGA. */ else if ( machine_is_msm7x27a_M660() || machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm8255_u8667() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D()) { lcd_resolution = LCD_IS_HVGA; } else if (machine_is_msm7x27a_U8185()) { lcd_resolution = LCD_IS_QVGA; } else { lcd_resolution = LCD_IS_HVGA; } return lcd_resolution; }
/* C8820VC uses PM pwm. */ hw_lcd_ctrl_bl_type get_hw_lcd_ctrl_bl_type(void) { hw_lcd_ctrl_bl_type ctrl_bl_type = CTRL_BL_BY_UNKNOW; /*< DTS2012021602342 zhongjinrong 20120224 begin */ /*control backlight by MSM pwm*/ /*< DTS2012022300887 fengwei 20120224 begin */ /* C8668D uses PM pwm. */ if (machine_is_msm7x27a_umts() || machine_is_msm7x27a_cdma() || machine_is_msm7x27a_U8815() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_U8185() || machine_is_msm7x27a_U8655() || machine_is_msm7x27a_M660() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860_92() || (machine_is_msm7x27a_C8820() && (HW_VER_SUB_VC <= get_hw_sub_board_id())) ||machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D() ) /* DTS2012022300887 fengwei 20120224 end >*/ /* DTS2012021602342 zhongjinrong 20120224 end >*/ { ctrl_bl_type = CTRL_BL_BY_MSM; } /*control backlight by LCD output pwm*/ /*< DTS2012021007223 lijianzhao 20120211 begin */ else if(machine_is_msm7x27a_C8655_NAND() || (machine_is_msm7x27a_C8820() && (HW_VER_SUB_VA == get_hw_sub_board_id())) || machine_is_msm7x27a_C8825D() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_51() /*< DTS2012042605475 zhongjinrong 20120426 begin */ || machine_is_msm8255_u8667() || machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) /* DTS2012042605475 zhongjinrong 20120426 end >*/ /* DTS2012021007223 lijianzhao 20120211 end >*/ { ctrl_bl_type = CTRL_BL_BY_LCD; } else { ctrl_bl_type = CTRL_BL_BY_LCD; } return ctrl_bl_type; }
void __ref msm_snddev_init_timpani(void) { #ifndef CONFIG_HUAWEI_KERNEL platform_add_devices(snd_devices_ffa, ARRAY_SIZE(snd_devices_ffa)); #ifdef CONFIG_DEBUG_FS debugfs_hsed_config = debugfs_create_file("msm_hsed_config", S_IFREG | S_IWUGO, NULL, (void *) "msm_hsed_config", &snddev_hsed_config_debug_fops); if (!debugfs_hsed_config) pr_err("failed to create msm_head_config debug fs entry\n"); #endif #else //#ifndef CONFIG_HUAWEI_KERNEL if (machine_is_msm7x30_ffa() || machine_is_msm8x55_ffa() || machine_is_msm8x55_svlte_ffa()) { platform_add_devices(snd_devices_ffa, ARRAY_SIZE(snd_devices_ffa)); #ifdef CONFIG_DEBUG_FS debugfs_hsed_config = debugfs_create_file("msm_hsed_config", S_IFREG | S_IWUGO, NULL, (void *) "msm_hsed_config", &snddev_hsed_config_debug_fops); if (!debugfs_hsed_config) pr_err("failed to create msm_head_config debug fs entry\n"); #endif }else if( machine_is_msm8255_u8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) { platform_add_devices(snd_devices_u8860, ARRAY_SIZE(snd_devices_u8860)); }else if (machine_is_msm8255_c8860()) { platform_add_devices(snd_devices_c8860, arraysize_c8860); } else { platform_add_devices(snd_devices_u8860, ARRAY_SIZE(snd_devices_u8860)); } #endif //#ifndef CONFIG_HUAWEI_KERNEL }
static bool pmic8xxx_detect_ghost_keys(struct pmic8xxx_kp *kp, u16 *new_state) { int row, found_first = -1; u16 check, row_state; /* * for u8860, c8860 and u8860lp, add the codes means: * when volumn-up and volumn-down keys are pressed in the sametime, * the state of kp scan matrix read from the register is wrong because of hardwared's wrong, * and it will make system think the state as ghost keys mistakenly , * so these board ids should not be check for ghost keys */ #ifdef CONFIG_HUAWEI_KERNEL if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_51()) { return 0; } #endif check = 0; for (row = 0; row < kp->pdata->num_rows; row++) { row_state = (~new_state[row]) & ((1 << kp->pdata->num_cols) - 1); if (hweight16(row_state) > 1) { if (found_first == -1) found_first = row; if (check & row_state) { dev_dbg(kp->dev, "detected ghost key on row[%d]" " and row[%d]\n", found_first, row); return true; } } check |= row_state; } return false; }
static int get_current_machine() { if( (machine_is_msm8255_u8800_pro()) || (machine_is_msm8255_u8860()) || (machine_is_msm8255_c8860()) || (machine_is_msm8255_u8860lp()) /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || (machine_is_msm8255_u8860_92()) || (machine_is_msm8255_u8860_51()) || (machine_is_msm8255_u8680()) || (machine_is_msm8255_u8730())) { OEMINFO_RPC_DEBUG("8x55 oeminfo. \n"); return HW_MACHINE_8X55; } else { OEMINFO_RPC_DEBUG("27a25a oeminfo. \n"); return HW_MACHINE_7X2725A; } }
lcd_panel_type get_lcd_panel_type(void) { lcd_panel_type hw_lcd_panel = LCD_NONE; if ( machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_NT35582_BYD_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = LCD_NT35582_TRULY_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA; break; case LCD_HW_ID3: hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA_TYPE2; break; default : hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA; break; } } else if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_NT35560_TOSHIBA_FWVGA; break; default : hw_lcd_panel = LCD_NT35560_TOSHIBA_FWVGA; break; } } else if( machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MDDI_RSP61408_CHIMEI_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = MDDI_HX8369A_TIANMA_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = MDDI_RSP61408_BYD_WVGA; break; default : hw_lcd_panel = MDDI_RSP61408_CHIMEI_WVGA; break; } } else if( machine_is_msm8255_u8667()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MDDI_HX8357C_CHIMEI_HVGA; break; case LCD_HW_ID2: hw_lcd_panel = MDDI_HX8357C_CHIMEI_IPS_HVGA; break; case LCD_HW_ID3: hw_lcd_panel = MDDI_HX8357C_TIANMA_HVGA; break; default: hw_lcd_panel = MDDI_HX8357C_CHIMEI_HVGA; break; } } /*delete some lines for changing the lcd panel type of C8950D/U8950D*/ else if( machine_is_msm7x27a_U8815() || machine_is_msm7x27a_C8820() || machine_is_msm8x25_U8825() || machine_is_msm8x25_U8825D() || machine_is_msm8x25_C8825D() ) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MIPI_RSP61408_CHIMEI_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = MIPI_HX8369A_TIANMA_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = MIPI_RSP61408_BYD_WVGA; break; case LCD_HW_ID3: hw_lcd_panel = MIPI_RSP61408_TRULY_WVGA; break; default: /*no mipi LCD lead to block, so default lcd RGB */ hw_lcd_panel = MIPI_RSP61408_CHIMEI_WVGA; break; } } else if (machine_is_msm8x25_C8950D() || machine_is_msm8x25_U8950() || machine_is_msm8x25_U8950D()) { switch (lcd_id) { case LCD_HW_ID3: hw_lcd_panel = MIPI_NT35516_TIANMA_QHD; break; default: hw_lcd_panel = MIPI_NT35516_TIANMA_QHD; break; } } else if( machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MIPI_HX8357C_CHIMEI_HVGA; break; case LCD_HW_ID1: hw_lcd_panel = MIPI_HX8357C_TIANMA_IPS_HVGA; break; case LCD_HW_ID2: hw_lcd_panel = MIPI_HX8357C_CHIMEI_IPS_HVGA; break; case LCD_HW_ID3: hw_lcd_panel = MIPI_HX8357C_TIANMA_HVGA; break; default: /*no mipi LCD lead to block, so default lcd RGB */ hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; } } else if( machine_is_msm7x27a_U8185()) { switch(lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_HX8347D_TRULY_QVGA; break; case LCD_HW_ID2: hw_lcd_panel = LCD_HX8347G_TIANMA_QVGA; break; case LCD_HW_ID3: hw_lcd_panel = LCD_HX8347D_CHIMEI_QVGA; break; default: hw_lcd_panel = LCD_HX8347G_TIANMA_QVGA; break; } } else if(machine_is_msm7x27a_M660()) { switch(lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_HX8357C_TIANMA_HVGA; break; case LCD_HW_ID1: hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; default: hw_lcd_panel = LCD_HX8357C_TIANMA_HVGA; break; } } else { hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; } return hw_lcd_panel; }
/* FUNCTION get_hw_lcd_interface_type * DEPENDENCIES * get lcd interface type * affect nfc. * RETURN VALUE * lcd interface type:LCD_IS_MIPI or LCD_IS_RGB */ hw_lcd_interface_type get_hw_lcd_interface_type(void) { hw_lcd_interface_type lcd_interface_type; lcd_panel_type hw_lcd_panel = LCD_NONE; hw_lcd_panel = get_lcd_panel_type(); if (machine_is_msm7x30_u8800()) { lcd_interface_type = LCD_IS_MDDI_TYPE1; } /* U8820 board version A is MMDI type1, so config it type1 * Version B and other is MDDI type2, so config it according to LCD */ else if(machine_is_msm7x30_u8820()) { if(HW_VER_SUB_VA == get_hw_sub_board_id()) { lcd_interface_type = LCD_IS_MDDI_TYPE1; } else { switch(hw_lcd_panel) { case LCD_NT35582_BYD_WVGA: case LCD_NT35582_TRULY_WVGA: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; case LCD_NT35510_ALPHA_SI_WVGA: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; case LCD_NT35510_ALPHA_SI_WVGA_TYPE2: lcd_interface_type = LCD_IS_MDDI_TYPE2; break; default: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; } } } else if (machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro()) { switch(hw_lcd_panel) { case LCD_NT35582_BYD_WVGA: case LCD_NT35582_TRULY_WVGA: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; case LCD_NT35510_ALPHA_SI_WVGA: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; case LCD_NT35510_ALPHA_SI_WVGA_TYPE2: lcd_interface_type = LCD_IS_MDDI_TYPE2; break; default: lcd_interface_type = LCD_IS_MDDI_TYPE1; break; } } else if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) { lcd_interface_type = LCD_IS_MDDI_TYPE2; } else if (machine_is_msm8255_u8667()) { lcd_interface_type = LCD_IS_MDDI_TYPE1; } else if(machine_is_msm7x27a_U8185() ||machine_is_msm7x27a_M660()) { lcd_interface_type = LCD_IS_RGB; } else { lcd_interface_type = LCD_IS_MIPI_CMD; } return lcd_interface_type; }
static int pm8058_kp_config_drv(int gpio_start, int num_gpios) { int rc; struct pm8058_gpio kypd_drv = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_OPEN_DRAIN, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = 2, .out_strength = PM_GPIO_STRENGTH_LOW, .function = PM_GPIO_FUNC_1, .inv_int_pol = 1, }; if (gpio_start < 0 || num_gpios < 0 || num_gpios > PM8058_GPIOS) return -EINVAL; while (num_gpios--) { if ((machine_is_msm8255_c8860()) && (PM_GPIO_13 == gpio_start)) { /* PM_GPIO_13 is used for RF in C8860, should not be configured here */ gpio_start++; continue; } rc = pm8058_gpio_config(gpio_start++, &kypd_drv); if (rc) { pr_err("%s: FAIL pm8058_gpio_config(): rc=%d.\n", __func__, rc); return rc; } } return 0; } static int pm8058_kp_config_sns(int gpio_start, int num_gpios) { int rc; struct pm8058_gpio kypd_sns = { .direction = PM_GPIO_DIR_IN, .pull = PM_GPIO_PULL_UP_31P5, .vin_sel = 2, .out_strength = PM_GPIO_STRENGTH_NO, .function = PM_GPIO_FUNC_NORMAL, .inv_int_pol = 1, }; if (gpio_start < 0 || num_gpios < 0 || num_gpios > PM8058_GPIOS) return -EINVAL; while (num_gpios--) { rc = pm8058_gpio_config(gpio_start++, &kypd_sns); if (rc) { pr_err("%s: FAIL pm8058_gpio_config(): rc=%d.\n", __func__, rc); return rc; } } return 0; } /* * keypad controller should be initialized in the following sequence * only, otherwise it might get into FSM stuck state. * * - Initialize keypad control parameters, like no. of rows, columns, * timing values etc., * - configure rows and column gpios pull up/down. * - set irq edge type. * - enable the keypad controller. */ static int __devinit pmic8058_kp_probe(struct platform_device *pdev) { struct pmic8058_keypad_data *pdata = pdev->dev.platform_data; const struct matrix_keymap_data *keymap_data; struct pmic8058_kp *kp; int rc; unsigned short *keycodes; u8 ctrl_val; struct pm8058_chip *pm_chip; pm_chip = dev_get_drvdata(pdev->dev.parent); if (pm_chip == NULL) { dev_err(&pdev->dev, "no parent data passed in\n"); return -EFAULT; } if (!pdata || !pdata->num_cols || !pdata->num_rows || pdata->num_cols > PM8058_MAX_COLS || pdata->num_rows > PM8058_MAX_ROWS || pdata->num_cols < PM8058_MIN_COLS || pdata->num_rows < PM8058_MIN_ROWS) { dev_err(&pdev->dev, "invalid platform data\n"); return -EINVAL; } if (pdata->rows_gpio_start < 0 || pdata->cols_gpio_start < 0) { dev_err(&pdev->dev, "invalid gpio_start platform data\n"); return -EINVAL; } if (!pdata->scan_delay_ms || pdata->scan_delay_ms > MAX_SCAN_DELAY || pdata->scan_delay_ms < MIN_SCAN_DELAY || !is_power_of_2(pdata->scan_delay_ms)) { dev_err(&pdev->dev, "invalid keypad scan time supplied\n"); return -EINVAL; } if (!pdata->row_hold_ns || pdata->row_hold_ns > MAX_ROW_HOLD_DELAY || pdata->row_hold_ns < MIN_ROW_HOLD_DELAY || ((pdata->row_hold_ns % MIN_ROW_HOLD_DELAY) != 0)) { dev_err(&pdev->dev, "invalid keypad row hold time supplied\n"); return -EINVAL; } if (pm8058_rev(pm_chip) == PM_8058_REV_1p0) { if (!pdata->debounce_ms || !is_power_of_2(pdata->debounce_ms[0]) || pdata->debounce_ms[0] > MAX_DEBOUNCE_A0_TIME || pdata->debounce_ms[0] < MIN_DEBOUNCE_A0_TIME) { dev_err(&pdev->dev, "invalid debounce time supplied\n"); return -EINVAL; } } else { if (!pdata->debounce_ms || ((pdata->debounce_ms[1] % 5) != 0) || pdata->debounce_ms[1] > MAX_DEBOUNCE_B0_TIME || pdata->debounce_ms[1] < MIN_DEBOUNCE_B0_TIME) { dev_err(&pdev->dev, "invalid debounce time supplied\n"); return -EINVAL; } } keymap_data = pdata->keymap_data; if (!keymap_data) { dev_err(&pdev->dev, "no keymap data supplied\n"); return -EINVAL; } kp = kzalloc(sizeof(*kp), GFP_KERNEL); if (!kp) return -ENOMEM; keycodes = kzalloc(PM8058_MATRIX_MAX_SIZE * sizeof(*keycodes), GFP_KERNEL); if (!keycodes) { rc = -ENOMEM; goto err_alloc_mem; } platform_set_drvdata(pdev, kp); mutex_init(&kp->mutex); kp->pdata = pdata; kp->dev = &pdev->dev; kp->keycodes = keycodes; kp->pm_chip = pm_chip; if (pm8058_rev(pm_chip) == PM_8058_REV_1p0) kp->flags |= KEYF_FIX_LAST_ROW; kp->input = input_allocate_device(); if (!kp->input) { dev_err(&pdev->dev, "unable to allocate input device\n"); rc = -ENOMEM; goto err_alloc_device; } /* Enable runtime PM ops, start in ACTIVE mode */ rc = pm_runtime_set_active(&pdev->dev); if (rc < 0) dev_dbg(&pdev->dev, "unable to set runtime pm state\n"); pm_runtime_enable(&pdev->dev); kp->key_sense_irq = platform_get_irq(pdev, 0); if (kp->key_sense_irq < 0) { dev_err(&pdev->dev, "unable to get keypad sense irq\n"); rc = -ENXIO; goto err_get_irq; } kp->key_stuck_irq = platform_get_irq(pdev, 1); if (kp->key_stuck_irq < 0) { dev_err(&pdev->dev, "unable to get keypad stuck irq\n"); rc = -ENXIO; goto err_get_irq; } if (pdata->input_name) kp->input->name = pdata->input_name; else kp->input->name = "PMIC8058 keypad"; if (pdata->input_phys_device) kp->input->phys = pdata->input_phys_device; else kp->input->phys = "pmic8058_keypad/input0"; kp->input->dev.parent = &pdev->dev; kp->input->id.bustype = BUS_HOST; kp->input->id.version = 0x0001; kp->input->id.product = 0x0001; kp->input->id.vendor = 0x0001; kp->input->evbit[0] = BIT_MASK(EV_KEY); if (pdata->rep) __set_bit(EV_REP, kp->input->evbit); kp->input->keycode = keycodes; kp->input->keycodemax = PM8058_MATRIX_MAX_SIZE; kp->input->keycodesize = sizeof(*keycodes); matrix_keypad_build_keymap(keymap_data, PM8058_ROW_SHIFT, kp->input->keycode, kp->input->keybit); input_set_capability(kp->input, EV_MSC, MSC_SCAN); input_set_drvdata(kp->input, kp); rc = input_register_device(kp->input); if (rc < 0) { dev_err(&pdev->dev, "unable to register keypad input device\n"); goto err_get_irq; } /* initialize keypad state */ memset(kp->keystate, 0xff, sizeof(kp->keystate)); memset(kp->stuckstate, 0xff, sizeof(kp->stuckstate)); rc = pmic8058_kpd_init(kp); if (rc < 0) { dev_err(&pdev->dev, "unable to initialize keypad controller\n"); goto err_kpd_init; } rc = pm8058_kp_config_sns(pdata->cols_gpio_start, pdata->num_cols); if (rc < 0) { dev_err(&pdev->dev, "unable to configure keypad sense lines\n"); goto err_gpio_config; } rc = pm8058_kp_config_drv(pdata->rows_gpio_start, pdata->num_rows); if (rc < 0) { dev_err(&pdev->dev, "unable to configure keypad drive lines\n"); goto err_gpio_config; } rc = request_threaded_irq(kp->key_sense_irq, NULL, pmic8058_kp_irq, IRQF_TRIGGER_RISING, "pmic-keypad", kp); if (rc < 0) { dev_err(&pdev->dev, "failed to request keypad sense irq\n"); goto err_req_sense_irq; } rc = request_threaded_irq(kp->key_stuck_irq, NULL, pmic8058_kp_stuck_irq, IRQF_TRIGGER_RISING, "pmic-keypad-stuck", kp); if (rc < 0) { dev_err(&pdev->dev, "failed to request keypad stuck irq\n"); goto err_req_stuck_irq; } rc = pmic8058_kp_read_u8(kp, &ctrl_val, KEYP_CTRL); ctrl_val |= KEYP_CTRL_KEYP_EN; rc = pmic8058_kp_write_u8(kp, ctrl_val, KEYP_CTRL); kp->ctrl_reg = ctrl_val; __dump_kp_regs(kp, "probe"); rc = device_create_file(&pdev->dev, &dev_attr_disable_kp); if (rc < 0) goto err_create_file; device_init_wakeup(&pdev->dev, pdata->wakeup); return 0; err_create_file: free_irq(kp->key_stuck_irq, NULL); err_req_stuck_irq: free_irq(kp->key_sense_irq, NULL); err_req_sense_irq: err_gpio_config: err_kpd_init: input_unregister_device(kp->input); kp->input = NULL; err_get_irq: pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); input_free_device(kp->input); err_alloc_device: kfree(keycodes); err_alloc_mem: kfree(kp); return rc; } static int __devexit pmic8058_kp_remove(struct platform_device *pdev) { struct pmic8058_kp *kp = platform_get_drvdata(pdev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); device_remove_file(&pdev->dev, &dev_attr_disable_kp); device_init_wakeup(&pdev->dev, 0); free_irq(kp->key_stuck_irq, NULL); free_irq(kp->key_sense_irq, NULL); input_unregister_device(kp->input); platform_set_drvdata(pdev, NULL); kfree(kp->input->keycode); kfree(kp); return 0; } #ifdef CONFIG_PM static int pmic8058_kp_suspend(struct device *dev) { struct pmic8058_kp *kp = dev_get_drvdata(dev); if (device_may_wakeup(dev) && !pmic8058_kp_disabled(kp)) { enable_irq_wake(kp->key_sense_irq); } else { mutex_lock(&kp->mutex); pmic8058_kp_disable(kp); mutex_unlock(&kp->mutex); } return 0; } static int pmic8058_kp_resume(struct device *dev) { struct pmic8058_kp *kp = dev_get_drvdata(dev); if (device_may_wakeup(dev) && !pmic8058_kp_disabled(kp)) { disable_irq_wake(kp->key_sense_irq); } else { mutex_lock(&kp->mutex); pmic8058_kp_enable(kp); mutex_unlock(&kp->mutex); } return 0; } static struct dev_pm_ops pm8058_kp_pm_ops = { .suspend = pmic8058_kp_suspend, .resume = pmic8058_kp_resume, }; #endif static struct platform_driver pmic8058_kp_driver = { .probe = pmic8058_kp_probe, .remove = __devexit_p(pmic8058_kp_remove), .driver = { .name = "pm8058-keypad", .owner = THIS_MODULE, #ifdef CONFIG_PM .pm = &pm8058_kp_pm_ops, #endif }, }; static int __init pmic8058_kp_init(void) { return platform_driver_register(&pmic8058_kp_driver); } module_init(pmic8058_kp_init); static void __exit pmic8058_kp_exit(void) { platform_driver_unregister(&pmic8058_kp_driver); }
int backlight_pwm_gpio_config(void) { int rc; struct pm_gpio backlight_drv = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = 0, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_2, .inv_int_pol = 1, }; /* U8800 use PM_GPIO25 as backlight's PWM,but U8820 use PM_GPIO26 */ /* < DTS2011102401822 liwei 20111024 begin */ if(machine_is_msm7x30_u8800() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8667() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) /* DTS2011102401822 liwei 20111024 end > */ /*< DTS2012051704510 houming 20120517 begin */ /* renew config the gpio value */ { rc = pm8xxx_gpio_config( PM8058_GPIO_PM_TO_SYS(24), &backlight_drv); } else if(machine_is_msm7x30_u8820()) { rc = pm8xxx_gpio_config( PM8058_GPIO_PM_TO_SYS(25), &backlight_drv); } /* DTS2012051704510 houming 20120517 end >*/ else { rc = -1; } if (rc) { pr_err("%s LCD backlight GPIO config failed\n", __func__); return rc; } return 0; } /* use the mmp pin like three-leds */ /*< DTS2012012101194 lijianzhao 20120121 begin */ void msm_backlight_set(int level) { static uint8 last_level = 0; static boolean first_set_bl = TRUE; /*< DTS2012042605475 zhongjinrong 20120426 begin */ /*< DTS2012032101654 liweiwu 20120321 begin */ /* keep duty 10% < level < 100% */ /* DTS2012032101654 liweiwu 20120321 end >*/ /* DTS2012042605475 zhongjinrong 20120426 end >*/ /*< DTS2012021602342 zhongjinrong 20120224 begin */ #ifdef CONFIG_ARCH_MSM7X27A /* DTS2012021602342 zhongjinrong 20120224 end >*/ if(level) { level = ((level * PWM_LEVEL_ADJUST_LPG) / PWM_LEVEL ); if (level < BL_MIN_LEVEL_LPG) { level = BL_MIN_LEVEL_LPG; } } if (last_level == level) { return ; } last_level = level; pmapp_disp_backlight_set_brightness(last_level); #endif #ifdef CONFIG_ARCH_MSM7X30 if(TRUE == first_set_bl) { backlight_pwm_gpio_config(); /* U8800 use PM_GPIO25 as backlight's PWM,but U8820 use PM_GPIO26 */ /* < DTS2011102401822 liwei 20111024 begin */ if(machine_is_msm7x30_u8800() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8667() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) /* DTS2011102401822 liwei 20111024 end > */ { bl_pwm = pwm_request(PM_GPIO25_PWM_ID, "backlight"); } else if(machine_is_msm7x30_u8820()) { bl_pwm = pwm_request(PM_GPIO26_PWM_ID, "backlight"); } else { bl_pwm = NULL; } if (NULL == bl_pwm || IS_ERR(bl_pwm)) { pr_err("%s: pwm_request() failed\n", __func__); bl_pwm = NULL; } first_set_bl = FALSE; } if (bl_pwm) { if(level) { level = ((level * PWM_LEVEL_ADJUST) / PWM_LEVEL + ADD_VALUE); if (level < BL_MIN_LEVEL) { level = BL_MIN_LEVEL; } } if (last_level == level) { return ; } last_level = level; pwm_config(bl_pwm, PWM_DUTY_LEVEL*level/NSEC_PER_USEC, PWM_PERIOD/NSEC_PER_USEC); pwm_enable(bl_pwm); } #endif } /* DTS2012012101194 lijianzhao 20120121 end >*/ void cabc_backlight_set(struct msm_fb_data_type * mfd) { struct msm_fb_panel_data *pdata = NULL; uint32 bl_level = mfd->bl_level; /*< DTS2012042605475 zhongjinrong 20120426 begin */ /*< DTS2012032101654 liweiwu 20120321 begin */ /* keep duty 10% < level < 100% */ /* DTS2012032101654 liweiwu 20120321 end >*/ if (bl_level) { /*< DTS2012032101654 liweiwu 20120321 begin */ /****delete one line codes for backlight*****/ /* DTS2012032101654 liweiwu 20120321 end >*/ /* DTS2012042605475 zhongjinrong 20120426 end >*/ if (bl_level < BL_MIN_LEVEL) { bl_level = BL_MIN_LEVEL; } } /* backlight ctrl by LCD-self, like as CABC */ /*< DTS2012012101194 lijianzhao 20120121 begin */ pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if ((pdata) && (pdata->set_cabc_brightness)) { pdata->set_cabc_brightness(mfd,bl_level); } /* DTS2012012101194 lijianzhao 20120121 end >*/ } /*< DTS2012022408079 zhongjinrong 20120306 begin */ void pwm_set_backlight(struct msm_fb_data_type *mfd) { lcd_panel_type lcd_panel_wvga = LCD_NONE; /*< DTS2011122704239 liuyuntao 20111229 begin */ /*When all the device are resume that can turn the light*/ if(atomic_read(&suspend_flag)) { mfd_local = mfd; backlight_set = TRUE; return; } /* DTS2011122704239 liuyuntao 20111229 end >*/ /*< DTS2012021601331 duanfei 20120216 begin */ /*< DTS2012021602342 zhongjinrong 20120224 begin */ #ifdef CONFIG_ARCH_MSM7X27A /* DTS2012021602342 zhongjinrong 20120224 end >*/ lcd_panel_wvga = get_lcd_panel_type(); /* <DTS2012022501992 liguosheng 20120229 begin */ if ((MIPI_RSP61408_CHIMEI_WVGA == lcd_panel_wvga ) || (MIPI_RSP61408_BYD_WVGA == lcd_panel_wvga ) || (MIPI_RSP61408_TRULY_WVGA == lcd_panel_wvga ) || (MIPI_HX8369A_TIANMA_WVGA == lcd_panel_wvga )) { /* keep duty is 75% of the quondam duty */ mfd->bl_level = mfd->bl_level * 75 / 100; } /* DTS2012022501992 liguosheng 20120229 end> */ #endif /* DTS2012021601331 duanfei 20120216 end >*/ if (get_hw_lcd_ctrl_bl_type() == CTRL_BL_BY_MSM) { msm_backlight_set(mfd->bl_level); } else { cabc_backlight_set(mfd); } return; }
int backlight_pwm_gpio_config(void) { int rc; struct pm_gpio backlight_drv = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = 0, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_2, .inv_int_pol = 1, }; /* U8800 use PM_GPIO25 as backlight's PWM,but U8820 use PM_GPIO26 */ if(machine_is_msm7x30_u8800() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8667() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) { rc = pm8xxx_gpio_config( 24, &backlight_drv); } else if(machine_is_msm7x30_u8820()) { rc = pm8xxx_gpio_config( 25, &backlight_drv); } else { rc = -1; } if (rc) { pr_err("%s LCD backlight GPIO config failed\n", __func__); return rc; } return 0; } /* use the mmp pin like three-leds */ void msm_backlight_set(int level) { static uint8 last_level = 0; /*fix bug in new base-line 1025*/ #ifdef CONFIG_ARCH_MSM7X30 static boolean first_set_bl = TRUE; static struct pwm_device *bl_pwm; #endif //CONFIG_ARCH_MSM7X30 /* keep duty 10% < level < 100% */ #ifdef CONFIG_ARCH_MSM7X27A if(level) { #ifdef CONFIG_HUAWEI_OLD_BACKLIGHT level = ((level * PWM_LEVEL_ADJUST_LPG) / PWM_LEVEL ); if (level < BL_MIN_LEVEL_LPG) { level = BL_MIN_LEVEL_LPG; } #else if (level < BL_MIN_LEVEL) { level = BL_MIN_LEVEL; } #endif } if (last_level == level) { return ; } last_level = level; pmapp_disp_backlight_set_brightness(last_level); #endif #ifdef CONFIG_ARCH_MSM7X30 if(TRUE == first_set_bl) { backlight_pwm_gpio_config(); /* U8800 use PM_GPIO25 as backlight's PWM,but U8820 use PM_GPIO26 */ if(machine_is_msm7x30_u8800() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8680() || machine_is_msm8255_u8667() || machine_is_msm8255_u8860_51() || machine_is_msm8255_u8730()) { bl_pwm = pwm_request(PM_GPIO25_PWM_ID, "backlight"); } else if(machine_is_msm7x30_u8820()) { bl_pwm = pwm_request(PM_GPIO26_PWM_ID, "backlight"); } else { bl_pwm = NULL; } if (NULL == bl_pwm || IS_ERR(bl_pwm)) { pr_err("%s: pwm_request() failed\n", __func__); bl_pwm = NULL; } first_set_bl = FALSE; } if (bl_pwm) { if(level) { level = ((level * PWM_LEVEL_ADJUST) / PWM_LEVEL + ADD_VALUE); if (level < BL_MIN_LEVEL) { level = BL_MIN_LEVEL; } } if (last_level == level) { return ; } last_level = level; pwm_config(bl_pwm, PWM_DUTY_LEVEL*level/NSEC_PER_USEC, PWM_PERIOD/NSEC_PER_USEC); pwm_enable(bl_pwm); } #endif } void cabc_backlight_set(struct msm_fb_data_type * mfd) { struct msm_fb_panel_data *pdata = NULL; uint32 bl_level = mfd->bl_level; /* keep duty 10% < level < 100% */ if (bl_level) { /****delete one line codes for backlight*****/ if (bl_level < BL_MIN_LEVEL) { bl_level = BL_MIN_LEVEL; } } /* backlight ctrl by LCD-self, like as CABC */ pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if ((pdata) && (pdata->set_cabc_brightness)) { pdata->set_cabc_brightness(mfd,bl_level); } } void pwm_set_backlight(struct msm_fb_data_type *mfd) { #ifdef CONFIG_HUAWEI_OLD_BACKLIGHT lcd_panel_type lcd_panel_wvga = LCD_NONE; #endif /*When all the device are resume that can turn the light*/ if(atomic_read(&suspend_flag)) { mfd_local = mfd; backlight_set = TRUE; return; } #ifdef CONFIG_HUAWEI_OLD_BACKLIGHT lcd_panel_wvga = get_lcd_panel_type(); if ((MIPI_CMD_RSP61408_CHIMEI_WVGA == lcd_panel_wvga ) || (MIPI_CMD_RSP61408_BYD_WVGA == lcd_panel_wvga ) || (MIPI_CMD_RSP61408_TRULY_WVGA == lcd_panel_wvga ) || (MIPI_CMD_HX8369A_TIANMA_WVGA == lcd_panel_wvga )) { /* keep duty is 75% of the quondam duty */ mfd->bl_level = mfd->bl_level * 75 / 100; } #endif if (get_hw_lcd_ctrl_bl_type() == CTRL_BL_BY_MSM) { msm_backlight_set(mfd->bl_level); } else { cabc_backlight_set(mfd); } return; }
/*hasGyro is a flag to note if has gyro,c8860e has gyro but M886 doesn't*/ static int get_sensors_list(void) { /* < DTS2012020902104 zhangmin 20120209 begin */ /*add 7x30's list*/ int sensors_list = G_SENSOR + L_SENSOR + P_SENSOR + M_SENSOR; int hasgyro = 0; // hasgyro = hasGyro; /*< DTS2012022006500 yangbo 20120220 begin */ if(machine_is_msm8255_u8860() || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860lp() ||(machine_is_msm8255_c8860() && hasgyro )) { sensors_list = G_SENSOR + L_SENSOR + P_SENSOR + M_SENSOR + GY_SENSOR; printk("####This device has gyro\n"); } /*version A and version B has compass, since version C don't have compass*/ else if( ( machine_is_msm7x27a_C8820() && (HW_VER_SUB_VC <= get_hw_sub_board_id()) ) || machine_is_msm7x27a_U8661()) { sensors_list = G_SENSOR + L_SENSOR + P_SENSOR; } /*< DTS2012022300887 fengwei 20120224 begin */ else if (machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm7x27a_M660() || machine_is_msm7x27a_U8815() || machine_is_msm7x27a_C8820() || machine_is_msm7x27a_C8825D() || machine_is_msm7x27a_C8668D() || machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() || machine_is_msm8255_c8860() || machine_is_msm8255_u8667() || machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) /* DTS2012022300887 fengwei 20120224 end >*/ { sensors_list = G_SENSOR + L_SENSOR + P_SENSOR + M_SENSOR; printk("####This device doesn't own gyro\n"); } /* move this else if to above for avoid C8820 without compass can not run in */ /* DTS2012022006500 yangbo 20120220 end > */ else if(machine_is_msm7x27a_U8185()) { sensors_list = G_SENSOR; } else { sensors_list = G_SENSOR + L_SENSOR + P_SENSOR + M_SENSOR; } /* DTS2012020902104 zhangmin 20120209 end > */ return sensors_list; }
lcd_panel_type get_lcd_panel_type(void) { lcd_panel_type hw_lcd_panel = LCD_NONE; if ( machine_is_msm7x30_u8800() || machine_is_msm7x30_u8820() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_NT35582_BYD_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = LCD_NT35582_TRULY_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA; break; case LCD_HW_ID3: hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA_TYPE2; break; default : hw_lcd_panel = LCD_NT35510_ALPHA_SI_WVGA; break; } } else if (machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860lp() /* < DTS2012022905490 ganfan 20120301 begin */ || machine_is_msm8255_u8860_r() /* DTS2012022905490 ganfan 20120301 end > */ || machine_is_msm8255_u8860_92() || machine_is_msm8255_u8860_51()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_NT35560_TOSHIBA_FWVGA; break; default : hw_lcd_panel = LCD_NT35560_TOSHIBA_FWVGA; break; } } else if( machine_is_msm8255_u8680() || machine_is_msm8255_u8730()) { /*< DTS2012021007223 lijianzhao 20120211 begin */ /*< DTS2012021602342 zhongjinrong 20120224 begin */ switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MDDI_RSP61408_CHIMEI_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = MDDI_HX8369A_TIANMA_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = MDDI_RSP61408_BYD_WVGA; break; /*< DTS2012042605475 zhongjinrong 20120426 begin */ /* <DTS2012030102766 sunkai 20120301 begin */ case LCD_HW_ID3: hw_lcd_panel = MDDI_RSP61408_TRULY_WVGA; break; /* DTS2012030102766 sunkai 20120301 end> */ /* DTS2012042605475 zhongjinrong 20120426 end >*/ default : hw_lcd_panel = MDDI_RSP61408_CHIMEI_WVGA; break; } /* DTS2012021602342 zhongjinrong 20120224 end >*/ } else if( machine_is_msm8255_u8667()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MDDI_HX8357C_CHIMEI_HVGA; break; /*< DTS2012042605475 zhongjinrong 20120426 begin */ /*< DTS2012022401352 qitongliang 20120224 begin */ case LCD_HW_ID1: hw_lcd_panel = MDDI_HX8357C_TIANMA_IPS_HVGA; break; /* DTS2012022401352 qitongliang 20120224 end >*/ /* DTS2012042605475 zhongjinrong 20120426 end >*/ case LCD_HW_ID2: hw_lcd_panel = MDDI_HX8357C_CHIMEI_IPS_HVGA; break; case LCD_HW_ID3: hw_lcd_panel = MDDI_HX8357C_TIANMA_HVGA; break; default: hw_lcd_panel = MDDI_HX8357C_CHIMEI_HVGA; break; } } /* DTS2012021007223 lijianzhao 20120211 end >*/ else if( machine_is_msm7x27a_umts() || machine_is_msm7x27a_cdma()) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MIPI_NT35560_TOSHIBA_FWVGA; break; case LCD_HW_ID1: hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; default: /*no mipi LCD lead to block, so default lcd RGB */ hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; } } else if( machine_is_msm7x27a_U8815() || machine_is_msm7x27a_C8820() || machine_is_msm7x27a_C8825D() ) { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MIPI_RSP61408_CHIMEI_WVGA; break; case LCD_HW_ID1: hw_lcd_panel = MIPI_HX8369A_TIANMA_WVGA; break; case LCD_HW_ID2: hw_lcd_panel = MIPI_RSP61408_BYD_WVGA; break; /* <DTS2012022501992 liguosheng 20120229 begin */ case LCD_HW_ID3: hw_lcd_panel = MIPI_RSP61408_TRULY_WVGA; break; /* DTS2012022501992 liguosheng 20120229 end> */ default: /*no mipi LCD lead to block, so default lcd RGB */ hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; } } /*< DTS2012022300887 fengwei 20120224 begin */ else if( machine_is_msm7x27a_U8655() || machine_is_msm7x27a_U8655_EMMC() || machine_is_msm7x27a_C8655_NAND() || machine_is_msm7x27a_U8661() || machine_is_msm7x27a_C8668D()) /* DTS2012022300887 fengwei 20120224 end >*/ { switch (lcd_id) { case LCD_HW_ID0: hw_lcd_panel = MIPI_HX8357C_CHIMEI_HVGA; break; /* <DTS2012022501992 liguosheng 20120229 begin */ case LCD_HW_ID1: hw_lcd_panel = MIPI_HX8357C_TIANMA_IPS_HVGA; break; /* DTS2012022501992 liguosheng 20120229 end> */ case LCD_HW_ID2: hw_lcd_panel = MIPI_HX8357C_CHIMEI_IPS_HVGA; break; case LCD_HW_ID3: hw_lcd_panel = MIPI_HX8357C_TIANMA_HVGA; break; default: /*no mipi LCD lead to block, so default lcd RGB */ hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; } } else if( machine_is_msm7x27a_U8185()) { switch(lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_HX8347D_TRULY_QVGA; break; case LCD_HW_ID2: hw_lcd_panel = LCD_HX8347G_TIANMA_QVGA; break; case LCD_HW_ID3: hw_lcd_panel = LCD_HX8347D_CHIMEI_QVGA; break; default: hw_lcd_panel = LCD_HX8347G_TIANMA_QVGA; break; } } else if(machine_is_msm7x27a_M660()) { switch(lcd_id) { case LCD_HW_ID0: hw_lcd_panel = LCD_HX8357C_TIANMA_HVGA; break; case LCD_HW_ID1: hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; break; default: hw_lcd_panel = LCD_HX8357C_TIANMA_HVGA; break; } } else { hw_lcd_panel = LCD_HX8357B_TIANMA_HVGA; } return hw_lcd_panel; }
/*configure GPIO 25 Of PIMIC as PWM to driver LED*/ int led_pwm_gpio_config(void) { int rc; struct pm_gpio backlight_drv = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = 0, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_2, .inv_int_pol = 1, }; if(machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() ||machine_is_msm8255_u8860_51()) { rc = pm8xxx_gpio_config( 24, &backlight_drv); } else { rc = -1; } if (rc) { pr_err("%s LED backlight GPIO config failed\n", __func__); return rc; } return 0; } #endif static void msm_keypad_bl_led_set(struct led_classdev *led_cdev, enum led_brightness value) { #ifdef CONFIG_HUAWEI_LEDS_PMIC int ret = 0; /* 7x27a platform use mpp7 as keypad backlight */ #ifdef CONFIG_ARCH_MSM7X27A if(machine_is_msm7x27a_C8820()) { ret = pmic_secure_mpp_config_i_sink(PM_MPP_7, PM_MPP__I_SINK__LEVEL_5mA, \ (!!value) ? PM_MPP__I_SINK__SWITCH_ENA : PM_MPP__I_SINK__SWITCH_DIS); } else { /* use pwm to control the brightness of keypad backlight*/ /* make sure the led is drived by pwm when */ /* the system sleep indicator switch is on */ pmapp_button_backlight_init(); ret = pmapp_button_backlight_set_brightness(value); } #else if(machine_is_msm7x30_u8800() || machine_is_msm7x30_u8800_51() || machine_is_msm8255_u8800_pro() ) { ret = pmic_set_led_intensity(LED_KEYPAD, !( ! value)); } else if( machine_is_msm8255_u8860lp() || machine_is_msm8255_u8860_r() ||machine_is_msm8255_u8860_51()) { pwm_config(bl_pwm, LED_PWM_DUTY_LEVEL*value/NSEC_PER_USEC, LED_PWM_PERIOD/NSEC_PER_USEC); pwm_enable(bl_pwm); } else if(machine_is_msm7x30_u8820() || (machine_is_msm8255_u8730())) { ret = pmic_set_mpp6_led_intensity(!( ! value)); } /*< when the value between 0 and 255,set the key brightness is LED_BRIGHRNESS_LEVEL or set the brightness is 0 */ else if( machine_is_msm8255_u8860() || machine_is_msm8255_c8860() || machine_is_msm8255_u8860_92()) { if(LED_BRIGHTNESS_OFF >= value || LED_PWM_LEVEL < value ) { ret = pmic_set_keyled_intensity(LED_KEYPAD,LED_BRIGHTNESS_OFF ); } else { ret = pmic_set_keyled_intensity(LED_KEYPAD, LED_BRIGHTNESS_LEVEL); } } else if(machine_is_msm8255_u8680()) { /* Set keypad led brightness level 12 for U8680 */ if(LED_BRIGHTNESS_OFF >= value || LED_PWM_LEVEL < value) { ret = pmic_set_keyled_intensity(LED_KEYPAD,LED_BRIGHTNESS_OFF); } else { ret = pmic_set_keyled_intensity(LED_KEYPAD, LED_BRIGHTNESS_LEVEL_U8680); } } else if(machine_is_msm8255_u8667()) { /* Set keypad led brightness level 16 for U8667 */ if(LED_BRIGHTNESS_OFF >= value || LED_PWM_LEVEL < value) { ret = pmic_set_keyled_intensity(LED_KEYPAD, LED_BRIGHTNESS_OFF); } else { ret = pmic_set_keyled_intensity(LED_KEYPAD, LED_BRIGHTNESS_LEVEL_U8667); } } #endif if (ret) dev_err(led_cdev->dev, "can't set keypad backlight\n"); #else int ret; ret = pmic_set_led_intensity(LED_KEYPAD, value / MAX_KEYPAD_BL_LEVEL); if (ret) dev_err(led_cdev->dev, "can't set keypad backlight\n"); #endif }