1 /**************************************************************************
2 * Copyright (c) 2007-2011, Intel Corporation.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 **************************************************************************/
23 #include <linux/kref.h>
26 #include "drm_global.h"
30 #include "psb_intel_drv.h"
35 /* Append new drm mode definition here, align with libdrm definition */
36 #define DRM_MODE_SCALE_NO_SCALE 2
39 CHIP_PSB_8108 = 0, /* Poulsbo */
40 CHIP_PSB_8109 = 1, /* Poulsbo */
41 CHIP_MRST_4100 = 2, /* Moorestown/Oaktrail */
42 CHIP_MFLD_0130 = 3, /* Medfield */
45 #define IS_PSB(dev) (((dev)->pci_device & 0xfffe) == 0x8108)
46 #define IS_MRST(dev) (((dev)->pci_device & 0xfffc) == 0x4100)
47 #define IS_MFLD(dev) (((dev)->pci_device & 0xfff8) == 0x0130)
53 #define DRIVER_NAME "gma500"
54 #define DRIVER_DESC "DRM driver for the Intel GMA500"
56 #define PSB_DRM_DRIVER_DATE "2011-06-06"
57 #define PSB_DRM_DRIVER_MAJOR 1
58 #define PSB_DRM_DRIVER_MINOR 0
59 #define PSB_DRM_DRIVER_PATCHLEVEL 0
64 #define PSB_VDC_OFFSET 0x00000000
65 #define PSB_VDC_SIZE 0x000080000
66 #define MRST_MMIO_SIZE 0x0000C0000
67 #define MDFLD_MMIO_SIZE 0x000100000
68 #define PSB_SGX_SIZE 0x8000
69 #define PSB_SGX_OFFSET 0x00040000
70 #define MRST_SGX_OFFSET 0x00080000
72 * PCI resource identifiers
74 #define PSB_MMIO_RESOURCE 0
75 #define PSB_GATT_RESOURCE 2
76 #define PSB_GTT_RESOURCE 3
80 #define PSB_GMCH_CTRL 0x52
82 #define _PSB_GMCH_ENABLED 0x4
83 #define PSB_PGETBL_CTL 0x2020
84 #define _PSB_PGETBL_ENABLED 0x00000001
85 #define PSB_SGX_2D_SLAVE_PORT 0x4000
88 #define PSB_TT_PRIV0_LIMIT (256*1024*1024)
89 #define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
92 * SGX side MMU definitions (these can probably go)
96 * Flags for external memory type field.
98 #define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */
99 #define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */
100 #define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */
104 #define PSB_PDE_MASK 0x003FFFFF
105 #define PSB_PDE_SHIFT 22
106 #define PSB_PTE_SHIFT 12
110 #define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */
111 #define PSB_PTE_WO 0x0002 /* Write only */
112 #define PSB_PTE_RO 0x0004 /* Read only */
113 #define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */
116 * VDC registers and bits
118 #define PSB_MSVDX_CLOCKGATING 0x2064
119 #define PSB_TOPAZ_CLOCKGATING 0x2068
120 #define PSB_HWSTAM 0x2098
121 #define PSB_INSTPM 0x20C0
122 #define PSB_INT_IDENTITY_R 0x20A4
123 #define _MDFLD_PIPEC_EVENT_FLAG (1<<2)
124 #define _MDFLD_PIPEC_VBLANK_FLAG (1<<3)
125 #define _PSB_DPST_PIPEB_FLAG (1<<4)
126 #define _MDFLD_PIPEB_EVENT_FLAG (1<<4)
127 #define _PSB_VSYNC_PIPEB_FLAG (1<<5)
128 #define _PSB_DPST_PIPEA_FLAG (1<<6)
129 #define _PSB_PIPEA_EVENT_FLAG (1<<6)
130 #define _PSB_VSYNC_PIPEA_FLAG (1<<7)
131 #define _MDFLD_MIPIA_FLAG (1<<16)
132 #define _MDFLD_MIPIC_FLAG (1<<17)
133 #define _PSB_IRQ_DISP_HOTSYNC (1<<17)
134 #define _PSB_IRQ_SGX_FLAG (1<<18)
135 #define _PSB_IRQ_MSVDX_FLAG (1<<19)
136 #define _LNC_IRQ_TOPAZ_FLAG (1<<20)
138 #define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \
139 _PSB_VSYNC_PIPEB_FLAG)
141 /* This flag includes all the display IRQ bits excepts the vblank irqs. */
142 #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \
143 _MDFLD_PIPEB_EVENT_FLAG | \
144 _PSB_PIPEA_EVENT_FLAG | \
145 _PSB_VSYNC_PIPEA_FLAG | \
146 _MDFLD_MIPIA_FLAG | \
148 #define PSB_INT_IDENTITY_R 0x20A4
149 #define PSB_INT_MASK_R 0x20A8
150 #define PSB_INT_ENABLE_R 0x20A0
152 #define _PSB_MMU_ER_MASK 0x0001FF00
153 #define _PSB_MMU_ER_HOST (1 << 16)
162 #define GPIO_CLOCK_DIR_MASK (1 << 0)
163 #define GPIO_CLOCK_DIR_IN (0 << 1)
164 #define GPIO_CLOCK_DIR_OUT (1 << 1)
165 #define GPIO_CLOCK_VAL_MASK (1 << 2)
166 #define GPIO_CLOCK_VAL_OUT (1 << 3)
167 #define GPIO_CLOCK_VAL_IN (1 << 4)
168 #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5)
169 #define GPIO_DATA_DIR_MASK (1 << 8)
170 #define GPIO_DATA_DIR_IN (0 << 9)
171 #define GPIO_DATA_DIR_OUT (1 << 9)
172 #define GPIO_DATA_VAL_MASK (1 << 10)
173 #define GPIO_DATA_VAL_OUT (1 << 11)
174 #define GPIO_DATA_VAL_IN (1 << 12)
175 #define GPIO_DATA_PULLUP_DISABLE (1 << 13)
177 #define VCLK_DIVISOR_VGA0 0x6000
178 #define VCLK_DIVISOR_VGA1 0x6004
179 #define VCLK_POST_DIV 0x6010
181 #define PSB_COMM_2D (PSB_ENGINE_2D << 4)
182 #define PSB_COMM_3D (PSB_ENGINE_3D << 4)
183 #define PSB_COMM_TA (PSB_ENGINE_TA << 4)
184 #define PSB_COMM_HP (PSB_ENGINE_HP << 4)
185 #define PSB_COMM_USER_IRQ (1024 >> 2)
186 #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1)
187 #define PSB_COMM_FW (2048 >> 2)
189 #define PSB_UIRQ_VISTEST 1
190 #define PSB_UIRQ_OOM_REPLY 2
191 #define PSB_UIRQ_FIRE_TA_REPLY 3
192 #define PSB_UIRQ_FIRE_RASTER_REPLY 4
194 #define PSB_2D_SIZE (256*1024*1024)
195 #define PSB_MAX_RELOC_PAGES 1024
197 #define PSB_LOW_REG_OFFS 0x0204
198 #define PSB_HIGH_REG_OFFS 0x0600
200 #define PSB_NUM_VBLANKS 2
203 #define PSB_2D_SIZE (256*1024*1024)
204 #define PSB_MAX_RELOC_PAGES 1024
206 #define PSB_LOW_REG_OFFS 0x0204
207 #define PSB_HIGH_REG_OFFS 0x0600
209 #define PSB_NUM_VBLANKS 2
210 #define PSB_WATCHDOG_DELAY (DRM_HZ * 2)
211 #define PSB_LID_DELAY (DRM_HZ / 10)
213 #define MDFLD_PNW_B0 0x04
214 #define MDFLD_PNW_C0 0x08
216 #define MDFLD_DSR_2D_3D_0 (1 << 0)
217 #define MDFLD_DSR_2D_3D_2 (1 << 1)
218 #define MDFLD_DSR_CURSOR_0 (1 << 2)
219 #define MDFLD_DSR_CURSOR_2 (1 << 3)
220 #define MDFLD_DSR_OVERLAY_0 (1 << 4)
221 #define MDFLD_DSR_OVERLAY_2 (1 << 5)
222 #define MDFLD_DSR_MIPI_CONTROL (1 << 6)
223 #define MDFLD_DSR_DAMAGE_MASK_0 ((1 << 0) | (1 << 2) | (1 << 4))
224 #define MDFLD_DSR_DAMAGE_MASK_2 ((1 << 1) | (1 << 3) | (1 << 5))
225 #define MDFLD_DSR_2D_3D (MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2)
227 #define MDFLD_DSR_RR 45
228 #define MDFLD_DPU_ENABLE (1 << 31)
229 #define MDFLD_DSR_FULLSCREEN (1 << 30)
230 #define MDFLD_DSR_DELAY (DRM_HZ / MDFLD_DSR_RR)
232 #define PSB_PWR_STATE_ON 1
233 #define PSB_PWR_STATE_OFF 2
235 #define PSB_PMPOLICY_NOPM 0
236 #define PSB_PMPOLICY_CLOCKGATING 1
237 #define PSB_PMPOLICY_POWERDOWN 2
239 #define PSB_PMSTATE_POWERUP 0
240 #define PSB_PMSTATE_CLOCKGATED 1
241 #define PSB_PMSTATE_POWERDOWN 2
242 #define PSB_PCIx_MSI_ADDR_LOC 0x94
243 #define PSB_PCIx_MSI_DATA_LOC 0x98
245 /* Medfield crystal settings */
246 #define KSEL_CRYSTAL_19 1
247 #define KSEL_BYPASS_19 5
248 #define KSEL_BYPASS_25 6
249 #define KSEL_BYPASS_83_100 7
251 struct opregion_header;
252 struct opregion_acpi;
253 struct opregion_swsci;
254 struct opregion_asle;
256 struct psb_intel_opregion {
257 struct opregion_header *header;
258 struct opregion_acpi *acpi;
259 struct opregion_swsci *swsci;
260 struct opregion_asle *asle;
265 struct sdvo_device_mapping {
276 struct i2c_adapter adapter;
277 struct i2c_adapter *force_bit;
282 * Register save state. This is used to hold the context when the
283 * device is powered off. In the case of Oaktrail this can (but does not
284 * yet) include screen blank. Operations occuring during the save
285 * update the register cache instead.
288 uint32_t saveDSPACNTR;
289 uint32_t saveDSPBCNTR;
290 uint32_t savePIPEACONF;
291 uint32_t savePIPEBCONF;
292 uint32_t savePIPEASRC;
293 uint32_t savePIPEBSRC;
297 uint32_t saveDPLL_A_MD;
298 uint32_t saveHTOTAL_A;
299 uint32_t saveHBLANK_A;
300 uint32_t saveHSYNC_A;
301 uint32_t saveVTOTAL_A;
302 uint32_t saveVBLANK_A;
303 uint32_t saveVSYNC_A;
304 uint32_t saveDSPASTRIDE;
305 uint32_t saveDSPASIZE;
306 uint32_t saveDSPAPOS;
307 uint32_t saveDSPABASE;
308 uint32_t saveDSPASURF;
309 uint32_t saveDSPASTATUS;
313 uint32_t saveDPLL_B_MD;
314 uint32_t saveHTOTAL_B;
315 uint32_t saveHBLANK_B;
316 uint32_t saveHSYNC_B;
317 uint32_t saveVTOTAL_B;
318 uint32_t saveVBLANK_B;
319 uint32_t saveVSYNC_B;
320 uint32_t saveDSPBSTRIDE;
321 uint32_t saveDSPBSIZE;
322 uint32_t saveDSPBPOS;
323 uint32_t saveDSPBBASE;
324 uint32_t saveDSPBSURF;
325 uint32_t saveDSPBSTATUS;
326 uint32_t saveVCLK_DIVISOR_VGA0;
327 uint32_t saveVCLK_DIVISOR_VGA1;
328 uint32_t saveVCLK_POST_DIV;
329 uint32_t saveVGACNTRL;
337 uint32_t savePP_CONTROL;
338 uint32_t savePP_CYCLE;
339 uint32_t savePFIT_CONTROL;
340 uint32_t savePaletteA[256];
341 uint32_t savePaletteB[256];
342 uint32_t saveCLOCKGATING;
344 uint32_t saveDSPATILEOFF;
345 uint32_t saveDSPBTILEOFF;
346 uint32_t saveDSPAADDR;
347 uint32_t saveDSPBADDR;
348 uint32_t savePFIT_AUTO_RATIOS;
349 uint32_t savePFIT_PGM_RATIOS;
350 uint32_t savePP_ON_DELAYS;
351 uint32_t savePP_OFF_DELAYS;
352 uint32_t savePP_DIVISOR;
353 uint32_t saveBCLRPAT_A;
354 uint32_t saveBCLRPAT_B;
355 uint32_t saveDSPALINOFF;
356 uint32_t saveDSPBLINOFF;
357 uint32_t savePERF_MODE;
364 uint32_t saveCHICKENBIT;
365 uint32_t saveDSPACURSOR_CTRL;
366 uint32_t saveDSPBCURSOR_CTRL;
367 uint32_t saveDSPACURSOR_BASE;
368 uint32_t saveDSPBCURSOR_BASE;
369 uint32_t saveDSPACURSOR_POS;
370 uint32_t saveDSPBCURSOR_POS;
371 uint32_t save_palette_a[256];
372 uint32_t save_palette_b[256];
373 uint32_t saveOV_OVADD;
374 uint32_t saveOV_OGAMC0;
375 uint32_t saveOV_OGAMC1;
376 uint32_t saveOV_OGAMC2;
377 uint32_t saveOV_OGAMC3;
378 uint32_t saveOV_OGAMC4;
379 uint32_t saveOV_OGAMC5;
380 uint32_t saveOVC_OVADD;
381 uint32_t saveOVC_OGAMC0;
382 uint32_t saveOVC_OGAMC1;
383 uint32_t saveOVC_OGAMC2;
384 uint32_t saveOVC_OGAMC3;
385 uint32_t saveOVC_OGAMC4;
386 uint32_t saveOVC_OGAMC5;
388 /* DPST register save */
389 uint32_t saveHISTOGRAM_INT_CONTROL_REG;
390 uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
391 uint32_t savePWM_CONTROL_LOGIC;
394 struct medfield_state {
397 uint32_t savePIPEACONF;
398 uint32_t saveHTOTAL_A;
399 uint32_t saveHBLANK_A;
400 uint32_t saveHSYNC_A;
401 uint32_t saveVTOTAL_A;
402 uint32_t saveVBLANK_A;
403 uint32_t saveVSYNC_A;
404 uint32_t savePIPEASRC;
405 uint32_t saveDSPASTRIDE;
406 uint32_t saveDSPALINOFF;
407 uint32_t saveDSPATILEOFF;
408 uint32_t saveDSPASIZE;
409 uint32_t saveDSPAPOS;
410 uint32_t saveDSPASURF;
411 uint32_t saveDSPACNTR;
412 uint32_t saveDSPASTATUS;
413 uint32_t save_palette_a[256];
418 uint32_t savePIPEBCONF;
419 uint32_t saveHTOTAL_B;
420 uint32_t saveHBLANK_B;
421 uint32_t saveHSYNC_B;
422 uint32_t saveVTOTAL_B;
423 uint32_t saveVBLANK_B;
424 uint32_t saveVSYNC_B;
425 uint32_t savePIPEBSRC;
426 uint32_t saveDSPBSTRIDE;
427 uint32_t saveDSPBLINOFF;
428 uint32_t saveDSPBTILEOFF;
429 uint32_t saveDSPBSIZE;
430 uint32_t saveDSPBPOS;
431 uint32_t saveDSPBSURF;
432 uint32_t saveDSPBCNTR;
433 uint32_t saveDSPBSTATUS;
434 uint32_t save_palette_b[256];
436 uint32_t savePIPECCONF;
437 uint32_t saveHTOTAL_C;
438 uint32_t saveHBLANK_C;
439 uint32_t saveHSYNC_C;
440 uint32_t saveVTOTAL_C;
441 uint32_t saveVBLANK_C;
442 uint32_t saveVSYNC_C;
443 uint32_t savePIPECSRC;
444 uint32_t saveDSPCSTRIDE;
445 uint32_t saveDSPCLINOFF;
446 uint32_t saveDSPCTILEOFF;
447 uint32_t saveDSPCSIZE;
448 uint32_t saveDSPCPOS;
449 uint32_t saveDSPCSURF;
450 uint32_t saveDSPCCNTR;
451 uint32_t saveDSPCSTATUS;
452 uint32_t save_palette_c[256];
455 uint32_t savePFIT_CONTROL;
456 uint32_t savePFIT_PGM_RATIOS;
457 uint32_t saveHDMIPHYMISCCTL;
458 uint32_t saveHDMIB_CONTROL;
462 uint32_t saveDSPCLK_GATE_D;
463 uint32_t saveRAMCLK_GATE_D;
465 uint32_t saveDSPFW[6];
467 uint32_t savePP_CONTROL;
468 uint32_t savePFIT_PGM_RATIOS;
470 uint32_t savePFIT_CONTROL;
471 uint32_t savePP_ON_DELAYS;
472 uint32_t savePP_OFF_DELAYS;
473 uint32_t savePP_CYCLE;
474 uint32_t saveVGACNTRL;
480 struct psb_save_area {
484 struct psb_state psb;
485 struct medfield_state mdfld;
486 struct cdv_state cdv;
488 uint32_t saveBLC_PWM_CTL2;
489 uint32_t saveBLC_PWM_CTL;
494 #define PSB_NUM_PIPE 3
496 struct drm_psb_private {
497 struct drm_device *dev;
498 const struct psb_ops *ops;
500 struct child_device_config *child_dev;
505 /* GTT Memory manager */
506 struct psb_gtt_mm *gtt_mm;
507 struct page *scratch_page;
509 uint32_t stolen_base;
511 unsigned long vram_stolen_size;
513 u16 gmch_ctrl; /* Saved GTT setup */
516 struct mutex gtt_mutex;
517 struct resource *gtt_mem; /* Our PCI resource */
519 struct psb_mmu_driver *mmu;
520 struct psb_mmu_pd *pf_pd;
528 uint32_t gatt_free_offset;
534 uint32_t vdc_irq_mask;
535 uint32_t pipestat[PSB_NUM_PIPE];
537 spinlock_t irqmask_lock;
550 struct psb_intel_mode_device mode_dev;
552 struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
553 struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
557 * OSPM info (Power management base) (can go ?)
566 u32 video_device_fuse;
568 /* PCI revision ID for B0:D2:F0 */
569 uint8_t platform_rev_id;
572 struct intel_gmbus *gmbus;
576 /* FIXME: The mappings should be parsed from bios but for now we can
577 pretend there are no mappings available */
578 struct sdvo_device_mapping sdvo_mappings[2];
579 u32 hotplug_supported_mask;
580 struct drm_property *broadcast_rgb_property;
581 struct drm_property *force_audio_property;
586 int backlight_duty_cycle; /* restore backlight to this value */
587 bool panel_wants_dither;
588 struct drm_display_mode *panel_fixed_mode;
589 struct drm_display_mode *lfp_lvds_vbt_mode;
590 struct drm_display_mode *sdvo_lvds_vbt_mode;
592 struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */
593 struct psb_intel_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */
595 /* Feature bits from the VBIOS */
596 unsigned int int_tv_support:1;
597 unsigned int lvds_dither:1;
598 unsigned int lvds_vbt:1;
599 unsigned int int_crt_support:1;
600 unsigned int lvds_use_ssc:1;
604 u32 mipi_ctrl_display;
606 unsigned int core_freq;
607 uint32_t iLVDS_enable;
609 /* Runtime PM state */
613 struct oaktrail_vbt vbt_data;
614 struct oaktrail_gct_data gct_data;
616 /* Oaktrail HDMI state */
617 struct oaktrail_hdmi_dev *hdmi_priv;
623 struct psb_save_area regs;
634 struct timer_list lid_timer;
635 struct psb_intel_opregion opregion;
647 * Used for modifying backlight from
648 * xrandr -- consider removing and using HAL instead
650 struct backlight_device *backlight_device;
651 struct drm_property *backlight_property;
657 /* 2D acceleration */
664 int brightness_adjusted;
668 bool dpi_panel_on[3];
669 void *dsi_configs[2];
678 bool dplla_96mhz; /* DPLL data from the VBT */
683 * Operations for each board type
688 unsigned int accel_2d:1;
689 int pipes; /* Number of output pipes */
690 int crtcs; /* Number of CRTCs */
691 int sgx_offset; /* Base offset of SGX device */
692 int hdmi_mask; /* Mask of HDMI CRTCs */
693 int lvds_mask; /* Mask of LVDS CRTCs */
696 struct drm_crtc_helper_funcs const *crtc_helper;
697 struct drm_crtc_funcs const *crtc_funcs;
700 int (*chip_setup)(struct drm_device *dev);
701 void (*chip_teardown)(struct drm_device *dev);
702 /* Optional helper caller after modeset */
703 void (*errata)(struct drm_device *dev);
705 /* Display management hooks */
706 int (*output_init)(struct drm_device *dev);
707 int (*hotplug)(struct drm_device *dev);
708 void (*hotplug_enable)(struct drm_device *dev, bool on);
709 /* Power management hooks */
710 void (*init_pm)(struct drm_device *dev);
711 int (*save_regs)(struct drm_device *dev);
712 int (*restore_regs)(struct drm_device *dev);
713 int (*power_up)(struct drm_device *dev);
714 int (*power_down)(struct drm_device *dev);
716 void (*lvds_bl_power)(struct drm_device *dev, bool on);
717 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
719 int (*backlight_init)(struct drm_device *dev);
721 int i2c_bus; /* I2C bus identifier for Moorestown */
726 struct psb_mmu_driver;
728 extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
729 extern int drm_pick_crtcs(struct drm_device *dev);
731 static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
733 return (struct drm_psb_private *) dev->dev_private;
740 extern struct psb_mmu_driver *psb_mmu_driver_init(uint8_t __iomem * registers,
743 struct drm_psb_private *dev_priv);
744 extern void psb_mmu_driver_takedown(struct psb_mmu_driver *driver);
745 extern struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver
747 extern void psb_mmu_mirror_gtt(struct psb_mmu_pd *pd, uint32_t mmu_offset,
748 uint32_t gtt_start, uint32_t gtt_pages);
749 extern struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
752 extern void psb_mmu_free_pagedir(struct psb_mmu_pd *pd);
753 extern void psb_mmu_flush(struct psb_mmu_driver *driver, int rc_prot);
754 extern void psb_mmu_remove_pfn_sequence(struct psb_mmu_pd *pd,
755 unsigned long address,
757 extern int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd,
759 unsigned long address,
760 uint32_t num_pages, int type);
761 extern int psb_mmu_virtual_to_pfn(struct psb_mmu_pd *pd, uint32_t virtual,
765 * Enable / disable MMU for different requestors.
769 extern void psb_mmu_set_pd_context(struct psb_mmu_pd *pd, int hw_context);
770 extern int psb_mmu_insert_pages(struct psb_mmu_pd *pd, struct page **pages,
771 unsigned long address, uint32_t num_pages,
772 uint32_t desired_tile_stride,
773 uint32_t hw_tile_stride, int type);
774 extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
775 unsigned long address, uint32_t num_pages,
776 uint32_t desired_tile_stride,
777 uint32_t hw_tile_stride);
782 extern irqreturn_t psb_irq_handler(DRM_IRQ_ARGS);
783 extern int psb_irq_enable_dpst(struct drm_device *dev);
784 extern int psb_irq_disable_dpst(struct drm_device *dev);
785 extern void psb_irq_preinstall(struct drm_device *dev);
786 extern int psb_irq_postinstall(struct drm_device *dev);
787 extern void psb_irq_uninstall(struct drm_device *dev);
788 extern void psb_irq_turn_on_dpst(struct drm_device *dev);
789 extern void psb_irq_turn_off_dpst(struct drm_device *dev);
791 extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
792 extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
793 extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
794 extern int psb_enable_vblank(struct drm_device *dev, int crtc);
795 extern void psb_disable_vblank(struct drm_device *dev, int crtc);
797 psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
800 psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
802 extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
807 extern int gma_intel_opregion_init(struct drm_device *dev);
808 extern int gma_intel_opregion_exit(struct drm_device *dev);
813 extern int psbfb_probed(struct drm_device *dev);
814 extern int psbfb_remove(struct drm_device *dev,
815 struct drm_framebuffer *fb);
819 extern void psbfb_copyarea(struct fb_info *info,
820 const struct fb_copyarea *region);
821 extern int psbfb_sync(struct fb_info *info);
822 extern void psb_spank(struct drm_psb_private *dev_priv);
828 extern void psb_lid_timer_init(struct drm_psb_private *dev_priv);
829 extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);
830 extern void psb_print_pagefault(struct drm_psb_private *dev_priv);
833 extern void psb_modeset_init(struct drm_device *dev);
834 extern void psb_modeset_cleanup(struct drm_device *dev);
835 extern int psb_fbdev_init(struct drm_device *dev);
838 int gma_backlight_init(struct drm_device *dev);
839 void gma_backlight_exit(struct drm_device *dev);
841 /* oaktrail_crtc.c */
842 extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
844 /* oaktrail_lvds.c */
845 extern void oaktrail_lvds_init(struct drm_device *dev,
846 struct psb_intel_mode_device *mode_dev);
848 /* psb_intel_display.c */
849 extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
850 extern const struct drm_crtc_funcs psb_intel_crtc_funcs;
852 /* psb_intel_lvds.c */
853 extern const struct drm_connector_helper_funcs
854 psb_intel_lvds_connector_helper_funcs;
855 extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
858 extern int psb_gem_init_object(struct drm_gem_object *obj);
859 extern void psb_gem_free_object(struct drm_gem_object *obj);
860 extern int psb_gem_get_aperture(struct drm_device *dev, void *data,
861 struct drm_file *file);
862 extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
863 struct drm_mode_create_dumb *args);
864 extern int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
866 extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
867 uint32_t handle, uint64_t *offset);
868 extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
869 extern int psb_gem_create_ioctl(struct drm_device *dev, void *data,
870 struct drm_file *file);
871 extern int psb_gem_mmap_ioctl(struct drm_device *dev, void *data,
872 struct drm_file *file);
875 extern const struct psb_ops psb_chip_ops;
877 /* oaktrail_device.c */
878 extern const struct psb_ops oaktrail_chip_ops;
881 extern const struct psb_ops mdfld_chip_ops;
884 extern const struct psb_ops cdv_chip_ops;
887 * Debug print bits setting
889 #define PSB_D_GENERAL (1 << 0)
890 #define PSB_D_INIT (1 << 1)
891 #define PSB_D_IRQ (1 << 2)
892 #define PSB_D_ENTRY (1 << 3)
893 /* debug the get H/V BP/FP count */
894 #define PSB_D_HV (1 << 4)
895 #define PSB_D_DBI_BF (1 << 5)
896 #define PSB_D_PM (1 << 6)
897 #define PSB_D_RENDER (1 << 7)
898 #define PSB_D_REG (1 << 8)
899 #define PSB_D_MSVDX (1 << 9)
900 #define PSB_D_TOPAZ (1 << 10)
902 extern int drm_psb_no_fb;
903 extern int drm_idle_check_interval;
909 static inline u32 MRST_MSG_READ32(uint port, uint offset)
911 int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
912 uint32_t ret_val = 0;
913 struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
914 pci_write_config_dword(pci_root, 0xD0, mcr);
915 pci_read_config_dword(pci_root, 0xD4, &ret_val);
916 pci_dev_put(pci_root);
919 static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
921 int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
922 struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
923 pci_write_config_dword(pci_root, 0xD4, value);
924 pci_write_config_dword(pci_root, 0xD0, mcr);
925 pci_dev_put(pci_root);
927 static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
929 int mcr = (0x10<<24) | (port << 16) | (offset << 8);
930 uint32_t ret_val = 0;
931 struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
932 pci_write_config_dword(pci_root, 0xD0, mcr);
933 pci_read_config_dword(pci_root, 0xD4, &ret_val);
934 pci_dev_put(pci_root);
937 static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
939 int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
940 struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
941 pci_write_config_dword(pci_root, 0xD4, value);
942 pci_write_config_dword(pci_root, 0xD0, mcr);
943 pci_dev_put(pci_root);
946 static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
948 struct drm_psb_private *dev_priv = dev->dev_private;
949 return ioread32(dev_priv->vdc_reg + reg);
952 #define REG_READ(reg) REGISTER_READ(dev, (reg))
954 static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
957 struct drm_psb_private *dev_priv = dev->dev_private;
958 iowrite32((val), dev_priv->vdc_reg + (reg));
961 #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val))
963 static inline void REGISTER_WRITE16(struct drm_device *dev,
964 uint32_t reg, uint32_t val)
966 struct drm_psb_private *dev_priv = dev->dev_private;
967 iowrite16((val), dev_priv->vdc_reg + (reg));
970 #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val))
972 static inline void REGISTER_WRITE8(struct drm_device *dev,
973 uint32_t reg, uint32_t val)
975 struct drm_psb_private *dev_priv = dev->dev_private;
976 iowrite8((val), dev_priv->vdc_reg + (reg));
979 #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val))
981 #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs))
982 #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs))
984 /* #define TRAP_SGX_PM_FAULT 1 */
985 #ifdef TRAP_SGX_PM_FAULT
986 #define PSB_RSGX32(_offs) \
988 if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) { \
990 "access sgx when it's off!! (READ) %s, %d\n", \
991 __FILE__, __LINE__); \
994 ioread32(dev_priv->sgx_reg + (_offs)); \
997 #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs))
999 #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs))
1001 #define MSVDX_REG_DUMP 0
1003 #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs))
1004 #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs))