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 Shinde X-Patchwork-Id: 15377 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 DAEDB23EA8 for ; Fri, 15 Mar 2013 10:36:38 +0000 (UTC) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by fiordland.canonical.com (Postfix) with ESMTP id 6F9F7A18871 for ; Fri, 15 Mar 2013 10:36:38 +0000 (UTC) Received: by mail-ve0-f170.google.com with SMTP id 14so2510055vea.29 for ; Fri, 15 Mar 2013 03:36:38 -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 :x-brightmail-tracker:x-brightmail-tracker:dlp-filter:x-mtr :x-cfilter-loop:x-gm-message-state; bh=gN2MOWtlLgY02WVGLrQFGP5R+9OvCL6ROitvgawVe+I=; b=Dm7BNH+//MBI6U2DCz88r+1S+tr8i1TYHTKLzL+B5W5IP1I7+/r/05uOMuoZZVQrnJ NlS07mSzmOsa9DZNTj2HAmz+208yJnMXy7XQi+QaL7URDWuILykxe04DRNo4JhtRMvew KCGQxDWqKTh2FskAbrXQMIyPpfBVOW0rpRmhKf+oa+lBby9JBGO+p/dqeODg949yrLjG BYnXc1yqJg8iGMf7YO4XqL+w0sUZgUEUzRV2hOKFmn3dY9dTZAtvjADKviAOORWxHIJL fcjt7s55e3bJb+D2LbdbBU22mW97BW3Jo+sjo+TeXbYCiV+SskJ6ibwANrf1oMLssvN9 Fy2w== X-Received: by 10.220.39.69 with SMTP id f5mr6152363vce.45.1363343797918; Fri, 15 Mar 2013 03:36:37 -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 nf2csp113433veb; Fri, 15 Mar 2013 03:36:37 -0700 (PDT) X-Received: by 10.68.234.100 with SMTP id ud4mr14604852pbc.8.1363343796852; Fri, 15 Mar 2013 03:36:36 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id tx10si9702339pbc.212.2013.03.15.03.36.36; Fri, 15 Mar 2013 03:36:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning rajeshwari.s@samsung.com does not designate 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning rajeshwari.s@samsung.com does not designate 203.254.224.33 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJP00EW86SQZ001@mailout3.samsung.com>; Fri, 15 Mar 2013 19:36:35 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id EC.36.12250.2B9F2415; Fri, 15 Mar 2013 19:36:34 +0900 (KST) X-AuditID: cbfee691-b7f5f6d000002fda-d1-5142f9b2206b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 16.9F.13494.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>; Fri, 15 Mar 2013 19:36:34 +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 V3] S5P: Serial: Add fdt support to driver 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+NgFtrILMWRmVeSWpSXmKPExsWyRsSkWnfTT6dAg/0fLSwerr/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlnPrUzFhwX61i7rke5gbGy/JdjJwcEgImEl2PljBC 2GISF+6tZwOxhQSWMkosfBUBU/Pz/E6mLkYuoPgiRolFZ1ayQDgTmSS29h8C62YTMJLYenIa mC0iICHxq/8qmM0sECPxev8PoKkcHMICdhIPPhqDhFkEVCXmbHsIVsIr4C5x681cdohlChLH pn5lBZkvIXCATWLfv15miAYBiW+TD7GAzJEQkJXYdIAZol5S4uCKGywTGAUXMDKsYhRNLUgu KE5KLzLVK07MLS7NS9dLzs/dxAgMrtP/nk3cwXj/gPUhxmSgcROZpUST84HBmVcSb2hsZmRh amJqbGRuaUaasJI4r3qLdaCQQHpiSWp2ampBalF8UWlOavEhRiYOTqkGRp1/dypypAMmPDv5 2Tnh4n7R+cwc5/c8MBP4sVV63ipD8eZvOVxu/e7JK9WfTwyVaDt+q/pq+oyqtuml7/wvu4kb F9lPs3huJ9Lv8aDZ6WGTE6P1gj+16stinnrs99uodClY52NHyuus5RLrO6r6cv8/nuIUvCk/ 93Ow0IqN9VUblv3veflvqRJLcUaioRZzUXEiAB6stYtEAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42I5/e+xgO6mn06BBj82alo8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzDj1qZmx4L5a xdxzPcwNjJfluxg5OSQETCR+nt/JBGGLSVy4t56ti5GLQ0hgEaPEojMrWSCciUwSW/sPMYJU sQkYSWw9OQ3MFhGQkPjVfxXMZhaIkXi9/wdQNweHsICdxIOPxiBhFgFViTnbHoKV8Aq4S9x6 M5cdYpmCxLGpX1knMHIvYGRYxSiaWpBcUJyUnmukV5yYW1yal66XnJ+7iREcvM+kdzCuarA4 xCjAwajEw+vw0DFQiDWxrLgy9xCjBAezkgjvx4tOgUK8KYmVValF+fFFpTmpxYcYk4G2T2SW Ek3OB0ZWXkm8obGJuamxqaWJhYmZJWnCSuK8B1utA4UE0hNLUrNTUwtSi2C2MHFwSjUwTpfd ZmPE/bikuCxsxj2tJnmRG0cijv3dLD2bMfp20NH+qjYPhiM11ie+Td5YWJNS8HBFRsDTkM9n jL7JZHIUMSk9v7DvRD/zmmuaoUIln1Zuf79pn9rE/zHl2Wd++f0+vKPEN6IgOqqc0V5tAhPX HaazQcuePNIJv7haf3vjVYGKmbf1ZSNOKrEUZyQaajEXFScCAI5rb4CiAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmvK4VVcJwYX4VWjqSR7yDsW3NgYNibqSVU4oHC5NvSEWKoGiCnIcNTFUuJmDxRTnUF5nXK 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)