예제 #1
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 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 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);
}
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;
    }
}
예제 #4
0
/*
 * De-initialize I2C for accelerometer.
 */
void NvGyroAccelI2CClose(NvOdmServicesI2cHandle hI2CDevice)
{
	// Close I2C handle.
	printk(" ## MPU3050 :  NvGyroAccelI2CClose \n") ;
	if (NULL != hI2CDevice) {
		NvOdmI2cClose(hI2CDevice);
	}
}
예제 #5
0
/*
 * De-initialize I2C for accelerometer.
 */
void NvAccelerometerI2CClose(NvOdmServicesI2cHandle hI2CDevice)
{
    // Close I2C handle.
    if(NULL != hI2CDevice)
    {
        NvOdmI2cClose(hI2CDevice);
    }
}
/*
 * De-initialize I2C for ambient light sensor.
 */
void NvAmbientsensorI2CClose(NvOdmServicesI2cHandle hI2CDevice)
{
    // Close I2C handle.
    if(NULL != hI2CDevice)
    {
        NvOdmI2cClose(hI2CDevice);
    }
}
예제 #7
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);
    }
}
예제 #8
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;
}
예제 #9
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;
}
예제 #10
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);
}
static NvBool GPIO_PCF50626_I2cWrite8(
    NvU8 Addr,
    NvU8 Data)
{
    NvBool RetVal = NV_TRUE;
    NvU8 WriteBuffer[2];
    NvOdmI2cStatus status = NvOdmI2cStatus_Success;    
    NvOdmI2cTransactionInfo TransactionInfo;
    NvU32 DeviceAddr = (NvU32)PCF50626_DEVICE_ADDR;

    s_hOdmI2c = NvOdmI2cOpen(NvOdmIoModule_I2c_Pmu, 0);
    if (!s_hOdmI2c)
    {
        RetVal = NV_FALSE;
        goto GPIO_PCF50626_I2cWrite8_exit;
    }

    WriteBuffer[0] = Addr & 0xFF;   // PMU offset
    WriteBuffer[1] = Data & 0xFF;   // written data

    TransactionInfo.Address = DeviceAddr;
    TransactionInfo.Buf = WriteBuffer;
    TransactionInfo.Flags = NVODM_I2C_IS_WRITE;
    TransactionInfo.NumBytes = 2;

    status = NvOdmI2cTransaction(s_hOdmI2c, &TransactionInfo, 1, 
                        PCF50626_I2C_SPEED_KHZ, NV_WAIT_INFINITE);
    if (status == NvOdmI2cStatus_Success)
        RetVal = NV_TRUE;
    else
        RetVal = NV_FALSE;

GPIO_PCF50626_I2cWrite8_exit:
    NvOdmI2cClose(s_hOdmI2c);
    s_hOdmI2c = NULL;
    return RetVal;
}
예제 #12
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
}
예제 #13
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;
}
예제 #14
0
NvBool VIBE_TPS658620_I2cWrite8(NvU8 Addr, NvU8 Data)
{
    NvBool RetVal = NV_TRUE;
    NvU8 WriteBuffer[2];
    NvOdmI2cStatus status = NvOdmI2cStatus_Success;    
    NvOdmI2cTransactionInfo TransactionInfo;
    NvU32 DeviceAddr = (NvU32)TPS658620_DEVICE_ADDR;
    NvU32 i = 0;

    NvOdmIoModule I2cModule = NvOdmIoModule_I2c;
    NvU32 I2cInstance = 0;
    NvU32 I2cAddress  = 0;

    const NvOdmPeripheralConnectivity *pConnectivity = 
                           NvOdmPeripheralGetGuid(NV_ODM_GUID('t','p','s','6','5','8','6','x'));

    for (i = 0; i < pConnectivity->NumAddress; i ++)
    {
        if (pConnectivity->AddressList[i].Interface == NvOdmIoModule_I2c_Pmu)
        {
            I2cModule   = NvOdmIoModule_I2c_Pmu;
            I2cInstance = pConnectivity->AddressList[i].Instance;
            I2cAddress  = pConnectivity->AddressList[i].Address;
            break;
        }
    }


    s_hOdmI2c = NvOdmI2cOpen(I2cModule, I2cInstance);
    if (!s_hOdmI2c)
    {
        RetVal = NV_FALSE;
        goto VIBE_TPS658620_I2cWrite8_exit;
    }


    DEBUG_VIBRATOR_TRACE(("[VIBE] : Open vibrate I2C success!\n"));

    WriteBuffer[0] = Addr & 0xFF;   // PMU offset
    //modify by ,set DPWM_MODE=0, fixed freq=250Hz ,duty cycle=0~127
    //WriteBuffer[1] = Data & 0xFF;   // written data
    WriteBuffer[1] = Data & 0x7F;   // written data

    TransactionInfo.Address = DeviceAddr;
    TransactionInfo.Buf = WriteBuffer;
    TransactionInfo.Flags = NVODM_I2C_IS_WRITE;
    TransactionInfo.NumBytes = 2;

    status = NvOdmI2cTransaction(s_hOdmI2c, &TransactionInfo, 1, 
                        TPS658620_I2C_SPEED_KHZ, NV_WAIT_INFINITE);

    if (status == NvOdmI2cStatus_Success)
    {
        RetVal = NV_TRUE;
        DEBUG_VIBRATOR_TRACE(("[VIBE] : Write vibrate I2C success!\n"));
    }
    else
    {
        RetVal = NV_FALSE;
        goto VIBE_TPS658620_I2cWrite8_exit;
        DEBUG_VIBRATOR_TRACE(("[VIBE] : Write vibrate I2C fail!\n"));
    }

    NvOdmI2cClose(s_hOdmI2c);
    s_hOdmI2c = NULL;
    return RetVal;

VIBE_TPS658620_I2cWrite8_exit:
    DEBUG_VIBRATOR_TRACE(("[VIBE] : Open or Write vibrate I2C fail!\n"));
    NvOdmI2cClose(s_hOdmI2c);
    s_hOdmI2c = NULL;
    return RetVal;
}
예제 #15
0
static int isl29023_probe(struct platform_device* pdev)
{
	struct input_dev *input_dev;
	struct isl29023_dev *dev;

	logd("isl29023_probe...\r\n");

	dev = &s_isl29023_dev;

	memset(dev, 0, sizeof(struct isl29023_dev));

	dev->i2c_instance = ISL29023_I2C_INSTANCE;
	dev->i2c_address = ISL29023_I2C_ADDRESS;
	dev->i2c_timeout = ISL29023_I2C_TIMEOUT_MS;
	dev->i2c_speed = ISL29023_I2C_SPEED_KHZ;
	dev->update_interval = ISL29023_UPDATE_INTERVAL;
	
	/* Set default accuracy */
	dev->accuracy = ISL29023_DEFAULT_ACCURACY;

	dev->i2c = NvOdmI2cOpen(NvOdmIoModule_I2c, dev->i2c_instance);
	if (!dev->i2c) {
		return -EINVAL;
	}

	input_dev = input_allocate_device();
	if (!input_dev) {
		goto failed_allocate_input;
	}
	set_bit(EV_SYN, input_dev->evbit);
	set_bit(EV_ABS, input_dev->evbit);
	input_set_abs_params(input_dev, ABS_MISC, -0, 0, 0, 0);
	input_dev->name = "light_sensor";
	if (input_register_device(input_dev)) {
		goto failed_register_input;
	}
	dev->input_dev = input_dev;

	isl29023_add_sysfs_entry(&pdev->dev);

	if (isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_I, 0) 
		|| isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_II, 0)) {
		goto failed_init_sensor;
	}
#if (__ISL29023_GENERIC_DEBUG__)
	isl29023_dump(dev);
#endif
	
	init_MUTEX(&dev->sem);

	INIT_DELAYED_WORK(&dev->update_work, isl29023_update_work_func);
	printk("ISL29023: init success\r\n");
	return 0;

//failed:
	isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_I, ISL29023_POWER_DOWN);
failed_init_sensor:
	input_unregister_device(input_dev);
failed_register_input:
	input_free_device(input_dev);
failed_allocate_input:
	NvOdmI2cClose(dev->i2c);
	dev->input_dev=NULL;
	//logd("ISL29023: Failed to init device\r\n");
	printk("ISL29023: Failed to init device\r\n");
	return -EINVAL;
}
예제 #16
0
int odm_i2c_close(struct odm_i2c_dev *dev) 
{
	if (dev->i2c) {
		NvOdmI2cClose(dev->i2c);
	}
}