]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/komeda: Add sysfs attribute: core_id and config_id
authorjames qian wang (Arm Technology China) <james.qian.wang@arm.com>
Tue, 22 Jan 2019 11:11:53 +0000 (11:11 +0000)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Tue, 7 May 2019 10:20:28 +0000 (11:20 +0100)
Add two sysfs node: core_id, config_id, user can read them to fetch the
HW product information.

Also, use memset to initialize config_id, rather than quirky C syntax.
Courtesy of Nathan Chancellor <natechancellor@gmail.com>.

Signed-off-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
[Merged Nathan's patch that uses memset to initialize config_id into
original patch as the fixes tag changed due to rebase, reworded the
commit to reference the merged patch]
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
drivers/gpu/drm/arm/display/include/malidp_product.h
drivers/gpu/drm/arm/display/komeda/komeda_dev.c
drivers/gpu/drm/arm/display/komeda/komeda_dev.h
drivers/gpu/drm/arm/display/komeda/komeda_drv.c

index b35fc5db866b0eb2e1542753bd1546b310dd4974..1053b11352eb346707dafbb298c84d7781392a7b 100644 (file)
 /* Mali-display product IDs */
 #define MALIDP_D71_PRODUCT_ID   0x0071
 
+union komeda_config_id {
+       struct {
+               __u32   max_line_sz:16,
+                       n_pipelines:2,
+                       n_scalers:2, /* number of scalers per pipeline */
+                       n_layers:3, /* number of layers per pipeline */
+                       n_richs:3, /* number of rich layers per pipeline */
+                       reserved_bits:6;
+       };
+       __u32 value;
+};
+
 #endif /* _MALIDP_PRODUCT_H_ */
index 131f26692a3d222a0e037310f5fd2f16c9203e43..ca3599e4a4d3013d2462abe2206d136e0408cb6d 100644 (file)
@@ -59,6 +59,48 @@ static void komeda_debugfs_init(struct komeda_dev *mdev)
 }
 #endif
 
+static ssize_t
+core_id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct komeda_dev *mdev = dev_to_mdev(dev);
+
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", mdev->chip.core_id);
+}
+static DEVICE_ATTR_RO(core_id);
+
+static ssize_t
+config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct komeda_dev *mdev = dev_to_mdev(dev);
+       struct komeda_pipeline *pipe = mdev->pipelines[0];
+       union komeda_config_id config_id;
+       int i;
+
+       memset(&config_id, 0, sizeof(config_id));
+
+       config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
+       config_id.n_pipelines = mdev->n_pipelines;
+       config_id.n_scalers = pipe->n_scalers;
+       config_id.n_layers = pipe->n_layers;
+       config_id.n_richs = 0;
+       for (i = 0; i < pipe->n_layers; i++) {
+               if (pipe->layers[i]->layer_type == KOMEDA_FMT_RICH_LAYER)
+                       config_id.n_richs++;
+       }
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value);
+}
+static DEVICE_ATTR_RO(config_id);
+
+static struct attribute *komeda_sysfs_entries[] = {
+       &dev_attr_core_id.attr,
+       &dev_attr_config_id.attr,
+       NULL,
+};
+
+static struct attribute_group komeda_sysfs_attr_group = {
+       .attrs = komeda_sysfs_entries,
+};
+
 static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
 {
        struct komeda_pipeline *pipe;
@@ -207,6 +249,12 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
                goto err_cleanup;
        }
 
+       err = sysfs_create_group(&dev->kobj, &komeda_sysfs_attr_group);
+       if (err) {
+               DRM_ERROR("create sysfs group failed.\n");
+               goto err_cleanup;
+       }
+
 #ifdef CONFIG_DEBUG_FS
        komeda_debugfs_init(mdev);
 #endif
@@ -224,6 +272,8 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
        struct komeda_dev_funcs *funcs = mdev->funcs;
        int i;
 
+       sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group);
+
 #ifdef CONFIG_DEBUG_FS
        debugfs_remove_recursive(mdev->debugfs_root);
 #endif
index 8acd25afb3e9da8067fe82dc70bce13a07a57aad..0c3e32b596d92853fb5aa24043f3ff455a46373a 100644 (file)
@@ -190,4 +190,6 @@ d71_identify(u32 __iomem *reg, struct komeda_chip_info *chip);
 struct komeda_dev *komeda_dev_create(struct device *dev);
 void komeda_dev_destroy(struct komeda_dev *mdev);
 
+struct komeda_dev *dev_to_mdev(struct device *dev);
+
 #endif /*_KOMEDA_DEV_H_*/
index 2bdd189b041db1b74cad3037ef695e4739642b42..0285fd37a01626ebb743c92b84f1bd358d4d1c83 100644 (file)
@@ -17,6 +17,13 @@ struct komeda_drv {
        struct komeda_kms_dev *kms;
 };
 
+struct komeda_dev *dev_to_mdev(struct device *dev)
+{
+       struct komeda_drv *mdrv = dev_get_drvdata(dev);
+
+       return mdrv ? mdrv->mdev : NULL;
+}
+
 static void komeda_unbind(struct device *dev)
 {
        struct komeda_drv *mdrv = dev_get_drvdata(dev);