From patchwork Thu Sep 20 21:07:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 972797 X-Patchwork-Delegate: jason.jin@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sysam.it Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42GbWl3z6Fz9sBq for ; Fri, 21 Sep 2018 11:25:39 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 894FBC21D9A; Fri, 21 Sep 2018 01:24:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RDNS_DYNAMIC autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EC047C21E44; Fri, 21 Sep 2018 01:24:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D49A2C21C6A; Fri, 21 Sep 2018 01:24:09 +0000 (UTC) Received: from sysam.it (ec2-18-194-220-216.eu-central-1.compute.amazonaws.com [18.194.220.216]) by lists.denx.de (Postfix) with ESMTP id 6E696C21C4A for ; Fri, 21 Sep 2018 01:24:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sysam.it (Postfix) with ESMTP id 9E2B821E61; Thu, 20 Sep 2018 21:08:07 +0000 (UTC) Received: from sysam.it ([127.0.0.1]) by localhost (sysam.it [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yRMScMqjbV-C; Thu, 20 Sep 2018 21:08:07 +0000 (UTC) Received: from localhost.localdomain (host238-237-dynamic.44-79-r.retail.telecomitalia.it [79.44.237.238]) by sysam.it (Postfix) with ESMTPSA id DBDDF21E60; Thu, 20 Sep 2018 21:08:06 +0000 (UTC) From: Angelo Dureghello To: trini@konsulko.com Date: Thu, 20 Sep 2018 23:07:51 +0200 Message-Id: <20180920210755.22381-4-angelo@sysam.it> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180920210755.22381-1-angelo@sysam.it> References: <20180920210755.22381-1-angelo@sysam.it> MIME-Version: 1.0 Cc: sjg.chromium.org@ip-172-31-46-226.eu-central-1.compute.internal, u-boot@lists.denx.de, Angelo Dureghello , jteki.openedev.com@ip-172-31-46-226.eu-central-1.compute.internal, alison.wang@freescale.com Subject: [U-Boot] [PATCH 3/7] drivers: serial: mcfuart: add DT support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds devicetree support to the mcfuart.c driver. Signed-off-by: Angelo Dureghello Reviewed-by: Simon Glass --- drivers/serial/mcfuart.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c index 1371049de2..5896a19805 100644 --- a/drivers/serial/mcfuart.c +++ b/drivers/serial/mcfuart.c @@ -5,6 +5,9 @@ * * Modified to add device model (DM) support * (C) Copyright 2015 Angelo Dureghello + * + * Modified to add fdt support + * (C) Copyright 2018 Angelo Dureghello */ /* @@ -212,6 +215,23 @@ static int coldfire_serial_pending(struct udevice *dev, bool input) return 0; } +static int coldfire_ofdata_to_platdata(struct udevice *dev) +{ + struct coldfire_serial_platdata *plat = dev_get_platdata(dev); + fdt_addr_t addr_base; + + addr_base = devfdt_get_addr(dev); + if (addr_base == FDT_ADDR_T_NONE) + return -ENODEV; + + plat->base = (uint32_t)addr_base; + + plat->port = dev->seq; + plat->baudrate = gd->baudrate; + + return 0; +} + static const struct dm_serial_ops coldfire_serial_ops = { .putc = coldfire_serial_putc, .pending = coldfire_serial_pending, @@ -219,9 +239,17 @@ static const struct dm_serial_ops coldfire_serial_ops = { .setbrg = coldfire_serial_setbrg, }; +static const struct udevice_id coldfire_serial_ids[] = { + { .compatible = "fsl,mcf-uart" }, + { } +}; + U_BOOT_DRIVER(serial_coldfire) = { .name = "serial_coldfire", .id = UCLASS_SERIAL, + .of_match = coldfire_serial_ids, + .ofdata_to_platdata = coldfire_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata), .probe = coldfire_serial_probe, .ops = &coldfire_serial_ops, .flags = DM_FLAG_PRE_RELOC,