[PATCH v2 09/14] phy: cadence-torrent: Add PHY lane reset support
From: Yuti Amonkar
Date: Mon Dec 23 2019 - 10:24:27 EST
From: Swapnil Jakhade <sjakhade@xxxxxxxxxxx>
Add reset support for PHY lane group.
Signed-off-by: Swapnil Jakhade <sjakhade@xxxxxxxxxxx>
---
drivers/phy/cadence/phy-cadence-torrent.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index 6c3eaaa..ebc3b68 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -18,6 +18,7 @@
#include <linux/of_device.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
+#include <linux/reset.h>
#define REF_CLK_19_2MHz 19200000
#define REF_CLK_25MHz 25000000
@@ -144,6 +145,7 @@ struct cdns_torrent_phy {
void __iomem *sd_base; /* SD0801 registers base */
u32 num_lanes; /* Number of lanes to use */
u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
+ struct reset_control *phy_rst;
struct device *dev;
struct clk *clk;
unsigned long ref_clk_rate;
@@ -182,9 +184,14 @@ static void cdns_dp_phy_write_field(struct cdns_torrent_phy *cdns_phy,
unsigned char num_bits,
unsigned int val);
+static int cdns_torrent_phy_on(struct phy *phy);
+static int cdns_torrent_phy_off(struct phy *phy);
+
static const struct phy_ops cdns_torrent_phy_ops = {
.init = cdns_torrent_dp_init,
.exit = cdns_torrent_dp_exit,
+ .power_on = cdns_torrent_phy_on,
+ .power_off = cdns_torrent_phy_off,
.owner = THIS_MODULE,
};
@@ -317,6 +324,9 @@ static int cdns_torrent_dp_init(struct phy *phy)
/* take out of reset */
cdns_dp_phy_write_field(cdns_phy, PHY_RESET, 8, 1, 1);
+
+ cdns_torrent_phy_on(phy);
+
ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
if (ret)
return ret;
@@ -945,6 +955,21 @@ static void cdns_dp_phy_write_field(struct cdns_torrent_phy *cdns_phy,
start_bit))));
}
+static int cdns_torrent_phy_on(struct phy *phy)
+{
+ struct cdns_torrent_phy *cdns_phy = phy_get_drvdata(phy);
+
+ /* Take the PHY lane group out of reset */
+ return reset_control_deassert(cdns_phy->phy_rst);
+}
+
+static int cdns_torrent_phy_off(struct phy *phy)
+{
+ struct cdns_torrent_phy *cdns_phy = phy_get_drvdata(phy);
+
+ return reset_control_assert(cdns_phy->phy_rst);
+}
+
static int cdns_torrent_phy_probe(struct platform_device *pdev)
{
struct resource *regs;
@@ -976,6 +1001,8 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
if (IS_ERR(cdns_phy->sd_base))
return PTR_ERR(cdns_phy->sd_base);
+ cdns_phy->phy_rst = devm_reset_control_array_get_exclusive(dev);
+
err = device_property_read_u32(dev, "num_lanes",
&cdns_phy->num_lanes);
if (err)
--
2.7.4