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

Merge branch 'sti_drivers'

Peter Griffin says:

====================
Fix sti drivers whcih mix reg address spaces

A V2 of this old series incorporating Arnd and Lees Feedback form v1.

Following on from Arnds comments about the picophy driver here
https://lkml.org/lkml/2014/11/13/161, this series fixes the
remaining upstreamed drivers for STI, which are mixing address spaces
in the reg property. We do this in a way similar to the keystone
and bcm7445 platforms, by having sysconfig phandle/ offset pair
(where only one register is required). Or phandle / integer array
where multiple offsets in the same bank are needed).

This series breaks DT compatability! But the platform support
is WIP and only being used by the few developers who are upstreaming
support for it. I've made each change to the driver / dt doc / dt
file as a single atomic commit so the kernel will remain bisectable.

This series then also enables the picophy driver, and adds back in
the ehci/ohci dt nodes for stih410 which make use of the picophy.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+143 -77
+5 -9
Documentation/devicetree/bindings/net/sti-dwmac.txt
··· 9 9 Required properties: 10 10 - compatible : Can be "st,stih415-dwmac", "st,stih416-dwmac", 11 11 "st,stih407-dwmac", "st,stid127-dwmac". 12 - - reg : Offset of the glue configuration register map in system 13 - configuration regmap pointed by st,syscon property and size. 14 - - st,syscon : Should be phandle to system configuration node which 15 - encompases this glue registers. 12 + - st,syscon : Should be phandle/offset pair. The phandle to the syscon node which 13 + encompases the glue register, and the offset of the control register. 16 14 - st,gmac_en: this is to enable the gmac into a dedicated sysctl control 17 15 register available on STiH407 SoC. 18 - - sti-ethconf: this is the gmac glue logic register to enable the GMAC, 19 - select among the different modes and program the clk retiming. 20 16 - pinctrl-0: pin-control for all the MII mode supported. 21 17 22 18 Optional properties: ··· 36 40 device_type = "network"; 37 41 status = "disabled"; 38 42 compatible = "st,stih407-dwmac", "snps,dwmac", "snps,dwmac-3.710"; 39 - reg = <0x9630000 0x8000>, <0x80 0x4>; 40 - reg-names = "stmmaceth", "sti-ethconf"; 43 + reg = <0x9630000 0x8000>; 44 + reg-names = "stmmaceth"; 41 45 42 - st,syscon = <&syscfg_sbc_reg>; 46 + st,syscon = <&syscfg_sbc_reg 0x80>; 43 47 st,gmac_en; 44 48 resets = <&softreset STIH407_ETH1_SOFTRESET>; 45 49 reset-names = "stmmaceth";
+8 -7
Documentation/devicetree/bindings/phy/phy-miphy365x.txt
··· 6 6 7 7 Required properties (controller (parent) node): 8 8 - compatible : Should be "st,miphy365x-phy" 9 - - st,syscfg : Should be a phandle of the system configuration register group 10 - which contain the SATA, PCIe mode setting bits 9 + - st,syscfg : Phandle / integer array property. Phandle of sysconfig group 10 + containing the miphy registers and integer array should contain 11 + an entry for each port sub-node, specifying the control 12 + register offset inside the sysconfig group. 11 13 12 14 Required nodes : A sub-node is required for each channel the controller 13 15 provides. Address range information including the usual ··· 28 26 registers filled in "reg": 29 27 - sata: For SATA devices 30 28 - pcie: For PCIe devices 31 - - syscfg: To specify the syscfg based config register 32 29 33 30 Optional properties (port (child) node): 34 31 - st,sata-gen : Generation of locally attached SATA IP. Expected values ··· 40 39 41 40 miphy365x_phy: miphy365x@fe382000 { 42 41 compatible = "st,miphy365x-phy"; 43 - st,syscfg = <&syscfg_rear>; 42 + st,syscfg = <&syscfg_rear 0x824 0x828>; 44 43 #address-cells = <1>; 45 44 #size-cells = <1>; 46 45 ranges; 47 46 48 47 phy_port0: port@fe382000 { 49 - reg = <0xfe382000 0x100>, <0xfe394000 0x100>, <0x824 0x4>; 50 - reg-names = "sata", "pcie", "syscfg"; 48 + reg = <0xfe382000 0x100>, <0xfe394000 0x100>; 49 + reg-names = "sata", "pcie"; 51 50 #phy-cells = <1>; 52 51 st,sata-gen = <3>; 53 52 }; 54 53 55 54 phy_port1: port@fe38a000 { 56 - reg = <0xfe38a000 0x100>, <0xfe804000 0x100>, <0x828 0x4>;; 55 + reg = <0xfe38a000 0x100>, <0xfe804000 0x100>;; 57 56 reg-names = "sata", "pcie", "syscfg"; 58 57 #phy-cells = <1>; 59 58 st,pcie-tx-pol-inv;
+2 -8
Documentation/devicetree/bindings/phy/phy-stih407-usb.txt
··· 5 5 6 6 Required properties: 7 7 - compatible : should be "st,stih407-usb2-phy" 8 - - reg : contain the offset and length of the system configuration registers 9 - used as glue logic to control & parameter phy 10 - - reg-names : the names of the system configuration registers in "reg", should be "param" and "reg" 11 - - st,syscfg : sysconfig register to manage phy parameter at driver level 8 + - st,syscfg : phandle of sysconfig bank plus integer array containing phyparam and phyctrl register offsets 12 9 - resets : list of phandle and reset specifier pairs. There should be two entries, one 13 10 for the whole phy and one for the port 14 11 - reset-names : list of reset signal names. Should be "global" and "port" ··· 16 19 17 20 usb2_picophy0: usbpicophy@f8 { 18 21 compatible = "st,stih407-usb2-phy"; 19 - reg = <0xf8 0x04>, /* syscfg 5062 */ 20 - <0xf4 0x04>; /* syscfg 5061 */ 21 - reg-names = "param", "ctrl"; 22 22 #phy-cells = <0>; 23 - st,syscfg = <&syscfg_core>; 23 + st,syscfg = <&syscfg_core 0x100 0xf4>; 24 24 resets = <&softreset STIH407_PICOPHY_SOFTRESET>, 25 25 <&picophyreset STIH407_PICOPHY0_RESET>; 26 26 reset-names = "global", "port";
+9
arch/arm/boot/dts/stih407-family.dtsi
··· 274 274 275 275 status = "disabled"; 276 276 }; 277 + 278 + usb2_picophy0: phy1 { 279 + compatible = "st,stih407-usb2-phy"; 280 + #phy-cells = <0>; 281 + st,syscfg = <&syscfg_core 0x100 0xf4>; 282 + resets = <&softreset STIH407_PICOPHY_SOFTRESET>, 283 + <&picophyreset STIH407_PICOPHY0_RESET>; 284 + reset-names = "global", "port"; 285 + }; 277 286 }; 278 287 };
+70
arch/arm/boot/dts/stih410.dtsi
··· 10 10 #include "stih407-family.dtsi" 11 11 #include "stih410-pinctrl.dtsi" 12 12 / { 13 + soc { 14 + usb2_picophy1: phy2 { 15 + compatible = "st,stih407-usb2-phy"; 16 + #phy-cells = <0>; 17 + st,syscfg = <&syscfg_core 0xf8 0xf4>; 18 + resets = <&softreset STIH407_PICOPHY_SOFTRESET>, 19 + <&picophyreset STIH407_PICOPHY0_RESET>; 20 + reset-names = "global", "port"; 21 + }; 13 22 23 + usb2_picophy2: phy3 { 24 + compatible = "st,stih407-usb2-phy"; 25 + #phy-cells = <0>; 26 + st,syscfg = <&syscfg_core 0xfc 0xf4>; 27 + resets = <&softreset STIH407_PICOPHY_SOFTRESET>, 28 + <&picophyreset STIH407_PICOPHY1_RESET>; 29 + reset-names = "global", "port"; 30 + }; 31 + 32 + ohci0: usb@9a03c00 { 33 + compatible = "st,st-ohci-300x"; 34 + reg = <0x9a03c00 0x100>; 35 + interrupts = <GIC_SPI 180 IRQ_TYPE_NONE>; 36 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; 37 + resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, 38 + <&softreset STIH407_USB2_PORT0_SOFTRESET>; 39 + reset-names = "power", "softreset"; 40 + phys = <&usb2_picophy1>; 41 + phy-names = "usb"; 42 + }; 43 + 44 + ehci0: usb@9a03e00 { 45 + compatible = "st,st-ehci-300x"; 46 + reg = <0x9a03e00 0x100>; 47 + interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>; 48 + pinctrl-names = "default"; 49 + pinctrl-0 = <&pinctrl_usb0>; 50 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; 51 + resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, 52 + <&softreset STIH407_USB2_PORT0_SOFTRESET>; 53 + reset-names = "power", "softreset"; 54 + phys = <&usb2_picophy1>; 55 + phy-names = "usb"; 56 + }; 57 + 58 + ohci1: usb@9a83c00 { 59 + compatible = "st,st-ohci-300x"; 60 + reg = <0x9a83c00 0x100>; 61 + interrupts = <GIC_SPI 181 IRQ_TYPE_NONE>; 62 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; 63 + resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, 64 + <&softreset STIH407_USB2_PORT1_SOFTRESET>; 65 + reset-names = "power", "softreset"; 66 + phys = <&usb2_picophy2>; 67 + phy-names = "usb"; 68 + }; 69 + 70 + ehci1: usb@9a83e00 { 71 + compatible = "st,st-ehci-300x"; 72 + reg = <0x9a83e00 0x100>; 73 + interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>; 74 + pinctrl-names = "default"; 75 + pinctrl-0 = <&pinctrl_usb1>; 76 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; 77 + resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, 78 + <&softreset STIH407_USB2_PORT1_SOFTRESET>; 79 + reset-names = "power", "softreset"; 80 + phys = <&usb2_picophy2>; 81 + phy-names = "usb"; 82 + }; 83 + }; 14 84 };
+6 -6
arch/arm/boot/dts/stih415.dtsi
··· 153 153 compatible = "st,stih415-dwmac", "snps,dwmac", "snps,dwmac-3.610"; 154 154 status = "disabled"; 155 155 156 - reg = <0xfe810000 0x8000>, <0x148 0x4>; 157 - reg-names = "stmmaceth", "sti-ethconf"; 156 + reg = <0xfe810000 0x8000>; 157 + reg-names = "stmmaceth"; 158 158 159 159 interrupts = <0 147 0>, <0 148 0>, <0 149 0>; 160 160 interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; ··· 165 165 snps,mixed-burst; 166 166 snps,force_sf_dma_mode; 167 167 168 - st,syscon = <&syscfg_rear>; 168 + st,syscon = <&syscfg_rear 0x148>; 169 169 170 170 pinctrl-names = "default"; 171 171 pinctrl-0 = <&pinctrl_mii0>; ··· 177 177 device_type = "network"; 178 178 compatible = "st,stih415-dwmac", "snps,dwmac", "snps,dwmac-3.610"; 179 179 status = "disabled"; 180 - reg = <0xfef08000 0x8000>, <0x74 0x4>; 181 - reg-names = "stmmaceth", "sti-ethconf"; 180 + reg = <0xfef08000 0x8000>; 181 + reg-names = "stmmaceth"; 182 182 interrupts = <0 150 0>, <0 151 0>, <0 152 0>; 183 183 interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; 184 184 ··· 186 186 snps,mixed-burst; 187 187 snps,force_sf_dma_mode; 188 188 189 - st,syscon = <&syscfg_sbc>; 189 + st,syscon = <&syscfg_sbc 0x74>; 190 190 191 191 resets = <&softreset STIH415_ETH1_SOFTRESET>; 192 192 reset-names = "stmmaceth";
+11 -11
arch/arm/boot/dts/stih416.dtsi
··· 163 163 device_type = "network"; 164 164 compatible = "st,stih416-dwmac", "snps,dwmac", "snps,dwmac-3.710"; 165 165 status = "disabled"; 166 - reg = <0xfe810000 0x8000>, <0x8bc 0x4>; 167 - reg-names = "stmmaceth", "sti-ethconf"; 166 + reg = <0xfe810000 0x8000>; 167 + reg-names = "stmmaceth"; 168 168 169 169 interrupts = <0 133 0>, <0 134 0>, <0 135 0>; 170 170 interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; ··· 172 172 snps,pbl = <32>; 173 173 snps,mixed-burst; 174 174 175 - st,syscon = <&syscfg_rear>; 175 + st,syscon = <&syscfg_rear 0x8bc>; 176 176 resets = <&softreset STIH416_ETH0_SOFTRESET>; 177 177 reset-names = "stmmaceth"; 178 178 pinctrl-names = "default"; ··· 185 185 device_type = "network"; 186 186 compatible = "st,stih416-dwmac", "snps,dwmac", "snps,dwmac-3.710"; 187 187 status = "disabled"; 188 - reg = <0xfef08000 0x8000>, <0x7f0 0x4>; 189 - reg-names = "stmmaceth", "sti-ethconf"; 188 + reg = <0xfef08000 0x8000>; 189 + reg-names = "stmmaceth"; 190 190 interrupts = <0 136 0>, <0 137 0>, <0 138 0>; 191 191 interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; 192 192 193 193 snps,pbl = <32>; 194 194 snps,mixed-burst; 195 195 196 - st,syscon = <&syscfg_sbc>; 196 + st,syscon = <&syscfg_sbc 0x7f0>; 197 197 198 198 resets = <&softreset STIH416_ETH1_SOFTRESET>; 199 199 reset-names = "stmmaceth"; ··· 283 283 284 284 miphy365x_phy: phy@fe382000 { 285 285 compatible = "st,miphy365x-phy"; 286 - st,syscfg = <&syscfg_rear>; 286 + st,syscfg = <&syscfg_rear 0x824 0x828>; 287 287 #address-cells = <1>; 288 288 #size-cells = <1>; 289 289 ranges; 290 290 291 291 phy_port0: port@fe382000 { 292 292 #phy-cells = <1>; 293 - reg = <0xfe382000 0x100>, <0xfe394000 0x100>, <0x824 0x4>; 294 - reg-names = "sata", "pcie", "syscfg"; 293 + reg = <0xfe382000 0x100>, <0xfe394000 0x100>; 294 + reg-names = "sata", "pcie"; 295 295 }; 296 296 297 297 phy_port1: port@fe38a000 { 298 298 #phy-cells = <1>; 299 - reg = <0xfe38a000 0x100>, <0xfe804000 0x100>, <0x828 0x4>; 300 - reg-names = "sata", "pcie", "syscfg"; 299 + reg = <0xfe38a000 0x100>, <0xfe804000 0x100>; 300 + reg-names = "sata", "pcie"; 301 301 }; 302 302 }; 303 303
+1
arch/arm/configs/multi_v7_defconfig
··· 456 456 CONFIG_TI_PIPE3=y 457 457 CONFIG_PHY_MIPHY365X=y 458 458 CONFIG_PHY_STIH41X_USB=y 459 + CONFIG_PHY_STIH407_USB=y 459 460 CONFIG_PHY_SUN4I_USB=y 460 461 CONFIG_EXT4_FS=y 461 462 CONFIG_AUTOFS4_FS=y
+7 -6
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 122 122 bool ext_phyclk; /* Clock from external PHY */ 123 123 u32 tx_retime_src; /* TXCLK Retiming*/ 124 124 struct clk *clk; /* PHY clock */ 125 - int ctrl_reg; /* GMAC glue-logic control register */ 125 + u32 ctrl_reg; /* GMAC glue-logic control register */ 126 126 int clk_sel_reg; /* GMAC ext clk selection register */ 127 127 struct device *dev; 128 128 struct regmap *regmap; ··· 285 285 if (!np) 286 286 return -EINVAL; 287 287 288 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-ethconf"); 289 - if (!res) 290 - return -ENODATA; 291 - dwmac->ctrl_reg = res->start; 292 - 293 288 /* clk selection from extra syscfg register */ 294 289 dwmac->clk_sel_reg = -ENXIO; 295 290 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf"); ··· 294 299 regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon"); 295 300 if (IS_ERR(regmap)) 296 301 return PTR_ERR(regmap); 302 + 303 + err = of_property_read_u32_index(np, "st,syscon", 1, &dwmac->ctrl_reg); 304 + if (err) { 305 + dev_err(dev, "Can't get sysconfig ctrl offset (%d)\n", err); 306 + return err; 307 + } 297 308 298 309 dwmac->dev = dev; 299 310 dwmac->interface = of_get_phy_mode(np);
+10 -19
drivers/phy/phy-miphy365x.c
··· 141 141 bool pcie_tx_pol_inv; 142 142 bool sata_tx_pol_inv; 143 143 u32 sata_gen; 144 - u64 ctrlreg; 144 + u32 ctrlreg; 145 145 u8 type; 146 146 }; 147 147 ··· 179 179 bool sata = (miphy_phy->type == MIPHY_TYPE_SATA); 180 180 181 181 return regmap_update_bits(miphy_dev->regmap, 182 - (unsigned int)miphy_phy->ctrlreg, 182 + miphy_phy->ctrlreg, 183 183 SYSCFG_SELECT_SATA_MASK, 184 184 sata << SYSCFG_SELECT_SATA_POS); 185 185 } ··· 445 445 { 446 446 struct device_node *phynode = miphy_phy->phy->dev.of_node; 447 447 const char *name; 448 - const __be32 *taddr; 449 448 int type = miphy_phy->type; 450 449 int ret; 451 450 ··· 452 453 if (ret) { 453 454 dev_err(dev, "no reg-names property not found\n"); 454 455 return ret; 455 - } 456 - 457 - if (!strncmp(name, "syscfg", 6)) { 458 - taddr = of_get_address(phynode, index, NULL, NULL); 459 - if (!taddr) { 460 - dev_err(dev, "failed to fetch syscfg address\n"); 461 - return -EINVAL; 462 - } 463 - 464 - miphy_phy->ctrlreg = of_translate_address(phynode, taddr); 465 - if (miphy_phy->ctrlreg == OF_BAD_ADDR) { 466 - dev_err(dev, "failed to translate syscfg address\n"); 467 - return -EINVAL; 468 - } 469 - 470 - return 0; 471 456 } 472 457 473 458 if (!((!strncmp(name, "sata", 4) && type == MIPHY_TYPE_SATA) || ··· 589 606 return ret; 590 607 591 608 phy_set_drvdata(phy, miphy_dev->phys[port]); 609 + 592 610 port++; 611 + /* sysconfig offsets are indexed from 1 */ 612 + ret = of_property_read_u32_index(np, "st,syscfg", port, 613 + &miphy_phy->ctrlreg); 614 + if (ret) { 615 + dev_err(&pdev->dev, "No sysconfig offset found\n"); 616 + return ret; 617 + } 593 618 } 594 619 595 620 provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate);
+14 -11
drivers/phy/phy-stih407-usb.c
··· 22 22 #include <linux/mfd/syscon.h> 23 23 #include <linux/phy/phy.h> 24 24 25 + #define PHYPARAM_REG 1 26 + #define PHYCTRL_REG 2 27 + 25 28 /* Default PHY_SEL and REFCLKSEL configuration */ 26 29 #define STIH407_USB_PICOPHY_CTRL_PORT_CONF 0x6 27 30 #define STIH407_USB_PICOPHY_CTRL_PORT_MASK 0x1f ··· 96 93 struct device_node *np = dev->of_node; 97 94 struct phy_provider *phy_provider; 98 95 struct phy *phy; 99 - struct resource *res; 96 + int ret; 100 97 101 98 phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL); 102 99 if (!phy_dev) ··· 126 123 return PTR_ERR(phy_dev->regmap); 127 124 } 128 125 129 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl"); 130 - if (!res) { 131 - dev_err(dev, "No ctrl reg found\n"); 132 - return -ENXIO; 126 + ret = of_property_read_u32_index(np, "st,syscfg", PHYPARAM_REG, 127 + &phy_dev->param); 128 + if (ret) { 129 + dev_err(dev, "can't get phyparam offset (%d)\n", ret); 130 + return ret; 133 131 } 134 - phy_dev->ctrl = res->start; 135 132 136 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param"); 137 - if (!res) { 138 - dev_err(dev, "No param reg found\n"); 139 - return -ENXIO; 133 + ret = of_property_read_u32_index(np, "st,syscfg", PHYCTRL_REG, 134 + &phy_dev->ctrl); 135 + if (ret) { 136 + dev_err(dev, "can't get phyctrl offset (%d)\n", ret); 137 + return ret; 140 138 } 141 - phy_dev->param = res->start; 142 139 143 140 phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data); 144 141 if (IS_ERR(phy)) {