diff mbox

[5/5] mmc: host: omap_hsmmc: set max_blk_size correctly

Message ID 1395878690-9650-6-git-send-email-balbi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi March 27, 2014, 12:04 a.m. UTC
now that we can finally read the new registers for
new versions of the mmc IP, we can set max_blk_size
correctly depending on the version of the IP we're
running on.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c | 45 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

Comments

Felipe Balbi March 27, 2014, 12:12 a.m. UTC | #1
Hi,

On Wed, Mar 26, 2014 at 07:04:50PM -0500, Felipe Balbi wrote:
> @@ -1867,6 +1879,37 @@ static inline struct omap_mmc_platform_data
>  }
>  #endif
>  
> +static void omap_hsmmc_set_max_blk_size(struct omap_hsmmc_host *host)
> +{
> +	struct mmc_host *mmc = host->mmc;
> +
> +	if (of_device_is_compatible(host->dev->of_node, "ti,omap4-hsmmc")) {
> +		u32 mem;
> +		u32 reg;
> +
> +		reg = omap_hsmmc_read_no_offset(host, OMAP_HSMMC_HL_HWINFO);
> +		mem = OMAP_HSMMC_HL_HWINFO_MEM_SIZE(reg);
> +
> +		switch (mem) {
> +		case 1:
> +			mmc->max_blk_size = 512;
> +			break;
> +		case 2:
> +			mmc->max_blk_size = 1024;
> +			break;
> +		case 4:
> +			/* FALLTHROUGH */
> +		case 8:
> +			/* FALLTHROUGH */
> +		default:
> +			mmc->max_blk_size = 2048;
> +			break;
> +		}
> +	} else {
> +		mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */

looks like here, we could read CAPA register to figure out if older
devices support bigger block sizes. According to TRM, omap3 should
support 1024 just fine.
diff mbox

Patch

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index d32f6ac..ae5583e 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -62,6 +62,18 @@ 
 #define OMAP_HSMMC_AC12		0x013C
 #define OMAP_HSMMC_CAPA		0x0140
 
+/* OMAP HSMMC Host Controller Register (NEW)
+ *
+ * NOTE: DO NOT READ THESE WITH OFFSET
+ */
+#define OMAP_HSMMC_HL_REV	0x0000
+#define OMAP_HSMMC_HL_HWINFO	0x0004
+#	define OMAP_HSMMC_HL_HWINFO_MADMA_EN	(1 << 0)
+#	define OMAP_HSMMC_HL_HWINFO_MERGE_MEM	(1 << 1)
+#	define OMAP_HSMMC_HL_HWINFO_MEM_SIZE(x)	(((x) & (0x0f << 2)) >> 2)
+#	define OMAP_HSMMC_HL_HWINFO_RETMODE	(1 << 6)
+#define OMAP_HSMMC_HL_SYSCONFIG	0x0010
+
 #define VS18			(1 << 26)
 #define VS30			(1 << 25)
 #define HSS			(1 << 21)
@@ -1867,6 +1879,37 @@  static inline struct omap_mmc_platform_data
 }
 #endif
 
+static void omap_hsmmc_set_max_blk_size(struct omap_hsmmc_host *host)
+{
+	struct mmc_host *mmc = host->mmc;
+
+	if (of_device_is_compatible(host->dev->of_node, "ti,omap4-hsmmc")) {
+		u32 mem;
+		u32 reg;
+
+		reg = omap_hsmmc_read_no_offset(host, OMAP_HSMMC_HL_HWINFO);
+		mem = OMAP_HSMMC_HL_HWINFO_MEM_SIZE(reg);
+
+		switch (mem) {
+		case 1:
+			mmc->max_blk_size = 512;
+			break;
+		case 2:
+			mmc->max_blk_size = 1024;
+			break;
+		case 4:
+			/* FALLTHROUGH */
+		case 8:
+			/* FALLTHROUGH */
+		default:
+			mmc->max_blk_size = 2048;
+			break;
+		}
+	} else {
+		mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
+	}
+}
+
 static int omap_hsmmc_probe(struct platform_device *pdev)
 {
 	struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
@@ -1986,7 +2029,7 @@  static int omap_hsmmc_probe(struct platform_device *pdev)
 	 * as we want. */
 	mmc->max_segs = 1024;
 
-	mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
+	omap_hsmmc_set_max_blk_size(host);
 	mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
 	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
 	mmc->max_seg_size = mmc->max_req_size;