xref: /linux/drivers/gpu/drm/gma500/psb_drv.h (revision 737292a3c0f251a93dcce4bedf7e4accb35335bc)
15c49fd3aSAlan Cox /**************************************************************************
25c49fd3aSAlan Cox  * Copyright (c) 2007-2011, Intel Corporation.
35c49fd3aSAlan Cox  * All Rights Reserved.
45c49fd3aSAlan Cox  *
55c49fd3aSAlan Cox  * This program is free software; you can redistribute it and/or modify it
65c49fd3aSAlan Cox  * under the terms and conditions of the GNU General Public License,
75c49fd3aSAlan Cox  * version 2, as published by the Free Software Foundation.
85c49fd3aSAlan Cox  *
95c49fd3aSAlan Cox  * This program is distributed in the hope it will be useful, but WITHOUT
105c49fd3aSAlan Cox  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
115c49fd3aSAlan Cox  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
125c49fd3aSAlan Cox  * more details.
135c49fd3aSAlan Cox  *
145c49fd3aSAlan Cox  * You should have received a copy of the GNU General Public License along with
155c49fd3aSAlan Cox  * this program; if not, write to the Free Software Foundation, Inc.,
165c49fd3aSAlan Cox  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
175c49fd3aSAlan Cox  *
185c49fd3aSAlan Cox  **************************************************************************/
195c49fd3aSAlan Cox 
205c49fd3aSAlan Cox #ifndef _PSB_DRV_H_
215c49fd3aSAlan Cox #define _PSB_DRV_H_
225c49fd3aSAlan Cox 
235c49fd3aSAlan Cox #include <linux/kref.h>
245c49fd3aSAlan Cox 
255c49fd3aSAlan Cox #include <drm/drmP.h>
26760285e7SDavid Howells #include <drm/drm_global.h>
27760285e7SDavid Howells #include <drm/gma_drm.h>
285c49fd3aSAlan Cox #include "psb_reg.h"
295c49fd3aSAlan Cox #include "psb_intel_drv.h"
305ea75e0fSPatrik Jakobsson #include "gma_display.h"
31d112a816SZhao Yakui #include "intel_bios.h"
325c49fd3aSAlan Cox #include "gtt.h"
335c49fd3aSAlan Cox #include "power.h"
34d839ede4SAlan Cox #include "opregion.h"
355c49fd3aSAlan Cox #include "oaktrail.h"
36ac1b01b0SPatrik Jakobsson #include "mmu.h"
375c49fd3aSAlan Cox 
38f90cd811SArthur Borsboom #define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others"
39f90cd811SArthur Borsboom #define DRIVER_LICENSE "GPL"
40f90cd811SArthur Borsboom 
41f90cd811SArthur Borsboom #define DRIVER_NAME "gma500"
42f90cd811SArthur Borsboom #define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650"
43f90cd811SArthur Borsboom #define DRIVER_DATE "20140314"
44f90cd811SArthur Borsboom 
45f90cd811SArthur Borsboom #define DRIVER_MAJOR 1
46f90cd811SArthur Borsboom #define DRIVER_MINOR 0
47f90cd811SArthur Borsboom #define DRIVER_PATCHLEVEL 0
48f90cd811SArthur Borsboom 
495c49fd3aSAlan Cox /* Append new drm mode definition here, align with libdrm definition */
505c49fd3aSAlan Cox #define DRM_MODE_SCALE_NO_SCALE   	2
515c49fd3aSAlan Cox 
525c49fd3aSAlan Cox enum {
535c49fd3aSAlan Cox 	CHIP_PSB_8108 = 0,		/* Poulsbo */
545c49fd3aSAlan Cox 	CHIP_PSB_8109 = 1,		/* Poulsbo */
555c49fd3aSAlan Cox 	CHIP_MRST_4100 = 2,		/* Moorestown/Oaktrail */
565c49fd3aSAlan Cox 	CHIP_MFLD_0130 = 3,		/* Medfield */
575c49fd3aSAlan Cox };
585c49fd3aSAlan Cox 
59ffbab09bSVille Syrjälä #define IS_PSB(dev) (((dev)->pdev->device & 0xfffe) == 0x8108)
609d3e2f53SPatrik Jakobsson #define IS_MRST(dev) (((dev)->pdev->device & 0xfff0) == 0x4100)
61ffbab09bSVille Syrjälä #define IS_MFLD(dev) (((dev)->pdev->device & 0xfff8) == 0x0130)
62ffbab09bSVille Syrjälä #define IS_CDV(dev) (((dev)->pdev->device & 0xfff0) == 0x0be0)
635c49fd3aSAlan Cox 
649083eb38SArthur Borsboom /* Hardware offsets */
655c49fd3aSAlan Cox #define PSB_VDC_OFFSET		 0x00000000
665c49fd3aSAlan Cox #define PSB_VDC_SIZE		 0x000080000
675c49fd3aSAlan Cox #define MRST_MMIO_SIZE		 0x0000C0000
685c49fd3aSAlan Cox #define MDFLD_MMIO_SIZE          0x000100000
695c49fd3aSAlan Cox #define PSB_SGX_SIZE		 0x8000
705c49fd3aSAlan Cox #define PSB_SGX_OFFSET		 0x00040000
715c49fd3aSAlan Cox #define MRST_SGX_OFFSET		 0x00080000
729083eb38SArthur Borsboom 
739083eb38SArthur Borsboom /* PCI resource identifiers */
745c49fd3aSAlan Cox #define PSB_MMIO_RESOURCE	 0
752657929dSPatrik Jakobsson #define PSB_AUX_RESOURCE	 0
765c49fd3aSAlan Cox #define PSB_GATT_RESOURCE	 2
775c49fd3aSAlan Cox #define PSB_GTT_RESOURCE	 3
789083eb38SArthur Borsboom 
799083eb38SArthur Borsboom /* PCI configuration */
805c49fd3aSAlan Cox #define PSB_GMCH_CTRL		 0x52
815c49fd3aSAlan Cox #define PSB_BSM			 0x5C
825c49fd3aSAlan Cox #define _PSB_GMCH_ENABLED	 0x4
835c49fd3aSAlan Cox #define PSB_PGETBL_CTL		 0x2020
845c49fd3aSAlan Cox #define _PSB_PGETBL_ENABLED	 0x00000001
855c49fd3aSAlan Cox #define PSB_SGX_2D_SLAVE_PORT	 0x4000
865a52b1f2SJan Safrata #define PSB_LPC_GBA		 0x44
875c49fd3aSAlan Cox 
889083eb38SArthur Borsboom /* TODO: To get rid of */
895c49fd3aSAlan Cox #define PSB_TT_PRIV0_LIMIT	 (256*1024*1024)
905c49fd3aSAlan Cox #define PSB_TT_PRIV0_PLIMIT	 (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
915c49fd3aSAlan Cox 
929083eb38SArthur Borsboom /* SGX side MMU definitions (these can probably go) */
935c49fd3aSAlan Cox 
949083eb38SArthur Borsboom /* Flags for external memory type field */
955c49fd3aSAlan Cox #define PSB_MMU_CACHED_MEMORY	  0x0001	/* Bind to MMU only */
965c49fd3aSAlan Cox #define PSB_MMU_RO_MEMORY	  0x0002	/* MMU RO memory */
975c49fd3aSAlan Cox #define PSB_MMU_WO_MEMORY	  0x0004	/* MMU WO memory */
989083eb38SArthur Borsboom 
999083eb38SArthur Borsboom /* PTE's and PDE's */
1005c49fd3aSAlan Cox #define PSB_PDE_MASK		  0x003FFFFF
1015c49fd3aSAlan Cox #define PSB_PDE_SHIFT		  22
1025c49fd3aSAlan Cox #define PSB_PTE_SHIFT		  12
1039083eb38SArthur Borsboom 
1049083eb38SArthur Borsboom /* Cache control */
1055c49fd3aSAlan Cox #define PSB_PTE_VALID		  0x0001	/* PTE / PDE valid */
1065c49fd3aSAlan Cox #define PSB_PTE_WO		  0x0002	/* Write only */
1075c49fd3aSAlan Cox #define PSB_PTE_RO		  0x0004	/* Read only */
1085c49fd3aSAlan Cox #define PSB_PTE_CACHED		  0x0008	/* CPU cache coherent */
1095c49fd3aSAlan Cox 
1109083eb38SArthur Borsboom /* VDC registers and bits */
1115c49fd3aSAlan Cox #define PSB_MSVDX_CLOCKGATING	  0x2064
1125c49fd3aSAlan Cox #define PSB_TOPAZ_CLOCKGATING	  0x2068
1135c49fd3aSAlan Cox #define PSB_HWSTAM		  0x2098
1145c49fd3aSAlan Cox #define PSB_INSTPM		  0x20C0
1155c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R        0x20A4
116d839ede4SAlan Cox #define _PSB_IRQ_ASLE		  (1<<0)
1175c49fd3aSAlan Cox #define _MDFLD_PIPEC_EVENT_FLAG   (1<<2)
1185c49fd3aSAlan Cox #define _MDFLD_PIPEC_VBLANK_FLAG  (1<<3)
1195c49fd3aSAlan Cox #define _PSB_DPST_PIPEB_FLAG      (1<<4)
1205c49fd3aSAlan Cox #define _MDFLD_PIPEB_EVENT_FLAG   (1<<4)
1215c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEB_FLAG	  (1<<5)
1225c49fd3aSAlan Cox #define _PSB_DPST_PIPEA_FLAG      (1<<6)
1235c49fd3aSAlan Cox #define _PSB_PIPEA_EVENT_FLAG     (1<<6)
1245c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEA_FLAG	  (1<<7)
1255c49fd3aSAlan Cox #define _MDFLD_MIPIA_FLAG	  (1<<16)
1265c49fd3aSAlan Cox #define _MDFLD_MIPIC_FLAG	  (1<<17)
12768cb638fSAlan Cox #define _PSB_IRQ_DISP_HOTSYNC	  (1<<17)
1285c49fd3aSAlan Cox #define _PSB_IRQ_SGX_FLAG	  (1<<18)
1295c49fd3aSAlan Cox #define _PSB_IRQ_MSVDX_FLAG	  (1<<19)
1305c49fd3aSAlan Cox #define _LNC_IRQ_TOPAZ_FLAG	  (1<<20)
1315c49fd3aSAlan Cox 
132700e59f6SPatrik Jakobsson #define _PSB_PIPE_EVENT_FLAG	(_PSB_VSYNC_PIPEA_FLAG | \
133700e59f6SPatrik Jakobsson 				 _PSB_VSYNC_PIPEB_FLAG)
134700e59f6SPatrik Jakobsson 
1355c49fd3aSAlan Cox /* This flag includes all the display IRQ bits excepts the vblank irqs. */
1365c49fd3aSAlan Cox #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \
1375c49fd3aSAlan Cox 				  _MDFLD_PIPEB_EVENT_FLAG | \
1385c49fd3aSAlan Cox 				  _PSB_PIPEA_EVENT_FLAG | \
1395c49fd3aSAlan Cox 				  _PSB_VSYNC_PIPEA_FLAG | \
1405c49fd3aSAlan Cox 				  _MDFLD_MIPIA_FLAG | \
1415c49fd3aSAlan Cox 				  _MDFLD_MIPIC_FLAG)
1425c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R	  0x20A4
1435c49fd3aSAlan Cox #define PSB_INT_MASK_R		  0x20A8
1445c49fd3aSAlan Cox #define PSB_INT_ENABLE_R	  0x20A0
1455c49fd3aSAlan Cox 
1465c49fd3aSAlan Cox #define _PSB_MMU_ER_MASK      0x0001FF00
1475c49fd3aSAlan Cox #define _PSB_MMU_ER_HOST      (1 << 16)
1485c49fd3aSAlan Cox #define GPIOA			0x5010
1495c49fd3aSAlan Cox #define GPIOB			0x5014
1505c49fd3aSAlan Cox #define GPIOC			0x5018
1515c49fd3aSAlan Cox #define GPIOD			0x501c
1525c49fd3aSAlan Cox #define GPIOE			0x5020
1535c49fd3aSAlan Cox #define GPIOF			0x5024
1545c49fd3aSAlan Cox #define GPIOG			0x5028
1555c49fd3aSAlan Cox #define GPIOH			0x502c
1565c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_MASK		(1 << 0)
1575c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_IN		(0 << 1)
1585c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_OUT		(1 << 1)
1595c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_MASK		(1 << 2)
1605c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_OUT		(1 << 3)
1615c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_IN		(1 << 4)
1625c49fd3aSAlan Cox #define GPIO_CLOCK_PULLUP_DISABLE	(1 << 5)
1635c49fd3aSAlan Cox #define GPIO_DATA_DIR_MASK		(1 << 8)
1645c49fd3aSAlan Cox #define GPIO_DATA_DIR_IN		(0 << 9)
1655c49fd3aSAlan Cox #define GPIO_DATA_DIR_OUT		(1 << 9)
1665c49fd3aSAlan Cox #define GPIO_DATA_VAL_MASK		(1 << 10)
1675c49fd3aSAlan Cox #define GPIO_DATA_VAL_OUT		(1 << 11)
1685c49fd3aSAlan Cox #define GPIO_DATA_VAL_IN		(1 << 12)
1695c49fd3aSAlan Cox #define GPIO_DATA_PULLUP_DISABLE	(1 << 13)
1705c49fd3aSAlan Cox 
1715c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA0   0x6000
1725c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA1   0x6004
1735c49fd3aSAlan Cox #define VCLK_POST_DIV	    0x6010
1745c49fd3aSAlan Cox 
1755c49fd3aSAlan Cox #define PSB_COMM_2D (PSB_ENGINE_2D << 4)
1765c49fd3aSAlan Cox #define PSB_COMM_3D (PSB_ENGINE_3D << 4)
1775c49fd3aSAlan Cox #define PSB_COMM_TA (PSB_ENGINE_TA << 4)
1785c49fd3aSAlan Cox #define PSB_COMM_HP (PSB_ENGINE_HP << 4)
1795c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ (1024 >> 2)
1805c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1)
1815c49fd3aSAlan Cox #define PSB_COMM_FW (2048 >> 2)
1825c49fd3aSAlan Cox 
1835c49fd3aSAlan Cox #define PSB_UIRQ_VISTEST	       1
1845c49fd3aSAlan Cox #define PSB_UIRQ_OOM_REPLY	       2
1855c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_TA_REPLY	       3
1865c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_RASTER_REPLY     4
1875c49fd3aSAlan Cox 
1885c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024)
1895c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024
1905c49fd3aSAlan Cox 
1915c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204
1925c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600
1935c49fd3aSAlan Cox 
1945c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2
1955c49fd3aSAlan Cox 
1965c49fd3aSAlan Cox 
1975c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024)
1985c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024
1995c49fd3aSAlan Cox 
2005c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204
2015c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600
2025c49fd3aSAlan Cox 
2035c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2
204bfd8303aSDaniel Vetter #define PSB_WATCHDOG_DELAY (HZ * 2)
205bfd8303aSDaniel Vetter #define PSB_LID_DELAY (HZ / 10)
2065c49fd3aSAlan Cox 
2075c49fd3aSAlan Cox #define MDFLD_PNW_B0 0x04
2085c49fd3aSAlan Cox #define MDFLD_PNW_C0 0x08
2095c49fd3aSAlan Cox 
2105c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_0 	(1 << 0)
2115c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_2 	(1 << 1)
2125c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_0 	(1 << 2)
2135c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_2	(1 << 3)
2145c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_0 	(1 << 4)
2155c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_2 	(1 << 5)
2165c49fd3aSAlan Cox #define MDFLD_DSR_MIPI_CONTROL	(1 << 6)
2175c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_0	((1 << 0) | (1 << 2) | (1 << 4))
2185c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_2	((1 << 1) | (1 << 3) | (1 << 5))
2195c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D 	(MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2)
2205c49fd3aSAlan Cox 
2215c49fd3aSAlan Cox #define MDFLD_DSR_RR		45
2225c49fd3aSAlan Cox #define MDFLD_DPU_ENABLE 	(1 << 31)
2235c49fd3aSAlan Cox #define MDFLD_DSR_FULLSCREEN 	(1 << 30)
224bfd8303aSDaniel Vetter #define MDFLD_DSR_DELAY		(HZ / MDFLD_DSR_RR)
2255c49fd3aSAlan Cox 
2265c49fd3aSAlan Cox #define PSB_PWR_STATE_ON		1
2275c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF		2
2285c49fd3aSAlan Cox 
2295c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM		0
2305c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING	1
2315c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN		2
2325c49fd3aSAlan Cox 
2335c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP		0
2345c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED		1
2355c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN		2
2365c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC		0x94
2375c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC		0x98
2385c49fd3aSAlan Cox 
2395c49fd3aSAlan Cox /* Medfield crystal settings */
2405c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1
2415c49fd3aSAlan Cox #define KSEL_BYPASS_19 5
2425c49fd3aSAlan Cox #define KSEL_BYPASS_25 6
2435c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7
2445c49fd3aSAlan Cox 
2455c49fd3aSAlan Cox struct opregion_header;
2465c49fd3aSAlan Cox struct opregion_acpi;
2475c49fd3aSAlan Cox struct opregion_swsci;
2485c49fd3aSAlan Cox struct opregion_asle;
2495c49fd3aSAlan Cox 
2505c49fd3aSAlan Cox struct psb_intel_opregion {
2515c49fd3aSAlan Cox 	struct opregion_header *header;
2525c49fd3aSAlan Cox 	struct opregion_acpi *acpi;
2535c49fd3aSAlan Cox 	struct opregion_swsci *swsci;
2545c49fd3aSAlan Cox 	struct opregion_asle *asle;
2551fb28e9eSAlan Cox 	void *vbt;
256d839ede4SAlan Cox 	u32 __iomem *lid_state;
257778e26deSPatrik Jakobsson 	struct work_struct asle_work;
2585c49fd3aSAlan Cox };
2595c49fd3aSAlan Cox 
2605736995bSPatrik Jakobsson struct sdvo_device_mapping {
2615736995bSPatrik Jakobsson 	u8 initialized;
2625736995bSPatrik Jakobsson 	u8 dvo_port;
2635736995bSPatrik Jakobsson 	u8 slave_addr;
2645736995bSPatrik Jakobsson 	u8 dvo_wiring;
2655736995bSPatrik Jakobsson 	u8 i2c_pin;
2665736995bSPatrik Jakobsson 	u8 i2c_speed;
2675736995bSPatrik Jakobsson 	u8 ddc_pin;
2685736995bSPatrik Jakobsson };
2695736995bSPatrik Jakobsson 
2705c0c1d50SPatrik Jakobsson struct intel_gmbus {
2715c0c1d50SPatrik Jakobsson 	struct i2c_adapter adapter;
2725c0c1d50SPatrik Jakobsson 	struct i2c_adapter *force_bit;
2735c0c1d50SPatrik Jakobsson 	u32 reg0;
2745c0c1d50SPatrik Jakobsson };
2755c0c1d50SPatrik Jakobsson 
2769083eb38SArthur Borsboom /* Register offset maps */
2778512e074SAlan Cox struct psb_offset {
2788512e074SAlan Cox 	u32	fp0;
2798512e074SAlan Cox 	u32	fp1;
2808512e074SAlan Cox 	u32	cntr;
2818512e074SAlan Cox 	u32	conf;
2828512e074SAlan Cox 	u32	src;
2838512e074SAlan Cox 	u32	dpll;
2848512e074SAlan Cox 	u32	dpll_md;
2858512e074SAlan Cox 	u32	htotal;
2868512e074SAlan Cox 	u32	hblank;
2878512e074SAlan Cox 	u32	hsync;
2888512e074SAlan Cox 	u32	vtotal;
2898512e074SAlan Cox 	u32	vblank;
2908512e074SAlan Cox 	u32	vsync;
2918512e074SAlan Cox 	u32	stride;
2928512e074SAlan Cox 	u32	size;
2938512e074SAlan Cox 	u32	pos;
2948512e074SAlan Cox 	u32	surf;
2958512e074SAlan Cox 	u32	addr;
2968512e074SAlan Cox 	u32	base;
2978512e074SAlan Cox 	u32	status;
2988512e074SAlan Cox 	u32	linoff;
2998512e074SAlan Cox 	u32	tileoff;
3008512e074SAlan Cox 	u32	palette;
3018512e074SAlan Cox };
3028512e074SAlan Cox 
3038512e074SAlan Cox /*
304648a8e34SAlan Cox  *	Register save state. This is used to hold the context when the
305648a8e34SAlan Cox  *	device is powered off. In the case of Oaktrail this can (but does not
306648a8e34SAlan Cox  *	yet) include screen blank. Operations occuring during the save
307648a8e34SAlan Cox  *	update the register cache instead.
308648a8e34SAlan Cox  */
3096256304bSAlan Cox 
3109083eb38SArthur Borsboom /* Common status for pipes */
3116256304bSAlan Cox struct psb_pipe {
3126256304bSAlan Cox 	u32	fp0;
3136256304bSAlan Cox 	u32	fp1;
3146256304bSAlan Cox 	u32	cntr;
3156256304bSAlan Cox 	u32	conf;
3166256304bSAlan Cox 	u32	src;
3176256304bSAlan Cox 	u32	dpll;
3186256304bSAlan Cox 	u32	dpll_md;
3196256304bSAlan Cox 	u32	htotal;
3206256304bSAlan Cox 	u32	hblank;
3216256304bSAlan Cox 	u32	hsync;
3226256304bSAlan Cox 	u32	vtotal;
3236256304bSAlan Cox 	u32	vblank;
3246256304bSAlan Cox 	u32	vsync;
3256256304bSAlan Cox 	u32	stride;
3266256304bSAlan Cox 	u32	size;
3276256304bSAlan Cox 	u32	pos;
3286256304bSAlan Cox 	u32	base;
3296256304bSAlan Cox 	u32	surf;
3306256304bSAlan Cox 	u32	addr;
3316256304bSAlan Cox 	u32	status;
3326256304bSAlan Cox 	u32	linoff;
3336256304bSAlan Cox 	u32	tileoff;
3346256304bSAlan Cox 	u32	palette[256];
3356256304bSAlan Cox };
3366256304bSAlan Cox 
337648a8e34SAlan Cox struct psb_state {
338648a8e34SAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA0;
339648a8e34SAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA1;
340648a8e34SAlan Cox 	uint32_t saveVCLK_POST_DIV;
341648a8e34SAlan Cox 	uint32_t saveVGACNTRL;
342648a8e34SAlan Cox 	uint32_t saveADPA;
343648a8e34SAlan Cox 	uint32_t saveLVDS;
344648a8e34SAlan Cox 	uint32_t saveDVOA;
345648a8e34SAlan Cox 	uint32_t saveDVOB;
346648a8e34SAlan Cox 	uint32_t saveDVOC;
347648a8e34SAlan Cox 	uint32_t savePP_ON;
348648a8e34SAlan Cox 	uint32_t savePP_OFF;
349648a8e34SAlan Cox 	uint32_t savePP_CONTROL;
350648a8e34SAlan Cox 	uint32_t savePP_CYCLE;
351648a8e34SAlan Cox 	uint32_t savePFIT_CONTROL;
352648a8e34SAlan Cox 	uint32_t saveCLOCKGATING;
353648a8e34SAlan Cox 	uint32_t saveDSPARB;
354648a8e34SAlan Cox 	uint32_t savePFIT_AUTO_RATIOS;
355648a8e34SAlan Cox 	uint32_t savePFIT_PGM_RATIOS;
356648a8e34SAlan Cox 	uint32_t savePP_ON_DELAYS;
357648a8e34SAlan Cox 	uint32_t savePP_OFF_DELAYS;
358648a8e34SAlan Cox 	uint32_t savePP_DIVISOR;
359648a8e34SAlan Cox 	uint32_t saveBCLRPAT_A;
360648a8e34SAlan Cox 	uint32_t saveBCLRPAT_B;
361648a8e34SAlan Cox 	uint32_t savePERF_MODE;
362648a8e34SAlan Cox 	uint32_t saveDSPFW1;
363648a8e34SAlan Cox 	uint32_t saveDSPFW2;
364648a8e34SAlan Cox 	uint32_t saveDSPFW3;
365648a8e34SAlan Cox 	uint32_t saveDSPFW4;
366648a8e34SAlan Cox 	uint32_t saveDSPFW5;
367648a8e34SAlan Cox 	uint32_t saveDSPFW6;
368648a8e34SAlan Cox 	uint32_t saveCHICKENBIT;
369648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_CTRL;
370648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_CTRL;
371648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_BASE;
372648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_BASE;
373648a8e34SAlan Cox 	uint32_t saveDSPACURSOR_POS;
374648a8e34SAlan Cox 	uint32_t saveDSPBCURSOR_POS;
375648a8e34SAlan Cox 	uint32_t saveOV_OVADD;
376648a8e34SAlan Cox 	uint32_t saveOV_OGAMC0;
377648a8e34SAlan Cox 	uint32_t saveOV_OGAMC1;
378648a8e34SAlan Cox 	uint32_t saveOV_OGAMC2;
379648a8e34SAlan Cox 	uint32_t saveOV_OGAMC3;
380648a8e34SAlan Cox 	uint32_t saveOV_OGAMC4;
381648a8e34SAlan Cox 	uint32_t saveOV_OGAMC5;
382648a8e34SAlan Cox 	uint32_t saveOVC_OVADD;
383648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC0;
384648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC1;
385648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC2;
386648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC3;
387648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC4;
388648a8e34SAlan Cox 	uint32_t saveOVC_OGAMC5;
389648a8e34SAlan Cox 
390648a8e34SAlan Cox 	/* DPST register save */
391648a8e34SAlan Cox 	uint32_t saveHISTOGRAM_INT_CONTROL_REG;
392648a8e34SAlan Cox 	uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
393648a8e34SAlan Cox 	uint32_t savePWM_CONTROL_LOGIC;
394648a8e34SAlan Cox };
395648a8e34SAlan Cox 
396026abc33SKirill A. Shutemov struct medfield_state {
397026abc33SKirill A. Shutemov 	uint32_t saveMIPI;
398026abc33SKirill A. Shutemov 	uint32_t saveMIPI_C;
399026abc33SKirill A. Shutemov 
400026abc33SKirill A. Shutemov 	uint32_t savePFIT_CONTROL;
401026abc33SKirill A. Shutemov 	uint32_t savePFIT_PGM_RATIOS;
402026abc33SKirill A. Shutemov 	uint32_t saveHDMIPHYMISCCTL;
403026abc33SKirill A. Shutemov 	uint32_t saveHDMIB_CONTROL;
404026abc33SKirill A. Shutemov };
405026abc33SKirill A. Shutemov 
40609016a11SAlan Cox struct cdv_state {
40709016a11SAlan Cox 	uint32_t saveDSPCLK_GATE_D;
40809016a11SAlan Cox 	uint32_t saveRAMCLK_GATE_D;
40909016a11SAlan Cox 	uint32_t saveDSPARB;
41009016a11SAlan Cox 	uint32_t saveDSPFW[6];
41109016a11SAlan Cox 	uint32_t saveADPA;
41209016a11SAlan Cox 	uint32_t savePP_CONTROL;
41309016a11SAlan Cox 	uint32_t savePFIT_PGM_RATIOS;
41409016a11SAlan Cox 	uint32_t saveLVDS;
41509016a11SAlan Cox 	uint32_t savePFIT_CONTROL;
41609016a11SAlan Cox 	uint32_t savePP_ON_DELAYS;
41709016a11SAlan Cox 	uint32_t savePP_OFF_DELAYS;
41809016a11SAlan Cox 	uint32_t savePP_CYCLE;
41909016a11SAlan Cox 	uint32_t saveVGACNTRL;
42009016a11SAlan Cox 	uint32_t saveIER;
42109016a11SAlan Cox 	uint32_t saveIMR;
42209016a11SAlan Cox 	u8	 saveLBB;
42309016a11SAlan Cox };
42409016a11SAlan Cox 
425c6265ff5SAlan Cox struct psb_save_area {
4266256304bSAlan Cox 	struct psb_pipe pipe[3];
427c6265ff5SAlan Cox 	uint32_t saveBSM;
428c6265ff5SAlan Cox 	uint32_t saveVBT;
429c6265ff5SAlan Cox 	union {
430c6265ff5SAlan Cox 	        struct psb_state psb;
431026abc33SKirill A. Shutemov 		struct medfield_state mdfld;
43209016a11SAlan Cox 		struct cdv_state cdv;
433c6265ff5SAlan Cox 	};
434c6265ff5SAlan Cox 	uint32_t saveBLC_PWM_CTL2;
435c6265ff5SAlan Cox 	uint32_t saveBLC_PWM_CTL;
436c6265ff5SAlan Cox };
437c6265ff5SAlan Cox 
4385c49fd3aSAlan Cox struct psb_ops;
4395c49fd3aSAlan Cox 
44004bd564fSAlan Cox #define PSB_NUM_PIPE		3
44104bd564fSAlan Cox 
4425c49fd3aSAlan Cox struct drm_psb_private {
4435c49fd3aSAlan Cox 	struct drm_device *dev;
4442657929dSPatrik Jakobsson 	struct pci_dev *aux_pdev; /* Currently only used by mrst */
4455a52b1f2SJan Safrata 	struct pci_dev *lpc_pdev; /* Currently only used by mrst */
4465c49fd3aSAlan Cox 	const struct psb_ops *ops;
4478512e074SAlan Cox 	const struct psb_offset *regmap;
4485c49fd3aSAlan Cox 
4491fb28e9eSAlan Cox 	struct child_device_config *child_dev;
4501fb28e9eSAlan Cox 	int child_dev_num;
4511fb28e9eSAlan Cox 
4525c49fd3aSAlan Cox 	struct psb_gtt gtt;
4535c49fd3aSAlan Cox 
4545c49fd3aSAlan Cox 	/* GTT Memory manager */
4555c49fd3aSAlan Cox 	struct psb_gtt_mm *gtt_mm;
4565c49fd3aSAlan Cox 	struct page *scratch_page;
457eab37607SKirill A. Shutemov 	u32 __iomem *gtt_map;
4585c49fd3aSAlan Cox 	uint32_t stolen_base;
45937214ca0SKirill A. Shutemov 	u8 __iomem *vram_addr;
4605c49fd3aSAlan Cox 	unsigned long vram_stolen_size;
4615c49fd3aSAlan Cox 	int gtt_initialized;
4625c49fd3aSAlan Cox 	u16 gmch_ctrl;		/* Saved GTT setup */
4635c49fd3aSAlan Cox 	u32 pge_ctl;
4645c49fd3aSAlan Cox 
4655c49fd3aSAlan Cox 	struct mutex gtt_mutex;
4665c49fd3aSAlan Cox 	struct resource *gtt_mem;	/* Our PCI resource */
4675c49fd3aSAlan Cox 
468*737292a3SDaniel Vetter 	struct mutex mmap_mutex;
469*737292a3SDaniel Vetter 
4705c49fd3aSAlan Cox 	struct psb_mmu_driver *mmu;
4715c49fd3aSAlan Cox 	struct psb_mmu_pd *pf_pd;
4725c49fd3aSAlan Cox 
4739083eb38SArthur Borsboom 	/* Register base */
474846a6038SKirill A. Shutemov 	uint8_t __iomem *sgx_reg;
475846a6038SKirill A. Shutemov 	uint8_t __iomem *vdc_reg;
4762657929dSPatrik Jakobsson 	uint8_t __iomem *aux_reg; /* Auxillary vdc pipe regs */
4775a52b1f2SJan Safrata 	uint16_t lpc_gpio_base;
4785c49fd3aSAlan Cox 	uint32_t gatt_free_offset;
4795c49fd3aSAlan Cox 
4809083eb38SArthur Borsboom 	/* Fencing / irq */
4815c49fd3aSAlan Cox 	uint32_t vdc_irq_mask;
4825c49fd3aSAlan Cox 	uint32_t pipestat[PSB_NUM_PIPE];
4835c49fd3aSAlan Cox 
4845c49fd3aSAlan Cox 	spinlock_t irqmask_lock;
4855c49fd3aSAlan Cox 
4869083eb38SArthur Borsboom 	/* Power */
4875c49fd3aSAlan Cox 	bool suspended;
4885c49fd3aSAlan Cox 	bool display_power;
4895c49fd3aSAlan Cox 	int display_count;
4905c49fd3aSAlan Cox 
4919083eb38SArthur Borsboom 	/* Modesetting */
4925c49fd3aSAlan Cox 	struct psb_intel_mode_device mode_dev;
4934ab2c7f1SAlan Cox 	bool modeset;	/* true if we have done the mode_device setup */
4945c49fd3aSAlan Cox 
4955c49fd3aSAlan Cox 	struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
4965c49fd3aSAlan Cox 	struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
4975c49fd3aSAlan Cox 	uint32_t num_pipe;
4985c49fd3aSAlan Cox 
4999083eb38SArthur Borsboom 	/* OSPM info (Power management base) (TODO: can go ?) */
5005c49fd3aSAlan Cox 	uint32_t ospm_base;
5015c49fd3aSAlan Cox 
5029083eb38SArthur Borsboom 	/* Sizes info */
5035c49fd3aSAlan Cox 	u32 fuse_reg_value;
5045c49fd3aSAlan Cox 	u32 video_device_fuse;
5055c49fd3aSAlan Cox 
5065c49fd3aSAlan Cox 	/* PCI revision ID for B0:D2:F0 */
5075c49fd3aSAlan Cox 	uint8_t platform_rev_id;
5085c49fd3aSAlan Cox 
5095c0c1d50SPatrik Jakobsson 	/* gmbus */
5105c0c1d50SPatrik Jakobsson 	struct intel_gmbus *gmbus;
5112657929dSPatrik Jakobsson 	uint8_t __iomem *gmbus_reg;
5125c0c1d50SPatrik Jakobsson 
5135736995bSPatrik Jakobsson 	/* Used by SDVO */
5145736995bSPatrik Jakobsson 	int crt_ddc_pin;
5155736995bSPatrik Jakobsson 	/* FIXME: The mappings should be parsed from bios but for now we can
5165736995bSPatrik Jakobsson 		  pretend there are no mappings available */
5175736995bSPatrik Jakobsson 	struct sdvo_device_mapping sdvo_mappings[2];
5185736995bSPatrik Jakobsson 	u32 hotplug_supported_mask;
5195736995bSPatrik Jakobsson 	struct drm_property *broadcast_rgb_property;
5205736995bSPatrik Jakobsson 	struct drm_property *force_audio_property;
5215736995bSPatrik Jakobsson 
5229083eb38SArthur Borsboom 	/* LVDS info */
5235c49fd3aSAlan Cox 	int backlight_duty_cycle;	/* restore backlight to this value */
5245c49fd3aSAlan Cox 	bool panel_wants_dither;
5255c49fd3aSAlan Cox 	struct drm_display_mode *panel_fixed_mode;
5265c49fd3aSAlan Cox 	struct drm_display_mode *lfp_lvds_vbt_mode;
5275c49fd3aSAlan Cox 	struct drm_display_mode *sdvo_lvds_vbt_mode;
5285c49fd3aSAlan Cox 
5295c49fd3aSAlan Cox 	struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */
530a12d6a07SPatrik Jakobsson 	struct psb_intel_i2c_chan *lvds_i2c_bus; /* FIXME: Remove this? */
5315c49fd3aSAlan Cox 
5325c49fd3aSAlan Cox 	/* Feature bits from the VBIOS */
5335c49fd3aSAlan Cox 	unsigned int int_tv_support:1;
5345c49fd3aSAlan Cox 	unsigned int lvds_dither:1;
5355c49fd3aSAlan Cox 	unsigned int lvds_vbt:1;
5365c49fd3aSAlan Cox 	unsigned int int_crt_support:1;
5375c49fd3aSAlan Cox 	unsigned int lvds_use_ssc:1;
5385c49fd3aSAlan Cox 	int lvds_ssc_freq;
5395c49fd3aSAlan Cox 	bool is_lvds_on;
5405c49fd3aSAlan Cox 	bool is_mipi_on;
5415c49fd3aSAlan Cox 	u32 mipi_ctrl_display;
5425c49fd3aSAlan Cox 
5435c49fd3aSAlan Cox 	unsigned int core_freq;
5445c49fd3aSAlan Cox 	uint32_t iLVDS_enable;
5455c49fd3aSAlan Cox 
5465c49fd3aSAlan Cox 	/* Runtime PM state */
5475c49fd3aSAlan Cox 	int rpm_enabled;
5485c49fd3aSAlan Cox 
5495c49fd3aSAlan Cox 	/* MID specific */
5504086b1e2SKirill A. Shutemov 	bool has_gct;
5515c49fd3aSAlan Cox 	struct oaktrail_gct_data gct_data;
5525c49fd3aSAlan Cox 
553933315acSAlan Cox 	/* Oaktrail HDMI state */
5545c49fd3aSAlan Cox 	struct oaktrail_hdmi_dev *hdmi_priv;
5555c49fd3aSAlan Cox 
5569083eb38SArthur Borsboom 	/* Register state */
557c6265ff5SAlan Cox 	struct psb_save_area regs;
558c6265ff5SAlan Cox 
5595c49fd3aSAlan Cox 	/* MSI reg save */
5605c49fd3aSAlan Cox 	uint32_t msi_addr;
5615c49fd3aSAlan Cox 	uint32_t msi_data;
5625c49fd3aSAlan Cox 
5639083eb38SArthur Borsboom 	/* Hotplug handling */
564ae0a246aSAlan Cox 	struct work_struct hotplug_work;
5655c49fd3aSAlan Cox 
5669083eb38SArthur Borsboom 	/* LID-Switch */
5675c49fd3aSAlan Cox 	spinlock_t lid_lock;
5685c49fd3aSAlan Cox 	struct timer_list lid_timer;
5695c49fd3aSAlan Cox 	struct psb_intel_opregion opregion;
5705c49fd3aSAlan Cox 	u32 lid_last_state;
5715c49fd3aSAlan Cox 
5729083eb38SArthur Borsboom 	/* Watchdog */
5735c49fd3aSAlan Cox 	uint32_t apm_reg;
5745c49fd3aSAlan Cox 	uint16_t apm_base;
5755c49fd3aSAlan Cox 
5765c49fd3aSAlan Cox 	/*
5775c49fd3aSAlan Cox 	 * Used for modifying backlight from
5785c49fd3aSAlan Cox 	 * xrandr -- consider removing and using HAL instead
5795c49fd3aSAlan Cox 	 */
5805c49fd3aSAlan Cox 	struct backlight_device *backlight_device;
5815c49fd3aSAlan Cox 	struct drm_property *backlight_property;
582d112a816SZhao Yakui 	bool backlight_enabled;
583d112a816SZhao Yakui 	int backlight_level;
5845c49fd3aSAlan Cox 	uint32_t blc_adj1;
5855c49fd3aSAlan Cox 	uint32_t blc_adj2;
5865c49fd3aSAlan Cox 
5875c49fd3aSAlan Cox 	void *fbdev;
5885c49fd3aSAlan Cox 
5895c49fd3aSAlan Cox 	/* 2D acceleration */
5909242fe23SAlan Cox 	spinlock_t lock_2d;
591026abc33SKirill A. Shutemov 
5929083eb38SArthur Borsboom 	/* Panel brightness */
593026abc33SKirill A. Shutemov 	int brightness;
594026abc33SKirill A. Shutemov 	int brightness_adjusted;
595026abc33SKirill A. Shutemov 
596026abc33SKirill A. Shutemov 	bool dsr_enable;
597026abc33SKirill A. Shutemov 	u32 dsr_fb_update;
598026abc33SKirill A. Shutemov 	bool dpi_panel_on[3];
599026abc33SKirill A. Shutemov 	void *dsi_configs[2];
600026abc33SKirill A. Shutemov 	u32 bpp;
601026abc33SKirill A. Shutemov 	u32 bpp2;
602026abc33SKirill A. Shutemov 
603026abc33SKirill A. Shutemov 	u32 pipeconf[3];
604026abc33SKirill A. Shutemov 	u32 dspcntr[3];
605026abc33SKirill A. Shutemov 
606026abc33SKirill A. Shutemov 	int mdfld_panel_id;
607642c52fcSAlan Cox 
608642c52fcSAlan Cox 	bool dplla_96mhz;	/* DPLL data from the VBT */
609d112a816SZhao Yakui 
610d112a816SZhao Yakui 	struct {
611d112a816SZhao Yakui 		int rate;
612d112a816SZhao Yakui 		int lanes;
613d112a816SZhao Yakui 		int preemphasis;
614d112a816SZhao Yakui 		int vswing;
615d112a816SZhao Yakui 
616d112a816SZhao Yakui 		bool initialized;
617d112a816SZhao Yakui 		bool support;
618d112a816SZhao Yakui 		int bpp;
619d112a816SZhao Yakui 		struct edp_power_seq pps;
620d112a816SZhao Yakui 	} edp;
621d112a816SZhao Yakui 	uint8_t panel_type;
6225c49fd3aSAlan Cox };
6235c49fd3aSAlan Cox 
6245c49fd3aSAlan Cox 
6259083eb38SArthur Borsboom /* Operations for each board type */
6265c49fd3aSAlan Cox struct psb_ops {
6275c49fd3aSAlan Cox 	const char *name;
6285c49fd3aSAlan Cox 	unsigned int accel_2d:1;
6295c49fd3aSAlan Cox 	int pipes;		/* Number of output pipes */
6305c49fd3aSAlan Cox 	int crtcs;		/* Number of CRTCs */
6315c49fd3aSAlan Cox 	int sgx_offset;		/* Base offset of SGX device */
632d235e64aSAlan Cox 	int hdmi_mask;		/* Mask of HDMI CRTCs */
633d235e64aSAlan Cox 	int lvds_mask;		/* Mask of LVDS CRTCs */
634cf8efd3aSPatrik Jakobsson 	int sdvo_mask;		/* Mask of SDVO CRTCs */
635bc794829SPatrik Jakobsson 	int cursor_needs_phys;  /* If cursor base reg need physical address */
6365c49fd3aSAlan Cox 
6375c49fd3aSAlan Cox 	/* Sub functions */
6385c49fd3aSAlan Cox 	struct drm_crtc_helper_funcs const *crtc_helper;
6395c49fd3aSAlan Cox 	struct drm_crtc_funcs const *crtc_funcs;
6405ea75e0fSPatrik Jakobsson 	const struct gma_clock_funcs *clock_funcs;
6415c49fd3aSAlan Cox 
6425c49fd3aSAlan Cox 	/* Setup hooks */
6435c49fd3aSAlan Cox 	int (*chip_setup)(struct drm_device *dev);
6445c49fd3aSAlan Cox 	void (*chip_teardown)(struct drm_device *dev);
645d235e64aSAlan Cox 	/* Optional helper caller after modeset */
646d235e64aSAlan Cox 	void (*errata)(struct drm_device *dev);
6475c49fd3aSAlan Cox 
6485c49fd3aSAlan Cox 	/* Display management hooks */
6495c49fd3aSAlan Cox 	int (*output_init)(struct drm_device *dev);
65068cb638fSAlan Cox 	int (*hotplug)(struct drm_device *dev);
65168cb638fSAlan Cox 	void (*hotplug_enable)(struct drm_device *dev, bool on);
6525c49fd3aSAlan Cox 	/* Power management hooks */
6535c49fd3aSAlan Cox 	void (*init_pm)(struct drm_device *dev);
6545c49fd3aSAlan Cox 	int (*save_regs)(struct drm_device *dev);
6555c49fd3aSAlan Cox 	int (*restore_regs)(struct drm_device *dev);
6565c49fd3aSAlan Cox 	int (*power_up)(struct drm_device *dev);
6575c49fd3aSAlan Cox 	int (*power_down)(struct drm_device *dev);
65828a8194cSPatrik Jakobsson 	void (*update_wm)(struct drm_device *dev, struct drm_crtc *crtc);
65975346fe9SPatrik Jakobsson 	void (*disable_sr)(struct drm_device *dev);
6605c49fd3aSAlan Cox 
6615c49fd3aSAlan Cox 	void (*lvds_bl_power)(struct drm_device *dev, bool on);
6625c49fd3aSAlan Cox #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
6635c49fd3aSAlan Cox 	/* Backlight */
6645c49fd3aSAlan Cox 	int (*backlight_init)(struct drm_device *dev);
6655c49fd3aSAlan Cox #endif
6665c49fd3aSAlan Cox 	int i2c_bus;		/* I2C bus identifier for Moorestown */
6675c49fd3aSAlan Cox };
6685c49fd3aSAlan Cox 
6695c49fd3aSAlan Cox 
6705c49fd3aSAlan Cox 
6715c49fd3aSAlan Cox extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
6725c49fd3aSAlan Cox extern int drm_pick_crtcs(struct drm_device *dev);
6735c49fd3aSAlan Cox 
6745c49fd3aSAlan Cox static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
6755c49fd3aSAlan Cox {
6765c49fd3aSAlan Cox 	return (struct drm_psb_private *) dev->dev_private;
6775c49fd3aSAlan Cox }
6785c49fd3aSAlan Cox 
6799083eb38SArthur Borsboom /* psb_irq.c */
680e9f0d76fSDaniel Vetter extern irqreturn_t psb_irq_handler(int irq, void *arg);
6815c49fd3aSAlan Cox extern int psb_irq_enable_dpst(struct drm_device *dev);
6825c49fd3aSAlan Cox extern int psb_irq_disable_dpst(struct drm_device *dev);
6835c49fd3aSAlan Cox extern void psb_irq_preinstall(struct drm_device *dev);
6845c49fd3aSAlan Cox extern int psb_irq_postinstall(struct drm_device *dev);
6855c49fd3aSAlan Cox extern void psb_irq_uninstall(struct drm_device *dev);
6865c49fd3aSAlan Cox extern void psb_irq_turn_on_dpst(struct drm_device *dev);
6875c49fd3aSAlan Cox extern void psb_irq_turn_off_dpst(struct drm_device *dev);
6885c49fd3aSAlan Cox 
6895c49fd3aSAlan Cox extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
6905c49fd3aSAlan Cox extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
6915c49fd3aSAlan Cox extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
69288e72717SThierry Reding extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
69388e72717SThierry Reding extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
6945c49fd3aSAlan Cox void
6955c49fd3aSAlan Cox psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
6965c49fd3aSAlan Cox 
6975c49fd3aSAlan Cox void
6985c49fd3aSAlan Cox psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
6995c49fd3aSAlan Cox 
70088e72717SThierry Reding extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
7015c49fd3aSAlan Cox 
7029083eb38SArthur Borsboom /* framebuffer.c */
7035c49fd3aSAlan Cox extern int psbfb_probed(struct drm_device *dev);
7045c49fd3aSAlan Cox extern int psbfb_remove(struct drm_device *dev,
7055c49fd3aSAlan Cox 			struct drm_framebuffer *fb);
7069083eb38SArthur Borsboom /* accel_2d.c */
7075c49fd3aSAlan Cox extern void psbfb_copyarea(struct fb_info *info,
7085c49fd3aSAlan Cox 					const struct fb_copyarea *region);
7095c49fd3aSAlan Cox extern int psbfb_sync(struct fb_info *info);
7105c49fd3aSAlan Cox extern void psb_spank(struct drm_psb_private *dev_priv);
7115c49fd3aSAlan Cox 
7129083eb38SArthur Borsboom /* psb_reset.c */
7135c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv);
7145c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);
7155c49fd3aSAlan Cox extern void psb_print_pagefault(struct drm_psb_private *dev_priv);
7165c49fd3aSAlan Cox 
7175c49fd3aSAlan Cox /* modesetting */
7185c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev);
7195c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev);
7205c49fd3aSAlan Cox extern int psb_fbdev_init(struct drm_device *dev);
7215c49fd3aSAlan Cox 
7225c49fd3aSAlan Cox /* backlight.c */
7235c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev);
7245c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev);
725d112a816SZhao Yakui void gma_backlight_disable(struct drm_device *dev);
726d112a816SZhao Yakui void gma_backlight_enable(struct drm_device *dev);
727d112a816SZhao Yakui void gma_backlight_set(struct drm_device *dev, int v);
7285c49fd3aSAlan Cox 
7295c49fd3aSAlan Cox /* oaktrail_crtc.c */
7305c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
7315c49fd3aSAlan Cox 
7325c49fd3aSAlan Cox /* oaktrail_lvds.c */
7335c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev,
7345c49fd3aSAlan Cox 		    struct psb_intel_mode_device *mode_dev);
7355c49fd3aSAlan Cox 
7365c49fd3aSAlan Cox /* psb_intel_display.c */
7375c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
7385c49fd3aSAlan Cox extern const struct drm_crtc_funcs psb_intel_crtc_funcs;
7395c49fd3aSAlan Cox 
7405c49fd3aSAlan Cox /* psb_intel_lvds.c */
7415c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs
7425c49fd3aSAlan Cox 					psb_intel_lvds_connector_helper_funcs;
7435c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
7445c49fd3aSAlan Cox 
7455c49fd3aSAlan Cox /* gem.c */
7465c49fd3aSAlan Cox extern void psb_gem_free_object(struct drm_gem_object *obj);
7475c49fd3aSAlan Cox extern int psb_gem_get_aperture(struct drm_device *dev, void *data,
7485c49fd3aSAlan Cox 			struct drm_file *file);
7495c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
7505c49fd3aSAlan Cox 			struct drm_mode_create_dumb *args);
7515c49fd3aSAlan Cox extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
7525c49fd3aSAlan Cox 			uint32_t handle, uint64_t *offset);
7535c49fd3aSAlan Cox extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
7545c49fd3aSAlan Cox extern int psb_gem_create_ioctl(struct drm_device *dev, void *data,
7555c49fd3aSAlan Cox 			struct drm_file *file);
7565c49fd3aSAlan Cox extern int psb_gem_mmap_ioctl(struct drm_device *dev, void *data,
7575c49fd3aSAlan Cox 					struct drm_file *file);
7585c49fd3aSAlan Cox 
7595c49fd3aSAlan Cox /* psb_device.c */
7605c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops;
7615c49fd3aSAlan Cox 
7625c49fd3aSAlan Cox /* oaktrail_device.c */
7635c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops;
7645c49fd3aSAlan Cox 
765026abc33SKirill A. Shutemov /* mdlfd_device.c */
766026abc33SKirill A. Shutemov extern const struct psb_ops mdfld_chip_ops;
767026abc33SKirill A. Shutemov 
7685c49fd3aSAlan Cox /* cdv_device.c */
7695c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops;
7705c49fd3aSAlan Cox 
7719083eb38SArthur Borsboom /* Debug print bits setting */
7725c49fd3aSAlan Cox #define PSB_D_GENERAL (1 << 0)
7735c49fd3aSAlan Cox #define PSB_D_INIT    (1 << 1)
7745c49fd3aSAlan Cox #define PSB_D_IRQ     (1 << 2)
7755c49fd3aSAlan Cox #define PSB_D_ENTRY   (1 << 3)
7765c49fd3aSAlan Cox /* debug the get H/V BP/FP count */
7775c49fd3aSAlan Cox #define PSB_D_HV      (1 << 4)
7785c49fd3aSAlan Cox #define PSB_D_DBI_BF  (1 << 5)
7795c49fd3aSAlan Cox #define PSB_D_PM      (1 << 6)
7805c49fd3aSAlan Cox #define PSB_D_RENDER  (1 << 7)
7815c49fd3aSAlan Cox #define PSB_D_REG     (1 << 8)
7825c49fd3aSAlan Cox #define PSB_D_MSVDX   (1 << 9)
7835c49fd3aSAlan Cox #define PSB_D_TOPAZ   (1 << 10)
7845c49fd3aSAlan Cox 
7855c49fd3aSAlan Cox extern int drm_idle_check_interval;
7865c49fd3aSAlan Cox 
7879083eb38SArthur Borsboom /* Utilities */
7885c49fd3aSAlan Cox static inline u32 MRST_MSG_READ32(uint port, uint offset)
7895c49fd3aSAlan Cox {
7905c49fd3aSAlan Cox 	int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
7915c49fd3aSAlan Cox 	uint32_t ret_val = 0;
7925c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
7935c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
7945c49fd3aSAlan Cox 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
7955c49fd3aSAlan Cox 	pci_dev_put(pci_root);
7965c49fd3aSAlan Cox 	return ret_val;
7975c49fd3aSAlan Cox }
7985c49fd3aSAlan Cox static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
7995c49fd3aSAlan Cox {
8005c49fd3aSAlan Cox 	int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
8015c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8025c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD4, value);
8035c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8045c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8055c49fd3aSAlan Cox }
8065c49fd3aSAlan Cox static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
8075c49fd3aSAlan Cox {
8085c49fd3aSAlan Cox 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
8095c49fd3aSAlan Cox 	uint32_t ret_val = 0;
8105c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8115c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8125c49fd3aSAlan Cox 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
8135c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8145c49fd3aSAlan Cox 	return ret_val;
8155c49fd3aSAlan Cox }
8165c49fd3aSAlan Cox static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
8175c49fd3aSAlan Cox {
8185c49fd3aSAlan Cox 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
8195c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8205c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD4, value);
8215c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8225c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8235c49fd3aSAlan Cox }
8245c49fd3aSAlan Cox 
8255c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
8265c49fd3aSAlan Cox {
8275c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8285c49fd3aSAlan Cox 	return ioread32(dev_priv->vdc_reg + reg);
8295c49fd3aSAlan Cox }
8305c49fd3aSAlan Cox 
8312657929dSPatrik Jakobsson static inline uint32_t REGISTER_READ_AUX(struct drm_device *dev, uint32_t reg)
8322657929dSPatrik Jakobsson {
8332657929dSPatrik Jakobsson 	struct drm_psb_private *dev_priv = dev->dev_private;
8342657929dSPatrik Jakobsson 	return ioread32(dev_priv->aux_reg + reg);
8352657929dSPatrik Jakobsson }
8362657929dSPatrik Jakobsson 
8375c49fd3aSAlan Cox #define REG_READ(reg)	       REGISTER_READ(dev, (reg))
8382657929dSPatrik Jakobsson #define REG_READ_AUX(reg)      REGISTER_READ_AUX(dev, (reg))
8395c49fd3aSAlan Cox 
840b97b8287SPatrik Jakobsson /* Useful for post reads */
841b97b8287SPatrik Jakobsson static inline uint32_t REGISTER_READ_WITH_AUX(struct drm_device *dev,
842b97b8287SPatrik Jakobsson 					      uint32_t reg, int aux)
843b97b8287SPatrik Jakobsson {
844b97b8287SPatrik Jakobsson 	uint32_t val;
845b97b8287SPatrik Jakobsson 
846b97b8287SPatrik Jakobsson 	if (aux)
847b97b8287SPatrik Jakobsson 		val = REG_READ_AUX(reg);
848b97b8287SPatrik Jakobsson 	else
849b97b8287SPatrik Jakobsson 		val = REG_READ(reg);
850b97b8287SPatrik Jakobsson 
851b97b8287SPatrik Jakobsson 	return val;
852b97b8287SPatrik Jakobsson }
853b97b8287SPatrik Jakobsson 
854b97b8287SPatrik Jakobsson #define REG_READ_WITH_AUX(reg, aux) REGISTER_READ_WITH_AUX(dev, (reg), (aux))
855b97b8287SPatrik Jakobsson 
8565c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
8575c49fd3aSAlan Cox 				  uint32_t val)
8585c49fd3aSAlan Cox {
8595c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8605c49fd3aSAlan Cox 	iowrite32((val), dev_priv->vdc_reg + (reg));
8615c49fd3aSAlan Cox }
8625c49fd3aSAlan Cox 
8632657929dSPatrik Jakobsson static inline void REGISTER_WRITE_AUX(struct drm_device *dev, uint32_t reg,
8642657929dSPatrik Jakobsson 				      uint32_t val)
8652657929dSPatrik Jakobsson {
8662657929dSPatrik Jakobsson 	struct drm_psb_private *dev_priv = dev->dev_private;
8672657929dSPatrik Jakobsson 	iowrite32((val), dev_priv->aux_reg + (reg));
8682657929dSPatrik Jakobsson }
8692657929dSPatrik Jakobsson 
8705c49fd3aSAlan Cox #define REG_WRITE(reg, val)	REGISTER_WRITE(dev, (reg), (val))
8712657929dSPatrik Jakobsson #define REG_WRITE_AUX(reg, val)	REGISTER_WRITE_AUX(dev, (reg), (val))
8725c49fd3aSAlan Cox 
873b97b8287SPatrik Jakobsson static inline void REGISTER_WRITE_WITH_AUX(struct drm_device *dev, uint32_t reg,
874b97b8287SPatrik Jakobsson 				      uint32_t val, int aux)
875b97b8287SPatrik Jakobsson {
876b97b8287SPatrik Jakobsson 	if (aux)
877b97b8287SPatrik Jakobsson 		REG_WRITE_AUX(reg, val);
878b97b8287SPatrik Jakobsson 	else
879b97b8287SPatrik Jakobsson 		REG_WRITE(reg, val);
880b97b8287SPatrik Jakobsson }
881b97b8287SPatrik Jakobsson 
882b97b8287SPatrik Jakobsson #define REG_WRITE_WITH_AUX(reg, val, aux) REGISTER_WRITE_WITH_AUX(dev, (reg), (val), (aux))
883b97b8287SPatrik Jakobsson 
8845c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev,
8855c49fd3aSAlan Cox 					uint32_t reg, uint32_t val)
8865c49fd3aSAlan Cox {
8875c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8885c49fd3aSAlan Cox 	iowrite16((val), dev_priv->vdc_reg + (reg));
8895c49fd3aSAlan Cox }
8905c49fd3aSAlan Cox 
8915c49fd3aSAlan Cox #define REG_WRITE16(reg, val)	  REGISTER_WRITE16(dev, (reg), (val))
8925c49fd3aSAlan Cox 
8935c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev,
8945c49fd3aSAlan Cox 				       uint32_t reg, uint32_t val)
8955c49fd3aSAlan Cox {
8965c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8975c49fd3aSAlan Cox 	iowrite8((val), dev_priv->vdc_reg + (reg));
8985c49fd3aSAlan Cox }
8995c49fd3aSAlan Cox 
9005c49fd3aSAlan Cox #define REG_WRITE8(reg, val)		REGISTER_WRITE8(dev, (reg), (val))
9015c49fd3aSAlan Cox 
9025c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs)		iowrite32(_val, dev_priv->vdc_reg + (_offs))
9035c49fd3aSAlan Cox #define PSB_RVDC32(_offs)		ioread32(dev_priv->vdc_reg + (_offs))
9045c49fd3aSAlan Cox 
9055c49fd3aSAlan Cox /* #define TRAP_SGX_PM_FAULT 1 */
9065c49fd3aSAlan Cox #ifdef TRAP_SGX_PM_FAULT
9075c49fd3aSAlan Cox #define PSB_RSGX32(_offs)						\
9085c49fd3aSAlan Cox ({									\
9095c49fd3aSAlan Cox 	if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) {		\
9105c49fd3aSAlan Cox 		printk(KERN_ERR						\
9115c49fd3aSAlan Cox 			"access sgx when it's off!! (READ) %s, %d\n",	\
9125c49fd3aSAlan Cox 	       __FILE__, __LINE__);					\
9135c49fd3aSAlan Cox 		melay(1000);						\
9145c49fd3aSAlan Cox 	}								\
9155c49fd3aSAlan Cox 	ioread32(dev_priv->sgx_reg + (_offs));				\
9165c49fd3aSAlan Cox })
9175c49fd3aSAlan Cox #else
9185c49fd3aSAlan Cox #define PSB_RSGX32(_offs)		ioread32(dev_priv->sgx_reg + (_offs))
9195c49fd3aSAlan Cox #endif
9205c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs)		iowrite32(_val, dev_priv->sgx_reg + (_offs))
9215c49fd3aSAlan Cox 
9225c49fd3aSAlan Cox #define MSVDX_REG_DUMP 0
9235c49fd3aSAlan Cox 
9245c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs)	iowrite32(_val, dev_priv->msvdx_reg + (_offs))
9255c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs)		ioread32(dev_priv->msvdx_reg + (_offs))
9265c49fd3aSAlan Cox 
9275c49fd3aSAlan Cox #endif
928