/** * @brief Closes the ODM device and destroys all allocated resources. * @param hOdmVibrate [IN] Opaque handle to the device. * @return None. */ void NvOdmVibClose(NvOdmVibDeviceHandle hOdmVibrate) { #if 1 /* yuyang(20100615):Close I2C handle */ if (hOdmVibrate != NULL) { NvOdmServicesPmuClose(hOdmVibrate->hOdmServicePmuDevice); hOdmVibrate->hOdmServicePmuDevice = NULL; hOdmVibrate->VddId = 0; hOdmVibrate->DeviceAddr = 0; if (hOdmVibrate->hOdmI2c) NvOdmI2cClose(hOdmVibrate->hOdmI2c); NvOsMemset(&hOdmVibrate->RailCaps, 0, sizeof(NvOdmServicesPmuVddRailCapabilities)); NvOdmOsFree(hOdmVibrate); hOdmVibrate = NULL; } #else if (hOdmVibrate != NULL) { NvOdmServicesPmuClose(hOdmVibrate->hOdmServicePmuDevice); hOdmVibrate->hOdmServicePmuDevice = NULL; hOdmVibrate->VddId = 0; NvOsMemset(&hOdmVibrate->RailCaps, 0, sizeof(NvOdmServicesPmuVddRailCapabilities)); NvOdmOsFree(hOdmVibrate); hOdmVibrate = NULL; } #endif /* __yuyang(20100615) */ }
void Pcf50626Release(NvOdmPmuDeviceHandle hDevice) { if (hDevice->pPrivate != NULL) { if (((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice != NULL) { NvOdmServicesPmuClose(((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice); ((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice = NULL; } if (((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C != NULL) { NvOdmI2cClose(((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C); ((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C = NULL; } if (((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable != NULL) { NvOdmOsFree(((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable); ((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable = NULL; } NvOdmOsFree(hDevice->pPrivate); hDevice->pPrivate = NULL; } }
void NvOdmAccelClose(NvOdmAccelHandle hDevice) { if(NULL != hDevice) { if(NULL != hDevice->SemaphoreForINT && NULL != hDevice->hGpioINT && NULL != hDevice->hPinINT && NULL != hDevice->hGpioInterrupt) { NvOdmGpioInterruptUnregister(hDevice->hGpioINT, hDevice->hPinINT, hDevice->hGpioInterrupt); NvOdmOsSemaphoreDestroy(hDevice->SemaphoreForINT); NvOdmGpioReleasePinHandle(hDevice->hGpioINT, hDevice->hPinINT); NvOdmGpioClose(hDevice->hGpioINT); } NvAccelerometerI2CClose(hDevice->hOdmI2C); // Power off accelermeter NvAccelerometerSetPowerRail(hDevice->hPmu, hDevice->VddId, NV_FALSE); if (hDevice->hPmu) { //NvAccelerometerSetPowerOn(0); NvOdmServicesPmuClose(hDevice->hPmu); } return; } }
void NvOdmGyroAccelClose(NvOdmGyroAccelHandle hDevice) { if (NULL != hDevice) { if (NULL != hDevice->SemaphoreForINT && NULL != hDevice->hGpioINT && NULL != hDevice->hPinINT && NULL != hDevice->hGpioInterrupt) { NvOdmGpioInterruptUnregister(hDevice->hGpioINT, hDevice->hPinINT, hDevice->hGpioInterrupt); NvOdmOsSemaphoreDestroy(hDevice->SemaphoreForINT); NvOdmGpioReleasePinHandle(hDevice->hGpioINT, hDevice->hPinINT); NvOdmGpioClose(hDevice->hGpioINT); } NvGyroAccelI2CClose(hDevice->hOdmI2C); #if 1 printk(" ## MPU3050 : [%s:%d] \n",__FUNCTION__, __LINE__) ; #endif // Power off accelermeter NvGyroAccelSetPowerRail(hDevice->hPmu, hDevice->VddId, NV_FALSE); if (hDevice->hPmu) { //NvGyroAccelSetPowerOn(0); NvOdmServicesPmuClose(hDevice->hPmu); } return; } }
static void star_proxi_vddio_vi_power_onoff( NvU32 vdd_id, NvBool is_enable ) { NvOdmServicesPmuHandle h_pmu = NvOdmServicesPmuOpen(); NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime; if(h_pmu) { NvOdmServicesPmuGetCapabilities(h_pmu, vdd_id, &vddrailcap); if( is_enable ) { #if 1 printk("VDDID_VI's pmu enable for PROXI_OUT\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, vddrailcap.requestMilliVolts, &settletime); } else { #if 1 printk("VDDID_VI's pmu do not enable for PROXI_OUT\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, NVODM_VOLTAGE_OFF, &settletime); } if(settletime) NvOdmOsWaitUS(settletime); } NvOdmServicesPmuClose(h_pmu); }
static int vib_set_power_rail( NvU32 vdd_id, NvBool is_enable ) { NvOdmServicesPmuHandle h_pmu = NvOdmServicesPmuOpen( ); NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime; if ( h_pmu ) { NvOdmServicesPmuGetCapabilities( h_pmu, vdd_id, &vddrailcap ); if ( is_enable ) { DbgOut(( "[ImmVibeSPI] vibrator PMU enable\n" )); NvOdmServicesPmuSetVoltage( h_pmu, vdd_id, vddrailcap.requestMilliVolts, &settletime ); } else { DbgOut(( "[ImmVibeSPI] vibrator PMU do not enable\n" )); NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, NVODM_VOLTAGE_OFF, &settletime); } if ( settletime ) NvOdmOsWaitUS( settletime ); NvOdmServicesPmuClose( h_pmu ); DbgOut(( "[ImmVibeSPI] vibrator voltage = %d or %d \n", vddrailcap.requestMilliVolts, vddrailcap.MinMilliVolts )); return 0; } return -1; }
static void vib_close( ) { NvU32 RequestedPeriod,ReturnedPeriod; NvU32 DutyCycle; if ( g_vib != NULL ) { NvOdmServicesPmuClose( g_vib->h_vib_pmu ); g_vib->h_vib_pmu = NULL; g_vib->vdd_id = 0; NvOdmGpioReleasePinHandle( g_vib->h_vib_gpio, g_vib->h_vib_gpio_pin ); NvOdmGpioClose( g_vib->h_vib_gpio ); if ( g_vib->hOdmPwm!= NULL ) { RequestedPeriod = 90000; // 49000; DutyCycle = 0x00320000; // 0x00630000; NvOdmPwmConfig( g_vib->hOdmPwm, NvOdmPwmOutputId_PWM3, NvOdmPwmMode_Disable, DutyCycle, &RequestedPeriod, &ReturnedPeriod ); } kfree( g_vib ); g_vib = NULL; } }
NvU32 headset_get_hook_adc_value(void) { NvU32 value =0; NvOdmServicesPmuHandle adc_pmu = NvOdmServicesPmuOpen(); value = NvOdmServicesPmuGetHookValue(adc_pmu); //20100716 [email protected] blocking for compile error [LGE] NvOdmServicesPmuClose(adc_pmu); return value; }
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 touchLED_remove(struct platform_device *pdev) { //20101104, [email protected], WLED set [START] sysfs_remove_group(&pdev->dev.kobj, &star_wled_group); //20101104, [email protected], WLED set [END] #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&s_touchLED.early_suspend); #endif touchLED_Control(NV_FALSE); NvOdmServicesPmuClose( s_touchLED.hPmu ); return 0; }
/** * @brief Closes the ODM device and destroys all allocated resources. * @param hOdmVibrate [IN] Opaque handle to the device. * @return None. */ void NvOdmVibClose(NvOdmVibDeviceHandle hOdmVibrate) { if (hOdmVibrate != NULL) { NvOdmServicesPmuClose(hOdmVibrate->hOdmServicePmuDevice); hOdmVibrate->hOdmServicePmuDevice = NULL; hOdmVibrate->VddId = 0; NvOsMemset(&hOdmVibrate->RailCaps, 0, sizeof(NvOdmServicesPmuVddRailCapabilities)); NvOdmOsFree(hOdmVibrate); hOdmVibrate = NULL; } }
void NvOdmUartClose(NvOdmUartHandle hOdmUart) { if (hOdmUart) { // Switch OFF UART Interface if (hOdmUart->hPmu != NULL) { NvOdmServicesPmuClose(hOdmUart->hPmu); } NvOdmOsFree(hOdmUart); hOdmUart = NULL; } }
static void Adt7461FreePrivData(ADT7461PrivData* pPrivData) { if (pPrivData) { if (pPrivData->hGpioIntr) { NvOdmGpioInterruptUnregister( pPrivData->hGpio, pPrivData->hGpioPin, pPrivData->hGpioIntr); } NvOdmI2cClose(pPrivData->hOdmI2C); NvOdmGpioReleasePinHandle(pPrivData->hGpio, pPrivData->hGpioPin); NvOdmGpioClose(pPrivData->hGpio); NvOdmServicesPmuClose(pPrivData->hOdmPmuSevice); NvOdmOsFree(pPrivData); } }
static int headsetdet_remove(struct platform_device *pdev) { lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_remove() : headset detection ended..!!\n"); //20100421 [email protected] [LGE] struct headset_switch_data *switch_data = platform_get_drvdata(pdev); //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [START] //wake_lock_destroy(&hook_det_lock); //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [END] if (headset_h_pmu) NvOdmServicesPmuClose(headset_h_pmu); cancel_work_sync(&switch_data->work); cancel_delayed_work_sync(&switch_data->delayed_work); //P990_IFX_GB_PORTING_LGSI_START //FIDO - GB Porting [09/08/2011] - Start #if 1 //defined (STAR_OPERATOR_FIDO) wake_lock_destroy(&headset_wake_lock); //20110425 [email protected] headset wake lock timeout #endif //FIDO - GB Porting [09/08/2011] - End //P990_IFX_GB_PORTING_LGSI_END /*====================== nVidia GPIO Control(S) =======================*/ NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, s_hHeadsetHandle.hheadsetInterrupt); NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, s_hHeadsetHandle.hhookInterrupt); //20100421 [email protected] for Hookkey [LGE] NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection); NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection); //20100421 [email protected] for Hookkey [LGE] NvOdmGpioClose(s_hHeadsetHandle.hGpio); /*====================== nVidia GPIO Control(E) =======================*/ switch_dev_unregister(&switch_data->sdev); input_unregister_device(switch_data->ip_dev); //20100421 [email protected] for Hookkey [LGE] kfree(switch_data); return 0; }
void NvOdmSdioClose(NvOdmSdioHandle hOdmSdio) { if (hOdmSdio->pConnectivity->Guid == WLAN_GUID) { // Call Turn off power when close is Called (void)SdioOdmWlanPower(hOdmSdio, NV_FALSE); NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hPwrPin); NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hResetPin); NvOdmGpioClose(hOdmSdio->hGpio); } NvOdmSetPowerOnSdio(hOdmSdio, NV_FALSE); if (hOdmSdio->hPmu != NULL) { NvOdmServicesPmuClose(hOdmSdio->hPmu); } NvOdmOsFree(hOdmSdio); hOdmSdio = NULL; }
NvU32 headset_get_hook_adc_average(int cnt) { NvU32 value =0; NvU32 aver =0; NvU32 i =0; NvOdmServicesPmuHandle adc_pmu = NvOdmServicesPmuOpen(); for(i=0;i<cnt;i++){ value += NvOdmServicesPmuGetHookValue(adc_pmu); } if(cnt !=0 ) aver = value/cnt; else aver = value; NvOdmServicesPmuClose(adc_pmu); lprintk(D_AUDIO, KERN_ERR "##(hook_det_work)## headset_get_hook_adc_average ADC: %d\n", aver); return aver; }
void NvGyroAccelSetPowerRail(NvOdmServicesPmuHandle hPMUDevice, NvU32 Id, NvBool IsEnable) { NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime; printk(" ## MPU3050 : 3 \n") ; Accel_PRail = Id; if (hPMUDevice) { NvOdmServicesPmuGetCapabilities(hPMUDevice, Id, &vddrailcap); if (IsEnable) { NvOdmServicesPmuSetVoltage(hPMUDevice, Id, vddrailcap.requestMilliVolts, &settletime); } else { NvOdmServicesPmuSetVoltage(hPMUDevice, Id, NVODM_VOLTAGE_OFF, &settletime); } if (settletime) NvOdmOsWaitUS(settletime); // wait to settle power } NvOdmServicesPmuClose(hPMUDevice); }
static int star_vib_set_power_rail( u32 vdd_id, u8 is_enable ) { printk("vib: %s,%d\n", __FUNCTION__, __LINE__); #if 0 // by DENNIS NvOdmServicesPmuHandle h_pmu = NvOdmServicesPmuOpen(); NvOdmServicesPmuVddRailCapabilities vddrailcap; u32 settletime; if(h_pmu) { NvOdmServicesPmuGetCapabilities( h_pmu, vdd_id, &vddrailcap ); if( is_enable ) { #if VIB_DEBUG printk("[skhwang] vibrator PMU enable\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, vddrailcap.requestMilliVolts, &settletime); } else { #if VIB_DEBUG printk("[skhwang] vibrator PMU do not enable\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, NVODM_VOLTAGE_OFF, &settletime); } if(settletime) NvOdmOsWaitUS(settletime); NvOdmServicesPmuClose(h_pmu); #if VIB_DEBUG printk("[skhwang] vibrator voltage = %d or %d \n", vddrailcap.requestMilliVolts, vddrailcap.MinMilliVolts); #endif return 0; } return -1; #endif }
static ssize_t star_pmic_store(struct device *dev, struct device_attribute *attr, char *buf, size_t count) { u32 val = 0; val = simple_strtoul(buf, NULL, 10); if(val){ NvOdmPeripheralConnectivity const *conn = NULL; NvOdmServicesPmuHandle hPmu; conn = NvOdmPeripheralGetGuid( NV_ODM_GUID('p','m','_','r','e','s','e','t') ); hPmu = NvOdmServicesPmuOpen(); if(!conn){ printk("ERROR : invalid GUID\n"); sprintf(buf, "PMIC reset fail\n"); return (ssize_t)(strlen(buf) + 1); } if( conn->AddressList[0].Interface == NvOdmIoModule_Vdd ) { NvU32 settle_us; /* set the rail volatage to the recommended */ NvOdmServicesPmuSetVoltage( hPmu, conn->AddressList[0].Address, NVODM_VOLTAGE_OFF, &settle_us ); /* wait for rail to settle */ NvOdmOsWaitUS( settle_us ); } NvOdmServicesPmuClose(hPmu); } sprintf(buf, "PMIC reset\n"); printk("PMIC reset\n"); return (ssize_t)(strlen(buf) + 1); }
static void star_proxi_power_onoff(ProximityDevice *data, bool enable) { #if 1 NvOdmServicesPmuHandle ldo_pmu = NvOdmServicesPmuOpen(); NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime = 0; if (enable) { NvOdmServicesPmuGetCapabilities(ldo_pmu, data->vddId, &vddrailcap); NvOdmServicesPmuSetVoltage(ldo_pmu, data->vddId, vddrailcap.requestMilliVolts, &settletime); } else { NvOdmServicesPmuSetVoltage(ldo_pmu, data->vddId, NVODM_VOLTAGE_OFF, &settletime); } //if (settletime) NvOdmOsWaitUS(10000); NvOdmServicesPmuClose(ldo_pmu); #endif }
static int headsetdet_remove(struct platform_device *pdev) { lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_remove() : headset detection ended..!!\n"); //20100421 [LGE] struct headset_switch_data *switch_data = platform_get_drvdata(pdev); //20101125, , hookkey press is skipped When wakeup from LP1 [START] //wake_lock_destroy(&hook_det_lock); //20101125, , hookkey press is skipped When wakeup from LP1 [END] if (headset_h_pmu) NvOdmServicesPmuClose(headset_h_pmu); cancel_work_sync(&switch_data->work); cancel_delayed_work_sync(&switch_data->delayed_work); /*====================== nVidia GPIO Control(S) =======================*/ NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, s_hHeadsetHandle.hheadsetInterrupt); NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, s_hHeadsetHandle.hhookInterrupt); //20100421 for Hookkey [LGE] NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection); NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection); //20100421 for Hookkey [LGE] NvOdmGpioClose(s_hHeadsetHandle.hGpio); /*====================== nVidia GPIO Control(E) =======================*/ switch_dev_unregister(&switch_data->sdev); input_unregister_device(switch_data->ip_dev); //20100421 for Hookkey [LGE] kfree(switch_data); return 0; }
void NvOdmSdioClose(NvOdmSdioHandle hOdmSdio) { const NvOdmPeripheralConnectivity *pConnectivity = NULL; NV_DRIVER_TRACE(("Close SDIO%d", hOdmSdio->Instance)); pConnectivity = hOdmSdio->pConnectivity; if (pConnectivity->Guid == WLAN_GUID) { // Call Turn off power when close is Called (void)SdioOdmWlanSetPowerOn(hOdmSdio, NV_FALSE); //NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hPwrPin); //Sam --- NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hResetPin); NvOdmGpioClose(hOdmSdio->hGpio); } NvOdmSetPowerOnSdio(hOdmSdio, NV_FALSE); if (hOdmSdio->hPmu != NULL) { NvOdmServicesPmuClose(hOdmSdio->hPmu); } NvOdmOsFree(hOdmSdio); hOdmSdio = NULL; }
// 20100903 Power control bug fix [START] static int star_hall_set_power_rail( NvU32 vdd_id, NvBool is_enable ) { NvOdmServicesPmuHandle h_pmu = NvOdmServicesPmuOpen(); NvOdmServicesPmuVddRailCapabilities vddrailcap; NvU32 settletime; if(h_pmu) { NvOdmServicesPmuGetCapabilities( h_pmu, vdd_id, &vddrailcap ); if( is_enable ) { #if HALL_DEBUG printk("HALL IC PMU enable\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, vddrailcap.requestMilliVolts, &settletime); } else { #if HALL_DEBUG printk("HALL IC PMU do not enable\n"); #endif NvOdmServicesPmuSetVoltage(h_pmu, vdd_id, NVODM_VOLTAGE_OFF, &settletime); } if(settletime) NvOdmOsWaitUS(settletime); NvOdmServicesPmuClose(h_pmu); #if HALL_DEBUG printk("[skhwang] HALL IC voltage = %d or %d \n", vddrailcap.requestMilliVolts, vddrailcap.MinMilliVolts); #endif return 0; } return -1; }
NvOdmSdioHandle NvOdmSdioOpen(NvU32 Instance) { static NvOdmSdio *pDevice = NULL; NvOdmServicesGpioHandle hGpioTemp = NULL; NvOdmPeripheralConnectivity *pConnectivity; NvU32 NumOfGuids = 1; NvU64 guid; NvU32 searchVals[4]; const NvU32 *pOdmConfigs; NvU32 NumOdmConfigs; NvBool Status = NV_TRUE; const NvOdmPeripheralSearch searchAttrs[] = { NvOdmPeripheralSearch_PeripheralClass, NvOdmPeripheralSearch_IoModule, NvOdmPeripheralSearch_Instance, NvOdmPeripheralSearch_Address, }; NvOdmBoardInfo BoardInfo; NvBool status = NV_FALSE; searchVals[0] = NvOdmPeripheralClass_Other; searchVals[1] = NvOdmIoModule_Sdio; searchVals[2] = Instance; NvOdmQueryPinMux(NvOdmIoModule_Sdio, &pOdmConfigs, &NumOdmConfigs); if ((Instance == 0) && (pOdmConfigs[0] == NvOdmSdioPinMap_Config1)) { // sdio is connected to sdio2 slot. searchVals[3] = NvOdmSdioDiscoveryAddress_1; } else { // sdio is connected to wifi module. searchVals[3] = NvOdmSdioDiscoveryAddress_0; } NumOfGuids = NvOdmPeripheralEnumerate(searchAttrs, searchVals, 4, &guid, NumOfGuids); // Get the peripheral connectivity information pConnectivity = (NvOdmPeripheralConnectivity *)NvOdmPeripheralGetGuid(guid); if (pConnectivity == NULL) return NULL; pDevice = NvOdmOsAlloc(sizeof(NvOdmSdio)); if(pDevice == NULL) return (pDevice); pDevice->hPmu = NvOdmServicesPmuOpen(); if(pDevice->hPmu == NULL) { NvOdmOsFree(pDevice); pDevice = NULL; return (NULL); } if (pConnectivity->Guid == WLAN_GUID) { // WARNING: This function *cannot* be called before RmOpen(). status = NvOdmPeripheralGetBoardInfo((BOARD_ID_E951), &BoardInfo); if (NV_TRUE != status) { // whistler should have E951 Module, if it is not presnt return NULL Handle. NvOdmServicesPmuClose(pDevice->hPmu); NvOdmOsFree(pDevice); pDevice = NULL; NvOdmOsDebugPrintf(("No E951 Detected")); return (pDevice); } } pDevice->pConnectivity = pConnectivity; NvOdmSetPowerOnSdio(pDevice, NV_TRUE); if (pConnectivity->Guid == WLAN_GUID) { // Getting the OdmGpio Handle hGpioTemp = NvOdmGpioOpen(); if (hGpioTemp == NULL) { NvOdmServicesPmuClose(pDevice->hPmu); NvOdmOsFree(pDevice); pDevice = NULL; return (pDevice); } // Search for the Vdd rail and set the proper volage to the rail. if (pConnectivity->AddressList[1].Interface == NvOdmIoModule_Gpio) { // Acquiring Pin Handles for Power Pin pDevice->hPwrPin= NvOdmGpioAcquirePinHandle(hGpioTemp, pConnectivity->AddressList[1].Instance, pConnectivity->AddressList[1].Address); } if (pConnectivity->AddressList[2].Interface == NvOdmIoModule_Gpio) { // Acquiring Pin Handles for Reset Pin pDevice->hResetPin= NvOdmGpioAcquirePinHandle(hGpioTemp, pConnectivity->AddressList[2].Instance, pConnectivity->AddressList[2].Address); } // Setting the ON/OFF pin to output mode. NvOdmGpioConfig(hGpioTemp, pDevice->hPwrPin, NvOdmGpioPinMode_Output); NvOdmGpioConfig(hGpioTemp, pDevice->hResetPin, NvOdmGpioPinMode_Output); // Setting the Output Pin to Low NvOdmGpioSetState(hGpioTemp, pDevice->hPwrPin, 0x0); NvOdmGpioSetState(hGpioTemp, pDevice->hResetPin, 0x0); pDevice->hGpio = hGpioTemp; Status = SdioOdmWlanSetPowerOn(pDevice, NV_TRUE); if (Status != NV_TRUE) { NvOdmServicesPmuClose(pDevice->hPmu); NvOdmGpioReleasePinHandle(pDevice->hGpio, pDevice->hPwrPin); NvOdmGpioReleasePinHandle(pDevice->hGpio, pDevice->hResetPin); NvOdmGpioClose(pDevice->hGpio); NvOdmOsFree(pDevice); pDevice = NULL; return (pDevice); } } pDevice->PoweredOn = NV_TRUE; pDevice->Instance = Instance; NV_DRIVER_TRACE(("Open SDIO%d", Instance)); return pDevice; }
//----------------------------------------------------------------- //--------------------------------New API-------------------------- //----------------------------------------------------------------- NvBool NvOdmGyroAccelOpen(NvOdmGyroAccelHandle* hDevice) { NvU32 i; NvBool foundGpio = NV_FALSE, foundI2cModule = NV_FALSE; const NvOdmPeripheralConnectivity *pConnectivity; NvOdmGyroAccelHandle hGyro; NvU32 reg_val = 0 ; #if 1 printk(" ## MPU3050 : [NvOdmGyroOpen:%d] \n",__LINE__) ; #endif hGyro = NvOdmOsAlloc(sizeof(NvOdmGyro)); if (hGyro == NULL) { printk("Error Allocating NvOdmAccel. \n"); return NV_FALSE; } NvOdmOsMemset(hGyro, 0, sizeof(NvOdmGyro)); hGyro->hPmu = NULL; hGyro->hOdmI2C = NULL; hGyro->hPmu = NvOdmServicesPmuOpen(); if (!hGyro->hPmu) { printk("NvOdmServicesPmuOpen Error \n"); goto error; } pConnectivity = (NvOdmPeripheralConnectivity*)NvOdmPeripheralGetGuid(NV_ODM_GUID('g','y','r','o','s','c','o','p')); if (!pConnectivity) { printk("NvOdmPeripheralGetGuid doesn't detect gyro_accel device\n"); goto error; } if(pConnectivity->Class != NvOdmPeripheralClass_Other) { goto error; } for (i = 0; i < pConnectivity->NumAddress; i++) { switch(pConnectivity->AddressList[i].Interface) { case NvOdmIoModule_I2c: hGyro->I2CChannelId = pConnectivity->AddressList[i].Instance; hGyro->nDevAddr = (pConnectivity->AddressList[i].Address << 1); foundI2cModule = NV_TRUE; foundGpio = NV_TRUE; //test #if 1 printk("## MPU3050 I2CChannelId = %x. ## \n", hGyro->I2CChannelId); printk("## MPU3050 i2c address = %x. ## \n", hGyro->nDevAddr); #endif break; /* case NvOdmIoModule_Gpio: hGyro->GPIOPortINT = pConnectivity->AddressList[i].Instance; hGyro->GPIOPinINT = pConnectivity->AddressList[i].Address; foundGpio = NV_TRUE; #if 1 printk("## MPU3050 GPIOPortINT = %x. ## \n",hGyro->GPIOPortINT); printk("## MPU3050 GPIOPinINT = %x. ## \n", hGyro->GPIOPinINT); #endif break;*/ case NvOdmIoModule_Vdd: hGyro->VddId = pConnectivity->AddressList[i].Address; #if 1 printk("## MPU3050 NvOdmIoModule_VddId = %x. ## \n", hGyro->VddId); #endif // Power on accelerometer according to Vddid NvGyroAccelSetPowerRail(hGyro->hPmu, hGyro->VddId, NV_TRUE); break; default: break; } } if (foundGpio != NV_TRUE || foundI2cModule != NV_TRUE) { printk("GyroAccel : didn't find any periperal in discovery query for touch device Error \n"); goto error; } // Set up I2C bus. if (NV_FALSE == NvGyroAccelI2COpen(&hGyro->hOdmI2C, hGyro->I2CChannelId)) { printk("GyroAccel : NvGyroAccelI2COpen Error \n"); goto error; }; printk(" ##1## GyroAccel : NvGyroAccelI2COpen check1 \n"); hGyro->RegsRead = NvGyroAccelI2CGetRegs; hGyro->RegsWrite = NvGyroAccelI2CSetRegs; printk(" ##2## GyroAccel : NvGyroAccelI2COpen check2 \n"); /* if(NV_FALSE == NvGyroAccelConnectSemaphore(hGyro)) { printk("GyroAccel : NvGyroAccelConnectSemaphore Error \n"); goto error; } */ *hDevice = hGyro; return NV_TRUE; error: // Release all of resources requested. if (NULL != hGyro) { NvGyroAccelSetPowerRail(hGyro->hPmu, hGyro->VddId, NV_FALSE); NvOdmServicesPmuClose(hGyro->hPmu); hGyro->hPmu = NULL; NvGyroAccelI2CClose(hGyro->hOdmI2C); hGyro->hOdmI2C = NULL; NvOdmOsFree(hGyro); *hDevice = NULL; } return NV_FALSE; }
static void headset_shutdown(struct platform_device *pdev) { lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_shutdown() : headset detection ended..!!\n"); //20100421 [email protected] [LGE] struct headset_switch_data *switch_data = platform_get_drvdata(pdev); //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [START] //wake_lock_destroy(&hook_det_lock); //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [END] headset_off = 1; if (headset_h_pmu) NvOdmServicesPmuClose(headset_h_pmu); lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_shutdown() : NvOdmServicesPmuClose\n"); #if 0 if (&headset_sw_data->work) { cancel_work_sync(&headset_sw_data->work); printk("switch_data->work canceled\n"); } if (&headset_sw_data->delayed_work) { cancel_delayed_work_sync(&headset_sw_data->delayed_work); printk("witch_data->delayed_work canceled\n"); } if(&headset_sw_data->hook_delayed_work) { cancel_delayed_work_sync(&headset_sw_data->hook_delayed_work); printk("headset_sw_data->hook_delayed_work canceled\n"); } #endif /*====================== nVidia GPIO Control(S) =======================*/ NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, s_hHeadsetHandle.hheadsetInterrupt); NvOdmGpioSetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, 0); NvOdmGpioConfig(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, NvOdmGpioPinMode_Output); NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, s_hHeadsetHandle.hhookInterrupt); //20100421 [email protected] for Hookkey [LGE] NvOdmGpioSetState(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, 0); NvOdmGpioConfig(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, NvOdmGpioPinMode_Output); NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection); NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection); //20100421 [email protected] for Hookkey [LGE] NvOdmGpioClose(s_hHeadsetHandle.hGpio); /*====================== nVidia GPIO Control(E) =======================*/ #if 0 switch_dev_unregister(&headset_sw_data->sdev); input_unregister_device(headset_sw_data->ip_dev); //20100421 [email protected] for Hookkey [LGE] if(headset_sw_data) kfree(headset_sw_data); #endif lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_shutdown() : completed\n"); }
//----------------------------------------------------------------- //--------------------------------New API-------------------------- //----------------------------------------------------------------- NvBool NvOdmAccelOpen(NvOdmAccelHandle* hDevice) { NvU32 test_val; NvU32 i; NvBool foundGpio = NV_FALSE, foundI2cModule = NV_FALSE; const NvOdmPeripheralConnectivity *pConnectivity; NvOdmAccelHandle hAccel; hAccel = NvOdmOsAlloc(sizeof(NvOdmAccel)); if (hAccel == NULL) { //NVODMACCELEROMETER_PRINTF("Error Allocating NvOdmAccel. \n"); return NV_FALSE; } NvOdmOsMemset(hAccel, 0, sizeof(NvOdmAccel)); hAccel->hPmu = NULL; hAccel->hOdmI2C = NULL; hAccel->nBusType = NV_ACCELEROMETER_BUS_I2C; // Chip init cfg info here, here just a sample for common interrupt now! // This part will move to a configuration table later. // Start here. // Only enable common interrupt // Enable common and single tap at the same time. hAccel->CtrlRegsList[0].RegAddr = XLR_CTL; //0x12 hAccel->CtrlRegsList[0].RegValue = 0x20; hAccel->CtrlRegsList[1].RegAddr = XLR_INTCONTROL; //0x13 hAccel->CtrlRegsList[1].RegValue = 0xF3; // modify so that sw is compatible hAccel->CtrlRegsList[2].RegAddr = XLR_INTCONTROL2; //0x14 hAccel->CtrlRegsList[2].RegValue = 0xe0; hAccel->CtrlRegsList[3].RegAddr = XLR_THRESHG; //0x1C hAccel->CtrlRegsList[3].RegValue = NV_ADI340_ACCELEROMETER_NORMAL_THRESHOLD; hAccel->CtrlRegsList[4].RegAddr = XLR_OFSX; //0x1E hAccel->CtrlRegsList[4].RegValue = 0; hAccel->CtrlRegsList[5].RegAddr = XLR_OFSY; //0x1F hAccel->CtrlRegsList[5].RegValue = 0; hAccel->CtrlRegsList[6].RegAddr = XLR_OFSZ; //0x20 hAccel->CtrlRegsList[6].RegValue = 0; hAccel->CtrlRegsList[7].RegAddr = XLR_THRESHC; //0x1D hAccel->CtrlRegsList[7].RegValue = NV_ADI340_ACCELEROMETER_TAP_THRESHOLD; hAccel->CtrlRegsList[8].RegAddr = XLR_DUR; //0x21 hAccel->CtrlRegsList[8].RegValue = 0x40; hAccel->CtrlRegsList[9].RegAddr = XLR_LATENT; //0x22 hAccel->CtrlRegsList[9].RegValue = 0xff; hAccel->CtrlRegsList[10].RegAddr = XLR_INTVL; //0x23 hAccel->CtrlRegsList[10].RegValue = 0; hAccel->CtrlRegsList[11].RegAddr = XLR_INTCONTROL2; //0x14 hAccel->CtrlRegsList[11].RegValue = 0xe1; hAccel->CtrlRegsList[12].RegAddr = XLR_INTCONTROL2; //0x14 hAccel->CtrlRegsList[12].RegValue = 0xe0; hAccel->nLength = 13; // Stop here. // Info of accelerometer with current setting. hAccel->Caption.MaxForceInGs = 2000; hAccel->Caption.MaxTapTimeDeltaInUs = 255; hAccel->Caption.NumMotionThresholds = 1; hAccel->Caption.SupportsFreefallInt = 0; hAccel->Caption.MaxSampleRate = 100; hAccel->Caption.MinSampleRate = 3; hAccel->PowerState = NvOdmAccelPower_Fullrun; hAccel->AxisXMapping = NvOdmAccelAxis_X; hAccel->AxisXDirection = 1; hAccel->AxisYMapping = NvOdmAccelAxis_Y; hAccel->AxisYDirection = 1; hAccel->AxisZMapping = NvOdmAccelAxis_Z; hAccel->AxisZDirection = -1; hAccel->hPmu = NvOdmServicesPmuOpen(); if (!hAccel->hPmu) { //NVODMACCELEROMETER_PRINTF("NvOdmServicesPmuOpen Error \n"); goto error; } pConnectivity = (NvOdmPeripheralConnectivity*)NvOdmPeripheralGetGuid(NV_ODM_GUID('a','c','c','e','l','e','r','o')); if (!pConnectivity) { NvOdmOsDebugPrintf("NvOdmPeripheralGetGuid doesn't detect accelerometer device\n"); goto error; } if(pConnectivity->Class != NvOdmPeripheralClass_Other) { goto error; } for( i = 0; i < pConnectivity->NumAddress; i++) { switch(pConnectivity->AddressList[i].Interface) { case NvOdmIoModule_I2c: hAccel->I2CChannelId = pConnectivity->AddressList[i].Instance; hAccel->nDevAddr = (NvU8)pConnectivity->AddressList[i].Address; foundI2cModule = NV_TRUE; break; case NvOdmIoModule_Gpio: hAccel->GPIOPortINT = pConnectivity->AddressList[i].Instance; hAccel->GPIOPinINT = pConnectivity->AddressList[i].Address; foundGpio = NV_TRUE; break; case NvOdmIoModule_Vdd: hAccel->VddId = pConnectivity->AddressList[i].Address; // Power on accelerometer according to Vddid NvAccelerometerSetPowerRail(hAccel->hPmu, hAccel->VddId, NV_TRUE); break; default: break; } } if(foundGpio != NV_TRUE || foundI2cModule != NV_TRUE) { //NVODMACCELEROMETER_PRINTF("Accelerometer : didn't find any periperal in discovery query for touch device Error \n"); goto error; } // Set up I2C bus. if(NV_FALSE == NvAccelerometerI2COpen(&hAccel->hOdmI2C, hAccel->I2CChannelId)) { goto error; }; hAccel->RegsRead = NvAccelerometerI2CGetRegs; hAccel->RegsWrite = NvAccelerometerI2CSetRegs; NvOdmAccelerometerGetParameter(hAccel, XLR_WHOAMI, &test_val); if(XLR_IDNUM != test_val) { goto error; } NvOdmAccelerometerGetParameter(hAccel, XLR_DEVID, &test_val); if (test_val == XLR_NEWCHIPID) { // This chip is ADXL345 //NvOdmOsDebugPrintf("This chip is ADXL345!!!\n"); hAccel->CtrlRegsList[4].RegValue = 0x0A; // offset X hAccel->CtrlRegsList[5].RegValue = 0x0B; // offset Y hAccel->CtrlRegsList[6].RegValue = 0x14; // offset Z } //NVODMACCELEROMETER_PRINTF("ID is 0x%x\n", test_val); /* We don't know the reset state of the accelerometer. So, program the * accelerometer to disable generation of interrupts. * * Write to INTCONTROL register to disable genetration of the interrupts. * Write to INTCONTROL2 to clear the already latched interrupts. */ NvOdmAccelerometerSetParameter(hAccel, XLR_ATTR_INTCONTROL, 0x0); NvOdmAccelerometerSetParameter(hAccel, XLR_ATTR_INTCONTROL2, 0x1); if(NV_FALSE == NvAccelerometerConnectSemaphore(hAccel)) { goto error; } //init accelerometer for(i=0; i<hAccel->nLength; i++) { NvOdmAccelerometerSetParameter(hAccel, hAccel->CtrlRegsList[i].RegAddr, hAccel->CtrlRegsList[i].RegValue); } // Set up event. //NvOdmAccelerometerGetParameter(XLR_SCALE, hAccel); *hDevice = hAccel; return NV_TRUE; error: // Release all of resources requested. if(NULL != hAccel) { NvAccelerometerSetPowerRail(hAccel->hPmu, hAccel->VddId, NV_FALSE); NvOdmServicesPmuClose(hAccel->hPmu); hAccel->hPmu = NULL; NvAccelerometerI2CClose(hAccel->hOdmI2C); hAccel->hOdmI2C = NULL; NvOdmOsFree(hAccel); *hDevice = NULL; } return NV_FALSE; }