Skip to contentSkip to conversation

OMAP4 HSMMC: Adding hsmmc support to board file

PATCH Superseded kishore kadiyala 5 participants 6 messages May 13, 2010 – May 15, 2010

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/5 OMAP4 HSMMC: Adding hsmmc support to board file

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

---
 arch/arm/mach-omap2/Makefile        |    3 +-
 arch/arm/mach-omap2/board-4430sdp.c |   64 +++++++++++++++++++++++++++++++----
 include/linux/i2c/twl.h             |   44 ++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/Makefile +2 -1
index ffe600a..65d8d11 100644
@@ -140,7 +140,8 @@ obj-$(CONFIG_MACH_IGEP0020)		+= board-igep0020.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK)	+= board-omap3touchbook.o \
 					   hsmmc.o
-obj-$(CONFIG_MACH_OMAP_4430SDP)		+= board-4430sdp.o
+obj-$(CONFIG_MACH_OMAP_4430SDP)		+= board-4430sdp.o \
+					   hsmmc.o
 
 obj-$(CONFIG_MACH_OMAP3517EVM)		+= board-am3517evm.o
 
arch/arm/mach-omap2/board-4430sdp.c +57 -7

100 lines not on this page · raw message

include/linux/i2c/twl.h +44 -0

56 lines not on this page · raw message

Signature · 1 line
1.6.3.3
maintainer
#1 lore raw
Quoted 2 lines · kishore kadiyala

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

This patch does not seem to apply, I don't know where you're getting the sdp4430_vmmc_supply in this patch?

I suggest you forget about the card detect patches for now and first produce a minimal set of patches to get the MMC working for board-4430sdp.c. The card detect patches should be applied only after board-4430sdp.c works for MMC. And we're running out of time for this merge window.

Regards,

Tony

Quoted 194 lines
---
 arch/arm/mach-omap2/Makefile        |    3 +-
 arch/arm/mach-omap2/board-4430sdp.c |   64 +++++++++++++++++++++++++++++++----
 include/linux/i2c/twl.h             |   44 ++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/Makefile +2 -1
index ffe600a..65d8d11 100644
@@ -140,7 +140,8 @@ obj-$(CONFIG_MACH_IGEP0020)		+= board-igep0020.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK)	+= board-omap3touchbook.o \
 					   hsmmc.o
-obj-$(CONFIG_MACH_OMAP_4430SDP)		+= board-4430sdp.o
+obj-$(CONFIG_MACH_OMAP_4430SDP)		+= board-4430sdp.o \
+					   hsmmc.o
 
 obj-$(CONFIG_MACH_OMAP3517EVM)		+= board-am3517evm.o
 
arch/arm/mach-omap2/board-4430sdp.c +57 -7
index d86e22d..70c8ab7 100644
@@ -32,6 +32,8 @@
 #include <plat/control.h>
 #include <plat/timer-gp.h>
 #include <plat/usb.h>
+#include <plat/mmc.h>
+#include "hsmmc.h"
 
 static struct platform_device sdp4430_lcd_device = {
 	.name		= "sdp4430_lcd",
@@ -68,24 +70,71 @@ static struct omap_musb_board_data musb_board_data = {
 	.power			= 100,
 };
 
-static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
-	{
-		.supply = "vmmc",
-	},
+static struct omap2_hsmmc_info mmc[] = {
 	{
-		.supply = "vmmc",
+		.mmc		= 1,
+		.wires		= 8,
+		.gpio_cd	= TWL6030_IRQ_BASE + MMCDETECT_INTR_OFFSET,
+		.cd_type	= NON_GPIO,
+		.gpio_wp	= -EINVAL,
 	},
 	{
-		.supply = "vmmc",
+		.mmc		= 2,
+		.wires		= 8,
+		.gpio_cd	= -EINVAL,
+		.gpio_wp	= -EINVAL,
+		.nonremovable   = true,
 	},
+	{}	/* Terminator */
+};
+
+static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
 	{
 		.supply = "vmmc",
+		.dev_name = "mmci-omap-hs.0",
 	},
 	{
 		.supply = "vmmc",
+		.dev_name = "mmci-omap-hs.1",
 	},
 };
 
+static int omap4_twl6030_hsmmc_late_init(struct device *dev)
+{
+	int ret = 0;
+	struct platform_device *pdev = container_of(dev,
+				struct platform_device, dev);
+	struct omap_mmc_platform_data *pdata = dev->platform_data;
+
+	/* MMC1 Card detect Configuration */
+	if (pdev->id == 0) {
+		ret = omap4_hsmmc1_card_detect_config();
+		if (ret < 0)
+			pr_err("Unable to configure Card detect for MMC1\n");
+		pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
+						MMCDETECT_INTR_OFFSET;
+	}
+	return ret;
+}
+
+static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
+{
+	struct omap_mmc_platform_data *pdata = dev->platform_data;
+
+	pdata->init =	omap4_twl6030_hsmmc_late_init;
+}
+
+static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
+{
+	struct omap2_hsmmc_info *c;
+
+	omap2_hsmmc_init(controllers);
+	for (c = controllers; c->mmc; c++)
+		omap4_twl6030_hsmmc_set_late_init(c->dev);
+
+	return 0;
+}
+
 static struct regulator_init_data sdp4430_vaux1 = {
 	.constraints = {
 		.min_uV			= 1000000,
@@ -137,7 +186,7 @@ static struct regulator_init_data sdp4430_vmmc = {
 					| REGULATOR_CHANGE_MODE
 					| REGULATOR_CHANGE_STATUS,
 	},
-	.num_consumer_supplies  = 5,
+	.num_consumer_supplies  = 2,
 	.consumer_supplies      = sdp4430_vmmc_supply,
 };
 
@@ -256,6 +305,7 @@ static void __init omap_4430sdp_init(void)
 	omap4_i2c_init();
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
 	omap_serial_init();
+	omap4_twl6030_hsmmc_init(mmc);
 	/* OMAP4 SDP uses internal transceiver so register nop transceiver */
 	usb_nop_xceiv_register();
 	/* FIXME: allow multi-omap to boot until musb is updated for omap4 */
include/linux/i2c/twl.h +44 -0
index fb6784e..f382d59 100644
@@ -141,6 +141,15 @@
 #define TWL6030_CHARGER_CTRL_INT_MASK 	0x10
 #define TWL6030_CHARGER_FAULT_INT_MASK 	0x60
 
+#define TWL6030_MMCCTRL			0xEE
+#define VMMC_AUTO_OFF			(0x1 << 3)
+#define SW_FC				(0x1 << 2)
+#define STS_MMC				0x1
+
+#define TWL6030_CFG_INPUT_PUPD3		0xF2
+#define MMC_PU				(0x1 << 3)
+#define MMC_PD				(0x1 << 2)
+
 
 #define TWL4030_CLASS_ID 		0x4030
 #define TWL6030_CLASS_ID 		0x6030
@@ -173,6 +182,41 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
 int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
+/* Configuring Card Detect for MMC1 */
+static inline int omap4_hsmmc1_card_detect_config(void)
+{
+	int res = -1;
+	u8 reg_val = 0;
+
+	/* Unmasking the Card detect Interrupt line for MMC1 from Phoenix */
+	if (twl_class_is_6030()) {
+		twl6030_interrupt_unmask(TWL6030_MMCDETECT_INT_MASK,
+							REG_INT_MSK_LINE_B);
+		twl6030_interrupt_unmask(TWL6030_MMCDETECT_INT_MASK,
+							REG_INT_MSK_STS_B);
+	}
+
+	/*
+	 * Intially Configuring MMC_CTRL for receving interrupts &
+	 * Card status on TWL6030 for MMC1
+	 */
+	res = twl_i2c_read_u8(TWL6030_MODULE_ID0, &reg_val, TWL6030_MMCCTRL);
+	if (res < 0)
+		return res;
+	reg_val &= ~VMMC_AUTO_OFF;
+	reg_val |= SW_FC;
+	twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
+
+	res = twl_i2c_read_u8(TWL6030_MODULE_ID0, &reg_val,
+						TWL6030_CFG_INPUT_PUPD3);
+	if (res < 0)
+		return res;
+	reg_val &= ~(MMC_PU | MMC_PD);
+	twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val,
+						TWL6030_CFG_INPUT_PUPD3);
+	return res;
+}
+
 /*----------------------------------------------------------------------*/
 
 /*
Signature · 1 line
1.6.3.3
#2 lore raw
Quoted 4 lines · Tony Lindgren
Quoted 2 lines · kishore kadiyala

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

Quoted 8 lines

This patch does not seem to apply, I don't know where you're getting the sdp4430_vmmc_supply in this patch?

I suggest you forget about the card detect patches for now and first produce a minimal set of patches to get the MMC working for board-4430sdp.c. The card detect patches should be applied only after board-4430sdp.c works for MMC. And we're running out of time for this merge window.

Absolutely - we _really_ _really_ _really_ need to get MMC usable on the 4430SDP for this merge window - don't care about the card detection provided the system can find a MMC card which is left plugged in.

To do this makes the overall 4430SDP more usable than it currently is with mainline kernels.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#3 lore raw

Kishore,

Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Russell King
Sent: Saturday, May 15, 2010 3:35 AM
To: Tony Lindgren
Cc: Kadiyala, Kishore; [email protected]; [email protected]; Chikkature Rajashekar, Madhusudhan; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 2/5] OMAP4 HSMMC: Adding hsmmc support to board file

Quoted 4 lines · Tony Lindgren
Quoted 2 lines · kishore kadiyala

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

Quoted 8 lines

This patch does not seem to apply, I don't know where you're getting the sdp4430_vmmc_supply in this patch?

I suggest you forget about the card detect patches for now and first produce a minimal set of patches to get the MMC working for board-4430sdp.c. The card detect patches should be applied only after board-4430sdp.c works for MMC. And we're running out of time for this merge window.

Quoted 8 lines

Absolutely - we _really_ _really_ _really_ need to get MMC usable on the 4430SDP for this merge window - don't care about the card detection provided the system can find a MMC card which is left plugged in.

To do this makes the overall 4430SDP more usable than it currently is with mainline kernels.

Why is it taking so much time to get 4-5 patches in shape for mainline?? What is expected is just basic MMC support and no advance features yet.

Regards,
Santosh

#4 lore raw

Kishore,

Quoted 40 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Shilimkar, Santosh
Sent: Saturday, May 15, 2010 11:41 AM
To: Kadiyala, Kishore
Cc: [email protected]; [email protected]; Chikkature Rajashekar, Madhusudhan; [email protected]; [email protected]; [email protected]; Russell King; Tony Lindgren
Subject: RE: [PATCH v3 2/5] OMAP4 HSMMC: Adding hsmmc support to board file

Kishore,

Quoted 2 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of

Russell

Quoted 4 lines

King
Sent: Saturday, May 15, 2010 3:35 AM
To: Tony Lindgren
Cc: Kadiyala, Kishore; [email protected]; [email protected]; Chikkature

Rajashekar,

Quoted 22 lines

Madhusudhan; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 2/5] OMAP4 HSMMC: Adding hsmmc support to board file

Quoted 4 lines · Tony Lindgren
Quoted 2 lines · kishore kadiyala

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

Quoted 8 lines

This patch does not seem to apply, I don't know where you're getting the sdp4430_vmmc_supply in this patch?

I suggest you forget about the card detect patches for now and first produce a minimal set of patches to get the MMC working for board-4430sdp.c. The card detect patches should be applied only after board-4430sdp.c works for MMC. And we're running out of time for this merge window.

Absolutely - we _really_ _really_ _really_ need to get MMC usable on the 4430SDP for this merge window - don't care about the card detection provided the system can find a MMC card which is left plugged in.

Quoted 6 lines
Quoted 3 lines

To do this makes the overall 4430SDP more usable than it currently is with mainline kernels.

Why is it taking so much time to get 4-5 patches in shape for mainline?? What is expected is just basic MMC support and no advance features yet.

Please have a look at Tony's "for-next" branch where your i2c board depedancy is taken care. May be you can rebase your patches against this branch.

Regards,
Santosh

#5 lore raw
In reply to Tony Lindgren

Tony,

Quoted 6 lines · Tony Lindgren
Quoted 2 lines · kishore kadiyala

Support for MMC1 & MMC2 controllers is added to the board file. Also includes configuration of MMC1 Card detect initially.

This patch does not seem to apply, I don't know where you're getting the sdp4430_vmmc_supply in this patch?

I have mentioned that patch series has dependency on I2c/regulator pacthes [with links] in the cover letter.
here is the link to exact patch where sdp4430_vmmc_supply is added to board file which i had mentioned :
http://www.mail-archive.com/[email protected]/msg26258.html

Quoted 6 lines

I suggest you forget about the card detect patches for now and first produce a minimal set of patches to get the MMC working for board-4430sdp.c. The card detect patches should be applied only after board-4430sdp.c works for MMC. And we're running out of time for this merge window.

Agree.
Actually the patches I've sent has that minimal changes with which MMC works but with card detect feature dependency [Thought that card detect is also a basic feature which is much needed].

Will rework and post patches as below :
1)As Sanotsh suggested, will re-base on "for_next " branch 2)Cover letter having links to dependencies on patches [I2c/Regulator]
with latest re-based
3)patch series with
a) Minimal set of changes for MMC
b) later Card detect. [Can take a call on this]

Regards,
Kishore

Quoted 204 lines

Regards,

Tony

Quoted 192 lines

---
 arch/arm/mach-omap2/Makefile        |    3 +- arch/arm/mach-omap2/board-4430sdp.c |   64 +++++++++++++++++++++++++++++++---- include/linux/i2c/twl.h             |   44 ++++++++++++++++++++++++

 3 files changed, 103 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/Makefile +0 -0
index ffe600a..65d8d11 100644
@@ -140,7 +140,8 @@ obj-$(CONFIG_MACH_IGEP0020)               += board-igep0020.o \

                                         hsmmc.o obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK)   += board-omap3touchbook.o \
                                         hsmmc.o

arch/arm/mach-omap2/Makefile +2 -1
-obj-$(CONFIG_MACH_OMAP_4430SDP)              += board-4430sdp.o
+obj-$(CONFIG_MACH_OMAP_4430SDP)              += board-4430sdp.o \
+                                        hsmmc.o

 obj-$(CONFIG_MACH_OMAP3517EVM)               += board-am3517evm.o

arch/arm/mach-omap2/board-4430sdp.c +55 -6
index d86e22d..70c8ab7 100644
@@ -32,6 +32,8 @@
  #include <plat/control.h>
  #include <plat/timer-gp.h>
  #include <plat/usb.h>
+#include <plat/mmc.h>
+#include "hsmmc.h"
 
  static struct platform_device sdp4430_lcd_device = {
       .name           = "sdp4430_lcd",
@@ -68,24 +70,71 @@ static struct omap_musb_board_data musb_board_data = {
       .power                  = 100,
  };
 
-static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
-     {
-             .supply = "vmmc",
-     },
+static struct omap2_hsmmc_info mmc[] = {
       {
-             .supply = "vmmc",
+             .mmc            = 1,
+             .wires          = 8,
+             .gpio_cd        = TWL6030_IRQ_BASE + MMCDETECT_INTR_OFFSET,
+             .cd_type        = NON_GPIO,
+             .gpio_wp        = -EINVAL,
       },
       {
-             .supply = "vmmc",
+             .mmc            = 2,
+             .wires          = 8,
+             .gpio_cd        = -EINVAL,
+             .gpio_wp        = -EINVAL,
+             .nonremovable   = true,
       },
+     {}      /* Terminator */
+};
+
+static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
       {
               .supply = "vmmc",
+             .dev_name = "mmci-omap-hs.0",
       },
       {
               .supply = "vmmc",
+             .dev_name = "mmci-omap-hs.1",
       },
  };
 
+static int omap4_twl6030_hsmmc_late_init(struct device *dev)
+{
+     int ret = 0;
+     struct platform_device *pdev = container_of(dev,
+                             struct platform_device, dev);
+     struct omap_mmc_platform_data *pdata = dev->platform_data;
+
+     /* MMC1 Card detect Configuration */
+     if (pdev->id == 0) {
+             ret = omap4_hsmmc1_card_detect_config();
+             if (ret < 0)
+                     pr_err("Unable to configure Card detect for MMC1\n");
+             pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
+                                             MMCDETECT_INTR_OFFSET;
+     }
+     return ret;
+}
+
+static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
+{
+     struct omap_mmc_platform_data *pdata = dev->platform_data;
+
+     pdata->init =   omap4_twl6030_hsmmc_late_init;
+}
+
+static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
+{
+     struct omap2_hsmmc_info *c;
+
+     omap2_hsmmc_init(controllers);
+     for (c = controllers; c->mmc; c++)
+             omap4_twl6030_hsmmc_set_late_init(c->dev);
+
+     return 0;
+}
+
  static struct regulator_init_data sdp4430_vaux1 = {
       .constraints = {
               .min_uV                 = 1000000,
@@ -137,7 +186,7 @@ static struct regulator_init_data sdp4430_vmmc = {

                                      | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS, },
-     .num_consumer_supplies  = 5,
+     .num_consumer_supplies  = 2,
      .consumer_supplies      = sdp4430_vmmc_supply, };

arch/arm/mach-omap2/board-4430sdp.c +1 -0
@@ -256,6 +305,7 @@ static void __init omap_4430sdp_init(void)
       omap4_i2c_init();
       platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
       omap_serial_init();
+     omap4_twl6030_hsmmc_init(mmc);
       /* OMAP4 SDP uses internal transceiver so register nop transceiver */
       usb_nop_xceiv_register();
       /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
include/linux/i2c/twl.h +44 -1
index fb6784e..f382d59 100644
@@ -141,6 +141,15 @@
  #define TWL6030_CHARGER_CTRL_INT_MASK        0x10
  #define TWL6030_CHARGER_FAULT_INT_MASK       0x60
 
+#define TWL6030_MMCCTRL                      0xEE
+#define VMMC_AUTO_OFF                        (0x1 << 3)
+#define SW_FC                                (0x1 << 2)
+#define STS_MMC                              0x1
+
+#define TWL6030_CFG_INPUT_PUPD3              0xF2
+#define MMC_PU                               (0x1 << 3)
+#define MMC_PD                               (0x1 << 2)
+
 
  #define TWL4030_CLASS_ID             0x4030
  #define TWL6030_CLASS_ID             0x6030
@@ -173,6 +182,41 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
  int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
  int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
+/* Configuring Card Detect for MMC1 */
+static inline int omap4_hsmmc1_card_detect_config(void)
+{
+     int res = -1;
+     u8 reg_val = 0;
+
+     /* Unmasking the Card detect Interrupt line for MMC1 from Phoenix */
+     if (twl_class_is_6030()) {
+             twl6030_interrupt_unmask(TWL6030_MMCDETECT_INT_MASK,
+                                                     REG_INT_MSK_LINE_B);
+             twl6030_interrupt_unmask(TWL6030_MMCDETECT_INT_MASK,
+                                                     REG_INT_MSK_STS_B);
+     }
+
+     /*
+      * Intially Configuring MMC_CTRL for receving interrupts &
+      * Card status on TWL6030 for MMC1
+      */
+     res = twl_i2c_read_u8(TWL6030_MODULE_ID0, &reg_val, TWL6030_MMCCTRL);
+     if (res < 0)
+             return res;
+     reg_val &= ~VMMC_AUTO_OFF;
+     reg_val |= SW_FC;
+     twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
+
+     res = twl_i2c_read_u8(TWL6030_MODULE_ID0, &reg_val,
+                                             TWL6030_CFG_INPUT_PUPD3);
+     if (res < 0)
+             return res;
+     reg_val &= ~(MMC_PU | MMC_PD);
+     twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val,
+                                             TWL6030_CFG_INPUT_PUPD3);
+     return res;
+}
+
  /*----------------------------------------------------------------------*/
 
  /*
--
Quoted 2 lines

1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html