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

phy: miphy28lp: Pass sysconfig register offsets via syscfg dt property.

Based on Arnds review comments here https://lkml.org/lkml/2014/11/13/161,
update the miphy28lp phy driver to access sysconfig register offsets via
syscfg dt property.

This is because the reg property should not be mixing address spaces like
it does currently for miphy28lp. This change then also aligns us to how other
platforms such as keystone and bcm7445 pass there syscon offsets via DT.

I have updated the miphy28lp phy driver same way as Peter's implementation.

Signed-off-by: Gabriel Fernandez <gabriel.fernandez@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Gabriel FERNANDEZ and committed by
Kishon Vijay Abraham I
de6e0f84 147fd9d6

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