aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-09-24 16:22:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-09-24 16:22:33 -0400
commitbaea7b946f00a291b166ccae7fcfed6c01530cc6 (patch)
tree4aa275fbdbec9c7b9b4629e8bee2bbecd3c6a6af /drivers/i2c/busses
parentae19ffbadc1b2100285a5b5b3d0a4e0a11390904 (diff)
parent94e0fb086fc5663c38bbc0fe86d698be8314f82f (diff)
Merge branch 'origin' into for-linus
Conflicts: MAINTAINERS
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/Kconfig19
-rw-r--r--drivers/i2c/busses/Makefile3
-rw-r--r--drivers/i2c/busses/i2c-imx.c3
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c4
-rw-r--r--drivers/i2c/busses/i2c-piix4.c9
-rw-r--r--drivers/i2c/busses/i2c-pnx.c7
-rw-r--r--drivers/i2c/busses/i2c-scmi.c430
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c39
-rw-r--r--drivers/i2c/busses/i2c-taos-evm.c45
-rw-r--r--drivers/i2c/busses/scx200_acb.c6
10 files changed, 529 insertions, 36 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 834a03414900..737335ff2b21 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -113,7 +113,7 @@ config I2C_ISCH
113 will be called i2c-isch. 113 will be called i2c-isch.
114 114
115config I2C_PIIX4 115config I2C_PIIX4
116 tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)" 116 tristate "Intel PIIX4 and compatible (ATI/AMD/Serverworks/Broadcom/SMSC)"
117 depends on PCI 117 depends on PCI
118 help 118 help
119 If you say yes to this option, support will be included for the Intel 119 If you say yes to this option, support will be included for the Intel
@@ -128,6 +128,7 @@ config I2C_PIIX4
128 ATI SB600 128 ATI SB600
129 ATI SB700 129 ATI SB700
130 ATI SB800 130 ATI SB800
131 AMD SB900
131 Serverworks OSB4 132 Serverworks OSB4
132 Serverworks CSB5 133 Serverworks CSB5
133 Serverworks CSB6 134 Serverworks CSB6
@@ -231,6 +232,22 @@ config I2C_VIAPRO
231 This driver can also be built as a module. If so, the module 232 This driver can also be built as a module. If so, the module
232 will be called i2c-viapro. 233 will be called i2c-viapro.
233 234
235if ACPI
236
237comment "ACPI drivers"
238
239config I2C_SCMI
240 tristate "SMBus Control Method Interface"
241 help
242 This driver supports the SMBus Control Method Interface. It needs the
243 BIOS to declare ACPI control methods as described in the SMBus Control
244 Method Interface specification.
245
246 To compile this driver as a module, choose M here:
247 the module will be called i2c-scmi.
248
249endif # ACPI
250
234comment "Mac SMBus host controller drivers" 251comment "Mac SMBus host controller drivers"
235 depends on PPC_CHRP || PPC_PMAC 252 depends on PPC_CHRP || PPC_PMAC
236 253
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index e654263bfc01..ff937ac69f5b 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -2,6 +2,9 @@
2# Makefile for the i2c bus drivers. 2# Makefile for the i2c bus drivers.
3# 3#
4 4
5# ACPI drivers
6obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o
7
5# PC SMBus host controller drivers 8# PC SMBus host controller drivers
6obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o 9obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o
7obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o 10obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 0b486a63460d..4afba3ec2a61 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -609,13 +609,12 @@ static int __init i2c_adap_imx_init(void)
609{ 609{
610 return platform_driver_probe(&i2c_imx_driver, i2c_imx_probe); 610 return platform_driver_probe(&i2c_imx_driver, i2c_imx_probe);
611} 611}
612subsys_initcall(i2c_adap_imx_init);
612 613
613static void __exit i2c_adap_imx_exit(void) 614static void __exit i2c_adap_imx_exit(void)
614{ 615{
615 platform_driver_unregister(&i2c_imx_driver); 616 platform_driver_unregister(&i2c_imx_driver);
616} 617}
617
618module_init(i2c_adap_imx_init);
619module_exit(i2c_adap_imx_exit); 618module_exit(i2c_adap_imx_exit);
620 619
621MODULE_LICENSE("GPL"); 620MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index c3869d94ad42..bbab0e166630 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -293,13 +293,13 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data)
293 } 293 }
294} 294}
295 295
296static int 296static irqreturn_t
297mv64xxx_i2c_intr(int irq, void *dev_id) 297mv64xxx_i2c_intr(int irq, void *dev_id)
298{ 298{
299 struct mv64xxx_i2c_data *drv_data = dev_id; 299 struct mv64xxx_i2c_data *drv_data = dev_id;
300 unsigned long flags; 300 unsigned long flags;
301 u32 status; 301 u32 status;
302 int rc = IRQ_NONE; 302 irqreturn_t rc = IRQ_NONE;
303 303
304 spin_lock_irqsave(&drv_data->lock, flags); 304 spin_lock_irqsave(&drv_data->lock, flags);
305 while (readl(drv_data->reg_base + MV64XXX_I2C_REG_CONTROL) & 305 while (readl(drv_data->reg_base + MV64XXX_I2C_REG_CONTROL) &
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 0249a7d762b9..a782c7a08f9e 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -22,6 +22,7 @@
22 Intel PIIX4, 440MX 22 Intel PIIX4, 440MX
23 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100 23 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
24 ATI IXP200, IXP300, IXP400, SB600, SB700, SB800 24 ATI IXP200, IXP300, IXP400, SB600, SB700, SB800
25 AMD SB900
25 SMSC Victory66 26 SMSC Victory66
26 27
27 Note: we assume there can only be one device, with one SMBus interface. 28 Note: we assume there can only be one device, with one SMBus interface.
@@ -479,6 +480,7 @@ static struct pci_device_id piix4_ids[] = {
479 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_SMBUS) }, 480 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_SMBUS) },
480 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) }, 481 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) },
481 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) }, 482 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) },
483 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SMBUS) },
482 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 484 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
483 PCI_DEVICE_ID_SERVERWORKS_OSB4) }, 485 PCI_DEVICE_ID_SERVERWORKS_OSB4) },
484 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 486 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
@@ -499,9 +501,10 @@ static int __devinit piix4_probe(struct pci_dev *dev,
499{ 501{
500 int retval; 502 int retval;
501 503
502 if ((dev->vendor == PCI_VENDOR_ID_ATI) && 504 if ((dev->vendor == PCI_VENDOR_ID_ATI &&
503 (dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS) && 505 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
504 (dev->revision >= 0x40)) 506 dev->revision >= 0x40) ||
507 dev->vendor == PCI_VENDOR_ID_AMD)
505 /* base address location etc changed in SB800 */ 508 /* base address location etc changed in SB800 */
506 retval = piix4_setup_sb800(dev, id); 509 retval = piix4_setup_sb800(dev, id);
507 else 510 else
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index ec15cff556b9..6ff6c20f1e78 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -586,7 +586,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
586 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; 586 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
587 587
588 /* Register I/O resource */ 588 /* Register I/O resource */
589 if (!request_region(alg_data->base, I2C_PNX_REGION_SIZE, pdev->name)) { 589 if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE,
590 pdev->name)) {
590 dev_err(&pdev->dev, 591 dev_err(&pdev->dev,
591 "I/O region 0x%08x for I2C already in use.\n", 592 "I/O region 0x%08x for I2C already in use.\n",
592 alg_data->base); 593 alg_data->base);
@@ -650,7 +651,7 @@ out_clock:
650out_unmap: 651out_unmap:
651 iounmap((void *)alg_data->ioaddr); 652 iounmap((void *)alg_data->ioaddr);
652out_release: 653out_release:
653 release_region(alg_data->base, I2C_PNX_REGION_SIZE); 654 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
654out_drvdata: 655out_drvdata:
655 platform_set_drvdata(pdev, NULL); 656 platform_set_drvdata(pdev, NULL);
656out: 657out:
@@ -667,7 +668,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
667 i2c_del_adapter(adap); 668 i2c_del_adapter(adap);
668 i2c_pnx->set_clock_stop(pdev); 669 i2c_pnx->set_clock_stop(pdev);
669 iounmap((void *)alg_data->ioaddr); 670 iounmap((void *)alg_data->ioaddr);
670 release_region(alg_data->base, I2C_PNX_REGION_SIZE); 671 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
671 platform_set_drvdata(pdev, NULL); 672 platform_set_drvdata(pdev, NULL);
672 673
673 return 0; 674 return 0;
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
new file mode 100644
index 000000000000..276a046ac93f
--- /dev/null
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -0,0 +1,430 @@
1/*
2 * SMBus driver for ACPI SMBus CMI
3 *
4 * Copyright (C) 2009 Crane Cai <crane.cai@amd.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation version 2.
9 */
10
11#include <linux/module.h>
12#include <linux/slab.h>
13#include <linux/kernel.h>
14#include <linux/stddef.h>
15#include <linux/init.h>
16#include <linux/i2c.h>
17#include <linux/acpi.h>
18
19#define ACPI_SMBUS_HC_CLASS "smbus"
20#define ACPI_SMBUS_HC_DEVICE_NAME "cmi"
21
22ACPI_MODULE_NAME("smbus_cmi");
23
24struct smbus_methods_t {
25 char *mt_info;
26 char *mt_sbr;
27 char *mt_sbw;
28};
29
30struct acpi_smbus_cmi {
31 acpi_handle handle;
32 struct i2c_adapter adapter;
33 u8 cap_info:1;
34 u8 cap_read:1;
35 u8 cap_write:1;
36};
37
38static const struct smbus_methods_t smbus_methods = {
39 .mt_info = "_SBI",
40 .mt_sbr = "_SBR",
41 .mt_sbw = "_SBW",
42};
43
44static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
45 {"SMBUS01", 0},
46 {"", 0}
47};
48
49#define ACPI_SMBUS_STATUS_OK 0x00
50#define ACPI_SMBUS_STATUS_FAIL 0x07
51#define ACPI_SMBUS_STATUS_DNAK 0x10
52#define ACPI_SMBUS_STATUS_DERR 0x11
53#define ACPI_SMBUS_STATUS_CMD_DENY 0x12
54#define ACPI_SMBUS_STATUS_UNKNOWN 0x13
55#define ACPI_SMBUS_STATUS_ACC_DENY 0x17
56#define ACPI_SMBUS_STATUS_TIMEOUT 0x18
57#define ACPI_SMBUS_STATUS_NOTSUP 0x19
58#define ACPI_SMBUS_STATUS_BUSY 0x1a
59#define ACPI_SMBUS_STATUS_PEC 0x1f
60
61#define ACPI_SMBUS_PRTCL_WRITE 0x00
62#define ACPI_SMBUS_PRTCL_READ 0x01
63#define ACPI_SMBUS_PRTCL_QUICK 0x02
64#define ACPI_SMBUS_PRTCL_BYTE 0x04
65#define ACPI_SMBUS_PRTCL_BYTE_DATA 0x06
66#define ACPI_SMBUS_PRTCL_WORD_DATA 0x08
67#define ACPI_SMBUS_PRTCL_BLOCK_DATA 0x0a
68
69
70static int
71acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
72 char read_write, u8 command, int size,
73 union i2c_smbus_data *data)
74{
75 int result = 0;
76 struct acpi_smbus_cmi *smbus_cmi = adap->algo_data;
77 unsigned char protocol;
78 acpi_status status = 0;
79 struct acpi_object_list input;
80 union acpi_object mt_params[5];
81 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
82 union acpi_object *obj;
83 union acpi_object *pkg;
84 char *method;
85 int len = 0;
86
87 dev_dbg(&adap->dev, "access size: %d %s\n", size,
88 (read_write) ? "READ" : "WRITE");
89 switch (size) {
90 case I2C_SMBUS_QUICK:
91 protocol = ACPI_SMBUS_PRTCL_QUICK;
92 command = 0;
93 if (read_write == I2C_SMBUS_WRITE) {
94 mt_params[3].type = ACPI_TYPE_INTEGER;
95 mt_params[3].integer.value = 0;
96 mt_params[4].type = ACPI_TYPE_INTEGER;
97 mt_params[4].integer.value = 0;
98 }
99 break;
100
101 case I2C_SMBUS_BYTE:
102 protocol = ACPI_SMBUS_PRTCL_BYTE;
103 if (read_write == I2C_SMBUS_WRITE) {
104 mt_params[3].type = ACPI_TYPE_INTEGER;
105 mt_params[3].integer.value = 0;
106 mt_params[4].type = ACPI_TYPE_INTEGER;
107 mt_params[4].integer.value = 0;
108 } else {
109 command = 0;
110 }
111 break;
112
113 case I2C_SMBUS_BYTE_DATA:
114 protocol = ACPI_SMBUS_PRTCL_BYTE_DATA;
115 if (read_write == I2C_SMBUS_WRITE) {
116 mt_params[3].type = ACPI_TYPE_INTEGER;
117 mt_params[3].integer.value = 1;
118 mt_params[4].type = ACPI_TYPE_INTEGER;
119 mt_params[4].integer.value = data->byte;
120 }
121 break;
122
123 case I2C_SMBUS_WORD_DATA:
124 protocol = ACPI_SMBUS_PRTCL_WORD_DATA;
125 if (read_write == I2C_SMBUS_WRITE) {
126 mt_params[3].type = ACPI_TYPE_INTEGER;
127 mt_params[3].integer.value = 2;
128 mt_params[4].type = ACPI_TYPE_INTEGER;
129 mt_params[4].integer.value = data->word;
130 }
131 break;
132
133 case I2C_SMBUS_BLOCK_DATA:
134 protocol = ACPI_SMBUS_PRTCL_BLOCK_DATA;
135 if (read_write == I2C_SMBUS_WRITE) {
136 len = data->block[0];
137 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
138 return -EINVAL;
139 mt_params[3].type = ACPI_TYPE_INTEGER;
140 mt_params[3].integer.value = len;
141 mt_params[4].type = ACPI_TYPE_BUFFER;
142 mt_params[4].buffer.pointer = data->block + 1;
143 }
144 break;
145
146 default:
147 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
148 return -EOPNOTSUPP;
149 }
150
151 if (read_write == I2C_SMBUS_READ) {
152 protocol |= ACPI_SMBUS_PRTCL_READ;
153 method = smbus_methods.mt_sbr;
154 input.count = 3;
155 } else {
156 protocol |= ACPI_SMBUS_PRTCL_WRITE;
157 method = smbus_methods.mt_sbw;
158 input.count = 5;
159 }
160
161 input.pointer = mt_params;
162 mt_params[0].type = ACPI_TYPE_INTEGER;
163 mt_params[0].integer.value = protocol;
164 mt_params[1].type = ACPI_TYPE_INTEGER;
165 mt_params[1].integer.value = addr;
166 mt_params[2].type = ACPI_TYPE_INTEGER;
167 mt_params[2].integer.value = command;
168
169 status = acpi_evaluate_object(smbus_cmi->handle, method, &input,
170 &buffer);
171 if (ACPI_FAILURE(status)) {
172 ACPI_ERROR((AE_INFO, "Evaluating %s: %i", method, status));
173 return -EIO;
174 }
175
176 pkg = buffer.pointer;
177 if (pkg && pkg->type == ACPI_TYPE_PACKAGE)
178 obj = pkg->package.elements;
179 else {
180 ACPI_ERROR((AE_INFO, "Invalid argument type"));
181 result = -EIO;
182 goto out;
183 }
184 if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
185 ACPI_ERROR((AE_INFO, "Invalid argument type"));
186 result = -EIO;
187 goto out;
188 }
189
190 result = obj->integer.value;
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s return status: %i\n",
192 method, result));
193
194 switch (result) {
195 case ACPI_SMBUS_STATUS_OK:
196 result = 0;
197 break;
198 case ACPI_SMBUS_STATUS_BUSY:
199 result = -EBUSY;
200 goto out;
201 case ACPI_SMBUS_STATUS_TIMEOUT:
202 result = -ETIMEDOUT;
203 goto out;
204 case ACPI_SMBUS_STATUS_DNAK:
205 result = -ENXIO;
206 goto out;
207 default:
208 result = -EIO;
209 goto out;
210 }
211
212 if (read_write == I2C_SMBUS_WRITE || size == I2C_SMBUS_QUICK)
213 goto out;
214
215 obj = pkg->package.elements + 1;
216 if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
217 ACPI_ERROR((AE_INFO, "Invalid argument type"));
218 result = -EIO;
219 goto out;
220 }
221
222 len = obj->integer.value;
223 obj = pkg->package.elements + 2;
224 switch (size) {
225 case I2C_SMBUS_BYTE:
226 case I2C_SMBUS_BYTE_DATA:
227 case I2C_SMBUS_WORD_DATA:
228 if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
229 ACPI_ERROR((AE_INFO, "Invalid argument type"));
230 result = -EIO;
231 goto out;
232 }
233 if (len == 2)
234 data->word = obj->integer.value;
235 else
236 data->byte = obj->integer.value;
237 break;
238 case I2C_SMBUS_BLOCK_DATA:
239 if (obj == NULL || obj->type != ACPI_TYPE_BUFFER) {
240 ACPI_ERROR((AE_INFO, "Invalid argument type"));
241 result = -EIO;
242 goto out;
243 }
244 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
245 return -EPROTO;
246 data->block[0] = len;
247 memcpy(data->block + 1, obj->buffer.pointer, len);
248 break;
249 }
250
251out:
252 kfree(buffer.pointer);
253 dev_dbg(&adap->dev, "Transaction status: %i\n", result);
254 return result;
255}
256
257static u32 acpi_smbus_cmi_func(struct i2c_adapter *adapter)
258{
259 struct acpi_smbus_cmi *smbus_cmi = adapter->algo_data;
260 u32 ret;
261
262 ret = smbus_cmi->cap_read | smbus_cmi->cap_write ?
263 I2C_FUNC_SMBUS_QUICK : 0;
264
265 ret |= smbus_cmi->cap_read ?
266 (I2C_FUNC_SMBUS_READ_BYTE |
267 I2C_FUNC_SMBUS_READ_BYTE_DATA |
268 I2C_FUNC_SMBUS_READ_WORD_DATA |
269 I2C_FUNC_SMBUS_READ_BLOCK_DATA) : 0;
270
271 ret |= smbus_cmi->cap_write ?
272 (I2C_FUNC_SMBUS_WRITE_BYTE |
273 I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
274 I2C_FUNC_SMBUS_WRITE_WORD_DATA |
275 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) : 0;
276
277 return ret;
278}
279
280static const struct i2c_algorithm acpi_smbus_cmi_algorithm = {
281 .smbus_xfer = acpi_smbus_cmi_access,
282 .functionality = acpi_smbus_cmi_func,
283};
284
285
286static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
287 const char *name)
288{
289 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
290 union acpi_object *obj;
291 acpi_status status;
292
293 if (!strcmp(name, smbus_methods.mt_info)) {
294 status = acpi_evaluate_object(smbus_cmi->handle,
295 smbus_methods.mt_info,
296 NULL, &buffer);
297 if (ACPI_FAILURE(status)) {
298 ACPI_ERROR((AE_INFO, "Evaluating %s: %i",
299 smbus_methods.mt_info, status));
300 return -EIO;
301 }
302
303 obj = buffer.pointer;
304 if (obj && obj->type == ACPI_TYPE_PACKAGE)
305 obj = obj->package.elements;
306 else {
307 ACPI_ERROR((AE_INFO, "Invalid argument type"));
308 kfree(buffer.pointer);
309 return -EIO;
310 }
311
312 if (obj->type != ACPI_TYPE_INTEGER) {
313 ACPI_ERROR((AE_INFO, "Invalid argument type"));
314 kfree(buffer.pointer);
315 return -EIO;
316 } else
317 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SMBus CMI Version %x"
318 "\n", (int)obj->integer.value));
319
320 kfree(buffer.pointer);
321 smbus_cmi->cap_info = 1;
322 } else if (!strcmp(name, smbus_methods.mt_sbr))
323 smbus_cmi->cap_read = 1;
324 else if (!strcmp(name, smbus_methods.mt_sbw))
325 smbus_cmi->cap_write = 1;
326 else
327 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n",
328 name));
329
330 return 0;
331}
332
333static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level,
334 void *context, void **return_value)
335{
336 char node_name[5];
337 struct acpi_buffer buffer = { sizeof(node_name), node_name };
338 struct acpi_smbus_cmi *smbus_cmi = context;
339 acpi_status status;
340
341 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
342
343 if (ACPI_SUCCESS(status))
344 acpi_smbus_cmi_add_cap(smbus_cmi, node_name);
345
346 return AE_OK;
347}
348
349static int acpi_smbus_cmi_add(struct acpi_device *device)
350{
351 struct acpi_smbus_cmi *smbus_cmi;
352
353 smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL);
354 if (!smbus_cmi)
355 return -ENOMEM;
356
357 smbus_cmi->handle = device->handle;
358 strcpy(acpi_device_name(device), ACPI_SMBUS_HC_DEVICE_NAME);
359 strcpy(acpi_device_class(device), ACPI_SMBUS_HC_CLASS);
360 device->driver_data = smbus_cmi;
361 smbus_cmi->cap_info = 0;
362 smbus_cmi->cap_read = 0;
363 smbus_cmi->cap_write = 0;
364
365 acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1,
366 acpi_smbus_cmi_query_methods, smbus_cmi, NULL);
367
368 if (smbus_cmi->cap_info == 0)
369 goto err;
370
371 snprintf(smbus_cmi->adapter.name, sizeof(smbus_cmi->adapter.name),
372 "SMBus CMI adapter %s (%s)",
373 acpi_device_name(device),
374 acpi_device_uid(device));
375 smbus_cmi->adapter.owner = THIS_MODULE;
376 smbus_cmi->adapter.algo = &acpi_smbus_cmi_algorithm;
377 smbus_cmi->adapter.algo_data = smbus_cmi;
378 smbus_cmi->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
379 smbus_cmi->adapter.dev.parent = &device->dev;
380
381 if (i2c_add_adapter(&smbus_cmi->adapter)) {
382 dev_err(&device->dev, "Couldn't register adapter!\n");
383 goto err;
384 }
385
386 return 0;
387
388err:
389 kfree(smbus_cmi);
390 device->driver_data = NULL;
391 return -EIO;
392}
393
394static int acpi_smbus_cmi_remove(struct acpi_device *device, int type)
395{
396 struct acpi_smbus_cmi *smbus_cmi = acpi_driver_data(device);
397
398 i2c_del_adapter(&smbus_cmi->adapter);
399 kfree(smbus_cmi);
400 device->driver_data = NULL;
401
402 return 0;
403}
404
405static struct acpi_driver acpi_smbus_cmi_driver = {
406 .name = ACPI_SMBUS_HC_DEVICE_NAME,
407 .class = ACPI_SMBUS_HC_CLASS,
408 .ids = acpi_smbus_cmi_ids,
409 .ops = {
410 .add = acpi_smbus_cmi_add,
411 .remove = acpi_smbus_cmi_remove,
412 },
413};
414
415static int __init acpi_smbus_cmi_init(void)
416{
417 return acpi_bus_register_driver(&acpi_smbus_cmi_driver);
418}
419
420static void __exit acpi_smbus_cmi_exit(void)
421{
422 acpi_bus_unregister_driver(&acpi_smbus_cmi_driver);
423}
424
425module_init(acpi_smbus_cmi_init);
426module_exit(acpi_smbus_cmi_exit);
427
428MODULE_LICENSE("GPL");
429MODULE_AUTHOR("Crane Cai <crane.cai@amd.com>");
430MODULE_DESCRIPTION("ACPI SMBus CMI driver");
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 820487d0d5c7..86a9d4e81472 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -28,6 +28,7 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/err.h> 30#include <linux/err.h>
31#include <linux/pm_runtime.h>
31#include <linux/clk.h> 32#include <linux/clk.h>
32#include <linux/io.h> 33#include <linux/io.h>
33 34
@@ -165,7 +166,8 @@ static void activate_ch(struct sh_mobile_i2c_data *pd)
165 u_int32_t denom; 166 u_int32_t denom;
166 u_int32_t tmp; 167 u_int32_t tmp;
167 168
168 /* Make sure the clock is enabled */ 169 /* Wake up device and enable clock */
170 pm_runtime_get_sync(pd->dev);
169 clk_enable(pd->clk); 171 clk_enable(pd->clk);
170 172
171 /* Get clock rate after clock is enabled */ 173 /* Get clock rate after clock is enabled */
@@ -213,8 +215,9 @@ static void deactivate_ch(struct sh_mobile_i2c_data *pd)
213 /* Disable channel */ 215 /* Disable channel */
214 iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); 216 iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd));
215 217
216 /* Disable clock */ 218 /* Disable clock and mark device as idle */
217 clk_disable(pd->clk); 219 clk_disable(pd->clk);
220 pm_runtime_put_sync(pd->dev);
218} 221}
219 222
220static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, 223static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
@@ -572,6 +575,19 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
572 goto err_irq; 575 goto err_irq;
573 } 576 }
574 577
578 /* Enable Runtime PM for this device.
579 *
580 * Also tell the Runtime PM core to ignore children
581 * for this device since it is valid for us to suspend
582 * this I2C master driver even though the slave devices
583 * on the I2C bus may not be suspended.
584 *
585 * The state of the I2C hardware bus is unaffected by
586 * the Runtime PM state.
587 */
588 pm_suspend_ignore_children(&dev->dev, true);
589 pm_runtime_enable(&dev->dev);
590
575 /* setup the private data */ 591 /* setup the private data */
576 adap = &pd->adap; 592 adap = &pd->adap;
577 i2c_set_adapdata(adap, pd); 593 i2c_set_adapdata(adap, pd);
@@ -614,14 +630,33 @@ static int sh_mobile_i2c_remove(struct platform_device *dev)
614 iounmap(pd->reg); 630 iounmap(pd->reg);
615 sh_mobile_i2c_hook_irqs(dev, 0); 631 sh_mobile_i2c_hook_irqs(dev, 0);
616 clk_put(pd->clk); 632 clk_put(pd->clk);
633 pm_runtime_disable(&dev->dev);
617 kfree(pd); 634 kfree(pd);
618 return 0; 635 return 0;
619} 636}
620 637
638static int sh_mobile_i2c_runtime_nop(struct device *dev)
639{
640 /* Runtime PM callback shared between ->runtime_suspend()
641 * and ->runtime_resume(). Simply returns success.
642 *
643 * This driver re-initializes all registers after
644 * pm_runtime_get_sync() anyway so there is no need
645 * to save and restore registers here.
646 */
647 return 0;
648}
649
650static struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
651 .runtime_suspend = sh_mobile_i2c_runtime_nop,
652 .runtime_resume = sh_mobile_i2c_runtime_nop,
653};
654
621static struct platform_driver sh_mobile_i2c_driver = { 655static struct platform_driver sh_mobile_i2c_driver = {
622 .driver = { 656 .driver = {
623 .name = "i2c-sh_mobile", 657 .name = "i2c-sh_mobile",
624 .owner = THIS_MODULE, 658 .owner = THIS_MODULE,
659 .pm = &sh_mobile_i2c_dev_pm_ops,
625 }, 660 },
626 .probe = sh_mobile_i2c_probe, 661 .probe = sh_mobile_i2c_probe,
627 .remove = sh_mobile_i2c_remove, 662 .remove = sh_mobile_i2c_remove,
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index 224aa12ee7c8..dd39c1eb03ed 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -32,10 +32,12 @@
32 32
33#define TAOS_STATE_INIT 0 33#define TAOS_STATE_INIT 0
34#define TAOS_STATE_IDLE 1 34#define TAOS_STATE_IDLE 1
35#define TAOS_STATE_SEND 2 35#define TAOS_STATE_EOFF 2
36#define TAOS_STATE_RECV 3 36#define TAOS_STATE_RECV 3
37 37
38#define TAOS_CMD_RESET 0x12 38#define TAOS_CMD_RESET 0x12
39#define TAOS_CMD_ECHO_ON '+'
40#define TAOS_CMD_ECHO_OFF '-'
39 41
40static DECLARE_WAIT_QUEUE_HEAD(wq); 42static DECLARE_WAIT_QUEUE_HEAD(wq);
41 43
@@ -102,17 +104,9 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
102 104
103 /* Send the transaction to the TAOS EVM */ 105 /* Send the transaction to the TAOS EVM */
104 dev_dbg(&adapter->dev, "Command buffer: %s\n", taos->buffer); 106 dev_dbg(&adapter->dev, "Command buffer: %s\n", taos->buffer);
105 taos->pos = 0; 107 for (p = taos->buffer; *p; p++)
106 taos->state = TAOS_STATE_SEND; 108 serio_write(serio, *p);
107 serio_write(serio, taos->buffer[0]); 109
108 wait_event_interruptible_timeout(wq, taos->state == TAOS_STATE_IDLE,
109 msecs_to_jiffies(250));
110 if (taos->state != TAOS_STATE_IDLE) {
111 dev_err(&adapter->dev, "Transaction failed "
112 "(state=%d, pos=%d)\n", taos->state, taos->pos);
113 taos->addr = 0;
114 return -EIO;
115 }
116 taos->addr = addr; 110 taos->addr = addr;
117 111
118 /* Start the transaction and read the answer */ 112 /* Start the transaction and read the answer */
@@ -122,7 +116,7 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
122 wait_event_interruptible_timeout(wq, taos->state == TAOS_STATE_IDLE, 116 wait_event_interruptible_timeout(wq, taos->state == TAOS_STATE_IDLE,
123 msecs_to_jiffies(150)); 117 msecs_to_jiffies(150));
124 if (taos->state != TAOS_STATE_IDLE 118 if (taos->state != TAOS_STATE_IDLE
125 || taos->pos != 6) { 119 || taos->pos != 5) {
126 dev_err(&adapter->dev, "Transaction timeout (pos=%d)\n", 120 dev_err(&adapter->dev, "Transaction timeout (pos=%d)\n",
127 taos->pos); 121 taos->pos);
128 return -EIO; 122 return -EIO;
@@ -130,7 +124,7 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
130 dev_dbg(&adapter->dev, "Answer buffer: %s\n", taos->buffer); 124 dev_dbg(&adapter->dev, "Answer buffer: %s\n", taos->buffer);
131 125
132 /* Interpret the returned string */ 126 /* Interpret the returned string */
133 p = taos->buffer + 2; 127 p = taos->buffer + 1;
134 p[3] = '\0'; 128 p[3] = '\0';
135 if (!strcmp(p, "NAK")) 129 if (!strcmp(p, "NAK"))
136 return -ENODEV; 130 return -ENODEV;
@@ -173,13 +167,9 @@ static irqreturn_t taos_interrupt(struct serio *serio, unsigned char data,
173 wake_up_interruptible(&wq); 167 wake_up_interruptible(&wq);
174 } 168 }
175 break; 169 break;
176 case TAOS_STATE_SEND: 170 case TAOS_STATE_EOFF:
177 if (taos->buffer[++taos->pos]) 171 taos->state = TAOS_STATE_IDLE;
178 serio_write(serio, taos->buffer[taos->pos]); 172 wake_up_interruptible(&wq);
179 else {
180 taos->state = TAOS_STATE_IDLE;
181 wake_up_interruptible(&wq);
182 }
183 break; 173 break;
184 case TAOS_STATE_RECV: 174 case TAOS_STATE_RECV:
185 taos->buffer[taos->pos++] = data; 175 taos->buffer[taos->pos++] = data;
@@ -257,6 +247,19 @@ static int taos_connect(struct serio *serio, struct serio_driver *drv)
257 } 247 }
258 strlcpy(adapter->name, name, sizeof(adapter->name)); 248 strlcpy(adapter->name, name, sizeof(adapter->name));
259 249
250 /* Turn echo off for better performance */
251 taos->state = TAOS_STATE_EOFF;
252 serio_write(serio, TAOS_CMD_ECHO_OFF);
253
254 wait_event_interruptible_timeout(wq, taos->state == TAOS_STATE_IDLE,
255 msecs_to_jiffies(250));
256 if (taos->state != TAOS_STATE_IDLE) {
257 err = -ENODEV;
258 dev_err(&adapter->dev, "Echo off failed "
259 "(state=%d)\n", taos->state);
260 goto exit_close;
261 }
262
260 err = i2c_add_adapter(adapter); 263 err = i2c_add_adapter(adapter);
261 if (err) 264 if (err)
262 goto exit_close; 265 goto exit_close;
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 648ecc6f60e6..cf994bd01d9c 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -217,8 +217,10 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
217 return; 217 return;
218 218
219 error: 219 error:
220 dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, 220 dev_err(&iface->adapter.dev,
221 scx200_acb_state_name[iface->state]); 221 "%s in state %s (addr=0x%02x, len=%d, status=0x%02x)\n", errmsg,
222 scx200_acb_state_name[iface->state], iface->address_byte,
223 iface->len, status);
222 224
223 iface->state = state_idle; 225 iface->state = state_idle;
224 iface->result = -EIO; 226 iface->result = -EIO;