From patchwork Mon Sep 22 15:48:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 392045 X-Patchwork-Delegate: sjg@chromium.org 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 AAF07140174 for ; Tue, 23 Sep 2014 01:54:45 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8BDE9A74F7; Mon, 22 Sep 2014 17:54:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 hGy3B4nWN+wo; Mon, 22 Sep 2014 17:54:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92378A759F; Mon, 22 Sep 2014 17:53:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30523A74F7 for ; Mon, 22 Sep 2014 17:53:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 YR4LkkkbxUM9 for ; Mon, 22 Sep 2014 17:53:25 +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 mail-pd0-f202.google.com (mail-pd0-f202.google.com [209.85.192.202]) by theia.denx.de (Postfix) with ESMTPS id 8A5B1A7488 for ; Mon, 22 Sep 2014 17:53:14 +0200 (CEST) Received: by mail-pd0-f202.google.com with SMTP id r10so141871pdi.1 for ; Mon, 22 Sep 2014 08:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fz5PEZxhLsVi4MsK/kd0/Cccl9Wxcbi22jFpmJdaR0o=; b=ZRrl+1r8YaMI9j83j6/dIinLl1e2da69fNezuNhGPldx8qHCxjIOQAbzpbHQoBnfcQ PceuVswUidh4kcMjGgrGZkFfcvYCFRZJOiRkIHZgV5ecsEYHWg+G61Lyox7kp4M0QBUF NDTKIypwY0pf93ahGC8EBSgJ0XINn/F4HBjFsSGuIKzROLgb3VC9AFRbukXUVoj10wt1 X6/5MoZbzYQDnb3CUAWpKm+VP+vOg1o3Lw70rirMlrotv3qaA+pagH307vDUUVr08J3H R4DLl+lRo3ra2/RGCON5ztYcnuSxsm6whonmAejNlcHUOFtFeeKu/LE9/z3ESNzg+SlY 4BBQ== X-Gm-Message-State: ALoCoQlUgXFSdJj380a3C7kg0glWryuOdFKrZ4yPEyCwnYUgb9nxPCMAKqsOFM2TyXWWsjkVJYr9 X-Received: by 10.66.196.70 with SMTP id ik6mr25224633pac.44.1411401193098; Mon, 22 Sep 2014 08:53:13 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id n24si498754yha.6.2014.09.22.08.53.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Sep 2014 08:53:13 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id oMF1BZBK.1; Mon, 22 Sep 2014 08:53:13 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 3F2A32212F2; Mon, 22 Sep 2014 09:53:12 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 22 Sep 2014 09:48:52 -0600 Message-Id: <1411400934-7754-13-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1411400934-7754-1-git-send-email-sjg@chromium.org> References: <1411400934-7754-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 12/14] dm: omap: serial: Add driver model support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add driver model support to this driver, while retaining support for the legacy system. Driver model serial support is enabled with CONFIG_DM_SERIAL as usual. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- drivers/serial/Makefile | 1 + drivers/serial/serial_omap.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 drivers/serial/serial_omap.c diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 853a8c6..9ac3496 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_FSL_LPUART) += serial_lpuart.o obj-$(CONFIG_MXS_AUART) += mxs_auart.o obj-$(CONFIG_ARC_SERIAL) += serial_arc.o obj-$(CONFIG_TEGRA_SERIAL) += serial_tegra.o +obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_USB_TTY) += usbtty.o diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c new file mode 100644 index 0000000..6866b21 --- /dev/null +++ b/drivers/serial/serial_omap.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#ifdef CONFIG_OF_CONTROL +static const struct udevice_id omap_serial_ids[] = { + { .compatible = "ti,omap3-uart" }, + { } +}; + +static int omap_serial_ofdata_to_platdata(struct udevice *dev) +{ + struct ns16550_platdata *plat = dev_get_platdata(dev); + int ret; + + ret = ns16550_serial_ofdata_to_platdata(dev); + if (ret) + return ret; + plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + "clock-frequency", -1); + plat->reg_shift = 2; + + return 0; +} +#endif + +U_BOOT_DRIVER(serial_omap_ns16550) = { + .name = "serial_omap", + .id = UCLASS_SERIAL, +#ifdef CONFIG_OF_CONTROL + .of_match = omap_serial_ids, + .ofdata_to_platdata = omap_serial_ofdata_to_platdata, +#endif + .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), + .priv_auto_alloc_size = sizeof(struct NS16550), + .probe = ns16550_serial_probe, + .ops = &ns16550_serial_ops, + .flags = DM_FLAG_PRE_RELOC, +};