xref: /linux/drivers/gpu/drm/gma500/psb_drv.h (revision 700e59f6924719c70ac63e004ccafc6f15074fb0)
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>
265c49fd3aSAlan Cox #include "drm_global.h"
275c49fd3aSAlan Cox #include "gem_glue.h"
28838fa588SAlan Cox #include "gma_drm.h"
295c49fd3aSAlan Cox #include "psb_reg.h"
305c49fd3aSAlan Cox #include "psb_intel_drv.h"
315c49fd3aSAlan Cox #include "gtt.h"
325c49fd3aSAlan Cox #include "power.h"
335c49fd3aSAlan Cox #include "oaktrail.h"
345c49fd3aSAlan Cox 
355c49fd3aSAlan Cox /* Append new drm mode definition here, align with libdrm definition */
365c49fd3aSAlan Cox #define DRM_MODE_SCALE_NO_SCALE   	2
375c49fd3aSAlan Cox 
385c49fd3aSAlan Cox enum {
395c49fd3aSAlan Cox 	CHIP_PSB_8108 = 0,		/* Poulsbo */
405c49fd3aSAlan Cox 	CHIP_PSB_8109 = 1,		/* Poulsbo */
415c49fd3aSAlan Cox 	CHIP_MRST_4100 = 2,		/* Moorestown/Oaktrail */
425c49fd3aSAlan Cox 	CHIP_MFLD_0130 = 3,		/* Medfield */
435c49fd3aSAlan Cox };
445c49fd3aSAlan Cox 
45e036ba59SPatrik Jakobsson #define IS_PSB(dev) (((dev)->pci_device & 0xfffe) == 0x8108)
465c49fd3aSAlan Cox #define IS_MRST(dev) (((dev)->pci_device & 0xfffc) == 0x4100)
475c49fd3aSAlan Cox #define IS_MFLD(dev) (((dev)->pci_device & 0xfff8) == 0x0130)
485c49fd3aSAlan Cox 
495c49fd3aSAlan Cox /*
505c49fd3aSAlan Cox  * Driver definitions
515c49fd3aSAlan Cox  */
525c49fd3aSAlan Cox 
535c49fd3aSAlan Cox #define DRIVER_NAME "gma500"
545c49fd3aSAlan Cox #define DRIVER_DESC "DRM driver for the Intel GMA500"
555c49fd3aSAlan Cox 
565c49fd3aSAlan Cox #define PSB_DRM_DRIVER_DATE "2011-06-06"
575c49fd3aSAlan Cox #define PSB_DRM_DRIVER_MAJOR 1
585c49fd3aSAlan Cox #define PSB_DRM_DRIVER_MINOR 0
595c49fd3aSAlan Cox #define PSB_DRM_DRIVER_PATCHLEVEL 0
605c49fd3aSAlan Cox 
615c49fd3aSAlan Cox /*
625c49fd3aSAlan Cox  *	Hardware offsets
635c49fd3aSAlan Cox  */
645c49fd3aSAlan Cox #define PSB_VDC_OFFSET		 0x00000000
655c49fd3aSAlan Cox #define PSB_VDC_SIZE		 0x000080000
665c49fd3aSAlan Cox #define MRST_MMIO_SIZE		 0x0000C0000
675c49fd3aSAlan Cox #define MDFLD_MMIO_SIZE          0x000100000
685c49fd3aSAlan Cox #define PSB_SGX_SIZE		 0x8000
695c49fd3aSAlan Cox #define PSB_SGX_OFFSET		 0x00040000
705c49fd3aSAlan Cox #define MRST_SGX_OFFSET		 0x00080000
715c49fd3aSAlan Cox /*
725c49fd3aSAlan Cox  *	PCI resource identifiers
735c49fd3aSAlan Cox  */
745c49fd3aSAlan Cox #define PSB_MMIO_RESOURCE	 0
755c49fd3aSAlan Cox #define PSB_GATT_RESOURCE	 2
765c49fd3aSAlan Cox #define PSB_GTT_RESOURCE	 3
775c49fd3aSAlan Cox /*
785c49fd3aSAlan Cox  *	PCI configuration
795c49fd3aSAlan Cox  */
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
865c49fd3aSAlan Cox 
875c49fd3aSAlan Cox /* To get rid of */
885c49fd3aSAlan Cox #define PSB_TT_PRIV0_LIMIT	 (256*1024*1024)
895c49fd3aSAlan Cox #define PSB_TT_PRIV0_PLIMIT	 (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
905c49fd3aSAlan Cox 
915c49fd3aSAlan Cox /*
925c49fd3aSAlan Cox  *	SGX side MMU definitions (these can probably go)
935c49fd3aSAlan Cox  */
945c49fd3aSAlan Cox 
955c49fd3aSAlan Cox /*
965c49fd3aSAlan Cox  *	Flags for external memory type field.
975c49fd3aSAlan Cox  */
985c49fd3aSAlan Cox #define PSB_MMU_CACHED_MEMORY	  0x0001	/* Bind to MMU only */
995c49fd3aSAlan Cox #define PSB_MMU_RO_MEMORY	  0x0002	/* MMU RO memory */
1005c49fd3aSAlan Cox #define PSB_MMU_WO_MEMORY	  0x0004	/* MMU WO memory */
1015c49fd3aSAlan Cox /*
1025c49fd3aSAlan Cox  *	PTE's and PDE's
1035c49fd3aSAlan Cox  */
1045c49fd3aSAlan Cox #define PSB_PDE_MASK		  0x003FFFFF
1055c49fd3aSAlan Cox #define PSB_PDE_SHIFT		  22
1065c49fd3aSAlan Cox #define PSB_PTE_SHIFT		  12
1075c49fd3aSAlan Cox /*
1085c49fd3aSAlan Cox  *	Cache control
1095c49fd3aSAlan Cox  */
1105c49fd3aSAlan Cox #define PSB_PTE_VALID		  0x0001	/* PTE / PDE valid */
1115c49fd3aSAlan Cox #define PSB_PTE_WO		  0x0002	/* Write only */
1125c49fd3aSAlan Cox #define PSB_PTE_RO		  0x0004	/* Read only */
1135c49fd3aSAlan Cox #define PSB_PTE_CACHED		  0x0008	/* CPU cache coherent */
1145c49fd3aSAlan Cox 
1155c49fd3aSAlan Cox /*
1165c49fd3aSAlan Cox  *	VDC registers and bits
1175c49fd3aSAlan Cox  */
1185c49fd3aSAlan Cox #define PSB_MSVDX_CLOCKGATING	  0x2064
1195c49fd3aSAlan Cox #define PSB_TOPAZ_CLOCKGATING	  0x2068
1205c49fd3aSAlan Cox #define PSB_HWSTAM		  0x2098
1215c49fd3aSAlan Cox #define PSB_INSTPM		  0x20C0
1225c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R        0x20A4
1235c49fd3aSAlan Cox #define _MDFLD_PIPEC_EVENT_FLAG   (1<<2)
1245c49fd3aSAlan Cox #define _MDFLD_PIPEC_VBLANK_FLAG  (1<<3)
1255c49fd3aSAlan Cox #define _PSB_DPST_PIPEB_FLAG      (1<<4)
1265c49fd3aSAlan Cox #define _MDFLD_PIPEB_EVENT_FLAG   (1<<4)
1275c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEB_FLAG	  (1<<5)
1285c49fd3aSAlan Cox #define _PSB_DPST_PIPEA_FLAG      (1<<6)
1295c49fd3aSAlan Cox #define _PSB_PIPEA_EVENT_FLAG     (1<<6)
1305c49fd3aSAlan Cox #define _PSB_VSYNC_PIPEA_FLAG	  (1<<7)
1315c49fd3aSAlan Cox #define _MDFLD_MIPIA_FLAG	  (1<<16)
1325c49fd3aSAlan Cox #define _MDFLD_MIPIC_FLAG	  (1<<17)
1335c49fd3aSAlan Cox #define _PSB_IRQ_SGX_FLAG	  (1<<18)
1345c49fd3aSAlan Cox #define _PSB_IRQ_MSVDX_FLAG	  (1<<19)
1355c49fd3aSAlan Cox #define _LNC_IRQ_TOPAZ_FLAG	  (1<<20)
1365c49fd3aSAlan Cox 
137*700e59f6SPatrik Jakobsson #define _PSB_PIPE_EVENT_FLAG	(_PSB_VSYNC_PIPEA_FLAG | \
138*700e59f6SPatrik Jakobsson 				 _PSB_VSYNC_PIPEB_FLAG)
139*700e59f6SPatrik Jakobsson 
1405c49fd3aSAlan Cox /* This flag includes all the display IRQ bits excepts the vblank irqs. */
1415c49fd3aSAlan Cox #define _MDFLD_DISP_ALL_IRQ_FLAG (_MDFLD_PIPEC_EVENT_FLAG | \
1425c49fd3aSAlan Cox 				  _MDFLD_PIPEB_EVENT_FLAG | \
1435c49fd3aSAlan Cox 				  _PSB_PIPEA_EVENT_FLAG | \
1445c49fd3aSAlan Cox 				  _PSB_VSYNC_PIPEA_FLAG | \
1455c49fd3aSAlan Cox 				  _MDFLD_MIPIA_FLAG | \
1465c49fd3aSAlan Cox 				  _MDFLD_MIPIC_FLAG)
1475c49fd3aSAlan Cox #define PSB_INT_IDENTITY_R	  0x20A4
1485c49fd3aSAlan Cox #define PSB_INT_MASK_R		  0x20A8
1495c49fd3aSAlan Cox #define PSB_INT_ENABLE_R	  0x20A0
1505c49fd3aSAlan Cox 
1515c49fd3aSAlan Cox #define _PSB_MMU_ER_MASK      0x0001FF00
1525c49fd3aSAlan Cox #define _PSB_MMU_ER_HOST      (1 << 16)
1535c49fd3aSAlan Cox #define GPIOA			0x5010
1545c49fd3aSAlan Cox #define GPIOB			0x5014
1555c49fd3aSAlan Cox #define GPIOC			0x5018
1565c49fd3aSAlan Cox #define GPIOD			0x501c
1575c49fd3aSAlan Cox #define GPIOE			0x5020
1585c49fd3aSAlan Cox #define GPIOF			0x5024
1595c49fd3aSAlan Cox #define GPIOG			0x5028
1605c49fd3aSAlan Cox #define GPIOH			0x502c
1615c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_MASK		(1 << 0)
1625c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_IN		(0 << 1)
1635c49fd3aSAlan Cox #define GPIO_CLOCK_DIR_OUT		(1 << 1)
1645c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_MASK		(1 << 2)
1655c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_OUT		(1 << 3)
1665c49fd3aSAlan Cox #define GPIO_CLOCK_VAL_IN		(1 << 4)
1675c49fd3aSAlan Cox #define GPIO_CLOCK_PULLUP_DISABLE	(1 << 5)
1685c49fd3aSAlan Cox #define GPIO_DATA_DIR_MASK		(1 << 8)
1695c49fd3aSAlan Cox #define GPIO_DATA_DIR_IN		(0 << 9)
1705c49fd3aSAlan Cox #define GPIO_DATA_DIR_OUT		(1 << 9)
1715c49fd3aSAlan Cox #define GPIO_DATA_VAL_MASK		(1 << 10)
1725c49fd3aSAlan Cox #define GPIO_DATA_VAL_OUT		(1 << 11)
1735c49fd3aSAlan Cox #define GPIO_DATA_VAL_IN		(1 << 12)
1745c49fd3aSAlan Cox #define GPIO_DATA_PULLUP_DISABLE	(1 << 13)
1755c49fd3aSAlan Cox 
1765c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA0   0x6000
1775c49fd3aSAlan Cox #define VCLK_DIVISOR_VGA1   0x6004
1785c49fd3aSAlan Cox #define VCLK_POST_DIV	    0x6010
1795c49fd3aSAlan Cox 
1805c49fd3aSAlan Cox #define PSB_COMM_2D (PSB_ENGINE_2D << 4)
1815c49fd3aSAlan Cox #define PSB_COMM_3D (PSB_ENGINE_3D << 4)
1825c49fd3aSAlan Cox #define PSB_COMM_TA (PSB_ENGINE_TA << 4)
1835c49fd3aSAlan Cox #define PSB_COMM_HP (PSB_ENGINE_HP << 4)
1845c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ (1024 >> 2)
1855c49fd3aSAlan Cox #define PSB_COMM_USER_IRQ_LOST (PSB_COMM_USER_IRQ + 1)
1865c49fd3aSAlan Cox #define PSB_COMM_FW (2048 >> 2)
1875c49fd3aSAlan Cox 
1885c49fd3aSAlan Cox #define PSB_UIRQ_VISTEST	       1
1895c49fd3aSAlan Cox #define PSB_UIRQ_OOM_REPLY	       2
1905c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_TA_REPLY	       3
1915c49fd3aSAlan Cox #define PSB_UIRQ_FIRE_RASTER_REPLY     4
1925c49fd3aSAlan Cox 
1935c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024)
1945c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024
1955c49fd3aSAlan Cox 
1965c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204
1975c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600
1985c49fd3aSAlan Cox 
1995c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2
2005c49fd3aSAlan Cox 
2015c49fd3aSAlan Cox 
2025c49fd3aSAlan Cox #define PSB_2D_SIZE (256*1024*1024)
2035c49fd3aSAlan Cox #define PSB_MAX_RELOC_PAGES 1024
2045c49fd3aSAlan Cox 
2055c49fd3aSAlan Cox #define PSB_LOW_REG_OFFS 0x0204
2065c49fd3aSAlan Cox #define PSB_HIGH_REG_OFFS 0x0600
2075c49fd3aSAlan Cox 
2085c49fd3aSAlan Cox #define PSB_NUM_VBLANKS 2
2095c49fd3aSAlan Cox #define PSB_WATCHDOG_DELAY (DRM_HZ * 2)
2105c49fd3aSAlan Cox #define PSB_LID_DELAY (DRM_HZ / 10)
2115c49fd3aSAlan Cox 
2125c49fd3aSAlan Cox #define MDFLD_PNW_B0 0x04
2135c49fd3aSAlan Cox #define MDFLD_PNW_C0 0x08
2145c49fd3aSAlan Cox 
2155c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_0 	(1 << 0)
2165c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D_2 	(1 << 1)
2175c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_0 	(1 << 2)
2185c49fd3aSAlan Cox #define MDFLD_DSR_CURSOR_2	(1 << 3)
2195c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_0 	(1 << 4)
2205c49fd3aSAlan Cox #define MDFLD_DSR_OVERLAY_2 	(1 << 5)
2215c49fd3aSAlan Cox #define MDFLD_DSR_MIPI_CONTROL	(1 << 6)
2225c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_0	((1 << 0) | (1 << 2) | (1 << 4))
2235c49fd3aSAlan Cox #define MDFLD_DSR_DAMAGE_MASK_2	((1 << 1) | (1 << 3) | (1 << 5))
2245c49fd3aSAlan Cox #define MDFLD_DSR_2D_3D 	(MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2)
2255c49fd3aSAlan Cox 
2265c49fd3aSAlan Cox #define MDFLD_DSR_RR		45
2275c49fd3aSAlan Cox #define MDFLD_DPU_ENABLE 	(1 << 31)
2285c49fd3aSAlan Cox #define MDFLD_DSR_FULLSCREEN 	(1 << 30)
2295c49fd3aSAlan Cox #define MDFLD_DSR_DELAY		(DRM_HZ / MDFLD_DSR_RR)
2305c49fd3aSAlan Cox 
2315c49fd3aSAlan Cox #define PSB_PWR_STATE_ON		1
2325c49fd3aSAlan Cox #define PSB_PWR_STATE_OFF		2
2335c49fd3aSAlan Cox 
2345c49fd3aSAlan Cox #define PSB_PMPOLICY_NOPM		0
2355c49fd3aSAlan Cox #define PSB_PMPOLICY_CLOCKGATING	1
2365c49fd3aSAlan Cox #define PSB_PMPOLICY_POWERDOWN		2
2375c49fd3aSAlan Cox 
2385c49fd3aSAlan Cox #define PSB_PMSTATE_POWERUP		0
2395c49fd3aSAlan Cox #define PSB_PMSTATE_CLOCKGATED		1
2405c49fd3aSAlan Cox #define PSB_PMSTATE_POWERDOWN		2
2415c49fd3aSAlan Cox #define PSB_PCIx_MSI_ADDR_LOC		0x94
2425c49fd3aSAlan Cox #define PSB_PCIx_MSI_DATA_LOC		0x98
2435c49fd3aSAlan Cox 
2445c49fd3aSAlan Cox /* Medfield crystal settings */
2455c49fd3aSAlan Cox #define KSEL_CRYSTAL_19 1
2465c49fd3aSAlan Cox #define KSEL_BYPASS_19 5
2475c49fd3aSAlan Cox #define KSEL_BYPASS_25 6
2485c49fd3aSAlan Cox #define KSEL_BYPASS_83_100 7
2495c49fd3aSAlan Cox 
2505c49fd3aSAlan Cox struct opregion_header;
2515c49fd3aSAlan Cox struct opregion_acpi;
2525c49fd3aSAlan Cox struct opregion_swsci;
2535c49fd3aSAlan Cox struct opregion_asle;
2545c49fd3aSAlan Cox 
2555c49fd3aSAlan Cox struct psb_intel_opregion {
2565c49fd3aSAlan Cox 	struct opregion_header *header;
2575c49fd3aSAlan Cox 	struct opregion_acpi *acpi;
2585c49fd3aSAlan Cox 	struct opregion_swsci *swsci;
2595c49fd3aSAlan Cox 	struct opregion_asle *asle;
2605c49fd3aSAlan Cox 	int enabled;
2615c49fd3aSAlan Cox };
2625c49fd3aSAlan Cox 
2635c49fd3aSAlan Cox struct psb_ops;
2645c49fd3aSAlan Cox 
26504bd564fSAlan Cox #define PSB_NUM_PIPE		3
26604bd564fSAlan Cox 
2675c49fd3aSAlan Cox struct drm_psb_private {
2685c49fd3aSAlan Cox 	struct drm_device *dev;
2695c49fd3aSAlan Cox 	const struct psb_ops *ops;
2705c49fd3aSAlan Cox 
2715c49fd3aSAlan Cox 	struct psb_gtt gtt;
2725c49fd3aSAlan Cox 
2735c49fd3aSAlan Cox 	/* GTT Memory manager */
2745c49fd3aSAlan Cox 	struct psb_gtt_mm *gtt_mm;
2755c49fd3aSAlan Cox 	struct page *scratch_page;
2765c49fd3aSAlan Cox 	u32 *gtt_map;
2775c49fd3aSAlan Cox 	uint32_t stolen_base;
2785c49fd3aSAlan Cox 	void *vram_addr;
2795c49fd3aSAlan Cox 	unsigned long vram_stolen_size;
2805c49fd3aSAlan Cox 	int gtt_initialized;
2815c49fd3aSAlan Cox 	u16 gmch_ctrl;		/* Saved GTT setup */
2825c49fd3aSAlan Cox 	u32 pge_ctl;
2835c49fd3aSAlan Cox 
2845c49fd3aSAlan Cox 	struct mutex gtt_mutex;
2855c49fd3aSAlan Cox 	struct resource *gtt_mem;	/* Our PCI resource */
2865c49fd3aSAlan Cox 
2875c49fd3aSAlan Cox 	struct psb_mmu_driver *mmu;
2885c49fd3aSAlan Cox 	struct psb_mmu_pd *pf_pd;
2895c49fd3aSAlan Cox 
2905c49fd3aSAlan Cox 	/*
2915c49fd3aSAlan Cox 	 * Register base
2925c49fd3aSAlan Cox 	 */
2935c49fd3aSAlan Cox 
2945c49fd3aSAlan Cox 	uint8_t *sgx_reg;
2955c49fd3aSAlan Cox 	uint8_t *vdc_reg;
2965c49fd3aSAlan Cox 	uint32_t gatt_free_offset;
2975c49fd3aSAlan Cox 
2985c49fd3aSAlan Cox 	/*
2995c49fd3aSAlan Cox 	 * Fencing / irq.
3005c49fd3aSAlan Cox 	 */
3015c49fd3aSAlan Cox 
3025c49fd3aSAlan Cox 	uint32_t vdc_irq_mask;
3035c49fd3aSAlan Cox 	uint32_t pipestat[PSB_NUM_PIPE];
3045c49fd3aSAlan Cox 
3055c49fd3aSAlan Cox 	spinlock_t irqmask_lock;
3065c49fd3aSAlan Cox 
3075c49fd3aSAlan Cox 	/*
3085c49fd3aSAlan Cox 	 * Power
3095c49fd3aSAlan Cox 	 */
3105c49fd3aSAlan Cox 
3115c49fd3aSAlan Cox 	bool suspended;
3125c49fd3aSAlan Cox 	bool display_power;
3135c49fd3aSAlan Cox 	int display_count;
3145c49fd3aSAlan Cox 
3155c49fd3aSAlan Cox 	/*
3165c49fd3aSAlan Cox 	 * Modesetting
3175c49fd3aSAlan Cox 	 */
3185c49fd3aSAlan Cox 	struct psb_intel_mode_device mode_dev;
3195c49fd3aSAlan Cox 
3205c49fd3aSAlan Cox 	struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
3215c49fd3aSAlan Cox 	struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
3225c49fd3aSAlan Cox 	uint32_t num_pipe;
3235c49fd3aSAlan Cox 
3245c49fd3aSAlan Cox 	/*
3255c49fd3aSAlan Cox 	 * OSPM info (Power management base) (can go ?)
3265c49fd3aSAlan Cox 	 */
3275c49fd3aSAlan Cox 	uint32_t ospm_base;
3285c49fd3aSAlan Cox 
3295c49fd3aSAlan Cox 	/*
3305c49fd3aSAlan Cox 	 * Sizes info
3315c49fd3aSAlan Cox 	 */
3325c49fd3aSAlan Cox 
3335c49fd3aSAlan Cox 	u32 fuse_reg_value;
3345c49fd3aSAlan Cox 	u32 video_device_fuse;
3355c49fd3aSAlan Cox 
3365c49fd3aSAlan Cox 	/* PCI revision ID for B0:D2:F0 */
3375c49fd3aSAlan Cox 	uint8_t platform_rev_id;
3385c49fd3aSAlan Cox 
3395c49fd3aSAlan Cox 	/*
3405c49fd3aSAlan Cox 	 * LVDS info
3415c49fd3aSAlan Cox 	 */
3425c49fd3aSAlan Cox 	int backlight_duty_cycle;	/* restore backlight to this value */
3435c49fd3aSAlan Cox 	bool panel_wants_dither;
3445c49fd3aSAlan Cox 	struct drm_display_mode *panel_fixed_mode;
3455c49fd3aSAlan Cox 	struct drm_display_mode *lfp_lvds_vbt_mode;
3465c49fd3aSAlan Cox 	struct drm_display_mode *sdvo_lvds_vbt_mode;
3475c49fd3aSAlan Cox 
3485c49fd3aSAlan Cox 	struct bdb_lvds_backlight *lvds_bl; /* LVDS backlight info from VBT */
3495c49fd3aSAlan Cox 	struct psb_intel_i2c_chan *lvds_i2c_bus;
3505c49fd3aSAlan Cox 
3515c49fd3aSAlan Cox 	/* Feature bits from the VBIOS */
3525c49fd3aSAlan Cox 	unsigned int int_tv_support:1;
3535c49fd3aSAlan Cox 	unsigned int lvds_dither:1;
3545c49fd3aSAlan Cox 	unsigned int lvds_vbt:1;
3555c49fd3aSAlan Cox 	unsigned int int_crt_support:1;
3565c49fd3aSAlan Cox 	unsigned int lvds_use_ssc:1;
3575c49fd3aSAlan Cox 	int lvds_ssc_freq;
3585c49fd3aSAlan Cox 	bool is_lvds_on;
3595c49fd3aSAlan Cox 	bool is_mipi_on;
3605c49fd3aSAlan Cox 	u32 mipi_ctrl_display;
3615c49fd3aSAlan Cox 
3625c49fd3aSAlan Cox 	unsigned int core_freq;
3635c49fd3aSAlan Cox 	uint32_t iLVDS_enable;
3645c49fd3aSAlan Cox 
3655c49fd3aSAlan Cox 	/* Runtime PM state */
3665c49fd3aSAlan Cox 	int rpm_enabled;
3675c49fd3aSAlan Cox 
3685c49fd3aSAlan Cox 	/* MID specific */
3695c49fd3aSAlan Cox 	struct oaktrail_vbt vbt_data;
3705c49fd3aSAlan Cox 	struct oaktrail_gct_data gct_data;
3715c49fd3aSAlan Cox 
3725c49fd3aSAlan Cox 	/* MIPI Panel type etc */
3735c49fd3aSAlan Cox 	int panel_id;
3745c49fd3aSAlan Cox 	bool dual_mipi;		/* dual display - DPI & DBI */
3755c49fd3aSAlan Cox 	bool dpi_panel_on;	/* The DPI panel power is on */
3765c49fd3aSAlan Cox 	bool dpi_panel_on2;	/* The DPI panel power is on */
3775c49fd3aSAlan Cox 	bool dbi_panel_on;	/* The DBI panel power is on */
3785c49fd3aSAlan Cox 	bool dbi_panel_on2;	/* The DBI panel power is on */
3795c49fd3aSAlan Cox 	u32 dsr_fb_update;	/* DSR FB update counter */
3805c49fd3aSAlan Cox 
3815c49fd3aSAlan Cox 	/* Moorestown HDMI state */
3825c49fd3aSAlan Cox 	struct oaktrail_hdmi_dev *hdmi_priv;
3835c49fd3aSAlan Cox 
3845c49fd3aSAlan Cox 	/* Moorestown pipe config register value cache */
3855c49fd3aSAlan Cox 	uint32_t pipeconf;
3865c49fd3aSAlan Cox 	uint32_t pipeconf1;
3875c49fd3aSAlan Cox 	uint32_t pipeconf2;
3885c49fd3aSAlan Cox 
3895c49fd3aSAlan Cox 	/* Moorestown plane control register value cache */
3905c49fd3aSAlan Cox 	uint32_t dspcntr;
3915c49fd3aSAlan Cox 	uint32_t dspcntr1;
3925c49fd3aSAlan Cox 	uint32_t dspcntr2;
3935c49fd3aSAlan Cox 
3945c49fd3aSAlan Cox 	/* Moorestown MM backlight cache */
3955c49fd3aSAlan Cox 	uint8_t saveBKLTCNT;
3965c49fd3aSAlan Cox 	uint8_t saveBKLTREQ;
3975c49fd3aSAlan Cox 	uint8_t saveBKLTBRTL;
3985c49fd3aSAlan Cox 
3995c49fd3aSAlan Cox 	/*
4005c49fd3aSAlan Cox 	 * Register state
4015c49fd3aSAlan Cox 	 */
4025c49fd3aSAlan Cox 	uint32_t saveDSPACNTR;
4035c49fd3aSAlan Cox 	uint32_t saveDSPBCNTR;
4045c49fd3aSAlan Cox 	uint32_t savePIPEACONF;
4055c49fd3aSAlan Cox 	uint32_t savePIPEBCONF;
4065c49fd3aSAlan Cox 	uint32_t savePIPEASRC;
4075c49fd3aSAlan Cox 	uint32_t savePIPEBSRC;
4085c49fd3aSAlan Cox 	uint32_t saveFPA0;
4095c49fd3aSAlan Cox 	uint32_t saveFPA1;
4105c49fd3aSAlan Cox 	uint32_t saveDPLL_A;
4115c49fd3aSAlan Cox 	uint32_t saveDPLL_A_MD;
4125c49fd3aSAlan Cox 	uint32_t saveHTOTAL_A;
4135c49fd3aSAlan Cox 	uint32_t saveHBLANK_A;
4145c49fd3aSAlan Cox 	uint32_t saveHSYNC_A;
4155c49fd3aSAlan Cox 	uint32_t saveVTOTAL_A;
4165c49fd3aSAlan Cox 	uint32_t saveVBLANK_A;
4175c49fd3aSAlan Cox 	uint32_t saveVSYNC_A;
4185c49fd3aSAlan Cox 	uint32_t saveDSPASTRIDE;
4195c49fd3aSAlan Cox 	uint32_t saveDSPASIZE;
4205c49fd3aSAlan Cox 	uint32_t saveDSPAPOS;
4215c49fd3aSAlan Cox 	uint32_t saveDSPABASE;
4225c49fd3aSAlan Cox 	uint32_t saveDSPASURF;
4235c49fd3aSAlan Cox 	uint32_t saveDSPASTATUS;
4245c49fd3aSAlan Cox 	uint32_t saveFPB0;
4255c49fd3aSAlan Cox 	uint32_t saveFPB1;
4265c49fd3aSAlan Cox 	uint32_t saveDPLL_B;
4275c49fd3aSAlan Cox 	uint32_t saveDPLL_B_MD;
4285c49fd3aSAlan Cox 	uint32_t saveHTOTAL_B;
4295c49fd3aSAlan Cox 	uint32_t saveHBLANK_B;
4305c49fd3aSAlan Cox 	uint32_t saveHSYNC_B;
4315c49fd3aSAlan Cox 	uint32_t saveVTOTAL_B;
4325c49fd3aSAlan Cox 	uint32_t saveVBLANK_B;
4335c49fd3aSAlan Cox 	uint32_t saveVSYNC_B;
4345c49fd3aSAlan Cox 	uint32_t saveDSPBSTRIDE;
4355c49fd3aSAlan Cox 	uint32_t saveDSPBSIZE;
4365c49fd3aSAlan Cox 	uint32_t saveDSPBPOS;
4375c49fd3aSAlan Cox 	uint32_t saveDSPBBASE;
4385c49fd3aSAlan Cox 	uint32_t saveDSPBSURF;
4395c49fd3aSAlan Cox 	uint32_t saveDSPBSTATUS;
4405c49fd3aSAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA0;
4415c49fd3aSAlan Cox 	uint32_t saveVCLK_DIVISOR_VGA1;
4425c49fd3aSAlan Cox 	uint32_t saveVCLK_POST_DIV;
4435c49fd3aSAlan Cox 	uint32_t saveVGACNTRL;
4445c49fd3aSAlan Cox 	uint32_t saveADPA;
4455c49fd3aSAlan Cox 	uint32_t saveLVDS;
4465c49fd3aSAlan Cox 	uint32_t saveDVOA;
4475c49fd3aSAlan Cox 	uint32_t saveDVOB;
4485c49fd3aSAlan Cox 	uint32_t saveDVOC;
4495c49fd3aSAlan Cox 	uint32_t savePP_ON;
4505c49fd3aSAlan Cox 	uint32_t savePP_OFF;
4515c49fd3aSAlan Cox 	uint32_t savePP_CONTROL;
4525c49fd3aSAlan Cox 	uint32_t savePP_CYCLE;
4535c49fd3aSAlan Cox 	uint32_t savePFIT_CONTROL;
4545c49fd3aSAlan Cox 	uint32_t savePaletteA[256];
4555c49fd3aSAlan Cox 	uint32_t savePaletteB[256];
4565c49fd3aSAlan Cox 	uint32_t saveBLC_PWM_CTL2;
4575c49fd3aSAlan Cox 	uint32_t saveBLC_PWM_CTL;
4585c49fd3aSAlan Cox 	uint32_t saveCLOCKGATING;
4595c49fd3aSAlan Cox 	uint32_t saveDSPARB;
4605c49fd3aSAlan Cox 	uint32_t saveDSPATILEOFF;
4615c49fd3aSAlan Cox 	uint32_t saveDSPBTILEOFF;
4625c49fd3aSAlan Cox 	uint32_t saveDSPAADDR;
4635c49fd3aSAlan Cox 	uint32_t saveDSPBADDR;
4645c49fd3aSAlan Cox 	uint32_t savePFIT_AUTO_RATIOS;
4655c49fd3aSAlan Cox 	uint32_t savePFIT_PGM_RATIOS;
4665c49fd3aSAlan Cox 	uint32_t savePP_ON_DELAYS;
4675c49fd3aSAlan Cox 	uint32_t savePP_OFF_DELAYS;
4685c49fd3aSAlan Cox 	uint32_t savePP_DIVISOR;
4695c49fd3aSAlan Cox 	uint32_t saveBSM;
4705c49fd3aSAlan Cox 	uint32_t saveVBT;
4715c49fd3aSAlan Cox 	uint32_t saveBCLRPAT_A;
4725c49fd3aSAlan Cox 	uint32_t saveBCLRPAT_B;
4735c49fd3aSAlan Cox 	uint32_t saveDSPALINOFF;
4745c49fd3aSAlan Cox 	uint32_t saveDSPBLINOFF;
4755c49fd3aSAlan Cox 	uint32_t savePERF_MODE;
4765c49fd3aSAlan Cox 	uint32_t saveDSPFW1;
4775c49fd3aSAlan Cox 	uint32_t saveDSPFW2;
4785c49fd3aSAlan Cox 	uint32_t saveDSPFW3;
4795c49fd3aSAlan Cox 	uint32_t saveDSPFW4;
4805c49fd3aSAlan Cox 	uint32_t saveDSPFW5;
4815c49fd3aSAlan Cox 	uint32_t saveDSPFW6;
4825c49fd3aSAlan Cox 	uint32_t saveCHICKENBIT;
4835c49fd3aSAlan Cox 	uint32_t saveDSPACURSOR_CTRL;
4845c49fd3aSAlan Cox 	uint32_t saveDSPBCURSOR_CTRL;
4855c49fd3aSAlan Cox 	uint32_t saveDSPACURSOR_BASE;
4865c49fd3aSAlan Cox 	uint32_t saveDSPBCURSOR_BASE;
4875c49fd3aSAlan Cox 	uint32_t saveDSPACURSOR_POS;
4885c49fd3aSAlan Cox 	uint32_t saveDSPBCURSOR_POS;
4895c49fd3aSAlan Cox 	uint32_t save_palette_a[256];
4905c49fd3aSAlan Cox 	uint32_t save_palette_b[256];
4915c49fd3aSAlan Cox 	uint32_t saveOV_OVADD;
4925c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC0;
4935c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC1;
4945c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC2;
4955c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC3;
4965c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC4;
4975c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC5;
4985c49fd3aSAlan Cox 	uint32_t saveOVC_OVADD;
4995c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC0;
5005c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC1;
5015c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC2;
5025c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC3;
5035c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC4;
5045c49fd3aSAlan Cox 	uint32_t saveOVC_OGAMC5;
5055c49fd3aSAlan Cox 
5065c49fd3aSAlan Cox 	/* MSI reg save */
5075c49fd3aSAlan Cox 	uint32_t msi_addr;
5085c49fd3aSAlan Cox 	uint32_t msi_data;
5095c49fd3aSAlan Cox 
5105c49fd3aSAlan Cox 	/* Medfield specific register save state */
5115c49fd3aSAlan Cox 	uint32_t saveHDMIPHYMISCCTL;
5125c49fd3aSAlan Cox 	uint32_t saveHDMIB_CONTROL;
5135c49fd3aSAlan Cox 	uint32_t saveDSPCCNTR;
5145c49fd3aSAlan Cox 	uint32_t savePIPECCONF;
5155c49fd3aSAlan Cox 	uint32_t savePIPECSRC;
5165c49fd3aSAlan Cox 	uint32_t saveHTOTAL_C;
5175c49fd3aSAlan Cox 	uint32_t saveHBLANK_C;
5185c49fd3aSAlan Cox 	uint32_t saveHSYNC_C;
5195c49fd3aSAlan Cox 	uint32_t saveVTOTAL_C;
5205c49fd3aSAlan Cox 	uint32_t saveVBLANK_C;
5215c49fd3aSAlan Cox 	uint32_t saveVSYNC_C;
5225c49fd3aSAlan Cox 	uint32_t saveDSPCSTRIDE;
5235c49fd3aSAlan Cox 	uint32_t saveDSPCSIZE;
5245c49fd3aSAlan Cox 	uint32_t saveDSPCPOS;
5255c49fd3aSAlan Cox 	uint32_t saveDSPCSURF;
5265c49fd3aSAlan Cox 	uint32_t saveDSPCSTATUS;
5275c49fd3aSAlan Cox 	uint32_t saveDSPCLINOFF;
5285c49fd3aSAlan Cox 	uint32_t saveDSPCTILEOFF;
5295c49fd3aSAlan Cox 	uint32_t saveDSPCCURSOR_CTRL;
5305c49fd3aSAlan Cox 	uint32_t saveDSPCCURSOR_BASE;
5315c49fd3aSAlan Cox 	uint32_t saveDSPCCURSOR_POS;
5325c49fd3aSAlan Cox 	uint32_t save_palette_c[256];
5335c49fd3aSAlan Cox 	uint32_t saveOV_OVADD_C;
5345c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC0_C;
5355c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC1_C;
5365c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC2_C;
5375c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC3_C;
5385c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC4_C;
5395c49fd3aSAlan Cox 	uint32_t saveOV_OGAMC5_C;
5405c49fd3aSAlan Cox 
5415c49fd3aSAlan Cox 	/* DSI register save */
5425c49fd3aSAlan Cox 	uint32_t saveDEVICE_READY_REG;
5435c49fd3aSAlan Cox 	uint32_t saveINTR_EN_REG;
5445c49fd3aSAlan Cox 	uint32_t saveDSI_FUNC_PRG_REG;
5455c49fd3aSAlan Cox 	uint32_t saveHS_TX_TIMEOUT_REG;
5465c49fd3aSAlan Cox 	uint32_t saveLP_RX_TIMEOUT_REG;
5475c49fd3aSAlan Cox 	uint32_t saveTURN_AROUND_TIMEOUT_REG;
5485c49fd3aSAlan Cox 	uint32_t saveDEVICE_RESET_REG;
5495c49fd3aSAlan Cox 	uint32_t saveDPI_RESOLUTION_REG;
5505c49fd3aSAlan Cox 	uint32_t saveHORIZ_SYNC_PAD_COUNT_REG;
5515c49fd3aSAlan Cox 	uint32_t saveHORIZ_BACK_PORCH_COUNT_REG;
5525c49fd3aSAlan Cox 	uint32_t saveHORIZ_FRONT_PORCH_COUNT_REG;
5535c49fd3aSAlan Cox 	uint32_t saveHORIZ_ACTIVE_AREA_COUNT_REG;
5545c49fd3aSAlan Cox 	uint32_t saveVERT_SYNC_PAD_COUNT_REG;
5555c49fd3aSAlan Cox 	uint32_t saveVERT_BACK_PORCH_COUNT_REG;
5565c49fd3aSAlan Cox 	uint32_t saveVERT_FRONT_PORCH_COUNT_REG;
5575c49fd3aSAlan Cox 	uint32_t saveHIGH_LOW_SWITCH_COUNT_REG;
5585c49fd3aSAlan Cox 	uint32_t saveINIT_COUNT_REG;
5595c49fd3aSAlan Cox 	uint32_t saveMAX_RET_PAK_REG;
5605c49fd3aSAlan Cox 	uint32_t saveVIDEO_FMT_REG;
5615c49fd3aSAlan Cox 	uint32_t saveEOT_DISABLE_REG;
5625c49fd3aSAlan Cox 	uint32_t saveLP_BYTECLK_REG;
5635c49fd3aSAlan Cox 	uint32_t saveHS_LS_DBI_ENABLE_REG;
5645c49fd3aSAlan Cox 	uint32_t saveTXCLKESC_REG;
5655c49fd3aSAlan Cox 	uint32_t saveDPHY_PARAM_REG;
5665c49fd3aSAlan Cox 	uint32_t saveMIPI_CONTROL_REG;
5675c49fd3aSAlan Cox 	uint32_t saveMIPI;
5685c49fd3aSAlan Cox 	uint32_t saveMIPI_C;
5695c49fd3aSAlan Cox 
5705c49fd3aSAlan Cox 	/* DPST register save */
5715c49fd3aSAlan Cox 	uint32_t saveHISTOGRAM_INT_CONTROL_REG;
5725c49fd3aSAlan Cox 	uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
5735c49fd3aSAlan Cox 	uint32_t savePWM_CONTROL_LOGIC;
5745c49fd3aSAlan Cox 
5755c49fd3aSAlan Cox 	/*
5765c49fd3aSAlan Cox 	 * DSI info.
5775c49fd3aSAlan Cox 	 */
5785c49fd3aSAlan Cox 	void * dbi_dsr_info;
5795c49fd3aSAlan Cox 	void * dbi_dpu_info;
5805c49fd3aSAlan Cox 	void * dsi_configs[2];
5815c49fd3aSAlan Cox 	/*
5825c49fd3aSAlan Cox 	 * LID-Switch
5835c49fd3aSAlan Cox 	 */
5845c49fd3aSAlan Cox 	spinlock_t lid_lock;
5855c49fd3aSAlan Cox 	struct timer_list lid_timer;
5865c49fd3aSAlan Cox 	struct psb_intel_opregion opregion;
5875c49fd3aSAlan Cox 	u32 *lid_state;
5885c49fd3aSAlan Cox 	u32 lid_last_state;
5895c49fd3aSAlan Cox 
5905c49fd3aSAlan Cox 	/*
5915c49fd3aSAlan Cox 	 * Watchdog
5925c49fd3aSAlan Cox 	 */
5935c49fd3aSAlan Cox 
5945c49fd3aSAlan Cox 	uint32_t apm_reg;
5955c49fd3aSAlan Cox 	uint16_t apm_base;
5965c49fd3aSAlan Cox 
5975c49fd3aSAlan Cox 	/*
5985c49fd3aSAlan Cox 	 * Used for modifying backlight from
5995c49fd3aSAlan Cox 	 * xrandr -- consider removing and using HAL instead
6005c49fd3aSAlan Cox 	 */
6015c49fd3aSAlan Cox 	struct backlight_device *backlight_device;
6025c49fd3aSAlan Cox 	struct drm_property *backlight_property;
6035c49fd3aSAlan Cox 	uint32_t blc_adj1;
6045c49fd3aSAlan Cox 	uint32_t blc_adj2;
6055c49fd3aSAlan Cox 
6065c49fd3aSAlan Cox 	void *fbdev;
6075c49fd3aSAlan Cox 
6085c49fd3aSAlan Cox 	/* 2D acceleration */
6095c49fd3aSAlan Cox 	struct mutex mutex_2d;
6105c49fd3aSAlan Cox };
6115c49fd3aSAlan Cox 
6125c49fd3aSAlan Cox 
6135c49fd3aSAlan Cox /*
6145c49fd3aSAlan Cox  *	Operations for each board type
6155c49fd3aSAlan Cox  */
6165c49fd3aSAlan Cox 
6175c49fd3aSAlan Cox struct psb_ops {
6185c49fd3aSAlan Cox 	const char *name;
6195c49fd3aSAlan Cox 	unsigned int accel_2d:1;
6205c49fd3aSAlan Cox 	int pipes;		/* Number of output pipes */
6215c49fd3aSAlan Cox 	int crtcs;		/* Number of CRTCs */
6225c49fd3aSAlan Cox 	int sgx_offset;		/* Base offset of SGX device */
6235c49fd3aSAlan Cox 
6245c49fd3aSAlan Cox 	/* Sub functions */
6255c49fd3aSAlan Cox 	struct drm_crtc_helper_funcs const *crtc_helper;
6265c49fd3aSAlan Cox 	struct drm_crtc_funcs const *crtc_funcs;
6275c49fd3aSAlan Cox 
6285c49fd3aSAlan Cox 	/* Setup hooks */
6295c49fd3aSAlan Cox 	int (*chip_setup)(struct drm_device *dev);
6305c49fd3aSAlan Cox 	void (*chip_teardown)(struct drm_device *dev);
6315c49fd3aSAlan Cox 
6325c49fd3aSAlan Cox 	/* Display management hooks */
6335c49fd3aSAlan Cox 	int (*output_init)(struct drm_device *dev);
6345c49fd3aSAlan Cox 	/* Power management hooks */
6355c49fd3aSAlan Cox 	void (*init_pm)(struct drm_device *dev);
6365c49fd3aSAlan Cox 	int (*save_regs)(struct drm_device *dev);
6375c49fd3aSAlan Cox 	int (*restore_regs)(struct drm_device *dev);
6385c49fd3aSAlan Cox 	int (*power_up)(struct drm_device *dev);
6395c49fd3aSAlan Cox 	int (*power_down)(struct drm_device *dev);
6405c49fd3aSAlan Cox 
6415c49fd3aSAlan Cox 	void (*lvds_bl_power)(struct drm_device *dev, bool on);
6425c49fd3aSAlan Cox #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
6435c49fd3aSAlan Cox 	/* Backlight */
6445c49fd3aSAlan Cox 	int (*backlight_init)(struct drm_device *dev);
6455c49fd3aSAlan Cox #endif
6465c49fd3aSAlan Cox 	int i2c_bus;		/* I2C bus identifier for Moorestown */
6475c49fd3aSAlan Cox };
6485c49fd3aSAlan Cox 
6495c49fd3aSAlan Cox 
6505c49fd3aSAlan Cox 
6515c49fd3aSAlan Cox struct psb_mmu_driver;
6525c49fd3aSAlan Cox 
6535c49fd3aSAlan Cox extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
6545c49fd3aSAlan Cox extern int drm_pick_crtcs(struct drm_device *dev);
6555c49fd3aSAlan Cox 
6565c49fd3aSAlan Cox static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
6575c49fd3aSAlan Cox {
6585c49fd3aSAlan Cox 	return (struct drm_psb_private *) dev->dev_private;
6595c49fd3aSAlan Cox }
6605c49fd3aSAlan Cox 
6615c49fd3aSAlan Cox /*
6625c49fd3aSAlan Cox  * MMU stuff.
6635c49fd3aSAlan Cox  */
6645c49fd3aSAlan Cox 
6655c49fd3aSAlan Cox extern struct psb_mmu_driver *psb_mmu_driver_init(uint8_t __iomem * registers,
6665c49fd3aSAlan Cox 					int trap_pagefaults,
6675c49fd3aSAlan Cox 					int invalid_type,
6685c49fd3aSAlan Cox 					struct drm_psb_private *dev_priv);
6695c49fd3aSAlan Cox extern void psb_mmu_driver_takedown(struct psb_mmu_driver *driver);
6705c49fd3aSAlan Cox extern struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver
6715c49fd3aSAlan Cox 						 *driver);
6725c49fd3aSAlan Cox extern void psb_mmu_mirror_gtt(struct psb_mmu_pd *pd, uint32_t mmu_offset,
6735c49fd3aSAlan Cox 			       uint32_t gtt_start, uint32_t gtt_pages);
6745c49fd3aSAlan Cox extern struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
6755c49fd3aSAlan Cox 					   int trap_pagefaults,
6765c49fd3aSAlan Cox 					   int invalid_type);
6775c49fd3aSAlan Cox extern void psb_mmu_free_pagedir(struct psb_mmu_pd *pd);
6785c49fd3aSAlan Cox extern void psb_mmu_flush(struct psb_mmu_driver *driver, int rc_prot);
6795c49fd3aSAlan Cox extern void psb_mmu_remove_pfn_sequence(struct psb_mmu_pd *pd,
6805c49fd3aSAlan Cox 					unsigned long address,
6815c49fd3aSAlan Cox 					uint32_t num_pages);
6825c49fd3aSAlan Cox extern int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd,
6835c49fd3aSAlan Cox 				       uint32_t start_pfn,
6845c49fd3aSAlan Cox 				       unsigned long address,
6855c49fd3aSAlan Cox 				       uint32_t num_pages, int type);
6865c49fd3aSAlan Cox extern int psb_mmu_virtual_to_pfn(struct psb_mmu_pd *pd, uint32_t virtual,
6875c49fd3aSAlan Cox 				  unsigned long *pfn);
6885c49fd3aSAlan Cox 
6895c49fd3aSAlan Cox /*
6905c49fd3aSAlan Cox  * Enable / disable MMU for different requestors.
6915c49fd3aSAlan Cox  */
6925c49fd3aSAlan Cox 
6935c49fd3aSAlan Cox 
6945c49fd3aSAlan Cox extern void psb_mmu_set_pd_context(struct psb_mmu_pd *pd, int hw_context);
6955c49fd3aSAlan Cox extern int psb_mmu_insert_pages(struct psb_mmu_pd *pd, struct page **pages,
6965c49fd3aSAlan Cox 				unsigned long address, uint32_t num_pages,
6975c49fd3aSAlan Cox 				uint32_t desired_tile_stride,
6985c49fd3aSAlan Cox 				uint32_t hw_tile_stride, int type);
6995c49fd3aSAlan Cox extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
7005c49fd3aSAlan Cox 				 unsigned long address, uint32_t num_pages,
7015c49fd3aSAlan Cox 				 uint32_t desired_tile_stride,
7025c49fd3aSAlan Cox 				 uint32_t hw_tile_stride);
7035c49fd3aSAlan Cox /*
7045c49fd3aSAlan Cox  *psb_irq.c
7055c49fd3aSAlan Cox  */
7065c49fd3aSAlan Cox 
7075c49fd3aSAlan Cox extern irqreturn_t psb_irq_handler(DRM_IRQ_ARGS);
7085c49fd3aSAlan Cox extern int psb_irq_enable_dpst(struct drm_device *dev);
7095c49fd3aSAlan Cox extern int psb_irq_disable_dpst(struct drm_device *dev);
7105c49fd3aSAlan Cox extern void psb_irq_preinstall(struct drm_device *dev);
7115c49fd3aSAlan Cox extern int psb_irq_postinstall(struct drm_device *dev);
7125c49fd3aSAlan Cox extern void psb_irq_uninstall(struct drm_device *dev);
7135c49fd3aSAlan Cox extern void psb_irq_turn_on_dpst(struct drm_device *dev);
7145c49fd3aSAlan Cox extern void psb_irq_turn_off_dpst(struct drm_device *dev);
7155c49fd3aSAlan Cox 
7165c49fd3aSAlan Cox extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
7175c49fd3aSAlan Cox extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
7185c49fd3aSAlan Cox extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
7195c49fd3aSAlan Cox extern int psb_enable_vblank(struct drm_device *dev, int crtc);
7205c49fd3aSAlan Cox extern void psb_disable_vblank(struct drm_device *dev, int crtc);
7215c49fd3aSAlan Cox void
7225c49fd3aSAlan Cox psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
7235c49fd3aSAlan Cox 
7245c49fd3aSAlan Cox void
7255c49fd3aSAlan Cox psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
7265c49fd3aSAlan Cox 
7275c49fd3aSAlan Cox extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
7285c49fd3aSAlan Cox 
7295c49fd3aSAlan Cox /*
7305c49fd3aSAlan Cox  * intel_opregion.c
7315c49fd3aSAlan Cox  */
7325c49fd3aSAlan Cox extern int gma_intel_opregion_init(struct drm_device *dev);
7335c49fd3aSAlan Cox extern int gma_intel_opregion_exit(struct drm_device *dev);
7345c49fd3aSAlan Cox 
7355c49fd3aSAlan Cox /*
7365c49fd3aSAlan Cox  * framebuffer.c
7375c49fd3aSAlan Cox  */
7385c49fd3aSAlan Cox extern int psbfb_probed(struct drm_device *dev);
7395c49fd3aSAlan Cox extern int psbfb_remove(struct drm_device *dev,
7405c49fd3aSAlan Cox 			struct drm_framebuffer *fb);
7415c49fd3aSAlan Cox /*
7425c49fd3aSAlan Cox  * accel_2d.c
7435c49fd3aSAlan Cox  */
7445c49fd3aSAlan Cox extern void psbfb_copyarea(struct fb_info *info,
7455c49fd3aSAlan Cox 					const struct fb_copyarea *region);
7465c49fd3aSAlan Cox extern int psbfb_sync(struct fb_info *info);
7475c49fd3aSAlan Cox extern void psb_spank(struct drm_psb_private *dev_priv);
7485c49fd3aSAlan Cox 
7495c49fd3aSAlan Cox /*
7505c49fd3aSAlan Cox  * psb_reset.c
7515c49fd3aSAlan Cox  */
7525c49fd3aSAlan Cox 
7535c49fd3aSAlan Cox extern void psb_lid_timer_init(struct drm_psb_private *dev_priv);
7545c49fd3aSAlan Cox extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);
7555c49fd3aSAlan Cox extern void psb_print_pagefault(struct drm_psb_private *dev_priv);
7565c49fd3aSAlan Cox 
7575c49fd3aSAlan Cox /* modesetting */
7585c49fd3aSAlan Cox extern void psb_modeset_init(struct drm_device *dev);
7595c49fd3aSAlan Cox extern void psb_modeset_cleanup(struct drm_device *dev);
7605c49fd3aSAlan Cox extern int psb_fbdev_init(struct drm_device *dev);
7615c49fd3aSAlan Cox 
7625c49fd3aSAlan Cox /* backlight.c */
7635c49fd3aSAlan Cox int gma_backlight_init(struct drm_device *dev);
7645c49fd3aSAlan Cox void gma_backlight_exit(struct drm_device *dev);
7655c49fd3aSAlan Cox 
7665c49fd3aSAlan Cox /* oaktrail_crtc.c */
7675c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs oaktrail_helper_funcs;
7685c49fd3aSAlan Cox 
7695c49fd3aSAlan Cox /* oaktrail_lvds.c */
7705c49fd3aSAlan Cox extern void oaktrail_lvds_init(struct drm_device *dev,
7715c49fd3aSAlan Cox 		    struct psb_intel_mode_device *mode_dev);
7725c49fd3aSAlan Cox 
7735c49fd3aSAlan Cox /* psb_intel_display.c */
7745c49fd3aSAlan Cox extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
7755c49fd3aSAlan Cox extern const struct drm_crtc_funcs psb_intel_crtc_funcs;
7765c49fd3aSAlan Cox 
7775c49fd3aSAlan Cox /* psb_intel_lvds.c */
7785c49fd3aSAlan Cox extern const struct drm_connector_helper_funcs
7795c49fd3aSAlan Cox 					psb_intel_lvds_connector_helper_funcs;
7805c49fd3aSAlan Cox extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
7815c49fd3aSAlan Cox 
7825c49fd3aSAlan Cox /* gem.c */
7835c49fd3aSAlan Cox extern int psb_gem_init_object(struct drm_gem_object *obj);
7845c49fd3aSAlan Cox extern void psb_gem_free_object(struct drm_gem_object *obj);
7855c49fd3aSAlan Cox extern int psb_gem_get_aperture(struct drm_device *dev, void *data,
7865c49fd3aSAlan Cox 			struct drm_file *file);
7875c49fd3aSAlan Cox extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
7885c49fd3aSAlan Cox 			struct drm_mode_create_dumb *args);
7895c49fd3aSAlan Cox extern int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
7905c49fd3aSAlan Cox 			uint32_t handle);
7915c49fd3aSAlan Cox extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
7925c49fd3aSAlan Cox 			uint32_t handle, uint64_t *offset);
7935c49fd3aSAlan Cox extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
7945c49fd3aSAlan Cox extern int psb_gem_create_ioctl(struct drm_device *dev, void *data,
7955c49fd3aSAlan Cox 			struct drm_file *file);
7965c49fd3aSAlan Cox extern int psb_gem_mmap_ioctl(struct drm_device *dev, void *data,
7975c49fd3aSAlan Cox 					struct drm_file *file);
7985c49fd3aSAlan Cox 
7995c49fd3aSAlan Cox /* psb_device.c */
8005c49fd3aSAlan Cox extern const struct psb_ops psb_chip_ops;
8015c49fd3aSAlan Cox 
8025c49fd3aSAlan Cox /* oaktrail_device.c */
8035c49fd3aSAlan Cox extern const struct psb_ops oaktrail_chip_ops;
8045c49fd3aSAlan Cox 
8055c49fd3aSAlan Cox /* cdv_device.c */
8065c49fd3aSAlan Cox extern const struct psb_ops cdv_chip_ops;
8075c49fd3aSAlan Cox 
8085c49fd3aSAlan Cox /*
8095c49fd3aSAlan Cox  * Debug print bits setting
8105c49fd3aSAlan Cox  */
8115c49fd3aSAlan Cox #define PSB_D_GENERAL (1 << 0)
8125c49fd3aSAlan Cox #define PSB_D_INIT    (1 << 1)
8135c49fd3aSAlan Cox #define PSB_D_IRQ     (1 << 2)
8145c49fd3aSAlan Cox #define PSB_D_ENTRY   (1 << 3)
8155c49fd3aSAlan Cox /* debug the get H/V BP/FP count */
8165c49fd3aSAlan Cox #define PSB_D_HV      (1 << 4)
8175c49fd3aSAlan Cox #define PSB_D_DBI_BF  (1 << 5)
8185c49fd3aSAlan Cox #define PSB_D_PM      (1 << 6)
8195c49fd3aSAlan Cox #define PSB_D_RENDER  (1 << 7)
8205c49fd3aSAlan Cox #define PSB_D_REG     (1 << 8)
8215c49fd3aSAlan Cox #define PSB_D_MSVDX   (1 << 9)
8225c49fd3aSAlan Cox #define PSB_D_TOPAZ   (1 << 10)
8235c49fd3aSAlan Cox 
8245c49fd3aSAlan Cox extern int drm_psb_no_fb;
8255c49fd3aSAlan Cox extern int drm_idle_check_interval;
8265c49fd3aSAlan Cox 
8275c49fd3aSAlan Cox /*
8285c49fd3aSAlan Cox  *	Utilities
8295c49fd3aSAlan Cox  */
8305c49fd3aSAlan Cox 
8315c49fd3aSAlan Cox static inline u32 MRST_MSG_READ32(uint port, uint offset)
8325c49fd3aSAlan Cox {
8335c49fd3aSAlan Cox 	int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
8345c49fd3aSAlan Cox 	uint32_t ret_val = 0;
8355c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8365c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8375c49fd3aSAlan Cox 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
8385c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8395c49fd3aSAlan Cox 	return ret_val;
8405c49fd3aSAlan Cox }
8415c49fd3aSAlan Cox static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
8425c49fd3aSAlan Cox {
8435c49fd3aSAlan Cox 	int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
8445c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8455c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD4, value);
8465c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8475c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8485c49fd3aSAlan Cox }
8495c49fd3aSAlan Cox static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
8505c49fd3aSAlan Cox {
8515c49fd3aSAlan Cox 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
8525c49fd3aSAlan Cox 	uint32_t ret_val = 0;
8535c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8545c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8555c49fd3aSAlan Cox 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
8565c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8575c49fd3aSAlan Cox 	return ret_val;
8585c49fd3aSAlan Cox }
8595c49fd3aSAlan Cox static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
8605c49fd3aSAlan Cox {
8615c49fd3aSAlan Cox 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
8625c49fd3aSAlan Cox 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
8635c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD4, value);
8645c49fd3aSAlan Cox 	pci_write_config_dword(pci_root, 0xD0, mcr);
8655c49fd3aSAlan Cox 	pci_dev_put(pci_root);
8665c49fd3aSAlan Cox }
8675c49fd3aSAlan Cox 
8685c49fd3aSAlan Cox static inline uint32_t REGISTER_READ(struct drm_device *dev, uint32_t reg)
8695c49fd3aSAlan Cox {
8705c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8715c49fd3aSAlan Cox 	return ioread32(dev_priv->vdc_reg + reg);
8725c49fd3aSAlan Cox }
8735c49fd3aSAlan Cox 
8745c49fd3aSAlan Cox #define REG_READ(reg)	       REGISTER_READ(dev, (reg))
8755c49fd3aSAlan Cox 
8765c49fd3aSAlan Cox static inline void REGISTER_WRITE(struct drm_device *dev, uint32_t reg,
8775c49fd3aSAlan Cox 				      uint32_t val)
8785c49fd3aSAlan Cox {
8795c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8805c49fd3aSAlan Cox 	iowrite32((val), dev_priv->vdc_reg + (reg));
8815c49fd3aSAlan Cox }
8825c49fd3aSAlan Cox 
8835c49fd3aSAlan Cox #define REG_WRITE(reg, val)	REGISTER_WRITE(dev, (reg), (val))
8845c49fd3aSAlan Cox 
8855c49fd3aSAlan Cox static inline void REGISTER_WRITE16(struct drm_device *dev,
8865c49fd3aSAlan Cox 					uint32_t reg, uint32_t val)
8875c49fd3aSAlan Cox {
8885c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8895c49fd3aSAlan Cox 	iowrite16((val), dev_priv->vdc_reg + (reg));
8905c49fd3aSAlan Cox }
8915c49fd3aSAlan Cox 
8925c49fd3aSAlan Cox #define REG_WRITE16(reg, val)	  REGISTER_WRITE16(dev, (reg), (val))
8935c49fd3aSAlan Cox 
8945c49fd3aSAlan Cox static inline void REGISTER_WRITE8(struct drm_device *dev,
8955c49fd3aSAlan Cox 				       uint32_t reg, uint32_t val)
8965c49fd3aSAlan Cox {
8975c49fd3aSAlan Cox 	struct drm_psb_private *dev_priv = dev->dev_private;
8985c49fd3aSAlan Cox 	iowrite8((val), dev_priv->vdc_reg + (reg));
8995c49fd3aSAlan Cox }
9005c49fd3aSAlan Cox 
9015c49fd3aSAlan Cox #define REG_WRITE8(reg, val)		REGISTER_WRITE8(dev, (reg), (val))
9025c49fd3aSAlan Cox 
9035c49fd3aSAlan Cox #define PSB_WVDC32(_val, _offs)		iowrite32(_val, dev_priv->vdc_reg + (_offs))
9045c49fd3aSAlan Cox #define PSB_RVDC32(_offs)		ioread32(dev_priv->vdc_reg + (_offs))
9055c49fd3aSAlan Cox 
9065c49fd3aSAlan Cox /* #define TRAP_SGX_PM_FAULT 1 */
9075c49fd3aSAlan Cox #ifdef TRAP_SGX_PM_FAULT
9085c49fd3aSAlan Cox #define PSB_RSGX32(_offs)						\
9095c49fd3aSAlan Cox ({									\
9105c49fd3aSAlan Cox 	if (inl(dev_priv->apm_base + PSB_APM_STS) & 0x3) {		\
9115c49fd3aSAlan Cox 		printk(KERN_ERR						\
9125c49fd3aSAlan Cox 			"access sgx when it's off!! (READ) %s, %d\n",	\
9135c49fd3aSAlan Cox 	       __FILE__, __LINE__);					\
9145c49fd3aSAlan Cox 		melay(1000);						\
9155c49fd3aSAlan Cox 	}								\
9165c49fd3aSAlan Cox 	ioread32(dev_priv->sgx_reg + (_offs));				\
9175c49fd3aSAlan Cox })
9185c49fd3aSAlan Cox #else
9195c49fd3aSAlan Cox #define PSB_RSGX32(_offs)		ioread32(dev_priv->sgx_reg + (_offs))
9205c49fd3aSAlan Cox #endif
9215c49fd3aSAlan Cox #define PSB_WSGX32(_val, _offs)		iowrite32(_val, dev_priv->sgx_reg + (_offs))
9225c49fd3aSAlan Cox 
9235c49fd3aSAlan Cox #define MSVDX_REG_DUMP 0
9245c49fd3aSAlan Cox 
9255c49fd3aSAlan Cox #define PSB_WMSVDX32(_val, _offs)	iowrite32(_val, dev_priv->msvdx_reg + (_offs))
9265c49fd3aSAlan Cox #define PSB_RMSVDX32(_offs)		ioread32(dev_priv->msvdx_reg + (_offs))
9275c49fd3aSAlan Cox 
9285c49fd3aSAlan Cox #endif
929