11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/kernel.h>
14 #include <linux/stddef.h>
16 #include <linux/i2c.h>
19 #define ACPI_SMBUS_HC_CLASS "smbus"
20 #define ACPI_SMBUS_HC_DEVICE_NAME "cmi"
59 #define ACPI_SMBUS_STATUS_OK 0x00
60 #define ACPI_SMBUS_STATUS_FAIL 0x07
61 #define ACPI_SMBUS_STATUS_DNAK 0x10
62 #define ACPI_SMBUS_STATUS_DERR 0x11
63 #define ACPI_SMBUS_STATUS_CMD_DENY 0x12
64 #define ACPI_SMBUS_STATUS_UNKNOWN 0x13
65 #define ACPI_SMBUS_STATUS_ACC_DENY 0x17
66 #define ACPI_SMBUS_STATUS_TIMEOUT 0x18
67 #define ACPI_SMBUS_STATUS_NOTSUP 0x19
68 #define ACPI_SMBUS_STATUS_BUSY 0x1a
69 #define ACPI_SMBUS_STATUS_PEC 0x1f
71 #define ACPI_SMBUS_PRTCL_WRITE 0x00
72 #define ACPI_SMBUS_PRTCL_READ 0x01
73 #define ACPI_SMBUS_PRTCL_QUICK 0x02
74 #define ACPI_SMBUS_PRTCL_BYTE 0x04
75 #define ACPI_SMBUS_PRTCL_BYTE_DATA 0x06
76 #define ACPI_SMBUS_PRTCL_WORD_DATA 0x08
77 #define ACPI_SMBUS_PRTCL_BLOCK_DATA 0x0a
97 dev_dbg(&adap->
dev,
"access size: %d %s\n", size,
98 (read_write) ?
"READ" :
"WRITE");
105 mt_params[3].
integer.value = 0;
107 mt_params[4].
integer.value = 0;
115 mt_params[3].
integer.value = 0;
117 mt_params[4].
integer.value = 0;
127 mt_params[3].
integer.value = 1;
137 mt_params[3].
integer.value = 2;
146 len = data->
block[0];
150 mt_params[3].
integer.value = len;
157 dev_warn(&adap->
dev,
"Unsupported transaction %d\n", size);
163 method = smbus_cmi->
methods->mt_sbr;
167 method = smbus_cmi->
methods->mt_sbw;
225 obj = pkg->
package.elements + 1;
233 obj = pkg->
package.elements + 2;
256 data->
block[0] = len;
263 dev_dbg(&adap->
dev,
"Transaction status: %i\n", result);
290 static const struct i2c_algorithm acpi_smbus_cmi_algorithm = {
291 .smbus_xfer = acpi_smbus_cmi_access,
292 .functionality = acpi_smbus_cmi_func,
296 static int acpi_smbus_cmi_add_cap(
struct acpi_smbus_cmi *smbus_cmi,
309 smbus_cmi->
methods->mt_info, status));
328 "\n", (
int)obj->
integer.value));
354 acpi_smbus_cmi_add_cap(smbus_cmi, node_name);
359 static int acpi_smbus_cmi_add(
struct acpi_device *
device)
368 smbus_cmi->
handle = device->handle;
371 device->driver_data = smbus_cmi;
376 for (
id = acpi_smbus_cmi_ids;
id->
id[0];
id++)
382 acpi_smbus_cmi_query_methods,
NULL, smbus_cmi,
NULL);
388 "SMBus CMI adapter %s",
389 acpi_device_name(device));
391 smbus_cmi->
adapter.algo = &acpi_smbus_cmi_algorithm;
392 smbus_cmi->
adapter.algo_data = smbus_cmi;
394 smbus_cmi->
adapter.dev.parent = &device->dev;
397 dev_err(&device->dev,
"Couldn't register adapter!\n");
405 device->driver_data =
NULL;
409 static int acpi_smbus_cmi_remove(
struct acpi_device *device,
int type)
415 device->driver_data =
NULL;
420 static struct acpi_driver acpi_smbus_cmi_driver = {
423 .ids = acpi_smbus_cmi_ids,
425 .add = acpi_smbus_cmi_add,
426 .remove = acpi_smbus_cmi_remove,