162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __ASM_ARCH_REGS_LCD_H
362306a36Sopenharmony_ci#define __ASM_ARCH_REGS_LCD_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci * LCD Controller Registers and Bits Definitions
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#define LCCR0		(0x000)	/* LCD Controller Control Register 0 */
962306a36Sopenharmony_ci#define LCCR1		(0x004)	/* LCD Controller Control Register 1 */
1062306a36Sopenharmony_ci#define LCCR2		(0x008)	/* LCD Controller Control Register 2 */
1162306a36Sopenharmony_ci#define LCCR3		(0x00C)	/* LCD Controller Control Register 3 */
1262306a36Sopenharmony_ci#define LCCR4		(0x010)	/* LCD Controller Control Register 4 */
1362306a36Sopenharmony_ci#define LCCR5		(0x014)	/* LCD Controller Control Register 5 */
1462306a36Sopenharmony_ci#define LCSR		(0x038)	/* LCD Controller Status Register 0 */
1562306a36Sopenharmony_ci#define LCSR1		(0x034)	/* LCD Controller Status Register 1 */
1662306a36Sopenharmony_ci#define LIIDR		(0x03C)	/* LCD Controller Interrupt ID Register */
1762306a36Sopenharmony_ci#define TMEDRGBR	(0x040)	/* TMED RGB Seed Register */
1862306a36Sopenharmony_ci#define TMEDCR		(0x044)	/* TMED Control Register */
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define FBR0		(0x020)	/* DMA Channel 0 Frame Branch Register */
2162306a36Sopenharmony_ci#define FBR1		(0x024)	/* DMA Channel 1 Frame Branch Register */
2262306a36Sopenharmony_ci#define FBR2		(0x028) /* DMA Channel 2 Frame Branch Register */
2362306a36Sopenharmony_ci#define FBR3		(0x02C) /* DMA Channel 2 Frame Branch Register */
2462306a36Sopenharmony_ci#define FBR4		(0x030) /* DMA Channel 2 Frame Branch Register */
2562306a36Sopenharmony_ci#define FBR5		(0x110) /* DMA Channel 2 Frame Branch Register */
2662306a36Sopenharmony_ci#define FBR6		(0x114) /* DMA Channel 2 Frame Branch Register */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define OVL1C1		(0x050)	/* Overlay 1 Control Register 1 */
2962306a36Sopenharmony_ci#define OVL1C2		(0x060)	/* Overlay 1 Control Register 2 */
3062306a36Sopenharmony_ci#define OVL2C1		(0x070)	/* Overlay 2 Control Register 1 */
3162306a36Sopenharmony_ci#define OVL2C2		(0x080)	/* Overlay 2 Control Register 2 */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define CMDCR		(0x100)	/* Command Control Register */
3462306a36Sopenharmony_ci#define PRSR		(0x104)	/* Panel Read Status Register */
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define LCCR3_BPP(x)	((((x) & 0x7) << 24) | (((x) & 0x8) ? (1 << 29) : 0))
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define LCCR3_PDFOR_0	(0 << 30)
3962306a36Sopenharmony_ci#define LCCR3_PDFOR_1	(1 << 30)
4062306a36Sopenharmony_ci#define LCCR3_PDFOR_2	(2 << 30)
4162306a36Sopenharmony_ci#define LCCR3_PDFOR_3	(3 << 30)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define LCCR4_PAL_FOR_0	(0 << 15)
4462306a36Sopenharmony_ci#define LCCR4_PAL_FOR_1	(1 << 15)
4562306a36Sopenharmony_ci#define LCCR4_PAL_FOR_2	(2 << 15)
4662306a36Sopenharmony_ci#define LCCR4_PAL_FOR_3	(3 << 15)
4762306a36Sopenharmony_ci#define LCCR4_PAL_FOR_MASK	(3 << 15)
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define FDADR0		(0x200)	/* DMA Channel 0 Frame Descriptor Address Register */
5062306a36Sopenharmony_ci#define FDADR1		(0x210)	/* DMA Channel 1 Frame Descriptor Address Register */
5162306a36Sopenharmony_ci#define FDADR2		(0x220)	/* DMA Channel 2 Frame Descriptor Address Register */
5262306a36Sopenharmony_ci#define FDADR3		(0x230)	/* DMA Channel 3 Frame Descriptor Address Register */
5362306a36Sopenharmony_ci#define FDADR4		(0x240)	/* DMA Channel 4 Frame Descriptor Address Register */
5462306a36Sopenharmony_ci#define FDADR5		(0x250)	/* DMA Channel 5 Frame Descriptor Address Register */
5562306a36Sopenharmony_ci#define FDADR6		(0x260) /* DMA Channel 6 Frame Descriptor Address Register */
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define LCCR0_ENB	(1 << 0)	/* LCD Controller enable */
5862306a36Sopenharmony_ci#define LCCR0_CMS	(1 << 1)	/* Color/Monochrome Display Select */
5962306a36Sopenharmony_ci#define LCCR0_Color	(LCCR0_CMS*0)	/*  Color display */
6062306a36Sopenharmony_ci#define LCCR0_Mono	(LCCR0_CMS*1)	/*  Monochrome display */
6162306a36Sopenharmony_ci#define LCCR0_SDS	(1 << 2)	/* Single/Dual Panel Display Select */
6262306a36Sopenharmony_ci#define LCCR0_Sngl	(LCCR0_SDS*0)	/*  Single panel display */
6362306a36Sopenharmony_ci#define LCCR0_Dual	(LCCR0_SDS*1)	/*  Dual panel display */
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define LCCR0_LDM	(1 << 3)	/* LCD Disable Done Mask */
6662306a36Sopenharmony_ci#define LCCR0_SFM	(1 << 4)	/* Start of frame mask */
6762306a36Sopenharmony_ci#define LCCR0_IUM	(1 << 5)	/* Input FIFO underrun mask */
6862306a36Sopenharmony_ci#define LCCR0_EFM	(1 << 6)	/* End of Frame mask */
6962306a36Sopenharmony_ci#define LCCR0_PAS	(1 << 7)	/* Passive/Active display Select */
7062306a36Sopenharmony_ci#define LCCR0_Pas	(LCCR0_PAS*0)	/*  Passive display (STN) */
7162306a36Sopenharmony_ci#define LCCR0_Act	(LCCR0_PAS*1)	/*  Active display (TFT) */
7262306a36Sopenharmony_ci#define LCCR0_DPD	(1 << 9)	/* Double Pixel Data (monochrome) */
7362306a36Sopenharmony_ci#define LCCR0_4PixMono	(LCCR0_DPD*0)	/*  4-Pixel/clock Monochrome display */
7462306a36Sopenharmony_ci#define LCCR0_8PixMono	(LCCR0_DPD*1)	/*  8-Pixel/clock Monochrome display */
7562306a36Sopenharmony_ci#define LCCR0_DIS	(1 << 10)	/* LCD Disable */
7662306a36Sopenharmony_ci#define LCCR0_QDM	(1 << 11)	/* LCD Quick Disable mask */
7762306a36Sopenharmony_ci#define LCCR0_PDD	(0xff << 12)	/* Palette DMA request delay */
7862306a36Sopenharmony_ci#define LCCR0_PDD_S	12
7962306a36Sopenharmony_ci#define LCCR0_BM	(1 << 20)	/* Branch mask */
8062306a36Sopenharmony_ci#define LCCR0_OUM	(1 << 21)	/* Output FIFO underrun mask */
8162306a36Sopenharmony_ci#define LCCR0_LCDT	(1 << 22)	/* LCD panel type */
8262306a36Sopenharmony_ci#define LCCR0_RDSTM	(1 << 23)	/* Read status interrupt mask */
8362306a36Sopenharmony_ci#define LCCR0_CMDIM	(1 << 24)	/* Command interrupt mask */
8462306a36Sopenharmony_ci#define LCCR0_OUC	(1 << 25)	/* Overlay Underlay control bit */
8562306a36Sopenharmony_ci#define LCCR0_LDDALT	(1 << 26)	/* LDD alternate mapping control */
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define Fld(Size, Shft)	(((Size) << 16) + (Shft))
8862306a36Sopenharmony_ci#define FShft(Field)	((Field) & 0x0000FFFF)
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define LCCR1_PPL	Fld (10, 0)	/* Pixels Per Line - 1 */
9162306a36Sopenharmony_ci#define LCCR1_DisWdth(Pixel)	(((Pixel) - 1) << FShft (LCCR1_PPL))
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define LCCR1_HSW	Fld (6, 10)	/* Horizontal Synchronization */
9462306a36Sopenharmony_ci#define LCCR1_HorSnchWdth(Tpix)	(((Tpix) - 1) << FShft (LCCR1_HSW))
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define LCCR1_ELW	Fld (8, 16)	/* End-of-Line pixel clock Wait - 1 */
9762306a36Sopenharmony_ci#define LCCR1_EndLnDel(Tpix)	(((Tpix) - 1) << FShft (LCCR1_ELW))
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define LCCR1_BLW	Fld (8, 24)	/* Beginning-of-Line pixel clock */
10062306a36Sopenharmony_ci#define LCCR1_BegLnDel(Tpix)	(((Tpix) - 1) << FShft (LCCR1_BLW))
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define LCCR2_LPP	Fld (10, 0)	/* Line Per Panel - 1 */
10362306a36Sopenharmony_ci#define LCCR2_DisHght(Line)	(((Line) - 1) << FShft (LCCR2_LPP))
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci#define LCCR2_VSW	Fld (6, 10)	/* Vertical Synchronization pulse - 1 */
10662306a36Sopenharmony_ci#define LCCR2_VrtSnchWdth(Tln)	(((Tln) - 1) << FShft (LCCR2_VSW))
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#define LCCR2_EFW	Fld (8, 16)	/* End-of-Frame line clock Wait */
10962306a36Sopenharmony_ci#define LCCR2_EndFrmDel(Tln)	((Tln) << FShft (LCCR2_EFW))
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define LCCR2_BFW	Fld (8, 24)	/* Beginning-of-Frame line clock */
11262306a36Sopenharmony_ci#define LCCR2_BegFrmDel(Tln)	((Tln) << FShft (LCCR2_BFW))
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define LCCR3_API	(0xf << 16)	/* AC Bias pin trasitions per interrupt */
11562306a36Sopenharmony_ci#define LCCR3_API_S	16
11662306a36Sopenharmony_ci#define LCCR3_VSP	(1 << 20)	/* vertical sync polarity */
11762306a36Sopenharmony_ci#define LCCR3_HSP	(1 << 21)	/* horizontal sync polarity */
11862306a36Sopenharmony_ci#define LCCR3_PCP	(1 << 22)	/* Pixel Clock Polarity (L_PCLK) */
11962306a36Sopenharmony_ci#define LCCR3_PixRsEdg	(LCCR3_PCP*0)	/*  Pixel clock Rising-Edge */
12062306a36Sopenharmony_ci#define LCCR3_PixFlEdg	(LCCR3_PCP*1)	/*  Pixel clock Falling-Edge */
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define LCCR3_OEP	(1 << 23)	/* Output Enable Polarity */
12362306a36Sopenharmony_ci#define LCCR3_OutEnH	(LCCR3_OEP*0)	/*  Output Enable active High */
12462306a36Sopenharmony_ci#define LCCR3_OutEnL	(LCCR3_OEP*1)	/*  Output Enable active Low */
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define LCCR3_DPC	(1 << 27)	/* double pixel clock mode */
12762306a36Sopenharmony_ci#define LCCR3_PCD	Fld (8, 0)	/* Pixel Clock Divisor */
12862306a36Sopenharmony_ci#define LCCR3_PixClkDiv(Div)	(((Div) << FShft (LCCR3_PCD)))
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci#define LCCR3_ACB	Fld (8, 8)	/* AC Bias */
13162306a36Sopenharmony_ci#define LCCR3_Acb(Acb)	(((Acb) << FShft (LCCR3_ACB)))
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define LCCR3_HorSnchH	(LCCR3_HSP*0)	/*  HSP Active High */
13462306a36Sopenharmony_ci#define LCCR3_HorSnchL	(LCCR3_HSP*1)	/*  HSP Active Low */
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#define LCCR3_VrtSnchH	(LCCR3_VSP*0)	/*  VSP Active High */
13762306a36Sopenharmony_ci#define LCCR3_VrtSnchL	(LCCR3_VSP*1)	/*  VSP Active Low */
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define LCCR5_IUM(x)	(1 << ((x) + 23)) /* input underrun mask */
14062306a36Sopenharmony_ci#define LCCR5_BSM(x)	(1 << ((x) + 15)) /* branch mask */
14162306a36Sopenharmony_ci#define LCCR5_EOFM(x)	(1 << ((x) + 7))  /* end of frame mask */
14262306a36Sopenharmony_ci#define LCCR5_SOFM(x)	(1 << ((x) + 0))  /* start of frame mask */
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci#define LCSR_LDD	(1 << 0)	/* LCD Disable Done */
14562306a36Sopenharmony_ci#define LCSR_SOF	(1 << 1)	/* Start of frame */
14662306a36Sopenharmony_ci#define LCSR_BER	(1 << 2)	/* Bus error */
14762306a36Sopenharmony_ci#define LCSR_ABC	(1 << 3)	/* AC Bias count */
14862306a36Sopenharmony_ci#define LCSR_IUL	(1 << 4)	/* input FIFO underrun Lower panel */
14962306a36Sopenharmony_ci#define LCSR_IUU	(1 << 5)	/* input FIFO underrun Upper panel */
15062306a36Sopenharmony_ci#define LCSR_OU		(1 << 6)	/* output FIFO underrun */
15162306a36Sopenharmony_ci#define LCSR_QD		(1 << 7)	/* quick disable */
15262306a36Sopenharmony_ci#define LCSR_EOF	(1 << 8)	/* end of frame */
15362306a36Sopenharmony_ci#define LCSR_BS		(1 << 9)	/* branch status */
15462306a36Sopenharmony_ci#define LCSR_SINT	(1 << 10)	/* subsequent interrupt */
15562306a36Sopenharmony_ci#define LCSR_RD_ST	(1 << 11)	/* read status */
15662306a36Sopenharmony_ci#define LCSR_CMD_INT	(1 << 12)	/* command interrupt */
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define LCSR1_IU(x)	(1 << ((x) + 23)) /* Input FIFO underrun */
15962306a36Sopenharmony_ci#define LCSR1_BS(x)	(1 << ((x) + 15)) /* Branch Status */
16062306a36Sopenharmony_ci#define LCSR1_EOF(x)	(1 << ((x) + 7))  /* End of Frame Status */
16162306a36Sopenharmony_ci#define LCSR1_SOF(x)	(1 << ((x) - 1))  /* Start of Frame Status */
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci#define LDCMD_PAL	(1 << 26)	/* instructs DMA to load palette buffer */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* overlay control registers */
16662306a36Sopenharmony_ci#define OVLxC1_PPL(x)	((((x) - 1) & 0x3ff) << 0)	/* Pixels Per Line */
16762306a36Sopenharmony_ci#define OVLxC1_LPO(x)	((((x) - 1) & 0x3ff) << 10)	/* Number of Lines */
16862306a36Sopenharmony_ci#define OVLxC1_BPP(x)	(((x) & 0xf) << 20)	/* Bits Per Pixel */
16962306a36Sopenharmony_ci#define OVLxC1_OEN	(1 << 31)		/* Enable bit for Overlay */
17062306a36Sopenharmony_ci#define OVLxC2_XPOS(x)	(((x) & 0x3ff) << 0)	/* Horizontal Position */
17162306a36Sopenharmony_ci#define OVLxC2_YPOS(x)	(((x) & 0x3ff) << 10)	/* Vertical Position */
17262306a36Sopenharmony_ci#define OVL2C2_PFOR(x)	(((x) & 0x7) << 20)	/* Pixel Format */
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci/* smartpanel related */
17562306a36Sopenharmony_ci#define PRSR_DATA(x)	((x) & 0xff)	/* Panel Data */
17662306a36Sopenharmony_ci#define PRSR_A0		(1 << 8)	/* Read Data Source */
17762306a36Sopenharmony_ci#define PRSR_ST_OK	(1 << 9)	/* Status OK */
17862306a36Sopenharmony_ci#define PRSR_CON_NT	(1 << 10)	/* Continue to Next Command */
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci#endif /* __ASM_ARCH_REGS_LCD_H */
181