162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/ 462306a36Sopenharmony_ci * Author: Rob Clark <rob@ti.com> 562306a36Sopenharmony_ci * Andy Gross <andy.gross@ti.com> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef OMAP_DMM_TILER_H 862306a36Sopenharmony_ci#define OMAP_DMM_TILER_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "omap_drv.h" 1162306a36Sopenharmony_ci#include "tcm.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cienum tiler_fmt { 1462306a36Sopenharmony_ci TILFMT_8BIT = 0, 1562306a36Sopenharmony_ci TILFMT_16BIT, 1662306a36Sopenharmony_ci TILFMT_32BIT, 1762306a36Sopenharmony_ci TILFMT_PAGE, 1862306a36Sopenharmony_ci TILFMT_NFORMATS 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistruct pat_area { 2262306a36Sopenharmony_ci u32 x0:8; 2362306a36Sopenharmony_ci u32 y0:8; 2462306a36Sopenharmony_ci u32 x1:8; 2562306a36Sopenharmony_ci u32 y1:8; 2662306a36Sopenharmony_ci}; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistruct tiler_block { 2962306a36Sopenharmony_ci struct list_head alloc_node; /* node for global block list */ 3062306a36Sopenharmony_ci struct tcm_area area; /* area */ 3162306a36Sopenharmony_ci enum tiler_fmt fmt; /* format */ 3262306a36Sopenharmony_ci}; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* bits representing the same slot in DMM-TILER hw-block */ 3562306a36Sopenharmony_ci#define SLOT_WIDTH_BITS 6 3662306a36Sopenharmony_ci#define SLOT_HEIGHT_BITS 6 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* bits reserved to describe coordinates in DMM-TILER hw-block */ 3962306a36Sopenharmony_ci#define CONT_WIDTH_BITS 14 4062306a36Sopenharmony_ci#define CONT_HEIGHT_BITS 13 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* calculated constants */ 4362306a36Sopenharmony_ci#define TILER_PAGE (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS)) 4462306a36Sopenharmony_ci#define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS)) 4562306a36Sopenharmony_ci#define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS)) 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* 4862306a36Sopenharmony_ciTable 15-11. Coding and Description of TILER Orientations 4962306a36Sopenharmony_ciS Y X Description Alternate description 5062306a36Sopenharmony_ci0 0 0 0-degree view Natural view 5162306a36Sopenharmony_ci0 0 1 0-degree view with vertical mirror 180-degree view with horizontal mirror 5262306a36Sopenharmony_ci0 1 0 0-degree view with horizontal mirror 180-degree view with vertical mirror 5362306a36Sopenharmony_ci0 1 1 180-degree view 5462306a36Sopenharmony_ci1 0 0 90-degree view with vertical mirror 270-degree view with horizontal mirror 5562306a36Sopenharmony_ci1 0 1 270-degree view 5662306a36Sopenharmony_ci1 1 0 90-degree view 5762306a36Sopenharmony_ci1 1 1 90-degree view with horizontal mirror 270-degree view with vertical mirror 5862306a36Sopenharmony_ci */ 5962306a36Sopenharmony_ci#define MASK_XY_FLIP (1 << 31) 6062306a36Sopenharmony_ci#define MASK_Y_INVERT (1 << 30) 6162306a36Sopenharmony_ci#define MASK_X_INVERT (1 << 29) 6262306a36Sopenharmony_ci#define SHIFT_ACC_MODE 27 6362306a36Sopenharmony_ci#define MASK_ACC_MODE 3 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define MASK(bits) ((1 << (bits)) - 1) 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define TILVIEW_8BIT 0x60000000u 6862306a36Sopenharmony_ci#define TILVIEW_16BIT (TILVIEW_8BIT + VIEW_SIZE) 6962306a36Sopenharmony_ci#define TILVIEW_32BIT (TILVIEW_16BIT + VIEW_SIZE) 7062306a36Sopenharmony_ci#define TILVIEW_PAGE (TILVIEW_32BIT + VIEW_SIZE) 7162306a36Sopenharmony_ci#define TILVIEW_END (TILVIEW_PAGE + VIEW_SIZE) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* create tsptr by adding view orientation and access mode */ 7462306a36Sopenharmony_ci#define TIL_ADDR(x, orient, a)\ 7562306a36Sopenharmony_ci ((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE)) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 7862306a36Sopenharmony_ciint tiler_map_show(struct seq_file *s, void *arg); 7962306a36Sopenharmony_ci#endif 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* pin/unpin */ 8262306a36Sopenharmony_ciint tiler_pin(struct tiler_block *block, struct page **pages, 8362306a36Sopenharmony_ci u32 npages, u32 roll, bool wait); 8462306a36Sopenharmony_ciint tiler_unpin(struct tiler_block *block); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* reserve/release */ 8762306a36Sopenharmony_cistruct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h, 8862306a36Sopenharmony_ci u16 align); 8962306a36Sopenharmony_cistruct tiler_block *tiler_reserve_1d(size_t size); 9062306a36Sopenharmony_ciint tiler_release(struct tiler_block *block); 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* utilities */ 9362306a36Sopenharmony_cidma_addr_t tiler_ssptr(struct tiler_block *block); 9462306a36Sopenharmony_cidma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient, 9562306a36Sopenharmony_ci u32 x, u32 y); 9662306a36Sopenharmony_ciu32 tiler_stride(enum tiler_fmt fmt, u32 orient); 9762306a36Sopenharmony_cisize_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h); 9862306a36Sopenharmony_cisize_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h); 9962306a36Sopenharmony_civoid tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h); 10062306a36Sopenharmony_ciu32 tiler_get_cpu_cache_flags(void); 10162306a36Sopenharmony_cibool dmm_is_available(void); 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciextern struct platform_driver omap_dmm_driver; 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* GEM bo flags -> tiler fmt */ 10662306a36Sopenharmony_cistatic inline enum tiler_fmt gem2fmt(u32 flags) 10762306a36Sopenharmony_ci{ 10862306a36Sopenharmony_ci switch (flags & OMAP_BO_TILED_MASK) { 10962306a36Sopenharmony_ci case OMAP_BO_TILED_8: 11062306a36Sopenharmony_ci return TILFMT_8BIT; 11162306a36Sopenharmony_ci case OMAP_BO_TILED_16: 11262306a36Sopenharmony_ci return TILFMT_16BIT; 11362306a36Sopenharmony_ci case OMAP_BO_TILED_32: 11462306a36Sopenharmony_ci return TILFMT_32BIT; 11562306a36Sopenharmony_ci default: 11662306a36Sopenharmony_ci return TILFMT_PAGE; 11762306a36Sopenharmony_ci } 11862306a36Sopenharmony_ci} 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistatic inline bool validfmt(enum tiler_fmt fmt) 12162306a36Sopenharmony_ci{ 12262306a36Sopenharmony_ci switch (fmt) { 12362306a36Sopenharmony_ci case TILFMT_8BIT: 12462306a36Sopenharmony_ci case TILFMT_16BIT: 12562306a36Sopenharmony_ci case TILFMT_32BIT: 12662306a36Sopenharmony_ci case TILFMT_PAGE: 12762306a36Sopenharmony_ci return true; 12862306a36Sopenharmony_ci default: 12962306a36Sopenharmony_ci return false; 13062306a36Sopenharmony_ci } 13162306a36Sopenharmony_ci} 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci#endif 134