日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

dwc3 linux usb3.0 driver架构

發布時間:2023/12/15 linux 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dwc3 linux usb3.0 driver架构 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

dwc3 linux usb3.0 driver架構:

?

1. DRD driver

DRD驅動在usb/dwc3

?

1.1 dts

dwc3@44000000 {/* Compatible ID used by the Linux driver for this kind of device */compatible = "snps,dwc3";/* Register bank location: AddressMSB, AddressLSB, SizeMSB, SizeLSB */reg = <0x0 0x44000000 0x0 0x100000>;interrupts = <0 8 4>;dr_mode = "otg";extcon = <&extcon_dwc3>; };extcon_dwc3: extcon_dwc3 {compatible = "linux,extcon-usb-gpio";id-gpio = <&porta 1 0>; };

dr_mode可以配置為otg、host或者peripheral。

?

1.2 drd driver

usb/dwc3/core.c:

static struct platform_driver dwc3_driver = {.probe = dwc3_probe,.remove = dwc3_remove,.driver = {.name = "dwc3",.of_match_table = of_match_ptr(of_dwc3_match),.acpi_match_table = ACPI_PTR(dwc3_acpi_match),.pm = &dwc3_dev_pm_ops,}, };static const struct of_device_id of_dwc3_match[] = {{.compatible = "snps,dwc3"},{.compatible = "synopsys,dwc3"},{ }, };

1)首先根據"snps,dwc3"進行dts和driver的匹配,執行dwc3_probe()

2)?在dwc3中先調用 dwc3_get_dr_mode()取得usb?mode(dr_mode),這可以是otg、host或者device

3)然后調用 dwc3_core_init()初始化usb?PHY?interface和usb?PHY,usb?PHY的初始化參照第4節。

4)最后調用 dwc3_core_init_mode()初始化usb?mode:

  • 如果dr_mode為device,則初始化gadget。

  • 如果dr_mode為host,需要初始化xHCI驅動。在dwc3_host_init函數的最后調用platform_device_add(xhci)添加platform?device(xhci-hcd),用于匹配xHCI?driver(xHCI?driver為platform?driver),參照第3節。

  • 如果dr_mode為otg,需要根據extcon來選定一個角色(host或者device)進行初始化,所以還需要extcon驅動的支持,參照第2節。

?

?

2. extcon driver

extcon驅動在drivers/extcon中,利用gpio或其他信號腳提供一種通知機制,控制usb DRD?模式的切換(作為host或者device)。

?

2.1?driver

extcon/extcon-usb-gpio.c:?

tatic const struct of_device_id usb_extcon_dt_match[] = {{ .compatible = "linux,extcon-usb-gpio", },{ /* sentinel */ } };static struct platform_driver usb_extcon_driver = {.probe = usb_extcon_probe,.remove = usb_extcon_remove,.driver = {.name = "extcon-usb-gpio",.pm = &usb_extcon_pm_ops,.of_match_table = usb_extcon_dt_match,},.id_table = usb_extcon_platform_ids, };

1)首先根據"linux,extcon-usb-gpio"進行dts和driver的匹配,執行usb_extcon_probe()

2)在 usb_extcon_probe()中,先調用devm_extcon_dev_register()注冊設備

3)然后為gpio注冊一個中斷處理程序,在該中斷處理中處理gpio中斷,并將信息通過通知鏈機制發送給DRD?driver

4)DRD?driver收到消息后,切換usb的角色,重新初始化usb驅動,作為device或者host

?

?

3. xHCI driver

xHCI驅動在usb/host中,主要初始化xHCI。xHCI作為usb?host部分的驅動。

3.1?

usb/host/xhci-plat.c:

static struct platform_driver usb_xhci_driver = {.probe = xhci_plat_probe,.remove = xhci_plat_remove,.driver = {.name = "xhci-hcd",.pm = &xhci_plat_pm_ops,.of_match_table = of_match_ptr(usb_xhci_of_match),.acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),}, };static int __init xhci_plat_init(void) {xhci_init_driver(&xhci_plat_hc_driver, &xhci_plat_overrides);return platform_driver_register(&usb_xhci_driver); }

1)在xhci_plat_init中調用platform_driver_register(&usb_xhci_driver)注冊platform?driver("xhci-hcd")

2)首先根據name="xhci-hcd"匹配到platform?device后,執行xhci_plat_probe

3)在xhci_plat_probe中,進行xHCI的初始化,最后添加到usb?core中

?

?

4. usb PHY driver

dwc3的PHY初始化主要在 dwc3_core_init中完成,如果確實需要初始化PHY,還需要相關PHY驅動的配合(提供具體的操作函數)。

?

1)synopsys采用femtoPHY,femtoPHY通常情況下無需初始化(設置)其寄存器,只有調試或使用特殊功能時才需要訪問。也就是說,對于femtoPHY,我們可以不寫驅動來進行初始化。

2)雖然不需要初始化PHY,但我們依然需要配置usb?controller的PHY?interface(PIPE、ULPI、UTMI),這在 dwc3_phy_setup中實現。

3)對于某些類型的PHY,必須要進行初始化,這就需要配置dts設置usb-phy或者phy-names。PHY初始化主要由 dwc3_core_get_phy和 dwc3_core_soft_reset等函數調用。里面用到的函數指針需要在相關PHY驅動中進行實現并注冊。

?

總結

以上是生活随笔為你收集整理的dwc3 linux usb3.0 driver架构的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。