Skip to contentSkip to conversation

phy: Add USB PHY driver for the MT76x8 (7628/7688) SoC

PATCH New Stefan Roese 2 participants 7 messages Apr 5, 2019 – Apr 11, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 phy: Add USB PHY driver for the MT76x8 (7628/7688) SoC

This driver is derived from this Linux driver:
linux/drivers/phy/ralink/phy-ralink-usb.c

The driver sets up power and host mode, but also needs to configure PHY registers for the MT7628 and MT7688.

I removed the reset controller handling for the USB host and device, as it does not seem to be necessary right now. The soft reset bits for both devices are enabled by default and testing has shown (with hackish reset handling added), that USB related commands work identical with or without the reset handling.

Please note that the resulting USB support is tested only very minimal. I was able to detect one of my 3 currently available USB sticks. Perhaps some further work is needed to fully support the EHCI controller integrated in the MT76x8 SoC.

Cc Marek Vasut <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
---
 drivers/phy/Kconfig          |   8 ++
 drivers/phy/Makefile         |   1 +
 drivers/phy/mt76x8-usb-phy.c | 161 +++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 drivers/phy/mt76x8-usb-phy.c
drivers/phy/Kconfig +8 -0
index 32bbf41dd1..102fb91fff 100644
@@ -174,4 +174,12 @@ config KEYSTONE_USB_PHY
 
 	  This PHY is found on some Keystone (K2) devices supporting USB.
 
+config MT76X8_USB_PHY
+	bool "MediaTek MT76x8 (7628/88) USB PHY support"
+	depends on PHY
+	help
+          Support the USB PHY in MT76x8 SoCs
+
+	  This PHY is found on MT76x8 devices supporting USB.
+
 endmenu
drivers/phy/Makefile +1 -0
index 099551d693..b55917bce1 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o meson-gxl-usb3.o
 obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o
 obj-$(CONFIG_OMAP_USB2_PHY) += omap-usb2-phy.o
 obj-$(CONFIG_KEYSTONE_USB_PHY) += keystone-usb-phy.o
+obj-$(CONFIG_MT76X8_USB_PHY) += mt76x8-usb-phy.o
drivers/phy/mt76x8-usb-phy.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/2 mips: mt76xx: linkit-smart-7688: Enable USB and FS support

This patch enables USB and file-system support on the LinkIt smart MT7688 module for both, the normal and the RAM default config.

Cc Daniel Schwierzeck <[email protected]>
---
 configs/linkit-smart-7688-ram_defconfig | 14 +++++++++++++-
 configs/linkit-smart-7688_defconfig     | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)
configs/linkit-smart-7688-ram_defconfig +13 -1
index 2d3ab7e35c..4cb1d7a603 100644
@@ -20,17 +20,21 @@ CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_PART=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="linkit-smart-7688"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
@@ -46,6 +50,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
+CONFIG_MT76X8_USB_PHY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_RAM=y
 CONFIG_DM_RESET=y
@@ -54,5 +59,12 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_STORAGE=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_FAT=y
 CONFIG_LZMA=y
 CONFIG_LZO=y
configs/linkit-smart-7688_defconfig +13 -1
index ad34aaf640..dd157795bd 100644
@@ -24,17 +24,21 @@ CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_PART=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="linkit-smart-7688"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
@@ -50,6 +54,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
+CONFIG_MT76X8_USB_PHY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_RAM=y
 CONFIG_DM_RESET=y
@@ -58,5 +63,12 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_STORAGE=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_FAT=y
 CONFIG_LZMA=y
 CONFIG_LZO=y
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/2 mips: mt76xx: linkit-smart-7688: Enable USB and FS support

Am 05.04.19 um 13:44 schrieb Stefan Roese:

Quoted 9 lines

This patch enables USB and file-system support on the LinkIt smart MT7688 module for both, the normal and the RAM default config.

Cc Daniel Schwierzeck <[email protected]>
---
 configs/linkit-smart-7688-ram_defconfig | 14 +++++++++++++-
 configs/linkit-smart-7688_defconfig     | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

there are now conflicts with current master branch. Could you check and resend?

Quoted 98 lines
configs/linkit-smart-7688-ram_defconfig +13 -1
index 2d3ab7e35c..4cb1d7a603 100644
@@ -20,17 +20,21 @@ CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_PART=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="linkit-smart-7688"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
@@ -46,6 +50,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
+CONFIG_MT76X8_USB_PHY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_RAM=y
 CONFIG_DM_RESET=y
@@ -54,5 +59,12 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_STORAGE=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_FAT=y
 CONFIG_LZMA=y
 CONFIG_LZO=y
configs/linkit-smart-7688_defconfig +13 -1
index ad34aaf640..dd157795bd 100644
@@ -24,17 +24,21 @@ CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_PART=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="linkit-smart-7688"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
@@ -50,6 +54,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
+CONFIG_MT76X8_USB_PHY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_RAM=y
 CONFIG_DM_RESET=y
@@ -58,5 +63,12 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_STORAGE=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_FAT=y
 CONFIG_LZMA=y
 CONFIG_LZO=y
Signature · 1 line
- Daniel
#3 lore raw

PATCH 2/2 mips: mt76xx: linkit-smart-7688: Enable USB and FS support

Hi Daniel,

Quoted 13 lines · Daniel Schwierzeck

Am 05.04.19 um 13:44 schrieb Stefan Roese:

Quoted 9 lines

This patch enables USB and file-system support on the LinkIt smart MT7688 module for both, the normal and the RAM default config.

Cc Daniel Schwierzeck <[email protected]>
---
  configs/linkit-smart-7688-ram_defconfig | 14 +++++++++++++-
  configs/linkit-smart-7688_defconfig     | 14 +++++++++++++-
  2 files changed, 26 insertions(+), 2 deletions(-)
Quoted 2 lines

there are now conflicts with current master branch. Could you check and resend?

Are you sure? I just rebased on the current master branch and it applies clean and the resulting patch is identical with the old one.

Thanks,
Stefan

#4 lore raw

PATCH 2/2 mips: mt76xx: linkit-smart-7688: Enable USB and FS support

Am 11.04.19 um 07:03 schrieb Stefan Roese:

Quoted 16 lines

Hi Daniel,

Quoted 13 lines · Daniel Schwierzeck

Am 05.04.19 um 13:44 schrieb Stefan Roese:

Quoted 9 lines

This patch enables USB and file-system support on the LinkIt smart MT7688 module for both, the normal and the RAM default config.

Cc Daniel Schwierzeck <[email protected]>

---
  configs/linkit-smart-7688-ram_defconfig | 14 +++++++++++++- configs/linkit-smart-7688_defconfig     | 14 +++++++++++++-

  2 files changed, 26 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 2 lines

there are now conflicts with current master branch. Could you check and resend?

Are you sure? I just rebased on the current master branch and it applies clean and the resulting patch is identical with the old one.

ok sorry, the conflict is only with u-boot-mips/next because of your previous patch "mips: mt76xx: linkit: Add mtd command support".

I've applied the patch on u-boot-mips/next. Could you check if the conflict resolution is correct? Thanks.

Signature · 1 line
- Daniel
#5 lore raw

PATCH 2/2 mips: mt76xx: linkit-smart-7688: Enable USB and FS support

Quoted 22 lines · Daniel Schwierzeck

Am 11.04.19 um 07:03 schrieb Stefan Roese:

Quoted 19 lines

Hi Daniel,

Quoted 15 lines · Daniel Schwierzeck

Am 05.04.19 um 13:44 schrieb Stefan Roese:

Quoted 9 lines

This patch enables USB and file-system support on the LinkIt smart MT7688 module for both, the normal and the RAM default config.

Cc Daniel Schwierzeck <[email protected]>
---
   configs/linkit-smart-7688-ram_defconfig | 14 +++++++++++++-
   configs/linkit-smart-7688_defconfig     | 14 +++++++++++++-
   2 files changed, 26 insertions(+), 2 deletions(-)

there are now conflicts with current master branch. Could you check and resend?

Quoted 7 lines
Quoted 4 lines

Are you sure? I just rebased on the current master branch and it applies clean and the resulting patch is identical with the old one.

ok sorry, the conflict is only with u-boot-mips/next because of your previous patch "mips: mt76xx: linkit: Add mtd command support".

I see.

Quoted 2 lines

I've applied the patch on u-boot-mips/next. Could you check if the conflict resolution is correct? Thanks.

Patch looks good in your tree. So please continue with it.

Thanks,
Stefan

#6 lore raw

PATCH 1/2 phy: Add USB PHY driver for the MT76x8 (7628/7688) SoC

In reply to Stefan Roese

Am 05.04.19 um 13:44 schrieb Stefan Roese:

Quoted 20 lines

This driver is derived from this Linux driver:
linux/drivers/phy/ralink/phy-ralink-usb.c

The driver sets up power and host mode, but also needs to configure PHY registers for the MT7628 and MT7688.

I removed the reset controller handling for the USB host and device, as it does not seem to be necessary right now. The soft reset bits for both devices are enabled by default and testing has shown (with hackish reset handling added), that USB related commands work identical with or without the reset handling.

Please note that the resulting USB support is tested only very minimal. I was able to detect one of my 3 currently available USB sticks. Perhaps some further work is needed to fully support the EHCI controller integrated in the MT76x8 SoC.

Cc Marek Vasut <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Quoted 7 lines
---
 drivers/phy/Kconfig          |   8 ++
 drivers/phy/Makefile         |   1 +
 drivers/phy/mt76x8-usb-phy.c | 161 +++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 drivers/phy/mt76x8-usb-phy.c
Signature · 1 line
- Daniel