int c2k_gpio_set_irq_type(int gpio, unsigned int type) { int irq, level; irq = c2k_gpio_to_irq(gpio); if (irq < 0) return irq; level = c2k_gpio_get_value(gpio); if (type == IRQ_TYPE_EDGE_BOTH) { if (level) type = IRQ_TYPE_EDGE_FALLING; else type = IRQ_TYPE_EDGE_RISING; } if (type == IRQ_TYPE_LEVEL_MASK) { if (level) type = IRQ_TYPE_LEVEL_LOW; else type = IRQ_TYPE_LEVEL_HIGH; } #ifndef CONFIG_EVDO_DT_VIA_SUPPORT c2k_irq_set_type(irq, type); #endif #if defined(CONFIG_MTK_LEGACY) mt_eint_set_hw_debounce(irq, 0); switch (type) { case IRQ_TYPE_EDGE_RISING: mt_eint_set_sens(irq, MT_EDGE_SENSITIVE); mt_eint_set_polarity(irq, MT_POLARITY_HIGH); break; case IRQ_TYPE_EDGE_FALLING: mt_eint_set_sens(irq, MT_EDGE_SENSITIVE); mt_eint_set_polarity(irq, MT_POLARITY_LOW); break; case IRQ_TYPE_LEVEL_HIGH: mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE); mt_eint_set_polarity(irq, MT_POLARITY_HIGH); break; case IRQ_TYPE_LEVEL_LOW: mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE); mt_eint_set_polarity(irq, MT_POLARITY_LOW); break; default: return -EINVAL; } #else gpio_set_debounce(gpio, 0); irq_set_irq_type(irq, type); #endif /*pr_debug("[C2K]set irq(%d) type(%d) done\n", irq, type); */ return 0; }
int swtp_mod_eint_init(void) { int init_value = 0; unsigned int init_flag = CUST_EINTF_TRIGGER_HIGH; mt_set_gpio_mode(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_MODE); mt_set_gpio_dir(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_DIR); mt_set_gpio_pull_enable(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_PULL); init_value = mt_get_gpio_in(SWTP_GPIO_EINT_PIN); if(init_value == SWTP_TRIGGERING) { init_flag = SWTP_OPPOSE_EINT_TYPE; //CUST_EINTF_TRIGGER_LOW; swtp_eint_state = EINT_PIN_PLUG_IN; } else { init_flag = SWTP_EINT_TYPE; //CUST_EINTF_TRIGGER_HIGH; swtp_eint_state = EINT_PIN_PLUG_OUT; } mt_eint_set_sens(SWTP_EINT_NUM, SWTP_SENSITIVE_TYPE); mt_eint_set_hw_debounce(SWTP_EINT_NUM, SWTP_DEBOUNCE_CN); mt_eint_registration(SWTP_EINT_NUM, init_flag, swtp_eint_handler, 0); return 0; }
static void och165twad_mhall_eint_config_polarity(u8 polarity) { MHALL_ERR("%s: penny \n", __func__); 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_eint_set_sens(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_SENSITIVE); mt_eint_set_hw_debounce(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_CN); mt_eint_registration(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_TYPE, och165twad_mhall_eint_interrupt_handler, 0); mt_eint_unmask(CUST_EINT_MHALL_NUM); }
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_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 void bq24196_irq_init(void) { int ret; /*unmask CHRG_FAULT and BAT_FAULT */ ret = bq24196_i2c_update_reg(bq_data, BQ24196_REG_MISC_CONTROL, 0x3, 0x3); mt_set_gpio_dir(GPIO_BQ_INT_PIN, GPIO_DIR_IN); mt_set_gpio_mode(GPIO_BQ_INT_PIN, GPIO_MODE_00); mt_eint_set_sens(GPIO_BQ_INT_NUM, MT_LEVEL_SENSITIVE); mt_eint_registration(GPIO_BQ_INT_NUM, EINTF_TRIGGER_LOW, bq24196_irq_handler, 0); mt_eint_unmask(GPIO_BQ_INT_NUM); }
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 }
static int kpd_pdrv_probe(struct platform_device *pdev) { int i, r; int err = 0; #ifdef CONFIG_OF kp_base = of_iomap(pdev->dev.of_node, 0); if (!kp_base) { pr_warn(KPD_SAY "KP iomap failed\n"); return -ENODEV; }; kp_irqnr = irq_of_parse_and_map(pdev->dev.of_node, 0); if (!kp_irqnr) { pr_warn(KPD_SAY "KP get irqnr failed\n"); return -ENODEV; } pr_warn(KPD_SAY "kp base: 0x%p, addr:0x%p, kp irq: %d\n", kp_base,&kp_base, kp_irqnr); #endif kpd_ldvt_test_init(); /* API 2 for kpd LFVT test enviroment settings */ /* initialize and register input device (/dev/input/eventX) */ kpd_input_dev = input_allocate_device(); if (!kpd_input_dev) return -ENOMEM; kpd_input_dev->name = KPD_NAME; kpd_input_dev->id.bustype = BUS_HOST; kpd_input_dev->id.vendor = 0x2454; kpd_input_dev->id.product = 0x6500; kpd_input_dev->id.version = 0x0010; kpd_input_dev->open = kpd_open; #ifdef AEON_FCOVER_SUPPORT spin_lock_init(&fcover_lock); fcover_close_flag = 1; #endif //fulfill custom settings kpd_memory_setting(); __set_bit(EV_KEY, kpd_input_dev->evbit); #if (KPD_PWRKEY_USE_EINT || KPD_PWRKEY_USE_PMIC) __set_bit(KPD_PWRKEY_MAP, kpd_input_dev->keybit); kpd_keymap[8] = 0; #endif #if !KPD_USE_EXTEND_TYPE for (i = 17; i < KPD_NUM_KEYS; i += 9) /* only [8] works for Power key */ kpd_keymap[i] = 0; #endif for (i = 0; i < KPD_NUM_KEYS; i++) { if (kpd_keymap[i] != 0) __set_bit(kpd_keymap[i], kpd_input_dev->keybit); } #if KPD_AUTOTEST for (i = 0; i < ARRAY_SIZE(kpd_auto_keymap); i++) __set_bit(kpd_auto_keymap[i], kpd_input_dev->keybit); #endif #if KPD_HAS_SLIDE_QWERTY __set_bit(EV_SW, kpd_input_dev->evbit); __set_bit(SW_LID, kpd_input_dev->swbit); #endif #ifdef KPD_PMIC_RSTKEY_MAP __set_bit(KPD_PMIC_RSTKEY_MAP, kpd_input_dev->keybit); #endif #ifdef KPD_KEY_MAP __set_bit(KPD_KEY_MAP, kpd_input_dev->keybit); #endif #ifdef AEON_FCOVER_SUPPORT // __set_bit(KEY_FCOVER_1, kpd_input_dev->keybit); // __set_bit(KEY_FCOVER_2, kpd_input_dev->keybit); __set_bit(KEY_F11, kpd_input_dev->keybit); __set_bit(KEY_F12, kpd_input_dev->keybit); #endif kpd_input_dev->dev.parent = &pdev->dev; r = input_register_device(kpd_input_dev); if (r) { printk(KPD_SAY "register input device failed (%d)\n", r); input_free_device(kpd_input_dev); return r; } /* register device (/dev/mt6575-kpd) */ kpd_dev.parent = &pdev->dev; r = misc_register(&kpd_dev); if (r) { printk(KPD_SAY "register device failed (%d)\n", r); input_unregister_device(kpd_input_dev); return r; } #ifdef CONFIG_MTK_TC1_FM_AT_SUSPEND wake_lock_init(&kpd_suspend_lock, WAKE_LOCK_SUSPEND, "kpd wakelock"); #endif /* register IRQ and EINT */ kpd_set_debounce(KPD_KEY_DEBOUNCE); #ifdef CONFIG_OF r = request_irq(kp_irqnr, kpd_irq_handler, IRQF_TRIGGER_NONE, KPD_NAME, NULL); #else r = request_irq(MT_KP_IRQ_ID, kpd_irq_handler, IRQF_TRIGGER_FALLING, KPD_NAME, NULL); #endif if (r) { printk(KPD_SAY "register IRQ failed (%d)\n", r); misc_deregister(&kpd_dev); input_unregister_device(kpd_input_dev); return r; } mt_eint_register(); #ifndef KPD_EARLY_PORTING /*add for avoid early porting build err the macro is defined in custom file */ long_press_reboot_function_setting(); /* /API 4 for kpd long press reboot function setting */ #endif hrtimer_init(&aee_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); aee_timer.function = aee_timer_func; #if AEE_ENABLE_5_15 hrtimer_init(&aee_timer_5s, CLOCK_MONOTONIC, HRTIMER_MODE_REL); aee_timer_5s.function = aee_timer_5s_func; #endif if ((err = kpd_create_attr(&kpd_pdrv.driver))) { kpd_print("create attr file fail\n"); kpd_delete_attr(&kpd_pdrv.driver); return err; } pr_warn(KPD_SAY "%s Done\n", __FUNCTION__); #ifdef AEON_FCOVER_SUPPORT fcover_workqueue = create_singlethread_workqueue("fcover"); INIT_WORK(&fcover_work, fcover_key_handler); fcover_data.name = "hall"; fcover_data.index = 0; fcover_data.state = fcover_close_flag; err = switch_dev_register(&fcover_data); if(err) { printk("[Accdet]switch_dev_register returned:%d!\n", err); // return 1; } switch_set_state((struct switch_dev *)&fcover_data, fcover_close_flag); #ifdef AEON_FCOVER_SUPPORT mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_GPIO); mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_DISABLE); // mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_UP); mdelay(20); fcover_close_flag = mt_get_gpio_in(GPIO_FCOVER_EINT_PIN); // tpd_fcover_setting(fcover_close_flag); mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_EINT); mt_eint_set_sens(FCOVER_KEY_EINT, FCOVER_KEY_SENSITIVE); mt_eint_set_hw_debounce(FCOVER_KEY_EINT, FCOVER_KEY_DEBOUNCE); mt_eint_registration(FCOVER_KEY_EINT, EINTF_TRIGGER_LOW, kpd_fcover_eint_handler, 0); mt_eint_unmask(FCOVER_KEY_EINT); printk(KPD_SAY "xuqian kpd_fcover_eint_handler ..\n"); #else mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_GPIO); mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_DOWN); #endif // err = device_create_file(&(pdev->dev), &dev_attr_kpd_fcover_state); // if(err) // { // printk("create attr file dev_attr_kpd_fcover_state error\n"); //// kpd_delete_attr(&kpd_pdrv.driver); //// return err; // } // else // { // printk("create attr file dev_attr_kpd_fcover_state ok\n"); // } #endif return 0; }
static int kpd_pdrv_probe(struct platform_device *pdev) { int i, r; int err = 0; kpd_ldvt_test_init();//API 2 for kpd LFVT test enviroment settings /* initialize and register input device (/dev/input/eventX) */ kpd_input_dev = input_allocate_device(); if (!kpd_input_dev) return -ENOMEM; kpd_input_dev->name = KPD_NAME; kpd_input_dev->id.bustype = BUS_HOST; kpd_input_dev->id.vendor = 0x2454; kpd_input_dev->id.product = 0x6500; kpd_input_dev->id.version = 0x0010; kpd_input_dev->open = kpd_open; //fulfill custom settings kpd_memory_setting(); __set_bit(EV_KEY, kpd_input_dev->evbit); #if (KPD_PWRKEY_USE_EINT||KPD_PWRKEY_USE_PMIC) __set_bit(KPD_PWRKEY_MAP, kpd_input_dev->keybit); kpd_keymap[8] = 0; #endif for (i = 17; i < KPD_NUM_KEYS; i += 9) /* only [8] works for Power key */ kpd_keymap[i] = 0; for (i = 0; i < KPD_NUM_KEYS; i++) { if (kpd_keymap[i] != 0) __set_bit(kpd_keymap[i], kpd_input_dev->keybit); } #if KPD_AUTOTEST for (i = 0; i < ARRAY_SIZE(kpd_auto_keymap); i++) __set_bit(kpd_auto_keymap[i], kpd_input_dev->keybit); #endif #if KPD_HAS_SLIDE_QWERTY __set_bit(EV_SW, kpd_input_dev->evbit); __set_bit(SW_LID, kpd_input_dev->swbit); #endif #ifdef KPD_PMIC_RSTKEY_MAP __set_bit(KPD_PMIC_RSTKEY_MAP, kpd_input_dev->keybit); #endif #ifdef AEON_FCOVER_SUPPORT __set_bit(KEY_FCOVER_1, kpd_input_dev->keybit); __set_bit(KEY_FCOVER_2, kpd_input_dev->keybit); #endif kpd_input_dev->dev.parent = &pdev->dev; r = input_register_device(kpd_input_dev); if (r) { printk(KPD_SAY "register input device failed (%d)\n", r); input_free_device(kpd_input_dev); return r; } /* register device (/dev/mt6575-kpd) */ kpd_dev.parent = &pdev->dev; r = misc_register(&kpd_dev); if (r) { printk(KPD_SAY "register device failed (%d)\n", r); input_unregister_device(kpd_input_dev); return r; } /* register IRQ and EINT */ kpd_set_debounce(KPD_KEY_DEBOUNCE); r = request_irq(MT_KP_IRQ_ID, kpd_irq_handler, IRQF_TRIGGER_FALLING, KPD_NAME, NULL); if (r) { printk(KPD_SAY "register IRQ failed (%d)\n", r); misc_deregister(&kpd_dev); input_unregister_device(kpd_input_dev); return r; } #if KPD_PWRKEY_USE_EINT mt_eint_register(); #endif #ifdef AEON_FCOVER_SUPPORT printk("leanda AEON_FCOVER_SUPPORT \r\n"); mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_MODE_01); mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_UP); mt_eint_set_sens(FCOVER_KEY_EINT, FCOVER_KEY_SENSITIVE); mt_eint_set_hw_debounce(FCOVER_KEY_EINT, FCOVER_KEY_DEBOUNCE); mt_eint_registration(FCOVER_KEY_EINT, FCOVER_KEY_TYPE, kpd_fcover_eint_handler, 0); mt_eint_unmask(FCOVER_KEY_EINT); #endif //mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1); #ifndef KPD_EARLY_PORTING /*add for avoid early porting build err the macro is defined in custom file*/ long_press_reboot_function_setting();///API 4 for kpd long press reboot function setting #endif hrtimer_init(&aee_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); aee_timer.function = aee_timer_func; #if AEE_ENABLE_5_15 hrtimer_init(&aee_timer_5s, CLOCK_MONOTONIC, HRTIMER_MODE_REL); aee_timer_5s.function = aee_timer_5s_func; #endif if((err = kpd_create_attr(&kpd_pdrv.driver))) { kpd_print("create attr file fail\n"); kpd_delete_attr(&kpd_pdrv.driver); return err; } return 0; }
static int __devinit tpd_probe(struct i2c_client *client, const struct i2c_device_id *id) { int retval = TPD_OK; int panel_version = 0; int panel_vendor = 0; int iRetry = 3; tinno_ts_data *ts; int ret = 0; if ( tpd_load_status ){ CTP_DBG("Already probed a TP, needn't to probe any more!"); return -1; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev,"need I2C_FUNC_I2C"); ret = -ENODEV; goto err_check_functionality_failed; } ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } CTP_DBG("TPD enter tpd_probe ts=0x%p, TPD_RES_X=%d, TPD_RES_Y=%d, addr=0x%x\n", ts, TPD_RES_X, TPD_RES_Y, client->addr); memset(ts, 0, sizeof(*ts)); g_pts = ts; client->timing = I2C_MASTER_CLOCK; ts->client = client; ts->start_reg = 0x00; atomic_set( &ts->ts_sleepState, 0 ); mutex_init(&ts->mutex); i2c_set_clientdata(client, ts); fts_5x06_hw_init(); msleep(120); fts_iic_init(ts); if ( fts_5x06_isp_init(ts) ){ goto err_isp_register; } while (iRetry) { ret = ft5x06_get_vendor_version(ts, &panel_vendor, &panel_version); if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ TPD_DMESG("Product version is %d\n", panel_version); fts_5x06_hw_reset(); }else{ break; } iRetry--; msleep(15); } if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ goto err_get_version; } #ifdef TPD_HAVE_BUTTON tinno_update_tp_button_dim(panel_vendor); #endif #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE if ( fts_keys_init(ts) ){ fts_keys_deinit(); goto err_get_version; } #endif 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); mt_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); mt_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 0); ts->thread = kthread_run(touch_event_handler, ts, TPD_DEVICE); if (IS_ERR(ts->thread)){ retval = PTR_ERR(ts->thread); TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", retval); goto err_start_touch_kthread; } tpd_load_status = 1; mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); CTP_DBG("Touch Panel Device(%s) Probe PASS\n", fts_get_vendor_name(panel_vendor)); #if defined (TINNO_ANDROID_S9091) || defined (TINNO_ANDROID_S9050) { extern char tpd_desc[50]; extern int tpd_fw_version; sprintf(tpd_desc, "%s-%s(0x%X)", DRIVER_NAME, fts_get_vendor_name(panel_vendor),panel_vendor); tpd_fw_version = panel_version; } #endif return 0; err_start_touch_kthread: mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); err_get_version: err_isp_register: #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP hwPowerDown(MT65XX_POWER_LDO_VGP, "touch"); #endif fts_5x06_isp_exit(); mutex_destroy(&ts->mutex); g_pts = NULL; kfree(ts); err_alloc_data_failed: err_check_functionality_failed: CTP_DBG("Touch Panel Device Probe FAIL\n"); return -1; }