From patchwork Mon Sep 26 12:26:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 675148 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sjPMM1Kzwz9ryZ for ; Mon, 26 Sep 2016 23:05:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC788A7636; Mon, 26 Sep 2016 15:04:50 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l1o1W-7avWUe; Mon, 26 Sep 2016 15:04:50 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1BC73A7664; Mon, 26 Sep 2016 15:04:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E390BA7527 for ; Mon, 26 Sep 2016 14:47:47 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fo4hngOp_U8Q for ; Mon, 26 Sep 2016 14:47:47 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) by theia.denx.de (Postfix) with ESMTPS id 62118A758E for ; Mon, 26 Sep 2016 14:47:45 +0200 (CEST) Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 14:27:41 +0200 Received: from linux-lm3i.site (nwb-a10-snat.microfocus.com [10.120.13.201]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 13:27:21 +0100 From: Fabian Vogt To: u-boot@lists.denx.de Date: Mon, 26 Sep 2016 14:26:44 +0200 Message-Id: <20160926122651.22132-3-fvogt@suse.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160926122651.22132-1-fvogt@suse.com> References: <20160926122651.22132-1-fvogt@suse.com> X-Mailman-Approved-At: Mon, 26 Sep 2016 15:04:20 +0200 Subject: [U-Boot] [PATCH 2/9] serial: bcm283x_mu: add device tree support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds device tree support for the bcm283x mini-uart driver. Signed-off-by: Fabian Vogt Reviewed-by: Simon Glass --- .../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 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 #include +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,