18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/**************************************************************************
38c2ecf20Sopenharmony_ci * Copyright (c) 2007-2011, Intel Corporation.
48c2ecf20Sopenharmony_ci * All Rights Reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci **************************************************************************/
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct psb_intel_mode_device;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/* MID device specific descriptors */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct oaktrail_timing_info {
138c2ecf20Sopenharmony_ci	u16 pixel_clock;
148c2ecf20Sopenharmony_ci	u8 hactive_lo;
158c2ecf20Sopenharmony_ci	u8 hblank_lo;
168c2ecf20Sopenharmony_ci	u8 hblank_hi:4;
178c2ecf20Sopenharmony_ci	u8 hactive_hi:4;
188c2ecf20Sopenharmony_ci	u8 vactive_lo;
198c2ecf20Sopenharmony_ci	u8 vblank_lo;
208c2ecf20Sopenharmony_ci	u8 vblank_hi:4;
218c2ecf20Sopenharmony_ci	u8 vactive_hi:4;
228c2ecf20Sopenharmony_ci	u8 hsync_offset_lo;
238c2ecf20Sopenharmony_ci	u8 hsync_pulse_width_lo;
248c2ecf20Sopenharmony_ci	u8 vsync_pulse_width_lo:4;
258c2ecf20Sopenharmony_ci	u8 vsync_offset_lo:4;
268c2ecf20Sopenharmony_ci	u8 vsync_pulse_width_hi:2;
278c2ecf20Sopenharmony_ci	u8 vsync_offset_hi:2;
288c2ecf20Sopenharmony_ci	u8 hsync_pulse_width_hi:2;
298c2ecf20Sopenharmony_ci	u8 hsync_offset_hi:2;
308c2ecf20Sopenharmony_ci	u8 width_mm_lo;
318c2ecf20Sopenharmony_ci	u8 height_mm_lo;
328c2ecf20Sopenharmony_ci	u8 height_mm_hi:4;
338c2ecf20Sopenharmony_ci	u8 width_mm_hi:4;
348c2ecf20Sopenharmony_ci	u8 hborder;
358c2ecf20Sopenharmony_ci	u8 vborder;
368c2ecf20Sopenharmony_ci	u8 unknown0:1;
378c2ecf20Sopenharmony_ci	u8 hsync_positive:1;
388c2ecf20Sopenharmony_ci	u8 vsync_positive:1;
398c2ecf20Sopenharmony_ci	u8 separate_sync:2;
408c2ecf20Sopenharmony_ci	u8 stereo:1;
418c2ecf20Sopenharmony_ci	u8 unknown6:1;
428c2ecf20Sopenharmony_ci	u8 interlaced:1;
438c2ecf20Sopenharmony_ci} __packed;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct gct_r10_timing_info {
468c2ecf20Sopenharmony_ci	u16 pixel_clock;
478c2ecf20Sopenharmony_ci	u32 hactive_lo:8;
488c2ecf20Sopenharmony_ci	u32 hactive_hi:4;
498c2ecf20Sopenharmony_ci	u32 hblank_lo:8;
508c2ecf20Sopenharmony_ci	u32 hblank_hi:4;
518c2ecf20Sopenharmony_ci	u32 hsync_offset_lo:8;
528c2ecf20Sopenharmony_ci	u16 hsync_offset_hi:2;
538c2ecf20Sopenharmony_ci	u16 hsync_pulse_width_lo:8;
548c2ecf20Sopenharmony_ci	u16 hsync_pulse_width_hi:2;
558c2ecf20Sopenharmony_ci	u16 hsync_positive:1;
568c2ecf20Sopenharmony_ci	u16 rsvd_1:3;
578c2ecf20Sopenharmony_ci	u8  vactive_lo:8;
588c2ecf20Sopenharmony_ci	u16 vactive_hi:4;
598c2ecf20Sopenharmony_ci	u16 vblank_lo:8;
608c2ecf20Sopenharmony_ci	u16 vblank_hi:4;
618c2ecf20Sopenharmony_ci	u16 vsync_offset_lo:4;
628c2ecf20Sopenharmony_ci	u16 vsync_offset_hi:2;
638c2ecf20Sopenharmony_ci	u16 vsync_pulse_width_lo:4;
648c2ecf20Sopenharmony_ci	u16 vsync_pulse_width_hi:2;
658c2ecf20Sopenharmony_ci	u16 vsync_positive:1;
668c2ecf20Sopenharmony_ci	u16 rsvd_2:3;
678c2ecf20Sopenharmony_ci} __packed;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistruct oaktrail_panel_descriptor_v1 {
708c2ecf20Sopenharmony_ci	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
718c2ecf20Sopenharmony_ci				/* 0x61190 if MIPI */
728c2ecf20Sopenharmony_ci	u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
738c2ecf20Sopenharmony_ci	u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
748c2ecf20Sopenharmony_ci	u32 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 dword */
758c2ecf20Sopenharmony_ci						/* Register 0x61210 */
768c2ecf20Sopenharmony_ci	struct oaktrail_timing_info DTD;/*18 bytes, Standard definition */
778c2ecf20Sopenharmony_ci	u16 Panel_Backlight_Inverter_Descriptor;/* 16 bits, as follows */
788c2ecf20Sopenharmony_ci				/* Bit 0, Frequency, 15 bits,0 - 32767Hz */
798c2ecf20Sopenharmony_ci			/* Bit 15, Polarity, 1 bit, 0: Normal, 1: Inverted */
808c2ecf20Sopenharmony_ci	u16 Panel_MIPI_Display_Descriptor;
818c2ecf20Sopenharmony_ci			/*16 bits, Defined as follows: */
828c2ecf20Sopenharmony_ci			/* if MIPI, 0x0000 if LVDS */
838c2ecf20Sopenharmony_ci			/* Bit 0, Type, 2 bits, */
848c2ecf20Sopenharmony_ci			/* 0: Type-1, */
858c2ecf20Sopenharmony_ci			/* 1: Type-2, */
868c2ecf20Sopenharmony_ci			/* 2: Type-3, */
878c2ecf20Sopenharmony_ci			/* 3: Type-4 */
888c2ecf20Sopenharmony_ci			/* Bit 2, Pixel Format, 4 bits */
898c2ecf20Sopenharmony_ci			/* Bit0: 16bpp (not supported in LNC), */
908c2ecf20Sopenharmony_ci			/* Bit1: 18bpp loosely packed, */
918c2ecf20Sopenharmony_ci			/* Bit2: 18bpp packed, */
928c2ecf20Sopenharmony_ci			/* Bit3: 24bpp */
938c2ecf20Sopenharmony_ci			/* Bit 6, Reserved, 2 bits, 00b */
948c2ecf20Sopenharmony_ci			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
958c2ecf20Sopenharmony_ci			/* Bit 14, Reserved, 2 bits, 00b */
968c2ecf20Sopenharmony_ci} __packed;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistruct oaktrail_panel_descriptor_v2 {
998c2ecf20Sopenharmony_ci	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
1008c2ecf20Sopenharmony_ci				/* 0x61190 if MIPI */
1018c2ecf20Sopenharmony_ci	u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
1028c2ecf20Sopenharmony_ci	u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
1038c2ecf20Sopenharmony_ci	u8 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 byte */
1048c2ecf20Sopenharmony_ci						/* Register 0x61210 */
1058c2ecf20Sopenharmony_ci	struct oaktrail_timing_info DTD;/*18 bytes, Standard definition */
1068c2ecf20Sopenharmony_ci	u16 Panel_Backlight_Inverter_Descriptor;/*16 bits, as follows*/
1078c2ecf20Sopenharmony_ci				/*Bit 0, Frequency, 16 bits, 0 - 32767Hz*/
1088c2ecf20Sopenharmony_ci	u8 Panel_Initial_Brightness;/* [7:0] 0 - 100% */
1098c2ecf20Sopenharmony_ci			/*Bit 7, Polarity, 1 bit,0: Normal, 1: Inverted*/
1108c2ecf20Sopenharmony_ci	u16 Panel_MIPI_Display_Descriptor;
1118c2ecf20Sopenharmony_ci			/*16 bits, Defined as follows: */
1128c2ecf20Sopenharmony_ci			/* if MIPI, 0x0000 if LVDS */
1138c2ecf20Sopenharmony_ci			/* Bit 0, Type, 2 bits, */
1148c2ecf20Sopenharmony_ci			/* 0: Type-1, */
1158c2ecf20Sopenharmony_ci			/* 1: Type-2, */
1168c2ecf20Sopenharmony_ci			/* 2: Type-3, */
1178c2ecf20Sopenharmony_ci			/* 3: Type-4 */
1188c2ecf20Sopenharmony_ci			/* Bit 2, Pixel Format, 4 bits */
1198c2ecf20Sopenharmony_ci			/* Bit0: 16bpp (not supported in LNC), */
1208c2ecf20Sopenharmony_ci			/* Bit1: 18bpp loosely packed, */
1218c2ecf20Sopenharmony_ci			/* Bit2: 18bpp packed, */
1228c2ecf20Sopenharmony_ci			/* Bit3: 24bpp */
1238c2ecf20Sopenharmony_ci			/* Bit 6, Reserved, 2 bits, 00b */
1248c2ecf20Sopenharmony_ci			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
1258c2ecf20Sopenharmony_ci			/* Bit 14, Reserved, 2 bits, 00b */
1268c2ecf20Sopenharmony_ci} __packed;
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciunion oaktrail_panel_rx {
1298c2ecf20Sopenharmony_ci	struct {
1308c2ecf20Sopenharmony_ci		u16 NumberOfLanes:2; /*Num of Lanes, 2 bits,0 = 1 lane,*/
1318c2ecf20Sopenharmony_ci			/* 1 = 2 lanes, 2 = 3 lanes, 3 = 4 lanes. */
1328c2ecf20Sopenharmony_ci		u16 MaxLaneFreq:3; /* 0: 100MHz, 1: 200MHz, 2: 300MHz, */
1338c2ecf20Sopenharmony_ci		/*3: 400MHz, 4: 500MHz, 5: 600MHz, 6: 700MHz, 7: 800MHz.*/
1348c2ecf20Sopenharmony_ci		u16 SupportedVideoTransferMode:2; /*0: Non-burst only */
1358c2ecf20Sopenharmony_ci					/* 1: Burst and non-burst */
1368c2ecf20Sopenharmony_ci					/* 2/3: Reserved */
1378c2ecf20Sopenharmony_ci		u16 HSClkBehavior:1; /*0: Continuous, 1: Non-continuous*/
1388c2ecf20Sopenharmony_ci		u16 DuoDisplaySupport:1; /*1 bit,0: No, 1: Yes*/
1398c2ecf20Sopenharmony_ci		u16 ECC_ChecksumCapabilities:1;/*1 bit,0: No, 1: Yes*/
1408c2ecf20Sopenharmony_ci		u16 BidirectionalCommunication:1;/*1 bit,0: No, 1: Yes */
1418c2ecf20Sopenharmony_ci		u16 Rsvd:5;/*5 bits,00000b */
1428c2ecf20Sopenharmony_ci	} panelrx;
1438c2ecf20Sopenharmony_ci	u16 panel_receiver;
1448c2ecf20Sopenharmony_ci} __packed;
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cistruct gct_r0 {
1478c2ecf20Sopenharmony_ci	union { /*8 bits,Defined as follows: */
1488c2ecf20Sopenharmony_ci		struct {
1498c2ecf20Sopenharmony_ci			u8 PanelType:4; /*4 bits, Bit field for panels*/
1508c2ecf20Sopenharmony_ci					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
1518c2ecf20Sopenharmony_ci					/*2 bits,Specifies which of the*/
1528c2ecf20Sopenharmony_ci			u8 BootPanelIndex:2;
1538c2ecf20Sopenharmony_ci					/* 4 panels to use by default*/
1548c2ecf20Sopenharmony_ci			u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
1558c2ecf20Sopenharmony_ci					/* the 4 MIPI DSI receivers to use*/
1568c2ecf20Sopenharmony_ci		} PD;
1578c2ecf20Sopenharmony_ci		u8 PanelDescriptor;
1588c2ecf20Sopenharmony_ci	};
1598c2ecf20Sopenharmony_ci	struct oaktrail_panel_descriptor_v1 panel[4];/*panel descrs,38 bytes each*/
1608c2ecf20Sopenharmony_ci	union oaktrail_panel_rx panelrx[4]; /* panel receivers*/
1618c2ecf20Sopenharmony_ci} __packed;
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistruct gct_r1 {
1648c2ecf20Sopenharmony_ci	union { /*8 bits,Defined as follows: */
1658c2ecf20Sopenharmony_ci		struct {
1668c2ecf20Sopenharmony_ci			u8 PanelType:4; /*4 bits, Bit field for panels*/
1678c2ecf20Sopenharmony_ci					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
1688c2ecf20Sopenharmony_ci					/*2 bits,Specifies which of the*/
1698c2ecf20Sopenharmony_ci			u8 BootPanelIndex:2;
1708c2ecf20Sopenharmony_ci					/* 4 panels to use by default*/
1718c2ecf20Sopenharmony_ci			u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
1728c2ecf20Sopenharmony_ci					/* the 4 MIPI DSI receivers to use*/
1738c2ecf20Sopenharmony_ci		} PD;
1748c2ecf20Sopenharmony_ci		u8 PanelDescriptor;
1758c2ecf20Sopenharmony_ci	};
1768c2ecf20Sopenharmony_ci	struct oaktrail_panel_descriptor_v2 panel[4];/*panel descrs,38 bytes each*/
1778c2ecf20Sopenharmony_ci	union oaktrail_panel_rx panelrx[4]; /* panel receivers*/
1788c2ecf20Sopenharmony_ci} __packed;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistruct gct_r10 {
1818c2ecf20Sopenharmony_ci	struct gct_r10_timing_info DTD;
1828c2ecf20Sopenharmony_ci	u16 Panel_MIPI_Display_Descriptor;
1838c2ecf20Sopenharmony_ci	u16 Panel_MIPI_Receiver_Descriptor;
1848c2ecf20Sopenharmony_ci	u16 Panel_Backlight_Inverter_Descriptor;
1858c2ecf20Sopenharmony_ci	u8 Panel_Initial_Brightness;
1868c2ecf20Sopenharmony_ci	u32 MIPI_Ctlr_Init_ptr;
1878c2ecf20Sopenharmony_ci	u32 MIPI_Panel_Init_ptr;
1888c2ecf20Sopenharmony_ci} __packed;
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistruct oaktrail_gct_data {
1918c2ecf20Sopenharmony_ci	u8 bpi; /* boot panel index, number of panel used during boot */
1928c2ecf20Sopenharmony_ci	u8 pt; /* panel type, 4 bit field, 0=lvds, 1=mipi */
1938c2ecf20Sopenharmony_ci	struct oaktrail_timing_info DTD; /* timing info for the selected panel */
1948c2ecf20Sopenharmony_ci	u32 Panel_Port_Control;
1958c2ecf20Sopenharmony_ci	u32 PP_On_Sequencing;/*1 dword,Register 0x61208,*/
1968c2ecf20Sopenharmony_ci	u32 PP_Off_Sequencing;/*1 dword,Register 0x6120C,*/
1978c2ecf20Sopenharmony_ci	u32 PP_Cycle_Delay;
1988c2ecf20Sopenharmony_ci	u16 Panel_Backlight_Inverter_Descriptor;
1998c2ecf20Sopenharmony_ci	u16 Panel_MIPI_Display_Descriptor;
2008c2ecf20Sopenharmony_ci} __packed;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci#define MODE_SETTING_IN_CRTC		0x1
2038c2ecf20Sopenharmony_ci#define MODE_SETTING_IN_ENCODER		0x2
2048c2ecf20Sopenharmony_ci#define MODE_SETTING_ON_GOING		0x3
2058c2ecf20Sopenharmony_ci#define MODE_SETTING_IN_DSR		0x4
2068c2ecf20Sopenharmony_ci#define MODE_SETTING_ENCODER_DONE	0x8
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/*
2098c2ecf20Sopenharmony_ci *	Moorestown HDMI interfaces
2108c2ecf20Sopenharmony_ci */
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_cistruct oaktrail_hdmi_dev {
2138c2ecf20Sopenharmony_ci	struct pci_dev *dev;
2148c2ecf20Sopenharmony_ci	void __iomem *regs;
2158c2ecf20Sopenharmony_ci	unsigned int mmio, mmio_len;
2168c2ecf20Sopenharmony_ci	int dpms_mode;
2178c2ecf20Sopenharmony_ci	struct hdmi_i2c_dev *i2c_dev;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	/* register state */
2208c2ecf20Sopenharmony_ci	u32 saveDPLL_CTRL;
2218c2ecf20Sopenharmony_ci	u32 saveDPLL_DIV_CTRL;
2228c2ecf20Sopenharmony_ci	u32 saveDPLL_ADJUST;
2238c2ecf20Sopenharmony_ci	u32 saveDPLL_UPDATE;
2248c2ecf20Sopenharmony_ci	u32 saveDPLL_CLK_ENABLE;
2258c2ecf20Sopenharmony_ci	u32 savePCH_HTOTAL_B;
2268c2ecf20Sopenharmony_ci	u32 savePCH_HBLANK_B;
2278c2ecf20Sopenharmony_ci	u32 savePCH_HSYNC_B;
2288c2ecf20Sopenharmony_ci	u32 savePCH_VTOTAL_B;
2298c2ecf20Sopenharmony_ci	u32 savePCH_VBLANK_B;
2308c2ecf20Sopenharmony_ci	u32 savePCH_VSYNC_B;
2318c2ecf20Sopenharmony_ci	u32 savePCH_PIPEBCONF;
2328c2ecf20Sopenharmony_ci	u32 savePCH_PIPEBSRC;
2338c2ecf20Sopenharmony_ci};
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_setup(struct drm_device *dev);
2368c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_teardown(struct drm_device *dev);
2378c2ecf20Sopenharmony_ciextern int  oaktrail_hdmi_i2c_init(struct pci_dev *dev);
2388c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_i2c_exit(struct pci_dev *dev);
2398c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_save(struct drm_device *dev);
2408c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_restore(struct drm_device *dev);
2418c2ecf20Sopenharmony_ciextern void oaktrail_hdmi_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev);
2428c2ecf20Sopenharmony_ciextern int oaktrail_crtc_hdmi_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
2438c2ecf20Sopenharmony_ci						struct drm_display_mode *adjusted_mode, int x, int y,
2448c2ecf20Sopenharmony_ci						struct drm_framebuffer *old_fb);
2458c2ecf20Sopenharmony_ciextern void oaktrail_crtc_hdmi_dpms(struct drm_crtc *crtc, int mode);
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci
248