linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Twibright I2C2P driver
@ 2004-12-27 13:18 Karel Kulhavy
  2004-12-27 15:06 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Karel Kulhavy @ 2004-12-27 13:18 UTC (permalink / raw)
  To: linux-kernel

Hello

I have just published Twibright I2C2P:

    * I2C interface (adaptor) for parallel port
    * Free technology electronics device
    * Bidirectional: Both SDA and SCL are bidirectional
    * Optically isolated
    * Powered from parallel port
    * Driver for Linux kernel 

http://i2c2p.twibright.com

The driver is at the end of this mail. The driver is tested and seems to
work flawlessly (which of course doesn't say much about it correctness ;-) )
The driver was developed on 2.6.8.1, 2.6.9 and 2.6.10 kernels.

Cl<

diff -Pur linux-2.6.9/drivers/i2c/busses/i2c-parport.c linux-2.6.9-patched/drivers/i2c/busses/i2c-parport.c
--- linux-2.6.9/drivers/i2c/busses/i2c-parport.c	2004-10-18 23:54:31.000000000 +0200
+++ linux-2.6.9-patched/drivers/i2c/busses/i2c-parport.c	2004-12-21 13:47:58.000000000 +0100
@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 #include <linux/parport.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
@@ -140,7 +141,11 @@
 	.getscl		= parport_getscl,
 	.udelay		= 60,
 	.mdelay		= 60,
-	.timeout	= HZ,
+	.timeout	= (HZ+99)/100,
+			/* This is 10ms. Parport adapter of type 6 may be
+			 * powered down which introduces 90sec delay to
+			 * machine boot. I consider 10ms to be sufficient for
+			 * the parport adapter timeout. --Clock */
 }; 
 
 /* ----- I2c and parallel port call-back functions and structures --------- */
@@ -190,6 +195,14 @@
 	/* Other init if needed (power on...) */
 	if (adapter_parm[type].init.val)
 		line_set(port, 1, &adapter_parm[type].init);
+	if (adapter_parm[type].init2.val)
+		line_set(port, 1, &adapter_parm[type].init2);
+	if (adapter_parm[type].init3.val)
+		line_set(port, 1, &adapter_parm[type].init3);
+	
+	/* Wait until the adapter puffs up */
+	if (adapter_parm[type].msleep)
+		msleep_interruptible(adapter_parm[type].msleep);
 
 	parport_release(adapter->pdev);
 
@@ -220,6 +233,10 @@
 			/* Un-init if needed (power off...) */
 			if (adapter_parm[type].init.val)
 				line_set(port, 0, &adapter_parm[type].init);
+			if (adapter_parm[type].init2.val)
+				line_set(port, 0, &adapter_parm[type].init2);
+			if (adapter_parm[type].init3.val)
+				line_set(port, 0, &adapter_parm[type].init3);
 				
 			i2c_bit_del_bus(&adapter->adapter);
 			parport_unregister_device(adapter->pdev);
diff -Pur linux-2.6.9/drivers/i2c/busses/i2c-parport.h linux-2.6.9-patched/drivers/i2c/busses/i2c-parport.h
--- linux-2.6.9/drivers/i2c/busses/i2c-parport.h	2004-10-18 23:55:29.000000000 +0200
+++ linux-2.6.9-patched/drivers/i2c/busses/i2c-parport.h	2004-12-21 12:33:18.000000000 +0100
@@ -38,6 +38,9 @@
 	struct lineop getsda;
 	struct lineop getscl;
 	struct lineop init;
+	struct lineop init2;	/* Added by Clock                    */
+	struct lineop init3;	/* Needed by Twibright I2C2P driver. */
+	int msleep;		/* Milliseconds after init           */
 };
 
 static struct adapter_parm adapter_parm[] = {
@@ -47,18 +50,21 @@
 		.setscl	= { 0x08, CTRL, 0 },
 		.getsda	= { 0x80, STAT, 0 },
 		.getscl	= { 0x08, STAT, 0 },
+		.msleep = 0,
 	},
 	/* type 1: home brew teletext adapter */
 	{
 		.setsda	= { 0x02, DATA, 0 },
 		.setscl	= { 0x01, DATA, 0 },
 		.getsda	= { 0x80, STAT, 1 },
+		.msleep = 0,
 	},
 	/* type 2: Velleman K8000 adapter */
 	{
 		.setsda	= { 0x02, CTRL, 1 },
 		.setscl	= { 0x08, CTRL, 1 },
 		.getsda	= { 0x10, STAT, 0 },
+		.msleep = 0,
 	},
 	/* type 3: ELV adapter */
 	{
@@ -66,6 +72,7 @@
 		.setscl	= { 0x01, DATA, 1 },
 		.getsda	= { 0x40, STAT, 1 },
 		.getscl	= { 0x08, STAT, 1 },
+		.msleep = 0,
 	},
 	/* type 4: ADM1032 evaluation board */
 	{
@@ -73,12 +80,25 @@
 		.setscl	= { 0x01, DATA, 1 },
 		.getsda	= { 0x10, STAT, 1 },
 		.init	= { 0xf0, DATA, 0 },
+		.msleep = 0,
 	},
 	/* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */
 	{
 		.setsda	= { 0x02, DATA, 1 },
 		.setscl	= { 0x01, DATA, 1 },
 		.getsda	= { 0x10, STAT, 1 },
+		.msleep = 0,
+	},
+	/* type 6: Twibright I2C2P adapter */
+	{
+		.setsda = { 0x01, CTRL, 1},
+		.getsda = { 0x80, STAT, 1},
+		.setscl = { 0x08, CTRL, 1},
+		.getscl = { 0x40, STAT, 0},
+		.init	= { 0xff, DATA, 0},
+		.init2	= { 0x04, CTRL, 0},
+		.init3	= { 0x02, CTRL, 1},
+		.msleep = 100,
 	},
 };
 
@@ -91,4 +111,5 @@
 	" 2 = Velleman K8000 adapter\n"
 	" 3 = ELV adapter\n"
 	" 4 = ADM1032 evaluation board\n"
-	" 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n");
+	" 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"
+	" 6 = Twibright I2C2P adapter\n");

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Twibright I2C2P driver
  2004-12-27 13:18 [PATCH] Twibright I2C2P driver Karel Kulhavy
@ 2004-12-27 15:06 ` Pavel Machek
       [not found]   ` <20041227155621.GC4626@beton.cybernet.src>
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2004-12-27 15:06 UTC (permalink / raw)
  To: Karel Kulhavy; +Cc: linux-kernel

Hi!

> I have just published Twibright I2C2P:
> 
>     * I2C interface (adaptor) for parallel port
>     * Free technology electronics device
>     * Bidirectional: Both SDA and SCL are bidirectional
>     * Optically isolated
>     * Powered from parallel port
>     * Driver for Linux kernel 

Its quite short. Did you forget to attach actual c source? Or is it
this simple?

> @@ -140,7 +141,11 @@
>  	.getscl		= parport_getscl,
>  	.udelay		= 60,
>  	.mdelay		= 60,
> -	.timeout	= HZ,
> +	.timeout	= (HZ+99)/100,
> +			/* This is 10ms. Parport adapter of type 6 may be
> +			 * powered down which introduces 90sec delay to
> +			 * machine boot. I consider 10ms to be sufficient for

90msec?

> +			 * the parport adapter timeout. --Clock */

Avoid signing comments like this. Neccessary info is
in bitkeeper logs anyway.
> @@ -38,6 +38,9 @@
>  	struct lineop getsda;
>  	struct lineop getscl;
>  	struct lineop init;
> +	struct lineop init2;	/* Added by Clock                    */

and this.


				Pavel
-- 
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Twibright I2C2P driver
       [not found]   ` <20041227155621.GC4626@beton.cybernet.src>
@ 2004-12-27 20:09     ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2004-12-27 20:09 UTC (permalink / raw)
  To: Karel Kulhavy; +Cc: kernel list

Hi!

> > Avoid signing comments like this. Neccessary info is
> > in bitkeeper logs anyway.
> 
> How does the general public determine? BK is a proprietary software, they
> can't just download and check. Or is this information not supposed to be
> published?

It is available through the web frontend and through the cvs
repository, too.
								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-27 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-27 13:18 [PATCH] Twibright I2C2P driver Karel Kulhavy
2004-12-27 15:06 ` Pavel Machek
     [not found]   ` <20041227155621.GC4626@beton.cybernet.src>
2004-12-27 20:09     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).