18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* DMA controller registers */ 38c2ecf20Sopenharmony_ci#define REG8_1(a0) ((const u16[8]) { a0, a0 + 1, a0 + 2, a0 + 3, \ 48c2ecf20Sopenharmony_ci a0 + 4, a0 + 5, a0 + 6, a0 + 7}) 58c2ecf20Sopenharmony_ci#define REG8_2(a0) ((const u16[8]) { a0, a0 + 2, a0 + 4, a0 + 6, \ 68c2ecf20Sopenharmony_ci a0 + 8, a0 + 0xa, a0 + 0xc, a0 + 0xe}) 78c2ecf20Sopenharmony_ci#define REG8_8(a0) ((const u16[8]) { a0, a0 + 8, a0 + 0x10, a0 + 0x18, \ 88c2ecf20Sopenharmony_ci a0 + 0x20, a0 + 0x28, a0 + 0x30, \ 98c2ecf20Sopenharmony_ci a0 + 0x38}) 108c2ecf20Sopenharmony_ci#define INT_STATUS 0x00 118c2ecf20Sopenharmony_ci#define PB_STATUS 0x01 128c2ecf20Sopenharmony_ci#define DMA_CMD 0x02 138c2ecf20Sopenharmony_ci#define VIDEO_FIFO_STATUS 0x03 148c2ecf20Sopenharmony_ci#define VIDEO_CHANNEL_ID 0x04 158c2ecf20Sopenharmony_ci#define VIDEO_PARSER_STATUS 0x05 168c2ecf20Sopenharmony_ci#define SYS_SOFT_RST 0x06 178c2ecf20Sopenharmony_ci#define DMA_PAGE_TABLE0_ADDR ((const u16[8]) { 0x08, 0xd0, 0xd2, 0xd4, \ 188c2ecf20Sopenharmony_ci 0xd6, 0xd8, 0xda, 0xdc }) 198c2ecf20Sopenharmony_ci#define DMA_PAGE_TABLE1_ADDR ((const u16[8]) { 0x09, 0xd1, 0xd3, 0xd5, \ 208c2ecf20Sopenharmony_ci 0xd7, 0xd9, 0xdb, 0xdd }) 218c2ecf20Sopenharmony_ci#define DMA_CHANNEL_ENABLE 0x0a 228c2ecf20Sopenharmony_ci#define DMA_CONFIG 0x0b 238c2ecf20Sopenharmony_ci#define DMA_TIMER_INTERVAL 0x0c 248c2ecf20Sopenharmony_ci#define DMA_CHANNEL_TIMEOUT 0x0d 258c2ecf20Sopenharmony_ci#define VDMA_CHANNEL_CONFIG REG8_1(0x10) 268c2ecf20Sopenharmony_ci#define ADMA_P_ADDR REG8_2(0x18) 278c2ecf20Sopenharmony_ci#define ADMA_B_ADDR REG8_2(0x19) 288c2ecf20Sopenharmony_ci#define DMA10_P_ADDR 0x28 298c2ecf20Sopenharmony_ci#define DMA10_B_ADDR 0x29 308c2ecf20Sopenharmony_ci#define VIDEO_CONTROL1 0x2a 318c2ecf20Sopenharmony_ci#define VIDEO_CONTROL2 0x2b 328c2ecf20Sopenharmony_ci#define AUDIO_CONTROL1 0x2c 338c2ecf20Sopenharmony_ci#define AUDIO_CONTROL2 0x2d 348c2ecf20Sopenharmony_ci#define PHASE_REF 0x2e 358c2ecf20Sopenharmony_ci#define GPIO_REG 0x2f 368c2ecf20Sopenharmony_ci#define INTL_HBAR_CTRL REG8_1(0x30) 378c2ecf20Sopenharmony_ci#define AUDIO_CONTROL3 0x38 388c2ecf20Sopenharmony_ci#define VIDEO_FIELD_CTRL REG8_1(0x39) 398c2ecf20Sopenharmony_ci#define HSCALER_CTRL REG8_1(0x42) 408c2ecf20Sopenharmony_ci#define VIDEO_SIZE REG8_1(0x4A) 418c2ecf20Sopenharmony_ci#define VIDEO_SIZE_F2 REG8_1(0x52) 428c2ecf20Sopenharmony_ci#define MD_CONF REG8_1(0x60) 438c2ecf20Sopenharmony_ci#define MD_INIT REG8_1(0x68) 448c2ecf20Sopenharmony_ci#define MD_MAP0 REG8_1(0x70) 458c2ecf20Sopenharmony_ci#define VDMA_P_ADDR REG8_8(0x80) /* not used in DMA SG mode */ 468c2ecf20Sopenharmony_ci#define VDMA_WHP REG8_8(0x81) 478c2ecf20Sopenharmony_ci#define VDMA_B_ADDR REG8_8(0x82) 488c2ecf20Sopenharmony_ci#define VDMA_F2_P_ADDR REG8_8(0x84) 498c2ecf20Sopenharmony_ci#define VDMA_F2_WHP REG8_8(0x85) 508c2ecf20Sopenharmony_ci#define VDMA_F2_B_ADDR REG8_8(0x86) 518c2ecf20Sopenharmony_ci#define EP_REG_ADDR 0xfe 528c2ecf20Sopenharmony_ci#define EP_REG_DATA 0xff 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* Video decoder registers */ 558c2ecf20Sopenharmony_ci#define VDREG8(a0) ((const u16[8]) { \ 568c2ecf20Sopenharmony_ci a0 + 0x000, a0 + 0x010, a0 + 0x020, a0 + 0x030, \ 578c2ecf20Sopenharmony_ci a0 + 0x100, a0 + 0x110, a0 + 0x120, a0 + 0x130}) 588c2ecf20Sopenharmony_ci#define VIDSTAT VDREG8(0x100) 598c2ecf20Sopenharmony_ci#define BRIGHT VDREG8(0x101) 608c2ecf20Sopenharmony_ci#define CONTRAST VDREG8(0x102) 618c2ecf20Sopenharmony_ci#define SHARPNESS VDREG8(0x103) 628c2ecf20Sopenharmony_ci#define SAT_U VDREG8(0x104) 638c2ecf20Sopenharmony_ci#define SAT_V VDREG8(0x105) 648c2ecf20Sopenharmony_ci#define HUE VDREG8(0x106) 658c2ecf20Sopenharmony_ci#define CROP_HI VDREG8(0x107) 668c2ecf20Sopenharmony_ci#define VDELAY_LO VDREG8(0x108) 678c2ecf20Sopenharmony_ci#define VACTIVE_LO VDREG8(0x109) 688c2ecf20Sopenharmony_ci#define HDELAY_LO VDREG8(0x10a) 698c2ecf20Sopenharmony_ci#define HACTIVE_LO VDREG8(0x10b) 708c2ecf20Sopenharmony_ci#define MVSN VDREG8(0x10c) 718c2ecf20Sopenharmony_ci#define STATUS2 VDREG8(0x10d) 728c2ecf20Sopenharmony_ci#define SDT VDREG8(0x10e) 738c2ecf20Sopenharmony_ci#define SDT_EN VDREG8(0x10f) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define VSCALE_LO VDREG8(0x144) 768c2ecf20Sopenharmony_ci#define SCALE_HI VDREG8(0x145) 778c2ecf20Sopenharmony_ci#define HSCALE_LO VDREG8(0x146) 788c2ecf20Sopenharmony_ci#define F2CROP_HI VDREG8(0x147) 798c2ecf20Sopenharmony_ci#define F2VDELAY_LO VDREG8(0x148) 808c2ecf20Sopenharmony_ci#define F2VACTIVE_LO VDREG8(0x149) 818c2ecf20Sopenharmony_ci#define F2HDELAY_LO VDREG8(0x14a) 828c2ecf20Sopenharmony_ci#define F2HACTIVE_LO VDREG8(0x14b) 838c2ecf20Sopenharmony_ci#define F2VSCALE_LO VDREG8(0x14c) 848c2ecf20Sopenharmony_ci#define F2SCALE_HI VDREG8(0x14d) 858c2ecf20Sopenharmony_ci#define F2HSCALE_LO VDREG8(0x14e) 868c2ecf20Sopenharmony_ci#define F2CNT VDREG8(0x14f) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define VDREG2(a0) ((const u16[2]) { a0, a0 + 0x100 }) 898c2ecf20Sopenharmony_ci#define SRST VDREG2(0x180) 908c2ecf20Sopenharmony_ci#define ACNTL VDREG2(0x181) 918c2ecf20Sopenharmony_ci#define ACNTL2 VDREG2(0x182) 928c2ecf20Sopenharmony_ci#define CNTRL1 VDREG2(0x183) 938c2ecf20Sopenharmony_ci#define CKHY VDREG2(0x184) 948c2ecf20Sopenharmony_ci#define SHCOR VDREG2(0x185) 958c2ecf20Sopenharmony_ci#define CORING VDREG2(0x186) 968c2ecf20Sopenharmony_ci#define CLMPG VDREG2(0x187) 978c2ecf20Sopenharmony_ci#define IAGC VDREG2(0x188) 988c2ecf20Sopenharmony_ci#define VCTRL1 VDREG2(0x18f) 998c2ecf20Sopenharmony_ci#define MISC1 VDREG2(0x194) 1008c2ecf20Sopenharmony_ci#define LOOP VDREG2(0x195) 1018c2ecf20Sopenharmony_ci#define MISC2 VDREG2(0x196) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define CLMD VDREG2(0x197) 1048c2ecf20Sopenharmony_ci#define ANPWRDOWN VDREG2(0x1ce) 1058c2ecf20Sopenharmony_ci#define AIGAIN ((const u16[8]) { 0x1d0, 0x1d1, 0x1d2, 0x1d3, \ 1068c2ecf20Sopenharmony_ci 0x2d0, 0x2d1, 0x2d2, 0x2d3 }) 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define SYS_MODE_DMA_SHIFT 13 1098c2ecf20Sopenharmony_ci#define AUDIO_DMA_SIZE_SHIFT 19 1108c2ecf20Sopenharmony_ci#define AUDIO_DMA_SIZE_MIN SZ_512 1118c2ecf20Sopenharmony_ci#define AUDIO_DMA_SIZE_MAX SZ_4K 1128c2ecf20Sopenharmony_ci#define AUDIO_DMA_SIZE_MASK (SZ_8K - 1) 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define DMA_CMD_ENABLE BIT(31) 1158c2ecf20Sopenharmony_ci#define INT_STATUS_DMA_TOUT BIT(17) 1168c2ecf20Sopenharmony_ci#define TW686X_VIDSTAT_HLOCK BIT(6) 1178c2ecf20Sopenharmony_ci#define TW686X_VIDSTAT_VDLOSS BIT(7) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define TW686X_STD_NTSC_M 0 1208c2ecf20Sopenharmony_ci#define TW686X_STD_PAL 1 1218c2ecf20Sopenharmony_ci#define TW686X_STD_SECAM 2 1228c2ecf20Sopenharmony_ci#define TW686X_STD_NTSC_443 3 1238c2ecf20Sopenharmony_ci#define TW686X_STD_PAL_M 4 1248c2ecf20Sopenharmony_ci#define TW686X_STD_PAL_CN 5 1258c2ecf20Sopenharmony_ci#define TW686X_STD_PAL_60 6 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define TW686X_FIELD_MODE 0x3 1288c2ecf20Sopenharmony_ci#define TW686X_FRAME_MODE 0x2 1298c2ecf20Sopenharmony_ci/* 0x1 is reserved */ 1308c2ecf20Sopenharmony_ci#define TW686X_SG_MODE 0x0 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define TW686X_FIFO_ERROR(x) (x & ~(0xff)) 133