gma_device.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**************************************************************************
  2. * Copyright (c) 2011, Intel Corporation.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. **************************************************************************/
  15. #include <drm/drmP.h>
  16. #include "psb_drv.h"
  17. void gma_get_core_freq(struct drm_device *dev)
  18. {
  19. uint32_t clock;
  20. struct pci_dev *pci_root =
  21. pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
  22. 0, 0);
  23. struct drm_psb_private *dev_priv = dev->dev_private;
  24. /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
  25. /*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/
  26. pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
  27. pci_read_config_dword(pci_root, 0xD4, &clock);
  28. pci_dev_put(pci_root);
  29. switch (clock & 0x07) {
  30. case 0:
  31. dev_priv->core_freq = 100;
  32. break;
  33. case 1:
  34. dev_priv->core_freq = 133;
  35. break;
  36. case 2:
  37. dev_priv->core_freq = 150;
  38. break;
  39. case 3:
  40. dev_priv->core_freq = 178;
  41. break;
  42. case 4:
  43. dev_priv->core_freq = 200;
  44. break;
  45. case 5:
  46. case 6:
  47. case 7:
  48. dev_priv->core_freq = 266;
  49. break;
  50. default:
  51. dev_priv->core_freq = 0;
  52. }
  53. }