Commit aef096db authored by Swapnil Jakhade's avatar Swapnil Jakhade Committed by Vinod Koul

phy: cadence-torrent: Migrate to clk_hw based registration and OF APIs

Use clk_hw based provider APIs to register clks to remove the usage of
deprecated APIs.
Signed-off-by: default avatarSwapnil Jakhade <sjakhade@cadence.com>
Link: https://lore.kernel.org/r/20210922123735.21927-2-sjakhade@cadence.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 8d55027f
...@@ -235,6 +235,8 @@ ...@@ -235,6 +235,8 @@
#define PHY_PMA_CMN_CTRL2 0x0001U #define PHY_PMA_CMN_CTRL2 0x0001U
#define PHY_PMA_PLL_RAW_CTRL 0x0003U #define PHY_PMA_PLL_RAW_CTRL 0x0003U
#define CDNS_TORRENT_OUTPUT_CLOCKS 1
static const char * const clk_names[] = { static const char * const clk_names[] = {
[CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver", [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
}; };
...@@ -333,8 +335,7 @@ struct cdns_torrent_phy { ...@@ -333,8 +335,7 @@ struct cdns_torrent_phy {
struct regmap_field *phy_pma_pll_raw_ctrl; struct regmap_field *phy_pma_pll_raw_ctrl;
struct regmap_field *phy_reset_ctrl; struct regmap_field *phy_reset_ctrl;
struct regmap_field *phy_pcs_iso_link_ctrl_1[MAX_NUM_LANES]; struct regmap_field *phy_pcs_iso_link_ctrl_1[MAX_NUM_LANES];
struct clk *clks[CDNS_TORRENT_REFCLK_DRIVER + 1]; struct clk_hw_onecell_data *clk_hw_data;
struct clk_onecell_data clk_data;
}; };
enum phy_powerstate { enum phy_powerstate {
...@@ -1659,8 +1660,9 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph ...@@ -1659,8 +1660,9 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph
const char *parent_name; const char *parent_name;
struct regmap *regmap; struct regmap *regmap;
char clk_name[100]; char clk_name[100];
struct clk_hw *hw;
struct clk *clk; struct clk *clk;
int i; int i, ret;
derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL); derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
if (!derived_refclk) if (!derived_refclk)
...@@ -1706,11 +1708,12 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph ...@@ -1706,11 +1708,12 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph
derived_refclk->hw.init = init; derived_refclk->hw.init = init;
clk = devm_clk_register(dev, &derived_refclk->hw); hw = &derived_refclk->hw;
if (IS_ERR(clk)) ret = devm_clk_hw_register(dev, hw);
return PTR_ERR(clk); if (ret)
return ret;
cdns_phy->clks[CDNS_TORRENT_REFCLK_DRIVER] = clk; cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw;
return 0; return 0;
} }
...@@ -2188,18 +2191,23 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) ...@@ -2188,18 +2191,23 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy)
{ {
struct device *dev = cdns_phy->dev; struct device *dev = cdns_phy->dev;
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
struct clk_hw_onecell_data *data;
int ret; int ret;
data = devm_kzalloc(dev, struct_size(data, hws, CDNS_TORRENT_OUTPUT_CLOCKS), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->num = CDNS_TORRENT_OUTPUT_CLOCKS;
cdns_phy->clk_hw_data = data;
ret = cdns_torrent_derived_refclk_register(cdns_phy); ret = cdns_torrent_derived_refclk_register(cdns_phy);
if (ret) { if (ret) {
dev_err(dev, "failed to register derived refclk\n"); dev_err(dev, "failed to register derived refclk\n");
return ret; return ret;
} }
cdns_phy->clk_data.clks = cdns_phy->clks; ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
cdns_phy->clk_data.clk_num = CDNS_TORRENT_REFCLK_DRIVER + 1;
ret = of_clk_add_provider(node, of_clk_src_onecell_get, &cdns_phy->clk_data);
if (ret) { if (ret) {
dev_err(dev, "Failed to add clock provider: %s\n", node->name); dev_err(dev, "Failed to add clock provider: %s\n", node->name);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment