Beispiel #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) */
}
Beispiel #2
0
static bool star_accel_i2c_write_data( star_accel_device *accel, unsigned char reg, unsigned char* data, unsigned char len )
{
	NvOdmI2cStatus i2c_status;
	NvOdmI2cTransactionInfo info;
	unsigned char* transfer_data;

	transfer_data = (unsigned char*)NvOdmOsAlloc(len+1);
    transfer_data[0] = reg; 
    NvOdmOsMemcpy( &transfer_data[1], data, (size_t)len);

    info.Address = accel->i2c_address;
    info.Buf = transfer_data;
    info.Flags = NVODM_I2C_IS_WRITE;
    info.NumBytes = len+1;
	
	do{  
        i2c_status = NvOdmI2cTransaction( accel->h_gen2_i2c, &info, 1, 400, 1000 );
    }while(i2c_status == NvOdmI2cStatus_Timeout);

    if( i2c_status != NvOdmI2cStatus_Success )
    {    
        printk("[star accel driver] %s : i2c transaction error(Number = %d)!\n",__func__,i2c_status);
        goto err; 
    }    
    NvOdmOsFree(transfer_data); 
    return true;
err:
    NvOdmOsFree(transfer_data);
    return false;
}
void Pcf50626Release(NvOdmPmuDeviceHandle hDevice)
{
    if (hDevice->pPrivate != NULL)
    {
        if (((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice != NULL)
        {
            NvOdmServicesPmuClose(((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice);
            ((Pcf50626PrivData*)hDevice->pPrivate)->hOdmPmuSevice = NULL;
        }
        
        if (((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C != NULL)
        {
            NvOdmI2cClose(((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C);
            ((Pcf50626PrivData*)hDevice->pPrivate)->hOdmI2C = NULL;
        }

        if (((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable != NULL)
        {
            NvOdmOsFree(((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable);
            ((Pcf50626PrivData*)hDevice->pPrivate)->supplyRefCntTable = NULL;
        }

        NvOdmOsFree(hDevice->pPrivate);
        hDevice->pPrivate = NULL;
    }
}
void 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);
}
Beispiel #5
0
void NvOdmUsbUlpiClose(NvOdmUsbUlpiHandle hOdmUlpi)
{
    if (hOdmUlpi)
    {
        NvOdmOsFree(hOdmUlpi);
        hOdmUlpi = NULL;
    }
}
NvOdmUsbUlpiHandle NvOdmUsbUlpiOpen(NvU32 Instance)
{
    NvOdmUsbUlpi*pDevice = NULL;
    NvU32 ClockInstances[MAX_CLOCKS];
    NvU32 ClockFrequencies[MAX_CLOCKS];
    NvU32 NumClocks;

    pDevice = NvOdmOsAlloc(sizeof(NvOdmUsbUlpi));
    if(pDevice == NULL)
		return NULL;
    
    if(!NvOdmExternalClockConfig(SMSC3317GUID, NV_FALSE, ClockInstances,
					ClockFrequencies, &NumClocks))
    {
        NV_DRIVER_TRACE (("ERROR NvOdmUsbUlpiOpen: "
				"NvOdmExternalClockConfig fail\n"));
        goto ExitUlpiOdm;
    }
    NvOdmOsSleepMS(10);

    if (!s_hGpio)
        s_hGpio = NvOdmGpioOpen();
    if (!s_hGpio)
    {
        NV_DRIVER_TRACE (("ERROR NvOdmUsbUlpiOpen: "
				"Not able to open gpio handle\n"));
        goto ExitUlpiOdm;
    }

    if (!s_hResetPin)
        s_hResetPin = NvOdmGpioAcquirePinHandle(s_hGpio, ULPI_RESET_PORT,
							ULPI_RESET_PIN);
    if (!s_hResetPin)
    {
        NvOdmGpioClose(s_hGpio);
        s_hGpio = NULL;
        NV_DRIVER_TRACE (("ERROR NvOdmGpioAcquirePinHandle: "
					"Not able to Acq pinhandle\n"));
        goto ExitUlpiOdm;
    }

    // Pull high on RESETB ( 22nd pin of smsc3315) 
    // config as out put pin
    NvOdmGpioConfig(s_hGpio,s_hResetPin, NvOdmGpioPinMode_Output);
    // Set low to write high on ULPI_RESETB pin
    NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x01);
    NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x0);
    NvOdmOsSleepMS(5);
    NvOdmGpioSetState(s_hGpio, s_hResetPin, 0x01);

    pDevice->CurrentGUID = SMSC3317GUID;
    return pDevice;

ExitUlpiOdm:
    NvOdmOsFree(pDevice);
    return NULL;
}
void
NvOdmMouseDeviceClose(
    NvOdmMouseDeviceHandle hDevice)
{
    if (hDevice)
    {
        // close channel to the EC
        NvEcClose(hDevice->hEc);
        hDevice->hEc = NULL;
        // Free the request/response structure objects
        NvOdmOsFree(hDevice->pRequest);
        hDevice->pRequest = NULL;
        NvOdmOsFree(hDevice->pResponse);
        hDevice->pResponse = NULL;
        NvOdmOsFree(hDevice->pEvent);
        hDevice->pEvent = NULL;
        NvOdmOsFree(hDevice);
        hDevice = NULL;
    }
}
Beispiel #8
0
static bool star_accel_i2c_read_data( star_accel_device *accel, unsigned char reg, unsigned char* data, unsigned char len )
{
	NvOdmI2cStatus i2c_status;
    NvOdmI2cTransactionInfo info[2];
    unsigned char* transfer_data;

	transfer_data = (unsigned char*)NvOdmOsAlloc(len);

	#if STAR_ACCEL_DEBUG
	//printk("address = %#x\n", g_accel->i2c_address);
	#endif

    info[0].Address = g_accel->i2c_address;
    info[0].Buf = ®
    info[0].Flags = NVODM_I2C_IS_WRITE;
    info[0].NumBytes = 1;

    info[1].Address = ( g_accel->i2c_address | 0x01 );
    info[1].Buf = transfer_data;
    info[1].Flags = 0;
    info[1].NumBytes = len;

    do{
        i2c_status = NvOdmI2cTransaction( g_accel->h_gen2_i2c, info, 2, 400, 1000 );
    }while( i2c_status == NvOdmI2cStatus_Timeout );

    if( i2c_status != NvOdmI2cStatus_Success )
    {
        printk("[star driver] %s : i2c transaction error(Number= %d)!\n",__func__, i2c_status);
        goto err;
    }
    NvOdmOsMemcpy( data, transfer_data, len );
    NvOdmOsFree(transfer_data);
    return true;
err:
    NvOdmOsFree(transfer_data);
    return false;

}
Beispiel #9
0
NvOdmUartHandle NvOdmUartOpen(NvU32 Instance)
{
    NvOdmUart *pDevice = NULL;
    NvOdmPeripheralConnectivity *pConnectivity;
    NvU32 NumOfGuids = 1;
    NvU64 guid;
    NvU32 searchVals[2];
    const NvOdmPeripheralSearch searchAttrs[] =
    {
        NvOdmPeripheralSearch_IoModule,
        NvOdmPeripheralSearch_Instance,
    };
    
    searchVals[0] =  NvOdmIoModule_Uart;
    searchVals[1] =  Instance;

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

    pConnectivity = (NvOdmPeripheralConnectivity *)NvOdmPeripheralGetGuid(guid);
    if (pConnectivity == NULL)
        goto ExitUartOdm;
    
    pDevice = NvOdmOsAlloc(sizeof(NvOdmUart));
    if(pDevice == NULL)
        goto ExitUartOdm;
    
    pDevice->hPmu = NvOdmServicesPmuOpen();
    if(pDevice->hPmu == NULL)
    {
        goto ExitUartOdm;
    }

    // Switch On UART Interface

    pDevice->pConnectivity = pConnectivity;
   
    return pDevice;

ExitUartOdm:
    NvOdmOsFree(pDevice);
    pDevice = NULL;
    
    return NULL;
}
Beispiel #10
0
void NvOdmUartClose(NvOdmUartHandle hOdmUart)
{

    if (hOdmUart)
    {
        // Switch OFF UART Interface

        if (hOdmUart->hPmu != NULL)
        {
            NvOdmServicesPmuClose(hOdmUart->hPmu);
        }
        NvOdmOsFree(hOdmUart);
        hOdmUart = NULL;
    }
}
/**
 *  @brief Closes the ODM device and destroys all allocated resources.
 *  @param hOdmVibrate  [IN] Opaque handle to the device.
 *  @return None.
 */
void NvOdmVibClose(NvOdmVibDeviceHandle hOdmVibrate)
{
    if (hOdmVibrate != NULL)
    {
        NvOdmServicesPmuClose(hOdmVibrate->hOdmServicePmuDevice);
        hOdmVibrate->hOdmServicePmuDevice = NULL;

        hOdmVibrate->VddId  = 0;

        NvOsMemset(&hOdmVibrate->RailCaps, 0, sizeof(NvOdmServicesPmuVddRailCapabilities));

        NvOdmOsFree(hOdmVibrate);
        hOdmVibrate = NULL;
    }
}
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);
    }
}
Beispiel #13
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;
    }

}
Beispiel #15
0
NvBool NvOdmVibOpen(NvOdmVibDeviceHandle* hDevice)
{
    NvOdmVibDeviceHandle tVib = NULL;
   
    tVib = kzalloc(sizeof(NvOdmVibrateDevice), GFP_KERNEL);

    if(tVib == NULL)
    {
        NvOdmOsFree(tVib);
        DEBUG_VIBRATOR_TRACE(("[VIBE] : kzalloc of tegra_touch_driver_data fail!\n"));
        return NV_FALSE;
    }
    else
    {
        *hDevice = tVib;
        tVib->CurrentIndex = 248;
        return NV_TRUE;
    }
}
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;
}
void NvOdmBatteryDeviceClose(NvOdmBatteryDeviceHandle hDevice)
{
    NvOdmBatteryDevice *pBattContext = NULL;
    pBattContext = (NvOdmBatteryDevice *)hDevice;

    if (pBattContext->hGpio)
    {
        NvRmGpioReleasePinHandles(pBattContext->hGpio, &pBattContext->hPin,
                  pBattContext->PinCount);
        NvRmGpioClose(pBattContext->hGpio);
    }

    if (pBattContext->hRm)
    {
        NvRmClose(pBattContext->hRm);
        pBattContext->hRm = NULL;
    }
    if (pBattContext)
        NvOdmOsFree(pBattContext);
}
Beispiel #18
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);
}
Beispiel #19
0
NvOdmUsbUlpiHandle NvOdmUsbUlpiOpen(NvU32 Instance)
{
    NvOdmUsbUlpi *pDevice = NULL;
    NvU32 ClockInstances[MAX_CLOCKS];
    NvU32 ClockFrequencies[MAX_CLOCKS];
    NvU32 NumClocks;
    NvOdmServicesGpioHandle hGpio;
    NvOdmGpioPinHandle hResetPin;
    NvU32 Port = NVODM_PORT('v');
    NvU32 Pin = 1;

    pDevice = NvOdmOsAlloc(sizeof(NvOdmUsbUlpi));
    if (pDevice == NULL)
        return NULL;

    if(!NvOdmExternalClockConfig(SMSC3317GUID, NV_FALSE,
                                 ClockInstances, ClockFrequencies, &NumClocks))
    {
        NvOdmOsDebugPrintf("NvOdmUsbUlpiOpen: NvOdmExternalClockConfig fail\n");
        goto ExitUlpiOdm;
    }
    NvOdmOsSleepMS(10);
    // Pull high on RESETB ( 22nd pin of smsc3315)
    hGpio = NvOdmGpioOpen();
    hResetPin = NvOdmGpioAcquirePinHandle(hGpio, Port, Pin);
    // config as out put pin
    NvOdmGpioConfig(hGpio,hResetPin, NvOdmGpioPinMode_Output);
    // Set low to write high on ULPI_RESETB pin
    NvOdmGpioSetState(hGpio, hResetPin, 0x01);
    NvOdmGpioSetState(hGpio, hResetPin, 0x0);
    NvOdmOsSleepMS(5);
    NvOdmGpioSetState(hGpio, hResetPin, 0x01);

    pDevice->CurrentGUID = SMSC3317GUID;
    return pDevice;

ExitUlpiOdm:
    NvOdmOsFree(pDevice);
    return NULL;
}
// setting register
static NvBool Synaptics_OneTouch_WriteRegisterMulti(Synaptics_OneTouch_Device* hTouch, NvU8* buffer, NvU32 len)
{
	int i=0;
	NvOdmI2cStatus Error = NvOdmI2cStatus_Timeout;
    NvOdmI2cTransactionInfo TransactionInfo;
    NvU8 *arr;

    arr = (NvU8*)NvOdmOsAlloc(len);
    if(arr ==NULL)
    {
    	NVODMTOUCH_PRINTF(("[ONETOUCH] cannot alloc memory (len=%d)\n",len));
		return NV_FALSE;
    }

    NvOdmOsMemcpy(&arr[0], buffer, len);// register address
    
    TransactionInfo.Address = hTouch->DeviceAddr;
    TransactionInfo.Buf = arr;
    TransactionInfo.Flags = NVODM_I2C_IS_WRITE;
    TransactionInfo.NumBytes = len;
    
	for (i = 0; i < SYNAPTICS_I2C_RETRY_COUNT && Error != NvOdmI2cStatus_Success; i++)
    {
        Error = NvOdmI2cTransaction(hTouch->hOdmI2c,
                                    &TransactionInfo,
                                    1,
                                    SYNAPTICS_I2C_SPEED_KHZ,
                                    SYNAPTICS_I2C_TIMEOUT);
	}
    
    NvOdmOsFree(arr);
    
    if (Error != NvOdmI2cStatus_Success)
    {
        NVODMTOUCH_PRINTF(("[ONETOUCH] I2C Write Failure = %d (addr=0x%x)\n", Error, hTouch->DeviceAddr));
        return NV_FALSE;
    }
    
    return NV_TRUE;
}
void NvOdmKeyboardDeInit(void)
{
#if WAKE_FROM_KEYBOARD
	NvRmGpioInterruptUnregister(s_hGpioGlobal, s_hRmGlobal, hOdm->GpioIntrHandle);
	hOdm->GpioIntrHandle = NULL;
	NvRmGpioReleasePinHandles(s_hGpioGlobal, &hOdm->hPin, hOdm->PinCount);
	hOdm->PinCount = 0;
	NvOdmOsFree(hOdm);
	hOdm = NULL;
#endif

    (void)NvEcUnregisterForEvents(s_hEcEventRegistration);
    s_hEcEventRegistration = NULL;

    s_KeyboardDeinit = NV_TRUE;
    NvOdmOsSemaphoreSignal(s_hKbcKeyScanRecvSema);
    NvOdmOsSemaphoreDestroy(s_hKbcKeyScanRecvSema);
    s_hKbcKeyScanRecvSema = NULL;

    NvEcClose(s_NvEcHandle);
    s_NvEcHandle = NULL;
}
Beispiel #22
0
void NvOdmSdioClose(NvOdmSdioHandle hOdmSdio)
{
    const NvOdmPeripheralConnectivity *pConnectivity = NULL;

    NV_DRIVER_TRACE(("Close SDIO%d", hOdmSdio->Instance));

    pConnectivity = hOdmSdio->pConnectivity;
    if (pConnectivity->Guid == WLAN_GUID)
    {
        // Call Turn off power when close is Called
        (void)SdioOdmWlanSetPowerOn(hOdmSdio, NV_FALSE);

        //NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hPwrPin); //Sam ---
        NvOdmGpioReleasePinHandle(hOdmSdio->hGpio, hOdmSdio->hResetPin);
        NvOdmGpioClose(hOdmSdio->hGpio);
    }
    NvOdmSetPowerOnSdio(hOdmSdio, NV_FALSE);
    if (hOdmSdio->hPmu != NULL)
    {
        NvOdmServicesPmuClose(hOdmSdio->hPmu);
    }
    NvOdmOsFree(hOdmSdio);
    hOdmSdio = NULL;
}
Beispiel #23
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;
}
Beispiel #24
0
NvOdmSdioHandle NvOdmSdioOpen(NvU32 Instance)
{
    static NvOdmSdio *pDevice = NULL;
    NvOdmServicesGpioHandle hGpioTemp = NULL;
    NvOdmPeripheralConnectivity *pConnectivity;
    NvU32 NumOfGuids = 1;
    NvU64 guid;
    NvU32 searchVals[2];
    const NvU32 *pOdmConfigs;
    NvU32 NumOdmConfigs;
    NvBool Status = NV_TRUE;
    NvU32 DutyCycle;
    NvU32 gRequestedFreqHzOrPeriod;
    NvU32 ReturnedFreq;
    const NvOdmPeripheralSearch searchAttrs[] =
    {
        NvOdmPeripheralSearch_IoModule,
        NvOdmPeripheralSearch_Instance,
    };

    searchVals[0] =  NvOdmIoModule_Sdio;
    searchVals[1] =  Instance;

    NvOdmQueryPinMux(NvOdmIoModule_Sdio, &pOdmConfigs, &NumOdmConfigs);
    if (Instance >= NumOdmConfigs )
        return NULL;
    if( pOdmConfigs[Instance] == 0 )
        return NULL;

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


    // Get the peripheral connectivity information
    pConnectivity = (NvOdmPeripheralConnectivity *)NvOdmPeripheralGetGuid(guid);
    if (pConnectivity == NULL)
        return NULL;

    pDevice = NvOdmOsAlloc(sizeof(NvOdmSdio));
    pDevice->hPmu = NULL;
    if(pDevice == NULL)
        return (pDevice);

    if (pDevice->hPmu == NULL)
    {
        pDevice->hPmu = NvOdmServicesPmuOpen();
        if(pDevice->hPmu == NULL)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (NULL);
        }
    }

    pDevice->pConnectivity = pConnectivity;
    NvOdmSetPowerOnSdio(pDevice, NV_TRUE);

    if (pConnectivity->Guid == WLAN_GUID)
    {
        // Getting the OdmGpio Handle
        hGpioTemp = NvOdmGpioOpen();
        if (hGpioTemp == NULL)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }

        // Search for the Vdd rail and set the proper volage to the rail.
        /*
                if (pConnectivity->AddressList[1].Interface == NvOdmIoModule_Gpio)
                {
                     // Acquiring Pin Handles for Power Pin
                     pDevice->hPwrPin= NvOdmGpioAcquirePinHandle(hGpioTemp,
                           pConnectivity->AddressList[1].Instance,
                           pConnectivity->AddressList[1].Address);
                }
        */// Sam ---
        if (pConnectivity->AddressList[2].Interface == NvOdmIoModule_Gpio)
        {
            // Acquiring Pin Handles for Reset Pin
            pDevice->hResetPin= NvOdmGpioAcquirePinHandle(hGpioTemp,
                                pConnectivity->AddressList[2].Instance,
                                pConnectivity->AddressList[2].Address);
        }

        // Setting the ON/OFF pin to output mode.
        //NvOdmGpioConfig(hGpioTemp, pDevice->hPwrPin, NvOdmGpioPinMode_Output);// Sam ---
        NvOdmGpioConfig(hGpioTemp, pDevice->hResetPin, NvOdmGpioPinMode_Output);

        // Setting the Output Pin to Low
        //NvOdmGpioSetState(hGpioTemp, pDevice->hPwrPin, 0x0); //Sam ---
        NvOdmGpioSetState(hGpioTemp, pDevice->hResetPin, 0x0);

        pDevice->hGpio = hGpioTemp;

        s_hOdmPwm = NvOdmPwmOpen();
        gRequestedFreqHzOrPeriod = 32000;	//32KHz
        DutyCycle = 3211264;

        NvOdmPwmConfig(s_hOdmPwm, NvOdmPwmOutputId_Blink, NvOdmPwmMode_Blink_32KHzClockOutput,
                       DutyCycle, &gRequestedFreqHzOrPeriod, &ReturnedFreq);

        Status = SdioOdmWlanSetPowerOn(pDevice, NV_TRUE);
        if (Status != NV_TRUE)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }
    }
    pDevice->PoweredOn = NV_TRUE;
    pDevice->Instance = Instance;
    NV_DRIVER_TRACE(("Open SDIO%d", Instance));
    return pDevice;
}
/**
 *  @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;
}
Beispiel #26
0
NvOdmSdioHandle NvOdmSdioOpen(NvU32 Instance)
{
    static NvOdmSdio *pDevice = NULL;
    NvOdmServicesGpioHandle hGpioTemp = NULL;
    NvOdmPeripheralConnectivity *pConnectivity;
    NvU32 NumOfGuids = 1;
    NvU64 guid;
    NvU32 searchVals[4];
    const NvU32 *pOdmConfigs;
    NvU32 NumOdmConfigs;
    NvBool Status = NV_TRUE;
    const NvOdmPeripheralSearch searchAttrs[] =
    {
        NvOdmPeripheralSearch_PeripheralClass,
        NvOdmPeripheralSearch_IoModule,
        NvOdmPeripheralSearch_Instance,
        NvOdmPeripheralSearch_Address,
    };
    NvOdmBoardInfo BoardInfo;
    NvBool status = NV_FALSE;
    
    searchVals[0] =  NvOdmPeripheralClass_Other;
    searchVals[1] =  NvOdmIoModule_Sdio;
    searchVals[2] =  Instance;

    NvOdmQueryPinMux(NvOdmIoModule_Sdio, &pOdmConfigs, &NumOdmConfigs); 
    if ((Instance == 0) && (pOdmConfigs[0] == NvOdmSdioPinMap_Config1))
    {
        // sdio is connected to sdio2 slot.  
        searchVals[3] =  NvOdmSdioDiscoveryAddress_1;
    }
    else
    {
        // sdio is connected to wifi module.
        searchVals[3] =  NvOdmSdioDiscoveryAddress_0;
    }

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

    // Get the peripheral connectivity information
    pConnectivity = (NvOdmPeripheralConnectivity *)NvOdmPeripheralGetGuid(guid);
    if (pConnectivity == NULL)
        return NULL;

    pDevice = NvOdmOsAlloc(sizeof(NvOdmSdio));
    if(pDevice == NULL)
        return (pDevice);

    pDevice->hPmu = NvOdmServicesPmuOpen();
    if(pDevice->hPmu == NULL)
    {
        NvOdmOsFree(pDevice);
        pDevice = NULL;
        return (NULL);
    }

    if (pConnectivity->Guid == WLAN_GUID)
    {
        // WARNING: This function *cannot* be called before RmOpen().
        status = NvOdmPeripheralGetBoardInfo((BOARD_ID_E951), &BoardInfo);
        if (NV_TRUE != status)
        {
            // whistler should have E951 Module, if it is not presnt return NULL Handle.
            NvOdmServicesPmuClose(pDevice->hPmu);
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            NvOdmOsDebugPrintf(("No E951 Detected"));
            return (pDevice);
        }
    }

    pDevice->pConnectivity = pConnectivity;
    NvOdmSetPowerOnSdio(pDevice, NV_TRUE);

    if (pConnectivity->Guid == WLAN_GUID)
    {
        // Getting the OdmGpio Handle
        hGpioTemp = NvOdmGpioOpen();
        if (hGpioTemp == NULL)
        {
            NvOdmServicesPmuClose(pDevice->hPmu);
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }
    
        // Search for the Vdd rail and set the proper volage to the rail.
        if (pConnectivity->AddressList[1].Interface == NvOdmIoModule_Gpio)
        {
             // Acquiring Pin Handles for Power Pin
             pDevice->hPwrPin= NvOdmGpioAcquirePinHandle(hGpioTemp, 
                   pConnectivity->AddressList[1].Instance,
                   pConnectivity->AddressList[1].Address);
        }
         
        if (pConnectivity->AddressList[2].Interface == NvOdmIoModule_Gpio)
        {
             // Acquiring Pin Handles for Reset Pin
             pDevice->hResetPin= NvOdmGpioAcquirePinHandle(hGpioTemp, 
                   pConnectivity->AddressList[2].Instance,
                   pConnectivity->AddressList[2].Address);
        }

        // Setting the ON/OFF pin to output mode.
        NvOdmGpioConfig(hGpioTemp, pDevice->hPwrPin, NvOdmGpioPinMode_Output);
        NvOdmGpioConfig(hGpioTemp, pDevice->hResetPin, NvOdmGpioPinMode_Output);

        // Setting the Output Pin to Low
        NvOdmGpioSetState(hGpioTemp, pDevice->hPwrPin, 0x0);
        NvOdmGpioSetState(hGpioTemp, pDevice->hResetPin, 0x0);

        pDevice->hGpio = hGpioTemp;

        Status = SdioOdmWlanSetPowerOn(pDevice, NV_TRUE);
        if (Status != NV_TRUE)
        {
            NvOdmServicesPmuClose(pDevice->hPmu);
            NvOdmGpioReleasePinHandle(pDevice->hGpio, pDevice->hPwrPin);
            NvOdmGpioReleasePinHandle(pDevice->hGpio, pDevice->hResetPin);    
            NvOdmGpioClose(pDevice->hGpio);   
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }
    }
    pDevice->PoweredOn = NV_TRUE;
    pDevice->Instance = Instance;
    NV_DRIVER_TRACE(("Open SDIO%d", Instance));
    return pDevice;
}
Beispiel #27
0
//-----------------------------------------------------------------
//--------------------------------New API--------------------------
//-----------------------------------------------------------------
NvBool
NvOdmGyroAccelOpen(NvOdmGyroAccelHandle* hDevice)
{
	NvU32 i;
	NvBool foundGpio = NV_FALSE, foundI2cModule = NV_FALSE;
	const NvOdmPeripheralConnectivity *pConnectivity;
	NvOdmGyroAccelHandle  hGyro;
	NvU32    reg_val = 0 ;
#if 1
	printk(" ## MPU3050 : [NvOdmGyroOpen:%d] \n",__LINE__) ;
#endif

	hGyro = NvOdmOsAlloc(sizeof(NvOdmGyro));
	if (hGyro == NULL) {
		printk("Error Allocating NvOdmAccel. \n");
		return NV_FALSE;
	}
	NvOdmOsMemset(hGyro, 0, sizeof(NvOdmGyro));

	hGyro->hPmu = NULL;
	hGyro->hOdmI2C =  NULL;

	hGyro->hPmu = NvOdmServicesPmuOpen();
	if (!hGyro->hPmu) {
		printk("NvOdmServicesPmuOpen Error \n");
		goto error;
	}

	pConnectivity = (NvOdmPeripheralConnectivity*)NvOdmPeripheralGetGuid(NV_ODM_GUID('g','y','r','o','s','c','o','p'));
	if (!pConnectivity) {
		printk("NvOdmPeripheralGetGuid doesn't detect gyro_accel device\n");
		goto error;
	}

	if(pConnectivity->Class != NvOdmPeripheralClass_Other) {
		goto error;
	}

	for (i = 0; i < pConnectivity->NumAddress; i++) {
		switch(pConnectivity->AddressList[i].Interface) {
			case NvOdmIoModule_I2c:
				hGyro->I2CChannelId = pConnectivity->AddressList[i].Instance;
				hGyro->nDevAddr = (pConnectivity->AddressList[i].Address << 1);
				foundI2cModule = NV_TRUE;
				foundGpio = NV_TRUE; //test
#if 1
				printk("## MPU3050 I2CChannelId = %x. ## \n", hGyro->I2CChannelId);
				printk("## MPU3050 i2c address = %x. ## \n", hGyro->nDevAddr);
#endif
				break;
				/*
				   case NvOdmIoModule_Gpio:
				   hGyro->GPIOPortINT = pConnectivity->AddressList[i].Instance;
				   hGyro->GPIOPinINT = pConnectivity->AddressList[i].Address;
				   foundGpio = NV_TRUE;
#if 1
printk("## MPU3050 GPIOPortINT = %x. ## \n",hGyro->GPIOPortINT);
printk("## MPU3050 GPIOPinINT = %x. ## \n", hGyro->GPIOPinINT);
#endif
break;*/
			case NvOdmIoModule_Vdd:
				hGyro->VddId = pConnectivity->AddressList[i].Address;
#if 1
				printk("## MPU3050 NvOdmIoModule_VddId = %x. ## \n", hGyro->VddId);
#endif
				// Power on accelerometer according to Vddid
				NvGyroAccelSetPowerRail(hGyro->hPmu, hGyro->VddId, NV_TRUE);
				break;
			default:
				break;
		}
	}

	if (foundGpio != NV_TRUE || foundI2cModule != NV_TRUE) {
		printk("GyroAccel : didn't find any periperal in discovery query for touch device Error \n");
		goto error;
	}

	// Set up I2C bus.
	if (NV_FALSE == NvGyroAccelI2COpen(&hGyro->hOdmI2C, hGyro->I2CChannelId)) {
		printk("GyroAccel : NvGyroAccelI2COpen Error \n");
		goto error;
	};
	printk(" ##1## GyroAccel : NvGyroAccelI2COpen check1 \n");
	hGyro->RegsRead = NvGyroAccelI2CGetRegs;
	hGyro->RegsWrite = NvGyroAccelI2CSetRegs;
	printk(" ##2## GyroAccel : NvGyroAccelI2COpen check2 \n");
	/*
		if(NV_FALSE == NvGyroAccelConnectSemaphore(hGyro))
		{
		printk("GyroAccel : NvGyroAccelConnectSemaphore Error \n");

		goto error;
		}
		*/

	*hDevice = hGyro;
	return NV_TRUE;
error:
	// Release all of resources requested.
	if (NULL != hGyro) {
		NvGyroAccelSetPowerRail(hGyro->hPmu, hGyro->VddId, NV_FALSE);
		NvOdmServicesPmuClose(hGyro->hPmu);
		hGyro->hPmu = NULL;
		NvGyroAccelI2CClose(hGyro->hOdmI2C);
		hGyro->hOdmI2C = NULL;
		NvOdmOsFree(hGyro);
		*hDevice = NULL;
	}
	return NV_FALSE;
}
NvOdmSdioHandle NvOdmSdioOpen(NvU32 Instance)
{
    static NvOdmSdio *pDevice = NULL;
    NvOdmServicesGpioHandle hGpioTemp = NULL;
    const NvOdmPeripheralConnectivity *pConnectivity;
    NvU32 NumOfGuids = 1;
    NvU64 guid;
    NvU32 searchVals[2];
    const NvU32 *pOdmConfigs;
    NvU32 NumOdmConfigs;
    NvBool Status = NV_TRUE;
    const NvOdmPeripheralSearch searchAttrs[] =
    {
        NvOdmPeripheralSearch_IoModule,
        NvOdmPeripheralSearch_Instance,
    };

    searchVals[0] =  NvOdmIoModule_Sdio;
    searchVals[1] =  Instance;

    NvOdmQueryPinMux(NvOdmIoModule_Sdio, &pOdmConfigs, &NumOdmConfigs);
    if (Instance >= NumOdmConfigs )
        return NULL;
    if( pOdmConfigs[Instance] == 0 )
        return NULL;

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


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

    pDevice = NvOdmOsAlloc(sizeof(NvOdmSdio));
    pDevice->hPmu = NULL;
    if(pDevice == NULL)
        return (pDevice);

    if (pDevice->hPmu == NULL)
    {
        pDevice->hPmu = NvOdmServicesPmuOpen();
        if(pDevice->hPmu == NULL)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (NULL);
        }
    }

    pDevice->pConnectivity = pConnectivity;
    NvOdmSetPowerOnSdio(pDevice, NV_TRUE);

    if (pConnectivity->Guid == WLAN_GUID)
    {
        // Getting the OdmGpio Handle
        hGpioTemp = NvOdmGpioOpen();
        if (hGpioTemp == NULL)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }

        // Search for the Vdd rail and set the proper volage to the rail.
        if (pConnectivity->AddressList[1].Interface == NvOdmIoModule_Gpio)
        {
             // Acquiring Pin Handles for Power Pin
             pDevice->hPwrPin= NvOdmGpioAcquirePinHandle(hGpioTemp,
                   pConnectivity->AddressList[1].Instance,
                   pConnectivity->AddressList[1].Address);
        }

        if (pConnectivity->AddressList[2].Interface == NvOdmIoModule_Gpio)
        {
             // Acquiring Pin Handles for Reset Pin
             pDevice->hResetPin= NvOdmGpioAcquirePinHandle(hGpioTemp,
                   pConnectivity->AddressList[2].Instance,
                   pConnectivity->AddressList[2].Address);
        }

        // Setting the ON/OFF pin to output mode.
        NvOdmGpioConfig(hGpioTemp, pDevice->hPwrPin, NvOdmGpioPinMode_Output);
        NvOdmGpioConfig(hGpioTemp, pDevice->hResetPin, NvOdmGpioPinMode_Output);

        // Setting the Output Pin to Low
        NvOdmGpioSetState(hGpioTemp, pDevice->hPwrPin, 0x0);
        NvOdmGpioSetState(hGpioTemp, pDevice->hResetPin, 0x0);

        pDevice->hGpio = hGpioTemp;

        Status = SdioOdmWlanPower(pDevice, NV_TRUE);
        if (Status != NV_TRUE)
        {
            NvOdmOsFree(pDevice);
            pDevice = NULL;
            return (pDevice);
        }
    }
    pDevice->PoweredOn = NV_TRUE;
    pDevice->Instance = Instance;
    return pDevice;
}
Beispiel #29
0
void NvOdmVibClose(NvOdmVibDeviceHandle hDevice)
{
    if (!hDevice)
        return;
    NvOdmOsFree(hDevice);
}
NvBool NvOdmKeyboardInit(void)
{
    NvError NvStatus = NvError_Success;
    NvEcRequest Request = {0};
    NvEcResponse Response = {0};

    /* get nvec handle */
    NvStatus = NvEcOpen(&s_NvEcHandle, 0 /* instance */);
    if (NvStatus != NvError_Success)
    {
        goto fail;
    }

    /* reset the EC to start the keyboard scanning */
    Request.PacketType = NvEcPacketType_Request;
    Request.RequestType = NvEcRequestResponseType_Keyboard;
    Request.RequestSubtype = (NvEcRequestResponseSubtype) NvEcKeyboardSubtype_Enable;
    Request.NumPayloadBytes = 0;

    NvStatus = NvEcSendRequest(s_NvEcHandle, &Request, &Response, sizeof(Request), sizeof(Response));
    if (NvStatus != NvError_Success)
    {
        goto cleanup;
    }

    /* check if command passed */
    if (Response.Status != NvEcStatus_Success)
    {
        goto cleanup;
    }

#if WAKE_FROM_KEYBOARD
	hOdm = NvOdmOsAlloc(sizeof(NvOdmKbdContext));
	if (!hOdm) {
		goto cleanup;
	}

	/* Check the supported GPIOs */
	hOdm->GpioPinInfo = NvOdmQueryGpioPinMap(NvOdmGpioPinGroup_EmbeddedController,
					0, &hOdm->PinCount);

	NvRmGpioAcquirePinHandle(s_hGpioGlobal,
		hOdm->GpioPinInfo->Port,
		hOdm->GpioPinInfo->Pin,
		&hOdm->hPin);
	if (!hOdm->hPin) {
		goto cleanup;
	}

	/* register to receive GPIO events */
	NvStatus = NvRmGpioInterruptRegister(s_hGpioGlobal,
		s_hRmGlobal,
		hOdm->hPin,
		(NvOsInterruptHandler)GpioInterruptHandler,
		NvRmGpioPinMode_InputData,
		hOdm,
		&hOdm->GpioIntrHandle,
		DEBOUNCE_TIME_MS);
	if (NvStatus != NvError_Success) {
		goto cleanup;
	}

	NvStatus = NvRmGpioInterruptEnable(hOdm->GpioIntrHandle);
	if (NvStatus != NvError_Success) {
		goto cleanup;
	}

	/* enable keyboard as wake up source */
	Request.PacketType = NvEcPacketType_Request;
	Request.RequestType = NvEcRequestResponseType_Keyboard;
	Request.RequestSubtype = (NvEcRequestResponseSubtype)
	NvEcKeyboardSubtype_ConfigureWake;
	Request.NumPayloadBytes = 2;
	Request.Payload[0] = NVEC_KEYBOARD_WAKE_ENABLE_0_ACTION_ENABLE;
	Request.Payload[1] = NVEC_KEYBOARD_EVENT_TYPE_0_ANY_KEY_PRESS_ENABLE;

	NvStatus = NvEcSendRequest(s_NvEcHandle,
		&Request,
		&Response,
		sizeof(Request),
		sizeof(Response));
	if (NvStatus != NvError_Success) {
		goto cleanup;
        }

	if (Response.Status != NvEcStatus_Success) {
		goto cleanup;
	}

        /* enable key reporting on wake up */
	Request.PacketType = NvEcPacketType_Request;
	Request.RequestType = NvEcRequestResponseType_Keyboard;
	Request.RequestSubtype = (NvEcRequestResponseSubtype)
	NvEcKeyboardSubtype_ConfigureWakeKeyReport;
	Request.NumPayloadBytes = 1;
	Request.Payload[0] = NVEC_KEYBOARD_REPORT_WAKE_KEY_0_ACTION_ENABLE;

	NvStatus = NvEcSendRequest(s_NvEcHandle,
		&Request,
		&Response,
		sizeof(Request),
		sizeof(Response));
	if (NvStatus != NvError_Success) {
		goto cleanup;
        }

	if (Response.Status != NvEcStatus_Success) {
		goto cleanup;
	}
#endif

    /* create semaphore which can be used to send scan codes to the clients */
    s_hKbcKeyScanRecvSema = NvOdmOsSemaphoreCreate(0);
    if (!s_hKbcKeyScanRecvSema)
    {
        goto cleanup;
    }

    /* register for keyboard events */
    NvStatus = NvEcRegisterForEvents(
                    s_NvEcHandle,       // nvec handle
                    &s_hEcEventRegistration,
                    (NvOsSemaphoreHandle)s_hKbcKeyScanRecvSema,
                    sizeof(EventTypes)/sizeof(NvEcEventType),
                    EventTypes, // receive keyboard scan codes
                    1,          // currently buffer only 1 packet from ECI at a time
                    sizeof(NvEcEvent));
    if (NvStatus != NvError_Success)
    {
        goto cleanup;
    }

    /* success */
    return NV_TRUE;

cleanup:
#if WAKE_FROM_KEYBOARD
	NvRmGpioInterruptUnregister(s_hGpioGlobal, s_hRmGlobal, hOdm->GpioIntrHandle);
	hOdm->GpioIntrHandle = NULL;
	NvRmGpioReleasePinHandles(s_hGpioGlobal, &hOdm->hPin, hOdm->PinCount);
	NvOdmOsFree(hOdm);
	hOdm = NULL;
#endif
    (void)NvEcUnregisterForEvents(s_hEcEventRegistration);
    s_hEcEventRegistration = NULL;

    NvOdmOsSemaphoreDestroy(s_hKbcKeyScanRecvSema);
    s_hKbcKeyScanRecvSema = NULL;

    NvEcClose(s_NvEcHandle);
fail:
    s_NvEcHandle = NULL;

    return NV_FALSE;
}