video: rockchip: fb: delete DISPLAY_POLICY_BOX_TEMP
[firefly-linux-kernel-4.4.55.git] / drivers / phy / phy-miphy365x.c
index 801afaf2d449655bcc6acc45dac5d8655a850008..98bffbc0f74dad1c4b6cf4892d92c3424dfadaad 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 
-#include <dt-bindings/phy/phy-miphy365x.h>
+#include <dt-bindings/phy/phy.h>
 
 #define HFC_TIMEOUT            100
 
@@ -141,7 +141,7 @@ struct miphy365x_phy {
        bool pcie_tx_pol_inv;
        bool sata_tx_pol_inv;
        u32 sata_gen;
-       u64 ctrlreg;
+       u32 ctrlreg;
        u8 type;
 };
 
@@ -176,10 +176,10 @@ static u8 rx_tx_spd[] = {
 static int miphy365x_set_path(struct miphy365x_phy *miphy_phy,
                              struct miphy365x_dev *miphy_dev)
 {
-       bool sata = (miphy_phy->type == MIPHY_TYPE_SATA);
+       bool sata = (miphy_phy->type == PHY_TYPE_SATA);
 
        return regmap_update_bits(miphy_dev->regmap,
-                                 (unsigned int)miphy_phy->ctrlreg,
+                                 miphy_phy->ctrlreg,
                                  SYSCFG_SELECT_SATA_MASK,
                                  sata << SYSCFG_SELECT_SATA_POS);
 }
@@ -430,7 +430,7 @@ static int miphy365x_init(struct phy *phy)
        }
 
        /* Initialise Miphy for PCIe or SATA */
-       if (miphy_phy->type == MIPHY_TYPE_PCIE)
+       if (miphy_phy->type == PHY_TYPE_PCIE)
                ret = miphy365x_init_pcie_port(miphy_phy, miphy_dev);
        else
                ret = miphy365x_init_sata_port(miphy_phy, miphy_dev);
@@ -445,7 +445,6 @@ int miphy365x_get_addr(struct device *dev, struct miphy365x_phy *miphy_phy,
 {
        struct device_node *phynode = miphy_phy->phy->dev.of_node;
        const char *name;
-       const __be32 *taddr;
        int type = miphy_phy->type;
        int ret;
 
@@ -455,24 +454,8 @@ int miphy365x_get_addr(struct device *dev, struct miphy365x_phy *miphy_phy,
                return ret;
        }
 
-       if (!strncmp(name, "syscfg", 6)) {
-               taddr = of_get_address(phynode, index, NULL, NULL);
-               if (!taddr) {
-                       dev_err(dev, "failed to fetch syscfg address\n");
-                       return -EINVAL;
-               }
-
-               miphy_phy->ctrlreg = of_translate_address(phynode, taddr);
-               if (miphy_phy->ctrlreg == OF_BAD_ADDR) {
-                       dev_err(dev, "failed to translate syscfg address\n");
-                       return -EINVAL;
-               }
-
-               return 0;
-       }
-
-       if (!((!strncmp(name, "sata", 4) && type == MIPHY_TYPE_SATA) ||
-             (!strncmp(name, "pcie", 4) && type == MIPHY_TYPE_PCIE)))
+       if (!((!strncmp(name, "sata", 4) && type == PHY_TYPE_SATA) ||
+             (!strncmp(name, "pcie", 4) && type == PHY_TYPE_PCIE)))
                return 0;
 
        miphy_phy->base = of_iomap(phynode, index);
@@ -515,8 +498,8 @@ static struct phy *miphy365x_xlate(struct device *dev,
 
        miphy_phy->type = args->args[0];
 
-       if (!(miphy_phy->type == MIPHY_TYPE_SATA ||
-             miphy_phy->type == MIPHY_TYPE_PCIE)) {
+       if (!(miphy_phy->type == PHY_TYPE_SATA ||
+             miphy_phy->type == PHY_TYPE_PCIE)) {
                dev_err(dev, "Unsupported device type: %d\n", miphy_phy->type);
                return ERR_PTR(-EINVAL);
        }
@@ -593,7 +576,7 @@ static int miphy365x_probe(struct platform_device *pdev)
 
                miphy_dev->phys[port] = miphy_phy;
 
-               phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops, NULL);
+               phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops);
                if (IS_ERR(phy)) {
                        dev_err(&pdev->dev, "failed to create PHY\n");
                        return PTR_ERR(phy);
@@ -606,14 +589,19 @@ static int miphy365x_probe(struct platform_device *pdev)
                        return ret;
 
                phy_set_drvdata(phy, miphy_dev->phys[port]);
+
                port++;
+               /* sysconfig offsets are indexed from 1 */
+               ret = of_property_read_u32_index(np, "st,syscfg", port,
+                                       &miphy_phy->ctrlreg);
+               if (ret) {
+                       dev_err(&pdev->dev, "No sysconfig offset found\n");
+                       return ret;
+               }
        }
 
        provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate);
-       if (IS_ERR(provider))
-               return PTR_ERR(provider);
-
-       return 0;
+       return PTR_ERR_OR_ZERO(provider);
 }
 
 static const struct of_device_id miphy365x_of_match[] = {