devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vignesh R <vigneshr@ti.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>
Cc: Jiri Slaby <jslaby@suse.com>, Vignesh R <vigneshr@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	linux-serial@vger.kernel.org, linux-omap@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] serial: 8250_omap: Use clk_get_rate() to obtain fclk frequency
Date: Wed, 9 Jan 2019 14:42:06 +0530	[thread overview]
Message-ID: <20190109091206.25759-4-vigneshr@ti.com> (raw)
In-Reply-To: <20190109091206.25759-1-vigneshr@ti.com>

8250_omap driver uses clock-frequency DT property to obtain functional
clk frequency. This is not ideal as users need to calculate functional
clk frequency offline and populate it in DT.
Therefore add support to obtain functional clock frequency using clk
APIs when clock-frequency DT property is not defined.

Suggested-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/tty/serial/8250/8250_omap.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index a74126569785..0a8316632d75 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -12,6 +12,7 @@
 #define SUPPORT_SYSRQ
 #endif
 
+#include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -1203,7 +1204,18 @@ static int omap8250_probe(struct platform_device *pdev)
 	}
 	up.port.line = ret;
 
-	of_property_read_u32(np, "clock-frequency", &up.port.uartclk);
+	if (of_property_read_u32(np, "clock-frequency", &up.port.uartclk)) {
+		struct clk *clk;
+
+		clk = devm_clk_get(&pdev->dev, NULL);
+		if (IS_ERR(clk)) {
+			if (PTR_ERR(clk) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+		} else {
+			up.port.uartclk = clk_get_rate(clk);
+		}
+	}
+
 	priv->wakeirq = irq_of_parse_and_map(np, 1);
 
 	id = of_match_device(of_match_ptr(omap8250_dt_ids), &pdev->dev);
-- 
2.20.1

      parent reply	other threads:[~2019-01-09  9:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09  9:12 [PATCH 0/3] 8250_omap: use clk APIs to get fclk freqeuncy Vignesh R
2019-01-09  9:12 ` [PATCH 1/3] serial: 8250_omap: Drop check for of_node Vignesh R
2019-01-09 21:44   ` Tony Lindgren
2019-01-10 12:07     ` Sebastian Reichel
2019-01-10 13:24       ` Vignesh R
2019-01-10 15:27         ` Tony Lindgren
2019-01-09  9:12 ` [PATCH 2/3] dt-bindings: serial: omap_serial: add clocks entry Vignesh R
2019-01-21 21:08   ` Rob Herring
2019-01-09  9:12 ` Vignesh R [this message]

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=20190109091206.25759-4-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=tony@atomide.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).