37 #include <linux/module.h>
38 #include <linux/pci.h>
39 #include <linux/kernel.h>
41 #include <linux/stddef.h>
43 #include <linux/i2c.h>
49 #define SMB_ADDR_OFFSET 0xE0
51 #define SMB_GLOBAL_STATUS (0x0 + amd756_ioport)
52 #define SMB_GLOBAL_ENABLE (0x2 + amd756_ioport)
53 #define SMB_HOST_ADDRESS (0x4 + amd756_ioport)
54 #define SMB_HOST_DATA (0x6 + amd756_ioport)
55 #define SMB_HOST_COMMAND (0x8 + amd756_ioport)
56 #define SMB_HOST_BLOCK_DATA (0x9 + amd756_ioport)
57 #define SMB_HAS_DATA (0xA + amd756_ioport)
58 #define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_ioport)
59 #define SMB_HAS_HOST_ADDRESS (0xE + amd756_ioport)
60 #define SMB_SNOOP_ADDRESS (0xF + amd756_ioport)
66 #define SMBBANFORCE 0x014
75 #define MAX_TIMEOUT 500
78 #define AMD756_QUICK 0x00
79 #define AMD756_BYTE 0x01
80 #define AMD756_BYTE_DATA 0x02
81 #define AMD756_WORD_DATA 0x03
82 #define AMD756_PROCESS_CALL 0x04
83 #define AMD756_BLOCK_DATA 0x05
86 static unsigned short amd756_ioport;
93 #define GS_ABRT_STS (1 << 0)
94 #define GS_COL_STS (1 << 1)
95 #define GS_PRERR_STS (1 << 2)
96 #define GS_HST_STS (1 << 3)
97 #define GS_HCYC_STS (1 << 4)
98 #define GS_TO_STS (1 << 5)
99 #define GS_SMB_STS (1 << 11)
101 #define GS_CLEAR_STS (GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \
102 GS_HCYC_STS | GS_TO_STS )
104 #define GE_CYC_TYPE_MASK (7)
105 #define GE_HOST_STC (1 << 3)
106 #define GE_ABORT (1 << 5)
109 static int amd756_transaction(
struct i2c_adapter *adap)
115 dev_dbg(&adap->
dev,
"Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
122 dev_dbg(&adap->
dev,
"SMBus busy (%04x). Waiting...\n", temp);
130 dev_dbg(&adap->
dev,
"Busy wait timeout (%04x)\n", temp);
153 dev_dbg(&adap->
dev,
"SMBus Protocol error (no response)!\n");
163 dev_dbg(&adap->
dev,
"SMBus protocol timeout!\n");
167 dev_dbg(&adap->
dev,
"SMBus protocol success!\n");
174 "Failed reset at end of transaction (%04x)\n", temp);
179 "Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
195 unsigned short flags,
char read_write,
203 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
208 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
215 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
223 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
231 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
235 len = data->
block[0];
242 for (i = 1; i <= len; i++)
249 dev_warn(&adap->
dev,
"Unsupported transaction %d\n", size);
256 status = amd756_transaction(adap);
276 if(data->
block[0] > 32)
279 for (i = 1; i <= data->
block[0]; i++)
295 .smbus_xfer = amd756_access,
296 .functionality = amd756_func,
302 .algo = &smbus_algorithm,
306 static const char* chipname[] = {
307 "AMD756",
"AMD766",
"AMD768",
308 "nVidia nForce",
"AMD8111",
330 int nforce = (
id->driver_data ==
NFORCE);
335 dev_err(&pdev->
dev,
"Only one device supported "
336 "(you have a strange motherboard, btw)\n");
344 pci_read_config_word(pdev,
SMBBANFORCE, &amd756_ioport);
345 amd756_ioport &= 0xfffc;
350 pci_read_config_byte(pdev,
SMBGCFG, &temp);
351 if ((temp & 128) == 0) {
353 "Error: SMBus controller I/O not enabled!\n");
359 pci_read_config_word(pdev,
SMBBA, &amd756_ioport);
360 amd756_ioport &= 0xff00;
370 dev_err(&pdev->
dev,
"SMB region 0x%x already in use!\n",
375 pci_read_config_byte(pdev,
SMBREV, &temp);
377 dev_dbg(&pdev->
dev,
"AMD756_smba = 0x%X\n", amd756_ioport);
380 amd756_smbus.
dev.parent = &pdev->
dev;
383 "SMBus %s adapter at %04x", chipname[id->
driver_data],
389 "Adapter registration failed, module not inserted\n");
407 .name =
"amd756_smbus",
408 .id_table = amd756_ids,
409 .probe = amd756_probe,