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 164bfd8303aSDaniel Vetter #define PSB_WATCHDOG_DELAY (HZ * 2) 165bfd8303aSDaniel Vetter #define PSB_LID_DELAY (HZ / 10) 1665c49fd3aSAlan Cox 1671f90b123SHans de Goede #define PSB_MAX_BRIGHTNESS 100 1681f90b123SHans de Goede 1695c49fd3aSAlan Cox #define PSB_PWR_STATE_ON 1 1705c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF 2 1715c49fd3aSAlan Cox 1725c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM 0 1735c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING 1 1745c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN 2 1755c49fd3aSAlan Cox 1765c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP 0 1775c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED 1 1785c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN 2 1795c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC 0x94 1805c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC 0x98 1815c49fd3aSAlan Cox 1825c49fd3aSAlan Cox /* Medfield crystal settings */ 1835c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1 1845c49fd3aSAlan Cox #define KSEL_BYPASS_19 5 1855c49fd3aSAlan Cox #define KSEL_BYPASS_25 6 1865c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7 1875c49fd3aSAlan Cox 1885c49fd3aSAlan Cox struct opregion_header; 1895c49fd3aSAlan Cox struct opregion_acpi; 1905c49fd3aSAlan Cox struct opregion_swsci; 1915c49fd3aSAlan Cox struct opregion_asle; 1925c49fd3aSAlan Cox 1935c49fd3aSAlan Cox struct psb_intel_opregion { 1945c49fd3aSAlan Cox struct opregion_header *header; 1955c49fd3aSAlan Cox struct opregion_acpi *acpi; 1965c49fd3aSAlan Cox struct opregion_swsci *swsci; 1975c49fd3aSAlan Cox struct opregion_asle *asle; 1981fb28e9eSAlan Cox void *vbt; 199d839ede4SAlan Cox u32 __iomem *lid_state; 200778e26deSPatrik Jakobsson struct work_struct asle_work; 2015c49fd3aSAlan Cox }; 2025c49fd3aSAlan Cox 2035736995bSPatrik Jakobsson struct sdvo_device_mapping { 2045736995bSPatrik Jakobsson u8 initialized; 2055736995bSPatrik Jakobsson u8 dvo_port; 2065736995bSPatrik Jakobsson u8 slave_addr; 2075736995bSPatrik Jakobsson u8 dvo_wiring; 2085736995bSPatrik Jakobsson u8 i2c_pin; 2095736995bSPatrik Jakobsson u8 i2c_speed; 2105736995bSPatrik Jakobsson u8 ddc_pin; 2115736995bSPatrik Jakobsson }; 2125736995bSPatrik Jakobsson 2135c0c1d50SPatrik Jakobsson struct intel_gmbus { 2145c0c1d50SPatrik Jakobsson struct i2c_adapter adapter; 2155c0c1d50SPatrik Jakobsson struct i2c_adapter *force_bit; 2165c0c1d50SPatrik Jakobsson u32 reg0; 2175c0c1d50SPatrik Jakobsson }; 2185c0c1d50SPatrik Jakobsson 2199083eb38SArthur Borsboom /* Register offset maps */ 2208512e074SAlan Cox struct psb_offset { 2218512e074SAlan Cox u32 fp0; 2228512e074SAlan Cox u32 fp1; 2238512e074SAlan Cox u32 cntr; 2248512e074SAlan Cox u32 conf; 2258512e074SAlan Cox u32 src; 2268512e074SAlan Cox u32 dpll; 2278512e074SAlan Cox u32 dpll_md; 2288512e074SAlan Cox u32 htotal; 2298512e074SAlan Cox u32 hblank; 2308512e074SAlan Cox u32 hsync; 2318512e074SAlan Cox u32 vtotal; 2328512e074SAlan Cox u32 vblank; 2338512e074SAlan Cox u32 vsync; 2348512e074SAlan Cox u32 stride; 2358512e074SAlan Cox u32 size; 2368512e074SAlan Cox u32 pos; 2378512e074SAlan Cox u32 surf; 2388512e074SAlan Cox u32 addr; 2398512e074SAlan Cox u32 base; 2408512e074SAlan Cox u32 status; 2418512e074SAlan Cox u32 linoff; 2428512e074SAlan Cox u32 tileoff; 2438512e074SAlan Cox u32 palette; 2448512e074SAlan Cox }; 2458512e074SAlan Cox 2468512e074SAlan Cox /* 247648a8e34SAlan Cox * Register save state. This is used to hold the context when the 248648a8e34SAlan Cox * device is powered off. In the case of Oaktrail this can (but does not 249648a8e34SAlan Cox * yet) include screen blank. Operations occuring during the save 250648a8e34SAlan Cox * update the register cache instead. 251648a8e34SAlan Cox */ 2526256304bSAlan Cox 2539083eb38SArthur Borsboom /* Common status for pipes */ 2546256304bSAlan Cox struct psb_pipe { 2556256304bSAlan Cox u32 fp0; 2566256304bSAlan Cox u32 fp1; 2576256304bSAlan Cox u32 cntr; 2586256304bSAlan Cox u32 conf; 2596256304bSAlan Cox u32 src; 2606256304bSAlan Cox u32 dpll; 2616256304bSAlan Cox u32 dpll_md; 2626256304bSAlan Cox u32 htotal; 2636256304bSAlan Cox u32 hblank; 2646256304bSAlan Cox u32 hsync; 2656256304bSAlan Cox u32 vtotal; 2666256304bSAlan Cox u32 vblank; 2676256304bSAlan Cox u32 vsync; 2686256304bSAlan Cox u32 stride; 2696256304bSAlan Cox u32 size; 2706256304bSAlan Cox u32 pos; 2716256304bSAlan Cox u32 base; 2726256304bSAlan Cox u32 surf; 2736256304bSAlan Cox u32 addr; 2746256304bSAlan Cox u32 status; 2756256304bSAlan Cox u32 linoff; 2766256304bSAlan Cox u32 tileoff; 2776256304bSAlan Cox u32 palette[256]; 2786256304bSAlan Cox }; 2796256304bSAlan Cox 280648a8e34SAlan Cox struct psb_state { 281648a8e34SAlan Cox uint32_t saveVCLK_DIVISOR_VGA0; 282648a8e34SAlan Cox uint32_t saveVCLK_DIVISOR_VGA1; 283648a8e34SAlan Cox uint32_t saveVCLK_POST_DIV; 284648a8e34SAlan Cox uint32_t saveVGACNTRL; 285648a8e34SAlan Cox uint32_t saveADPA; 286648a8e34SAlan Cox uint32_t saveLVDS; 287648a8e34SAlan Cox uint32_t saveDVOA; 288648a8e34SAlan Cox uint32_t saveDVOB; 289648a8e34SAlan Cox uint32_t saveDVOC; 290648a8e34SAlan Cox uint32_t savePP_ON; 291648a8e34SAlan Cox uint32_t savePP_OFF; 292648a8e34SAlan Cox uint32_t savePP_CONTROL; 293648a8e34SAlan Cox uint32_t savePP_CYCLE; 294648a8e34SAlan Cox uint32_t savePFIT_CONTROL; 295648a8e34SAlan Cox uint32_t saveCLOCKGATING; 296648a8e34SAlan Cox uint32_t saveDSPARB; 297648a8e34SAlan Cox uint32_t savePFIT_AUTO_RATIOS; 298648a8e34SAlan Cox uint32_t savePFIT_PGM_RATIOS; 299648a8e34SAlan Cox uint32_t savePP_ON_DELAYS; 300648a8e34SAlan Cox uint32_t savePP_OFF_DELAYS; 301648a8e34SAlan Cox uint32_t savePP_DIVISOR; 302648a8e34SAlan Cox uint32_t saveBCLRPAT_A; 303648a8e34SAlan Cox uint32_t saveBCLRPAT_B; 304648a8e34SAlan Cox uint32_t savePERF_MODE; 305648a8e34SAlan Cox uint32_t saveDSPFW1; 306648a8e34SAlan Cox uint32_t saveDSPFW2; 307648a8e34SAlan Cox uint32_t saveDSPFW3; 308648a8e34SAlan Cox uint32_t saveDSPFW4; 309648a8e34SAlan Cox uint32_t saveDSPFW5; 310648a8e34SAlan Cox uint32_t saveDSPFW6; 311648a8e34SAlan Cox uint32_t saveCHICKENBIT; 312648a8e34SAlan Cox uint32_t saveDSPACURSOR_CTRL; 313648a8e34SAlan Cox uint32_t saveDSPBCURSOR_CTRL; 314648a8e34SAlan Cox uint32_t saveDSPACURSOR_BASE; 315648a8e34SAlan Cox uint32_t saveDSPBCURSOR_BASE; 316648a8e34SAlan Cox uint32_t saveDSPACURSOR_POS; 317648a8e34SAlan Cox uint32_t saveDSPBCURSOR_POS; 318648a8e34SAlan Cox uint32_t saveOV_OVADD; 319648a8e34SAlan Cox uint32_t saveOV_OGAMC0; 320648a8e34SAlan Cox uint32_t saveOV_OGAMC1; 321648a8e34SAlan Cox uint32_t saveOV_OGAMC2; 322648a8e34SAlan Cox uint32_t saveOV_OGAMC3; 323648a8e34SAlan Cox uint32_t saveOV_OGAMC4; 324648a8e34SAlan Cox uint32_t saveOV_OGAMC5; 325648a8e34SAlan Cox uint32_t saveOVC_OVADD; 326648a8e34SAlan Cox uint32_t saveOVC_OGAMC0; 327648a8e34SAlan Cox uint32_t saveOVC_OGAMC1; 328648a8e34SAlan Cox uint32_t saveOVC_OGAMC2; 329648a8e34SAlan Cox uint32_t saveOVC_OGAMC3; 330648a8e34SAlan Cox uint32_t saveOVC_OGAMC4; 331648a8e34SAlan Cox uint32_t saveOVC_OGAMC5; 332648a8e34SAlan Cox 333648a8e34SAlan Cox /* DPST register save */ 334648a8e34SAlan Cox uint32_t saveHISTOGRAM_INT_CONTROL_REG; 335648a8e34SAlan Cox uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG; 336648a8e34SAlan Cox uint32_t savePWM_CONTROL_LOGIC; 337648a8e34SAlan Cox }; 338648a8e34SAlan Cox 33909016a11SAlan Cox struct cdv_state { 34009016a11SAlan Cox uint32_t saveDSPCLK_GATE_D; 34109016a11SAlan Cox uint32_t saveRAMCLK_GATE_D; 34209016a11SAlan Cox uint32_t saveDSPARB; 34309016a11SAlan Cox uint32_t saveDSPFW[6]; 34409016a11SAlan Cox uint32_t saveADPA; 34509016a11SAlan Cox uint32_t savePP_CONTROL; 34609016a11SAlan Cox uint32_t savePFIT_PGM_RATIOS; 34709016a11SAlan Cox uint32_t saveLVDS; 34809016a11SAlan Cox uint32_t savePFIT_CONTROL; 34909016a11SAlan Cox uint32_t savePP_ON_DELAYS; 35009016a11SAlan Cox uint32_t savePP_OFF_DELAYS; 35109016a11SAlan Cox uint32_t savePP_CYCLE; 35209016a11SAlan Cox uint32_t saveVGACNTRL; 35309016a11SAlan Cox uint32_t saveIER; 35409016a11SAlan Cox uint32_t saveIMR; 35509016a11SAlan Cox u8 saveLBB; 35609016a11SAlan Cox }; 35709016a11SAlan Cox 358c6265ff5SAlan Cox struct psb_save_area { 3596256304bSAlan Cox struct psb_pipe pipe[3]; 360c6265ff5SAlan Cox uint32_t saveBSM; 361c6265ff5SAlan Cox uint32_t saveVBT; 362c6265ff5SAlan Cox union { 363c6265ff5SAlan Cox struct psb_state psb; 36409016a11SAlan Cox struct cdv_state cdv; 365c6265ff5SAlan Cox }; 366c6265ff5SAlan Cox uint32_t saveBLC_PWM_CTL2; 367c6265ff5SAlan Cox uint32_t saveBLC_PWM_CTL; 368c6265ff5SAlan Cox }; 369c6265ff5SAlan Cox 3705c49fd3aSAlan Cox struct psb_ops; 3715c49fd3aSAlan Cox 37204bd564fSAlan Cox #define PSB_NUM_PIPE 3 37304bd564fSAlan Cox 374bfc838f8SAndy Shevchenko struct intel_scu_ipc_dev; 375bfc838f8SAndy Shevchenko 3765c49fd3aSAlan Cox struct drm_psb_private { 377c2f17e60SThomas Zimmermann struct drm_device dev; 378c2f17e60SThomas Zimmermann 3792657929dSPatrik Jakobsson struct pci_dev *aux_pdev; /* Currently only used by mrst */ 3805a52b1f2SJan Safrata struct pci_dev *lpc_pdev; /* Currently only used by mrst */ 3815c49fd3aSAlan Cox const struct psb_ops *ops; 3828512e074SAlan Cox const struct psb_offset *regmap; 3835c49fd3aSAlan Cox 3841fb28e9eSAlan Cox struct child_device_config *child_dev; 3851fb28e9eSAlan Cox int child_dev_num; 3861fb28e9eSAlan Cox 3875c49fd3aSAlan Cox struct psb_gtt gtt; 3885c49fd3aSAlan Cox 3895c49fd3aSAlan Cox /* GTT Memory manager */ 3905c49fd3aSAlan Cox struct psb_gtt_mm *gtt_mm; 3915c49fd3aSAlan Cox struct page *scratch_page; 392eab37607SKirill A. Shutemov u32 __iomem *gtt_map; 3935c49fd3aSAlan Cox uint32_t stolen_base; 39437214ca0SKirill A. Shutemov u8 __iomem *vram_addr; 3955c49fd3aSAlan Cox unsigned long vram_stolen_size; 3965c49fd3aSAlan Cox u16 gmch_ctrl; /* Saved GTT setup */ 3975c49fd3aSAlan Cox u32 pge_ctl; 3985c49fd3aSAlan Cox 3995c49fd3aSAlan Cox struct mutex gtt_mutex; 4005c49fd3aSAlan Cox struct resource *gtt_mem; /* Our PCI resource */ 4015c49fd3aSAlan Cox 402737292a3SDaniel Vetter struct mutex mmap_mutex; 403737292a3SDaniel Vetter 4045c49fd3aSAlan Cox struct psb_mmu_driver *mmu; 4055c49fd3aSAlan Cox struct psb_mmu_pd *pf_pd; 4065c49fd3aSAlan Cox 4079083eb38SArthur Borsboom /* Register base */ 408846a6038SKirill A. Shutemov uint8_t __iomem *sgx_reg; 409846a6038SKirill A. Shutemov uint8_t __iomem *vdc_reg; 4102657929dSPatrik Jakobsson uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */ 4115a52b1f2SJan Safrata uint16_t lpc_gpio_base; 4125c49fd3aSAlan Cox uint32_t gatt_free_offset; 4135c49fd3aSAlan Cox 4149083eb38SArthur Borsboom /* Fencing / irq */ 4155c49fd3aSAlan Cox uint32_t vdc_irq_mask; 4165c49fd3aSAlan Cox uint32_t pipestat[PSB_NUM_PIPE]; 4175c49fd3aSAlan Cox 4185c49fd3aSAlan Cox spinlock_t irqmask_lock; 419*da596080SSui Jingfeng bool irq_enabled; 4205c49fd3aSAlan Cox 4219083eb38SArthur Borsboom /* Power */ 422672c4735SHans de Goede bool pm_initialized; 4235c49fd3aSAlan Cox 4249083eb38SArthur Borsboom /* Modesetting */ 4255c49fd3aSAlan Cox struct psb_intel_mode_device mode_dev; 4264ab2c7f1SAlan Cox bool modeset; /* true if we have done the mode_device setup */ 4275c49fd3aSAlan Cox 4285c49fd3aSAlan Cox struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE]; 4295c49fd3aSAlan Cox struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE]; 4305c49fd3aSAlan Cox uint32_t num_pipe; 4315c49fd3aSAlan Cox 4329083eb38SArthur Borsboom /* OSPM info (Power management base) (TODO: can go ?) */ 4335c49fd3aSAlan Cox uint32_t ospm_base; 4345c49fd3aSAlan Cox 4359083eb38SArthur Borsboom /* Sizes info */ 4365c49fd3aSAlan Cox u32 fuse_reg_value; 4375c49fd3aSAlan Cox u32 video_device_fuse; 4385c49fd3aSAlan Cox 4395c49fd3aSAlan Cox /* PCI revision ID for B0:D2:F0 */ 4405c49fd3aSAlan Cox uint8_t platform_rev_id; 4415c49fd3aSAlan Cox 4425c0c1d50SPatrik Jakobsson /* gmbus */ 4435c0c1d50SPatrik Jakobsson struct intel_gmbus *gmbus; 4442657929dSPatrik Jakobsson uint8_t __iomem *gmbus_reg; 4455c0c1d50SPatrik Jakobsson 4465736995bSPatrik Jakobsson /* Used by SDVO */ 4475736995bSPatrik Jakobsson int crt_ddc_pin; 4485736995bSPatrik Jakobsson /* FIXME: The mappings should be parsed from bios but for now we can 4495736995bSPatrik Jakobsson pretend there are no mappings available */ 4505736995bSPatrik Jakobsson struct sdvo_device_mapping sdvo_mappings[2]; 4515736995bSPatrik Jakobsson u32 hotplug_supported_mask; 4525736995bSPatrik Jakobsson struct drm_property *broadcast_rgb_property; 4535736995bSPatrik Jakobsson struct drm_property *force_audio_property; 4545736995bSPatrik Jakobsson 4559083eb38SArthur Borsboom /* LVDS info */ 4565c49fd3aSAlan Cox int backlight_duty_cycle; /* restore backlight to this value */ 4575c49fd3aSAlan Cox bool panel_wants_dither; 4585c49fd3aSAlan Cox struct drm_display_mode *panel_fixed_mode; 4595c49fd3aSAlan Cox struct drm_display_mode *lfp_lvds_vbt_mode; 4605c49fd3aSAlan Cox struct drm_display_mode *sdvo_lvds_vbt_mode; 4615c49fd3aSAlan Cox 4625c49fd3aSAlan Cox struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */ 46304477e5eSPatrik Jakobsson struct gma_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */ 4645c49fd3aSAlan Cox 4655c49fd3aSAlan Cox /* Feature bits from the VBIOS */ 4665c49fd3aSAlan Cox unsigned int int_tv_support:1; 4675c49fd3aSAlan Cox unsigned int lvds_dither:1; 4685c49fd3aSAlan Cox unsigned int lvds_vbt:1; 4695c49fd3aSAlan Cox unsigned int int_crt_support:1; 4705c49fd3aSAlan Cox unsigned int lvds_use_ssc:1; 4715c49fd3aSAlan Cox int lvds_ssc_freq; 4725c49fd3aSAlan Cox bool is_lvds_on; 4735c49fd3aSAlan Cox bool is_mipi_on; 4747c420636SPatrik Jakobsson bool lvds_enabled_in_vbt; 4755c49fd3aSAlan Cox u32 mipi_ctrl_display; 4765c49fd3aSAlan Cox 4775c49fd3aSAlan Cox unsigned int core_freq; 4785c49fd3aSAlan Cox uint32_t iLVDS_enable; 4795c49fd3aSAlan Cox 4805c49fd3aSAlan Cox /* MID specific */ 4819b6a1657SHans de Goede bool use_msi; 4824086b1e2SKirill A. Shutemov bool has_gct; 4835c49fd3aSAlan Cox struct oaktrail_gct_data gct_data; 4845c49fd3aSAlan Cox 485933315acSAlan Cox /* Oaktrail HDMI state */ 4865c49fd3aSAlan Cox struct oaktrail_hdmi_dev *hdmi_priv; 4875c49fd3aSAlan Cox 4889083eb38SArthur Borsboom /* Register state */ 489c6265ff5SAlan Cox struct psb_save_area regs; 490c6265ff5SAlan Cox 4919083eb38SArthur Borsboom /* Hotplug handling */ 492ae0a246aSAlan Cox struct work_struct hotplug_work; 4935c49fd3aSAlan Cox 4949083eb38SArthur Borsboom /* LID-Switch */ 4955c49fd3aSAlan Cox spinlock_t lid_lock; 4965c49fd3aSAlan Cox struct timer_list lid_timer; 4975c49fd3aSAlan Cox struct psb_intel_opregion opregion; 4985c49fd3aSAlan Cox u32 lid_last_state; 4995c49fd3aSAlan Cox 5009083eb38SArthur Borsboom /* Watchdog */ 5015c49fd3aSAlan Cox uint32_t apm_reg; 5025c49fd3aSAlan Cox uint16_t apm_base; 5035c49fd3aSAlan Cox 5045c49fd3aSAlan Cox /* 5055c49fd3aSAlan Cox * Used for modifying backlight from 5065c49fd3aSAlan Cox * xrandr -- consider removing and using HAL instead 5075c49fd3aSAlan Cox */ 508bfc838f8SAndy Shevchenko struct intel_scu_ipc_dev *scu; 5095c49fd3aSAlan Cox struct backlight_device *backlight_device; 5105c49fd3aSAlan Cox struct drm_property *backlight_property; 511d112a816SZhao Yakui bool backlight_enabled; 512d112a816SZhao Yakui int backlight_level; 5135c49fd3aSAlan Cox uint32_t blc_adj1; 5145c49fd3aSAlan Cox uint32_t blc_adj2; 5155c49fd3aSAlan Cox 516026abc33SKirill A. Shutemov bool dsr_enable; 517026abc33SKirill A. Shutemov u32 dsr_fb_update; 518026abc33SKirill A. Shutemov bool dpi_panel_on[3]; 519026abc33SKirill A. Shutemov void *dsi_configs[2]; 520026abc33SKirill A. Shutemov u32 bpp; 521026abc33SKirill A. Shutemov u32 bpp2; 522026abc33SKirill A. Shutemov 523026abc33SKirill A. Shutemov u32 pipeconf[3]; 524026abc33SKirill A. Shutemov u32 dspcntr[3]; 525026abc33SKirill A. Shutemov 526642c52fcSAlan Cox bool dplla_96mhz; /* DPLL data from the VBT */ 527d112a816SZhao Yakui 528d112a816SZhao Yakui struct { 529d112a816SZhao Yakui int rate; 530d112a816SZhao Yakui int lanes; 531d112a816SZhao Yakui int preemphasis; 532d112a816SZhao Yakui int vswing; 533d112a816SZhao Yakui 534d112a816SZhao Yakui bool initialized; 535d112a816SZhao Yakui bool support; 536d112a816SZhao Yakui int bpp; 537d112a816SZhao Yakui struct edp_power_seq pps; 538d112a816SZhao Yakui } edp; 539d112a816SZhao Yakui uint8_t panel_type; 5405c49fd3aSAlan Cox }; 5415c49fd3aSAlan Cox 542f71635e8SThomas Zimmermann static inline struct drm_psb_private *to_drm_psb_private(struct drm_device *dev) 543f71635e8SThomas Zimmermann { 544c2f17e60SThomas Zimmermann return container_of(dev, struct drm_psb_private, dev); 545f71635e8SThomas Zimmermann } 5465c49fd3aSAlan Cox 5479083eb38SArthur Borsboom /* Operations for each board type */ 5485c49fd3aSAlan Cox struct psb_ops { 5495c49fd3aSAlan Cox const char *name; 5505c49fd3aSAlan Cox int pipes; /* Number of output pipes */ 5515c49fd3aSAlan Cox int crtcs; /* Number of CRTCs */ 5525c49fd3aSAlan Cox int sgx_offset; /* Base offset of SGX device */ 553d235e64aSAlan Cox int hdmi_mask; /* Mask of HDMI CRTCs */ 554d235e64aSAlan Cox int lvds_mask; /* Mask of LVDS CRTCs */ 555cf8efd3aSPatrik Jakobsson int sdvo_mask; /* Mask of SDVO CRTCs */ 556bc794829SPatrik Jakobsson int cursor_needs_phys; /* If cursor base reg need physical address */ 5575c49fd3aSAlan Cox 5585c49fd3aSAlan Cox /* Sub functions */ 5595c49fd3aSAlan Cox struct drm_crtc_helper_funcs const *crtc_helper; 5605ea75e0fSPatrik Jakobsson const struct gma_clock_funcs *clock_funcs; 5615c49fd3aSAlan Cox 5625c49fd3aSAlan Cox /* Setup hooks */ 5635c49fd3aSAlan Cox int (*chip_setup)(struct drm_device *dev); 5645c49fd3aSAlan Cox void (*chip_teardown)(struct drm_device *dev); 565d235e64aSAlan Cox /* Optional helper caller after modeset */ 566d235e64aSAlan Cox void (*errata)(struct drm_device *dev); 5675c49fd3aSAlan Cox 5685c49fd3aSAlan Cox /* Display management hooks */ 5695c49fd3aSAlan Cox int (*output_init)(struct drm_device *dev); 57068cb638fSAlan Cox int (*hotplug)(struct drm_device *dev); 57168cb638fSAlan Cox void (*hotplug_enable)(struct drm_device *dev, bool on); 5725c49fd3aSAlan Cox /* Power management hooks */ 5735c49fd3aSAlan Cox void (*init_pm)(struct drm_device *dev); 5745c49fd3aSAlan Cox int (*save_regs)(struct drm_device *dev); 5755c49fd3aSAlan Cox int (*restore_regs)(struct drm_device *dev); 576d56f57acSDaniel Vetter void (*save_crtc)(struct drm_crtc *crtc); 577d56f57acSDaniel Vetter void (*restore_crtc)(struct drm_crtc *crtc); 5785c49fd3aSAlan Cox int (*power_up)(struct drm_device *dev); 5795c49fd3aSAlan Cox int (*power_down)(struct drm_device *dev); 58028a8194cSPatrik Jakobsson void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc); 58175346fe9SPatrik Jakobsson void (*disable_sr)(struct drm_device *dev); 5825c49fd3aSAlan Cox 5835c49fd3aSAlan Cox void (*lvds_bl_power)(struct drm_device *dev, bool on); 5841f90b123SHans de Goede 5855c49fd3aSAlan Cox /* Backlight */ 5865c49fd3aSAlan Cox int (*backlight_init)(struct drm_device *dev); 5871f90b123SHans de Goede void (*backlight_set)(struct drm_device *dev, int level); 5881f90b123SHans de Goede int (*backlight_get)(struct drm_device *dev); 5891f90b123SHans de Goede const char *backlight_name; 5901f90b123SHans de Goede 5915c49fd3aSAlan Cox int i2c_bus; /* I2C bus identifier for Moorestown */ 5925c49fd3aSAlan Cox }; 5935c49fd3aSAlan Cox 5943138ba6eSPatrik Jakobsson /* psb_lid.c */ 5955c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv); 5965c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv); 5975c49fd3aSAlan Cox 5985c49fd3aSAlan Cox /* modesetting */ 5995c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev); 6005c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev); 601b8bbbea1SThomas Zimmermann 602b8bbbea1SThomas Zimmermann /* framebuffer */ 603b8bbbea1SThomas Zimmermann struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev, 604b8bbbea1SThomas Zimmermann const struct drm_mode_fb_cmd2 *mode_cmd, 605b8bbbea1SThomas Zimmermann struct drm_gem_object *obj); 606b8bbbea1SThomas Zimmermann 607b8bbbea1SThomas Zimmermann /* fbdev */ 608b8bbbea1SThomas Zimmermann #if defined(CONFIG_DRM_FBDEV_EMULATION) 6098f1aaccbSThomas Zimmermann void psb_fbdev_setup(struct drm_psb_private *dev_priv); 610b8bbbea1SThomas Zimmermann #else 6118f1aaccbSThomas Zimmermann static inline void psb_fbdev_setup(struct drm_psb_private *dev_priv) 612b8bbbea1SThomas Zimmermann { } 613b8bbbea1SThomas Zimmermann #endif 6145c49fd3aSAlan Cox 6155c49fd3aSAlan Cox /* backlight.c */ 6165c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev); 6175c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev); 618d112a816SZhao Yakui void gma_backlight_disable(struct drm_device *dev); 619d112a816SZhao Yakui void gma_backlight_enable(struct drm_device *dev); 620d112a816SZhao Yakui void gma_backlight_set(struct drm_device *dev, int v); 6215c49fd3aSAlan Cox 6225c49fd3aSAlan Cox /* oaktrail_crtc.c */ 6235c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs; 6245c49fd3aSAlan Cox 6255c49fd3aSAlan Cox /* oaktrail_lvds.c */ 6265c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev, 6275c49fd3aSAlan Cox struct psb_intel_mode_device *mode_dev); 6285c49fd3aSAlan Cox 6295c49fd3aSAlan Cox /* psb_intel_display.c */ 6305c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs; 6315c49fd3aSAlan Cox 6325c49fd3aSAlan Cox /* psb_intel_lvds.c */ 6335c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs 6345c49fd3aSAlan Cox psb_intel_lvds_connector_helper_funcs; 6355c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs; 6365c49fd3aSAlan Cox 6375c49fd3aSAlan Cox /* gem.c */ 6385c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, 6395c49fd3aSAlan Cox struct drm_mode_create_dumb *args); 6405c49fd3aSAlan Cox 6415c49fd3aSAlan Cox /* psb_device.c */ 6425c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops; 6435c49fd3aSAlan Cox 6445c49fd3aSAlan Cox /* oaktrail_device.c */ 6455c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops; 6465c49fd3aSAlan Cox 6475c49fd3aSAlan Cox /* cdv_device.c */ 6485c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops; 6495c49fd3aSAlan Cox 6509083eb38SArthur Borsboom /* Utilities */ 6515c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg) 6525c49fd3aSAlan Cox { 653f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6545c49fd3aSAlan Cox return ioread32(dev_priv->vdc_reg + reg); 6555c49fd3aSAlan Cox } 6565c49fd3aSAlan Cox 6572657929dSPatrik Jakobsson static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg) 6582657929dSPatrik Jakobsson { 659f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6602657929dSPatrik Jakobsson return ioread32(dev_priv->aux_reg + reg); 6612657929dSPatrik Jakobsson } 6622657929dSPatrik Jakobsson 6635c49fd3aSAlan Cox #define REG_READ(reg) REGISTER_READ(dev, (reg)) 6642657929dSPatrik Jakobsson #define REG_READ_AUX(reg) REGISTER_READ_AUX(dev, (reg)) 6655c49fd3aSAlan Cox 666b97b8287SPatrik Jakobsson /* Useful for post reads */ 667b97b8287SPatrik Jakobsson static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev, 668b97b8287SPatrik Jakobsson uint32_t reg, int aux) 669b97b8287SPatrik Jakobsson { 670b97b8287SPatrik Jakobsson uint32_t val; 671b97b8287SPatrik Jakobsson 672b97b8287SPatrik Jakobsson if (aux) 673b97b8287SPatrik Jakobsson val = REG_READ_AUX(reg); 674b97b8287SPatrik Jakobsson else 675b97b8287SPatrik Jakobsson val = REG_READ(reg); 676b97b8287SPatrik Jakobsson 677b97b8287SPatrik Jakobsson return val; 678b97b8287SPatrik Jakobsson } 679b97b8287SPatrik Jakobsson 680b97b8287SPatrik Jakobsson #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux)) 681b97b8287SPatrik Jakobsson 6825c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg, 6835c49fd3aSAlan Cox uint32_t val) 6845c49fd3aSAlan Cox { 685f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6865c49fd3aSAlan Cox iowrite32((val), dev_priv->vdc_reg + (reg)); 6875c49fd3aSAlan Cox } 6885c49fd3aSAlan Cox 6892657929dSPatrik Jakobsson static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg, 6902657929dSPatrik Jakobsson uint32_t val) 6912657929dSPatrik Jakobsson { 692f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 6932657929dSPatrik Jakobsson iowrite32((val), dev_priv->aux_reg + (reg)); 6942657929dSPatrik Jakobsson } 6952657929dSPatrik Jakobsson 6965c49fd3aSAlan Cox #define REG_WRITE(reg, val) REGISTER_WRITE(dev, (reg), (val)) 6972657929dSPatrik Jakobsson #define REG_WRITE_AUX(reg, val) REGISTER_WRITE_AUX(dev, (reg), (val)) 6985c49fd3aSAlan Cox 699b97b8287SPatrik Jakobsson static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg, 700b97b8287SPatrik Jakobsson uint32_t val, int aux) 701b97b8287SPatrik Jakobsson { 702b97b8287SPatrik Jakobsson if (aux) 703b97b8287SPatrik Jakobsson REG_WRITE_AUX(reg, val); 704b97b8287SPatrik Jakobsson else 705b97b8287SPatrik Jakobsson REG_WRITE(reg, val); 706b97b8287SPatrik Jakobsson } 707b97b8287SPatrik Jakobsson 708b97b8287SPatrik Jakobsson #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux)) 709b97b8287SPatrik Jakobsson 7105c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev, 7115c49fd3aSAlan Cox uint32_t reg, uint32_t val) 7125c49fd3aSAlan Cox { 713f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 7145c49fd3aSAlan Cox iowrite16((val), dev_priv->vdc_reg + (reg)); 7155c49fd3aSAlan Cox } 7165c49fd3aSAlan Cox 7175c49fd3aSAlan Cox #define REG_WRITE16(reg, val) REGISTER_WRITE16(dev, (reg), (val)) 7185c49fd3aSAlan Cox 7195c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev, 7205c49fd3aSAlan Cox uint32_t reg, uint32_t val) 7215c49fd3aSAlan Cox { 722f71635e8SThomas Zimmermann struct drm_psb_private *dev_priv = to_drm_psb_private(dev); 7235c49fd3aSAlan Cox iowrite8((val), dev_priv->vdc_reg + (reg)); 7245c49fd3aSAlan Cox } 7255c49fd3aSAlan Cox 7265c49fd3aSAlan Cox #define REG_WRITE8(reg, val) REGISTER_WRITE8(dev, (reg), (val)) 7275c49fd3aSAlan Cox 7285c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs) iowrite32(_val, dev_priv->vdc_reg + (_offs)) 7295c49fd3aSAlan Cox #define PSB_RVDC32(_offs) ioread32(dev_priv->vdc_reg + (_offs)) 7305c49fd3aSAlan Cox 7315c49fd3aSAlan Cox #define PSB_RSGX32(_offs) ioread32(dev_priv->sgx_reg + (_offs)) 7325c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs) iowrite32(_val, dev_priv->sgx_reg + (_offs)) 7335c49fd3aSAlan Cox 7345c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs) iowrite32(_val, dev_priv->msvdx_reg + (_offs)) 7355c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs) ioread32(dev_priv->msvdx_reg + (_offs)) 7365c49fd3aSAlan Cox 7375c49fd3aSAlan Cox #endif 738