[v9,3/3] uart: pl011: polish registers offset handling

Message ID 1430730692-10615-4-git-send-email-jun.nie@linaro.org
State New
Headers show

Commit Message

Jun Nie May 4, 2015, 9:11 a.m.
Use enum definition for register offset look up table
entry.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/amba-pl011.c | 124 ++++++++++++++++++++++------------------
 1 file changed, 67 insertions(+), 57 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 79f6793..c5ccdf7 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -87,6 +87,27 @@  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 +116,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)]	= UART011_LCRH,
-	[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 +153,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)]		= ST_UART011_LCRH_RX,
-	[IDX(UART01x_ILPR)]		= UART01x_ILPR,
-	[IDX(UART011_IBRD)]		= UART011_IBRD,
-	[IDX(UART011_FBRD)]		= UART011_FBRD,
-	[IDX(ST_UART011_LCRH_TX)]	= ST_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]	= ST_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 +193,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 = {