* [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration
@ 2021-03-10 15:54 Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 1/4] phy: ti: j721e-wiz: Do not configure wiz if its already configured Kishon Vijay Abraham I
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-10 15:54 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel,
Swapnil Jakhade
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
Add support to skip SERDES configuration if it's already configured in
bootloader.
The wiz part was initially sent in [1] but that was sent more in the
context of Sierra but this is in context of Torrent. The Sierra part
would be sent later.
[1] -> http://lore.kernel.org/r/20201103035556.21260-1-kishon@ti.com
Faiz Abbas (1):
phy: ti: j721e-wiz: Do not configure wiz if its already configured
Kishon Vijay Abraham I (3):
phy: cadence-torrent: Group reset APIs and clock APIs
phy: cadence-torrent: Do not configure SERDES if it's already
configured
phy: cadence-torrent: Explicitly request exclusive reset control
drivers/phy/cadence/phy-cadence-torrent.c | 106 ++++++++++++++--------
drivers/phy/ti/phy-j721e-wiz.c | 21 ++++-
2 files changed, 86 insertions(+), 41 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] phy: ti: j721e-wiz: Do not configure wiz if its already configured
2021-03-10 15:54 [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration Kishon Vijay Abraham I
@ 2021-03-10 15:54 ` Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs Kishon Vijay Abraham I
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-10 15:54 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel,
Swapnil Jakhade
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy, Faiz Abbas
From: Faiz Abbas <faiz_abbas@ti.com>
Serdes lanes might be shared between multiple cores in some usecases
and its not possible to lock PLLs for both the lanes independently
by the two cores. This requires a bootloader to configure both the
lanes at early boot time.
To handle this case, skip all configuration if any of the lanes has
already been enabled.
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/ti/phy-j721e-wiz.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c
index 659597645201..95905e5c4f3d 100644
--- a/drivers/phy/ti/phy-j721e-wiz.c
+++ b/drivers/phy/ti/phy-j721e-wiz.c
@@ -1132,13 +1132,14 @@ static int wiz_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct platform_device *serdes_pdev;
+ bool already_configured = false;
struct device_node *child_node;
struct regmap *regmap;
struct resource res;
void __iomem *base;
struct wiz *wiz;
+ int ret, val, i;
u32 num_lanes;
- int ret;
wiz = devm_kzalloc(dev, sizeof(*wiz), GFP_KERNEL);
if (!wiz)
@@ -1266,10 +1267,20 @@ static int wiz_probe(struct platform_device *pdev)
goto err_get_sync;
}
- ret = wiz_init(wiz);
- if (ret) {
- dev_err(dev, "WIZ initialization failed\n");
- goto err_wiz_init;
+ for (i = 0; i < wiz->num_lanes; i++) {
+ regmap_field_read(wiz->p_enable[i], &val);
+ if (val & (P_ENABLE | P_ENABLE_FORCE)) {
+ already_configured = true;
+ break;
+ }
+ }
+
+ if (!already_configured) {
+ ret = wiz_init(wiz);
+ if (ret) {
+ dev_err(dev, "WIZ initialization failed\n");
+ goto err_wiz_init;
+ }
}
serdes_pdev = of_platform_device_create(child_node, NULL, dev);
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs
2021-03-10 15:54 [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 1/4] phy: ti: j721e-wiz: Do not configure wiz if its already configured Kishon Vijay Abraham I
@ 2021-03-10 15:54 ` Kishon Vijay Abraham I
2021-03-18 9:56 ` Swapnil Kashinath Jakhade
2021-03-10 15:54 ` [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control Kishon Vijay Abraham I
3 siblings, 1 reply; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-10 15:54 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel,
Swapnil Jakhade
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
No functional change intended. Group reset APIs and clock APIs in
preparation for adding support to skip configuration if the SERDES
is already configured by bootloader.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/cadence/phy-cadence-torrent.c | 84 ++++++++++++++---------
1 file changed, 53 insertions(+), 31 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index 3fdab0d288c4..ab51c4bf7b30 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -2249,6 +2249,54 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy)
return 0;
}
+static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy)
+{
+ struct device *dev = cdns_phy->dev;
+
+ cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
+ if (IS_ERR(cdns_phy->phy_rst)) {
+ dev_err(dev, "%s: failed to get reset\n",
+ dev->of_node->full_name);
+ return PTR_ERR(cdns_phy->phy_rst);
+ }
+
+ cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb");
+ if (IS_ERR(cdns_phy->apb_rst)) {
+ dev_err(dev, "%s: failed to get apb reset\n",
+ dev->of_node->full_name);
+ return PTR_ERR(cdns_phy->apb_rst);
+ }
+
+ return 0;
+}
+
+static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy)
+{
+ struct device *dev = cdns_phy->dev;
+ int ret;
+
+ cdns_phy->clk = devm_clk_get(dev, "refclk");
+ if (IS_ERR(cdns_phy->clk)) {
+ dev_err(dev, "phy ref clock not found\n");
+ return PTR_ERR(cdns_phy->clk);
+ }
+
+ ret = clk_prepare_enable(cdns_phy->clk);
+ if (ret) {
+ dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
+ return ret;
+ }
+
+ cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
+ if (!(cdns_phy->ref_clk_rate)) {
+ dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
+ clk_disable_unprepare(cdns_phy->clk);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int cdns_torrent_phy_probe(struct platform_device *pdev)
{
struct cdns_torrent_phy *cdns_phy;
@@ -2274,26 +2322,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
cdns_phy->dev = dev;
cdns_phy->init_data = data;
- cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
- if (IS_ERR(cdns_phy->phy_rst)) {
- dev_err(dev, "%s: failed to get reset\n",
- dev->of_node->full_name);
- return PTR_ERR(cdns_phy->phy_rst);
- }
-
- cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb");
- if (IS_ERR(cdns_phy->apb_rst)) {
- dev_err(dev, "%s: failed to get apb reset\n",
- dev->of_node->full_name);
- return PTR_ERR(cdns_phy->apb_rst);
- }
-
- cdns_phy->clk = devm_clk_get(dev, "refclk");
- if (IS_ERR(cdns_phy->clk)) {
- dev_err(dev, "phy ref clock not found\n");
- return PTR_ERR(cdns_phy->clk);
- }
-
cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(cdns_phy->sd_base))
return PTR_ERR(cdns_phy->sd_base);
@@ -2316,18 +2344,13 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = clk_prepare_enable(cdns_phy->clk);
- if (ret) {
- dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
+ ret = cdns_torrent_reset(cdns_phy);
+ if (ret)
goto clk_cleanup;
- }
- cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
- if (!(cdns_phy->ref_clk_rate)) {
- dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
- ret = -EINVAL;
- goto clk_disable;
- }
+ ret = cdns_torrent_clk(cdns_phy);
+ if (ret)
+ goto clk_cleanup;
/* Enable APB */
reset_control_deassert(cdns_phy->apb_rst);
@@ -2505,7 +2528,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
reset_control_put(cdns_phy->phys[i].lnk_rst);
of_node_put(child);
reset_control_assert(cdns_phy->apb_rst);
-clk_disable:
clk_disable_unprepare(cdns_phy->clk);
clk_cleanup:
cdns_torrent_clk_cleanup(cdns_phy);
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured
2021-03-10 15:54 [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 1/4] phy: ti: j721e-wiz: Do not configure wiz if its already configured Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs Kishon Vijay Abraham I
@ 2021-03-10 15:54 ` Kishon Vijay Abraham I
2021-03-18 9:55 ` Swapnil Kashinath Jakhade
2021-03-10 15:54 ` [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control Kishon Vijay Abraham I
3 siblings, 1 reply; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-10 15:54 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel,
Swapnil Jakhade
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
Do not configure torrent SERDES if it's already configured.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/cadence/phy-cadence-torrent.c | 32 ++++++++++++++++-------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index ab51c4bf7b30..5ee1657f5a1c 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -371,6 +371,10 @@ static const struct phy_ops cdns_torrent_phy_ops = {
.owner = THIS_MODULE,
};
+static const struct phy_ops noop_ops = {
+ .owner = THIS_MODULE,
+};
+
struct cdns_reg_pairs {
u32 val;
u32 off;
@@ -2306,6 +2310,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
struct device_node *child;
int ret, subnodes, node = 0, i;
u32 total_num_lanes = 0;
+ int already_configured;
u8 init_dp_regmap = 0;
u32 phy_type;
@@ -2344,16 +2349,20 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = cdns_torrent_reset(cdns_phy);
- if (ret)
- goto clk_cleanup;
+ regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured);
- ret = cdns_torrent_clk(cdns_phy);
- if (ret)
- goto clk_cleanup;
+ if (!already_configured) {
+ ret = cdns_torrent_reset(cdns_phy);
+ if (ret)
+ goto clk_cleanup;
+
+ ret = cdns_torrent_clk(cdns_phy);
+ if (ret)
+ goto clk_cleanup;
- /* Enable APB */
- reset_control_deassert(cdns_phy->apb_rst);
+ /* Enable APB */
+ reset_control_deassert(cdns_phy->apb_rst);
+ }
for_each_available_child_of_node(dev->of_node, child) {
struct phy *gphy;
@@ -2423,7 +2432,10 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
of_property_read_u32(child, "cdns,ssc-mode",
&cdns_phy->phys[node].ssc_mode);
- gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
+ if (!already_configured)
+ gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
+ else
+ gphy = devm_phy_create(dev, child, &noop_ops);
if (IS_ERR(gphy)) {
ret = PTR_ERR(gphy);
goto put_child;
@@ -2507,7 +2519,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
goto put_lnk_rst;
}
- if (cdns_phy->nsubnodes > 1) {
+ if (cdns_phy->nsubnodes > 1 && !already_configured) {
ret = cdns_torrent_phy_configure_multilink(cdns_phy);
if (ret)
goto put_lnk_rst;
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control
2021-03-10 15:54 [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration Kishon Vijay Abraham I
` (2 preceding siblings ...)
2021-03-10 15:54 ` [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured Kishon Vijay Abraham I
@ 2021-03-10 15:54 ` Kishon Vijay Abraham I
2021-03-18 9:58 ` Swapnil Kashinath Jakhade
3 siblings, 1 reply; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-10 15:54 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel,
Swapnil Jakhade
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
No functional change. Since the reset controls obtained in
Torrent is exclusively used by the Torrent device, use
exclusive reset control request API calls.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/cadence/phy-cadence-torrent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index 5ee1657f5a1c..ff8bb4b724c0 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -2264,7 +2264,7 @@ static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy)
return PTR_ERR(cdns_phy->phy_rst);
}
- cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb");
+ cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb");
if (IS_ERR(cdns_phy->apb_rst)) {
dev_err(dev, "%s: failed to get apb reset\n",
dev->of_node->full_name);
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured
2021-03-10 15:54 ` [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured Kishon Vijay Abraham I
@ 2021-03-18 9:55 ` Swapnil Kashinath Jakhade
2021-03-30 9:57 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 9+ messages in thread
From: Swapnil Kashinath Jakhade @ 2021-03-18 9:55 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
> -----Original Message-----
> From: Kishon Vijay Abraham I <kishon@ti.com>
> Sent: Wednesday, March 10, 2021 9:25 PM
> To: Kishon Vijay Abraham I <kishon@ti.com>; Vinod Koul
> <vkoul@kernel.org>; Rob Herring <robh+dt@kernel.org>; Philipp Zabel
> <p.zabel@pengutronix.de>; Swapnil Kashinath Jakhade
> <sjakhade@cadence.com>
> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; Lokesh Vutla
> <lokeshvutla@ti.com>; linux-phy@lists.infradead.org
> Subject: [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's
> already configured
>
> EXTERNAL MAIL
>
>
> Do not configure torrent SERDES if it's already configured.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> drivers/phy/cadence/phy-cadence-torrent.c | 32 ++++++++++++++++-------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c
> b/drivers/phy/cadence/phy-cadence-torrent.c
> index ab51c4bf7b30..5ee1657f5a1c 100644
> --- a/drivers/phy/cadence/phy-cadence-torrent.c
> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
> @@ -371,6 +371,10 @@ static const struct phy_ops cdns_torrent_phy_ops =
> {
> .owner = THIS_MODULE,
> };
>
> +static const struct phy_ops noop_ops = {
> + .owner = THIS_MODULE,
> +};
> +
> struct cdns_reg_pairs {
> u32 val;
> u32 off;
> @@ -2306,6 +2310,7 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> struct device_node *child;
> int ret, subnodes, node = 0, i;
> u32 total_num_lanes = 0;
> + int already_configured;
> u8 init_dp_regmap = 0;
> u32 phy_type;
>
> @@ -2344,16 +2349,20 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> if (ret)
> return ret;
>
> - ret = cdns_torrent_reset(cdns_phy);
> - if (ret)
> - goto clk_cleanup;
> + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1,
> &already_configured);
>
> - ret = cdns_torrent_clk(cdns_phy);
> - if (ret)
> - goto clk_cleanup;
> + if (!already_configured) {
> + ret = cdns_torrent_reset(cdns_phy);
> + if (ret)
> + goto clk_cleanup;
> +
> + ret = cdns_torrent_clk(cdns_phy);
> + if (ret)
> + goto clk_cleanup;
>
Should if (!already_configured) be checked while calling clk_disable_unprepare()?
Otherwise,
Reviewed-by: Swapnil Jakhade <sjakhade@cadence.com>
Thanks & regards,
Swapnil
> - /* Enable APB */
> - reset_control_deassert(cdns_phy->apb_rst);
> + /* Enable APB */
> + reset_control_deassert(cdns_phy->apb_rst);
> + }
>
> for_each_available_child_of_node(dev->of_node, child) {
> struct phy *gphy;
> @@ -2423,7 +2432,10 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> of_property_read_u32(child, "cdns,ssc-mode",
> &cdns_phy->phys[node].ssc_mode);
>
> - gphy = devm_phy_create(dev, child,
> &cdns_torrent_phy_ops);
> + if (!already_configured)
> + gphy = devm_phy_create(dev, child,
> &cdns_torrent_phy_ops);
> + else
> + gphy = devm_phy_create(dev, child, &noop_ops);
> if (IS_ERR(gphy)) {
> ret = PTR_ERR(gphy);
> goto put_child;
> @@ -2507,7 +2519,7 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> goto put_lnk_rst;
> }
>
> - if (cdns_phy->nsubnodes > 1) {
> + if (cdns_phy->nsubnodes > 1 && !already_configured) {
> ret = cdns_torrent_phy_configure_multilink(cdns_phy);
> if (ret)
> goto put_lnk_rst;
> --
> 2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs
2021-03-10 15:54 ` [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs Kishon Vijay Abraham I
@ 2021-03-18 9:56 ` Swapnil Kashinath Jakhade
0 siblings, 0 replies; 9+ messages in thread
From: Swapnil Kashinath Jakhade @ 2021-03-18 9:56 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
> -----Original Message-----
> From: Kishon Vijay Abraham I <kishon@ti.com>
> Sent: Wednesday, March 10, 2021 9:25 PM
> To: Kishon Vijay Abraham I <kishon@ti.com>; Vinod Koul
> <vkoul@kernel.org>; Rob Herring <robh+dt@kernel.org>; Philipp Zabel
> <p.zabel@pengutronix.de>; Swapnil Kashinath Jakhade
> <sjakhade@cadence.com>
> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; Lokesh Vutla
> <lokeshvutla@ti.com>; linux-phy@lists.infradead.org
> Subject: [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs
>
> EXTERNAL MAIL
>
>
> No functional change intended. Group reset APIs and clock APIs in
> preparation for adding support to skip configuration if the SERDES
> is already configured by bootloader.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> drivers/phy/cadence/phy-cadence-torrent.c | 84 ++++++++++++++---------
> 1 file changed, 53 insertions(+), 31 deletions(-)
>
Reviewed-by: Swapnil Jakhade <sjakhade@cadence.com>
Thanks & regards,
Swapnil
> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c
> b/drivers/phy/cadence/phy-cadence-torrent.c
> index 3fdab0d288c4..ab51c4bf7b30 100644
> --- a/drivers/phy/cadence/phy-cadence-torrent.c
> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
> @@ -2249,6 +2249,54 @@ static int cdns_torrent_clk_register(struct
> cdns_torrent_phy *cdns_phy)
> return 0;
> }
>
> +static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy)
> +{
> + struct device *dev = cdns_phy->dev;
> +
> + cdns_phy->phy_rst =
> devm_reset_control_get_exclusive_by_index(dev, 0);
> + if (IS_ERR(cdns_phy->phy_rst)) {
> + dev_err(dev, "%s: failed to get reset\n",
> + dev->of_node->full_name);
> + return PTR_ERR(cdns_phy->phy_rst);
> + }
> +
> + cdns_phy->apb_rst = devm_reset_control_get_optional(dev,
> "torrent_apb");
> + if (IS_ERR(cdns_phy->apb_rst)) {
> + dev_err(dev, "%s: failed to get apb reset\n",
> + dev->of_node->full_name);
> + return PTR_ERR(cdns_phy->apb_rst);
> + }
> +
> + return 0;
> +}
> +
> +static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy)
> +{
> + struct device *dev = cdns_phy->dev;
> + int ret;
> +
> + cdns_phy->clk = devm_clk_get(dev, "refclk");
> + if (IS_ERR(cdns_phy->clk)) {
> + dev_err(dev, "phy ref clock not found\n");
> + return PTR_ERR(cdns_phy->clk);
> + }
> +
> + ret = clk_prepare_enable(cdns_phy->clk);
> + if (ret) {
> + dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
> + return ret;
> + }
> +
> + cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
> + if (!(cdns_phy->ref_clk_rate)) {
> + dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
> + clk_disable_unprepare(cdns_phy->clk);
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> static int cdns_torrent_phy_probe(struct platform_device *pdev)
> {
> struct cdns_torrent_phy *cdns_phy;
> @@ -2274,26 +2322,6 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> cdns_phy->dev = dev;
> cdns_phy->init_data = data;
>
> - cdns_phy->phy_rst =
> devm_reset_control_get_exclusive_by_index(dev, 0);
> - if (IS_ERR(cdns_phy->phy_rst)) {
> - dev_err(dev, "%s: failed to get reset\n",
> - dev->of_node->full_name);
> - return PTR_ERR(cdns_phy->phy_rst);
> - }
> -
> - cdns_phy->apb_rst = devm_reset_control_get_optional(dev,
> "torrent_apb");
> - if (IS_ERR(cdns_phy->apb_rst)) {
> - dev_err(dev, "%s: failed to get apb reset\n",
> - dev->of_node->full_name);
> - return PTR_ERR(cdns_phy->apb_rst);
> - }
> -
> - cdns_phy->clk = devm_clk_get(dev, "refclk");
> - if (IS_ERR(cdns_phy->clk)) {
> - dev_err(dev, "phy ref clock not found\n");
> - return PTR_ERR(cdns_phy->clk);
> - }
> -
> cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(cdns_phy->sd_base))
> return PTR_ERR(cdns_phy->sd_base);
> @@ -2316,18 +2344,13 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> if (ret)
> return ret;
>
> - ret = clk_prepare_enable(cdns_phy->clk);
> - if (ret) {
> - dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
> + ret = cdns_torrent_reset(cdns_phy);
> + if (ret)
> goto clk_cleanup;
> - }
>
> - cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
> - if (!(cdns_phy->ref_clk_rate)) {
> - dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
> - ret = -EINVAL;
> - goto clk_disable;
> - }
> + ret = cdns_torrent_clk(cdns_phy);
> + if (ret)
> + goto clk_cleanup;
>
> /* Enable APB */
> reset_control_deassert(cdns_phy->apb_rst);
> @@ -2505,7 +2528,6 @@ static int cdns_torrent_phy_probe(struct
> platform_device *pdev)
> reset_control_put(cdns_phy->phys[i].lnk_rst);
> of_node_put(child);
> reset_control_assert(cdns_phy->apb_rst);
> -clk_disable:
> clk_disable_unprepare(cdns_phy->clk);
> clk_cleanup:
> cdns_torrent_clk_cleanup(cdns_phy);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control
2021-03-10 15:54 ` [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control Kishon Vijay Abraham I
@ 2021-03-18 9:58 ` Swapnil Kashinath Jakhade
0 siblings, 0 replies; 9+ messages in thread
From: Swapnil Kashinath Jakhade @ 2021-03-18 9:58 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring, Philipp Zabel
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
> -----Original Message-----
> From: Kishon Vijay Abraham I <kishon@ti.com>
> Sent: Wednesday, March 10, 2021 9:25 PM
> To: Kishon Vijay Abraham I <kishon@ti.com>; Vinod Koul
> <vkoul@kernel.org>; Rob Herring <robh+dt@kernel.org>; Philipp Zabel
> <p.zabel@pengutronix.de>; Swapnil Kashinath Jakhade
> <sjakhade@cadence.com>
> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; Lokesh Vutla
> <lokeshvutla@ti.com>; linux-phy@lists.infradead.org
> Subject: [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset
> control
>
> EXTERNAL MAIL
>
>
> No functional change. Since the reset controls obtained in
> Torrent is exclusively used by the Torrent device, use
> exclusive reset control request API calls.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> drivers/phy/cadence/phy-cadence-torrent.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Swapnil Jakhade <sjakhade@cadence.com>
Thanks & regards,
Swapnil
> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c
> b/drivers/phy/cadence/phy-cadence-torrent.c
> index 5ee1657f5a1c..ff8bb4b724c0 100644
> --- a/drivers/phy/cadence/phy-cadence-torrent.c
> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
> @@ -2264,7 +2264,7 @@ static int cdns_torrent_reset(struct
> cdns_torrent_phy *cdns_phy)
> return PTR_ERR(cdns_phy->phy_rst);
> }
>
> - cdns_phy->apb_rst = devm_reset_control_get_optional(dev,
> "torrent_apb");
> + cdns_phy->apb_rst =
> devm_reset_control_get_optional_exclusive(dev, "torrent_apb");
> if (IS_ERR(cdns_phy->apb_rst)) {
> dev_err(dev, "%s: failed to get apb reset\n",
> dev->of_node->full_name);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured
2021-03-18 9:55 ` Swapnil Kashinath Jakhade
@ 2021-03-30 9:57 ` Kishon Vijay Abraham I
0 siblings, 0 replies; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2021-03-30 9:57 UTC (permalink / raw)
To: Swapnil Kashinath Jakhade, Vinod Koul, Rob Herring, Philipp Zabel
Cc: linux-kernel, devicetree, Lokesh Vutla, linux-phy
Hi Swapnil,
On 18/03/21 3:25 pm, Swapnil Kashinath Jakhade wrote:
>
>
>> -----Original Message-----
>> From: Kishon Vijay Abraham I <kishon@ti.com>
>> Sent: Wednesday, March 10, 2021 9:25 PM
>> To: Kishon Vijay Abraham I <kishon@ti.com>; Vinod Koul
>> <vkoul@kernel.org>; Rob Herring <robh+dt@kernel.org>; Philipp Zabel
>> <p.zabel@pengutronix.de>; Swapnil Kashinath Jakhade
>> <sjakhade@cadence.com>
>> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; Lokesh Vutla
>> <lokeshvutla@ti.com>; linux-phy@lists.infradead.org
>> Subject: [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's
>> already configured
>>
>> EXTERNAL MAIL
>>
>>
>> Do not configure torrent SERDES if it's already configured.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>> drivers/phy/cadence/phy-cadence-torrent.c | 32 ++++++++++++++++-------
>> 1 file changed, 22 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c
>> b/drivers/phy/cadence/phy-cadence-torrent.c
>> index ab51c4bf7b30..5ee1657f5a1c 100644
>> --- a/drivers/phy/cadence/phy-cadence-torrent.c
>> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
>> @@ -371,6 +371,10 @@ static const struct phy_ops cdns_torrent_phy_ops =
>> {
>> .owner = THIS_MODULE,
>> };
>>
>> +static const struct phy_ops noop_ops = {
>> + .owner = THIS_MODULE,
>> +};
>> +
>> struct cdns_reg_pairs {
>> u32 val;
>> u32 off;
>> @@ -2306,6 +2310,7 @@ static int cdns_torrent_phy_probe(struct
>> platform_device *pdev)
>> struct device_node *child;
>> int ret, subnodes, node = 0, i;
>> u32 total_num_lanes = 0;
>> + int already_configured;
>> u8 init_dp_regmap = 0;
>> u32 phy_type;
>>
>> @@ -2344,16 +2349,20 @@ static int cdns_torrent_phy_probe(struct
>> platform_device *pdev)
>> if (ret)
>> return ret;
>>
>> - ret = cdns_torrent_reset(cdns_phy);
>> - if (ret)
>> - goto clk_cleanup;
>> + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1,
>> &already_configured);
>>
>> - ret = cdns_torrent_clk(cdns_phy);
>> - if (ret)
>> - goto clk_cleanup;
>> + if (!already_configured) {
>> + ret = cdns_torrent_reset(cdns_phy);
>> + if (ret)
>> + goto clk_cleanup;
>> +
>> + ret = cdns_torrent_clk(cdns_phy);
>> + if (ret)
>> + goto clk_cleanup;
>>
> Should if (!already_configured) be checked while calling clk_disable_unprepare()?
Both clk_unprepare() and clk_disable() checks for passed clk for ERR or
NULL. So don't think it's necessary to have !already_configured check.
> Otherwise,
> Reviewed-by: Swapnil Jakhade <sjakhade@cadence.com>
Thanks
Kishon
>
> Thanks & regards,
> Swapnil
>
>> - /* Enable APB */
>> - reset_control_deassert(cdns_phy->apb_rst);
>> + /* Enable APB */
>> + reset_control_deassert(cdns_phy->apb_rst);
>> + }
>>
>> for_each_available_child_of_node(dev->of_node, child) {
>> struct phy *gphy;
>> @@ -2423,7 +2432,10 @@ static int cdns_torrent_phy_probe(struct
>> platform_device *pdev)
>> of_property_read_u32(child, "cdns,ssc-mode",
>> &cdns_phy->phys[node].ssc_mode);
>>
>> - gphy = devm_phy_create(dev, child,
>> &cdns_torrent_phy_ops);
>> + if (!already_configured)
>> + gphy = devm_phy_create(dev, child,
>> &cdns_torrent_phy_ops);
>> + else
>> + gphy = devm_phy_create(dev, child, &noop_ops);
>> if (IS_ERR(gphy)) {
>> ret = PTR_ERR(gphy);
>> goto put_child;
>> @@ -2507,7 +2519,7 @@ static int cdns_torrent_phy_probe(struct
>> platform_device *pdev)
>> goto put_lnk_rst;
>> }
>>
>> - if (cdns_phy->nsubnodes > 1) {
>> + if (cdns_phy->nsubnodes > 1 && !already_configured) {
>> ret = cdns_torrent_phy_configure_multilink(cdns_phy);
>> if (ret)
>> goto put_lnk_rst;
>> --
>> 2.17.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-03-30 9:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 15:54 [PATCH 0/4] j721e-wiz/cadence-torrent: Support to skip SERDES configuration Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 1/4] phy: ti: j721e-wiz: Do not configure wiz if its already configured Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 2/4] phy: cadence-torrent: Group reset APIs and clock APIs Kishon Vijay Abraham I
2021-03-18 9:56 ` Swapnil Kashinath Jakhade
2021-03-10 15:54 ` [PATCH 3/4] phy: cadence-torrent: Do not configure SERDES if it's already configured Kishon Vijay Abraham I
2021-03-18 9:55 ` Swapnil Kashinath Jakhade
2021-03-30 9:57 ` Kishon Vijay Abraham I
2021-03-10 15:54 ` [PATCH 4/4] phy: cadence-torrent: Explicitly request exclusive reset control Kishon Vijay Abraham I
2021-03-18 9:58 ` Swapnil Kashinath Jakhade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).