static void kpd_slide_handler(unsigned long data) { bool slid; u8 old_state = kpd_slide_state; kpd_slide_state = !kpd_slide_state; slid = (kpd_slide_state == !!KPD_SLIDE_POLARITY); /* for SW_LID, 1: lid open => slid, 0: lid shut => closed */ input_report_switch(kpd_input_dev, SW_LID, slid); input_sync(kpd_input_dev); kpd_print("report QWERTY = %s\n", slid ? "slid" : "closed"); if(old_state) { mt_set_gpio_pull_select(GPIO_QWERTYSLIDE_EINT_PIN, 0); } else { mt_set_gpio_pull_select(GPIO_QWERTYSLIDE_EINT_PIN, 1); } /* for detecting the return to old_state */ mt65xx_eint_set_polarity(KPD_SLIDE_EINT, old_state); mt65xx_eint_unmask(KPD_SLIDE_EINT); }
INT32 wmt_plat_all_eint_ctrl( ENUM_PIN_STATE state ) { #ifdef GPIO_COMBO_ALL_EINT_PIN switch (state) { case PIN_STA_INIT: mt_set_gpio_mode(GPIO_COMBO_ALL_EINT_PIN, GPIO_COMBO_ALL_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_ALL_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_ENABLE); WMT_DBG_FUNC("WMT-PLAT:ALLInt init(in pd) \n"); break; case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_ALL_EINT_PIN, GPIO_COMBO_ALL_EINT_PIN_M_GPIO); mt_set_gpio_pull_enable(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_COMBO_ALL_EINT_PIN, GPIO_COMBO_ALL_EINT_PIN_M_EINT); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: /*set to gpio input low, pull down enable*/ mt_set_gpio_mode(GPIO_COMBO_ALL_EINT_PIN, GPIO_COMBO_ALL_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_ALL_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_ENABLE); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on ALL EINT\n", state); break; } #else WMT_INFO_FUNC("WMT-PLAT:ALL EINT not defined\n"); #endif return 0; }
INT32 wmt_plat_wifi_eint_ctrl(ENUM_PIN_STATE state) { #if 0 /*def GPIO_WIFI_EINT_PIN*/ switch (state) { case PIN_STA_INIT: mt_set_gpio_pull_enable(GPIO_WIFI_EINT_PIN, GPIO_PULL_DISABLE); mt_set_gpio_dir(GPIO_WIFI_EINT_PIN, GPIO_DIR_OUT); mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_MODE_GPIO); mt_set_gpio_out(GPIO_WIFI_EINT_PIN, GPIO_OUT_ONE); break; case PIN_STA_MUX: mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_WIFI_EINT_PIN_M_GPIO); mt_set_gpio_pull_enable(GPIO_WIFI_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_WIFI_EINT_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_WIFI_EINT_PIN_M_EINT); break; case PIN_STA_EINT_EN: mt_eint_unmask(CUST_EINT_WIFI_NUM); break; case PIN_STA_EINT_DIS: mt_eint_mask(CUST_EINT_WIFI_NUM); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: /*set to gpio input low, pull down enable*/ mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_COMBO_BGF_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_WIFI_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_WIFI_EINT_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_WIFI_EINT_PIN, GPIO_PULL_ENABLE); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on WIFI EINT\n", state); break; } #else WMT_INFO_FUNC("WMT-PLAT:WIFI EINT is controlled by MSDC driver \n"); #endif return 0; }
INT32 wmt_plat_rst_ctrl ( ENUM_PIN_STATE state ) { switch(state) { case PIN_STA_INIT: /*set to gpio output low, disable pull*/ mt_set_gpio_pull_enable(GPIO_COMBO_RST_PIN, GPIO_PULL_DISABLE); mt_set_gpio_dir(GPIO_COMBO_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_mode(GPIO_COMBO_RST_PIN, GPIO_MODE_GPIO); mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:RST init (out 0) \n"); break; case PIN_STA_OUT_H: mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ONE); WMT_DBG_FUNC("WMT-PLAT:RST (out 1) \n"); break; case PIN_STA_OUT_L: mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:RST (out 0) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: /*set to gpio input low, pull down enable*/ mt_set_gpio_mode(GPIO_COMBO_RST_PIN, GPIO_COMBO_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_RST_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_RST_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_RST_PIN, GPIO_PULL_ENABLE); WMT_DBG_FUNC("WMT-PLAT:RST deinit (in pd) \n"); break; case PIN_STA_SHOW: WMT_INFO_FUNC("WMT-PLAT:RST PIN_STA_SHOW start\n"); WMT_INFO_FUNC("WMT-PLAT:RST Mode(%d)\n", mt_get_gpio_mode(GPIO_COMBO_RST_PIN)); WMT_INFO_FUNC("WMT-PLAT:RST Dir(%d)\n", mt_get_gpio_dir(GPIO_COMBO_RST_PIN)); WMT_INFO_FUNC("WMT-PLAT:RST Pull enable(%d)\n", mt_get_gpio_pull_enable(GPIO_COMBO_RST_PIN)); WMT_INFO_FUNC("WMT-PLAT:RST Pull select(%d)\n", mt_get_gpio_pull_select(GPIO_COMBO_RST_PIN)); WMT_INFO_FUNC("WMT-PLAT:RST out(%d)\n", mt_get_gpio_out(GPIO_COMBO_RST_PIN)); WMT_INFO_FUNC("WMT-PLAT:RST PIN_STA_SHOW end\n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on RST\n", state); break; } return 0; }
static unsigned int lcm_compare_id() { unsigned int id = 0; unsigned int lcd_id=0; unsigned char buffer[4]; unsigned int data_array[16]; SET_RESET_PIN(1); //TE:should reset LCM firstly MDELAY(1); SET_RESET_PIN(0); MDELAY(20); SET_RESET_PIN(1); MDELAY(120); #ifdef BUILD_LK DSI_clk_HS_mode(1); #endif MDELAY(10); #ifdef BUILD_LK DSI_clk_HS_mode(0); #endif //data_array[0]=0x00063902; //data_array[1]=0x52AA55F0; // SET password //data_array[2]=0x00000108; push_table(lcm_read_lcm_compare_id, sizeof(lcm_read_lcm_compare_id) / sizeof(struct LCM_setting_table), 1); read_reg_v2(0xF4, buffer, 3); id = buffer[0]; //we only need ID 0x00 0x80 0x00 #ifndef BUILD_LK printk("<6>zhangjun [lcm_compare_id %x,%x,%x\n",buffer[0],buffer[1],buffer[2]); #else printf("<6>zhangjun [lcm_compare_id %x,%x,%x\n",buffer[0],buffer[1],buffer[2]); #endif if(0x79!= id) return 0; mt_set_gpio_mode(GPIO_LCM_ID, GPIO_LCM_ID_M_GPIO); mt_set_gpio_dir(GPIO_LCM_ID, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_LCM_ID,GPIO_PULL_DISABLE); mt_set_gpio_pull_select(GPIO_LCM_ID,GPIO_PULL_DOWN); MDELAY(1); lcd_id = mt_get_gpio_in(GPIO_LCM_ID); #ifndef BUILD_LK printk("<6>vendor jingtai [lcm_compare_id] lcd_id =%x\n",lcd_id); #else printf("<6>vendor jingtai [lcm_compare_id] lcd_id =%x\n",lcd_id); #endif if(lcd_id) return 0; else return 1; }
static void mtk_enable_pmic_otg_mode(void) { int val; printk("set pmic power on, begin\n"); mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN, GPIO_MODE_GPIO); mt_set_gpio_pull_select(GPIO_OTG_DRVVBUS_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_OTG_DRVVBUS_PIN, GPIO_PULL_ENABLE); /* save PMIC related registers */ printk("set pmic power on, begin2\n"); pmic_save_regs(); printk("set pmic power on, begin3\n"); pmic_config_interface(0x8D22, 0x1, 0x1, 12); pmic_config_interface(0x8D14, 0x1, 0x1, 12); pmic_config_interface(0x803C, 0x3, 0x3, 0); pmic_config_interface(0x803C, 0x2, 0x3, 2); pmic_config_interface(0x803C, 0x1, 0x1, 14); pmic_config_interface(0x8036, 0x0, 0x0, 0); pmic_config_interface(0x8D24, 0xf, 0xf, 12); pmic_config_interface(0x8D16, 0x1, 0x1, 15); pmic_config_interface(0x803A, 0x1, 0x1, 6); pmic_config_interface(0x8046, 0x00A0, 0xffff, 0); pmic_config_interface(0x803E, 0x1, 0x1, 2); pmic_config_interface(0x803E, 0x1, 0x1, 3); pmic_config_interface(0x803E, 0x3, 0x3, 8); pmic_config_interface(0x803E, 0x0, 0x1, 10); pmic_config_interface(0x8044, 0x3, 0x3, 0); pmic_config_interface(0x8044, 0x3, 0x7, 8); pmic_config_interface(0x8044, 0x1, 0x1, 11); pmic_config_interface(0x809C, 0x8000, 0xFFFF, 0); printk("set pmic power on, begin4\n"); val = 0; while (val == 0) { pmic_read_interface(0x809A, &val, 0x1, 15); } printk("set pmic power on, begin5\n"); pmic_config_interface(0x8084, 0x1, 0x1, 0); mdelay(50); val = 0; while (val == 0) { pmic_read_interface(0x8060, &val, 0x1, 14); } printk("set pmic power on, done\n"); }
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err; i2c_client = client; i2c_rs_client = client; i2c_rs_client->addr = i2c_rs_client->addr & I2C_MASK_FLAG | I2C_WR_FLAG | I2C_RS_FLAG; printk("[mtk-tpd] i2c device probe\n"); /* added in android 2.2, for configuring EINT2 to GPIO mode */ mt_set_gpio_mode(GPIO61, 0x00); mt_set_gpio_pull_enable(GPIO61, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO61,GPIO_PULL_UP); mt_set_gpio_dir(GPIO61, GPIO_DIR_OUT); mt_set_gpio_out(GPIO61, GPIO_OUT_ZERO); hwPowerDown(TPD_POWER_SOURCE,"TP"); hwPowerOn(TPD_POWER_SOURCE,VOL_3300,"TP"); msleep(20); thread = kthread_run(touch_event_handler, 0, TPD_DEVICE); if (IS_ERR(thread)) { err = PTR_ERR(thread); TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err); } /* added in android 2.2, for configuring EINT2 to EINT mode */ mt_set_gpio_mode(GPIO61, 0x01); mt_set_gpio_pull_enable(GPIO61, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO61, GPIO_PULL_UP); MT6516_EINT_Set_Sensitivity(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); MT6516_EINT_Set_HW_Debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); MT6516_EINT_Registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1); MT6516_EINTIRQUnmask(CUST_EINT_TOUCH_PANEL_NUM); return 0; }
void mt_gpio_set_default_chip(void) { GPIO_REGS *pReg = (GPIO_REGS*)(GPIO_BASE); unsigned int idx; u32 val; for (idx = 0; idx < sizeof(pReg->dir)/sizeof(pReg->dir[0]); idx++){ val = gpio_init_dir_data[idx]; GPIO_WR32(&pReg->dir[idx],val); } for (idx = 0; idx < sizeof(pReg->pullen)/sizeof(pReg->pullen[0]); idx++){ val = gpio_init_pullen_data[idx]; GPIO_WR32(&pReg->pullen[idx],val); } for (idx = 0; idx < sizeof(pReg->pullsel)/sizeof(pReg->pullsel[0]); idx++){ val = gpio_init_pullsel_data[idx]; GPIO_WR32(&pReg->pullsel[idx],val); } /*for keypad special register*/ mt_set_gpio_pull_select(GPIO74, GPIO74_PULL); mt_set_gpio_pull_select(GPIO75, GPIO75_PULL); mt_set_gpio_pull_select(GPIO92, GPIO92_PULL); mt_set_gpio_pull_select(GPIO93, GPIO93_PULL); mt_set_gpio_pull_select(GPIO167, GPIO167_PULL); mt_set_gpio_pull_select(GPIO168, GPIO168_PULL); for (idx = 0; idx < sizeof(pReg->dout)/sizeof(pReg->dout[0]); idx++) { val = gpio_init_dout_data[idx]; GPIO_WR32(&pReg->dout[idx],val); } for (idx = 0; idx < sizeof(pReg->mode)/sizeof(pReg->mode[0]); idx++) { val = gpio_init_mode_data[idx]; GPIO_WR32(&pReg->mode[idx],val); } for (idx = 0; idx < sizeof(pReg->smt)/sizeof(pReg->smt[0]); idx++) { val = gpio_init_smt_data[idx]; GPIO_WR32(&pReg->smt[idx],val); } /*for msdc special smt */ mt_set_gpio_smt(GPIO_SMT_GRP25, GPIO_SMT_GROUP_25); mt_set_gpio_smt(GPIO_SMT_GRP26, GPIO_SMT_GROUP_26); mt_set_gpio_smt(GPIO_SMT_GRP27, GPIO_SMT_GROUP_27); mt_set_gpio_smt(GPIO_SMT_GRP28, GPIO_SMT_GROUP_28); mt_set_gpio_smt(GPIO_SMT_GRP29, GPIO_SMT_GROUP_29); mt_set_gpio_smt(GPIO_SMT_GRP30, GPIO_SMT_GROUP_30); mt_set_gpio_smt(GPIO_SMT_GRP31, GPIO_SMT_GROUP_31); mt_set_gpio_smt(GPIO_SMT_GRP32, GPIO_SMT_GROUP_32); mt_set_gpio_smt(GPIO_SMT_GRP33, GPIO_SMT_GROUP_33); //set BSI driving 2ma->4ma: 0x10005B30[7:4]=0x2 GPIO_WR32(&pReg->drv_mode[3].set, 0x20); GPIOVER("mt_gpio_set_default() done\n"); }
static int lcm_check_id(void) { mt_set_gpio_mode(97,0); mt_set_gpio_dir(97,0); mt_set_gpio_pull_enable(97,1); mt_set_gpio_pull_select(97,1); //MDELAY(10); /// mt_set_gpio_out(97,1); MDELAY(20); mt_get_gpio_in(97); MDELAY(80); return mt_get_gpio_in(97); }
/* platform device functions */ void tpd_suspend(struct early_suspend *h) { tpd_halt = 1; mt_set_gpio_mode(GPIO61, 0x00); mt_set_gpio_pull_enable(GPIO61, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO61,GPIO_PULL_UP); mt_set_gpio_dir(GPIO61, GPIO_DIR_OUT); mt_set_gpio_out(GPIO61, GPIO_OUT_ONE); MT6516_EINTIRQMask(CUST_EINT_TOUCH_PANEL_NUM); MT6516_IRQMask(MT6516_TOUCH_IRQ_LINE); msleep(50); hwPowerDown(TPD_POWER_SOURCE,"TP"); }
static void kpd_set_config(void) { int i = 0, col_num = 7; //for stable Col0, else still can check keys pressed, set USBDL_EN bit //unsigned short value = *(volatile unsigned short *)(0x7002f62c); //*(volatile unsigned short *)(0x7002f62c) = value&(~(0x1<<5)); /* KROW0 ~ KROW7: output + pull disable + pull down */ for(i = 0; i < 8; i++) { mt_set_gpio_mode(kpd_gpio[i].gpio_num, 1); mt_set_gpio_dir(kpd_gpio[i].gpio_num, 1); mt_set_gpio_pull_enable(kpd_gpio[i].gpio_num, 0); mt_set_gpio_pull_select(kpd_gpio[i].gpio_num, 0); } /* KCOL0 ~ KCOL7: input + pull enable + pull up */ for(i = col_num; i < 8 + col_num; i++) { mt_set_gpio_mode(kpd_gpio[i].gpio_num, 1); mt_set_gpio_dir(kpd_gpio[i].gpio_num, 0); mt_set_gpio_pull_enable(kpd_gpio[i].gpio_num, 1); mt_set_gpio_pull_select(kpd_gpio[i].gpio_num, 1); } }
static int txc_irq_init(struct txc_data *txc) { int ret; int irq; mt_set_gpio_dir(GPIO_IR_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_IR_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_IR_EINT_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_IR_EINT_PIN, GPIO_MODE_00); mt_eint_set_sens(CUST_EINT_INTI_INT_NUM, MT_EDGE_SENSITIVE); mt_eint_registration(CUST_EINT_INTI_INT_NUM, EINTF_TRIGGER_FALLING, txc_irq_handler, 0); mt_eint_unmask(CUST_EINT_INTI_INT_NUM); return ret; }
static int hw_irq_enable(void) { int retval = -1 ; /* Recovery EINT Mode */ retval = mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); retval |=mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); retval |=mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); retval |=mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); info_printk("TPD wake up\n"); return retval; }
// --------------------------------------------------------------------------- // LCM Driver Implementations // --------------------------------------------------------------------------- static void config_gpio(void) { lcm_util.set_gpio_mode(LSCE_GPIO_PIN, GPIO_DISP_LSCE_PIN_M_GPIO); lcm_util.set_gpio_mode(LSCK_GPIO_PIN, GPIO_DISP_LSCK_PIN_M_GPIO); lcm_util.set_gpio_mode(LSDA_GPIO_PIN, GPIO_DISP_LSDA_PIN_M_GPIO); lcm_util.set_gpio_mode(LSDI_GPIO_PIN, GPIO_MODE_00); lcm_util.set_gpio_dir(LSCE_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_dir(LSCK_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_dir(LSDA_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_dir(LSDI_GPIO_PIN, GPIO_DIR_IN); lcm_util.set_gpio_pull_enable(LSCE_GPIO_PIN, GPIO_PULL_DISABLE); lcm_util.set_gpio_pull_enable(LSCK_GPIO_PIN, GPIO_PULL_DISABLE); lcm_util.set_gpio_pull_enable(LSDA_GPIO_PIN, GPIO_PULL_DISABLE); lcm_util.set_gpio_pull_enable(LSDI_GPIO_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(LSDI_GPIO_PIN, GPIO_PULL_UP); //set pwm output clk lcm_util.set_gpio_mode(SSD2825_MIPI_CLK_GPIO_PIN, GPIO_MODE_02); lcm_util.set_gpio_dir(SSD2825_MIPI_CLK_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_pull_enable(SSD2825_MIPI_CLK_GPIO_PIN, GPIO_PULL_DISABLE); lcd_set_pwm(PWM0); MDELAY(10); //set ssd2825 shut ping high lcm_util.set_gpio_mode(SSD2825_SHUT_GPIO_PIN, GPIO_MODE_00); lcm_util.set_gpio_dir(SSD2825_SHUT_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_pull_enable(SSD2825_SHUT_GPIO_PIN, GPIO_PULL_DISABLE); SET_GPIO_OUT(SSD2825_SHUT_GPIO_PIN , 1); MDELAY(1); //set ssd2825 poweron lcm_util.set_gpio_mode(SSD2825_POWER_GPIO_PIN, GPIO_MODE_00); lcm_util.set_gpio_dir(SSD2825_POWER_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_pull_enable(SSD2825_POWER_GPIO_PIN, GPIO_PULL_DISABLE); SET_GPIO_OUT(SSD2825_POWER_GPIO_PIN , 1); MDELAY(1); //set s6e8aa poweron lcm_util.set_gpio_mode(LCD_POWER_GPIO_PIN, GPIO_MODE_00); lcm_util.set_gpio_dir(LCD_POWER_GPIO_PIN, GPIO_DIR_OUT); lcm_util.set_gpio_pull_enable(LCD_POWER_GPIO_PIN, GPIO_PULL_DISABLE); SET_GPIO_OUT(LCD_POWER_GPIO_PIN , 1); MDELAY(50); }
void cm_relese_rst_signal(void) { EMD_MSG_INF("chr","cm_relese_rst_signal1:GPIO_EXT_MD_RST(%d)\n",mt_get_gpio_out(GPIO_EXT_MD_RST)); mt_set_gpio_dir(GPIO_EXT_MD_RST, 1); #ifdef GPIO_EXT_USB_SW2 mt_set_gpio_out(GPIO_EXT_MD_RST, 1); EMD_MSG_INF("chr","cm_relese_rst_signal2:GPIO_EXT_MD_RST(%d)\n",mt_get_gpio_out(GPIO_EXT_MD_RST)); mt_set_gpio_pull_enable(GPIO_EXT_MD_RST, 1); mt_set_gpio_dir(GPIO_EXT_MD_RST, 0); mt_set_gpio_pull_select(GPIO_EXT_MD_RST, 1); EMD_MSG_INF("chr","cm_relese_rst_signal3:set evb GPIO_EXT_MD_RST(in)=%d!\n",mt_get_gpio_in(GPIO_EXT_MD_RST)); #else mt_set_gpio_out(GPIO_EXT_MD_RST, 0); EMD_MSG_INF("chr","cm_relese_rst_signal3:set phoneGPIO_EXT_MD_RST(in)=%d!\n",mt_get_gpio_in(GPIO_EXT_MD_RST)); #endif }
/* * register irq handler * parmaters pass by inno_core * @handler - if101 irq handler function pointer * @irq_type - if101 irq type (falling edge detect or rising) */ int inno_irq_setup(void (*interrupthandler)(void )) { mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_EINT); //set to eint MODE for enable eint function mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_IN); #if 1 mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1); mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN, 1); #endif inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN), mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN)); // rename the functions mt65xx_eint_xx by mt_eint_xx rui mt_eint_registration(CUST_EINT_CMMB_NUM, EINTF_TRIGGER_FALLING, interrupthandler, 0); // 0:auto mask is no mt_eint_unmask(CUST_EINT_CMMB_NUM); // mt_eint_mask(CUST_EINT_CMMB_NUM); return 0; }
void mtk_wcn_cmb_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data) { mtk_wcn_sdio_irq_flag_set (0); mtk_wcn_cmb_sdio_eirq_data = data; mtk_wcn_cmb_sdio_eirq_handler = irq_handler; //mt_eint_set_sens(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_SENSITIVE); /*CUST_EINT_WIFI_NUM */ //mt_eint_set_hw_debounce(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */ mt_set_gpio_pull_enable(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_UP); mt_eint_registration(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_POLARITY, mtk_wcn_cmb_sdio_eirq_handler_stub, 0); mt_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */ }
static int get_lcd_id(void) { mt_set_gpio_mode(GPIO_LCD_ID_PIN,0); mt_set_gpio_dir(GPIO_LCD_ID_PIN,0); mt_set_gpio_pull_enable(GPIO_LCD_ID_PIN,1); mt_set_gpio_pull_select(GPIO_LCD_ID_PIN,1); MDELAY(1); #if defined(BUILD_LK) printf("wqcat %s, get_lcd_id=%d\n", __func__, mt_get_gpio_in(GPIO_LCD_ID_PIN)); #endif #ifndef BUILD_LK printk("wqcat %s, get_lcd_id=%d\n", __func__, mt_get_gpio_in(GPIO_LCD_ID_PIN)); #endif return mt_get_gpio_in(GPIO_LCD_ID_PIN); }
int __init musb_platform_init(struct musb *musb) { int err; #ifdef CONFIG_USB_MTK_HDRC_HCD if (is_host_enabled(musb)) { musb->board_set_vbus = mtk_set_vbus; //<2013/03/27-23263-stevenchen, Correct GPIO12 & GPIO38 configuration to low down standby current. #ifndef CONFIG_MT6589_FPGA #ifndef MTK_BQ24196_SUPPORT #ifndef MTK_BQ24157_SUPPORT mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN,GPIO_OTG_DRVVBUS_PIN_M_GPIO);//should set GPIO2 as gpio mode. mt_set_gpio_dir(GPIO_OTG_DRVVBUS_PIN,GPIO_DIR_OUT); mt_get_gpio_pull_enable(GPIO_OTG_DRVVBUS_PIN); mt_set_gpio_pull_select(GPIO_OTG_DRVVBUS_PIN,GPIO_PULL_UP); #endif #endif #endif //>2013/03/27-23263-stevenchen } #endif musb->nIrq = MT6589_USB0_IRQ_ID; musb->dma_irq= (int)SHARE_IRQ; musb->fifo_cfg = fifo_cfg; musb->fifo_cfg_size = ARRAY_SIZE(fifo_cfg); musb->fifo_cfg_host = fifo_cfg_host; musb->fifo_cfg_host_size = ARRAY_SIZE(fifo_cfg_host); mtk_musb->power = FALSE; mtk_musb->is_host = FALSE; mtk_musb->fifo_size = 8*1024; #ifndef CONFIG_MT6589_FPGA hwPowerOn(MT65XX_POWER_LDO_VUSB, VOL_3300, "VUSB_LDO"); printk("%s, enable VBUS_LDO \n", __func__); #endif musb_platform_enable(musb); emi_mpu_notifier_register(MST_ID_MMPERI_1, musb_check_mpu_violation); musb->isr = mt_usb_interrupt; musb_writel(musb->mregs,MUSB_HSDMA_INTR,0xff | (0xff << DMA_INTR_UNMASK_SET_OFFSET)); DBG(2,"musb platform init %x\n",musb_readl(musb->mregs,MUSB_HSDMA_INTR)); musb_writel(musb->mregs,USB_L1INTM,TX_INT_STATUS | RX_INT_STATUS | USBCOM_INT_STATUS | DMA_INT_STATUS); err = device_create_file(musb->controller,&dev_attr_cmode); return 0; }
INT32 wmt_plat_ldo_ctrl ( ENUM_PIN_STATE state ) { #ifdef GPIO_COMBO_6620_LDO_EN_PIN switch(state) { case PIN_STA_INIT: /*set to gpio output low, disable pull*/ mt_set_gpio_pull_enable(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_PULL_DISABLE); mt_set_gpio_dir(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_mode(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_MODE_GPIO); mt_set_gpio_out(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:LDO init (out 0) \n"); break; case PIN_STA_OUT_H: mt_set_gpio_out(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_OUT_ONE); WMT_DBG_FUNC("WMT-PLAT:LDO (out 1) \n"); break; case PIN_STA_OUT_L: mt_set_gpio_out(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:LDO (out 0) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: /*set to gpio input low, pull down enable*/ mt_set_gpio_mode(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_COMBO_6620_LDO_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_6620_LDO_EN_PIN, GPIO_PULL_ENABLE); WMT_DBG_FUNC("WMT-PLAT:LDO deinit (in pd) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on LDO\n", state); break; } #else WMT_INFO_FUNC("WMT-PLAT:LDO is not used\n"); #endif return 0; }
/* * register irq handler * parmaters pass by inno_core * @handler - if101 irq handler function pointer * @irq_type - if101 irq type (falling edge detect or rising) */ int inno_irq_setup(void (*interrupthandler)(void )) { mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_EINT); //set to eint MODE for enable eint function mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_IN); #if 1 mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1); mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN, 1); #endif inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN), mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN)); mt65xx_eint_set_sens(CUST_EINT_CMMB_NUM, CUST_EINT_EDGE_SENSITIVE); mt65xx_eint_registration(CUST_EINT_CMMB_NUM, CUST_EINT_DEBOUNCE_DISABLE, CUST_EINT_POLARITY_LOW, interrupthandler, 0); // 0:auto mask is no mt65xx_eint_unmask(CUST_EINT_CMMB_NUM); // mt65xx_eint_mask(CUST_EINT_CMMB_NUM); return 0; }
static void mtk_wcn_cmb_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data) { mtk_wcn_sdio_irq_flag_set (0); mtk_wcn_cmb_sdio_eirq_data = data; mtk_wcn_cmb_sdio_eirq_handler = irq_handler; #if CUST_EINT_WIFI_DEBOUNCE_EN mt_eint_set_hw_debounce(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */ #endif mt_set_gpio_pull_enable(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_UP); mt_eint_registration(mtk_wcn_cmb_sdio_eint_num/*CUST_EINT_WIFI_NUM */, CUST_EINT_WIFI_TYPE, mtk_wcn_cmb_sdio_eirq_handler_stub, 0); mt_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */ }
static int mt8193_init(void) { MT8193_DRV_FUNC(); memset((void*)&r_hdmi_timer, 0, sizeof(r_hdmi_timer)); r_hdmi_timer.expires = jiffies + 1000/(1000/HZ); // wait 1s to stable r_hdmi_timer.function = hdmi_poll_isr; r_hdmi_timer.data = 0; init_timer(&r_hdmi_timer); add_timer(&r_hdmi_timer); memset((void*)&r_cec_timer, 0, sizeof(r_cec_timer)); r_cec_timer.expires = jiffies + 1000/(1000/HZ); // wait 1s to stable r_cec_timer.function = cec_poll_isr; r_cec_timer.data = 0; init_timer(&r_cec_timer); add_timer(&r_cec_timer); init_waitqueue_head(&hdmi_timer_wq); hdmi_timer_task = kthread_create(hdmi_timer_kthread, NULL, "hdmi_timer_kthread"); wake_up_process(hdmi_timer_task); init_waitqueue_head(&cec_timer_wq); cec_timer_task = kthread_create(cec_timer_kthread, NULL, "cec_timer_kthread"); wake_up_process(cec_timer_task); init_waitqueue_head(&mt8193_nlh_wq); mt8193_nlh_task = kthread_create(mt8193_nlh_kthread, NULL, "mt8193_nlh_kthread"); wake_up_process(mt8193_nlh_task); #if defined(CONFIG_HAS_EARLYSUSPEND) register_early_suspend(&mt8193_hdmi_early_suspend_desc); #endif mt_set_gpio_mode(GPIO_HDMI_EINT_PIN, GPIO_MODE_01); mt_set_gpio_dir(GPIO_HDMI_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_HDMI_EINT_PIN, true); mt_set_gpio_pull_select(GPIO_HDMI_EINT_PIN, GPIO_PULL_UP); mt65xx_eint_set_sens(CUST_EINT_EINT_HDMI_HPD_NUM, CUST_EINT_EDGE_SENSITIVE); mt65xx_eint_registration(CUST_EINT_EINT_HDMI_HPD_NUM, 0, CUST_EINT_POLARITY_LOW, &_mt8193_irq_handler, 0); mt65xx_eint_unmask(CUST_EINT_EINT_HDMI_HPD_NUM); return 0; }
static int cyttsp4_wakeup(struct device *dev) { int rc = 0; mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EINT_PIN, GPIO_OUT_ZERO); udelay(2000); mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); dev_info(dev, "%s: WAKEUP CYTTSP gpio=%d r=%d\n", __func__, GPIO_CTP_EINT_PIN, rc); return rc; }
int hall_setup_eint(void) { /*configure to GPIO function, external interrupt*/ mt_set_gpio_mode(GPIO_HALL_COVER_PIN, GPIO_HALL_COVER_PIN_M_EINT); mt_set_gpio_dir(GPIO_HALL_COVER_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_HALL_COVER_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_HALL_COVER_PIN, GPIO_PULL_UP); HALL_LOG("hall_setup_eint 111\n"); mt_eint_set_hw_debounce(CUST_EINT_HALL_COVER_NUM , CUST_EINT_HALL_COVER_DEBOUNCE_CN); mt_eint_registration(CUST_EINT_HALL_COVER_NUM , CUST_EINT_HALL_COVER_TYPE, hall_eint_func, 0); mt_eint_unmask(CUST_EINT_HALL_COVER_NUM ); HALL_LOG("hall_setup_eint 222\n"); return 0; }
static kal_uint32 mt_get_board_type(void) { /* * Note: Don't use it in IRQ context */ #if 1 static int board_type = MT_BOARD_NONE; if (board_type != MT_BOARD_NONE) return board_type; spin_lock(&mt_board_lock); /* Enable AUX_IN0 as GPI */ mt_set_gpio_ies(GPIO_PHONE_EVB_DETECT, GPIO_IES_ENABLE); /* Set internal pull-down for AUX_IN0 */ mt_set_gpio_pull_select(GPIO_PHONE_EVB_DETECT, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_PHONE_EVB_DETECT, GPIO_PULL_ENABLE); /* Wait 20us */ udelay(20); /* Read AUX_INO's GPI value*/ mt_set_gpio_mode(GPIO_PHONE_EVB_DETECT, GPIO_MODE_00); mt_set_gpio_dir(GPIO_PHONE_EVB_DETECT, GPIO_DIR_IN); if (mt_get_gpio_in(GPIO_PHONE_EVB_DETECT) == 1) { /* Disable internal pull-down if external pull-up on PCB(leakage) */ mt_set_gpio_pull_enable(GPIO_PHONE_EVB_DETECT, GPIO_PULL_DISABLE); board_type = MT_BOARD_EVB; } else { /* Disable internal pull-down if external pull-up on PCB(leakage) */ mt_set_gpio_pull_enable(GPIO_PHONE_EVB_DETECT, GPIO_PULL_DISABLE); board_type = MT_BOARD_PHONE; } spin_unlock(&mt_board_lock); battery_xlog_printk(BAT_LOG_CRTI, "[Kernel] Board type is %s\n", (board_type == MT_BOARD_EVB) ? "EVB" : "PHONE"); return board_type; #else return MT_BOARD_EVB; #endif }
static unsigned int lcm_compare_id(void) { unsigned int id = 0,ID_PIN =2; #ifdef BUILD_LK pmic_config_interface(0x0532,5,0x7,5);//add by libo for VGP2 POWER ON pmic_config_interface(0x050C,1,0x1,15); #else //hwPowerOn(MT6323_POWER_LDO_VGP2,VOL_2800,"LCM"); #endif MDELAY(100); SET_RESET_PIN(1); MDELAY(20); SET_RESET_PIN(0); MDELAY(50); SET_RESET_PIN(1); MDELAY(120); send_ctrl_cmd(0xB9); // SET password send_data_cmd(0xFF); send_data_cmd(0x83); send_data_cmd(0x69); send_ctrl_cmd(0xC3); send_data_cmd(0xFF); send_ctrl_cmd(0xF4); read_data_cmd(); id = read_data_cmd(); #if defined(BUILD_LK) printf("xxxxx MYCAT hx8369_p908 READ ID = 0x%x\n", id); #endif mt_set_gpio_mode(GPIO_LCD_ID_PIN,0); mt_set_gpio_dir(GPIO_LCD_ID_PIN,0); mt_set_gpio_pull_enable(GPIO_LCD_ID_PIN,1); mt_set_gpio_pull_select(GPIO_LCD_ID_PIN,1); MDELAY(1); ID_PIN=mt_get_gpio_in(GPIO_LCD_ID_PIN); #if defined(BUILD_LK) printf("xxxxx MYCAT ID_PIN = 0x%x\n", ID_PIN); #endif return ((LCM_ID == id)&&(ID_PIN==1))?1:0; }
int cm_do_md_go(void) { int ret = -1; if (is_hold_rst) { is_hold_rst=0; unsigned int retry = 100; EMD_MSG_INF("chr","cm_do_md_go:1\n"); EMD_MSG_INF("chr","cm_do_md_go2:GPIO_EXT_MD_RST(out)=%d,GPIO_EXT_MD_WD(in)=%d\n",mt_get_gpio_out(GPIO_EXT_MD_RST),mt_get_gpio_in(GPIO_EXT_MD_WD)); cm_relese_rst_signal(); EMD_MSG_INF("chr","cm_do_md_go3:GPIO_EXT_MD_RST(out)=%d,GPIO_EXT_MD_WD(in)=%d\n",mt_get_gpio_out(GPIO_EXT_MD_RST),mt_get_gpio_in(GPIO_EXT_MD_WD)); // Check WDT pin to high while(retry>0){ retry--; if(mt_get_gpio_in(GPIO_EXT_MD_WD)==0) { msleep(10); } else { ret=100-retry; break; } } atomic_set(&traffic_on, 1); msleep(1000); // for use AP_WK_MD as EXT_MD_META, give 6261 bootloader sometime to read boot mode atomic_set(&allow_wk_md, 1); cm_hold_wakeup_md_signal(); EMD_MSG_INF("chr","cm_do_md_go4:GPIO_EXT_MD_RST(out)=%d,GPIO_EXT_MD_WD(in)=%d\n",mt_get_gpio_out(GPIO_EXT_MD_RST),mt_get_gpio_in(GPIO_EXT_MD_WD)); msleep(POWER_ON_HOLD_TIME); mt_set_gpio_out(GPIO_EXT_MD_PWR_KEY, 0); } mt_set_gpio_dir(GPIO_EXT_MD_WK_AP, 0); mt_set_gpio_pull_enable(GPIO_EXT_MD_WK_AP, 1); mt_set_gpio_pull_select(GPIO_EXT_MD_WK_AP, 1); cm_enable_ext_md_wdt_irq(); cm_enable_ext_md_wakeup_irq(); cm_enable_ext_md_exp_irq(); //msleep(50); // WDT IRQ is level triggered now, no need this debounce ignore_wdt_interrupt = 0; return ret; }
static void md_gpio_set(GPIO_PIN pin, GPIO_MODE mode, GPIO_DIR dir, GPIO_OUT out, GPIO_PULL_EN pull_en, GPIO_PULL pull, GPIO_SMT smt) { mt_set_gpio_mode(pin, mode); if (dir != GPIO_DIR_UNSUPPORTED) mt_set_gpio_dir(pin, dir); if (dir == GPIO_DIR_OUT) mt_set_gpio_out(pin, out); if (dir == GPIO_DIR_IN) mt_set_gpio_smt(pin, smt); if (pull_en != GPIO_PULL_EN_UNSUPPORTED) { mt_set_gpio_pull_enable(pin, pull_en); mt_set_gpio_pull_select(pin, pull); } md_gpio_get(pin, "-"); }
void static otg_int_init(void) { #ifdef ID_PIN_USE_EX_EINT mt_set_gpio_mode(GPIO_OTG_IDDIG_EINT_PIN, GPIO_OTG_IDDIG_EINT_PIN_M_USB_IDDIG); mt_set_gpio_dir(GPIO_OTG_IDDIG_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_UP); mt_eint_set_sens(IDDIG_EINT_PIN, MT_LEVEL_SENSITIVE); mt_eint_set_hw_debounce(IDDIG_EINT_PIN,64); mt_eint_registration(IDDIG_EINT_PIN, EINTF_TRIGGER_LOW, mt_usb_ext_iddig_int, FALSE); #else u32 phy_id_pull = 0; phy_id_pull = __raw_readl(U2PHYDTM1); phy_id_pull |= ID_PULL_UP; __raw_writel(phy_id_pull,U2PHYDTM1); musb_writel(mtk_musb->mregs,USB_L1INTM,IDDIG_INT_STATUS|musb_readl(mtk_musb->mregs,USB_L1INTM)); #endif }