29 #include <linux/module.h>
31 #include <linux/kernel.h>
33 #include <linux/stddef.h>
35 #include <linux/i2c.h>
41 #define SMBHSTCNT (0 + sch_smba)
42 #define SMBHSTSTS (1 + sch_smba)
43 #define SMBHSTADD (4 + sch_smba)
44 #define SMBHSTCMD (5 + sch_smba)
45 #define SMBHSTDAT0 (6 + sch_smba)
46 #define SMBHSTDAT1 (7 + sch_smba)
47 #define SMBBLKDAT (0x20 + sch_smba)
50 #define MAX_RETRIES 5000
53 #define SCH_QUICK 0x00
55 #define SCH_BYTE_DATA 0x02
56 #define SCH_WORD_DATA 0x03
57 #define SCH_BLOCK_DATA 0x05
59 static unsigned short sch_smba;
67 static int sch_transaction(
void)
73 dev_dbg(&sch_adapter.dev,
"Transaction (pre): CNT=%02x, CMD=%02x, "
83 dev_dbg(&sch_adapter.dev,
"Completion (%02x). "
87 dev_dbg(&sch_adapter.dev,
"SMBus error (%02x). "
88 "Resetting...\n", temp);
94 "SMBus is not ready: (%02x)\n", temp);
105 }
while ((temp & 0x08) && (retries++ <
MAX_RETRIES));
109 dev_err(&sch_adapter.dev,
"SMBus Timeout!\n");
114 dev_dbg(&sch_adapter.dev,
"Bus collision! SMBus may be "
115 "locked until next hard reset. (sorry!)\n");
117 }
else if (temp & 0x02) {
119 dev_err(&sch_adapter.dev,
"Error: no response!\n");
120 }
else if (temp & 0x01) {
121 dev_dbg(&sch_adapter.dev,
"Post complete!\n");
126 dev_dbg(&sch_adapter.dev,
"Failed reset at end of "
127 "transaction (%02x), Bus error!\n", temp);
131 dev_dbg(&sch_adapter.dev,
"No such address.\n");
133 dev_dbg(&sch_adapter.dev,
"Transaction (post): CNT=%02x, CMD=%02x, "
148 unsigned short flags,
char read_write,
156 dev_dbg(&sch_adapter.dev,
"SMBus busy (%02x)\n", temp);
159 dev_dbg(&sch_adapter.dev,
"access size: %d %s\n", size,
160 (read_write)?
"READ":
"WRITE");
192 len = data->
block[0];
196 for (i = 1; i <= len; i++)
202 dev_warn(&adap->
dev,
"Unsupported transaction %d\n", size);
208 rc = sch_transaction();
227 for (i = 1; i <= data->
block[0]; i++)
242 .smbus_xfer = sch_access,
243 .functionality = sch_func,
249 .algo = &smbus_algorithm,
262 dev_err(&dev->
dev,
"SMBus region 0x%x already in use!\n",
267 sch_smba = res->
start;
269 dev_dbg(&dev->
dev,
"SMBA = 0x%X\n", sch_smba);
272 sch_adapter.
dev.parent = &dev->
dev;
275 "SMBus SCH adapter at %04x", sch_smba);
279 dev_err(&dev->
dev,
"Couldn't register adapter!\n");
302 .name =
"isch_smbus",
305 .probe = smbus_sch_probe,