Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/gma500: Unify _get_core_freq for cdv and psb

Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

+82 -78
+1
drivers/gpu/drm/gma500/Makefile
··· 17 17 power.o \ 18 18 psb_drv.o \ 19 19 gma_display.o \ 20 + gma_device.o \ 20 21 psb_intel_display.o \ 21 22 psb_intel_lvds.o \ 22 23 psb_intel_modes.o \
+2 -38
drivers/gpu/drm/gma500/cdv_device.c
··· 26 26 #include "psb_intel_reg.h" 27 27 #include "intel_bios.h" 28 28 #include "cdv_device.h" 29 + #include "gma_device.h" 29 30 30 31 #define VGA_SR_INDEX 0x3c4 31 32 #define VGA_SR_DATA 0x3c5 ··· 427 426 return 0; 428 427 } 429 428 430 - /* FIXME ? - shared with Poulsbo */ 431 - static void cdv_get_core_freq(struct drm_device *dev) 432 - { 433 - uint32_t clock; 434 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 435 - struct drm_psb_private *dev_priv = dev->dev_private; 436 - 437 - pci_write_config_dword(pci_root, 0xD0, 0xD0050300); 438 - pci_read_config_dword(pci_root, 0xD4, &clock); 439 - pci_dev_put(pci_root); 440 - 441 - switch (clock & 0x07) { 442 - case 0: 443 - dev_priv->core_freq = 100; 444 - break; 445 - case 1: 446 - dev_priv->core_freq = 133; 447 - break; 448 - case 2: 449 - dev_priv->core_freq = 150; 450 - break; 451 - case 3: 452 - dev_priv->core_freq = 178; 453 - break; 454 - case 4: 455 - dev_priv->core_freq = 200; 456 - break; 457 - case 5: 458 - case 6: 459 - case 7: 460 - dev_priv->core_freq = 266; 461 - break; 462 - default: 463 - dev_priv->core_freq = 0; 464 - } 465 - } 466 - 467 429 static void cdv_hotplug_work_func(struct work_struct *work) 468 430 { 469 431 struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private, ··· 582 618 if (pci_enable_msi(dev->pdev)) 583 619 dev_warn(dev->dev, "Enabling MSI failed!\n"); 584 620 dev_priv->regmap = cdv_regmap; 585 - cdv_get_core_freq(dev); 621 + gma_get_core_freq(dev); 586 622 psb_intel_opregion_init(dev); 587 623 psb_intel_init_bios(dev); 588 624 cdv_hotplug_enable(dev, false);
+56
drivers/gpu/drm/gma500/gma_device.c
··· 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 <drm/drmP.h> 17 + #include "psb_drv.h" 18 + 19 + void gma_get_core_freq(struct drm_device *dev) 20 + { 21 + uint32_t clock; 22 + struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 23 + struct drm_psb_private *dev_priv = dev->dev_private; 24 + 25 + /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/ 26 + /*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/ 27 + 28 + pci_write_config_dword(pci_root, 0xD0, 0xD0050300); 29 + pci_read_config_dword(pci_root, 0xD4, &clock); 30 + pci_dev_put(pci_root); 31 + 32 + switch (clock & 0x07) { 33 + case 0: 34 + dev_priv->core_freq = 100; 35 + break; 36 + case 1: 37 + dev_priv->core_freq = 133; 38 + break; 39 + case 2: 40 + dev_priv->core_freq = 150; 41 + break; 42 + case 3: 43 + dev_priv->core_freq = 178; 44 + break; 45 + case 4: 46 + dev_priv->core_freq = 200; 47 + break; 48 + case 5: 49 + case 6: 50 + case 7: 51 + dev_priv->core_freq = 266; 52 + break; 53 + default: 54 + dev_priv->core_freq = 0; 55 + } 56 + }
+21
drivers/gpu/drm/gma500/gma_device.h
··· 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 + #ifndef _GMA_DEVICE_H 17 + #define _GMA_DEVICE_H 18 + 19 + extern void gma_get_core_freq(struct drm_device *dev); 20 + 21 + #endif
+2 -40
drivers/gpu/drm/gma500/psb_device.c
··· 26 26 #include "psb_intel_reg.h" 27 27 #include "intel_bios.h" 28 28 #include "psb_device.h" 29 + #include "gma_device.h" 29 30 30 31 static int psb_output_init(struct drm_device *dev) 31 32 { ··· 258 257 return 0; 259 258 } 260 259 261 - static void psb_get_core_freq(struct drm_device *dev) 262 - { 263 - uint32_t clock; 264 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 265 - struct drm_psb_private *dev_priv = dev->dev_private; 266 - 267 - /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/ 268 - /*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/ 269 - 270 - pci_write_config_dword(pci_root, 0xD0, 0xD0050300); 271 - pci_read_config_dword(pci_root, 0xD4, &clock); 272 - pci_dev_put(pci_root); 273 - 274 - switch (clock & 0x07) { 275 - case 0: 276 - dev_priv->core_freq = 100; 277 - break; 278 - case 1: 279 - dev_priv->core_freq = 133; 280 - break; 281 - case 2: 282 - dev_priv->core_freq = 150; 283 - break; 284 - case 3: 285 - dev_priv->core_freq = 178; 286 - break; 287 - case 4: 288 - dev_priv->core_freq = 200; 289 - break; 290 - case 5: 291 - case 6: 292 - case 7: 293 - dev_priv->core_freq = 266; 294 - break; 295 - default: 296 - dev_priv->core_freq = 0; 297 - } 298 - } 299 - 300 260 /* Poulsbo */ 301 261 static const struct psb_offset psb_regmap[2] = { 302 262 { ··· 314 352 { 315 353 struct drm_psb_private *dev_priv = dev->dev_private; 316 354 dev_priv->regmap = psb_regmap; 317 - psb_get_core_freq(dev); 355 + gma_get_core_freq(dev); 318 356 gma_intel_setup_gmbus(dev); 319 357 psb_intel_opregion_init(dev); 320 358 psb_intel_init_bios(dev);