| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <console/console.h> |
| 11 |
#include <device/device.h> |
| 12 |
#include <device/pnp.h> |
| 13 |
#include <drivers/ipmi/ipmi_if.h> |
| 14 |
#include <drivers/ocp/dmi/ocp_dmi.h> |
| 15 |
#include <types.h> |
| 16 |
|
| 17 |
#include "ipmi_ocp.h" |
| 18 |
|
| 19 |
static enum cb_err ipmi_set_ppin(struct device *dev) |
| 20 |
{ |
| 21 |
int ret; |
| 22 |
struct ipmi_rsp rsp; |
| 23 |
struct ppin_req req = {0}; |
| 24 |
|
| 25 |
req.cpu0_lo = xeon_sp_ppin[0].lo; |
| 26 |
req.cpu0_hi = xeon_sp_ppin[0].hi; |
| 27 |
if (CONFIG_MAX_SOCKET > 1) { |
| 28 |
req.cpu1_lo = xeon_sp_ppin[1].lo; |
| 29 |
req.cpu1_hi = xeon_sp_ppin[1].hi; |
| 30 |
} |
| 31 |
ret = ipmi_message(dev->path.pnp.port, IPMI_NETFN_OEM, 0x0, IPMI_OEM_SET_PPIN, |
| 32 |
(const unsigned char *)&req, sizeof(req), |
| 33 |
(unsigned char *)&rsp, sizeof(rsp)); |
| 34 |
|
| 35 |
if (ret < sizeof(struct ipmi_rsp) || rsp.completion_code) { |
| 36 |
printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n", |
| 37 |
__func__, ret, rsp.completion_code); |
| 38 |
return CB_ERR; |
| 39 |
} |
| 40 |
printk(BIOS_DEBUG, "IPMI: %s command success\n", __func__); |
| 41 |
return CB_SUCCESS; |
| 42 |
} |
| 43 |
|
| 44 |
static void ipmi_ocp_init(struct device *dev) |
| 45 |
{ |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
static void ipmi_ocp_final(struct device *dev) |
| 50 |
{ |
| 51 |
|
| 52 |
|
| 53 |
if (CONFIG(OCP_DMI)) |
| 54 |
ipmi_set_ppin(dev); |
| 55 |
} |
| 56 |
|
| 57 |
static void ipmi_set_resources(struct device *dev) |
| 58 |
{ |
| 59 |
struct resource *res; |
| 60 |
|
| 61 |
for (res = dev->resource_list; res; res = res->next) { |
| 62 |
if (!(res->flags & IORESOURCE_ASSIGNED)) |
| 63 |
continue; |
| 64 |
|
| 65 |
res->flags |= IORESOURCE_STORED; |
| 66 |
report_resource_stored(dev, res, ""); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
static void ipmi_read_resources(struct device *dev) |
| 71 |
{ |
| 72 |
struct resource *res = new_resource(dev, 0); |
| 73 |
res->base = dev->path.pnp.port; |
| 74 |
res->size = 2; |
| 75 |
res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 76 |
} |
| 77 |
|
| 78 |
static struct device_operations ops = { |
| 79 |
.read_resources = ipmi_read_resources, |
| 80 |
.set_resources = ipmi_set_resources, |
| 81 |
.init = ipmi_ocp_init, |
| 82 |
.final = ipmi_ocp_final, |
| 83 |
}; |
| 84 |
|
| 85 |
static void enable_dev(struct device *dev) |
| 86 |
{ |
| 87 |
if (dev->path.type != DEVICE_PATH_PNP) |
| 88 |
printk(BIOS_ERR, "%s: Unsupported device type\n", |
| 89 |
dev_path(dev)); |
| 90 |
else if (dev->path.pnp.port & 1) |
| 91 |
printk(BIOS_ERR, "%s: Base address needs to be aligned to 2\n", |
| 92 |
dev_path(dev)); |
| 93 |
else |
| 94 |
dev->ops = &ops; |
| 95 |
} |
| 96 |
|
| 97 |
struct chip_operations drivers_ipmi_ocp_ops = { |
| 98 |
.name = "IPMI OCP", |
| 99 |
.enable_dev = enable_dev, |
| 100 |
}; |