Lines Matching +full:sata +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0-only
3 * ST spear1340-miphy driver
12 #include <linux/dma-mapping.h>
23 #define SPEAR1340_PCM_CFG 0x100
25 #define SPEAR1340_PCM_WKUP_CFG 0x104
26 #define SPEAR1340_SWITCH_CTR 0x108
28 #define SPEAR1340_PERIP1_SW_RST 0x318
30 #define SPEAR1340_PERIP2_SW_RST 0x31C
31 #define SPEAR1340_PERIP3_SW_RST 0x320
33 /* PCIE - SATA configuration registers */
34 #define SPEAR1340_PCIE_SATA_CFG 0x424
44 #define SPEAR1340_PCIE_SATA_SEL_PCIE (0)
46 #define SPEAR1340_PCIE_SATA_CFG_MASK 0xF1F
58 #define SPEAR1340_PCIE_MIPHY_CFG 0x428
63 #define SPEAR1340_MIPHY_PLL_RATIO_TOP(x) (x << 0)
64 #define SPEAR1340_PCIE_MIPHY_CFG_MASK 0xF80000FF
76 SATA, enumerator
81 /* phy mode: 0 for SATA 1 for PCIe */
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()
106 SPEAR1340_PERIP1_SW_RSATA, 0); in spear1340_miphy_sata_init()
107 /* Wait for SATA reset de-assert completion */ in spear1340_miphy_sata_init()
110 return 0; in spear1340_miphy_sata_init()
115 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_sata_exit()
116 SPEAR1340_PCIE_SATA_CFG_MASK, 0); in spear1340_miphy_sata_exit()
117 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_sata_exit()
118 SPEAR1340_PCIE_MIPHY_CFG_MASK, 0); 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()
128 SPEAR1340_PCM_CFG_SATA_POWER_EN, 0); in spear1340_miphy_sata_exit()
129 /* Wait for SATA reset assert completion */ in spear1340_miphy_sata_exit()
132 return 0; 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()
144 return 0; in spear1340_miphy_pcie_init()
149 regmap_update_bits(priv->misc, SPEAR1340_PCIE_MIPHY_CFG, in spear1340_miphy_pcie_exit()
150 SPEAR1340_PCIE_MIPHY_CFG_MASK, 0); in spear1340_miphy_pcie_exit()
151 regmap_update_bits(priv->misc, SPEAR1340_PCIE_SATA_CFG, in spear1340_miphy_pcie_exit()
152 SPEAR1340_PCIE_SATA_CFG_MASK, 0); in spear1340_miphy_pcie_exit()
154 return 0; in spear1340_miphy_pcie_exit()
160 int ret = 0; in spear1340_miphy_init()
162 if (priv->mode == SATA) in spear1340_miphy_init()
164 else if (priv->mode == PCIE) in spear1340_miphy_init()
173 int ret = 0; 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" },
199 int ret = 0; in spear1340_miphy_suspend()
201 if (priv->mode == SATA) in spear1340_miphy_suspend()
210 int ret = 0; in spear1340_miphy_resume()
212 if (priv->mode == SATA) in spear1340_miphy_resume()
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()
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()
275 return 0; in spear1340_miphy_probe()
281 .name = "spear1340-miphy",
289 MODULE_DESCRIPTION("ST SPEAR1340-MIPHY driver");