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

phy: sun4i: add support for A64 usb phy

There's something unknown in the pmu part that shared with H3.
It's renamed as PMU_UNK1 from PMU_UNK_H3.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Icenowy Zheng and committed by
Kishon Vijay Abraham I
b3e0d141 732e35da

+29 -6
+29 -6
drivers/phy/phy-sun4i-usb.c
··· 50 50 #define REG_PHYCTL_A33 0x10 51 51 #define REG_PHY_UNK_H3 0x20 52 52 53 - #define REG_PMU_UNK_H3 0x10 53 + #define REG_PMU_UNK1 0x10 54 54 55 55 #define PHYCTL_DATA BIT(7) 56 56 ··· 98 98 sun6i_a31_phy, 99 99 sun8i_a33_phy, 100 100 sun8i_h3_phy, 101 + sun50i_a64_phy, 101 102 }; 102 103 103 104 struct sun4i_usb_phy_cfg { ··· 107 106 u32 disc_thresh; 108 107 u8 phyctl_offset; 109 108 bool dedicated_clocks; 109 + bool enable_pmu_unk1; 110 110 }; 111 111 112 112 struct sun4i_usb_phy_data { ··· 185 183 186 184 mutex_lock(&phy_data->mutex); 187 185 188 - if (phy_data->cfg->type == sun8i_a33_phy) { 189 - /* A33 needs us to set phyctl to 0 explicitly */ 186 + if (phy_data->cfg->type == sun8i_a33_phy || 187 + phy_data->cfg->type == sun50i_a64_phy) { 188 + /* A33 or A64 needs us to set phyctl to 0 explicitly */ 190 189 writel(0, phyctl); 191 190 } 192 191 ··· 261 258 return ret; 262 259 } 263 260 261 + if (data->cfg->enable_pmu_unk1) { 262 + val = readl(phy->pmu + REG_PMU_UNK1); 263 + writel(val & ~2, phy->pmu + REG_PMU_UNK1); 264 + } 265 + 264 266 if (data->cfg->type == sun8i_h3_phy) { 265 267 if (phy->index == 0) { 266 268 val = readl(data->base + REG_PHY_UNK_H3); 267 269 writel(val & ~1, data->base + REG_PHY_UNK_H3); 268 270 } 269 - 270 - val = readl(phy->pmu + REG_PMU_UNK_H3); 271 - writel(val & ~2, phy->pmu + REG_PMU_UNK_H3); 272 271 } else { 273 272 /* Enable USB 45 Ohm resistor calibration */ 274 273 if (phy->index == 0) ··· 742 737 .disc_thresh = 3, 743 738 .phyctl_offset = REG_PHYCTL_A10, 744 739 .dedicated_clocks = false, 740 + .enable_pmu_unk1 = false, 745 741 }; 746 742 747 743 static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { ··· 751 745 .disc_thresh = 2, 752 746 .phyctl_offset = REG_PHYCTL_A10, 753 747 .dedicated_clocks = false, 748 + .enable_pmu_unk1 = false, 754 749 }; 755 750 756 751 static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { ··· 760 753 .disc_thresh = 3, 761 754 .phyctl_offset = REG_PHYCTL_A10, 762 755 .dedicated_clocks = true, 756 + .enable_pmu_unk1 = false, 763 757 }; 764 758 765 759 static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { ··· 769 761 .disc_thresh = 2, 770 762 .phyctl_offset = REG_PHYCTL_A10, 771 763 .dedicated_clocks = false, 764 + .enable_pmu_unk1 = false, 772 765 }; 773 766 774 767 static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { ··· 778 769 .disc_thresh = 3, 779 770 .phyctl_offset = REG_PHYCTL_A10, 780 771 .dedicated_clocks = true, 772 + .enable_pmu_unk1 = false, 781 773 }; 782 774 783 775 static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { ··· 787 777 .disc_thresh = 3, 788 778 .phyctl_offset = REG_PHYCTL_A33, 789 779 .dedicated_clocks = true, 780 + .enable_pmu_unk1 = false, 790 781 }; 791 782 792 783 static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { ··· 795 784 .type = sun8i_h3_phy, 796 785 .disc_thresh = 3, 797 786 .dedicated_clocks = true, 787 + .enable_pmu_unk1 = true, 788 + }; 789 + 790 + static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = { 791 + .num_phys = 2, 792 + .type = sun50i_a64_phy, 793 + .disc_thresh = 3, 794 + .phyctl_offset = REG_PHYCTL_A33, 795 + .dedicated_clocks = true, 796 + .enable_pmu_unk1 = true, 798 797 }; 799 798 800 799 static const struct of_device_id sun4i_usb_phy_of_match[] = { ··· 815 794 { .compatible = "allwinner,sun8i-a23-usb-phy", .data = &sun8i_a23_cfg }, 816 795 { .compatible = "allwinner,sun8i-a33-usb-phy", .data = &sun8i_a33_cfg }, 817 796 { .compatible = "allwinner,sun8i-h3-usb-phy", .data = &sun8i_h3_cfg }, 797 + { .compatible = "allwinner,sun50i-a64-usb-phy", 798 + .data = &sun50i_a64_cfg}, 818 799 { }, 819 800 }; 820 801 MODULE_DEVICE_TABLE(of, sun4i_usb_phy_of_match);