18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2008 48c2ecf20Sopenharmony_ci * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _IPU_INTERN_H_ 108c2ecf20Sopenharmony_ci#define _IPU_INTERN_H_ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/dmaengine.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* IPU Common registers */ 178c2ecf20Sopenharmony_ci#define IPU_CONF 0x00 188c2ecf20Sopenharmony_ci#define IPU_CHA_BUF0_RDY 0x04 198c2ecf20Sopenharmony_ci#define IPU_CHA_BUF1_RDY 0x08 208c2ecf20Sopenharmony_ci#define IPU_CHA_DB_MODE_SEL 0x0C 218c2ecf20Sopenharmony_ci#define IPU_CHA_CUR_BUF 0x10 228c2ecf20Sopenharmony_ci#define IPU_FS_PROC_FLOW 0x14 238c2ecf20Sopenharmony_ci#define IPU_FS_DISP_FLOW 0x18 248c2ecf20Sopenharmony_ci#define IPU_TASKS_STAT 0x1C 258c2ecf20Sopenharmony_ci#define IPU_IMA_ADDR 0x20 268c2ecf20Sopenharmony_ci#define IPU_IMA_DATA 0x24 278c2ecf20Sopenharmony_ci#define IPU_INT_CTRL_1 0x28 288c2ecf20Sopenharmony_ci#define IPU_INT_CTRL_2 0x2C 298c2ecf20Sopenharmony_ci#define IPU_INT_CTRL_3 0x30 308c2ecf20Sopenharmony_ci#define IPU_INT_CTRL_4 0x34 318c2ecf20Sopenharmony_ci#define IPU_INT_CTRL_5 0x38 328c2ecf20Sopenharmony_ci#define IPU_INT_STAT_1 0x3C 338c2ecf20Sopenharmony_ci#define IPU_INT_STAT_2 0x40 348c2ecf20Sopenharmony_ci#define IPU_INT_STAT_3 0x44 358c2ecf20Sopenharmony_ci#define IPU_INT_STAT_4 0x48 368c2ecf20Sopenharmony_ci#define IPU_INT_STAT_5 0x4C 378c2ecf20Sopenharmony_ci#define IPU_BRK_CTRL_1 0x50 388c2ecf20Sopenharmony_ci#define IPU_BRK_CTRL_2 0x54 398c2ecf20Sopenharmony_ci#define IPU_BRK_STAT 0x58 408c2ecf20Sopenharmony_ci#define IPU_DIAGB_CTRL 0x5C 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* IPU_CONF Register bits */ 438c2ecf20Sopenharmony_ci#define IPU_CONF_CSI_EN 0x00000001 448c2ecf20Sopenharmony_ci#define IPU_CONF_IC_EN 0x00000002 458c2ecf20Sopenharmony_ci#define IPU_CONF_ROT_EN 0x00000004 468c2ecf20Sopenharmony_ci#define IPU_CONF_PF_EN 0x00000008 478c2ecf20Sopenharmony_ci#define IPU_CONF_SDC_EN 0x00000010 488c2ecf20Sopenharmony_ci#define IPU_CONF_ADC_EN 0x00000020 498c2ecf20Sopenharmony_ci#define IPU_CONF_DI_EN 0x00000040 508c2ecf20Sopenharmony_ci#define IPU_CONF_DU_EN 0x00000080 518c2ecf20Sopenharmony_ci#define IPU_CONF_PXL_ENDIAN 0x00000100 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* Image Converter Registers */ 548c2ecf20Sopenharmony_ci#define IC_CONF 0x88 558c2ecf20Sopenharmony_ci#define IC_PRP_ENC_RSC 0x8C 568c2ecf20Sopenharmony_ci#define IC_PRP_VF_RSC 0x90 578c2ecf20Sopenharmony_ci#define IC_PP_RSC 0x94 588c2ecf20Sopenharmony_ci#define IC_CMBP_1 0x98 598c2ecf20Sopenharmony_ci#define IC_CMBP_2 0x9C 608c2ecf20Sopenharmony_ci#define PF_CONF 0xA0 618c2ecf20Sopenharmony_ci#define IDMAC_CONF 0xA4 628c2ecf20Sopenharmony_ci#define IDMAC_CHA_EN 0xA8 638c2ecf20Sopenharmony_ci#define IDMAC_CHA_PRI 0xAC 648c2ecf20Sopenharmony_ci#define IDMAC_CHA_BUSY 0xB0 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* Image Converter Register bits */ 678c2ecf20Sopenharmony_ci#define IC_CONF_PRPENC_EN 0x00000001 688c2ecf20Sopenharmony_ci#define IC_CONF_PRPENC_CSC1 0x00000002 698c2ecf20Sopenharmony_ci#define IC_CONF_PRPENC_ROT_EN 0x00000004 708c2ecf20Sopenharmony_ci#define IC_CONF_PRPVF_EN 0x00000100 718c2ecf20Sopenharmony_ci#define IC_CONF_PRPVF_CSC1 0x00000200 728c2ecf20Sopenharmony_ci#define IC_CONF_PRPVF_CSC2 0x00000400 738c2ecf20Sopenharmony_ci#define IC_CONF_PRPVF_CMB 0x00000800 748c2ecf20Sopenharmony_ci#define IC_CONF_PRPVF_ROT_EN 0x00001000 758c2ecf20Sopenharmony_ci#define IC_CONF_PP_EN 0x00010000 768c2ecf20Sopenharmony_ci#define IC_CONF_PP_CSC1 0x00020000 778c2ecf20Sopenharmony_ci#define IC_CONF_PP_CSC2 0x00040000 788c2ecf20Sopenharmony_ci#define IC_CONF_PP_CMB 0x00080000 798c2ecf20Sopenharmony_ci#define IC_CONF_PP_ROT_EN 0x00100000 808c2ecf20Sopenharmony_ci#define IC_CONF_IC_GLB_LOC_A 0x10000000 818c2ecf20Sopenharmony_ci#define IC_CONF_KEY_COLOR_EN 0x20000000 828c2ecf20Sopenharmony_ci#define IC_CONF_RWS_EN 0x40000000 838c2ecf20Sopenharmony_ci#define IC_CONF_CSI_MEM_WR_EN 0x80000000 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define IDMA_CHAN_INVALID 0x000000FF 868c2ecf20Sopenharmony_ci#define IDMA_IC_0 0x00000001 878c2ecf20Sopenharmony_ci#define IDMA_IC_1 0x00000002 888c2ecf20Sopenharmony_ci#define IDMA_IC_2 0x00000004 898c2ecf20Sopenharmony_ci#define IDMA_IC_3 0x00000008 908c2ecf20Sopenharmony_ci#define IDMA_IC_4 0x00000010 918c2ecf20Sopenharmony_ci#define IDMA_IC_5 0x00000020 928c2ecf20Sopenharmony_ci#define IDMA_IC_6 0x00000040 938c2ecf20Sopenharmony_ci#define IDMA_IC_7 0x00000080 948c2ecf20Sopenharmony_ci#define IDMA_IC_8 0x00000100 958c2ecf20Sopenharmony_ci#define IDMA_IC_9 0x00000200 968c2ecf20Sopenharmony_ci#define IDMA_IC_10 0x00000400 978c2ecf20Sopenharmony_ci#define IDMA_IC_11 0x00000800 988c2ecf20Sopenharmony_ci#define IDMA_IC_12 0x00001000 998c2ecf20Sopenharmony_ci#define IDMA_IC_13 0x00002000 1008c2ecf20Sopenharmony_ci#define IDMA_SDC_BG 0x00004000 1018c2ecf20Sopenharmony_ci#define IDMA_SDC_FG 0x00008000 1028c2ecf20Sopenharmony_ci#define IDMA_SDC_MASK 0x00010000 1038c2ecf20Sopenharmony_ci#define IDMA_SDC_PARTIAL 0x00020000 1048c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS1_WR 0x00040000 1058c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS2_WR 0x00080000 1068c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS1_CMD 0x00100000 1078c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS2_CMD 0x00200000 1088c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS1_RD 0x00400000 1098c2ecf20Sopenharmony_ci#define IDMA_ADC_SYS2_RD 0x00800000 1108c2ecf20Sopenharmony_ci#define IDMA_PF_QP 0x01000000 1118c2ecf20Sopenharmony_ci#define IDMA_PF_BSP 0x02000000 1128c2ecf20Sopenharmony_ci#define IDMA_PF_Y_IN 0x04000000 1138c2ecf20Sopenharmony_ci#define IDMA_PF_U_IN 0x08000000 1148c2ecf20Sopenharmony_ci#define IDMA_PF_V_IN 0x10000000 1158c2ecf20Sopenharmony_ci#define IDMA_PF_Y_OUT 0x20000000 1168c2ecf20Sopenharmony_ci#define IDMA_PF_U_OUT 0x40000000 1178c2ecf20Sopenharmony_ci#define IDMA_PF_V_OUT 0x80000000 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define TSTAT_PF_H264_PAUSE 0x00000001 1208c2ecf20Sopenharmony_ci#define TSTAT_CSI2MEM_MASK 0x0000000C 1218c2ecf20Sopenharmony_ci#define TSTAT_CSI2MEM_OFFSET 2 1228c2ecf20Sopenharmony_ci#define TSTAT_VF_MASK 0x00000600 1238c2ecf20Sopenharmony_ci#define TSTAT_VF_OFFSET 9 1248c2ecf20Sopenharmony_ci#define TSTAT_VF_ROT_MASK 0x000C0000 1258c2ecf20Sopenharmony_ci#define TSTAT_VF_ROT_OFFSET 18 1268c2ecf20Sopenharmony_ci#define TSTAT_ENC_MASK 0x00000180 1278c2ecf20Sopenharmony_ci#define TSTAT_ENC_OFFSET 7 1288c2ecf20Sopenharmony_ci#define TSTAT_ENC_ROT_MASK 0x00030000 1298c2ecf20Sopenharmony_ci#define TSTAT_ENC_ROT_OFFSET 16 1308c2ecf20Sopenharmony_ci#define TSTAT_PP_MASK 0x00001800 1318c2ecf20Sopenharmony_ci#define TSTAT_PP_OFFSET 11 1328c2ecf20Sopenharmony_ci#define TSTAT_PP_ROT_MASK 0x00300000 1338c2ecf20Sopenharmony_ci#define TSTAT_PP_ROT_OFFSET 20 1348c2ecf20Sopenharmony_ci#define TSTAT_PF_MASK 0x00C00000 1358c2ecf20Sopenharmony_ci#define TSTAT_PF_OFFSET 22 1368c2ecf20Sopenharmony_ci#define TSTAT_ADCSYS1_MASK 0x03000000 1378c2ecf20Sopenharmony_ci#define TSTAT_ADCSYS1_OFFSET 24 1388c2ecf20Sopenharmony_ci#define TSTAT_ADCSYS2_MASK 0x0C000000 1398c2ecf20Sopenharmony_ci#define TSTAT_ADCSYS2_OFFSET 26 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci#define TASK_STAT_IDLE 0 1428c2ecf20Sopenharmony_ci#define TASK_STAT_ACTIVE 1 1438c2ecf20Sopenharmony_ci#define TASK_STAT_WAIT4READY 2 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistruct idmac { 1468c2ecf20Sopenharmony_ci struct dma_device dma; 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct ipu { 1508c2ecf20Sopenharmony_ci void __iomem *reg_ipu; 1518c2ecf20Sopenharmony_ci void __iomem *reg_ic; 1528c2ecf20Sopenharmony_ci unsigned int irq_fn; /* IPU Function IRQ to the CPU */ 1538c2ecf20Sopenharmony_ci unsigned int irq_err; /* IPU Error IRQ to the CPU */ 1548c2ecf20Sopenharmony_ci unsigned int irq_base; /* Beginning of the IPU IRQ range */ 1558c2ecf20Sopenharmony_ci unsigned long channel_init_mask; 1568c2ecf20Sopenharmony_ci spinlock_t lock; 1578c2ecf20Sopenharmony_ci struct clk *ipu_clk; 1588c2ecf20Sopenharmony_ci struct device *dev; 1598c2ecf20Sopenharmony_ci struct idmac idmac; 1608c2ecf20Sopenharmony_ci struct idmac_channel channel[IPU_CHANNELS_NUM]; 1618c2ecf20Sopenharmony_ci struct tasklet_struct tasklet; 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define to_idmac(d) container_of(d, struct idmac, dma) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ciextern int ipu_irq_attach_irq(struct ipu *ipu, struct platform_device *dev); 1678c2ecf20Sopenharmony_ciextern void ipu_irq_detach_irq(struct ipu *ipu, struct platform_device *dev); 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ciextern bool ipu_irq_status(uint32_t irq); 1708c2ecf20Sopenharmony_ciextern int ipu_irq_map(unsigned int source); 1718c2ecf20Sopenharmony_ciextern int ipu_irq_unmap(unsigned int source); 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci#endif 174