From patchwork Sun Jul 15 02:44:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 1198361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 682F33FC4C for ; Sun, 15 Jul 2012 02:57:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SqEwa-0000x9-Aw; Sun, 15 Jul 2012 02:52:24 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SqEqd-0008VS-BV for linux-arm-kernel@lists.infradead.org; Sun, 15 Jul 2012 02:46:34 +0000 Received: by weyr3 with SMTP id r3so3441842wey.36 for ; Sat, 14 Jul 2012 19:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:user-agent:date:from:to:cc:subject:references :content-disposition; bh=uyGWT0mFWAr40+6l+9ff42IAayMoWM1ofROQGelBYvI=; b=hS4+FXgxxxWaLmOr20/4Q0ivrvJtscs8ePKX37nNXyjpRJXFHjGDfEFvw1IUAAdYei v1JPpK7QMtepjkn5bMVLWP57BmpRrkJCXyPsIRwJt2EFyC58SDSR8kfIrAsTZxscV5ol qK98lzmxFZolSU3yPSGClHyabQc23Brwlic1nJ1ZGiGqEGHLldAPPmdu6WnlVHU50V4p RW7TVTVIa/MTmqOUq0g+mQF3ZkmLjLt1mcQFby0bpJWNyYuQyKWJNip3vo7mkDZ635kx DNDuI84Kdnxjq8UMByD6BNuPWQ2yRNlJpp/MThwuNS5nqaALa6Fca0O+hT7SZgpkzgke ZsRw== Received: by 10.216.90.19 with SMTP id d19mr3454736wef.113.1342320372147; Sat, 14 Jul 2012 19:46:12 -0700 (PDT) Received: from raptus.dandreoli.com (178-85-163-250.dynamic.upc.nl. [178.85.163.250]) by mx.google.com with ESMTPS id cl8sm13065364wib.10.2012.07.14.19.46.10 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 Jul 2012 19:46:11 -0700 (PDT) Received: by raptus.dandreoli.com (Postfix, from userid 1000) id 247E737B201; Sun, 15 Jul 2012 04:46:11 +0200 (CEST) Message-Id: <20120715024610.831894961@gmail.com> User-Agent: quilt/0.60-1 Date: Sun, 15 Jul 2012 04:44:17 +0200 From: Domenico Andreoli To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 09/12] ARM: Decompressor support for AMBA PL010 UARTs References: <20120715024408.747946928@gmail.com> Content-Disposition: inline; filename=decomp-console-uart-amba-pl010.patch X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (cavokz[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Domenico Andreoli , Russell King - ARM Linux , Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Domenico Andreoli Very easy implementation of the AMBA PL010 driver. That drv->devdata masked by macro pl010_decomp_base() is exactly the Nth element of the array of "things" in the console data. In this case the "things" in that array are bare base addresses. This is how the console data definition in the board file may look: static const unsigned long decomp_console[] __decomp_archdata = { 0xa0000, 0xb0000, 0xc0000, 0xd0000, }; DECOMP_CONSOLE_MACH(SOMEMACH, "amba-pl011", decomp_console); Signed-off-by: Domenico Andreoli --- drivers/tty/serial/amba-pl010.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) Index: b/drivers/tty/serial/amba-pl010.c =================================================================== --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -832,6 +833,56 @@ static void __exit pl010_exit(void) module_init(pl010_init); module_exit(pl010_exit); +#define pl010_decomp_base(_drv) (*(unsigned long *) (_drv)->devdata) + +static int __decomp_arch pl010_decomp_probe(struct decomp_console_drv *drv) +{ + unsigned long base = pl010_decomp_base(drv); + volatile uint32_t *cr; + + /* this driver doesn't support probing of the base address */ + if (!base) + return -EINVAL; + + cr = (volatile uint32_t *) (base + UART010_CR); + return (*cr & UART01x_CR_UARTEN) ? 0 : -1; +} + +static void __decomp_arch pl010_decomp_putc(struct decomp_console_drv *drv, int ch) +{ + unsigned long base = pl010_decomp_base(drv); + volatile uint32_t *fr, *dr; + + fr = (volatile uint32_t *) (base + UART01x_FR); + while (*fr & UART01x_FR_TXFF) + barrier(); + + dr = (volatile uint32_t *) (base + UART01x_DR); + *dr = ch; +} + +static void __decomp_arch pl010_decomp_flush(struct decomp_console_drv *drv) +{ + unsigned long base = pl010_decomp_base(drv); + volatile uint32_t *fr; + + fr = (volatile uint32_t *) (base + UART01x_FR); + while (*fr & UART01x_FR_BUSY) + barrier(); +} + +static const char pl010_dt_compat[][16] __decomp_archdata = { + "amba-pl010", + "", +}; + +DECOMP_CONSOLE_START("ttyAM") + .probe = pl010_decomp_probe, + .putc = pl010_decomp_putc, + .flush = pl010_decomp_flush, + .dt_compat = pl010_dt_compat, +DECOMP_CONSOLE_END + MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd"); MODULE_DESCRIPTION("ARM AMBA serial port driver"); MODULE_LICENSE("GPL");