18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Parts of this file were based on sources as follows: 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (c) 2006-2008 Intel Corporation 98c2ecf20Sopenharmony_ci * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> 108c2ecf20Sopenharmony_ci * Copyright (C) 2011 Texas Instruments 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef _PL111_DRM_H_ 148c2ecf20Sopenharmony_ci#define _PL111_DRM_H_ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 178c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include <drm/drm_bridge.h> 208c2ecf20Sopenharmony_ci#include <drm/drm_connector.h> 218c2ecf20Sopenharmony_ci#include <drm/drm_encoder.h> 228c2ecf20Sopenharmony_ci#include <drm/drm_gem.h> 238c2ecf20Sopenharmony_ci#include <drm/drm_panel.h> 248c2ecf20Sopenharmony_ci#include <drm/drm_simple_kms_helper.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * CLCD Controller Internal Register addresses 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define CLCD_TIM0 0x00000000 308c2ecf20Sopenharmony_ci#define CLCD_TIM1 0x00000004 318c2ecf20Sopenharmony_ci#define CLCD_TIM2 0x00000008 328c2ecf20Sopenharmony_ci#define CLCD_TIM3 0x0000000c 338c2ecf20Sopenharmony_ci#define CLCD_UBAS 0x00000010 348c2ecf20Sopenharmony_ci#define CLCD_LBAS 0x00000014 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define CLCD_PL110_IENB 0x00000018 378c2ecf20Sopenharmony_ci#define CLCD_PL110_CNTL 0x0000001c 388c2ecf20Sopenharmony_ci#define CLCD_PL110_STAT 0x00000020 398c2ecf20Sopenharmony_ci#define CLCD_PL110_INTR 0x00000024 408c2ecf20Sopenharmony_ci#define CLCD_PL110_UCUR 0x00000028 418c2ecf20Sopenharmony_ci#define CLCD_PL110_LCUR 0x0000002C 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define CLCD_PL111_CNTL 0x00000018 448c2ecf20Sopenharmony_ci#define CLCD_PL111_IENB 0x0000001c 458c2ecf20Sopenharmony_ci#define CLCD_PL111_RIS 0x00000020 468c2ecf20Sopenharmony_ci#define CLCD_PL111_MIS 0x00000024 478c2ecf20Sopenharmony_ci#define CLCD_PL111_ICR 0x00000028 488c2ecf20Sopenharmony_ci#define CLCD_PL111_UCUR 0x0000002c 498c2ecf20Sopenharmony_ci#define CLCD_PL111_LCUR 0x00000030 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define CLCD_PALL 0x00000200 528c2ecf20Sopenharmony_ci#define CLCD_PALETTE 0x00000200 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define TIM2_PCD_LO_MASK GENMASK(4, 0) 558c2ecf20Sopenharmony_ci#define TIM2_PCD_LO_BITS 5 568c2ecf20Sopenharmony_ci#define TIM2_CLKSEL (1 << 5) 578c2ecf20Sopenharmony_ci#define TIM2_ACB_MASK GENMASK(10, 6) 588c2ecf20Sopenharmony_ci#define TIM2_IVS (1 << 11) 598c2ecf20Sopenharmony_ci#define TIM2_IHS (1 << 12) 608c2ecf20Sopenharmony_ci#define TIM2_IPC (1 << 13) 618c2ecf20Sopenharmony_ci#define TIM2_IOE (1 << 14) 628c2ecf20Sopenharmony_ci#define TIM2_BCD (1 << 26) 638c2ecf20Sopenharmony_ci#define TIM2_PCD_HI_MASK GENMASK(31, 27) 648c2ecf20Sopenharmony_ci#define TIM2_PCD_HI_BITS 5 658c2ecf20Sopenharmony_ci#define TIM2_PCD_HI_SHIFT 27 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define CNTL_LCDEN (1 << 0) 688c2ecf20Sopenharmony_ci#define CNTL_LCDBPP1 (0 << 1) 698c2ecf20Sopenharmony_ci#define CNTL_LCDBPP2 (1 << 1) 708c2ecf20Sopenharmony_ci#define CNTL_LCDBPP4 (2 << 1) 718c2ecf20Sopenharmony_ci#define CNTL_LCDBPP8 (3 << 1) 728c2ecf20Sopenharmony_ci#define CNTL_LCDBPP16 (4 << 1) 738c2ecf20Sopenharmony_ci#define CNTL_LCDBPP16_565 (6 << 1) 748c2ecf20Sopenharmony_ci#define CNTL_LCDBPP16_444 (7 << 1) 758c2ecf20Sopenharmony_ci#define CNTL_LCDBPP24 (5 << 1) 768c2ecf20Sopenharmony_ci#define CNTL_LCDBW (1 << 4) 778c2ecf20Sopenharmony_ci#define CNTL_LCDTFT (1 << 5) 788c2ecf20Sopenharmony_ci#define CNTL_LCDMONO8 (1 << 6) 798c2ecf20Sopenharmony_ci#define CNTL_LCDDUAL (1 << 7) 808c2ecf20Sopenharmony_ci#define CNTL_BGR (1 << 8) 818c2ecf20Sopenharmony_ci#define CNTL_BEBO (1 << 9) 828c2ecf20Sopenharmony_ci#define CNTL_BEPO (1 << 10) 838c2ecf20Sopenharmony_ci#define CNTL_LCDPWR (1 << 11) 848c2ecf20Sopenharmony_ci#define CNTL_LCDVCOMP(x) ((x) << 12) 858c2ecf20Sopenharmony_ci#define CNTL_LDMAFIFOTIME (1 << 15) 868c2ecf20Sopenharmony_ci#define CNTL_WATERMARK (1 << 16) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* ST Microelectronics variant bits */ 898c2ecf20Sopenharmony_ci#define CNTL_ST_1XBPP_444 0x0 908c2ecf20Sopenharmony_ci#define CNTL_ST_1XBPP_5551 (1 << 17) 918c2ecf20Sopenharmony_ci#define CNTL_ST_1XBPP_565 (1 << 18) 928c2ecf20Sopenharmony_ci#define CNTL_ST_CDWID_12 0x0 938c2ecf20Sopenharmony_ci#define CNTL_ST_CDWID_16 (1 << 19) 948c2ecf20Sopenharmony_ci#define CNTL_ST_CDWID_18 (1 << 20) 958c2ecf20Sopenharmony_ci#define CNTL_ST_CDWID_24 ((1 << 19) | (1 << 20)) 968c2ecf20Sopenharmony_ci#define CNTL_ST_CEAEN (1 << 21) 978c2ecf20Sopenharmony_ci#define CNTL_ST_LCDBPP24_PACKED (6 << 1) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define CLCD_IRQ_NEXTBASE_UPDATE BIT(2) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistruct drm_minor; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/** 1048c2ecf20Sopenharmony_ci * struct pl111_variant_data - encodes IP differences 1058c2ecf20Sopenharmony_ci * @name: the name of this variant 1068c2ecf20Sopenharmony_ci * @is_pl110: this is the early PL110 variant 1078c2ecf20Sopenharmony_ci * @is_lcdc: this is the ST Microelectronics Nomadik LCDC variant 1088c2ecf20Sopenharmony_ci * @external_bgr: this is the Versatile Pl110 variant with external 1098c2ecf20Sopenharmony_ci * BGR/RGB routing 1108c2ecf20Sopenharmony_ci * @broken_clockdivider: the clock divider is broken and we need to 1118c2ecf20Sopenharmony_ci * use the supplied clock directly 1128c2ecf20Sopenharmony_ci * @broken_vblank: the vblank IRQ is broken on this variant 1138c2ecf20Sopenharmony_ci * @st_bitmux_control: this variant is using the ST Micro bitmux 1148c2ecf20Sopenharmony_ci * extensions to the control register 1158c2ecf20Sopenharmony_ci * @formats: array of supported pixel formats on this variant 1168c2ecf20Sopenharmony_ci * @nformats: the length of the array of supported pixel formats 1178c2ecf20Sopenharmony_ci * @fb_bpp: desired bits per pixel on the default framebuffer 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_cistruct pl111_variant_data { 1208c2ecf20Sopenharmony_ci const char *name; 1218c2ecf20Sopenharmony_ci bool is_pl110; 1228c2ecf20Sopenharmony_ci bool is_lcdc; 1238c2ecf20Sopenharmony_ci bool external_bgr; 1248c2ecf20Sopenharmony_ci bool broken_clockdivider; 1258c2ecf20Sopenharmony_ci bool broken_vblank; 1268c2ecf20Sopenharmony_ci bool st_bitmux_control; 1278c2ecf20Sopenharmony_ci const u32 *formats; 1288c2ecf20Sopenharmony_ci unsigned int nformats; 1298c2ecf20Sopenharmony_ci unsigned int fb_bpp; 1308c2ecf20Sopenharmony_ci}; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistruct pl111_drm_dev_private { 1338c2ecf20Sopenharmony_ci struct drm_device *drm; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci struct drm_connector *connector; 1368c2ecf20Sopenharmony_ci struct drm_panel *panel; 1378c2ecf20Sopenharmony_ci struct drm_bridge *bridge; 1388c2ecf20Sopenharmony_ci struct drm_simple_display_pipe pipe; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci void *regs; 1418c2ecf20Sopenharmony_ci u32 memory_bw; 1428c2ecf20Sopenharmony_ci u32 ienb; 1438c2ecf20Sopenharmony_ci u32 ctrl; 1448c2ecf20Sopenharmony_ci /* The pixel clock (a reference to our clock divider off of CLCDCLK). */ 1458c2ecf20Sopenharmony_ci struct clk *clk; 1468c2ecf20Sopenharmony_ci /* pl111's internal clock divider. */ 1478c2ecf20Sopenharmony_ci struct clk_hw clk_div; 1488c2ecf20Sopenharmony_ci /* Lock to sync access to CLCD_TIM2 between the common clock 1498c2ecf20Sopenharmony_ci * subsystem and pl111_display_enable(). 1508c2ecf20Sopenharmony_ci */ 1518c2ecf20Sopenharmony_ci spinlock_t tim2_lock; 1528c2ecf20Sopenharmony_ci const struct pl111_variant_data *variant; 1538c2ecf20Sopenharmony_ci void (*variant_display_enable) (struct drm_device *drm, u32 format); 1548c2ecf20Sopenharmony_ci void (*variant_display_disable) (struct drm_device *drm); 1558c2ecf20Sopenharmony_ci bool use_device_memory; 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ciint pl111_display_init(struct drm_device *dev); 1598c2ecf20Sopenharmony_ciirqreturn_t pl111_irq(int irq, void *data); 1608c2ecf20Sopenharmony_civoid pl111_debugfs_init(struct drm_minor *minor); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#endif /* _PL111_DRM_H_ */ 163