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 
16 #include "psb_drv.h"
17 
18 void gma_get_core_freq(struct drm_device *dev)
19 {
20 	uint32_t clock;
21 	struct pci_dev *pci_root =
22 		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
23 					    0, 0);
24 	struct drm_psb_private *dev_priv = dev->dev_private;
25 
26 	/*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
27 	/*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/
28 
29 	pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
30 	pci_read_config_dword(pci_root, 0xD4, &clock);
31 	pci_dev_put(pci_root);
32 
33 	switch (clock & 0x07) {
34 	case 0:
35 		dev_priv->core_freq = 100;
36 		break;
37 	case 1:
38 		dev_priv->core_freq = 133;
39 		break;
40 	case 2:
41 		dev_priv->core_freq = 150;
42 		break;
43 	case 3:
44 		dev_priv->core_freq = 178;
45 		break;
46 	case 4:
47 		dev_priv->core_freq = 200;
48 		break;
49 	case 5:
50 	case 6:
51 	case 7:
52 		dev_priv->core_freq = 266;
53 		break;
54 	default:
55 		dev_priv->core_freq = 0;
56 	}
57 }
58