/* Function to manage power-on resume */ void tpd_resume(struct early_suspend *h) { tpd_hw_enable(); mdelay(200); #if 0 uint8_t bfffer[2] = {0x01,0x02}; //if(tpd_debuglog==1) { //TPD_DMESG("[mtk-tpd] %s\n", __FUNCTION__); //} #ifdef TPD_HAVE_POWER_ON_OFF mt_set_gpio_mode(181, 1); mt_set_gpio_mode(182, 1); /*mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE);*/ tpd_hw_enable(); tpd_i2c_master_send(i2c_client,bfffer,2); msleep(10); #endif tpd_i2c_master_rs_send(i2c_client,bfffer,1<<8|1); bfffer[1] &= ~0x0E; bfffer[1] |= 0x02; tpd_i2c_master_send(i2c_client,bfffer,2); msleep(5); #endif mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); tpd_halt = 0; }
static inline int accfix_setup_eint(void) { /*configure to GPIO function, external interrupt*/ ACCFIX_DEBUG("[accfix]accfix_setup_eint\n"); mt_set_gpio_mode(GPIO_ACCDET_EINT_PIN, GPIO_ACCDET_EINT_PIN_M_EINT); mt_set_gpio_dir(GPIO_ACCDET_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_ACCDET_EINT_PIN, GPIO_PULL_ENABLE); #ifdef ACCFIX_EINT_HIGH_ACTIVE mt_set_gpio_pull_select(GPIO_ACCDET_EINT_PIN, GPIO_PULL_DOWN); #else mt_set_gpio_pull_select(GPIO_ACCDET_EINT_PIN, GPIO_PULL_UP); #endif /** mt65xx_eint_set_sens(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_SENSITIVE); #ifdef ACCFIX_EINT_HIGH_ACTIVE mt65xx_eint_set_polarity(CUST_EINT_ACCDET_NUM, 1); ACCFIX_DEBUG("[accfix]accfix_setup_eint active high \n"); #else mt65xx_eint_set_polarity(CUST_EINT_ACCDET_NUM, 0); ACCFIX_DEBUG("[accfix]accfix_setup_eint active low\n"); #endif **/ mt65xx_eint_set_hw_debounce(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_DEBOUNCE_CN); mt65xx_eint_registration(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_DEBOUNCE_EN, CUST_EINT_ACCDET_POLARITY, accfix_eint_func, 0); mt65xx_eint_unmask(CUST_EINT_ACCDET_NUM); return 0; }
void tpd_resume(struct early_suspend *h) { TPD_DEBUG("TP tpd_resume\n"); if (ft5316_i2c_client == NULL) return; // if (atomic_read( &g_pts->isp_opened )) // return; TPD_DEBUG("[mtk-tpd] Resume++.\n"); tinno_tp_power_on(); int err = 0; int i=0; for(i=0;i<5;i++){ err = tinno_check_focaltech(); if(err) break; tinno_tp_power_off(); tinno_tp_power_on(); } if (err ==0) TPD_DEBUG("tinno_init_panel ****************************************************power on failed.\n"); tpd_init_skip = 1; tpd_status = 1; //Ivan 6573 MT6516_IRQUnmask(MT6516_TOUCH_IRQ_LINE); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); TPD_DEBUG("[mtk-tpd] Resume--.\n"); }
static void tpd_resume(struct early_suspend *h) { if ( g_pts ){ CTP_DBG("TPD wake up\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP fts_5x06_hw_init(); #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ZERO); msleep(1); mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ONE); #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mutex_unlock(&g_pts->mutex);//Lock on suspend mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); atomic_set( &g_pts->ts_sleepState, 0 ); //LINE<JIRA_ID><DATE20130320><add charger flag>zenghaihui g_need_refresh_tp_flag = 1; } }
int hdmi_drv_power_on(void) { int ret = 0; HDMI_FUNC(); mt65xx_eint_mask(CUST_EINT_MHL_NUM); #if 1 SiiMhlTxHwGpioResume(); //pmic_config_interface(0x87,0x1,0x01,0x0); /* Vanzo:lubaoquan on: Tue, 21 May 2013 22:35:29 +0800 * TODO: replace this line with your comment */ hwPowerOn(MT65XX_POWER_LDO_VGP5, VOL_1200, "HDMI"); // End of Vanzo: lubaoquan #endif //msleep(100); SiiMhlTxHwReset(5,5); //xuecheng HalInstallCheckDeviceCB(SiiCheckDevice); HalAcquireIsrLock(); siHdmiTx_VideoSel(HDMI_720P60); siHdmiTx_AudioSel(I2S_44); ret = SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); HalReleaseIsrLock(); mt65xx_eint_unmask(CUST_EINT_MHL_NUM); return ret; }
/* When I2C readings are failing too much, we delay the next reading by masking the IRQ */ static void open_nfc_enable_irq(unsigned long arg) { ENTER(); // enable_irq(arg); mt65xx_eint_unmask(CUST_EINT_NFC_NUM); }
void inline disable_accfix(void) { // disable ACCDET unit ACCFIX_DEBUG("accfix: disable_accfix\n"); pre_state_swctrl = INREG32(ACCDET_STATE_SWCTRL); OUTREG32(ACCDET_CTRL, ACCDET_DISABLE); OUTREG32(ACCDET_STATE_SWCTRL, 0); //unmask EINT mt65xx_eint_unmask(CUST_EINT_ACCDET_NUM); }
static int touch_event_handler(void *unused) { struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; struct touch_info cinfo, sinfo; int pending = 0; struct i2c_client * i2c_client = ft5316_i2c_client ; TPD_DEBUG("touch_event_handler\n"); cinfo.pending=0; sched_setscheduler(current, SCHED_RR, ¶m); do { //Ivan added for testing if (tpd_status == 1){ mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); // possibly to lose event? } set_current_state(TASK_INTERRUPTIBLE); if (!kthread_should_stop()) { // TPD_DEBUG_CHECK_NO_RESPONSE; do { if(pending) wait_event_interruptible_timeout(waiter, tpd_flag!=0, HZ/10); else wait_event_interruptible_timeout(waiter,tpd_flag!=0, HZ*2); } while(0); if(tpd_flag==0 && !pending) continue; // if timeout for no touch, then re-wait. if(tpd_flag!=0 && pending>0) pending=0; tpd_flag=0; TPD_DEBUG_SET_TIME; } set_current_state(TASK_RUNNING); if(!pending) if(tpd_gettouchinfo(&cinfo, &sinfo)) continue; if(pending>1) { pending--; continue; } //Ivan ++ if (tpd_init_skip) {tpd_init_skip = 0; continue; } TPD_DEBUG("cinfo->count == %d!\n", cinfo.count); if(cinfo.count > 0) { int i; for ( i=0; i < cinfo.count; i++ ) { TPD_DEBUG("cinfo->count == %d!\n", cinfo.count); TPD_DEBUG("Point ID == %d, x == %d , y == %d ,z ==%d\n!",cinfo.pt[i].id,cinfo.pt[i].x,cinfo.pt[i].y,cinfo.pt[i].z ); tpd_down(cinfo.pt[i].x, cinfo.pt[i].y, cinfo.pt[i].id); } input_sync(tpd->dev); } else { TPD_DEBUG("TPD up x == %d , y == %d\n!",x_history[cinfo.count], y_history[cinfo.count]); tpd_up(x_history[cinfo.count], y_history[cinfo.count], 0); input_sync(tpd->dev); } } while (!kthread_should_stop()); return 0; }
static int touch_event_handler(void *para) { int i; tinno_ts_point touch_point[TINNO_TOUCH_TRACK_IDS]; struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; tinno_ts_data *ts = (tinno_ts_data *)para; sched_setscheduler(current, SCHED_RR, ¶m); do { set_current_state(TASK_INTERRUPTIBLE); wait_event_interruptible(waiter, tpd_flag!=0); tpd_flag = 0; memset(touch_point, FTS_INVALID_DATA, sizeof(touch_point)); set_current_state(TASK_RUNNING); //LINE<JIRA_ID><DATE20130320><BUG_INFO>zenghaihui if(g_tp_charger_flag != g_pre_tp_charger_flag) { g_pre_tp_charger_flag = g_tp_charger_flag; g_need_refresh_tp_flag = 1; } if(g_need_refresh_tp_flag) { g_need_refresh_tp_flag = 0; fts_ft5316_switch_charger_status(g_tp_charger_flag); } if (!tpd_touchinfo(ts, &touch_point)) { if(ts->pcount > 0) { for ( i=0; i < ts->pcount; i++ ) { tpd_down(ts, touch_point[i].x, touch_point[i].y, touch_point[i].pressure, touch_point[i].touch_id);//<20120714><for multi-touch id>wangyanhui } input_sync(tpd->dev); } else { tpd_up(ts, touch_point[0].x, touch_point[0].y, touch_point[0].pressure, touch_point[0].touch_id); input_sync(tpd->dev); } } mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); }while(!kthread_should_stop()); mt65xx_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); return 0; }
void oem_gpio_irq_unmask(int gpio) { int irq; irq = oem_gpio_to_irq(gpio); if(irq < 0){ return ; } mt65xx_eint_unmask(irq); }
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0;// ret = -1; #ifdef TPD_NO_GPIO u16 temp; temp = *(volatile u16 *) TPD_RESET_PIN_ADDR; temp = temp | 0x40; *(volatile u16 *) TPD_RESET_PIN_ADDR = temp; #endif i2c_client = client; printk("MediaTek touch panel i2c probe\n"); #ifndef TPD_NO_GPIO mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(10); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE); 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); #endif msleep(50); I2CDMABuf_va = (u8 *)dma_alloc_coherent(NULL, 4096, &I2CDMABuf_pa, GFP_KERNEL); if(!I2CDMABuf_va) { printk("Allocate Touch DMA I2C Buffer failed!\n"); return -1; } 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); } tpd_load_status = 1; mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); printk("MediaTek touch panel i2c probe success\n"); return 0; }
static void hall_init_hw(void) { mt_set_gpio_mode(GPIO_MHALL_EINT_PIN, GPIO_MHALL_EINT_PIN_M_EINT); mt_set_gpio_dir(GPIO_MHALL_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_MHALL_EINT_PIN, GPIO_PULL_DISABLE); mt_set_gpio_ies(GPIO_MHALL_EINT_PIN, GPIO_IES_ENABLE); mt65xx_eint_set_sens(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_SENSITIVE); mt65xx_eint_set_polarity(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_POLARITY); mt65xx_eint_set_hw_debounce(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_CN); mt65xx_eint_registration(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_EN, CUST_EINT_MHALL_POLARITY, hall_cover_eint_handler, 0); mt65xx_eint_unmask(CUST_EINT_MHALL_NUM); }
//void tpd_resume(struct i2c_client *client) static void tpd_resume( struct early_suspend *h ) { int ret = 0; unsigned char Wrbuf[2] = {0x14, 0x00}; i2c_client->addr = ( i2c_client->addr & I2C_MASK_FLAG ) | I2C_ENEXT_FLAG; ret = i2c_master_send(i2c_client, Wrbuf, 2); if(ret != sizeof(Wrbuf)) { TPD_DEBUG("[mtk-tpd] i2c write communcate error during resume: 0x%x\n", ret); } mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); tpd_halt = 0; }
static ssize_t pn544_dev_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) { struct pn544_dev *pn544_dev; int ret, i; char tmp[MAX_BUFFER_SIZE]; pn544_dev = filp->private_data; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; if (copy_from_user(tmp, buf, count)) { pr_err("pn544 %s : failed to copy from user space\n", __func__); return -EFAULT; } printk("pn544 copy from user:"******" %02X", tmp[i]); } printk("\n"); if (pn544_dev->irq_enabled) { mt65xx_eint_mask(EINT_NUM); pn544_dev->irq_enabled = false; printk("pn544 write mask eint\n"); } printk("pn544 %s : writing %zu bytes.\n", __func__, count); /* Write data */ ret = i2c_master_send(pn544_dev->client, tmp, count); if (ret != count) { pr_err("pn544 %s : i2c_master_send returned %d\n", __func__, ret); ret = -EIO; } printk("pn544 PC->IFD:"); for(i = 0; i < count; i++) { printk(" %02X", tmp[i]); } printk("\n"); if (!pn544_dev->irq_enabled) { mt65xx_eint_unmask(EINT_NUM); pn544_dev->irq_enabled = true; printk("pn544 write unmask eint\n"); } return ret; }
void mt8193_nlh_impl(void) { u32 u4Data; u8 bData, bData1; u8 bMask; //read register and then assert which interrupt occured mt8193_i2c_read(0x1508, &u4Data); mt8193_i2c_write(0x1504, 0xffffffff); MT8193_DRV_LOG("0x1508 = 0x%08x\n", u4Data); if(u4Data&0x20) { MT8193_CEC_LOG("cec interrupt\n"); if(mt8193_cec_on==1) { if(mt8193_cec_isrprocess(mt8193_rxcecmode)) { vNotifyAppHdmiState(HDMI_PLUG_IN_CEC); } } } if(u4Data&0x4) { bCheckHDCPStatus(0xfb); bData=bReadGRLInt(); if(bData&INT_HDCP) { MT8193_HDCP_LOG("hdcp interrupt\n"); bClearGRLInt(INT_HDCP); } else if(bData&INT_MDI) { MT8193_PLUG_LOG("hdmi interrupt\n"); bClearGRLInt(INT_MDI); bMask = bReadHdmiIntMask(); //vWriteHdmiIntMask((0xfd));//INT mask MDI } } mt65xx_eint_unmask(CUST_EINT_EINT_HDMI_HPD_NUM); }
/* * 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 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; }
void hdmi_drv_power_on(void) { HDMI_FUNC(); mt65xx_eint_mask(CUST_EINT_HDMI_HPD_NUM); SiiMhlTxHwGpioResume(); pmic_config_interface(0x87,0x1,0x01,0x0); //msleep(100); SiiMhlTxHwReset(50,200); //xuecheng HalInstallCheckDeviceCB(SiiCheckDevice); HalAcquireIsrLock(); siHdmiTx_VideoSel(HDMI_720P60); siHdmiTx_AudioSel(I2S_44); SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); HalReleaseIsrLock(); mt65xx_eint_unmask(CUST_EINT_HDMI_HPD_NUM); }
static int mhl_irq_kthread(void *data) { struct sched_param param = { .sched_priority = RTPM_PRIO_SCRN_UPDATE }; sched_setscheduler(current, SCHED_RR, ¶m); for( ;; ) { wait_event_interruptible(mhl_irq_wq, atomic_read(&mhl_irq_event)); printk("mhl_irq_kthread, mhl irq received\n"); //hdmi_update_impl(); atomic_set(&mhl_irq_event, 0); SiiMhlTxDeviceIsr(); if (kthread_should_stop()) break; mt65xx_eint_unmask(CUST_EINT_MHL_NUM); } return 0; }
/* Function to manage power-on resume */ void tpd_resume(struct early_suspend *h) { char buffer[8]; if(tpd_debuglog==1) { TPD_DMESG("[mtk-tpd] %s\n", __FUNCTION__); } // msleep(100); #ifdef TPD_POWER_SOURCE_CUSTOM hwPowerOn(TPD_POWER_SOURCE_CUSTOM, VOL_2800, "TP"); #endif #ifdef TPD_POWER_SOURCE_1800 hwPowerOn(TPD_POWER_SOURCE_1800, VOL_1800, "TP"); #endif #ifdef GPIO_CTP_EN_PIN mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE); #endif msleep(1); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(1); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE); msleep(100); buffer[0] = 0x00; buffer[1] = 0x03; i2c_master_send(i2c_client,buffer,2); msleep(50); buffer[0] = 0x00; buffer[1] = 0x05; i2c_master_send(i2c_client,buffer,2); //status = i2c_master_recv(i2c_client, buffer, 3); msleep(50); buffer[0] = 0x00; buffer[1] = 0x21; buffer[2] = 0x07; buffer[3] = 0x01; buffer[4] = 0x00; i2c_master_send(i2c_client,buffer,5); msleep(50); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); tpd_halt = 0; }
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_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: mt65xx_eint_unmask(CUST_EINT_WIFI_NUM); break; case PIN_STA_EINT_DIS: mt65xx_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; }
static void hall_eint_work_callback(struct work_struct *work) { bool cover; u8 old_state = hall_cover_state; mt65xx_eint_mask(CUST_EINT_MHALL_NUM); DOCK_DEBUG("[hall] hall_cover_state = %d\n", hall_cover_state ); hall_cover_state = !mt_get_gpio_in(GPIO_MHALL_EINT_PIN); if ( old_state == hall_cover_state ) { DOCK_ERR("[hall] no hall state changed!!!\n"); //mt65xx_eint_unmask(CUST_EINT_MHALL_NUM); //return; } switch_set_state((struct switch_dev *)&hall_data, hall_cover_state); //input_report_switch(kpd_input_dev, SW_LID, hall_cover_state); //input_sync(kpd_input_dev); mt65xx_eint_set_polarity(CUST_EINT_MHALL_NUM, !old_state); mt65xx_eint_unmask(CUST_EINT_MHALL_NUM); }
long open_nfc_custom_ioctl_connect(struct file *filp, unsigned int cmd, unsigned long arg) { struct open_nfc_custom_device *p_device = filp->private_data; int retval = 0; ENTER(); if (!p_device) { printk("open_nfc_custom_ioctl_connect: Internal error p_device is missing\n"); return -ENODEV; } mutex_lock(&p_device->mutex); if (p_device->state != CUSTOM_CONFIGURED) { printk("CONNECT called while device was not configured / already connected\n"); retval = -EALREADY; goto end; } p_device->state = CUSTOM_READY; /* start collecting the received messages */ p_device->rx_listener = 1; #ifndef WAKE_AND_PURGE_I2C_ON_LOAD // enable_irq(p_device->irqout); mt65xx_eint_unmask(CUST_EINT_NFC_NUM); #endif /* WAKE_AND_PURGE_I2C_ON_LOAD */ end: mutex_unlock(&p_device->mutex); return retval; }
static ssize_t pn544_dev_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { struct pn544_dev *pn544_dev = filp->private_data; int ret,i; char tmp[MAX_BUFFER_SIZE]; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; printk("pn544 %s : reading %zu bytes.\n", __func__, count); mutex_lock(&pn544_dev->read_mutex); if (!mt_get_gpio_in(IRQ_PIN)) { printk("pn544 read no event\n"); if (filp->f_flags & O_NONBLOCK) { ret = -EAGAIN; goto fail; } printk("pn544 read wait event\n"); pn544_dev->irq_enabled = true; mt65xx_eint_unmask(EINT_NUM); ret = wait_event_interruptible(pn544_dev->read_wq, mt_get_gpio_in(IRQ_PIN)); pn544_disable_irq(pn544_dev); if (ret) { printk("pn544 read wait event error\n"); goto fail; } } /* Read data */ ret = i2c_master_recv(pn544_dev->client, tmp, count); mutex_unlock(&pn544_dev->read_mutex); if (ret < 0) { pr_err("pn544 %s: i2c_master_recv returned %d\n", __func__, ret); return ret; } if (ret > count) { pr_err("pn544 %s: received too many bytes from i2c (%d)\n", __func__, ret); return -EIO; } if (copy_to_user(buf, tmp, ret)) { pr_warning("pn544 %s : failed to copy to user space\n", __func__); return -EFAULT; } printk("pn544 IFD->PC:"); for(i = 0; i < ret; i++) { printk(" %02X", tmp[i]); } printk("\n"); return ret; fail: mutex_unlock(&pn544_dev->read_mutex); return ret; }
void cm_enable_ext_md_wakeup_irq(void) { mt65xx_eint_unmask(CUST_EINT_DT_EXT_MD_WK_UP_NUM); }
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0; char buffer[2]; int status=0; i2c_client = client; TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe ++++\n"); #ifdef TPD_NO_GPIO u32 temp; temp = *(volatile u32 *) TPD_GPIO_GPO_ADDR; //temp = temp | 0x40; temp = temp |(1<<16) ; temp = temp |(1<<17); //temp = (temp | 1<<16); //mt65xx_reg_sync_write(TPD_GPIO_GPO_ADDR, temp); //*(volatile u32 *) TPD_GPIO_GPO_ADDR = temp; printk("TPD_GPIO_GPO_ADDR:0x%x\n", *(volatile u32 *) TPD_GPIO_GPO_ADDR); temp = *(volatile u32 *) TPD_GPIO_OE_ADDR; //temp = temp | 0x40; temp = temp |(1<<16) ; temp = temp |(1<<17); //temp = (temp | 1<<16) ; //mt65xx_reg_sync_write(TPD_GPIO_OE_ADDR, temp); // *(volatile u32 *) TPD_GPIO_OE_ADDR = temp; printk("TPD_GPIO_OE_ADDR:0x%x\n", *(volatile u32 *) TPD_GPIO_OE_ADDR); #endif #ifndef TPD_NO_GPIO mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(10); mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE); // mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); // mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); // mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE); // msleep(10); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(1); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE); 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); #endif msleep(50); // buffer[0]=0x00; // i2c_client->ext_flag = I2C_WR_FLAG; // status=i2c_master_send(i2c_client ,buffer, 0x101); TPD_DMESG("1...........\n"); status = i2c_smbus_read_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0])); if(status<0) { TPD_DMESG("fwq read error\n"); TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe failed!!\n"); status = i2c_smbus_read_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0])); if(status<0) { TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe retry failed!!\n"); return status; } } TPD_DMESG("fwq buffer=%x \n",buffer[0]); TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe success!!\n"); tpd_load_status = 1; if ((buffer[0] & 0x70) != 0x00) { buffer[0] = 0x00; // switch to operation mode i2c_smbus_write_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0])); if(status < 0) { TPD_DMESG("fwq write error\n"); } msleep(50); } 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); } #ifndef POLL_MODE //mt6575t fpga debug 0: enable polling mode mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); TPD_DMESG("EINT num=%d\n",CUST_EINT_TOUCH_PANEL_NUM); #endif TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe ----\n"); return 0; }
static void mtk_wcn_cmb_sdio_enable_eirq(void) { mt65xx_eint_unmask(mtk_wcn_cmb_sdio_eint_num);/* CUST_EINT_WIFI_NUM */ }
static int gt927_diffdata_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int driving_num = 0; int sensing_num = 0; int i; char *ptr = page; u8 *buf; mt65xx_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); driving_num += (config[27 + GTP_ADDR_LENGTH] & 0x1F); driving_num += (config[28 + GTP_ADDR_LENGTH] & 0x1F); sensing_num += (config[29 + GTP_ADDR_LENGTH] & 0x0F); sensing_num += (config[29 + GTP_ADDR_LENGTH] & 0xF0) >> 4; GTP_INFO("TPD driving_num %d", driving_num); GTP_INFO("TPD sensing_num %d", sensing_num); buf = (u8 *)kzalloc(driving_num * sensing_num, GFP_KERNEL); //0x8040 write 1 for rawdata/diff access buf[0] = 1; i2c_write_bytes(i2c_client_point, GTP_REG_SLEEP, buf, 1); // wait for normal INT finished while (tpd_flag == 1) { msleep(20); } msleep(100); //check for raw data ready i2c_read_bytes(i2c_client_point, GTP_READ_COOR_ADDR, buf, 1); while (buf[0] == 0) { //wait for data ready GTP_INFO("Wati for raw data"); i2c_read_bytes(i2c_client_point, GTP_READ_COOR_ADDR, buf, 1); GTP_INFO("0x814E : %2X", buf[0]); buf[0] &= 0x80; msleep(5); } i2c_read_bytes(i2c_client_point, GTP_DIFFDATA_REG, buf, driving_num * sensing_num); for (i = 0 ; i < driving_num * sensing_num; i = i + 1) { ptr += sprintf(ptr, "%d\t", buf[i]); if ((i % (sensing_num)) == (sensing_num - 1)) ptr += sprintf(ptr, "\n"); } //clear data ready status buf[0] = 0; i2c_write_bytes(i2c_client_point, GTP_READ_COOR_ADDR, buf, 1); //0x8040 write 0 for leaving rawdata/diff access mode buf[0] = 0; i2c_write_bytes(i2c_client_point, GTP_REG_SLEEP, buf, 1); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); kfree(buf); *eof = 1; return (ptr - page); }
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0; TPD_DEBUG("ft5316 tpd_i2c_probe\n"); if (ft5316_i2c_client != NULL) return 1; ft5316_i2c_client = client; TPD_DEBUG("ft5316_i2c_client addr ==== %X \n", ft5316_i2c_client->addr); tinno_tp_power_off(); tinno_tp_power_on(); int i = 0; while(i++ <5){ err=tinno_ts_get_fw_version(); TPD_DEBUG("Product version ==== %X \n", panel_version); if(err > 0) break; else continue; } if ( err < 0 ){ TPD_DEBUG("Product version %X is invalid.\n", panel_version); goto err_detect_failed; } tpd_load_status = 1; /* added in android 2.2, for configuring EINT2 */ mt_set_gpio_mode(TPIO_EINT, GPIO_CTP_EINT_PIN_M_EINT); mt_set_gpio_pull_enable(TPIO_EINT, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(TPIO_EINT,GPIO_PULL_UP); mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1); mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); mutex_init(&tp_mutex); #ifdef CONFIG_TOUCHSCREEN_FT5X05_SUPPORT_ISP magnum_fts_isp_register(ft5316_i2c_client); #endif/*CONFIG_TOUCHSCREEN_FT5X05_SUPPORT_ISP*/ tpd_status = 1; thread = kthread_run(touch_event_handler, 0, TPD_DEVICE); if (IS_ERR(thread)) { err = PTR_ERR(thread); TPD_DEBUG(TPD_DEVICE " failed to create kernel thread: %d\n", err); } //edit by Magnum 2012-12-25 #ifdef TP_AUTO_UPGRADE focaltech_auto_upgrade(); #endif TPD_DEBUG("tpd_i2c_probe OK\n"); return 0; err_detect_failed: TPD_DEBUG("tpd_i2c_probe ERROR\n"); ft5316_i2c_client = NULL; tinno_tp_power_off(); return 1; }