From patchwork Tue Apr 2 06:46:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 15799 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 07BFF23E00 for ; Tue, 2 Apr 2013 06:39:41 +0000 (UTC) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by fiordland.canonical.com (Postfix) with ESMTP id A4430A1A2B0 for ; Tue, 2 Apr 2013 06:39:40 +0000 (UTC) Received: by mail-ve0-f178.google.com with SMTP id db10so87139veb.23 for ; Mon, 01 Apr 2013 23:39:40 -0700 (PDT) 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=8UWEj7wU4JnQarrkDV/8cxIwSkgEPH/sGYpG25Bdm4w=; b=kzlYVMK4CpN03XOzkIMOVpsYUhHZcCn7VDVRzzeCO10Fy+8zevYafxKiVd3prKJzBX 98dYOiSQfIuNpGR4vlzGulWqqG3FV+EgCisGlIXe807N1fWx6q8LCl2OMscbsj6ZG+En GlAqTqN0dx2Hf+hfCG3BOJqq9u+ObIA9efKYFftWxOcVchyKHxV6elN5QATRX83wWPCd z/CNDPw6qerBByiCsYDiwRgZe4GWYeJqhTLHr2JgvE9HQZC3otlxtRyFL0TFTLXFPJKk r4Bu50YdAh6dyIjHXbqXx2XwoqjcEzIiWx4Yj5ZB4eBqYONPava2DkWgV1VJccAf9X9d Ynjw== X-Received: by 10.58.223.134 with SMTP id qu6mr8746494vec.35.1364884780143; Mon, 01 Apr 2013 23:39:40 -0700 (PDT) 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.59.4.204 with SMTP id cg12csp112071ved; Mon, 1 Apr 2013 23:39:39 -0700 (PDT) X-Received: by 10.66.123.105 with SMTP id lz9mr23456193pab.137.1364884778158; Mon, 01 Apr 2013 23:39:38 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id ed2si376636pbb.275.2013.04.01.23.39.37; Mon, 01 Apr 2013 23:39:38 -0700 (PDT) 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 epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKM005I67TZ8MA0@mailout2.samsung.com>; Tue, 02 Apr 2013 15:39:36 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 3B.53.07735.82D7A515; Tue, 02 Apr 2013 15:39:36 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-81-515a7d288815 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id CD.A5.13494.82D7A515; Tue, 02 Apr 2013 15:39:36 +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 <0MKM00N1L7TS0X70@mmp1.samsung.com>; Tue, 02 Apr 2013 15:39:36 +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 V4] S5P: Serial: Add fdt support to driver Date: Tue, 02 Apr 2013 12:16:26 +0530 Message-id: <1364885187-2237-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1364885187-2237-1-git-send-email-rajeshwari.s@samsung.com> References: <1364885187-2237-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsWyRsSkSlejNirQYNdiHYuH62+yWHQcaWG0 mHL4C4vFty3bGC3e7u1kd2D1mN1wkcXjzrU9bB5n7+xg9OjbsooxgCWKyyYlNSezLLVI3y6B K+P5g2VMBd/VKlpu+TcwPpbvYuTkkBAwkVjQcZ8NwhaTuHBvPZDNxSEksJRR4tvRBhaYoglT d7FDJBYxSiz/th+qaiKTxKfrl9lBqtgEjCS2npzGCGKLCEhI/Oq/CmYzC8RIvN7/A2yFsICd xJRTk5lBbBYBVYlvl96C2bwC7hJ75txnhdimIHFs6lcwm1PAQ2Ll5uNgvUJANe+3r4OqaWaX WNjMDjFHQOLb5ENAl3IAxWUlNh1ghiiRlDi44gbLBEbhBYwMqxhFUwuSC4qT0ouM9IoTc4tL 89L1kvNzNzECA/n0v2d9OxhvHrA+xJgMNG4is5Rocj4wEvJK4g2NzYwsTE1MjY3MLc1IE1YS 51VrsQ4UEkhPLEnNTk0tSC2KLyrNSS0+xMjEwSnVwGgTMU2auSdqzcdfi9bz9ExlSPk6yepU ReDU9kMteTKPGk9/Xen5JKlU4sdb8Zq/yhbKdQeOf6hVn5/2zMRdSuy+QRfn72MzDha88Hhk wmlyYvO70ocXLms2PeCbd9p4d0no0syFX56nFBq/NVAtipI8qmmxxFNJTG/mp1nv0hNq87Jc KnqmvFFiKc5INNRiLipOBAADiHOJegIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsVy+t9jAV2N2qhAg9tTVCwerr/JYtFxpIXR YsrhLywW37ZsY7R4u7eT3YHVY3bDRRaPO9f2sHmcvbOD0aNvyyrGAJaoBkabjNTElNQihdS8 5PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKDNSgpliTmlQKGAxOJiJX07 TBNCQ9x0LWAaI3R9Q4LgeowM0EDCGsaM5w+WMRV8V6toueXfwPhYvouRk0NCwERiwtRd7BC2 mMSFe+vZuhi5OIQEFjFKLP+2H8qZyCTx6fplsCo2ASOJrSenMYLYIgISEr/6r4LZzAIxEq/3 /2ADsYUF7CSmnJrMDGKzCKhKfLv0FszmFXCX2DPnPivENgWJY1O/gtmcAh4SKzcfB+sVAqp5 v30d6wRG3gWMDKsYRVMLkguKk9JzjfSKE3OLS/PS9ZLzczcxgiPlmfQOxlUNFocYBTgYlXh4 HeZEBgqxJpYVV+YeYpTgYFYS4d2qGxUoxJuSWFmVWpQfX1Sak1p8iDEZ6KqJzFKiyfnAKM4r iTc0NjE3NTa1NLEwMbMkTVhJnPdgq3WgkEB6YklqdmpqQWoRzBYmDk6pBsachC1JVzgO1Qdv Sn+svyHj4MWFIay+Bz0nJL/cqHBlI/e1UNfWVME1UdLyttbfPQ+Vmrx5e/ZWzhumlS7SIdp1 JXfu7Zn/NtfVZ2t6397HD66qFvJM2f60bdLVq9MT/C3OOMzcyuzOxmfxesllxdyKDU3Ssu9u Vzr0P3TKZjI45lG3etdbRkMlluKMREMt5qLiRABw8JsV2AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQn1OKb2zht1LRRyrN2mOAd2OTeJEWeyEDA71gFUiiCAQdhATpXRlM1FUSu+KyDB/D46/Rgb 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 --- 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 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)