参考文件:
kernel/drivers/usb/phy/phy-msm-usb.c
kernel/msm-3.18/drivers/usb/phy/phy-msm-usb.c
+//begin:stone modify for usb id
+static bool usb_id_flag = 1;
+bool get_usb_id(void)
+{
+ return usb_id_flag;
+}
+EXPORT_SYMBOL(get_usb_id);
+//end:stone modify for usb id
在msm_id_status_w函数中添加即可:
static void msm_id_status_w(struct work_struct *w)
{
struct msm_otg *motg = container_of(w, struct msm_otg,
id_status_work.work);
int work = 0;
int id_state = 0;
dev_dbg(motg->phy.dev, "ID status_w\n");
if (motg->pdata->pmic_id_irq)
id_state = msm_otg_read_pmic_id_state(motg);
else if (motg->ext_id_irq)
id_state = gpio_get_value(motg->pdata->usb_id_gpio);
/******************************************************/
else if (motg->phy_irq)
id_state = msm_otg_read_phy_id_state(motg);
//usb_otg: usb@78d9000 {中定义了:
//interrupt-names = "core_irq", "async_irq","phy_irq";
//motg->phy_irq = platform_get_irq_byname(pdev, "phy_irq");
//所以phy_irq不为空,走到这里
/******************************************************/
if (id_state) {
if (!test_and_set_bit(ID, &motg->inputs)) {
pr_debug("ID set\n");
msm_otg_dbg_log_event(&motg->phy, "ID SET",
motg->inputs, motg->phy.state);
work = 1;
}
} else {
if (test_and_clear_bit(ID, &motg->inputs)) {
pr_debug

本文介绍了在高通平台上如何读取USB ID,主要参考了kernel的相关源代码,如phy-msm-usb.c。在msm_id_status_w函数中添加代码,利用msm_otg_read_phy_id_state函数来获取ID状态。USB2_PHY_USB_PHY_INTERRUPT_SRC_STATUS中的IDDIG_1_0标识中断状态变化。设备树节点的配置和msm_otg_probe函数中的中断注册也是关键步骤,中断处理函数msm_otg_phy_irq_handler用于读取ID状态。
最低0.47元/天 解锁文章
5149





