0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/acpi.h>
0010 #include <linux/bitops.h>
0011 #include <linux/device.h>
0012 #include <linux/errno.h>
0013 #include <linux/intel-ish-client-if.h>
0014 #include <linux/kernel.h>
0015 #include <linux/module.h>
0016 #include <linux/mutex.h>
0017 #include <linux/slab.h>
0018 #include <linux/suspend.h>
0019 #include <linux/types.h>
0020 #include <linux/uuid.h>
0021 #include <linux/uaccess.h>
0022
0023 #define ECLITE_DATA_OPREGION_ID 0x9E
0024 #define ECLITE_CMD_OPREGION_ID 0x9F
0025
0026 #define ECL_MSG_DATA 0x1
0027 #define ECL_MSG_EVENT 0x2
0028
0029 #define ECL_ISH_READ 0x1
0030 #define ECL_ISH_WRITE 0x2
0031 #define ECL_ISH_HEADER_VERSION 0
0032
0033 #define ECL_CL_RX_RING_SIZE 16
0034 #define ECL_CL_TX_RING_SIZE 8
0035
0036 #define ECL_DATA_OPR_BUFLEN 384
0037 #define ECL_EVENTS_NOTIFY 333
0038
0039 #define cmd_opr_offsetof(element) offsetof(struct opregion_cmd, element)
0040 #define cl_data_to_dev(opr_dev) ishtp_device((opr_dev)->cl_device)
0041
0042 #ifndef BITS_TO_BYTES
0043 #define BITS_TO_BYTES(x) ((x) / 8)
0044 #endif
0045
0046 struct opregion_cmd {
0047 unsigned int command;
0048 unsigned int offset;
0049 unsigned int length;
0050 unsigned int event_id;
0051 };
0052
0053 struct opregion_data {
0054 char data[ECL_DATA_OPR_BUFLEN];
0055 };
0056
0057 struct opregion_context {
0058 struct opregion_cmd cmd_area;
0059 struct opregion_data data_area;
0060 };
0061
0062 struct ecl_message_header {
0063 unsigned int version:2;
0064 unsigned int data_type:2;
0065 unsigned int request_type:2;
0066 unsigned int offset:9;
0067 unsigned int data_len:9;
0068 unsigned int event:8;
0069 };
0070
0071 struct ecl_message {
0072 struct ecl_message_header header;
0073 char payload[ECL_DATA_OPR_BUFLEN];
0074 };
0075
0076 struct ishtp_opregion_dev {
0077 struct opregion_context opr_context;
0078 struct ishtp_cl *ecl_ishtp_cl;
0079 struct ishtp_cl_device *cl_device;
0080 struct ishtp_fw_client *fw_client;
0081 struct ishtp_cl_rb *rb;
0082 struct acpi_device *adev;
0083 unsigned int dsm_event_id;
0084 unsigned int ish_link_ready;
0085 unsigned int ish_read_done;
0086 unsigned int acpi_init_done;
0087 wait_queue_head_t read_wait;
0088 struct work_struct event_work;
0089 struct work_struct reset_work;
0090
0091 struct mutex lock;
0092
0093 };
0094
0095
0096 static const struct ishtp_device_id ecl_ishtp_id_table[] = {
0097 { .guid = GUID_INIT(0x6a19cc4b, 0xd760, 0x4de3,
0098 0xb1, 0x4d, 0xf2, 0x5e, 0xbd, 0xf, 0xbc, 0xd9), },
0099 { }
0100 };
0101 MODULE_DEVICE_TABLE(ishtp, ecl_ishtp_id_table);
0102
0103
0104 static const guid_t ecl_acpi_guid =
0105 GUID_INIT(0x91d936a7, 0x1f01, 0x49c6, 0xa6,
0106 0xb4, 0x72, 0xf0, 0x0a, 0xd8, 0xd8, 0xa5);
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 static int ecl_ish_cl_read(struct ishtp_opregion_dev *opr_dev)
0118 {
0119 struct ecl_message_header header;
0120 int len, rv;
0121
0122 if (!opr_dev->ish_link_ready)
0123 return -EIO;
0124
0125 if ((opr_dev->opr_context.cmd_area.offset +
0126 opr_dev->opr_context.cmd_area.length) > ECL_DATA_OPR_BUFLEN) {
0127 return -EINVAL;
0128 }
0129
0130 header.version = ECL_ISH_HEADER_VERSION;
0131 header.data_type = ECL_MSG_DATA;
0132 header.request_type = ECL_ISH_READ;
0133 header.offset = opr_dev->opr_context.cmd_area.offset;
0134 header.data_len = opr_dev->opr_context.cmd_area.length;
0135 header.event = opr_dev->opr_context.cmd_area.event_id;
0136 len = sizeof(header);
0137
0138 opr_dev->ish_read_done = false;
0139 rv = ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&header, len);
0140 if (rv) {
0141 dev_err(cl_data_to_dev(opr_dev), "ish-read : send failed\n");
0142 return -EIO;
0143 }
0144
0145 dev_dbg(cl_data_to_dev(opr_dev),
0146 "[ish_rd] Req: off : %x, len : %x\n",
0147 header.offset,
0148 header.data_len);
0149
0150 rv = wait_event_interruptible_timeout(opr_dev->read_wait,
0151 opr_dev->ish_read_done,
0152 2 * HZ);
0153 if (!rv) {
0154 dev_err(cl_data_to_dev(opr_dev),
0155 "[ish_rd] No response from firmware\n");
0156 return -EIO;
0157 }
0158
0159 return 0;
0160 }
0161
0162
0163
0164
0165
0166
0167
0168
0169 static int ecl_ish_cl_write(struct ishtp_opregion_dev *opr_dev)
0170 {
0171 struct ecl_message message;
0172 int len;
0173
0174 if (!opr_dev->ish_link_ready)
0175 return -EIO;
0176
0177 if ((opr_dev->opr_context.cmd_area.offset +
0178 opr_dev->opr_context.cmd_area.length) > ECL_DATA_OPR_BUFLEN) {
0179 return -EINVAL;
0180 }
0181
0182 message.header.version = ECL_ISH_HEADER_VERSION;
0183 message.header.data_type = ECL_MSG_DATA;
0184 message.header.request_type = ECL_ISH_WRITE;
0185 message.header.offset = opr_dev->opr_context.cmd_area.offset;
0186 message.header.data_len = opr_dev->opr_context.cmd_area.length;
0187 message.header.event = opr_dev->opr_context.cmd_area.event_id;
0188 len = sizeof(struct ecl_message_header) + message.header.data_len;
0189
0190 memcpy(message.payload,
0191 opr_dev->opr_context.data_area.data + message.header.offset,
0192 message.header.data_len);
0193
0194 dev_dbg(cl_data_to_dev(opr_dev),
0195 "[ish_wr] off : %x, len : %x\n",
0196 message.header.offset,
0197 message.header.data_len);
0198
0199 return ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&message, len);
0200 }
0201
0202 static acpi_status
0203 ecl_opregion_cmd_handler(u32 function, acpi_physical_address address,
0204 u32 bits, u64 *value64,
0205 void *handler_context, void *region_context)
0206 {
0207 struct ishtp_opregion_dev *opr_dev;
0208 struct opregion_cmd *cmd;
0209 acpi_status status = AE_OK;
0210
0211 if (!region_context || !value64)
0212 return AE_BAD_PARAMETER;
0213
0214 if (function == ACPI_READ)
0215 return AE_ERROR;
0216
0217 opr_dev = (struct ishtp_opregion_dev *)region_context;
0218
0219 mutex_lock(&opr_dev->lock);
0220
0221 cmd = &opr_dev->opr_context.cmd_area;
0222
0223 switch (address) {
0224 case cmd_opr_offsetof(command):
0225 cmd->command = (u32)*value64;
0226
0227 if (cmd->command == ECL_ISH_READ)
0228 status = ecl_ish_cl_read(opr_dev);
0229 else if (cmd->command == ECL_ISH_WRITE)
0230 status = ecl_ish_cl_write(opr_dev);
0231 else
0232 status = AE_ERROR;
0233 break;
0234 case cmd_opr_offsetof(offset):
0235 cmd->offset = (u32)*value64;
0236 break;
0237 case cmd_opr_offsetof(length):
0238 cmd->length = (u32)*value64;
0239 break;
0240 case cmd_opr_offsetof(event_id):
0241 cmd->event_id = (u32)*value64;
0242 break;
0243 default:
0244 status = AE_ERROR;
0245 }
0246
0247 mutex_unlock(&opr_dev->lock);
0248
0249 return status;
0250 }
0251
0252 static acpi_status
0253 ecl_opregion_data_handler(u32 function, acpi_physical_address address,
0254 u32 bits, u64 *value64,
0255 void *handler_context, void *region_context)
0256 {
0257 struct ishtp_opregion_dev *opr_dev;
0258 unsigned int bytes = BITS_TO_BYTES(bits);
0259 void *data_addr;
0260
0261 if (!region_context || !value64)
0262 return AE_BAD_PARAMETER;
0263
0264 if (address + bytes > ECL_DATA_OPR_BUFLEN)
0265 return AE_BAD_PARAMETER;
0266
0267 opr_dev = (struct ishtp_opregion_dev *)region_context;
0268
0269 mutex_lock(&opr_dev->lock);
0270
0271 data_addr = &opr_dev->opr_context.data_area.data[address];
0272
0273 if (function == ACPI_READ) {
0274 memcpy(value64, data_addr, bytes);
0275 } else if (function == ACPI_WRITE) {
0276 memcpy(data_addr, value64, bytes);
0277 } else {
0278 mutex_unlock(&opr_dev->lock);
0279 return AE_BAD_PARAMETER;
0280 }
0281
0282 mutex_unlock(&opr_dev->lock);
0283
0284 return AE_OK;
0285 }
0286
0287 static int acpi_find_eclite_device(struct ishtp_opregion_dev *opr_dev)
0288 {
0289 struct acpi_device *adev;
0290
0291
0292 adev = acpi_dev_get_first_match_dev("INTC1035", NULL, -1);
0293 if (!adev) {
0294 dev_err(cl_data_to_dev(opr_dev), "eclite ACPI device not found\n");
0295 return -ENODEV;
0296 }
0297
0298 opr_dev->adev = adev;
0299
0300 return 0;
0301 }
0302
0303 static int acpi_opregion_init(struct ishtp_opregion_dev *opr_dev)
0304 {
0305 acpi_status status;
0306
0307 status = acpi_install_address_space_handler(opr_dev->adev->handle,
0308 ECLITE_CMD_OPREGION_ID,
0309 ecl_opregion_cmd_handler,
0310 NULL, opr_dev);
0311 if (ACPI_FAILURE(status)) {
0312 dev_err(cl_data_to_dev(opr_dev),
0313 "cmd space handler install failed\n");
0314 return -ENODEV;
0315 }
0316
0317 status = acpi_install_address_space_handler(opr_dev->adev->handle,
0318 ECLITE_DATA_OPREGION_ID,
0319 ecl_opregion_data_handler,
0320 NULL, opr_dev);
0321 if (ACPI_FAILURE(status)) {
0322 dev_err(cl_data_to_dev(opr_dev),
0323 "data space handler install failed\n");
0324
0325 acpi_remove_address_space_handler(opr_dev->adev->handle,
0326 ECLITE_CMD_OPREGION_ID,
0327 ecl_opregion_cmd_handler);
0328 return -ENODEV;
0329 }
0330 opr_dev->acpi_init_done = true;
0331
0332 dev_dbg(cl_data_to_dev(opr_dev), "Opregion handlers are installed\n");
0333
0334 return 0;
0335 }
0336
0337 static void acpi_opregion_deinit(struct ishtp_opregion_dev *opr_dev)
0338 {
0339 acpi_remove_address_space_handler(opr_dev->adev->handle,
0340 ECLITE_CMD_OPREGION_ID,
0341 ecl_opregion_cmd_handler);
0342
0343 acpi_remove_address_space_handler(opr_dev->adev->handle,
0344 ECLITE_DATA_OPREGION_ID,
0345 ecl_opregion_data_handler);
0346 opr_dev->acpi_init_done = false;
0347 }
0348
0349 static void ecl_acpi_invoke_dsm(struct work_struct *work)
0350 {
0351 struct ishtp_opregion_dev *opr_dev;
0352 union acpi_object *obj;
0353
0354 opr_dev = container_of(work, struct ishtp_opregion_dev, event_work);
0355 if (!opr_dev->acpi_init_done)
0356 return;
0357
0358 obj = acpi_evaluate_dsm(opr_dev->adev->handle, &ecl_acpi_guid, 0,
0359 opr_dev->dsm_event_id, NULL);
0360 if (!obj) {
0361 dev_warn(cl_data_to_dev(opr_dev), "_DSM fn call failed\n");
0362 return;
0363 }
0364
0365 dev_dbg(cl_data_to_dev(opr_dev), "Exec DSM function code: %d success\n",
0366 opr_dev->dsm_event_id);
0367
0368 ACPI_FREE(obj);
0369 }
0370
0371 static void ecl_ish_process_rx_data(struct ishtp_opregion_dev *opr_dev)
0372 {
0373 struct ecl_message *message =
0374 (struct ecl_message *)opr_dev->rb->buffer.data;
0375
0376 dev_dbg(cl_data_to_dev(opr_dev),
0377 "[ish_rd] Resp: off : %x, len : %x\n",
0378 message->header.offset,
0379 message->header.data_len);
0380
0381 if ((message->header.offset + message->header.data_len) >
0382 ECL_DATA_OPR_BUFLEN) {
0383 return;
0384 }
0385
0386 memcpy(opr_dev->opr_context.data_area.data + message->header.offset,
0387 message->payload, message->header.data_len);
0388
0389 opr_dev->ish_read_done = true;
0390 wake_up_interruptible(&opr_dev->read_wait);
0391 }
0392
0393 static void ecl_ish_process_rx_event(struct ishtp_opregion_dev *opr_dev)
0394 {
0395 struct ecl_message_header *header =
0396 (struct ecl_message_header *)opr_dev->rb->buffer.data;
0397
0398 dev_dbg(cl_data_to_dev(opr_dev),
0399 "[ish_ev] Evt received: %8x\n", header->event);
0400
0401 opr_dev->dsm_event_id = header->event;
0402 schedule_work(&opr_dev->event_work);
0403 }
0404
0405 static int ecl_ish_cl_enable_events(struct ishtp_opregion_dev *opr_dev,
0406 bool config_enable)
0407 {
0408 struct ecl_message message;
0409 int len;
0410
0411 message.header.version = ECL_ISH_HEADER_VERSION;
0412 message.header.data_type = ECL_MSG_DATA;
0413 message.header.request_type = ECL_ISH_WRITE;
0414 message.header.offset = ECL_EVENTS_NOTIFY;
0415 message.header.data_len = 1;
0416 message.payload[0] = config_enable;
0417
0418 len = sizeof(struct ecl_message_header) + message.header.data_len;
0419
0420 return ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&message, len);
0421 }
0422
0423 static void ecl_ishtp_cl_event_cb(struct ishtp_cl_device *cl_device)
0424 {
0425 struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
0426 struct ishtp_opregion_dev *opr_dev;
0427 struct ecl_message_header *header;
0428 struct ishtp_cl_rb *rb;
0429
0430 opr_dev = ishtp_get_client_data(ecl_ishtp_cl);
0431 while ((rb = ishtp_cl_rx_get_rb(opr_dev->ecl_ishtp_cl)) != NULL) {
0432 opr_dev->rb = rb;
0433 header = (struct ecl_message_header *)rb->buffer.data;
0434
0435 if (header->data_type == ECL_MSG_DATA)
0436 ecl_ish_process_rx_data(opr_dev);
0437 else if (header->data_type == ECL_MSG_EVENT)
0438 ecl_ish_process_rx_event(opr_dev);
0439 else
0440
0441 dev_err(cl_data_to_dev(opr_dev),
0442 "[ish_cb] Received wrong data_type\n");
0443
0444 ishtp_cl_io_rb_recycle(rb);
0445 }
0446 }
0447
0448 static int ecl_ishtp_cl_init(struct ishtp_cl *ecl_ishtp_cl)
0449 {
0450 struct ishtp_opregion_dev *opr_dev =
0451 ishtp_get_client_data(ecl_ishtp_cl);
0452 struct ishtp_fw_client *fw_client;
0453 struct ishtp_device *dev;
0454 int rv;
0455
0456 rv = ishtp_cl_link(ecl_ishtp_cl);
0457 if (rv) {
0458 dev_err(cl_data_to_dev(opr_dev), "ishtp_cl_link failed\n");
0459 return rv;
0460 }
0461
0462 dev = ishtp_get_ishtp_device(ecl_ishtp_cl);
0463
0464
0465 ishtp_set_tx_ring_size(ecl_ishtp_cl, ECL_CL_TX_RING_SIZE);
0466 ishtp_set_rx_ring_size(ecl_ishtp_cl, ECL_CL_RX_RING_SIZE);
0467
0468 fw_client = ishtp_fw_cl_get_client(dev, &ecl_ishtp_id_table[0].guid);
0469 if (!fw_client) {
0470 dev_err(cl_data_to_dev(opr_dev), "fw client not found\n");
0471 return -ENOENT;
0472 }
0473
0474 ishtp_cl_set_fw_client_id(ecl_ishtp_cl,
0475 ishtp_get_fw_client_id(fw_client));
0476
0477 ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_CONNECTING);
0478
0479 rv = ishtp_cl_connect(ecl_ishtp_cl);
0480 if (rv) {
0481 dev_err(cl_data_to_dev(opr_dev), "client connect failed\n");
0482
0483 ishtp_cl_unlink(ecl_ishtp_cl);
0484 return rv;
0485 }
0486
0487 dev_dbg(cl_data_to_dev(opr_dev), "Host connected to fw client\n");
0488
0489 return 0;
0490 }
0491
0492 static void ecl_ishtp_cl_deinit(struct ishtp_cl *ecl_ishtp_cl)
0493 {
0494 ishtp_cl_unlink(ecl_ishtp_cl);
0495 ishtp_cl_flush_queues(ecl_ishtp_cl);
0496 ishtp_cl_free(ecl_ishtp_cl);
0497 }
0498
0499 static void ecl_ishtp_cl_reset_handler(struct work_struct *work)
0500 {
0501 struct ishtp_opregion_dev *opr_dev;
0502 struct ishtp_cl_device *cl_device;
0503 struct ishtp_cl *ecl_ishtp_cl;
0504 int rv;
0505 int retry;
0506
0507 opr_dev = container_of(work, struct ishtp_opregion_dev, reset_work);
0508
0509 opr_dev->ish_link_ready = false;
0510
0511 cl_device = opr_dev->cl_device;
0512 ecl_ishtp_cl = opr_dev->ecl_ishtp_cl;
0513
0514 ecl_ishtp_cl_deinit(ecl_ishtp_cl);
0515
0516 ecl_ishtp_cl = ishtp_cl_allocate(cl_device);
0517 if (!ecl_ishtp_cl)
0518 return;
0519
0520 ishtp_set_drvdata(cl_device, ecl_ishtp_cl);
0521 ishtp_set_client_data(ecl_ishtp_cl, opr_dev);
0522
0523 opr_dev->ecl_ishtp_cl = ecl_ishtp_cl;
0524
0525 for (retry = 0; retry < 3; ++retry) {
0526 rv = ecl_ishtp_cl_init(ecl_ishtp_cl);
0527 if (!rv)
0528 break;
0529 }
0530 if (rv) {
0531 ishtp_cl_free(ecl_ishtp_cl);
0532 opr_dev->ecl_ishtp_cl = NULL;
0533 dev_err(cl_data_to_dev(opr_dev),
0534 "[ish_rst] Reset failed. Link not ready.\n");
0535 return;
0536 }
0537
0538 ishtp_register_event_cb(cl_device, ecl_ishtp_cl_event_cb);
0539 dev_info(cl_data_to_dev(opr_dev),
0540 "[ish_rst] Reset Success. Link ready.\n");
0541
0542 opr_dev->ish_link_ready = true;
0543
0544 if (opr_dev->acpi_init_done)
0545 return;
0546
0547 rv = acpi_opregion_init(opr_dev);
0548 if (rv) {
0549 dev_err(cl_data_to_dev(opr_dev),
0550 "ACPI opregion init failed\n");
0551 }
0552 }
0553
0554 static int ecl_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
0555 {
0556 struct ishtp_cl *ecl_ishtp_cl;
0557 struct ishtp_opregion_dev *opr_dev;
0558 int rv;
0559
0560 opr_dev = devm_kzalloc(ishtp_device(cl_device), sizeof(*opr_dev),
0561 GFP_KERNEL);
0562 if (!opr_dev)
0563 return -ENOMEM;
0564
0565 ecl_ishtp_cl = ishtp_cl_allocate(cl_device);
0566 if (!ecl_ishtp_cl)
0567 return -ENOMEM;
0568
0569 ishtp_set_drvdata(cl_device, ecl_ishtp_cl);
0570 ishtp_set_client_data(ecl_ishtp_cl, opr_dev);
0571 opr_dev->ecl_ishtp_cl = ecl_ishtp_cl;
0572 opr_dev->cl_device = cl_device;
0573
0574 init_waitqueue_head(&opr_dev->read_wait);
0575 INIT_WORK(&opr_dev->event_work, ecl_acpi_invoke_dsm);
0576 INIT_WORK(&opr_dev->reset_work, ecl_ishtp_cl_reset_handler);
0577
0578
0579 rv = ecl_ishtp_cl_init(ecl_ishtp_cl);
0580 if (rv) {
0581 dev_err(cl_data_to_dev(opr_dev), "Client init failed\n");
0582 goto err_exit;
0583 }
0584
0585 dev_dbg(cl_data_to_dev(opr_dev), "eclite-ishtp client initialised\n");
0586
0587 opr_dev->ish_link_ready = true;
0588 mutex_init(&opr_dev->lock);
0589
0590 rv = acpi_find_eclite_device(opr_dev);
0591 if (rv) {
0592 dev_err(cl_data_to_dev(opr_dev), "ECLite ACPI ID not found\n");
0593 goto err_exit;
0594 }
0595
0596
0597 ishtp_register_event_cb(cl_device, ecl_ishtp_cl_event_cb);
0598
0599
0600 rv = acpi_opregion_init(opr_dev);
0601 if (rv) {
0602 dev_err(cl_data_to_dev(opr_dev), "ACPI opregion init failed\n");
0603 goto err_exit;
0604 }
0605
0606
0607 acpi_dev_clear_dependencies(opr_dev->adev);
0608
0609 return 0;
0610 err_exit:
0611 ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_DISCONNECTING);
0612 ishtp_cl_disconnect(ecl_ishtp_cl);
0613 ecl_ishtp_cl_deinit(ecl_ishtp_cl);
0614
0615 return rv;
0616 }
0617
0618 static void ecl_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
0619 {
0620 struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
0621 struct ishtp_opregion_dev *opr_dev =
0622 ishtp_get_client_data(ecl_ishtp_cl);
0623
0624 if (opr_dev->acpi_init_done)
0625 acpi_opregion_deinit(opr_dev);
0626
0627 acpi_dev_put(opr_dev->adev);
0628
0629 ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_DISCONNECTING);
0630 ishtp_cl_disconnect(ecl_ishtp_cl);
0631 ecl_ishtp_cl_deinit(ecl_ishtp_cl);
0632
0633 cancel_work_sync(&opr_dev->reset_work);
0634 cancel_work_sync(&opr_dev->event_work);
0635 }
0636
0637 static int ecl_ishtp_cl_reset(struct ishtp_cl_device *cl_device)
0638 {
0639 struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
0640 struct ishtp_opregion_dev *opr_dev =
0641 ishtp_get_client_data(ecl_ishtp_cl);
0642
0643 schedule_work(&opr_dev->reset_work);
0644
0645 return 0;
0646 }
0647
0648 static int ecl_ishtp_cl_suspend(struct device *device)
0649 {
0650 struct ishtp_cl_device *cl_device = ishtp_dev_to_cl_device(device);
0651 struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
0652 struct ishtp_opregion_dev *opr_dev =
0653 ishtp_get_client_data(ecl_ishtp_cl);
0654
0655 if (acpi_target_system_state() == ACPI_STATE_S0)
0656 return 0;
0657
0658 acpi_opregion_deinit(opr_dev);
0659 ecl_ish_cl_enable_events(opr_dev, false);
0660
0661 return 0;
0662 }
0663
0664 static int ecl_ishtp_cl_resume(struct device *device)
0665 {
0666
0667
0668
0669
0670 return 0;
0671 }
0672
0673 static const struct dev_pm_ops ecl_ishtp_pm_ops = {
0674 .suspend = ecl_ishtp_cl_suspend,
0675 .resume = ecl_ishtp_cl_resume,
0676 };
0677
0678 static struct ishtp_cl_driver ecl_ishtp_cl_driver = {
0679 .name = "ishtp-eclite",
0680 .id = ecl_ishtp_id_table,
0681 .probe = ecl_ishtp_cl_probe,
0682 .remove = ecl_ishtp_cl_remove,
0683 .reset = ecl_ishtp_cl_reset,
0684 .driver.pm = &ecl_ishtp_pm_ops,
0685 };
0686
0687 static int __init ecl_ishtp_init(void)
0688 {
0689 return ishtp_cl_driver_register(&ecl_ishtp_cl_driver, THIS_MODULE);
0690 }
0691
0692 static void __exit ecl_ishtp_exit(void)
0693 {
0694 return ishtp_cl_driver_unregister(&ecl_ishtp_cl_driver);
0695 }
0696
0697 late_initcall(ecl_ishtp_init);
0698 module_exit(ecl_ishtp_exit);
0699
0700 MODULE_DESCRIPTION("ISH ISHTP eclite client opregion driver");
0701 MODULE_AUTHOR("K Naduvalath, Sumesh <sumesh.k.naduvalath@intel.com>");
0702
0703 MODULE_LICENSE("GPL v2");