Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: phy-mt65xx-usb3: add mediatek directory and rename file

The driver is actually for T-PHY which supports USB3.0, PCIe and SATA,
and supports more SoCs now, but not just only for series of mt65xx SoCs,
so the name of file, data struct, functions etc with 'mt65xx' may cause
misunderstanding when new SoCs are supported. Here rename them to reflect
the real functions and also enhance readability.

And also update MAINTAINERS file to reflect the correct driver

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Chunfeng Yun and committed by
Kishon Vijay Abraham I
cd4ec4b0 7c6eac23

+154 -142
+1 -1
MAINTAINERS
··· 1599 1599 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1600 1600 L: linux-mediatek@lists.infradead.org (moderated for non-subscribers) 1601 1601 S: Maintained 1602 - F: drivers/phy/phy-mt65xx-usb3.c 1602 + F: drivers/phy/mediatek/phy-mtk-tphy.c 1603 1603 1604 1604 ARM/MICREL KS8695 ARCHITECTURE 1605 1605 M: Greg Ungerer <gerg@uclinux.org>
+1 -8
drivers/phy/Kconfig
··· 26 26 This driver is need for USB0 support on LPC18xx/43xx and takes 27 27 care of enabling and clock setup. 28 28 29 - config PHY_MT65XX_USB3 30 - tristate "Mediatek USB3.0 PHY Driver" 31 - depends on ARCH_MEDIATEK && OF 32 - select GENERIC_PHY 33 - help 34 - Say 'Y' here to add support for Mediatek USB3.0 PHY driver, 35 - it supports multiple usb2.0 and usb3.0 ports. 36 - 37 29 config PHY_PISTACHIO_USB 38 30 tristate "IMG Pistachio USB2.0 PHY driver" 39 31 depends on MACH_PISTACHIO ··· 45 53 source "drivers/phy/broadcom/Kconfig" 46 54 source "drivers/phy/hisilicon/Kconfig" 47 55 source "drivers/phy/marvell/Kconfig" 56 + source "drivers/phy/mediatek/Kconfig" 48 57 source "drivers/phy/motorola/Kconfig" 49 58 source "drivers/phy/qualcomm/Kconfig" 50 59 source "drivers/phy/renesas/Kconfig"
+1 -1
drivers/phy/Makefile
··· 4 4 5 5 obj-$(CONFIG_GENERIC_PHY) += phy-core.o 6 6 obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o 7 - obj-$(CONFIG_PHY_MT65XX_USB3) += phy-mt65xx-usb3.o 8 7 obj-$(CONFIG_PHY_XGENE) += phy-xgene.o 9 8 obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o 10 9 11 10 obj-$(CONFIG_ARCH_SUNXI) += allwinner/ 12 11 obj-$(CONFIG_ARCH_MESON) += amlogic/ 12 + obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ 13 13 obj-$(CONFIG_ARCH_RENESAS) += renesas/ 14 14 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ 15 15 obj-$(CONFIG_ARCH_TEGRA) += tegra/
+14
drivers/phy/mediatek/Kconfig
··· 1 + # 2 + # Phy drivers for Mediatek devices 3 + # 4 + config PHY_MTK_TPHY 5 + tristate "MediaTek T-PHY Driver" 6 + depends on ARCH_MEDIATEK && OF 7 + select GENERIC_PHY 8 + help 9 + Say 'Y' here to add support for MediaTek T-PHY driver, 10 + it supports multiple usb2.0, usb3.0 ports, PCIe and 11 + SATA, and meanwhile supports two version T-PHY which have 12 + different banks layout, the T-PHY with shared banks between 13 + multi-ports is first version, otherwise is second veriosn, 14 + so you can easily distinguish them by banks layout.
+5
drivers/phy/mediatek/Makefile
··· 1 + # 2 + # Makefile for the phy drivers. 3 + # 4 + 5 + obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o
+132 -132
drivers/phy/phy-mt65xx-usb3.c drivers/phy/mediatek/phy-mtk-tphy.c
··· 38 38 #define SSUSB_SIFSLV_V2_MISC 0x000 39 39 #define SSUSB_SIFSLV_V2_U2FREQ 0x100 40 40 #define SSUSB_SIFSLV_V2_U2PHY_COM 0x300 41 - /* u3 phy banks */ 41 + /* u3/pcie/sata phy banks */ 42 42 #define SSUSB_SIFSLV_V2_SPLLC 0x000 43 43 #define SSUSB_SIFSLV_V2_CHIP 0x100 44 44 #define SSUSB_SIFSLV_V2_U3PHYD 0x200 ··· 258 258 #define RG_CDR_BIRLTD0_GEN3_MSK GENMASK(4, 0) 259 259 #define RG_CDR_BIRLTD0_GEN3_VAL(x) (0x1f & (x)) 260 260 261 - enum mt_phy_version { 262 - MT_PHY_V1 = 1, 263 - MT_PHY_V2, 261 + enum mtk_phy_version { 262 + MTK_PHY_V1 = 1, 263 + MTK_PHY_V2, 264 264 }; 265 265 266 - struct mt65xx_phy_pdata { 266 + struct mtk_phy_pdata { 267 267 /* avoid RX sensitivity level degradation only for mt8173 */ 268 268 bool avoid_rx_sen_degradation; 269 - enum mt_phy_version version; 269 + enum mtk_phy_version version; 270 270 }; 271 271 272 272 struct u2phy_banks { ··· 282 282 void __iomem *phya; /* include u3phya_da */ 283 283 }; 284 284 285 - struct mt65xx_phy_instance { 285 + struct mtk_phy_instance { 286 286 struct phy *phy; 287 287 void __iomem *port_base; 288 288 union { ··· 294 294 u8 type; 295 295 }; 296 296 297 - struct mt65xx_u3phy { 297 + struct mtk_tphy { 298 298 struct device *dev; 299 299 void __iomem *sif_base; /* only shared sif */ 300 300 /* deprecated, use @ref_clk instead in phy instance */ 301 301 struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ 302 - const struct mt65xx_phy_pdata *pdata; 303 - struct mt65xx_phy_instance **phys; 302 + const struct mtk_phy_pdata *pdata; 303 + struct mtk_phy_instance **phys; 304 304 int nphys; 305 305 }; 306 306 307 - static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, 308 - struct mt65xx_phy_instance *instance) 307 + static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, 308 + struct mtk_phy_instance *instance) 309 309 { 310 310 struct u2phy_banks *u2_banks = &instance->u2_banks; 311 311 void __iomem *fmreg = u2_banks->fmreg; ··· 329 329 tmp = readl(fmreg + U3P_U2FREQ_FMCR0); 330 330 tmp &= ~(P2F_RG_CYCLECNT | P2F_RG_MONCLK_SEL); 331 331 tmp |= P2F_RG_CYCLECNT_VAL(U3P_FM_DET_CYCLE_CNT); 332 - if (u3phy->pdata->version == MT_PHY_V1) 332 + if (tphy->pdata->version == MTK_PHY_V1) 333 333 tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index >> 1); 334 334 335 335 writel(tmp, fmreg + U3P_U2FREQ_FMCR0); ··· 364 364 /* if FM detection fail, set default value */ 365 365 calibration_val = 4; 366 366 } 367 - dev_dbg(u3phy->dev, "phy:%d, fm_out:%d, calib:%d\n", 367 + dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d\n", 368 368 instance->index, fm_out, calibration_val); 369 369 370 370 /* set HS slew rate */ ··· 379 379 writel(tmp, com + U3P_USBPHYACR5); 380 380 } 381 381 382 - static void u3_phy_instance_init(struct mt65xx_u3phy *u3phy, 383 - struct mt65xx_phy_instance *instance) 382 + static void u3_phy_instance_init(struct mtk_tphy *tphy, 383 + struct mtk_phy_instance *instance) 384 384 { 385 385 struct u3phy_banks *u3_banks = &instance->u3_banks; 386 386 u32 tmp; ··· 426 426 tmp |= P3D_RG_RXDET_STB2_SET_P3_VAL(0x10); 427 427 writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RXDET2); 428 428 429 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, instance->index); 429 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); 430 430 } 431 431 432 - static void u2_phy_instance_init(struct mt65xx_u3phy *u3phy, 433 - struct mt65xx_phy_instance *instance) 432 + static void u2_phy_instance_init(struct mtk_tphy *tphy, 433 + struct mtk_phy_instance *instance) 434 434 { 435 435 struct u2phy_banks *u2_banks = &instance->u2_banks; 436 436 void __iomem *com = u2_banks->com; ··· 462 462 writel(tmp, com + U3P_U2PHYACR4); 463 463 } 464 464 465 - if (u3phy->pdata->avoid_rx_sen_degradation) { 465 + if (tphy->pdata->avoid_rx_sen_degradation) { 466 466 if (!index) { 467 467 tmp = readl(com + U3P_USBPHYACR2); 468 468 tmp |= PA2_RG_SIF_U2PLL_FORCE_EN; ··· 488 488 tmp |= PA6_RG_U2_SQTH_VAL(2); 489 489 writel(tmp, com + U3P_USBPHYACR6); 490 490 491 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); 491 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, index); 492 492 } 493 493 494 - static void u2_phy_instance_power_on(struct mt65xx_u3phy *u3phy, 495 - struct mt65xx_phy_instance *instance) 494 + static void u2_phy_instance_power_on(struct mtk_tphy *tphy, 495 + struct mtk_phy_instance *instance) 496 496 { 497 497 struct u2phy_banks *u2_banks = &instance->u2_banks; 498 498 void __iomem *com = u2_banks->com; ··· 515 515 tmp &= ~P2C_RG_SESSEND; 516 516 writel(tmp, com + U3P_U2PHYDTM1); 517 517 518 - if (u3phy->pdata->avoid_rx_sen_degradation && index) { 518 + if (tphy->pdata->avoid_rx_sen_degradation && index) { 519 519 tmp = readl(com + U3D_U2PHYDCR0); 520 520 tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; 521 521 writel(tmp, com + U3D_U2PHYDCR0); ··· 524 524 tmp |= P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM; 525 525 writel(tmp, com + U3P_U2PHYDTM0); 526 526 } 527 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); 527 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, index); 528 528 } 529 529 530 - static void u2_phy_instance_power_off(struct mt65xx_u3phy *u3phy, 531 - struct mt65xx_phy_instance *instance) 530 + static void u2_phy_instance_power_off(struct mtk_tphy *tphy, 531 + struct mtk_phy_instance *instance) 532 532 { 533 533 struct u2phy_banks *u2_banks = &instance->u2_banks; 534 534 void __iomem *com = u2_banks->com; ··· 556 556 tmp |= P2C_RG_SESSEND; 557 557 writel(tmp, com + U3P_U2PHYDTM1); 558 558 559 - if (u3phy->pdata->avoid_rx_sen_degradation && index) { 559 + if (tphy->pdata->avoid_rx_sen_degradation && index) { 560 560 tmp = readl(com + U3D_U2PHYDCR0); 561 561 tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; 562 562 writel(tmp, com + U3D_U2PHYDCR0); 563 563 } 564 564 565 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); 565 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, index); 566 566 } 567 567 568 - static void u2_phy_instance_exit(struct mt65xx_u3phy *u3phy, 569 - struct mt65xx_phy_instance *instance) 568 + static void u2_phy_instance_exit(struct mtk_tphy *tphy, 569 + struct mtk_phy_instance *instance) 570 570 { 571 571 struct u2phy_banks *u2_banks = &instance->u2_banks; 572 572 void __iomem *com = u2_banks->com; 573 573 u32 index = instance->index; 574 574 u32 tmp; 575 575 576 - if (u3phy->pdata->avoid_rx_sen_degradation && index) { 576 + if (tphy->pdata->avoid_rx_sen_degradation && index) { 577 577 tmp = readl(com + U3D_U2PHYDCR0); 578 578 tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; 579 579 writel(tmp, com + U3D_U2PHYDCR0); ··· 584 584 } 585 585 } 586 586 587 - static void pcie_phy_instance_init(struct mt65xx_u3phy *u3phy, 588 - struct mt65xx_phy_instance *instance) 587 + static void pcie_phy_instance_init(struct mtk_tphy *tphy, 588 + struct mtk_phy_instance *instance) 589 589 { 590 590 struct u3phy_banks *u3_banks = &instance->u3_banks; 591 591 u32 tmp; 592 592 593 - if (u3phy->pdata->version != MT_PHY_V1) 593 + if (tphy->pdata->version != MTK_PHY_V1) 594 594 return; 595 595 596 596 tmp = readl(u3_banks->phya + U3P_U3_PHYA_DA_REG0); ··· 654 654 655 655 /* wait for PCIe subsys register to active */ 656 656 usleep_range(2500, 3000); 657 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, instance->index); 657 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); 658 658 } 659 659 660 - static void pcie_phy_instance_power_on(struct mt65xx_u3phy *u3phy, 661 - struct mt65xx_phy_instance *instance) 660 + static void pcie_phy_instance_power_on(struct mtk_tphy *tphy, 661 + struct mtk_phy_instance *instance) 662 662 { 663 663 struct u3phy_banks *bank = &instance->u3_banks; 664 664 u32 tmp; ··· 673 673 writel(tmp, bank->chip + U3P_U3_CHIP_GPIO_CTLE); 674 674 } 675 675 676 - static void pcie_phy_instance_power_off(struct mt65xx_u3phy *u3phy, 677 - struct mt65xx_phy_instance *instance) 676 + static void pcie_phy_instance_power_off(struct mtk_tphy *tphy, 677 + struct mtk_phy_instance *instance) 678 678 679 679 { 680 680 struct u3phy_banks *bank = &instance->u3_banks; ··· 689 689 writel(tmp, bank->chip + U3P_U3_CHIP_GPIO_CTLE); 690 690 } 691 691 692 - static void sata_phy_instance_init(struct mt65xx_u3phy *u3phy, 693 - struct mt65xx_phy_instance *instance) 692 + static void sata_phy_instance_init(struct mtk_tphy *tphy, 693 + struct mtk_phy_instance *instance) 694 694 { 695 695 struct u3phy_banks *u3_banks = &instance->u3_banks; 696 696 void __iomem *phyd = u3_banks->phyd; ··· 744 744 tmp |= RG_EQ_DLEQ_LFI_GEN1_VAL(0x03); 745 745 writel(tmp, phyd + ANA_EQ_EYE_CTRL_SIGNAL1); 746 746 747 - dev_dbg(u3phy->dev, "%s(%d)\n", __func__, instance->index); 747 + dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); 748 748 } 749 749 750 - static void phy_v1_banks_init(struct mt65xx_u3phy *u3phy, 751 - struct mt65xx_phy_instance *instance) 750 + static void phy_v1_banks_init(struct mtk_tphy *tphy, 751 + struct mtk_phy_instance *instance) 752 752 { 753 753 struct u2phy_banks *u2_banks = &instance->u2_banks; 754 754 struct u3phy_banks *u3_banks = &instance->u3_banks; ··· 756 756 switch (instance->type) { 757 757 case PHY_TYPE_USB2: 758 758 u2_banks->misc = NULL; 759 - u2_banks->fmreg = u3phy->sif_base + SSUSB_SIFSLV_V1_U2FREQ; 759 + u2_banks->fmreg = tphy->sif_base + SSUSB_SIFSLV_V1_U2FREQ; 760 760 u2_banks->com = instance->port_base + SSUSB_SIFSLV_V1_U2PHY_COM; 761 761 break; 762 762 case PHY_TYPE_USB3: 763 763 case PHY_TYPE_PCIE: 764 - u3_banks->spllc = u3phy->sif_base + SSUSB_SIFSLV_V1_SPLLC; 764 + u3_banks->spllc = tphy->sif_base + SSUSB_SIFSLV_V1_SPLLC; 765 765 u3_banks->chip = NULL; 766 766 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD; 767 767 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA; ··· 770 770 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD; 771 771 break; 772 772 default: 773 - dev_err(u3phy->dev, "incompatible PHY type\n"); 773 + dev_err(tphy->dev, "incompatible PHY type\n"); 774 774 return; 775 775 } 776 776 } 777 777 778 - static void phy_v2_banks_init(struct mt65xx_u3phy *u3phy, 779 - struct mt65xx_phy_instance *instance) 778 + static void phy_v2_banks_init(struct mtk_tphy *tphy, 779 + struct mtk_phy_instance *instance) 780 780 { 781 781 struct u2phy_banks *u2_banks = &instance->u2_banks; 782 782 struct u3phy_banks *u3_banks = &instance->u3_banks; ··· 795 795 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V2_U3PHYA; 796 796 break; 797 797 default: 798 - dev_err(u3phy->dev, "incompatible PHY type\n"); 798 + dev_err(tphy->dev, "incompatible PHY type\n"); 799 799 return; 800 800 } 801 801 } 802 802 803 - static int mt65xx_phy_init(struct phy *phy) 803 + static int mtk_phy_init(struct phy *phy) 804 804 { 805 - struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); 806 - struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); 805 + struct mtk_phy_instance *instance = phy_get_drvdata(phy); 806 + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); 807 807 int ret; 808 808 809 - ret = clk_prepare_enable(u3phy->u3phya_ref); 809 + ret = clk_prepare_enable(tphy->u3phya_ref); 810 810 if (ret) { 811 - dev_err(u3phy->dev, "failed to enable u3phya_ref\n"); 811 + dev_err(tphy->dev, "failed to enable u3phya_ref\n"); 812 812 return ret; 813 813 } 814 814 815 815 ret = clk_prepare_enable(instance->ref_clk); 816 816 if (ret) { 817 - dev_err(u3phy->dev, "failed to enable ref_clk\n"); 817 + dev_err(tphy->dev, "failed to enable ref_clk\n"); 818 818 return ret; 819 819 } 820 820 821 821 switch (instance->type) { 822 822 case PHY_TYPE_USB2: 823 - u2_phy_instance_init(u3phy, instance); 823 + u2_phy_instance_init(tphy, instance); 824 824 break; 825 825 case PHY_TYPE_USB3: 826 - u3_phy_instance_init(u3phy, instance); 826 + u3_phy_instance_init(tphy, instance); 827 827 break; 828 828 case PHY_TYPE_PCIE: 829 - pcie_phy_instance_init(u3phy, instance); 829 + pcie_phy_instance_init(tphy, instance); 830 830 break; 831 831 case PHY_TYPE_SATA: 832 - sata_phy_instance_init(u3phy, instance); 832 + sata_phy_instance_init(tphy, instance); 833 833 break; 834 834 default: 835 - dev_err(u3phy->dev, "incompatible PHY type\n"); 835 + dev_err(tphy->dev, "incompatible PHY type\n"); 836 836 return -EINVAL; 837 837 } 838 838 839 839 return 0; 840 840 } 841 841 842 - static int mt65xx_phy_power_on(struct phy *phy) 842 + static int mtk_phy_power_on(struct phy *phy) 843 843 { 844 - struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); 845 - struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); 844 + struct mtk_phy_instance *instance = phy_get_drvdata(phy); 845 + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); 846 846 847 847 if (instance->type == PHY_TYPE_USB2) { 848 - u2_phy_instance_power_on(u3phy, instance); 849 - hs_slew_rate_calibrate(u3phy, instance); 848 + u2_phy_instance_power_on(tphy, instance); 849 + hs_slew_rate_calibrate(tphy, instance); 850 850 } else if (instance->type == PHY_TYPE_PCIE) { 851 - pcie_phy_instance_power_on(u3phy, instance); 851 + pcie_phy_instance_power_on(tphy, instance); 852 852 } 853 853 854 854 return 0; 855 855 } 856 856 857 - static int mt65xx_phy_power_off(struct phy *phy) 857 + static int mtk_phy_power_off(struct phy *phy) 858 858 { 859 - struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); 860 - struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); 859 + struct mtk_phy_instance *instance = phy_get_drvdata(phy); 860 + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); 861 861 862 862 if (instance->type == PHY_TYPE_USB2) 863 - u2_phy_instance_power_off(u3phy, instance); 863 + u2_phy_instance_power_off(tphy, instance); 864 864 else if (instance->type == PHY_TYPE_PCIE) 865 - pcie_phy_instance_power_off(u3phy, instance); 865 + pcie_phy_instance_power_off(tphy, instance); 866 866 867 867 return 0; 868 868 } 869 869 870 - static int mt65xx_phy_exit(struct phy *phy) 870 + static int mtk_phy_exit(struct phy *phy) 871 871 { 872 - struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); 873 - struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); 872 + struct mtk_phy_instance *instance = phy_get_drvdata(phy); 873 + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); 874 874 875 875 if (instance->type == PHY_TYPE_USB2) 876 - u2_phy_instance_exit(u3phy, instance); 876 + u2_phy_instance_exit(tphy, instance); 877 877 878 878 clk_disable_unprepare(instance->ref_clk); 879 - clk_disable_unprepare(u3phy->u3phya_ref); 879 + clk_disable_unprepare(tphy->u3phya_ref); 880 880 return 0; 881 881 } 882 882 883 - static struct phy *mt65xx_phy_xlate(struct device *dev, 883 + static struct phy *mtk_phy_xlate(struct device *dev, 884 884 struct of_phandle_args *args) 885 885 { 886 - struct mt65xx_u3phy *u3phy = dev_get_drvdata(dev); 887 - struct mt65xx_phy_instance *instance = NULL; 886 + struct mtk_tphy *tphy = dev_get_drvdata(dev); 887 + struct mtk_phy_instance *instance = NULL; 888 888 struct device_node *phy_np = args->np; 889 889 int index; 890 890 ··· 893 893 return ERR_PTR(-EINVAL); 894 894 } 895 895 896 - for (index = 0; index < u3phy->nphys; index++) 897 - if (phy_np == u3phy->phys[index]->phy->dev.of_node) { 898 - instance = u3phy->phys[index]; 896 + for (index = 0; index < tphy->nphys; index++) 897 + if (phy_np == tphy->phys[index]->phy->dev.of_node) { 898 + instance = tphy->phys[index]; 899 899 break; 900 900 } 901 901 ··· 913 913 return ERR_PTR(-EINVAL); 914 914 } 915 915 916 - if (u3phy->pdata->version == MT_PHY_V1) { 917 - phy_v1_banks_init(u3phy, instance); 918 - } else if (u3phy->pdata->version == MT_PHY_V2) { 919 - phy_v2_banks_init(u3phy, instance); 916 + if (tphy->pdata->version == MTK_PHY_V1) { 917 + phy_v1_banks_init(tphy, instance); 918 + } else if (tphy->pdata->version == MTK_PHY_V2) { 919 + phy_v2_banks_init(tphy, instance); 920 920 } else { 921 921 dev_err(dev, "phy version is not supported\n"); 922 922 return ERR_PTR(-EINVAL); ··· 925 925 return instance->phy; 926 926 } 927 927 928 - static const struct phy_ops mt65xx_u3phy_ops = { 929 - .init = mt65xx_phy_init, 930 - .exit = mt65xx_phy_exit, 931 - .power_on = mt65xx_phy_power_on, 932 - .power_off = mt65xx_phy_power_off, 928 + static const struct phy_ops mtk_tphy_ops = { 929 + .init = mtk_phy_init, 930 + .exit = mtk_phy_exit, 931 + .power_on = mtk_phy_power_on, 932 + .power_off = mtk_phy_power_off, 933 933 .owner = THIS_MODULE, 934 934 }; 935 935 936 - static const struct mt65xx_phy_pdata tphy_v1_pdata = { 936 + static const struct mtk_phy_pdata tphy_v1_pdata = { 937 937 .avoid_rx_sen_degradation = false, 938 - .version = MT_PHY_V1, 938 + .version = MTK_PHY_V1, 939 939 }; 940 940 941 - static const struct mt65xx_phy_pdata tphy_v2_pdata = { 941 + static const struct mtk_phy_pdata tphy_v2_pdata = { 942 942 .avoid_rx_sen_degradation = false, 943 - .version = MT_PHY_V2, 943 + .version = MTK_PHY_V2, 944 944 }; 945 945 946 - static const struct mt65xx_phy_pdata mt8173_pdata = { 946 + static const struct mtk_phy_pdata mt8173_pdata = { 947 947 .avoid_rx_sen_degradation = true, 948 - .version = MT_PHY_V1, 948 + .version = MTK_PHY_V1, 949 949 }; 950 950 951 - static const struct of_device_id mt65xx_u3phy_id_table[] = { 951 + static const struct of_device_id mtk_tphy_id_table[] = { 952 952 { .compatible = "mediatek,mt2701-u3phy", .data = &tphy_v1_pdata }, 953 953 { .compatible = "mediatek,mt2712-u3phy", .data = &tphy_v2_pdata }, 954 954 { .compatible = "mediatek,mt8173-u3phy", .data = &mt8173_pdata }, ··· 956 956 { .compatible = "mediatek,generic-tphy-v2", .data = &tphy_v2_pdata }, 957 957 { }, 958 958 }; 959 - MODULE_DEVICE_TABLE(of, mt65xx_u3phy_id_table); 959 + MODULE_DEVICE_TABLE(of, mtk_tphy_id_table); 960 960 961 - static int mt65xx_u3phy_probe(struct platform_device *pdev) 961 + static int mtk_tphy_probe(struct platform_device *pdev) 962 962 { 963 963 const struct of_device_id *match; 964 964 struct device *dev = &pdev->dev; ··· 966 966 struct device_node *child_np; 967 967 struct phy_provider *provider; 968 968 struct resource *sif_res; 969 - struct mt65xx_u3phy *u3phy; 969 + struct mtk_tphy *tphy; 970 970 struct resource res; 971 971 int port, retval; 972 972 973 - match = of_match_node(mt65xx_u3phy_id_table, pdev->dev.of_node); 973 + match = of_match_node(mtk_tphy_id_table, pdev->dev.of_node); 974 974 if (!match) 975 975 return -EINVAL; 976 976 977 - u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); 978 - if (!u3phy) 977 + tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL); 978 + if (!tphy) 979 979 return -ENOMEM; 980 980 981 - u3phy->pdata = match->data; 982 - u3phy->nphys = of_get_child_count(np); 983 - u3phy->phys = devm_kcalloc(dev, u3phy->nphys, 984 - sizeof(*u3phy->phys), GFP_KERNEL); 985 - if (!u3phy->phys) 981 + tphy->pdata = match->data; 982 + tphy->nphys = of_get_child_count(np); 983 + tphy->phys = devm_kcalloc(dev, tphy->nphys, 984 + sizeof(*tphy->phys), GFP_KERNEL); 985 + if (!tphy->phys) 986 986 return -ENOMEM; 987 987 988 - u3phy->dev = dev; 989 - platform_set_drvdata(pdev, u3phy); 988 + tphy->dev = dev; 989 + platform_set_drvdata(pdev, tphy); 990 990 991 - if (u3phy->pdata->version == MT_PHY_V1) { 991 + if (tphy->pdata->version == MTK_PHY_V1) { 992 992 /* get banks shared by multiple phys */ 993 993 sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 994 - u3phy->sif_base = devm_ioremap_resource(dev, sif_res); 995 - if (IS_ERR(u3phy->sif_base)) { 994 + tphy->sif_base = devm_ioremap_resource(dev, sif_res); 995 + if (IS_ERR(tphy->sif_base)) { 996 996 dev_err(dev, "failed to remap sif regs\n"); 997 - return PTR_ERR(u3phy->sif_base); 997 + return PTR_ERR(tphy->sif_base); 998 998 } 999 999 } 1000 1000 1001 1001 /* it's deprecated, make it optional for backward compatibility */ 1002 - u3phy->u3phya_ref = devm_clk_get(dev, "u3phya_ref"); 1003 - if (IS_ERR(u3phy->u3phya_ref)) { 1004 - if (PTR_ERR(u3phy->u3phya_ref) == -EPROBE_DEFER) 1002 + tphy->u3phya_ref = devm_clk_get(dev, "u3phya_ref"); 1003 + if (IS_ERR(tphy->u3phya_ref)) { 1004 + if (PTR_ERR(tphy->u3phya_ref) == -EPROBE_DEFER) 1005 1005 return -EPROBE_DEFER; 1006 1006 1007 - u3phy->u3phya_ref = NULL; 1007 + tphy->u3phya_ref = NULL; 1008 1008 } 1009 1009 1010 1010 port = 0; 1011 1011 for_each_child_of_node(np, child_np) { 1012 - struct mt65xx_phy_instance *instance; 1012 + struct mtk_phy_instance *instance; 1013 1013 struct phy *phy; 1014 1014 1015 1015 instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); ··· 1018 1018 goto put_child; 1019 1019 } 1020 1020 1021 - u3phy->phys[port] = instance; 1021 + tphy->phys[port] = instance; 1022 1022 1023 - phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); 1023 + phy = devm_phy_create(dev, child_np, &mtk_tphy_ops); 1024 1024 if (IS_ERR(phy)) { 1025 1025 dev_err(dev, "failed to create phy\n"); 1026 1026 retval = PTR_ERR(phy); ··· 1047 1047 port++; 1048 1048 1049 1049 /* if deprecated clock is provided, ignore instance's one */ 1050 - if (u3phy->u3phya_ref) 1050 + if (tphy->u3phya_ref) 1051 1051 continue; 1052 1052 1053 1053 instance->ref_clk = devm_clk_get(&phy->dev, "ref"); ··· 1058 1058 } 1059 1059 } 1060 1060 1061 - provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); 1061 + provider = devm_of_phy_provider_register(dev, mtk_phy_xlate); 1062 1062 1063 1063 return PTR_ERR_OR_ZERO(provider); 1064 1064 put_child: ··· 1066 1066 return retval; 1067 1067 } 1068 1068 1069 - static struct platform_driver mt65xx_u3phy_driver = { 1070 - .probe = mt65xx_u3phy_probe, 1069 + static struct platform_driver mtk_tphy_driver = { 1070 + .probe = mtk_tphy_probe, 1071 1071 .driver = { 1072 - .name = "mt65xx-u3phy", 1073 - .of_match_table = mt65xx_u3phy_id_table, 1072 + .name = "mtk-tphy", 1073 + .of_match_table = mtk_tphy_id_table, 1074 1074 }, 1075 1075 }; 1076 1076 1077 - module_platform_driver(mt65xx_u3phy_driver); 1077 + module_platform_driver(mtk_tphy_driver); 1078 1078 1079 1079 MODULE_AUTHOR("Chunfeng Yun <chunfeng.yun@mediatek.com>"); 1080 - MODULE_DESCRIPTION("mt65xx USB PHY driver"); 1080 + MODULE_DESCRIPTION("MediaTek T-PHY driver"); 1081 1081 MODULE_LICENSE("GPL v2");