Exemplo n.º 1
0
static int h2w_switch_remove(struct platform_device *pdev)
{
	struct h2w_switch_dev *hsdev;

	hsdev = (struct h2w_switch_dev *)platform_get_drvdata(pdev);
#ifdef CONFIG_SWITCH_DOCK_H2W
	#if !TIMER_DEALER
	NvOdmGpioInterruptUnregister(hsdev->gpio, hsdev->dock_hp_det_pin, hsdev->dock_hp_det_irq);
	#endif
#endif
	#if !TIMER_DEALER
	NvOdmGpioInterruptUnregister(hsdev->gpio, hsdev->hp_det_pin, hsdev->hp_det_irq);
	#endif
	
	destroy_workqueue(hsdev->workqueue);
	switch_dev_unregister(&hsdev->sdev);
#ifdef CONFIG_SWITCH_DOCK_H2W
	NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->dock_hp_det_pin);
#endif
	NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->hp_det_pin);
	NvOdmGpioClose(hsdev->gpio);
	kfree(hsdev);
	
	return 0;
}
Exemplo n.º 2
0
static int powerkey_remove(struct platform_device *pdev)
{
//20100703, [email protected], PMIC reset [START]
    sysfs_remove_group(&pdev->dev.kobj, &star_pmic_group);
    sysfs_remove_group(&pdev->dev.kobj, &star_hwsku_group);
    sysfs_remove_group(&pdev->dev.kobj, &star_reset_group); //20101110, [email protected], Function for Warm-boot
//20100703, [email protected], PMIC reset [END]
    
//20100610, [email protected], sleep status gpio for modem [START]
#ifdef AP_SUSPEND_STATUS
    NvOdmGpioReleasePinHandle(s_modemCheck.gpioHandle, s_modemCheck.pinHandle);
    NvOdmGpioClose(s_modemCheck.gpioHandle); 
#endif
//20100610, [email protected], sleep status gpio for modem [END]

    input_unregister_device(s_powerkey.inputDev);
    input_free_device(s_powerkey.inputDev);  

    NvOdmGpioInterruptUnregister(s_powerkey.gpioHandle, s_powerkey.pinHandle,
        s_powerkey.intHandle);
    
    NvOdmGpioReleasePinHandle(s_powerkey.gpioHandle, s_powerkey.pinHandle);
    NvOdmGpioClose(s_powerkey.gpioHandle);
    
#ifdef POWERKEY_DELAYED_WORKQUEUE
    wake_lock_destroy(&s_powerkey.wlock);
#endif
    return 0;
}
Exemplo n.º 3
0
int mdm_reset(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;
    NvOdmGpioPinHandle h_uart1_rtspin;

    printk("%s \n", __func__);    
    h_gpio = NvOdmGpioOpen();
    if (!h_gpio)
	{
		printk("%s: NvOdmGpioOpen Error\n", __func__);
		goto error_open_gpio_fail;
	}

    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 0);
    if (!h_gpiopin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    h_uart1_rtspin = NvOdmGpioAcquirePinHandle(h_gpio, 'o' - 'a', 3);
    if (!h_uart1_rtspin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    NvOdmGpioSetState( h_gpio, h_uart1_rtspin, 0x1);
    NvOdmGpioConfig( h_gpio, h_uart1_rtspin, NvOdmGpioPinMode_Output);
    NvOdmGpioGetState( h_gpio, h_uart1_rtspin, &pin_val);
    printk("ifx_reset_high - [CP RTS]: pin %d\n", pin_val);         

	//reset Communication Processor (GPIO_PV0: high -> 1000ms -> low -> 3000ms -> high)
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);
    msleep(1000);
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x0);
    msleep(3000);
    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_reset_high - [CP RESET]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_uart1_rtspin);
    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
    return 0;

error_open_gpio_pin_acquire_fail:
	NvOdmGpioClose(h_gpio);
error_open_gpio_fail:
	return -ENOSYS;
}
void Synaptics_OneTouch_Close (NvOdmOneTouchDeviceHandle hDevice)
{
    Synaptics_OneTouch_Device* hTouch = (Synaptics_OneTouch_Device*)hDevice;
	NVODMTOUCH_PRINTF(("[Touch Driver] Synaptics_OneTouch_Close\n"));

    if (!hTouch) return;

// 20101120 [email protected] power off when Onetouch close    
#if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F)
    Synaptics_OneTouch_PowerOnOff(&hTouch->OdmOneTouch, NV_FALSE);
#endif 

    if (hTouch->hGpio)
    {
        if (hTouch->hPin)
        {
            if (hTouch->hGpioIntr)
                NvOdmGpioInterruptUnregister(hTouch->hGpio, hTouch->hPin, hTouch->hGpioIntr);

            NvOdmGpioReleasePinHandle(hTouch->hGpio, hTouch->hPin);
        }

        NvOdmGpioClose(hTouch->hGpio);
    }

    if (hTouch->hOdmI2c)
        NvOdmI2cClose(hTouch->hOdmI2c);

    NvOdmOsFree(hTouch);
}
Exemplo n.º 5
0
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;
    }
}
Exemplo n.º 6
0
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;
	}
}
Exemplo n.º 7
0
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;

	}

}
Exemplo n.º 8
0
int mdm_rts_low(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_uart1_rtspin;

    printk("%s \n", __func__);    
    h_gpio = NvOdmGpioOpen();
    if (!h_gpio)
	{
		printk("%s: NvOdmGpioOpen Error\n", __func__);
		goto error_open_gpio_fail;
	}

    h_uart1_rtspin = NvOdmGpioAcquirePinHandle(h_gpio, 'o' - 'a', 3);
    if (!h_uart1_rtspin)
	{
		printk("%s: Couldn't NvOdmGpioAcquirePinHandle pin\n", __func__);
		goto error_open_gpio_pin_acquire_fail;
	}

    NvOdmGpioSetState( h_gpio, h_uart1_rtspin, 0x1);
    NvOdmGpioConfig( h_gpio, h_uart1_rtspin, NvOdmGpioPinMode_Output);
    NvOdmGpioGetState( h_gpio, h_uart1_rtspin, &pin_val);
    printk("ifx_reset_high - [CP RTS]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_uart1_rtspin);
    NvOdmGpioClose(h_gpio);
    return 0;

error_open_gpio_pin_acquire_fail:
	NvOdmGpioClose(h_gpio);
error_open_gpio_fail:
	return -ENOSYS;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
static int h2w_switch_remove(struct platform_device *pdev)
{
	struct h2w_switch_dev *hsdev;

	hsdev = (struct h2w_switch_dev *)platform_get_drvdata(pdev);
	NvOdmGpioInterruptUnregister(hsdev->gpio, hsdev->hp_det_pin, hsdev->hp_det_irq);
	NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->hp_det_pin);
	if (hsdev->have_dock_hp) {
		NvOdmGpioInterruptUnregister(hsdev->gpio, hsdev->dock_hp_det_pin, hsdev->dock_hp_det_irq);
		NvOdmGpioReleasePinHandle(hsdev->gpio, hsdev->dock_hp_det_pin);
	}
	NvOdmGpioClose(hsdev->gpio);
	destroy_workqueue(hsdev->workqueue);
	switch_dev_unregister(&hsdev->sdev);
	kfree(hsdev);
	
	return 0;
}
Exemplo n.º 11
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;
}
Exemplo n.º 12
0
static int muic_remove(struct platform_device *pdev)
{
    NvOdmGpioInterruptUnregister(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC,
            s_hMuicHandle.hGpioInterrupt);

    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USIF1_SW);
#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F)
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN);
#endif

    NvOdmGpioClose(s_hMuicHandle.hGpio);
#ifndef _MUIC_GPIO_I2C_
    NvOdmI2cClose(s_hMuicHandle.hOdmI2c);
#endif
    wake_lock_destroy(&s_hMuicHandle.wlock);
    remove_star_muic_proc_file();
    return 0;
}
Exemplo n.º 13
0
static int __devexit Msensor_remove(struct platform_device *pdev)
{

	//printk("==============>Msensor_remove\r\n");
	
	ms3c_ControlStatus(STATUS_SUSPEND);

	if( s_hResetGpioPin )
		NvOdmGpioReleasePinHandle(s_hGpio, s_hResetGpioPin);
	if( s_hGpio )
		NvOdmGpioClose(s_hGpio);

	return 0;
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
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);
        NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hResetPin);    
        NvOdmGpioClose(hOdmSdio->hGpio);
    }
    NvOdmSetPowerOnSdio(hOdmSdio, NV_FALSE);
    if (hOdmSdio->hPmu != NULL)
    {
         NvOdmServicesPmuClose(hOdmSdio->hPmu);
    }
    NvOdmOsFree(hOdmSdio);
    hOdmSdio = NULL;
}
Exemplo n.º 16
0
static int proximity_remove(struct platform_device *pdev)
{
    struct device *dev = &pdev->dev;
    star_proxi_disable(&s_proximity);
    sysfs_remove_group(&dev->kobj, &star_proxi_group);
    input_unregister_device(s_proximity.input_dev);

    NvOdmGpioInterruptUnregister(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin,
        s_proximity.proxi_out_intr);
    NvOdmGpioReleasePinHandle(s_proximity.proxi_out_gpio, s_proximity.proxi_out_gpio_pin);
    NvOdmGpioClose(s_proximity.proxi_out_gpio);
    
    NvOdmI2cClose(s_proximity.gen2_i2c);

    return 0;
}
Exemplo n.º 17
0
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);
    }
}
Exemplo n.º 18
0
void ifx_power_low(void)
{
    unsigned int pin_val = 0;
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;

    printk("%s LOW\n", __func__);
    h_gpio = NvOdmGpioOpen();
    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 1);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);

    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x0);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_power_low - [CP POWER]: pin %d\n", pin_val);

    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
}
Exemplo n.º 19
0
void NvOdmUsbUlpiClose(NvOdmUsbUlpiHandle hOdmUlpi)
{
    if (hOdmUlpi->hResetPin)
    {
        NvOdmGpioSetState(hOdmUlpi->hGpio, hOdmUlpi->hResetPin, 0x0);
        NvOdmGpioReleasePinHandle(hOdmUlpi->hGpio, hOdmUlpi->hResetPin);
        hOdmUlpi->hResetPin = NULL;
    }
    if (hOdmUlpi->hGpio)
    {
        NvOdmGpioClose(hOdmUlpi->hGpio);
        hOdmUlpi->hGpio = NULL;
    }
    if (hOdmUlpi)
    {
        NvOdmOsFree(hOdmUlpi);
    }
}
void NvOdmUsbUlpiClose(NvOdmUsbUlpiHandle hOdmUlpi)
{
    if (hOdmUlpi)
    {
        NvOdmOsFree(hOdmUlpi);
    }
    if (s_hResetPin)
    {
        NvOdmGpioReleasePinHandle(s_hGpio, s_hResetPin);
        s_hResetPin = NULL;
    }
    if (s_hGpio)
    {
        NvOdmGpioClose(s_hGpio);
        s_hGpio = NULL;
    }

}
Exemplo n.º 21
0
void ifx_reset_high(void)
{
    unsigned int pin_val = 0;    
    NvOdmServicesGpioHandle h_gpio;	
    NvOdmGpioPinHandle h_gpiopin;

    printk("%s HIGH\n", __func__);    
    h_gpio = NvOdmGpioOpen();
    h_gpiopin = NvOdmGpioAcquirePinHandle(h_gpio, 'v' - 'a', 0);
    NvOdmGpioConfig( h_gpio, h_gpiopin, NvOdmGpioPinMode_Output);

    NvOdmGpioSetState( h_gpio, h_gpiopin, 0x1);
    NvOdmGpioGetState( h_gpio, h_gpiopin, &pin_val);
    printk("ifx_reset_high - [CP RESET]: pin %d\n", pin_val);         

    NvOdmGpioReleasePinHandle(h_gpio, h_gpiopin);
    NvOdmGpioClose(h_gpio);
}
Exemplo n.º 22
0
static int gps_control_remove(struct platform_device *pdev)
{
	struct gps_control_dev *gps_control;

	gps_control = (struct gps_control_dev *)platform_get_drvdata(pdev);
	if (gps_control != NULL) {
		NvOdmGpioReleasePinHandle(gps_control->gpio_handle, gps_control->pin_handle);
		gps_control->pin_handle = 0;
		NvOdmGpioClose(gps_control->gpio_handle);
		gps_control->gpio_handle = 0;
		if (gps_control->input_dev) {
			input_unregister_device(gps_control->input_dev);
			input_free_device(gps_control->input_dev);
			gps_control->input_dev = 0;
		}
	}

	return 0;
}
Exemplo n.º 23
0
void EETI_Close (NvOdmTouchDeviceHandle hDevice) {
    EETI_TouchDevice* hTouch = (EETI_TouchDevice*)hDevice;

    if (!hTouch) return;

    if (hTouch->hGpio) {
        if (hTouch->hPin) {
            if (hTouch->hGpioIntr)
                NvOdmGpioInterruptUnregister(hTouch->hGpio, hTouch->hPin, hTouch->hGpioIntr);

            NvOdmGpioReleasePinHandle(hTouch->hGpio, hTouch->hPin);
        }

        NvOdmGpioClose(hTouch->hGpio);
    }

    if (hTouch->hOdmI2c)
        NvOdmI2cClose(hTouch->hOdmI2c);

    NvOdmOsFree(hTouch);
}
Exemplo n.º 24
0
static int cpcap_usb_connected_remove(struct platform_device *pdev)
{
	struct cpcap_usb_connected_data *data = platform_get_drvdata(pdev);

	mdm_ctrl_set_usb_ipc(false);

	/* Configure CPCAP-AP20 USB Mux to CPCAP */
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x0);
	NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin);
	NvOdmGpioClose(data->h_gpio);

	if((data->accy == CPCAP_ACCY_USB) || (data->accy == CPCAP_ACCY_FACTORY))
		android_usb_set_connected(0, data->accy);

#ifdef CONFIG_USB_TEGRA_OTG
	tegra_otg_set_mode(2);
#endif

	kfree(data);

        return 0;
}
Exemplo n.º 25
0
static int cpcap_usb_connected_remove(struct platform_device *pdev)
{
/*	struct cpcap_usb_connected_data *data = platform_get_drvdata(pdev);*/
	struct cpcap_accy_platform_data *pdata = pdev->dev.platform_data;

	int nr_gpio;
#ifdef CONFIG_MDM_CTRL
	mdm_ctrl_set_usb_ipc(false);
#endif
#if 0
	/* Configure CPCAP-AP20 USB Mux to CPCAP */
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x0);
	printk(KERN_INFO "pICS_%s: NvOdmGpioSetState (data->h_gpio, data->h_pin, 0x0)\n",__func__);
	NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin);
	printk(KERN_INFO "pICS_%s: NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin)\n",__func__);
	NvOdmGpioClose(data->h_gpio);
	printk(KERN_INFO "pICS_%s: NvOdmGpioClose(data->h_gpio)\n",__func__);
#endif
	
	nr_gpio = 174;
	gpio_set_value(nr_gpio, 0);

	gpio_free(nr_gpio);
/*	gpio_data[nr_gpio].val = false;
	gpio_data[nr_gpio].alloc = false;*/
	
	tegra_gpio_disable(nr_gpio);
#ifdef CONFIG_USB_MOT_ANDROID
	if((pdata->accy == CPCAP_ACCY_USB) || (pdata->accy == CPCAP_ACCY_FACTORY))
		android_usb_set_connected(0, pdata->accy);
#endif

	tegra_otg_set_mode(2);

/*	kfree(data);*/

        return 0;
}
Exemplo n.º 26
0
static int __devexit headset_switch_remove(struct platform_device *pdev)
{

	struct gpio_switch_data *switch_data = platform_get_drvdata(pdev);

	cancel_work_sync(&switch_data->work);
	

    //remove interrupt
    NvOdmGpioInterruptUnregister(
        s_hGpio, s_hHeadphoneGpioPin, s_hGpioIntr_Headphone);
    NvOdmGpioReleasePinHandle(s_hGpio, s_hHeadphoneGpioPin);
    s_hHeadphoneGpioPin = NULL;

    //remove thread
    //terminate thread 
    g_DetectThread_exit = 1;
    if ( g_hDetectEventSema )
        NvOdmOsSemaphoreSignal( g_hDetectEventSema );
    
    if( !g_hDetectThread )
        NvOdmOsThreadJoin( g_hDetectThread );
    g_hDetectThread = NULL;

    if ( g_hDetectEventSema )
    {
        NvOdmOsSemaphoreDestroy( g_hDetectEventSema );
        g_hDetectEventSema = 0;
    }

    switch_dev_unregister(&switch_data->sdev);
	kfree(switch_data);


	return 0;
}
static int headsetdet_remove(struct platform_device *pdev)
{
#if 0
	printk(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);

	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.hGpioInterrupt);
    //NvOdmGpioInterruptUnregister(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, s_hHeadsetHandle.hGpioInterrupt);	//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);
#endif
	return 0;
}
Exemplo n.º 28
0
static int __init powerkey_probe(struct platform_device *pdev)
{
    int ret;
    NvU32 pin, port;
    const NvOdmPeripheralConnectivity *con = NULL;

//20101129, [email protected], idle current issue [START]
    //GPIO configuration
    s_touchMaker.gpioHandle = NvOdmGpioOpen();
    port = 'x'-'a';
    pin = 5;
    s_touchMaker.pinHandle = NvOdmGpioAcquirePinHandle(s_touchMaker.gpioHandle, 
                                                    port, pin);
    NvOdmGpioConfig(s_touchMaker.gpioHandle, s_touchMaker.pinHandle, 
                    NvOdmGpioPinMode_InputData);
//20101129, [email protected], idle current issue [END]


//20100610, [email protected], sleep status gpio for modem [START]
#ifdef AP_SUSPEND_STATUS
    //GPIO configuration
    s_modemCheck.gpioHandle = NvOdmGpioOpen();
    if (!s_modemCheck.gpioHandle)
    {
        printk(KERN_ERR "[star modem_chk] NvOdmGpioOpen Error \n");
        goto err_open_modem_chk_gpio_fail;
    }
    port = 'r'-'a';
    pin = 0;
    s_modemCheck.pinHandle = NvOdmGpioAcquirePinHandle(s_modemCheck.gpioHandle, 
                                                    port, pin);
    if (!s_modemCheck.pinHandle)
    {
        printk(KERN_ERR "[star modem_chk] NvOdmGpioAcquirePinHandle Error\n");
        goto err_modem_chk_gpio_pin_acquire_fail;
    }
    NvOdmGpioSetState(s_modemCheck.gpioHandle, s_modemCheck.pinHandle, 1);
    NvOdmGpioConfig(s_modemCheck.gpioHandle, s_modemCheck.pinHandle, 
                    NvOdmGpioPinMode_Output);
#endif
//20100610, [email protected], sleep status gpio for modem [END]

    memset(&s_powerkey, 0x00, sizeof(s_powerkey));

    //get query
    con = NvOdmPeripheralGetGuid(NV_ODM_GUID('p','o','w','e','r','k','e','y'));
    if(!con){
        printk(KERN_ERR "[star powerkey] ODM GUID Error \n");
        goto err_probe_fail;
    }

    if ( con->AddressList[0].Interface == NvOdmIoModule_Gpio){
        port = con->AddressList[0].Instance;
        pin = con->AddressList[0].Address;
    }else{
        printk(KERN_ERR "[star powerkey] cannot find ODM GUID \n");
        goto err_probe_fail;
    }
    
#ifdef POWERKEY_DELAYED_WORKQUEUE
    INIT_DELAYED_WORK(&s_powerkey.work, powerkey_handle);
    wake_lock_init(&s_powerkey.wlock, WAKE_LOCK_SUSPEND, "powerkey_delay");
#else
    INIT_WORK(&s_powerkey.work, powerkey_handle);
#endif

    //GPIO configuration
    s_powerkey.gpioHandle = NvOdmGpioOpen();
    if (!s_powerkey.gpioHandle)
    {
        printk(KERN_ERR "[star powerkey] NvOdmGpioOpen Error \n");
        goto err_open_gpio_fail;
    }
    s_powerkey.pinHandle = NvOdmGpioAcquirePinHandle(s_powerkey.gpioHandle, 
                                                    port, pin);
    if (!s_powerkey.pinHandle)
    {
        printk(KERN_ERR "[star powerkey] NvOdmGpioAcquirePinHandle Error\n");
        goto err_gpio_pin_acquire_fail;
    }
    //NvOdmGpioSetState(s_powerkey.gpioHandle, s_powerkey.pinHandle, 0);
    NvOdmGpioConfig(s_powerkey.gpioHandle, s_powerkey.pinHandle, 
                    NvOdmGpioPinMode_InputData);

    //GPIO interrupt registration
    if (NvOdmGpioInterruptRegister(s_powerkey.gpioHandle, &s_powerkey.intHandle,
            s_powerkey.pinHandle, NvOdmGpioPinMode_InputInterruptAny, 
            powerkey_interrupt_handler, (void*)&s_powerkey, 0) == NV_FALSE)
    {
        printk(KERN_ERR "[star Powerkey] interrupt registeration fail!\n");
        goto err_interrupt_register_fail;
    }

    // input device
    s_powerkey.inputDev = input_allocate_device();
    if (!s_powerkey.inputDev) {
        printk(KERN_ERR "[star Powerkey] input_allocate_device Error!\n");
        goto err_input_device_allocation_fail;
    }
    s_powerkey.inputDev->name = "powerkey";
    //s_powerkey.inputDev->id.bustype = BUS_HOST;
    s_powerkey.inputDev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
    set_bit(KEY_POWER, s_powerkey.inputDev->keybit);

    ret = input_register_device(s_powerkey.inputDev);
    if (ret) {
        printk(KERN_ERR "[star powerkey] input_register_device Error\n");
        goto err_input_device_register_fail;
    }

//20100703, [email protected], PMIC reset [START]
    ret = sysfs_create_group(&pdev->dev.kobj, &star_pmic_group);
    if (ret) {
        printk(KERN_ERR "[star powerkey] sysfs_create_group ERROR\n");
        goto err_pmic_sysfs_fail;
    }
//20100703, [email protected], PMIC reset [END]
    
    ret = sysfs_create_group(&pdev->dev.kobj, &star_hwsku_group);
    if (ret) {
        printk(KERN_ERR "[star powerkey] sysfs_create_group ERROR\n");
        goto err_hwsku_sysfs_fail;
    }

//20101110, [email protected], Function for Warm-boot [START]
    ret = sysfs_create_group(&pdev->dev.kobj, &star_reset_group);
    if (ret) {
        printk(KERN_ERR "[star powerkey] sysfs_create_group ERROR\n");
        goto err_reset_sysfs_fail;
    }
//20101110, [email protected], Function for Warm-boot [END]

// 20110209 [email protected] disable gpio interrupt during power-off  [START] 
    ret = sysfs_create_group(&pdev->dev.kobj, &star_poweroff_group);
    if (ret) {
        printk(KERN_ERR "[star powerkey] sysfs_create_group <star_poweroff_group> ERROR\n");
        goto err_input_device_register_fail;
    }
// 20110209 [email protected] disable gpio interrupt during power-off  [END] 

    return 0;
err_reset_sysfs_fail:    
    sysfs_remove_group(&pdev->dev.kobj, &star_hwsku_group);
err_hwsku_sysfs_fail:
    sysfs_remove_group(&pdev->dev.kobj, &star_pmic_group);
err_pmic_sysfs_fail:
    input_unregister_device(s_powerkey.inputDev);

err_input_device_register_fail: 
    input_free_device(s_powerkey.inputDev);    
err_input_device_allocation_fail: 
    NvOdmGpioInterruptUnregister(s_powerkey.gpioHandle, s_powerkey.pinHandle,
        s_powerkey.intHandle);    
err_interrupt_register_fail:  
    NvOdmGpioReleasePinHandle(s_powerkey.gpioHandle, s_powerkey.pinHandle);
err_gpio_pin_acquire_fail:
    NvOdmGpioClose(s_powerkey.gpioHandle);  

err_open_gpio_fail:
#ifdef POWERKEY_DELAYED_WORKQUEUE
    wake_lock_destroy(&s_powerkey.wlock);
#endif

err_probe_fail:

//20100610, [email protected], sleep status gpio for modem [START]
#ifdef AP_SUSPEND_STATUS
    NvOdmGpioReleasePinHandle(s_modemCheck.gpioHandle, s_modemCheck.pinHandle);
err_modem_chk_gpio_pin_acquire_fail:
    NvOdmGpioClose(s_modemCheck.gpioHandle); 
err_open_modem_chk_gpio_fail:
#endif
//20100610, [email protected], sleep status gpio for modem [END]
    return -ENOSYS;
}
Exemplo n.º 29
0
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
}
Exemplo n.º 30
0
static int __init muic_probe(struct platform_device *pdev)
{
    int i, j, ret;
#ifdef _MUIC_GPIO_I2C_
    int ret_val;
#else	
    NvU32 I2cInstance = 0;
#endif
#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F)
    NvU32 pin[5], port[5];
#else
    NvU32 pin[4], port[4];
#endif
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;

    printk(KERN_INFO "muic_probe\n");

    pConnectivity = NvOdmPeripheralGetGuid(MUIC_GUID);

    for (i = 0, j = 0 ; i < pConnectivity->NumAddress; i++)
    {
        switch (pConnectivity->AddressList[i].Interface)
        {
#ifndef _MUIC_GPIO_I2C_
            case NvOdmIoModule_I2c:
                s_hMuicHandle.DeviceAddr = (pConnectivity->AddressList[i].Address << 1);
                I2cInstance = pConnectivity->AddressList[i].Instance;
                break;
#endif
            case NvOdmIoModule_Gpio:
                port[j] = pConnectivity->AddressList[i].Instance;
                pin[j] = pConnectivity->AddressList[i].Address;
                j++;
                break;
            default:
                break;
        }
    }

    s_hMuicHandle.hGpio = NvOdmGpioOpen();
    if (!s_hMuicHandle.hGpio)
    {
        lprintk(D_MUIC, "%s: NvOdmGpioOpen Error \n", __func__);
        goto err_open_gpio_fail;
    }

    s_hMuicHandle.h_INT_N_MUIC = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[0], pin[0]);
    if (!s_hMuicHandle.h_INT_N_MUIC)
    {
        lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }

    s_hMuicHandle.h_AP20_UART_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[1], pin[1]);
    if (!s_hMuicHandle.h_AP20_UART_SW)
    {
        lprintk(D_MUIC, "%s:Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }

    s_hMuicHandle.h_IFX_UART_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[2], pin[2]);
    if (!s_hMuicHandle.h_IFX_UART_SW)
    {
        lprintk(D_MUIC, "%s:Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }

    s_hMuicHandle.h_USIF1_SW = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[3], pin[3]);
    if (!s_hMuicHandle.h_USIF1_SW)
    {
        lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }

#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F)
    s_hMuicHandle.h_USB_VBUS_EN = NvOdmGpioAcquirePinHandle(s_hMuicHandle.hGpio, port[4], pin[4]);
    if (!s_hMuicHandle.h_USB_VBUS_EN)
    {
        lprintk(D_MUIC, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }
#endif
    NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC, NvOdmGpioPinMode_InputData);
    NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW, NvOdmGpioPinMode_Output);
    NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW, NvOdmGpioPinMode_Output);
    NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_USIF1_SW, NvOdmGpioPinMode_Output);
#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F)
    NvOdmGpioConfig(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN, NvOdmGpioPinMode_Output);
#endif


#ifdef _MUIC_GPIO_I2C_
    ret_val = MUIC_Gpio_i2c_init(&s_hMuicHandle);
    if (ret_val < 0)
    {	
        lprintk(D_MUIC, "%s: MUIC_Gpio_i2c_init Error \n", __func__);
        goto err_open_i2c_handle;
    }
#else
    s_hMuicHandle.hOdmI2c = NvOdmI2cOpen(NvOdmIoModule_I2c, I2cInstance);
    if (!s_hMuicHandle.hOdmI2c)
    {
        lprintk(D_MUIC, "%s: NvOdmI2cOpen Error \n", __func__);
        goto err_open_i2c_handle;
    }
#endif
    wake_lock_init(&s_hMuicHandle.wlock, WAKE_LOCK_SUSPEND, "muic_active");

//20101117, [email protected], for autorun [START]
#ifdef CONFIG_USB_SUPPORT_LGE_ANDROID_AUTORUN
    s_hMuicHandle.sdev_autorun.name = DRIVER_NAME_FOR_AUTORUN;
    s_hMuicHandle.sdev_autorun.print_name = print_switch_name_for_autorun;
    s_hMuicHandle.sdev_autorun.print_state = print_switch_state_for_autorun;

    ret = switch_dev_register(&s_hMuicHandle.sdev_autorun);
    if (ret) {
        goto err_sdev_unregister;
    }
#endif
//20101117, [email protected], for autorun [END]

    INIT_DELAYED_WORK(&muic_wq, muic_wq_func);

    if (NvOdmGpioInterruptRegister(s_hMuicHandle.hGpio, &s_hMuicHandle.hGpioInterrupt,
                s_hMuicHandle.h_INT_N_MUIC, NvOdmGpioPinMode_InputInterruptFallingEdge , muic_interrupt_handler,
                (void*)&s_hMuicHandle, 0) == NV_FALSE) 

    {
        lprintk(D_MUIC, KERN_ERR "%s: cannot register interrupt.\n", __func__);
        goto err_get_interrupt_handler;
    }

    create_star_muic_proc_file();
    current_device = DEVICE_NONE;

    muic_initialize_max(RESET);

    
    //20100915, [email protected], move to late_initcall [START]     
#if 0		
    NvOdmOsSleepMS(400) ;
    MAX14526_Device_Detection();
#endif		
    //20100915, [email protected], move to late_initcall [STOP]  

    return 0;

err_get_interrupt_handler:
#ifndef _MUIC_GPIO_I2C_	
    NvOdmI2cClose(s_hMuicHandle.hOdmI2c);
#endif
//20101117, [email protected], for autorun [START]
#ifdef CONFIG_USB_SUPPORT_LGE_ANDROID_AUTORUN
err_sdev_unregister:
	switch_dev_unregister(&s_hMuicHandle.sdev_autorun);
#endif
//20101117, [email protected], for autorun [END]
err_open_i2c_handle:
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_INT_N_MUIC);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_AP20_UART_SW);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_IFX_UART_SW);
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USIF1_SW);
#if defined(CONFIG_MACH_STAR_REV_D) || defined(CONFIG_MACH_STAR_REV_E) || defined(CONFIG_MACH_STAR_REV_F)
    NvOdmGpioReleasePinHandle(s_hMuicHandle.hGpio, s_hMuicHandle.h_USB_VBUS_EN);
#endif

err_open_gpio_pin_acquire_fail:
    NvOdmGpioClose(s_hMuicHandle.hGpio);
err_open_gpio_fail:

    return -ENOSYS;
}