Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp935768ybl; Fri, 31 Jan 2020 10:39:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzvPu2mu+P/kQv3/sfGmmq82YQw0cB5m8u9xTe+/CfkpPHXg4rzTuhEU7949g1KnFuJnrMn X-Received: by 2002:aca:f20b:: with SMTP id q11mr6960843oih.78.1580495989211; Fri, 31 Jan 2020 10:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580495989; cv=none; d=google.com; s=arc-20160816; b=uW/hkMt3QcrDQhBPf8B4TVzUIGu/7mrq8Pl8e1L8miFOTwgsKP0C+Xo62EH7MTuguV rSmoDAeaspjDw6zoq/kEa5TnKNQTrR+8O17bDWIpgR2qNfT3xMX61sCOap9CKuXzUbrR YIhad9R7krkfBuYeWOLWzKhmt1M2mcAdAuuIiZbh2DBO0/mFSb5O5X2CsBAYAuymmvgZ 4MqJYK2vxrrZCDTUM9fe8aKT48Cwv6RnF+aISQkCxFn7wN1672lmuIZZdZWeuOuRQHrG nzhPAgiA+BYkWja6EYDwamUc8TI5yfe7ap0R1qugmm+IIzO/J6oqcDg6+0pLX/9KNW5n OBUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kUnDPc9PL0Pj0s+ivwfIR9uEkgxYzA8VwIqaCUZlzyw=; b=GxiandgK9kp4nUyeB8DdNoHcJKRFRlrWJLIe0tO+RMZpyUwqy5801rzJP4QejU9l4b IRhZWk/huNfz+CuIEh6BX+jwg2xBcHON2uYfcwCFTWz+pTtlBy3vCYsHHCVmvRskB3g4 Sm3c+VTjglN/EOSG3PVLbn60pvfApPVQE1jWKA7ygE+IAIEgueKUO4O0T6aPf2nsqYXt MazOfbJVRa75s8f8l7SLZ4i4U951RZ11fvltTQfs/CIENV/wYcw5AIdf+OPWym0L0ctx TXdVeoDWcA9AenXlb5BNPAF5VmdpLTFlsqAbic2F5K39RrG8cWElvUWhJHFBOn9G/4zz wxmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eHh4Ku0N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si5272890otp.273.2020.01.31.10.39.37; Fri, 31 Jan 2020 10:39:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eHh4Ku0N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726216AbgAaSiH (ORCPT + 99 others); Fri, 31 Jan 2020 13:38:07 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:49246 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgAaSiH (ORCPT ); Fri, 31 Jan 2020 13:38:07 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 00VIbrks064185; Fri, 31 Jan 2020 12:37:53 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1580495874; bh=kUnDPc9PL0Pj0s+ivwfIR9uEkgxYzA8VwIqaCUZlzyw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eHh4Ku0Nn7tOnoYz2GK13qJkBU4v1l8ArFY1MVw1js4WZCsIB8hLL9WeRdqMxKFPy jw5HnnsmOoCcS5KYSeKyQgCeJlbgrOahwo8ph5XPw7xl7A4CD6pjXRDKnfWWogqFKZ o6zDyD6YcGhnbDTKeblnqOhejJK11lccdJCoN9h4= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 00VIbrnG101524 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 31 Jan 2020 12:37:53 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 31 Jan 2020 12:37:53 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 31 Jan 2020 12:37:53 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00VIbrB3055583; Fri, 31 Jan 2020 12:37:53 -0600 From: Dan Murphy To: , , , , CC: , Dan Murphy Subject: [PATCH linux-master 2/3] can: m_can_platform: Move clock discovery and init to platform Date: Fri, 31 Jan 2020 12:34:32 -0600 Message-ID: <20200131183433.11041-3-dmurphy@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131183433.11041-1-dmurphy@ti.com> References: <20200131183433.11041-1-dmurphy@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the clock discovery and init to the platform driver as the platform driver needs an additional clock to the CAN clock to be initilialized and managed. Signed-off-by: Dan Murphy --- drivers/net/can/m_can/m_can_platform.c | 37 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c index 38ea5e600fb8..8bd459317eba 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -12,6 +12,9 @@ struct m_can_plat_priv { void __iomem *base; void __iomem *mram_base; + + struct clk *hclk; + struct clk *cclk; }; static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg) @@ -53,6 +56,22 @@ static struct m_can_ops m_can_plat_ops = { .read_fifo = iomap_read_fifo, }; +static int m_can_plat_get_clocks(struct m_can_plat_priv *priv, + struct m_can_classdev *mcan_class) +{ + int ret = 0; + + priv->hclk = devm_clk_get(mcan_class->dev, "hclk"); + + priv->cclk = devm_clk_get(mcan_class->dev, "cclk"); + if (IS_ERR(priv->cclk)) { + dev_err(mcan_class->dev, "no clock found\n"); + ret = -ENODEV; + } + + return ret; +} + static int m_can_plat_probe(struct platform_device *pdev) { struct m_can_classdev *mcan_class; @@ -72,7 +91,9 @@ static int m_can_plat_probe(struct platform_device *pdev) mcan_class->device_data = priv; - m_can_class_get_clocks(mcan_class); + ret = m_can_plat_get_clocks(priv, mcan_class); + if (ret) + return ret; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "m_can"); addr = devm_ioremap_resource(&pdev->dev, res); @@ -100,7 +121,7 @@ static int m_can_plat_probe(struct platform_device *pdev) mcan_class->net->irq = irq; mcan_class->pm_clock_support = 1; - mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk); + mcan_class->can.clock.freq = clk_get_rate(priv->cclk); mcan_class->dev = &pdev->dev; mcan_class->ops = &m_can_plat_ops; @@ -143,11 +164,12 @@ static int __maybe_unused m_can_runtime_suspend(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct m_can_classdev *mcan_class = netdev_priv(ndev); + struct m_can_plat_priv *priv = mcan_class->device_data; m_can_class_suspend(dev); - clk_disable_unprepare(mcan_class->cclk); - clk_disable_unprepare(mcan_class->hclk); + clk_disable_unprepare(priv->cclk); + clk_disable_unprepare(priv->hclk); return 0; } @@ -156,15 +178,16 @@ static int __maybe_unused m_can_runtime_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct m_can_classdev *mcan_class = netdev_priv(ndev); + struct m_can_plat_priv *priv = mcan_class->device_data; int err; - err = clk_prepare_enable(mcan_class->hclk); + err = clk_prepare_enable(priv->hclk); if (err) return err; - err = clk_prepare_enable(mcan_class->cclk); + err = clk_prepare_enable(priv->cclk); if (err) - clk_disable_unprepare(mcan_class->hclk); + clk_disable_unprepare(priv->hclk); return err; } -- 2.25.0