Skip to contentSkip to conversation

OMAP3: Clean up MMC code

PATCH New Dirk Behme 1 participant 1 message Feb 20, 2009 MMC, SD and SDIO

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH v3 7/7 OMAP3: Clean up MMC code

Clean up OMAP3 MMC code:

* Convert register access to struct & readx/writex style
* Replace hardcode values by macros
* Remove macro defined twice

---
Changes in v3:

Rebase after MMC framework merge to mainline. No functional change.

This patch is against U-Boot master branch, commit e5e88c3614b79b54719905f66aefb51f9494bc1f "ARM:OMAP3 Change mmc_init to mmc_legacy_init"

This patch replaces v2 version of this patch

http://lists.denx.de/pipermail/u-boot/2009-February/047454.html

All other patches of OMAP3 v2 patch series

http://lists.denx.de/pipermail/u-boot/2009-February/047450.html

still apply cleanly to above master branch and are unchanged.

 drivers/mmc/omap3_mmc.c                   |  145 +++++++++++++++---------------
 include/asm-arm/arch-omap3/mmc_host_def.h |   64 ++++++++-----
 include/asm-arm/arch-omap3/omap3.h        |    3 
 3 files changed, 118 insertions(+), 94 deletions(-)
include/asm-arm/arch-omap3/mmc_host_def.h +41 -23
Index: u-boot-main/include/asm-arm/arch-omap3/mmc_host_def.h
===================================================================
@@ -25,30 +25,50 @@
 #ifndef MMC_HOST_DEF_H
 #define MMC_HOST_DEF_H
 
+/* T2 Register definitions */
+#define T2_BASE			0x48002000
+
+typedef struct t2 {
+	unsigned char res1[0x274];
+	unsigned int devconf0;		/* 0x274 */
+	unsigned char res2[0x2A8];
+	unsigned int pbias_lite;	/* 0x520 */
+} t2_t;
+
+#define MMCSDIO1ADPCLKISEL		(1 << 24)
+
+#define PBIASLITEPWRDNZ0		(1 << 1)
+#define PBIASSPEEDCTRL0			(1 << 2)
+#define PBIASLITEPWRDNZ1		(1 << 9)
+
 /*
  * OMAP HSMMC register definitions
  */
-#define OMAP_HSMMC_SYSCONFIG		(*(unsigned int *) 0x4809C010)
-#define OMAP_HSMMC_SYSSTATUS		(*(unsigned int *) 0x4809C014)
-#define OMAP_HSMMC_CON			(*(unsigned int *) 0x4809C02C)
-#define OMAP_HSMMC_BLK			(*(unsigned int *) 0x4809C104)
-#define OMAP_HSMMC_ARG			(*(unsigned int *) 0x4809C108)
-#define OMAP_HSMMC_CMD			(*(unsigned int *) 0x4809C10C)
-#define OMAP_HSMMC_RSP10		(*(unsigned int *) 0x4809C110)
-#define OMAP_HSMMC_RSP32		(*(unsigned int *) 0x4809C114)
-#define OMAP_HSMMC_RSP54		(*(unsigned int *) 0x4809C118)
-#define OMAP_HSMMC_RSP76		(*(unsigned int *) 0x4809C11C)
-#define OMAP_HSMMC_DATA			(*(unsigned int *) 0x4809C120)
-#define OMAP_HSMMC_PSTATE		(*(unsigned int *) 0x4809C124)
-#define OMAP_HSMMC_HCTL			(*(unsigned int *) 0x4809C128)
-#define OMAP_HSMMC_SYSCTL		(*(unsigned int *) 0x4809C12C)
-#define OMAP_HSMMC_STAT			(*(unsigned int *) 0x4809C130)
-#define OMAP_HSMMC_IE			(*(unsigned int *) 0x4809C134)
-#define OMAP_HSMMC_CAPA			(*(unsigned int *) 0x4809C140)
+#define OMAP_HSMMC_BASE		0x4809C000
 
-/* T2 Register definitions */
-#define CONTROL_DEV_CONF0		(*(unsigned int *) 0x48002274)
-#define CONTROL_PBIAS_LITE		(*(unsigned int *) 0x48002520)
+typedef struct hsmmc {
+	unsigned char res1[0x10];
+	unsigned int sysconfig;		/* 0x10 */
+	unsigned int sysstatus;		/* 0x14 */
+	unsigned char res2[0x14];
+	unsigned int con;		/* 0x2C */
+	unsigned char res3[0xD4];
+	unsigned int blk;		/* 0x104 */
+	unsigned int arg;		/* 0x108 */
+	unsigned int cmd;		/* 0x10C */
+	unsigned int rsp10;		/* 0x110 */
+	unsigned int rsp32;		/* 0x114 */
+	unsigned int rsp54;		/* 0x118 */
+	unsigned int rsp76;		/* 0x11C */
+	unsigned int data;		/* 0x120 */
+	unsigned int pstate;		/* 0x124 */
+	unsigned int hctl;		/* 0x128 */
+	unsigned int sysctl;		/* 0x12C */
+	unsigned int stat;		/* 0x130 */
+	unsigned int ie;		/* 0x134 */
+	unsigned char res4[0x8];
+	unsigned int capa;		/* 0x140 */
+} hsmmc_t;
 
 /*
  * OMAP HS MMC Bit definitions
@@ -159,8 +179,6 @@ typedef struct {
 } mmc_card_data;
 
 #define mmc_reg_out(addr, mask, val)\
-	(addr) = (((addr)) & (~(mask))) | ((val) & (mask));
-#define mmc_reg_out(addr, mask, val)\
-	(addr) = (((addr)) & (~(mask))) | ((val) & (mask));
+	writel((readl(addr) & (~(mask))) | ((val) & (mask)), (addr))
 
 #endif /* MMC_HOST_DEF_H */
drivers/mmc/omap3_mmc.c +74 -71

268 lines not on this page · raw message

include/asm-arm/arch-omap3/omap3.h +3 -0
Index: u-boot-main/include/asm-arm/arch-omap3/omap3.h
===================================================================
@@ -206,6 +206,8 @@ typedef struct gpio {
 #define VAUX2_DEDICATED		0x79
 #define VAUX3_DEV_GRP		0x7A
 #define VAUX3_DEDICATED		0x7D
+#define VMMC1_DEV_GRP		0x82
+#define VMMC1_DEDICATED		0x85
 #define VPLL2_DEV_GRP		0x8E
 #define VPLL2_DEDICATED		0x91
 #define VDAC_DEV_GRP		0x96
@@ -227,5 +229,6 @@ typedef struct gpio {
 #define VAUX3_VSEL_28		0x03
 #define VPLL2_VSEL_18		0x05
 #define VDAC_VSEL_18		0x03
+#define VMMC1_VSEL_30		0x02
 
 #endif