Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5561725pxj; Wed, 26 May 2021 13:39:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsCqgRSfArk11vePRzl/HBQwmXmO1yOomyHZ5O8adRjmhZW25GxdcdKGZrtb2RD2DbAgvm X-Received: by 2002:a05:6402:35c4:: with SMTP id z4mr89647edc.362.1622061554582; Wed, 26 May 2021 13:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622061554; cv=none; d=google.com; s=arc-20160816; b=x29XQd00n9QQ75VWRj+B1jonDgvqkJb0X0e/Z/Mdwu4BX6QSmtGXQBybC/HDGBE042 qXNX0iZcRO9AbLM6LaLTlYc21GMvYW5CSiMJZEfGJFn60gXX9UaP4i+yWv9LD02TfD4u PU6gXJhz3CQxOUM7fAeP5KjywGDKddhLfy6JNMYpzIOsnKvT0uxPiPJjMYS0dU7d17C3 FdZitzO1D7iENUD0t1GQ6K8/CXFZOGbqENejGVDw8gDit+zkCu9WcsNEa99lh7lcRrei hJK9N9Z7ShB3YuKMRNoyxb4PRG/Q/5bwYj5U2BCWJPFA3JJ3VheLA7o1fyYAIqLii2+1 BqIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=RoMR9eFi93CS09A/FAqQsuFK1I21lE+6U/1WAI+VgrY=; b=dJK/hYCz6KFdO5yE119um/ieTboSGrRLcEpYQIHYWs8dNnXgMNXYZ4rAQNWkMLVQp1 xorIB26tYgxhtwsnY+0aHj70movAoDPFpxKF1eZOR91xooCT7/huRl1ns+z2gtAz0zHU 1TyspFeHx1p172pcu05gRdvlhoPkgKMQVq9gX7EVWVoqYbqS5cXf36fNJghARnuqM2xu UfkU3C3SDTEKFpkQPmWUAncMTJvULui3xtXZ4erMKScG+C1OucVzGnUX9PuSHa05IDuQ rRqJ2gf+I3U+VYd3gqoUmxZHmhwVIZXsNhKCU4rjzICwle3GYJKsH1bjkgixYvIUtNbI 0pOg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si293669edq.173.2021.05.26.13.38.47; Wed, 26 May 2021 13:39:14 -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; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234281AbhEZTer (ORCPT + 99 others); Wed, 26 May 2021 15:34:47 -0400 Received: from mga14.intel.com ([192.55.52.115]:17299 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbhEZTeq (ORCPT ); Wed, 26 May 2021 15:34:46 -0400 IronPort-SDR: YaI/khUR/StpxGKi6mv65lSK99MkJS6s0XqqtR7sO6TP+KVNcHzRmtBNEgLYC6Vv50b28u2TdL qtzOEIq88fPg== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="202314545" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="202314545" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 12:33:11 -0700 IronPort-SDR: u5Dsla4+nA3YXcRtVgubHz+WtYEUida1UdESPh5X61zZuSIm6ARXQRD1b5pTeA7eWHlTlWzYkl SAeRcmWumKrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="397439038" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 26 May 2021 12:33:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5308CB7; Wed, 26 May 2021 22:33:31 +0300 (EEST) From: Andy Shevchenko To: Marc Kleine-Budde , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Manivannan Sadhasivam , Thomas Kopp , Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski , Andy Shevchenko Subject: [PATCH v2 1/2] can: mcp251xfd: Try to get crystal clock rate from property Date: Wed, 26 May 2021 22:33:26 +0300 Message-Id: <20210526193327.70468-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some configurations, mainly ACPI-based, the clock frequency of the device is supplied by very well established 'clock-frequency' property. Hence, try to get it from the property at last if no other providers are available. Signed-off-by: Andy Shevchenko --- v2: new patch drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c index e0ae00e34c7b..e42f87c3f2ec 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c @@ -2856,7 +2856,7 @@ static int mcp251xfd_probe(struct spi_device *spi) struct gpio_desc *rx_int; struct regulator *reg_vdd, *reg_xceiver; struct clk *clk; - u32 freq; + u32 freq, rate; int err; if (!spi->irq) @@ -2883,11 +2883,16 @@ static int mcp251xfd_probe(struct spi_device *spi) return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver), "Failed to get Transceiver regulator!\n"); - clk = devm_clk_get(&spi->dev, NULL); + /* Always ask for fixed clock rate from a property. */ + device_property_read_u32(&spi->dev, "clock-frequency", &rate); + + clk = devm_clk_get_optional(&spi->dev, NULL); if (IS_ERR(clk)) return dev_err_probe(&spi->dev, PTR_ERR(clk), "Failed to get Oscillator (clock)!\n"); freq = clk_get_rate(clk); + if (freq == 0) + freq = rate; /* Sanity check */ if (freq < MCP251XFD_SYSCLOCK_HZ_MIN || -- 2.30.2