1*5c49fd3aSAlan Cox /************************************************************************** 2*5c49fd3aSAlan Cox * Copyright (c) 2007-2011, Intel Corporation. 3*5c49fd3aSAlan Cox * All Rights Reserved. 4*5c49fd3aSAlan Cox * 5*5c49fd3aSAlan Cox * This program is free software; you can redistribute it and/or modify it 6*5c49fd3aSAlan Cox * under the terms and conditions of the GNU General Public License, 7*5c49fd3aSAlan Cox * version 2, as published by the Free Software Foundation. 8*5c49fd3aSAlan Cox * 9*5c49fd3aSAlan Cox * This program is distributed in the hope it will be useful, but WITHOUT 10*5c49fd3aSAlan Cox * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11*5c49fd3aSAlan Cox * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12*5c49fd3aSAlan Cox * more details. 13*5c49fd3aSAlan Cox * 14*5c49fd3aSAlan Cox * You should have received a copy of the GNU General Public License along with 15*5c49fd3aSAlan Cox * this program; if not, write to the Free Software Foundation, Inc., 16*5c49fd3aSAlan Cox * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17*5c49fd3aSAlan Cox * 18*5c49fd3aSAlan Cox **************************************************************************/ 19*5c49fd3aSAlan Cox 20*5c49fd3aSAlan Cox #ifndef _PSB_DRV_H_ 21*5c49fd3aSAlan Cox #define _PSB_DRV_H_ 22*5c49fd3aSAlan Cox 23*5c49fd3aSAlan Cox #include <linux/kref.h> 24*5c49fd3aSAlan Cox 25*5c49fd3aSAlan Cox #include <drm/drmP.h> 26*5c49fd3aSAlan Cox #include "drm_global.h" 27*5c49fd3aSAlan Cox #include "gem_glue.h" 28*5c49fd3aSAlan Cox #include "psb_drm.h" 29*5c49fd3aSAlan Cox #include "psb_reg.h" 30*5c49fd3aSAlan Cox #include "psb_intel_drv.h" 31*5c49fd3aSAlan Cox #include "gtt.h" 32*5c49fd3aSAlan Cox #include "power.h" 33*5c49fd3aSAlan Cox #include "oaktrail.h" 34*5c49fd3aSAlan Cox 35*5c49fd3aSAlan Cox /* Append new drm mode definition here, align with libdrm definition */ 36*5c49fd3aSAlan Cox #define DRM_MODE_SCALE_NO_SCALE 2 37*5c49fd3aSAlan Cox 38*5c49fd3aSAlan Cox enum { 39*5c49fd3aSAlan Cox CHIP_PSB_8108 = 0, /* Poulsbo */ 40*5c49fd3aSAlan Cox CHIP_PSB_8109 = 1, /* Poulsbo */ 41*5c49fd3aSAlan Cox CHIP_MRST_4100 = 2, /* Moorestown/Oaktrail */ 42*5c49fd3aSAlan Cox CHIP_MFLD_0130 = 3, /* Medfield */ 43*5c49fd3aSAlan Cox }; 44*5c49fd3aSAlan Cox 45*5c49fd3aSAlan Cox #define IS_MRST(dev) (((dev)->pci_device & 0xfffc) == 0x4100) 46*5c49fd3aSAlan Cox #define IS_MFLD(dev) (((dev)->pci_device & 0xfff8) == 0x0130) 47*5c49fd3aSAlan Cox 48*5c49fd3aSAlan Cox /* 49*5c49fd3aSAlan Cox * Driver definitions 50*5c49fd3aSAlan Cox */ 51*5c49fd3aSAlan Cox 52*5c49fd3aSAlan Cox #define DRIVER_NAME "gma500" 53*5c49fd3aSAlan Cox #define DRIVER_DESC "DRM driver for the Intel GMA500" 54*5c49fd3aSAlan Cox 55*5c49fd3aSAlan Cox #define PSB_DRM_DRIVER_DATE "2011-06-06" 56*5c49fd3aSAlan Cox #define PSB_DRM_DRIVER_MAJOR 1 57*5c49fd3aSAlan Cox #define PSB_DRM_DRIVER_MINOR 0 58*5c49fd3aSAlan Cox #define PSB_DRM_DRIVER_PATCHLEVEL 0 59*5c49fd3aSAlan Cox 60*5c49fd3aSAlan Cox /* 61*5c49fd3aSAlan Cox * Hardware offsets 62*5c49fd3aSAlan Cox */ 63*5c49fd3aSAlan Cox #define PSB_VDC_OFFSET 0x00000000 64*5c49fd3aSAlan Cox #define PSB_VDC_SIZE 0x000080000 65*5c49fd3aSAlan Cox #define MRST_MMIO_SIZE 0x0000C0000 66*5c49fd3aSAlan Cox #define MDFLD_MMIO_SIZE 0x000100000 67*5c49fd3aSAlan Cox #define PSB_SGX_SIZE 0x8000 68*5c49fd3aSAlan Cox #define PSB_SGX_OFFSET 0x00040000 69*5c49fd3aSAlan Cox #define MRST_SGX_OFFSET 0x00080000 70*5c49fd3aSAlan Cox /* 71*5c49fd3aSAlan Cox * PCI resource identifiers 72*5c49fd3aSAlan Cox */ 73*5c49fd3aSAlan Cox #define PSB_MMIO_RESOURCE 0 74*5c49fd3aSAlan Cox #define PSB_GATT_RESOURCE 2 75*5c49fd3aSAlan Cox #define PSB_GTT_RESOURCE 3 76*5c49fd3aSAlan Cox /* 77*5c49fd3aSAlan Cox * PCI configuration 78*5c49fd3aSAlan Cox */ 79*5c49fd3aSAlan Cox #define PSB_GMCH_CTRL 0x52 80*5c49fd3aSAlan Cox #define PSB_BSM 0x5C 81*5c49fd3aSAlan Cox #define _PSB_GMCH_ENABLED 0x4 82*5c49fd3aSAlan Cox #define PSB_PGETBL_CTL 0x2020 83*5c49fd3aSAlan Cox #define _PSB_PGETBL_ENABLED 0x00000001 84*5c49fd3aSAlan Cox #define PSB_SGX_2D_SLAVE_PORT 0x4000 85*5c49fd3aSAlan Cox 86*5c49fd3aSAlan Cox /* To get rid of */ 87*5c49fd3aSAlan Cox #define PSB_TT_PRIV0_LIMIT (256*1024*1024) 88*5c49fd3aSAlan Cox #define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT) 89*5c49fd3aSAlan Cox 90*5c49fd3aSAlan Cox /* 91*5c49fd3aSAlan Cox * SGX side MMU definitions (these can probably go) 92*5c49fd3aSAlan Cox */ 93*5c49fd3aSAlan Cox 94*5c49fd3aSAlan Cox /* 95*5c49fd3aSAlan Cox * Flags for external memory type field. 96*5c49fd3aSAlan Cox */ 97*5c49fd3aSAlan Cox #define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */ 98*5c49fd3aSAlan Cox #define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */ 99*5c49fd3aSAlan Cox #define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */ 100*5c49fd3aSAlan Cox /* 101*5c49fd3aSAlan Cox * PTE's and PDE's 102*5c49fd3aSAlan Cox */ 103*5c49fd3aSAlan Cox #define PSB_PDE_MASK 0x003FFFFF 104*5c49fd3aSAlan Cox #define PSB_PDE_SHIFT 22 105*5c49fd3aSAlan Cox #define PSB_PTE_SHIFT 12 106*5c49fd3aSAlan Cox /* 107*5c49fd3aSAlan Cox * Cache control 108*5c49fd3aSAlan Cox */ 109*5c49fd3aSAlan Cox #define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */ 110*5c49fd3aSAlan Cox #define PSB_PTE_WO 0x0002 /* Write only */ 111*5c49fd3aSAlan Cox #define PSB_PTE_RO 0x0004 /* Read only */ 112*5c49fd3aSAlan Cox #define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */ 113*5c49fd3aSAlan Cox 114*5c49fd3aSAlan Cox /* 115*5c49fd3aSAlan Cox * VDC registers and bits 116*5c49fd3aSAlan Cox */ 117*5c49fd3aSAlan Cox #define PSB_MSVDX_CLOCKGATING 0x2064 118*5c49fd3aSAlan Cox #define PSB_TOPAZ_CLOCKGATING 0x2068 119*5c49fd3aSAlan Cox #define PSB_HWSTAM 0x2098 120*5c49fd3aSAlan Cox #define PSB_INSTPM 0x20C0 121*5c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R 0x20A4 122*5c49fd3aSAlan Cox #define _MDFLD_PIPEC_EVENT_FLAG (1<<2) 123*5c49fd3aSAlan Cox #define _MDFLD_PIPEC_VBLANK_FLAG (1<<3) 124*5c49fd3aSAlan Cox #define _PSB_DPST_PIPEB_FLAG (1<<4) 125*5c49fd3aSAlan Cox #define _MDFLD_PIPEB_EVENT_FLAG (1<<4) 126*5c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEB_FLAG (1<<5) 127*5c49fd3aSAlan Cox #define _PSB_DPST_PIPEA_FLAG (1<<6) 128*5c49fd3aSAlan Cox #define _PSB_PIPEA_EVENT_FLAG (1<<6) 129*5c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEA_FLAG (1<<7) 130*5c49fd3aSAlan Cox #define _MDFLD_MIPIA_FLAG (1<<16) 131*5c49fd3aSAlan Cox #define _MDFLD_MIPIC_FLAG (1<<17) 132*5c49fd3aSAlan Cox #define _PSB_IRQ_SGX_FLAG (1<<18) 133*5c49fd3aSAlan Cox #define _PSB_IRQ_MSVDX_FLAG (1<<19) 134*5c49fd3aSAlan Cox #define _LNC_IRQ_TOPAZ_FLAG (1<<20) 135*5c49fd3aSAlan Cox 136*5c49fd3aSAlan Cox /* This flag includes all the display IRQ bits excepts the vblank irqs. */ 137*5c49fd3aSAlan Cox #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \ 138*5c49fd3aSAlan Cox _MDFLD_PIPEB_EVENT_FLAG | \ 139*5c49fd3aSAlan Cox _PSB_PIPEA_EVENT_FLAG | \ 140*5c49fd3aSAlan Cox _PSB_VSYNC_PIPEA_FLAG | \ 141*5c49fd3aSAlan Cox _MDFLD_MIPIA_FLAG | \ 142*5c49fd3aSAlan Cox _MDFLD_MIPIC_FLAG) 143*5c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R 0x20A4 144*5c49fd3aSAlan Cox #define PSB_INT_MASK_R 0x20A8 145*5c49fd3aSAlan Cox #define PSB_INT_ENABLE_R 0x20A0 146*5c49fd3aSAlan Cox 147*5c49fd3aSAlan Cox #define _PSB_MMU_ER_MASK 0x0001FF00 148*5c49fd3aSAlan Cox #define _PSB_MMU_ER_HOST (1 << 16) 149*5c49fd3aSAlan Cox #define GPIOA 0x5010 150*5c49fd3aSAlan Cox #define GPIOB 0x5014 151*5c49fd3aSAlan Cox #define GPIOC 0x5018 152*5c49fd3aSAlan Cox #define GPIOD 0x501c 153*5c49fd3aSAlan Cox #define GPIOE 0x5020 154*5c49fd3aSAlan Cox #define GPIOF 0x5024 155*5c49fd3aSAlan Cox #define GPIOG 0x5028 156*5c49fd3aSAlan Cox #define GPIOH 0x502c 157*5c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_MASK (1 << 0) 158*5c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_IN (0 << 1) 159*5c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_OUT (1 << 1) 160*5c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_MASK (1 << 2) 161*5c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_OUT (1 << 3) 162*5c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_IN (1 << 4) 163*5c49fd3aSAlan Cox #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5) 164*5c49fd3aSAlan Cox #define GPIO_DATA_DIR_MASK (1 << 8) 165*5c49fd3aSAlan Cox #define GPIO_DATA_DIR_IN (0 << 9) 166*5c49fd3aSAlan Cox #define GPIO_DATA_DIR_OUT (1 << 9) 167*5c49fd3aSAlan Cox #define GPIO_DATA_VAL_MASK (1 << 10) 168*5c49fd3aSAlan Cox #define GPIO_DATA_VAL_OUT (1 << 11) 169*5c49fd3aSAlan Cox #define GPIO_DATA_VAL_IN (1 << 12) 170*5c49fd3aSAlan Cox #define GPIO_DATA_PULLUP_DISABLE (1 << 13) 171*5c49fd3aSAlan Cox 172*5c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA0 0x6000 173*5c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA1 0x6004 174*5c49fd3aSAlan Cox #define VCLK_POST_DIV 0x6010 175*5c49fd3aSAlan Cox 176*5c49fd3aSAlan Cox #define PSB_COMM_2D (PSB_ENGINE_2D << 4) 177*5c49fd3aSAlan Cox #define PSB_COMM_3D (PSB_ENGINE_3D << 4) 178*5c49fd3aSAlan Cox #define PSB_COMM_TA (PSB_ENGINE_TA << 4) 179*5c49fd3aSAlan Cox #define PSB_COMM_HP (PSB_ENGINE_HP << 4) 180*5c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ (1024 >> 2) 181*5c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1) 182*5c49fd3aSAlan Cox #define PSB_COMM_FW (2048 >> 2) 183*5c49fd3aSAlan Cox 184*5c49fd3aSAlan Cox #define PSB_UIRQ_VISTEST 1 185*5c49fd3aSAlan Cox #define PSB_UIRQ_OOM_REPLY 2 186*5c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_TA_REPLY 3 187*5c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_RASTER_REPLY 4 188*5c49fd3aSAlan Cox 189*5c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024) 190*5c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024 191*5c49fd3aSAlan Cox 192*5c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204 193*5c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600 194*5c49fd3aSAlan Cox 195*5c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2 196*5c49fd3aSAlan Cox 197*5c49fd3aSAlan Cox 198*5c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024) 199*5c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024 200*5c49fd3aSAlan Cox 201*5c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204 202*5c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600 203*5c49fd3aSAlan Cox 204*5c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2 205*5c49fd3aSAlan Cox #define PSB_WATCHDOG_DELAY (DRM_HZ * 2) 206*5c49fd3aSAlan Cox #define PSB_LID_DELAY (DRM_HZ / 10) 207*5c49fd3aSAlan Cox 208*5c49fd3aSAlan Cox #define MDFLD_PNW_B0 0x04 209*5c49fd3aSAlan Cox #define MDFLD_PNW_C0 0x08 210*5c49fd3aSAlan Cox 211*5c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_0 (1 << 0) 212*5c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_2 (1 << 1) 213*5c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_0 (1 << 2) 214*5c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_2 (1 << 3) 215*5c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_0 (1 << 4) 216*5c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_2 (1 << 5) 217*5c49fd3aSAlan Cox #define MDFLD_DSR_MIPI_CONTROL (1 << 6) 218*5c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_0 ((1 << 0) | (1 << 2) | (1 << 4)) 219*5c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_2 ((1 << 1) | (1 << 3) | (1 << 5)) 220*5c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D (MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2) 221*5c49fd3aSAlan Cox 222*5c49fd3aSAlan Cox #define MDFLD_DSR_RR 45 223*5c49fd3aSAlan Cox #define MDFLD_DPU_ENABLE (1 << 31) 224*5c49fd3aSAlan Cox #define MDFLD_DSR_FULLSCREEN (1 << 30) 225*5c49fd3aSAlan Cox #define MDFLD_DSR_DELAY (DRM_HZ / MDFLD_DSR_RR) 226*5c49fd3aSAlan Cox 227*5c49fd3aSAlan Cox #define PSB_PWR_STATE_ON 1 228*5c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF 2 229*5c49fd3aSAlan Cox 230*5c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM 0 231*5c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING 1 232*5c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN 2 233*5c49fd3aSAlan Cox 234*5c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP 0 235*5c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED 1 236*5c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN 2 237*5c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC 0x94 238*5c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC 0x98 239*5c49fd3aSAlan Cox 240*5c49fd3aSAlan Cox /* Medfield crystal settings */ 241*5c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1 242*5c49fd3aSAlan Cox #define KSEL_BYPASS_19 5 243*5c49fd3aSAlan Cox #define KSEL_BYPASS_25 6 244*5c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7 245*5c49fd3aSAlan Cox 246*5c49fd3aSAlan Cox struct opregion_header; 247*5c49fd3aSAlan Cox struct opregion_acpi; 248*5c49fd3aSAlan Cox struct opregion_swsci; 249*5c49fd3aSAlan Cox struct opregion_asle; 250*5c49fd3aSAlan Cox 251*5c49fd3aSAlan Cox struct psb_intel_opregion { 252*5c49fd3aSAlan Cox struct opregion_header *header; 253*5c49fd3aSAlan Cox struct opregion_acpi *acpi; 254*5c49fd3aSAlan Cox struct opregion_swsci *swsci; 255*5c49fd3aSAlan Cox struct opregion_asle *asle; 256*5c49fd3aSAlan Cox int enabled; 257*5c49fd3aSAlan Cox }; 258*5c49fd3aSAlan Cox 259*5c49fd3aSAlan Cox struct psb_ops; 260*5c49fd3aSAlan Cox 261*5c49fd3aSAlan Cox struct drm_psb_private { 262*5c49fd3aSAlan Cox struct drm_device *dev; 263*5c49fd3aSAlan Cox const struct psb_ops *ops; 264*5c49fd3aSAlan Cox 265*5c49fd3aSAlan Cox struct psb_gtt gtt; 266*5c49fd3aSAlan Cox 267*5c49fd3aSAlan Cox /* GTT Memory manager */ 268*5c49fd3aSAlan Cox struct psb_gtt_mm *gtt_mm; 269*5c49fd3aSAlan Cox struct page *scratch_page; 270*5c49fd3aSAlan Cox u32 *gtt_map; 271*5c49fd3aSAlan Cox uint32_t stolen_base; 272*5c49fd3aSAlan Cox void *vram_addr; 273*5c49fd3aSAlan Cox unsigned long vram_stolen_size; 274*5c49fd3aSAlan Cox int gtt_initialized; 275*5c49fd3aSAlan Cox u16 gmch_ctrl; /* Saved GTT setup */ 276*5c49fd3aSAlan Cox u32 pge_ctl; 277*5c49fd3aSAlan Cox 278*5c49fd3aSAlan Cox struct mutex gtt_mutex; 279*5c49fd3aSAlan Cox struct resource *gtt_mem; /* Our PCI resource */ 280*5c49fd3aSAlan Cox 281*5c49fd3aSAlan Cox struct psb_mmu_driver *mmu; 282*5c49fd3aSAlan Cox struct psb_mmu_pd *pf_pd; 283*5c49fd3aSAlan Cox 284*5c49fd3aSAlan Cox /* 285*5c49fd3aSAlan Cox * Register base 286*5c49fd3aSAlan Cox */ 287*5c49fd3aSAlan Cox 288*5c49fd3aSAlan Cox uint8_t *sgx_reg; 289*5c49fd3aSAlan Cox uint8_t *vdc_reg; 290*5c49fd3aSAlan Cox uint32_t gatt_free_offset; 291*5c49fd3aSAlan Cox 292*5c49fd3aSAlan Cox /* 293*5c49fd3aSAlan Cox * Fencing / irq. 294*5c49fd3aSAlan Cox */ 295*5c49fd3aSAlan Cox 296*5c49fd3aSAlan Cox uint32_t vdc_irq_mask; 297*5c49fd3aSAlan Cox uint32_t pipestat[PSB_NUM_PIPE]; 298*5c49fd3aSAlan Cox 299*5c49fd3aSAlan Cox spinlock_t irqmask_lock; 300*5c49fd3aSAlan Cox 301*5c49fd3aSAlan Cox /* 302*5c49fd3aSAlan Cox * Power 303*5c49fd3aSAlan Cox */ 304*5c49fd3aSAlan Cox 305*5c49fd3aSAlan Cox bool suspended; 306*5c49fd3aSAlan Cox bool display_power; 307*5c49fd3aSAlan Cox int display_count; 308*5c49fd3aSAlan Cox 309*5c49fd3aSAlan Cox /* 310*5c49fd3aSAlan Cox * Modesetting 311*5c49fd3aSAlan Cox */ 312*5c49fd3aSAlan Cox struct psb_intel_mode_device mode_dev; 313*5c49fd3aSAlan Cox 314*5c49fd3aSAlan Cox struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE]; 315*5c49fd3aSAlan Cox struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE]; 316*5c49fd3aSAlan Cox uint32_t num_pipe; 317*5c49fd3aSAlan Cox 318*5c49fd3aSAlan Cox /* 319*5c49fd3aSAlan Cox * OSPM info (Power management base) (can go ?) 320*5c49fd3aSAlan Cox */ 321*5c49fd3aSAlan Cox uint32_t ospm_base; 322*5c49fd3aSAlan Cox 323*5c49fd3aSAlan Cox /* 324*5c49fd3aSAlan Cox * Sizes info 325*5c49fd3aSAlan Cox */ 326*5c49fd3aSAlan Cox 327*5c49fd3aSAlan Cox struct drm_psb_sizes_arg sizes; 328*5c49fd3aSAlan Cox 329*5c49fd3aSAlan Cox u32 fuse_reg_value; 330*5c49fd3aSAlan Cox u32 video_device_fuse; 331*5c49fd3aSAlan Cox 332*5c49fd3aSAlan Cox /* PCI revision ID for B0:D2:F0 */ 333*5c49fd3aSAlan Cox uint8_t platform_rev_id; 334*5c49fd3aSAlan Cox 335*5c49fd3aSAlan Cox /* 336*5c49fd3aSAlan Cox * LVDS info 337*5c49fd3aSAlan Cox */ 338*5c49fd3aSAlan Cox int backlight_duty_cycle; /* restore backlight to this value */ 339*5c49fd3aSAlan Cox bool panel_wants_dither; 340*5c49fd3aSAlan Cox struct drm_display_mode *panel_fixed_mode; 341*5c49fd3aSAlan Cox struct drm_display_mode *lfp_lvds_vbt_mode; 342*5c49fd3aSAlan Cox struct drm_display_mode *sdvo_lvds_vbt_mode; 343*5c49fd3aSAlan Cox 344*5c49fd3aSAlan Cox struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */ 345*5c49fd3aSAlan Cox struct psb_intel_i2c_chan *lvds_i2c_bus; 346*5c49fd3aSAlan Cox 347*5c49fd3aSAlan Cox /* Feature bits from the VBIOS */ 348*5c49fd3aSAlan Cox unsigned int int_tv_support:1; 349*5c49fd3aSAlan Cox unsigned int lvds_dither:1; 350*5c49fd3aSAlan Cox unsigned int lvds_vbt:1; 351*5c49fd3aSAlan Cox unsigned int int_crt_support:1; 352*5c49fd3aSAlan Cox unsigned int lvds_use_ssc:1; 353*5c49fd3aSAlan Cox int lvds_ssc_freq; 354*5c49fd3aSAlan Cox bool is_lvds_on; 355*5c49fd3aSAlan Cox bool is_mipi_on; 356*5c49fd3aSAlan Cox u32 mipi_ctrl_display; 357*5c49fd3aSAlan Cox 358*5c49fd3aSAlan Cox unsigned int core_freq; 359*5c49fd3aSAlan Cox uint32_t iLVDS_enable; 360*5c49fd3aSAlan Cox 361*5c49fd3aSAlan Cox /* Runtime PM state */ 362*5c49fd3aSAlan Cox int rpm_enabled; 363*5c49fd3aSAlan Cox 364*5c49fd3aSAlan Cox /* MID specific */ 365*5c49fd3aSAlan Cox struct oaktrail_vbt vbt_data; 366*5c49fd3aSAlan Cox struct oaktrail_gct_data gct_data; 367*5c49fd3aSAlan Cox 368*5c49fd3aSAlan Cox /* MIPI Panel type etc */ 369*5c49fd3aSAlan Cox int panel_id; 370*5c49fd3aSAlan Cox bool dual_mipi; /* dual display - DPI & DBI */ 371*5c49fd3aSAlan Cox bool dpi_panel_on; /* The DPI panel power is on */ 372*5c49fd3aSAlan Cox bool dpi_panel_on2; /* The DPI panel power is on */ 373*5c49fd3aSAlan Cox bool dbi_panel_on; /* The DBI panel power is on */ 374*5c49fd3aSAlan Cox bool dbi_panel_on2; /* The DBI panel power is on */ 375*5c49fd3aSAlan Cox u32 dsr_fb_update; /* DSR FB update counter */ 376*5c49fd3aSAlan Cox 377*5c49fd3aSAlan Cox /* Moorestown HDMI state */ 378*5c49fd3aSAlan Cox struct oaktrail_hdmi_dev *hdmi_priv; 379*5c49fd3aSAlan Cox 380*5c49fd3aSAlan Cox /* Moorestown pipe config register value cache */ 381*5c49fd3aSAlan Cox uint32_t pipeconf; 382*5c49fd3aSAlan Cox uint32_t pipeconf1; 383*5c49fd3aSAlan Cox uint32_t pipeconf2; 384*5c49fd3aSAlan Cox 385*5c49fd3aSAlan Cox /* Moorestown plane control register value cache */ 386*5c49fd3aSAlan Cox uint32_t dspcntr; 387*5c49fd3aSAlan Cox uint32_t dspcntr1; 388*5c49fd3aSAlan Cox uint32_t dspcntr2; 389*5c49fd3aSAlan Cox 390*5c49fd3aSAlan Cox /* Moorestown MM backlight cache */ 391*5c49fd3aSAlan Cox uint8_t saveBKLTCNT; 392*5c49fd3aSAlan Cox uint8_t saveBKLTREQ; 393*5c49fd3aSAlan Cox uint8_t saveBKLTBRTL; 394*5c49fd3aSAlan Cox 395*5c49fd3aSAlan Cox /* 396*5c49fd3aSAlan Cox * Register state 397*5c49fd3aSAlan Cox */ 398*5c49fd3aSAlan Cox uint32_t saveDSPACNTR; 399*5c49fd3aSAlan Cox uint32_t saveDSPBCNTR; 400*5c49fd3aSAlan Cox uint32_t savePIPEACONF; 401*5c49fd3aSAlan Cox uint32_t savePIPEBCONF; 402*5c49fd3aSAlan Cox uint32_t savePIPEASRC; 403*5c49fd3aSAlan Cox uint32_t savePIPEBSRC; 404*5c49fd3aSAlan Cox uint32_t saveFPA0; 405*5c49fd3aSAlan Cox uint32_t saveFPA1; 406*5c49fd3aSAlan Cox uint32_t saveDPLL_A; 407*5c49fd3aSAlan Cox uint32_t saveDPLL_A_MD; 408*5c49fd3aSAlan Cox uint32_t saveHTOTAL_A; 409*5c49fd3aSAlan Cox uint32_t saveHBLANK_A; 410*5c49fd3aSAlan Cox uint32_t saveHSYNC_A; 411*5c49fd3aSAlan Cox uint32_t saveVTOTAL_A; 412*5c49fd3aSAlan Cox uint32_t saveVBLANK_A; 413*5c49fd3aSAlan Cox uint32_t saveVSYNC_A; 414*5c49fd3aSAlan Cox uint32_t saveDSPASTRIDE; 415*5c49fd3aSAlan Cox uint32_t saveDSPASIZE; 416*5c49fd3aSAlan Cox uint32_t saveDSPAPOS; 417*5c49fd3aSAlan Cox uint32_t saveDSPABASE; 418*5c49fd3aSAlan Cox uint32_t saveDSPASURF; 419*5c49fd3aSAlan Cox uint32_t saveDSPASTATUS; 420*5c49fd3aSAlan Cox uint32_t saveFPB0; 421*5c49fd3aSAlan Cox uint32_t saveFPB1; 422*5c49fd3aSAlan Cox uint32_t saveDPLL_B; 423*5c49fd3aSAlan Cox uint32_t saveDPLL_B_MD; 424*5c49fd3aSAlan Cox uint32_t saveHTOTAL_B; 425*5c49fd3aSAlan Cox uint32_t saveHBLANK_B; 426*5c49fd3aSAlan Cox uint32_t saveHSYNC_B; 427*5c49fd3aSAlan Cox uint32_t saveVTOTAL_B; 428*5c49fd3aSAlan Cox uint32_t saveVBLANK_B; 429*5c49fd3aSAlan Cox uint32_t saveVSYNC_B; 430*5c49fd3aSAlan Cox uint32_t saveDSPBSTRIDE; 431*5c49fd3aSAlan Cox uint32_t saveDSPBSIZE; 432*5c49fd3aSAlan Cox uint32_t saveDSPBPOS; 433*5c49fd3aSAlan Cox uint32_t saveDSPBBASE; 434*5c49fd3aSAlan Cox uint32_t saveDSPBSURF; 435*5c49fd3aSAlan Cox uint32_t saveDSPBSTATUS; 436*5c49fd3aSAlan Cox uint32_t saveVCLK_DIVISOR_VGA0; 437*5c49fd3aSAlan Cox uint32_t saveVCLK_DIVISOR_VGA1; 438*5c49fd3aSAlan Cox uint32_t saveVCLK_POST_DIV; 439*5c49fd3aSAlan Cox uint32_t saveVGACNTRL; 440*5c49fd3aSAlan Cox uint32_t saveADPA; 441*5c49fd3aSAlan Cox uint32_t saveLVDS; 442*5c49fd3aSAlan Cox uint32_t saveDVOA; 443*5c49fd3aSAlan Cox uint32_t saveDVOB; 444*5c49fd3aSAlan Cox uint32_t saveDVOC; 445*5c49fd3aSAlan Cox uint32_t savePP_ON; 446*5c49fd3aSAlan Cox uint32_t savePP_OFF; 447*5c49fd3aSAlan Cox uint32_t savePP_CONTROL; 448*5c49fd3aSAlan Cox uint32_t savePP_CYCLE; 449*5c49fd3aSAlan Cox uint32_t savePFIT_CONTROL; 450*5c49fd3aSAlan Cox uint32_t savePaletteA[256]; 451*5c49fd3aSAlan Cox uint32_t savePaletteB[256]; 452*5c49fd3aSAlan Cox uint32_t saveBLC_PWM_CTL2; 453*5c49fd3aSAlan Cox uint32_t saveBLC_PWM_CTL; 454*5c49fd3aSAlan Cox uint32_t saveCLOCKGATING; 455*5c49fd3aSAlan Cox uint32_t saveDSPARB; 456*5c49fd3aSAlan Cox uint32_t saveDSPATILEOFF; 457*5c49fd3aSAlan Cox uint32_t saveDSPBTILEOFF; 458*5c49fd3aSAlan Cox uint32_t saveDSPAADDR; 459*5c49fd3aSAlan Cox uint32_t saveDSPBADDR; 460*5c49fd3aSAlan Cox uint32_t savePFIT_AUTO_RATIOS; 461*5c49fd3aSAlan Cox uint32_t savePFIT_PGM_RATIOS; 462*5c49fd3aSAlan Cox uint32_t savePP_ON_DELAYS; 463*5c49fd3aSAlan Cox uint32_t savePP_OFF_DELAYS; 464*5c49fd3aSAlan Cox uint32_t savePP_DIVISOR; 465*5c49fd3aSAlan Cox uint32_t saveBSM; 466*5c49fd3aSAlan Cox uint32_t saveVBT; 467*5c49fd3aSAlan Cox uint32_t saveBCLRPAT_A; 468*5c49fd3aSAlan Cox uint32_t saveBCLRPAT_B; 469*5c49fd3aSAlan Cox uint32_t saveDSPALINOFF; 470*5c49fd3aSAlan Cox uint32_t saveDSPBLINOFF; 471*5c49fd3aSAlan Cox uint32_t savePERF_MODE; 472*5c49fd3aSAlan Cox uint32_t saveDSPFW1; 473*5c49fd3aSAlan Cox uint32_t saveDSPFW2; 474*5c49fd3aSAlan Cox uint32_t saveDSPFW3; 475*5c49fd3aSAlan Cox uint32_t saveDSPFW4; 476*5c49fd3aSAlan Cox uint32_t saveDSPFW5; 477*5c49fd3aSAlan Cox uint32_t saveDSPFW6; 478*5c49fd3aSAlan Cox uint32_t saveCHICKENBIT; 479*5c49fd3aSAlan Cox uint32_t saveDSPACURSOR_CTRL; 480*5c49fd3aSAlan Cox uint32_t saveDSPBCURSOR_CTRL; 481*5c49fd3aSAlan Cox uint32_t saveDSPACURSOR_BASE; 482*5c49fd3aSAlan Cox uint32_t saveDSPBCURSOR_BASE; 483*5c49fd3aSAlan Cox uint32_t saveDSPACURSOR_POS; 484*5c49fd3aSAlan Cox uint32_t saveDSPBCURSOR_POS; 485*5c49fd3aSAlan Cox uint32_t save_palette_a[256]; 486*5c49fd3aSAlan Cox uint32_t save_palette_b[256]; 487*5c49fd3aSAlan Cox uint32_t saveOV_OVADD; 488*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC0; 489*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC1; 490*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC2; 491*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC3; 492*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC4; 493*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC5; 494*5c49fd3aSAlan Cox uint32_t saveOVC_OVADD; 495*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC0; 496*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC1; 497*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC2; 498*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC3; 499*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC4; 500*5c49fd3aSAlan Cox uint32_t saveOVC_OGAMC5; 501*5c49fd3aSAlan Cox 502*5c49fd3aSAlan Cox /* MSI reg save */ 503*5c49fd3aSAlan Cox uint32_t msi_addr; 504*5c49fd3aSAlan Cox uint32_t msi_data; 505*5c49fd3aSAlan Cox 506*5c49fd3aSAlan Cox /* Medfield specific register save state */ 507*5c49fd3aSAlan Cox uint32_t saveHDMIPHYMISCCTL; 508*5c49fd3aSAlan Cox uint32_t saveHDMIB_CONTROL; 509*5c49fd3aSAlan Cox uint32_t saveDSPCCNTR; 510*5c49fd3aSAlan Cox uint32_t savePIPECCONF; 511*5c49fd3aSAlan Cox uint32_t savePIPECSRC; 512*5c49fd3aSAlan Cox uint32_t saveHTOTAL_C; 513*5c49fd3aSAlan Cox uint32_t saveHBLANK_C; 514*5c49fd3aSAlan Cox uint32_t saveHSYNC_C; 515*5c49fd3aSAlan Cox uint32_t saveVTOTAL_C; 516*5c49fd3aSAlan Cox uint32_t saveVBLANK_C; 517*5c49fd3aSAlan Cox uint32_t saveVSYNC_C; 518*5c49fd3aSAlan Cox uint32_t saveDSPCSTRIDE; 519*5c49fd3aSAlan Cox uint32_t saveDSPCSIZE; 520*5c49fd3aSAlan Cox uint32_t saveDSPCPOS; 521*5c49fd3aSAlan Cox uint32_t saveDSPCSURF; 522*5c49fd3aSAlan Cox uint32_t saveDSPCSTATUS; 523*5c49fd3aSAlan Cox uint32_t saveDSPCLINOFF; 524*5c49fd3aSAlan Cox uint32_t saveDSPCTILEOFF; 525*5c49fd3aSAlan Cox uint32_t saveDSPCCURSOR_CTRL; 526*5c49fd3aSAlan Cox uint32_t saveDSPCCURSOR_BASE; 527*5c49fd3aSAlan Cox uint32_t saveDSPCCURSOR_POS; 528*5c49fd3aSAlan Cox uint32_t save_palette_c[256]; 529*5c49fd3aSAlan Cox uint32_t saveOV_OVADD_C; 530*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC0_C; 531*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC1_C; 532*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC2_C; 533*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC3_C; 534*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC4_C; 535*5c49fd3aSAlan Cox uint32_t saveOV_OGAMC5_C; 536*5c49fd3aSAlan Cox 537*5c49fd3aSAlan Cox /* DSI register save */ 538*5c49fd3aSAlan Cox uint32_t saveDEVICE_READY_REG; 539*5c49fd3aSAlan Cox uint32_t saveINTR_EN_REG; 540*5c49fd3aSAlan Cox uint32_t saveDSI_FUNC_PRG_REG; 541*5c49fd3aSAlan Cox uint32_t saveHS_TX_TIMEOUT_REG; 542*5c49fd3aSAlan Cox uint32_t saveLP_RX_TIMEOUT_REG; 543*5c49fd3aSAlan Cox uint32_t saveTURN_AROUND_TIMEOUT_REG; 544*5c49fd3aSAlan Cox uint32_t saveDEVICE_RESET_REG; 545*5c49fd3aSAlan Cox uint32_t saveDPI_RESOLUTION_REG; 546*5c49fd3aSAlan Cox uint32_t saveHORIZ_SYNC_PAD_COUNT_REG; 547*5c49fd3aSAlan Cox uint32_t saveHORIZ_BACK_PORCH_COUNT_REG; 548*5c49fd3aSAlan Cox uint32_t saveHORIZ_FRONT_PORCH_COUNT_REG; 549*5c49fd3aSAlan Cox uint32_t saveHORIZ_ACTIVE_AREA_COUNT_REG; 550*5c49fd3aSAlan Cox uint32_t saveVERT_SYNC_PAD_COUNT_REG; 551*5c49fd3aSAlan Cox uint32_t saveVERT_BACK_PORCH_COUNT_REG; 552*5c49fd3aSAlan Cox uint32_t saveVERT_FRONT_PORCH_COUNT_REG; 553*5c49fd3aSAlan Cox uint32_t saveHIGH_LOW_SWITCH_COUNT_REG; 554*5c49fd3aSAlan Cox uint32_t saveINIT_COUNT_REG; 555*5c49fd3aSAlan Cox uint32_t saveMAX_RET_PAK_REG; 556*5c49fd3aSAlan Cox uint32_t saveVIDEO_FMT_REG; 557*5c49fd3aSAlan Cox uint32_t saveEOT_DISABLE_REG; 558*5c49fd3aSAlan Cox uint32_t saveLP_BYTECLK_REG; 559*5c49fd3aSAlan Cox uint32_t saveHS_LS_DBI_ENABLE_REG; 560*5c49fd3aSAlan Cox uint32_t saveTXCLKESC_REG; 561*5c49fd3aSAlan Cox uint32_t saveDPHY_PARAM_REG; 562*5c49fd3aSAlan Cox uint32_t saveMIPI_CONTROL_REG; 563*5c49fd3aSAlan Cox uint32_t saveMIPI; 564*5c49fd3aSAlan Cox uint32_t saveMIPI_C; 565*5c49fd3aSAlan Cox 566*5c49fd3aSAlan Cox /* DPST register save */ 567*5c49fd3aSAlan Cox uint32_t saveHISTOGRAM_INT_CONTROL_REG; 568*5c49fd3aSAlan Cox uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG; 569*5c49fd3aSAlan Cox uint32_t savePWM_CONTROL_LOGIC; 570*5c49fd3aSAlan Cox 571*5c49fd3aSAlan Cox /* 572*5c49fd3aSAlan Cox * DSI info. 573*5c49fd3aSAlan Cox */ 574*5c49fd3aSAlan Cox void * dbi_dsr_info; 575*5c49fd3aSAlan Cox void * dbi_dpu_info; 576*5c49fd3aSAlan Cox void * dsi_configs[2]; 577*5c49fd3aSAlan Cox /* 578*5c49fd3aSAlan Cox * LID-Switch 579*5c49fd3aSAlan Cox */ 580*5c49fd3aSAlan Cox spinlock_t lid_lock; 581*5c49fd3aSAlan Cox struct timer_list lid_timer; 582*5c49fd3aSAlan Cox struct psb_intel_opregion opregion; 583*5c49fd3aSAlan Cox u32 *lid_state; 584*5c49fd3aSAlan Cox u32 lid_last_state; 585*5c49fd3aSAlan Cox 586*5c49fd3aSAlan Cox /* 587*5c49fd3aSAlan Cox * Watchdog 588*5c49fd3aSAlan Cox */ 589*5c49fd3aSAlan Cox 590*5c49fd3aSAlan Cox uint32_t apm_reg; 591*5c49fd3aSAlan Cox uint16_t apm_base; 592*5c49fd3aSAlan Cox 593*5c49fd3aSAlan Cox /* 594*5c49fd3aSAlan Cox * Used for modifying backlight from 595*5c49fd3aSAlan Cox * xrandr -- consider removing and using HAL instead 596*5c49fd3aSAlan Cox */ 597*5c49fd3aSAlan Cox struct backlight_device *backlight_device; 598*5c49fd3aSAlan Cox struct drm_property *backlight_property; 599*5c49fd3aSAlan Cox uint32_t blc_adj1; 600*5c49fd3aSAlan Cox uint32_t blc_adj2; 601*5c49fd3aSAlan Cox 602*5c49fd3aSAlan Cox void *fbdev; 603*5c49fd3aSAlan Cox 604*5c49fd3aSAlan Cox /* 2D acceleration */ 605*5c49fd3aSAlan Cox struct mutex mutex_2d; 606*5c49fd3aSAlan Cox }; 607*5c49fd3aSAlan Cox 608*5c49fd3aSAlan Cox 609*5c49fd3aSAlan Cox /* 610*5c49fd3aSAlan Cox * Operations for each board type 611*5c49fd3aSAlan Cox */ 612*5c49fd3aSAlan Cox 613*5c49fd3aSAlan Cox struct psb_ops { 614*5c49fd3aSAlan Cox const char *name; 615*5c49fd3aSAlan Cox unsigned int accel_2d:1; 616*5c49fd3aSAlan Cox int pipes; /* Number of output pipes */ 617*5c49fd3aSAlan Cox int crtcs; /* Number of CRTCs */ 618*5c49fd3aSAlan Cox int sgx_offset; /* Base offset of SGX device */ 619*5c49fd3aSAlan Cox 620*5c49fd3aSAlan Cox /* Sub functions */ 621*5c49fd3aSAlan Cox struct drm_crtc_helper_funcs const *crtc_helper; 622*5c49fd3aSAlan Cox struct drm_crtc_funcs const *crtc_funcs; 623*5c49fd3aSAlan Cox 624*5c49fd3aSAlan Cox /* Setup hooks */ 625*5c49fd3aSAlan Cox int (*chip_setup)(struct drm_device *dev); 626*5c49fd3aSAlan Cox void (*chip_teardown)(struct drm_device *dev); 627*5c49fd3aSAlan Cox 628*5c49fd3aSAlan Cox /* Display management hooks */ 629*5c49fd3aSAlan Cox int (*output_init)(struct drm_device *dev); 630*5c49fd3aSAlan Cox /* Power management hooks */ 631*5c49fd3aSAlan Cox void (*init_pm)(struct drm_device *dev); 632*5c49fd3aSAlan Cox int (*save_regs)(struct drm_device *dev); 633*5c49fd3aSAlan Cox int (*restore_regs)(struct drm_device *dev); 634*5c49fd3aSAlan Cox int (*power_up)(struct drm_device *dev); 635*5c49fd3aSAlan Cox int (*power_down)(struct drm_device *dev); 636*5c49fd3aSAlan Cox 637*5c49fd3aSAlan Cox void (*lvds_bl_power)(struct drm_device *dev, bool on); 638*5c49fd3aSAlan Cox #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE 639*5c49fd3aSAlan Cox /* Backlight */ 640*5c49fd3aSAlan Cox int (*backlight_init)(struct drm_device *dev); 641*5c49fd3aSAlan Cox #endif 642*5c49fd3aSAlan Cox int i2c_bus; /* I2C bus identifier for Moorestown */ 643*5c49fd3aSAlan Cox }; 644*5c49fd3aSAlan Cox 645*5c49fd3aSAlan Cox 646*5c49fd3aSAlan Cox 647*5c49fd3aSAlan Cox struct psb_mmu_driver; 648*5c49fd3aSAlan Cox 649*5c49fd3aSAlan Cox extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int); 650*5c49fd3aSAlan Cox extern int drm_pick_crtcs(struct drm_device *dev); 651*5c49fd3aSAlan Cox 652*5c49fd3aSAlan Cox static inline struct drm_psb_private *psb_priv(struct drm_device *dev) 653*5c49fd3aSAlan Cox { 654*5c49fd3aSAlan Cox return (struct drm_psb_private *) dev->dev_private; 655*5c49fd3aSAlan Cox } 656*5c49fd3aSAlan Cox 657*5c49fd3aSAlan Cox /* 658*5c49fd3aSAlan Cox * MMU stuff. 659*5c49fd3aSAlan Cox */ 660*5c49fd3aSAlan Cox 661*5c49fd3aSAlan Cox extern struct psb_mmu_driver *psb_mmu_driver_init(uint8_t __iomem * registers, 662*5c49fd3aSAlan Cox int trap_pagefaults, 663*5c49fd3aSAlan Cox int invalid_type, 664*5c49fd3aSAlan Cox struct drm_psb_private *dev_priv); 665*5c49fd3aSAlan Cox extern void psb_mmu_driver_takedown(struct psb_mmu_driver *driver); 666*5c49fd3aSAlan Cox extern struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver 667*5c49fd3aSAlan Cox *driver); 668*5c49fd3aSAlan Cox extern void psb_mmu_mirror_gtt(struct psb_mmu_pd *pd, uint32_t mmu_offset, 669*5c49fd3aSAlan Cox uint32_t gtt_start, uint32_t gtt_pages); 670*5c49fd3aSAlan Cox extern struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver, 671*5c49fd3aSAlan Cox int trap_pagefaults, 672*5c49fd3aSAlan Cox int invalid_type); 673*5c49fd3aSAlan Cox extern void psb_mmu_free_pagedir(struct psb_mmu_pd *pd); 674*5c49fd3aSAlan Cox extern void psb_mmu_flush(struct psb_mmu_driver *driver, int rc_prot); 675*5c49fd3aSAlan Cox extern void psb_mmu_remove_pfn_sequence(struct psb_mmu_pd *pd, 676*5c49fd3aSAlan Cox unsigned long address, 677*5c49fd3aSAlan Cox uint32_t num_pages); 678*5c49fd3aSAlan Cox extern int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd, 679*5c49fd3aSAlan Cox uint32_t start_pfn, 680*5c49fd3aSAlan Cox unsigned long address, 681*5c49fd3aSAlan Cox uint32_t num_pages, int type); 682*5c49fd3aSAlan Cox extern int psb_mmu_virtual_to_pfn(struct psb_mmu_pd *pd, uint32_t virtual, 683*5c49fd3aSAlan Cox unsigned long *pfn); 684*5c49fd3aSAlan Cox 685*5c49fd3aSAlan Cox /* 686*5c49fd3aSAlan Cox * Enable / disable MMU for different requestors. 687*5c49fd3aSAlan Cox */ 688*5c49fd3aSAlan Cox 689*5c49fd3aSAlan Cox 690*5c49fd3aSAlan Cox extern void psb_mmu_set_pd_context(struct psb_mmu_pd *pd, int hw_context); 691*5c49fd3aSAlan Cox extern int psb_mmu_insert_pages(struct psb_mmu_pd *pd, struct page **pages, 692*5c49fd3aSAlan Cox unsigned long address, uint32_t num_pages, 693*5c49fd3aSAlan Cox uint32_t desired_tile_stride, 694*5c49fd3aSAlan Cox uint32_t hw_tile_stride, int type); 695*5c49fd3aSAlan Cox extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd, 696*5c49fd3aSAlan Cox unsigned long address, uint32_t num_pages, 697*5c49fd3aSAlan Cox uint32_t desired_tile_stride, 698*5c49fd3aSAlan Cox uint32_t hw_tile_stride); 699*5c49fd3aSAlan Cox /* 700*5c49fd3aSAlan Cox *psb_irq.c 701*5c49fd3aSAlan Cox */ 702*5c49fd3aSAlan Cox 703*5c49fd3aSAlan Cox extern irqreturn_t psb_irq_handler(DRM_IRQ_ARGS); 704*5c49fd3aSAlan Cox extern int psb_irq_enable_dpst(struct drm_device *dev); 705*5c49fd3aSAlan Cox extern int psb_irq_disable_dpst(struct drm_device *dev); 706*5c49fd3aSAlan Cox extern void psb_irq_preinstall(struct drm_device *dev); 707*5c49fd3aSAlan Cox extern int psb_irq_postinstall(struct drm_device *dev); 708*5c49fd3aSAlan Cox extern void psb_irq_uninstall(struct drm_device *dev); 709*5c49fd3aSAlan Cox extern void psb_irq_turn_on_dpst(struct drm_device *dev); 710*5c49fd3aSAlan Cox extern void psb_irq_turn_off_dpst(struct drm_device *dev); 711*5c49fd3aSAlan Cox 712*5c49fd3aSAlan Cox extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands); 713*5c49fd3aSAlan Cox extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence); 714*5c49fd3aSAlan Cox extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence); 715*5c49fd3aSAlan Cox extern int psb_enable_vblank(struct drm_device *dev, int crtc); 716*5c49fd3aSAlan Cox extern void psb_disable_vblank(struct drm_device *dev, int crtc); 717*5c49fd3aSAlan Cox void 718*5c49fd3aSAlan Cox psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask); 719*5c49fd3aSAlan Cox 720*5c49fd3aSAlan Cox void 721*5c49fd3aSAlan Cox psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask); 722*5c49fd3aSAlan Cox 723*5c49fd3aSAlan Cox extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc); 724*5c49fd3aSAlan Cox 725*5c49fd3aSAlan Cox /* 726*5c49fd3aSAlan Cox * intel_opregion.c 727*5c49fd3aSAlan Cox */ 728*5c49fd3aSAlan Cox extern int gma_intel_opregion_init(struct drm_device *dev); 729*5c49fd3aSAlan Cox extern int gma_intel_opregion_exit(struct drm_device *dev); 730*5c49fd3aSAlan Cox 731*5c49fd3aSAlan Cox /* 732*5c49fd3aSAlan Cox * framebuffer.c 733*5c49fd3aSAlan Cox */ 734*5c49fd3aSAlan Cox extern int psbfb_probed(struct drm_device *dev); 735*5c49fd3aSAlan Cox extern int psbfb_remove(struct drm_device *dev, 736*5c49fd3aSAlan Cox struct drm_framebuffer *fb); 737*5c49fd3aSAlan Cox /* 738*5c49fd3aSAlan Cox * accel_2d.c 739*5c49fd3aSAlan Cox */ 740*5c49fd3aSAlan Cox extern void psbfb_copyarea(struct fb_info *info, 741*5c49fd3aSAlan Cox const struct fb_copyarea *region); 742*5c49fd3aSAlan Cox extern int psbfb_sync(struct fb_info *info); 743*5c49fd3aSAlan Cox extern void psb_spank(struct drm_psb_private *dev_priv); 744*5c49fd3aSAlan Cox 745*5c49fd3aSAlan Cox /* 746*5c49fd3aSAlan Cox * psb_reset.c 747*5c49fd3aSAlan Cox */ 748*5c49fd3aSAlan Cox 749*5c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv); 750*5c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv); 751*5c49fd3aSAlan Cox extern void psb_print_pagefault(struct drm_psb_private *dev_priv); 752*5c49fd3aSAlan Cox 753*5c49fd3aSAlan Cox /* modesetting */ 754*5c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev); 755*5c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev); 756*5c49fd3aSAlan Cox extern int psb_fbdev_init(struct drm_device *dev); 757*5c49fd3aSAlan Cox 758*5c49fd3aSAlan Cox /* backlight.c */ 759*5c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev); 760*5c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev); 761*5c49fd3aSAlan Cox 762*5c49fd3aSAlan Cox /* oaktrail_crtc.c */ 763*5c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs; 764*5c49fd3aSAlan Cox 765*5c49fd3aSAlan Cox /* oaktrail_lvds.c */ 766*5c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev, 767*5c49fd3aSAlan Cox struct psb_intel_mode_device *mode_dev); 768*5c49fd3aSAlan Cox 769*5c49fd3aSAlan Cox /* psb_intel_display.c */ 770*5c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs; 771*5c49fd3aSAlan Cox extern const struct drm_crtc_funcs psb_intel_crtc_funcs; 772*5c49fd3aSAlan Cox 773*5c49fd3aSAlan Cox /* psb_intel_lvds.c */ 774*5c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs 775*5c49fd3aSAlan Cox psb_intel_lvds_connector_helper_funcs; 776*5c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs; 777*5c49fd3aSAlan Cox 778*5c49fd3aSAlan Cox /* gem.c */ 779*5c49fd3aSAlan Cox extern int psb_gem_init_object(struct drm_gem_object *obj); 780*5c49fd3aSAlan Cox extern void psb_gem_free_object(struct drm_gem_object *obj); 781*5c49fd3aSAlan Cox extern int psb_gem_get_aperture(struct drm_device *dev, void *data, 782*5c49fd3aSAlan Cox struct drm_file *file); 783*5c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, 784*5c49fd3aSAlan Cox struct drm_mode_create_dumb *args); 785*5c49fd3aSAlan Cox extern int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, 786*5c49fd3aSAlan Cox uint32_t handle); 787*5c49fd3aSAlan Cox extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev, 788*5c49fd3aSAlan Cox uint32_t handle, uint64_t *offset); 789*5c49fd3aSAlan Cox extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 790*5c49fd3aSAlan Cox extern int psb_gem_create_ioctl(struct drm_device *dev, void *data, 791*5c49fd3aSAlan Cox struct drm_file *file); 792*5c49fd3aSAlan Cox extern int psb_gem_mmap_ioctl(struct drm_device *dev, void *data, 793*5c49fd3aSAlan Cox struct drm_file *file); 794*5c49fd3aSAlan Cox 795*5c49fd3aSAlan Cox /* psb_device.c */ 796*5c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops; 797*5c49fd3aSAlan Cox 798*5c49fd3aSAlan Cox /* oaktrail_device.c */ 799*5c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops; 800*5c49fd3aSAlan Cox 801*5c49fd3aSAlan Cox /* cdv_device.c */ 802*5c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops; 803*5c49fd3aSAlan Cox 804*5c49fd3aSAlan Cox /* 805*5c49fd3aSAlan Cox * Debug print bits setting 806*5c49fd3aSAlan Cox */ 807*5c49fd3aSAlan Cox #define PSB_D_GENERAL (1 << 0) 808*5c49fd3aSAlan Cox #define PSB_D_INIT (1 << 1) 809*5c49fd3aSAlan Cox #define PSB_D_IRQ (1 << 2) 810*5c49fd3aSAlan Cox #define PSB_D_ENTRY (1 << 3) 811*5c49fd3aSAlan Cox /* debug the get H/V BP/FP count */ 812*5c49fd3aSAlan Cox #define PSB_D_HV (1 << 4) 813*5c49fd3aSAlan Cox #define PSB_D_DBI_BF (1 << 5) 814*5c49fd3aSAlan Cox #define PSB_D_PM (1 << 6) 815*5c49fd3aSAlan Cox #define PSB_D_RENDER (1 << 7) 816*5c49fd3aSAlan Cox #define PSB_D_REG (1 << 8) 817*5c49fd3aSAlan Cox #define PSB_D_MSVDX (1 << 9) 818*5c49fd3aSAlan Cox #define PSB_D_TOPAZ (1 << 10) 819*5c49fd3aSAlan Cox 820*5c49fd3aSAlan Cox extern int drm_psb_no_fb; 821*5c49fd3aSAlan Cox extern int drm_idle_check_interval; 822*5c49fd3aSAlan Cox 823*5c49fd3aSAlan Cox /* 824*5c49fd3aSAlan Cox * Utilities 825*5c49fd3aSAlan Cox */ 826*5c49fd3aSAlan Cox 827*5c49fd3aSAlan Cox static inline u32 MRST_MSG_READ32(uint port, uint offset) 828*5c49fd3aSAlan Cox { 829*5c49fd3aSAlan Cox int mcr = (0xD0<<24) | (port << 16) | (offset << 8); 830*5c49fd3aSAlan Cox uint32_t ret_val = 0; 831*5c49fd3aSAlan Cox struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 832*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD0, mcr); 833*5c49fd3aSAlan Cox pci_read_config_dword(pci_root, 0xD4, &ret_val); 834*5c49fd3aSAlan Cox pci_dev_put(pci_root); 835*5c49fd3aSAlan Cox return ret_val; 836*5c49fd3aSAlan Cox } 837*5c49fd3aSAlan Cox static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value) 838*5c49fd3aSAlan Cox { 839*5c49fd3aSAlan Cox int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0; 840*5c49fd3aSAlan Cox struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 841*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD4, value); 842*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD0, mcr); 843*5c49fd3aSAlan Cox pci_dev_put(pci_root); 844*5c49fd3aSAlan Cox } 845*5c49fd3aSAlan Cox static inline u32 MDFLD_MSG_READ32(uint port, uint offset) 846*5c49fd3aSAlan Cox { 847*5c49fd3aSAlan Cox int mcr = (0x10<<24) | (port << 16) | (offset << 8); 848*5c49fd3aSAlan Cox uint32_t ret_val = 0; 849*5c49fd3aSAlan Cox struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 850*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD0, mcr); 851*5c49fd3aSAlan Cox pci_read_config_dword(pci_root, 0xD4, &ret_val); 852*5c49fd3aSAlan Cox pci_dev_put(pci_root); 853*5c49fd3aSAlan Cox return ret_val; 854*5c49fd3aSAlan Cox } 855*5c49fd3aSAlan Cox static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value) 856*5c49fd3aSAlan Cox { 857*5c49fd3aSAlan Cox int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0; 858*5c49fd3aSAlan Cox struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 859*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD4, value); 860*5c49fd3aSAlan Cox pci_write_config_dword(pci_root, 0xD0, mcr); 861*5c49fd3aSAlan Cox pci_dev_put(pci_root); 862*5c49fd3aSAlan Cox } 863*5c49fd3aSAlan Cox 864*5c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg) 865*5c49fd3aSAlan Cox { 866*5c49fd3aSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 867*5c49fd3aSAlan Cox return ioread32(dev_priv->vdc_reg + reg); 868*5c49fd3aSAlan Cox } 869*5c49fd3aSAlan Cox 870*5c49fd3aSAlan Cox #define REG_READ(reg) REGISTER_READ(dev, (reg)) 871*5c49fd3aSAlan Cox 872*5c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg, 873*5c49fd3aSAlan Cox uint32_t val) 874*5c49fd3aSAlan Cox { 875*5c49fd3aSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 876*5c49fd3aSAlan Cox iowrite32((val), dev_priv->vdc_reg + (reg)); 877*5c49fd3aSAlan Cox } 878*5c49fd3aSAlan Cox 879*5c49fd3aSAlan Cox #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val)) 880*5c49fd3aSAlan Cox 881*5c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev, 882*5c49fd3aSAlan Cox uint32_t reg, uint32_t val) 883*5c49fd3aSAlan Cox { 884*5c49fd3aSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 885*5c49fd3aSAlan Cox iowrite16((val), dev_priv->vdc_reg + (reg)); 886*5c49fd3aSAlan Cox } 887*5c49fd3aSAlan Cox 888*5c49fd3aSAlan Cox #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val)) 889*5c49fd3aSAlan Cox 890*5c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev, 891*5c49fd3aSAlan Cox uint32_t reg, uint32_t val) 892*5c49fd3aSAlan Cox { 893*5c49fd3aSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 894*5c49fd3aSAlan Cox iowrite8((val), dev_priv->vdc_reg + (reg)); 895*5c49fd3aSAlan Cox } 896*5c49fd3aSAlan Cox 897*5c49fd3aSAlan Cox #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val)) 898*5c49fd3aSAlan Cox 899*5c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs)) 900*5c49fd3aSAlan Cox #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs)) 901*5c49fd3aSAlan Cox 902*5c49fd3aSAlan Cox /* #define TRAP_SGX_PM_FAULT 1 */ 903*5c49fd3aSAlan Cox #ifdef TRAP_SGX_PM_FAULT 904*5c49fd3aSAlan Cox #define PSB_RSGX32(_offs) \ 905*5c49fd3aSAlan Cox ({ \ 906*5c49fd3aSAlan Cox if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) { \ 907*5c49fd3aSAlan Cox printk(KERN_ERR \ 908*5c49fd3aSAlan Cox "access sgx when it's off!! (READ) %s, %d\n", \ 909*5c49fd3aSAlan Cox __FILE__, __LINE__); \ 910*5c49fd3aSAlan Cox melay(1000); \ 911*5c49fd3aSAlan Cox } \ 912*5c49fd3aSAlan Cox ioread32(dev_priv->sgx_reg + (_offs)); \ 913*5c49fd3aSAlan Cox }) 914*5c49fd3aSAlan Cox #else 915*5c49fd3aSAlan Cox #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs)) 916*5c49fd3aSAlan Cox #endif 917*5c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs)) 918*5c49fd3aSAlan Cox 919*5c49fd3aSAlan Cox #define MSVDX_REG_DUMP 0 920*5c49fd3aSAlan Cox 921*5c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs)) 922*5c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs)) 923*5c49fd3aSAlan Cox 924*5c49fd3aSAlan Cox #endif 925