18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/************************************************************************** 38c2ecf20Sopenharmony_ci * Copyright (c) 2007-2011, Intel Corporation. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci **************************************************************************/ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _PSB_DRV_H_ 98c2ecf20Sopenharmony_ci#define _PSB_DRV_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/kref.h> 128c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "gma_display.h" 178c2ecf20Sopenharmony_ci#include "gtt.h" 188c2ecf20Sopenharmony_ci#include "intel_bios.h" 198c2ecf20Sopenharmony_ci#include "mmu.h" 208c2ecf20Sopenharmony_ci#include "oaktrail.h" 218c2ecf20Sopenharmony_ci#include "opregion.h" 228c2ecf20Sopenharmony_ci#include "power.h" 238c2ecf20Sopenharmony_ci#include "psb_intel_drv.h" 248c2ecf20Sopenharmony_ci#include "psb_reg.h" 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define DRIVER_NAME "gma500" 298c2ecf20Sopenharmony_ci#define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650" 308c2ecf20Sopenharmony_ci#define DRIVER_DATE "20140314" 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define DRIVER_MAJOR 1 338c2ecf20Sopenharmony_ci#define DRIVER_MINOR 0 348c2ecf20Sopenharmony_ci#define DRIVER_PATCHLEVEL 0 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Append new drm mode definition here, align with libdrm definition */ 378c2ecf20Sopenharmony_ci#define DRM_MODE_SCALE_NO_SCALE 2 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cienum { 408c2ecf20Sopenharmony_ci CHIP_PSB_8108 = 0, /* Poulsbo */ 418c2ecf20Sopenharmony_ci CHIP_PSB_8109 = 1, /* Poulsbo */ 428c2ecf20Sopenharmony_ci CHIP_MRST_4100 = 2, /* Moorestown/Oaktrail */ 438c2ecf20Sopenharmony_ci CHIP_MFLD_0130 = 3, /* Medfield */ 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define IS_PSB(dev) (((dev)->pdev->device & 0xfffe) == 0x8108) 478c2ecf20Sopenharmony_ci#define IS_MRST(dev) (((dev)->pdev->device & 0xfff0) == 0x4100) 488c2ecf20Sopenharmony_ci#define IS_MFLD(dev) (((dev)->pdev->device & 0xfff8) == 0x0130) 498c2ecf20Sopenharmony_ci#define IS_CDV(dev) (((dev)->pdev->device & 0xfff0) == 0x0be0) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Hardware offsets */ 528c2ecf20Sopenharmony_ci#define PSB_VDC_OFFSET 0x00000000 538c2ecf20Sopenharmony_ci#define PSB_VDC_SIZE 0x000080000 548c2ecf20Sopenharmony_ci#define MRST_MMIO_SIZE 0x0000C0000 558c2ecf20Sopenharmony_ci#define MDFLD_MMIO_SIZE 0x000100000 568c2ecf20Sopenharmony_ci#define PSB_SGX_SIZE 0x8000 578c2ecf20Sopenharmony_ci#define PSB_SGX_OFFSET 0x00040000 588c2ecf20Sopenharmony_ci#define MRST_SGX_OFFSET 0x00080000 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* PCI resource identifiers */ 618c2ecf20Sopenharmony_ci#define PSB_MMIO_RESOURCE 0 628c2ecf20Sopenharmony_ci#define PSB_AUX_RESOURCE 0 638c2ecf20Sopenharmony_ci#define PSB_GATT_RESOURCE 2 648c2ecf20Sopenharmony_ci#define PSB_GTT_RESOURCE 3 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* PCI configuration */ 678c2ecf20Sopenharmony_ci#define PSB_GMCH_CTRL 0x52 688c2ecf20Sopenharmony_ci#define PSB_BSM 0x5C 698c2ecf20Sopenharmony_ci#define _PSB_GMCH_ENABLED 0x4 708c2ecf20Sopenharmony_ci#define PSB_PGETBL_CTL 0x2020 718c2ecf20Sopenharmony_ci#define _PSB_PGETBL_ENABLED 0x00000001 728c2ecf20Sopenharmony_ci#define PSB_SGX_2D_SLAVE_PORT 0x4000 738c2ecf20Sopenharmony_ci#define PSB_LPC_GBA 0x44 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* TODO: To get rid of */ 768c2ecf20Sopenharmony_ci#define PSB_TT_PRIV0_LIMIT (256*1024*1024) 778c2ecf20Sopenharmony_ci#define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* SGX side MMU definitions (these can probably go) */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* Flags for external memory type field */ 828c2ecf20Sopenharmony_ci#define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */ 838c2ecf20Sopenharmony_ci#define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */ 848c2ecf20Sopenharmony_ci#define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */ 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* PTE's and PDE's */ 878c2ecf20Sopenharmony_ci#define PSB_PDE_MASK 0x003FFFFF 888c2ecf20Sopenharmony_ci#define PSB_PDE_SHIFT 22 898c2ecf20Sopenharmony_ci#define PSB_PTE_SHIFT 12 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Cache control */ 928c2ecf20Sopenharmony_ci#define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */ 938c2ecf20Sopenharmony_ci#define PSB_PTE_WO 0x0002 /* Write only */ 948c2ecf20Sopenharmony_ci#define PSB_PTE_RO 0x0004 /* Read only */ 958c2ecf20Sopenharmony_ci#define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */ 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* VDC registers and bits */ 988c2ecf20Sopenharmony_ci#define PSB_MSVDX_CLOCKGATING 0x2064 998c2ecf20Sopenharmony_ci#define PSB_TOPAZ_CLOCKGATING 0x2068 1008c2ecf20Sopenharmony_ci#define PSB_HWSTAM 0x2098 1018c2ecf20Sopenharmony_ci#define PSB_INSTPM 0x20C0 1028c2ecf20Sopenharmony_ci#define PSB_INT_IDENTITY_R 0x20A4 1038c2ecf20Sopenharmony_ci#define _PSB_IRQ_ASLE (1<<0) 1048c2ecf20Sopenharmony_ci#define _MDFLD_PIPEC_EVENT_FLAG (1<<2) 1058c2ecf20Sopenharmony_ci#define _MDFLD_PIPEC_VBLANK_FLAG (1<<3) 1068c2ecf20Sopenharmony_ci#define _PSB_DPST_PIPEB_FLAG (1<<4) 1078c2ecf20Sopenharmony_ci#define _MDFLD_PIPEB_EVENT_FLAG (1<<4) 1088c2ecf20Sopenharmony_ci#define _PSB_VSYNC_PIPEB_FLAG (1<<5) 1098c2ecf20Sopenharmony_ci#define _PSB_DPST_PIPEA_FLAG (1<<6) 1108c2ecf20Sopenharmony_ci#define _PSB_PIPEA_EVENT_FLAG (1<<6) 1118c2ecf20Sopenharmony_ci#define _PSB_VSYNC_PIPEA_FLAG (1<<7) 1128c2ecf20Sopenharmony_ci#define _MDFLD_MIPIA_FLAG (1<<16) 1138c2ecf20Sopenharmony_ci#define _MDFLD_MIPIC_FLAG (1<<17) 1148c2ecf20Sopenharmony_ci#define _PSB_IRQ_DISP_HOTSYNC (1<<17) 1158c2ecf20Sopenharmony_ci#define _PSB_IRQ_SGX_FLAG (1<<18) 1168c2ecf20Sopenharmony_ci#define _PSB_IRQ_MSVDX_FLAG (1<<19) 1178c2ecf20Sopenharmony_ci#define _LNC_IRQ_TOPAZ_FLAG (1<<20) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \ 1208c2ecf20Sopenharmony_ci _PSB_VSYNC_PIPEB_FLAG) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* This flag includes all the display IRQ bits excepts the vblank irqs. */ 1238c2ecf20Sopenharmony_ci#define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \ 1248c2ecf20Sopenharmony_ci _MDFLD_PIPEB_EVENT_FLAG | \ 1258c2ecf20Sopenharmony_ci _PSB_PIPEA_EVENT_FLAG | \ 1268c2ecf20Sopenharmony_ci _PSB_VSYNC_PIPEA_FLAG | \ 1278c2ecf20Sopenharmony_ci _MDFLD_MIPIA_FLAG | \ 1288c2ecf20Sopenharmony_ci _MDFLD_MIPIC_FLAG) 1298c2ecf20Sopenharmony_ci#define PSB_INT_IDENTITY_R 0x20A4 1308c2ecf20Sopenharmony_ci#define PSB_INT_MASK_R 0x20A8 1318c2ecf20Sopenharmony_ci#define PSB_INT_ENABLE_R 0x20A0 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define _PSB_MMU_ER_MASK 0x0001FF00 1348c2ecf20Sopenharmony_ci#define _PSB_MMU_ER_HOST (1 << 16) 1358c2ecf20Sopenharmony_ci#define GPIOA 0x5010 1368c2ecf20Sopenharmony_ci#define GPIOB 0x5014 1378c2ecf20Sopenharmony_ci#define GPIOC 0x5018 1388c2ecf20Sopenharmony_ci#define GPIOD 0x501c 1398c2ecf20Sopenharmony_ci#define GPIOE 0x5020 1408c2ecf20Sopenharmony_ci#define GPIOF 0x5024 1418c2ecf20Sopenharmony_ci#define GPIOG 0x5028 1428c2ecf20Sopenharmony_ci#define GPIOH 0x502c 1438c2ecf20Sopenharmony_ci#define GPIO_CLOCK_DIR_MASK (1 << 0) 1448c2ecf20Sopenharmony_ci#define GPIO_CLOCK_DIR_IN (0 << 1) 1458c2ecf20Sopenharmony_ci#define GPIO_CLOCK_DIR_OUT (1 << 1) 1468c2ecf20Sopenharmony_ci#define GPIO_CLOCK_VAL_MASK (1 << 2) 1478c2ecf20Sopenharmony_ci#define GPIO_CLOCK_VAL_OUT (1 << 3) 1488c2ecf20Sopenharmony_ci#define GPIO_CLOCK_VAL_IN (1 << 4) 1498c2ecf20Sopenharmony_ci#define GPIO_CLOCK_PULLUP_DISABLE (1 << 5) 1508c2ecf20Sopenharmony_ci#define GPIO_DATA_DIR_MASK (1 << 8) 1518c2ecf20Sopenharmony_ci#define GPIO_DATA_DIR_IN (0 << 9) 1528c2ecf20Sopenharmony_ci#define GPIO_DATA_DIR_OUT (1 << 9) 1538c2ecf20Sopenharmony_ci#define GPIO_DATA_VAL_MASK (1 << 10) 1548c2ecf20Sopenharmony_ci#define GPIO_DATA_VAL_OUT (1 << 11) 1558c2ecf20Sopenharmony_ci#define GPIO_DATA_VAL_IN (1 << 12) 1568c2ecf20Sopenharmony_ci#define GPIO_DATA_PULLUP_DISABLE (1 << 13) 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci#define VCLK_DIVISOR_VGA0 0x6000 1598c2ecf20Sopenharmony_ci#define VCLK_DIVISOR_VGA1 0x6004 1608c2ecf20Sopenharmony_ci#define VCLK_POST_DIV 0x6010 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define PSB_COMM_2D (PSB_ENGINE_2D << 4) 1638c2ecf20Sopenharmony_ci#define PSB_COMM_3D (PSB_ENGINE_3D << 4) 1648c2ecf20Sopenharmony_ci#define PSB_COMM_TA (PSB_ENGINE_TA << 4) 1658c2ecf20Sopenharmony_ci#define PSB_COMM_HP (PSB_ENGINE_HP << 4) 1668c2ecf20Sopenharmony_ci#define PSB_COMM_USER_IRQ (1024 >> 2) 1678c2ecf20Sopenharmony_ci#define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1) 1688c2ecf20Sopenharmony_ci#define PSB_COMM_FW (2048 >> 2) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define PSB_UIRQ_VISTEST 1 1718c2ecf20Sopenharmony_ci#define PSB_UIRQ_OOM_REPLY 2 1728c2ecf20Sopenharmony_ci#define PSB_UIRQ_FIRE_TA_REPLY 3 1738c2ecf20Sopenharmony_ci#define PSB_UIRQ_FIRE_RASTER_REPLY 4 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci#define PSB_2D_SIZE (256*1024*1024) 1768c2ecf20Sopenharmony_ci#define PSB_MAX_RELOC_PAGES 1024 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#define PSB_LOW_REG_OFFS 0x0204 1798c2ecf20Sopenharmony_ci#define PSB_HIGH_REG_OFFS 0x0600 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci#define PSB_NUM_VBLANKS 2 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci#define PSB_2D_SIZE (256*1024*1024) 1858c2ecf20Sopenharmony_ci#define PSB_MAX_RELOC_PAGES 1024 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#define PSB_LOW_REG_OFFS 0x0204 1888c2ecf20Sopenharmony_ci#define PSB_HIGH_REG_OFFS 0x0600 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci#define PSB_NUM_VBLANKS 2 1918c2ecf20Sopenharmony_ci#define PSB_WATCHDOG_DELAY (HZ * 2) 1928c2ecf20Sopenharmony_ci#define PSB_LID_DELAY (HZ / 10) 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci#define MDFLD_PNW_B0 0x04 1958c2ecf20Sopenharmony_ci#define MDFLD_PNW_C0 0x08 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci#define MDFLD_DSR_2D_3D_0 (1 << 0) 1988c2ecf20Sopenharmony_ci#define MDFLD_DSR_2D_3D_2 (1 << 1) 1998c2ecf20Sopenharmony_ci#define MDFLD_DSR_CURSOR_0 (1 << 2) 2008c2ecf20Sopenharmony_ci#define MDFLD_DSR_CURSOR_2 (1 << 3) 2018c2ecf20Sopenharmony_ci#define MDFLD_DSR_OVERLAY_0 (1 << 4) 2028c2ecf20Sopenharmony_ci#define MDFLD_DSR_OVERLAY_2 (1 << 5) 2038c2ecf20Sopenharmony_ci#define MDFLD_DSR_MIPI_CONTROL (1 << 6) 2048c2ecf20Sopenharmony_ci#define MDFLD_DSR_DAMAGE_MASK_0 ((1 << 0) | (1 << 2) | (1 << 4)) 2058c2ecf20Sopenharmony_ci#define MDFLD_DSR_DAMAGE_MASK_2 ((1 << 1) | (1 << 3) | (1 << 5)) 2068c2ecf20Sopenharmony_ci#define MDFLD_DSR_2D_3D (MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2) 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci#define MDFLD_DSR_RR 45 2098c2ecf20Sopenharmony_ci#define MDFLD_DPU_ENABLE (1 << 31) 2108c2ecf20Sopenharmony_ci#define MDFLD_DSR_FULLSCREEN (1 << 30) 2118c2ecf20Sopenharmony_ci#define MDFLD_DSR_DELAY (HZ / MDFLD_DSR_RR) 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define PSB_PWR_STATE_ON 1 2148c2ecf20Sopenharmony_ci#define PSB_PWR_STATE_OFF 2 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define PSB_PMPOLICY_NOPM 0 2178c2ecf20Sopenharmony_ci#define PSB_PMPOLICY_CLOCKGATING 1 2188c2ecf20Sopenharmony_ci#define PSB_PMPOLICY_POWERDOWN 2 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci#define PSB_PMSTATE_POWERUP 0 2218c2ecf20Sopenharmony_ci#define PSB_PMSTATE_CLOCKGATED 1 2228c2ecf20Sopenharmony_ci#define PSB_PMSTATE_POWERDOWN 2 2238c2ecf20Sopenharmony_ci#define PSB_PCIx_MSI_ADDR_LOC 0x94 2248c2ecf20Sopenharmony_ci#define PSB_PCIx_MSI_DATA_LOC 0x98 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* Medfield crystal settings */ 2278c2ecf20Sopenharmony_ci#define KSEL_CRYSTAL_19 1 2288c2ecf20Sopenharmony_ci#define KSEL_BYPASS_19 5 2298c2ecf20Sopenharmony_ci#define KSEL_BYPASS_25 6 2308c2ecf20Sopenharmony_ci#define KSEL_BYPASS_83_100 7 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_cistruct drm_fb_helper; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistruct opregion_header; 2358c2ecf20Sopenharmony_cistruct opregion_acpi; 2368c2ecf20Sopenharmony_cistruct opregion_swsci; 2378c2ecf20Sopenharmony_cistruct opregion_asle; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistruct psb_intel_opregion { 2408c2ecf20Sopenharmony_ci struct opregion_header *header; 2418c2ecf20Sopenharmony_ci struct opregion_acpi *acpi; 2428c2ecf20Sopenharmony_ci struct opregion_swsci *swsci; 2438c2ecf20Sopenharmony_ci struct opregion_asle *asle; 2448c2ecf20Sopenharmony_ci void *vbt; 2458c2ecf20Sopenharmony_ci u32 __iomem *lid_state; 2468c2ecf20Sopenharmony_ci struct work_struct asle_work; 2478c2ecf20Sopenharmony_ci}; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_cistruct sdvo_device_mapping { 2508c2ecf20Sopenharmony_ci u8 initialized; 2518c2ecf20Sopenharmony_ci u8 dvo_port; 2528c2ecf20Sopenharmony_ci u8 slave_addr; 2538c2ecf20Sopenharmony_ci u8 dvo_wiring; 2548c2ecf20Sopenharmony_ci u8 i2c_pin; 2558c2ecf20Sopenharmony_ci u8 i2c_speed; 2568c2ecf20Sopenharmony_ci u8 ddc_pin; 2578c2ecf20Sopenharmony_ci}; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistruct intel_gmbus { 2608c2ecf20Sopenharmony_ci struct i2c_adapter adapter; 2618c2ecf20Sopenharmony_ci struct i2c_adapter *force_bit; 2628c2ecf20Sopenharmony_ci u32 reg0; 2638c2ecf20Sopenharmony_ci}; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* Register offset maps */ 2668c2ecf20Sopenharmony_cistruct psb_offset { 2678c2ecf20Sopenharmony_ci u32 fp0; 2688c2ecf20Sopenharmony_ci u32 fp1; 2698c2ecf20Sopenharmony_ci u32 cntr; 2708c2ecf20Sopenharmony_ci u32 conf; 2718c2ecf20Sopenharmony_ci u32 src; 2728c2ecf20Sopenharmony_ci u32 dpll; 2738c2ecf20Sopenharmony_ci u32 dpll_md; 2748c2ecf20Sopenharmony_ci u32 htotal; 2758c2ecf20Sopenharmony_ci u32 hblank; 2768c2ecf20Sopenharmony_ci u32 hsync; 2778c2ecf20Sopenharmony_ci u32 vtotal; 2788c2ecf20Sopenharmony_ci u32 vblank; 2798c2ecf20Sopenharmony_ci u32 vsync; 2808c2ecf20Sopenharmony_ci u32 stride; 2818c2ecf20Sopenharmony_ci u32 size; 2828c2ecf20Sopenharmony_ci u32 pos; 2838c2ecf20Sopenharmony_ci u32 surf; 2848c2ecf20Sopenharmony_ci u32 addr; 2858c2ecf20Sopenharmony_ci u32 base; 2868c2ecf20Sopenharmony_ci u32 status; 2878c2ecf20Sopenharmony_ci u32 linoff; 2888c2ecf20Sopenharmony_ci u32 tileoff; 2898c2ecf20Sopenharmony_ci u32 palette; 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci/* 2938c2ecf20Sopenharmony_ci * Register save state. This is used to hold the context when the 2948c2ecf20Sopenharmony_ci * device is powered off. In the case of Oaktrail this can (but does not 2958c2ecf20Sopenharmony_ci * yet) include screen blank. Operations occuring during the save 2968c2ecf20Sopenharmony_ci * update the register cache instead. 2978c2ecf20Sopenharmony_ci */ 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci/* Common status for pipes */ 3008c2ecf20Sopenharmony_cistruct psb_pipe { 3018c2ecf20Sopenharmony_ci u32 fp0; 3028c2ecf20Sopenharmony_ci u32 fp1; 3038c2ecf20Sopenharmony_ci u32 cntr; 3048c2ecf20Sopenharmony_ci u32 conf; 3058c2ecf20Sopenharmony_ci u32 src; 3068c2ecf20Sopenharmony_ci u32 dpll; 3078c2ecf20Sopenharmony_ci u32 dpll_md; 3088c2ecf20Sopenharmony_ci u32 htotal; 3098c2ecf20Sopenharmony_ci u32 hblank; 3108c2ecf20Sopenharmony_ci u32 hsync; 3118c2ecf20Sopenharmony_ci u32 vtotal; 3128c2ecf20Sopenharmony_ci u32 vblank; 3138c2ecf20Sopenharmony_ci u32 vsync; 3148c2ecf20Sopenharmony_ci u32 stride; 3158c2ecf20Sopenharmony_ci u32 size; 3168c2ecf20Sopenharmony_ci u32 pos; 3178c2ecf20Sopenharmony_ci u32 base; 3188c2ecf20Sopenharmony_ci u32 surf; 3198c2ecf20Sopenharmony_ci u32 addr; 3208c2ecf20Sopenharmony_ci u32 status; 3218c2ecf20Sopenharmony_ci u32 linoff; 3228c2ecf20Sopenharmony_ci u32 tileoff; 3238c2ecf20Sopenharmony_ci u32 palette[256]; 3248c2ecf20Sopenharmony_ci}; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistruct psb_state { 3278c2ecf20Sopenharmony_ci uint32_t saveVCLK_DIVISOR_VGA0; 3288c2ecf20Sopenharmony_ci uint32_t saveVCLK_DIVISOR_VGA1; 3298c2ecf20Sopenharmony_ci uint32_t saveVCLK_POST_DIV; 3308c2ecf20Sopenharmony_ci uint32_t saveVGACNTRL; 3318c2ecf20Sopenharmony_ci uint32_t saveADPA; 3328c2ecf20Sopenharmony_ci uint32_t saveLVDS; 3338c2ecf20Sopenharmony_ci uint32_t saveDVOA; 3348c2ecf20Sopenharmony_ci uint32_t saveDVOB; 3358c2ecf20Sopenharmony_ci uint32_t saveDVOC; 3368c2ecf20Sopenharmony_ci uint32_t savePP_ON; 3378c2ecf20Sopenharmony_ci uint32_t savePP_OFF; 3388c2ecf20Sopenharmony_ci uint32_t savePP_CONTROL; 3398c2ecf20Sopenharmony_ci uint32_t savePP_CYCLE; 3408c2ecf20Sopenharmony_ci uint32_t savePFIT_CONTROL; 3418c2ecf20Sopenharmony_ci uint32_t saveCLOCKGATING; 3428c2ecf20Sopenharmony_ci uint32_t saveDSPARB; 3438c2ecf20Sopenharmony_ci uint32_t savePFIT_AUTO_RATIOS; 3448c2ecf20Sopenharmony_ci uint32_t savePFIT_PGM_RATIOS; 3458c2ecf20Sopenharmony_ci uint32_t savePP_ON_DELAYS; 3468c2ecf20Sopenharmony_ci uint32_t savePP_OFF_DELAYS; 3478c2ecf20Sopenharmony_ci uint32_t savePP_DIVISOR; 3488c2ecf20Sopenharmony_ci uint32_t saveBCLRPAT_A; 3498c2ecf20Sopenharmony_ci uint32_t saveBCLRPAT_B; 3508c2ecf20Sopenharmony_ci uint32_t savePERF_MODE; 3518c2ecf20Sopenharmony_ci uint32_t saveDSPFW1; 3528c2ecf20Sopenharmony_ci uint32_t saveDSPFW2; 3538c2ecf20Sopenharmony_ci uint32_t saveDSPFW3; 3548c2ecf20Sopenharmony_ci uint32_t saveDSPFW4; 3558c2ecf20Sopenharmony_ci uint32_t saveDSPFW5; 3568c2ecf20Sopenharmony_ci uint32_t saveDSPFW6; 3578c2ecf20Sopenharmony_ci uint32_t saveCHICKENBIT; 3588c2ecf20Sopenharmony_ci uint32_t saveDSPACURSOR_CTRL; 3598c2ecf20Sopenharmony_ci uint32_t saveDSPBCURSOR_CTRL; 3608c2ecf20Sopenharmony_ci uint32_t saveDSPACURSOR_BASE; 3618c2ecf20Sopenharmony_ci uint32_t saveDSPBCURSOR_BASE; 3628c2ecf20Sopenharmony_ci uint32_t saveDSPACURSOR_POS; 3638c2ecf20Sopenharmony_ci uint32_t saveDSPBCURSOR_POS; 3648c2ecf20Sopenharmony_ci uint32_t saveOV_OVADD; 3658c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC0; 3668c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC1; 3678c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC2; 3688c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC3; 3698c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC4; 3708c2ecf20Sopenharmony_ci uint32_t saveOV_OGAMC5; 3718c2ecf20Sopenharmony_ci uint32_t saveOVC_OVADD; 3728c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC0; 3738c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC1; 3748c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC2; 3758c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC3; 3768c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC4; 3778c2ecf20Sopenharmony_ci uint32_t saveOVC_OGAMC5; 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci /* DPST register save */ 3808c2ecf20Sopenharmony_ci uint32_t saveHISTOGRAM_INT_CONTROL_REG; 3818c2ecf20Sopenharmony_ci uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG; 3828c2ecf20Sopenharmony_ci uint32_t savePWM_CONTROL_LOGIC; 3838c2ecf20Sopenharmony_ci}; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_cistruct medfield_state { 3868c2ecf20Sopenharmony_ci uint32_t saveMIPI; 3878c2ecf20Sopenharmony_ci uint32_t saveMIPI_C; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci uint32_t savePFIT_CONTROL; 3908c2ecf20Sopenharmony_ci uint32_t savePFIT_PGM_RATIOS; 3918c2ecf20Sopenharmony_ci uint32_t saveHDMIPHYMISCCTL; 3928c2ecf20Sopenharmony_ci uint32_t saveHDMIB_CONTROL; 3938c2ecf20Sopenharmony_ci}; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistruct cdv_state { 3968c2ecf20Sopenharmony_ci uint32_t saveDSPCLK_GATE_D; 3978c2ecf20Sopenharmony_ci uint32_t saveRAMCLK_GATE_D; 3988c2ecf20Sopenharmony_ci uint32_t saveDSPARB; 3998c2ecf20Sopenharmony_ci uint32_t saveDSPFW[6]; 4008c2ecf20Sopenharmony_ci uint32_t saveADPA; 4018c2ecf20Sopenharmony_ci uint32_t savePP_CONTROL; 4028c2ecf20Sopenharmony_ci uint32_t savePFIT_PGM_RATIOS; 4038c2ecf20Sopenharmony_ci uint32_t saveLVDS; 4048c2ecf20Sopenharmony_ci uint32_t savePFIT_CONTROL; 4058c2ecf20Sopenharmony_ci uint32_t savePP_ON_DELAYS; 4068c2ecf20Sopenharmony_ci uint32_t savePP_OFF_DELAYS; 4078c2ecf20Sopenharmony_ci uint32_t savePP_CYCLE; 4088c2ecf20Sopenharmony_ci uint32_t saveVGACNTRL; 4098c2ecf20Sopenharmony_ci uint32_t saveIER; 4108c2ecf20Sopenharmony_ci uint32_t saveIMR; 4118c2ecf20Sopenharmony_ci u8 saveLBB; 4128c2ecf20Sopenharmony_ci}; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistruct psb_save_area { 4158c2ecf20Sopenharmony_ci struct psb_pipe pipe[3]; 4168c2ecf20Sopenharmony_ci uint32_t saveBSM; 4178c2ecf20Sopenharmony_ci uint32_t saveVBT; 4188c2ecf20Sopenharmony_ci union { 4198c2ecf20Sopenharmony_ci struct psb_state psb; 4208c2ecf20Sopenharmony_ci struct medfield_state mdfld; 4218c2ecf20Sopenharmony_ci struct cdv_state cdv; 4228c2ecf20Sopenharmony_ci }; 4238c2ecf20Sopenharmony_ci uint32_t saveBLC_PWM_CTL2; 4248c2ecf20Sopenharmony_ci uint32_t saveBLC_PWM_CTL; 4258c2ecf20Sopenharmony_ci}; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cistruct psb_ops; 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci#define PSB_NUM_PIPE 3 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_cistruct drm_psb_private { 4328c2ecf20Sopenharmony_ci struct drm_device *dev; 4338c2ecf20Sopenharmony_ci struct pci_dev *aux_pdev; /* Currently only used by mrst */ 4348c2ecf20Sopenharmony_ci struct pci_dev *lpc_pdev; /* Currently only used by mrst */ 4358c2ecf20Sopenharmony_ci const struct psb_ops *ops; 4368c2ecf20Sopenharmony_ci const struct psb_offset *regmap; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci struct child_device_config *child_dev; 4398c2ecf20Sopenharmony_ci int child_dev_num; 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci struct psb_gtt gtt; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci /* GTT Memory manager */ 4448c2ecf20Sopenharmony_ci struct psb_gtt_mm *gtt_mm; 4458c2ecf20Sopenharmony_ci struct page *scratch_page; 4468c2ecf20Sopenharmony_ci u32 __iomem *gtt_map; 4478c2ecf20Sopenharmony_ci uint32_t stolen_base; 4488c2ecf20Sopenharmony_ci u8 __iomem *vram_addr; 4498c2ecf20Sopenharmony_ci unsigned long vram_stolen_size; 4508c2ecf20Sopenharmony_ci int gtt_initialized; 4518c2ecf20Sopenharmony_ci u16 gmch_ctrl; /* Saved GTT setup */ 4528c2ecf20Sopenharmony_ci u32 pge_ctl; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci struct mutex gtt_mutex; 4558c2ecf20Sopenharmony_ci struct resource *gtt_mem; /* Our PCI resource */ 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci struct mutex mmap_mutex; 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci struct psb_mmu_driver *mmu; 4608c2ecf20Sopenharmony_ci struct psb_mmu_pd *pf_pd; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci /* Register base */ 4638c2ecf20Sopenharmony_ci uint8_t __iomem *sgx_reg; 4648c2ecf20Sopenharmony_ci uint8_t __iomem *vdc_reg; 4658c2ecf20Sopenharmony_ci uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */ 4668c2ecf20Sopenharmony_ci uint16_t lpc_gpio_base; 4678c2ecf20Sopenharmony_ci uint32_t gatt_free_offset; 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci /* Fencing / irq */ 4708c2ecf20Sopenharmony_ci uint32_t vdc_irq_mask; 4718c2ecf20Sopenharmony_ci uint32_t pipestat[PSB_NUM_PIPE]; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci spinlock_t irqmask_lock; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci /* Power */ 4768c2ecf20Sopenharmony_ci bool suspended; 4778c2ecf20Sopenharmony_ci bool display_power; 4788c2ecf20Sopenharmony_ci int display_count; 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci /* Modesetting */ 4818c2ecf20Sopenharmony_ci struct psb_intel_mode_device mode_dev; 4828c2ecf20Sopenharmony_ci bool modeset; /* true if we have done the mode_device setup */ 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE]; 4858c2ecf20Sopenharmony_ci struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE]; 4868c2ecf20Sopenharmony_ci uint32_t num_pipe; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci /* OSPM info (Power management base) (TODO: can go ?) */ 4898c2ecf20Sopenharmony_ci uint32_t ospm_base; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci /* Sizes info */ 4928c2ecf20Sopenharmony_ci u32 fuse_reg_value; 4938c2ecf20Sopenharmony_ci u32 video_device_fuse; 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci /* PCI revision ID for B0:D2:F0 */ 4968c2ecf20Sopenharmony_ci uint8_t platform_rev_id; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci /* gmbus */ 4998c2ecf20Sopenharmony_ci struct intel_gmbus *gmbus; 5008c2ecf20Sopenharmony_ci uint8_t __iomem *gmbus_reg; 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci /* Used by SDVO */ 5038c2ecf20Sopenharmony_ci int crt_ddc_pin; 5048c2ecf20Sopenharmony_ci /* FIXME: The mappings should be parsed from bios but for now we can 5058c2ecf20Sopenharmony_ci pretend there are no mappings available */ 5068c2ecf20Sopenharmony_ci struct sdvo_device_mapping sdvo_mappings[2]; 5078c2ecf20Sopenharmony_ci u32 hotplug_supported_mask; 5088c2ecf20Sopenharmony_ci struct drm_property *broadcast_rgb_property; 5098c2ecf20Sopenharmony_ci struct drm_property *force_audio_property; 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci /* LVDS info */ 5128c2ecf20Sopenharmony_ci int backlight_duty_cycle; /* restore backlight to this value */ 5138c2ecf20Sopenharmony_ci bool panel_wants_dither; 5148c2ecf20Sopenharmony_ci struct drm_display_mode *panel_fixed_mode; 5158c2ecf20Sopenharmony_ci struct drm_display_mode *lfp_lvds_vbt_mode; 5168c2ecf20Sopenharmony_ci struct drm_display_mode *sdvo_lvds_vbt_mode; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */ 5198c2ecf20Sopenharmony_ci struct psb_intel_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */ 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci /* Feature bits from the VBIOS */ 5228c2ecf20Sopenharmony_ci unsigned int int_tv_support:1; 5238c2ecf20Sopenharmony_ci unsigned int lvds_dither:1; 5248c2ecf20Sopenharmony_ci unsigned int lvds_vbt:1; 5258c2ecf20Sopenharmony_ci unsigned int int_crt_support:1; 5268c2ecf20Sopenharmony_ci unsigned int lvds_use_ssc:1; 5278c2ecf20Sopenharmony_ci int lvds_ssc_freq; 5288c2ecf20Sopenharmony_ci bool is_lvds_on; 5298c2ecf20Sopenharmony_ci bool is_mipi_on; 5308c2ecf20Sopenharmony_ci bool lvds_enabled_in_vbt; 5318c2ecf20Sopenharmony_ci u32 mipi_ctrl_display; 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci unsigned int core_freq; 5348c2ecf20Sopenharmony_ci uint32_t iLVDS_enable; 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci /* Runtime PM state */ 5378c2ecf20Sopenharmony_ci int rpm_enabled; 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci /* MID specific */ 5408c2ecf20Sopenharmony_ci bool has_gct; 5418c2ecf20Sopenharmony_ci struct oaktrail_gct_data gct_data; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci /* Oaktrail HDMI state */ 5448c2ecf20Sopenharmony_ci struct oaktrail_hdmi_dev *hdmi_priv; 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci /* Register state */ 5478c2ecf20Sopenharmony_ci struct psb_save_area regs; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci /* MSI reg save */ 5508c2ecf20Sopenharmony_ci uint32_t msi_addr; 5518c2ecf20Sopenharmony_ci uint32_t msi_data; 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci /* Hotplug handling */ 5548c2ecf20Sopenharmony_ci struct work_struct hotplug_work; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci /* LID-Switch */ 5578c2ecf20Sopenharmony_ci spinlock_t lid_lock; 5588c2ecf20Sopenharmony_ci struct timer_list lid_timer; 5598c2ecf20Sopenharmony_ci struct psb_intel_opregion opregion; 5608c2ecf20Sopenharmony_ci u32 lid_last_state; 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci /* Watchdog */ 5638c2ecf20Sopenharmony_ci uint32_t apm_reg; 5648c2ecf20Sopenharmony_ci uint16_t apm_base; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci /* 5678c2ecf20Sopenharmony_ci * Used for modifying backlight from 5688c2ecf20Sopenharmony_ci * xrandr -- consider removing and using HAL instead 5698c2ecf20Sopenharmony_ci */ 5708c2ecf20Sopenharmony_ci struct backlight_device *backlight_device; 5718c2ecf20Sopenharmony_ci struct drm_property *backlight_property; 5728c2ecf20Sopenharmony_ci bool backlight_enabled; 5738c2ecf20Sopenharmony_ci int backlight_level; 5748c2ecf20Sopenharmony_ci uint32_t blc_adj1; 5758c2ecf20Sopenharmony_ci uint32_t blc_adj2; 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci struct drm_fb_helper *fb_helper; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci /* 2D acceleration */ 5808c2ecf20Sopenharmony_ci spinlock_t lock_2d; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci /* Panel brightness */ 5838c2ecf20Sopenharmony_ci int brightness; 5848c2ecf20Sopenharmony_ci int brightness_adjusted; 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci bool dsr_enable; 5878c2ecf20Sopenharmony_ci u32 dsr_fb_update; 5888c2ecf20Sopenharmony_ci bool dpi_panel_on[3]; 5898c2ecf20Sopenharmony_ci void *dsi_configs[2]; 5908c2ecf20Sopenharmony_ci u32 bpp; 5918c2ecf20Sopenharmony_ci u32 bpp2; 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci u32 pipeconf[3]; 5948c2ecf20Sopenharmony_ci u32 dspcntr[3]; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci int mdfld_panel_id; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci bool dplla_96mhz; /* DPLL data from the VBT */ 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci struct { 6018c2ecf20Sopenharmony_ci int rate; 6028c2ecf20Sopenharmony_ci int lanes; 6038c2ecf20Sopenharmony_ci int preemphasis; 6048c2ecf20Sopenharmony_ci int vswing; 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci bool initialized; 6078c2ecf20Sopenharmony_ci bool support; 6088c2ecf20Sopenharmony_ci int bpp; 6098c2ecf20Sopenharmony_ci struct edp_power_seq pps; 6108c2ecf20Sopenharmony_ci } edp; 6118c2ecf20Sopenharmony_ci uint8_t panel_type; 6128c2ecf20Sopenharmony_ci}; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci/* Operations for each board type */ 6168c2ecf20Sopenharmony_cistruct psb_ops { 6178c2ecf20Sopenharmony_ci const char *name; 6188c2ecf20Sopenharmony_ci unsigned int accel_2d:1; 6198c2ecf20Sopenharmony_ci int pipes; /* Number of output pipes */ 6208c2ecf20Sopenharmony_ci int crtcs; /* Number of CRTCs */ 6218c2ecf20Sopenharmony_ci int sgx_offset; /* Base offset of SGX device */ 6228c2ecf20Sopenharmony_ci int hdmi_mask; /* Mask of HDMI CRTCs */ 6238c2ecf20Sopenharmony_ci int lvds_mask; /* Mask of LVDS CRTCs */ 6248c2ecf20Sopenharmony_ci int sdvo_mask; /* Mask of SDVO CRTCs */ 6258c2ecf20Sopenharmony_ci int cursor_needs_phys; /* If cursor base reg need physical address */ 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci /* Sub functions */ 6288c2ecf20Sopenharmony_ci struct drm_crtc_helper_funcs const *crtc_helper; 6298c2ecf20Sopenharmony_ci struct drm_crtc_funcs const *crtc_funcs; 6308c2ecf20Sopenharmony_ci const struct gma_clock_funcs *clock_funcs; 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci /* Setup hooks */ 6338c2ecf20Sopenharmony_ci int (*chip_setup)(struct drm_device *dev); 6348c2ecf20Sopenharmony_ci void (*chip_teardown)(struct drm_device *dev); 6358c2ecf20Sopenharmony_ci /* Optional helper caller after modeset */ 6368c2ecf20Sopenharmony_ci void (*errata)(struct drm_device *dev); 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci /* Display management hooks */ 6398c2ecf20Sopenharmony_ci int (*output_init)(struct drm_device *dev); 6408c2ecf20Sopenharmony_ci int (*hotplug)(struct drm_device *dev); 6418c2ecf20Sopenharmony_ci void (*hotplug_enable)(struct drm_device *dev, bool on); 6428c2ecf20Sopenharmony_ci /* Power management hooks */ 6438c2ecf20Sopenharmony_ci void (*init_pm)(struct drm_device *dev); 6448c2ecf20Sopenharmony_ci int (*save_regs)(struct drm_device *dev); 6458c2ecf20Sopenharmony_ci int (*restore_regs)(struct drm_device *dev); 6468c2ecf20Sopenharmony_ci void (*save_crtc)(struct drm_crtc *crtc); 6478c2ecf20Sopenharmony_ci void (*restore_crtc)(struct drm_crtc *crtc); 6488c2ecf20Sopenharmony_ci int (*power_up)(struct drm_device *dev); 6498c2ecf20Sopenharmony_ci int (*power_down)(struct drm_device *dev); 6508c2ecf20Sopenharmony_ci void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc); 6518c2ecf20Sopenharmony_ci void (*disable_sr)(struct drm_device *dev); 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci void (*lvds_bl_power)(struct drm_device *dev, bool on); 6548c2ecf20Sopenharmony_ci#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE 6558c2ecf20Sopenharmony_ci /* Backlight */ 6568c2ecf20Sopenharmony_ci int (*backlight_init)(struct drm_device *dev); 6578c2ecf20Sopenharmony_ci#endif 6588c2ecf20Sopenharmony_ci int i2c_bus; /* I2C bus identifier for Moorestown */ 6598c2ecf20Sopenharmony_ci}; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ciextern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int); 6648c2ecf20Sopenharmony_ciextern int drm_pick_crtcs(struct drm_device *dev); 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_cistatic inline struct drm_psb_private *psb_priv(struct drm_device *dev) 6678c2ecf20Sopenharmony_ci{ 6688c2ecf20Sopenharmony_ci return (struct drm_psb_private *) dev->dev_private; 6698c2ecf20Sopenharmony_ci} 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci/* psb_irq.c */ 6728c2ecf20Sopenharmony_ciextern irqreturn_t psb_irq_handler(int irq, void *arg); 6738c2ecf20Sopenharmony_ciextern int psb_irq_enable_dpst(struct drm_device *dev); 6748c2ecf20Sopenharmony_ciextern int psb_irq_disable_dpst(struct drm_device *dev); 6758c2ecf20Sopenharmony_ciextern void psb_irq_preinstall(struct drm_device *dev); 6768c2ecf20Sopenharmony_ciextern int psb_irq_postinstall(struct drm_device *dev); 6778c2ecf20Sopenharmony_ciextern void psb_irq_uninstall(struct drm_device *dev); 6788c2ecf20Sopenharmony_ciextern void psb_irq_turn_on_dpst(struct drm_device *dev); 6798c2ecf20Sopenharmony_ciextern void psb_irq_turn_off_dpst(struct drm_device *dev); 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ciextern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands); 6828c2ecf20Sopenharmony_ciextern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence); 6838c2ecf20Sopenharmony_ciextern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence); 6848c2ecf20Sopenharmony_ciextern int psb_enable_vblank(struct drm_crtc *crtc); 6858c2ecf20Sopenharmony_ciextern void psb_disable_vblank(struct drm_crtc *crtc); 6868c2ecf20Sopenharmony_civoid 6878c2ecf20Sopenharmony_cipsb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask); 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_civoid 6908c2ecf20Sopenharmony_cipsb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask); 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ciextern u32 psb_get_vblank_counter(struct drm_crtc *crtc); 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci/* framebuffer.c */ 6958c2ecf20Sopenharmony_ciextern int psbfb_probed(struct drm_device *dev); 6968c2ecf20Sopenharmony_ciextern int psbfb_remove(struct drm_device *dev, 6978c2ecf20Sopenharmony_ci struct drm_framebuffer *fb); 6988c2ecf20Sopenharmony_ci/* accel_2d.c */ 6998c2ecf20Sopenharmony_ciextern void psbfb_copyarea(struct fb_info *info, 7008c2ecf20Sopenharmony_ci const struct fb_copyarea *region); 7018c2ecf20Sopenharmony_ciextern int psbfb_sync(struct fb_info *info); 7028c2ecf20Sopenharmony_ciextern void psb_spank(struct drm_psb_private *dev_priv); 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci/* psb_reset.c */ 7058c2ecf20Sopenharmony_ciextern void psb_lid_timer_init(struct drm_psb_private *dev_priv); 7068c2ecf20Sopenharmony_ciextern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv); 7078c2ecf20Sopenharmony_ciextern void psb_print_pagefault(struct drm_psb_private *dev_priv); 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ci/* modesetting */ 7108c2ecf20Sopenharmony_ciextern void psb_modeset_init(struct drm_device *dev); 7118c2ecf20Sopenharmony_ciextern void psb_modeset_cleanup(struct drm_device *dev); 7128c2ecf20Sopenharmony_ciextern int psb_fbdev_init(struct drm_device *dev); 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci/* backlight.c */ 7158c2ecf20Sopenharmony_ciint gma_backlight_init(struct drm_device *dev); 7168c2ecf20Sopenharmony_civoid gma_backlight_exit(struct drm_device *dev); 7178c2ecf20Sopenharmony_civoid gma_backlight_disable(struct drm_device *dev); 7188c2ecf20Sopenharmony_civoid gma_backlight_enable(struct drm_device *dev); 7198c2ecf20Sopenharmony_civoid gma_backlight_set(struct drm_device *dev, int v); 7208c2ecf20Sopenharmony_ci 7218c2ecf20Sopenharmony_ci/* oaktrail_crtc.c */ 7228c2ecf20Sopenharmony_ciextern const struct drm_crtc_helper_funcs oaktrail_helper_funcs; 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci/* oaktrail_lvds.c */ 7258c2ecf20Sopenharmony_ciextern void oaktrail_lvds_init(struct drm_device *dev, 7268c2ecf20Sopenharmony_ci struct psb_intel_mode_device *mode_dev); 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci/* psb_intel_display.c */ 7298c2ecf20Sopenharmony_ciextern const struct drm_crtc_helper_funcs psb_intel_helper_funcs; 7308c2ecf20Sopenharmony_ciextern const struct drm_crtc_funcs psb_intel_crtc_funcs; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci/* psb_intel_lvds.c */ 7338c2ecf20Sopenharmony_ciextern const struct drm_connector_helper_funcs 7348c2ecf20Sopenharmony_ci psb_intel_lvds_connector_helper_funcs; 7358c2ecf20Sopenharmony_ciextern const struct drm_connector_funcs psb_intel_lvds_connector_funcs; 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_ci/* gem.c */ 7388c2ecf20Sopenharmony_ciextern void psb_gem_free_object(struct drm_gem_object *obj); 7398c2ecf20Sopenharmony_ciextern int psb_gem_get_aperture(struct drm_device *dev, void *data, 7408c2ecf20Sopenharmony_ci struct drm_file *file); 7418c2ecf20Sopenharmony_ciextern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, 7428c2ecf20Sopenharmony_ci struct drm_mode_create_dumb *args); 7438c2ecf20Sopenharmony_ciextern vm_fault_t psb_gem_fault(struct vm_fault *vmf); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci/* psb_device.c */ 7468c2ecf20Sopenharmony_ciextern const struct psb_ops psb_chip_ops; 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci/* oaktrail_device.c */ 7498c2ecf20Sopenharmony_ciextern const struct psb_ops oaktrail_chip_ops; 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ci/* mdlfd_device.c */ 7528c2ecf20Sopenharmony_ciextern const struct psb_ops mdfld_chip_ops; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci/* cdv_device.c */ 7558c2ecf20Sopenharmony_ciextern const struct psb_ops cdv_chip_ops; 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci/* Debug print bits setting */ 7588c2ecf20Sopenharmony_ci#define PSB_D_GENERAL (1 << 0) 7598c2ecf20Sopenharmony_ci#define PSB_D_INIT (1 << 1) 7608c2ecf20Sopenharmony_ci#define PSB_D_IRQ (1 << 2) 7618c2ecf20Sopenharmony_ci#define PSB_D_ENTRY (1 << 3) 7628c2ecf20Sopenharmony_ci/* debug the get H/V BP/FP count */ 7638c2ecf20Sopenharmony_ci#define PSB_D_HV (1 << 4) 7648c2ecf20Sopenharmony_ci#define PSB_D_DBI_BF (1 << 5) 7658c2ecf20Sopenharmony_ci#define PSB_D_PM (1 << 6) 7668c2ecf20Sopenharmony_ci#define PSB_D_RENDER (1 << 7) 7678c2ecf20Sopenharmony_ci#define PSB_D_REG (1 << 8) 7688c2ecf20Sopenharmony_ci#define PSB_D_MSVDX (1 << 9) 7698c2ecf20Sopenharmony_ci#define PSB_D_TOPAZ (1 << 10) 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ciextern int drm_idle_check_interval; 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_ci/* Utilities */ 7748c2ecf20Sopenharmony_cistatic inline u32 MRST_MSG_READ32(int domain, uint port, uint offset) 7758c2ecf20Sopenharmony_ci{ 7768c2ecf20Sopenharmony_ci int mcr = (0xD0<<24) | (port << 16) | (offset << 8); 7778c2ecf20Sopenharmony_ci uint32_t ret_val = 0; 7788c2ecf20Sopenharmony_ci struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 7798c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD0, mcr); 7808c2ecf20Sopenharmony_ci pci_read_config_dword(pci_root, 0xD4, &ret_val); 7818c2ecf20Sopenharmony_ci pci_dev_put(pci_root); 7828c2ecf20Sopenharmony_ci return ret_val; 7838c2ecf20Sopenharmony_ci} 7848c2ecf20Sopenharmony_cistatic inline void MRST_MSG_WRITE32(int domain, uint port, uint offset, 7858c2ecf20Sopenharmony_ci u32 value) 7868c2ecf20Sopenharmony_ci{ 7878c2ecf20Sopenharmony_ci int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0; 7888c2ecf20Sopenharmony_ci struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 7898c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD4, value); 7908c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD0, mcr); 7918c2ecf20Sopenharmony_ci pci_dev_put(pci_root); 7928c2ecf20Sopenharmony_ci} 7938c2ecf20Sopenharmony_cistatic inline u32 MDFLD_MSG_READ32(int domain, uint port, uint offset) 7948c2ecf20Sopenharmony_ci{ 7958c2ecf20Sopenharmony_ci int mcr = (0x10<<24) | (port << 16) | (offset << 8); 7968c2ecf20Sopenharmony_ci uint32_t ret_val = 0; 7978c2ecf20Sopenharmony_ci struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 7988c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD0, mcr); 7998c2ecf20Sopenharmony_ci pci_read_config_dword(pci_root, 0xD4, &ret_val); 8008c2ecf20Sopenharmony_ci pci_dev_put(pci_root); 8018c2ecf20Sopenharmony_ci return ret_val; 8028c2ecf20Sopenharmony_ci} 8038c2ecf20Sopenharmony_cistatic inline void MDFLD_MSG_WRITE32(int domain, uint port, uint offset, 8048c2ecf20Sopenharmony_ci u32 value) 8058c2ecf20Sopenharmony_ci{ 8068c2ecf20Sopenharmony_ci int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0; 8078c2ecf20Sopenharmony_ci struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 8088c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD4, value); 8098c2ecf20Sopenharmony_ci pci_write_config_dword(pci_root, 0xD0, mcr); 8108c2ecf20Sopenharmony_ci pci_dev_put(pci_root); 8118c2ecf20Sopenharmony_ci} 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_cistatic inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg) 8148c2ecf20Sopenharmony_ci{ 8158c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8168c2ecf20Sopenharmony_ci return ioread32(dev_priv->vdc_reg + reg); 8178c2ecf20Sopenharmony_ci} 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_cistatic inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg) 8208c2ecf20Sopenharmony_ci{ 8218c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8228c2ecf20Sopenharmony_ci return ioread32(dev_priv->aux_reg + reg); 8238c2ecf20Sopenharmony_ci} 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_ci#define REG_READ(reg) REGISTER_READ(dev, (reg)) 8268c2ecf20Sopenharmony_ci#define REG_READ_AUX(reg) REGISTER_READ_AUX(dev, (reg)) 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci/* Useful for post reads */ 8298c2ecf20Sopenharmony_cistatic inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev, 8308c2ecf20Sopenharmony_ci uint32_t reg, int aux) 8318c2ecf20Sopenharmony_ci{ 8328c2ecf20Sopenharmony_ci uint32_t val; 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_ci if (aux) 8358c2ecf20Sopenharmony_ci val = REG_READ_AUX(reg); 8368c2ecf20Sopenharmony_ci else 8378c2ecf20Sopenharmony_ci val = REG_READ(reg); 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_ci return val; 8408c2ecf20Sopenharmony_ci} 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci#define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux)) 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_cistatic inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg, 8458c2ecf20Sopenharmony_ci uint32_t val) 8468c2ecf20Sopenharmony_ci{ 8478c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8488c2ecf20Sopenharmony_ci iowrite32((val), dev_priv->vdc_reg + (reg)); 8498c2ecf20Sopenharmony_ci} 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_cistatic inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg, 8528c2ecf20Sopenharmony_ci uint32_t val) 8538c2ecf20Sopenharmony_ci{ 8548c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8558c2ecf20Sopenharmony_ci iowrite32((val), dev_priv->aux_reg + (reg)); 8568c2ecf20Sopenharmony_ci} 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci#define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val)) 8598c2ecf20Sopenharmony_ci#define REG_WRITE_AUX(reg, val) REGISTER_WRITE_AUX(dev, (reg), (val)) 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_cistatic inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg, 8628c2ecf20Sopenharmony_ci uint32_t val, int aux) 8638c2ecf20Sopenharmony_ci{ 8648c2ecf20Sopenharmony_ci if (aux) 8658c2ecf20Sopenharmony_ci REG_WRITE_AUX(reg, val); 8668c2ecf20Sopenharmony_ci else 8678c2ecf20Sopenharmony_ci REG_WRITE(reg, val); 8688c2ecf20Sopenharmony_ci} 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci#define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux)) 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_cistatic inline void REGISTER_WRITE16(struct drm_device *dev, 8738c2ecf20Sopenharmony_ci uint32_t reg, uint32_t val) 8748c2ecf20Sopenharmony_ci{ 8758c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8768c2ecf20Sopenharmony_ci iowrite16((val), dev_priv->vdc_reg + (reg)); 8778c2ecf20Sopenharmony_ci} 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_ci#define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val)) 8808c2ecf20Sopenharmony_ci 8818c2ecf20Sopenharmony_cistatic inline void REGISTER_WRITE8(struct drm_device *dev, 8828c2ecf20Sopenharmony_ci uint32_t reg, uint32_t val) 8838c2ecf20Sopenharmony_ci{ 8848c2ecf20Sopenharmony_ci struct drm_psb_private *dev_priv = dev->dev_private; 8858c2ecf20Sopenharmony_ci iowrite8((val), dev_priv->vdc_reg + (reg)); 8868c2ecf20Sopenharmony_ci} 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci#define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val)) 8898c2ecf20Sopenharmony_ci 8908c2ecf20Sopenharmony_ci#define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs)) 8918c2ecf20Sopenharmony_ci#define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs)) 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci/* #define TRAP_SGX_PM_FAULT 1 */ 8948c2ecf20Sopenharmony_ci#ifdef TRAP_SGX_PM_FAULT 8958c2ecf20Sopenharmony_ci#define PSB_RSGX32(_offs) \ 8968c2ecf20Sopenharmony_ci({ \ 8978c2ecf20Sopenharmony_ci if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) { \ 8988c2ecf20Sopenharmony_ci pr_err("access sgx when it's off!! (READ) %s, %d\n", \ 8998c2ecf20Sopenharmony_ci __FILE__, __LINE__); \ 9008c2ecf20Sopenharmony_ci melay(1000); \ 9018c2ecf20Sopenharmony_ci } \ 9028c2ecf20Sopenharmony_ci ioread32(dev_priv->sgx_reg + (_offs)); \ 9038c2ecf20Sopenharmony_ci}) 9048c2ecf20Sopenharmony_ci#else 9058c2ecf20Sopenharmony_ci#define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs)) 9068c2ecf20Sopenharmony_ci#endif 9078c2ecf20Sopenharmony_ci#define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs)) 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci#define MSVDX_REG_DUMP 0 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci#define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs)) 9128c2ecf20Sopenharmony_ci#define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs)) 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci#endif 915