[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b43ee5ca-2aab-445a-e24b-cbc95f9186ea@ti.com>
Date: Wed, 9 Aug 2023 10:00:11 -0500
From: Andrew Davis <afd@...com>
To: MD Danish Anwar <danishanwar@...com>,
Randy Dunlap
<rdunlap@...radead.org>,
Roger Quadros <rogerq@...nel.org>,
Simon Horman
<simon.horman@...igine.com>,
Vignesh Raghavendra <vigneshr@...com>, Andrew
Lunn <andrew@...n.ch>,
Richard Cochran <richardcochran@...il.com>,
Conor
Dooley <conor+dt@...nel.org>,
Krzysztof Kozlowski
<krzysztof.kozlowski+dt@...aro.org>,
Rob Herring <robh+dt@...nel.org>, Paolo
Abeni <pabeni@...hat.com>,
Jakub Kicinski <kuba@...nel.org>, Eric Dumazet
<edumazet@...gle.com>,
"David S. Miller" <davem@...emloft.net>
CC: <nm@...com>, <srk@...com>, <linux-kernel@...r.kernel.org>,
<devicetree@...r.kernel.org>, <netdev@...r.kernel.org>,
<linux-omap@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v3 3/5] net: ti: icss-iep: Add IEP driver
On 8/9/23 6:49 AM, MD Danish Anwar wrote:
> From: Roger Quadros <rogerq@...com>
>
> Add a driver for Industrial Ethernet Peripheral (IEP) block of PRUSS to
> support timestamping of ethernet packets and thus support PTP and PPS
> for PRU ethernet ports.
>
> Signed-off-by: Roger Quadros <rogerq@...com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@...com>
> Signed-off-by: Murali Karicheri <m-karicheri2@...com>
> Signed-off-by: Vignesh Raghavendra <vigneshr@...com>
> Signed-off-by: MD Danish Anwar <danishanwar@...com>
> ---
> drivers/net/ethernet/ti/Kconfig | 12 +
> drivers/net/ethernet/ti/Makefile | 1 +
> drivers/net/ethernet/ti/icssg/icss_iep.c | 935 +++++++++++++++++++++++
> drivers/net/ethernet/ti/icssg/icss_iep.h | 38 +
> 4 files changed, 986 insertions(+)
> create mode 100644 drivers/net/ethernet/ti/icssg/icss_iep.c
> create mode 100644 drivers/net/ethernet/ti/icssg/icss_iep.h
>
> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index 63e510b6860f..88b5b1b47779 100644
> --- a/drivers/net/ethernet/ti/Kconfig
> +++ b/drivers/net/ethernet/ti/Kconfig
> @@ -186,6 +186,7 @@ config CPMAC
> config TI_ICSSG_PRUETH
> tristate "TI Gigabit PRU Ethernet driver"
> select PHYLIB
> + select TI_ICSS_IEP
Why not save selecting this until you add its use in the ICSSG_PRUETH driver in the next patch.
[...]
> +
> +static u32 icss_iep_readl(struct icss_iep *iep, int reg)
> +{
> + return readl(iep->base + iep->plat_data->reg_offs[reg]);
> +}
Do these one line functions really add anything? Actually why
not use the regmap you have here.
[...]
> +static void icss_iep_enable(struct icss_iep *iep)
> +{
> + regmap_update_bits(iep->map, ICSS_IEP_GLOBAL_CFG_REG,
> + IEP_GLOBAL_CFG_CNT_ENABLE,
> + IEP_GLOBAL_CFG_CNT_ENABLE);
Have you looked into regmap_fields?
[...]
> +
> + if (!!(iep->latch_enable & BIT(index)) == !!on)
> + goto exit;
> +
There has to be a better way to write this logic..
[...]
> +
> +static const struct of_device_id icss_iep_of_match[];
> +
Why the forward declaration?
> +static int icss_iep_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct icss_iep *iep;
> + struct clk *iep_clk;
> +
> + iep = devm_kzalloc(dev, sizeof(*iep), GFP_KERNEL);
> + if (!iep)
> + return -ENOMEM;
> +
> + iep->dev = dev;
> + iep->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(iep->base))
> + return -ENODEV;
> +
> + iep_clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(iep_clk))
> + return PTR_ERR(iep_clk);
> +
> + iep->refclk_freq = clk_get_rate(iep_clk);
> +
> + iep->def_inc = NSEC_PER_SEC / iep->refclk_freq; /* ns per clock tick */
> + if (iep->def_inc > IEP_MAX_DEF_INC) {
> + dev_err(dev, "Failed to set def_inc %d. IEP_clock is too slow to be supported\n",
> + iep->def_inc);
> + return -EINVAL;
> + }
> +
> + iep->plat_data = of_device_get_match_data(dev);
Directly using of_*() functions is often wrong, try just device_get_match_data().
[...]
> +static struct platform_driver icss_iep_driver = {
> + .driver = {
> + .name = "icss-iep",
> + .of_match_table = of_match_ptr(icss_iep_of_match),
This driver cannot work without OF, using of_match_ptr() is not needed.
Andrew
Powered by blists - more mailing lists