예제 #1
0
static BSP_S32 udiAdpIccInit(VOID)
{
	UDI_DRV_INTEFACE_TABLE* pDrvInterface = NULL;
	BSP_U32 u32Cnt;

	/* 构造回调函数指针列表 */
	pDrvInterface = kmalloc(sizeof(UDI_DRV_INTEFACE_TABLE), GFP_KERNEL);
	if (NULL == pDrvInterface)
	{
		printk(KERN_ERR "BSP_MODU_UDI NO Mem, line:%d\n", __LINE__);
		return ERROR;
	}
	memset((VOID*)pDrvInterface, 0, sizeof(UDI_DRV_INTEFACE_TABLE));

	/* 只设置需要实现的几个接口 */
	pDrvInterface->udi_open_cb = (UDI_OPEN_CB_T)udiIccAdpOpen;
	pDrvInterface->udi_close_cb = (UDI_CLOSE_CB_T)BSP_ICC_Close;
	pDrvInterface->udi_write_cb = (UDI_WRITE_CB_T)BSP_ICC_Write;
	pDrvInterface->udi_read_cb = (UDI_READ_CB_T)BSP_ICC_Read;
	pDrvInterface->udi_ioctl_cb = (UDI_IOCTL_CB_T)BSP_ICC_Ioctl;

	/* 几个 ICC 都使用同一套驱动函数指针 */
	for (u32Cnt = 0; u32Cnt < ICC_CHAN_NUM_MAX; u32Cnt++)
	{
		(BSP_VOID)BSP_UDI_SetCapability((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_ICC, u32Cnt), UDI_ICC_CAPA);
		(BSP_VOID)BSP_UDI_SetInterfaceTable((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_ICC, u32Cnt), pDrvInterface);
	}

	return OK;
}
예제 #2
0
LOCAL BSP_S32 udiAdpUartInit(VOID)
{
    UDI_DRV_INTEFACE_TABLE* pDrvInterface = NULL;
    BSP_U32 u32Cnt;

    /* 构造回调函数指针列表 */
    pDrvInterface = malloc(sizeof(UDI_DRV_INTEFACE_TABLE));
    /* coverity[dead_error_condition] */
    if (NULL == pDrvInterface)
    {
        /* coverity[dead_error_condition] */
        bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_UDI, "NO Mem, line:%d\n", __LINE__, 0,0,0,0,0);/* [false alarm]:Disable fortify false alarm */
                   
        /* coverity[dead_error_condition] */
        return ERROR;/* [false alarm]:Disable fortify false alarm */
    }
    memset((VOID*)pDrvInterface, 0, sizeof(UDI_DRV_INTEFACE_TABLE));

    /* 只设置需要实现的几个接口 */
    pDrvInterface->udi_open_cb = udiUartAdpOpen;
    pDrvInterface->udi_close_cb = (UDI_CLOSE_CB_T)close;
    pDrvInterface->udi_write_cb = (UDI_WRITE_CB_T)write;
    pDrvInterface->udi_read_cb = (UDI_READ_CB_T)read;
    pDrvInterface->udi_ioctl_cb = (UDI_IOCTL_CB_T)ioctl;

    /* 3个 ACM 都使用同一套驱动函数指针 */
    for (u32Cnt = 0; u32Cnt < UDI_GET_UART_NUM(); u32Cnt++)
    {
        (BSP_VOID)BSP_UDI_SetCapability((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_UART, u32Cnt), UDI_USB_ACM_CAPA);
        (BSP_VOID)BSP_UDI_SetInterfaceTable((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_UART, u32Cnt), pDrvInterface);
    }

    /* pDrvInterface' (line 287) has not been freed or returned */
    return OK;/*lint !e429 */
}
예제 #3
0
LOCAL BSP_S32 udiAdpIccInit(VOID)
{
    UDI_DRV_INTEFACE_TABLE* pDrvInterface = NULL;
    BSP_U32 u32Cnt;

    /* 构造回调函数指针列表 */
    pDrvInterface = malloc(sizeof(UDI_DRV_INTEFACE_TABLE));
    /* coverity[dead_error_condition] */
    if (NULL == pDrvInterface)
    {
        /* coverity[dead_error_condition] */
        bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_UDI, "NO Mem, line:%d\n", __LINE__, 0,0,0,0,0);/* [false alarm]:Disable fortify false alarm */
                   
        /* coverity[dead_error_condition] */
        return ERROR;/* [false alarm]:Disable fortify false alarm */
    }
    memset((VOID*)pDrvInterface, 0, sizeof(UDI_DRV_INTEFACE_TABLE));

    /* 只设置需要实现的几个接口 */
    pDrvInterface->udi_open_cb = (UDI_OPEN_CB_T)udiIccAdpOpen;
    pDrvInterface->udi_close_cb = (UDI_CLOSE_CB_T)BSP_ICC_Close;
    pDrvInterface->udi_write_cb = (UDI_WRITE_CB_T)BSP_ICC_Write;
    pDrvInterface->udi_read_cb = (UDI_READ_CB_T)BSP_ICC_Read;
    pDrvInterface->udi_ioctl_cb = (UDI_IOCTL_CB_T)BSP_ICC_Ioctl;

    /* 几个 ICC 都使用同一套驱动函数指针 */
    for (u32Cnt = 0; u32Cnt < ICC_CHAN_NUM_MAX; u32Cnt++)
    {
        (BSP_VOID)BSP_UDI_SetCapability((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_ICC, u32Cnt), UDI_ICC_CAPA);
        (BSP_VOID)BSP_UDI_SetInterfaceTable((UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_ICC, u32Cnt), pDrvInterface);
    }

    /*Custodial pointer 'pDrvInterface' (line 342) has not been freed or returned */
    return OK; /*lint !e429 */
}
예제 #4
0
void cshell_icc_open(void)
{
    ICC_CHAN_ATTR_S attr;
    UDI_OPEN_PARAM cshell_icc_param;
    UDI_HANDLE cshell_udi_handle = UDI_INVALID_HANDLE;

    if (1 == g_usb_cshell_disabled) {
        printk("%s : usb cshell disabled\n", __FUNCTION__);
        return ;
    }
	
    attr.enChanMode  = ICC_CHAN_MODE_STREAM;
    attr.u32Priority = 255;
    attr.u32TimeOut  = 1000;
    attr.event_cb = cshell_event_cb;
    attr.read_cb  = cshell_read_cb;
    attr.write_cb = cshell_write_cb;
    attr.u32FIFOInSize  = 8192;
    attr.u32FIFOOutSize = 8192;

    cshell_icc_param.devid = (UDI_DEVICE_ID)UDI_BUILD_DEV_ID(UDI_DEV_ICC, 31);
    cshell_icc_param.pPrivate = &attr;

    cshell_udi_handle = udi_open(&cshell_icc_param);
    if(cshell_udi_handle <= 0)
    {
        printk("cshell_icc_open fail,cshell_udi_handle is %d \n",cshell_udi_handle);
        g_cshell_udi_handle = -1;
    }
    else
    {
        printk("cshell_icc_open success,cshell_udi_handle is %d \n",cshell_udi_handle);
        g_cshell_udi_handle = cshell_udi_handle;
    }
}
/*****************************************************************************
 函 数 名  : udi_acm_init
 功能描述  : acm端口注册到udi适配层初始化函数,用于将acm设备回调挂接到udi上
 输入参数  : void
 输出参数  : 无
 返 回 值  : int 成功返回ADP_OK 失败返回ADP_ERROR
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2012年9月12日
    作    者   : 夏青 00195127
    修改内容   : 新生成函数

*****************************************************************************/
int udi_acm_init(void)
{
    int dev_num;
    int i;
    UDI_DRV_INTEFACE_TABLE *pDrvInterface = NULL;
    struct device_node *np = NULL;
    int phyaddr_from_app = 1;/*默认使用协议栈传下来的物理地址*/

    pDrvInterface = (UDI_DRV_INTEFACE_TABLE *)kmalloc(sizeof(UDI_DRV_INTEFACE_TABLE),GFP_KERNEL);
    if (NULL == pDrvInterface) {
        ACM_ADP_ERR("kmalloc failed\n");
        return ADP_ERROR;
    }
    ACM_ADP_DBG("enter\n");

    /* 挂接UDI回调函数 */
    pDrvInterface->udi_open_cb  = (UDI_OPEN_CB_T)udi_acm_open;
    pDrvInterface->udi_close_cb = (UDI_CLOSE_CB_T)udi_acm_close;
    pDrvInterface->udi_write_cb = (UDI_WRITE_CB_T)udi_acm_write;
    pDrvInterface->udi_read_cb  = (UDI_READ_CB_T)udi_acm_read;
    pDrvInterface->udi_ioctl_cb = (UDI_IOCTL_CB_T)udi_acm_ioctl;

    /* 设置acm设备驱动回调函数,3个acm使用同一套驱动指针 */
    for (dev_num = UDI_USB_ACM_CTRL; dev_num < UDI_USB_ACM_MAX; dev_num++){
        (void)BSP_UDI_SetCapability((UDI_DEVICE_ID_E)UDI_BUILD_DEV_ID(UDI_DEV_USB_ACM, dev_num), UDI_USB_ACM_CAPA);
        (void)BSP_UDI_SetInterfaceTable((UDI_DEVICE_ID_E)UDI_BUILD_DEV_ID(UDI_DEV_USB_ACM, dev_num), pDrvInterface);
    }

    np = of_find_compatible_node(NULL, NULL, "hisilicon,hi6xxx-usb-otg");
    if (np) {
        if (of_property_read_u32(np, "huawei,phyaddr_from_app",&phyaddr_from_app)){
            printk(KERN_ERR "%s:huawei,phyaddr_from_app read error\n",__FUNCTION__);
        }
        printk(KERN_INFO "%s:huawei,phyaddr_from_app %d\n",__FUNCTION__,phyaddr_from_app);
    }

    for (i = 0; i < USB_ACM_COM_UDI_NUM; i++) {
        g_acm_priv[i].tty_name      = acm_dev_name[i];
        g_acm_priv[i].bopen         = ACM_DEV_CLOSE;
        g_acm_priv[i].readDoneCB    = NULL;
        g_acm_priv[i].writeDoneCB   = NULL;
        g_acm_priv[i].eventCB       = NULL;
        g_acm_priv[i].freeSendbuff  = NULL;
        g_acm_priv[i].acm_ncpy      = NULL;
        g_acm_priv[i].tty           = NULL;
        g_acm_priv[i].acm_ldisc_ctx = NULL;
        g_acm_priv[i].do_copy       = 0;
        g_acm_priv[i].cur_evt       = ACM_EVT_DEV_SUSPEND;
        g_acm_priv[i].ncopy         = 0;
        g_acm_priv[i].phyaddr_from_app = 0;
        INIT_WORK(&g_acm_priv[i].notify_work, acm_event_notify);

        if (ACM_NEED_NCOPY(g_acm_priv[i].tty_name)) {
            g_acm_priv[i].ncopy = 1;
            g_acm_priv[i].phyaddr_from_app = phyaddr_from_app;
        }

    }

    atomic_notifier_chain_register(&android_usb_suspend_notifier_list, &acm_suspend_notifier);
    atomic_notifier_chain_register(&android_usb_resume_notifier_list,  &acm_resume_notifier);

    BSP_ACM_RegCmdHandle((ACM_HANDLE_COMMAND_CB_T)acm_handle_command);

    return ADP_OK;
}