mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
drm/mali-dp: Add core_id file to the sysfs interface
Add a core_id file in the driver's sysfs directory, exposing the hardware CORE ID. This is useful to allow userspace to discover the hardware version used. Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
This commit is contained in:
parent
6954f24588
commit
50c7512fd7
@ -371,6 +371,32 @@ static bool malidp_has_sufficient_address_space(const struct resource *res,
|
||||
return true;
|
||||
}
|
||||
|
||||
static ssize_t core_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct drm_device *drm = dev_get_drvdata(dev);
|
||||
struct malidp_drm *malidp = drm->dev_private;
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%08x\n", malidp->core_id);
|
||||
}
|
||||
|
||||
DEVICE_ATTR_RO(core_id);
|
||||
|
||||
static int malidp_init_sysfs(struct device *dev)
|
||||
{
|
||||
int ret = device_create_file(dev, &dev_attr_core_id);
|
||||
|
||||
if (ret)
|
||||
DRM_ERROR("failed to create device file for core_id\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void malidp_fini_sysfs(struct device *dev)
|
||||
{
|
||||
device_remove_file(dev, &dev_attr_core_id);
|
||||
}
|
||||
|
||||
#define MAX_OUTPUT_CHANNELS 3
|
||||
|
||||
static int malidp_runtime_pm_suspend(struct device *dev)
|
||||
@ -503,6 +529,8 @@ static int malidp_bind(struct device *dev)
|
||||
DRM_INFO("found ARM Mali-DP%3x version r%dp%d\n", version >> 16,
|
||||
(version >> 12) & 0xf, (version >> 8) & 0xf);
|
||||
|
||||
malidp->core_id = version;
|
||||
|
||||
/* set the number of lines used for output of RGB data */
|
||||
ret = of_property_read_u8_array(dev->of_node,
|
||||
"arm,malidp-output-port-lines",
|
||||
@ -521,6 +549,10 @@ static int malidp_bind(struct device *dev)
|
||||
if (ret < 0)
|
||||
goto query_hw_fail;
|
||||
|
||||
ret = malidp_init_sysfs(dev);
|
||||
if (ret)
|
||||
goto init_fail;
|
||||
|
||||
/* Set the CRTC's port so that the encoder component can find it */
|
||||
malidp->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);
|
||||
|
||||
@ -580,6 +612,8 @@ irq_init_fail:
|
||||
bind_fail:
|
||||
of_node_put(malidp->crtc.port);
|
||||
malidp->crtc.port = NULL;
|
||||
init_fail:
|
||||
malidp_fini_sysfs(dev);
|
||||
malidp_fini(drm);
|
||||
query_hw_fail:
|
||||
pm_runtime_put(dev);
|
||||
@ -614,6 +648,7 @@ static void malidp_unbind(struct device *dev)
|
||||
component_unbind_all(dev, drm);
|
||||
of_node_put(malidp->crtc.port);
|
||||
malidp->crtc.port = NULL;
|
||||
malidp_fini_sysfs(dev);
|
||||
malidp_fini(drm);
|
||||
pm_runtime_put(dev);
|
||||
if (pm_runtime_enabled(dev))
|
||||
|
@ -25,6 +25,7 @@ struct malidp_drm {
|
||||
wait_queue_head_t wq;
|
||||
atomic_t config_valid;
|
||||
struct drm_atomic_state *pm_state;
|
||||
u32 core_id;
|
||||
};
|
||||
|
||||
#define crtc_to_malidp_device(x) container_of(x, struct malidp_drm, crtc)
|
||||
|
Loading…
Reference in New Issue
Block a user