devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Aswath Govindraju <a-govindraju@ti.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Faiz Abbas <faiz_abbas@ti.com>,
	Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	Sriram Dash <sriram.dash@samsung.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-phy@lists.infradead.org
Subject: Re: [PATCH 4/4] can: m_can_platform: Add support for transceiver as phy
Date: Mon, 12 Apr 2021 12:22:26 +0200	[thread overview]
Message-ID: <9509372e-60f1-85cf-cc22-f7c1e66ae738@pengutronix.de> (raw)
In-Reply-To: <20210409134056.18740-5-a-govindraju@ti.com>


[-- Attachment #1.1: Type: text/plain, Size: 2713 bytes --]

On 4/9/21 3:40 PM, Aswath Govindraju wrote:
> From: Faiz Abbas <faiz_abbas@ti.com>
> 
> Add support for implementing transceiver node as phy. The max_bitrate is
> obtained by getting a phy attribute.
> 
> Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
> ---
>  drivers/net/can/m_can/m_can_platform.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
> index 599de0e08cd7..4a762b5a21d8 100644
> --- a/drivers/net/can/m_can/m_can_platform.c
> +++ b/drivers/net/can/m_can/m_can_platform.c
> @@ -6,6 +6,7 @@
>  // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
>  
>  #include <linux/platform_device.h>
> +#include <linux/phy/phy.h>
>  
>  #include "m_can.h"
>  
> @@ -67,7 +68,9 @@ static int m_can_plat_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	void __iomem *addr;
>  	void __iomem *mram_addr;
> +	struct phy *transceiver;
>  	int irq, ret = 0;
> +	u32 bitrate_max;
>  
>  	mcan_class = m_can_class_allocate_dev(&pdev->dev,
>  					      sizeof(struct m_can_plat_priv));
> @@ -101,6 +104,28 @@ static int m_can_plat_probe(struct platform_device *pdev)
>  		goto probe_fail;
>  	}
>  
> +	transceiver = devm_phy_optional_get(&pdev->dev, "can_transceiver");
> +	if (IS_ERR(transceiver)) {
> +		ret = PTR_ERR(transceiver);
> +		dev_err(&pdev->dev, "error while getting phy, err=%d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!transceiver) {
> +		dev_warn(&pdev->dev, "No transceiver phy found\n");

I think that's a bit to loud.

> +	} else {
> +		ret = phy_power_on(transceiver);

Please move the phy power on/off to the ndo_open and ndo_stop callbacks. There's
no need to power the transceivers if the CAN interface is down.

> +		if (ret) {
> +			dev_err(&pdev->dev, "error powering on phy, err=%d\n", ret);
> +			return ret;
> +		}
> +		/* converting from Mbps to bps */
> +		bitrate_max = (transceiver->attrs.max_link_rate) * 1000000;
> +		if (!bitrate_max)
> +			dev_warn(&pdev->dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n");

Please move this check to the generic transcevier code.

> +		priv->cdev.can.bitrate_max = bitrate_max;
> +	}
> +
>  	priv->base = addr;
>  	priv->mram_base = mram_addr;
>  
> 

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-04-12 10:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 13:40 [PATCH 0/4] CAN TRANSCEIVER: Add support for CAN transceivers Aswath Govindraju
2021-04-09 13:40 ` [PATCH 1/4] dt-bindings: phy: Add binding for TI TCAN104x " Aswath Govindraju
2021-04-12 10:19   ` Marc Kleine-Budde
2021-04-12 17:49     ` Rob Herring
2021-04-13  7:41       ` Marc Kleine-Budde
2021-04-13 13:15         ` Rob Herring
2021-04-14 12:53           ` Aswath Govindraju
2021-04-09 13:40 ` [PATCH 2/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Aswath Govindraju
2021-04-12 10:18   ` Marc Kleine-Budde
2021-04-14  6:24     ` Aswath Govindraju
2021-04-14  6:57       ` Marc Kleine-Budde
2021-04-09 13:40 ` [PATCH 3/4] dt-bindings: net: can: Document transceiver implementation as phy Aswath Govindraju
2021-04-12 17:51   ` Rob Herring
2021-04-14  6:49     ` Aswath Govindraju
2021-04-14 13:24       ` Rob Herring
2021-04-09 13:40 ` [PATCH 4/4] can: m_can_platform: Add support for transceiver " Aswath Govindraju
2021-04-12 10:22   ` Marc Kleine-Budde [this message]
2021-04-14  6:59 ` [PATCH 0/4] CAN TRANSCEIVER: Add support for CAN transceivers Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9509372e-60f1-85cf-cc22-f7c1e66ae738@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=a-govindraju@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=faiz_abbas@ti.com \
    --cc=grygorii.strashko@ti.com \
    --cc=kishon@ti.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=lokeshvutla@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=rcsekar@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=sriram.dash@samsung.com \
    --cc=vigneshr@ti.com \
    --cc=vkoul@kernel.org \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).