gma_device.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = pci_get_bus_and_slot(0, 0);
  21. struct drm_psb_private *dev_priv = dev->dev_private;
  22. /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
  23. /*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/
  24. pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
  25. pci_read_config_dword(pci_root, 0xD4, &clock);
  26. pci_dev_put(pci_root);
  27. switch (clock & 0x07) {
  28. case 0:
  29. dev_priv->core_freq = 100;
  30. break;
  31. case 1:
  32. dev_priv->core_freq = 133;
  33. break;
  34. case 2:
  35. dev_priv->core_freq = 150;
  36. break;
  37. case 3:
  38. dev_priv->core_freq = 178;
  39. break;
  40. case 4:
  41. dev_priv->core_freq = 200;
  42. break;
  43. case 5:
  44. case 6:
  45. case 7:
  46. dev_priv->core_freq = 266;
  47. break;
  48. default:
  49. dev_priv->core_freq = 0;
  50. }
  51. }