diff options
-rw-r--r-- | Documentation/devicetree/bindings/phy/phy-miphy28lp.txt | 43 | ||||
-rw-r--r-- | drivers/phy/phy-miphy28lp.c | 61 |
2 files changed, 48 insertions, 56 deletions
diff --git a/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt b/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt index 46a135dae6b3..89caa885d08c 100644 --- a/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt +++ b/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt | |||
@@ -26,6 +26,7 @@ Required properties (port (child) node): | |||
26 | filled in "reg". It can also contain the offset of the system configuration | 26 | filled in "reg". It can also contain the offset of the system configuration |
27 | registers used as glue-logic to setup the device for SATA/PCIe or USB3 | 27 | registers used as glue-logic to setup the device for SATA/PCIe or USB3 |
28 | devices. | 28 | devices. |
29 | - st,syscfg : Offset of the parent configuration register. | ||
29 | - resets : phandle to the parent reset controller. | 30 | - resets : phandle to the parent reset controller. |
30 | - reset-names : Associated name must be "miphy-sw-rst". | 31 | - reset-names : Associated name must be "miphy-sw-rst". |
31 | 32 | ||
@@ -54,18 +55,12 @@ example: | |||
54 | phy_port0: port@9b22000 { | 55 | phy_port0: port@9b22000 { |
55 | reg = <0x9b22000 0xff>, | 56 | reg = <0x9b22000 0xff>, |
56 | <0x9b09000 0xff>, | 57 | <0x9b09000 0xff>, |
57 | <0x9b04000 0xff>, | 58 | <0x9b04000 0xff>; |
58 | <0x114 0x4>, /* sysctrl MiPHY cntrl */ | ||
59 | <0x818 0x4>, /* sysctrl MiPHY status*/ | ||
60 | <0xe0 0x4>, /* sysctrl PCIe */ | ||
61 | <0xec 0x4>; /* sysctrl SATA */ | ||
62 | reg-names = "sata-up", | 59 | reg-names = "sata-up", |
63 | "pcie-up", | 60 | "pcie-up", |
64 | "pipew", | 61 | "pipew"; |
65 | "miphy-ctrl-glue", | 62 | |
66 | "miphy-status-glue", | 63 | st,syscfg = <0x114 0x818 0xe0 0xec>; |
67 | "pcie-glue", | ||
68 | "sata-glue"; | ||
69 | #phy-cells = <1>; | 64 | #phy-cells = <1>; |
70 | st,osc-rdy; | 65 | st,osc-rdy; |
71 | reset-names = "miphy-sw-rst"; | 66 | reset-names = "miphy-sw-rst"; |
@@ -75,18 +70,13 @@ example: | |||
75 | phy_port1: port@9b2a000 { | 70 | phy_port1: port@9b2a000 { |
76 | reg = <0x9b2a000 0xff>, | 71 | reg = <0x9b2a000 0xff>, |
77 | <0x9b19000 0xff>, | 72 | <0x9b19000 0xff>, |
78 | <0x9b14000 0xff>, | 73 | <0x9b14000 0xff>; |
79 | <0x118 0x4>, | ||
80 | <0x81c 0x4>, | ||
81 | <0xe4 0x4>, | ||
82 | <0xf0 0x4>; | ||
83 | reg-names = "sata-up", | 74 | reg-names = "sata-up", |
84 | "pcie-up", | 75 | "pcie-up", |
85 | "pipew", | 76 | "pipew"; |
86 | "miphy-ctrl-glue", | 77 | |
87 | "miphy-status-glue", | 78 | st,syscfg = <0x118 0x81c 0xe4 0xf0>; |
88 | "pcie-glue", | 79 | |
89 | "sata-glue"; | ||
90 | #phy-cells = <1>; | 80 | #phy-cells = <1>; |
91 | st,osc-force-ext; | 81 | st,osc-force-ext; |
92 | reset-names = "miphy-sw-rst"; | 82 | reset-names = "miphy-sw-rst"; |
@@ -95,13 +85,12 @@ example: | |||
95 | 85 | ||
96 | phy_port2: port@8f95000 { | 86 | phy_port2: port@8f95000 { |
97 | reg = <0x8f95000 0xff>, | 87 | reg = <0x8f95000 0xff>, |
98 | <0x8f90000 0xff>, | 88 | <0x8f90000 0xff>; |
99 | <0x11c 0x4>, | ||
100 | <0x820 0x4>; | ||
101 | reg-names = "pipew", | 89 | reg-names = "pipew", |
102 | "usb3-up", | 90 | "usb3-up"; |
103 | "miphy-ctrl-glue", | 91 | |
104 | "miphy-status-glue"; | 92 | st,syscfg = <0x11c 0x820>; |
93 | |||
105 | #phy-cells = <1>; | 94 | #phy-cells = <1>; |
106 | reset-names = "miphy-sw-rst"; | 95 | reset-names = "miphy-sw-rst"; |
107 | resets = <&softreset STIH407_MIPHY2_SOFTRESET>; | 96 | resets = <&softreset STIH407_MIPHY2_SOFTRESET>; |
@@ -125,4 +114,4 @@ example: | |||
125 | 114 | ||
126 | Macro definitions for the supported miphy configuration can be found in: | 115 | Macro definitions for the supported miphy configuration can be found in: |
127 | 116 | ||
128 | include/dt-bindings/phy/phy-miphy28lp.h | 117 | include/dt-bindings/phy/phy.h |
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c index 27fa62ce6136..9b2848e6115d 100644 --- a/drivers/phy/phy-miphy28lp.c +++ b/drivers/phy/phy-miphy28lp.c | |||
@@ -194,6 +194,14 @@ | |||
194 | #define MIPHY_SATA_BANK_NB 3 | 194 | #define MIPHY_SATA_BANK_NB 3 |
195 | #define MIPHY_PCIE_BANK_NB 2 | 195 | #define MIPHY_PCIE_BANK_NB 2 |
196 | 196 | ||
197 | enum { | ||
198 | SYSCFG_CTRL, | ||
199 | SYSCFG_STATUS, | ||
200 | SYSCFG_PCI, | ||
201 | SYSCFG_SATA, | ||
202 | SYSCFG_REG_MAX, | ||
203 | }; | ||
204 | |||
197 | struct miphy28lp_phy { | 205 | struct miphy28lp_phy { |
198 | struct phy *phy; | 206 | struct phy *phy; |
199 | struct miphy28lp_dev *phydev; | 207 | struct miphy28lp_dev *phydev; |
@@ -211,10 +219,7 @@ struct miphy28lp_phy { | |||
211 | u32 sata_gen; | 219 | u32 sata_gen; |
212 | 220 | ||
213 | /* Sysconfig registers offsets needed to configure the device */ | 221 | /* Sysconfig registers offsets needed to configure the device */ |
214 | u32 syscfg_miphy_ctrl; | 222 | u32 syscfg_reg[SYSCFG_REG_MAX]; |
215 | u32 syscfg_miphy_status; | ||
216 | u32 syscfg_pci; | ||
217 | u32 syscfg_sata; | ||
218 | u8 type; | 223 | u8 type; |
219 | }; | 224 | }; |
220 | 225 | ||
@@ -834,12 +839,12 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy) | |||
834 | if (!miphy_phy->osc_rdy) | 839 | if (!miphy_phy->osc_rdy) |
835 | return 0; | 840 | return 0; |
836 | 841 | ||
837 | if (!miphy_phy->syscfg_miphy_status) | 842 | if (!miphy_phy->syscfg_reg[SYSCFG_STATUS]) |
838 | return -EINVAL; | 843 | return -EINVAL; |
839 | 844 | ||
840 | do { | 845 | do { |
841 | regmap_read(miphy_dev->regmap, miphy_phy->syscfg_miphy_status, | 846 | regmap_read(miphy_dev->regmap, |
842 | &val); | 847 | miphy_phy->syscfg_reg[SYSCFG_STATUS], &val); |
843 | 848 | ||
844 | if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY) | 849 | if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY) |
845 | cpu_relax(); | 850 | cpu_relax(); |
@@ -888,7 +893,7 @@ static int miphy28lp_setup(struct miphy28lp_phy *miphy_phy, u32 miphy_val) | |||
888 | int err; | 893 | int err; |
889 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; | 894 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; |
890 | 895 | ||
891 | if (!miphy_phy->syscfg_miphy_ctrl) | 896 | if (!miphy_phy->syscfg_reg[SYSCFG_CTRL]) |
892 | return -EINVAL; | 897 | return -EINVAL; |
893 | 898 | ||
894 | err = reset_control_assert(miphy_phy->miphy_rst); | 899 | err = reset_control_assert(miphy_phy->miphy_rst); |
@@ -900,7 +905,8 @@ static int miphy28lp_setup(struct miphy28lp_phy *miphy_phy, u32 miphy_val) | |||
900 | if (miphy_phy->osc_force_ext) | 905 | if (miphy_phy->osc_force_ext) |
901 | miphy_val |= MIPHY_OSC_FORCE_EXT; | 906 | miphy_val |= MIPHY_OSC_FORCE_EXT; |
902 | 907 | ||
903 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_miphy_ctrl, | 908 | regmap_update_bits(miphy_dev->regmap, |
909 | miphy_phy->syscfg_reg[SYSCFG_CTRL], | ||
904 | MIPHY_CTRL_MASK, miphy_val); | 910 | MIPHY_CTRL_MASK, miphy_val); |
905 | 911 | ||
906 | err = reset_control_deassert(miphy_phy->miphy_rst); | 912 | err = reset_control_deassert(miphy_phy->miphy_rst); |
@@ -917,8 +923,9 @@ static int miphy28lp_init_sata(struct miphy28lp_phy *miphy_phy) | |||
917 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; | 923 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; |
918 | int err, sata_conf = SATA_CTRL_SELECT_SATA; | 924 | int err, sata_conf = SATA_CTRL_SELECT_SATA; |
919 | 925 | ||
920 | if ((!miphy_phy->syscfg_sata) || (!miphy_phy->syscfg_pci) | 926 | if ((!miphy_phy->syscfg_reg[SYSCFG_SATA]) || |
921 | || (!miphy_phy->base)) | 927 | (!miphy_phy->syscfg_reg[SYSCFG_PCI]) || |
928 | (!miphy_phy->base)) | ||
922 | return -EINVAL; | 929 | return -EINVAL; |
923 | 930 | ||
924 | dev_info(miphy_dev->dev, "sata-up mode, addr 0x%p\n", miphy_phy->base); | 931 | dev_info(miphy_dev->dev, "sata-up mode, addr 0x%p\n", miphy_phy->base); |
@@ -926,10 +933,11 @@ static int miphy28lp_init_sata(struct miphy28lp_phy *miphy_phy) | |||
926 | /* Configure the glue-logic */ | 933 | /* Configure the glue-logic */ |
927 | sata_conf |= ((miphy_phy->sata_gen - SATA_GEN1) << SATA_SPDMODE); | 934 | sata_conf |= ((miphy_phy->sata_gen - SATA_GEN1) << SATA_SPDMODE); |
928 | 935 | ||
929 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_sata, | 936 | regmap_update_bits(miphy_dev->regmap, |
937 | miphy_phy->syscfg_reg[SYSCFG_SATA], | ||
930 | SATA_CTRL_MASK, sata_conf); | 938 | SATA_CTRL_MASK, sata_conf); |
931 | 939 | ||
932 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_pci, | 940 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_reg[SYSCFG_PCI], |
933 | PCIE_CTRL_MASK, SATA_CTRL_SELECT_PCIE); | 941 | PCIE_CTRL_MASK, SATA_CTRL_SELECT_PCIE); |
934 | 942 | ||
935 | /* MiPHY path and clocking init */ | 943 | /* MiPHY path and clocking init */ |
@@ -951,17 +959,19 @@ static int miphy28lp_init_pcie(struct miphy28lp_phy *miphy_phy) | |||
951 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; | 959 | struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; |
952 | int err; | 960 | int err; |
953 | 961 | ||
954 | if ((!miphy_phy->syscfg_sata) || (!miphy_phy->syscfg_pci) | 962 | if ((!miphy_phy->syscfg_reg[SYSCFG_SATA]) || |
963 | (!miphy_phy->syscfg_reg[SYSCFG_PCI]) | ||
955 | || (!miphy_phy->base) || (!miphy_phy->pipebase)) | 964 | || (!miphy_phy->base) || (!miphy_phy->pipebase)) |
956 | return -EINVAL; | 965 | return -EINVAL; |
957 | 966 | ||
958 | dev_info(miphy_dev->dev, "pcie-up mode, addr 0x%p\n", miphy_phy->base); | 967 | dev_info(miphy_dev->dev, "pcie-up mode, addr 0x%p\n", miphy_phy->base); |
959 | 968 | ||
960 | /* Configure the glue-logic */ | 969 | /* Configure the glue-logic */ |
961 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_sata, | 970 | regmap_update_bits(miphy_dev->regmap, |
971 | miphy_phy->syscfg_reg[SYSCFG_SATA], | ||
962 | SATA_CTRL_MASK, SATA_CTRL_SELECT_PCIE); | 972 | SATA_CTRL_MASK, SATA_CTRL_SELECT_PCIE); |
963 | 973 | ||
964 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_pci, | 974 | regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_reg[SYSCFG_PCI], |
965 | PCIE_CTRL_MASK, SYSCFG_PCIE_PCIE_VAL); | 975 | PCIE_CTRL_MASK, SYSCFG_PCIE_PCIE_VAL); |
966 | 976 | ||
967 | /* MiPHY path and clocking init */ | 977 | /* MiPHY path and clocking init */ |
@@ -1156,7 +1166,8 @@ static int miphy28lp_probe_resets(struct device_node *node, | |||
1156 | static int miphy28lp_of_probe(struct device_node *np, | 1166 | static int miphy28lp_of_probe(struct device_node *np, |
1157 | struct miphy28lp_phy *miphy_phy) | 1167 | struct miphy28lp_phy *miphy_phy) |
1158 | { | 1168 | { |
1159 | struct resource res; | 1169 | int i; |
1170 | u32 ctrlreg; | ||
1160 | 1171 | ||
1161 | miphy_phy->osc_force_ext = | 1172 | miphy_phy->osc_force_ext = |
1162 | of_property_read_bool(np, "st,osc-force-ext"); | 1173 | of_property_read_bool(np, "st,osc-force-ext"); |
@@ -1175,18 +1186,10 @@ static int miphy28lp_of_probe(struct device_node *np, | |||
1175 | if (!miphy_phy->sata_gen) | 1186 | if (!miphy_phy->sata_gen) |
1176 | miphy_phy->sata_gen = SATA_GEN1; | 1187 | miphy_phy->sata_gen = SATA_GEN1; |
1177 | 1188 | ||
1178 | if (!miphy28lp_get_resource_byname(np, "miphy-ctrl-glue", &res)) | 1189 | for (i = 0; i < SYSCFG_REG_MAX; i++) { |
1179 | miphy_phy->syscfg_miphy_ctrl = res.start; | 1190 | if (!of_property_read_u32_index(np, "st,syscfg", i, &ctrlreg)) |
1180 | 1191 | miphy_phy->syscfg_reg[i] = ctrlreg; | |
1181 | if (!miphy28lp_get_resource_byname(np, "miphy-status-glue", &res)) | 1192 | } |
1182 | miphy_phy->syscfg_miphy_status = res.start; | ||
1183 | |||
1184 | if (!miphy28lp_get_resource_byname(np, "pcie-glue", &res)) | ||
1185 | miphy_phy->syscfg_pci = res.start; | ||
1186 | |||
1187 | if (!miphy28lp_get_resource_byname(np, "sata-glue", &res)) | ||
1188 | miphy_phy->syscfg_sata = res.start; | ||
1189 | |||
1190 | 1193 | ||
1191 | return 0; | 1194 | return 0; |
1192 | } | 1195 | } |