ALI1563 SMBus driver fix
PATCH 1/1 ALI1563 SMBus driver fix
Hi Greg,
Following patch contains fixies to "grave" errors of ALI1563 SMBus driver. It removes checking for HST_STS_DONE bit, because this bit is raised only after finishing for block transfers in newer chips revisions. Then it fixes missing "and" mask for transfer type settings. And to third it fixes the "continous byte mode" transaction, because command is not transfered in command register but in DAT0 register. Last thing it changes is error recovery and error messages. All was successfully tested with help
of Chunhao Huang from Winbond.
I added my name to source because now I feel quite familiar with the chip. :)
Please apply.
Thanks
Regards
Rudolf
drivers/i2c/busses/i2c-ali1563.c +32 -16
@@ -1,4 +1,4 @@ -/** +/* * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge * * Copyright (C) 2004 Patrick Mochel
@@ -13,6 +13,9 @@* with a little help from the ALi 1563 spec. * * This file is released under the GPLv2 +* +* 2005-04-08: Fixed SMBus mode setting, fixed byte data transactions +* Rudolf Marek <[email protected]> */ #include <linux/module.h>
@@ -55,8 +58,7 @@#define HST_CNTL2_BYTE_DATA 0x02#define HST_CNTL2_WORD_DATA 0x03#define HST_CNTL2_BLOCK 0x05 - - +#define HST_CNTL2_SIZEMASK 0x38static unsigned short ali1563_smba;
@@ -73,7 +75,7 @@ data =inb_p (SMB_HST_STS );if (data &HST_STS_BAD ) { -dev_warn (&a->dev,"ali1563: Trying to reset busy device\n" ); +dev_err (&a->dev,"ali1563: Trying to reset busy device\n" );outb_p (data |HST_STS_BAD ,SMB_HST_STS ); data =inb_p (SMB_HST_STS );if (data &HST_STS_BAD )
@@ -94,19 +96,31 @@if (timeout && !(data &HST_STS_BAD ))return 0 ; -dev_warn (&a->dev,"SMBus Error: %s%s%s%s%s\n" , - timeout ?"Timeout " :"" , - data &HST_STS_FAIL ?"Transaction Failed " :"" , - data &HST_STS_BUSERR ?"No response or Bus Collision " :"" , - data &HST_STS_DEVERR ?"Device Error " :"" , - !(data &HST_STS_DONE ) ?"Transaction Never Finished " :"" ); -if (!(data &HST_STS_DONE )) +if (!timeout) { +dev_err (&a->dev,"Timeout - Trying to KILL transaction!\n" );/* Issue 'kill' to host controller */ outb_p (HST_CNTL2_KILL ,SMB_HST_CNTL2 ); -else -/* Issue timeout to reset all devices on bus */ + data =inb_p (SMB_HST_STS ); + } + +/* device error - probably missing ACK, from autdetection I2C_QUICK */ +if (data &HST_STS_DEVERR ) { +dev_dbg (&a->dev,"Device error!\n" ); + } + +/* bus collision */ +if (data &HST_STS_BUSERR ) { +dev_err (&a->dev,"Bus collision!\n" ); +/* Issue timeout, hoping it helps */ outb_p (HST_CNTL1_TIMEOUT ,SMB_HST_CNTL1 ); + } + +if (data &HST_STS_FAIL ) { +dev_err (&a->dev,"Cleaning fail after KILL!\n" ); +outb_p (0x0 ,SMB_HST_CNTL2 ); + } +return -1 ; }
@@ -149,7 +163,7 @@if (timeout && !(data &HST_STS_BAD ))return 0 ; - dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", + dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", timeout ? "Timeout " : "", data & HST_STS_FAIL ? "Transaction Failed " : "", data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
@@ -242,13 +256,15 @@ }outb_p (((addr &0x7f ) <<1 ) | (rw &0x01 ),SMB_HST_ADD ); -outb_p (inb_p (SMB_HST_CNTL2 ) | (size <<3 ),SMB_HST_CNTL2 ); +outb_p ((inb_p (SMB_HST_CNTL2 ) & ~HST_CNTL2_SIZEMASK ) | (size <<3 ),SMB_HST_CNTL2 );/* Write the command register */ +switch (size) {case HST_CNTL2_BYTE :if (rw=I2C_SMBUS_WRITE ) -outb_p (cmd,SMB_HST_CMD ); +/* Beware it uses DAT0 register and not CMD !!! */ +outb_p (cmd,SMB_HST_DAT0 );break ;case HST_CNTL2_BYTE_DATA :outb_p (cmd,SMB_HST_CMD );
PATCH 1/1 ALI1563 SMBus driver fix
Quoted 11 lines · On Mon, Apr 11, 2005 at 08:17:12AM -0000, [email protected] wrote:
Hi Greg,
Following patch contains fixies to "grave" errors of ALI1563 SMBus driver. It removes checking for
HST_STS_DONEbit, because this bit is raised only after finishing for block transfers in newer chips revisions. Then it fixes missing "and" mask for transfer type settings. And to third it fixes the "continous byte mode" transaction, because command is not transfered in command register but in DAT0 register. Last thing it changes is error recovery and error messages. All was successfully tested with help
of Chunhao Huang from Winbond.
Quoted 1 line
I added my name to source because now I feel quite familiar with the chip. :)
Did you email Pat Mochel about these changes to make sure nothing breaks on his hardware?
Also, I need a Signed-off-by: line (as the fileDocumentation/SubmittingPatches states).
Quoted 10 lines
diff -Naur
a/drivers/i2c/busses/i2c-ali1563.cc/drivers/i2c/busses/i2c-ali1563.cdrivers/i2c/busses/i2c-ali1563.c +1
-1@@ -1,4 +1,4 @@ -/** +/* * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge * * Copyright (C) 2004 Patrick Mochel
drivers/i2c/busses/i2c-ali1563.c line 19
Quoted 7 lines
drivers/i2c/busses/i2c-ali1563.c +3
-0@@ -13,6 +13,9 @@* with a little help from the ALi 1563 spec. * * This file is released under the GPLv2 +* +* 2005-04-08: Fixed SMBus mode setting, fixed byte data transactions +* Rudolf Marek <[email protected]> */
Please do not add change log information to a .c file, it is not needed, and only gets old and stale.
thanks,
greg k-h
PATCH 1/1 ALI1563 SMBus driver fix
In reply to [email protected]Hi Ruik,
drivers/i2c/busses/i2c-ali1563.c line 4
Quoted 5 lines
drivers/i2c/busses/i2c-ali1563.c +1
-1-/** +/* * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge * * Copyright (C) 2004 Patrick Mochel
Please avoid noise in patches, it doesn't help review.
drivers/i2c/busses/i2c-ali1563.c line 110
Quoted 4 lines
drivers/i2c/busses/i2c-ali1563.c +4
-0+/* device error - probably missing ACK, from autdetection I2C_QUICK */ +if (data &HST_STS_DEVERR ) { +dev_dbg (&a->dev,"Device error!\n" ); + }
I don't like this. If this "error" is normal for I2C_QUICK, then don't issue any message and return 0 in this case, and issue an *error*, not debug, message in the other cases.
As far as I can see, this means adding a second parameter to ali1563_transaction, but I don't think this is a problem.
drivers/i2c/busses/i2c-ali1563.c line 263
Quoted 3 lines
drivers/i2c/busses/i2c-ali1563.c +1
-0/* Write the command register */ +switch (size) {
Noise :p
I'm otherwise fine with your patch, thanks a lot for your great investigation work on this.
Signature · 1 line
Jean Delvare
PATCH 1/1 ALI1563 SMBus driver fix
In reply to [email protected]Hi Greg and Jean
I'm very sorry about my patch submitting policy I hope I will improve in future :)
Quoted 10 lines
drivers/i2c/busses/i2c-ali1563.c line 110
Quoted 5 lines
drivers/i2c/busses/i2c-ali1563.c +4
-0+/* device error - probably missing ACK, from autdetection I2C_QUICK */ +if (data &HST_STS_DEVERR ) { +dev_dbg (&a->dev,"Device error!\n" ); + }I don't like this. If this "error" is normal for
I2C_QUICK, then don't issue any message and return 0 in this case, and issue an *error*, not debug, message in the other cases.
Yes this will happen when no-one will respond to I2C_QUICK. If we would return 0;
then i2cdetect would have detected all devices as "present"??? (Or am I missing something? Its quite late here...When someting will respond to I2C QUICK we would leave the routine more to the top)
Quoted 3 lines
As far as I can see, this means adding a second parameter to
ali1563_transaction, but I don't think this is a problem.
Please can you explain more? Or tomorrow on IRC if you want...
I will remove all noise in future revisions of this patch.
Quoted 2 lines
I'm otherwise fine with your patch, thanks a lot for your great investigation work on this.
Thank you, it was nice detective story, so I'm proud that I found all "murders" in our case. Funny is that I could not take a look to book :)
Before I will create new patch I will send patch to Patrick in extra thread.
Regards
Rudolf
PATCH 1/1 ALI1563 SMBus driver fix
In reply to [email protected]Hi Rudolf,
Quoted 9 lines
Quoted 8 lines
drivers/i2c/busses/i2c-ali1563.c line 110
Quoted 5 lines
drivers/i2c/busses/i2c-ali1563.c +4
-0+/* device error - probably missing ACK, from autdetection I2C_QUICK */ +if (data &HST_STS_DEVERR ) { +dev_dbg (&a->dev,"Device error!\n" ); + }I don't like this. If this "error" is normal for
I2C_QUICK, then don't issue any message and return 0 in this case, and issue an *error*, not debug, message in the other cases.
Quoted 4 lines
Yes this will happen when no-one will respond to
I2C_QUICK. If we would return 0; then i2cdetect would have detected all devices as "present"??? (Or am I missing something? Its quite late here...When someting will respond to I2C QUICK we would leave the routine more to the top)
Ah, OK, *I* missed something then. I thought that the "error" was expected on any I2C_QUICK command, not just un-acked ones. So the returned value is indeed just fine.
Still, wouldn't it be better to have dev_dbg only in the case of I2C_QUICK, and dev_warn or even dev_err otherwise? The way things are done for now, most errors are likely to be unnoticed unless debug mode is enabled,
Quoted 4 lines
Quoted 2 lines
As far as I can see, this means adding a second parameter to
ali1563_transaction, but I don't think this is a problem.Please can you explain more? Or tomorrow on IRC if you want...
For now, you have no way (that I can see) in ali1563_transaction() to know what kind of SMBus command is done. If you want to be able to handle I2C_QUICK errors differently from other commands errors, you will have to pass it to that function as an extra argument, unless I'm missing something again.
Quoted 1 line
I will remove all noise in future revisions of this patch.
Thanks.
Quoted 1 line
Funny is that I could not take a look to book :)
That's not exactly funny :(
--
Jean Delvare