diff options
| author | Icenowy Zheng <icenowy@aosc.xyz> | 2016-08-11 23:06:21 -0400 |
|---|---|---|
| committer | Kishon Vijay Abraham I <kishon@ti.com> | 2016-09-10 07:18:27 -0400 |
| commit | b3e0d141ca9f7355fca8a12feb451c31f6b2ee18 (patch) | |
| tree | f090544c4e0e0da6e96beb22b3098961710a234a /drivers/phy | |
| parent | 732e35da7b4ab054239b92ce10c8e7936724a2c8 (diff) | |
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>
Diffstat (limited to 'drivers/phy')
| -rw-r--r-- | drivers/phy/phy-sun4i-usb.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index 8c7eb335622e..fcf4d95ecc6d 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | #define REG_PHYCTL_A33 0x10 | 50 | #define REG_PHYCTL_A33 0x10 |
| 51 | #define REG_PHY_UNK_H3 0x20 | 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 | #define PHYCTL_DATA BIT(7) | 55 | #define PHYCTL_DATA BIT(7) |
| 56 | 56 | ||
| @@ -98,6 +98,7 @@ enum sun4i_usb_phy_type { | |||
| 98 | sun6i_a31_phy, | 98 | sun6i_a31_phy, |
| 99 | sun8i_a33_phy, | 99 | sun8i_a33_phy, |
| 100 | sun8i_h3_phy, | 100 | sun8i_h3_phy, |
| 101 | sun50i_a64_phy, | ||
| 101 | }; | 102 | }; |
| 102 | 103 | ||
| 103 | struct sun4i_usb_phy_cfg { | 104 | struct sun4i_usb_phy_cfg { |
| @@ -106,6 +107,7 @@ struct sun4i_usb_phy_cfg { | |||
| 106 | u32 disc_thresh; | 107 | u32 disc_thresh; |
| 107 | u8 phyctl_offset; | 108 | u8 phyctl_offset; |
| 108 | bool dedicated_clocks; | 109 | bool dedicated_clocks; |
| 110 | bool enable_pmu_unk1; | ||
| 109 | }; | 111 | }; |
| 110 | 112 | ||
| 111 | struct sun4i_usb_phy_data { | 113 | struct sun4i_usb_phy_data { |
| @@ -183,8 +185,9 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data, | |||
| 183 | 185 | ||
| 184 | mutex_lock(&phy_data->mutex); | 186 | mutex_lock(&phy_data->mutex); |
| 185 | 187 | ||
| 186 | if (phy_data->cfg->type == sun8i_a33_phy) { | 188 | if (phy_data->cfg->type == sun8i_a33_phy || |
| 187 | /* A33 needs us to set phyctl to 0 explicitly */ | 189 | phy_data->cfg->type == sun50i_a64_phy) { |
| 190 | /* A33 or A64 needs us to set phyctl to 0 explicitly */ | ||
| 188 | writel(0, phyctl); | 191 | writel(0, phyctl); |
| 189 | } | 192 | } |
| 190 | 193 | ||
| @@ -258,14 +261,16 @@ static int sun4i_usb_phy_init(struct phy *_phy) | |||
| 258 | return ret; | 261 | return ret; |
| 259 | } | 262 | } |
| 260 | 263 | ||
| 264 | if (data->cfg->enable_pmu_unk1) { | ||
| 265 | val = readl(phy->pmu + REG_PMU_UNK1); | ||
| 266 | writel(val & ~2, phy->pmu + REG_PMU_UNK1); | ||
| 267 | } | ||
| 268 | |||
| 261 | if (data->cfg->type == sun8i_h3_phy) { | 269 | if (data->cfg->type == sun8i_h3_phy) { |
| 262 | if (phy->index == 0) { | 270 | if (phy->index == 0) { |
| 263 | val = readl(data->base + REG_PHY_UNK_H3); | 271 | val = readl(data->base + REG_PHY_UNK_H3); |
| 264 | writel(val & ~1, data->base + REG_PHY_UNK_H3); | 272 | writel(val & ~1, data->base + REG_PHY_UNK_H3); |
| 265 | } | 273 | } |
| 266 | |||
| 267 | val = readl(phy->pmu + REG_PMU_UNK_H3); | ||
| 268 | writel(val & ~2, phy->pmu + REG_PMU_UNK_H3); | ||
| 269 | } else { | 274 | } else { |
| 270 | /* Enable USB 45 Ohm resistor calibration */ | 275 | /* Enable USB 45 Ohm resistor calibration */ |
| 271 | if (phy->index == 0) | 276 | if (phy->index == 0) |
| @@ -737,6 +742,7 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = { | |||
| 737 | .disc_thresh = 3, | 742 | .disc_thresh = 3, |
| 738 | .phyctl_offset = REG_PHYCTL_A10, | 743 | .phyctl_offset = REG_PHYCTL_A10, |
| 739 | .dedicated_clocks = false, | 744 | .dedicated_clocks = false, |
| 745 | .enable_pmu_unk1 = false, | ||
| 740 | }; | 746 | }; |
| 741 | 747 | ||
| 742 | static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { | 748 | static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { |
| @@ -745,6 +751,7 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { | |||
| 745 | .disc_thresh = 2, | 751 | .disc_thresh = 2, |
| 746 | .phyctl_offset = REG_PHYCTL_A10, | 752 | .phyctl_offset = REG_PHYCTL_A10, |
| 747 | .dedicated_clocks = false, | 753 | .dedicated_clocks = false, |
| 754 | .enable_pmu_unk1 = false, | ||
| 748 | }; | 755 | }; |
| 749 | 756 | ||
| 750 | static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { | 757 | static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { |
| @@ -753,6 +760,7 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { | |||
| 753 | .disc_thresh = 3, | 760 | .disc_thresh = 3, |
| 754 | .phyctl_offset = REG_PHYCTL_A10, | 761 | .phyctl_offset = REG_PHYCTL_A10, |
| 755 | .dedicated_clocks = true, | 762 | .dedicated_clocks = true, |
| 763 | .enable_pmu_unk1 = false, | ||
| 756 | }; | 764 | }; |
| 757 | 765 | ||
| 758 | static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { | 766 | static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { |
| @@ -761,6 +769,7 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { | |||
| 761 | .disc_thresh = 2, | 769 | .disc_thresh = 2, |
| 762 | .phyctl_offset = REG_PHYCTL_A10, | 770 | .phyctl_offset = REG_PHYCTL_A10, |
| 763 | .dedicated_clocks = false, | 771 | .dedicated_clocks = false, |
| 772 | .enable_pmu_unk1 = false, | ||
| 764 | }; | 773 | }; |
| 765 | 774 | ||
| 766 | static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { | 775 | static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { |
| @@ -769,6 +778,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { | |||
| 769 | .disc_thresh = 3, | 778 | .disc_thresh = 3, |
| 770 | .phyctl_offset = REG_PHYCTL_A10, | 779 | .phyctl_offset = REG_PHYCTL_A10, |
| 771 | .dedicated_clocks = true, | 780 | .dedicated_clocks = true, |
| 781 | .enable_pmu_unk1 = false, | ||
| 772 | }; | 782 | }; |
| 773 | 783 | ||
| 774 | static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { | 784 | static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { |
| @@ -777,6 +787,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { | |||
| 777 | .disc_thresh = 3, | 787 | .disc_thresh = 3, |
| 778 | .phyctl_offset = REG_PHYCTL_A33, | 788 | .phyctl_offset = REG_PHYCTL_A33, |
| 779 | .dedicated_clocks = true, | 789 | .dedicated_clocks = true, |
| 790 | .enable_pmu_unk1 = false, | ||
| 780 | }; | 791 | }; |
| 781 | 792 | ||
| 782 | static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { | 793 | static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { |
| @@ -784,6 +795,16 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { | |||
| 784 | .type = sun8i_h3_phy, | 795 | .type = sun8i_h3_phy, |
| 785 | .disc_thresh = 3, | 796 | .disc_thresh = 3, |
| 786 | .dedicated_clocks = true, | 797 | .dedicated_clocks = true, |
| 798 | .enable_pmu_unk1 = true, | ||
| 799 | }; | ||
| 800 | |||
| 801 | static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = { | ||
| 802 | .num_phys = 2, | ||
| 803 | .type = sun50i_a64_phy, | ||
| 804 | .disc_thresh = 3, | ||
| 805 | .phyctl_offset = REG_PHYCTL_A33, | ||
| 806 | .dedicated_clocks = true, | ||
| 807 | .enable_pmu_unk1 = true, | ||
| 787 | }; | 808 | }; |
| 788 | 809 | ||
| 789 | static const struct of_device_id sun4i_usb_phy_of_match[] = { | 810 | static const struct of_device_id sun4i_usb_phy_of_match[] = { |
| @@ -794,6 +815,8 @@ static const struct of_device_id sun4i_usb_phy_of_match[] = { | |||
| 794 | { .compatible = "allwinner,sun8i-a23-usb-phy", .data = &sun8i_a23_cfg }, | 815 | { .compatible = "allwinner,sun8i-a23-usb-phy", .data = &sun8i_a23_cfg }, |
| 795 | { .compatible = "allwinner,sun8i-a33-usb-phy", .data = &sun8i_a33_cfg }, | 816 | { .compatible = "allwinner,sun8i-a33-usb-phy", .data = &sun8i_a33_cfg }, |
| 796 | { .compatible = "allwinner,sun8i-h3-usb-phy", .data = &sun8i_h3_cfg }, | 817 | { .compatible = "allwinner,sun8i-h3-usb-phy", .data = &sun8i_h3_cfg }, |
| 818 | { .compatible = "allwinner,sun50i-a64-usb-phy", | ||
| 819 | .data = &sun50i_a64_cfg}, | ||
| 797 | { }, | 820 | { }, |
| 798 | }; | 821 | }; |
| 799 | MODULE_DEVICE_TABLE(of, sun4i_usb_phy_of_match); | 822 | MODULE_DEVICE_TABLE(of, sun4i_usb_phy_of_match); |
