Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1364563pxf; Fri, 9 Apr 2021 06:44:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2Mb3JkrS/SKvKNFL5/0i+0MpVCCHrA/e9Yhk7Qg325UsGc/vvltfrVjo9RsGoXzrpLGPu X-Received: by 2002:aa7:814e:0:b029:20e:f3fa:2900 with SMTP id d14-20020aa7814e0000b029020ef3fa2900mr12740780pfn.62.1617975887558; Fri, 09 Apr 2021 06:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617975887; cv=none; d=google.com; s=arc-20160816; b=fe7NOgKwZ54ZX2glnBwsyh/MEGGKhWrCNKOF24BrKqVhVU00Y7J6+Pw/9vehVBrFxl mejE07VVWHVGqiSWqwnEcHCC3aHW315NrEEzg3ZWHqYvsENFrHlBrFvTMM+6gFxiz3MS vl13w6ZRadtaBTbphwydpp5rA3SO4inGqpEdYe9dHuyRrZQDEo9qGqk55FkfjAonKSjp Km+r+heYo9mbaxhIkaOHEF2j4AmZk+jcVbf3hgBOWURZAvIQmX1S4xJ71jqJ/jtfKkPR ++Hl1+9RnVLfVs6IEWTKpFG9VzklxatLpQTeIlF6iC2J+yv0Y4lkmEWt4sk6HiLkkNIn 6PFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:mime-version:references:in-reply-to :message-id:date:subject:cc:from:dkim-signature; bh=yzQFMlEvLc1NJ8+6qQzAMS/IJa1/2LrIrpQLN6vAeQU=; b=odre+RzHbka4UsC1qTpk3iOALecPw9apZXzT01pruQi4Xl2H151fnqk612fhrugRoy 7B5+Pkm2avqkpYKiGwm85izJkq+SUeplVQ76zQB0YlkWvvgu11ZBrDsaX4Ao0SmrklPi Oa27pjsi4arqJ1+PMskEaqFZhLljP9n5B71ou7L7oYbr7+MOP9HA1XIFQTLFjtstRZC2 te2ld80XU1nPzElSz8KqsD6FIo2aaJnHnmw1lssZJksrOcZIMV+gC7BEPVrowOM1w4z5 dk6G6sB+Fh8+30nS9iQpGo+0SezQPPPxzeDPrewr0vD40+ainsp0JS0UuQF8PPK4oMkL rD7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=UNQR6TKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si2981323pll.388.2021.04.09.06.44.34; Fri, 09 Apr 2021 06:44:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=UNQR6TKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233712AbhDINmL (ORCPT + 99 others); Fri, 9 Apr 2021 09:42:11 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:52444 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbhDINmD (ORCPT ); Fri, 9 Apr 2021 09:42:03 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 139Dfbol029329; Fri, 9 Apr 2021 08:41:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1617975697; bh=yzQFMlEvLc1NJ8+6qQzAMS/IJa1/2LrIrpQLN6vAeQU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UNQR6TKCVjkHc2LapYnv+gSYZDa9D7jgM4msj9gaN4CbCbyhk70VjclQuaPZ27NTK dO4M2i4au2NgZaIC+aksBNFvCZq2NCDdC13YvOL8Lh0I5CSU8dyfplbQVb11I3YiKZ ZVVVF9vzfQ55HLYEixq0dNtSgTG3w9PjhNOwd+Ho= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 139DfbJF116872 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 9 Apr 2021 08:41:37 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 9 Apr 2021 08:41:37 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Fri, 9 Apr 2021 08:41:36 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 139Dewmd029277; Fri, 9 Apr 2021 08:41:31 -0500 From: Aswath Govindraju CC: Vignesh Raghavendra , Kishon Vijay Abraham I , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju , Faiz Abbas , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Rob Herring , Vinod Koul , Sriram Dash , , , , , Subject: [PATCH 4/4] can: m_can_platform: Add support for transceiver as phy Date: Fri, 9 Apr 2021 19:10:54 +0530 Message-ID: <20210409134056.18740-5-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409134056.18740-1-a-govindraju@ti.com> References: <20210409134056.18740-1-a-govindraju@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Faiz Abbas Add support for implementing transceiver node as phy. The max_bitrate is obtained by getting a phy attribute. Signed-off-by: Faiz Abbas Signed-off-by: Aswath Govindraju --- 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 +#include #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"); + } else { + ret = phy_power_on(transceiver); + 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"); + priv->cdev.can.bitrate_max = bitrate_max; + } + priv->base = addr; priv->mram_base = mram_addr; -- 2.17.1