mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 12:44:11 +08:00
ipmi: Convert DMI handling over to a platform device
Now that the IPMI DMI code creates a platform device for IPMI devices in the firmware, use that instead of handling all the DMI work in the IPMI drivers themselves. Signed-off-by: Corey Minyard <cminyard@mvista.com> Cc: Andy Lutomirski <luto@kernel.org>
This commit is contained in:
parent
9f88145f18
commit
0944d889a2
@ -61,6 +61,7 @@
|
||||
#include <linux/ipmi_smi.h>
|
||||
#include <asm/io.h>
|
||||
#include "ipmi_si_sm.h"
|
||||
#include "ipmi_dmi.h"
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/ctype.h>
|
||||
@ -2273,136 +2274,105 @@ static void spmi_find_bmc(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DMI
|
||||
struct dmi_ipmi_data {
|
||||
u8 type;
|
||||
u8 addr_space;
|
||||
unsigned long base_addr;
|
||||
u8 irq;
|
||||
u8 offset;
|
||||
u8 slave_addr;
|
||||
};
|
||||
|
||||
static int decode_dmi(const struct dmi_header *dm,
|
||||
struct dmi_ipmi_data *dmi)
|
||||
#if defined(CONFIG_DMI) || defined(CONFIG_ACPI)
|
||||
struct resource *ipmi_get_info_from_resources(struct platform_device *pdev,
|
||||
struct smi_info *info)
|
||||
{
|
||||
const u8 *data = (const u8 *)dm;
|
||||
unsigned long base_addr;
|
||||
u8 reg_spacing;
|
||||
u8 len = dm->length;
|
||||
struct resource *res, *res_second;
|
||||
|
||||
dmi->type = data[4];
|
||||
|
||||
memcpy(&base_addr, data+8, sizeof(unsigned long));
|
||||
if (len >= 0x11) {
|
||||
if (base_addr & 1) {
|
||||
/* I/O */
|
||||
base_addr &= 0xFFFE;
|
||||
dmi->addr_space = IPMI_IO_ADDR_SPACE;
|
||||
} else
|
||||
/* Memory */
|
||||
dmi->addr_space = IPMI_MEM_ADDR_SPACE;
|
||||
|
||||
/* If bit 4 of byte 0x10 is set, then the lsb for the address
|
||||
is odd. */
|
||||
dmi->base_addr = base_addr | ((data[0x10] & 0x10) >> 4);
|
||||
|
||||
dmi->irq = data[0x11];
|
||||
|
||||
/* The top two bits of byte 0x10 hold the register spacing. */
|
||||
reg_spacing = (data[0x10] & 0xC0) >> 6;
|
||||
switch (reg_spacing) {
|
||||
case 0x00: /* Byte boundaries */
|
||||
dmi->offset = 1;
|
||||
break;
|
||||
case 0x01: /* 32-bit boundaries */
|
||||
dmi->offset = 4;
|
||||
break;
|
||||
case 0x02: /* 16-byte boundaries */
|
||||
dmi->offset = 16;
|
||||
break;
|
||||
default:
|
||||
/* Some other interface, just ignore it. */
|
||||
return -EIO;
|
||||
}
|
||||
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||
if (res) {
|
||||
info->io_setup = port_setup;
|
||||
info->io.addr_type = IPMI_IO_ADDR_SPACE;
|
||||
} else {
|
||||
/* Old DMI spec. */
|
||||
/*
|
||||
* Note that technically, the lower bit of the base
|
||||
* address should be 1 if the address is I/O and 0 if
|
||||
* the address is in memory. So many systems get that
|
||||
* wrong (and all that I have seen are I/O) so we just
|
||||
* ignore that bit and assume I/O. Systems that use
|
||||
* memory should use the newer spec, anyway.
|
||||
*/
|
||||
dmi->base_addr = base_addr & 0xfffe;
|
||||
dmi->addr_space = IPMI_IO_ADDR_SPACE;
|
||||
dmi->offset = 1;
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (res) {
|
||||
info->io_setup = mem_setup;
|
||||
info->io.addr_type = IPMI_MEM_ADDR_SPACE;
|
||||
}
|
||||
}
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "no I/O or memory address\n");
|
||||
return NULL;
|
||||
}
|
||||
info->io.addr_data = res->start;
|
||||
|
||||
dmi->slave_addr = data[6];
|
||||
info->io.regspacing = DEFAULT_REGSPACING;
|
||||
res_second = platform_get_resource(pdev,
|
||||
(info->io.addr_type == IPMI_IO_ADDR_SPACE) ?
|
||||
IORESOURCE_IO : IORESOURCE_MEM,
|
||||
1);
|
||||
if (res_second) {
|
||||
if (res_second->start > info->io.addr_data)
|
||||
info->io.regspacing =
|
||||
res_second->start - info->io.addr_data;
|
||||
}
|
||||
info->io.regsize = DEFAULT_REGSIZE;
|
||||
info->io.regshift = 0;
|
||||
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DMI
|
||||
static int dmi_ipmi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct smi_info *info;
|
||||
u8 type, slave_addr;
|
||||
int rv;
|
||||
|
||||
if (!si_trydmi)
|
||||
return -ENODEV;
|
||||
|
||||
rv = device_property_read_u8(&pdev->dev, "ipmi-type", &type);
|
||||
if (rv)
|
||||
return -ENODEV;
|
||||
|
||||
info = smi_info_alloc();
|
||||
if (!info) {
|
||||
pr_err(PFX "Could not allocate SI data\n");
|
||||
return;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
info->addr_source = SI_SMBIOS;
|
||||
pr_info(PFX "probing via SMBIOS\n");
|
||||
|
||||
switch (ipmi_data->type) {
|
||||
case 0x01: /* KCS */
|
||||
switch (type) {
|
||||
case IPMI_DMI_TYPE_KCS:
|
||||
info->si_type = SI_KCS;
|
||||
break;
|
||||
case 0x02: /* SMIC */
|
||||
case IPMI_DMI_TYPE_SMIC:
|
||||
info->si_type = SI_SMIC;
|
||||
break;
|
||||
case 0x03: /* BT */
|
||||
case IPMI_DMI_TYPE_BT:
|
||||
info->si_type = SI_BT;
|
||||
break;
|
||||
default:
|
||||
kfree(info);
|
||||
return;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (ipmi_data->addr_space) {
|
||||
case IPMI_MEM_ADDR_SPACE:
|
||||
info->io_setup = mem_setup;
|
||||
info->io.addr_type = IPMI_MEM_ADDR_SPACE;
|
||||
break;
|
||||
|
||||
case IPMI_IO_ADDR_SPACE:
|
||||
info->io_setup = port_setup;
|
||||
info->io.addr_type = IPMI_IO_ADDR_SPACE;
|
||||
break;
|
||||
|
||||
default:
|
||||
kfree(info);
|
||||
pr_warn(PFX "Unknown SMBIOS I/O Address type: %d\n",
|
||||
ipmi_data->addr_space);
|
||||
return;
|
||||
if (!ipmi_get_info_from_resources(pdev, info)) {
|
||||
rv = -EINVAL;
|
||||
goto err_free;
|
||||
}
|
||||
info->io.addr_data = ipmi_data->base_addr;
|
||||
|
||||
info->io.regspacing = ipmi_data->offset;
|
||||
if (!info->io.regspacing)
|
||||
info->io.regspacing = DEFAULT_REGSPACING;
|
||||
info->io.regsize = DEFAULT_REGSIZE;
|
||||
info->io.regshift = 0;
|
||||
rv = device_property_read_u8(&pdev->dev, "slave-addr", &slave_addr);
|
||||
if (rv) {
|
||||
dev_warn(&pdev->dev, "device has no slave-addr property");
|
||||
info->slave_addr = 0x20;
|
||||
} else {
|
||||
info->slave_addr = slave_addr;
|
||||
}
|
||||
|
||||
info->slave_addr = ipmi_data->slave_addr;
|
||||
|
||||
info->irq = ipmi_data->irq;
|
||||
if (info->irq)
|
||||
info->irq = platform_get_irq(pdev, 0);
|
||||
if (info->irq > 0)
|
||||
info->irq_setup = std_irq_setup;
|
||||
else
|
||||
info->irq = 0;
|
||||
|
||||
info->dev = &pdev->dev;
|
||||
|
||||
pr_info("ipmi_si: SMBIOS: %s %#lx regsize %d spacing %d irq %d\n",
|
||||
(info->io.addr_type == IPMI_IO_ADDR_SPACE) ? "io" : "mem",
|
||||
@ -2411,21 +2381,17 @@ static void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
|
||||
|
||||
if (add_smi(info))
|
||||
kfree(info);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
kfree(info);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void dmi_find_bmc(void)
|
||||
#else
|
||||
static int dmi_ipmi_probe(struct platform_device *pdev)
|
||||
{
|
||||
const struct dmi_device *dev = NULL;
|
||||
struct dmi_ipmi_data data;
|
||||
int rv;
|
||||
|
||||
while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) {
|
||||
memset(&data, 0, sizeof(data));
|
||||
rv = decode_dmi((const struct dmi_header *) dev->device_data,
|
||||
&data);
|
||||
if (!rv)
|
||||
try_init_dmi(&data);
|
||||
}
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif /* CONFIG_DMI */
|
||||
|
||||
@ -2684,17 +2650,47 @@ static int of_ipmi_probe(struct platform_device *dev)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
static int find_slave_address(struct smi_info *info, int slave_addr)
|
||||
{
|
||||
#ifdef CONFIG_IPMI_DMI_DECODE
|
||||
if (!slave_addr) {
|
||||
int type = -1;
|
||||
u32 flags = IORESOURCE_IO;
|
||||
|
||||
switch (info->si_type) {
|
||||
case SI_KCS:
|
||||
type = IPMI_DMI_TYPE_KCS;
|
||||
break;
|
||||
case SI_BT:
|
||||
type = IPMI_DMI_TYPE_BT;
|
||||
break;
|
||||
case SI_SMIC:
|
||||
type = IPMI_DMI_TYPE_SMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
if (info->io.addr_type == IPMI_MEM_ADDR_SPACE)
|
||||
flags = IORESOURCE_MEM;
|
||||
|
||||
slave_addr = ipmi_dmi_get_slave_addr(type, flags,
|
||||
info->io.addr_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
return slave_addr;
|
||||
}
|
||||
|
||||
static int acpi_ipmi_probe(struct platform_device *dev)
|
||||
{
|
||||
struct smi_info *info;
|
||||
struct resource *res, *res_second;
|
||||
acpi_handle handle;
|
||||
acpi_status status;
|
||||
unsigned long long tmp;
|
||||
struct resource *res;
|
||||
int rv = -EINVAL;
|
||||
|
||||
if (!si_tryacpi)
|
||||
return 0;
|
||||
return -ENODEV;
|
||||
|
||||
handle = ACPI_HANDLE(&dev->dev);
|
||||
if (!handle)
|
||||
@ -2734,35 +2730,11 @@ static int acpi_ipmi_probe(struct platform_device *dev)
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
res = platform_get_resource(dev, IORESOURCE_IO, 0);
|
||||
if (res) {
|
||||
info->io_setup = port_setup;
|
||||
info->io.addr_type = IPMI_IO_ADDR_SPACE;
|
||||
} else {
|
||||
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
||||
if (res) {
|
||||
info->io_setup = mem_setup;
|
||||
info->io.addr_type = IPMI_MEM_ADDR_SPACE;
|
||||
}
|
||||
}
|
||||
res = ipmi_get_info_from_resources(dev, info);
|
||||
if (!res) {
|
||||
dev_err(&dev->dev, "no I/O or memory address\n");
|
||||
rv = -EINVAL;
|
||||
goto err_free;
|
||||
}
|
||||
info->io.addr_data = res->start;
|
||||
|
||||
info->io.regspacing = DEFAULT_REGSPACING;
|
||||
res_second = platform_get_resource(dev,
|
||||
(info->io.addr_type == IPMI_IO_ADDR_SPACE) ?
|
||||
IORESOURCE_IO : IORESOURCE_MEM,
|
||||
1);
|
||||
if (res_second) {
|
||||
if (res_second->start > info->io.addr_data)
|
||||
info->io.regspacing =
|
||||
res_second->start - info->io.addr_data;
|
||||
}
|
||||
info->io.regsize = DEFAULT_REGSIZE;
|
||||
info->io.regshift = 0;
|
||||
|
||||
/* If _GPE exists, use it; otherwise use standard interrupts */
|
||||
status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp);
|
||||
@ -2778,6 +2750,8 @@ static int acpi_ipmi_probe(struct platform_device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
info->slave_addr = find_slave_address(info, info->slave_addr);
|
||||
|
||||
info->dev = &dev->dev;
|
||||
platform_set_drvdata(dev, info);
|
||||
|
||||
@ -2813,7 +2787,10 @@ static int ipmi_probe(struct platform_device *dev)
|
||||
if (of_ipmi_probe(dev) == 0)
|
||||
return 0;
|
||||
|
||||
return acpi_ipmi_probe(dev);
|
||||
if (acpi_ipmi_probe(dev) == 0)
|
||||
return 0;
|
||||
|
||||
return dmi_ipmi_probe(dev);
|
||||
}
|
||||
|
||||
static int ipmi_remove(struct platform_device *dev)
|
||||
@ -3786,11 +3763,6 @@ static int init_ipmi_si(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DMI
|
||||
if (si_trydmi)
|
||||
dmi_find_bmc();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
if (si_tryacpi)
|
||||
spmi_find_bmc();
|
||||
@ -3938,6 +3910,7 @@ static void cleanup_ipmi_si(void)
|
||||
}
|
||||
module_exit(cleanup_ipmi_si);
|
||||
|
||||
MODULE_ALIAS("platform:dmi-ipmi-si");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
|
||||
MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT"
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/time64.h>
|
||||
#include "ipmi_dmi.h"
|
||||
|
||||
#define PFX "ipmi_ssif: "
|
||||
#define DEVICE_NAME "ipmi_ssif"
|
||||
@ -180,6 +181,8 @@ struct ssif_addr_info {
|
||||
int slave_addr;
|
||||
enum ipmi_addr_src addr_src;
|
||||
union ipmi_smi_info_union addr_info;
|
||||
struct device *dev;
|
||||
struct i2c_client *client;
|
||||
|
||||
struct mutex clients_mutex;
|
||||
struct list_head clients;
|
||||
@ -1171,6 +1174,7 @@ static LIST_HEAD(ssif_infos);
|
||||
static int ssif_remove(struct i2c_client *client)
|
||||
{
|
||||
struct ssif_info *ssif_info = i2c_get_clientdata(client);
|
||||
struct ssif_addr_info *addr_info;
|
||||
int rv;
|
||||
|
||||
if (!ssif_info)
|
||||
@ -1198,6 +1202,13 @@ static int ssif_remove(struct i2c_client *client)
|
||||
kthread_stop(ssif_info->thread);
|
||||
}
|
||||
|
||||
list_for_each_entry(addr_info, &ssif_infos, link) {
|
||||
if (addr_info->client == client) {
|
||||
addr_info->client = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No message can be outstanding now, we have removed the
|
||||
* upper layer and it permitted us to do so.
|
||||
@ -1406,27 +1417,13 @@ static bool check_acpi(struct ssif_info *ssif_info, struct device *dev)
|
||||
|
||||
static int find_slave_address(struct i2c_client *client, int slave_addr)
|
||||
{
|
||||
struct ssif_addr_info *info;
|
||||
|
||||
if (slave_addr)
|
||||
return slave_addr;
|
||||
|
||||
/*
|
||||
* Came in without a slave address, search around to see if
|
||||
* the other sources have a slave address. This lets us pick
|
||||
* up an SMBIOS slave address when using ACPI.
|
||||
*/
|
||||
list_for_each_entry(info, &ssif_infos, link) {
|
||||
if (info->binfo.addr != client->addr)
|
||||
continue;
|
||||
if (info->adapter_name && strcmp_nospace(info->adapter_name,
|
||||
client->adapter->name))
|
||||
continue;
|
||||
if (info->slave_addr) {
|
||||
slave_addr = info->slave_addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_IPMI_DMI_DECODE
|
||||
if (!slave_addr)
|
||||
slave_addr = ipmi_dmi_get_slave_addr(
|
||||
IPMI_DMI_TYPE_SSIF,
|
||||
i2c_adapter_id(client->adapter),
|
||||
client->addr);
|
||||
#endif
|
||||
|
||||
return slave_addr;
|
||||
}
|
||||
@ -1448,7 +1445,6 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
u8 slave_addr = 0;
|
||||
struct ssif_addr_info *addr_info = NULL;
|
||||
|
||||
|
||||
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
|
||||
if (!resp)
|
||||
return -ENOMEM;
|
||||
@ -1469,6 +1465,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
ssif_info->addr_source = addr_info->addr_src;
|
||||
ssif_info->ssif_debug = addr_info->debug;
|
||||
ssif_info->addr_info = addr_info->addr_info;
|
||||
addr_info->client = client;
|
||||
slave_addr = addr_info->slave_addr;
|
||||
}
|
||||
}
|
||||
@ -1707,8 +1704,19 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
}
|
||||
|
||||
out:
|
||||
if (rv)
|
||||
if (rv) {
|
||||
/*
|
||||
* Note that if addr_info->client is assigned, we
|
||||
* leave it. The i2c client hangs around even if we
|
||||
* return a failure here, and the failure here is not
|
||||
* propagated back to the i2c code. This seems to be
|
||||
* design intent, strange as it may be. But if we
|
||||
* don't leave it, ssif_platform_remove will not remove
|
||||
* the client like it should.
|
||||
*/
|
||||
dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv);
|
||||
kfree(ssif_info);
|
||||
}
|
||||
kfree(resp);
|
||||
return rv;
|
||||
|
||||
@ -1733,7 +1741,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
|
||||
|
||||
static int new_ssif_client(int addr, char *adapter_name,
|
||||
int debug, int slave_addr,
|
||||
enum ipmi_addr_src addr_src)
|
||||
enum ipmi_addr_src addr_src,
|
||||
struct device *dev)
|
||||
{
|
||||
struct ssif_addr_info *addr_info;
|
||||
int rv = 0;
|
||||
@ -1766,6 +1775,9 @@ static int new_ssif_client(int addr, char *adapter_name,
|
||||
addr_info->debug = debug;
|
||||
addr_info->slave_addr = slave_addr;
|
||||
addr_info->addr_src = addr_src;
|
||||
addr_info->dev = dev;
|
||||
|
||||
dev_set_drvdata(dev, addr_info);
|
||||
|
||||
list_add_tail(&addr_info->link, &ssif_infos);
|
||||
|
||||
@ -1904,7 +1916,7 @@ static int try_init_spmi(struct SPMITable *spmi)
|
||||
|
||||
myaddr = spmi->addr.address & 0x7f;
|
||||
|
||||
return new_ssif_client(myaddr, NULL, 0, 0, SI_SPMI);
|
||||
return new_ssif_client(myaddr, NULL, 0, 0, SI_SPMI, NULL);
|
||||
}
|
||||
|
||||
static void spmi_find_bmc(void)
|
||||
@ -1933,48 +1945,40 @@ static void spmi_find_bmc(void) { }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DMI
|
||||
static int decode_dmi(const struct dmi_device *dmi_dev)
|
||||
static int dmi_ipmi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct dmi_header *dm = dmi_dev->device_data;
|
||||
u8 *data = (u8 *) dm;
|
||||
u8 len = dm->length;
|
||||
unsigned short myaddr;
|
||||
int slave_addr;
|
||||
u8 type, slave_addr = 0;
|
||||
u16 i2c_addr;
|
||||
int rv;
|
||||
|
||||
if (num_addrs >= MAX_SSIF_BMCS)
|
||||
return -1;
|
||||
if (!ssif_trydmi)
|
||||
return -ENODEV;
|
||||
|
||||
if (len < 9)
|
||||
return -1;
|
||||
rv = device_property_read_u8(&pdev->dev, "ipmi-type", &type);
|
||||
if (rv)
|
||||
return -ENODEV;
|
||||
|
||||
if (data[0x04] != 4) /* Not SSIF */
|
||||
return -1;
|
||||
if (type != IPMI_DMI_TYPE_SSIF)
|
||||
return -ENODEV;
|
||||
|
||||
if ((data[8] >> 1) == 0) {
|
||||
/*
|
||||
* Some broken systems put the I2C address in
|
||||
* the slave address field. We try to
|
||||
* accommodate them here.
|
||||
*/
|
||||
myaddr = data[6] >> 1;
|
||||
slave_addr = 0;
|
||||
} else {
|
||||
myaddr = data[8] >> 1;
|
||||
slave_addr = data[6];
|
||||
rv = device_property_read_u16(&pdev->dev, "i2c-addr", &i2c_addr);
|
||||
if (rv) {
|
||||
dev_warn(&pdev->dev, PFX "No i2c-addr property\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return new_ssif_client(myaddr, NULL, 0, slave_addr, SI_SMBIOS);
|
||||
}
|
||||
rv = device_property_read_u8(&pdev->dev, "slave-addr", &slave_addr);
|
||||
if (rv)
|
||||
dev_warn(&pdev->dev, "device has no slave-addr property");
|
||||
|
||||
static void dmi_iterator(void)
|
||||
{
|
||||
const struct dmi_device *dev = NULL;
|
||||
|
||||
while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev)))
|
||||
decode_dmi(dev);
|
||||
return new_ssif_client(i2c_addr, NULL, 0,
|
||||
slave_addr, SI_SMBIOS, &pdev->dev);
|
||||
}
|
||||
#else
|
||||
static void dmi_iterator(void) { }
|
||||
static int dmi_ipmi_probe(struct platform_device *pdev)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct i2c_device_id ssif_id[] = {
|
||||
@ -1995,6 +1999,36 @@ static struct i2c_driver ssif_i2c_driver = {
|
||||
.detect = ssif_detect
|
||||
};
|
||||
|
||||
static int ssif_platform_probe(struct platform_device *dev)
|
||||
{
|
||||
return dmi_ipmi_probe(dev);
|
||||
}
|
||||
|
||||
static int ssif_platform_remove(struct platform_device *dev)
|
||||
{
|
||||
struct ssif_addr_info *addr_info = dev_get_drvdata(&dev->dev);
|
||||
|
||||
if (!addr_info)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&ssif_infos_mutex);
|
||||
if (addr_info->client)
|
||||
i2c_unregister_device(addr_info->client);
|
||||
|
||||
list_del(&addr_info->link);
|
||||
kfree(addr_info);
|
||||
mutex_unlock(&ssif_infos_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver ipmi_driver = {
|
||||
.driver = {
|
||||
.name = DEVICE_NAME,
|
||||
},
|
||||
.probe = ssif_platform_probe,
|
||||
.remove = ssif_platform_remove,
|
||||
};
|
||||
|
||||
static int init_ipmi_ssif(void)
|
||||
{
|
||||
int i;
|
||||
@ -2009,7 +2043,7 @@ static int init_ipmi_ssif(void)
|
||||
for (i = 0; i < num_addrs; i++) {
|
||||
rv = new_ssif_client(addr[i], adapter_name[i],
|
||||
dbg[i], slave_addrs[i],
|
||||
SI_HARDCODED);
|
||||
SI_HARDCODED, NULL);
|
||||
if (rv)
|
||||
pr_err(PFX
|
||||
"Couldn't add hardcoded device at addr 0x%x\n",
|
||||
@ -2019,11 +2053,16 @@ static int init_ipmi_ssif(void)
|
||||
if (ssif_tryacpi)
|
||||
ssif_i2c_driver.driver.acpi_match_table =
|
||||
ACPI_PTR(ssif_acpi_match);
|
||||
if (ssif_trydmi)
|
||||
dmi_iterator();
|
||||
|
||||
if (ssif_tryacpi)
|
||||
spmi_find_bmc();
|
||||
|
||||
if (ssif_trydmi) {
|
||||
rv = platform_driver_register(&ipmi_driver);
|
||||
if (rv)
|
||||
pr_err(PFX "Unable to register driver: %d\n", rv);
|
||||
}
|
||||
|
||||
ssif_i2c_driver.address_list = ssif_address_list();
|
||||
|
||||
rv = i2c_add_driver(&ssif_i2c_driver);
|
||||
@ -2043,10 +2082,13 @@ static void cleanup_ipmi_ssif(void)
|
||||
|
||||
i2c_del_driver(&ssif_i2c_driver);
|
||||
|
||||
platform_driver_unregister(&ipmi_driver);
|
||||
|
||||
free_ssif_clients();
|
||||
}
|
||||
module_exit(cleanup_ipmi_ssif);
|
||||
|
||||
MODULE_ALIAS("platform:dmi-ipmi-ssif");
|
||||
MODULE_AUTHOR("Todd C Davis <todd.c.davis@intel.com>, Corey Minyard <minyard@acm.org>");
|
||||
MODULE_DESCRIPTION("IPMI driver for management controllers on a SMBus");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
Loading…
Reference in New Issue
Block a user