1*16ea975eSRob Clark /* 2*16ea975eSRob Clark * Copyright (C) 2012 Texas Instruments 3*16ea975eSRob Clark * Author: Rob Clark <robdclark@gmail.com> 4*16ea975eSRob Clark * 5*16ea975eSRob Clark * This program is free software; you can redistribute it and/or modify it 6*16ea975eSRob Clark * under the terms of the GNU General Public License version 2 as published by 7*16ea975eSRob Clark * the Free Software Foundation. 8*16ea975eSRob Clark * 9*16ea975eSRob Clark * This program is distributed in the hope that it will be useful, but WITHOUT 10*16ea975eSRob Clark * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11*16ea975eSRob Clark * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12*16ea975eSRob Clark * more details. 13*16ea975eSRob Clark * 14*16ea975eSRob Clark * You should have received a copy of the GNU General Public License along with 15*16ea975eSRob Clark * this program. If not, see <http://www.gnu.org/licenses/>. 16*16ea975eSRob Clark */ 17*16ea975eSRob Clark 18*16ea975eSRob Clark #ifndef __TILCDC_REGS_H__ 19*16ea975eSRob Clark #define __TILCDC_REGS_H__ 20*16ea975eSRob Clark 21*16ea975eSRob Clark /* LCDC register definitions, based on da8xx-fb */ 22*16ea975eSRob Clark 23*16ea975eSRob Clark #include <linux/bitops.h> 24*16ea975eSRob Clark 25*16ea975eSRob Clark #include "tilcdc_drv.h" 26*16ea975eSRob Clark 27*16ea975eSRob Clark /* LCDC Status Register */ 28*16ea975eSRob Clark #define LCDC_END_OF_FRAME1 BIT(9) 29*16ea975eSRob Clark #define LCDC_END_OF_FRAME0 BIT(8) 30*16ea975eSRob Clark #define LCDC_PL_LOAD_DONE BIT(6) 31*16ea975eSRob Clark #define LCDC_FIFO_UNDERFLOW BIT(5) 32*16ea975eSRob Clark #define LCDC_SYNC_LOST BIT(2) 33*16ea975eSRob Clark #define LCDC_FRAME_DONE BIT(0) 34*16ea975eSRob Clark 35*16ea975eSRob Clark /* LCDC DMA Control Register */ 36*16ea975eSRob Clark #define LCDC_DMA_BURST_SIZE(x) ((x) << 4) 37*16ea975eSRob Clark #define LCDC_DMA_BURST_1 0x0 38*16ea975eSRob Clark #define LCDC_DMA_BURST_2 0x1 39*16ea975eSRob Clark #define LCDC_DMA_BURST_4 0x2 40*16ea975eSRob Clark #define LCDC_DMA_BURST_8 0x3 41*16ea975eSRob Clark #define LCDC_DMA_BURST_16 0x4 42*16ea975eSRob Clark #define LCDC_V1_END_OF_FRAME_INT_ENA BIT(2) 43*16ea975eSRob Clark #define LCDC_V2_END_OF_FRAME0_INT_ENA BIT(8) 44*16ea975eSRob Clark #define LCDC_V2_END_OF_FRAME1_INT_ENA BIT(9) 45*16ea975eSRob Clark #define LCDC_DUAL_FRAME_BUFFER_ENABLE BIT(0) 46*16ea975eSRob Clark 47*16ea975eSRob Clark /* LCDC Control Register */ 48*16ea975eSRob Clark #define LCDC_CLK_DIVISOR(x) ((x) << 8) 49*16ea975eSRob Clark #define LCDC_RASTER_MODE 0x01 50*16ea975eSRob Clark 51*16ea975eSRob Clark /* LCDC Raster Control Register */ 52*16ea975eSRob Clark #define LCDC_PALETTE_LOAD_MODE(x) ((x) << 20) 53*16ea975eSRob Clark #define PALETTE_AND_DATA 0x00 54*16ea975eSRob Clark #define PALETTE_ONLY 0x01 55*16ea975eSRob Clark #define DATA_ONLY 0x02 56*16ea975eSRob Clark 57*16ea975eSRob Clark #define LCDC_MONO_8BIT_MODE BIT(9) 58*16ea975eSRob Clark #define LCDC_RASTER_ORDER BIT(8) 59*16ea975eSRob Clark #define LCDC_TFT_MODE BIT(7) 60*16ea975eSRob Clark #define LCDC_V1_UNDERFLOW_INT_ENA BIT(6) 61*16ea975eSRob Clark #define LCDC_V2_UNDERFLOW_INT_ENA BIT(5) 62*16ea975eSRob Clark #define LCDC_V1_PL_INT_ENA BIT(4) 63*16ea975eSRob Clark #define LCDC_V2_PL_INT_ENA BIT(6) 64*16ea975eSRob Clark #define LCDC_MONOCHROME_MODE BIT(1) 65*16ea975eSRob Clark #define LCDC_RASTER_ENABLE BIT(0) 66*16ea975eSRob Clark #define LCDC_TFT_ALT_ENABLE BIT(23) 67*16ea975eSRob Clark #define LCDC_STN_565_ENABLE BIT(24) 68*16ea975eSRob Clark #define LCDC_V2_DMA_CLK_EN BIT(2) 69*16ea975eSRob Clark #define LCDC_V2_LIDD_CLK_EN BIT(1) 70*16ea975eSRob Clark #define LCDC_V2_CORE_CLK_EN BIT(0) 71*16ea975eSRob Clark #define LCDC_V2_LPP_B10 26 72*16ea975eSRob Clark #define LCDC_V2_TFT_24BPP_MODE BIT(25) 73*16ea975eSRob Clark #define LCDC_V2_TFT_24BPP_UNPACK BIT(26) 74*16ea975eSRob Clark 75*16ea975eSRob Clark /* LCDC Raster Timing 2 Register */ 76*16ea975eSRob Clark #define LCDC_AC_BIAS_TRANSITIONS_PER_INT(x) ((x) << 16) 77*16ea975eSRob Clark #define LCDC_AC_BIAS_FREQUENCY(x) ((x) << 8) 78*16ea975eSRob Clark #define LCDC_SYNC_CTRL BIT(25) 79*16ea975eSRob Clark #define LCDC_SYNC_EDGE BIT(24) 80*16ea975eSRob Clark #define LCDC_INVERT_PIXEL_CLOCK BIT(22) 81*16ea975eSRob Clark #define LCDC_INVERT_HSYNC BIT(21) 82*16ea975eSRob Clark #define LCDC_INVERT_VSYNC BIT(20) 83*16ea975eSRob Clark 84*16ea975eSRob Clark /* LCDC Block */ 85*16ea975eSRob Clark #define LCDC_PID_REG 0x0 86*16ea975eSRob Clark #define LCDC_CTRL_REG 0x4 87*16ea975eSRob Clark #define LCDC_STAT_REG 0x8 88*16ea975eSRob Clark #define LCDC_RASTER_CTRL_REG 0x28 89*16ea975eSRob Clark #define LCDC_RASTER_TIMING_0_REG 0x2c 90*16ea975eSRob Clark #define LCDC_RASTER_TIMING_1_REG 0x30 91*16ea975eSRob Clark #define LCDC_RASTER_TIMING_2_REG 0x34 92*16ea975eSRob Clark #define LCDC_DMA_CTRL_REG 0x40 93*16ea975eSRob Clark #define LCDC_DMA_FB_BASE_ADDR_0_REG 0x44 94*16ea975eSRob Clark #define LCDC_DMA_FB_CEILING_ADDR_0_REG 0x48 95*16ea975eSRob Clark #define LCDC_DMA_FB_BASE_ADDR_1_REG 0x4c 96*16ea975eSRob Clark #define LCDC_DMA_FB_CEILING_ADDR_1_REG 0x50 97*16ea975eSRob Clark 98*16ea975eSRob Clark /* Interrupt Registers available only in Version 2 */ 99*16ea975eSRob Clark #define LCDC_RAW_STAT_REG 0x58 100*16ea975eSRob Clark #define LCDC_MASKED_STAT_REG 0x5c 101*16ea975eSRob Clark #define LCDC_INT_ENABLE_SET_REG 0x60 102*16ea975eSRob Clark #define LCDC_INT_ENABLE_CLR_REG 0x64 103*16ea975eSRob Clark #define LCDC_END_OF_INT_IND_REG 0x68 104*16ea975eSRob Clark 105*16ea975eSRob Clark /* Clock registers available only on Version 2 */ 106*16ea975eSRob Clark #define LCDC_CLK_ENABLE_REG 0x6c 107*16ea975eSRob Clark #define LCDC_CLK_RESET_REG 0x70 108*16ea975eSRob Clark #define LCDC_CLK_MAIN_RESET BIT(3) 109*16ea975eSRob Clark 110*16ea975eSRob Clark 111*16ea975eSRob Clark /* 112*16ea975eSRob Clark * Helpers: 113*16ea975eSRob Clark */ 114*16ea975eSRob Clark 115*16ea975eSRob Clark static inline void tilcdc_write(struct drm_device *dev, u32 reg, u32 data) 116*16ea975eSRob Clark { 117*16ea975eSRob Clark struct tilcdc_drm_private *priv = dev->dev_private; 118*16ea975eSRob Clark iowrite32(data, priv->mmio + reg); 119*16ea975eSRob Clark } 120*16ea975eSRob Clark 121*16ea975eSRob Clark static inline u32 tilcdc_read(struct drm_device *dev, u32 reg) 122*16ea975eSRob Clark { 123*16ea975eSRob Clark struct tilcdc_drm_private *priv = dev->dev_private; 124*16ea975eSRob Clark return ioread32(priv->mmio + reg); 125*16ea975eSRob Clark } 126*16ea975eSRob Clark 127*16ea975eSRob Clark static inline void tilcdc_set(struct drm_device *dev, u32 reg, u32 mask) 128*16ea975eSRob Clark { 129*16ea975eSRob Clark tilcdc_write(dev, reg, tilcdc_read(dev, reg) | mask); 130*16ea975eSRob Clark } 131*16ea975eSRob Clark 132*16ea975eSRob Clark static inline void tilcdc_clear(struct drm_device *dev, u32 reg, u32 mask) 133*16ea975eSRob Clark { 134*16ea975eSRob Clark tilcdc_write(dev, reg, tilcdc_read(dev, reg) & ~mask); 135*16ea975eSRob Clark } 136*16ea975eSRob Clark 137*16ea975eSRob Clark /* the register to read/clear irqstatus differs between v1 and v2 of the IP */ 138*16ea975eSRob Clark static inline u32 tilcdc_irqstatus_reg(struct drm_device *dev) 139*16ea975eSRob Clark { 140*16ea975eSRob Clark struct tilcdc_drm_private *priv = dev->dev_private; 141*16ea975eSRob Clark return (priv->rev == 2) ? LCDC_MASKED_STAT_REG : LCDC_STAT_REG; 142*16ea975eSRob Clark } 143*16ea975eSRob Clark 144*16ea975eSRob Clark static inline u32 tilcdc_read_irqstatus(struct drm_device *dev) 145*16ea975eSRob Clark { 146*16ea975eSRob Clark return tilcdc_read(dev, tilcdc_irqstatus_reg(dev)); 147*16ea975eSRob Clark } 148*16ea975eSRob Clark 149*16ea975eSRob Clark static inline void tilcdc_clear_irqstatus(struct drm_device *dev, u32 mask) 150*16ea975eSRob Clark { 151*16ea975eSRob Clark tilcdc_write(dev, tilcdc_irqstatus_reg(dev), mask); 152*16ea975eSRob Clark } 153*16ea975eSRob Clark 154*16ea975eSRob Clark #endif /* __TILCDC_REGS_H__ */ 155