diff mbox

davinci: Correct ro and cd feature in DM355

Message ID 1248243504-8384-1-git-send-email-vipin.bhandari@ti.com (mailing list archive)
State Rejected
Headers show

Commit Message

Vipin Bhandari July 22, 2009, 6:18 a.m. UTC
This patch corrects the support for MMCSD card detection
and read only feature for SoC DM355.

Signed-off-by: Vipin Bhandari <vipin.bhandari@ti.com>
---
 This patch has been tested on DM355 EVM.

 arch/arm/mach-davinci/board-dm355-evm.c |  107 +++++++++++++++++++++++-------
 1 files changed, 82 insertions(+), 25 deletions(-)

Comments

David Brownell July 22, 2009, 9:54 a.m. UTC | #1
On Tuesday 21 July 2009, Vipin Bhandari wrote:
> This patch corrects the support for MMCSD card detection
> and read only feature for SoC DM355.
> 
> Signed-off-by: Vipin Bhandari <vipin.bhandari@ti.com>
> ---
>  This patch has been tested on DM355 EVM.


I don't follow.  It does seem like some indices in
the current driver, drivers/mfd/dm355evm_msp.c, may
need to swap ... but why would a patch changing two
lines of code need to get blown up into

> 
>  arch/arm/mach-davinci/board-dm355-evm.c |  107 +++++++++++++++++++++++-------
>  1 files changed, 82 insertions(+), 25 deletions(-)

.... 107 lines of changes, breaking the RTC and IR/Remote
drivers in the process????

NAK on this patch.

It looks like you should only need to swap two index
pairs in the drivers/mfd code, and add a comment about
how the docs are wrong.

- Dave
Vipin Bhandari July 22, 2009, 10:59 a.m. UTC | #2
Thank you for the suggestion. I'll submit the patch again with the desired
changes.

Thanks and regards,
~Vipin


> -----Original Message-----
> From: David Brownell [mailto:david-b@pacbell.net]
> Sent: Wednesday, July 22, 2009 3:25 PM
> To: davinci-linux-open-source@linux.davincidsp.com; Vipin Bhandari
> Subject: Re: [PATCH] davinci: Correct ro and cd feature in DM355
> 
> On Tuesday 21 July 2009, Vipin Bhandari wrote:
> > This patch corrects the support for MMCSD card detection
> > and read only feature for SoC DM355.
> >
> > Signed-off-by: Vipin Bhandari <vipin.bhandari@ti.com>
> > ---
> >  This patch has been tested on DM355 EVM.
> 
> 
> I don't follow.  It does seem like some indices in
> the current driver, drivers/mfd/dm355evm_msp.c, may
> need to swap ... but why would a patch changing two
> lines of code need to get blown up into
> 
> >
> >  arch/arm/mach-davinci/board-dm355-evm.c |  107
> +++++++++++++++++++++++-------
> >  1 files changed, 82 insertions(+), 25 deletions(-)
> 
> .... 107 lines of changes, breaking the RTC and IR/Remote
> drivers in the process????
> 
> NAK on this patch.
> 
> It looks like you should only need to swap two index
> pairs in the drivers/mfd code, and add a comment about
> how the docs are wrong.
> 
> - Dave
> 
>
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index ff55c52..92c3781 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -113,6 +113,37 @@  static struct platform_device davinci_nand_device = {
 	},
 };
 
+
+/*
+ * MSP430 supports card detection and write protection checking
+ */
+static struct i2c_client *dm355evm_msp;
+
+static int dm355evm_msp_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+	dm355evm_msp = client;
+	return 0;
+}
+
+static int dm355evm_msp_remove(struct i2c_client *client)
+{
+	dm355evm_msp = NULL;
+	return 0;
+}
+
+static const struct i2c_device_id dm355evm_msp_ids[] = {
+	{ "dm355evm_msp", 0, },
+	{ /* end of list */ },
+};
+
+static struct i2c_driver dm355evm_msp_driver = {
+	.driver.name	= "dm355evm_msp",
+	.id_table	= dm355evm_msp_ids,
+	.probe		= dm355evm_msp_probe,
+	.remove		= dm355evm_msp_remove,
+};
+
 static struct davinci_i2c_platform_data i2c_pdata = {
 	.bus_freq	= 400	/* kHz */,
 	.bus_delay	= 0	/* usec */,
@@ -120,25 +151,9 @@  static struct davinci_i2c_platform_data i2c_pdata = {
 
 static struct snd_platform_data dm355_evm_snd_data;
 
-static int dm355evm_mmc_gpios = -EINVAL;
-
-static void dm355evm_mmcsd_gpios(unsigned gpio)
-{
-	gpio_request(gpio + 0, "mmc0_ro");
-	gpio_request(gpio + 1, "mmc0_cd");
-	gpio_request(gpio + 2, "mmc1_ro");
-	gpio_request(gpio + 3, "mmc1_cd");
 
-	/* we "know" these are input-only so we don't
-	 * need to call gpio_direction_input()
-	 */
-
-	dm355evm_mmc_gpios = gpio;
-}
-
-static struct i2c_board_info dm355evm_i2c_info[] = {
+static struct i2c_board_info __initdata dm355evm_i2c_info[] = {
 	{ I2C_BOARD_INFO("dm355evm_msp", 0x25),
-		.platform_data = dm355evm_mmcsd_gpios,
 		/* plus irq */ },
 	/* { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }, */
 	/* { I2C_BOARD_INFO("tvp5146", 0x5d), }, */
@@ -152,6 +167,8 @@  static void __init evm_init_i2c(void)
 	gpio_direction_input(5);
 	dm355evm_i2c_info[0].irq = gpio_to_irq(5);
 
+	i2c_add_driver(&dm355evm_msp_driver);
+
 	i2c_register_board_info(1, dm355evm_i2c_info,
 			ARRAY_SIZE(dm355evm_i2c_info));
 }
@@ -194,20 +211,60 @@  static void __init dm355_evm_map_io(void)
 	dm355_init();
 }
 
-static int dm355evm_mmc_get_cd(int module)
+static int dm355evm_msp430_get_pins(void)
 {
-	if (!gpio_is_valid(dm355evm_mmc_gpios))
+	static const char txbuf[1] = {0x06};
+	char buf[1];
+	struct i2c_msg msg[2] = {
+		{
+			.addr = dm355evm_msp->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = (void __force *)txbuf,
+		},
+		{
+			.addr = dm355evm_msp->addr,
+			.flags = I2C_M_RD,
+			.len = 1,
+			.buf = buf,
+		},
+	};
+	int status;
+
+	if (!dm355evm_msp)
 		return -ENXIO;
-	/* low == card present */
-	return !gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 1);
+
+	status = i2c_transfer(dm355evm_msp->adapter, msg, 2);
+	if (status < 0)
+		return status;
+
+	return buf[0];
+}
+
+static int dm355evm_mmc_get_cd(int module)
+{
+	int status = dm355evm_msp430_get_pins();
+	/* Bit value low == card present */
+	/* Note: EVMDM355_ECP_VA4.pdf suggests that Bit 2 and 4 should
+	 * be checked for card detection. However on the EVM bit 1 and 3 gives
+	 * this status, respectively for 0 and 1 instance */
+	if (module == 0)
+		return (status < 0) ? status : !(status & BIT(1));
+	else
+		return (status < 0) ? status : !(status & BIT(3));
 }
 
 static int dm355evm_mmc_get_ro(int module)
 {
-	if (!gpio_is_valid(dm355evm_mmc_gpios))
-		return -ENXIO;
-	/* high == card's write protect switch active */
-	return gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 0);
+	int status = dm355evm_msp430_get_pins();
+	/* Bit value high == card's write protect switch active */
+	/* Note: EVMDM355_ECP_VA4.pdf suggests that Bit 1 and 3 should
+	 * be checked for card detection. However on the EVM bit 2 and 4 gives
+	 * this status, respectively for 0 and 1 instance */
+	if (module == 0)
+		return (status < 0) ? status : status & BIT(2);
+	else
+		return (status < 0) ? status : status & BIT(4);
 }
 
 static struct davinci_mmc_config dm355evm_mmc_config = {