From patchwork Wed Feb 27 06:01:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 15110 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id BB99123E02 for ; Wed, 27 Feb 2013 05:54:35 +0000 (UTC) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by fiordland.canonical.com (Postfix) with ESMTP id 4701BA19199 for ; Wed, 27 Feb 2013 05:54:35 +0000 (UTC) Received: by mail-ve0-f175.google.com with SMTP id cy12so174468veb.34 for ; Tue, 26 Feb 2013 21:54:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=+kTbMCOHE3Dx8RK5SSs7dnwvM+ofbO+IMXJHWkWcNME=; b=fWzGatVgxls1x5Npsbe3N5zp0agEn3/z3aUlWM7+wG6HWDLewyk01JeUdwy4hrBar0 nW1QzvrerOQdNsqn+T1oCyqIMQhxTgtAgs52vW2Ex4nCXAO5gM9j5GSNuc4FphZAwu2a mYzglAER5wvjTxPpsHORW9fVWnLjwnpVTwfNlLR7s/vc+BRG6XhJWnX7hKoB+l+/0hpm 1pkIp1FzFCFYmh5P3siAQKDYbN5ef2HPPY0EDnXEEYaS/A0YaLGEfCsEc1/NW0AnOQhN 7vDZderZFoGfBALp/7tAku6m4isJYZwW33gcspa/BQAGsCJyKiVOpBCBJMd9/b2wEYnx TPvA== X-Received: by 10.52.18.148 with SMTP id w20mr384242vdd.8.1361944474773; Tue, 26 Feb 2013 21:54:34 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp150373veb; Tue, 26 Feb 2013 21:54:34 -0800 (PST) X-Received: by 10.66.219.134 with SMTP id po6mr5605729pac.175.1361944473442; Tue, 26 Feb 2013 21:54:33 -0800 (PST) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id h9si3778762paz.92.2013.02.26.21.54.32; Tue, 26 Feb 2013 21:54:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MIV000VS72TZ3F0@mailout2.samsung.com>; Wed, 27 Feb 2013 14:54:32 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 32.CA.18793.79F9D215; Wed, 27 Feb 2013 14:54:32 +0900 (KST) X-AuditID: cbfee68f-b7f6a6d000004969-34-512d9f97ce98 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AA.0D.03918.79F9D215; Wed, 27 Feb 2013 14:54:31 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MIV00KG172NXA10@mmp1.samsung.com>; Wed, 27 Feb 2013 14:54:31 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 3/4] S5P: Serial: Add fdt support to driver Date: Wed, 27 Feb 2013 11:31:58 +0530 Message-id: <1361944919-13384-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1361944919-13384-1-git-send-email-rajeshwari.s@samsung.com> References: <1361944919-13384-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsWyRsSkSnfGfN1Ag2N/WC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBltDVdZCzoUK34uGkfYwPjSrkuRk4OCQETiekfP7JA 2GISF+6tZ+ti5OIQEljKKNFwaRozTNH1P2dYIBKLGCU+7pwKVTWRSeJB31GwdjYBI4mtJ6cx gtgiAhISv/qvgtnMAjESr/f/YAOxhQWsJQ7vaQCbyiKgKrFnzScmEJtXwEPizc7lUNsUJI5N /coKYnMKeEocfbqEHcQWAqqZeP0J1Km32SR+L82CmCMg8W3yIaA4B1BcVmLTAagxkhIHV9xg mcAovICRYRWjaGpBckFxUnqRsV5xYm5xaV66XnJ+7iZGYDie/vesfwfj3QPWhxiTgcZNZJYS Tc4HhnNeSbyhsYm5qbGpmZGlpaUpacJK4rzyl2QChQTSE0tSs1NTC1KL4otKc1KLDzEycXBK NTCaKj949+tcFfec92cexqsVPemz/NIWKS7rEdzKlyZ+bQHHobJXQc0bOMzsw97bHdKRtrtm 22t1Jt7wS/JeGTFu++lbV19oaJ+ZwH54tnKfbcSGb475aZXzBEWtvKUqrVTO95r6rujVn21g P3nvqy/PtJymaSks2v5/+vbCMhGtF/v+v/UJSVZiKc5INNRiLipOBADzBVBYXQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsVy+t9jAd3p83UDDda8MbF4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmNHWdJGxoEO1 4uOmfYwNjCvluhg5OSQETCSu/znDAmGLSVy4t56ti5GLQ0hgEaPEx51ToZyJTBIP+o6CVbEJ GElsPTmNEcQWEZCQ+NV/FcxmFoiReL3/BxuILSxgLXF4TwMziM0ioCqxZ80nJhCbV8BD4s3O 5cwQ2xQkjk39ygpicwp4Shx9uoQdxBYCqpl4/QnLBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL 89L1kvNzNzGCw/2Z1A7GlQ0WhxgFOBiVeHgXXNIJFGJNLCuuzD3EKMHBrCTC+/EAUIg3JbGy KrUoP76oNCe1+BBjMtBVE5mlRJPzgbGYVxJvaGxibmpsamliYWJmSZqwkjgv46knAUIC6Ykl qdmpqQWpRTBbmDg4pRoYFwY3K5wsdxdbFnHQ6sGxWSu6uKddXixygO17aOikqK2i/2eH5f+o Efqr0r2N+YD3o92nFHWz3rZctGy4fibN4dxNgZnzJZwnNM3kjZR+v3fV512fV0ase7zj1BFr 3kmPWtcHvC6bzrmgzins6ZtQ77yeGEs1y7tXFdziRAoK4ha+2CbExfVVW4mlOCPRUIu5qDgR ABjpJ7C7AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm/yohE57twoQaSEDO57n1oRZQVU6TtJoVDe6LqJuHhHIkF8pxc1DwjW7I2uvE7biHagKGK This patch adds FDT support to the serial s5p driver. At present disabling the serial console (from the device tree) crashes U-Boot. Add checks for this case, so that execution can continue without a serial console. It also enables the serial_s5p driver recognize the silent_console option. Signed-off-by: Abhilash Kesavan Signed-off-by: Gabe Black Signed-off-by: Simon Glass Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- drivers/serial/serial_s5p.c | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 3c41242..4502ffb 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -24,16 +24,30 @@ #include #include #include +#include #include #include #include DECLARE_GLOBAL_DATA_PTR; +/* Information about a serial port */ +struct fdt_serial { + u32 base_addr; /* address of registers in physical memory */ + u8 port_id; /* uart port number */ + u8 enabled; /* 1 if enabled, 0 if disabled */ +} config = { + -1U +}; + static inline struct s5p_uart *s5p_get_base_uart(int dev_index) { +#ifdef CONFIG_OF_CONTROL + return (struct s5p_uart *)(config.base_addr); +#else u32 offset = dev_index * sizeof(struct s5p_uart); return (struct s5p_uart *)(samsung_get_base_uart() + offset); +#endif } /* @@ -69,6 +83,9 @@ void serial_setbrg_dev(const int dev_index) u32 baudrate = gd->baudrate; u32 val; + if (!config.enabled) + return; + val = uclk / baudrate; writel(val / 16 - 1, &uart->ubrdiv); @@ -87,6 +104,16 @@ int serial_init_dev(const int dev_index) { struct s5p_uart *const uart = s5p_get_base_uart(dev_index); +#if defined(CONFIG_SILENT_CONSOLE) && \ + defined(CONFIG_OF_CONTROL) && \ + !defined(CONFIG_SPL_BUILD) + if (fdtdec_get_config_int(gd->fdt_blob, "silent_console", 0)) + gd->flags |= GD_FLG_SILENT; +#endif + + if (!config.enabled) + return 0; + /* reset and enable FIFOs, set triggers to the maximum */ writel(0, &uart->ufcon); writel(0, &uart->umcon); @@ -129,6 +156,9 @@ int serial_getc_dev(const int dev_index) { struct s5p_uart *const uart = s5p_get_base_uart(dev_index); + if (!config.enabled) + return 0; + /* wait for character to arrive */ while (!(readl(&uart->utrstat) & 0x1)) { if (serial_err_check(dev_index, 0)) @@ -145,6 +175,9 @@ void serial_putc_dev(const char c, const int dev_index) { struct s5p_uart *const uart = s5p_get_base_uart(dev_index); + if (!config.enabled) + return; + /* wait for room in the tx FIFO */ while (!(readl(&uart->utrstat) & 0x2)) { if (serial_err_check(dev_index, 1)) @@ -165,6 +198,9 @@ int serial_tstc_dev(const int dev_index) { struct s5p_uart *const uart = s5p_get_base_uart(dev_index); + if (!config.enabled) + return 0; + return (int)(readl(&uart->utrstat) & 0x1); } @@ -207,8 +243,51 @@ DECLARE_S5P_SERIAL_FUNCTIONS(3); struct serial_device s5p_serial3_device = INIT_S5P_SERIAL_STRUCTURE(3, "s5pser3"); +#ifdef CONFIG_OF_CONTROL +int fdtdec_decode_console(int *index, struct fdt_serial *uart) +{ + const void *blob = gd->fdt_blob; + int node; + + node = fdtdec_next_alias(blob, "serial", COMPAT_SAMSUNG_EXYNOS5_SERIAL, + index); + if (node < 0) + return node; + + uart->base_addr = fdtdec_get_addr(blob, node, "reg"); + if (uart->base_addr == FDT_ADDR_T_NONE) + return -FDT_ERR_NOTFOUND; + + uart->port_id = fdtdec_get_int(blob, node, "id", -1); + uart->enabled = fdtdec_get_is_enabled(blob, node); + + return 0; +} +#endif + __weak struct serial_device *default_serial_console(void) { +#ifdef CONFIG_OF_CONTROL + int index = 0; + if (fdtdec_decode_console(&index, &config)) { + debug("Cannot decode default console node\n"); + return NULL; + } + + if (config.port_id == 0) + return &s5p_serial0_device; + else if (config.port_id == 1) + return &s5p_serial1_device; + else if (config.port_id == 2) + return &s5p_serial2_device; + else if (config.port_id == 3) + return &s5p_serial3_device; + else + debug("Unknown config.port_id: %d", config.port_id); + + return NULL; +#else + config.enabled = 1; #if defined(CONFIG_SERIAL0) return &s5p_serial0_device; #elif defined(CONFIG_SERIAL1) @@ -220,6 +299,7 @@ __weak struct serial_device *default_serial_console(void) #else #error "CONFIG_SERIAL? missing." #endif +#endif } void s5p_serial_initialize(void)