Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | cddd600 | 2019-09-23 17:38:27 -0600 | [diff] [blame] | 2 | |
| 3 | /* |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 4 | * Place in devicetree.cb: |
| 5 | * |
| 6 | * chip drivers/ipmi |
| 7 | * device pnp ca2.0 on end # IPMI KCS |
| 8 | * end |
| 9 | */ |
| 10 | |
Elyes HAOUAS | 92f46aa | 2020-09-15 08:42:17 +0200 | [diff] [blame] | 11 | #include <arch/io.h> |
Michael Niewöhner | 548a3dc | 2020-11-24 12:45:07 +0100 | [diff] [blame] | 12 | #include <bootstate.h> |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 13 | #include <console/console.h> |
| 14 | #include <device/device.h> |
Michael Niewöhner | 31830d3 | 2020-11-23 13:24:40 +0100 | [diff] [blame] | 15 | #include <device/gpio.h> |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 16 | #include <device/pnp.h> |
| 17 | #if CONFIG(HAVE_ACPI_TABLES) |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 18 | #include <acpi/acpi.h> |
| 19 | #include <acpi/acpigen.h> |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 20 | #endif |
| 21 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
| 22 | #include <smbios.h> |
| 23 | #endif |
| 24 | #include <version.h> |
| 25 | #include <delay.h> |
Patrick Rudolph | 3d41a13 | 2019-07-22 16:31:35 +0200 | [diff] [blame] | 26 | #include <timer.h> |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 27 | #include "ipmi_if.h" |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 28 | #include "ipmi_supermicro_oem.h" |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 29 | #include "chip.h" |
| 30 | |
| 31 | /* 4 bit encoding */ |
| 32 | static u8 ipmi_revision_major = 0x1; |
| 33 | static u8 ipmi_revision_minor = 0x0; |
| 34 | |
Tim Chu | 278ad21 | 2020-10-06 01:40:53 -0700 | [diff] [blame] | 35 | static u8 bmc_revision_major = 0x0; |
| 36 | static u8 bmc_revision_minor = 0x0; |
| 37 | |
Michael Niewöhner | 548a3dc | 2020-11-24 12:45:07 +0100 | [diff] [blame] | 38 | static struct boot_state_callback bscb_post_complete; |
| 39 | |
Michael Niewöhner | 548a3dc | 2020-11-24 12:45:07 +0100 | [diff] [blame] | 40 | static void bmc_set_post_complete_gpio_callback(void *arg) |
| 41 | { |
| 42 | struct drivers_ipmi_config *conf = arg; |
| 43 | const struct gpio_operations *gpio_ops; |
| 44 | |
| 45 | if (!conf || !conf->post_complete_gpio) |
| 46 | return; |
| 47 | |
| 48 | gpio_ops = dev_get_gpio_ops(conf->gpio_dev); |
| 49 | if (!gpio_ops) { |
| 50 | printk(BIOS_WARNING, "IPMI: specified gpio device is missing gpio ops!\n"); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | /* Set POST Complete pin. The `invert` field controls the polarity. */ |
| 55 | gpio_ops->output(conf->post_complete_gpio, conf->post_complete_invert ^ 1); |
| 56 | |
| 57 | printk(BIOS_DEBUG, "BMC: POST complete gpio set\n"); |
| 58 | } |
| 59 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 60 | static void ipmi_kcs_init(struct device *dev) |
| 61 | { |
| 62 | struct ipmi_devid_rsp rsp; |
| 63 | uint32_t man_id = 0, prod_id = 0; |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 64 | struct drivers_ipmi_config *conf = dev->chip_info; |
Michael Niewöhner | 31830d3 | 2020-11-23 13:24:40 +0100 | [diff] [blame] | 65 | const struct gpio_operations *gpio_ops; |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 66 | |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 67 | if (!conf) { |
| 68 | printk(BIOS_WARNING, "IPMI: chip_info is missing! Skip init.\n"); |
| 69 | return; |
| 70 | } |
Patrick Rudolph | 3d41a13 | 2019-07-22 16:31:35 +0200 | [diff] [blame] | 71 | |
Michael Niewöhner | 31830d3 | 2020-11-23 13:24:40 +0100 | [diff] [blame] | 72 | if (conf->bmc_jumper_gpio) { |
| 73 | gpio_ops = dev_get_gpio_ops(conf->gpio_dev); |
| 74 | if (!gpio_ops) { |
| 75 | printk(BIOS_WARNING, "IPMI: gpio device is missing gpio ops!\n"); |
| 76 | } else { |
| 77 | /* Get jumper value and set device state accordingly */ |
| 78 | dev->enabled = gpio_ops->get(conf->bmc_jumper_gpio); |
| 79 | if (!dev->enabled) |
| 80 | printk(BIOS_INFO, "IPMI: Disabled by jumper\n"); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | if (!dev->enabled) |
| 85 | return; |
| 86 | |
| 87 | printk(BIOS_DEBUG, "IPMI: PNP KCS 0x%x\n", dev->path.pnp.port); |
| 88 | |
Michael Niewöhner | 548a3dc | 2020-11-24 12:45:07 +0100 | [diff] [blame] | 89 | /* Set up boot state callback for POST_COMPLETE# */ |
| 90 | if (conf->post_complete_gpio) { |
| 91 | bscb_post_complete.callback = bmc_set_post_complete_gpio_callback; |
| 92 | bscb_post_complete.arg = conf; |
| 93 | boot_state_sched_on_entry(&bscb_post_complete, BS_PAYLOAD_BOOT); |
| 94 | } |
| 95 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 96 | /* Get IPMI version for ACPI and SMBIOS */ |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 97 | if (conf->wait_for_bmc && conf->bmc_boot_timeout) { |
Patrick Rudolph | 3d41a13 | 2019-07-22 16:31:35 +0200 | [diff] [blame] | 98 | struct stopwatch sw; |
| 99 | stopwatch_init_msecs_expire(&sw, conf->bmc_boot_timeout * 1000); |
Paul Menzel | 01c1815 | 2020-06-02 11:12:30 +0200 | [diff] [blame] | 100 | printk(BIOS_INFO, "IPMI: Waiting for BMC...\n"); |
Patrick Rudolph | 3d41a13 | 2019-07-22 16:31:35 +0200 | [diff] [blame] | 101 | |
| 102 | while (!stopwatch_expired(&sw)) { |
| 103 | if (inb(dev->path.pnp.port) != 0xff) |
| 104 | break; |
| 105 | mdelay(100); |
| 106 | } |
| 107 | if (stopwatch_expired(&sw)) { |
| 108 | printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n"); |
| 109 | /* Don't write tables if communication failed */ |
| 110 | dev->enabled = 0; |
| 111 | return; |
| 112 | } |
| 113 | } |
| 114 | |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 115 | if (ipmi_process_self_test_result(dev)) |
Morgan Jang | 5015502 | 2019-11-06 10:24:47 +0800 | [diff] [blame] | 116 | /* Don't write tables if communication failed */ |
| 117 | dev->enabled = 0; |
Morgan Jang | 5015502 | 2019-11-06 10:24:47 +0800 | [diff] [blame] | 118 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 119 | if (!ipmi_get_device_id(dev, &rsp)) { |
Patrick Rudolph | 3d41a13 | 2019-07-22 16:31:35 +0200 | [diff] [blame] | 120 | /* Queried the IPMI revision from BMC */ |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 121 | ipmi_revision_minor = IPMI_IPMI_VERSION_MINOR(rsp.ipmi_version); |
| 122 | ipmi_revision_major = IPMI_IPMI_VERSION_MAJOR(rsp.ipmi_version); |
| 123 | |
Tim Chu | 278ad21 | 2020-10-06 01:40:53 -0700 | [diff] [blame] | 124 | bmc_revision_major = rsp.fw_rev1; |
| 125 | bmc_revision_minor = rsp.fw_rev2; |
| 126 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 127 | memcpy(&man_id, rsp.manufacturer_id, |
| 128 | sizeof(rsp.manufacturer_id)); |
| 129 | |
| 130 | memcpy(&prod_id, rsp.product_id, sizeof(rsp.product_id)); |
| 131 | |
| 132 | printk(BIOS_INFO, "IPMI: Found man_id 0x%06x, prod_id 0x%04x\n", |
| 133 | man_id, prod_id); |
| 134 | |
| 135 | printk(BIOS_INFO, "IPMI: Version %01x.%01x\n", |
| 136 | ipmi_revision_major, ipmi_revision_minor); |
| 137 | } else { |
| 138 | /* Don't write tables if communication failed */ |
| 139 | dev->enabled = 0; |
| 140 | } |
Patrick Rudolph | 09cdeba | 2019-12-30 14:40:04 +0100 | [diff] [blame] | 141 | |
| 142 | if (!dev->enabled) |
| 143 | return; |
| 144 | |
| 145 | if (CONFIG(DRIVERS_IPMI_SUPERMICRO_OEM)) |
| 146 | supermicro_ipmi_oem(dev->path.pnp.port); |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | #if CONFIG(HAVE_ACPI_TABLES) |
| 150 | static uint32_t uid_cnt = 0; |
| 151 | |
| 152 | static unsigned long |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 153 | ipmi_write_acpi_tables(const struct device *dev, unsigned long current, |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 154 | struct acpi_rsdp *rsdp) |
| 155 | { |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 156 | struct drivers_ipmi_config *conf = dev->chip_info; |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 157 | struct acpi_spmi *spmi; |
| 158 | s8 gpe_interrupt = -1; |
| 159 | u32 apic_interrupt = 0; |
| 160 | acpi_addr_t addr = { |
| 161 | .space_id = ACPI_ADDRESS_SPACE_IO, |
| 162 | .access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS, |
| 163 | .addrl = dev->path.pnp.port, |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 164 | .bit_width = 8, |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 165 | }; |
| 166 | |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 167 | switch (CONFIG_IPMI_KCS_REGISTER_SPACING) { |
| 168 | case 4: |
| 169 | addr.bit_offset = 32; |
| 170 | break; |
| 171 | case 16: |
| 172 | addr.bit_offset = 128; |
| 173 | break; |
| 174 | default: |
| 175 | printk(BIOS_ERR, "IPMI: Unsupported register spacing for SPMI\n"); |
Arthur Heymans | fff2021 | 2021-03-15 14:56:16 +0100 | [diff] [blame] | 176 | __fallthrough; |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 177 | case 1: |
| 178 | addr.bit_offset = 8; |
| 179 | break; |
| 180 | } |
| 181 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 182 | current = ALIGN_UP(current, 8); |
| 183 | printk(BIOS_DEBUG, "ACPI: * SPMI at %lx\n", current); |
| 184 | spmi = (struct acpi_spmi *)current; |
| 185 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 186 | if (conf) { |
| 187 | if (conf->have_gpe) |
| 188 | gpe_interrupt = conf->gpe_interrupt; |
| 189 | if (conf->have_apic) |
| 190 | apic_interrupt = conf->apic_interrupt; |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 191 | |
| 192 | /* Use command to get UID from ipmi_ssdt */ |
| 193 | acpi_create_ipmi(dev, spmi, (ipmi_revision_major << 8) | |
| 194 | (ipmi_revision_minor << 4), &addr, |
| 195 | IPMI_INTERFACE_KCS, gpe_interrupt, apic_interrupt, |
| 196 | conf->uid); |
| 197 | |
| 198 | acpi_add_table(rsdp, spmi); |
| 199 | |
| 200 | current += spmi->header.length; |
| 201 | } else { |
| 202 | printk(BIOS_WARNING, "IPMI: chip_info is missing!\n"); |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 203 | } |
| 204 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 205 | return current; |
| 206 | } |
| 207 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 208 | static void ipmi_ssdt(const struct device *dev) |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 209 | { |
| 210 | const char *scope = acpi_device_scope(dev); |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 211 | struct drivers_ipmi_config *conf = dev->chip_info; |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 212 | |
| 213 | if (!scope) { |
| 214 | printk(BIOS_ERR, "IPMI: Missing ACPI scope for %s\n", |
| 215 | dev_path(dev)); |
| 216 | return; |
| 217 | } |
| 218 | |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 219 | if (!conf) { |
| 220 | printk(BIOS_WARNING, "IPMI: chip_info is missing!\n"); |
| 221 | return; |
| 222 | } |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 223 | |
| 224 | /* Use command to pass UID to ipmi_write_acpi_tables */ |
Furquan Shaikh | 0f6e652 | 2020-04-24 21:35:23 -0700 | [diff] [blame] | 225 | conf->uid = uid_cnt++; |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 226 | |
| 227 | /* write SPMI device */ |
| 228 | acpigen_write_scope(scope); |
| 229 | acpigen_write_device("SPMI"); |
| 230 | acpigen_write_name_string("_HID", "IPI0001"); |
Patrick Rudolph | 389c827 | 2019-12-17 13:54:41 +0100 | [diff] [blame] | 231 | acpigen_write_name_unicode("_STR", "IPMI_KCS"); |
Furquan Shaikh | 0f6e652 | 2020-04-24 21:35:23 -0700 | [diff] [blame] | 232 | acpigen_write_name_byte("_UID", conf->uid); |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 233 | acpigen_write_STA(0xf); |
| 234 | acpigen_write_name("_CRS"); |
| 235 | acpigen_write_resourcetemplate_header(); |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 236 | acpigen_write_io16(dev->path.pnp.port, dev->path.pnp.port, 1, 1, 1); |
| 237 | acpigen_write_io16(dev->path.pnp.port + CONFIG_IPMI_KCS_REGISTER_SPACING, |
| 238 | dev->path.pnp.port + CONFIG_IPMI_KCS_REGISTER_SPACING, 1, 1, 1); |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 239 | |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 240 | // FIXME: is that correct? |
| 241 | if (conf->have_apic) |
| 242 | acpigen_write_irq(1 << conf->apic_interrupt); |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 243 | |
| 244 | acpigen_write_resourcetemplate_footer(); |
| 245 | |
| 246 | acpigen_write_method("_IFT", 0); |
| 247 | acpigen_write_return_byte(1); // KCS |
| 248 | acpigen_pop_len(); |
| 249 | |
| 250 | acpigen_write_method("_SRV", 0); |
| 251 | acpigen_write_return_integer((ipmi_revision_major << 8) | |
| 252 | (ipmi_revision_minor << 4)); |
| 253 | acpigen_pop_len(); |
| 254 | |
| 255 | acpigen_pop_len(); /* pop device */ |
| 256 | acpigen_pop_len(); /* pop scope */ |
| 257 | } |
| 258 | #endif |
| 259 | |
Tim Chu | 278ad21 | 2020-10-06 01:40:53 -0700 | [diff] [blame] | 260 | void ipmi_bmc_version(uint8_t *ipmi_bmc_major_revision, uint8_t *ipmi_bmc_minor_revision) |
| 261 | { |
| 262 | if (!bmc_revision_major || !bmc_revision_minor) { |
| 263 | printk(BIOS_ERR, "IPMI: BMC revision missing\n"); |
| 264 | *ipmi_bmc_major_revision = 0; |
| 265 | *ipmi_bmc_minor_revision = 0; |
| 266 | } else { |
| 267 | *ipmi_bmc_major_revision = bmc_revision_major; |
| 268 | *ipmi_bmc_minor_revision = bmc_revision_minor; |
| 269 | } |
| 270 | } |
| 271 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 272 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
| 273 | static int ipmi_smbios_data(struct device *dev, int *handle, |
| 274 | unsigned long *current) |
| 275 | { |
Bill XIE | f880eb0 | 2020-11-10 15:20:24 +0800 | [diff] [blame] | 276 | struct drivers_ipmi_config *conf = dev->chip_info; |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 277 | u8 nv_storage = 0xff; |
| 278 | u8 i2c_address = 0; |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 279 | u8 register_spacing; |
| 280 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 281 | int len = 0; |
| 282 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 283 | if (conf) { |
| 284 | if (conf->have_nv_storage) |
| 285 | nv_storage = conf->nv_storage_device_address; |
| 286 | i2c_address = conf->bmc_i2c_address; |
| 287 | } |
| 288 | |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 289 | switch (CONFIG_IPMI_KCS_REGISTER_SPACING) { |
| 290 | case 4: |
| 291 | register_spacing = 1 << 6; |
| 292 | break; |
| 293 | case 16: |
| 294 | register_spacing = 2 << 6; |
| 295 | break; |
| 296 | default: |
| 297 | printk(BIOS_ERR, "IPMI: Unsupported register spacing for SMBIOS\n"); |
Arthur Heymans | fff2021 | 2021-03-15 14:56:16 +0100 | [diff] [blame] | 298 | __fallthrough; |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 299 | case 1: |
| 300 | register_spacing = 0 << 6; |
| 301 | break; |
| 302 | } |
| 303 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 304 | // add IPMI Device Information |
| 305 | len += smbios_write_type38( |
| 306 | current, handle, |
| 307 | SMBIOS_BMC_INTERFACE_KCS, |
| 308 | ipmi_revision_minor | (ipmi_revision_major << 4), |
| 309 | i2c_address, // I2C address |
| 310 | nv_storage, // NV storage |
| 311 | dev->path.pnp.port | 1, // IO interface |
Patrick Rudolph | a96c4a1 | 2019-08-29 19:44:32 +0200 | [diff] [blame] | 312 | register_spacing, |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 313 | 0); // no IRQ |
| 314 | |
Angel Pons | 6a73b24 | 2021-09-03 12:18:10 +0200 | [diff] [blame] | 315 | len += get_smbios_data(dev, handle, current); |
| 316 | |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 317 | return len; |
| 318 | } |
| 319 | #endif |
| 320 | |
| 321 | static void ipmi_set_resources(struct device *dev) |
| 322 | { |
| 323 | struct resource *res; |
| 324 | |
| 325 | for (res = dev->resource_list; res; res = res->next) { |
| 326 | if (!(res->flags & IORESOURCE_ASSIGNED)) |
| 327 | continue; |
| 328 | |
| 329 | res->flags |= IORESOURCE_STORED; |
| 330 | report_resource_stored(dev, res, ""); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static void ipmi_read_resources(struct device *dev) |
| 335 | { |
| 336 | struct resource *res = new_resource(dev, 0); |
| 337 | res->base = dev->path.pnp.port; |
| 338 | res->size = 2; |
| 339 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 340 | } |
| 341 | |
| 342 | static struct device_operations ops = { |
| 343 | .read_resources = ipmi_read_resources, |
| 344 | .set_resources = ipmi_set_resources, |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 345 | .init = ipmi_kcs_init, |
| 346 | #if CONFIG(HAVE_ACPI_TABLES) |
| 347 | .write_acpi_tables = ipmi_write_acpi_tables, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 348 | .acpi_fill_ssdt = ipmi_ssdt, |
Patrick Rudolph | ffbc3b5 | 2019-06-06 15:45:51 +0200 | [diff] [blame] | 349 | #endif |
| 350 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
| 351 | .get_smbios_data = ipmi_smbios_data, |
| 352 | #endif |
| 353 | }; |
| 354 | |
| 355 | static void enable_dev(struct device *dev) |
| 356 | { |
| 357 | if (dev->path.type != DEVICE_PATH_PNP) |
| 358 | printk(BIOS_ERR, "%s: Unsupported device type\n", |
| 359 | dev_path(dev)); |
| 360 | else if (dev->path.pnp.port & 1) |
| 361 | printk(BIOS_ERR, "%s: Base address needs to be aligned to 2\n", |
| 362 | dev_path(dev)); |
| 363 | else |
| 364 | dev->ops = &ops; |
| 365 | } |
| 366 | |
| 367 | struct chip_operations drivers_ipmi_ops = { |
| 368 | CHIP_NAME("IPMI KCS") |
| 369 | .enable_dev = enable_dev, |
| 370 | }; |