2019-05-31 08:09:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2009-09-18 20:45:51 +00:00
|
|
|
/*
|
|
|
|
* SMBus driver for ACPI SMBus CMI
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Crane Cai <crane.cai@amd.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2022-09-06 15:55:07 +00:00
|
|
|
#include <linux/platform_device.h>
|
2009-09-18 20:45:51 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
|
2017-04-04 16:18:27 +00:00
|
|
|
/* SMBUS HID definition as supported by Microsoft Windows */
|
|
|
|
#define ACPI_SMBUS_MS_HID "SMB0001"
|
|
|
|
|
2009-09-18 20:45:51 +00:00
|
|
|
struct smbus_methods_t {
|
|
|
|
char *mt_info;
|
|
|
|
char *mt_sbr;
|
|
|
|
char *mt_sbw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_smbus_cmi {
|
|
|
|
acpi_handle handle;
|
|
|
|
struct i2c_adapter adapter;
|
|
|
|
u8 cap_info:1;
|
|
|
|
u8 cap_read:1;
|
|
|
|
u8 cap_write:1;
|
2022-09-06 15:55:07 +00:00
|
|
|
const struct smbus_methods_t *methods;
|
2009-09-18 20:45:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct smbus_methods_t smbus_methods = {
|
|
|
|
.mt_info = "_SBI",
|
|
|
|
.mt_sbr = "_SBR",
|
|
|
|
.mt_sbw = "_SBW",
|
|
|
|
};
|
|
|
|
|
2010-03-24 13:38:38 +00:00
|
|
|
/* Some IBM BIOSes omit the leading underscore */
|
|
|
|
static const struct smbus_methods_t ibm_smbus_methods = {
|
|
|
|
.mt_info = "SBI_",
|
|
|
|
.mt_sbr = "SBR_",
|
|
|
|
.mt_sbw = "SBW_",
|
|
|
|
};
|
|
|
|
|
2009-09-18 20:45:51 +00:00
|
|
|
static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
|
2010-03-24 13:38:38 +00:00
|
|
|
{"SMBUS01", (kernel_ulong_t)&smbus_methods},
|
|
|
|
{ACPI_SMBUS_IBM_HID, (kernel_ulong_t)&ibm_smbus_methods},
|
2017-04-04 16:18:27 +00:00
|
|
|
{ACPI_SMBUS_MS_HID, (kernel_ulong_t)&smbus_methods},
|
2009-09-18 20:45:51 +00:00
|
|
|
{"", 0}
|
|
|
|
};
|
2010-03-24 13:38:39 +00:00
|
|
|
MODULE_DEVICE_TABLE(acpi, acpi_smbus_cmi_ids);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
#define ACPI_SMBUS_STATUS_OK 0x00
|
|
|
|
#define ACPI_SMBUS_STATUS_FAIL 0x07
|
|
|
|
#define ACPI_SMBUS_STATUS_DNAK 0x10
|
|
|
|
#define ACPI_SMBUS_STATUS_DERR 0x11
|
|
|
|
#define ACPI_SMBUS_STATUS_CMD_DENY 0x12
|
|
|
|
#define ACPI_SMBUS_STATUS_UNKNOWN 0x13
|
|
|
|
#define ACPI_SMBUS_STATUS_ACC_DENY 0x17
|
|
|
|
#define ACPI_SMBUS_STATUS_TIMEOUT 0x18
|
|
|
|
#define ACPI_SMBUS_STATUS_NOTSUP 0x19
|
|
|
|
#define ACPI_SMBUS_STATUS_BUSY 0x1a
|
|
|
|
#define ACPI_SMBUS_STATUS_PEC 0x1f
|
|
|
|
|
|
|
|
#define ACPI_SMBUS_PRTCL_WRITE 0x00
|
|
|
|
#define ACPI_SMBUS_PRTCL_READ 0x01
|
|
|
|
#define ACPI_SMBUS_PRTCL_QUICK 0x02
|
|
|
|
#define ACPI_SMBUS_PRTCL_BYTE 0x04
|
|
|
|
#define ACPI_SMBUS_PRTCL_BYTE_DATA 0x06
|
|
|
|
#define ACPI_SMBUS_PRTCL_WORD_DATA 0x08
|
|
|
|
#define ACPI_SMBUS_PRTCL_BLOCK_DATA 0x0a
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
|
|
|
|
char read_write, u8 command, int size,
|
|
|
|
union i2c_smbus_data *data)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
struct acpi_smbus_cmi *smbus_cmi = adap->algo_data;
|
|
|
|
unsigned char protocol;
|
|
|
|
acpi_status status = 0;
|
|
|
|
struct acpi_object_list input;
|
|
|
|
union acpi_object mt_params[5];
|
|
|
|
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
union acpi_object *obj;
|
|
|
|
union acpi_object *pkg;
|
|
|
|
char *method;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
dev_dbg(&adap->dev, "access size: %d %s\n", size,
|
|
|
|
(read_write) ? "READ" : "WRITE");
|
|
|
|
switch (size) {
|
|
|
|
case I2C_SMBUS_QUICK:
|
|
|
|
protocol = ACPI_SMBUS_PRTCL_QUICK;
|
|
|
|
command = 0;
|
|
|
|
if (read_write == I2C_SMBUS_WRITE) {
|
|
|
|
mt_params[3].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[3].integer.value = 0;
|
|
|
|
mt_params[4].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[4].integer.value = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case I2C_SMBUS_BYTE:
|
|
|
|
protocol = ACPI_SMBUS_PRTCL_BYTE;
|
|
|
|
if (read_write == I2C_SMBUS_WRITE) {
|
|
|
|
mt_params[3].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[3].integer.value = 0;
|
|
|
|
mt_params[4].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[4].integer.value = 0;
|
|
|
|
} else {
|
|
|
|
command = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case I2C_SMBUS_BYTE_DATA:
|
|
|
|
protocol = ACPI_SMBUS_PRTCL_BYTE_DATA;
|
|
|
|
if (read_write == I2C_SMBUS_WRITE) {
|
|
|
|
mt_params[3].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[3].integer.value = 1;
|
|
|
|
mt_params[4].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[4].integer.value = data->byte;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case I2C_SMBUS_WORD_DATA:
|
|
|
|
protocol = ACPI_SMBUS_PRTCL_WORD_DATA;
|
|
|
|
if (read_write == I2C_SMBUS_WRITE) {
|
|
|
|
mt_params[3].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[3].integer.value = 2;
|
|
|
|
mt_params[4].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[4].integer.value = data->word;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case I2C_SMBUS_BLOCK_DATA:
|
|
|
|
protocol = ACPI_SMBUS_PRTCL_BLOCK_DATA;
|
|
|
|
if (read_write == I2C_SMBUS_WRITE) {
|
|
|
|
len = data->block[0];
|
|
|
|
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
mt_params[3].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[3].integer.value = len;
|
|
|
|
mt_params[4].type = ACPI_TYPE_BUFFER;
|
2018-09-27 08:56:03 +00:00
|
|
|
mt_params[4].buffer.length = len;
|
2009-09-18 20:45:51 +00:00
|
|
|
mt_params[4].buffer.pointer = data->block + 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read_write == I2C_SMBUS_READ) {
|
|
|
|
protocol |= ACPI_SMBUS_PRTCL_READ;
|
2010-03-24 13:38:38 +00:00
|
|
|
method = smbus_cmi->methods->mt_sbr;
|
2009-09-18 20:45:51 +00:00
|
|
|
input.count = 3;
|
|
|
|
} else {
|
|
|
|
protocol |= ACPI_SMBUS_PRTCL_WRITE;
|
2010-03-24 13:38:38 +00:00
|
|
|
method = smbus_cmi->methods->mt_sbw;
|
2009-09-18 20:45:51 +00:00
|
|
|
input.count = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
input.pointer = mt_params;
|
|
|
|
mt_params[0].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[0].integer.value = protocol;
|
|
|
|
mt_params[1].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[1].integer.value = addr;
|
|
|
|
mt_params[2].type = ACPI_TYPE_INTEGER;
|
|
|
|
mt_params[2].integer.value = command;
|
|
|
|
|
|
|
|
status = acpi_evaluate_object(smbus_cmi->handle, method, &input,
|
|
|
|
&buffer);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle,
|
|
|
|
"Failed to evaluate %s: %i\n", method, status);
|
2009-09-18 20:45:51 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg = buffer.pointer;
|
|
|
|
if (pkg && pkg->type == ACPI_TYPE_PACKAGE)
|
|
|
|
obj = pkg->package.elements;
|
|
|
|
else {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = obj->integer.value;
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_debug(smbus_cmi->handle, "%s return status: %i\n", method,
|
|
|
|
result);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case ACPI_SMBUS_STATUS_OK:
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
case ACPI_SMBUS_STATUS_BUSY:
|
|
|
|
result = -EBUSY;
|
|
|
|
goto out;
|
|
|
|
case ACPI_SMBUS_STATUS_TIMEOUT:
|
|
|
|
result = -ETIMEDOUT;
|
|
|
|
goto out;
|
|
|
|
case ACPI_SMBUS_STATUS_DNAK:
|
|
|
|
result = -ENXIO;
|
|
|
|
goto out;
|
|
|
|
default:
|
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read_write == I2C_SMBUS_WRITE || size == I2C_SMBUS_QUICK)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
obj = pkg->package.elements + 1;
|
2013-10-19 08:46:22 +00:00
|
|
|
if (obj->type != ACPI_TYPE_INTEGER) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = obj->integer.value;
|
|
|
|
obj = pkg->package.elements + 2;
|
|
|
|
switch (size) {
|
|
|
|
case I2C_SMBUS_BYTE:
|
|
|
|
case I2C_SMBUS_BYTE_DATA:
|
|
|
|
case I2C_SMBUS_WORD_DATA:
|
2013-10-19 08:46:22 +00:00
|
|
|
if (obj->type != ACPI_TYPE_INTEGER) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle,
|
|
|
|
"Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (len == 2)
|
|
|
|
data->word = obj->integer.value;
|
|
|
|
else
|
|
|
|
data->byte = obj->integer.value;
|
|
|
|
break;
|
|
|
|
case I2C_SMBUS_BLOCK_DATA:
|
2013-10-19 08:46:22 +00:00
|
|
|
if (obj->type != ACPI_TYPE_BUFFER) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(smbus_cmi->handle,
|
|
|
|
"Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
result = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
|
|
|
|
return -EPROTO;
|
|
|
|
data->block[0] = len;
|
|
|
|
memcpy(data->block + 1, obj->buffer.pointer, len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(buffer.pointer);
|
|
|
|
dev_dbg(&adap->dev, "Transaction status: %i\n", result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 acpi_smbus_cmi_func(struct i2c_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct acpi_smbus_cmi *smbus_cmi = adapter->algo_data;
|
|
|
|
u32 ret;
|
|
|
|
|
|
|
|
ret = smbus_cmi->cap_read | smbus_cmi->cap_write ?
|
|
|
|
I2C_FUNC_SMBUS_QUICK : 0;
|
|
|
|
|
|
|
|
ret |= smbus_cmi->cap_read ?
|
|
|
|
(I2C_FUNC_SMBUS_READ_BYTE |
|
|
|
|
I2C_FUNC_SMBUS_READ_BYTE_DATA |
|
|
|
|
I2C_FUNC_SMBUS_READ_WORD_DATA |
|
|
|
|
I2C_FUNC_SMBUS_READ_BLOCK_DATA) : 0;
|
|
|
|
|
|
|
|
ret |= smbus_cmi->cap_write ?
|
|
|
|
(I2C_FUNC_SMBUS_WRITE_BYTE |
|
|
|
|
I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
|
|
|
|
I2C_FUNC_SMBUS_WRITE_WORD_DATA |
|
|
|
|
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) : 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_algorithm acpi_smbus_cmi_algorithm = {
|
|
|
|
.smbus_xfer = acpi_smbus_cmi_access,
|
|
|
|
.functionality = acpi_smbus_cmi_func,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
2018-03-01 08:04:13 +00:00
|
|
|
struct acpi_handle *handle = smbus_cmi->handle;
|
2009-09-18 20:45:51 +00:00
|
|
|
union acpi_object *obj;
|
|
|
|
acpi_status status;
|
|
|
|
|
2010-03-24 13:38:38 +00:00
|
|
|
if (!strcmp(name, smbus_cmi->methods->mt_info)) {
|
2009-09-18 20:45:51 +00:00
|
|
|
status = acpi_evaluate_object(smbus_cmi->handle,
|
2010-03-24 13:38:38 +00:00
|
|
|
smbus_cmi->methods->mt_info,
|
2009-09-18 20:45:51 +00:00
|
|
|
NULL, &buffer);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(handle, "Failed to evaluate %s: %i\n",
|
|
|
|
smbus_cmi->methods->mt_info, status);
|
2009-09-18 20:45:51 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = buffer.pointer;
|
|
|
|
if (obj && obj->type == ACPI_TYPE_PACKAGE)
|
|
|
|
obj = obj->package.elements;
|
|
|
|
else {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(handle, "Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
kfree(buffer.pointer);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj->type != ACPI_TYPE_INTEGER) {
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_err(handle, "Invalid argument type\n");
|
2009-09-18 20:45:51 +00:00
|
|
|
kfree(buffer.pointer);
|
|
|
|
return -EIO;
|
|
|
|
} else
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_debug(handle, "SMBus CMI Version %x\n",
|
|
|
|
(int)obj->integer.value);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
kfree(buffer.pointer);
|
|
|
|
smbus_cmi->cap_info = 1;
|
2010-03-24 13:38:38 +00:00
|
|
|
} else if (!strcmp(name, smbus_cmi->methods->mt_sbr))
|
2009-09-18 20:45:51 +00:00
|
|
|
smbus_cmi->cap_read = 1;
|
2010-03-24 13:38:38 +00:00
|
|
|
else if (!strcmp(name, smbus_cmi->methods->mt_sbw))
|
2009-09-18 20:45:51 +00:00
|
|
|
smbus_cmi->cap_write = 1;
|
|
|
|
else
|
2018-03-01 08:04:13 +00:00
|
|
|
acpi_handle_debug(handle, "Unsupported CMI method: %s\n", name);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level,
|
|
|
|
void *context, void **return_value)
|
|
|
|
{
|
|
|
|
char node_name[5];
|
|
|
|
struct acpi_buffer buffer = { sizeof(node_name), node_name };
|
|
|
|
struct acpi_smbus_cmi *smbus_cmi = context;
|
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
|
|
|
|
|
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
acpi_smbus_cmi_add_cap(smbus_cmi, node_name);
|
|
|
|
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
2022-09-06 15:55:07 +00:00
|
|
|
static int smbus_cmi_probe(struct platform_device *device)
|
2009-09-18 20:45:51 +00:00
|
|
|
{
|
2022-09-06 15:55:07 +00:00
|
|
|
struct device *dev = &device->dev;
|
2009-09-18 20:45:51 +00:00
|
|
|
struct acpi_smbus_cmi *smbus_cmi;
|
2018-11-21 09:19:55 +00:00
|
|
|
int ret;
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL);
|
|
|
|
if (!smbus_cmi)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2022-09-06 15:55:07 +00:00
|
|
|
smbus_cmi->handle = ACPI_HANDLE(dev);
|
|
|
|
smbus_cmi->methods = device_get_match_data(dev);
|
|
|
|
|
|
|
|
platform_set_drvdata(device, smbus_cmi);
|
|
|
|
|
2009-09-18 20:45:51 +00:00
|
|
|
smbus_cmi->cap_info = 0;
|
|
|
|
smbus_cmi->cap_read = 0;
|
|
|
|
smbus_cmi->cap_write = 0;
|
|
|
|
|
|
|
|
acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1,
|
2009-11-13 02:06:08 +00:00
|
|
|
acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
2018-11-21 09:19:55 +00:00
|
|
|
if (smbus_cmi->cap_info == 0) {
|
|
|
|
ret = -ENODEV;
|
2009-09-18 20:45:51 +00:00
|
|
|
goto err;
|
2018-11-21 09:19:55 +00:00
|
|
|
}
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
snprintf(smbus_cmi->adapter.name, sizeof(smbus_cmi->adapter.name),
|
2022-09-06 15:55:07 +00:00
|
|
|
"SMBus CMI adapter %s", dev_name(dev));
|
2009-09-18 20:45:51 +00:00
|
|
|
smbus_cmi->adapter.owner = THIS_MODULE;
|
|
|
|
smbus_cmi->adapter.algo = &acpi_smbus_cmi_algorithm;
|
|
|
|
smbus_cmi->adapter.algo_data = smbus_cmi;
|
|
|
|
smbus_cmi->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
|
|
|
|
smbus_cmi->adapter.dev.parent = &device->dev;
|
|
|
|
|
2018-11-21 09:19:55 +00:00
|
|
|
ret = i2c_add_adapter(&smbus_cmi->adapter);
|
|
|
|
if (ret) {
|
2009-09-18 20:45:51 +00:00
|
|
|
dev_err(&device->dev, "Couldn't register adapter!\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
kfree(smbus_cmi);
|
2018-11-21 09:19:55 +00:00
|
|
|
return ret;
|
2009-09-18 20:45:51 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 15:55:07 +00:00
|
|
|
static int smbus_cmi_remove(struct platform_device *device)
|
2009-09-18 20:45:51 +00:00
|
|
|
{
|
2022-09-06 15:55:07 +00:00
|
|
|
struct acpi_smbus_cmi *smbus_cmi = platform_get_drvdata(device);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
i2c_del_adapter(&smbus_cmi->adapter);
|
|
|
|
kfree(smbus_cmi);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-06 15:55:07 +00:00
|
|
|
static struct platform_driver smbus_cmi_driver = {
|
|
|
|
.probe = smbus_cmi_probe,
|
|
|
|
.remove = smbus_cmi_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "smbus_cmi",
|
|
|
|
.acpi_match_table = acpi_smbus_cmi_ids,
|
2009-09-18 20:45:51 +00:00
|
|
|
},
|
|
|
|
};
|
2022-09-06 15:55:07 +00:00
|
|
|
module_platform_driver(smbus_cmi_driver);
|
2009-09-18 20:45:51 +00:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Crane Cai <crane.cai@amd.com>");
|
|
|
|
MODULE_DESCRIPTION("ACPI SMBus CMI driver");
|