Re: [PATCH 1/3] omap4 hsmmc : Adding card detect support for MMC1
Oops my fault will correct it and repost ... Regards, Kishore On Tue, Aug 31, 2010 at 11:25 AM, Matt Fleming wrote: > 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 >> Cc: Adrian Hunter >> Cc: Madhusudhan Chikkature >> Cc: Andrew Morton >> Signed-off-by: Kishore Kadiyala > > [...] > >> @@ -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, ®_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, ®_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 > -- 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/3] omap4 hsmmc : Adding card detect support for MMC1
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 > Cc: Adrian Hunter > Cc: Madhusudhan Chikkature > Cc: Andrew Morton > Signed-off-by: Kishore Kadiyala [...] > @@ -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, ®_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, ®_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
[PATCH 1/3] omap4 hsmmc : Adding card detect support for MMC1
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 Cc: Adrian Hunter Cc: Madhusudhan Chikkature Cc: Andrew Morton Signed-off-by: Kishore Kadiyala --- 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 #include #include +#include /* * 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, ®_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, ®_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; +} +EXPORT_SYMBOL(twl6030_mmc_card_detect); + int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) { diff --git a/drivers/