[PATCH] HDQ driver update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch updates the HDQ driver not to export omap_hdq_get, omap_hdq_put and omap_hdq_break fns,use them
internally in the driver.Remove the unused function omap_hdq_reset.

Signed-off-by: Madhusudhan Chikkature<madhu.cr@xxxxxx>

---
 drivers/w1/masters/omap_hdq.c   |   75 ++++++++++++++++++++++++----------------
 include/asm-arm/arch-omap/hdq.h |    9 ++--
 2 files changed, 50 insertions(+), 34 deletions(-)

Index: linux-omap-2.6-hdq-rework/drivers/w1/masters/omap_hdq.c
===================================================================
--- linux-omap-2.6-hdq-rework.orig/drivers/w1/masters/omap_hdq.c	2008-01-28 10:46:48.000000000 +0530
+++ linux-omap-2.6-hdq-rework/drivers/w1/masters/omap_hdq.c	2008-02-14 16:34:22.253898066 +0530
@@ -294,30 +294,9 @@ _omap_hdq_reset(void)
 }
 
 /*
- * Soft reset the HDQ controller.
- */
-int
-omap_hdq_reset(void)
-{
-	int ret;
-
-	ret = down_interruptible(&hdq_data->hdq_semlock);
-	if (ret < 0)
-		return -EINTR;
-
-	if (!hdq_data->hdq_usecount) {
-		up(&hdq_data->hdq_semlock);
-		return -EINVAL;
-	}
-	ret = _omap_hdq_reset();
-	up(&hdq_data->hdq_semlock);
-	return ret;
-}
-
-/*
  * Issue break pulse to the device.
  */
-int
+static int
 omap_hdq_break()
 {
 	int ret;
@@ -379,9 +358,8 @@ omap_hdq_break()
 	up(&hdq_data->hdq_semlock);
 	return ret;
 }
-EXPORT_SYMBOL(omap_hdq_break);
 
-int hdq_read_byte(u8 *val)
+static int hdq_read_byte(u8 *val)
 {
 	int ret;
 	u8 status;
@@ -437,7 +415,7 @@ int hdq_read_byte(u8 *val)
 /*
  * Enable clocks and set the controller to HDQ mode.
  */
-int
+static int
 omap_hdq_get()
 {
 	int ret = 0;
@@ -490,12 +468,11 @@ omap_hdq_get()
 	up(&hdq_data->hdq_semlock);
 	return ret;
 }
-EXPORT_SYMBOL(omap_hdq_get);
 
 /*
  * Disable clocks to the module.
  */
-int
+static int
 omap_hdq_put()
 {
 	int ret = 0;
@@ -518,7 +495,13 @@ omap_hdq_put()
 	up(&hdq_data->hdq_semlock);
 	return ret;
 }
-EXPORT_SYMBOL(omap_hdq_put);
+
+/*
+ * Used to control the call to omap_hdq_get and omap_hdq_put.
+ * HDQ Protocol: Write the CMD|REG_address first, followed by
+ * the data wrire or read.
+ */
+static int init_trans;
 
 /*
  * Read a byte of data from the device.
@@ -531,6 +514,13 @@ static u8 omap_w1_read_byte(void *data)
 	ret = hdq_read_byte(&val);
 	if (ret)
 		return -1;
+
+	/* Write followed by a read. */
+	if (init_trans) {
+		init_trans = 0;
+		omap_hdq_put();
+	}
+
 	return val;
 }
 
@@ -541,8 +531,21 @@ static void omap_w1_write_byte(void *dat
 {
 	u8 status;
 
+	/* First write to initialize the transfer */
+	if (init_trans == 0)
+		omap_hdq_get();
+
+	init_trans++;
+
 	hdq_write_byte(byte, &status);
 	pr_debug("Ctrl status %x\n", status);
+
+	/* Second write, data transfered. */
+	if (init_trans > 1) {
+		omap_hdq_put();
+		init_trans = 0;
+	}
+
 	return;
 }
 
@@ -602,10 +605,23 @@ static int __init omap_hdq_probe(struct 
 		return -ENODEV;
 	}
 
+	if (clk_enable(hdq_data->hdq_fck)) {
+		pr_debug("Can not enable fck\n");
+		clk_disable(hdq_data->hdq_ick);
+		clk_put(hdq_data->hdq_ick);
+		clk_put(hdq_data->hdq_fck);
+		platform_set_drvdata(pdev, NULL);
+		kfree(hdq_data);
+		return -ENODEV;
+	}
+
 	rev = hdq_reg_in(OMAP_HDQ_REVISION);
 	pr_info("OMAP HDQ Hardware Revision %c.%c. Driver in %s mode.\n",
 		(rev >> 4) + '0', (rev & 0x0f) + '0', "Interrupt");
 
+	spin_lock_init(&hdq_data->hdq_spinlock);
+	omap_hdq_break();
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq	< 0) {
 		platform_set_drvdata(pdev, NULL);
@@ -623,9 +639,10 @@ static int __init omap_hdq_probe(struct 
 		kfree(hdq_data);
 		return -ENODEV;
 	}
-	spin_lock_init(&hdq_data->hdq_spinlock);
+
 	/* don't clock the HDQ until it is needed */
 	clk_disable(hdq_data->hdq_ick);
+	clk_disable(hdq_data->hdq_fck);
 
 	ret = w1_add_master_device(&omap_w1_master);
 	if (ret) {
Index: linux-omap-2.6-hdq-rework/include/asm-arm/arch-omap/hdq.h
===================================================================
--- linux-omap-2.6-hdq-rework.orig/include/asm-arm/arch-omap/hdq.h	2008-01-28 10:46:48.000000000 +0530
+++ linux-omap-2.6-hdq-rework/include/asm-arm/arch-omap/hdq.h	2008-02-12 14:36:41.988642027 +0530
@@ -13,10 +13,9 @@
 #define __ASM_OMAP2_HDQ_H__
 
 /* Note the following APIs have to be called in a process context */
-int omap_hdq_get(void); /* request the HDQ block */
-int omap_hdq_put(void); /* release the HDQ block */
-int omap_hdq_break(void); /* reset the slave by sending it a break pulse */
-
-int omap_hdq_reset(void); /* reset the HDQ block */
+static int omap_hdq_get(void); /* request the HDQ block */
+static int omap_hdq_put(void); /* release the HDQ block */
+/* reset the slave by sending it a break pulse */
+static int omap_hdq_break(void);
 
 #endif

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

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux