Пример #1
0
static void
ConfigPowerRail(
    NvOdmServicesPmuHandle hPMUDevice,
    NvU32 Id,
    NvBool IsEnable)
{
    NvOdmServicesPmuVddRailCapabilities vddrailcap;
    NvU32 settletime;

    if (hPMUDevice && Id)
    {
        NvOdmServicesPmuGetCapabilities(hPMUDevice, Id, &vddrailcap);
        if (IsEnable)
        {
            NvOdmServicesPmuSetVoltage(hPMUDevice, Id,
                vddrailcap.requestMilliVolts, &settletime);
        }
        else
        {
            NvOdmServicesPmuSetVoltage(hPMUDevice, Id,
                vddrailcap.MinMilliVolts, &settletime);
        }
    if (settletime)
        NvOdmOsWaitUS(settletime);
    }
}
Пример #2
0
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);
}
Пример #3
0
static void NvOdmSetPowerOnSdio(NvOdmSdioHandle pDevice, NvBool enable)
{
    const NvOdmPeripheralConnectivity *pConn;
    NvU32 i;

    pConn = pDevice->pConnectivity;

    for (i=0; i<pConn->NumAddress; i++)
    {
        const NvOdmIoAddress *addr = &pConn->AddressList[i];
        NvU32 settle;
        NvU32 voltage;

        if (addr->Interface != NvOdmIoModule_Vdd)
            continue;

        if (enable)
        {
            NvOdmServicesPmuVddRailCapabilities caps;
            NvOdmServicesPmuGetCapabilities(pDevice->hPmu, addr->Address, &caps);
            voltage = caps.requestMilliVolts;
        }
        else
        {
            voltage = ODM_VOLTAGE_OFF;
        }

        NvOdmServicesPmuSetVoltage(pDevice->hPmu, addr->Address,
                                   voltage, &settle);

        if (settle)
            NvOdmOsWaitUS(settle);
    }
}
Пример #4
0
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;

}
Пример #5
0
static void NvOdmSetPowerOnSdio(NvOdmSdioHandle pDevice,
                                NvBool IsEnable)
{
    NvU32 Index = 0;
    NvOdmServicesPmuVddRailCapabilities RailCaps;
    NvU32 SettlingTime = 0;
    const NvOdmPeripheralConnectivity *pConnectivity;

    pConnectivity = pDevice->pConnectivity;
    if (IsEnable) // Turn on Power
    {
        // Search for the Vdd rail and set the proper volage to the rail.
        for (Index = 0; Index < pConnectivity->NumAddress; ++Index)
        {
            if (pConnectivity->AddressList[Index].Interface == NvOdmIoModule_Vdd)
            {
                NvOdmServicesPmuGetCapabilities(pDevice->hPmu, pConnectivity->AddressList[Index].Address, &RailCaps);
                NvOdmServicesPmuSetVoltage(pDevice->hPmu, pConnectivity->AddressList[Index].Address,
                                           RailCaps.requestMilliVolts, &SettlingTime);
                if (SettlingTime)
                {
                    NvOdmOsWaitUS(SettlingTime);
                }
            }
        }
    }
    else // Shutdown Power
    {
        // Search for the Vdd rail and power Off the module
        for (Index = 0; Index < pConnectivity->NumAddress; ++Index)
        {
            if (pConnectivity->AddressList[Index].Interface == NvOdmIoModule_Vdd)
            {
                NvOdmServicesPmuGetCapabilities(pDevice->hPmu, pConnectivity->AddressList[Index].Address, &RailCaps);
                NvOdmServicesPmuSetVoltage(pDevice->hPmu, pConnectivity->AddressList[Index].Address,
                                           ODM_VOLTAGE_OFF, &SettlingTime);
                if (SettlingTime)
                {
                    NvOdmOsWaitUS(SettlingTime);
                }
            }
        }
    }
}
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;
}
Пример #7
0
static int __init touchLED_probe(struct platform_device *pdev)
{
    s_touchLED.conn = NvOdmPeripheralGetGuid( NV_ODM_GUID('t','o','u','c','h','L','E','D') );

    /* enable the power rail */
    s_touchLED.hPmu = NvOdmServicesPmuOpen();
    if( s_touchLED.conn->AddressList[0].Interface == NvOdmIoModule_Vdd )
    {
        NvOdmServicesPmuVddRailCapabilities cap;
        NvU32 settle_us;

        /* address is the vdd rail id */
        NvOdmServicesPmuGetCapabilities( s_touchLED.hPmu,
            s_touchLED.conn->AddressList[0].Address, &cap );

        s_touchLED.setVal = cap.requestMilliVolts;
        s_touchLED.maxVal = 100;    /*10.0mA*/

        /* set the rail volatage to the recommended */
        NvOdmServicesPmuSetVoltage( s_touchLED.hPmu,
            s_touchLED.conn->AddressList[0].Address, cap.requestMilliVolts,
            &settle_us );

        /* wait for rail to settle */
        NvOdmOsWaitUS( settle_us );
    }
    INIT_WORK(&s_touchLED.work, touchLED_timeout);

#ifdef TOUCH_LED_TIMER 
    hrtimer_init(&s_touchLED.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    s_touchLED.timer.function = touchLED_timer_func;
    s_touchLED.delay = TOUCH_DELAY_SEC;
    hrtimer_start(&s_touchLED.timer, ktime_set(BOOT_DELAY_SEC, 0), HRTIMER_MODE_REL);
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
    s_touchLED.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    s_touchLED.early_suspend.suspend = touchLED_early_suspend;
    s_touchLED.early_suspend.resume = touchLED_late_resume;
    register_early_suspend(&s_touchLED.early_suspend);
#endif

    //20101104, [email protected], WLED set [START]
    if (sysfs_create_group(&pdev->dev.kobj, &star_wled_group)) {
        printk(KERN_ERR "[star touch led] sysfs_create_group ERROR\n");
    }
    //20101104, [email protected], WLED set [END]

    return 0;
}
Пример #8
0
void NvAccelerometerSetPowerRail(NvOdmServicesPmuHandle hPMUDevice, NvU32 Id, NvBool IsEnable)
{
    NvOdmServicesPmuVddRailCapabilities vddrailcap;
    NvU32 settletime;

    if (hPMUDevice)
    {       
        NvOdmServicesPmuGetCapabilities(hPMUDevice, Id, &vddrailcap);
        if (IsEnable)
        {
            NvOdmServicesPmuSetVoltage(hPMUDevice, Id, vddrailcap.requestMilliVolts, &settletime);
        }
        else
        {
            NvOdmServicesPmuSetVoltage(hPMUDevice, Id, vddrailcap.MinMilliVolts, &settletime);
        }
        NvOdmOsWaitUS(settletime);  // wait to settle power
    }
}
Пример #9
0
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
	}
}
Пример #10
0
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
}
Пример #11
0
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
}
Пример #12
0
// 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;
}
/**
 *  @brief Allocates a handle to the device. Configures the PWM
 *   control to the Vibro motor with default values. To change
 *   the amplitude and frequency use NvOdmVibrateSetParameter API.
 *  @param hOdmVibrate  [IN] Opaque handle to the device.
 *  @return  NV_TRUE on success and NV_FALSE on error
 */
NvBool
NvOdmVibOpen(NvOdmVibDeviceHandle *hOdmVibrate)
{
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;
    NvU32 Index = 0;

    NV_ASSERT(hOdmVibrate);

    /* Allocate the handle */
    (*hOdmVibrate) = (NvOdmVibDeviceHandle)NvOdmOsAlloc(sizeof(NvOdmVibDevice));
    if (*hOdmVibrate == NULL)
    {
        NV_ODM_TRACE(("Error Allocating NvOdmPmuDevice. \n"));
        return NV_FALSE;
    }
    NvOsMemset((*hOdmVibrate), 0, sizeof(NvOdmVibDevice));
#if (defined(CONFIG_7546Y_V10))    /*HZJ ADD FOR VIBRATE*/
   (*hOdmVibrate)->vibrate_gpio= NvOdmGpioOpen();
	if (!(*hOdmVibrate)->vibrate_gpio) {
		NV_ODM_TRACE("err open gpio vibrate hzj added\r\n");
		kfree(*hOdmVibrate);
		return -1;
	}	

   	(*hOdmVibrate)->vibrate_pin = NvOdmGpioAcquirePinHandle((*hOdmVibrate)->vibrate_gpio, VIBRATE_DET_ENABLE_PORT, VIBRATE_DET_ENABLE_PIN);
	if (!(*hOdmVibrate)->vibrate_pin) {
		NV_ODM_TRACE("err acquire detect pin handle vibrate\r\n");
		NvOdmGpioClose((*hOdmVibrate)->vibrate_gpio);
		return -1;
	}

	NvOdmGpioConfig((*hOdmVibrate)->vibrate_gpio, (*hOdmVibrate)->vibrate_pin, NvOdmGpioPinMode_Output);
  /*End Hzj aded*/ 
   (*hOdmVibrate)->vibrate_segpio= NvOdmGpioOpen();
	if (!(*hOdmVibrate)->vibrate_segpio) {
		NV_ODM_TRACE("err open gpio vibrate hzj added\r\n");
		kfree(*hOdmVibrate);
		return -1;
	}

   	(*hOdmVibrate)->vibrate_sepin = NvOdmGpioAcquirePinHandle((*hOdmVibrate)->vibrate_segpio, VIBRATE_SE_PORT, VIBRATE_SE_PIN);
	if (!(*hOdmVibrate)->vibrate_sepin) {
		NV_ODM_TRACE("err acquire detect pin handle vibrate\r\n");
		NvOdmGpioClose((*hOdmVibrate)->vibrate_segpio);
		return -1;
	}

	NvOdmGpioConfig((*hOdmVibrate)->vibrate_segpio, (*hOdmVibrate)->vibrate_sepin, NvOdmGpioPinMode_Output);
  
#endif
    /* Get the PMU handle */
    (*hOdmVibrate)->hOdmServicePmuDevice = NvOdmServicesPmuOpen();
    if (!(*hOdmVibrate)->hOdmServicePmuDevice)
    {
        NV_ODM_TRACE(("Error Opening Pmu device. \n"));
        NvOdmOsFree(*hOdmVibrate);
        *hOdmVibrate = NULL;
        return NV_FALSE;
    }

        // Get the peripheral connectivity information
    pConnectivity = NvOdmPeripheralGetGuid(VIBRATE_DEVICE_GUID);
    if (pConnectivity == NULL)
        return NV_FALSE;

        // Search for the Vdd rail and set the proper volage to the rail.
    for (Index = 0; Index < pConnectivity->NumAddress; ++Index)
    {
        if (pConnectivity->AddressList[Index].Interface == NvOdmIoModule_Vdd)
        {
            (*hOdmVibrate)->VddId = pConnectivity->AddressList[Index].Address;
            NvOdmServicesPmuGetCapabilities((*hOdmVibrate)->hOdmServicePmuDevice, (*hOdmVibrate)->VddId, &((*hOdmVibrate)->RailCaps));
            break;
        }
    }

    return NV_TRUE;
}
Пример #14
0
static int headsetdet_probe(struct platform_device *pdev)
{
	struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;
	struct headset_switch_data *switch_data;
	int ret = 0;
	NvS32 err = 0;

	struct input_dev *ip_dev;  
    struct input_dev *ip_dev_wake; 

    int i, j;
    NvU32 I2cInstance = 0;
    NvU32 pin[4], port[4];
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;

    pConnectivity = NvOdmPeripheralGetGuid(HEADSET_GUID);

    for (i = 0, j = 0 ; i < pConnectivity->NumAddress; i++)
    {
        switch (pConnectivity->AddressList[i].Interface)
        {
            case NvOdmIoModule_Gpio:
                port[j] = pConnectivity->AddressList[i].Instance;
                pin[j] = pConnectivity->AddressList[i].Address;
                j++;
                break;
            //20101117, [email protected], gpio wakeup from LP1 [START]
            case NvOdmIoModule_Vdd:
                {
                    NvOdmServicesPmuVddRailCapabilities vddrailcap;

                    headset_h_pmu = NvOdmServicesPmuOpen();
                    headset_vdd_address = pConnectivity->AddressList[i].Address;
                    NvOdmServicesPmuGetCapabilities(headset_h_pmu, pConnectivity->AddressList[i].Address, &vddrailcap);
                    headset_vdd_voltage = vddrailcap.requestMilliVolts;
                }
                break;
            //20101117, [email protected], gpio wakeup from LP1 [END]
            default:
                break;
        }
    }

	if (!pdata)
		return -EBUSY;
	switch_data = kzalloc(sizeof(struct headset_switch_data), GFP_KERNEL);
	if (!switch_data)
		return -ENOMEM;

	switch_data->sdev.name = pdata->name;
	switch_data->gpio = pdata->gpio;
	switch_data->name_on = pdata->name_on;
	switch_data->name_off = pdata->name_off;
	switch_data->state_on = pdata->state_on;
	switch_data->state_off = pdata->state_off;
	switch_data->sdev.print_state = switch_gpio_print_state;


	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headsetdet_probe() => headset detection started..!!\n");	//20100421 [email protected] [LGE]

    ret = switch_dev_register(&switch_data->sdev);	//20100421 [email protected] Headset Detection by Headset Observer [LGE]
	if (ret < 0)
		goto err_switch_dev_register;

	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - switch device registered..!!\n");	//20100421 [email protected] [LGE]


/*====================== nVidia GPIO Control(S) =======================*/

    s_hHeadsetHandle.hGpio = NvOdmGpioOpen();
    if (!s_hHeadsetHandle.hGpio)
    {
        lprintk(D_AUDIO, "%s: NvOdmGpioOpen Error \n", __func__);
        goto err_open_gpio_fail;
    }
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - NvOdmGpioOpen() success..!! : s_hHeadsetHandle.hGpio = %d, port[0] = %d, pin[0] = %d\n", s_hHeadsetHandle.hGpio, port[0], pin[0]);	//20100421 [email protected] [LGE]


    s_hHeadsetHandle.h_Headset_Detection = NvOdmGpioAcquirePinHandle(s_hHeadsetHandle.hGpio, port[0], pin[0]);
    if (!s_hHeadsetHandle.h_Headset_Detection)
    {
        lprintk(D_AUDIO, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - NvOdmGpioAcquirePinHandle() success..!!\n");	//20100421 [email protected] [LGE]


    NvOdmGpioConfig(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection, NvOdmGpioPinMode_InputData/*NvOdmGpioPinMode_InputInterruptHigh*/);
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - NvOdmGpioConfig() success..!! - NvOdmGpioPinMode_InputData");	//20100421 [email protected] [LGE]



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

    NvOdmGpioConfig(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection, NvOdmGpioPinMode_InputData);
	ip_dev = input_allocate_device();
    
	switch_data->ip_dev = ip_dev;
	set_bit(EV_SYN, switch_data->ip_dev->evbit);
	set_bit(EV_KEY, switch_data->ip_dev->evbit);
	set_bit(KEY_HOOK, switch_data->ip_dev->keybit); 
	switch_data->ip_dev->name = "star_headset_hook";

    ip_dev_wake = input_allocate_device();
    switch_data->ip_dev_wake = ip_dev_wake;
	set_bit(EV_SYN, switch_data->ip_dev_wake->evbit);
	set_bit(EV_KEY, switch_data->ip_dev_wake->evbit);
	set_bit(KEY_VOLUMEDOWN, switch_data->ip_dev_wake->keybit); 
	switch_data->ip_dev_wake->name = "star_headset_wake";

		
	ret = input_register_device(switch_data->ip_dev);  
	INIT_DELAYED_WORK(&switch_data->hook_delayed_work, hook_det_work);
    if (NvOdmGpioInterruptRegister(s_hHeadsetHandle.hGpio, &s_hHeadsetHandle.hhookInterrupt,
        s_hHeadsetHandle.h_Hookkey_Detection, NvOdmGpioPinMode_InputInterruptAny, headset_hook_int_handler,
        switch_data, 0) == NV_FALSE)
    {
        lprintk(D_AUDIO, KERN_ERR "%s: cannot register interrupt.\n", __func__);
        goto err_get_interrupt_handler;
    }

	block_hook_int =1;
//20101005 [email protected] Gpio MicBias[START_LGE_LAB1]
#if defined(STAR_COUNTRY_KR)&& !defined(CONFIG_MACH_STAR_SKT_REV_A)
    s_hHeadsetHandle.h_Headset_MicBias = NvOdmGpioAcquirePinHandle(s_hHeadsetHandle.hGpio, port[2], pin[2]);
    if (!s_hHeadsetHandle.h_Headset_MicBias)
    {
        lprintk(D_AUDIO, "%s: Couldn't NvOdmGpioAcquirePinHandle  pin \n", __func__);
        goto err_open_gpio_pin_acquire_fail;
    }
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset MicBias - NvOdmGpioAcquirePinHandle() success..!!\n");	//20100421 [email protected] [LGE]

    NvOdmGpioConfig(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_MicBias, NvOdmGpioPinMode_Output);
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset MicBias- NvOdmGpioConfig() success..!! - NvOdmGpioPinMode_Output");	//20100421 [email protected] [LGE]
#endif
//20101005 [email protected] Gpio MicBias[END_LGE_LAB1]

	INIT_WORK(&switch_data->work, headset_det_work);
    INIT_DELAYED_WORK(&switch_data->delayed_work, type_det_work);
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - INIT_WORK() & INIT_DELAYED_WORK() success..!!\n");	//20100421 [email protected] [LGE]

    if (NvOdmGpioInterruptRegister(s_hHeadsetHandle.hGpio, &s_hHeadsetHandle.hheadsetInterrupt,
        s_hHeadsetHandle.h_Headset_Detection, NvOdmGpioPinMode_InputInterruptAny/*NvOdmGpioPinMode_InputInterruptFallingEdge*//*NvOdmGpioPinMode_InputInterruptRisingEdge*/, headset_int_handler,
        switch_data, 0) == NV_FALSE)
    {
        lprintk(D_AUDIO, KERN_ERR "%s: cannot register interrupt.\n", __func__);
        goto err_get_interrupt_handler;
    }
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - NvOdmGpioInterruptRegister() success..!!\n");	//20100421 [email protected] [LGE]

    //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [START]
    //wake_lock_init(&hook_det_lock, WAKE_LOCK_SUSPEND, "hook_det_wake");
    //20101125, [email protected], hookkey press is skipped When wakeup from LP1 [END]

/*====================== nVidia GPIO Control(E) =======================*/

	/* Perform initial detection */
	headset_sw_data = switch_data;

//P990_IFX_GB_PORTING_LGSI_START
//FIDO - GB Porting [09/08/2011] - Start
#if 1 //defined (STAR_OPERATOR_FIDO)
       wake_lock_init(&headset_wake_lock, WAKE_LOCK_SUSPEND, "headset_wlock");		 //20110425 [email protected] headset wake lock timeout
#endif
//FIDO - GB Porting [09/08/2011] - End
//P990_IFX_GB_PORTING_LGSI_END

	

	
	//headset_det_work(&switch_data->work);
	lprintk(D_AUDIO, KERN_ERR "##(Headset_det.c)## headset detection - headset_det_work() first detection - success..!!\n"); //20100421 [email protected] [LGE]	

	err = device_create_file(&pdev->dev, &dev_attr_detect);
    err = device_create_file(&pdev->dev, &dev_attr_block_hook);
    err = device_create_file(&pdev->dev, &dev_attr_factory_test);
	return 0;

err_open_gpio_fail:	
    switch_dev_unregister(&switch_data->sdev);
err_switch_dev_register:
	kfree(switch_data);
err_open_gpio_pin_acquire_fail:
	NvOdmGpioClose(s_hHeadsetHandle.hGpio);
err_get_interrupt_handler:
    NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Headset_Detection);
	
    NvOdmGpioReleasePinHandle(s_hHeadsetHandle.hGpio, s_hHeadsetHandle.h_Hookkey_Detection);	//20100421 [email protected] for Hookkey [LGE]
    

	return ret;
}
Пример #15
0
/**
 *  @brief Allocates a handle to the device. Configures the PWM
 *   control to the Vibro motor with default values. To change
 *   the amplitude and frequency use NvOdmVibrateSetParameter API.
 *  @param hOdmVibrate  [IN] Opaque handle to the device.
 *  @return  NV_TRUE on success and NV_FALSE on error
 */
NvBool
NvOdmVibOpen(NvOdmVibDeviceHandle *hOdmVibrate)
{

#if 1	/* yuyang(20100615):Create I2C handle */
	const NvOdmPeripheralConnectivity *pConnectivity = NULL;
    NvU32 Index = 0;
    NvU32 I2cInstance = 0;

    NV_ASSERT(hOdmVibrate);

    /* Allocate the handle */
    (*hOdmVibrate) = (NvOdmVibDeviceHandle)NvOdmOsAlloc(sizeof(NvOdmVibDevice));
    if (*hOdmVibrate == NULL)
    {
        NV_ODM_TRACE(("Error Allocating NvOdmPmuDevice. \n"));
        return NV_FALSE;
    }
    NvOsMemset((*hOdmVibrate), 0, sizeof(NvOdmVibDevice));

    /* Get the PMU handle */
    (*hOdmVibrate)->hOdmServicePmuDevice = NvOdmServicesPmuOpen();

    if (!(*hOdmVibrate)->hOdmServicePmuDevice)
    {
        NV_ODM_TRACE(("Error Opening Pmu device. \n"));
        NvOdmOsFree(*hOdmVibrate);
        *hOdmVibrate = NULL;
        return NV_FALSE;
    }

    // Get the peripheral connectivity information
    pConnectivity = NvOdmPeripheralGetGuid(VIBRATE_DEVICE_GUID);
    if (pConnectivity == NULL)
    {
        NV_ODM_TRACE(("Error pConnectivity NULL. \n"));
        return NV_FALSE;
    }

	for (Index = 0; Index < pConnectivity->NumAddress; ++Index)
    {
        switch (pConnectivity->AddressList[Index].Interface)
        {
			case NvOdmIoModule_I2c:
                (*hOdmVibrate)->DeviceAddr = (pConnectivity->AddressList[Index].Address);
                I2cInstance = pConnectivity->AddressList[Index].Instance;
                NV_ODM_TRACE("%s: hTouch->DeviceAddr = 0x%x, I2cInstance = %x\n", __func__, (*hOdmVibrate)->DeviceAddr, I2cInstance); 
                break;
            case NvOdmIoModule_Vdd:
                (*hOdmVibrate)->VddId = pConnectivity->AddressList[Index].Address;
                NvOdmServicesPmuGetCapabilities((*hOdmVibrate)->hOdmServicePmuDevice, (*hOdmVibrate)->VddId, &((*hOdmVibrate)->RailCaps));
                break;
            default:
                break;
        }
    }

	(*hOdmVibrate)->hOdmI2c = NvOdmI2cOpen(NvOdmIoModule_I2c_Pmu, I2cInstance);

	if (!(*hOdmVibrate)->hOdmI2c)
    {
        NV_ODM_TRACE(("NvOdm Touch : NvOdmI2cOpen Error \n"));
        return NV_FALSE;
    }
#else
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;
    NvU32 Index = 0;

    NV_ASSERT(hOdmVibrate);

    /* Allocate the handle */
    (*hOdmVibrate) = (NvOdmVibDeviceHandle)NvOdmOsAlloc(sizeof(NvOdmVibDevice));
    if (*hOdmVibrate == NULL)
    {
        NV_ODM_TRACE(("Error Allocating NvOdmPmuDevice. \n"));
        return NV_FALSE;
    }
    NvOsMemset((*hOdmVibrate), 0, sizeof(NvOdmVibDevice));

    /* Get the PMU handle */
    (*hOdmVibrate)->hOdmServicePmuDevice = NvOdmServicesPmuOpen();
    if (!(*hOdmVibrate)->hOdmServicePmuDevice)
    {
        NV_ODM_TRACE(("Error Opening Pmu device. \n"));
        NvOdmOsFree(*hOdmVibrate);
        *hOdmVibrate = NULL;
        return NV_FALSE;
    }

        // Get the peripheral connectivity information
    pConnectivity = NvOdmPeripheralGetGuid(VIBRATE_DEVICE_GUID);
    if (pConnectivity == NULL)
        return NV_FALSE;

        // Search for the Vdd rail and set the proper volage to the rail.
    for (Index = 0; Index < pConnectivity->NumAddress; ++Index)
    {
        if (pConnectivity->AddressList[Index].Interface == NvOdmIoModule_Vdd)
        {
            (*hOdmVibrate)->VddId = pConnectivity->AddressList[Index].Address;
            NvOdmServicesPmuGetCapabilities((*hOdmVibrate)->hOdmServicePmuDevice, (*hOdmVibrate)->VddId, &((*hOdmVibrate)->RailCaps));
            break;
        }
    }
#endif	/* __yuyang(20100615) */

    return NV_TRUE;
}
Пример #16
0
NvBool Adt7461Init(NvOdmTmonDeviceHandle hTmon)
{
    NvU8 Data;
    NvBool ExtRange;
    NvU32 i = 0;
    NvU32 I2cInstance = 0;
    NvOdmIoModule I2cModule = NvOdmIoModule_Num;    // Inavlid module
    const ADT7461RegisterInfo* pReg = NULL;
    ADT7461PrivData* pPrivData = NULL;
    
    NV_ASSERT(hTmon && hTmon->pConn && hTmon->pConn->AddressList);
    
    // Allocate and clear priavte data
    pPrivData = (ADT7461PrivData*) NvOdmOsAlloc(sizeof(ADT7461PrivData));
    if (pPrivData == NULL)
    {
        NVODM_ADT7461_PRINTF(("ADT7461: Error Allocating PrivData. \n"));
        return NV_FALSE;
    }
    NvOdmOsMemset(pPrivData, 0, sizeof(ADT7461PrivData));
    hTmon->pPrivate = pPrivData;

    // Register for PMU services
    pPrivData->hOdmPmuSevice = NvOdmServicesPmuOpen();
    if (pPrivData->hOdmPmuSevice == NULL)
    {
        NVODM_ADT7461_PRINTF(("ADT7461: Error Open PMU service. \n"));
        goto fail;
    }

    // Register for GPIO services
    pPrivData->hGpio = NvOdmGpioOpen();
    if (pPrivData->hOdmPmuSevice == NULL)
    {
        NVODM_ADT7461_PRINTF(("ADT7461: Error Open GPIO service. \n"));
        goto fail;
    }

    /*
     * Parse connectivity data: turn On power to the device, acquire I2C
     * interface and GPIO interrupt (optional); map device channels to
     * thermal zones
     */
    for (i = 0; i < hTmon->pConn->NumAddress; i ++)
    {
        const NvOdmIoAddress* pIoAddress = &hTmon->pConn->AddressList[i];
        if (pIoAddress->Interface == NvOdmIoModule_I2c_Pmu)
        {
            I2cModule   = NvOdmIoModule_I2c_Pmu;
            I2cInstance = pIoAddress->Instance;
            NV_ASSERT(pIoAddress->Address != 0);
            pPrivData->DeviceI2cAddr = pIoAddress->Address;
        }
        else if (pIoAddress->Interface == NvOdmIoModule_Tsense)
        {
            NV_ASSERT(pIoAddress->Instance < NvOdmTmonZoneID_Num);
            NV_ASSERT(pIoAddress->Address < ADT7461ChannelID_Num);
            pPrivData->ConnectivityMap[pIoAddress->Instance] =
                pIoAddress->Address;
        }
        else if (pIoAddress->Interface == NvOdmIoModule_Vdd)
        {
            NvU32 usec = 0;
            NvU32 RailAddress = pIoAddress->Address;
            NvOdmServicesPmuVddRailCapabilities RailCapabilities;
            NvOdmServicesPmuGetCapabilities(
                pPrivData->hOdmPmuSevice, RailAddress, &RailCapabilities);
            NvOdmServicesPmuSetVoltage(pPrivData->hOdmPmuSevice, RailAddress,
                              RailCapabilities.requestMilliVolts, &usec);
            NvOdmOsWaitUS(usec + (ADT7461_POWERUP_DELAY_MS * 1000));
        }
        else if (pIoAddress->Interface == NvOdmIoModule_Gpio)
        {
            NvU32 port = pIoAddress->Instance;
            NvU32 pin = pIoAddress->Address;
            pPrivData->hGpioPin = NvOdmGpioAcquirePinHandle(
                pPrivData->hGpio, port, pin);
        }

    }
    NV_ASSERT(I2cModule == NvOdmIoModule_I2c_Pmu);
    pPrivData->hOdmI2C = NvOdmI2cOpen(I2cModule, I2cInstance);
    if (pPrivData->hOdmI2C == NULL)
    {
        NVODM_ADT7461_PRINTF(("ADT7461: Error Open I2C device. \n"));     
        goto fail;
    }

    /*
     * Initialize device info and configuration. Force standby mode to avoid
     * glitch on shutdown comparator output when temperature range and/or
     * comparator limit is changing during initialization. The Adt7461Run()
     * call from the hal that follows initialization will switch device to
     * run mode and re-start temperature monitoring (note that out of limit
     * interrupt is always masked during and after initialization)
     */
    pPrivData->pDeviceInfo = &s_Adt7461Info;
    pPrivData->ShadowRegPtr = ADT7461_INVALID_ADDR;

    pReg = &pPrivData->pDeviceInfo->Config;
    if (!Adt7461ReadReg(pPrivData, pReg, &Data))
        goto fail;
    if ((Data & ADT7461ConfigBits_ExtendedRange) !=
        (ADT7461_INITIAL_CONFIG & ADT7461ConfigBits_ExtendedRange))
    {
        // Only switch from standard to extended range is supported
        NV_ASSERT((Data & ADT7461ConfigBits_ExtendedRange) == 0);
        Data |= ADT7461ConfigBits_Standby;
        if(!Adt7461WriteReg(pPrivData, pReg, Data))
            goto fail;
    }
    Data = ADT7461_INITIAL_CONFIG | ADT7461ConfigBits_Standby;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;
    pPrivData->ShadowConfig = Data;
#if PRE_ER_GMT_THERMALSENSOR
    ExtRange = 0; /* not support ADT thermal sensor*/
#else
    ExtRange = ((Data & ADT7461ConfigBits_ExtendedRange) != 0);	
#endif
    // Program shutdown comparators settings
    Data = ADT7461_T_VALUE_TO_DATA(
        ExtRange, ADT7461_ODM_LOCAL_COMPARATOR_LIMIT_VALUE);
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Local].ComparatorLimit;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;

    Data = ADT7461_T_VALUE_TO_DATA(
        ExtRange, ADT7461_ODM_REMOTE_COMPARATOR_LIMIT_VALUE);
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Remote].ComparatorLimit;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;

    // Set interrupt limits to the range boundaries to prevent out of limit
    // interrupt
    Data = ADT7461_T_VALUE_TO_DATA(
        ExtRange, ADT7461_T_RANGE_LIMIT_HIGH(ExtRange)); 
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Local].IntrLimitHigh;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Remote].IntrLimitHigh;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;

    Data = ADT7461_T_VALUE_TO_DATA(
            ExtRange, ADT7461_T_RANGE_LIMIT_LOW(ExtRange));
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Local].IntrLimitLow;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Remote].IntrLimitLow;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;

    // Set initial rate
    Data = ADT7461_INITIAL_RATE_SETTING;  
    pReg = &pPrivData->pDeviceInfo->Rate;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;
    pPrivData->ShadowRate = Data;

    // Set remote channel offset (8-bit 2's complement value for any range)
    Data = ((NvU8)ADT7461_ODM_REMOTE_OFFSET_VALUE);
    pReg = &pPrivData->pDeviceInfo->Channels[
        ADT7461ChannelID_Remote].Toffset;
    if(!Adt7461WriteReg(pPrivData, pReg, Data))
        goto fail;

    // Read ADT7461 status and ARA (clear pending Alert interrupt, if any)
    pReg = &pPrivData->pDeviceInfo->Status;
    if (!Adt7461ReadReg(pPrivData, pReg, &Data))
        goto fail;
    // TODO: check open remote circuit error

    Adt7461ReadAra(pPrivData);

    return NV_TRUE;

fail:
    Adt7461FreePrivData(pPrivData);
    hTmon->pPrivate = NULL;
    return NV_FALSE;
}
Пример #17
0
int __devinit tegra_sdhci_simple_probe(struct platform_device *pdev)
{
	struct tegra_sdhci_simple *host;
	struct tegra_sdhci_simple_platform_data *pdata = pdev->dev.platform_data;
	NvOdmPeripheralConnectivity *pConn;
	NvU32 NumOfGuids = 1;
	NvU64 guid;
	NvU32 searchVals[4];
	const NvOdmPeripheralSearch searchAttrs[] = {
		NvOdmPeripheralSearch_PeripheralClass,
		NvOdmPeripheralSearch_IoModule,
		NvOdmPeripheralSearch_Instance,
		NvOdmPeripheralSearch_Address,
	};
	int i, ret = -ENODEV;

	pr_info("%s", __func__);
	if (pdev->id == -1) {
		dev_err(&pdev->dev, "dynamic instance assignment not allowed\n");
		return -ENODEV;
	}

	host = &tegra_sdhci_simple_host;

	/*
	 * Emulate NvOdmSdioOpen() to avoid heap usage and power on request
	 */
	searchVals[0] =  NvOdmPeripheralClass_Other;
	searchVals[1] =  NvOdmIoModule_Sdio;
	searchVals[2] =  pdev->id;
	searchVals[3] =  0;

	NumOfGuids = NvOdmPeripheralEnumerate(searchAttrs,
					      searchVals,
					      4,
					      &guid,
					      NumOfGuids);

	pConn = (NvOdmPeripheralConnectivity*)NvOdmPeripheralGetGuid(guid);
	if (pConn == NULL)
		goto err_odm;

	for (i = 0; i < pConn->NumAddress; i++)
	{
		if (pConn->AddressList[i].Interface == NvOdmIoModule_Vdd)
		{
			host->VddAddress = pConn->AddressList[i].Address;
			NvOdmServicesPmuGetCapabilities(host->hPmu,
							host->VddAddress,
							&host->VddRailCaps);
		}
	}
	host->hPmu = NvOdmServicesPmuOpen();
	if (host->hPmu == NULL) {
		pr_err("%s: failed to open PMU\n", __func__);
		goto err_odm;
	}

	for (i = 0; i < pdata->num_resources; i++) {
		if (pdata->resource &&
		    pdata->resource[i].flags & IORESOURCE_MEM &&
		    pdata->resource[i].end - pdata->resource[i].start > 0)
			break;
	}

	if (i >= pdata->num_resources) {
		dev_err(&pdev->dev, "no memory I/O resource provided\n");
		ret = -ENODEV;
		goto err_odm;
	}

	host->ioaddr = ioremap(pdata->resource[i].start,
			       pdata->resource[i].end -
					pdata->resource[i].start + 1);

	host->clk = clk_get_sys(pdata->clk_dev_name, NULL);
	if (!host->clk) {
		dev_err(&pdev->dev, "unable to get clock %s\n", pdata->clk_dev_name);
		ret = -ENODEV;
		goto err_ioremap;
	}

	host->pdev = pdev;
	host->pinmux = pdata->sdhci_pdata->pinmux;
	host->nr_pins = pdata->sdhci_pdata->nr_pins;
	if (pdata->sdhci_pdata->max_clk)
		host->max_clk = min_t(unsigned int, 52000000, pdata->sdhci_pdata->max_clk);
	else {