LINUX驱动学习——内核USB驱动编写八USB的OTG驱动2(转载)(4)
 
- UID
- 1029342
- 性别
- 男
|

LINUX驱动学习——内核USB驱动编写八USB的OTG驱动2(转载)(4)
/* Set OTG state machine operations */ /**************************************************************/
static struct otg_fsm_ops fsl_otg_ops = {
.chrg_vbus = fsl_otg_chrg_vbus,
.drv_vbus = fsl_otg_drv_vbus,
.loc_conn = fsl_otg_loc_conn,
.loc_sof = fsl_otg_loc_sof,
.start_pulse = fsl_otg_start_pulse,
.add_timer = fsl_otg_add_timer,
.del_timer = fsl_otg_del_timer,
.start_host = fsl_otg_start_host,
.start_gadget = fsl_otg_start_gadget,
};
/**************************************************************/
fsl_otg_tc->fsm.ops = &fsl_otg_ops;
/* initialize the otg structure */
fsl_otg_tc->otg.label = DRIVER_DESC;
fsl_otg_tc->otg.set_host = fsl_otg_set_host;
fsl_otg_tc->otg.set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->otg.set_power = fsl_otg_set_power;
fsl_otg_tc->otg.start_hnp = fsl_otg_start_hnp;
fsl_otg_tc->otg.start_srp = fsl_otg_start_srp;
fsl_otg_dev = fsl_otg_tc;
/* Store the otg transceiver */
/***************************************************************/
int otg_set_transceiver(struct otg_transceiver *x)
{
if (xceiv && x)
return -EBUSY;
xceiv = x;
return 0;
}
该函数就是将struct otg_transceiver结构副给一个全局变量保存,供以后使用,以后会通过调用下面函数得到该结构
struct otg_transceiver *otg_get_transceiver(void)
{
if (xceiv)
get_device(xceiv->dev);
return xceiv;
}
/***************************************************************/
status = otg_set_transceiver(&fsl_otg_tc->otg);
if (status) {
printk(KERN_WARNING ": unable to register OTG transceiver.\n");
return status;
}
return 0;
} |
|
|
|
|
|