1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * 4 * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved. 5 * 6 * Parts of this file were based on sources as follows: 7 * 8 * Copyright (c) 2006-2008 Intel Corporation 9 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> 10 * Copyright (C) 2011 Texas Instruments 11 */ 12 13 #ifndef _PL111_DRM_H_ 14 #define _PL111_DRM_H_ 15 16 #include <linux/clk-provider.h> 17 #include <linux/interrupt.h> 18 19 #include <drm/drm_bridge.h> 20 #include <drm/drm_connector.h> 21 #include <drm/drm_encoder.h> 22 #include <drm/drm_gem.h> 23 #include <drm/drm_panel.h> 24 25 /* 26 * CLCD Controller Internal Register addresses 27 */ 28 #define CLCD_TIM0 0x00000000 29 #define CLCD_TIM1 0x00000004 30 #define CLCD_TIM2 0x00000008 31 #define CLCD_TIM3 0x0000000c 32 #define CLCD_UBAS 0x00000010 33 #define CLCD_LBAS 0x00000014 34 35 #define CLCD_PL110_IENB 0x00000018 36 #define CLCD_PL110_CNTL 0x0000001c 37 #define CLCD_PL110_STAT 0x00000020 38 #define CLCD_PL110_INTR 0x00000024 39 #define CLCD_PL110_UCUR 0x00000028 40 #define CLCD_PL110_LCUR 0x0000002C 41 42 #define CLCD_PL111_CNTL 0x00000018 43 #define CLCD_PL111_IENB 0x0000001c 44 #define CLCD_PL111_RIS 0x00000020 45 #define CLCD_PL111_MIS 0x00000024 46 #define CLCD_PL111_ICR 0x00000028 47 #define CLCD_PL111_UCUR 0x0000002c 48 #define CLCD_PL111_LCUR 0x00000030 49 50 #define CLCD_PALL 0x00000200 51 #define CLCD_PALETTE 0x00000200 52 53 #define TIM2_PCD_LO_MASK GENMASK(4, 0) 54 #define TIM2_PCD_LO_BITS 5 55 #define TIM2_CLKSEL (1 << 5) 56 #define TIM2_ACB_MASK GENMASK(10, 6) 57 #define TIM2_IVS (1 << 11) 58 #define TIM2_IHS (1 << 12) 59 #define TIM2_IPC (1 << 13) 60 #define TIM2_IOE (1 << 14) 61 #define TIM2_BCD (1 << 26) 62 #define TIM2_PCD_HI_MASK GENMASK(31, 27) 63 #define TIM2_PCD_HI_BITS 5 64 #define TIM2_PCD_HI_SHIFT 27 65 66 #define CNTL_LCDEN (1 << 0) 67 #define CNTL_LCDBPP1 (0 << 1) 68 #define CNTL_LCDBPP2 (1 << 1) 69 #define CNTL_LCDBPP4 (2 << 1) 70 #define CNTL_LCDBPP8 (3 << 1) 71 #define CNTL_LCDBPP16 (4 << 1) 72 #define CNTL_LCDBPP16_565 (6 << 1) 73 #define CNTL_LCDBPP16_444 (7 << 1) 74 #define CNTL_LCDBPP24 (5 << 1) 75 #define CNTL_LCDBW (1 << 4) 76 #define CNTL_LCDTFT (1 << 5) 77 #define CNTL_LCDMONO8 (1 << 6) 78 #define CNTL_LCDDUAL (1 << 7) 79 #define CNTL_BGR (1 << 8) 80 #define CNTL_BEBO (1 << 9) 81 #define CNTL_BEPO (1 << 10) 82 #define CNTL_LCDPWR (1 << 11) 83 #define CNTL_LCDVCOMP(x) ((x) << 12) 84 #define CNTL_LDMAFIFOTIME (1 << 15) 85 #define CNTL_WATERMARK (1 << 16) 86 87 /* ST Microelectronics variant bits */ 88 #define CNTL_ST_1XBPP_444 0x0 89 #define CNTL_ST_1XBPP_5551 (1 << 17) 90 #define CNTL_ST_1XBPP_565 (1 << 18) 91 #define CNTL_ST_CDWID_12 0x0 92 #define CNTL_ST_CDWID_16 (1 << 19) 93 #define CNTL_ST_CDWID_18 (1 << 20) 94 #define CNTL_ST_CDWID_24 ((1 << 19) | (1 << 20)) 95 #define CNTL_ST_CEAEN (1 << 21) 96 #define CNTL_ST_LCDBPP24_PACKED (6 << 1) 97 98 #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2) 99 100 struct drm_minor; 101 102 /** 103 * struct pl111_variant_data - encodes IP differences 104 * @name: the name of this variant 105 * @is_pl110: this is the early PL110 variant 106 * @is_lcdc: this is the ST Microelectronics Nomadik LCDC variant 107 * @external_bgr: this is the Versatile Pl110 variant with external 108 * BGR/RGB routing 109 * @broken_clockdivider: the clock divider is broken and we need to 110 * use the supplied clock directly 111 * @broken_vblank: the vblank IRQ is broken on this variant 112 * @st_bitmux_control: this variant is using the ST Micro bitmux 113 * extensions to the control register 114 * @formats: array of supported pixel formats on this variant 115 * @nformats: the length of the array of supported pixel formats 116 * @fb_depth: desired depth per pixel on the default framebuffer 117 */ 118 struct pl111_variant_data { 119 const char *name; 120 bool is_pl110; 121 bool is_lcdc; 122 bool external_bgr; 123 bool broken_clockdivider; 124 bool broken_vblank; 125 bool st_bitmux_control; 126 const u32 *formats; 127 unsigned int nformats; 128 unsigned int fb_depth; 129 }; 130 131 struct pl111_drm_dev_private { 132 struct drm_device *drm; 133 134 struct drm_connector *connector; 135 struct drm_panel *panel; 136 struct drm_bridge *bridge; 137 struct drm_plane plane; 138 struct drm_crtc crtc; 139 struct drm_encoder encoder; 140 141 void *regs; 142 u32 memory_bw; 143 u32 ienb; 144 u32 ctrl; 145 /* The pixel clock (a reference to our clock divider off of CLCDCLK). */ 146 struct clk *clk; 147 /* pl111's internal clock divider. */ 148 struct clk_hw clk_div; 149 /* Lock to sync access to CLCD_TIM2 between the common clock 150 * subsystem and pl111_display_enable(). 151 */ 152 spinlock_t tim2_lock; 153 const struct pl111_variant_data *variant; 154 void (*variant_display_enable) (struct drm_device *drm, u32 format); 155 void (*variant_display_disable) (struct drm_device *drm); 156 bool use_device_memory; 157 }; 158 159 int pl111_display_init(struct drm_device *dev); 160 irqreturn_t pl111_irq(int irq, void *data); 161 void pl111_debugfs_init(struct drm_minor *minor); 162 163 #endif /* _PL111_DRM_H_ */ 164