Exemplo n.º 1
0
/*******************************************************************************
* Function Name  : OTGD_FS_CoreInit
* Description    : Initialize the USB_OTG controller registers and prepares the core
                   for device mode or host mode operation.
* Input          : None
* Output         : None
* Return         : Status
*******************************************************************************/
USB_OTG_Status OTGD_FS_CoreInit(void)
{
  USB_OTG_Status status = USB_OTG_OK;
  USB_OTG_GUSBCFG_TypeDef usbcfg;
  USB_OTG_GCCFG_TypeDef    gccfg;
 
  usbcfg.d32 = 0;
  gccfg.d32  = 0;
  
  usbcfg.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.GREGS->GUSBCFG);
  usbcfg.b.physel = 1;
  USB_OTG_WRITE_REG32 (&USB_OTG_FS_regs.GREGS->GUSBCFG, usbcfg.d32);

  /* init and configure the phy */
  gccfg.d32 = 0;
  gccfg.b.vbussensingB = 1;
  gccfg.b.pwdn = 1;
  USB_OTG_WRITE_REG32 (&USB_OTG_FS_regs.GREGS->GCCFG, gccfg.d32);
  mDELAY(50);

  /* Reset after a PHY select and set Host mode */
  OTGD_FS_CoreReset();

  /* Set Device Mode */
  OTGD_FS_SetDeviceMode();

  return status;
}
Exemplo n.º 2
0
/*******************************************************************************
* adopt_CAMERA_HW_Open
********************************************************************************/
inline static int adopt_CAMERA_HW_Open(void)
{
    UINT32 err = 0;

        KD_IMGSENSOR_PROFILE_INIT(); 
        //power on sensor
    if (atomic_read(&g_CamHWOpend) == 0) {
        // turn on power 
        atomic_set(&g_CamHWOpening, 1);
        kdModulePowerOn((CAMERA_DUAL_CAMERA_SENSOR_ENUM) g_currDualSensorIdx, g_currSensorName,true, CAMERA_HW_DRVNAME);
        //wait for power stable 
        mDELAY(10); 
        KD_IMGSENSOR_PROFILE("kdModulePowerOn"); 
        
        //
        if (g_pSensorFunc) {
            err = g_pSensorFunc->SensorOpen();
            if(ERROR_NONE != err) {
                PK_DBG(" ERROR:SensorOpen(), turn off power \n");                
                kdModulePowerOn((CAMERA_DUAL_CAMERA_SENSOR_ENUM) g_currDualSensorIdx, NULL, false, CAMERA_HW_DRVNAME);
            }
        }
        else {
            PK_DBG(" ERROR:NULL g_pSensorFunc\n");
        }
        KD_IMGSENSOR_PROFILE("SensorOpen"); 
    }
    if (err == 0 ) {
        atomic_set(&g_CamHWOpend, 1); 
    }
    return err?-EIO:err;
}	/* adopt_CAMERA_HW_Open() */
Exemplo n.º 3
0
/*******************************************************************************
* Function Name  : PCD_DevDisconnect
* Description    : Disconnect device
* Input         : None
* Output         : None
* Return         : status
*******************************************************************************/
void  PCD_DevDisconnect (void)
{

  USB_OTG_DCTL_TypeDef dctl;

  dctl.d32 = 0;
  
  dctl.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.DEV->DCTL);

  /* Disconnect device for 20ms */
  dctl.b.sftdiscon  = 1;
  USB_OTG_WRITE_REG32(&USB_OTG_FS_regs.DEV->DCTL, dctl.d32);
  mDELAY(25);
}
Exemplo n.º 4
0
/*******************************************************************************
* Function Name  : SetID
* Description    : Set ID line
* Input          : None
* Output         : None
* Return         : num_in_ep
*******************************************************************************/
USB_OTG_Status SetID(void)
{

  USB_OTG_Status status = USB_OTG_OK;
  USB_OTG_usb_cfg_data usbcfg;

  usbcfg.d32 = READ_REG32(&core_regs.common_regs->usb_cfg);

  usbcfg.b.force_dev = 1;

  WRITE_REG32(&core_regs.common_regs->usb_cfg, usbcfg.d32);

  mDELAY(50);

  return status;
}
Exemplo n.º 5
0
/*******************************************************************************
* Function Name  : OTGD_FS_SetDeviceMode
* Description    : Set device mode
* Input          : None
* Output         : None
* Return         : Status
*******************************************************************************/
USB_OTG_Status OTGD_FS_SetDeviceMode(void)
{

  USB_OTG_Status status = USB_OTG_OK;
  USB_OTG_GUSBCFG_TypeDef usbcfg ;
  
  usbcfg.d32 = 0;

  usbcfg.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.GREGS->GUSBCFG);

  usbcfg.b.force_dev = 1;

  USB_OTG_WRITE_REG32(&USB_OTG_FS_regs.GREGS->GUSBCFG, usbcfg.d32);

  mDELAY(50);

  return status;
}
Exemplo n.º 6
0
/*******************************************************************************
* adopt_CAMERA_HW_CheckIsAlive
********************************************************************************/
inline static int adopt_CAMERA_HW_CheckIsAlive(void)
{
    UINT32 err = 0;

    KD_IMGSENSOR_PROFILE_INIT(); 
    //power on sensor
    kdModulePowerOn((CAMERA_DUAL_CAMERA_SENSOR_ENUM) g_currDualSensorIdx, g_currSensorName,true, CAMERA_HW_DRVNAME);
    //wait for power stable 
    mDELAY(10); 
    KD_IMGSENSOR_PROFILE("kdModulePowerOn"); 
                        
    //            
    if (g_pSensorFunc)
    {
        MUINT32 sensorID = 0; 
        MUINT32 retLen = 0; 
        err = g_pSensorFunc->SensorFeatureControl(SENSOR_FEATURE_CHECK_SENSOR_ID, (MUINT8*)&sensorID, &retLen);
        if (sensorID == 0) {    //not implement this feature ID 
            PK_DBG(" Not implement!!, use old open function to check\n"); 
            err = g_pSensorFunc->SensorOpen();                                     
        }
        else if (sensorID == 0xFFFFFFFF) {    //fail to open the sensor 
            PK_DBG(" No Sensor Found"); 
            err = ERROR_SENSOR_CONNECT_FAIL; 
        }
        else {
            PK_DBG(" Sensor found ID = 0x%x\n", sensorID); 
            err = ERROR_NONE;                 
        }            
        if(ERROR_NONE != err)
        {
            PK_DBG("ERROR:adopt_CAMERA_HW_CheckIsAlive(), No imgsensor alive \n");
        }
    }
    else
    {
        PK_DBG("ERROR:NULL g_pSensorFunc\n");
    }
    kdModulePowerOn((CAMERA_DUAL_CAMERA_SENSOR_ENUM) g_currDualSensorIdx, NULL, false, CAMERA_HW_DRVNAME);
    KD_IMGSENSOR_PROFILE("CheckIsAlive"); 

    return err?-EIO:err;
}	/* adopt_CAMERA_HW_Open() */
Exemplo n.º 7
0
/*******************************************************************************
* Function Name  : OTGD_FS_PhyInit
* Description    : Initialize the phy
* Input          : None
* Output         : None
* Return         : Status
*******************************************************************************/
USB_OTG_Status OTGD_FS_PhyInit(void)
{
  USB_OTG_gpio_data    gpioctl;
  USB_OTG_usb_cfg_data usbcfg;
  USB_OTG_Status status = USB_OTG_OK;

  /* Enable the I2C interface and deactivate the power down*/
  gpioctl.d32 = 0;
  gpioctl.b.vbussensingB = 1;
  gpioctl.b.pwdn = 1;
  gpioctl.b.i2cifen = 0;
  WRITE_REG32 (&core_regs.common_regs->gpio, gpioctl.d32);
  mDELAY(200);

  /* Program GUSBCFG.OtgUtmifsSel to I2C*/
  usbcfg.d32 = READ_REG32(&core_regs.common_regs->usb_cfg);
  usbcfg.b.otgutmifssel = 0;
  WRITE_REG32 (&core_regs.common_regs->usb_cfg, usbcfg.d32);

  return status;
}