Lines Matching refs:pmf_dev
338 static void amd_pmf_custom_bios_inputs_rb(struct amd_pmf_dev *pmf_dev) in amd_pmf_custom_bios_inputs_rb() argument
340 struct pmf_cbi_ring_buffer *rb = &pmf_dev->cbi_buf; in amd_pmf_custom_bios_inputs_rb()
343 guard(mutex)(&pmf_dev->cbi_mutex); in amd_pmf_custom_bios_inputs_rb()
345 switch (pmf_dev->cpu_id) { in amd_pmf_custom_bios_inputs_rb()
348 rb->data[rb->head].val[i] = pmf_dev->req1.custom_policy[i]; in amd_pmf_custom_bios_inputs_rb()
349 rb->data[rb->head].preq = pmf_dev->req1.pending_req; in amd_pmf_custom_bios_inputs_rb()
354 rb->data[rb->head].val[i] = pmf_dev->req.custom_policy[i]; in amd_pmf_custom_bios_inputs_rb()
355 rb->data[rb->head].preq = pmf_dev->req.pending_req; in amd_pmf_custom_bios_inputs_rb()
363 dev_warn(pmf_dev->dev, "Overwriting BIOS input value, data may be lost\n"); in amd_pmf_custom_bios_inputs_rb()
381 struct amd_pmf_dev *pmf_dev = data; in apmf_event_handler_v2() local
384 guard(mutex)(&pmf_dev->cb_mutex); in apmf_event_handler_v2()
386 ret = apmf_get_sbios_requests_v2(pmf_dev, &pmf_dev->req); in apmf_event_handler_v2()
388 dev_err(pmf_dev->dev, "Failed to get v2 SBIOS requests: %d\n", ret); in apmf_event_handler_v2()
392 dev_dbg(pmf_dev->dev, "Pending request (preq): 0x%x\n", pmf_dev->req.pending_req); in apmf_event_handler_v2()
394 amd_pmf_handle_early_preq(pmf_dev); in apmf_event_handler_v2()
396 amd_pmf_custom_bios_inputs_rb(pmf_dev); in apmf_event_handler_v2()
401 struct amd_pmf_dev *pmf_dev = data; in apmf_event_handler_v1() local
404 guard(mutex)(&pmf_dev->cb_mutex); in apmf_event_handler_v1()
406 ret = apmf_get_sbios_requests_v1(pmf_dev, &pmf_dev->req1); in apmf_event_handler_v1()
408 dev_err(pmf_dev->dev, "Failed to get v1 SBIOS requests: %d\n", ret); in apmf_event_handler_v1()
412 dev_dbg(pmf_dev->dev, "Pending request (preq1): 0x%x\n", pmf_dev->req1.pending_req); in apmf_event_handler_v1()
414 amd_pmf_handle_early_preq(pmf_dev); in apmf_event_handler_v1()
416 amd_pmf_custom_bios_inputs_rb(pmf_dev); in apmf_event_handler_v1()
421 struct amd_pmf_dev *pmf_dev = data; in apmf_event_handler() local
425 guard(mutex)(&pmf_dev->update_mutex); in apmf_event_handler()
426 ret = apmf_get_sbios_requests(pmf_dev, &req); in apmf_event_handler()
428 dev_err(pmf_dev->dev, "Failed to get SBIOS requests:%d\n", ret); in apmf_event_handler()
433 dev_dbg(pmf_dev->dev, "AMT is supported and notifications %s\n", in apmf_event_handler()
435 pmf_dev->amt_enabled = !!req.amt_event; in apmf_event_handler()
437 if (pmf_dev->amt_enabled) in apmf_event_handler()
438 amd_pmf_handle_amt(pmf_dev); in apmf_event_handler()
440 amd_pmf_reset_amt(pmf_dev); in apmf_event_handler()
444 dev_dbg(pmf_dev->dev, "CQL is supported and notifications %s\n", in apmf_event_handler()
448 if (pmf_dev->amt_enabled) in apmf_event_handler()
449 amd_pmf_update_2_cql(pmf_dev, req.cql_event); in apmf_event_handler()
513 int apmf_install_handler(struct amd_pmf_dev *pmf_dev) in apmf_install_handler() argument
515 acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev); in apmf_install_handler()
519 if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) && in apmf_install_handler()
520 is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) { in apmf_install_handler()
522 apmf_event_handler, pmf_dev); in apmf_install_handler()
524 dev_err(pmf_dev->dev, "failed to install notify handler\n"); in apmf_install_handler()
529 apmf_event_handler(ahandle, 0, pmf_dev); in apmf_install_handler()
532 if (!pmf_dev->smart_pc_enabled) in apmf_install_handler()
535 switch (pmf_dev->pmf_if_version) { in apmf_install_handler()
537 if (!is_apmf_bios_input_notifications_supported(pmf_dev)) in apmf_install_handler()
542 apmf_event_handlers[pmf_dev->pmf_if_version], pmf_dev); in apmf_install_handler()
544 dev_err(pmf_dev->dev, in apmf_install_handler()
546 pmf_dev->pmf_if_version); in apmf_install_handler()
557 int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev) in apmf_check_smart_pc() argument
559 struct platform_device *pdev = to_platform_device(pmf_dev->dev); in apmf_check_smart_pc()
561 pmf_dev->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); in apmf_check_smart_pc()
562 if (!pmf_dev->res) { in apmf_check_smart_pc()
563 dev_dbg(pmf_dev->dev, "Failed to get I/O memory resource\n"); in apmf_check_smart_pc()
567 pmf_dev->policy_addr = pmf_dev->res->start; in apmf_check_smart_pc()
575 pmf_dev->policy_sz = pmf_dev->res->end - pmf_dev->res->start; in apmf_check_smart_pc()
577 if (!pmf_dev->policy_addr || pmf_dev->policy_sz > POLICY_BUF_MAX_SZ || in apmf_check_smart_pc()
578 pmf_dev->policy_sz == 0) { in apmf_check_smart_pc()
579 dev_err(pmf_dev->dev, "Incorrect policy params, possibly a SBIOS bug\n"); in apmf_check_smart_pc()
594 void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev) in apmf_acpi_deinit() argument
596 acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev); in apmf_acpi_deinit()
598 if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) in apmf_acpi_deinit()
599 cancel_delayed_work_sync(&pmf_dev->heart_beat); in apmf_acpi_deinit()
601 if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) && in apmf_acpi_deinit()
602 is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) in apmf_acpi_deinit()
605 if (!pmf_dev->smart_pc_enabled) in apmf_acpi_deinit()
608 switch (pmf_dev->pmf_if_version) { in apmf_acpi_deinit()
610 if (!is_apmf_bios_input_notifications_supported(pmf_dev)) in apmf_acpi_deinit()
615 apmf_event_handlers[pmf_dev->pmf_if_version]); in apmf_acpi_deinit()
622 int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) in apmf_acpi_init() argument
626 ret = apmf_if_verify_interface(pmf_dev); in apmf_acpi_init()
628 dev_err(pmf_dev->dev, "APMF verify interface failed :%d\n", ret); in apmf_acpi_init()
632 ret = apmf_get_system_params(pmf_dev); in apmf_acpi_init()
634 dev_dbg(pmf_dev->dev, "APMF apmf_get_system_params failed :%d\n", ret); in apmf_acpi_init()
638 if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) { in apmf_acpi_init()
640 INIT_DELAYED_WORK(&pmf_dev->heart_beat, apmf_sbios_heartbeat_notify); in apmf_acpi_init()
641 schedule_delayed_work(&pmf_dev->heart_beat, 0); in apmf_acpi_init()