prm.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * AMD Address Translation Library
  4. *
  5. * prm.c : Plumbing code for ACPI Platform Runtime Mechanism (PRM)
  6. *
  7. * Information on AMD PRM modules and handlers including the GUIDs and buffer
  8. * structures used here are defined in the AMD ACPI Porting Guide in the
  9. * chapter "Platform Runtime Mechanism Table (PRMT)"
  10. *
  11. * Copyright (c) 2024, Advanced Micro Devices, Inc.
  12. * All Rights Reserved.
  13. *
  14. * Author: John Allen <john.allen@amd.com>
  15. */
  16. #include "internal.h"
  17. #include <linux/prmt.h>
  18. /*
  19. * PRM parameter buffer - normalized to system physical address, as described
  20. * in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide.
  21. */
  22. struct norm_to_sys_param_buf {
  23. u64 norm_addr;
  24. u8 socket;
  25. u64 bank_id;
  26. void *out_buf;
  27. } __packed;
  28. unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
  29. {
  30. struct norm_to_sys_param_buf p_buf;
  31. unsigned long ret_addr;
  32. int ret;
  33. p_buf.norm_addr = addr;
  34. p_buf.socket = socket_id;
  35. p_buf.bank_id = bank_id;
  36. p_buf.out_buf = &ret_addr;
  37. ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
  38. if (!ret)
  39. return ret_addr;
  40. if (ret == -ENODEV)
  41. pr_debug("PRM module/handler not available\n");
  42. else
  43. pr_notice_once("PRM address translation failed\n");
  44. return ret;
  45. }