void
GPIO_PCF50626_NvOdmExternalGpioWritePins(
    NvU32 Port,
    NvU32 Pin,
    NvU32 PinValue)
{
    NvU8 val;
    NvBool RetVal = NV_TRUE;

    switch (Port)
    {
    case NVODM_GPIO_EXT_PORT_2:
        if (Pin != 1) // Only Pin 1 is implemented at this time
            break;

        if (PinValue) // Enable
        {
            val = (1UL << 6) // invert polarity
                | 0x3;       // pwm1 output
            RetVal = GPIO_PCF50626_I2cWrite8(PCF50626_GPO2C1_ADDR, val);
        }
        else // Disable
        {
            RetVal = GPIO_PCF50626_I2cWrite8(PCF50626_GPO2C1_ADDR, 0x0);
        }
        break;
    }

    if (RetVal == NV_FALSE)
    {
        NvOdmOsDebugPrintf("ERROR: GPIO_PCF50626_I2cWrite8() failed.\n");
    }

    return;
}
static void TPK_CheckError (TPK_TouchDevice* hTouch)
{
    NvU8 status;
    TPK_READ(hTouch, TPK_DEVICE_STATUS, &status, 1);
    if (status & 0x80)
    {
        NvU8 error;
        TPK_READ(hTouch, TPK_ERROR_STATUE, &error, 1);
        NvOdmOsDebugPrintf("Panel error %x %x\n", status, error);
    }
#if TPK_DUMP_REGISTER
    TPK_READ(hTouch, TPK_DEVICE_STATUS, &status, 1);
    NvOdmOsDebugPrintf("DeviceStatus(0x%x)=0x%x\n", TPK_DEVICE_STATUS, status);
    
    TPK_READ(hTouch, TPK_DEVICE_CONTROL, &status, 1);
    NvOdmOsDebugPrintf("DeviceControl(0x%x)=0x%x\n", TPK_DEVICE_CONTROL, status);
        
    TPK_READ(hTouch, TPK_INTR_ENABLE, &status, 1);
    NvOdmOsDebugPrintf("InterruptEnable(0x%x)=0x%x\n", TPK_INTR_ENABLE, status);
        
    TPK_READ(hTouch, TPK_ERROR_STATUE, &status, 1);
    NvOdmOsDebugPrintf("TPK_ERROR_STATUE(0x%x)=0x%x\n", TPK_ERROR_STATUE, status);
       
    TPK_READ(hTouch, TPK_INTR_STATUS, &status, 1);
    NvOdmOsDebugPrintf("InterruptStatus(0x%x)=0x%x\n", TPK_INTR_STATUS, status);
        
    TPK_READ(hTouch, TPK_DEVICE_COMMAND, &status, 1);
    NvOdmOsDebugPrintf("DeviceCommand(0x%x)=0x%x\n", TPK_DEVICE_COMMAND, status);
#endif      
}
Example #3
0
NvBool EETI_ReadCoordinate (NvOdmTouchDeviceHandle hDevice, NvOdmTouchCoordinateInfo* coord) {
    EETI_TouchDevice* hTouch = (EETI_TouchDevice*)hDevice;

#if EETI_BENCHMARK_SAMPLE    
    NvU32 time = NvOdmOsGetTimeMS();
#endif
    NVODMTOUCH_PRINTF(("GpioIst+\n"));

    EETI_GetSample(hTouch, coord);


#if EETI_BENCHMARK_SAMPLE    
    NvOdmOsDebugPrintf("Touch sample time %d\n", NvOdmOsGetTimeMS() - time);
#endif

    return NV_TRUE;
}
Example #4
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;
}
Example #5
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;
}
static NvBool TPK_GetSample (TPK_TouchDevice* hTouch, NvOdmTouchCoordinateInfo* coord)
{
    NvU8 Finger0[6] = {0};
    NvU8 Finger1[6] = {0};
    NvU8 Relative[2] = {0};
    int status = 0;

    NVODMTOUCH_PRINTF(("TPK_GetSample+\n"));
    coord->fingerstate = NvOdmTouchSampleIgnore;

    if (!TPK_ReadRegisterOnce(hTouch, TPK_DATA_0, Finger0, 6))
        return NV_FALSE;
    else
        status = (Finger0[0] & 0x7);

    if (!TPK_ReadRegisterOnce(hTouch, TPK_DATA_0+6, Finger1, 6))
        return NV_FALSE;

    if (!TPK_ReadRegisterOnce(hTouch, TPK_DATA_0+12, Relative, 2))
        return NV_FALSE; 

    /* tell windows to ignore transitional finger count samples */
    coord->fingerstate = (status > 2) ? NvOdmTouchSampleIgnore : NvOdmTouchSampleValidFlag;
    coord->additionalInfo.Fingers = status;

    if (Finger0[0] & 0x8)
        // Bit 3 of status indicates a tap. Driver still doesn't expose
        // gesture capabilities. This is added more for testing of the support
        // in the hardware for gesture support.
    {
        coord->additionalInfo.Gesture = NvOdmTouchGesture_Tap;
        // NvOdmOsDebugPrintf("Detected the Tap gesture\n");
    }

    if (status)
    {
        /* always read first finger data, even if transitional */
        coord->fingerstate |= NvOdmTouchSampleDownFlag;

        coord->xcoord =
        coord->additionalInfo.multi_XYCoords[0][0] =
            (((NvU16)Finger0[2] & 0x1f) << 8) | (NvU16)Finger0[3];

        coord->ycoord =
        coord->additionalInfo.multi_XYCoords[0][1] =
            (((NvU16)Finger0[4] & 0x1f) << 8) | (NvU16)Finger0[5];

        coord->additionalInfo.width[0] = Finger0[0] >> 4;
        coord->additionalInfo.Pressure[0] = Finger0[1];

        /* only read second finger data if reported */
        if (status == 2)
        {
            coord->additionalInfo.multi_XYCoords[1][0] =
                (((NvU16)Finger1[2] & 0x1f) << 8) | (NvU16)Finger1[3];

            coord->additionalInfo.multi_XYCoords[1][1] =
            (((NvU16)Finger1[4] & 0x1f) << 8) | (NvU16)Finger1[5];

            /* these are not supported, zero out just in case */
            coord->additionalInfo.width[1] = 0;
            coord->additionalInfo.Pressure[1] = 0;
            if ( coord->additionalInfo.multi_XYCoords[1][0] <= 0 ||
                coord->additionalInfo.multi_XYCoords[1][0] >= hTouch->Caps.XMaxPosition ||
                coord->additionalInfo.multi_XYCoords[1][1] <= 0 || 
                coord->additionalInfo.multi_XYCoords[1][1] >= hTouch->Caps.YMaxPosition)
                coord->fingerstate = NvOdmTouchSampleIgnore;
#if TPK_REPORT_2ND_FINGER_DATA
            else
                NvOdmOsDebugPrintf("catch 2 fingers width=0x%x, X=%d, Y=%d, DeltaX=%d, DeltaY=%d\n",
                                    coord->additionalInfo.width[0],
                                    coord->additionalInfo.multi_XYCoords[1][0],
                                    coord->additionalInfo.multi_XYCoords[1][1],
                                    Relative[0], Relative[1]);
#endif
        }
    }
    else if (!hTouch->PrevFingers)
Example #7
0
//-----------------------------------------------------------------
//--------------------------------New API--------------------------
//-----------------------------------------------------------------
NvBool
NvOdmAccelOpen(NvOdmAccelHandle* hDevice)
{
    NvU32    test_val;
    NvU32 i;
    NvBool foundGpio = NV_FALSE, foundI2cModule = NV_FALSE;
    const NvOdmPeripheralConnectivity *pConnectivity;
    NvOdmAccelHandle  hAccel;

    hAccel = NvOdmOsAlloc(sizeof(NvOdmAccel));
    if (hAccel == NULL)
    {
        //NVODMACCELEROMETER_PRINTF("Error Allocating NvOdmAccel. \n");
        return NV_FALSE;
    }
    NvOdmOsMemset(hAccel, 0, sizeof(NvOdmAccel));

    hAccel->hPmu = NULL;
    hAccel->hOdmI2C =  NULL;
    hAccel->nBusType = NV_ACCELEROMETER_BUS_I2C;
    
    // Chip init cfg info here, here just a sample for common interrupt now!
    // This part will move to a configuration table later.
    // Start here.
    // Only enable common interrupt
    // Enable common and single tap at the same time.
    hAccel->CtrlRegsList[0].RegAddr = XLR_CTL; //0x12
    hAccel->CtrlRegsList[0].RegValue = 0x20;
    hAccel->CtrlRegsList[1].RegAddr = XLR_INTCONTROL; //0x13
    hAccel->CtrlRegsList[1].RegValue = 0xF3;  // modify so that sw is compatible
    hAccel->CtrlRegsList[2].RegAddr = XLR_INTCONTROL2; //0x14
    hAccel->CtrlRegsList[2].RegValue = 0xe0;
    hAccel->CtrlRegsList[3].RegAddr = XLR_THRESHG; //0x1C
    hAccel->CtrlRegsList[3].RegValue = NV_ADI340_ACCELEROMETER_NORMAL_THRESHOLD;
    hAccel->CtrlRegsList[4].RegAddr = XLR_OFSX; //0x1E
    hAccel->CtrlRegsList[4].RegValue = 0;
    hAccel->CtrlRegsList[5].RegAddr = XLR_OFSY; //0x1F
    hAccel->CtrlRegsList[5].RegValue = 0;
    hAccel->CtrlRegsList[6].RegAddr = XLR_OFSZ; //0x20
    hAccel->CtrlRegsList[6].RegValue = 0;
    hAccel->CtrlRegsList[7].RegAddr = XLR_THRESHC; //0x1D
    hAccel->CtrlRegsList[7].RegValue = NV_ADI340_ACCELEROMETER_TAP_THRESHOLD;
    hAccel->CtrlRegsList[8].RegAddr = XLR_DUR; //0x21
    hAccel->CtrlRegsList[8].RegValue = 0x40;
    hAccel->CtrlRegsList[9].RegAddr = XLR_LATENT; //0x22
    hAccel->CtrlRegsList[9].RegValue = 0xff;
    hAccel->CtrlRegsList[10].RegAddr = XLR_INTVL; //0x23
    hAccel->CtrlRegsList[10].RegValue = 0;
    hAccel->CtrlRegsList[11].RegAddr = XLR_INTCONTROL2; //0x14
    hAccel->CtrlRegsList[11].RegValue = 0xe1;
    hAccel->CtrlRegsList[12].RegAddr = XLR_INTCONTROL2; //0x14
    hAccel->CtrlRegsList[12].RegValue = 0xe0;
    hAccel->nLength = 13;
    // Stop here.
    // Info of accelerometer with current setting.
    hAccel->Caption.MaxForceInGs = 2000;
    hAccel->Caption.MaxTapTimeDeltaInUs = 255;
    hAccel->Caption.NumMotionThresholds = 1;
    hAccel->Caption.SupportsFreefallInt = 0;
    hAccel->Caption.MaxSampleRate = 100;
    hAccel->Caption.MinSampleRate = 3;
    hAccel->PowerState = NvOdmAccelPower_Fullrun;
    hAccel->AxisXMapping = NvOdmAccelAxis_X;
    hAccel->AxisXDirection = 1;
    hAccel->AxisYMapping = NvOdmAccelAxis_Y;
    hAccel->AxisYDirection = 1;
    hAccel->AxisZMapping = NvOdmAccelAxis_Z;
    hAccel->AxisZDirection = -1;
    
    hAccel->hPmu = NvOdmServicesPmuOpen();
    if (!hAccel->hPmu)
    {
        //NVODMACCELEROMETER_PRINTF("NvOdmServicesPmuOpen Error \n");
        goto error;
    }
    
    pConnectivity = (NvOdmPeripheralConnectivity*)NvOdmPeripheralGetGuid(NV_ODM_GUID('a','c','c','e','l','e','r','o'));
    if (!pConnectivity)
    {
        NvOdmOsDebugPrintf("NvOdmPeripheralGetGuid doesn't detect accelerometer device\n");
        goto error;
    }
 
    if(pConnectivity->Class != NvOdmPeripheralClass_Other)
    {
        goto error;
    }
        
    for( i = 0; i < pConnectivity->NumAddress; i++)
    {
        switch(pConnectivity->AddressList[i].Interface)
        {
            case NvOdmIoModule_I2c:
                hAccel->I2CChannelId = pConnectivity->AddressList[i].Instance;
                hAccel->nDevAddr = (NvU8)pConnectivity->AddressList[i].Address;
                foundI2cModule = NV_TRUE;
                break;
            case NvOdmIoModule_Gpio:
                hAccel->GPIOPortINT = pConnectivity->AddressList[i].Instance;
                hAccel->GPIOPinINT = pConnectivity->AddressList[i].Address;
                foundGpio = NV_TRUE;
                break;
            case NvOdmIoModule_Vdd:
                hAccel->VddId = pConnectivity->AddressList[i].Address;
                // Power on accelerometer according to Vddid
                NvAccelerometerSetPowerRail(hAccel->hPmu, hAccel->VddId, NV_TRUE);
                break;
            default:
                break;
        }
    }

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

    
    // Set up I2C bus.
    if(NV_FALSE == NvAccelerometerI2COpen(&hAccel->hOdmI2C, hAccel->I2CChannelId))
    {
        goto error;
    };
    hAccel->RegsRead  = NvAccelerometerI2CGetRegs;
    hAccel->RegsWrite = NvAccelerometerI2CSetRegs;
    
    NvOdmAccelerometerGetParameter(hAccel, XLR_WHOAMI, &test_val);
    if(XLR_IDNUM != test_val)
    {
        goto error;
    }
    
    NvOdmAccelerometerGetParameter(hAccel, XLR_DEVID, &test_val);
    if (test_val == XLR_NEWCHIPID)
    {
        // This chip is ADXL345
        //NvOdmOsDebugPrintf("This chip is ADXL345!!!\n");
        hAccel->CtrlRegsList[4].RegValue = 0x0A; // offset X
        hAccel->CtrlRegsList[5].RegValue = 0x0B; // offset Y
        hAccel->CtrlRegsList[6].RegValue = 0x14; // offset Z
    }
    //NVODMACCELEROMETER_PRINTF("ID is 0x%x\n", test_val);
    
    /* We don't know the reset state of the accelerometer. So, program the
     * accelerometer to disable generation of interrupts.
     *  
     *  Write to INTCONTROL register to disable genetration of the interrupts.
     *  Write to INTCONTROL2 to clear the already latched interrupts.
     */
    NvOdmAccelerometerSetParameter(hAccel, XLR_ATTR_INTCONTROL, 0x0);
    NvOdmAccelerometerSetParameter(hAccel, XLR_ATTR_INTCONTROL2, 0x1);
    if(NV_FALSE == NvAccelerometerConnectSemaphore(hAccel))
    {
        goto error;
    }
    
    //init accelerometer
    for(i=0; i<hAccel->nLength; i++)
    {
            NvOdmAccelerometerSetParameter(hAccel,
                                           hAccel->CtrlRegsList[i].RegAddr, 
                                           hAccel->CtrlRegsList[i].RegValue);
    }
    // Set up event.
    
    //NvOdmAccelerometerGetParameter(XLR_SCALE, hAccel);
    *hDevice = hAccel;
    return NV_TRUE;
    error:
        // Release all of resources requested.
        if(NULL != hAccel)
        {
            NvAccelerometerSetPowerRail(hAccel->hPmu, hAccel->VddId, NV_FALSE);
            NvOdmServicesPmuClose(hAccel->hPmu);
            hAccel->hPmu = NULL;
            NvAccelerometerI2CClose(hAccel->hOdmI2C);
            hAccel->hOdmI2C = NULL;
            NvOdmOsFree(hAccel);
            *hDevice = NULL;
        }
        return NV_FALSE;
}