static void star_proxi_interrupt_handler(void *arg) { //When VOUT terminal changes from H to L, enter the this function --> procedure 3 s_proximity.MVO++; //Update the MVO value if( (s_proximity.MVO & 1) == 0 ) { printk("Even Number INT, MVO = %d\n", s_proximity.MVO); s_proximity.MVO = 0; } else { printk("Odd Number INT, MVO = %d\n", s_proximity.MVO); s_proximity.MVO = 1; } NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_TRUE); //Procedure 4 if(s_proximity.MVO == 1) star_proxi_write_reg(&s_proximity, 0x02, 0x00 ); else star_proxi_write_reg(&s_proximity, 0x02, 0x20 ); star_proxi_write_reg(&s_proximity, 0x06, 0x18 ); #if STAR_PROX_DEBUG printk("PROX interrupt!!!\n"); printk("PROX interrupt!!!\n"); #endif schedule_work(&s_proximity.work); NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_FALSE); NvOdmGpioInterruptDone(s_proximity.proxi_out_intr); }
NvBool Synaptics_OneTouch_PowerOnOff (NvOdmOneTouchDeviceHandle hDevice, NvBool OnOff) { // 20101120 [email protected] power off when Onetouch close #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime; Synaptics_OneTouch_Device* hTouch = (Synaptics_OneTouch_Device*)hDevice; hTouch->hPmu = NvOdmServicesPmuOpen(); printk("[ONETOUCH] Synaptics_OneTouch_PowerOnOff\n"); if (!hTouch->hPmu) { printk("[ONETOUCH] NvOdmServicesPmuOpen Error\n"); return NV_FALSE; } NvOdmServicesPmuGetCapabilities( hTouch->hPmu, hTouch->VddId, &vddrailcap); printk("[ONETOUCH] power on[%d], vol[%d]\n", OnOff, vddrailcap.requestMilliVolts); if(OnOff) { // 20101223 [email protected] [SU660] block touch interrupt when onetouch is on reset [START] #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) if(hGpioIntr_touch) NvOdmGpioInterruptMask(hGpioIntr_touch, NV_TRUE); #endif // 20101223 [email protected] [SU660] block touch interrupt when onetouch is on reset [END] NvOdmServicesPmuSetVoltage( hTouch->hPmu, hTouch->I2cVddId, NVODM_VOLTAGE_OFF, &settletime); NvOdmOsWaitUS(SYNAPTICS_POR_DELAY_MS*1000); // wait to settle power NvOdmServicesPmuSetVoltage( hTouch->hPmu, Max8907PmuSupply_LDO16, NVODM_VOLTAGE_OFF, &settletime); NvOdmOsWaitUS(SYNAPTICS_POR_DELAY_MS*2*1000); // wait to settle power NvOdmServicesPmuSetVoltage( hTouch->hPmu, Max8907PmuSupply_LDO16, MAX8907_REQUESTVOLTAGE_LDO16, &settletime); NvOdmServicesPmuSetVoltage( hTouch->hPmu, hTouch->I2cVddId, MAX8907_REQUESTVOLTAGE_LDO19, &settletime); // 20101223 [email protected] [SU660] block touch interrupt when onetouch is on reset [START] #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) if(hGpioIntr_touch) NvOdmGpioInterruptMask(hGpioIntr_touch, NV_FALSE); #endif // 20101223 [email protected] [SU660] block touch interrupt when onetouch is on reset [END] }else NvOdmServicesPmuSetVoltage( hTouch->hPmu, Max8907PmuSupply_LDO16, NVODM_VOLTAGE_OFF, &settletime); NvOdmOsWaitUS(SYNAPTICS_POR_DELAY_MS*5*1000); // wait to settle power NvOdmServicesPmuClose(hTouch->hPmu); #endif return NV_TRUE; }
static int proximity_resume(struct platform_device *pdev) { if (!proxi_enabled) return 0; if (s_proximity.wakeup_while_sleep) NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_FALSE); if (hrtimer_try_to_cancel(&s_proximity.timer) == 0) hrtimer_start(&s_proximity.timer, ktime_set(0, s_proximity.delay), HRTIMER_MODE_REL); if (!s_proximity.wakeup_while_sleep) NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_TRUE); return 0; }
static void star_proxi_enable(ProximityDevice *data) { if (proxi_enabled == true) return; //star_proxi_power_onoff(data, true); star_proxi_i2c_init_write(); //Initail Operation, Procedure 1, see the 25page GP2AP datasheet s_proximity.MVO = 0; if (data->use_int_mode) NvOdmGpioInterruptMask(data->proxi_out_intr, NV_FALSE);//Interrupt Enable(NV_FALSE) Procedure 2 else hrtimer_start(&data->timer, ktime_set(1, 0), HRTIMER_MODE_REL); proxi_enabled = true; atomic_set(&proxi_status, 1); input_report_abs(s_proximity.input_dev, ABS_DISTANCE, atomic_read(&proxi_status)); input_sync(s_proximity.input_dev); }
static NvBool EETI_Resume(NvOdmTouchDeviceHandle hDevice) { EETI_TouchDevice* hTouch = (EETI_TouchDevice*)hDevice; if (hDevice == NULL) { return NV_FALSE; } #if 0 NvOdmGpioInterruptMask(hTouch->hGpioIntr, NV_TRUE); NvOdmGpioInterruptUnregister(hTouch->hGpio, hTouch->hPin, hTouch->hGpioIntr); #endif NvOdmGpioConfig(hTouch->hGpio, hTouch->hPin, NvOdmGpioPinMode_Output); /* Send reset pulse to touch HW */ NvOdmGpioSetState(hTouch->hGpio, hTouch->hPin, 1); NvOsWaitUS(50); NvOdmGpioSetState(hTouch->hGpio, hTouch->hPin, 0); NvOsSleepMS(50); NvOdmGpioSetState(hTouch->hGpio, hTouch->hPin, 1); NvOdmGpioConfig(hTouch->hGpio, hTouch->hPin, NvOdmGpioPinMode_InputInterruptLow); #if 0 if (NvOdmGpioInterruptRegister(hTouch->hGpio, &hTouch->hGpioIntr, hTouch->hPin, NvOdmGpioPinMode_InputInterruptLow, EETI_GpioIsr, (void*)hTouch, EETI_DEBOUNCE_TIME_MS) == NV_FALSE) { return NV_FALSE; } #endif return NV_TRUE; }
static void star_proxi_sleep_handler(void *arg) { NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_FALSE); input_report_key(s_proximity.input_dev, KEY_POWER, 1); input_sync(s_proximity.input_dev); input_report_key(s_proximity.input_dev, KEY_POWER, 0); input_sync(s_proximity.input_dev); }
static int h2w_switch_resume(struct platform_device *pdev) { struct h2w_switch_dev *hsdev; hsdev = (struct h2w_switch_dev *)platform_get_drvdata(pdev); if (hsdev != NULL) { queue_work(hsdev->workqueue, &hsdev->work); NvOdmGpioInterruptMask(hsdev->hp_det_irq, NV_FALSE); } return 0; }
static int h2w_switch_suspend(struct platform_device *pdev, pm_message_t state) { struct h2w_switch_dev *hsdev; hsdev = (struct h2w_switch_dev *)platform_get_drvdata(pdev); if (hsdev != NULL) { NvOdmGpioInterruptMask(hsdev->hp_det_irq, NV_TRUE); cancel_work_sync(&hsdev->work); } return 0; }
void Synaptics_OneTouch_InterruptMask(NvOdmOneTouchDeviceHandle hDevice, NvBool mask) { /* If mask is NV_TRUE, then disable irq. If mask is NV_FALSE, then enable irq. */ Synaptics_OneTouch_Device* hTouch = (Synaptics_OneTouch_Device*)hDevice; if (hTouch->hGpioIntr) { NvOdmGpioInterruptMask(hTouch->hGpioIntr, mask); printk("[ONETOUCH] Synaptics_OneTouch_InterruptMask by %d\n", mask); } }
static int proximity_suspend(struct platform_device *pdev, pm_message_t state) { if (!proxi_enabled) return 0; if (atomic_read(&proxi_status)) return 0; if (hrtimer_try_to_cancel(&s_proximity.timer) > 0) hrtimer_cancel(&s_proximity.timer); if (s_proximity.wakeup_while_sleep) NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_TRUE); else star_proxi_disable(&s_proximity); return 0; }
static void star_proxi_disable(ProximityDevice *data) { if (proxi_enabled == false) return; if (data->use_int_mode) NvOdmGpioInterruptMask(data->proxi_out_intr, NV_TRUE);//Interrupt Disable(NV_TRUE) else hrtimer_cancel(&data->timer); cancel_work_sync(&data->work); //go to shutdown star_proxi_write_reg(&s_proximity, 0x04, 0x02 ); s_shutdown_mode = true; //star_proxi_power_onoff(data, false); // NvOdmGpioInterruptUnregister( s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, star_proxi_interrupt_handler); proxi_enabled = false; }
static int __init proximity_probe(struct platform_device *pdev) { int i, ret = 0; NvU32 I2cInstance = 0; const NvOdmPeripheralConnectivity *pConnectivity = NULL; NvU32 port = 0, pin = 0; struct device *dev = &pdev->dev; unsigned int pinvalue; atomic_set(&proxi_status, 1); pConnectivity = NvOdmPeripheralGetGuid(PROXIMITY_GUID); for (i = 0; i < pConnectivity->NumAddress; i++) { switch (pConnectivity->AddressList[i].Interface) { case NvOdmIoModule_I2c: s_proximity.i2c_address = (pConnectivity->AddressList[i].Address << 1); I2cInstance = pConnectivity->AddressList[i].Instance; break; case NvOdmIoModule_Gpio: port = pConnectivity->AddressList[i].Instance; pin = pConnectivity->AddressList[i].Address; break; case NvOdmIoModule_Vdd: s_proximity.vddId = pConnectivity->AddressList[i].Address; break; default: break; } } s_proximity.MVO = 0; #if defined(CONFIG_MACH_STAR_MDM_C) port = 'r' - 'a';//'a' - 'a'; pin = 2;//0; #elif defined (CONFIG_MACH_STAR_REV_F) || defined (CONFIG_MACH_STAR_TMUS) port = 'w'-'a'; pin = 2; #else #error PROXI_OUT PIN not assigned #endif lprintk(D_PROXI, "[star Proximity] start!!!--------------------------------------------------------------------------\n"); s_proximity.proxi_out_gpio = NvOdmGpioOpen(); if (!s_proximity.proxi_out_gpio) { lprintk(D_PROXI, "[star Proximity] gpio open fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); ret = -ENOSYS; goto err_open_gpio_fail; } s_proximity.proxi_out_gpio_pin = NvOdmGpioAcquirePinHandle(s_proximity.proxi_out_gpio, port, pin); if (!s_proximity.proxi_out_gpio_pin) { lprintk(D_PROXI, "[star Proximity] gpio pin acquire fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); ret = -ENOSYS; goto err_open_gpio_pin_acquire_fail; } // NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1); // NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputData); #if 1 INIT_WORK(&s_proximity.work, star_proxi_workqueue_func); s_proximity.gen2_i2c = NvOdmI2cPinMuxOpen(NvOdmIoModule_I2c, 1, NvOdmI2cPinMap_Config2); if (!s_proximity.gen2_i2c) { lprintk(D_PROXI, "[star Proximity] i2c open fail!\n"); ret = -ENOSYS; goto err_open_i2c_handle_fail; } s_proximity.use_int_mode = true; #if 0 NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_Output); NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1); NvOdmOsWaitUS(100000);//100ms NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue); printk("interrupt pin level = %d\n----------------", pinvalue ); NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0); NvOdmOsWaitUS(100000);//100ms NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue); printk("interrupt pin level = %d\n----------------", pinvalue ); NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1); NvOdmOsWaitUS(100000);//100ms NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue); printk("interrupt pin level = %d\n----------------", pinvalue ); NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0); NvOdmOsWaitUS(100000);//100ms NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue); printk("interrupt pin level = %d\n----------------", pinvalue ); NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1); NvOdmOsWaitUS(100000);//100ms NvOdmGpioGetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, &pinvalue); printk("interrupt pin level = %d\n----------------", pinvalue ); #endif #if 0 while(1) { NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x1); NvOdmOsWaitUS(100000);//100ms NvOdmGpioSetState(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, 0x0); NvOdmOsWaitUS(100000);//100ms } #endif NvOdmGpioConfig(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputData); if (s_proximity.use_int_mode == true) { if (NvOdmGpioInterruptRegister(s_proximity.proxi_out_gpio, &s_proximity.proxi_out_intr, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputInterruptLow, star_proxi_interrupt_handler, (void*)&s_proximity, 0) == NV_FALSE) { lprintk(D_PROXI, "[star Proximity] interrupt register fail!\n"); ret = -ENOSYS; goto err_open_irq_handle_fail; } } else { if (NvOdmGpioInterruptRegister(s_proximity.proxi_out_gpio, &s_proximity.proxi_out_intr, s_proximity.proxi_out_gpio_pin, NvOdmGpioPinMode_InputInterruptFallingEdge, star_proxi_sleep_handler, (void*)&s_proximity, 0) == NV_FALSE) { lprintk(D_PROXI, "[star Proximity] interrupt register fail!\n"); ret = -ENOSYS; goto err_open_irq_handle_fail; } hrtimer_init(&s_proximity.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); s_proximity.timer.function = star_proxi_timer_func; s_proximity.delay = PROXI_DEFAULT_DELAY_NS; } NvOdmGpioInterruptMask(s_proximity.proxi_out_intr, NV_TRUE); s_proximity.input_dev = input_allocate_device(); if (!s_proximity.input_dev) { lprintk(D_PROXI, "[star Proximity] input device alloc fail!\n"); ret = -ENOMEM; goto err_alloc_input_device_fail; } set_bit(EV_KEY, s_proximity.input_dev->evbit); set_bit(KEY_POWER, s_proximity.input_dev->keybit); set_bit(EV_ABS, s_proximity.input_dev->evbit); input_set_abs_params(s_proximity.input_dev, ABS_DISTANCE, 0, 1, 0, 0); s_proximity.input_dev->name = "proximity"; ret = input_register_device(s_proximity.input_dev); if (ret) { lprintk(D_PROXI, "[star Proximity] input device register fail!\n"); ret = -ENOMEM; goto err_alloc_input_device_fail; } if ((ret = sysfs_create_group(&dev->kobj, &star_proxi_group))) { lprintk(D_PROXI, "[star Proximity] sysfs_create_group fail!\n"); ret = -ENOMEM; goto err_sysfs_group_fail; } // star_proxi_power_onoff(&s_proximity, true); return 0; err_sysfs_group_fail: input_unregister_device(s_proximity.input_dev); err_alloc_input_device_fail: NvOdmGpioInterruptUnregister(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin, s_proximity.proxi_out_intr); err_open_irq_handle_fail: NvOdmI2cClose(s_proximity.gen2_i2c); err_open_i2c_handle_fail: NvOdmGpioReleasePinHandle(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin); err_open_gpio_pin_acquire_fail: NvOdmGpioClose(s_proximity.proxi_out_gpio); err_open_gpio_fail: return ret; #endif }
void NvOdmEcompasspioInterruptUnMask(NvOdmEcompassHandle hDevice){ NvOdmGpioInterruptMask(hDevice->hGpioInterrupt, NV_FALSE); }