xref: /linux/drivers/gpu/drm/gma500/psb_drv.h (revision 1f90b1232773249d924868bec3c31525a69fd482)
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 
175*1f90b123SHans de Goede #define PSB_MAX_BRIGHTNESS		100
176*1f90b123SHans de Goede 
1775c49fd3aSAlan Cox #define PSB_PWR_STATE_ON		1
1785c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF		2
1795c49fd3aSAlan Cox 
1805c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM		0
1815c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING	1
1825c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN		2
1835c49fd3aSAlan Cox 
1845c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP		0
1855c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED		1
1865c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN		2
1875c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC		0x94
1885c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC		0x98
1895c49fd3aSAlan Cox 
1905c49fd3aSAlan Cox /* Medfield crystal settings */
1915c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1
1925c49fd3aSAlan Cox #define KSEL_BYPASS_19 5
1935c49fd3aSAlan Cox #define KSEL_BYPASS_25 6
1945c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7
1955c49fd3aSAlan Cox 
1966b7ce2c4SThomas Zimmermann struct drm_fb_helper;
1976b7ce2c4SThomas Zimmermann 
1985c49fd3aSAlan Cox struct opregion_header;
1995c49fd3aSAlan Cox struct opregion_acpi;
2005c49fd3aSAlan Cox struct opregion_swsci;
2015c49fd3aSAlan Cox struct opregion_asle;
2025c49fd3aSAlan Cox 
2035c49fd3aSAlan Cox struct psb_intel_opregion {
2045c49fd3aSAlan Cox 	struct opregion_header *header;
2055c49fd3aSAlan Cox 	struct opregion_acpi *acpi;
2065c49fd3aSAlan Cox 	struct opregion_swsci *swsci;
2075c49fd3aSAlan Cox 	struct opregion_asle *asle;
2081fb28e9eSAlan Cox 	void *vbt;
209d839ede4SAlan Cox 	u32 __iomem *lid_state;
210778e26deSPatrik Jakobsson 	struct work_struct asle_work;
2115c49fd3aSAlan Cox };
2125c49fd3aSAlan Cox 
2135736995bSPatrik Jakobsson struct sdvo_device_mapping {
2145736995bSPatrik Jakobsson 	u8 initialized;
2155736995bSPatrik Jakobsson 	u8 dvo_port;
2165736995bSPatrik Jakobsson 	u8 slave_addr;
2175736995bSPatrik Jakobsson 	u8 dvo_wiring;
2185736995bSPatrik Jakobsson 	u8 i2c_pin;
2195736995bSPatrik Jakobsson 	u8 i2c_speed;
2205736995bSPatrik Jakobsson 	u8 ddc_pin;
2215736995bSPatrik Jakobsson };
2225736995bSPatrik Jakobsson 
2235c0c1d50SPatrik Jakobsson struct intel_gmbus {
2245c0c1d50SPatrik Jakobsson 	struct i2c_adapter adapter;
2255c0c1d50SPatrik Jakobsson 	struct i2c_adapter *force_bit;
2265c0c1d50SPatrik Jakobsson 	u32 reg0;
2275c0c1d50SPatrik Jakobsson };
2285c0c1d50SPatrik Jakobsson 
2299083eb38SArthur Borsboom /* Register offset maps */
2308512e074SAlan Cox struct psb_offset {
2318512e074SAlan Cox 	u32	fp0;
2328512e074SAlan Cox 	u32	fp1;
2338512e074SAlan Cox 	u32	cntr;
2348512e074SAlan Cox 	u32	conf;
2358512e074SAlan Cox 	u32	src;
2368512e074SAlan Cox 	u32	dpll;
2378512e074SAlan Cox 	u32	dpll_md;
2388512e074SAlan Cox 	u32	htotal;
2398512e074SAlan Cox 	u32	hblank;
2408512e074SAlan Cox 	u32	hsync;
2418512e074SAlan Cox 	u32	vtotal;
2428512e074SAlan Cox 	u32	vblank;
2438512e074SAlan Cox 	u32	vsync;
2448512e074SAlan Cox 	u32	stride;
2458512e074SAlan Cox 	u32	size;
2468512e074SAlan Cox 	u32	pos;
2478512e074SAlan Cox 	u32	surf;
2488512e074SAlan Cox 	u32	addr;
2498512e074SAlan Cox 	u32	base;
2508512e074SAlan Cox 	u32	status;
2518512e074SAlan Cox 	u32	linoff;
2528512e074SAlan Cox 	u32	tileoff;
2538512e074SAlan Cox 	u32	palette;
2548512e074SAlan Cox };
2558512e074SAlan Cox 
2568512e074SAlan Cox /*
257648a8e34SAlan Cox  *	Register save state. This is used to hold the context when the
258648a8e34SAlan Cox  *	device is powered off. In the case of Oaktrail this can (but does not
259648a8e34SAlan Cox  *	yet) include screen blank. Operations occuring during the save
260648a8e34SAlan Cox  *	update the register cache instead.
261648a8e34SAlan Cox  */
2626256304bSAlan Cox 
2639083eb38SArthur Borsboom /* Common status for pipes */
2646256304bSAlan Cox struct psb_pipe {
2656256304bSAlan Cox 	u32	fp0;
2666256304bSAlan Cox 	u32	fp1;
2676256304bSAlan Cox 	u32	cntr;
2686256304bSAlan Cox 	u32	conf;
2696256304bSAlan Cox 	u32	src;
2706256304bSAlan Cox 	u32	dpll;
2716256304bSAlan Cox 	u32	dpll_md;
2726256304bSAlan Cox 	u32	htotal;
2736256304bSAlan Cox 	u32	hblank;
2746256304bSAlan Cox 	u32	hsync;
2756256304bSAlan Cox 	u32	vtotal;
2766256304bSAlan Cox 	u32	vblank;
2776256304bSAlan Cox 	u32	vsync;
2786256304bSAlan Cox 	u32	stride;
2796256304bSAlan Cox 	u32	size;
2806256304bSAlan Cox 	u32	pos;
2816256304bSAlan Cox 	u32	base;
2826256304bSAlan Cox 	u32	surf;
2836256304bSAlan Cox 	u32	addr;
2846256304bSAlan Cox 	u32	status;
2856256304bSAlan Cox 	u32	linoff;
2866256304bSAlan Cox 	u32	tileoff;
2876256304bSAlan Cox 	u32	palette[256];
2886256304bSAlan Cox };
2896256304bSAlan Cox 
290648a8e34SAlan Cox struct psb_state {
291648a8e34SAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA0;
292648a8e34SAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA1;
293648a8e34SAlan Cox 	uint32_t saveVCLK_POST_DIV;
294648a8e34SAlan Cox 	uint32_t saveVGACNTRL;
295648a8e34SAlan Cox 	uint32_t saveADPA;
296648a8e34SAlan Cox 	uint32_t saveLVDS;
297648a8e34SAlan Cox 	uint32_t saveDVOA;
298648a8e34SAlan Cox 	uint32_t saveDVOB;
299648a8e34SAlan Cox 	uint32_t saveDVOC;
300648a8e34SAlan Cox 	uint32_t savePP_ON;
301648a8e34SAlan Cox 	uint32_t savePP_OFF;
302648a8e34SAlan Cox 	uint32_t savePP_CONTROL;
303648a8e34SAlan Cox 	uint32_t savePP_CYCLE;
304648a8e34SAlan Cox 	uint32_t savePFIT_CONTROL;
305648a8e34SAlan Cox 	uint32_t saveCLOCKGATING;
306648a8e34SAlan Cox 	uint32_t saveDSPARB;
307648a8e34SAlan Cox 	uint32_t savePFIT_AUTO_RATIOS;
308648a8e34SAlan Cox 	uint32_t savePFIT_PGM_RATIOS;
309648a8e34SAlan Cox 	uint32_t savePP_ON_DELAYS;
310648a8e34SAlan Cox 	uint32_t savePP_OFF_DELAYS;
311648a8e34SAlan Cox 	uint32_t savePP_DIVISOR;
312648a8e34SAlan Cox 	uint32_t saveBCLRPAT_A;
313648a8e34SAlan Cox 	uint32_t saveBCLRPAT_B;
314648a8e34SAlan Cox 	uint32_t savePERF_MODE;
315648a8e34SAlan Cox 	uint32_t saveDSPFW1;
316648a8e34SAlan Cox 	uint32_t saveDSPFW2;
317648a8e34SAlan Cox 	uint32_t saveDSPFW3;
318648a8e34SAlan Cox 	uint32_t saveDSPFW4;
319648a8e34SAlan Cox 	uint32_t saveDSPFW5;
320648a8e34SAlan Cox 	uint32_t saveDSPFW6;
321648a8e34SAlan Cox 	uint32_t saveCHICKENBIT;
322648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_CTRL;
323648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_CTRL;
324648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_BASE;
325648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_BASE;
326648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_POS;
327648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_POS;
328648a8e34SAlan Cox 	uint32_t saveOV_OVADD;
329648a8e34SAlan Cox 	uint32_t saveOV_OGAMC0;
330648a8e34SAlan Cox 	uint32_t saveOV_OGAMC1;
331648a8e34SAlan Cox 	uint32_t saveOV_OGAMC2;
332648a8e34SAlan Cox 	uint32_t saveOV_OGAMC3;
333648a8e34SAlan Cox 	uint32_t saveOV_OGAMC4;
334648a8e34SAlan Cox 	uint32_t saveOV_OGAMC5;
335648a8e34SAlan Cox 	uint32_t saveOVC_OVADD;
336648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC0;
337648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC1;
338648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC2;
339648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC3;
340648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC4;
341648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC5;
342648a8e34SAlan Cox 
343648a8e34SAlan Cox 	/* DPST register save */
344648a8e34SAlan Cox 	uint32_t saveHISTOGRAM_INT_CONTROL_REG;
345648a8e34SAlan Cox 	uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
346648a8e34SAlan Cox 	uint32_t savePWM_CONTROL_LOGIC;
347648a8e34SAlan Cox };
348648a8e34SAlan Cox 
34909016a11SAlan Cox struct cdv_state {
35009016a11SAlan Cox 	uint32_t saveDSPCLK_GATE_D;
35109016a11SAlan Cox 	uint32_t saveRAMCLK_GATE_D;
35209016a11SAlan Cox 	uint32_t saveDSPARB;
35309016a11SAlan Cox 	uint32_t saveDSPFW[6];
35409016a11SAlan Cox 	uint32_t saveADPA;
35509016a11SAlan Cox 	uint32_t savePP_CONTROL;
35609016a11SAlan Cox 	uint32_t savePFIT_PGM_RATIOS;
35709016a11SAlan Cox 	uint32_t saveLVDS;
35809016a11SAlan Cox 	uint32_t savePFIT_CONTROL;
35909016a11SAlan Cox 	uint32_t savePP_ON_DELAYS;
36009016a11SAlan Cox 	uint32_t savePP_OFF_DELAYS;
36109016a11SAlan Cox 	uint32_t savePP_CYCLE;
36209016a11SAlan Cox 	uint32_t saveVGACNTRL;
36309016a11SAlan Cox 	uint32_t saveIER;
36409016a11SAlan Cox 	uint32_t saveIMR;
36509016a11SAlan Cox 	u8	 saveLBB;
36609016a11SAlan Cox };
36709016a11SAlan Cox 
368c6265ff5SAlan Cox struct psb_save_area {
3696256304bSAlan Cox 	struct psb_pipe pipe[3];
370c6265ff5SAlan Cox 	uint32_t saveBSM;
371c6265ff5SAlan Cox 	uint32_t saveVBT;
372c6265ff5SAlan Cox 	union {
373c6265ff5SAlan Cox 	        struct psb_state psb;
37409016a11SAlan Cox 		struct cdv_state cdv;
375c6265ff5SAlan Cox 	};
376c6265ff5SAlan Cox 	uint32_t saveBLC_PWM_CTL2;
377c6265ff5SAlan Cox 	uint32_t saveBLC_PWM_CTL;
378c6265ff5SAlan Cox };
379c6265ff5SAlan Cox 
3805c49fd3aSAlan Cox struct psb_ops;
3815c49fd3aSAlan Cox 
38204bd564fSAlan Cox #define PSB_NUM_PIPE		3
38304bd564fSAlan Cox 
384bfc838f8SAndy Shevchenko struct intel_scu_ipc_dev;
385bfc838f8SAndy Shevchenko 
3865c49fd3aSAlan Cox struct drm_psb_private {
387c2f17e60SThomas Zimmermann 	struct drm_device dev;
388c2f17e60SThomas Zimmermann 
3892657929dSPatrik Jakobsson 	struct pci_dev *aux_pdev; /* Currently only used by mrst */
3905a52b1f2SJan Safrata 	struct pci_dev *lpc_pdev; /* Currently only used by mrst */
3915c49fd3aSAlan Cox 	const struct psb_ops *ops;
3928512e074SAlan Cox 	const struct psb_offset *regmap;
3935c49fd3aSAlan Cox 
3941fb28e9eSAlan Cox 	struct child_device_config *child_dev;
3951fb28e9eSAlan Cox 	int child_dev_num;
3961fb28e9eSAlan Cox 
3975c49fd3aSAlan Cox 	struct psb_gtt gtt;
3985c49fd3aSAlan Cox 
3995c49fd3aSAlan Cox 	/* GTT Memory manager */
4005c49fd3aSAlan Cox 	struct psb_gtt_mm *gtt_mm;
4015c49fd3aSAlan Cox 	struct page *scratch_page;
402eab37607SKirill A. Shutemov 	u32 __iomem *gtt_map;
4035c49fd3aSAlan Cox 	uint32_t stolen_base;
40437214ca0SKirill A. Shutemov 	u8 __iomem *vram_addr;
4055c49fd3aSAlan Cox 	unsigned long vram_stolen_size;
4065c49fd3aSAlan Cox 	u16 gmch_ctrl;		/* Saved GTT setup */
4075c49fd3aSAlan Cox 	u32 pge_ctl;
4085c49fd3aSAlan Cox 
4095c49fd3aSAlan Cox 	struct mutex gtt_mutex;
4105c49fd3aSAlan Cox 	struct resource *gtt_mem;	/* Our PCI resource */
4115c49fd3aSAlan Cox 
412737292a3SDaniel Vetter 	struct mutex mmap_mutex;
413737292a3SDaniel Vetter 
4145c49fd3aSAlan Cox 	struct psb_mmu_driver *mmu;
4155c49fd3aSAlan Cox 	struct psb_mmu_pd *pf_pd;
4165c49fd3aSAlan Cox 
4179083eb38SArthur Borsboom 	/* Register base */
418846a6038SKirill A. Shutemov 	uint8_t __iomem *sgx_reg;
419846a6038SKirill A. Shutemov 	uint8_t __iomem *vdc_reg;
4202657929dSPatrik Jakobsson 	uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */
4215a52b1f2SJan Safrata 	uint16_t lpc_gpio_base;
4225c49fd3aSAlan Cox 	uint32_t gatt_free_offset;
4235c49fd3aSAlan Cox 
4249083eb38SArthur Borsboom 	/* Fencing / irq */
4255c49fd3aSAlan Cox 	uint32_t vdc_irq_mask;
4265c49fd3aSAlan Cox 	uint32_t pipestat[PSB_NUM_PIPE];
4275c49fd3aSAlan Cox 
4285c49fd3aSAlan Cox 	spinlock_t irqmask_lock;
4295c49fd3aSAlan Cox 
4309083eb38SArthur Borsboom 	/* Power */
431672c4735SHans de Goede 	bool pm_initialized;
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 */
47204477e5eSPatrik 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 	/* MID specific */
4909b6a1657SHans de Goede 	bool use_msi;
4914086b1e2SKirill A. Shutemov 	bool has_gct;
4925c49fd3aSAlan Cox 	struct oaktrail_gct_data gct_data;
4935c49fd3aSAlan Cox 
494933315acSAlan Cox 	/* Oaktrail HDMI state */
4955c49fd3aSAlan Cox 	struct oaktrail_hdmi_dev *hdmi_priv;
4965c49fd3aSAlan Cox 
4979083eb38SArthur Borsboom 	/* Register state */
498c6265ff5SAlan Cox 	struct psb_save_area regs;
499c6265ff5SAlan Cox 
5009083eb38SArthur Borsboom 	/* Hotplug handling */
501ae0a246aSAlan Cox 	struct work_struct hotplug_work;
5025c49fd3aSAlan Cox 
5039083eb38SArthur Borsboom 	/* LID-Switch */
5045c49fd3aSAlan Cox 	spinlock_t lid_lock;
5055c49fd3aSAlan Cox 	struct timer_list lid_timer;
5065c49fd3aSAlan Cox 	struct psb_intel_opregion opregion;
5075c49fd3aSAlan Cox 	u32 lid_last_state;
5085c49fd3aSAlan Cox 
5099083eb38SArthur Borsboom 	/* Watchdog */
5105c49fd3aSAlan Cox 	uint32_t apm_reg;
5115c49fd3aSAlan Cox 	uint16_t apm_base;
5125c49fd3aSAlan Cox 
5135c49fd3aSAlan Cox 	/*
5145c49fd3aSAlan Cox 	 * Used for modifying backlight from
5155c49fd3aSAlan Cox 	 * xrandr -- consider removing and using HAL instead
5165c49fd3aSAlan Cox 	 */
517bfc838f8SAndy Shevchenko 	struct intel_scu_ipc_dev *scu;
5185c49fd3aSAlan Cox 	struct backlight_device *backlight_device;
5195c49fd3aSAlan Cox 	struct drm_property *backlight_property;
520d112a816SZhao Yakui 	bool backlight_enabled;
521d112a816SZhao Yakui 	int backlight_level;
5225c49fd3aSAlan Cox 	uint32_t blc_adj1;
5235c49fd3aSAlan Cox 	uint32_t blc_adj2;
5245c49fd3aSAlan Cox 
5256b7ce2c4SThomas Zimmermann 	struct drm_fb_helper *fb_helper;
5265c49fd3aSAlan Cox 
527026abc33SKirill A. Shutemov 	bool dsr_enable;
528026abc33SKirill A. Shutemov 	u32 dsr_fb_update;
529026abc33SKirill A. Shutemov 	bool dpi_panel_on[3];
530026abc33SKirill A. Shutemov 	void *dsi_configs[2];
531026abc33SKirill A. Shutemov 	u32 bpp;
532026abc33SKirill A. Shutemov 	u32 bpp2;
533026abc33SKirill A. Shutemov 
534026abc33SKirill A. Shutemov 	u32 pipeconf[3];
535026abc33SKirill A. Shutemov 	u32 dspcntr[3];
536026abc33SKirill A. Shutemov 
537642c52fcSAlan Cox 	bool dplla_96mhz;	/* DPLL data from the VBT */
538d112a816SZhao Yakui 
539d112a816SZhao Yakui 	struct {
540d112a816SZhao Yakui 		int rate;
541d112a816SZhao Yakui 		int lanes;
542d112a816SZhao Yakui 		int preemphasis;
543d112a816SZhao Yakui 		int vswing;
544d112a816SZhao Yakui 
545d112a816SZhao Yakui 		bool initialized;
546d112a816SZhao Yakui 		bool support;
547d112a816SZhao Yakui 		int bpp;
548d112a816SZhao Yakui 		struct edp_power_seq pps;
549d112a816SZhao Yakui 	} edp;
550d112a816SZhao Yakui 	uint8_t panel_type;
5515c49fd3aSAlan Cox };
5525c49fd3aSAlan Cox 
553f71635e8SThomas Zimmermann static inline struct drm_psb_private *to_drm_psb_private(struct drm_device *dev)
554f71635e8SThomas Zimmermann {
555c2f17e60SThomas Zimmermann 	return container_of(dev, struct drm_psb_private, dev);
556f71635e8SThomas Zimmermann }
5575c49fd3aSAlan Cox 
5589083eb38SArthur Borsboom /* Operations for each board type */
5595c49fd3aSAlan Cox struct psb_ops {
5605c49fd3aSAlan Cox 	const char *name;
5615c49fd3aSAlan Cox 	int pipes;		/* Number of output pipes */
5625c49fd3aSAlan Cox 	int crtcs;		/* Number of CRTCs */
5635c49fd3aSAlan Cox 	int sgx_offset;		/* Base offset of SGX device */
564d235e64aSAlan Cox 	int hdmi_mask;		/* Mask of HDMI CRTCs */
565d235e64aSAlan Cox 	int lvds_mask;		/* Mask of LVDS CRTCs */
566cf8efd3aSPatrik Jakobsson 	int sdvo_mask;		/* Mask of SDVO CRTCs */
567bc794829SPatrik Jakobsson 	int cursor_needs_phys;  /* If cursor base reg need physical address */
5685c49fd3aSAlan Cox 
5695c49fd3aSAlan Cox 	/* Sub functions */
5705c49fd3aSAlan Cox 	struct drm_crtc_helper_funcs const *crtc_helper;
5715ea75e0fSPatrik Jakobsson 	const struct gma_clock_funcs *clock_funcs;
5725c49fd3aSAlan Cox 
5735c49fd3aSAlan Cox 	/* Setup hooks */
5745c49fd3aSAlan Cox 	int (*chip_setup)(struct drm_device *dev);
5755c49fd3aSAlan Cox 	void (*chip_teardown)(struct drm_device *dev);
576d235e64aSAlan Cox 	/* Optional helper caller after modeset */
577d235e64aSAlan Cox 	void (*errata)(struct drm_device *dev);
5785c49fd3aSAlan Cox 
5795c49fd3aSAlan Cox 	/* Display management hooks */
5805c49fd3aSAlan Cox 	int (*output_init)(struct drm_device *dev);
58168cb638fSAlan Cox 	int (*hotplug)(struct drm_device *dev);
58268cb638fSAlan Cox 	void (*hotplug_enable)(struct drm_device *dev, bool on);
5835c49fd3aSAlan Cox 	/* Power management hooks */
5845c49fd3aSAlan Cox 	void (*init_pm)(struct drm_device *dev);
5855c49fd3aSAlan Cox 	int (*save_regs)(struct drm_device *dev);
5865c49fd3aSAlan Cox 	int (*restore_regs)(struct drm_device *dev);
587d56f57acSDaniel Vetter 	void (*save_crtc)(struct drm_crtc *crtc);
588d56f57acSDaniel Vetter 	void (*restore_crtc)(struct drm_crtc *crtc);
5895c49fd3aSAlan Cox 	int (*power_up)(struct drm_device *dev);
5905c49fd3aSAlan Cox 	int (*power_down)(struct drm_device *dev);
59128a8194cSPatrik Jakobsson 	void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc);
59275346fe9SPatrik Jakobsson 	void (*disable_sr)(struct drm_device *dev);
5935c49fd3aSAlan Cox 
5945c49fd3aSAlan Cox 	void (*lvds_bl_power)(struct drm_device *dev, bool on);
595*1f90b123SHans de Goede 
5965c49fd3aSAlan Cox 	/* Backlight */
5975c49fd3aSAlan Cox 	int (*backlight_init)(struct drm_device *dev);
598*1f90b123SHans de Goede 	void (*backlight_set)(struct drm_device *dev, int level);
599*1f90b123SHans de Goede 	int (*backlight_get)(struct drm_device *dev);
600*1f90b123SHans de Goede 	const char *backlight_name;
601*1f90b123SHans de Goede 
6025c49fd3aSAlan Cox 	int i2c_bus;		/* I2C bus identifier for Moorestown */
6035c49fd3aSAlan Cox };
6045c49fd3aSAlan Cox 
6053138ba6eSPatrik Jakobsson /* psb_lid.c */
6065c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv);
6075c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);
6085c49fd3aSAlan Cox 
6095c49fd3aSAlan Cox /* modesetting */
6105c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev);
6115c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev);
6125c49fd3aSAlan Cox extern int psb_fbdev_init(struct drm_device *dev);
6135c49fd3aSAlan Cox 
6145c49fd3aSAlan Cox /* backlight.c */
6155c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev);
6165c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev);
617d112a816SZhao Yakui void gma_backlight_disable(struct drm_device *dev);
618d112a816SZhao Yakui void gma_backlight_enable(struct drm_device *dev);
619d112a816SZhao Yakui void gma_backlight_set(struct drm_device *dev, int v);
6205c49fd3aSAlan Cox 
6215c49fd3aSAlan Cox /* oaktrail_crtc.c */
6225c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
6235c49fd3aSAlan Cox 
6245c49fd3aSAlan Cox /* oaktrail_lvds.c */
6255c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev,
6265c49fd3aSAlan Cox 		    struct psb_intel_mode_device *mode_dev);
6275c49fd3aSAlan Cox 
6285c49fd3aSAlan Cox /* psb_intel_display.c */
6295c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
6305c49fd3aSAlan Cox 
6315c49fd3aSAlan Cox /* psb_intel_lvds.c */
6325c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs
6335c49fd3aSAlan Cox 					psb_intel_lvds_connector_helper_funcs;
6345c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
6355c49fd3aSAlan Cox 
6365c49fd3aSAlan Cox /* gem.c */
6375c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
6385c49fd3aSAlan Cox 			struct drm_mode_create_dumb *args);
6395c49fd3aSAlan Cox 
6405c49fd3aSAlan Cox /* psb_device.c */
6415c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops;
6425c49fd3aSAlan Cox 
6435c49fd3aSAlan Cox /* oaktrail_device.c */
6445c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops;
6455c49fd3aSAlan Cox 
6465c49fd3aSAlan Cox /* cdv_device.c */
6475c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops;
6485c49fd3aSAlan Cox 
6499083eb38SArthur Borsboom /* Utilities */
6505c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
6515c49fd3aSAlan Cox {
652f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
6535c49fd3aSAlan Cox 	return ioread32(dev_priv->vdc_reg + reg);
6545c49fd3aSAlan Cox }
6555c49fd3aSAlan Cox 
6562657929dSPatrik Jakobsson static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg)
6572657929dSPatrik Jakobsson {
658f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
6592657929dSPatrik Jakobsson 	return ioread32(dev_priv->aux_reg + reg);
6602657929dSPatrik Jakobsson }
6612657929dSPatrik Jakobsson 
6625c49fd3aSAlan Cox #define REG_READ(reg)	       REGISTER_READ(dev, (reg))
6632657929dSPatrik Jakobsson #define REG_READ_AUX(reg)      REGISTER_READ_AUX(dev, (reg))
6645c49fd3aSAlan Cox 
665b97b8287SPatrik Jakobsson /* Useful for post reads */
666b97b8287SPatrik Jakobsson static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev,
667b97b8287SPatrik Jakobsson 					      uint32_t reg, int aux)
668b97b8287SPatrik Jakobsson {
669b97b8287SPatrik Jakobsson 	uint32_t val;
670b97b8287SPatrik Jakobsson 
671b97b8287SPatrik Jakobsson 	if (aux)
672b97b8287SPatrik Jakobsson 		val = REG_READ_AUX(reg);
673b97b8287SPatrik Jakobsson 	else
674b97b8287SPatrik Jakobsson 		val = REG_READ(reg);
675b97b8287SPatrik Jakobsson 
676b97b8287SPatrik Jakobsson 	return val;
677b97b8287SPatrik Jakobsson }
678b97b8287SPatrik Jakobsson 
679b97b8287SPatrik Jakobsson #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux))
680b97b8287SPatrik Jakobsson 
6815c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
6825c49fd3aSAlan Cox 				  uint32_t val)
6835c49fd3aSAlan Cox {
684f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
6855c49fd3aSAlan Cox 	iowrite32((val), dev_priv->vdc_reg + (reg));
6865c49fd3aSAlan Cox }
6875c49fd3aSAlan Cox 
6882657929dSPatrik Jakobsson static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg,
6892657929dSPatrik Jakobsson 				      uint32_t val)
6902657929dSPatrik Jakobsson {
691f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
6922657929dSPatrik Jakobsson 	iowrite32((val), dev_priv->aux_reg + (reg));
6932657929dSPatrik Jakobsson }
6942657929dSPatrik Jakobsson 
6955c49fd3aSAlan Cox #define REG_WRITE(reg, val)	REGISTER_WRITE(dev, (reg), (val))
6962657929dSPatrik Jakobsson #define REG_WRITE_AUX(reg, val)	REGISTER_WRITE_AUX(dev, (reg), (val))
6975c49fd3aSAlan Cox 
698b97b8287SPatrik Jakobsson static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg,
699b97b8287SPatrik Jakobsson 				      uint32_t val, int aux)
700b97b8287SPatrik Jakobsson {
701b97b8287SPatrik Jakobsson 	if (aux)
702b97b8287SPatrik Jakobsson 		REG_WRITE_AUX(reg, val);
703b97b8287SPatrik Jakobsson 	else
704b97b8287SPatrik Jakobsson 		REG_WRITE(reg, val);
705b97b8287SPatrik Jakobsson }
706b97b8287SPatrik Jakobsson 
707b97b8287SPatrik Jakobsson #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux))
708b97b8287SPatrik Jakobsson 
7095c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev,
7105c49fd3aSAlan Cox 					uint32_t reg, uint32_t val)
7115c49fd3aSAlan Cox {
712f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
7135c49fd3aSAlan Cox 	iowrite16((val), dev_priv->vdc_reg + (reg));
7145c49fd3aSAlan Cox }
7155c49fd3aSAlan Cox 
7165c49fd3aSAlan Cox #define REG_WRITE16(reg, val)	  REGISTER_WRITE16(dev, (reg), (val))
7175c49fd3aSAlan Cox 
7185c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev,
7195c49fd3aSAlan Cox 				       uint32_t reg, uint32_t val)
7205c49fd3aSAlan Cox {
721f71635e8SThomas Zimmermann 	struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
7225c49fd3aSAlan Cox 	iowrite8((val), dev_priv->vdc_reg + (reg));
7235c49fd3aSAlan Cox }
7245c49fd3aSAlan Cox 
7255c49fd3aSAlan Cox #define REG_WRITE8(reg, val)		REGISTER_WRITE8(dev, (reg), (val))
7265c49fd3aSAlan Cox 
7275c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs)		iowrite32(_val, dev_priv->vdc_reg + (_offs))
7285c49fd3aSAlan Cox #define PSB_RVDC32(_offs)		ioread32(dev_priv->vdc_reg + (_offs))
7295c49fd3aSAlan Cox 
7305c49fd3aSAlan Cox #define PSB_RSGX32(_offs)		ioread32(dev_priv->sgx_reg + (_offs))
7315c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs)		iowrite32(_val, dev_priv->sgx_reg + (_offs))
7325c49fd3aSAlan Cox 
7335c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs)	iowrite32(_val, dev_priv->msvdx_reg + (_offs))
7345c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs)		ioread32(dev_priv->msvdx_reg + (_offs))
7355c49fd3aSAlan Cox 
7365c49fd3aSAlan Cox #endif
737