From patchwork Thu Apr 30 06:43:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 47757 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F4AC20553 for ; Thu, 30 Apr 2015 06:44:11 +0000 (UTC) Received: by wghm4 with SMTP id m4sf12378219wgh.2 for ; Wed, 29 Apr 2015 23:44:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=XwBdmS42wqRgZxX3e8p+W8iFgPv1XVzYIyFU8OJqW9c=; b=jVZvdM8wB17UZekcTVkSWpEsdV/iSETdST/6C2w4asGvE5a/kAsA0vIqo5osiN/3ny yZNUo3Um+IPjOULG1bKJXGJsiy6qYdSoLCahHyImvt7VsGb62Ud/LfKT8+wgxxrgCimN 6gQq+rHGFhhAlPDFD2tHbJhEtNEERfxHoSsUAPhOuENDv0yORWsZmLnCJbRX8G9KD2wL 7qpd/N4WQjil69syGLJc/aCp+pPne3t/B7yN5kcTm+lqGtlKuKyox+0GhpXIGuA3kPR5 xCz/imZCv05P+wA1Vpc/exWOeIpWk/ZkJY4N2zpWkjbpZ9L8mnwtDldj/QMBKyvE7cDL PGqw== X-Gm-Message-State: ALoCoQnLeVGDnxlu3S1PkEcXaZYsuVT+flq9Uw9h9ny9dYhqo5kDE6kZWMQUqI8h4jVBEH2KA7Y/ X-Received: by 10.112.162.228 with SMTP id yd4mr1650357lbb.8.1430376250322; Wed, 29 Apr 2015 23:44:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.70 with SMTP id 6ls309571las.14.gmail; Wed, 29 Apr 2015 23:44:10 -0700 (PDT) X-Received: by 10.152.7.97 with SMTP id i1mr2356876laa.49.1430376250179; Wed, 29 Apr 2015 23:44:10 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id jj4si1009416lbb.174.2015.04.29.23.44.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 23:44:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by layy10 with SMTP id y10so36931985lay.0 for ; Wed, 29 Apr 2015 23:44:09 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr2519916lad.56.1430376249753; Wed, 29 Apr 2015 23:44:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp2927224lbt; Wed, 29 Apr 2015 23:44:08 -0700 (PDT) X-Received: by 10.70.41.135 with SMTP id f7mr5233376pdl.113.1430376247781; Wed, 29 Apr 2015 23:44:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si2059311pas.144.2015.04.29.23.44.07 for ; Wed, 29 Apr 2015 23:44:07 -0700 (PDT) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750995AbbD3GoG (ORCPT ); Thu, 30 Apr 2015 02:44:06 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:32923 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbbD3GoF (ORCPT ); Thu, 30 Apr 2015 02:44:05 -0400 Received: by pacwv17 with SMTP id wv17so50834624pac.0 for ; Wed, 29 Apr 2015 23:44:05 -0700 (PDT) X-Received: by 10.68.65.38 with SMTP id u6mr5261811pbs.41.1430376245163; Wed, 29 Apr 2015 23:44:05 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.179]) by mx.google.com with ESMTPSA id l14sm1087093pdn.96.2015.04.29.23.43.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Apr 2015 23:44:03 -0700 (PDT) From: Jun Nie To: peter@hurleysoftware.com, linux@arm.linux.org.uk, Andrew.Jackson@arm.com, gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, shawn.guo@linaro.org, zte-lt@lists.linaro.org Cc: Jun Nie Subject: [PATCH v8 3/3] uart: pl011: polish registers offset handling Date: Thu, 30 Apr 2015 14:43:24 +0800 Message-Id: <1430376204-12267-3-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430376204-12267-1-git-send-email-jun.nie@linaro.org> References: <1430376204-12267-1-git-send-email-jun.nie@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jun.nie@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use enum definition for register offset look up table entry. Signed-off-by: Jun Nie Reviewed-by: Peter Hurley --- drivers/tty/serial/amba-pl011.c | 124 +++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 58 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index a63503f..9a620b8 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -67,7 +67,6 @@ #define AMBA_ISR_PASS_LIMIT 256 #define REG_NR 19 -#define IDX(x) ((x) >> 2) #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) #define UART_DUMMY_DR_RX (1 << 16) @@ -86,6 +85,26 @@ struct vendor_data { unsigned int (*get_fifosize)(struct amba_device *dev); }; +enum reg_idx { + REG_DR = 0, + REG_RSR, + REG_ST_DMAWM, + REG_LCRM, + REG_LCRL, + REG_FR = 6, + REG_LCRH_RX, + REG_ILPR, + REG_IBRD, + REG_FBRD, + REG_LCRH_TX, + REG_CR, + REG_IFLS, + REG_IMSC, + REG_RIS, + REG_MIS, + REG_ICR, + REG_DMACR, +}; #ifdef CONFIG_ARM_AMBA static unsigned int get_fifosize_arm(struct amba_device *dev) @@ -95,25 +114,21 @@ static unsigned int get_fifosize_arm(struct amba_device *dev) static u8 arm_reg[REG_NR] = { /* All registers offset are in order except LCRH as comment */ - [IDX(UART01x_DR)] = UART01x_DR, - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = UART01x_FR, - [IDX(UART011_LCRH_RX)] = UART011_LCRH, /* remapped */ - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = UART011_LCRH_TX, - [IDX(UART011_CR)] = UART011_CR, - [IDX(UART011_IFLS)] = UART011_IFLS, - [IDX(UART011_IMSC)] = UART011_IMSC, - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = UART011_MIS, - [IDX(UART011_ICR)] = UART011_ICR, - [IDX(UART011_DMACR)] = UART011_DMACR, + [REG_DR] = UART01x_DR, + [REG_RSR] = UART01x_RSR, + [REG_FR] = UART01x_FR, + [REG_LCRH_RX] = UART011_LCRH, /* remapped */ + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = UART011_LCRH_TX, + [REG_CR] = UART011_CR, + [REG_IFLS] = UART011_IFLS, + [REG_IMSC] = UART011_IMSC, + [REG_RIS] = UART011_RIS, + [REG_MIS] = UART011_MIS, + [REG_ICR] = UART011_ICR, + [REG_DMACR] = UART011_DMACR, }; static struct vendor_data vendor_arm = { @@ -136,25 +151,22 @@ static unsigned int get_fifosize_st(struct amba_device *dev) static u8 st_reg[REG_NR] = { /* All registers offset are in order */ - [IDX(UART01x_DR)] = UART01x_DR, - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = UART01x_FR, - [IDX(UART011_LCRH_RX)] = UART011_LCRH_RX, - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = UART011_LCRH_TX, - [IDX(UART011_CR)] = UART011_CR, - [IDX(UART011_IFLS)] = UART011_IFLS, - [IDX(UART011_IMSC)] = UART011_IMSC, - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = UART011_MIS, - [IDX(UART011_ICR)] = UART011_ICR, - [IDX(UART011_DMACR)] = UART011_DMACR, + [REG_DR] = UART01x_DR, + [REG_RSR] = UART01x_RSR, + [REG_ST_DMAWM] = ST_UART011_DMAWM, + [REG_FR] = UART01x_FR, + [REG_LCRH_RX] = ST_UART011_LCRH_RX, + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = UART011_LCRH_TX, + [REG_CR] = UART011_CR, + [REG_IFLS] = UART011_IFLS, + [REG_IMSC] = UART011_IMSC, + [REG_RIS] = UART011_RIS, + [REG_MIS] = UART011_MIS, + [REG_ICR] = UART011_ICR, + [REG_DMACR] = UART011_DMACR, }; static struct vendor_data vendor_st = { @@ -179,25 +191,21 @@ static unsigned int get_fifosize_zx(struct amba_device *dev) static u8 zx_reg[REG_NR] = { /* Registers offset are remapped from origin offset as in comment */ - [IDX(UART01x_DR)] = ZX_UART01x_DR, /* remapped */ - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = ZX_UART01x_FR, /* remapped */ - [IDX(UART011_LCRH_RX)] = UART011_LCRH_RX, - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = ZX_UART011_LCRH_TX, /* remapped */ - [IDX(UART011_CR)] = ZX_UART011_CR, /* remapped */ - [IDX(UART011_IFLS)] = ZX_UART011_IFLS, /* remapped */ - [IDX(UART011_IMSC)] = ZX_UART011_IMSC, /* remapped */ - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = ZX_UART011_MIS, /* remapped */ - [IDX(UART011_ICR)] = ZX_UART011_ICR, /* remapped */ - [IDX(UART011_DMACR)] = ZX_UART011_DMACR, /* remapped */ + [REG_DR] = ZX_UART01x_DR, /* remapped */ + [REG_RSR] = UART01x_RSR, + [REG_FR] = ZX_UART01x_FR, /* remapped */ + [REG_LCRH_RX] = UART011_LCRH_RX, + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = ZX_UART011_LCRH_TX, /* remapped */ + [REG_CR] = ZX_UART011_CR, /* remapped */ + [REG_IFLS] = ZX_UART011_IFLS, /* remapped */ + [REG_IMSC] = ZX_UART011_IMSC, /* remapped */ + [REG_RIS] = UART011_RIS, + [REG_MIS] = ZX_UART011_MIS, /* remapped */ + [REG_ICR] = ZX_UART011_ICR, /* remapped */ + [REG_DMACR] = ZX_UART011_DMACR, /* remapped */ }; static struct vendor_data vendor_zx = {