···239W: http://www.linux-usb.org/SpeedTouch/240S: Maintained241000000242ALPHA PORT243P: Richard Henderson244M: rth@twiddle.net
···239W: http://www.linux-usb.org/SpeedTouch/240S: Maintained241242+ALI1563 I2C DRIVER243+P: Rudolf Marek244+M: r.marek@sh.cvut.cz245+L: sensors@stimpy.netroedge.com246+S: Maintained247+248ALPHA PORT249P: Richard Henderson250M: rth@twiddle.net
+31-15
drivers/i2c/busses/i2c-ali1563.c
···2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge3 *4 * Copyright (C) 2004 Patrick Mochel05 *6 * The 1563 southbridge is deceptively similar to the 1533, with a7 * few notable exceptions. One of those happens to be the fact they···58#define HST_CNTL2_BLOCK 0x05596006162static unsigned short ali1563_smba;6364-static int ali1563_transaction(struct i2c_adapter * a)65{66 u32 data;67 int timeout;···7576 data = inb_p(SMB_HST_STS);77 if (data & HST_STS_BAD) {78- dev_warn(&a->dev,"ali1563: Trying to reset busy device\n");79 outb_p(data | HST_STS_BAD,SMB_HST_STS);80 data = inb_p(SMB_HST_STS);81 if (data & HST_STS_BAD)···9697 if (timeout && !(data & HST_STS_BAD))98 return 0;99- dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n",100- timeout ? "Timeout " : "",101- data & HST_STS_FAIL ? "Transaction Failed " : "",102- data & HST_STS_BUSERR ? "No response or Bus Collision " : "",103- data & HST_STS_DEVERR ? "Device Error " : "",104- !(data & HST_STS_DONE) ? "Transaction Never Finished " : "");105106- if (!(data & HST_STS_DONE))0107 /* Issue 'kill' to host controller */108 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2);109- else110- /* Issue timeout to reset all devices on bus */0000000000111 outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1);0000000112 return -1;113}114···163164 if (timeout && !(data & HST_STS_BAD))165 return 0;166- dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n",167 timeout ? "Timeout " : "",168 data & HST_STS_FAIL ? "Transaction Failed " : "",169 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",···256 }257258 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);259- outb_p(inb_p(SMB_HST_CNTL2) | (size << 3), SMB_HST_CNTL2);260261 /* Write the command register */0262 switch(size) {263 case HST_CNTL2_BYTE:264 if (rw== I2C_SMBUS_WRITE)265- outb_p(cmd, SMB_HST_CMD);0266 break;267 case HST_CNTL2_BYTE_DATA:268 outb_p(cmd, SMB_HST_CMD);···284 goto Done;285 }286287- if ((error = ali1563_transaction(a)))288 goto Done;289290 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK))
···2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge3 *4 * Copyright (C) 2004 Patrick Mochel5+ * 2005 Rudolf Marek <r.marek@sh.cvut.cz>6 *7 * The 1563 southbridge is deceptively similar to the 1533, with a8 * few notable exceptions. One of those happens to be the fact they···57#define HST_CNTL2_BLOCK 0x05585960+#define HST_CNTL2_SIZEMASK 0x386162static unsigned short ali1563_smba;6364+static int ali1563_transaction(struct i2c_adapter * a, int size)65{66 u32 data;67 int timeout;···7374 data = inb_p(SMB_HST_STS);75 if (data & HST_STS_BAD) {76+ dev_err(&a->dev, "ali1563: Trying to reset busy device\n");77 outb_p(data | HST_STS_BAD,SMB_HST_STS);78 data = inb_p(SMB_HST_STS);79 if (data & HST_STS_BAD)···9495 if (timeout && !(data & HST_STS_BAD))96 return 0;0000009798+ if (!timeout) {99+ dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n");100 /* Issue 'kill' to host controller */101 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2);102+ data = inb_p(SMB_HST_STS);103+ }104+105+ /* device error - no response, ignore the autodetection case */106+ if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) {107+ dev_err(&a->dev, "Device error!\n");108+ }109+110+ /* bus collision */111+ if (data & HST_STS_BUSERR) {112+ dev_err(&a->dev, "Bus collision!\n");113+ /* Issue timeout, hoping it helps */114 outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1);115+ }116+117+ if (data & HST_STS_FAIL) {118+ dev_err(&a->dev, "Cleaning fail after KILL!\n");119+ outb_p(0x0,SMB_HST_CNTL2);120+ }121+122 return -1;123}124···149150 if (timeout && !(data & HST_STS_BAD))151 return 0;152+ dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n",153 timeout ? "Timeout " : "",154 data & HST_STS_FAIL ? "Transaction Failed " : "",155 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",···242 }243244 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);245+ outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) | (size << 3), SMB_HST_CNTL2);246247 /* Write the command register */248+249 switch(size) {250 case HST_CNTL2_BYTE:251 if (rw== I2C_SMBUS_WRITE)252+ /* Beware it uses DAT0 register and not CMD! */253+ outb_p(cmd, SMB_HST_DAT0);254 break;255 case HST_CNTL2_BYTE_DATA:256 outb_p(cmd, SMB_HST_CMD);···268 goto Done;269 }270271+ if ((error = ali1563_transaction(a, size)))272 goto Done;273274 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK))