Path: blob/master/drivers/gpu/drm/armada/armada_debugfs.c
49611 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Copyright (C) 2012 Russell King3* Rewritten from the dovefb driver, and Armada510 manuals.4*/56#include <linux/ctype.h>7#include <linux/debugfs.h>8#include <linux/module.h>9#include <linux/seq_file.h>10#include <linux/uaccess.h>1112#include <drm/drm_debugfs.h>13#include <drm/drm_file.h>14#include <drm/drm_print.h>1516#include "armada_crtc.h"17#include "armada_drm.h"1819static int armada_debugfs_gem_linear_show(struct seq_file *m, void *data)20{21struct drm_info_node *node = m->private;22struct drm_device *dev = node->minor->dev;23struct armada_private *priv = drm_to_armada_dev(dev);24struct drm_printer p = drm_seq_file_printer(m);2526mutex_lock(&priv->linear_lock);27drm_mm_print(&priv->linear, &p);28mutex_unlock(&priv->linear_lock);2930return 0;31}3233static int armada_debugfs_crtc_reg_show(struct seq_file *m, void *data)34{35struct armada_crtc *dcrtc = m->private;36int i;3738for (i = 0x84; i <= 0x1c4; i += 4) {39u32 v = readl_relaxed(dcrtc->base + i);40seq_printf(m, "0x%04x: 0x%08x\n", i, v);41}4243return 0;44}4546static int armada_debugfs_crtc_reg_open(struct inode *inode, struct file *file)47{48return single_open(file, armada_debugfs_crtc_reg_show,49inode->i_private);50}5152static int armada_debugfs_crtc_reg_write(struct file *file,53const char __user *ptr, size_t len, loff_t *off)54{55struct armada_crtc *dcrtc;56unsigned long reg, mask, val;57char buf[32];58int ret;59u32 v;6061if (*off != 0)62return 0;6364if (len > sizeof(buf) - 1)65len = sizeof(buf) - 1;6667ret = strncpy_from_user(buf, ptr, len);68if (ret < 0)69return ret;70buf[len] = '\0';7172if (sscanf(buf, "%lx %lx %lx", ®, &mask, &val) != 3)73return -EINVAL;74if (reg < 0x84 || reg > 0x1c4 || reg & 3)75return -ERANGE;7677dcrtc = ((struct seq_file *)file->private_data)->private;78v = readl(dcrtc->base + reg);79v &= ~mask;80v |= val & mask;81writel(v, dcrtc->base + reg);8283return len;84}8586static const struct file_operations armada_debugfs_crtc_reg_fops = {87.owner = THIS_MODULE,88.open = armada_debugfs_crtc_reg_open,89.read = seq_read,90.write = armada_debugfs_crtc_reg_write,91.llseek = seq_lseek,92.release = single_release,93};9495void armada_drm_crtc_debugfs_init(struct armada_crtc *dcrtc)96{97debugfs_create_file("armada-regs", 0600, dcrtc->crtc.debugfs_entry,98dcrtc, &armada_debugfs_crtc_reg_fops);99}100101static struct drm_info_list armada_debugfs_list[] = {102{ "gem_linear", armada_debugfs_gem_linear_show, 0 },103};104#define ARMADA_DEBUGFS_ENTRIES ARRAY_SIZE(armada_debugfs_list)105106int armada_drm_debugfs_init(struct drm_minor *minor)107{108drm_debugfs_create_files(armada_debugfs_list, ARMADA_DEBUGFS_ENTRIES,109minor->debugfs_root, minor);110111return 0;112}113114115