[U-Boot] [PATCH] gpio: mvmfp: support newer MFP bit definitions

Rob Herring robh at kernel.org
Mon Mar 23 23:56:58 CET 2015


From: Xiang Wang <wangx at marvell.com>

1. The bits 11..10 for mfp driver strength is only valid for
aspen and old xscale family, for newer Marvell chip, this range
has been moved to 12..11.
2. add sleep bit support

Signed-off-by: Xiang Wang <wangx at marvell.com>
[robh: rebase to current mainline]
Signed-off-by: Rob Herring <robh at kernel.org>
---
 drivers/gpio/mvmfp.c | 14 ++------
 include/mvmfp.h      | 90 +++++++++++++++++++++++++++++++---------------------
 2 files changed, 55 insertions(+), 49 deletions(-)

diff --git a/drivers/gpio/mvmfp.c b/drivers/gpio/mvmfp.c
index 97bbe99..43ecf66 100644
--- a/drivers/gpio/mvmfp.c
+++ b/drivers/gpio/mvmfp.c
@@ -43,18 +43,8 @@ void mfp_config(u32 *mfp_cfgs)
 
 		/* Write a mfg register as per configuration */
 		val = 0;
-		if (cfg_val & MFP_AF_FLAG)
-			/* Abstract and program Afternate-Func Selection */
-			val |= cfg_val & MFP_AF_MASK;
-		if (cfg_val & MFP_EDGE_FLAG)
-			/* Abstract and program Edge configuration */
-			val |= cfg_val & MFP_LPM_EDGE_MASK;
-		if (cfg_val & MFP_DRIVE_FLAG)
-			/* Abstract and program Drive configuration */
-			val |= cfg_val & MFP_DRIVE_MASK;
-		if (cfg_val & MFP_PULL_FLAG)
-			/* Abstract and program Pullup/down configuration */
-			val |= cfg_val & MFP_PULL_MASK;
+		if (cfg_val & MFP_VALUE_MASK)
+			val |= cfg_val & MFP_VALUE_MASK;
 
 		writel(val, p_mfpr);
 	} while (1);
diff --git a/include/mvmfp.h b/include/mvmfp.h
index 961d799..e61e92d 100644
--- a/include/mvmfp.h
+++ b/include/mvmfp.h
@@ -21,61 +21,77 @@
 /*
  * MFP configuration is represented by a 32-bit unsigned integer
  */
-#define MFP(_off, _pull, _pF, _drv, _dF, _edge, _eF, _afn, _aF) ( \
+#ifdef CONFIG_MVMFP_V2
+#define MFP(_off, _pull, _drv, _slp, _edge, _sleep, _afn) ( \
+	/* bits 31..16 - MFP Register Offset */	(((_off) & 0xffff) << 16) | \
+	/* bits 15..13 - Run Mode Pull State */	(((_pull) & 0x7) << 13) | \
+	/* bit  12..11 - Driver Strength */	(((_drv) & 0x3) << 11) | \
+	/* bits 10     - pad driver */		(((_slp) & 0x1) << 10) | \
+	/* bit  09..07 - sleep mode */		(((_sleep) & 0xe) << 6) | \
+	/* bits 06..04 - Edge Detection */	(((_edge) & 0x7) << 4) | \
+	/* bits 03     - sleep mode */		(((_sleep) & 0x1) << 3) | \
+	/* bits 02..00 - Alt-fun select */	((_afn) & 0x7))
+#else
+#define MFP(_off, _pull, _drv, _slp, _edge, _sleep, _afn) ( \
 	/* bits 31..16 - MFP Register Offset */	(((_off) & 0xffff) << 16) | \
 	/* bits 15..13 - Run Mode Pull State */	(((_pull) & 0x7) << 13) | \
 	/* bit  12     - Unused */ \
 	/* bits 11..10 - Driver Strength */	(((_drv) & 0x3) << 10) | \
-	/* bit  09     - Pull State flag */	(((_pF) & 0x1) << 9) | \
-	/* bit  08     - Drv-strength flag */	(((_dF) & 0x1) << 8) | \
-	/* bit  07     - Edge-det flag */	(((_eF) & 0x1) << 7) | \
+	/* bit  09..07 - sleep mode */		(((_sleep) & 0xe) << 6) | \
 	/* bits 06..04 - Edge Detection */	(((_edge) & 0x7) << 4) | \
-	/* bits 03..00 - Alt-fun flag */	(((_aF) & 0x1) << 3) | \
-	/* bits Alternate-fun select */		((_afn) & 0x7))
+	/* bits 03     - sleep mode */		(((_sleep) & 0x1) << 3) | \
+	/* bits 02..00 - Alt-fun select */	((_afn) & 0x7))
+#endif
 
 /*
  * to facilitate the definition, the following macros are provided
  *
  * 				    offset, pull,pF, drv,dF, edge,eF ,afn,aF
  */
-#define MFP_OFFSET_MASK		MFP(0xffff,    0,0,    0,0,     0,0,   0,0)
-#define MFP_REG(x)		MFP(x,         0,0,    0,0,     0,0,   0,0)
+#define MFP_OFFSET_MASK		MFP(0xffff,    0,    0,   0,   0,   0,   0)
+#define MFP_REG(x)		MFP(x,         0,    0,   0,   0,   0,   0)
 #define MFP_REG_GET_OFFSET(x)	((x & MFP_OFFSET_MASK) >> 16)
 
-#define MFP_AF_FLAG		MFP(0x0000,    0,0,    0,0,     0,0,   0,1)
-#define MFP_DRIVE_FLAG		MFP(0x0000,    0,0,    0,1,     0,0,   0,0)
-#define MFP_EDGE_FLAG		MFP(0x0000,    0,0,    0,0,     0,1,   0,0)
-#define MFP_PULL_FLAG		MFP(0x0000,    0,1,    0,0,     0,0,   0,0)
+#define MFP_AF0			MFP(0x0000,    0,    0,   0,   0,   0,   0)
+#define MFP_AF1			MFP(0x0000,    0,    0,   0,   0,   0,   1)
+#define MFP_AF2			MFP(0x0000,    0,    0,   0,   0,   0,   2)
+#define MFP_AF3			MFP(0x0000,    0,    0,   0,   0,   0,   3)
+#define MFP_AF4			MFP(0x0000,    0,    0,   0,   0,   0,   4)
+#define MFP_AF5			MFP(0x0000,    0,    0,   0,   0,   0,   5)
+#define MFP_AF6			MFP(0x0000,    0,    0,   0,   0,   0,   6)
+#define MFP_AF7			MFP(0x0000,    0,    0,   0,   0,   0,   7)
+#define MFP_AF_MASK		MFP(0x0000,    0,    0,   0,   0,   0,   7)
+
+#define MFP_SLEEP_CTRL2		MFP(0x0000,    0,    0,   0,   0,   1,   0)
+#define MFP_SLEEP_DIR		MFP(0x0000,    0,    0,   0,   0,   2,   0)
+#define MFP_SLEEP_DATA		MFP(0x0000,    0,    0,   0,   0,   4,   0)
+#define MFP_SLEEP_CTRL		MFP(0x0000,    0,    0,   0,   0,   8,   0)
+#define MFP_SLEEP_MASK		MFP(0x0000,    0,    0,   0,   0, 0xf,   0)
 
-#define MFP_AF0			MFP(0x0000,    0,0,    0,0,     0,0,   0,1)
-#define MFP_AF1			MFP(0x0000,    0,0,    0,0,     0,0,   1,1)
-#define MFP_AF2			MFP(0x0000,    0,0,    0,0,     0,0,   2,1)
-#define MFP_AF3			MFP(0x0000,    0,0,    0,0,     0,0,   3,1)
-#define MFP_AF4			MFP(0x0000,    0,0,    0,0,     0,0,   4,1)
-#define MFP_AF5			MFP(0x0000,    0,0,    0,0,     0,0,   5,1)
-#define MFP_AF6			MFP(0x0000,    0,0,    0,0,     0,0,   6,1)
-#define MFP_AF7			MFP(0x0000,    0,0,    0,0,     0,0,   7,1)
-#define MFP_AF_MASK		MFP(0x0000,    0,0,    0,0,     0,0,   7,0)
+#define MFP_LPM_EDGE_NONE	MFP(0x0000,    0,    0,   0,   4,   0,   0)
+#define MFP_LPM_EDGE_RISE	MFP(0x0000,    0,    0,   0,   1,   0,   0)
+#define MFP_LPM_EDGE_FALL	MFP(0x0000,    0,    0,   0,   2,   0,   0)
+#define MFP_LPM_EDGE_BOTH	MFP(0x0000,    0,    0,   0,   3,   0,   0)
+#define MFP_LPM_EDGE_MASK	MFP(0x0000,    0,    0,   0,   7,   0,   0)
 
-#define MFP_LPM_EDGE_NONE	MFP(0x0000,    0,0,    0,0,     0,1,   0,0)
-#define MFP_LPM_EDGE_RISE	MFP(0x0000,    0,0,    0,0,     1,1,   0,0)
-#define MFP_LPM_EDGE_FALL	MFP(0x0000,    0,0,    0,0,     2,1,   0,0)
-#define MFP_LPM_EDGE_BOTH	MFP(0x0000,    0,0,    0,0,     3,1,   0,0)
-#define MFP_LPM_EDGE_MASK	MFP(0x0000,    0,0,    0,0,     3,0,   0,0)
+#define MFP_SLP_DI		MFP(0x0000,    0,    0,   1,   0,   0,   0)
 
-#define MFP_DRIVE_VERY_SLOW	MFP(0x0000,    0,0,    0,1,     0,0,   0,0)
-#define MFP_DRIVE_SLOW		MFP(0x0000,    0,0,    1,1,     0,0,   0,0)
-#define MFP_DRIVE_MEDIUM	MFP(0x0000,    0,0,    2,1,     0,0,   0,0)
-#define MFP_DRIVE_FAST		MFP(0x0000,    0,0,    3,1,     0,0,   0,0)
-#define MFP_DRIVE_MASK		MFP(0x0000,    0,0,    3,0,     0,0,   0,0)
+#define MFP_DRIVE_VERY_SLOW	MFP(0x0000,    0,    0,   0,   0,   0,   0)
+#define MFP_DRIVE_SLOW		MFP(0x0000,    0,    1,   0,   0,   0,   0)
+#define MFP_DRIVE_MEDIUM	MFP(0x0000,    0,    2,   0,   0,   0,   0)
+#define MFP_DRIVE_FAST		MFP(0x0000,    0,    3,   0,   0,   0,   0)
+#define MFP_DRIVE_MASK		MFP(0x0000,    0,    3,   0,   0,   0,   0)
 
-#define MFP_PULL_NONE		MFP(0x0000,    0,1,    0,0,     0,0,   0,0)
-#define MFP_PULL_LOW		MFP(0x0000,    1,1,    0,0,     0,0,   0,0)
-#define MFP_PULL_HIGH		MFP(0x0000,    2,1,    0,0,     0,0,   0,0)
-#define MFP_PULL_BOTH		MFP(0x0000,    3,1,    0,0,     0,0,   0,0)
-#define MFP_PULL_FLOAT		MFP(0x0000,    4,1,    0,0,     0,0,   0,0)
-#define MFP_PULL_MASK		MFP(0x0000,    7,0,    0,0,     0,0,   0,0)
+#define MFP_PULL_NONE		MFP(0x0000,    0,    0,   0,   0,   0,   0)
+#define MFP_PULL_LOW		MFP(0x0000,    5,    0,   0,   0,   0,   0)
+#define MFP_PULL_HIGH		MFP(0x0000,    6,    0,   0,   0,   0,   0)
+#define MFP_PULL_BOTH		MFP(0x0000,    7,    0,   0,   0,   0,   0)
+#define MFP_PULL_FLOAT		MFP(0x0000,    4,    0,   0,   0,   0,   0)
+#define MFP_PULL_MASK		MFP(0x0000,    7,    0,   0,   0,   0,   0)
 
+#define MFP_VALUE_MASK		(MFP_PULL_MASK | MFP_DRIVE_MASK | MFP_SLP_DI \
+				| MFP_LPM_EDGE_MASK | MFP_SLEEP_MASK \
+				| MFP_AF_MASK)
 #define MFP_EOC			0xffffffff	/* indicates end-of-conf */
 
 /* Functions */
-- 
2.1.0



More information about the U-Boot mailing list