11bb76ff1Sjsg /* SPDX-License-Identifier: MIT */
21bb76ff1Sjsg /*
31bb76ff1Sjsg  * Copyright © 2022 Intel Corporation
41bb76ff1Sjsg  */
51bb76ff1Sjsg 
61bb76ff1Sjsg #ifndef __INTEL_BACKLIGHT_REGS_H__
71bb76ff1Sjsg #define __INTEL_BACKLIGHT_REGS_H__
81bb76ff1Sjsg 
9*f005ef32Sjsg #include "intel_display_reg_defs.h"
101bb76ff1Sjsg 
11*f005ef32Sjsg #define _VLV_BLC_PWM_CTL2_A		(VLV_DISPLAY_BASE + 0x61250)
12*f005ef32Sjsg #define _VLV_BLC_PWM_CTL2_B		(VLV_DISPLAY_BASE + 0x61350)
13*f005ef32Sjsg #define VLV_BLC_PWM_CTL2(pipe) _MMIO_PIPE(pipe, _VLV_BLC_PWM_CTL2_A, _VLV_BLC_PWM_CTL2_B)
141bb76ff1Sjsg 
15*f005ef32Sjsg #define _VLV_BLC_PWM_CTL_A		(VLV_DISPLAY_BASE + 0x61254)
16*f005ef32Sjsg #define _VLV_BLC_PWM_CTL_B		(VLV_DISPLAY_BASE + 0x61354)
17*f005ef32Sjsg #define VLV_BLC_PWM_CTL(pipe) _MMIO_PIPE(pipe, _VLV_BLC_PWM_CTL_A, _VLV_BLC_PWM_CTL_B)
181bb76ff1Sjsg 
19*f005ef32Sjsg #define _VLV_BLC_HIST_CTL_A		(VLV_DISPLAY_BASE + 0x61260)
20*f005ef32Sjsg #define _VLV_BLC_HIST_CTL_B		(VLV_DISPLAY_BASE + 0x61360)
21*f005ef32Sjsg #define VLV_BLC_HIST_CTL(pipe) _MMIO_PIPE(pipe, _VLV_BLC_HIST_CTL_A, _VLV_BLC_HIST_CTL_B)
221bb76ff1Sjsg 
231bb76ff1Sjsg /* Backlight control */
24*f005ef32Sjsg #define BLC_PWM_CTL2	_MMIO(0x61250) /* 965+ only */
251bb76ff1Sjsg #define   BLM_PWM_ENABLE		(1 << 31)
261bb76ff1Sjsg #define   BLM_COMBINATION_MODE		(1 << 30) /* gen4 only */
271bb76ff1Sjsg #define   BLM_PIPE_SELECT		(1 << 29)
281bb76ff1Sjsg #define   BLM_PIPE_SELECT_IVB		(3 << 29)
291bb76ff1Sjsg #define   BLM_PIPE_A			(0 << 29)
301bb76ff1Sjsg #define   BLM_PIPE_B			(1 << 29)
311bb76ff1Sjsg #define   BLM_PIPE_C			(2 << 29) /* ivb + */
321bb76ff1Sjsg #define   BLM_TRANSCODER_A		BLM_PIPE_A /* hsw */
331bb76ff1Sjsg #define   BLM_TRANSCODER_B		BLM_PIPE_B
341bb76ff1Sjsg #define   BLM_TRANSCODER_C		BLM_PIPE_C
351bb76ff1Sjsg #define   BLM_TRANSCODER_EDP		(3 << 29)
361bb76ff1Sjsg #define   BLM_PIPE(pipe)		((pipe) << 29)
371bb76ff1Sjsg #define   BLM_POLARITY_I965		(1 << 28) /* gen4 only */
381bb76ff1Sjsg #define   BLM_PHASE_IN_INTERUPT_STATUS	(1 << 26)
391bb76ff1Sjsg #define   BLM_PHASE_IN_ENABLE		(1 << 25)
401bb76ff1Sjsg #define   BLM_PHASE_IN_INTERUPT_ENABL	(1 << 24)
411bb76ff1Sjsg #define   BLM_PHASE_IN_TIME_BASE_SHIFT	(16)
421bb76ff1Sjsg #define   BLM_PHASE_IN_TIME_BASE_MASK	(0xff << 16)
431bb76ff1Sjsg #define   BLM_PHASE_IN_COUNT_SHIFT	(8)
441bb76ff1Sjsg #define   BLM_PHASE_IN_COUNT_MASK	(0xff << 8)
451bb76ff1Sjsg #define   BLM_PHASE_IN_INCR_SHIFT	(0)
461bb76ff1Sjsg #define   BLM_PHASE_IN_INCR_MASK	(0xff << 0)
47*f005ef32Sjsg #define BLC_PWM_CTL	_MMIO(0x61254)
481bb76ff1Sjsg /*
491bb76ff1Sjsg  * This is the most significant 15 bits of the number of backlight cycles in a
501bb76ff1Sjsg  * complete cycle of the modulated backlight control.
511bb76ff1Sjsg  *
521bb76ff1Sjsg  * The actual value is this field multiplied by two.
531bb76ff1Sjsg  */
541bb76ff1Sjsg #define   BACKLIGHT_MODULATION_FREQ_SHIFT	(17)
551bb76ff1Sjsg #define   BACKLIGHT_MODULATION_FREQ_MASK	(0x7fff << 17)
561bb76ff1Sjsg #define   BLM_LEGACY_MODE			(1 << 16) /* gen2 only */
571bb76ff1Sjsg /*
581bb76ff1Sjsg  * This is the number of cycles out of the backlight modulation cycle for which
591bb76ff1Sjsg  * the backlight is on.
601bb76ff1Sjsg  *
611bb76ff1Sjsg  * This field must be no greater than the number of cycles in the complete
621bb76ff1Sjsg  * backlight modulation cycle.
631bb76ff1Sjsg  */
641bb76ff1Sjsg #define   BACKLIGHT_DUTY_CYCLE_SHIFT		(0)
651bb76ff1Sjsg #define   BACKLIGHT_DUTY_CYCLE_MASK		(0xffff)
661bb76ff1Sjsg #define   BACKLIGHT_DUTY_CYCLE_MASK_PNV		(0xfffe)
671bb76ff1Sjsg #define   BLM_POLARITY_PNV			(1 << 0) /* pnv only */
681bb76ff1Sjsg 
69*f005ef32Sjsg #define BLC_HIST_CTL	_MMIO(0x61260)
701bb76ff1Sjsg #define  BLM_HISTOGRAM_ENABLE			(1 << 31)
711bb76ff1Sjsg 
721bb76ff1Sjsg /* New registers for PCH-split platforms. Safe where new bits show up, the
731bb76ff1Sjsg  * register layout machtes with gen4 BLC_PWM_CTL[12]. */
741bb76ff1Sjsg #define BLC_PWM_CPU_CTL2	_MMIO(0x48250)
751bb76ff1Sjsg #define BLC_PWM_CPU_CTL		_MMIO(0x48254)
761bb76ff1Sjsg 
771bb76ff1Sjsg #define HSW_BLC_PWM2_CTL	_MMIO(0x48350)
781bb76ff1Sjsg 
791bb76ff1Sjsg /* PCH CTL1 is totally different, all but the below bits are reserved. CTL2 is
801bb76ff1Sjsg  * like the normal CTL from gen4 and earlier. Hooray for confusing naming. */
811bb76ff1Sjsg #define BLC_PWM_PCH_CTL1	_MMIO(0xc8250)
821bb76ff1Sjsg #define   BLM_PCH_PWM_ENABLE			(1 << 31)
831bb76ff1Sjsg #define   BLM_PCH_OVERRIDE_ENABLE		(1 << 30)
841bb76ff1Sjsg #define   BLM_PCH_POLARITY			(1 << 29)
851bb76ff1Sjsg #define BLC_PWM_PCH_CTL2	_MMIO(0xc8254)
861bb76ff1Sjsg 
871bb76ff1Sjsg /* BXT backlight register definition. */
881bb76ff1Sjsg #define _BXT_BLC_PWM_CTL1			0xC8250
891bb76ff1Sjsg #define   BXT_BLC_PWM_ENABLE			(1 << 31)
901bb76ff1Sjsg #define   BXT_BLC_PWM_POLARITY			(1 << 29)
911bb76ff1Sjsg #define _BXT_BLC_PWM_FREQ1			0xC8254
921bb76ff1Sjsg #define _BXT_BLC_PWM_DUTY1			0xC8258
931bb76ff1Sjsg 
941bb76ff1Sjsg #define _BXT_BLC_PWM_CTL2			0xC8350
951bb76ff1Sjsg #define _BXT_BLC_PWM_FREQ2			0xC8354
961bb76ff1Sjsg #define _BXT_BLC_PWM_DUTY2			0xC8358
971bb76ff1Sjsg 
981bb76ff1Sjsg #define BXT_BLC_PWM_CTL(controller)    _MMIO_PIPE(controller,		\
991bb76ff1Sjsg 					_BXT_BLC_PWM_CTL1, _BXT_BLC_PWM_CTL2)
1001bb76ff1Sjsg #define BXT_BLC_PWM_FREQ(controller)   _MMIO_PIPE(controller, \
1011bb76ff1Sjsg 					_BXT_BLC_PWM_FREQ1, _BXT_BLC_PWM_FREQ2)
1021bb76ff1Sjsg #define BXT_BLC_PWM_DUTY(controller)   _MMIO_PIPE(controller, \
1031bb76ff1Sjsg 					_BXT_BLC_PWM_DUTY1, _BXT_BLC_PWM_DUTY2)
1041bb76ff1Sjsg 
1051bb76ff1Sjsg /* Utility pin */
1061bb76ff1Sjsg #define UTIL_PIN_CTL			_MMIO(0x48400)
1071bb76ff1Sjsg #define   UTIL_PIN_ENABLE		(1 << 31)
1081bb76ff1Sjsg #define   UTIL_PIN_PIPE_MASK		(3 << 29)
1091bb76ff1Sjsg #define   UTIL_PIN_PIPE(x)		((x) << 29)
1101bb76ff1Sjsg #define   UTIL_PIN_MODE_MASK		(0xf << 24)
1111bb76ff1Sjsg #define   UTIL_PIN_MODE_DATA		(0 << 24)
1121bb76ff1Sjsg #define   UTIL_PIN_MODE_PWM		(1 << 24)
1131bb76ff1Sjsg #define   UTIL_PIN_MODE_VBLANK		(4 << 24)
1141bb76ff1Sjsg #define   UTIL_PIN_MODE_VSYNC		(5 << 24)
1151bb76ff1Sjsg #define   UTIL_PIN_MODE_EYE_LEVEL	(8 << 24)
1161bb76ff1Sjsg #define   UTIL_PIN_OUTPUT_DATA		(1 << 23)
1171bb76ff1Sjsg #define   UTIL_PIN_POLARITY		(1 << 22)
1181bb76ff1Sjsg #define   UTIL_PIN_DIRECTION_INPUT	(1 << 19)
1191bb76ff1Sjsg #define   UTIL_PIN_INPUT_DATA		(1 << 16)
1201bb76ff1Sjsg 
1211bb76ff1Sjsg #endif /* __INTEL_BACKLIGHT_REGS_H__ */
122