gma_device.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /**************************************************************************
  3. * Copyright (c) 2011, Intel Corporation.
  4. * All Rights Reserved.
  5. *
  6. **************************************************************************/
  7. #include "psb_drv.h"
  8. #include "gma_device.h"
  9. void gma_get_core_freq(struct drm_device *dev)
  10. {
  11. uint32_t clock;
  12. struct pci_dev *pdev = to_pci_dev(dev->dev);
  13. struct pci_dev *pci_root =
  14. pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
  15. 0, 0);
  16. struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
  17. /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
  18. /*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/
  19. pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
  20. pci_read_config_dword(pci_root, 0xD4, &clock);
  21. pci_dev_put(pci_root);
  22. switch (clock & 0x07) {
  23. case 0:
  24. dev_priv->core_freq = 100;
  25. break;
  26. case 1:
  27. dev_priv->core_freq = 133;
  28. break;
  29. case 2:
  30. dev_priv->core_freq = 150;
  31. break;
  32. case 3:
  33. dev_priv->core_freq = 178;
  34. break;
  35. case 4:
  36. dev_priv->core_freq = 200;
  37. break;
  38. case 5:
  39. case 6:
  40. case 7:
  41. dev_priv->core_freq = 266;
  42. break;
  43. default:
  44. dev_priv->core_freq = 0;
  45. }
  46. }