56 #include <linux/kernel.h>
57 #include <linux/module.h>
59 #include <linux/pci.h>
62 #include <linux/i2c.h>
66 static int blacklist[] = {
88 #define SIS5595_EXTENT 8
90 #define SMB_STS_LO 0x00
91 #define SMB_STS_HI 0x01
92 #define SMB_CTL_LO 0x02
93 #define SMB_CTL_HI 0x03
105 #define SMB_INDEX 0x38
107 #define SIS5595_ENABLE_REG 0x40
108 #define ACPI_BASE 0x90
111 #define MAX_TIMEOUT 500
114 #define SIS5595_QUICK 0x00
115 #define SIS5595_BYTE 0x02
116 #define SIS5595_BYTE_DATA 0x04
117 #define SIS5595_WORD_DATA 0x06
118 #define SIS5595_PROC_CALL 0x08
119 #define SIS5595_BLOCK_DATA 0x0A
125 static u16 force_addr;
127 MODULE_PARM_DESC(force_addr,
"Initialize the base address of the i2c controller");
130 static unsigned short sis5595_base;
131 static struct pci_dev *sis5595_pdev;
153 for (i = blacklist; *i != 0; i++) {
157 dev_err(&SIS5595_dev->
dev,
"Looked for SIS5595 but found unsupported device %.4x\n", *i);
164 pci_read_config_word(SIS5595_dev,
ACPI_BASE, &sis5595_base);
165 if (sis5595_base == 0 && force_addr == 0) {
166 dev_err(&SIS5595_dev->
dev,
"ACPI base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n");
172 dev_dbg(&SIS5595_dev->
dev,
"ACPI Base address: %04x\n", sis5595_base);
177 sis5595_driver.name);
182 sis5595_driver.name)) {
183 dev_err(&SIS5595_dev->
dev,
"SMBus registers 0x%04x-0x%04x already in use!\n",
189 dev_info(&SIS5595_dev->
dev,
"forcing ISA address 0x%04X\n", sis5595_base);
190 if (pci_write_config_word(SIS5595_dev,
ACPI_BASE, sis5595_base)
193 if (pci_read_config_word(SIS5595_dev,
ACPI_BASE, &a)
198 dev_err(&SIS5595_dev->
dev,
"force address failed - not supported?\n");
206 if ((val & 0x80) == 0) {
214 if ((val & 0x80) == 0) {
216 dev_err(&SIS5595_dev->
dev,
"ACPI enable failed - not supported?\n");
229 static int sis5595_transaction(
struct i2c_adapter *adap)
238 dev_dbg(&adap->
dev,
"SMBus busy (%04x). Resetting...\n", temp);
242 dev_dbg(&adap->
dev,
"Failed! (%02x)\n", temp);
256 }
while (!(temp & 0x40) && (timeout++ <
MAX_TIMEOUT));
265 dev_dbg(&adap->
dev,
"Error: Failed bus transaction\n");
270 dev_err(&adap->
dev,
"Bus collision! SMBus may be locked until "
271 "next hard reset (or not...)\n");
284 dev_dbg(&adap->
dev,
"Failed reset at end of transaction (%02x)\n", temp);
291 unsigned short flags,
char read_write,
298 sis5595_write(
SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
302 sis5595_write(
SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
304 sis5595_write(
SMB_CMD, command);
308 sis5595_write(
SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
309 sis5595_write(
SMB_CMD, command);
316 sis5595_write(
SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
317 sis5595_write(
SMB_CMD, command);
321 (data->
word & 0xff00) >> 8);
326 dev_warn(&adap->
dev,
"Unsupported transaction %d\n", size);
332 status = sis5595_transaction(adap);
362 .smbus_xfer = sis5595_access,
363 .functionality = sis5595_func,
369 .algo = &smbus_algorithm,
383 if (sis5595_setup(dev)) {
384 dev_err(&dev->
dev,
"SIS5595 not detected, module not inserted.\n");
389 sis5595_adapter.
dev.parent = &dev->
dev;
392 "SMBus SIS5595 adapter at %04x", sis5595_base +
SMB_INDEX);
408 .name =
"sis5595_smbus",
409 .id_table = sis5595_ids,
410 .probe = sis5595_probe,
413 static int __init i2c_sis5595_init(
void)
415 return pci_register_driver(&sis5595_driver);
418 static void __exit i2c_sis5595_exit(
void)