1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2012 Russell King 4 */ 5 #ifndef ARMADA_DRM_H 6 #define ARMADA_DRM_H 7 8 #include <linux/kfifo.h> 9 #include <linux/io.h> 10 #include <linux/workqueue.h> 11 #include <drm/drmP.h> 12 13 struct armada_crtc; 14 struct armada_gem_object; 15 struct clk; 16 struct drm_fb_helper; 17 18 static inline void 19 armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr) 20 { 21 uint32_t ov, v; 22 23 ov = v = readl_relaxed(ptr); 24 v = (v & ~mask) | val; 25 if (ov != v) 26 writel_relaxed(v, ptr); 27 } 28 29 static inline uint32_t armada_pitch(uint32_t width, uint32_t bpp) 30 { 31 uint32_t pitch = bpp != 4 ? width * ((bpp + 7) / 8) : width / 2; 32 33 /* 88AP510 spec recommends pitch be a multiple of 128 */ 34 return ALIGN(pitch, 128); 35 } 36 37 38 struct armada_private; 39 40 struct armada_variant { 41 bool has_spu_adv_reg; 42 int (*init)(struct armada_crtc *, struct device *); 43 int (*compute_clock)(struct armada_crtc *, 44 const struct drm_display_mode *, 45 uint32_t *); 46 void (*disable)(struct armada_crtc *); 47 void (*enable)(struct armada_crtc *, const struct drm_display_mode *); 48 }; 49 50 /* Variant ops */ 51 extern const struct armada_variant armada510_ops; 52 53 struct armada_private { 54 struct drm_device drm; 55 struct drm_fb_helper *fbdev; 56 struct armada_crtc *dcrtc[2]; 57 struct drm_mm linear; /* protected by linear_lock */ 58 struct mutex linear_lock; 59 struct drm_property *colorkey_prop; 60 struct drm_property *colorkey_min_prop; 61 struct drm_property *colorkey_max_prop; 62 struct drm_property *colorkey_val_prop; 63 struct drm_property *colorkey_alpha_prop; 64 struct drm_property *colorkey_mode_prop; 65 struct drm_property *brightness_prop; 66 struct drm_property *contrast_prop; 67 struct drm_property *saturation_prop; 68 #ifdef CONFIG_DEBUG_FS 69 struct dentry *de; 70 #endif 71 }; 72 73 int armada_fbdev_init(struct drm_device *); 74 void armada_fbdev_fini(struct drm_device *); 75 76 int armada_overlay_plane_create(struct drm_device *, unsigned long); 77 78 int armada_drm_debugfs_init(struct drm_minor *); 79 80 #endif 81