Message ID | 20221110151748.795767-3-dmitry.baryshkov@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | phy: qcom-qmp-ufs: add symbol clocks support | expand |
On Thu, Nov 10, 2022 at 06:17:46PM +0300, Dmitry Baryshkov wrote: > Register three UFS symbol clocks (ufs_rx_symbol_0_clk_src, > ufs_rx_symbol_1_clk_src ufs_tx_symbol_0_clk_src). Register OF clock > provider to let other devices link these clocks through the DT. > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- I was not CCed on this revision of this series either. > drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 64 +++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c > index 189103d1bd18..78d7daf34667 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c > +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c > @@ -1023,6 +1023,66 @@ static int qmp_ufs_clk_init(struct qmp_ufs *qmp) > return devm_clk_bulk_get(dev, num, qmp->clks); > } > > +static void phy_clk_release_provider(void *res) > +{ > + of_clk_del_provider(res); > +} > + > +#define UFS_SYMBOL_CLOCKS 3 > + > +static int phy_symbols_clk_register(struct qmp_ufs *qmp, struct device_node *np) Since you're adding a new function, please use the common prefix and reordering the terms and dropping the redundant "symbols" should make it more readable: qmp_ufs_register_clocks() > +{ > + struct clk_hw_onecell_data *clk_data; > + struct clk_hw *hw; > + char name[64]; > + int ret; > + > + clk_data = devm_kzalloc(qmp->dev, > + struct_size(clk_data, hws, UFS_SYMBOL_CLOCKS), > + GFP_KERNEL); > + if (!clk_data) > + return -ENOMEM; > + > + clk_data->num = UFS_SYMBOL_CLOCKS; > + > + snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); > + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + > + clk_data->hws[0] = hw; > + > + snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); > + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + > + clk_data->hws[1] = hw; > + > + snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); > + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + > + clk_data->hws[2] = hw; > + > + ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); > + if (ret) > + return ret; > + > + /* > + * Roll a devm action because the clock provider is the child node, but > + * the child node is not actually a device. > + */ I know you just copied this from one of the other drivers, but perhaps rephrase as "can be a child node". You can just drop the second clause (no node *is* a device). > + return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); > +} > + > +static const struct phy_ops qcom_qmp_ufs_ops = { > + .power_on = qmp_ufs_enable, > + .power_off = qmp_ufs_disable, > + .owner = THIS_MODULE, > +}; As I've already pointed out once, the above phy_ops struct hunk does not belong in this patch and is just some left over after you rebased on phy-next that must be removed. > static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) > { > struct platform_device *pdev = to_platform_device(qmp->dev); > @@ -1135,6 +1195,10 @@ static int qmp_ufs_probe(struct platform_device *pdev) > if (ret) > goto err_node_put; > > + ret = phy_symbols_clk_register(qmp, np); > + if (ret) > + goto err_node_put; > + > qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); > if (IS_ERR(qmp->phy)) { > ret = PTR_ERR(qmp->phy); Johan
On 16/11/2022 18:15, Johan Hovold wrote: > On Thu, Nov 10, 2022 at 06:17:46PM +0300, Dmitry Baryshkov wrote: >> Register three UFS symbol clocks (ufs_rx_symbol_0_clk_src, >> ufs_rx_symbol_1_clk_src ufs_tx_symbol_0_clk_src). Register OF clock >> provider to let other devices link these clocks through the DT. >> >> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >> --- > > I was not CCed on this revision of this series either. > >> drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 64 +++++++++++++++++++++++++ >> 1 file changed, 64 insertions(+) >> >> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c >> index 189103d1bd18..78d7daf34667 100644 >> --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c >> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c >> @@ -1023,6 +1023,66 @@ static int qmp_ufs_clk_init(struct qmp_ufs *qmp) >> return devm_clk_bulk_get(dev, num, qmp->clks); >> } >> >> +static void phy_clk_release_provider(void *res) >> +{ >> + of_clk_del_provider(res); >> +} >> + >> +#define UFS_SYMBOL_CLOCKS 3 >> + >> +static int phy_symbols_clk_register(struct qmp_ufs *qmp, struct device_node *np) > > Since you're adding a new function, please use the common prefix and > reordering the terms and dropping the redundant "symbols" should make it > more readable: > > qmp_ufs_register_clocks() > >> +{ >> + struct clk_hw_onecell_data *clk_data; >> + struct clk_hw *hw; >> + char name[64]; >> + int ret; >> + >> + clk_data = devm_kzalloc(qmp->dev, >> + struct_size(clk_data, hws, UFS_SYMBOL_CLOCKS), >> + GFP_KERNEL); >> + if (!clk_data) >> + return -ENOMEM; >> + >> + clk_data->num = UFS_SYMBOL_CLOCKS; >> + >> + snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); >> + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); >> + if (IS_ERR(hw)) >> + return PTR_ERR(hw); >> + >> + clk_data->hws[0] = hw; >> + >> + snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); >> + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); >> + if (IS_ERR(hw)) >> + return PTR_ERR(hw); >> + >> + clk_data->hws[1] = hw; >> + >> + snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); >> + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); >> + if (IS_ERR(hw)) >> + return PTR_ERR(hw); >> + >> + clk_data->hws[2] = hw; >> + >> + ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); >> + if (ret) >> + return ret; >> + >> + /* >> + * Roll a devm action because the clock provider is the child node, but >> + * the child node is not actually a device. >> + */ > > I know you just copied this from one of the other drivers, but perhaps > rephrase as "can be a child node". You can just drop the second clause > (no node *is* a device). Ack, thanks for the suggestion. > >> + return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); >> +} >> + >> +static const struct phy_ops qcom_qmp_ufs_ops = { >> + .power_on = qmp_ufs_enable, >> + .power_off = qmp_ufs_disable, >> + .owner = THIS_MODULE, >> +}; > > As I've already pointed out once, the above phy_ops struct hunk does not > belong in this patch and is just some left over after you rebased on > phy-next that must be removed. Oops. I'll fix this during the next respin. > >> static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) >> { >> struct platform_device *pdev = to_platform_device(qmp->dev); >> @@ -1135,6 +1195,10 @@ static int qmp_ufs_probe(struct platform_device *pdev) >> if (ret) >> goto err_node_put; >> >> + ret = phy_symbols_clk_register(qmp, np); >> + if (ret) >> + goto err_node_put; >> + >> qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); >> if (IS_ERR(qmp->phy)) { >> ret = PTR_ERR(qmp->phy); > > Johan
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c index 189103d1bd18..78d7daf34667 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -1023,6 +1023,66 @@ static int qmp_ufs_clk_init(struct qmp_ufs *qmp) return devm_clk_bulk_get(dev, num, qmp->clks); } +static void phy_clk_release_provider(void *res) +{ + of_clk_del_provider(res); +} + +#define UFS_SYMBOL_CLOCKS 3 + +static int phy_symbols_clk_register(struct qmp_ufs *qmp, struct device_node *np) +{ + struct clk_hw_onecell_data *clk_data; + struct clk_hw *hw; + char name[64]; + int ret; + + clk_data = devm_kzalloc(qmp->dev, + struct_size(clk_data, hws, UFS_SYMBOL_CLOCKS), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = UFS_SYMBOL_CLOCKS; + + snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[0] = hw; + + snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[1] = hw; + + snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[2] = hw; + + ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); + if (ret) + return ret; + + /* + * Roll a devm action because the clock provider is the child node, but + * the child node is not actually a device. + */ + return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); +} + +static const struct phy_ops qcom_qmp_ufs_ops = { + .power_on = qmp_ufs_enable, + .power_off = qmp_ufs_disable, + .owner = THIS_MODULE, +}; + static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) { struct platform_device *pdev = to_platform_device(qmp->dev); @@ -1135,6 +1195,10 @@ static int qmp_ufs_probe(struct platform_device *pdev) if (ret) goto err_node_put; + ret = phy_symbols_clk_register(qmp, np); + if (ret) + goto err_node_put; + qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); if (IS_ERR(qmp->phy)) { ret = PTR_ERR(qmp->phy);
Register three UFS symbol clocks (ufs_rx_symbol_0_clk_src, ufs_rx_symbol_1_clk_src ufs_tx_symbol_0_clk_src). Register OF clock provider to let other devices link these clocks through the DT. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+)