diff mbox series

[net-next,v2,1/3] net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices

Message ID 20240604-iep-v2-1-ea8e1c0a5686@siemens.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Enable PTP timestamping/PPS for AM65x SR1.0 devices | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 84 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-04--18-00 (tests: 1045)

Commit Message

Diogo Ivo June 4, 2024, 1:15 p.m. UTC
Enable PTP support for AM65x SR1.0 devices by registering with the IEP
infrastructure in order to expose a PTP clock to userspace.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 51 +++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

Comments

Wojciech Drewek June 4, 2024, 2:19 p.m. UTC | #1
On 04.06.2024 15:15, Diogo Ivo wrote:
> Enable PTP support for AM65x SR1.0 devices by registering with the IEP
> infrastructure in order to expose a PTP clock to userspace.
> 
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 51 +++++++++++++++++++++++-
>  1 file changed, 50 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
> index 7b3304bbd7fc..fa98bdb11ece 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
> @@ -1011,16 +1011,44 @@ static int prueth_probe(struct platform_device *pdev)
>  	dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa,
>  		prueth->msmcram.va, prueth->msmcram.size);
>  
> +	prueth->iep0 = icss_iep_get_idx(np, 0);
> +	if (IS_ERR(prueth->iep0)) {
> +		ret = dev_err_probe(dev, PTR_ERR(prueth->iep0),
> +				    "iep0 get failed\n");
> +		goto free_pool;
> +	}
> +
> +	prueth->iep1 = icss_iep_get_idx(np, 1);
> +	if (IS_ERR(prueth->iep1)) {
> +		ret = dev_err_probe(dev, PTR_ERR(prueth->iep1),
> +				    "iep1 get failed\n");
> +		goto put_iep0;
> +	}
> +
> +	ret = icss_iep_init(prueth->iep0, NULL, NULL, 0);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to init iep0\n");
> +		goto put_iep;
> +	}
> +
> +	ret = icss_iep_init(prueth->iep1, NULL, NULL, 0);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to init iep1\n");
> +		goto exit_iep0;
> +	}
> +
>  	if (eth0_node) {
>  		ret = prueth_netdev_init(prueth, eth0_node);
>  		if (ret) {
>  			dev_err_probe(dev, ret, "netdev init %s failed\n",
>  				      eth0_node->name);
> -			goto free_pool;
> +			goto exit_iep;
>  		}
>  
>  		if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
>  			prueth->emac[PRUETH_MAC0]->half_duplex = 1;
> +
> +		prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
>  	}
>  
>  	if (eth1_node) {
> @@ -1033,6 +1061,8 @@ static int prueth_probe(struct platform_device *pdev)
>  
>  		if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
>  			prueth->emac[PRUETH_MAC1]->half_duplex = 1;
> +
> +		prueth->emac[PRUETH_MAC1]->iep = prueth->iep1;
>  	}
>  
>  	/* register the network devices */
> @@ -1091,6 +1121,19 @@ static int prueth_probe(struct platform_device *pdev)
>  		prueth_netdev_exit(prueth, eth_node);
>  	}
>  
> +exit_iep:
> +	icss_iep_exit(prueth->iep1);
> +exit_iep0:
> +	icss_iep_exit(prueth->iep0);
> +
> +put_iep:
> +	icss_iep_put(prueth->iep1);
> +
> +put_iep0:
> +	icss_iep_put(prueth->iep0);
> +	prueth->iep0 = NULL;
> +	prueth->iep1 = NULL;
> +
>  free_pool:
>  	gen_pool_free(prueth->sram_pool,
>  		      (unsigned long)prueth->msmcram.va, msmc_ram_size);
> @@ -1138,6 +1181,12 @@ static void prueth_remove(struct platform_device *pdev)
>  		prueth_netdev_exit(prueth, eth_node);
>  	}
>  
> +	icss_iep_exit(prueth->iep1);
> +	icss_iep_exit(prueth->iep0);
> +
> +	icss_iep_put(prueth->iep1);
> +	icss_iep_put(prueth->iep0);
> +
>  	gen_pool_free(prueth->sram_pool,
>  		      (unsigned long)prueth->msmcram.va,
>  		      MSMC_RAM_SIZE_SR1);
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index 7b3304bbd7fc..fa98bdb11ece 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -1011,16 +1011,44 @@  static int prueth_probe(struct platform_device *pdev)
 	dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa,
 		prueth->msmcram.va, prueth->msmcram.size);
 
+	prueth->iep0 = icss_iep_get_idx(np, 0);
+	if (IS_ERR(prueth->iep0)) {
+		ret = dev_err_probe(dev, PTR_ERR(prueth->iep0),
+				    "iep0 get failed\n");
+		goto free_pool;
+	}
+
+	prueth->iep1 = icss_iep_get_idx(np, 1);
+	if (IS_ERR(prueth->iep1)) {
+		ret = dev_err_probe(dev, PTR_ERR(prueth->iep1),
+				    "iep1 get failed\n");
+		goto put_iep0;
+	}
+
+	ret = icss_iep_init(prueth->iep0, NULL, NULL, 0);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to init iep0\n");
+		goto put_iep;
+	}
+
+	ret = icss_iep_init(prueth->iep1, NULL, NULL, 0);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to init iep1\n");
+		goto exit_iep0;
+	}
+
 	if (eth0_node) {
 		ret = prueth_netdev_init(prueth, eth0_node);
 		if (ret) {
 			dev_err_probe(dev, ret, "netdev init %s failed\n",
 				      eth0_node->name);
-			goto free_pool;
+			goto exit_iep;
 		}
 
 		if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
 			prueth->emac[PRUETH_MAC0]->half_duplex = 1;
+
+		prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
 	}
 
 	if (eth1_node) {
@@ -1033,6 +1061,8 @@  static int prueth_probe(struct platform_device *pdev)
 
 		if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
 			prueth->emac[PRUETH_MAC1]->half_duplex = 1;
+
+		prueth->emac[PRUETH_MAC1]->iep = prueth->iep1;
 	}
 
 	/* register the network devices */
@@ -1091,6 +1121,19 @@  static int prueth_probe(struct platform_device *pdev)
 		prueth_netdev_exit(prueth, eth_node);
 	}
 
+exit_iep:
+	icss_iep_exit(prueth->iep1);
+exit_iep0:
+	icss_iep_exit(prueth->iep0);
+
+put_iep:
+	icss_iep_put(prueth->iep1);
+
+put_iep0:
+	icss_iep_put(prueth->iep0);
+	prueth->iep0 = NULL;
+	prueth->iep1 = NULL;
+
 free_pool:
 	gen_pool_free(prueth->sram_pool,
 		      (unsigned long)prueth->msmcram.va, msmc_ram_size);
@@ -1138,6 +1181,12 @@  static void prueth_remove(struct platform_device *pdev)
 		prueth_netdev_exit(prueth, eth_node);
 	}
 
+	icss_iep_exit(prueth->iep1);
+	icss_iep_exit(prueth->iep0);
+
+	icss_iep_put(prueth->iep1);
+	icss_iep_put(prueth->iep0);
+
 	gen_pool_free(prueth->sram_pool,
 		      (unsigned long)prueth->msmcram.va,
 		      MSMC_RAM_SIZE_SR1);