From patchwork Fri Mar 15 10:38:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 15374 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 BC46123EA8 for ; Fri, 15 Mar 2013 10:32:25 +0000 (UTC) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by fiordland.canonical.com (Postfix) with ESMTP id 5666EA184FF for ; Fri, 15 Mar 2013 10:32:25 +0000 (UTC) Received: by mail-vc0-f173.google.com with SMTP id gd11so1106971vcb.4 for ; Fri, 15 Mar 2013 03:32:24 -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=gN2MOWtlLgY02WVGLrQFGP5R+9OvCL6ROitvgawVe+I=; b=krHFTKTuc0a8wPQ490eHupNJX/Blch2vCjaTsk075ApGMz9DTtTb9ebMPQVrAmIhgv 1Vyy6OAo6XdDVGq50g0AJXNhvioq6HNBKlGGYEIrEOrU704uq029zSX2QUsR8olWFaB7 FqoEMyEXRKwT6JtwuP8+9UgqxYr75Exm/vxaSYzJyTJQ0H2PnlxceSuJhlDvU0or1Mxh My1hovOqahee6k+swhRr0XDVn1+f2bEP6wiRFJne+8PtYz8UNhUtVBKziKQS2ITzSgsK n9FE85Tzqw8jG+meSWCs+uK0z6YN/hlM+iHco1sVonnUECbxcauCnoENN+LqExORNZEz Fksg== X-Received: by 10.221.0.199 with SMTP id nn7mr5704660vcb.14.1363343544807; Fri, 15 Mar 2013 03:32:24 -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.58.127.98 with SMTP id nf2csp113293veb; Fri, 15 Mar 2013 03:32:24 -0700 (PDT) X-Received: by 10.68.184.66 with SMTP id es2mr14570865pbc.217.1363343542933; Fri, 15 Mar 2013 03:32:22 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id xm3si9756669pbc.16.2013.03.15.03.32.22; Fri, 15 Mar 2013 03:32:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning rajeshwari.s@samsung.com does not designate 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning rajeshwari.s@samsung.com does not designate 203.254.224.25 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJP00GQK6LLP221@mailout2.samsung.com>; Fri, 15 Mar 2013 19:32:18 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 2C.25.12250.1B8F2415; Fri, 15 Mar 2013 19:32:17 +0900 (KST) X-AuditID: cbfee691-b7f5f6d000002fda-b8-5142f8b18cd8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 38.C2.17838.1B8F2415; Fri, 15 Mar 2013 19:32:17 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJP00JXM6LMDY90@mmp2.samsung.com>; Fri, 15 Mar 2013 19:32:17 +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: Fri, 15 Mar 2013 16:08:48 +0530 Message-id: <1363343929-6190-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1363343929-6190-1-git-send-email-rajeshwari.s@samsung.com> References: <1363343929-6190-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsWyRsSkSnfjD6dAg+cfbSwerr/JYtFxpIXR YsrhLywW37ZsY7R4u7eT3YHVY3bDRRaPO9f2sHmcvbOD0aNvyyrGAJYoLpuU1JzMstQifbsE roxTn5oZC+6rVcw918PcwHhZvouRg0NCwETiw0qBLkZOIFNM4sK99WxdjFwcQgJLGSXWLtjH ApEwkWjp+skEkZjOKLHlBURCSGAik8TD+YEgNpuAkcTWk9MYQWwRAQmJX/1XwWxmgRiJ1/t/ sIHYwgLWEof3NDCD2CwCqhJTtn8Dq+EVcJe49PEuM8QyBYljU7+ygticAh4S7W2HWUAOFQKq 2XspEOQGCYFudokr02+zQ8wRkPg2+RALxDOyEpsOQI2RlDi44gbLBEbhBYwMqxhFUwuSC4qT 0otM9YoTc4tL89L1kvNzNzECw/j0v2cTdzDeP2B9iDEZaNxEZinR5HxgHOSVxBsamxlZmJqY GhuZW5qRJqwkzqveYh0oJJCeWJKanZpakFoUX1Sak1p8iJGJg1OqgfFop5PNq4MbBPTkvTut 1ojMU5pVHCbGeeiwbLz0hID1tvzOPc+U7rtuCxJab318y/x58lP7Jqnf4LGZXWQwd013UzCn 4NXsTh3HX3HHJiqHPbpZNM33VND65D/hOXbcWVt3cl1OMGjXjGl7uYBb+KPdvrjWq/fU9Y1r 37Swm835P3nWKalL/kosxRmJhlrMRcWJABYOQId5AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsVy+t9jQd2NP5wCDfadNrZ4uP4mi0XHkRZG iymHv7BYfNuyjdHi7d5OdgdWj9kNF1k87lzbw+Zx9s4ORo++LasYA1iiGhhtMlITU1KLFFLz kvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4A2KymUJeaUAoUCEouLlfTt ME0IDXHTtYBpjND1DQmC6zEyQAMJaxgzTn1qZiy4r1Yx91wPcwPjZfkuRk4OCQETiZaun0wQ tpjEhXvr2boYuTiEBKYzSmx5sY8FJCEkMJFJ4uH8QBCbTcBIYuvJaYwgtoiAhMSv/qtgNrNA jMTr/T/YQGxhAWuJw3samEFsFgFViSnbv4HV8Aq4S1z6eJcZYpmCxLGpX1lBbE4BD4n2tsNA uziAdrlL7L0UOIGRdwEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2M4Dh5JrWDcWWDxSFG AQ5GJR7eA/0OgUKsiWXFlbmHGCU4mJVEeD29HAOFeFMSK6tSi/Lji0pzUosPMSYDHTWRWUo0 OR8Yw3kl8YbGJuamxqaWJhYmZpakCSuJ8x5otQ4UEkhPLEnNTk0tSC2C2cLEwSnVwLjv0PVt tdErBQReMShM+bJpy4SGC2cDtsrq/49uvPBSMXwlg5fLhcr5x+ZrCnvc9HvlcYnlX/3vnQzP FC6yyzx9Mdfm8Iuq9GPX7XdvdN4wY/m1sCu/p6v1Fl3P5TEv/CopHCJ6+7Xf3SU9qpYuoaZJ fs8Z8rqCLVv/Wr5/a6V+omCaYtHXAylKLMUZiYZazEXFiQCbAqk+1wIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQkTbV550+rqml2qgrFqikEn8LXfiK7iR7E1ALMUsVhznYzbMafs+goonCT+8U00bB3X1zo1 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. 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)