| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
|---|
| 3 | 4 | * Copyright (C) 2013 Red Hat |
|---|
| 4 | 5 | * Author: Rob Clark <robdclark@gmail.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 8 | | - * the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - * more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 16 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 6 | */ |
|---|
| 18 | 7 | |
|---|
| 19 | 8 | #ifndef __DPU_KMS_H__ |
|---|
| 20 | 9 | #define __DPU_KMS_H__ |
|---|
| 21 | 10 | |
|---|
| 11 | +#include <linux/interconnect.h> |
|---|
| 12 | + |
|---|
| 13 | +#include <drm/drm_drv.h> |
|---|
| 14 | + |
|---|
| 22 | 15 | #include "msm_drv.h" |
|---|
| 23 | 16 | #include "msm_kms.h" |
|---|
| 24 | 17 | #include "msm_mmu.h" |
|---|
| 25 | 18 | #include "msm_gem.h" |
|---|
| 26 | | -#include "dpu_dbg.h" |
|---|
| 27 | 19 | #include "dpu_hw_catalog.h" |
|---|
| 28 | 20 | #include "dpu_hw_ctl.h" |
|---|
| 29 | 21 | #include "dpu_hw_lm.h" |
|---|
| 30 | 22 | #include "dpu_hw_interrupts.h" |
|---|
| 31 | 23 | #include "dpu_hw_top.h" |
|---|
| 24 | +#include "dpu_io_util.h" |
|---|
| 32 | 25 | #include "dpu_rm.h" |
|---|
| 33 | | -#include "dpu_power_handle.h" |
|---|
| 34 | | -#include "dpu_irq.h" |
|---|
| 35 | 26 | #include "dpu_core_perf.h" |
|---|
| 36 | 27 | |
|---|
| 37 | 28 | #define DRMID(x) ((x) ? (x)->base.id : -1) |
|---|
| .. | .. |
|---|
| 42 | 33 | */ |
|---|
| 43 | 34 | #define DPU_DEBUG(fmt, ...) \ |
|---|
| 44 | 35 | do { \ |
|---|
| 45 | | - if (unlikely(drm_debug & DRM_UT_KMS)) \ |
|---|
| 36 | + if (drm_debug_enabled(DRM_UT_KMS)) \ |
|---|
| 46 | 37 | DRM_DEBUG(fmt, ##__VA_ARGS__); \ |
|---|
| 47 | 38 | else \ |
|---|
| 48 | 39 | pr_debug(fmt, ##__VA_ARGS__); \ |
|---|
| .. | .. |
|---|
| 54 | 45 | */ |
|---|
| 55 | 46 | #define DPU_DEBUG_DRIVER(fmt, ...) \ |
|---|
| 56 | 47 | do { \ |
|---|
| 57 | | - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ |
|---|
| 48 | + if (drm_debug_enabled(DRM_UT_DRIVER)) \ |
|---|
| 58 | 49 | DRM_ERROR(fmt, ##__VA_ARGS__); \ |
|---|
| 59 | 50 | else \ |
|---|
| 60 | 51 | pr_debug(fmt, ##__VA_ARGS__); \ |
|---|
| .. | .. |
|---|
| 74 | 65 | ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0)) |
|---|
| 75 | 66 | |
|---|
| 76 | 67 | #define DPU_NAME_SIZE 12 |
|---|
| 77 | | - |
|---|
| 78 | | -/* timeout in frames waiting for frame done */ |
|---|
| 79 | | -#define DPU_FRAME_DONE_TIMEOUT 60 |
|---|
| 80 | 68 | |
|---|
| 81 | 69 | /* |
|---|
| 82 | 70 | * struct dpu_irq_callback - IRQ callback handlers |
|---|
| .. | .. |
|---|
| 104 | 92 | atomic_t *enable_counts; |
|---|
| 105 | 93 | atomic_t *irq_counts; |
|---|
| 106 | 94 | spinlock_t cb_lock; |
|---|
| 107 | | - struct dentry *debugfs_file; |
|---|
| 108 | 95 | }; |
|---|
| 109 | 96 | |
|---|
| 110 | 97 | struct dpu_kms { |
|---|
| .. | .. |
|---|
| 113 | 100 | int core_rev; |
|---|
| 114 | 101 | struct dpu_mdss_cfg *catalog; |
|---|
| 115 | 102 | |
|---|
| 116 | | - struct dpu_power_handle phandle; |
|---|
| 117 | | - struct dpu_power_client *core_client; |
|---|
| 118 | | - struct dpu_power_event *power_event; |
|---|
| 119 | | - |
|---|
| 120 | | - /* directory entry for debugfs */ |
|---|
| 121 | | - struct dentry *debugfs_root; |
|---|
| 122 | | - struct dentry *debugfs_danger; |
|---|
| 123 | | - struct dentry *debugfs_vbif; |
|---|
| 124 | | - |
|---|
| 125 | 103 | /* io/register spaces: */ |
|---|
| 126 | 104 | void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma; |
|---|
| 127 | | - unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len; |
|---|
| 128 | 105 | |
|---|
| 129 | 106 | struct regulator *vdd; |
|---|
| 130 | 107 | struct regulator *mmagic; |
|---|
| .. | .. |
|---|
| 135 | 112 | |
|---|
| 136 | 113 | struct dpu_core_perf perf; |
|---|
| 137 | 114 | |
|---|
| 138 | | - /* saved atomic state during system suspend */ |
|---|
| 139 | | - struct drm_atomic_state *suspend_state; |
|---|
| 140 | | - bool suspend_block; |
|---|
| 115 | + /* |
|---|
| 116 | + * Global private object state, Do not access directly, use |
|---|
| 117 | + * dpu_kms_global_get_state() |
|---|
| 118 | + */ |
|---|
| 119 | + struct drm_modeset_lock global_state_lock; |
|---|
| 120 | + struct drm_private_obj global_state; |
|---|
| 141 | 121 | |
|---|
| 142 | 122 | struct dpu_rm rm; |
|---|
| 143 | 123 | bool rm_init; |
|---|
| .. | .. |
|---|
| 149 | 129 | |
|---|
| 150 | 130 | struct platform_device *pdev; |
|---|
| 151 | 131 | bool rpm_enabled; |
|---|
| 132 | + |
|---|
| 133 | + struct opp_table *opp_table; |
|---|
| 134 | + bool has_opp_table; |
|---|
| 135 | + |
|---|
| 152 | 136 | struct dss_module_power mp; |
|---|
| 137 | + |
|---|
| 138 | + /* reference count bandwidth requests, so we know when we can |
|---|
| 139 | + * release bandwidth. Each atomic update increments, and frame- |
|---|
| 140 | + * done event decrements. Additionally, for video mode, the |
|---|
| 141 | + * reference is incremented when crtc is enabled, and decremented |
|---|
| 142 | + * when disabled. |
|---|
| 143 | + */ |
|---|
| 144 | + atomic_t bandwidth_ref; |
|---|
| 145 | + struct icc_path *path[2]; |
|---|
| 146 | + u32 num_paths; |
|---|
| 153 | 147 | }; |
|---|
| 154 | 148 | |
|---|
| 155 | 149 | struct vsync_info { |
|---|
| .. | .. |
|---|
| 159 | 153 | |
|---|
| 160 | 154 | #define to_dpu_kms(x) container_of(x, struct dpu_kms, base) |
|---|
| 161 | 155 | |
|---|
| 162 | | -/* get struct msm_kms * from drm_device * */ |
|---|
| 163 | | -#define ddev_to_msm_kms(D) ((D) && (D)->dev_private ? \ |
|---|
| 164 | | - ((struct msm_drm_private *)((D)->dev_private))->kms : NULL) |
|---|
| 156 | +#define to_dpu_global_state(x) container_of(x, struct dpu_global_state, base) |
|---|
| 165 | 157 | |
|---|
| 166 | | -/** |
|---|
| 167 | | - * dpu_kms_is_suspend_state - whether or not the system is pm suspended |
|---|
| 168 | | - * @dev: Pointer to drm device |
|---|
| 169 | | - * Return: Suspend status |
|---|
| 158 | +/* Global private object state for tracking resources that are shared across |
|---|
| 159 | + * multiple kms objects (planes/crtcs/etc). |
|---|
| 170 | 160 | */ |
|---|
| 171 | | -static inline bool dpu_kms_is_suspend_state(struct drm_device *dev) |
|---|
| 172 | | -{ |
|---|
| 173 | | - if (!ddev_to_msm_kms(dev)) |
|---|
| 174 | | - return false; |
|---|
| 161 | +struct dpu_global_state { |
|---|
| 162 | + struct drm_private_state base; |
|---|
| 175 | 163 | |
|---|
| 176 | | - return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_state != NULL; |
|---|
| 177 | | -} |
|---|
| 164 | + uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0]; |
|---|
| 165 | + uint32_t mixer_to_enc_id[LM_MAX - LM_0]; |
|---|
| 166 | + uint32_t ctl_to_enc_id[CTL_MAX - CTL_0]; |
|---|
| 167 | + uint32_t intf_to_enc_id[INTF_MAX - INTF_0]; |
|---|
| 168 | + uint32_t dspp_to_enc_id[DSPP_MAX - DSPP_0]; |
|---|
| 169 | +}; |
|---|
| 178 | 170 | |
|---|
| 179 | | -/** |
|---|
| 180 | | - * dpu_kms_is_suspend_blocked - whether or not commits are blocked due to pm |
|---|
| 181 | | - * suspend status |
|---|
| 182 | | - * @dev: Pointer to drm device |
|---|
| 183 | | - * Return: True if commits should be rejected due to pm suspend |
|---|
| 184 | | - */ |
|---|
| 185 | | -static inline bool dpu_kms_is_suspend_blocked(struct drm_device *dev) |
|---|
| 186 | | -{ |
|---|
| 187 | | - if (!dpu_kms_is_suspend_state(dev)) |
|---|
| 188 | | - return false; |
|---|
| 189 | | - |
|---|
| 190 | | - return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_block; |
|---|
| 191 | | -} |
|---|
| 171 | +struct dpu_global_state |
|---|
| 172 | + *dpu_kms_get_existing_global_state(struct dpu_kms *dpu_kms); |
|---|
| 173 | +struct dpu_global_state |
|---|
| 174 | + *__must_check dpu_kms_get_global_state(struct drm_atomic_state *s); |
|---|
| 192 | 175 | |
|---|
| 193 | 176 | /** |
|---|
| 194 | 177 | * Debugfs functions - extra helper functions for debugfs support |
|---|
| 195 | 178 | * |
|---|
| 196 | 179 | * Main debugfs documentation is located at, |
|---|
| 197 | 180 | * |
|---|
| 198 | | - * Documentation/filesystems/debugfs.txt |
|---|
| 181 | + * Documentation/filesystems/debugfs.rst |
|---|
| 199 | 182 | * |
|---|
| 200 | 183 | * @dpu_debugfs_setup_regset32: Initialize data for dpu_debugfs_create_regset32 |
|---|
| 201 | 184 | * @dpu_debugfs_create_regset32: Create 32-bit register dump file |
|---|
| .. | .. |
|---|
| 243 | 226 | * @mode: File mode within debugfs |
|---|
| 244 | 227 | * @parent: Parent directory entry within debugfs, can be NULL |
|---|
| 245 | 228 | * @regset: Pointer to persistent register block definition |
|---|
| 246 | | - * |
|---|
| 247 | | - * Return: dentry pointer for newly created file, use either debugfs_remove() |
|---|
| 248 | | - * or debugfs_remove_recursive() (on a parent directory) to remove the |
|---|
| 249 | | - * file |
|---|
| 250 | 229 | */ |
|---|
| 251 | | -void *dpu_debugfs_create_regset32(const char *name, umode_t mode, |
|---|
| 230 | +void dpu_debugfs_create_regset32(const char *name, umode_t mode, |
|---|
| 252 | 231 | void *parent, struct dpu_debugfs_regset32 *regset); |
|---|
| 253 | 232 | |
|---|
| 254 | 233 | /** |
|---|