From patchwork Fri Mar 15 10:43:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Birje X-Patchwork-Id: 227953 X-Patchwork-Delegate: promsoft@gmail.com 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 74A1D2C009B for ; Fri, 15 Mar 2013 21:36:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 546414A163; Fri, 15 Mar 2013 11:36:44 +0100 (CET) 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 kW5eFI7rvJ3o; Fri, 15 Mar 2013 11:36:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C795F4A168; Fri, 15 Mar 2013 11:36:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10BE24A168 for ; Fri, 15 Mar 2013 11:36:41 +0100 (CET) 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 8m0TxP03EbKv for ; Fri, 15 Mar 2013 11:36:40 +0100 (CET) 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 mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTP id 58B874A163 for ; Fri, 15 Mar 2013 11:36:38 +0100 (CET) Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJP00CIZ6SON550@mailout4.samsung.com> for u-boot@lists.denx.de; Fri, 15 Mar 2013 19:36:34 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 2E.28.02019.2B9F2415; Fri, 15 Mar 2013 19:36:34 +0900 (KST) X-AuditID: cbfee690-b7f656d0000007e3-bd-5142f9b2b0c8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9F.93.17838.2B9F2415; Fri, 15 Mar 2013 19:36:34 +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 <0MJP00BN96ST6910@mmp1.samsung.com> for u-boot@lists.denx.de; Fri, 15 Mar 2013 19:36:34 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Date: Fri, 15 Mar 2013 16:13:08 +0530 Message-id: <1363344188-6276-1-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsWyRsSkSnfTT6dAgxWvLSze7u1kd2D0OHtn B2MAYxSXTUpqTmZZapG+XQJXxqlPzYwF99Uq5p7rYW5gvCzfxcjBISFgIjH5ml8XIyeQKSZx 4d56ti5GLg4hgaWMEgeOP2CESJhIPOzbyQSRWMQocebmK1YIZxWTxMypb8Gq2ASMJLaenAZm iwhISPzqvwpmMwvESLze/4MNZJuwgJ3Eg4/GIGEWAVWJOdsegpXwCrhL3Hozlx1imYLEsalf weZLCOxhk2hoOMoM0SAg8W3yIRaIq2UlNh1ghqiXlDi44gbLBEbBBYwMqxhFUwuSC4qT0otM 9IoTc4tL89L1kvNzNzECQ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FGckGmoxFxUnAgBoiHhvnQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: patches@linaro.org Subject: [U-Boot] [PATCH 3/4 V3] S5P: Serial: Add fdt support to driver 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 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. 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)