From patchwork Fri Mar 1 10:16:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 15189 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 9B86423E0D for ; Fri, 1 Mar 2013 10:09:12 +0000 (UTC) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2357CA185D4 for ; Fri, 1 Mar 2013 10:09:12 +0000 (UTC) Received: by mail-ve0-f180.google.com with SMTP id jx10so2683160veb.39 for ; Fri, 01 Mar 2013 02:09:11 -0800 (PST) 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=Ju4DQi1YhyH5bPs9JGUurZeyX9rDA32uloC1wvOqgxU=; b=W3UG3NecuzEH59XJ5j5qTzo+hUcXzGmZOkEqSoPdUippX9LQBXcUw9Gw0XQmeMP/U5 CY6doLcXf5nSIKiJiadLm/FCs/aKEXDK2rPQEz0xJVCDIp6dtBJkYjHX52IF4jKjlZm9 3cpVdlUZMrQUGRMHHsH9dWO4DPCOGk57SE/ee4NQav1OrEoGnRB1JyOglNAea5pEFtCf 2sv/ipJxtk/CJ73MeX4tS3ZmDJ5Xx75B9FR95dNda4Y8MYiBAaIk0WWDtGzvzos0Wns7 heQe6xG0zGhZfNMOPri2z8nlJcnREr4Y9/o4ptGrg7WJ59QVumWPq3CdNgu9f0/5zGbo 8y2g== X-Received: by 10.52.88.237 with SMTP id bj13mr3328391vdb.75.1362132551627; Fri, 01 Mar 2013 02:09:11 -0800 (PST) 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.145.101 with SMTP id st5csp20742veb; Fri, 1 Mar 2013 02:09:10 -0800 (PST) X-Received: by 10.66.250.169 with SMTP id zd9mr18110733pac.134.1362132549088; Fri, 01 Mar 2013 02:09:09 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id z9si11898547pav.45.2013.03.01.02.09.08; Fri, 01 Mar 2013 02:09:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MIZ00IF8873N800@mailout4.samsung.com>; Fri, 01 Mar 2013 19:09:07 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id D4.F7.25214.34E70315; Fri, 01 Mar 2013 19:09:07 +0900 (KST) X-AuditID: cbfee68e-b7fa46d00000627e-68-51307e434b0e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 4E.B7.03918.34E70315; Fri, 01 Mar 2013 19:09:07 +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 <0MIZ00FVN86VUH70@mmp2.samsung.com>; Fri, 01 Mar 2013 19:09:07 +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 V2] S5P: Serial: Add fdt support to driver Date: Fri, 01 Mar 2013 15:46:13 +0530 Message-id: <1362132974-15460-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1362132974-15460-1-git-send-email-rajeshwari.s@samsung.com> References: <1362132974-15460-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsWyRsSkWte5ziDQoHeBksXD9TdZLDqOtDBa TDn8hcXi25ZtjBZv93ayO7B6zG64yOJx59oeNo+zd3YwevRtWcUYwBLFZZOSmpNZllqkb5fA lXFt31O2gtOqFRM+uTQw3pfrYuTkkBAwkbi08i4LhC0mceHeejYQW0hgKaPEvF3MMDWN9y4w dTFyAcWnM0p8PTSJDcKZyCTxecsMsG42ASOJrSenMYLYIgISEr/6r4LZzAIxEq/3/wCbKixg J3HqWQ/YVBYBVYkPn1eAxXkFPCQOPetkg9imIHFs6lfWLkYODk4BT4kZq7hBTCGgktNnU0HW Sgg0s0tcOruXBWKMgMS3yYdYQGokBGQlNh2AullS4uCKGywTGIUXMDKsYhRNLUguKE5KLzLS K07MLS7NS9dLzs/dxAgM4tP/nvXtYLx5wPoQYzLQuInMUqLJ+cAoyCuJNzQ2MTc1NjUzsrS0 NCVNWEmcV/6STKCQQHpiSWp2ampBalF8UWlOavEhRiYOTqkGxnIlsYMf9/+5/XrDivuL7/NH eFw/r6Puk134oYJpz5SuU+ckFt/Xz/p9peTgvTNbtGewb4w8cfGssabeZDHxP3tuuG4z2R9j duzT5AXd62tKEs57+99e3V+X8YVL2/L63debzHb9OHZFJNBc81Wma/Y1r8sB1xzWNjD+YroY m2i2WPpjv6Zm/EYlluKMREMt5qLiRADwmWCTeAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsVy+t9jQV3nOoNAg90NkhYP199kseg40sJo MeXwFxaLb1u2MVq83dvJ7sDqMbvhIovHnWt72DzO3tnB6NG3ZRVjAEtUA6NNRmpiSmqRQmpe cn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtBmJYWyxJxSoFBAYnGxkr4d pgmhIW66FjCNEbq+IUFwPUYGaCBhDWPGtX1P2QpOq1ZM+OTSwHhfrouRk0NCwESi8d4FJghb TOLCvfVsXYxcHEIC0xklvh6aBOVMZJL4vGUGC0gVm4CRxNaT0xhBbBEBCYlf/VfBbGaBGInX +3+wgdjCAnYSp571MIPYLAKqEh8+rwCL8wp4SBx61skGsU1B4tjUr6xdjBwcnAKeEjNWcYOY QkAlp8+mTmDkXcDIsIpRNLUguaA4KT3XUK84Mbe4NC9dLzk/dxMjOEqeSe1gXNlgcYhRgINR iYd3ZY1+oBBrYllxZe4hRgkOZiUR3so3QCHelMTKqtSi/Pii0pzU4kOMyUA3TWSWEk3OB0Zw Xkm8obGJuamxqaWJhYmZJWnCSuK8jKeeBAgJpCeWpGanphakFsFsYeLglGpgLP3tqFFXmvn3 t/OHdcx97+6u3c7PmzFRObulLO5zWGmB+cOQXYs9FkyN19ggOmt/9AsbvlLLQMeOmBzjl5f4 5zhs5ZeLst9RuCVRMNNmw5OPhZdXbTt86PfvQ0/qt2h0vZ27Snl95VL5OQybriw1EJr6RWij yrszLQbPcn1m/jgtOWOC5/Wlf5RYijMSDbWYi4oTASRSAbHWAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm2DwG8oBEh2Zw8pZLV7vJvgAt9/6b8D7zW2k2E8H4T53Kdoy7RW6Xiybss09RGqf/02K/2 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 drivers/serial/serial_s5p.c | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 3c41242..4502ffb 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -24,16 +24,30 @@ #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 = { + -1U +}; + 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 +83,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 +104,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 +156,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 +175,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 +198,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 +243,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 = fdtdec_next_alias(blob, "serial", COMPAT_SAMSUNG_EXYNOS5_SERIAL, + index); + 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 (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 +299,7 @@ __weak struct serial_device *default_serial_console(void) #else #error "CONFIG_SERIAL? missing." #endif +#endif } void s5p_serial_initialize(void)