Skip to contentSkip to conversation

phy: qcom-qmp-ufs: provide symbol clocks

PATCH Superseded Dmitry Baryshkov 2 participants 3 messages Oct 28, 2022 – Oct 29, 2022

Subsystems (2)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 phy: qcom-qmp-ufs: provide symbol clocks

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.

---

Changes since v5:
- Rebased on top of phy/next

Changes since v4:
- Rebased, dropping merged clk patches
- Fixed whitespace errors
- Added linebreaks to fit into 100 chars limit

---
 drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 67 +++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +67 -0
index 189103d1bd18..c1c9c6e7949d 100644
@@ -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,13 @@ static int qmp_ufs_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_node_put;
 
+	ret = phy_symbols_clk_register(qmp, np);
+	if (ret) {
+		dev_err(dev, "failed to create symbol clocks, %d\n",
+			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);
Signature · 7 lines
2.35.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#1 lore raw
Quoted 76 lines · Dmitry Baryshkov

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.

---

Changes since v5:
- Rebased on top of phy/next

Changes since v4:
- Rebased, dropping merged clk patches
- Fixed whitespace errors
- Added linebreaks to fit into 100 chars limit

---
 drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 67 +++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +49 -0
index 189103d1bd18..c1c9c6e7949d 100644
@@ -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

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_clk_init(struct qmp_ufs *qmp) · line 1084

Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +10 -0
+	 * 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,
+};

This phy_ops addition looks an artefact of the rebase and should not be here.

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1198

Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +1 -0
 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,13 @@ static int qmp_ufs_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_node_put;
 
+	ret = phy_symbols_clk_register(qmp, np);

Looks like this should go in probe() instead, or was there a reason for not registering these clocks when using the new bindings?

And don't they need to be described in both the old and new bindings first either way?

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1201

Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +3 -0
+	if (ret) {
+		dev_err(dev, "failed to create symbol clocks, %d\n",
+			ret);

Please use the "...: %d\n" form for consistency.

But you can probably just drop this error message instead.

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1207

Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +3 -0
+		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

#2 lore raw
Quoted 14 lines · Johan Hovold
Quoted 13 lines · Dmitry Baryshkov

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.

static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) {

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +0 -0
 	struct platform_device *pdev = to_platform_device(qmp->dev);
@@ -1135,6 +1195,13 @@ static int qmp_ufs_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_node_put;
 
Quoted 4 lines

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1198

Quoted 1 line
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +1 -0
+	ret = phy_symbols_clk_register(qmp, np);

Looks like this should go in probe() instead, or was there a reason for not registering these clocks when using the new bindings?

Oops, misread the diff. Please ignore this bit.

Quoted 2 lines

And don't they need to be described in both the old and new bindings first either way?

This still applies though (i.e. you need to add #clock-cells to the bindings).

Quoted 6 lines

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1201

Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +3 -0
+	if (ret) {
+		dev_err(dev, "failed to create symbol clocks, %d\n",
+			ret);

Please use the "...: %d\n" form for consistency.

Quoted 8 lines

But you can probably just drop this error message instead.

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c static int qmp_ufs_probe(struct platform_device *pdev) · line 1207

Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +3 -0
+		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

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy