1a61127c2SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 25c49fd3aSAlan Cox /************************************************************************** 35c49fd3aSAlan Cox * Copyright (c) 2007-2011, Intel Corporation. 45c49fd3aSAlan Cox * All Rights Reserved. 55c49fd3aSAlan Cox * 65c49fd3aSAlan Cox **************************************************************************/ 75c49fd3aSAlan Cox 85c49fd3aSAlan Cox #ifndef _PSB_DRV_H_ 95c49fd3aSAlan Cox #define _PSB_DRV_H_ 105c49fd3aSAlan Cox 115c49fd3aSAlan Cox #include <linux/kref.h> 120edf6813SSouptick Joarder #include <linux/mm_types.h> 135c49fd3aSAlan Cox 1451474335SSam Ravnborg #include <drm/drm_device.h> 15d825c565SSam Ravnborg 165c49fd3aSAlan Cox #include "gtt.h" 170c7b178aSSam Ravnborg #include "intel_bios.h" 18ac1b01b0SPatrik Jakobsson #include "mmu.h" 190c7b178aSSam Ravnborg #include "oaktrail.h" 200c7b178aSSam Ravnborg #include "opregion.h" 210c7b178aSSam Ravnborg #include "power.h" 220c7b178aSSam Ravnborg #include "psb_intel_drv.h" 230c7b178aSSam Ravnborg #include "psb_reg.h" 245c49fd3aSAlan Cox 25f90cd811SArthur Borsboom #define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others" 26f90cd811SArthur Borsboom 27f90cd811SArthur Borsboom #define DRIVER_NAME "gma500" 28f90cd811SArthur Borsboom #define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650" 29f90cd811SArthur Borsboom #define DRIVER_DATE "20140314" 30f90cd811SArthur Borsboom 31f90cd811SArthur Borsboom #define DRIVER_MAJOR 1 32f90cd811SArthur Borsboom #define DRIVER_MINOR 0 33f90cd811SArthur Borsboom #define DRIVER_PATCHLEVEL 0 34f90cd811SArthur Borsboom 355c49fd3aSAlan Cox /* Append new drm mode definition here, align with libdrm definition */ 365c49fd3aSAlan Cox #define DRM_MODE_SCALE_NO_SCALE 2 375c49fd3aSAlan Cox 38a2c68495SThomas Zimmermann #define IS_PSB(drm) ((to_pci_dev((drm)->dev)->device & 0xfffe) == 0x8108) 39a2c68495SThomas Zimmermann #define IS_MRST(drm) ((to_pci_dev((drm)->dev)->device & 0xfff0) == 0x4100) 40a2c68495SThomas Zimmermann #define IS_CDV(drm) ((to_pci_dev((drm)->dev)->device & 0xfff0) == 0x0be0) 415c49fd3aSAlan Cox 429083eb38SArthur Borsboom /* Hardware offsets */ 435c49fd3aSAlan Cox #define PSB_VDC_OFFSET 0x00000000 445c49fd3aSAlan Cox #define PSB_VDC_SIZE 0x000080000 455c49fd3aSAlan Cox #define MRST_MMIO_SIZE 0x0000C0000 465c49fd3aSAlan Cox #define PSB_SGX_SIZE 0x8000 475c49fd3aSAlan Cox #define PSB_SGX_OFFSET 0x00040000 485c49fd3aSAlan Cox #define MRST_SGX_OFFSET 0x00080000 499083eb38SArthur Borsboom 509083eb38SArthur Borsboom /* PCI resource identifiers */ 515c49fd3aSAlan Cox #define PSB_MMIO_RESOURCE 0 522657929dSPatrik Jakobsson #define PSB_AUX_RESOURCE 0 535c49fd3aSAlan Cox #define PSB_GATT_RESOURCE 2 545c49fd3aSAlan Cox #define PSB_GTT_RESOURCE 3 559083eb38SArthur Borsboom 569083eb38SArthur Borsboom /* PCI configuration */ 575c49fd3aSAlan Cox #define PSB_GMCH_CTRL 0x52 585c49fd3aSAlan Cox #define PSB_BSM 0x5C 595c49fd3aSAlan Cox #define _PSB_GMCH_ENABLED 0x4 605c49fd3aSAlan Cox #define PSB_PGETBL_CTL 0x2020 615c49fd3aSAlan Cox #define _PSB_PGETBL_ENABLED 0x00000001 625c49fd3aSAlan Cox #define PSB_SGX_2D_SLAVE_PORT 0x4000 635a52b1f2SJan Safrata #define PSB_LPC_GBA 0x44 645c49fd3aSAlan Cox 659083eb38SArthur Borsboom /* TODO: To get rid of */ 665c49fd3aSAlan Cox #define PSB_TT_PRIV0_LIMIT (256*1024*1024) 675c49fd3aSAlan Cox #define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT) 685c49fd3aSAlan Cox 699083eb38SArthur Borsboom /* SGX side MMU definitions (these can probably go) */ 705c49fd3aSAlan Cox 719083eb38SArthur Borsboom /* Flags for external memory type field */ 725c49fd3aSAlan Cox #define PSB_MMU_CACHED_MEMORY 0x0001 /* Bind to MMU only */ 735c49fd3aSAlan Cox #define PSB_MMU_RO_MEMORY 0x0002 /* MMU RO memory */ 745c49fd3aSAlan Cox #define PSB_MMU_WO_MEMORY 0x0004 /* MMU WO memory */ 759083eb38SArthur Borsboom 769083eb38SArthur Borsboom /* PTE's and PDE's */ 775c49fd3aSAlan Cox #define PSB_PDE_MASK 0x003FFFFF 785c49fd3aSAlan Cox #define PSB_PDE_SHIFT 22 795c49fd3aSAlan Cox #define PSB_PTE_SHIFT 12 809083eb38SArthur Borsboom 819083eb38SArthur Borsboom /* Cache control */ 825c49fd3aSAlan Cox #define PSB_PTE_VALID 0x0001 /* PTE / PDE valid */ 835c49fd3aSAlan Cox #define PSB_PTE_WO 0x0002 /* Write only */ 845c49fd3aSAlan Cox #define PSB_PTE_RO 0x0004 /* Read only */ 855c49fd3aSAlan Cox #define PSB_PTE_CACHED 0x0008 /* CPU cache coherent */ 865c49fd3aSAlan Cox 879083eb38SArthur Borsboom /* VDC registers and bits */ 885c49fd3aSAlan Cox #define PSB_MSVDX_CLOCKGATING 0x2064 895c49fd3aSAlan Cox #define PSB_TOPAZ_CLOCKGATING 0x2068 905c49fd3aSAlan Cox #define PSB_HWSTAM 0x2098 915c49fd3aSAlan Cox #define PSB_INSTPM 0x20C0 925c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R 0x20A4 93d839ede4SAlan Cox #define _PSB_IRQ_ASLE (1<<0) 945c49fd3aSAlan Cox #define _MDFLD_PIPEC_EVENT_FLAG (1<<2) 955c49fd3aSAlan Cox #define _MDFLD_PIPEC_VBLANK_FLAG (1<<3) 965c49fd3aSAlan Cox #define _PSB_DPST_PIPEB_FLAG (1<<4) 975c49fd3aSAlan Cox #define _MDFLD_PIPEB_EVENT_FLAG (1<<4) 985c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEB_FLAG (1<<5) 995c49fd3aSAlan Cox #define _PSB_DPST_PIPEA_FLAG (1<<6) 1005c49fd3aSAlan Cox #define _PSB_PIPEA_EVENT_FLAG (1<<6) 1015c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEA_FLAG (1<<7) 10268cb638fSAlan Cox #define _PSB_IRQ_DISP_HOTSYNC (1<<17) 1035c49fd3aSAlan Cox #define _PSB_IRQ_SGX_FLAG (1<<18) 1045c49fd3aSAlan Cox #define _PSB_IRQ_MSVDX_FLAG (1<<19) 1055c49fd3aSAlan Cox #define _LNC_IRQ_TOPAZ_FLAG (1<<20) 1065c49fd3aSAlan Cox 107700e59f6SPatrik Jakobsson #define _PSB_PIPE_EVENT_FLAG (_PSB_VSYNC_PIPEA_FLAG | \ 108700e59f6SPatrik Jakobsson _PSB_VSYNC_PIPEB_FLAG) 109700e59f6SPatrik Jakobsson 1105c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R 0x20A4 1115c49fd3aSAlan Cox #define PSB_INT_MASK_R 0x20A8 1125c49fd3aSAlan Cox #define PSB_INT_ENABLE_R 0x20A0 1135c49fd3aSAlan Cox 1145c49fd3aSAlan Cox #define _PSB_MMU_ER_MASK 0x0001FF00 1155c49fd3aSAlan Cox #define _PSB_MMU_ER_HOST (1 << 16) 1165c49fd3aSAlan Cox #define GPIOA 0x5010 1175c49fd3aSAlan Cox #define GPIOB 0x5014 1185c49fd3aSAlan Cox #define GPIOC 0x5018 1195c49fd3aSAlan Cox #define GPIOD 0x501c 1205c49fd3aSAlan Cox #define GPIOE 0x5020 1215c49fd3aSAlan Cox #define GPIOF 0x5024 1225c49fd3aSAlan Cox #define GPIOG 0x5028 1235c49fd3aSAlan Cox #define GPIOH 0x502c 1245c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_MASK (1 << 0) 1255c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_IN (0 << 1) 1265c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_OUT (1 << 1) 1275c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_MASK (1 << 2) 1285c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_OUT (1 << 3) 1295c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_IN (1 << 4) 1305c49fd3aSAlan Cox #define GPIO_CLOCK_PULLUP_DISABLE (1 << 5) 1315c49fd3aSAlan Cox #define GPIO_DATA_DIR_MASK (1 << 8) 1325c49fd3aSAlan Cox #define GPIO_DATA_DIR_IN (0 << 9) 1335c49fd3aSAlan Cox #define GPIO_DATA_DIR_OUT (1 << 9) 1345c49fd3aSAlan Cox #define GPIO_DATA_VAL_MASK (1 << 10) 1355c49fd3aSAlan Cox #define GPIO_DATA_VAL_OUT (1 << 11) 1365c49fd3aSAlan Cox #define GPIO_DATA_VAL_IN (1 << 12) 1375c49fd3aSAlan Cox #define GPIO_DATA_PULLUP_DISABLE (1 << 13) 1385c49fd3aSAlan Cox 1395c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA0 0x6000 1405c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA1 0x6004 1415c49fd3aSAlan Cox #define VCLK_POST_DIV 0x6010 1425c49fd3aSAlan Cox 1435c49fd3aSAlan Cox #define PSB_COMM_2D (PSB_ENGINE_2D << 4) 1445c49fd3aSAlan Cox #define PSB_COMM_3D (PSB_ENGINE_3D << 4) 1455c49fd3aSAlan Cox #define PSB_COMM_TA (PSB_ENGINE_TA << 4) 1465c49fd3aSAlan Cox #define PSB_COMM_HP (PSB_ENGINE_HP << 4) 1475c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ (1024 >> 2) 1485c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1) 1495c49fd3aSAlan Cox #define PSB_COMM_FW (2048 >> 2) 1505c49fd3aSAlan Cox 1515c49fd3aSAlan Cox #define PSB_UIRQ_VISTEST 1 1525c49fd3aSAlan Cox #define PSB_UIRQ_OOM_REPLY 2 1535c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_TA_REPLY 3 1545c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_RASTER_REPLY 4 1555c49fd3aSAlan Cox 1565c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024) 1575c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024 1585c49fd3aSAlan Cox 1595c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204 1605c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600 1615c49fd3aSAlan Cox 1625c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2 1635c49fd3aSAlan Cox 1645c49fd3aSAlan Cox 1655c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024) 1665c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024 1675c49fd3aSAlan Cox 1685c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204 1695c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600 1705c49fd3aSAlan Cox 1715c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2 172bfd8303aSDaniel Vetter #define PSB_WATCHDOG_DELAY (HZ * 2) 173bfd8303aSDaniel Vetter #define PSB_LID_DELAY (HZ / 10) 1745c49fd3aSAlan Cox 1755c49fd3aSAlan Cox #define PSB_PWR_STATE_ON 1 1765c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF 2 1775c49fd3aSAlan Cox 1785c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM 0 1795c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING 1 1805c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN 2 1815c49fd3aSAlan Cox 1825c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP 0 1835c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED 1 1845c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN 2 1855c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC 0x94 1865c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC 0x98 1875c49fd3aSAlan Cox 1885c49fd3aSAlan Cox /* Medfield crystal settings */ 1895c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1 1905c49fd3aSAlan Cox #define KSEL_BYPASS_19 5 1915c49fd3aSAlan Cox #define KSEL_BYPASS_25 6 1925c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7 1935c49fd3aSAlan Cox 1946b7ce2c4SThomas Zimmermann struct drm_fb_helper; 1956b7ce2c4SThomas Zimmermann 1965c49fd3aSAlan Cox struct opregion_header; 1975c49fd3aSAlan Cox struct opregion_acpi; 1985c49fd3aSAlan Cox struct opregion_swsci; 1995c49fd3aSAlan Cox struct opregion_asle; 2005c49fd3aSAlan Cox 2015c49fd3aSAlan Cox struct psb_intel_opregion { 2025c49fd3aSAlan Cox struct opregion_header *header; 2035c49fd3aSAlan Cox struct opregion_acpi *acpi; 2045c49fd3aSAlan Cox struct opregion_swsci *swsci; 2055c49fd3aSAlan Cox struct opregion_asle *asle; 2061fb28e9eSAlan Cox void *vbt; 207d839ede4SAlan Cox u32 __iomem *lid_state; 208778e26deSPatrik Jakobsson struct work_struct asle_work; 2095c49fd3aSAlan Cox }; 2105c49fd3aSAlan Cox 2115736995bSPatrik Jakobsson struct sdvo_device_mapping { 2125736995bSPatrik Jakobsson u8 initialized; 2135736995bSPatrik Jakobsson u8 dvo_port; 2145736995bSPatrik Jakobsson u8 slave_addr; 2155736995bSPatrik Jakobsson u8 dvo_wiring; 2165736995bSPatrik Jakobsson u8 i2c_pin; 2175736995bSPatrik Jakobsson u8 i2c_speed; 2185736995bSPatrik Jakobsson u8 ddc_pin; 2195736995bSPatrik Jakobsson }; 2205736995bSPatrik Jakobsson 2215c0c1d50SPatrik Jakobsson struct intel_gmbus { 2225c0c1d50SPatrik Jakobsson struct i2c_adapter adapter; 2235c0c1d50SPatrik Jakobsson struct i2c_adapter *force_bit; 2245c0c1d50SPatrik Jakobsson u32 reg0; 2255c0c1d50SPatrik Jakobsson }; 2265c0c1d50SPatrik Jakobsson 2279083eb38SArthur Borsboom /* Register offset maps */ 2288512e074SAlan Cox struct psb_offset { 2298512e074SAlan Cox u32 fp0; 2308512e074SAlan Cox u32 fp1; 2318512e074SAlan Cox u32 cntr; 2328512e074SAlan Cox u32 conf; 2338512e074SAlan Cox u32 src; 2348512e074SAlan Cox u32 dpll; 2358512e074SAlan Cox u32 dpll_md; 2368512e074SAlan Cox u32 htotal; 2378512e074SAlan Cox u32 hblank; 2388512e074SAlan Cox u32 hsync; 2398512e074SAlan Cox u32 vtotal; 2408512e074SAlan Cox u32 vblank; 2418512e074SAlan Cox u32 vsync; 2428512e074SAlan Cox u32 stride; 2438512e074SAlan Cox u32 size; 2448512e074SAlan Cox u32 pos; 2458512e074SAlan Cox u32 surf; 2468512e074SAlan Cox u32 addr; 2478512e074SAlan Cox u32 base; 2488512e074SAlan Cox u32 status; 2498512e074SAlan Cox u32 linoff; 2508512e074SAlan Cox u32 tileoff; 2518512e074SAlan Cox u32 palette; 2528512e074SAlan Cox }; 2538512e074SAlan Cox 2548512e074SAlan Cox /* 255648a8e34SAlan Cox * Register save state. This is used to hold the context when the 256648a8e34SAlan Cox * device is powered off. In the case of Oaktrail this can (but does not 257648a8e34SAlan Cox * yet) include screen blank. Operations occuring during the save 258648a8e34SAlan Cox * update the register cache instead. 259648a8e34SAlan Cox */ 2606256304bSAlan Cox 2619083eb38SArthur Borsboom /* Common status for pipes */ 2626256304bSAlan Cox struct psb_pipe { 2636256304bSAlan Cox u32 fp0; 2646256304bSAlan Cox u32 fp1; 2656256304bSAlan Cox u32 cntr; 2666256304bSAlan Cox u32 conf; 2676256304bSAlan Cox u32 src; 2686256304bSAlan Cox u32 dpll; 2696256304bSAlan Cox u32 dpll_md; 2706256304bSAlan Cox u32 htotal; 2716256304bSAlan Cox u32 hblank; 2726256304bSAlan Cox u32 hsync; 2736256304bSAlan Cox u32 vtotal; 2746256304bSAlan Cox u32 vblank; 2756256304bSAlan Cox u32 vsync; 2766256304bSAlan Cox u32 stride; 2776256304bSAlan Cox u32 size; 2786256304bSAlan Cox u32 pos; 2796256304bSAlan Cox u32 base; 2806256304bSAlan Cox u32 surf; 2816256304bSAlan Cox u32 addr; 2826256304bSAlan Cox u32 status; 2836256304bSAlan Cox u32 linoff; 2846256304bSAlan Cox u32 tileoff; 2856256304bSAlan Cox u32 palette[256]; 2866256304bSAlan Cox }; 2876256304bSAlan Cox 288648a8e34SAlan Cox struct psb_state { 289648a8e34SAlan Cox uint32_t saveVCLK_DIVISOR_VGA0; 290648a8e34SAlan Cox uint32_t saveVCLK_DIVISOR_VGA1; 291648a8e34SAlan Cox uint32_t saveVCLK_POST_DIV; 292648a8e34SAlan Cox uint32_t saveVGACNTRL; 293648a8e34SAlan Cox uint32_t saveADPA; 294648a8e34SAlan Cox uint32_t saveLVDS; 295648a8e34SAlan Cox uint32_t saveDVOA; 296648a8e34SAlan Cox uint32_t saveDVOB; 297648a8e34SAlan Cox uint32_t saveDVOC; 298648a8e34SAlan Cox uint32_t savePP_ON; 299648a8e34SAlan Cox uint32_t savePP_OFF; 300648a8e34SAlan Cox uint32_t savePP_CONTROL; 301648a8e34SAlan Cox uint32_t savePP_CYCLE; 302648a8e34SAlan Cox uint32_t savePFIT_CONTROL; 303648a8e34SAlan Cox uint32_t saveCLOCKGATING; 304648a8e34SAlan Cox uint32_t saveDSPARB; 305648a8e34SAlan Cox uint32_t savePFIT_AUTO_RATIOS; 306648a8e34SAlan Cox uint32_t savePFIT_PGM_RATIOS; 307648a8e34SAlan Cox uint32_t savePP_ON_DELAYS; 308648a8e34SAlan Cox uint32_t savePP_OFF_DELAYS; 309648a8e34SAlan Cox uint32_t savePP_DIVISOR; 310648a8e34SAlan Cox uint32_t saveBCLRPAT_A; 311648a8e34SAlan Cox uint32_t saveBCLRPAT_B; 312648a8e34SAlan Cox uint32_t savePERF_MODE; 313648a8e34SAlan Cox uint32_t saveDSPFW1; 314648a8e34SAlan Cox uint32_t saveDSPFW2; 315648a8e34SAlan Cox uint32_t saveDSPFW3; 316648a8e34SAlan Cox uint32_t saveDSPFW4; 317648a8e34SAlan Cox uint32_t saveDSPFW5; 318648a8e34SAlan Cox uint32_t saveDSPFW6; 319648a8e34SAlan Cox uint32_t saveCHICKENBIT; 320648a8e34SAlan Cox uint32_t saveDSPACURSOR_CTRL; 321648a8e34SAlan Cox uint32_t saveDSPBCURSOR_CTRL; 322648a8e34SAlan Cox uint32_t saveDSPACURSOR_BASE; 323648a8e34SAlan Cox uint32_t saveDSPBCURSOR_BASE; 324648a8e34SAlan Cox uint32_t saveDSPACURSOR_POS; 325648a8e34SAlan Cox uint32_t saveDSPBCURSOR_POS; 326648a8e34SAlan Cox uint32_t saveOV_OVADD; 327648a8e34SAlan Cox uint32_t saveOV_OGAMC0; 328648a8e34SAlan Cox uint32_t saveOV_OGAMC1; 329648a8e34SAlan Cox uint32_t saveOV_OGAMC2; 330648a8e34SAlan Cox uint32_t saveOV_OGAMC3; 331648a8e34SAlan Cox uint32_t saveOV_OGAMC4; 332648a8e34SAlan Cox uint32_t saveOV_OGAMC5; 333648a8e34SAlan Cox uint32_t saveOVC_OVADD; 334648a8e34SAlan Cox uint32_t saveOVC_OGAMC0; 335648a8e34SAlan Cox uint32_t saveOVC_OGAMC1; 336648a8e34SAlan Cox uint32_t saveOVC_OGAMC2; 337648a8e34SAlan Cox uint32_t saveOVC_OGAMC3; 338648a8e34SAlan Cox uint32_t saveOVC_OGAMC4; 339648a8e34SAlan Cox uint32_t saveOVC_OGAMC5; 340648a8e34SAlan Cox 341648a8e34SAlan Cox /* DPST register save */ 342648a8e34SAlan Cox uint32_t saveHISTOGRAM_INT_CONTROL_REG; 343648a8e34SAlan Cox uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG; 344648a8e34SAlan Cox uint32_t savePWM_CONTROL_LOGIC; 345648a8e34SAlan Cox }; 346648a8e34SAlan Cox 34709016a11SAlan Cox struct cdv_state { 34809016a11SAlan Cox uint32_t saveDSPCLK_GATE_D; 34909016a11SAlan Cox uint32_t saveRAMCLK_GATE_D; 35009016a11SAlan Cox uint32_t saveDSPARB; 35109016a11SAlan Cox uint32_t saveDSPFW[6]; 35209016a11SAlan Cox uint32_t saveADPA; 35309016a11SAlan Cox uint32_t savePP_CONTROL; 35409016a11SAlan Cox uint32_t savePFIT_PGM_RATIOS; 35509016a11SAlan Cox uint32_t saveLVDS; 35609016a11SAlan Cox uint32_t savePFIT_CONTROL; 35709016a11SAlan Cox uint32_t savePP_ON_DELAYS; 35809016a11SAlan Cox uint32_t savePP_OFF_DELAYS; 35909016a11SAlan Cox uint32_t savePP_CYCLE; 36009016a11SAlan Cox uint32_t saveVGACNTRL; 36109016a11SAlan Cox uint32_t saveIER; 36209016a11SAlan Cox uint32_t saveIMR; 36309016a11SAlan Cox u8 saveLBB; 36409016a11SAlan Cox }; 36509016a11SAlan Cox 366c6265ff5SAlan Cox struct psb_save_area { 3676256304bSAlan Cox struct psb_pipe pipe[3]; 368c6265ff5SAlan Cox uint32_t saveBSM; 369c6265ff5SAlan Cox uint32_t saveVBT; 370c6265ff5SAlan Cox union { 371c6265ff5SAlan Cox struct psb_state psb; 37209016a11SAlan Cox struct cdv_state cdv; 373c6265ff5SAlan Cox }; 374c6265ff5SAlan Cox uint32_t saveBLC_PWM_CTL2; 375c6265ff5SAlan Cox uint32_t saveBLC_PWM_CTL; 376c6265ff5SAlan Cox }; 377c6265ff5SAlan Cox 3785c49fd3aSAlan Cox struct psb_ops; 3795c49fd3aSAlan Cox 38004bd564fSAlan Cox #define PSB_NUM_PIPE 3 38104bd564fSAlan Cox 382bfc838f8SAndy Shevchenko struct intel_scu_ipc_dev; 383bfc838f8SAndy Shevchenko 3845c49fd3aSAlan Cox struct drm_psb_private { 385c2f17e60SThomas Zimmermann struct drm_device dev; 386c2f17e60SThomas Zimmermann 3872657929dSPatrik Jakobsson struct pci_dev *aux_pdev; /* Currently only used by mrst */ 3885a52b1f2SJan Safrata struct pci_dev *lpc_pdev; /* Currently only used by mrst */ 3895c49fd3aSAlan Cox const struct psb_ops *ops; 3908512e074SAlan Cox const struct psb_offset *regmap; 3915c49fd3aSAlan Cox 3921fb28e9eSAlan Cox struct child_device_config *child_dev; 3931fb28e9eSAlan Cox int child_dev_num; 3941fb28e9eSAlan Cox 3955c49fd3aSAlan Cox struct psb_gtt gtt; 3965c49fd3aSAlan Cox 3975c49fd3aSAlan Cox /* GTT Memory manager */ 3985c49fd3aSAlan Cox struct psb_gtt_mm *gtt_mm; 3995c49fd3aSAlan Cox struct page *scratch_page; 400eab37607SKirill A. Shutemov u32 __iomem *gtt_map; 4015c49fd3aSAlan Cox uint32_t stolen_base; 40237214ca0SKirill A. Shutemov u8 __iomem *vram_addr; 4035c49fd3aSAlan Cox unsigned long vram_stolen_size; 4045c49fd3aSAlan Cox u16 gmch_ctrl; /* Saved GTT setup */ 4055c49fd3aSAlan Cox u32 pge_ctl; 4065c49fd3aSAlan Cox 4075c49fd3aSAlan Cox struct mutex gtt_mutex; 4085c49fd3aSAlan Cox struct resource *gtt_mem; /* Our PCI resource */ 4095c49fd3aSAlan Cox 410737292a3SDaniel Vetter struct mutex mmap_mutex; 411737292a3SDaniel Vetter 4125c49fd3aSAlan Cox struct psb_mmu_driver *mmu; 4135c49fd3aSAlan Cox struct psb_mmu_pd *pf_pd; 4145c49fd3aSAlan Cox 4159083eb38SArthur Borsboom /* Register base */ 416846a6038SKirill A. Shutemov uint8_t __iomem *sgx_reg; 417846a6038SKirill A. Shutemov uint8_t __iomem *vdc_reg; 4182657929dSPatrik Jakobsson uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */ 4195a52b1f2SJan Safrata uint16_t lpc_gpio_base; 4205c49fd3aSAlan Cox uint32_t gatt_free_offset; 4215c49fd3aSAlan Cox 4229083eb38SArthur Borsboom /* Fencing / irq */ 4235c49fd3aSAlan Cox uint32_t vdc_irq_mask; 4245c49fd3aSAlan Cox uint32_t pipestat[PSB_NUM_PIPE]; 4255c49fd3aSAlan Cox 4265c49fd3aSAlan Cox spinlock_t irqmask_lock; 4275c49fd3aSAlan Cox 4289083eb38SArthur Borsboom /* Power */ 4295c49fd3aSAlan Cox bool suspended; 4305c49fd3aSAlan Cox bool display_power; 4315c49fd3aSAlan Cox int display_count; 4325c49fd3aSAlan Cox 4339083eb38SArthur Borsboom /* Modesetting */ 4345c49fd3aSAlan Cox struct psb_intel_mode_device mode_dev; 4354ab2c7f1SAlan Cox bool modeset; /* true if we have done the mode_device setup */ 4365c49fd3aSAlan Cox 4375c49fd3aSAlan Cox struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE]; 4385c49fd3aSAlan Cox struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE]; 4395c49fd3aSAlan Cox uint32_t num_pipe; 4405c49fd3aSAlan Cox 4419083eb38SArthur Borsboom /* OSPM info (Power management base) (TODO: can go ?) */ 4425c49fd3aSAlan Cox uint32_t ospm_base; 4435c49fd3aSAlan Cox 4449083eb38SArthur Borsboom /* Sizes info */ 4455c49fd3aSAlan Cox u32 fuse_reg_value; 4465c49fd3aSAlan Cox u32 video_device_fuse; 4475c49fd3aSAlan Cox 4485c49fd3aSAlan Cox /* PCI revision ID for B0:D2:F0 */ 4495c49fd3aSAlan Cox uint8_t platform_rev_id; 4505c49fd3aSAlan Cox 4515c0c1d50SPatrik Jakobsson /* gmbus */ 4525c0c1d50SPatrik Jakobsson struct intel_gmbus *gmbus; 4532657929dSPatrik Jakobsson uint8_t __iomem *gmbus_reg; 4545c0c1d50SPatrik Jakobsson 4555736995bSPatrik Jakobsson /* Used by SDVO */ 4565736995bSPatrik Jakobsson int crt_ddc_pin; 4575736995bSPatrik Jakobsson /* FIXME: The mappings should be parsed from bios but for now we can 4585736995bSPatrik Jakobsson pretend there are no mappings available */ 4595736995bSPatrik Jakobsson struct sdvo_device_mapping sdvo_mappings[2]; 4605736995bSPatrik Jakobsson u32 hotplug_supported_mask; 4615736995bSPatrik Jakobsson struct drm_property *broadcast_rgb_property; 4625736995bSPatrik Jakobsson struct drm_property *force_audio_property; 4635736995bSPatrik Jakobsson 4649083eb38SArthur Borsboom /* LVDS info */ 4655c49fd3aSAlan Cox int backlight_duty_cycle; /* restore backlight to this value */ 4665c49fd3aSAlan Cox bool panel_wants_dither; 4675c49fd3aSAlan Cox struct drm_display_mode *panel_fixed_mode; 4685c49fd3aSAlan Cox struct drm_display_mode *lfp_lvds_vbt_mode; 4695c49fd3aSAlan Cox struct drm_display_mode *sdvo_lvds_vbt_mode; 4705c49fd3aSAlan Cox 4715c49fd3aSAlan Cox struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */ 472*04477e5eSPatrik Jakobsson struct gma_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */ 4735c49fd3aSAlan Cox 4745c49fd3aSAlan Cox /* Feature bits from the VBIOS */ 4755c49fd3aSAlan Cox unsigned int int_tv_support:1; 4765c49fd3aSAlan Cox unsigned int lvds_dither:1; 4775c49fd3aSAlan Cox unsigned int lvds_vbt:1; 4785c49fd3aSAlan Cox unsigned int int_crt_support:1; 4795c49fd3aSAlan Cox unsigned int lvds_use_ssc:1; 4805c49fd3aSAlan Cox int lvds_ssc_freq; 4815c49fd3aSAlan Cox bool is_lvds_on; 4825c49fd3aSAlan Cox bool is_mipi_on; 4837c420636SPatrik Jakobsson bool lvds_enabled_in_vbt; 4845c49fd3aSAlan Cox u32 mipi_ctrl_display; 4855c49fd3aSAlan Cox 4865c49fd3aSAlan Cox unsigned int core_freq; 4875c49fd3aSAlan Cox uint32_t iLVDS_enable; 4885c49fd3aSAlan Cox 4895c49fd3aSAlan Cox /* Runtime PM state */ 4905c49fd3aSAlan Cox int rpm_enabled; 4915c49fd3aSAlan Cox 4925c49fd3aSAlan Cox /* MID specific */ 4934086b1e2SKirill A. Shutemov bool has_gct; 4945c49fd3aSAlan Cox struct oaktrail_gct_data gct_data; 4955c49fd3aSAlan Cox 496933315acSAlan Cox /* Oaktrail HDMI state */ 4975c49fd3aSAlan Cox struct oaktrail_hdmi_dev *hdmi_priv; 4985c49fd3aSAlan Cox 4999083eb38SArthur Borsboom /* Register state */ 500c6265ff5SAlan Cox struct psb_save_area regs; 501c6265ff5SAlan Cox 5025c49fd3aSAlan Cox /* MSI reg save */ 5035c49fd3aSAlan Cox uint32_t msi_addr; 5045c49fd3aSAlan Cox uint32_t msi_data; 5055c49fd3aSAlan Cox 5069083eb38SArthur Borsboom /* Hotplug handling */ 507ae0a246aSAlan Cox struct work_struct hotplug_work; 5085c49fd3aSAlan Cox 5099083eb38SArthur Borsboom /* LID-Switch */ 5105c49fd3aSAlan Cox spinlock_t lid_lock; 5115c49fd3aSAlan Cox struct timer_list lid_timer; 5125c49fd3aSAlan Cox struct psb_intel_opregion opregion; 5135c49fd3aSAlan Cox u32 lid_last_state; 5145c49fd3aSAlan Cox 5159083eb38SArthur Borsboom /* Watchdog */ 5165c49fd3aSAlan Cox uint32_t apm_reg; 5175c49fd3aSAlan Cox uint16_t apm_base; 5185c49fd3aSAlan Cox 5195c49fd3aSAlan Cox /* 5205c49fd3aSAlan Cox * Used for modifying backlight from 5215c49fd3aSAlan Cox * xrandr -- consider removing and using HAL instead 5225c49fd3aSAlan Cox */ 523bfc838f8SAndy Shevchenko struct intel_scu_ipc_dev *scu; 5245c49fd3aSAlan Cox struct backlight_device *backlight_device; 5255c49fd3aSAlan Cox struct drm_property *backlight_property; 526d112a816SZhao Yakui bool backlight_enabled; 527d112a816SZhao Yakui int backlight_level; 5285c49fd3aSAlan Cox uint32_t blc_adj1; 5295c49fd3aSAlan Cox uint32_t blc_adj2; 5305c49fd3aSAlan Cox 5316b7ce2c4SThomas Zimmermann struct drm_fb_helper *fb_helper; 5325c49fd3aSAlan Cox 5339083eb38SArthur Borsboom /* Panel brightness */ 534026abc33SKirill A. Shutemov int brightness; 535026abc33SKirill A. Shutemov int brightness_adjusted; 536026abc33SKirill A. Shutemov 537026abc33SKirill A. Shutemov bool dsr_enable; 538026abc33SKirill A. Shutemov u32 dsr_fb_update; 539026abc33SKirill A. Shutemov bool dpi_panel_on[3]; 540026abc33SKirill A. Shutemov void *dsi_configs[2]; 541026abc33SKirill A. Shutemov u32 bpp; 542026abc33SKirill A. Shutemov u32 bpp2; 543026abc33SKirill A. Shutemov 544026abc33SKirill A. Shutemov u32 pipeconf[3]; 545026abc33SKirill A. Shutemov u32 dspcntr[3]; 546026abc33SKirill A. Shutemov 547642c52fcSAlan Cox bool dplla_96mhz; /* DPLL data from the VBT */ 548d112a816SZhao Yakui 549d112a816SZhao Yakui struct { 550d112a816SZhao Yakui int rate; 551d112a816SZhao Yakui int lanes; 552d112a816SZhao Yakui int preemphasis; 553d112a816SZhao Yakui int vswing; 554d112a816SZhao Yakui 555d112a816SZhao Yakui bool initialized; 556d112a816SZhao Yakui bool support; 557d112a816SZhao Yakui int bpp; 558d112a816SZhao Yakui struct edp_power_seq pps; 559d112a816SZhao Yakui } edp; 560d112a816SZhao Yakui uint8_t panel_type; 5615c49fd3aSAlan Cox }; 5625c49fd3aSAlan Cox 563f71635e8SThomas Zimmermann static inline struct drm_psb_private *to_drm_psb_private(struct drm_device *dev) 564f71635e8SThomas Zimmermann { 565c2f17e60SThomas Zimmermann return container_of(dev, struct drm_psb_private, dev); 566f71635e8SThomas Zimmermann } 5675c49fd3aSAlan Cox 5689083eb38SArthur Borsboom /* Operations for each board type */ 5695c49fd3aSAlan Cox struct psb_ops { 5705c49fd3aSAlan Cox const char *name; 5715c49fd3aSAlan Cox int pipes; /* Number of output pipes */ 5725c49fd3aSAlan Cox int crtcs; /* Number of CRTCs */ 5735c49fd3aSAlan Cox int sgx_offset; /* Base offset of SGX device */ 574d235e64aSAlan Cox int hdmi_mask; /* Mask of HDMI CRTCs */ 575d235e64aSAlan Cox int lvds_mask; /* Mask of LVDS CRTCs */ 576cf8efd3aSPatrik Jakobsson int sdvo_mask; /* Mask of SDVO CRTCs */ 577bc794829SPatrik Jakobsson int cursor_needs_phys; /* If cursor base reg need physical address */ 5785c49fd3aSAlan Cox 5795c49fd3aSAlan Cox /* Sub functions */ 5805c49fd3aSAlan Cox struct drm_crtc_helper_funcs const *crtc_helper; 5815ea75e0fSPatrik Jakobsson const struct gma_clock_funcs *clock_funcs; 5825c49fd3aSAlan Cox 5835c49fd3aSAlan Cox /* Setup hooks */ 5845c49fd3aSAlan Cox int (*chip_setup)(struct drm_device *dev); 5855c49fd3aSAlan Cox void (*chip_teardown)(struct drm_device *dev); 586d235e64aSAlan Cox /* Optional helper caller after modeset */ 587d235e64aSAlan Cox void (*errata)(struct drm_device *dev); 5885c49fd3aSAlan Cox 5895c49fd3aSAlan Cox /* Display management hooks */ 5905c49fd3aSAlan Cox int (*output_init)(struct drm_device *dev); 59168cb638fSAlan Cox int (*hotplug)(struct drm_device *dev); 59268cb638fSAlan Cox void (*hotplug_enable)(struct drm_device *dev, bool on); 5935c49fd3aSAlan Cox /* Power management hooks */ 5945c49fd3aSAlan Cox void (*init_pm)(struct drm_device *dev); 5955c49fd3aSAlan Cox int (*save_regs)(struct drm_device *dev); 5965c49fd3aSAlan Cox int (*restore_regs)(struct drm_device *dev); 597d56f57acSDaniel Vetter void (*save_crtc)(struct drm_crtc *crtc); 598d56f57acSDaniel Vetter void (*restore_crtc)(struct drm_crtc *crtc); 5995c49fd3aSAlan Cox int (*power_up)(struct drm_device *dev); 6005c49fd3aSAlan Cox int (*power_down)(struct drm_device *dev); 60128a8194cSPatrik Jakobsson void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc); 60275346fe9SPatrik Jakobsson void (*disable_sr)(struct drm_device *dev); 6035c49fd3aSAlan Cox 6045c49fd3aSAlan Cox void (*lvds_bl_power)(struct drm_device *dev, bool on); 6055c49fd3aSAlan Cox #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE 6065c49fd3aSAlan Cox /* Backlight */ 6075c49fd3aSAlan Cox int (*backlight_init)(struct drm_device *dev); 6085c49fd3aSAlan Cox #endif 6095c49fd3aSAlan Cox int i2c_bus; /* I2C bus identifier for Moorestown */ 6105c49fd3aSAlan Cox }; 6115c49fd3aSAlan Cox 6123138ba6eSPatrik Jakobsson /* psb_lid.c */ 6135c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv); 6145c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv); 6155c49fd3aSAlan Cox 6165c49fd3aSAlan Cox /* modesetting */ 6175c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev); 6185c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev); 6195c49fd3aSAlan Cox extern int psb_fbdev_init(struct drm_device *dev); 6205c49fd3aSAlan Cox 6215c49fd3aSAlan Cox /* backlight.c */ 6225c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev); 6235c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev); 624d112a816SZhao Yakui void gma_backlight_disable(struct drm_device *dev); 625d112a816SZhao Yakui void gma_backlight_enable(struct drm_device *dev); 626d112a816SZhao Yakui void gma_backlight_set(struct drm_device *dev, int v); 6275c49fd3aSAlan Cox 6285c49fd3aSAlan Cox /* oaktrail_crtc.c */ 6295c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs; 6305c49fd3aSAlan Cox 6315c49fd3aSAlan Cox /* oaktrail_lvds.c */ 6325c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev, 6335c49fd3aSAlan Cox struct psb_intel_mode_device *mode_dev); 6345c49fd3aSAlan Cox 6355c49fd3aSAlan Cox /* psb_intel_display.c */ 6365c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs; 6375c49fd3aSAlan Cox 6385c49fd3aSAlan Cox /* psb_intel_lvds.c */ 6395c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs 6405c49fd3aSAlan Cox psb_intel_lvds_connector_helper_funcs; 6415c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs; 6425c49fd3aSAlan Cox 6435c49fd3aSAlan Cox /* gem.c */ 6445c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, 6455c49fd3aSAlan Cox struct drm_mode_create_dumb *args); 6465c49fd3aSAlan Cox 6475c49fd3aSAlan Cox /* psb_device.c */ 6485c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops; 6495c49fd3aSAlan Cox 6505c49fd3aSAlan Cox /* oaktrail_device.c */ 6515c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops; 6525c49fd3aSAlan Cox 6535c49fd3aSAlan Cox /* cdv_device.c */ 6545c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops; 6555c49fd3aSAlan Cox 6569083eb38SArthur Borsboom /* Utilities */ 6575c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg) 6585c49fd3aSAlan Cox { 659f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6605c49fd3aSAlan Cox return ioread32(dev_priv->vdc_reg + reg); 6615c49fd3aSAlan Cox } 6625c49fd3aSAlan Cox 6632657929dSPatrik Jakobsson static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg) 6642657929dSPatrik Jakobsson { 665f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6662657929dSPatrik Jakobsson return ioread32(dev_priv->aux_reg + reg); 6672657929dSPatrik Jakobsson } 6682657929dSPatrik Jakobsson 6695c49fd3aSAlan Cox #define REG_READ(reg) REGISTER_READ(dev, (reg)) 6702657929dSPatrik Jakobsson #define REG_READ_AUX(reg) REGISTER_READ_AUX(dev, (reg)) 6715c49fd3aSAlan Cox 672b97b8287SPatrik Jakobsson /* Useful for post reads */ 673b97b8287SPatrik Jakobsson static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev, 674b97b8287SPatrik Jakobsson uint32_t reg, int aux) 675b97b8287SPatrik Jakobsson { 676b97b8287SPatrik Jakobsson uint32_t val; 677b97b8287SPatrik Jakobsson 678b97b8287SPatrik Jakobsson if (aux) 679b97b8287SPatrik Jakobsson val = REG_READ_AUX(reg); 680b97b8287SPatrik Jakobsson else 681b97b8287SPatrik Jakobsson val = REG_READ(reg); 682b97b8287SPatrik Jakobsson 683b97b8287SPatrik Jakobsson return val; 684b97b8287SPatrik Jakobsson } 685b97b8287SPatrik Jakobsson 686b97b8287SPatrik Jakobsson #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux)) 687b97b8287SPatrik Jakobsson 6885c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg, 6895c49fd3aSAlan Cox uint32_t val) 6905c49fd3aSAlan Cox { 691f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6925c49fd3aSAlan Cox iowrite32((val), dev_priv->vdc_reg + (reg)); 6935c49fd3aSAlan Cox } 6945c49fd3aSAlan Cox 6952657929dSPatrik Jakobsson static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg, 6962657929dSPatrik Jakobsson uint32_t val) 6972657929dSPatrik Jakobsson { 698f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6992657929dSPatrik Jakobsson iowrite32((val), dev_priv->aux_reg + (reg)); 7002657929dSPatrik Jakobsson } 7012657929dSPatrik Jakobsson 7025c49fd3aSAlan Cox #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val)) 7032657929dSPatrik Jakobsson #define REG_WRITE_AUX(reg, val) REGISTER_WRITE_AUX(dev, (reg), (val)) 7045c49fd3aSAlan Cox 705b97b8287SPatrik Jakobsson static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg, 706b97b8287SPatrik Jakobsson uint32_t val, int aux) 707b97b8287SPatrik Jakobsson { 708b97b8287SPatrik Jakobsson if (aux) 709b97b8287SPatrik Jakobsson REG_WRITE_AUX(reg, val); 710b97b8287SPatrik Jakobsson else 711b97b8287SPatrik Jakobsson REG_WRITE(reg, val); 712b97b8287SPatrik Jakobsson } 713b97b8287SPatrik Jakobsson 714b97b8287SPatrik Jakobsson #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux)) 715b97b8287SPatrik Jakobsson 7165c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev, 7175c49fd3aSAlan Cox uint32_t reg, uint32_t val) 7185c49fd3aSAlan Cox { 719f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 7205c49fd3aSAlan Cox iowrite16((val), dev_priv->vdc_reg + (reg)); 7215c49fd3aSAlan Cox } 7225c49fd3aSAlan Cox 7235c49fd3aSAlan Cox #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val)) 7245c49fd3aSAlan Cox 7255c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev, 7265c49fd3aSAlan Cox uint32_t reg, uint32_t val) 7275c49fd3aSAlan Cox { 728f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 7295c49fd3aSAlan Cox iowrite8((val), dev_priv->vdc_reg + (reg)); 7305c49fd3aSAlan Cox } 7315c49fd3aSAlan Cox 7325c49fd3aSAlan Cox #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val)) 7335c49fd3aSAlan Cox 7345c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs)) 7355c49fd3aSAlan Cox #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs)) 7365c49fd3aSAlan Cox 7375c49fd3aSAlan Cox #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs)) 7385c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs)) 7395c49fd3aSAlan Cox 7405c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs)) 7415c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs)) 7425c49fd3aSAlan Cox 7435c49fd3aSAlan Cox #endif 744