Lines Matching +full:sata +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ST spear1340-miphy driver
12 #include <linux/dma-mapping.h>
17 #include <linux/phy/phy.h>
33 /* PCIE - SATA configuration registers */
76 SATA, enumerator
81 /* phy mode: 0 for SATA 1 for PCIe */
85 /* phy struct pointer */
86 struct phy *phy; member
91 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_sata_init()
94 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_sata_init()
97 /* Switch on sata power domain */ in spear1340_miphy_sata_init()
98 regmap_update_bits(priv->misc, SPEAR1340_PCM_CFG, in spear1340_miphy_sata_init()
101 /* Wait for SATA power domain on */ in spear1340_miphy_sata_init()
104 /* Disable PCIE SATA Controller reset */ in spear1340_miphy_sata_init()
105 regmap_update_bits(priv->misc, SPEAR1340_PERIP1_SW_RST, in spear1340_miphy_sata_init()
107 /* Wait for SATA reset de-assert completion */ in spear1340_miphy_sata_init()
115 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_sata_exit()
117 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_sata_exit()
120 /* Enable PCIE SATA Controller reset */ in spear1340_miphy_sata_exit()
121 regmap_update_bits(priv->misc, SPEAR1340_PERIP1_SW_RST, in spear1340_miphy_sata_exit()
124 /* Wait for SATA power domain off */ in spear1340_miphy_sata_exit()
126 /* Switch off sata power domain */ in spear1340_miphy_sata_exit()
127 regmap_update_bits(priv->misc, SPEAR1340_PCM_CFG, in spear1340_miphy_sata_exit()
129 /* Wait for SATA reset assert completion */ in spear1340_miphy_sata_exit()
137 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_pcie_init()
140 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_pcie_init()
149 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_pcie_exit()
151 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_pcie_exit()
157 static int spear1340_miphy_init(struct phy *phy) in spear1340_miphy_init() argument
159 struct spear1340_miphy_priv *priv = phy_get_drvdata(phy); in spear1340_miphy_init()
162 if (priv->mode == SATA) in spear1340_miphy_init()
164 else if (priv->mode == PCIE) in spear1340_miphy_init()
170 static int spear1340_miphy_exit(struct phy *phy) in spear1340_miphy_exit() argument
172 struct spear1340_miphy_priv *priv = phy_get_drvdata(phy); in spear1340_miphy_exit()
175 if (priv->mode == SATA) in spear1340_miphy_exit()
177 else if (priv->mode == PCIE) in spear1340_miphy_exit()
184 { .compatible = "st,spear1340-miphy" },
201 if (priv->mode == SATA) in spear1340_miphy_suspend()
212 if (priv->mode == SATA) in spear1340_miphy_resume()
222 static struct phy *spear1340_miphy_xlate(struct device *dev, in spear1340_miphy_xlate()
227 if (args->args_count < 1) { in spear1340_miphy_xlate()
229 return ERR_PTR(-ENODEV); in spear1340_miphy_xlate()
232 priv->mode = args->args[0]; in spear1340_miphy_xlate()
234 if (priv->mode != SATA && priv->mode != PCIE) { in spear1340_miphy_xlate()
235 dev_err(dev, "DT did not pass correct phy mode\n"); in spear1340_miphy_xlate()
236 return ERR_PTR(-ENODEV); in spear1340_miphy_xlate()
239 return priv->phy; in spear1340_miphy_xlate()
244 struct device *dev = &pdev->dev; in spear1340_miphy_probe()
250 return -ENOMEM; in spear1340_miphy_probe()
252 priv->misc = in spear1340_miphy_probe()
253 syscon_regmap_lookup_by_phandle(dev->of_node, "misc"); in spear1340_miphy_probe()
254 if (IS_ERR(priv->misc)) { in spear1340_miphy_probe()
256 return PTR_ERR(priv->misc); in spear1340_miphy_probe()
259 priv->phy = devm_phy_create(dev, NULL, &spear1340_miphy_ops); in spear1340_miphy_probe()
260 if (IS_ERR(priv->phy)) { in spear1340_miphy_probe()
261 dev_err(dev, "failed to create SATA PCIe PHY\n"); in spear1340_miphy_probe()
262 return PTR_ERR(priv->phy); in spear1340_miphy_probe()
266 phy_set_drvdata(priv->phy, priv); in spear1340_miphy_probe()
271 dev_err(dev, "failed to register phy provider\n"); in spear1340_miphy_probe()
281 .name = "spear1340-miphy",
289 MODULE_DESCRIPTION("ST SPEAR1340-MIPHY driver");