drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / media / pci / mgb4 / mgb4_sysfs_pci.c
blobd26935ff956b64f466ec48b8b6da5862cda408bf
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2021-2022 Digiteq Automotive
4 * author: Martin Tuma <martin.tuma@digiteqautomotive.com>
6 * This module handles all the sysfs info/configuration that is related to the
7 * PCI card device.
8 */
10 #include <linux/device.h>
11 #include "mgb4_core.h"
12 #include "mgb4_sysfs.h"
14 static ssize_t module_version_show(struct device *dev,
15 struct device_attribute *attr, char *buf)
17 struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
19 return sprintf(buf, "%u\n", mgbdev->module_version & 0x0F);
22 static ssize_t module_type_show(struct device *dev,
23 struct device_attribute *attr, char *buf)
25 struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
27 return sprintf(buf, "%u\n", mgbdev->module_version >> 4);
30 static ssize_t fw_version_show(struct device *dev,
31 struct device_attribute *attr, char *buf)
33 struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
34 u32 config = mgb4_read_reg(&mgbdev->video, 0xC4);
36 return sprintf(buf, "%u\n", config & 0xFFFF);
39 static ssize_t fw_type_show(struct device *dev,
40 struct device_attribute *attr, char *buf)
42 struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
43 u32 config = mgb4_read_reg(&mgbdev->video, 0xC4);
45 return sprintf(buf, "%u\n", config >> 24);
48 static ssize_t serial_number_show(struct device *dev,
49 struct device_attribute *attr, char *buf)
51 struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
52 u32 sn = mgbdev->serial_number;
54 return sprintf(buf, "%03d-%03d-%03d-%03d\n", sn >> 24, (sn >> 16) & 0xFF,
55 (sn >> 8) & 0xFF, sn & 0xFF);
58 static DEVICE_ATTR_RO(module_version);
59 static DEVICE_ATTR_RO(module_type);
60 static DEVICE_ATTR_RO(fw_version);
61 static DEVICE_ATTR_RO(fw_type);
62 static DEVICE_ATTR_RO(serial_number);
64 struct attribute *mgb4_pci_attrs[] = {
65 &dev_attr_module_type.attr,
66 &dev_attr_module_version.attr,
67 &dev_attr_fw_type.attr,
68 &dev_attr_fw_version.attr,
69 &dev_attr_serial_number.attr,
70 NULL