public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] serial_sh: Add OF support
Date: Mon,  1 Jun 2015 13:32:47 +0900	[thread overview]
Message-ID: <1433133168-4159-1-git-send-email-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <1432189870-21598-1-git-send-email-ysato@users.sourceforge.jp>

Add device tree support.

Changes v2:
rebased v2015.07-rc1

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 doc/device-tree-bindings/serial/sh.txt |  6 ++++++
 drivers/serial/serial_sh.c             | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/sh.txt

diff --git a/doc/device-tree-bindings/serial/sh.txt b/doc/device-tree-bindings/serial/sh.txt
new file mode 100644
index 0000000..b23b135
--- /dev/null
+++ b/doc/device-tree-bindings/serial/sh.txt
@@ -0,0 +1,6 @@
+* Renesas SCI serial interface
+
+Required properties:
+- compatible: must be "renesas,scif" or "renesas,scifa"
+- reg: exactly one register range with length
+- clock: input clock frequency for the SCI unit
diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index 8693c1e..32b2bf0 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -17,6 +17,8 @@
 #include <dm/platform_data/serial_sh.h>
 #include "serial_sh.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #if defined(CONFIG_CPU_SH7760) || \
 	defined(CONFIG_CPU_SH7780) || \
 	defined(CONFIG_CPU_SH7785) || \
@@ -201,9 +203,35 @@ static const struct dm_serial_ops sh_serial_ops = {
 	.setbrg = sh_serial_setbrg,
 };
 
+#ifdef CONFIG_OF_CONTROL
+static const struct udevice_id sh_serial_id[] ={
+	{.compatible = "renesas,scif", .data = PORT_SCIF},
+	{.compatible = "renesas,scifa", .data = PORT_SCIFA},
+	{}
+};
+
+static int sh_serial_ofdata_to_platdata(struct udevice *dev)
+{
+	struct sh_serial_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr;
+
+	addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	plat->base = addr;
+	plat->clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+	plat->type = dev_get_driver_data(dev);
+	return 0;
+}
+#endif
+
 U_BOOT_DRIVER(serial_sh) = {
 	.name	= "serial_sh",
 	.id	= UCLASS_SERIAL,
+	.of_match = of_match_ptr(sh_serial_id),
+	.ofdata_to_platdata = of_match_ptr(sh_serial_ofdata_to_platdata),
+	.platdata_auto_alloc_size = sizeof(struct sh_serial_platdata),
 	.probe	= sh_serial_probe,
 	.ops	= &sh_serial_ops,
 	.flags	= DM_FLAG_PRE_RELOC,
-- 
2.1.4

  parent reply	other threads:[~2015-06-01  4:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  6:31 [U-Boot] [PATCH 1/2] serial_sh: Add OF support Yoshinori Sato
2015-05-21  6:31 ` [U-Boot] [PATCH 2/2] serial_sh: Add standrad SCI (w/o FIFO) support Yoshinori Sato
2015-06-01  0:08 ` [U-Boot] [PATCH 1/2] serial_sh: Add OF support Nobuhiro Iwamatsu
2015-06-01  4:31   ` Yoshinori Sato
2015-06-01  4:32 ` Yoshinori Sato [this message]
2015-06-01  4:32   ` [U-Boot] [PATCH v2 2/2] serial_sh: Add standrad SCI (w/o FIFO) support Yoshinori Sato

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=1433133168-4159-1-git-send-email-ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=u-boot@lists.denx.de \
    /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