From patchwork Fri May 17 11:03:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 17015 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A4E45238F0 for ; Fri, 17 May 2013 10:55:59 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id k14sf475715qcv.5 for ; Fri, 17 May 2013 03:55:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe; bh=oDP6H8C5eo4RVy/i3MpT9lm2PeN0iYy1vfVwSadVih0=; b=lvxSW4OXONuLSU+meqprB2rQEQVCDS4soZvLpcdQ7/0Gd7r9ggs2odJd55xp6TLwEH GuqUvo5Cc7EaECibq6GahFbC9IkEmFub9EnnHGe7DjbdACCki46MUxTVumkziKmGYK8+ poQuyuPNMraeTkV8N6fRZfEQuKsB7LZaRwcPg1T3zzImHMF5qlA2QxkjOMFg9fPzTp7O H4pHlinSmpPBNF0UD/RLTyMtDfWn20lTy+A15UaTDptd7DCOQ5RMPxuMOqY7dn7sP1g3 kxA4L4cC0aursC4FudlmTkEDX2eIv6UttdhB+U5jbnHhgVqoymUFhhNQXaH4sBCc4V6g nDhA== X-Received: by 10.224.36.66 with SMTP id s2mr27882114qad.6.1368788118440; Fri, 17 May 2013 03:55:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.105 with SMTP id b9ls1808494qeb.34.gmail; Fri, 17 May 2013 03:55:18 -0700 (PDT) X-Received: by 10.220.172.2 with SMTP id j2mr29449471vcz.17.1368788118290; Fri, 17 May 2013 03:55:18 -0700 (PDT) Received: from mail-ve0-x235.google.com (mail-ve0-x235.google.com [2607:f8b0:400c:c01::235]) by mx.google.com with ESMTPS id gr7si5607122vdc.64.2013.05.17.03.55.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 03:55:18 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::235; Received: by mail-ve0-f181.google.com with SMTP id pb11so3713621veb.26 for ; Fri, 17 May 2013 03:55:18 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr950710vcb.8.1368788118081; Fri, 17 May 2013 03:55:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp103571vcs; Fri, 17 May 2013 03:55:17 -0700 (PDT) X-Received: by 10.66.253.34 with SMTP id zx2mr49389701pac.35.1368788116601; Fri, 17 May 2013 03:55:16 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id hb2si7805538pac.147.2013.05.17.03.55.16 for ; Fri, 17 May 2013 03:55:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MMX00MB3VNHBMO0@mailout3.samsung.com> for patches@linaro.org; Fri, 17 May 2013 19:55:15 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id B8.0D.08825.39C06915; Fri, 17 May 2013 19:55:15 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-08-51960c938d0f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 61.74.16109.39C06915; Fri, 17 May 2013 19:55:15 +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 <0MMX00F8CVNTEW90@mmp1.samsung.com>; Fri, 17 May 2013 19:55:15 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, u-boot-review@google.com Subject: [PATCH 3/4 V5] S5P: Serial: Add fdt support to driver Date: Fri, 17 May 2013 16:33:20 +0530 Message-id: <1368788601-11221-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1368788601-11221-1-git-send-email-rajeshwari.s@samsung.com> References: <1368788601-11221-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsWyRsSkWncyz7RAg9NnjS06jrQwWkw5/IXF 4tuWbYwWy19vZLd4u7eT3YHVY3bDRRaPBZtKPe5c28PmcfbODkaPvi2rGANYo7hsUlJzMstS i/TtErgyXly7w1YwUb1i0p/DTA2MX+W7GDk5JARMJG4vbmCHsMUkLtxbz9bFyMUhJLCUUaKz fSUjTNH5rUfBbCGBRYwSs28IQhRNZJLYtPUpE0iCTcBIYuvJaWBFIgISEr/6r4LZzAJREt+7 L4FtEBawk7h+6QhQPQc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rU0sTAxsyRNWEmc90CrdaCQQHpiSWp2ampBahHMFiYOTqkGRoeS G5EdV+0279rOGFPIwG3O/nXDjFaOl9ndH1e4aWSUxT90ivmteqK9pOfIlZIZ5g4b99akWgkL Op7ri6vb1dXwxqFxwrY3NpVpoq8ZapZdu6ebuj9M4KZowuM/u375MO9Lu/lnyYqyW1PsuUqO mbLpXA6oMOp89mN/lp6o2OaTp1Yvu/v4txJLcUaioRZzUXEiAHqqwgjbAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQkBej17b8Z/sVXRfbGEjjSIPKdj5VxNq5V4pAXJODFloHHaJ4rhasomLk3HzxA/qRhCyrC3 X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- Changes in V2: - None Changes in V3: - Moved driver config structure to data section. - Changed silent_console to silent-console. - Did put a check for base address before doing fdt decoding. Changes in V4: - None Changes in V5: - None drivers/serial/serial_s5p.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 3c41242..55ef2bf 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -24,16 +24,28 @@ #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 __attribute__ ((section(".data"))); + 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 +81,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 +102,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 +154,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 +173,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 +196,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 +241,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 = fdt_path_offset(blob, "console"); + 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 ((!config.base_addr) && (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 +297,7 @@ __weak struct serial_device *default_serial_console(void) #else #error "CONFIG_SERIAL? missing." #endif +#endif } void s5p_serial_initialize(void)