diff mbox

[U-Boot,2/9] serial: bcm283x_mu: add device tree support

Message ID 20160926122651.22132-3-fvogt@suse.com
State Accepted
Commit 9f755f5d09b8739441265d56ac1081e0fba2b21f
Delegated to: Tom Rini
Headers show

Commit Message

Fabian Vogt Sept. 26, 2016, 12:26 p.m. UTC
This patch adds device tree support for the bcm283x mini-uart driver.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
---
 .../serial/bcm2835-aux-uart.txt                    | 10 ++++++++
 drivers/serial/serial_bcm283x_mu.c                 | 28 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/bcm2835-aux-uart.txt

Comments

Simon Glass Sept. 27, 2016, 12:34 a.m. UTC | #1
On 26 September 2016 at 06:26, Fabian Vogt <fvogt@suse.com> wrote:
> This patch adds device tree support for the bcm283x mini-uart driver.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.com>
> ---
>  .../serial/bcm2835-aux-uart.txt                    | 10 ++++++++
>  drivers/serial/serial_bcm283x_mu.c                 | 28 ++++++++++++++++++++++
>  2 files changed, 38 insertions(+)
>  create mode 100644 doc/device-tree-bindings/serial/bcm2835-aux-uart.txt

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Nov. 29, 2016, 5:34 p.m. UTC | #2
On Mon, Sep 26, 2016 at 02:26:44PM +0200, Fabian Vogt wrote:

> This patch adds device tree support for the bcm283x mini-uart driver.
> 
> Signed-off-by: Fabian Vogt <fvogt@suse.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/doc/device-tree-bindings/serial/bcm2835-aux-uart.txt b/doc/device-tree-bindings/serial/bcm2835-aux-uart.txt
new file mode 100644
index 0000000..75886e5
--- /dev/null
+++ b/doc/device-tree-bindings/serial/bcm2835-aux-uart.txt
@@ -0,0 +1,10 @@ 
+* BCM283x mini UART
+
+Required properties:
+- compatible: must be "brcm,bcm2835-aux-uart"
+- reg: exactly one register range with length 0x1000
+- clock: input clock frequency for the UART (used to calculate the baud
+  rate divisor)
+
+Optional properties:
+- skip-init: if present, the baud rate divisor is not changed
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index f4e062f..e361909 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -25,6 +25,8 @@ 
 #include <linux/compiler.h>
 #include <fdtdec.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 struct bcm283x_mu_regs {
 	u32 io;
 	u32 iir;
@@ -132,9 +134,35 @@  static const struct dm_serial_ops bcm283x_mu_serial_ops = {
 	.setbrg = bcm283x_mu_serial_setbrg,
 };
 
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct udevice_id bcm283x_mu_serial_id[] = {
+	{.compatible = "brcm,bcm2835-aux-uart"},
+	{}
+};
+
+static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
+{
+	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr;
+
+	addr = dev_get_addr(dev);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	plat->base = addr;
+	plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+	                                  "skip-init");
+	plat->disabled = false;
+	return 0;
+}
+#endif
+
 U_BOOT_DRIVER(serial_bcm283x_mu) = {
 	.name = "serial_bcm283x_mu",
 	.id = UCLASS_SERIAL,
+	.of_match = of_match_ptr(bcm283x_mu_serial_id),
+	.ofdata_to_platdata = of_match_ptr(bcm283x_mu_serial_ofdata_to_platdata),
 	.platdata_auto_alloc_size = sizeof(struct bcm283x_mu_serial_platdata),
 	.probe = bcm283x_mu_serial_probe,
 	.ops = &bcm283x_mu_serial_ops,