From patchwork Wed Apr 29 01:38:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 47700 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 391CB2121F for ; Wed, 29 Apr 2015 01:39:15 +0000 (UTC) Received: by wiun10 with SMTP id n10sf10533431wiu.1 for ; Tue, 28 Apr 2015 18:39:14 -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=przgK/n93YzJuyGC8NBgAxB1h+H3NozbTOeTBe1FCfg=; b=RYatywBTBPWde5BoMcN+iZd4Fkg2Do2v8Xgfq41uEYoL4qZhoUSTW6lA+n1Opo0RhL ZpWHTmxnuE03p9OtGrmCSStdw0YKdH177gi+M/rcOj48kQSRqXlAHesVVWzNMVpSE1fF xmm2QVbUpUsRhIfpXdQuje/BMJxrKO/kvevR6Yi3h1cOxTFGh/gruraWK0m6mRI96Yfg 2eJjT7WrSxPZMzPvhyiufxGoyeMXLhERpJdsfEWPX0J7JuDaFOrzXKKF2CPcDstvk62U B7Ag9v/w0oeb/ONVL8TsJR5DRy6lK1u3xmv0lED1ZnVxqFahfhzl9mn15qgYCLfEye2s 15mA== X-Gm-Message-State: ALoCoQmm9XJZOTQOK7OxehKGmwtv//o1+xxW4Por7N+A2EfVYq3U3R1poe/p7nhpzCThObITmnvW X-Received: by 10.180.74.197 with SMTP id w5mr11600662wiv.5.1430271554561; Tue, 28 Apr 2015 18:39:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.81 with SMTP id v17ls182003laz.2.gmail; Tue, 28 Apr 2015 18:39:14 -0700 (PDT) X-Received: by 10.112.220.34 with SMTP id pt2mr16947747lbc.81.1430271554399; Tue, 28 Apr 2015 18:39:14 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id lf3si13825100lbc.136.2015.04.28.18.39.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2015 18:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labbd9 with SMTP id bd9so9391383lab.2 for ; Tue, 28 Apr 2015 18:39:14 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr6561399laj.88.1430271554246; Tue, 28 Apr 2015 18:39:14 -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 l1csp2215008lbt; Tue, 28 Apr 2015 18:39:13 -0700 (PDT) X-Received: by 10.70.38.33 with SMTP id d1mr36741343pdk.99.1430271552403; Tue, 28 Apr 2015 18:39:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si3572827pdm.195.2015.04.28.18.39.11 for ; Tue, 28 Apr 2015 18:39:12 -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 S1031401AbbD2BjL (ORCPT ); Tue, 28 Apr 2015 21:39:11 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:32968 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031366AbbD2BjK (ORCPT ); Tue, 28 Apr 2015 21:39:10 -0400 Received: by pdbnk13 with SMTP id nk13so12883429pdb.0 for ; Tue, 28 Apr 2015 18:39:10 -0700 (PDT) X-Received: by 10.66.102.34 with SMTP id fl2mr37210863pab.40.1430271549889; Tue, 28 Apr 2015 18:39:09 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.178]) by mx.google.com with ESMTPSA id fp3sm23638236pdb.52.2015.04.28.18.39.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Apr 2015 18:39:08 -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 v7 3/3] uart: pl011: polish registers offset handling Date: Wed, 29 Apr 2015 09:38:38 +0800 Message-Id: <1430271518-27364-3-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430271518-27364-1-git-send-email-jun.nie@linaro.org> References: <1430271518-27364-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.49 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 --- 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 6db5ee4..6ab3143 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 = {