Re: [PATCH 1/7] mmc: at91_mci: fix pointer errors

2010-08-30 Thread Ryan Mallon
Wolfgang Mües wrote:
 Hi,
 
 Am 29.08.2010 23:39, schrieb Ryan Mallon:
 I see this is already applied, but why all the type trickery here? Why
 not just:

 memcpy(dmabuf, sgbuffer, amount);
 dmabuf += amount / sizeof(dmabuf);
 
 Because this is wrong?
 
 Maybe you mean sizeof(*dmabuf)?

Sorry, yes.

 The exact style of the bug fix is not important, it's important that
 it's fixed.

I disagree, it's also important that it is fixed in a clear,
understandable way. I found the fix confusing, especially since there
are casts to both signed and unsigned char.

~Ryan

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/7] mmc: at91_mci: fix pointer errors

2010-08-30 Thread Wolfgang Mües

Hi,

Am 29.08.2010 23:39, schrieb Ryan Mallon:

I see this is already applied, but why all the type trickery here? Why
not just:

memcpy(dmabuf, sgbuffer, amount);
dmabuf += amount / sizeof(dmabuf);


Because this is wrong?

Maybe you mean sizeof(*dmabuf)?

The exact style of the bug fix is not important, it's important that 
it's fixed.


best regards

i. A. Wolfgang Muees

Hardware-Entwicklung
Leiter Pruefen  Layout
--
Auerswald Gesellschaft fuer Datensysteme mbH

Phone: +49 5306-9219-562
Fax:   +49 5306-9200-94
--
Auerswald Gesellschaft fuer Datensysteme mbH,
Vor den Grashoefen 1, 38162 Cremlingen

Registriert beim AG Braunschweig HRB 7499
Geschäftsführer: Dipl-Ing. Gerhard Auerswald
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] at91_mci.c: use resource_size()

2010-08-30 Thread Nicolas Ferre
Le 27/08/2010 21:08, Chris Ball :
 From: H Hartley Sweeten hswee...@visionengravers.com
 Date: Mon, 14 Dec 2009 14:10:26 -0500
 
 Use resource_size().
 
 Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
 [cjb: rebased patch against Linus]
 Signed-off-by: Chris Ball c...@laptop.org

A bit late but you can add my:

Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
  drivers/mmc/host/at91_mci.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
 index 5f3a599..3995db3 100644
 --- a/drivers/mmc/host/at91_mci.c
 +++ b/drivers/mmc/host/at91_mci.c
 @@ -927,7 +927,7 @@ static int __init at91_mci_probe(struct platform_device 
 *pdev)
   if (!res)
   return -ENXIO;
  
 - if (!request_mem_region(res-start, res-end - res-start + 1, 
 DRIVER_NAME))
 + if (!request_mem_region(res-start, resource_size(res), DRIVER_NAME))
   return -EBUSY;
  
   mmc = mmc_alloc_host(sizeof(struct at91mci_host), pdev-dev);
 @@ -1016,7 +1016,7 @@ static int __init at91_mci_probe(struct platform_device 
 *pdev)
   /*
* Map I/O region
*/
 - host-baseaddr = ioremap(res-start, res-end - res-start + 1);
 + host-baseaddr = ioremap(res-start, resource_size(res));
   if (!host-baseaddr) {
   ret = -ENOMEM;
   goto fail1;
 @@ -1092,7 +1092,7 @@ fail4b:
  fail5:
   mmc_free_host(mmc);
  fail6:
 - release_mem_region(res-start, res-end - res-start + 1);
 + release_mem_region(res-start, resource_size(res));
   dev_err(pdev-dev, probe failed, err %d\n, ret);
   return ret;
  }
 @@ -1137,7 +1137,7 @@ static int __exit at91_mci_remove(struct 
 platform_device *pdev)
  
   iounmap(host-baseaddr);
   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 - release_mem_region(res-start, res-end - res-start + 1);
 + release_mem_region(res-start, resource_size(res));
  
   mmc_free_host(mmc);
   platform_set_drvdata(pdev, NULL);


-- 
Nicolas Ferre

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sdhci : reduce irq off latency

2010-08-30 Thread Matthieu CASTET

Hi Chris,

Chris Ball a écrit :

Hi Matthieu,

This patch didn't make it upstream.  Kyungmin offered a suggestion for 
fixing it -- would you like to resend an updated patch?
It seems http://marc.info/?l=linux-kernelm=127911287108683w=2 
(http://marc.info/?a=127137055700010r=1w=2) is a better solution.


Matthieu

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mmc: Add helper function to check if a card is removable

2010-08-30 Thread Matt Fleming
There are two checks that need to be made when determining whether a
card is removable. A host controller may set MMC_CAP_NONREMOVABLE if the
controller does not support removing cards (e.g. eMMC), in which case
the card is physically non-removable. Also the 'mmc_assume_removable'
module parameter can be configured at module load time, in which case
the card may be logically non-removable.

A helper function keeps the logic in one place so that code always
checks both conditions.

Signed-off-by: Matt Fleming m...@console-pimps.org
---

Guys, it'd be good if someone could give me a Tested-by: for this patch
just to make sure that it works as intended. Jaehoon, Kyungmin, does
this patch work for you?

 drivers/mmc/core/core.h  |1 -
 drivers/mmc/core/mmc.c   |2 +-
 drivers/mmc/core/sd.c|2 +-
 include/linux/mmc/host.h |8 
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 9d9eef5..a2ca770 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -58,7 +58,6 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
 /* Module parameters */
 extern int use_spi_crc;
-extern int mmc_assume_removable;
 
 /* Debugfs information for hosts and cards */
 void mmc_add_host_debugfs(struct mmc_host *host);
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index dcfc921..66c4a59 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -718,7 +718,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
 {
const struct mmc_bus_ops *bus_ops;
 
-   if (host-caps  MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+   if (!mmc_card_is_removable(host))
bus_ops = mmc_ops_unsafe;
else
bus_ops = mmc_ops;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 0f52410..bc745e1 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -750,7 +750,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
 {
const struct mmc_bus_ops *bus_ops;
 
-   if (host-caps  MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+   if (!mmc_card_is_removable(host))
bus_ops = mmc_sd_ops_unsafe;
else
bus_ops = mmc_sd_ops;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 09dbb90..c920cfc 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -272,5 +272,13 @@ static inline void mmc_set_disable_delay(struct mmc_host 
*host,
host-disable_delay = disable_delay;
 }
 
+/* Module parameter */
+extern int mmc_assume_removable;
+
+static inline int mmc_card_is_removable(struct mmc_host *host)
+{
+   return (!(host-caps  MMC_CAP_NONREMOVABLE)  mmc_assume_removable);
+}
+
 #endif
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V7] mxc : Add i.MX21 support to mxcmmc driver

2010-08-30 Thread Martin Fuzzey
Chris Ball wrote:
 Hi Martin,

 On Sat, Feb 13, 2010 at 04:36:32PM +0100, Martin Fuzzey wrote:
   
 Even though the i.MX21 SDHC module has the same revision number as the i.MX27
 one there are a few differences!!
 
 Looks like this wasn't merged.  Are you interested in resubmitting it?

   
Ok, I'll post a rebased version soon (next couple of days)

Regards,

Martin


--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] of_mmc_spi: add card detect irq support

2010-08-30 Thread Esben Haabendal
Hi

Comments below, and updated patch attached.

On Mon, Aug 30, 2010 at 3:29 PM, Anton Vorontsov cbouatmai...@gmail.com wrote:
 +static int of_mmc_spi_init(struct device *dev,
 +  irqreturn_t (*irqhandler)(int, void *), void *mmc)
 +{
 +   struct of_mmc_spi *oms = to_of_mmc_spi(dev);

 Please add an empty line here.

Ok.

 +   return request_threaded_irq(
 +   oms-detect_irq, NULL, irqhandler, 0, dev_name(dev), mmc);

 I'd write it this way:

 return request_threaded_irq(oms-detect_irq, NULL, irqhandler,
0, dev_name(dev), mmc);

 But that's a matter of taste.

Fine with me.

 +}
 +
 +static void of_mmc_spi_exit(struct device *dev, void *mmc)
 +{
 +   struct of_mmc_spi *oms = to_of_mmc_spi(dev);

 Empty line.

Ok.

 +   free_irq(oms-detect_irq, mmc);
 +}
 +
  struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
  {
 struct device *dev = spi-dev;
 @@ -121,8 +136,14 @@ struct mmc_spi_platform_data
 *mmc_spi_get_pdata(struct spi_device *spi)
 if (gpio_is_valid(oms-gpios[WP_GPIO]))
 oms-pdata.get_ro = of_mmc_spi_get_ro;

 -   /* We don't support interrupts yet, let's poll. */
 -   oms-pdata.caps |= MMC_CAP_NEEDS_POLL;
 +   oms-detect_irq = irq_of_parse_and_map(np, 0);
 +   if (oms-detect_irq != NO_IRQ) {

 I'd write if (oms-detect_irq), which is a bit more natural
 (and still correct, 0 is the only invalid VIRQ number).

Most other architectures has NO_IRQ defined to -1, so I will stick
with the NO_IRQ comparsion.
Hopefully, arm users will soon enjoy this driver/wrapper soon also.

 +   oms-pdata.init = of_mmc_spi_init;
 +   oms-pdata.exit = of_mmc_spi_exit;
 +   }
 +   else {

 } else {

Done.

 Plus, please add an appropriate interrupts =  bindings into
 Documentation/powerpc/dts-bindings/mmc-spi-slot.txt.

Done.

 And on the next resend, be sure to add Andrew Morton
 a...@linux-foundation.org, David Brownell
 dbrown...@users.sourceforge.net, and linux-mmc@vger.kernel.org
 the Cc list.

Should be there now.

/Esben
of_mmc_spi: add card detect irq support

Signed-off-by: Esben Haabendal e...@doredevelopment.dk
---
 .../powerpc/dts-bindings/mmc-spi-slot.txt  |9 ++-
 drivers/mmc/host/of_mmc_spi.c  |   26 ++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
index c39ac28..89a0084 100644
--- a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
+++ b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
@@ -7,8 +7,13 @@ Required properties:
 - voltage-ranges : two cells are required, first cell specifies minimum
   slot voltage (mV), second cell specifies maximum slot voltage (mV).
   Several ranges could be specified.
-- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,
+
+Optional properties:
+- gpios : may specify GPIOs in this order: Card-Detect GPIO,
   Write-Protect GPIO.
+- interrupts : the interrupt of a card detect interrupt.
+- interrupt-parent : the phandle for the interrupt controller that
+  services interrupts for this device.
 
 Example:
 
@@ -20,4 +25,6 @@ Example:
 			 qe_pio_d 15 0;
 		voltage-ranges = 3300 3300;
 		spi-max-frequency = 5000;
+		interrupts = 42;
+		interrupt-parent = PIC;
 	};
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index 1247e5d..5530def 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -34,6 +34,7 @@ enum {
 struct of_mmc_spi {
 	int gpios[NUM_GPIOS];
 	bool alow_gpios[NUM_GPIOS];
+	int detect_irq;
 	struct mmc_spi_platform_data pdata;
 };
 
@@ -61,6 +62,22 @@ static int of_mmc_spi_get_ro(struct device *dev)
 	return of_mmc_spi_read_gpio(dev, WP_GPIO);
 }
 
+static int of_mmc_spi_init(struct device *dev,
+			   irqreturn_t (*irqhandler)(int, void *), void *mmc)
+{
+	struct of_mmc_spi *oms = to_of_mmc_spi(dev);
+
+	return request_threaded_irq(oms-detect_irq, NULL, irqhandler, 0,
+dev_name(dev), mmc);
+}
+
+static void of_mmc_spi_exit(struct device *dev, void *mmc)
+{
+	struct of_mmc_spi *oms = to_of_mmc_spi(dev);
+
+	free_irq(oms-detect_irq, mmc);
+}
+
 struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
 {
 	struct device *dev = spi-dev;
@@ -121,8 +138,13 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
 	if (gpio_is_valid(oms-gpios[WP_GPIO]))
 		oms-pdata.get_ro = of_mmc_spi_get_ro;
 
-	/* We don't support interrupts yet, let's poll. */
-	oms-pdata.caps |= MMC_CAP_NEEDS_POLL;
+	oms-detect_irq = irq_of_parse_and_map(np, 0);
+	if (oms-detect_irq != NO_IRQ) {
+		oms-pdata.init = of_mmc_spi_init;
+		oms-pdata.exit = of_mmc_spi_exit;
+	} else {
+		oms-pdata.caps |= MMC_CAP_NEEDS_POLL;
+	}
 
 	dev-platform_data = oms-pdata;
 	return dev-platform_data;
-- 
1.7.1.1



Re: [PATCH] of_mmc_spi: add card detect irq support

2010-08-30 Thread David Brownell
Since I don't do OpenFirmware, let's hear from
Grant on this one.


--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] omap4 hsmmc : Adding card detect support for MMC1

2010-08-30 Thread kishore kadiyala
Adding card detect callback function and card detect configuration
function for MMC1 Controller.

Card detect configuration function does initial configuration of the
MMC Control  PullUp-PullDown registers of Phoenix.

For MMC1 Controller, Card detect interrupt source is
twl6030 and the card detect call back function provides card present/absent
status by reading MMC Control register.

Cc: Tony Lindgren t...@atomide.com
Cc: Adrian Hunter adrian.hun...@nokia.com
Cc: Madhusudhan Chikkature madhu...@ti.com
Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Kishore Kadiyala kishore.kadiy...@ti.com

---
 arch/arm/mach-omap2/board-4430sdp.c |7 +++-
 drivers/mfd/twl6030-irq.c   |   76 +++
 drivers/mmc/host/omap_hsmmc.c   |4 +-
 include/linux/i2c/twl.h |   31 ++
 4 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 9447644..a49f285 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -227,9 +227,14 @@ static int omap4_twl6030_hsmmc_late_init(struct device 
*dev)
struct omap_mmc_platform_data *pdata = dev-platform_data;

/* Setting MMC1 Card detect Irq */
-   if (pdev-id == 0)
+   if (pdev-id == 0) {
+   ret = twl6030_mmc_card_detect_config();
+   if (ret)
+   pr_err(Failed configuring MMC1 card detect\n);
pdata-slots[0].card_detect_irq = TWL6030_IRQ_BASE +
MMCDETECT_INTR_OFFSET;
+   pdata-slots[0].card_detect = twl6030_mmc_card_detect;
+   }
return ret;
 }

diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index 10bf228..91a6a45 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -36,6 +36,7 @@
 #include linux/irq.h
 #include linux/kthread.h
 #include linux/i2c/twl.h
+#include linux/platform_device.h

 /*
  * TWL6030 (unlike its predecessors, which had two level interrupt handling)
@@ -223,6 +224,81 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset)
 }
 EXPORT_SYMBOL(twl6030_interrupt_mask);

+int twl6030_mmc_card_detect_config(void)
+{
+   int ret;
+   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
+*/
+   ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
+   if (ret  0) {
+   pr_err(twl6030: Failed to read MMCCTRL, error %d\n, ret);
+   return ret;
+   }
+   reg_val = ~VMMC_AUTO_OFF;
+   reg_val |= SW_FC;
+   ret = twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
+   if (ret  0) {
+   return ret;
+   pr_err(twl6030: Failed to write MMCCTRL, error %d\n, ret);
+   }
+
+   /* Configuring PullUp-PullDown register */
+   ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, reg_val,
+   TWL6030_CFG_INPUT_PUPD3);
+   if (ret  0) {
+   return ret;
+   pr_err(twl6030: Failed to read CFG_INPUT_PUPD3, error %d\n,
+   ret);
+   }
+   reg_val = ~(MMC_PU | MMC_PD);
+   ret = twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val,
+   TWL6030_CFG_INPUT_PUPD3);
+   if (ret  0) {
+   pr_err(twl6030: Failed to write CFG_INPUT_PUPD3, error %d\n,
+   ret);
+   return ret;
+   }
+   return 0;
+}
+EXPORT_SYMBOL(twl6030_mmc_card_detect_config);
+
+int twl6030_mmc_card_detect(struct device *dev, int slot)
+{
+   int ret = -EIO;
+   u8 read_reg = 0;
+   struct platform_device *pdev = container_of(dev,
+   struct platform_device, dev);
+
+   switch (pdev-id) {
+   case 0:
+   /*
+* BIT0 of REG_MMC_CTRL
+* 0 - Card not present ,1 - Card present
+*/
+   ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, read_reg,
+   TWL6030_MMCCTRL);
+   if (ret = 0)
+   ret = read_reg  STS_MMC;
+   break;
+   default:
+   pr_err(Unkown MMC controller %d in %s\n, pdev-id, __func__);
+   }
+   return ret;
+}

[PATCH 0/3] OMAP hsmmc : card detect and Register offset handling

2010-08-30 Thread kishore kadiyala
Hi,

The patch series includes :
adding carddetect feature for MMC1 controller on OMAP4 and register offset 
handling
for OMAP3  OMAP4 and followed by a fix when CONFIG_MMC_OMAP_HS not selected 
for OMAP4.

Patch series has been tested on OMAP3430SDP and OMAP4430SDP

Kishore Kadiyala (2):
  omap4 hsmmc : Adding card detect support for MMC1
  omap3/omap4 hsmmc: Register offset handling

Benoit Cousson (1);
  omap4 hsmmc: Fix the init if CONFIG_MMC_OMAP_HS is not set

 arch/arm/mach-omap2/board-4430sdp.c   |   15 ++-
 arch/arm/mach-omap2/devices.c |   30 +++--
 arch/arm/mach-omap2/hsmmc.c   |6 +
 arch/arm/plat-omap/include/plat/mmc.h |   78 ++-
 drivers/mfd/twl6030-irq.c |   76 ++
 drivers/mmc/host/omap_hsmmc.c |  255 +++--
 include/linux/i2c/twl.h   |   31 
 7 files changed, 340 insertions(+), 151 deletions(-)


--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] omap3/omap4 hsmmc: Register offset handling

2010-08-30 Thread kishore kadiyala
OMAP4 not only have newly added hsmmc registers but also
have registers which were there in OMAP3 and which doesn't
have a common offset deviation compared to OMAP3.

For generic handling, OMAP3 and OMAP4 has different array's of
register offset maintained and right one is choosen during run time.

Cc: Tony Lindgren t...@atomide.com
Cc: Adrian Hunter adrian.hun...@nokia.com
Cc: Madhusudhan Chikkature madhu...@ti.com
Cc: Andrew Morton a...@linux-foundation.org
Signed-off-by: Kishore Kadiyala kishore.kadiy...@ti.com
---
 arch/arm/mach-omap2/devices.c |   30 +++--
 arch/arm/mach-omap2/hsmmc.c   |6 +
 arch/arm/plat-omap/include/plat/mmc.h |   78 ++-
 drivers/mmc/host/omap_hsmmc.c |  251 +++--
 4 files changed, 218 insertions(+), 147 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 2dbb265..03add6e 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -506,6 +506,8 @@ static inline void omap_init_sham(void) { }
 #define MMCHS_SYSCONFIG_SWRESET(1  1)
 #define MMCHS_SYSSTATUS0x0014
 #define MMCHS_SYSSTATUS_RESETDONE  (1  0)
+#define OMAP4_MMCHS_SYSCONFIG_SWRESET  (1  0)
+#define OMAP4_MMCHS_OFFSET 0x100

 static struct platform_device dummy_pdev = {
.dev = {
@@ -528,6 +530,8 @@ static struct platform_device dummy_pdev = {
 static void __init omap_hsmmc_reset(void)
 {
u32 i, nr_controllers;
+   u32 reg_val = 0;
+   u32 reg_off = 0;

if (cpu_is_omap242x())
return;
@@ -562,9 +566,6 @@ static void __init omap_hsmmc_reset(void)
break;
}

-   if (cpu_is_omap44xx())
-   base += OMAP4_MMC_REG_OFFSET;
-
dummy_pdev.id = i;
dev_set_name(dummy_pdev.dev, mmci-omap-hs.%d, i);
iclk = clk_get(dev, ick);
@@ -582,9 +583,18 @@ static void __init omap_hsmmc_reset(void)
break;
}

-   omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
-   v = omap_readl(base + MMCHS_SYSSTATUS);
-   while (!(omap_readl(base + MMCHS_SYSSTATUS) 
+   if (cpu_is_omap44xx())
+   reg_val = MMCHS_SYSCONFIG_SWRESET;
+   else
+   reg_val = MMCHS_SYSCONFIG_SWRESET;
+   omap_writel(reg_val, base + MMCHS_SYSCONFIG);
+
+   reg_off = MMCHS_SYSSTATUS;
+   if (cpu_is_omap44xx())
+   reg_off += OMAP4_MMCHS_OFFSET;
+   v = omap_readl(base + reg_off);
+
+   while (!(omap_readl(base + reg_off) 
 MMCHS_SYSSTATUS_RESETDONE))
cpu_relax();

@@ -745,13 +755,13 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data 
**mmc_data,
case 3:
if (!cpu_is_omap44xx())
return;
-   base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
+   base = OMAP4_MMC4_BASE;
irq = OMAP44XX_IRQ_MMC4;
break;
case 4:
if (!cpu_is_omap44xx())
return;
-   base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
+   base = OMAP4_MMC5_BASE;
irq = OMAP44XX_IRQ_MMC5;
break;
default:
@@ -762,10 +772,8 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data 
**mmc_data,
size = OMAP2420_MMC_SIZE;
name = mmci-omap;
} else if (cpu_is_omap44xx()) {
-   if (i  3) {
-   base += OMAP4_MMC_REG_OFFSET;
+   if (i  3)
irq += OMAP44XX_IRQ_GIC_START;
-   }
size = OMAP4_HSMMC_SIZE;
name = mmci-omap-hs;
} else {
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index c8f647b..d93b704 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -262,6 +262,12 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info 
*controllers)
mmc-slots[0].internal_clock = !c-ext_clock;
mmc-dma_mask = 0x;

+   /* Register offset Mapping */
+   if (cpu_is_omap44xx())
+   mmc-regs_map = (u16 *) omap4_mmc_reg_map;
+   else
+   mmc-regs_map = (u16 *) omap3_mmc_reg_map;
+
mmc-get_context_loss_count = hsmmc_get_context_loss;

mmc-slots[0].switch_pin = c-gpio_cd;
diff --git a/arch/arm/plat-omap/include/plat/mmc.h 
b/arch/arm/plat-omap/include/plat/mmc.h
index 

Re: [PATCH 1/3] omap4 hsmmc : Adding card detect support for MMC1

2010-08-30 Thread Matt Fleming
On Mon, Aug 30, 2010 at 11:18:23PM +0530, kishore kadiyala wrote:
 Adding card detect callback function and card detect configuration
 function for MMC1 Controller.
 
 Card detect configuration function does initial configuration of the
 MMC Control  PullUp-PullDown registers of Phoenix.
 
 For MMC1 Controller, Card detect interrupt source is
 twl6030 and the card detect call back function provides card present/absent
 status by reading MMC Control register.
 
 Cc: Tony Lindgren t...@atomide.com
 Cc: Adrian Hunter adrian.hun...@nokia.com
 Cc: Madhusudhan Chikkature madhu...@ti.com
 Cc: Andrew Morton a...@linux-foundation.org
 Signed-off-by: Kishore Kadiyala kishore.kadiy...@ti.com

[...]

 @@ -223,6 +224,81 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset)
  }
  EXPORT_SYMBOL(twl6030_interrupt_mask);
 
 +int twl6030_mmc_card_detect_config(void)
 +{
 + int ret;
 + 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
 +  */
 + ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
 + if (ret  0) {
 + pr_err(twl6030: Failed to read MMCCTRL, error %d\n, ret);
 + return ret;
 + }
 + reg_val = ~VMMC_AUTO_OFF;
 + reg_val |= SW_FC;
 + ret = twl_i2c_write_u8(TWL6030_MODULE_ID0, reg_val, TWL6030_MMCCTRL);
 + if (ret  0) {
 + return ret;
 + pr_err(twl6030: Failed to write MMCCTRL, error %d\n, ret);
 + }

Shouldn't this be

pr_err(twl6030: Failed to write MMCCTRL, error %d\n, ret);
return ret;

?

 +
 + /* Configuring PullUp-PullDown register */
 + ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, reg_val,
 + TWL6030_CFG_INPUT_PUPD3);
 + if (ret  0) {
 + return ret;
 + pr_err(twl6030: Failed to read CFG_INPUT_PUPD3, error %d\n,
 + ret);

Shouldn't this be,

pr_err(twl6030: Failed to read CFG_INPUT_PUPD3, error %d\n,
ret);
return ret;
?
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html