linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kronos <kronos@kronoz.cjb.net>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Linux Fbdev development list <linux-fbdev-devel@lists.sourceforge.net>
Subject: Re: [PATCH] Remove voodoo code from i2c
Date: Sat, 6 Mar 2004 01:47:47 +0100	[thread overview]
Message-ID: <20040306004747.GA3218@dreamland.darkstar.lan> (raw)
In-Reply-To: <1078530914.5700.127.camel@gaston>

Il Sat, Mar 06, 2004 at 10:55:14AM +1100, Benjamin Herrenschmidt ha scritto: 
> On Sat, 2004-03-06 at 08:52, Kronos wrote:
> > Hi,
> > radeon_probe_i2c_connector contains very strange code that just send
> > empty start-stop sequencies on the I2C bus. I copied the code from
> > XFree86, but speaking with I2C gurus the general feeling is that this
> > code can go away without any harm. I tested it on 3 different setup (all
> > x86...) and it works well. I don't have any "old" monitor around to
> > fiddle with though.
> > 
> > Oh, if you think that this code should stay I'll send you another patch
> > to make it more readable.
> 
> I'd rather keep the code as close to XFree as possible at this point..

Ok, what about this (cosmetic) patch:

--- linux-2.6/drivers/video/aty/radeon_i2c.c.orig	Sat Feb 28 18:11:42 2004
+++ linux-2.6/drivers/video/aty/radeon_i2c.c	Sat Feb 28 18:49:31 2004
@@ -174,65 +174,59 @@
 int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, u8 **out_edid)
 {
 	u32 reg = rinfo->i2c[conn-1].ddc_reg;
+	struct radeon_i2c_chan *chan = &rinfo->i2c[conn-1];
 	u8 *edid = NULL;
 	int i, j;
 
 	OUTREG(reg, INREG(reg) & 
 			~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
 
-	OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
-	(void)INREG(reg);
+	radeon_gpio_setscl(chan, 1);
 
 	for (i = 0; i < 3; i++) {
 		/* For some old monitors we need the
 		 * following process to initialize/stop DDC
 		 */
-		OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
-		(void)INREG(reg);
+		radeon_gpio_setsda(chan, 1);
 		wait_ms(13);
 
-		OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
-		(void)INREG(reg);
+		radeon_gpio_setscl(chan, 1);
 		for (j = 0; j < 5; j++) {
+			/* Wait for ack */
 			wait_ms(10);
-			if (INREG(reg) & VGA_DDC_CLK_INPUT)
+			if (radeon_gpio_getscl(chan))
 				break;
 		}
 		if (j == 5)
 			continue;
 
-		OUTREG(reg, INREG(reg) | VGA_DDC_DATA_OUT_EN);
-		(void)INREG(reg);
+		radeon_gpio_setsda(chan, 0);
 		wait_ms(15);
-		OUTREG(reg, INREG(reg) | VGA_DDC_CLK_OUT_EN);
-		(void)INREG(reg);
+		radeon_gpio_setscl(chan, 0);
 		wait_ms(15);
-		OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
-		(void)INREG(reg);
+		radeon_gpio_setsda(chan, 1);
 		wait_ms(15);
 
 		/* Do the real work */
-		edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn-1]);
+		edid = radeon_do_probe_i2c_edid(chan);
 
-		OUTREG(reg, INREG(reg) | 
-				(VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
-		(void)INREG(reg);
+		radeon_gpio_setsda(chan, 0);
+		radeon_gpio_setscl(chan, 0);
 		wait_ms(15);
-		
-		OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
-		(void)INREG(reg);
+	
+		radeon_gpio_setscl(chan, 1);
 		for (j = 0; j < 10; j++) {
+			/* Wait for ack */
 			wait_ms(10);
-			if (INREG(reg) & VGA_DDC_CLK_INPUT)
+			if (radeon_gpio_getscl(chan))
 				break;
 		}
 
-		OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
-		(void)INREG(reg);
+		radeon_gpio_setsda(chan, 1);
 		wait_ms(15);
-		OUTREG(reg, INREG(reg) |
-				(VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
-		(void)INREG(reg);
+
+		radeon_gpio_setsda(chan, 0);
+		radeon_gpio_setscl(chan, 0);
 		if (edid)
 			break;
 	}

In this way it clearer what's going on.

Luca
-- 
Home: http://kronoz.cjb.net
"Sei l'unica donna della mia vita".
(Adamo)


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

  reply	other threads:[~2004-03-06  1:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-05 21:52 [PATCH] Remove voodoo code from i2c Kronos
2004-03-05 23:55 ` Benjamin Herrenschmidt
2004-03-06  0:47   ` Kronos [this message]
2004-03-06  2:10     ` Jon Smirl
2004-03-06  3:42       ` Benjamin Herrenschmidt
2004-03-06  4:02         ` Jon Smirl
2004-03-06 15:08       ` Kronos
2004-03-08 22:17   ` Richard Smith
2004-03-08 22:56     ` Benjamin Herrenschmidt
2004-03-06  0:12 ` Michel Dänzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040306004747.GA3218@dreamland.darkstar.lan \
    --to=kronos@kronoz.cjb.net \
    --cc=benh@kernel.crashing.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).