| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2016 Broadcom Limited |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 6 | | - * the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 14 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | /** |
|---|
| .. | .. |
|---|
| 24 | 13 | |
|---|
| 25 | 14 | #include <drm/drm_atomic_helper.h> |
|---|
| 26 | 15 | #include <drm/drm_bridge.h> |
|---|
| 27 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 28 | 16 | #include <drm/drm_edid.h> |
|---|
| 29 | 17 | #include <drm/drm_of.h> |
|---|
| 30 | 18 | #include <drm/drm_panel.h> |
|---|
| 19 | +#include <drm/drm_probe_helper.h> |
|---|
| 20 | +#include <drm/drm_simple_kms_helper.h> |
|---|
| 31 | 21 | #include <linux/clk.h> |
|---|
| 32 | 22 | #include <linux/component.h> |
|---|
| 33 | 23 | #include <linux/of_graph.h> |
|---|
| .. | .. |
|---|
| 101 | 91 | |
|---|
| 102 | 92 | struct clk *pixel_clock; |
|---|
| 103 | 93 | struct clk *core_clock; |
|---|
| 94 | + |
|---|
| 95 | + struct debugfs_regset32 regset; |
|---|
| 104 | 96 | }; |
|---|
| 105 | 97 | |
|---|
| 106 | 98 | #define DPI_READ(offset) readl(dpi->regs + (offset)) |
|---|
| .. | .. |
|---|
| 118 | 110 | return container_of(encoder, struct vc4_dpi_encoder, base.base); |
|---|
| 119 | 111 | } |
|---|
| 120 | 112 | |
|---|
| 121 | | -#define DPI_REG(reg) { reg, #reg } |
|---|
| 122 | | -static const struct { |
|---|
| 123 | | - u32 reg; |
|---|
| 124 | | - const char *name; |
|---|
| 125 | | -} dpi_regs[] = { |
|---|
| 126 | | - DPI_REG(DPI_C), |
|---|
| 127 | | - DPI_REG(DPI_ID), |
|---|
| 128 | | -}; |
|---|
| 129 | | - |
|---|
| 130 | | -#ifdef CONFIG_DEBUG_FS |
|---|
| 131 | | -int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused) |
|---|
| 132 | | -{ |
|---|
| 133 | | - struct drm_info_node *node = (struct drm_info_node *)m->private; |
|---|
| 134 | | - struct drm_device *dev = node->minor->dev; |
|---|
| 135 | | - struct vc4_dev *vc4 = to_vc4_dev(dev); |
|---|
| 136 | | - struct vc4_dpi *dpi = vc4->dpi; |
|---|
| 137 | | - int i; |
|---|
| 138 | | - |
|---|
| 139 | | - if (!dpi) |
|---|
| 140 | | - return 0; |
|---|
| 141 | | - |
|---|
| 142 | | - for (i = 0; i < ARRAY_SIZE(dpi_regs); i++) { |
|---|
| 143 | | - seq_printf(m, "%s (0x%04x): 0x%08x\n", |
|---|
| 144 | | - dpi_regs[i].name, dpi_regs[i].reg, |
|---|
| 145 | | - DPI_READ(dpi_regs[i].reg)); |
|---|
| 146 | | - } |
|---|
| 147 | | - |
|---|
| 148 | | - return 0; |
|---|
| 149 | | -} |
|---|
| 150 | | -#endif |
|---|
| 151 | | - |
|---|
| 152 | | -static const struct drm_encoder_funcs vc4_dpi_encoder_funcs = { |
|---|
| 153 | | - .destroy = drm_encoder_cleanup, |
|---|
| 113 | +static const struct debugfs_reg32 dpi_regs[] = { |
|---|
| 114 | + VC4_REG32(DPI_C), |
|---|
| 115 | + VC4_REG32(DPI_ID), |
|---|
| 154 | 116 | }; |
|---|
| 155 | 117 | |
|---|
| 156 | 118 | static void vc4_dpi_encoder_disable(struct drm_encoder *encoder) |
|---|
| .. | .. |
|---|
| 284 | 246 | } |
|---|
| 285 | 247 | |
|---|
| 286 | 248 | if (panel) |
|---|
| 287 | | - bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI); |
|---|
| 249 | + bridge = drm_panel_bridge_add_typed(panel, |
|---|
| 250 | + DRM_MODE_CONNECTOR_DPI); |
|---|
| 288 | 251 | |
|---|
| 289 | | - return drm_bridge_attach(dpi->encoder, bridge, NULL); |
|---|
| 252 | + return drm_bridge_attach(dpi->encoder, bridge, NULL, 0); |
|---|
| 290 | 253 | } |
|---|
| 291 | 254 | |
|---|
| 292 | 255 | static int vc4_dpi_bind(struct device *dev, struct device *master, void *data) |
|---|
| .. | .. |
|---|
| 314 | 277 | dpi->regs = vc4_ioremap_regs(pdev, 0); |
|---|
| 315 | 278 | if (IS_ERR(dpi->regs)) |
|---|
| 316 | 279 | return PTR_ERR(dpi->regs); |
|---|
| 280 | + dpi->regset.base = dpi->regs; |
|---|
| 281 | + dpi->regset.regs = dpi_regs; |
|---|
| 282 | + dpi->regset.nregs = ARRAY_SIZE(dpi_regs); |
|---|
| 317 | 283 | |
|---|
| 318 | 284 | if (DPI_READ(DPI_ID) != DPI_ID_VALUE) { |
|---|
| 319 | 285 | dev_err(dev, "Port returned 0x%08x for ID instead of 0x%08x\n", |
|---|
| .. | .. |
|---|
| 340 | 306 | if (ret) |
|---|
| 341 | 307 | DRM_ERROR("Failed to turn on core clock: %d\n", ret); |
|---|
| 342 | 308 | |
|---|
| 343 | | - drm_encoder_init(drm, dpi->encoder, &vc4_dpi_encoder_funcs, |
|---|
| 344 | | - DRM_MODE_ENCODER_DPI, NULL); |
|---|
| 309 | + drm_simple_encoder_init(drm, dpi->encoder, DRM_MODE_ENCODER_DPI); |
|---|
| 345 | 310 | drm_encoder_helper_add(dpi->encoder, &vc4_dpi_encoder_helper_funcs); |
|---|
| 346 | 311 | |
|---|
| 347 | 312 | ret = vc4_dpi_init_bridge(dpi); |
|---|
| .. | .. |
|---|
| 352 | 317 | |
|---|
| 353 | 318 | vc4->dpi = dpi; |
|---|
| 354 | 319 | |
|---|
| 320 | + vc4_debugfs_add_regset32(drm, "dpi_regs", &dpi->regset); |
|---|
| 321 | + |
|---|
| 355 | 322 | return 0; |
|---|
| 356 | 323 | |
|---|
| 357 | 324 | err_destroy_encoder: |
|---|