linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [mmc-omap] Add support for 16-bit and 32-bit registers
@ 2009-10-03 21:57 Cory Maccarrone
  0 siblings, 0 replies; 12+ messages in thread
From: Cory Maccarrone @ 2009-10-03 21:57 UTC (permalink / raw)
  To: linux-omap

The omap850 and omap730 use 16-bit registers instead of 32-bit, requiring
a modification of the register addresses in the mmc-omap driver.  To
make this as portable as possible, I made the following changes:

* Moved register address offsets from drivers/mmc/host/omap.c to
  drivers/mmc/host/omap.h
* Implemented a lookup table for 16-bit and 32-bit register offsets
* Added a reg_size field in the mmc_omap_host structure
* Added code in mmc_omap_probe() to populate the reg_size
  field based on processor in use
* Added inline function to return the register offset based on
  the register size and register name
* Modified mmc-omap driver to use the new inline function to call out
  register names

This change should allow the omap7xx-series of processors to correctly
utilize the MMC driver.

Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
---
 drivers/mmc/host/omap.c |   42 +++++------------
 drivers/mmc/host/omap.h |  115 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mmc/host/omap.h

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index e7a331d..b82f935 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -37,31 +37,7 @@
 #include <mach/mux.h>
 #include <mach/fpga.h>

-#define	OMAP_MMC_REG_CMD	0x00
-#define	OMAP_MMC_REG_ARGL	0x04
-#define	OMAP_MMC_REG_ARGH	0x08
-#define	OMAP_MMC_REG_CON	0x0c
-#define	OMAP_MMC_REG_STAT	0x10
-#define	OMAP_MMC_REG_IE		0x14
-#define	OMAP_MMC_REG_CTO	0x18
-#define	OMAP_MMC_REG_DTO	0x1c
-#define	OMAP_MMC_REG_DATA	0x20
-#define	OMAP_MMC_REG_BLEN	0x24
-#define	OMAP_MMC_REG_NBLK	0x28
-#define	OMAP_MMC_REG_BUF	0x2c
-#define OMAP_MMC_REG_SDIO	0x34
-#define	OMAP_MMC_REG_REV	0x3c
-#define	OMAP_MMC_REG_RSP0	0x40
-#define	OMAP_MMC_REG_RSP1	0x44
-#define	OMAP_MMC_REG_RSP2	0x48
-#define	OMAP_MMC_REG_RSP3	0x4c
-#define	OMAP_MMC_REG_RSP4	0x50
-#define	OMAP_MMC_REG_RSP5	0x54
-#define	OMAP_MMC_REG_RSP6	0x58
-#define	OMAP_MMC_REG_RSP7	0x5c
-#define	OMAP_MMC_REG_IOSR	0x60
-#define	OMAP_MMC_REG_SYSC	0x64
-#define	OMAP_MMC_REG_SYSS	0x68
+#include "omap.h"

 #define	OMAP_MMC_STAT_CARD_ERR		(1 << 14)
 #define	OMAP_MMC_STAT_CARD_IRQ		(1 << 13)
@@ -77,8 +53,10 @@
 #define	OMAP_MMC_STAT_CARD_BUSY		(1 <<  2)
 #define	OMAP_MMC_STAT_END_OF_CMD	(1 <<  0)

-#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base +
OMAP_MMC_REG_##reg)
-#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val),
(host)->virt_base + OMAP_MMC_REG_##reg)
+#define OMAP_MMC_REG(host,
reg)		mmc_omap_get_register(host->reg_size, OMAP_MMC_REG_##reg)
+
+#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base +
OMAP_MMC_REG(host, reg))
+#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val),
(host)->virt_base + OMAP_MMC_REG(host, reg))

 /*
  * Command types
@@ -167,6 +145,8 @@ struct mmc_omap_host {
 	spinlock_t		clk_lock;     /* for changing enabled state */
 	unsigned int            fclk_enabled:1;

+	unsigned		reg_size:1;
+
 	struct omap_mmc_platform_data *pdata;
 };

@@ -679,9 +659,9 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
 	host->data->bytes_xfered += n;

 	if (write) {
-		__raw_writesw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_writesw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	} else {
-		__raw_readsw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_readsw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	}
 }

@@ -899,7 +879,7 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host,
struct mmc_data *data)
 	int dst_port = 0;
 	int sync_dev = 0;

-	data_addr = host->phys_base + OMAP_MMC_REG_DATA;
+	data_addr = host->phys_base + OMAP_MMC_REG(host, DATA);
 	frame = data->blksz;
 	count = sg_dma_len(sg);

@@ -1490,6 +1470,8 @@ static int __init mmc_omap_probe(struct
platform_device *pdev)
 		}
 	}

+	host->reg_size = (cpu_is_omap7xx() ? OMAP_MMC_REG_SIZE_2 :
OMAP_MMC_REG_SIZE_4);
+
 	return 0;

 err_plat_cleanup:
diff --git a/drivers/mmc/host/omap.h b/drivers/mmc/host/omap.h
new file mode 100644
index 0000000..9a52203
--- /dev/null
+++ b/drivers/mmc/host/omap.h
@@ -0,0 +1,115 @@
+/*
+ *  linux/drivers/mmc/host/omap.h
+ *
+ *  Copyright (C) 2009 Cory Maccarrone <darkstar6262@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MMC_MMC_OMAP_H
+#define MMC_MMC_OMAP_H
+
+/* MMC registers used for omap-mmc driver */
+enum {
+	OMAP_MMC_REG_CMD = 0,
+	OMAP_MMC_REG_ARGL,
+	OMAP_MMC_REG_ARGH,
+	OMAP_MMC_REG_CON,
+	OMAP_MMC_REG_STAT,
+	OMAP_MMC_REG_IE,
+	OMAP_MMC_REG_CTO,
+	OMAP_MMC_REG_DTO,
+	OMAP_MMC_REG_DATA,
+	OMAP_MMC_REG_BLEN,
+	OMAP_MMC_REG_NBLK,
+	OMAP_MMC_REG_BUF,
+	OMAP_MMC_REG_SDIO,
+	OMAP_MMC_REG_REV,
+	OMAP_MMC_REG_RSP0,
+	OMAP_MMC_REG_RSP1,
+	OMAP_MMC_REG_RSP2,
+	OMAP_MMC_REG_RSP3,
+	OMAP_MMC_REG_RSP4,
+	OMAP_MMC_REG_RSP5,
+	OMAP_MMC_REG_RSP6,
+	OMAP_MMC_REG_RSP7,
+	OMAP_MMC_REG_IOSR,
+	OMAP_MMC_REG_SYSC,
+	OMAP_MMC_REG_SYSS,
+};
+
+/* There are two known register sizes, 2-byte and 4-byte. */
+enum {
+	OMAP_MMC_REG_SIZE_2 = 0,
+	OMAP_MMC_REG_SIZE_4,
+};
+
+#define OMAP_MMC_MAX_REG	25
+#define OMAP_MMC_MAX_REG_SIZES	2
+
+/* MMC register table for 2 or 4-byte register sizes */
+static u8 omap_mmc_reg_map[OMAP_MMC_MAX_REG_SIZES][OMAP_MMC_MAX_REG] = {
+	[OMAP_MMC_REG_SIZE_2] = {
+		[OMAP_MMC_REG_CMD]	= 0x00,
+		[OMAP_MMC_REG_ARGL]	= 0x02,
+		[OMAP_MMC_REG_ARGH]	= 0x04,
+		[OMAP_MMC_REG_CON]	= 0x06,
+		[OMAP_MMC_REG_STAT]	= 0x08,
+		[OMAP_MMC_REG_IE]	= 0x0a,
+		[OMAP_MMC_REG_CTO]	= 0x0c,
+		[OMAP_MMC_REG_DTO]	= 0x0e,
+		[OMAP_MMC_REG_DATA]	= 0x10,
+		[OMAP_MMC_REG_BLEN]	= 0x12,
+		[OMAP_MMC_REG_NBLK]	= 0x14,
+		[OMAP_MMC_REG_BUF]	= 0x16,
+		[OMAP_MMC_REG_SDIO]	= 0x1a,
+		[OMAP_MMC_REG_REV]	= 0x1e,
+		[OMAP_MMC_REG_RSP0]	= 0x20,
+		[OMAP_MMC_REG_RSP1]	= 0x22,
+		[OMAP_MMC_REG_RSP2]	= 0x24,
+		[OMAP_MMC_REG_RSP3]	= 0x26,
+		[OMAP_MMC_REG_RSP4]	= 0x28,
+		[OMAP_MMC_REG_RSP5]	= 0x2a,
+		[OMAP_MMC_REG_RSP6]	= 0x2c,
+		[OMAP_MMC_REG_RSP7]	= 0x2e,
+		[OMAP_MMC_REG_IOSR]	= 0x30,
+		[OMAP_MMC_REG_SYSC]	= 0x32,
+		[OMAP_MMC_REG_SYSS]	= 0x34,
+	},
+	[OMAP_MMC_REG_SIZE_4] = {
+		[OMAP_MMC_REG_CMD]	= 0x00,
+		[OMAP_MMC_REG_ARGL]	= 0x04,
+		[OMAP_MMC_REG_ARGH]	= 0x08,
+		[OMAP_MMC_REG_CON]	= 0x0c,
+		[OMAP_MMC_REG_STAT]	= 0x10,
+		[OMAP_MMC_REG_IE]	= 0x14,
+		[OMAP_MMC_REG_CTO]	= 0x18,
+		[OMAP_MMC_REG_DTO]	= 0x1c,
+		[OMAP_MMC_REG_DATA]	= 0x20,
+		[OMAP_MMC_REG_BLEN]	= 0x24,
+		[OMAP_MMC_REG_NBLK]	= 0x28,
+		[OMAP_MMC_REG_BUF]	= 0x2c,
+		[OMAP_MMC_REG_SDIO]	= 0x34,
+		[OMAP_MMC_REG_REV]	= 0x3c,
+		[OMAP_MMC_REG_RSP0]	= 0x40,
+		[OMAP_MMC_REG_RSP1]	= 0x44,
+		[OMAP_MMC_REG_RSP2]	= 0x48,
+		[OMAP_MMC_REG_RSP3]	= 0x4c,
+		[OMAP_MMC_REG_RSP4]	= 0x50,
+		[OMAP_MMC_REG_RSP5]	= 0x54,
+		[OMAP_MMC_REG_RSP6]	= 0x58,
+		[OMAP_MMC_REG_RSP7]	= 0x5c,
+		[OMAP_MMC_REG_IOSR]	= 0x60,
+		[OMAP_MMC_REG_SYSC]	= 0x64,
+		[OMAP_MMC_REG_SYSS]	= 0x68,
+	},
+};
+
+static inline int mmc_omap_get_register(unsigned int reg_size,
unsigned int reg)
+{
+	return omap_mmc_reg_map[reg_size][reg];
+}
+
+#endif /* MMC_MMC_OMAP_H */
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] [mmc-omap] Add support for 16-bit and 32-bit registers
@ 2009-11-15  3:24 Cory Maccarrone
  2009-11-18 18:41 ` Ladislav Michl
  0 siblings, 1 reply; 12+ messages in thread
From: Cory Maccarrone @ 2009-11-15  3:24 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-omap

The omap850 and omap730 use 16-bit registers instead of 32-bit, requiring
a modification of the register addresses in the mmc-omap driver.  To
make this as portable as possible, I made the following changes:

* Moved register address offsets from drivers/mmc/host/omap.c to
  drivers/mmc/host/omap.h
* Implemented a lookup table for 16-bit and 32-bit register offsets
* Added a reg_size field in the mmc_omap_host structure
* Added code in mmc_omap_probe() to populate the reg_size
  field based on processor in use
* Added inline function to return the register offset based on
  the register size and register name
* Modified mmc-omap driver to use the new inline function to call out
  register names

This change should allow the omap7xx-series of processors to correctly
utilize the MMC driver.

Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
---
 drivers/mmc/host/omap.c |   42 +++++------------
 drivers/mmc/host/omap.h |  115 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mmc/host/omap.h

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 5f970e2..c0071b3 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -37,31 +37,7 @@
 #include <plat/mux.h>
 #include <plat/fpga.h>
 
-#define	OMAP_MMC_REG_CMD	0x00
-#define	OMAP_MMC_REG_ARGL	0x04
-#define	OMAP_MMC_REG_ARGH	0x08
-#define	OMAP_MMC_REG_CON	0x0c
-#define	OMAP_MMC_REG_STAT	0x10
-#define	OMAP_MMC_REG_IE		0x14
-#define	OMAP_MMC_REG_CTO	0x18
-#define	OMAP_MMC_REG_DTO	0x1c
-#define	OMAP_MMC_REG_DATA	0x20
-#define	OMAP_MMC_REG_BLEN	0x24
-#define	OMAP_MMC_REG_NBLK	0x28
-#define	OMAP_MMC_REG_BUF	0x2c
-#define OMAP_MMC_REG_SDIO	0x34
-#define	OMAP_MMC_REG_REV	0x3c
-#define	OMAP_MMC_REG_RSP0	0x40
-#define	OMAP_MMC_REG_RSP1	0x44
-#define	OMAP_MMC_REG_RSP2	0x48
-#define	OMAP_MMC_REG_RSP3	0x4c
-#define	OMAP_MMC_REG_RSP4	0x50
-#define	OMAP_MMC_REG_RSP5	0x54
-#define	OMAP_MMC_REG_RSP6	0x58
-#define	OMAP_MMC_REG_RSP7	0x5c
-#define	OMAP_MMC_REG_IOSR	0x60
-#define	OMAP_MMC_REG_SYSC	0x64
-#define	OMAP_MMC_REG_SYSS	0x68
+#include "omap.h"
 
 #define	OMAP_MMC_STAT_CARD_ERR		(1 << 14)
 #define	OMAP_MMC_STAT_CARD_IRQ		(1 << 13)
@@ -77,8 +53,10 @@
 #define	OMAP_MMC_STAT_CARD_BUSY		(1 <<  2)
 #define	OMAP_MMC_STAT_END_OF_CMD	(1 <<  0)
 
-#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base + OMAP_MMC_REG_##reg)
-#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val), (host)->virt_base + OMAP_MMC_REG_##reg)
+#define OMAP_MMC_REG(host, reg)		mmc_omap_get_register(host->reg_size, OMAP_MMC_REG_##reg)
+
+#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg))
+#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg))
 
 /*
  * Command types
@@ -167,6 +145,8 @@ struct mmc_omap_host {
 	spinlock_t		clk_lock;     /* for changing enabled state */
 	unsigned int            fclk_enabled:1;
 
+	unsigned		reg_size:1;
+
 	struct omap_mmc_platform_data *pdata;
 };
 
@@ -679,9 +659,9 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
 	host->data->bytes_xfered += n;
 
 	if (write) {
-		__raw_writesw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_writesw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	} else {
-		__raw_readsw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_readsw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	}
 }
 
@@ -899,7 +879,7 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
 	int dst_port = 0;
 	int sync_dev = 0;
 
-	data_addr = host->phys_base + OMAP_MMC_REG_DATA;
+	data_addr = host->phys_base + OMAP_MMC_REG(host, DATA);
 	frame = data->blksz;
 	count = sg_dma_len(sg);
 
@@ -1490,6 +1470,8 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
 		}
 	}
 
+	host->reg_size = (cpu_is_omap7xx() ? OMAP_MMC_REG_SIZE_2 : OMAP_MMC_REG_SIZE_4);
+
 	return 0;
 
 err_plat_cleanup:
diff --git a/drivers/mmc/host/omap.h b/drivers/mmc/host/omap.h
new file mode 100644
index 0000000..9a52203
--- /dev/null
+++ b/drivers/mmc/host/omap.h
@@ -0,0 +1,115 @@
+/*
+ *  linux/drivers/mmc/host/omap.h
+ *
+ *  Copyright (C) 2009 Cory Maccarrone <darkstar6262@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MMC_MMC_OMAP_H
+#define MMC_MMC_OMAP_H
+
+/* MMC registers used for omap-mmc driver */
+enum {
+	OMAP_MMC_REG_CMD = 0,
+	OMAP_MMC_REG_ARGL,
+	OMAP_MMC_REG_ARGH,
+	OMAP_MMC_REG_CON,
+	OMAP_MMC_REG_STAT,
+	OMAP_MMC_REG_IE,
+	OMAP_MMC_REG_CTO,
+	OMAP_MMC_REG_DTO,
+	OMAP_MMC_REG_DATA,
+	OMAP_MMC_REG_BLEN,
+	OMAP_MMC_REG_NBLK,
+	OMAP_MMC_REG_BUF,
+	OMAP_MMC_REG_SDIO,
+	OMAP_MMC_REG_REV,
+	OMAP_MMC_REG_RSP0,
+	OMAP_MMC_REG_RSP1,
+	OMAP_MMC_REG_RSP2,
+	OMAP_MMC_REG_RSP3,
+	OMAP_MMC_REG_RSP4,
+	OMAP_MMC_REG_RSP5,
+	OMAP_MMC_REG_RSP6,
+	OMAP_MMC_REG_RSP7,
+	OMAP_MMC_REG_IOSR,
+	OMAP_MMC_REG_SYSC,
+	OMAP_MMC_REG_SYSS,
+};
+
+/* There are two known register sizes, 2-byte and 4-byte. */
+enum {
+	OMAP_MMC_REG_SIZE_2 = 0,
+	OMAP_MMC_REG_SIZE_4,
+};
+
+#define OMAP_MMC_MAX_REG	25
+#define OMAP_MMC_MAX_REG_SIZES	2
+
+/* MMC register table for 2 or 4-byte register sizes */
+static u8 omap_mmc_reg_map[OMAP_MMC_MAX_REG_SIZES][OMAP_MMC_MAX_REG] = {
+	[OMAP_MMC_REG_SIZE_2] = {
+		[OMAP_MMC_REG_CMD]	= 0x00,
+		[OMAP_MMC_REG_ARGL]	= 0x02,
+		[OMAP_MMC_REG_ARGH]	= 0x04,
+		[OMAP_MMC_REG_CON]	= 0x06,
+		[OMAP_MMC_REG_STAT]	= 0x08,
+		[OMAP_MMC_REG_IE]	= 0x0a,
+		[OMAP_MMC_REG_CTO]	= 0x0c,
+		[OMAP_MMC_REG_DTO]	= 0x0e,
+		[OMAP_MMC_REG_DATA]	= 0x10,
+		[OMAP_MMC_REG_BLEN]	= 0x12,
+		[OMAP_MMC_REG_NBLK]	= 0x14,
+		[OMAP_MMC_REG_BUF]	= 0x16,
+		[OMAP_MMC_REG_SDIO]	= 0x1a,
+		[OMAP_MMC_REG_REV]	= 0x1e,
+		[OMAP_MMC_REG_RSP0]	= 0x20,
+		[OMAP_MMC_REG_RSP1]	= 0x22,
+		[OMAP_MMC_REG_RSP2]	= 0x24,
+		[OMAP_MMC_REG_RSP3]	= 0x26,
+		[OMAP_MMC_REG_RSP4]	= 0x28,
+		[OMAP_MMC_REG_RSP5]	= 0x2a,
+		[OMAP_MMC_REG_RSP6]	= 0x2c,
+		[OMAP_MMC_REG_RSP7]	= 0x2e,
+		[OMAP_MMC_REG_IOSR]	= 0x30,
+		[OMAP_MMC_REG_SYSC]	= 0x32,
+		[OMAP_MMC_REG_SYSS]	= 0x34,
+	},
+	[OMAP_MMC_REG_SIZE_4] = {
+		[OMAP_MMC_REG_CMD]	= 0x00,
+		[OMAP_MMC_REG_ARGL]	= 0x04,
+		[OMAP_MMC_REG_ARGH]	= 0x08,
+		[OMAP_MMC_REG_CON]	= 0x0c,
+		[OMAP_MMC_REG_STAT]	= 0x10,
+		[OMAP_MMC_REG_IE]	= 0x14,
+		[OMAP_MMC_REG_CTO]	= 0x18,
+		[OMAP_MMC_REG_DTO]	= 0x1c,
+		[OMAP_MMC_REG_DATA]	= 0x20,
+		[OMAP_MMC_REG_BLEN]	= 0x24,
+		[OMAP_MMC_REG_NBLK]	= 0x28,
+		[OMAP_MMC_REG_BUF]	= 0x2c,
+		[OMAP_MMC_REG_SDIO]	= 0x34,
+		[OMAP_MMC_REG_REV]	= 0x3c,
+		[OMAP_MMC_REG_RSP0]	= 0x40,
+		[OMAP_MMC_REG_RSP1]	= 0x44,
+		[OMAP_MMC_REG_RSP2]	= 0x48,
+		[OMAP_MMC_REG_RSP3]	= 0x4c,
+		[OMAP_MMC_REG_RSP4]	= 0x50,
+		[OMAP_MMC_REG_RSP5]	= 0x54,
+		[OMAP_MMC_REG_RSP6]	= 0x58,
+		[OMAP_MMC_REG_RSP7]	= 0x5c,
+		[OMAP_MMC_REG_IOSR]	= 0x60,
+		[OMAP_MMC_REG_SYSC]	= 0x64,
+		[OMAP_MMC_REG_SYSS]	= 0x68,
+	},
+};
+
+static inline int mmc_omap_get_register(unsigned int reg_size, unsigned int reg)
+{
+	return omap_mmc_reg_map[reg_size][reg];
+}
+
+#endif /* MMC_MMC_OMAP_H */
-- 
1.6.3.3



^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] mmc-omap: Add support for 16-bit and 32-bit registers
@ 2010-03-07 17:47 Cory Maccarrone
  2010-03-07 22:59 ` Ben Dooks
  2010-05-13 19:29 ` Tony Lindgren
  0 siblings, 2 replies; 12+ messages in thread
From: Cory Maccarrone @ 2010-03-07 17:47 UTC (permalink / raw)
  To: linux-mmc, akpm
  Cc: Ladislav Michl, linux-omap, Tony Lindgren, Marek Belisko,
	Cory Maccarrone

From: Marek Belisko <marek.belisko@open-nandra.com>

The omap850 and omap730 use 16-bit registers instead of 32-bit, requiring
a modification of the register addresses in the mmc-omap driver.  To resolve
this, a bit shift is performed on base register addresses, either by 1 or 2
bits depending on the CPU in use.  This yields the correct registers for
each CPU.

Signed-off-by: Marek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/omap.c |   62 +++++++++++++++++++++++++----------------------
 1 files changed, 33 insertions(+), 29 deletions(-)

This is a resubmit of a patch I sent in several months ago.  Tony Lindgren merged
this into linux-omap's master and testing branches but has stated that he will not
merge it further as linux-mmc needs to approve this.  There hasn't been any comments
raised on either of the linux-omap or linux-mmc mailing lists about problems.  Due to
the unique nature of the omap7xx platform, this patch is required for MMC card access.
Is there any chance this can be included into the next -rc cycle, as it is a fix for
devices that have 16-bit registers?

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index c6d7e8e..53362c4 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -38,30 +38,30 @@
 #include <plat/fpga.h>
 
 #define	OMAP_MMC_REG_CMD	0x00
-#define	OMAP_MMC_REG_ARGL	0x04
-#define	OMAP_MMC_REG_ARGH	0x08
-#define	OMAP_MMC_REG_CON	0x0c
-#define	OMAP_MMC_REG_STAT	0x10
-#define	OMAP_MMC_REG_IE		0x14
-#define	OMAP_MMC_REG_CTO	0x18
-#define	OMAP_MMC_REG_DTO	0x1c
-#define	OMAP_MMC_REG_DATA	0x20
-#define	OMAP_MMC_REG_BLEN	0x24
-#define	OMAP_MMC_REG_NBLK	0x28
-#define	OMAP_MMC_REG_BUF	0x2c
-#define OMAP_MMC_REG_SDIO	0x34
-#define	OMAP_MMC_REG_REV	0x3c
-#define	OMAP_MMC_REG_RSP0	0x40
-#define	OMAP_MMC_REG_RSP1	0x44
-#define	OMAP_MMC_REG_RSP2	0x48
-#define	OMAP_MMC_REG_RSP3	0x4c
-#define	OMAP_MMC_REG_RSP4	0x50
-#define	OMAP_MMC_REG_RSP5	0x54
-#define	OMAP_MMC_REG_RSP6	0x58
-#define	OMAP_MMC_REG_RSP7	0x5c
-#define	OMAP_MMC_REG_IOSR	0x60
-#define	OMAP_MMC_REG_SYSC	0x64
-#define	OMAP_MMC_REG_SYSS	0x68
+#define	OMAP_MMC_REG_ARGL	0x01
+#define	OMAP_MMC_REG_ARGH	0x02
+#define	OMAP_MMC_REG_CON	0x03
+#define	OMAP_MMC_REG_STAT	0x04
+#define	OMAP_MMC_REG_IE		0x05
+#define	OMAP_MMC_REG_CTO	0x06
+#define	OMAP_MMC_REG_DTO	0x07
+#define	OMAP_MMC_REG_DATA	0x08
+#define	OMAP_MMC_REG_BLEN	0x09
+#define	OMAP_MMC_REG_NBLK	0x0a
+#define	OMAP_MMC_REG_BUF	0x0b
+#define	OMAP_MMC_REG_SDIO	0x0d
+#define	OMAP_MMC_REG_REV	0x0f
+#define	OMAP_MMC_REG_RSP0	0x10
+#define	OMAP_MMC_REG_RSP1	0x11
+#define	OMAP_MMC_REG_RSP2	0x12
+#define	OMAP_MMC_REG_RSP3	0x13
+#define	OMAP_MMC_REG_RSP4	0x14
+#define	OMAP_MMC_REG_RSP5	0x15
+#define	OMAP_MMC_REG_RSP6	0x16
+#define	OMAP_MMC_REG_RSP7	0x17
+#define	OMAP_MMC_REG_IOSR	0x18
+#define	OMAP_MMC_REG_SYSC	0x19
+#define	OMAP_MMC_REG_SYSS	0x1a
 
 #define	OMAP_MMC_STAT_CARD_ERR		(1 << 14)
 #define	OMAP_MMC_STAT_CARD_IRQ		(1 << 13)
@@ -77,8 +77,9 @@
 #define	OMAP_MMC_STAT_CARD_BUSY		(1 <<  2)
 #define	OMAP_MMC_STAT_END_OF_CMD	(1 <<  0)
 
-#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base + OMAP_MMC_REG_##reg)
-#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val), (host)->virt_base + OMAP_MMC_REG_##reg)
+#define OMAP_MMC_REG(host, reg)		(OMAP_MMC_REG_##reg << (host)->reg_shift)
+#define OMAP_MMC_READ(host, reg)	__raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg))
+#define OMAP_MMC_WRITE(host, reg, val)	__raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg))
 
 /*
  * Command types
@@ -132,6 +133,7 @@ struct mmc_omap_host {
 	int			irq;
 	unsigned char		bus_mode;
 	unsigned char		hw_bus_mode;
+	unsigned int		reg_shift;
 
 	struct work_struct	cmd_abort_work;
 	unsigned		abort:1;
@@ -679,9 +681,9 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
 	host->data->bytes_xfered += n;
 
 	if (write) {
-		__raw_writesw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_writesw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	} else {
-		__raw_readsw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
+		__raw_readsw(host->virt_base + OMAP_MMC_REG(host, DATA), host->buffer, n);
 	}
 }
 
@@ -899,7 +901,7 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
 	int dst_port = 0;
 	int sync_dev = 0;
 
-	data_addr = host->phys_base + OMAP_MMC_REG_DATA;
+	data_addr = host->phys_base + OMAP_MMC_REG(host, DATA);
 	frame = data->blksz;
 	count = sg_dma_len(sg);
 
@@ -1492,6 +1494,8 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
 		}
 	}
 
+	host->reg_shift = (cpu_is_omap7xx() ? 1 : 2);
+
 	return 0;
 
 err_plat_cleanup:
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-05-13 19:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-03 21:57 [PATCH] [mmc-omap] Add support for 16-bit and 32-bit registers Cory Maccarrone
  -- strict thread matches above, loose matches on Subject: below --
2009-11-15  3:24 Cory Maccarrone
2009-11-18 18:41 ` Ladislav Michl
2009-11-18 21:09   ` Cory Maccarrone
2009-11-18 23:35     ` Ladislav Michl
2010-03-07 17:47 [PATCH] mmc-omap: " Cory Maccarrone
2010-03-07 22:59 ` Ben Dooks
2010-03-08  0:16   ` Cory Maccarrone
2010-03-08 10:04   ` Ben Dooks
2010-05-13 19:29 ` Tony Lindgren
2010-05-13 19:41   ` Andrew Morton
2010-05-13 19:49     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).