Lines Matching refs:opr_dev

40 #define cl_data_to_dev(opr_dev)	ishtp_device((opr_dev)->cl_device)  argument
117 static int ecl_ish_cl_read(struct ishtp_opregion_dev *opr_dev) in ecl_ish_cl_read() argument
122 if (!opr_dev->ish_link_ready) in ecl_ish_cl_read()
125 if ((opr_dev->opr_context.cmd_area.offset + in ecl_ish_cl_read()
126 opr_dev->opr_context.cmd_area.length) > ECL_DATA_OPR_BUFLEN) { in ecl_ish_cl_read()
133 header.offset = opr_dev->opr_context.cmd_area.offset; in ecl_ish_cl_read()
134 header.data_len = opr_dev->opr_context.cmd_area.length; in ecl_ish_cl_read()
135 header.event = opr_dev->opr_context.cmd_area.event_id; in ecl_ish_cl_read()
138 opr_dev->ish_read_done = false; in ecl_ish_cl_read()
139 rv = ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&header, len); in ecl_ish_cl_read()
141 dev_err(cl_data_to_dev(opr_dev), "ish-read : send failed\n"); in ecl_ish_cl_read()
145 dev_dbg(cl_data_to_dev(opr_dev), in ecl_ish_cl_read()
150 rv = wait_event_interruptible_timeout(opr_dev->read_wait, in ecl_ish_cl_read()
151 opr_dev->ish_read_done, in ecl_ish_cl_read()
154 dev_err(cl_data_to_dev(opr_dev), in ecl_ish_cl_read()
169 static int ecl_ish_cl_write(struct ishtp_opregion_dev *opr_dev) in ecl_ish_cl_write() argument
174 if (!opr_dev->ish_link_ready) in ecl_ish_cl_write()
177 if ((opr_dev->opr_context.cmd_area.offset + in ecl_ish_cl_write()
178 opr_dev->opr_context.cmd_area.length) > ECL_DATA_OPR_BUFLEN) { in ecl_ish_cl_write()
185 message.header.offset = opr_dev->opr_context.cmd_area.offset; in ecl_ish_cl_write()
186 message.header.data_len = opr_dev->opr_context.cmd_area.length; in ecl_ish_cl_write()
187 message.header.event = opr_dev->opr_context.cmd_area.event_id; in ecl_ish_cl_write()
191 opr_dev->opr_context.data_area.data + message.header.offset, in ecl_ish_cl_write()
194 dev_dbg(cl_data_to_dev(opr_dev), in ecl_ish_cl_write()
199 return ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&message, len); in ecl_ish_cl_write()
207 struct ishtp_opregion_dev *opr_dev; in ecl_opregion_cmd_handler() local
217 opr_dev = (struct ishtp_opregion_dev *)region_context; in ecl_opregion_cmd_handler()
219 mutex_lock(&opr_dev->lock); in ecl_opregion_cmd_handler()
221 cmd = &opr_dev->opr_context.cmd_area; in ecl_opregion_cmd_handler()
228 status = ecl_ish_cl_read(opr_dev); in ecl_opregion_cmd_handler()
230 status = ecl_ish_cl_write(opr_dev); in ecl_opregion_cmd_handler()
247 mutex_unlock(&opr_dev->lock); in ecl_opregion_cmd_handler()
257 struct ishtp_opregion_dev *opr_dev; in ecl_opregion_data_handler() local
267 opr_dev = (struct ishtp_opregion_dev *)region_context; in ecl_opregion_data_handler()
269 mutex_lock(&opr_dev->lock); in ecl_opregion_data_handler()
271 data_addr = &opr_dev->opr_context.data_area.data[address]; in ecl_opregion_data_handler()
278 mutex_unlock(&opr_dev->lock); in ecl_opregion_data_handler()
282 mutex_unlock(&opr_dev->lock); in ecl_opregion_data_handler()
287 static int acpi_find_eclite_device(struct ishtp_opregion_dev *opr_dev) in acpi_find_eclite_device() argument
294 dev_err(cl_data_to_dev(opr_dev), "eclite ACPI device not found\n"); in acpi_find_eclite_device()
298 opr_dev->adev = adev; in acpi_find_eclite_device()
303 static int acpi_opregion_init(struct ishtp_opregion_dev *opr_dev) in acpi_opregion_init() argument
307 status = acpi_install_address_space_handler(opr_dev->adev->handle, in acpi_opregion_init()
310 NULL, opr_dev); in acpi_opregion_init()
312 dev_err(cl_data_to_dev(opr_dev), in acpi_opregion_init()
317 status = acpi_install_address_space_handler(opr_dev->adev->handle, in acpi_opregion_init()
320 NULL, opr_dev); in acpi_opregion_init()
322 dev_err(cl_data_to_dev(opr_dev), in acpi_opregion_init()
325 acpi_remove_address_space_handler(opr_dev->adev->handle, in acpi_opregion_init()
330 opr_dev->acpi_init_done = true; in acpi_opregion_init()
332 dev_dbg(cl_data_to_dev(opr_dev), "Opregion handlers are installed\n"); in acpi_opregion_init()
337 static void acpi_opregion_deinit(struct ishtp_opregion_dev *opr_dev) in acpi_opregion_deinit() argument
339 acpi_remove_address_space_handler(opr_dev->adev->handle, in acpi_opregion_deinit()
343 acpi_remove_address_space_handler(opr_dev->adev->handle, in acpi_opregion_deinit()
346 opr_dev->acpi_init_done = false; in acpi_opregion_deinit()
351 struct ishtp_opregion_dev *opr_dev; in ecl_acpi_invoke_dsm() local
354 opr_dev = container_of(work, struct ishtp_opregion_dev, event_work); in ecl_acpi_invoke_dsm()
355 if (!opr_dev->acpi_init_done) in ecl_acpi_invoke_dsm()
358 obj = acpi_evaluate_dsm(opr_dev->adev->handle, &ecl_acpi_guid, 0, in ecl_acpi_invoke_dsm()
359 opr_dev->dsm_event_id, NULL); in ecl_acpi_invoke_dsm()
361 dev_warn(cl_data_to_dev(opr_dev), "_DSM fn call failed\n"); in ecl_acpi_invoke_dsm()
365 dev_dbg(cl_data_to_dev(opr_dev), "Exec DSM function code: %d success\n", in ecl_acpi_invoke_dsm()
366 opr_dev->dsm_event_id); in ecl_acpi_invoke_dsm()
371 static void ecl_ish_process_rx_data(struct ishtp_opregion_dev *opr_dev) in ecl_ish_process_rx_data() argument
374 (struct ecl_message *)opr_dev->rb->buffer.data; in ecl_ish_process_rx_data()
376 dev_dbg(cl_data_to_dev(opr_dev), in ecl_ish_process_rx_data()
386 memcpy(opr_dev->opr_context.data_area.data + message->header.offset, in ecl_ish_process_rx_data()
389 opr_dev->ish_read_done = true; in ecl_ish_process_rx_data()
390 wake_up_interruptible(&opr_dev->read_wait); in ecl_ish_process_rx_data()
393 static void ecl_ish_process_rx_event(struct ishtp_opregion_dev *opr_dev) in ecl_ish_process_rx_event() argument
396 (struct ecl_message_header *)opr_dev->rb->buffer.data; in ecl_ish_process_rx_event()
398 dev_dbg(cl_data_to_dev(opr_dev), in ecl_ish_process_rx_event()
401 opr_dev->dsm_event_id = header->event; in ecl_ish_process_rx_event()
402 schedule_work(&opr_dev->event_work); in ecl_ish_process_rx_event()
405 static int ecl_ish_cl_enable_events(struct ishtp_opregion_dev *opr_dev, in ecl_ish_cl_enable_events() argument
420 return ishtp_cl_send(opr_dev->ecl_ishtp_cl, (uint8_t *)&message, len); in ecl_ish_cl_enable_events()
426 struct ishtp_opregion_dev *opr_dev; in ecl_ishtp_cl_event_cb() local
430 opr_dev = ishtp_get_client_data(ecl_ishtp_cl); in ecl_ishtp_cl_event_cb()
431 while ((rb = ishtp_cl_rx_get_rb(opr_dev->ecl_ishtp_cl)) != NULL) { in ecl_ishtp_cl_event_cb()
432 opr_dev->rb = rb; in ecl_ishtp_cl_event_cb()
436 ecl_ish_process_rx_data(opr_dev); in ecl_ishtp_cl_event_cb()
438 ecl_ish_process_rx_event(opr_dev); in ecl_ishtp_cl_event_cb()
441 dev_err(cl_data_to_dev(opr_dev), in ecl_ishtp_cl_event_cb()
450 struct ishtp_opregion_dev *opr_dev = in ecl_ishtp_cl_init() local
458 dev_err(cl_data_to_dev(opr_dev), "ishtp_cl_link failed\n"); in ecl_ishtp_cl_init()
470 dev_err(cl_data_to_dev(opr_dev), "fw client not found\n"); in ecl_ishtp_cl_init()
481 dev_err(cl_data_to_dev(opr_dev), "client connect failed\n"); in ecl_ishtp_cl_init()
487 dev_dbg(cl_data_to_dev(opr_dev), "Host connected to fw client\n"); in ecl_ishtp_cl_init()
501 struct ishtp_opregion_dev *opr_dev; in ecl_ishtp_cl_reset_handler() local
507 opr_dev = container_of(work, struct ishtp_opregion_dev, reset_work); in ecl_ishtp_cl_reset_handler()
509 opr_dev->ish_link_ready = false; in ecl_ishtp_cl_reset_handler()
511 cl_device = opr_dev->cl_device; in ecl_ishtp_cl_reset_handler()
512 ecl_ishtp_cl = opr_dev->ecl_ishtp_cl; in ecl_ishtp_cl_reset_handler()
521 ishtp_set_client_data(ecl_ishtp_cl, opr_dev); in ecl_ishtp_cl_reset_handler()
523 opr_dev->ecl_ishtp_cl = ecl_ishtp_cl; in ecl_ishtp_cl_reset_handler()
532 opr_dev->ecl_ishtp_cl = NULL; in ecl_ishtp_cl_reset_handler()
533 dev_err(cl_data_to_dev(opr_dev), in ecl_ishtp_cl_reset_handler()
539 dev_info(cl_data_to_dev(opr_dev), in ecl_ishtp_cl_reset_handler()
542 opr_dev->ish_link_ready = true; in ecl_ishtp_cl_reset_handler()
544 if (opr_dev->acpi_init_done) in ecl_ishtp_cl_reset_handler()
547 rv = acpi_opregion_init(opr_dev); in ecl_ishtp_cl_reset_handler()
549 dev_err(cl_data_to_dev(opr_dev), in ecl_ishtp_cl_reset_handler()
557 struct ishtp_opregion_dev *opr_dev; in ecl_ishtp_cl_probe() local
560 opr_dev = devm_kzalloc(ishtp_device(cl_device), sizeof(*opr_dev), in ecl_ishtp_cl_probe()
562 if (!opr_dev) in ecl_ishtp_cl_probe()
570 ishtp_set_client_data(ecl_ishtp_cl, opr_dev); in ecl_ishtp_cl_probe()
571 opr_dev->ecl_ishtp_cl = ecl_ishtp_cl; in ecl_ishtp_cl_probe()
572 opr_dev->cl_device = cl_device; in ecl_ishtp_cl_probe()
574 init_waitqueue_head(&opr_dev->read_wait); in ecl_ishtp_cl_probe()
575 INIT_WORK(&opr_dev->event_work, ecl_acpi_invoke_dsm); in ecl_ishtp_cl_probe()
576 INIT_WORK(&opr_dev->reset_work, ecl_ishtp_cl_reset_handler); in ecl_ishtp_cl_probe()
581 dev_err(cl_data_to_dev(opr_dev), "Client init failed\n"); in ecl_ishtp_cl_probe()
585 dev_dbg(cl_data_to_dev(opr_dev), "eclite-ishtp client initialised\n"); in ecl_ishtp_cl_probe()
587 opr_dev->ish_link_ready = true; in ecl_ishtp_cl_probe()
588 mutex_init(&opr_dev->lock); in ecl_ishtp_cl_probe()
590 rv = acpi_find_eclite_device(opr_dev); in ecl_ishtp_cl_probe()
592 dev_err(cl_data_to_dev(opr_dev), "ECLite ACPI ID not found\n"); in ecl_ishtp_cl_probe()
600 rv = acpi_opregion_init(opr_dev); in ecl_ishtp_cl_probe()
602 dev_err(cl_data_to_dev(opr_dev), "ACPI opregion init failed\n"); in ecl_ishtp_cl_probe()
607 acpi_dev_clear_dependencies(opr_dev->adev); in ecl_ishtp_cl_probe()
621 struct ishtp_opregion_dev *opr_dev = in ecl_ishtp_cl_remove() local
624 if (opr_dev->acpi_init_done) in ecl_ishtp_cl_remove()
625 acpi_opregion_deinit(opr_dev); in ecl_ishtp_cl_remove()
627 acpi_dev_put(opr_dev->adev); in ecl_ishtp_cl_remove()
633 cancel_work_sync(&opr_dev->reset_work); in ecl_ishtp_cl_remove()
634 cancel_work_sync(&opr_dev->event_work); in ecl_ishtp_cl_remove()
640 struct ishtp_opregion_dev *opr_dev = in ecl_ishtp_cl_reset() local
643 schedule_work(&opr_dev->reset_work); in ecl_ishtp_cl_reset()
652 struct ishtp_opregion_dev *opr_dev = in ecl_ishtp_cl_suspend() local
658 acpi_opregion_deinit(opr_dev); in ecl_ishtp_cl_suspend()
659 ecl_ish_cl_enable_events(opr_dev, false); in ecl_ishtp_cl_suspend()